Geen omschrijving

index.js 1.8MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. function _interopDefault(ex) {
  4. return ex && typeof ex === "object" && "default" in ex ? ex["default"] : ex;
  5. }
  6. var React = require("react");
  7. var React__default = _interopDefault(React);
  8. var reactDom = require("react-dom");
  9. var reactDom__default = _interopDefault(reactDom);
  10. var styleInject_es = require("../style-inject.es-dcee06b6.js");
  11. var _commonjsHelpers = require("../_commonjsHelpers-72d386ba.js");
  12. var slicedToArray = require("../slicedToArray-172f4624.js");
  13. var server = _interopDefault(require("react-dom/server"));
  14. /*
  15. object-assign
  16. (c) Sindre Sorhus
  17. @license MIT
  18. */
  19. /* eslint-disable no-unused-vars */
  20. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  21. var hasOwnProperty = Object.prototype.hasOwnProperty;
  22. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  23. function toObject(val) {
  24. if (val === null || val === undefined) {
  25. throw new TypeError(
  26. "Object.assign cannot be called with null or undefined"
  27. );
  28. }
  29. return Object(val);
  30. }
  31. function shouldUseNative() {
  32. try {
  33. if (!Object.assign) {
  34. return false;
  35. }
  36. // Detect buggy property enumeration order in older V8 versions.
  37. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  38. var test1 = new String("abc"); // eslint-disable-line no-new-wrappers
  39. test1[5] = "de";
  40. if (Object.getOwnPropertyNames(test1)[0] === "5") {
  41. return false;
  42. }
  43. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  44. var test2 = {};
  45. for (var i = 0; i < 10; i++) {
  46. test2["_" + String.fromCharCode(i)] = i;
  47. }
  48. var order2 = Object.getOwnPropertyNames(test2).map(function(n) {
  49. return test2[n];
  50. });
  51. if (order2.join("") !== "0123456789") {
  52. return false;
  53. }
  54. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  55. var test3 = {};
  56. "abcdefghijklmnopqrst".split("").forEach(function(letter) {
  57. test3[letter] = letter;
  58. });
  59. if (
  60. Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst"
  61. ) {
  62. return false;
  63. }
  64. return true;
  65. } catch (err) {
  66. // We don't expect any of the above to throw, but better to be safe.
  67. return false;
  68. }
  69. }
  70. var objectAssign = shouldUseNative()
  71. ? Object.assign
  72. : function(target, source) {
  73. var from;
  74. var to = toObject(target);
  75. var symbols;
  76. for (var s = 1; s < arguments.length; s++) {
  77. from = Object(arguments[s]);
  78. for (var key in from) {
  79. if (hasOwnProperty.call(from, key)) {
  80. to[key] = from[key];
  81. }
  82. }
  83. if (getOwnPropertySymbols) {
  84. symbols = getOwnPropertySymbols(from);
  85. for (var i = 0; i < symbols.length; i++) {
  86. if (propIsEnumerable.call(from, symbols[i])) {
  87. to[symbols[i]] = from[symbols[i]];
  88. }
  89. }
  90. }
  91. }
  92. return to;
  93. };
  94. var immutable = _commonjsHelpers.createCommonjsModule(function(
  95. module,
  96. exports
  97. ) {
  98. /**
  99. * Copyright (c) 2014-2015, Facebook, Inc.
  100. * All rights reserved.
  101. *
  102. * This source code is licensed under the BSD-style license found in the
  103. * LICENSE file in the root directory of this source tree. An additional grant
  104. * of patent rights can be found in the PATENTS file in the same directory.
  105. */
  106. (function(global, factory) {
  107. module.exports = factory();
  108. })(_commonjsHelpers.commonjsGlobal, function() {
  109. var SLICE$0 = Array.prototype.slice;
  110. function createClass(ctor, superClass) {
  111. if (superClass) {
  112. ctor.prototype = Object.create(superClass.prototype);
  113. }
  114. ctor.prototype.constructor = ctor;
  115. }
  116. function Iterable(value) {
  117. return isIterable(value) ? value : Seq(value);
  118. }
  119. createClass(KeyedIterable, Iterable);
  120. function KeyedIterable(value) {
  121. return isKeyed(value) ? value : KeyedSeq(value);
  122. }
  123. createClass(IndexedIterable, Iterable);
  124. function IndexedIterable(value) {
  125. return isIndexed(value) ? value : IndexedSeq(value);
  126. }
  127. createClass(SetIterable, Iterable);
  128. function SetIterable(value) {
  129. return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
  130. }
  131. function isIterable(maybeIterable) {
  132. return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
  133. }
  134. function isKeyed(maybeKeyed) {
  135. return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
  136. }
  137. function isIndexed(maybeIndexed) {
  138. return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
  139. }
  140. function isAssociative(maybeAssociative) {
  141. return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
  142. }
  143. function isOrdered(maybeOrdered) {
  144. return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
  145. }
  146. Iterable.isIterable = isIterable;
  147. Iterable.isKeyed = isKeyed;
  148. Iterable.isIndexed = isIndexed;
  149. Iterable.isAssociative = isAssociative;
  150. Iterable.isOrdered = isOrdered;
  151. Iterable.Keyed = KeyedIterable;
  152. Iterable.Indexed = IndexedIterable;
  153. Iterable.Set = SetIterable;
  154. var IS_ITERABLE_SENTINEL = "@@__IMMUTABLE_ITERABLE__@@";
  155. var IS_KEYED_SENTINEL = "@@__IMMUTABLE_KEYED__@@";
  156. var IS_INDEXED_SENTINEL = "@@__IMMUTABLE_INDEXED__@@";
  157. var IS_ORDERED_SENTINEL = "@@__IMMUTABLE_ORDERED__@@";
  158. // Used for setting prototype methods that IE8 chokes on.
  159. var DELETE = "delete";
  160. // Constants describing the size of trie nodes.
  161. var SHIFT = 5; // Resulted in best performance after ______?
  162. var SIZE = 1 << SHIFT;
  163. var MASK = SIZE - 1;
  164. // A consistent shared value representing "not set" which equals nothing other
  165. // than itself, and nothing that could be provided externally.
  166. var NOT_SET = {};
  167. // Boolean references, Rough equivalent of `bool &`.
  168. var CHANGE_LENGTH = { value: false };
  169. var DID_ALTER = { value: false };
  170. function MakeRef(ref) {
  171. ref.value = false;
  172. return ref;
  173. }
  174. function SetRef(ref) {
  175. ref && (ref.value = true);
  176. }
  177. // A function which returns a value representing an "owner" for transient writes
  178. // to tries. The return value will only ever equal itself, and will not equal
  179. // the return of any subsequent call of this function.
  180. function OwnerID() {}
  181. // http://jsperf.com/copy-array-inline
  182. function arrCopy(arr, offset) {
  183. offset = offset || 0;
  184. var len = Math.max(0, arr.length - offset);
  185. var newArr = new Array(len);
  186. for (var ii = 0; ii < len; ii++) {
  187. newArr[ii] = arr[ii + offset];
  188. }
  189. return newArr;
  190. }
  191. function ensureSize(iter) {
  192. if (iter.size === undefined) {
  193. iter.size = iter.__iterate(returnTrue);
  194. }
  195. return iter.size;
  196. }
  197. function wrapIndex(iter, index) {
  198. // This implements "is array index" which the ECMAString spec defines as:
  199. //
  200. // A String property name P is an array index if and only if
  201. // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
  202. // to 2^32−1.
  203. //
  204. // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
  205. if (typeof index !== "number") {
  206. var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
  207. if ("" + uint32Index !== index || uint32Index === 4294967295) {
  208. return NaN;
  209. }
  210. index = uint32Index;
  211. }
  212. return index < 0 ? ensureSize(iter) + index : index;
  213. }
  214. function returnTrue() {
  215. return true;
  216. }
  217. function wholeSlice(begin, end, size) {
  218. return (
  219. (begin === 0 || (size !== undefined && begin <= -size)) &&
  220. (end === undefined || (size !== undefined && end >= size))
  221. );
  222. }
  223. function resolveBegin(begin, size) {
  224. return resolveIndex(begin, size, 0);
  225. }
  226. function resolveEnd(end, size) {
  227. return resolveIndex(end, size, size);
  228. }
  229. function resolveIndex(index, size, defaultIndex) {
  230. return index === undefined
  231. ? defaultIndex
  232. : index < 0
  233. ? Math.max(0, size + index)
  234. : size === undefined
  235. ? index
  236. : Math.min(size, index);
  237. }
  238. /* global Symbol */
  239. var ITERATE_KEYS = 0;
  240. var ITERATE_VALUES = 1;
  241. var ITERATE_ENTRIES = 2;
  242. var REAL_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
  243. var FAUX_ITERATOR_SYMBOL = "@@iterator";
  244. var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
  245. function Iterator(next) {
  246. this.next = next;
  247. }
  248. Iterator.prototype.toString = function() {
  249. return "[Iterator]";
  250. };
  251. Iterator.KEYS = ITERATE_KEYS;
  252. Iterator.VALUES = ITERATE_VALUES;
  253. Iterator.ENTRIES = ITERATE_ENTRIES;
  254. Iterator.prototype.inspect = Iterator.prototype.toSource = function() {
  255. return this.toString();
  256. };
  257. Iterator.prototype[ITERATOR_SYMBOL] = function() {
  258. return this;
  259. };
  260. function iteratorValue(type, k, v, iteratorResult) {
  261. var value = type === 0 ? k : type === 1 ? v : [k, v];
  262. iteratorResult
  263. ? (iteratorResult.value = value)
  264. : (iteratorResult = {
  265. value: value,
  266. done: false
  267. });
  268. return iteratorResult;
  269. }
  270. function iteratorDone() {
  271. return { value: undefined, done: true };
  272. }
  273. function hasIterator(maybeIterable) {
  274. return !!getIteratorFn(maybeIterable);
  275. }
  276. function isIterator(maybeIterator) {
  277. return maybeIterator && typeof maybeIterator.next === "function";
  278. }
  279. function getIterator(iterable) {
  280. var iteratorFn = getIteratorFn(iterable);
  281. return iteratorFn && iteratorFn.call(iterable);
  282. }
  283. function getIteratorFn(iterable) {
  284. var iteratorFn =
  285. iterable &&
  286. ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
  287. iterable[FAUX_ITERATOR_SYMBOL]);
  288. if (typeof iteratorFn === "function") {
  289. return iteratorFn;
  290. }
  291. }
  292. function isArrayLike(value) {
  293. return value && typeof value.length === "number";
  294. }
  295. createClass(Seq, Iterable);
  296. function Seq(value) {
  297. return value === null || value === undefined
  298. ? emptySequence()
  299. : isIterable(value)
  300. ? value.toSeq()
  301. : seqFromValue(value);
  302. }
  303. Seq.of = function(/*...values*/) {
  304. return Seq(arguments);
  305. };
  306. Seq.prototype.toSeq = function() {
  307. return this;
  308. };
  309. Seq.prototype.toString = function() {
  310. return this.__toString("Seq {", "}");
  311. };
  312. Seq.prototype.cacheResult = function() {
  313. if (!this._cache && this.__iterateUncached) {
  314. this._cache = this.entrySeq().toArray();
  315. this.size = this._cache.length;
  316. }
  317. return this;
  318. };
  319. // abstract __iterateUncached(fn, reverse)
  320. Seq.prototype.__iterate = function(fn, reverse) {
  321. return seqIterate(this, fn, reverse, true);
  322. };
  323. // abstract __iteratorUncached(type, reverse)
  324. Seq.prototype.__iterator = function(type, reverse) {
  325. return seqIterator(this, type, reverse, true);
  326. };
  327. createClass(KeyedSeq, Seq);
  328. function KeyedSeq(value) {
  329. return value === null || value === undefined
  330. ? emptySequence().toKeyedSeq()
  331. : isIterable(value)
  332. ? isKeyed(value)
  333. ? value.toSeq()
  334. : value.fromEntrySeq()
  335. : keyedSeqFromValue(value);
  336. }
  337. KeyedSeq.prototype.toKeyedSeq = function() {
  338. return this;
  339. };
  340. createClass(IndexedSeq, Seq);
  341. function IndexedSeq(value) {
  342. return value === null || value === undefined
  343. ? emptySequence()
  344. : !isIterable(value)
  345. ? indexedSeqFromValue(value)
  346. : isKeyed(value)
  347. ? value.entrySeq()
  348. : value.toIndexedSeq();
  349. }
  350. IndexedSeq.of = function(/*...values*/) {
  351. return IndexedSeq(arguments);
  352. };
  353. IndexedSeq.prototype.toIndexedSeq = function() {
  354. return this;
  355. };
  356. IndexedSeq.prototype.toString = function() {
  357. return this.__toString("Seq [", "]");
  358. };
  359. IndexedSeq.prototype.__iterate = function(fn, reverse) {
  360. return seqIterate(this, fn, reverse, false);
  361. };
  362. IndexedSeq.prototype.__iterator = function(type, reverse) {
  363. return seqIterator(this, type, reverse, false);
  364. };
  365. createClass(SetSeq, Seq);
  366. function SetSeq(value) {
  367. return (value === null || value === undefined
  368. ? emptySequence()
  369. : !isIterable(value)
  370. ? indexedSeqFromValue(value)
  371. : isKeyed(value)
  372. ? value.entrySeq()
  373. : value
  374. ).toSetSeq();
  375. }
  376. SetSeq.of = function(/*...values*/) {
  377. return SetSeq(arguments);
  378. };
  379. SetSeq.prototype.toSetSeq = function() {
  380. return this;
  381. };
  382. Seq.isSeq = isSeq;
  383. Seq.Keyed = KeyedSeq;
  384. Seq.Set = SetSeq;
  385. Seq.Indexed = IndexedSeq;
  386. var IS_SEQ_SENTINEL = "@@__IMMUTABLE_SEQ__@@";
  387. Seq.prototype[IS_SEQ_SENTINEL] = true;
  388. createClass(ArraySeq, IndexedSeq);
  389. function ArraySeq(array) {
  390. this._array = array;
  391. this.size = array.length;
  392. }
  393. ArraySeq.prototype.get = function(index, notSetValue) {
  394. return this.has(index)
  395. ? this._array[wrapIndex(this, index)]
  396. : notSetValue;
  397. };
  398. ArraySeq.prototype.__iterate = function(fn, reverse) {
  399. var array = this._array;
  400. var maxIndex = array.length - 1;
  401. for (var ii = 0; ii <= maxIndex; ii++) {
  402. if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
  403. return ii + 1;
  404. }
  405. }
  406. return ii;
  407. };
  408. ArraySeq.prototype.__iterator = function(type, reverse) {
  409. var array = this._array;
  410. var maxIndex = array.length - 1;
  411. var ii = 0;
  412. return new Iterator(function() {
  413. return ii > maxIndex
  414. ? iteratorDone()
  415. : iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++]);
  416. });
  417. };
  418. createClass(ObjectSeq, KeyedSeq);
  419. function ObjectSeq(object) {
  420. var keys = Object.keys(object);
  421. this._object = object;
  422. this._keys = keys;
  423. this.size = keys.length;
  424. }
  425. ObjectSeq.prototype.get = function(key, notSetValue) {
  426. if (notSetValue !== undefined && !this.has(key)) {
  427. return notSetValue;
  428. }
  429. return this._object[key];
  430. };
  431. ObjectSeq.prototype.has = function(key) {
  432. return this._object.hasOwnProperty(key);
  433. };
  434. ObjectSeq.prototype.__iterate = function(fn, reverse) {
  435. var object = this._object;
  436. var keys = this._keys;
  437. var maxIndex = keys.length - 1;
  438. for (var ii = 0; ii <= maxIndex; ii++) {
  439. var key = keys[reverse ? maxIndex - ii : ii];
  440. if (fn(object[key], key, this) === false) {
  441. return ii + 1;
  442. }
  443. }
  444. return ii;
  445. };
  446. ObjectSeq.prototype.__iterator = function(type, reverse) {
  447. var object = this._object;
  448. var keys = this._keys;
  449. var maxIndex = keys.length - 1;
  450. var ii = 0;
  451. return new Iterator(function() {
  452. var key = keys[reverse ? maxIndex - ii : ii];
  453. return ii++ > maxIndex
  454. ? iteratorDone()
  455. : iteratorValue(type, key, object[key]);
  456. });
  457. };
  458. ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
  459. createClass(IterableSeq, IndexedSeq);
  460. function IterableSeq(iterable) {
  461. this._iterable = iterable;
  462. this.size = iterable.length || iterable.size;
  463. }
  464. IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
  465. if (reverse) {
  466. return this.cacheResult().__iterate(fn, reverse);
  467. }
  468. var iterable = this._iterable;
  469. var iterator = getIterator(iterable);
  470. var iterations = 0;
  471. if (isIterator(iterator)) {
  472. var step;
  473. while (!(step = iterator.next()).done) {
  474. if (fn(step.value, iterations++, this) === false) {
  475. break;
  476. }
  477. }
  478. }
  479. return iterations;
  480. };
  481. IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
  482. if (reverse) {
  483. return this.cacheResult().__iterator(type, reverse);
  484. }
  485. var iterable = this._iterable;
  486. var iterator = getIterator(iterable);
  487. if (!isIterator(iterator)) {
  488. return new Iterator(iteratorDone);
  489. }
  490. var iterations = 0;
  491. return new Iterator(function() {
  492. var step = iterator.next();
  493. return step.done ? step : iteratorValue(type, iterations++, step.value);
  494. });
  495. };
  496. createClass(IteratorSeq, IndexedSeq);
  497. function IteratorSeq(iterator) {
  498. this._iterator = iterator;
  499. this._iteratorCache = [];
  500. }
  501. IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
  502. if (reverse) {
  503. return this.cacheResult().__iterate(fn, reverse);
  504. }
  505. var iterator = this._iterator;
  506. var cache = this._iteratorCache;
  507. var iterations = 0;
  508. while (iterations < cache.length) {
  509. if (fn(cache[iterations], iterations++, this) === false) {
  510. return iterations;
  511. }
  512. }
  513. var step;
  514. while (!(step = iterator.next()).done) {
  515. var val = step.value;
  516. cache[iterations] = val;
  517. if (fn(val, iterations++, this) === false) {
  518. break;
  519. }
  520. }
  521. return iterations;
  522. };
  523. IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
  524. if (reverse) {
  525. return this.cacheResult().__iterator(type, reverse);
  526. }
  527. var iterator = this._iterator;
  528. var cache = this._iteratorCache;
  529. var iterations = 0;
  530. return new Iterator(function() {
  531. if (iterations >= cache.length) {
  532. var step = iterator.next();
  533. if (step.done) {
  534. return step;
  535. }
  536. cache[iterations] = step.value;
  537. }
  538. return iteratorValue(type, iterations, cache[iterations++]);
  539. });
  540. };
  541. // # pragma Helper functions
  542. function isSeq(maybeSeq) {
  543. return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
  544. }
  545. var EMPTY_SEQ;
  546. function emptySequence() {
  547. return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
  548. }
  549. function keyedSeqFromValue(value) {
  550. var seq = Array.isArray(value)
  551. ? new ArraySeq(value).fromEntrySeq()
  552. : isIterator(value)
  553. ? new IteratorSeq(value).fromEntrySeq()
  554. : hasIterator(value)
  555. ? new IterableSeq(value).fromEntrySeq()
  556. : typeof value === "object"
  557. ? new ObjectSeq(value)
  558. : undefined;
  559. if (!seq) {
  560. throw new TypeError(
  561. "Expected Array or iterable object of [k, v] entries, " +
  562. "or keyed object: " +
  563. value
  564. );
  565. }
  566. return seq;
  567. }
  568. function indexedSeqFromValue(value) {
  569. var seq = maybeIndexedSeqFromValue(value);
  570. if (!seq) {
  571. throw new TypeError(
  572. "Expected Array or iterable object of values: " + value
  573. );
  574. }
  575. return seq;
  576. }
  577. function seqFromValue(value) {
  578. var seq =
  579. maybeIndexedSeqFromValue(value) ||
  580. (typeof value === "object" && new ObjectSeq(value));
  581. if (!seq) {
  582. throw new TypeError(
  583. "Expected Array or iterable object of values, or keyed object: " +
  584. value
  585. );
  586. }
  587. return seq;
  588. }
  589. function maybeIndexedSeqFromValue(value) {
  590. return isArrayLike(value)
  591. ? new ArraySeq(value)
  592. : isIterator(value)
  593. ? new IteratorSeq(value)
  594. : hasIterator(value)
  595. ? new IterableSeq(value)
  596. : undefined;
  597. }
  598. function seqIterate(seq, fn, reverse, useKeys) {
  599. var cache = seq._cache;
  600. if (cache) {
  601. var maxIndex = cache.length - 1;
  602. for (var ii = 0; ii <= maxIndex; ii++) {
  603. var entry = cache[reverse ? maxIndex - ii : ii];
  604. if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
  605. return ii + 1;
  606. }
  607. }
  608. return ii;
  609. }
  610. return seq.__iterateUncached(fn, reverse);
  611. }
  612. function seqIterator(seq, type, reverse, useKeys) {
  613. var cache = seq._cache;
  614. if (cache) {
  615. var maxIndex = cache.length - 1;
  616. var ii = 0;
  617. return new Iterator(function() {
  618. var entry = cache[reverse ? maxIndex - ii : ii];
  619. return ii++ > maxIndex
  620. ? iteratorDone()
  621. : iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
  622. });
  623. }
  624. return seq.__iteratorUncached(type, reverse);
  625. }
  626. function fromJS(json, converter) {
  627. return converter
  628. ? fromJSWith(converter, json, "", { "": json })
  629. : fromJSDefault(json);
  630. }
  631. function fromJSWith(converter, json, key, parentJSON) {
  632. if (Array.isArray(json)) {
  633. return converter.call(
  634. parentJSON,
  635. key,
  636. IndexedSeq(json).map(function(v, k) {
  637. return fromJSWith(converter, v, k, json);
  638. })
  639. );
  640. }
  641. if (isPlainObj(json)) {
  642. return converter.call(
  643. parentJSON,
  644. key,
  645. KeyedSeq(json).map(function(v, k) {
  646. return fromJSWith(converter, v, k, json);
  647. })
  648. );
  649. }
  650. return json;
  651. }
  652. function fromJSDefault(json) {
  653. if (Array.isArray(json)) {
  654. return IndexedSeq(json)
  655. .map(fromJSDefault)
  656. .toList();
  657. }
  658. if (isPlainObj(json)) {
  659. return KeyedSeq(json)
  660. .map(fromJSDefault)
  661. .toMap();
  662. }
  663. return json;
  664. }
  665. function isPlainObj(value) {
  666. return (
  667. value &&
  668. (value.constructor === Object || value.constructor === undefined)
  669. );
  670. }
  671. /**
  672. * An extension of the "same-value" algorithm as [described for use by ES6 Map
  673. * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
  674. *
  675. * NaN is considered the same as NaN, however -0 and 0 are considered the same
  676. * value, which is different from the algorithm described by
  677. * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
  678. *
  679. * This is extended further to allow Objects to describe the values they
  680. * represent, by way of `valueOf` or `equals` (and `hashCode`).
  681. *
  682. * Note: because of this extension, the key equality of Immutable.Map and the
  683. * value equality of Immutable.Set will differ from ES6 Map and Set.
  684. *
  685. * ### Defining custom values
  686. *
  687. * The easiest way to describe the value an object represents is by implementing
  688. * `valueOf`. For example, `Date` represents a value by returning a unix
  689. * timestamp for `valueOf`:
  690. *
  691. * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
  692. * var date2 = new Date(1234567890000);
  693. * date1.valueOf(); // 1234567890000
  694. * assert( date1 !== date2 );
  695. * assert( Immutable.is( date1, date2 ) );
  696. *
  697. * Note: overriding `valueOf` may have other implications if you use this object
  698. * where JavaScript expects a primitive, such as implicit string coercion.
  699. *
  700. * For more complex types, especially collections, implementing `valueOf` may
  701. * not be performant. An alternative is to implement `equals` and `hashCode`.
  702. *
  703. * `equals` takes another object, presumably of similar type, and returns true
  704. * if the it is equal. Equality is symmetrical, so the same result should be
  705. * returned if this and the argument are flipped.
  706. *
  707. * assert( a.equals(b) === b.equals(a) );
  708. *
  709. * `hashCode` returns a 32bit integer number representing the object which will
  710. * be used to determine how to store the value object in a Map or Set. You must
  711. * provide both or neither methods, one must not exist without the other.
  712. *
  713. * Also, an important relationship between these methods must be upheld: if two
  714. * values are equal, they *must* return the same hashCode. If the values are not
  715. * equal, they might have the same hashCode; this is called a hash collision,
  716. * and while undesirable for performance reasons, it is acceptable.
  717. *
  718. * if (a.equals(b)) {
  719. * assert( a.hashCode() === b.hashCode() );
  720. * }
  721. *
  722. * All Immutable collections implement `equals` and `hashCode`.
  723. *
  724. */
  725. function is(valueA, valueB) {
  726. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  727. return true;
  728. }
  729. if (!valueA || !valueB) {
  730. return false;
  731. }
  732. if (
  733. typeof valueA.valueOf === "function" &&
  734. typeof valueB.valueOf === "function"
  735. ) {
  736. valueA = valueA.valueOf();
  737. valueB = valueB.valueOf();
  738. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  739. return true;
  740. }
  741. if (!valueA || !valueB) {
  742. return false;
  743. }
  744. }
  745. if (
  746. typeof valueA.equals === "function" &&
  747. typeof valueB.equals === "function" &&
  748. valueA.equals(valueB)
  749. ) {
  750. return true;
  751. }
  752. return false;
  753. }
  754. function deepEqual(a, b) {
  755. if (a === b) {
  756. return true;
  757. }
  758. if (
  759. !isIterable(b) ||
  760. (a.size !== undefined && b.size !== undefined && a.size !== b.size) ||
  761. (a.__hash !== undefined &&
  762. b.__hash !== undefined &&
  763. a.__hash !== b.__hash) ||
  764. isKeyed(a) !== isKeyed(b) ||
  765. isIndexed(a) !== isIndexed(b) ||
  766. isOrdered(a) !== isOrdered(b)
  767. ) {
  768. return false;
  769. }
  770. if (a.size === 0 && b.size === 0) {
  771. return true;
  772. }
  773. var notAssociative = !isAssociative(a);
  774. if (isOrdered(a)) {
  775. var entries = a.entries();
  776. return (
  777. b.every(function(v, k) {
  778. var entry = entries.next().value;
  779. return (
  780. entry && is(entry[1], v) && (notAssociative || is(entry[0], k))
  781. );
  782. }) && entries.next().done
  783. );
  784. }
  785. var flipped = false;
  786. if (a.size === undefined) {
  787. if (b.size === undefined) {
  788. if (typeof a.cacheResult === "function") {
  789. a.cacheResult();
  790. }
  791. } else {
  792. flipped = true;
  793. var _ = a;
  794. a = b;
  795. b = _;
  796. }
  797. }
  798. var allEqual = true;
  799. var bSize = b.__iterate(function(v, k) {
  800. if (
  801. notAssociative
  802. ? !a.has(v)
  803. : flipped
  804. ? !is(v, a.get(k, NOT_SET))
  805. : !is(a.get(k, NOT_SET), v)
  806. ) {
  807. allEqual = false;
  808. return false;
  809. }
  810. });
  811. return allEqual && a.size === bSize;
  812. }
  813. createClass(Repeat, IndexedSeq);
  814. function Repeat(value, times) {
  815. if (!(this instanceof Repeat)) {
  816. return new Repeat(value, times);
  817. }
  818. this._value = value;
  819. this.size = times === undefined ? Infinity : Math.max(0, times);
  820. if (this.size === 0) {
  821. if (EMPTY_REPEAT) {
  822. return EMPTY_REPEAT;
  823. }
  824. EMPTY_REPEAT = this;
  825. }
  826. }
  827. Repeat.prototype.toString = function() {
  828. if (this.size === 0) {
  829. return "Repeat []";
  830. }
  831. return "Repeat [ " + this._value + " " + this.size + " times ]";
  832. };
  833. Repeat.prototype.get = function(index, notSetValue) {
  834. return this.has(index) ? this._value : notSetValue;
  835. };
  836. Repeat.prototype.includes = function(searchValue) {
  837. return is(this._value, searchValue);
  838. };
  839. Repeat.prototype.slice = function(begin, end) {
  840. var size = this.size;
  841. return wholeSlice(begin, end, size)
  842. ? this
  843. : new Repeat(
  844. this._value,
  845. resolveEnd(end, size) - resolveBegin(begin, size)
  846. );
  847. };
  848. Repeat.prototype.reverse = function() {
  849. return this;
  850. };
  851. Repeat.prototype.indexOf = function(searchValue) {
  852. if (is(this._value, searchValue)) {
  853. return 0;
  854. }
  855. return -1;
  856. };
  857. Repeat.prototype.lastIndexOf = function(searchValue) {
  858. if (is(this._value, searchValue)) {
  859. return this.size;
  860. }
  861. return -1;
  862. };
  863. Repeat.prototype.__iterate = function(fn, reverse) {
  864. for (var ii = 0; ii < this.size; ii++) {
  865. if (fn(this._value, ii, this) === false) {
  866. return ii + 1;
  867. }
  868. }
  869. return ii;
  870. };
  871. Repeat.prototype.__iterator = function(type, reverse) {
  872. var this$0 = this;
  873. var ii = 0;
  874. return new Iterator(function() {
  875. return ii < this$0.size
  876. ? iteratorValue(type, ii++, this$0._value)
  877. : iteratorDone();
  878. });
  879. };
  880. Repeat.prototype.equals = function(other) {
  881. return other instanceof Repeat
  882. ? is(this._value, other._value)
  883. : deepEqual(other);
  884. };
  885. var EMPTY_REPEAT;
  886. function invariant(condition, error) {
  887. if (!condition) throw new Error(error);
  888. }
  889. createClass(Range, IndexedSeq);
  890. function Range(start, end, step) {
  891. if (!(this instanceof Range)) {
  892. return new Range(start, end, step);
  893. }
  894. invariant(step !== 0, "Cannot step a Range by 0");
  895. start = start || 0;
  896. if (end === undefined) {
  897. end = Infinity;
  898. }
  899. step = step === undefined ? 1 : Math.abs(step);
  900. if (end < start) {
  901. step = -step;
  902. }
  903. this._start = start;
  904. this._end = end;
  905. this._step = step;
  906. this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
  907. if (this.size === 0) {
  908. if (EMPTY_RANGE) {
  909. return EMPTY_RANGE;
  910. }
  911. EMPTY_RANGE = this;
  912. }
  913. }
  914. Range.prototype.toString = function() {
  915. if (this.size === 0) {
  916. return "Range []";
  917. }
  918. return (
  919. "Range [ " +
  920. this._start +
  921. "..." +
  922. this._end +
  923. (this._step > 1 ? " by " + this._step : "") +
  924. " ]"
  925. );
  926. };
  927. Range.prototype.get = function(index, notSetValue) {
  928. return this.has(index)
  929. ? this._start + wrapIndex(this, index) * this._step
  930. : notSetValue;
  931. };
  932. Range.prototype.includes = function(searchValue) {
  933. var possibleIndex = (searchValue - this._start) / this._step;
  934. return (
  935. possibleIndex >= 0 &&
  936. possibleIndex < this.size &&
  937. possibleIndex === Math.floor(possibleIndex)
  938. );
  939. };
  940. Range.prototype.slice = function(begin, end) {
  941. if (wholeSlice(begin, end, this.size)) {
  942. return this;
  943. }
  944. begin = resolveBegin(begin, this.size);
  945. end = resolveEnd(end, this.size);
  946. if (end <= begin) {
  947. return new Range(0, 0);
  948. }
  949. return new Range(
  950. this.get(begin, this._end),
  951. this.get(end, this._end),
  952. this._step
  953. );
  954. };
  955. Range.prototype.indexOf = function(searchValue) {
  956. var offsetValue = searchValue - this._start;
  957. if (offsetValue % this._step === 0) {
  958. var index = offsetValue / this._step;
  959. if (index >= 0 && index < this.size) {
  960. return index;
  961. }
  962. }
  963. return -1;
  964. };
  965. Range.prototype.lastIndexOf = function(searchValue) {
  966. return this.indexOf(searchValue);
  967. };
  968. Range.prototype.__iterate = function(fn, reverse) {
  969. var maxIndex = this.size - 1;
  970. var step = this._step;
  971. var value = reverse ? this._start + maxIndex * step : this._start;
  972. for (var ii = 0; ii <= maxIndex; ii++) {
  973. if (fn(value, ii, this) === false) {
  974. return ii + 1;
  975. }
  976. value += reverse ? -step : step;
  977. }
  978. return ii;
  979. };
  980. Range.prototype.__iterator = function(type, reverse) {
  981. var maxIndex = this.size - 1;
  982. var step = this._step;
  983. var value = reverse ? this._start + maxIndex * step : this._start;
  984. var ii = 0;
  985. return new Iterator(function() {
  986. var v = value;
  987. value += reverse ? -step : step;
  988. return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
  989. });
  990. };
  991. Range.prototype.equals = function(other) {
  992. return other instanceof Range
  993. ? this._start === other._start &&
  994. this._end === other._end &&
  995. this._step === other._step
  996. : deepEqual(this, other);
  997. };
  998. var EMPTY_RANGE;
  999. createClass(Collection, Iterable);
  1000. function Collection() {
  1001. throw TypeError("Abstract");
  1002. }
  1003. createClass(KeyedCollection, Collection);
  1004. function KeyedCollection() {}
  1005. createClass(IndexedCollection, Collection);
  1006. function IndexedCollection() {}
  1007. createClass(SetCollection, Collection);
  1008. function SetCollection() {}
  1009. Collection.Keyed = KeyedCollection;
  1010. Collection.Indexed = IndexedCollection;
  1011. Collection.Set = SetCollection;
  1012. var imul =
  1013. typeof Math.imul === "function" && Math.imul(0xffffffff, 2) === -2
  1014. ? Math.imul
  1015. : function imul(a, b) {
  1016. a = a | 0; // int
  1017. b = b | 0; // int
  1018. var c = a & 0xffff;
  1019. var d = b & 0xffff;
  1020. // Shift by 0 fixes the sign on the high part.
  1021. return (
  1022. (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0
  1023. ); // int
  1024. };
  1025. // v8 has an optimization for storing 31-bit signed numbers.
  1026. // Values which have either 00 or 11 as the high order bits qualify.
  1027. // This function drops the highest order bit in a signed number, maintaining
  1028. // the sign bit.
  1029. function smi(i32) {
  1030. return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff);
  1031. }
  1032. function hash(o) {
  1033. if (o === false || o === null || o === undefined) {
  1034. return 0;
  1035. }
  1036. if (typeof o.valueOf === "function") {
  1037. o = o.valueOf();
  1038. if (o === false || o === null || o === undefined) {
  1039. return 0;
  1040. }
  1041. }
  1042. if (o === true) {
  1043. return 1;
  1044. }
  1045. var type = typeof o;
  1046. if (type === "number") {
  1047. var h = o | 0;
  1048. if (h !== o) {
  1049. h ^= o * 0xffffffff;
  1050. }
  1051. while (o > 0xffffffff) {
  1052. o /= 0xffffffff;
  1053. h ^= o;
  1054. }
  1055. return smi(h);
  1056. }
  1057. if (type === "string") {
  1058. return o.length > STRING_HASH_CACHE_MIN_STRLEN
  1059. ? cachedHashString(o)
  1060. : hashString(o);
  1061. }
  1062. if (typeof o.hashCode === "function") {
  1063. return o.hashCode();
  1064. }
  1065. if (type === "object") {
  1066. return hashJSObj(o);
  1067. }
  1068. if (typeof o.toString === "function") {
  1069. return hashString(o.toString());
  1070. }
  1071. throw new Error("Value type " + type + " cannot be hashed.");
  1072. }
  1073. function cachedHashString(string) {
  1074. var hash = stringHashCache[string];
  1075. if (hash === undefined) {
  1076. hash = hashString(string);
  1077. if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
  1078. STRING_HASH_CACHE_SIZE = 0;
  1079. stringHashCache = {};
  1080. }
  1081. STRING_HASH_CACHE_SIZE++;
  1082. stringHashCache[string] = hash;
  1083. }
  1084. return hash;
  1085. }
  1086. // http://jsperf.com/hashing-strings
  1087. function hashString(string) {
  1088. // This is the hash from JVM
  1089. // The hash code for a string is computed as
  1090. // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  1091. // where s[i] is the ith character of the string and n is the length of
  1092. // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  1093. // (exclusive) by dropping high bits.
  1094. var hash = 0;
  1095. for (var ii = 0; ii < string.length; ii++) {
  1096. hash = (31 * hash + string.charCodeAt(ii)) | 0;
  1097. }
  1098. return smi(hash);
  1099. }
  1100. function hashJSObj(obj) {
  1101. var hash;
  1102. if (usingWeakMap) {
  1103. hash = weakMap.get(obj);
  1104. if (hash !== undefined) {
  1105. return hash;
  1106. }
  1107. }
  1108. hash = obj[UID_HASH_KEY];
  1109. if (hash !== undefined) {
  1110. return hash;
  1111. }
  1112. if (!canDefineProperty) {
  1113. hash =
  1114. obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
  1115. if (hash !== undefined) {
  1116. return hash;
  1117. }
  1118. hash = getIENodeHash(obj);
  1119. if (hash !== undefined) {
  1120. return hash;
  1121. }
  1122. }
  1123. hash = ++objHashUID;
  1124. if (objHashUID & 0x40000000) {
  1125. objHashUID = 0;
  1126. }
  1127. if (usingWeakMap) {
  1128. weakMap.set(obj, hash);
  1129. } else if (isExtensible !== undefined && isExtensible(obj) === false) {
  1130. throw new Error("Non-extensible objects are not allowed as keys.");
  1131. } else if (canDefineProperty) {
  1132. Object.defineProperty(obj, UID_HASH_KEY, {
  1133. enumerable: false,
  1134. configurable: false,
  1135. writable: false,
  1136. value: hash
  1137. });
  1138. } else if (
  1139. obj.propertyIsEnumerable !== undefined &&
  1140. obj.propertyIsEnumerable ===
  1141. obj.constructor.prototype.propertyIsEnumerable
  1142. ) {
  1143. // Since we can't define a non-enumerable property on the object
  1144. // we'll hijack one of the less-used non-enumerable properties to
  1145. // save our hash on it. Since this is a function it will not show up in
  1146. // `JSON.stringify` which is what we want.
  1147. obj.propertyIsEnumerable = function() {
  1148. return this.constructor.prototype.propertyIsEnumerable.apply(
  1149. this,
  1150. arguments
  1151. );
  1152. };
  1153. obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
  1154. } else if (obj.nodeType !== undefined) {
  1155. // At this point we couldn't get the IE `uniqueID` to use as a hash
  1156. // and we couldn't use a non-enumerable property to exploit the
  1157. // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
  1158. // itself.
  1159. obj[UID_HASH_KEY] = hash;
  1160. } else {
  1161. throw new Error("Unable to set a non-enumerable property on object.");
  1162. }
  1163. return hash;
  1164. }
  1165. // Get references to ES5 object methods.
  1166. var isExtensible = Object.isExtensible;
  1167. // True if Object.defineProperty works as expected. IE8 fails this test.
  1168. var canDefineProperty = (function() {
  1169. try {
  1170. Object.defineProperty({}, "@", {});
  1171. return true;
  1172. } catch (e) {
  1173. return false;
  1174. }
  1175. })();
  1176. // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
  1177. // and avoid memory leaks from the IE cloneNode bug.
  1178. function getIENodeHash(node) {
  1179. if (node && node.nodeType > 0) {
  1180. switch (node.nodeType) {
  1181. case 1: // Element
  1182. return node.uniqueID;
  1183. case 9: // Document
  1184. return node.documentElement && node.documentElement.uniqueID;
  1185. }
  1186. }
  1187. }
  1188. // If possible, use a WeakMap.
  1189. var usingWeakMap = typeof WeakMap === "function";
  1190. var weakMap;
  1191. if (usingWeakMap) {
  1192. weakMap = new WeakMap();
  1193. }
  1194. var objHashUID = 0;
  1195. var UID_HASH_KEY = "__immutablehash__";
  1196. if (typeof Symbol === "function") {
  1197. UID_HASH_KEY = Symbol(UID_HASH_KEY);
  1198. }
  1199. var STRING_HASH_CACHE_MIN_STRLEN = 16;
  1200. var STRING_HASH_CACHE_MAX_SIZE = 255;
  1201. var STRING_HASH_CACHE_SIZE = 0;
  1202. var stringHashCache = {};
  1203. function assertNotInfinite(size) {
  1204. invariant(
  1205. size !== Infinity,
  1206. "Cannot perform this action with an infinite size."
  1207. );
  1208. }
  1209. createClass(Map, KeyedCollection);
  1210. // @pragma Construction
  1211. function Map(value) {
  1212. return value === null || value === undefined
  1213. ? emptyMap()
  1214. : isMap(value) && !isOrdered(value)
  1215. ? value
  1216. : emptyMap().withMutations(function(map) {
  1217. var iter = KeyedIterable(value);
  1218. assertNotInfinite(iter.size);
  1219. iter.forEach(function(v, k) {
  1220. return map.set(k, v);
  1221. });
  1222. });
  1223. }
  1224. Map.prototype.toString = function() {
  1225. return this.__toString("Map {", "}");
  1226. };
  1227. // @pragma Access
  1228. Map.prototype.get = function(k, notSetValue) {
  1229. return this._root
  1230. ? this._root.get(0, undefined, k, notSetValue)
  1231. : notSetValue;
  1232. };
  1233. // @pragma Modification
  1234. Map.prototype.set = function(k, v) {
  1235. return updateMap(this, k, v);
  1236. };
  1237. Map.prototype.setIn = function(keyPath, v) {
  1238. return this.updateIn(keyPath, NOT_SET, function() {
  1239. return v;
  1240. });
  1241. };
  1242. Map.prototype.remove = function(k) {
  1243. return updateMap(this, k, NOT_SET);
  1244. };
  1245. Map.prototype.deleteIn = function(keyPath) {
  1246. return this.updateIn(keyPath, function() {
  1247. return NOT_SET;
  1248. });
  1249. };
  1250. Map.prototype.update = function(k, notSetValue, updater) {
  1251. return arguments.length === 1
  1252. ? k(this)
  1253. : this.updateIn([k], notSetValue, updater);
  1254. };
  1255. Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
  1256. if (!updater) {
  1257. updater = notSetValue;
  1258. notSetValue = undefined;
  1259. }
  1260. var updatedValue = updateInDeepMap(
  1261. this,
  1262. forceIterator(keyPath),
  1263. notSetValue,
  1264. updater
  1265. );
  1266. return updatedValue === NOT_SET ? undefined : updatedValue;
  1267. };
  1268. Map.prototype.clear = function() {
  1269. if (this.size === 0) {
  1270. return this;
  1271. }
  1272. if (this.__ownerID) {
  1273. this.size = 0;
  1274. this._root = null;
  1275. this.__hash = undefined;
  1276. this.__altered = true;
  1277. return this;
  1278. }
  1279. return emptyMap();
  1280. };
  1281. // @pragma Composition
  1282. Map.prototype.merge = function(/*...iters*/) {
  1283. return mergeIntoMapWith(this, undefined, arguments);
  1284. };
  1285. Map.prototype.mergeWith = function(merger) {
  1286. var iters = SLICE$0.call(arguments, 1);
  1287. return mergeIntoMapWith(this, merger, iters);
  1288. };
  1289. Map.prototype.mergeIn = function(keyPath) {
  1290. var iters = SLICE$0.call(arguments, 1);
  1291. return this.updateIn(keyPath, emptyMap(), function(m) {
  1292. return typeof m.merge === "function"
  1293. ? m.merge.apply(m, iters)
  1294. : iters[iters.length - 1];
  1295. });
  1296. };
  1297. Map.prototype.mergeDeep = function(/*...iters*/) {
  1298. return mergeIntoMapWith(this, deepMerger, arguments);
  1299. };
  1300. Map.prototype.mergeDeepWith = function(merger) {
  1301. var iters = SLICE$0.call(arguments, 1);
  1302. return mergeIntoMapWith(this, deepMergerWith(merger), iters);
  1303. };
  1304. Map.prototype.mergeDeepIn = function(keyPath) {
  1305. var iters = SLICE$0.call(arguments, 1);
  1306. return this.updateIn(keyPath, emptyMap(), function(m) {
  1307. return typeof m.mergeDeep === "function"
  1308. ? m.mergeDeep.apply(m, iters)
  1309. : iters[iters.length - 1];
  1310. });
  1311. };
  1312. Map.prototype.sort = function(comparator) {
  1313. // Late binding
  1314. return OrderedMap(sortFactory(this, comparator));
  1315. };
  1316. Map.prototype.sortBy = function(mapper, comparator) {
  1317. // Late binding
  1318. return OrderedMap(sortFactory(this, comparator, mapper));
  1319. };
  1320. // @pragma Mutability
  1321. Map.prototype.withMutations = function(fn) {
  1322. var mutable = this.asMutable();
  1323. fn(mutable);
  1324. return mutable.wasAltered()
  1325. ? mutable.__ensureOwner(this.__ownerID)
  1326. : this;
  1327. };
  1328. Map.prototype.asMutable = function() {
  1329. return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
  1330. };
  1331. Map.prototype.asImmutable = function() {
  1332. return this.__ensureOwner();
  1333. };
  1334. Map.prototype.wasAltered = function() {
  1335. return this.__altered;
  1336. };
  1337. Map.prototype.__iterator = function(type, reverse) {
  1338. return new MapIterator(this, type, reverse);
  1339. };
  1340. Map.prototype.__iterate = function(fn, reverse) {
  1341. var this$0 = this;
  1342. var iterations = 0;
  1343. this._root &&
  1344. this._root.iterate(function(entry) {
  1345. iterations++;
  1346. return fn(entry[1], entry[0], this$0);
  1347. }, reverse);
  1348. return iterations;
  1349. };
  1350. Map.prototype.__ensureOwner = function(ownerID) {
  1351. if (ownerID === this.__ownerID) {
  1352. return this;
  1353. }
  1354. if (!ownerID) {
  1355. this.__ownerID = ownerID;
  1356. this.__altered = false;
  1357. return this;
  1358. }
  1359. return makeMap(this.size, this._root, ownerID, this.__hash);
  1360. };
  1361. function isMap(maybeMap) {
  1362. return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
  1363. }
  1364. Map.isMap = isMap;
  1365. var IS_MAP_SENTINEL = "@@__IMMUTABLE_MAP__@@";
  1366. var MapPrototype = Map.prototype;
  1367. MapPrototype[IS_MAP_SENTINEL] = true;
  1368. MapPrototype[DELETE] = MapPrototype.remove;
  1369. MapPrototype.removeIn = MapPrototype.deleteIn;
  1370. // #pragma Trie Nodes
  1371. function ArrayMapNode(ownerID, entries) {
  1372. this.ownerID = ownerID;
  1373. this.entries = entries;
  1374. }
  1375. ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  1376. var entries = this.entries;
  1377. for (var ii = 0, len = entries.length; ii < len; ii++) {
  1378. if (is(key, entries[ii][0])) {
  1379. return entries[ii][1];
  1380. }
  1381. }
  1382. return notSetValue;
  1383. };
  1384. ArrayMapNode.prototype.update = function(
  1385. ownerID,
  1386. shift,
  1387. keyHash,
  1388. key,
  1389. value,
  1390. didChangeSize,
  1391. didAlter
  1392. ) {
  1393. var removed = value === NOT_SET;
  1394. var entries = this.entries;
  1395. var idx = 0;
  1396. for (var len = entries.length; idx < len; idx++) {
  1397. if (is(key, entries[idx][0])) {
  1398. break;
  1399. }
  1400. }
  1401. var exists = idx < len;
  1402. if (exists ? entries[idx][1] === value : removed) {
  1403. return this;
  1404. }
  1405. SetRef(didAlter);
  1406. (removed || !exists) && SetRef(didChangeSize);
  1407. if (removed && entries.length === 1) {
  1408. return; // undefined
  1409. }
  1410. if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
  1411. return createNodes(ownerID, entries, key, value);
  1412. }
  1413. var isEditable = ownerID && ownerID === this.ownerID;
  1414. var newEntries = isEditable ? entries : arrCopy(entries);
  1415. if (exists) {
  1416. if (removed) {
  1417. idx === len - 1
  1418. ? newEntries.pop()
  1419. : (newEntries[idx] = newEntries.pop());
  1420. } else {
  1421. newEntries[idx] = [key, value];
  1422. }
  1423. } else {
  1424. newEntries.push([key, value]);
  1425. }
  1426. if (isEditable) {
  1427. this.entries = newEntries;
  1428. return this;
  1429. }
  1430. return new ArrayMapNode(ownerID, newEntries);
  1431. };
  1432. function BitmapIndexedNode(ownerID, bitmap, nodes) {
  1433. this.ownerID = ownerID;
  1434. this.bitmap = bitmap;
  1435. this.nodes = nodes;
  1436. }
  1437. BitmapIndexedNode.prototype.get = function(
  1438. shift,
  1439. keyHash,
  1440. key,
  1441. notSetValue
  1442. ) {
  1443. if (keyHash === undefined) {
  1444. keyHash = hash(key);
  1445. }
  1446. var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK);
  1447. var bitmap = this.bitmap;
  1448. return (bitmap & bit) === 0
  1449. ? notSetValue
  1450. : this.nodes[popCount(bitmap & (bit - 1))].get(
  1451. shift + SHIFT,
  1452. keyHash,
  1453. key,
  1454. notSetValue
  1455. );
  1456. };
  1457. BitmapIndexedNode.prototype.update = function(
  1458. ownerID,
  1459. shift,
  1460. keyHash,
  1461. key,
  1462. value,
  1463. didChangeSize,
  1464. didAlter
  1465. ) {
  1466. if (keyHash === undefined) {
  1467. keyHash = hash(key);
  1468. }
  1469. var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  1470. var bit = 1 << keyHashFrag;
  1471. var bitmap = this.bitmap;
  1472. var exists = (bitmap & bit) !== 0;
  1473. if (!exists && value === NOT_SET) {
  1474. return this;
  1475. }
  1476. var idx = popCount(bitmap & (bit - 1));
  1477. var nodes = this.nodes;
  1478. var node = exists ? nodes[idx] : undefined;
  1479. var newNode = updateNode(
  1480. node,
  1481. ownerID,
  1482. shift + SHIFT,
  1483. keyHash,
  1484. key,
  1485. value,
  1486. didChangeSize,
  1487. didAlter
  1488. );
  1489. if (newNode === node) {
  1490. return this;
  1491. }
  1492. if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
  1493. return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
  1494. }
  1495. if (
  1496. exists &&
  1497. !newNode &&
  1498. nodes.length === 2 &&
  1499. isLeafNode(nodes[idx ^ 1])
  1500. ) {
  1501. return nodes[idx ^ 1];
  1502. }
  1503. if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
  1504. return newNode;
  1505. }
  1506. var isEditable = ownerID && ownerID === this.ownerID;
  1507. var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit;
  1508. var newNodes = exists
  1509. ? newNode
  1510. ? setIn(nodes, idx, newNode, isEditable)
  1511. : spliceOut(nodes, idx, isEditable)
  1512. : spliceIn(nodes, idx, newNode, isEditable);
  1513. if (isEditable) {
  1514. this.bitmap = newBitmap;
  1515. this.nodes = newNodes;
  1516. return this;
  1517. }
  1518. return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
  1519. };
  1520. function HashArrayMapNode(ownerID, count, nodes) {
  1521. this.ownerID = ownerID;
  1522. this.count = count;
  1523. this.nodes = nodes;
  1524. }
  1525. HashArrayMapNode.prototype.get = function(
  1526. shift,
  1527. keyHash,
  1528. key,
  1529. notSetValue
  1530. ) {
  1531. if (keyHash === undefined) {
  1532. keyHash = hash(key);
  1533. }
  1534. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  1535. var node = this.nodes[idx];
  1536. return node
  1537. ? node.get(shift + SHIFT, keyHash, key, notSetValue)
  1538. : notSetValue;
  1539. };
  1540. HashArrayMapNode.prototype.update = function(
  1541. ownerID,
  1542. shift,
  1543. keyHash,
  1544. key,
  1545. value,
  1546. didChangeSize,
  1547. didAlter
  1548. ) {
  1549. if (keyHash === undefined) {
  1550. keyHash = hash(key);
  1551. }
  1552. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  1553. var removed = value === NOT_SET;
  1554. var nodes = this.nodes;
  1555. var node = nodes[idx];
  1556. if (removed && !node) {
  1557. return this;
  1558. }
  1559. var newNode = updateNode(
  1560. node,
  1561. ownerID,
  1562. shift + SHIFT,
  1563. keyHash,
  1564. key,
  1565. value,
  1566. didChangeSize,
  1567. didAlter
  1568. );
  1569. if (newNode === node) {
  1570. return this;
  1571. }
  1572. var newCount = this.count;
  1573. if (!node) {
  1574. newCount++;
  1575. } else if (!newNode) {
  1576. newCount--;
  1577. if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
  1578. return packNodes(ownerID, nodes, newCount, idx);
  1579. }
  1580. }
  1581. var isEditable = ownerID && ownerID === this.ownerID;
  1582. var newNodes = setIn(nodes, idx, newNode, isEditable);
  1583. if (isEditable) {
  1584. this.count = newCount;
  1585. this.nodes = newNodes;
  1586. return this;
  1587. }
  1588. return new HashArrayMapNode(ownerID, newCount, newNodes);
  1589. };
  1590. function HashCollisionNode(ownerID, keyHash, entries) {
  1591. this.ownerID = ownerID;
  1592. this.keyHash = keyHash;
  1593. this.entries = entries;
  1594. }
  1595. HashCollisionNode.prototype.get = function(
  1596. shift,
  1597. keyHash,
  1598. key,
  1599. notSetValue
  1600. ) {
  1601. var entries = this.entries;
  1602. for (var ii = 0, len = entries.length; ii < len; ii++) {
  1603. if (is(key, entries[ii][0])) {
  1604. return entries[ii][1];
  1605. }
  1606. }
  1607. return notSetValue;
  1608. };
  1609. HashCollisionNode.prototype.update = function(
  1610. ownerID,
  1611. shift,
  1612. keyHash,
  1613. key,
  1614. value,
  1615. didChangeSize,
  1616. didAlter
  1617. ) {
  1618. if (keyHash === undefined) {
  1619. keyHash = hash(key);
  1620. }
  1621. var removed = value === NOT_SET;
  1622. if (keyHash !== this.keyHash) {
  1623. if (removed) {
  1624. return this;
  1625. }
  1626. SetRef(didAlter);
  1627. SetRef(didChangeSize);
  1628. return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
  1629. }
  1630. var entries = this.entries;
  1631. var idx = 0;
  1632. for (var len = entries.length; idx < len; idx++) {
  1633. if (is(key, entries[idx][0])) {
  1634. break;
  1635. }
  1636. }
  1637. var exists = idx < len;
  1638. if (exists ? entries[idx][1] === value : removed) {
  1639. return this;
  1640. }
  1641. SetRef(didAlter);
  1642. (removed || !exists) && SetRef(didChangeSize);
  1643. if (removed && len === 2) {
  1644. return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
  1645. }
  1646. var isEditable = ownerID && ownerID === this.ownerID;
  1647. var newEntries = isEditable ? entries : arrCopy(entries);
  1648. if (exists) {
  1649. if (removed) {
  1650. idx === len - 1
  1651. ? newEntries.pop()
  1652. : (newEntries[idx] = newEntries.pop());
  1653. } else {
  1654. newEntries[idx] = [key, value];
  1655. }
  1656. } else {
  1657. newEntries.push([key, value]);
  1658. }
  1659. if (isEditable) {
  1660. this.entries = newEntries;
  1661. return this;
  1662. }
  1663. return new HashCollisionNode(ownerID, this.keyHash, newEntries);
  1664. };
  1665. function ValueNode(ownerID, keyHash, entry) {
  1666. this.ownerID = ownerID;
  1667. this.keyHash = keyHash;
  1668. this.entry = entry;
  1669. }
  1670. ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  1671. return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
  1672. };
  1673. ValueNode.prototype.update = function(
  1674. ownerID,
  1675. shift,
  1676. keyHash,
  1677. key,
  1678. value,
  1679. didChangeSize,
  1680. didAlter
  1681. ) {
  1682. var removed = value === NOT_SET;
  1683. var keyMatch = is(key, this.entry[0]);
  1684. if (keyMatch ? value === this.entry[1] : removed) {
  1685. return this;
  1686. }
  1687. SetRef(didAlter);
  1688. if (removed) {
  1689. SetRef(didChangeSize);
  1690. return; // undefined
  1691. }
  1692. if (keyMatch) {
  1693. if (ownerID && ownerID === this.ownerID) {
  1694. this.entry[1] = value;
  1695. return this;
  1696. }
  1697. return new ValueNode(ownerID, this.keyHash, [key, value]);
  1698. }
  1699. SetRef(didChangeSize);
  1700. return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
  1701. };
  1702. // #pragma Iterators
  1703. ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = function(
  1704. fn,
  1705. reverse
  1706. ) {
  1707. var entries = this.entries;
  1708. for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
  1709. if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
  1710. return false;
  1711. }
  1712. }
  1713. };
  1714. BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = function(
  1715. fn,
  1716. reverse
  1717. ) {
  1718. var nodes = this.nodes;
  1719. for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
  1720. var node = nodes[reverse ? maxIndex - ii : ii];
  1721. if (node && node.iterate(fn, reverse) === false) {
  1722. return false;
  1723. }
  1724. }
  1725. };
  1726. ValueNode.prototype.iterate = function(fn, reverse) {
  1727. return fn(this.entry);
  1728. };
  1729. createClass(MapIterator, Iterator);
  1730. function MapIterator(map, type, reverse) {
  1731. this._type = type;
  1732. this._reverse = reverse;
  1733. this._stack = map._root && mapIteratorFrame(map._root);
  1734. }
  1735. MapIterator.prototype.next = function() {
  1736. var type = this._type;
  1737. var stack = this._stack;
  1738. while (stack) {
  1739. var node = stack.node;
  1740. var index = stack.index++;
  1741. var maxIndex;
  1742. if (node.entry) {
  1743. if (index === 0) {
  1744. return mapIteratorValue(type, node.entry);
  1745. }
  1746. } else if (node.entries) {
  1747. maxIndex = node.entries.length - 1;
  1748. if (index <= maxIndex) {
  1749. return mapIteratorValue(
  1750. type,
  1751. node.entries[this._reverse ? maxIndex - index : index]
  1752. );
  1753. }
  1754. } else {
  1755. maxIndex = node.nodes.length - 1;
  1756. if (index <= maxIndex) {
  1757. var subNode = node.nodes[this._reverse ? maxIndex - index : index];
  1758. if (subNode) {
  1759. if (subNode.entry) {
  1760. return mapIteratorValue(type, subNode.entry);
  1761. }
  1762. stack = this._stack = mapIteratorFrame(subNode, stack);
  1763. }
  1764. continue;
  1765. }
  1766. }
  1767. stack = this._stack = this._stack.__prev;
  1768. }
  1769. return iteratorDone();
  1770. };
  1771. function mapIteratorValue(type, entry) {
  1772. return iteratorValue(type, entry[0], entry[1]);
  1773. }
  1774. function mapIteratorFrame(node, prev) {
  1775. return {
  1776. node: node,
  1777. index: 0,
  1778. __prev: prev
  1779. };
  1780. }
  1781. function makeMap(size, root, ownerID, hash) {
  1782. var map = Object.create(MapPrototype);
  1783. map.size = size;
  1784. map._root = root;
  1785. map.__ownerID = ownerID;
  1786. map.__hash = hash;
  1787. map.__altered = false;
  1788. return map;
  1789. }
  1790. var EMPTY_MAP;
  1791. function emptyMap() {
  1792. return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
  1793. }
  1794. function updateMap(map, k, v) {
  1795. var newRoot;
  1796. var newSize;
  1797. if (!map._root) {
  1798. if (v === NOT_SET) {
  1799. return map;
  1800. }
  1801. newSize = 1;
  1802. newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
  1803. } else {
  1804. var didChangeSize = MakeRef(CHANGE_LENGTH);
  1805. var didAlter = MakeRef(DID_ALTER);
  1806. newRoot = updateNode(
  1807. map._root,
  1808. map.__ownerID,
  1809. 0,
  1810. undefined,
  1811. k,
  1812. v,
  1813. didChangeSize,
  1814. didAlter
  1815. );
  1816. if (!didAlter.value) {
  1817. return map;
  1818. }
  1819. newSize =
  1820. map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0);
  1821. }
  1822. if (map.__ownerID) {
  1823. map.size = newSize;
  1824. map._root = newRoot;
  1825. map.__hash = undefined;
  1826. map.__altered = true;
  1827. return map;
  1828. }
  1829. return newRoot ? makeMap(newSize, newRoot) : emptyMap();
  1830. }
  1831. function updateNode(
  1832. node,
  1833. ownerID,
  1834. shift,
  1835. keyHash,
  1836. key,
  1837. value,
  1838. didChangeSize,
  1839. didAlter
  1840. ) {
  1841. if (!node) {
  1842. if (value === NOT_SET) {
  1843. return node;
  1844. }
  1845. SetRef(didAlter);
  1846. SetRef(didChangeSize);
  1847. return new ValueNode(ownerID, keyHash, [key, value]);
  1848. }
  1849. return node.update(
  1850. ownerID,
  1851. shift,
  1852. keyHash,
  1853. key,
  1854. value,
  1855. didChangeSize,
  1856. didAlter
  1857. );
  1858. }
  1859. function isLeafNode(node) {
  1860. return (
  1861. node.constructor === ValueNode || node.constructor === HashCollisionNode
  1862. );
  1863. }
  1864. function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
  1865. if (node.keyHash === keyHash) {
  1866. return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
  1867. }
  1868. var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
  1869. var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  1870. var newNode;
  1871. var nodes =
  1872. idx1 === idx2
  1873. ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)]
  1874. : ((newNode = new ValueNode(ownerID, keyHash, entry)),
  1875. idx1 < idx2 ? [node, newNode] : [newNode, node]);
  1876. return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
  1877. }
  1878. function createNodes(ownerID, entries, key, value) {
  1879. if (!ownerID) {
  1880. ownerID = new OwnerID();
  1881. }
  1882. var node = new ValueNode(ownerID, hash(key), [key, value]);
  1883. for (var ii = 0; ii < entries.length; ii++) {
  1884. var entry = entries[ii];
  1885. node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
  1886. }
  1887. return node;
  1888. }
  1889. function packNodes(ownerID, nodes, count, excluding) {
  1890. var bitmap = 0;
  1891. var packedII = 0;
  1892. var packedNodes = new Array(count);
  1893. for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
  1894. var node = nodes[ii];
  1895. if (node !== undefined && ii !== excluding) {
  1896. bitmap |= bit;
  1897. packedNodes[packedII++] = node;
  1898. }
  1899. }
  1900. return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
  1901. }
  1902. function expandNodes(ownerID, nodes, bitmap, including, node) {
  1903. var count = 0;
  1904. var expandedNodes = new Array(SIZE);
  1905. for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
  1906. expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
  1907. }
  1908. expandedNodes[including] = node;
  1909. return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
  1910. }
  1911. function mergeIntoMapWith(map, merger, iterables) {
  1912. var iters = [];
  1913. for (var ii = 0; ii < iterables.length; ii++) {
  1914. var value = iterables[ii];
  1915. var iter = KeyedIterable(value);
  1916. if (!isIterable(value)) {
  1917. iter = iter.map(function(v) {
  1918. return fromJS(v);
  1919. });
  1920. }
  1921. iters.push(iter);
  1922. }
  1923. return mergeIntoCollectionWith(map, merger, iters);
  1924. }
  1925. function deepMerger(existing, value, key) {
  1926. return existing && existing.mergeDeep && isIterable(value)
  1927. ? existing.mergeDeep(value)
  1928. : is(existing, value)
  1929. ? existing
  1930. : value;
  1931. }
  1932. function deepMergerWith(merger) {
  1933. return function(existing, value, key) {
  1934. if (existing && existing.mergeDeepWith && isIterable(value)) {
  1935. return existing.mergeDeepWith(merger, value);
  1936. }
  1937. var nextValue = merger(existing, value, key);
  1938. return is(existing, nextValue) ? existing : nextValue;
  1939. };
  1940. }
  1941. function mergeIntoCollectionWith(collection, merger, iters) {
  1942. iters = iters.filter(function(x) {
  1943. return x.size !== 0;
  1944. });
  1945. if (iters.length === 0) {
  1946. return collection;
  1947. }
  1948. if (
  1949. collection.size === 0 &&
  1950. !collection.__ownerID &&
  1951. iters.length === 1
  1952. ) {
  1953. return collection.constructor(iters[0]);
  1954. }
  1955. return collection.withMutations(function(collection) {
  1956. var mergeIntoMap = merger
  1957. ? function(value, key) {
  1958. collection.update(key, NOT_SET, function(existing) {
  1959. return existing === NOT_SET
  1960. ? value
  1961. : merger(existing, value, key);
  1962. });
  1963. }
  1964. : function(value, key) {
  1965. collection.set(key, value);
  1966. };
  1967. for (var ii = 0; ii < iters.length; ii++) {
  1968. iters[ii].forEach(mergeIntoMap);
  1969. }
  1970. });
  1971. }
  1972. function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
  1973. var isNotSet = existing === NOT_SET;
  1974. var step = keyPathIter.next();
  1975. if (step.done) {
  1976. var existingValue = isNotSet ? notSetValue : existing;
  1977. var newValue = updater(existingValue);
  1978. return newValue === existingValue ? existing : newValue;
  1979. }
  1980. invariant(isNotSet || (existing && existing.set), "invalid keyPath");
  1981. var key = step.value;
  1982. var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
  1983. var nextUpdated = updateInDeepMap(
  1984. nextExisting,
  1985. keyPathIter,
  1986. notSetValue,
  1987. updater
  1988. );
  1989. return nextUpdated === nextExisting
  1990. ? existing
  1991. : nextUpdated === NOT_SET
  1992. ? existing.remove(key)
  1993. : (isNotSet ? emptyMap() : existing).set(key, nextUpdated);
  1994. }
  1995. function popCount(x) {
  1996. x = x - ((x >> 1) & 0x55555555);
  1997. x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  1998. x = (x + (x >> 4)) & 0x0f0f0f0f;
  1999. x = x + (x >> 8);
  2000. x = x + (x >> 16);
  2001. return x & 0x7f;
  2002. }
  2003. function setIn(array, idx, val, canEdit) {
  2004. var newArray = canEdit ? array : arrCopy(array);
  2005. newArray[idx] = val;
  2006. return newArray;
  2007. }
  2008. function spliceIn(array, idx, val, canEdit) {
  2009. var newLen = array.length + 1;
  2010. if (canEdit && idx + 1 === newLen) {
  2011. array[idx] = val;
  2012. return array;
  2013. }
  2014. var newArray = new Array(newLen);
  2015. var after = 0;
  2016. for (var ii = 0; ii < newLen; ii++) {
  2017. if (ii === idx) {
  2018. newArray[ii] = val;
  2019. after = -1;
  2020. } else {
  2021. newArray[ii] = array[ii + after];
  2022. }
  2023. }
  2024. return newArray;
  2025. }
  2026. function spliceOut(array, idx, canEdit) {
  2027. var newLen = array.length - 1;
  2028. if (canEdit && idx === newLen) {
  2029. array.pop();
  2030. return array;
  2031. }
  2032. var newArray = new Array(newLen);
  2033. var after = 0;
  2034. for (var ii = 0; ii < newLen; ii++) {
  2035. if (ii === idx) {
  2036. after = 1;
  2037. }
  2038. newArray[ii] = array[ii + after];
  2039. }
  2040. return newArray;
  2041. }
  2042. var MAX_ARRAY_MAP_SIZE = SIZE / 4;
  2043. var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
  2044. var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
  2045. createClass(List, IndexedCollection);
  2046. // @pragma Construction
  2047. function List(value) {
  2048. var empty = emptyList();
  2049. if (value === null || value === undefined) {
  2050. return empty;
  2051. }
  2052. if (isList(value)) {
  2053. return value;
  2054. }
  2055. var iter = IndexedIterable(value);
  2056. var size = iter.size;
  2057. if (size === 0) {
  2058. return empty;
  2059. }
  2060. assertNotInfinite(size);
  2061. if (size > 0 && size < SIZE) {
  2062. return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
  2063. }
  2064. return empty.withMutations(function(list) {
  2065. list.setSize(size);
  2066. iter.forEach(function(v, i) {
  2067. return list.set(i, v);
  2068. });
  2069. });
  2070. }
  2071. List.of = function(/*...values*/) {
  2072. return this(arguments);
  2073. };
  2074. List.prototype.toString = function() {
  2075. return this.__toString("List [", "]");
  2076. };
  2077. // @pragma Access
  2078. List.prototype.get = function(index, notSetValue) {
  2079. index = wrapIndex(this, index);
  2080. if (index >= 0 && index < this.size) {
  2081. index += this._origin;
  2082. var node = listNodeFor(this, index);
  2083. return node && node.array[index & MASK];
  2084. }
  2085. return notSetValue;
  2086. };
  2087. // @pragma Modification
  2088. List.prototype.set = function(index, value) {
  2089. return updateList(this, index, value);
  2090. };
  2091. List.prototype.remove = function(index) {
  2092. return !this.has(index)
  2093. ? this
  2094. : index === 0
  2095. ? this.shift()
  2096. : index === this.size - 1
  2097. ? this.pop()
  2098. : this.splice(index, 1);
  2099. };
  2100. List.prototype.insert = function(index, value) {
  2101. return this.splice(index, 0, value);
  2102. };
  2103. List.prototype.clear = function() {
  2104. if (this.size === 0) {
  2105. return this;
  2106. }
  2107. if (this.__ownerID) {
  2108. this.size = this._origin = this._capacity = 0;
  2109. this._level = SHIFT;
  2110. this._root = this._tail = null;
  2111. this.__hash = undefined;
  2112. this.__altered = true;
  2113. return this;
  2114. }
  2115. return emptyList();
  2116. };
  2117. List.prototype.push = function(/*...values*/) {
  2118. var values = arguments;
  2119. var oldSize = this.size;
  2120. return this.withMutations(function(list) {
  2121. setListBounds(list, 0, oldSize + values.length);
  2122. for (var ii = 0; ii < values.length; ii++) {
  2123. list.set(oldSize + ii, values[ii]);
  2124. }
  2125. });
  2126. };
  2127. List.prototype.pop = function() {
  2128. return setListBounds(this, 0, -1);
  2129. };
  2130. List.prototype.unshift = function(/*...values*/) {
  2131. var values = arguments;
  2132. return this.withMutations(function(list) {
  2133. setListBounds(list, -values.length);
  2134. for (var ii = 0; ii < values.length; ii++) {
  2135. list.set(ii, values[ii]);
  2136. }
  2137. });
  2138. };
  2139. List.prototype.shift = function() {
  2140. return setListBounds(this, 1);
  2141. };
  2142. // @pragma Composition
  2143. List.prototype.merge = function(/*...iters*/) {
  2144. return mergeIntoListWith(this, undefined, arguments);
  2145. };
  2146. List.prototype.mergeWith = function(merger) {
  2147. var iters = SLICE$0.call(arguments, 1);
  2148. return mergeIntoListWith(this, merger, iters);
  2149. };
  2150. List.prototype.mergeDeep = function(/*...iters*/) {
  2151. return mergeIntoListWith(this, deepMerger, arguments);
  2152. };
  2153. List.prototype.mergeDeepWith = function(merger) {
  2154. var iters = SLICE$0.call(arguments, 1);
  2155. return mergeIntoListWith(this, deepMergerWith(merger), iters);
  2156. };
  2157. List.prototype.setSize = function(size) {
  2158. return setListBounds(this, 0, size);
  2159. };
  2160. // @pragma Iteration
  2161. List.prototype.slice = function(begin, end) {
  2162. var size = this.size;
  2163. if (wholeSlice(begin, end, size)) {
  2164. return this;
  2165. }
  2166. return setListBounds(
  2167. this,
  2168. resolveBegin(begin, size),
  2169. resolveEnd(end, size)
  2170. );
  2171. };
  2172. List.prototype.__iterator = function(type, reverse) {
  2173. var index = 0;
  2174. var values = iterateList(this, reverse);
  2175. return new Iterator(function() {
  2176. var value = values();
  2177. return value === DONE
  2178. ? iteratorDone()
  2179. : iteratorValue(type, index++, value);
  2180. });
  2181. };
  2182. List.prototype.__iterate = function(fn, reverse) {
  2183. var index = 0;
  2184. var values = iterateList(this, reverse);
  2185. var value;
  2186. while ((value = values()) !== DONE) {
  2187. if (fn(value, index++, this) === false) {
  2188. break;
  2189. }
  2190. }
  2191. return index;
  2192. };
  2193. List.prototype.__ensureOwner = function(ownerID) {
  2194. if (ownerID === this.__ownerID) {
  2195. return this;
  2196. }
  2197. if (!ownerID) {
  2198. this.__ownerID = ownerID;
  2199. return this;
  2200. }
  2201. return makeList(
  2202. this._origin,
  2203. this._capacity,
  2204. this._level,
  2205. this._root,
  2206. this._tail,
  2207. ownerID,
  2208. this.__hash
  2209. );
  2210. };
  2211. function isList(maybeList) {
  2212. return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
  2213. }
  2214. List.isList = isList;
  2215. var IS_LIST_SENTINEL = "@@__IMMUTABLE_LIST__@@";
  2216. var ListPrototype = List.prototype;
  2217. ListPrototype[IS_LIST_SENTINEL] = true;
  2218. ListPrototype[DELETE] = ListPrototype.remove;
  2219. ListPrototype.setIn = MapPrototype.setIn;
  2220. ListPrototype.deleteIn = ListPrototype.removeIn = MapPrototype.removeIn;
  2221. ListPrototype.update = MapPrototype.update;
  2222. ListPrototype.updateIn = MapPrototype.updateIn;
  2223. ListPrototype.mergeIn = MapPrototype.mergeIn;
  2224. ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  2225. ListPrototype.withMutations = MapPrototype.withMutations;
  2226. ListPrototype.asMutable = MapPrototype.asMutable;
  2227. ListPrototype.asImmutable = MapPrototype.asImmutable;
  2228. ListPrototype.wasAltered = MapPrototype.wasAltered;
  2229. function VNode(array, ownerID) {
  2230. this.array = array;
  2231. this.ownerID = ownerID;
  2232. }
  2233. // TODO: seems like these methods are very similar
  2234. VNode.prototype.removeBefore = function(ownerID, level, index) {
  2235. if (index === level ? 1 << level : this.array.length === 0) {
  2236. return this;
  2237. }
  2238. var originIndex = (index >>> level) & MASK;
  2239. if (originIndex >= this.array.length) {
  2240. return new VNode([], ownerID);
  2241. }
  2242. var removingFirst = originIndex === 0;
  2243. var newChild;
  2244. if (level > 0) {
  2245. var oldChild = this.array[originIndex];
  2246. newChild =
  2247. oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
  2248. if (newChild === oldChild && removingFirst) {
  2249. return this;
  2250. }
  2251. }
  2252. if (removingFirst && !newChild) {
  2253. return this;
  2254. }
  2255. var editable = editableVNode(this, ownerID);
  2256. if (!removingFirst) {
  2257. for (var ii = 0; ii < originIndex; ii++) {
  2258. editable.array[ii] = undefined;
  2259. }
  2260. }
  2261. if (newChild) {
  2262. editable.array[originIndex] = newChild;
  2263. }
  2264. return editable;
  2265. };
  2266. VNode.prototype.removeAfter = function(ownerID, level, index) {
  2267. if (index === (level ? 1 << level : 0) || this.array.length === 0) {
  2268. return this;
  2269. }
  2270. var sizeIndex = ((index - 1) >>> level) & MASK;
  2271. if (sizeIndex >= this.array.length) {
  2272. return this;
  2273. }
  2274. var newChild;
  2275. if (level > 0) {
  2276. var oldChild = this.array[sizeIndex];
  2277. newChild =
  2278. oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
  2279. if (newChild === oldChild && sizeIndex === this.array.length - 1) {
  2280. return this;
  2281. }
  2282. }
  2283. var editable = editableVNode(this, ownerID);
  2284. editable.array.splice(sizeIndex + 1);
  2285. if (newChild) {
  2286. editable.array[sizeIndex] = newChild;
  2287. }
  2288. return editable;
  2289. };
  2290. var DONE = {};
  2291. function iterateList(list, reverse) {
  2292. var left = list._origin;
  2293. var right = list._capacity;
  2294. var tailPos = getTailOffset(right);
  2295. var tail = list._tail;
  2296. return iterateNodeOrLeaf(list._root, list._level, 0);
  2297. function iterateNodeOrLeaf(node, level, offset) {
  2298. return level === 0
  2299. ? iterateLeaf(node, offset)
  2300. : iterateNode(node, level, offset);
  2301. }
  2302. function iterateLeaf(node, offset) {
  2303. var array =
  2304. offset === tailPos ? tail && tail.array : node && node.array;
  2305. var from = offset > left ? 0 : left - offset;
  2306. var to = right - offset;
  2307. if (to > SIZE) {
  2308. to = SIZE;
  2309. }
  2310. return function() {
  2311. if (from === to) {
  2312. return DONE;
  2313. }
  2314. var idx = reverse ? --to : from++;
  2315. return array && array[idx];
  2316. };
  2317. }
  2318. function iterateNode(node, level, offset) {
  2319. var values;
  2320. var array = node && node.array;
  2321. var from = offset > left ? 0 : (left - offset) >> level;
  2322. var to = ((right - offset) >> level) + 1;
  2323. if (to > SIZE) {
  2324. to = SIZE;
  2325. }
  2326. return function() {
  2327. do {
  2328. if (values) {
  2329. var value = values();
  2330. if (value !== DONE) {
  2331. return value;
  2332. }
  2333. values = null;
  2334. }
  2335. if (from === to) {
  2336. return DONE;
  2337. }
  2338. var idx = reverse ? --to : from++;
  2339. values = iterateNodeOrLeaf(
  2340. array && array[idx],
  2341. level - SHIFT,
  2342. offset + (idx << level)
  2343. );
  2344. } while (true);
  2345. };
  2346. }
  2347. }
  2348. function makeList(origin, capacity, level, root, tail, ownerID, hash) {
  2349. var list = Object.create(ListPrototype);
  2350. list.size = capacity - origin;
  2351. list._origin = origin;
  2352. list._capacity = capacity;
  2353. list._level = level;
  2354. list._root = root;
  2355. list._tail = tail;
  2356. list.__ownerID = ownerID;
  2357. list.__hash = hash;
  2358. list.__altered = false;
  2359. return list;
  2360. }
  2361. var EMPTY_LIST;
  2362. function emptyList() {
  2363. return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
  2364. }
  2365. function updateList(list, index, value) {
  2366. index = wrapIndex(list, index);
  2367. if (index !== index) {
  2368. return list;
  2369. }
  2370. if (index >= list.size || index < 0) {
  2371. return list.withMutations(function(list) {
  2372. index < 0
  2373. ? setListBounds(list, index).set(0, value)
  2374. : setListBounds(list, 0, index + 1).set(index, value);
  2375. });
  2376. }
  2377. index += list._origin;
  2378. var newTail = list._tail;
  2379. var newRoot = list._root;
  2380. var didAlter = MakeRef(DID_ALTER);
  2381. if (index >= getTailOffset(list._capacity)) {
  2382. newTail = updateVNode(
  2383. newTail,
  2384. list.__ownerID,
  2385. 0,
  2386. index,
  2387. value,
  2388. didAlter
  2389. );
  2390. } else {
  2391. newRoot = updateVNode(
  2392. newRoot,
  2393. list.__ownerID,
  2394. list._level,
  2395. index,
  2396. value,
  2397. didAlter
  2398. );
  2399. }
  2400. if (!didAlter.value) {
  2401. return list;
  2402. }
  2403. if (list.__ownerID) {
  2404. list._root = newRoot;
  2405. list._tail = newTail;
  2406. list.__hash = undefined;
  2407. list.__altered = true;
  2408. return list;
  2409. }
  2410. return makeList(
  2411. list._origin,
  2412. list._capacity,
  2413. list._level,
  2414. newRoot,
  2415. newTail
  2416. );
  2417. }
  2418. function updateVNode(node, ownerID, level, index, value, didAlter) {
  2419. var idx = (index >>> level) & MASK;
  2420. var nodeHas = node && idx < node.array.length;
  2421. if (!nodeHas && value === undefined) {
  2422. return node;
  2423. }
  2424. var newNode;
  2425. if (level > 0) {
  2426. var lowerNode = node && node.array[idx];
  2427. var newLowerNode = updateVNode(
  2428. lowerNode,
  2429. ownerID,
  2430. level - SHIFT,
  2431. index,
  2432. value,
  2433. didAlter
  2434. );
  2435. if (newLowerNode === lowerNode) {
  2436. return node;
  2437. }
  2438. newNode = editableVNode(node, ownerID);
  2439. newNode.array[idx] = newLowerNode;
  2440. return newNode;
  2441. }
  2442. if (nodeHas && node.array[idx] === value) {
  2443. return node;
  2444. }
  2445. SetRef(didAlter);
  2446. newNode = editableVNode(node, ownerID);
  2447. if (value === undefined && idx === newNode.array.length - 1) {
  2448. newNode.array.pop();
  2449. } else {
  2450. newNode.array[idx] = value;
  2451. }
  2452. return newNode;
  2453. }
  2454. function editableVNode(node, ownerID) {
  2455. if (ownerID && node && ownerID === node.ownerID) {
  2456. return node;
  2457. }
  2458. return new VNode(node ? node.array.slice() : [], ownerID);
  2459. }
  2460. function listNodeFor(list, rawIndex) {
  2461. if (rawIndex >= getTailOffset(list._capacity)) {
  2462. return list._tail;
  2463. }
  2464. if (rawIndex < 1 << (list._level + SHIFT)) {
  2465. var node = list._root;
  2466. var level = list._level;
  2467. while (node && level > 0) {
  2468. node = node.array[(rawIndex >>> level) & MASK];
  2469. level -= SHIFT;
  2470. }
  2471. return node;
  2472. }
  2473. }
  2474. function setListBounds(list, begin, end) {
  2475. // Sanitize begin & end using this shorthand for ToInt32(argument)
  2476. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  2477. if (begin !== undefined) {
  2478. begin = begin | 0;
  2479. }
  2480. if (end !== undefined) {
  2481. end = end | 0;
  2482. }
  2483. var owner = list.__ownerID || new OwnerID();
  2484. var oldOrigin = list._origin;
  2485. var oldCapacity = list._capacity;
  2486. var newOrigin = oldOrigin + begin;
  2487. var newCapacity =
  2488. end === undefined
  2489. ? oldCapacity
  2490. : end < 0
  2491. ? oldCapacity + end
  2492. : oldOrigin + end;
  2493. if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
  2494. return list;
  2495. }
  2496. // If it's going to end after it starts, it's empty.
  2497. if (newOrigin >= newCapacity) {
  2498. return list.clear();
  2499. }
  2500. var newLevel = list._level;
  2501. var newRoot = list._root;
  2502. // New origin might need creating a higher root.
  2503. var offsetShift = 0;
  2504. while (newOrigin + offsetShift < 0) {
  2505. newRoot = new VNode(
  2506. newRoot && newRoot.array.length ? [undefined, newRoot] : [],
  2507. owner
  2508. );
  2509. newLevel += SHIFT;
  2510. offsetShift += 1 << newLevel;
  2511. }
  2512. if (offsetShift) {
  2513. newOrigin += offsetShift;
  2514. oldOrigin += offsetShift;
  2515. newCapacity += offsetShift;
  2516. oldCapacity += offsetShift;
  2517. }
  2518. var oldTailOffset = getTailOffset(oldCapacity);
  2519. var newTailOffset = getTailOffset(newCapacity);
  2520. // New size might need creating a higher root.
  2521. while (newTailOffset >= 1 << (newLevel + SHIFT)) {
  2522. newRoot = new VNode(
  2523. newRoot && newRoot.array.length ? [newRoot] : [],
  2524. owner
  2525. );
  2526. newLevel += SHIFT;
  2527. }
  2528. // Locate or create the new tail.
  2529. var oldTail = list._tail;
  2530. var newTail =
  2531. newTailOffset < oldTailOffset
  2532. ? listNodeFor(list, newCapacity - 1)
  2533. : newTailOffset > oldTailOffset
  2534. ? new VNode([], owner)
  2535. : oldTail;
  2536. // Merge Tail into tree.
  2537. if (
  2538. oldTail &&
  2539. newTailOffset > oldTailOffset &&
  2540. newOrigin < oldCapacity &&
  2541. oldTail.array.length
  2542. ) {
  2543. newRoot = editableVNode(newRoot, owner);
  2544. var node = newRoot;
  2545. for (var level = newLevel; level > SHIFT; level -= SHIFT) {
  2546. var idx = (oldTailOffset >>> level) & MASK;
  2547. node = node.array[idx] = editableVNode(node.array[idx], owner);
  2548. }
  2549. node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
  2550. }
  2551. // If the size has been reduced, there's a chance the tail needs to be trimmed.
  2552. if (newCapacity < oldCapacity) {
  2553. newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
  2554. }
  2555. // If the new origin is within the tail, then we do not need a root.
  2556. if (newOrigin >= newTailOffset) {
  2557. newOrigin -= newTailOffset;
  2558. newCapacity -= newTailOffset;
  2559. newLevel = SHIFT;
  2560. newRoot = null;
  2561. newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
  2562. // Otherwise, if the root has been trimmed, garbage collect.
  2563. } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
  2564. offsetShift = 0;
  2565. // Identify the new top root node of the subtree of the old root.
  2566. while (newRoot) {
  2567. var beginIndex = (newOrigin >>> newLevel) & MASK;
  2568. if ((beginIndex !== newTailOffset >>> newLevel) & MASK) {
  2569. break;
  2570. }
  2571. if (beginIndex) {
  2572. offsetShift += (1 << newLevel) * beginIndex;
  2573. }
  2574. newLevel -= SHIFT;
  2575. newRoot = newRoot.array[beginIndex];
  2576. }
  2577. // Trim the new sides of the new root.
  2578. if (newRoot && newOrigin > oldOrigin) {
  2579. newRoot = newRoot.removeBefore(
  2580. owner,
  2581. newLevel,
  2582. newOrigin - offsetShift
  2583. );
  2584. }
  2585. if (newRoot && newTailOffset < oldTailOffset) {
  2586. newRoot = newRoot.removeAfter(
  2587. owner,
  2588. newLevel,
  2589. newTailOffset - offsetShift
  2590. );
  2591. }
  2592. if (offsetShift) {
  2593. newOrigin -= offsetShift;
  2594. newCapacity -= offsetShift;
  2595. }
  2596. }
  2597. if (list.__ownerID) {
  2598. list.size = newCapacity - newOrigin;
  2599. list._origin = newOrigin;
  2600. list._capacity = newCapacity;
  2601. list._level = newLevel;
  2602. list._root = newRoot;
  2603. list._tail = newTail;
  2604. list.__hash = undefined;
  2605. list.__altered = true;
  2606. return list;
  2607. }
  2608. return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
  2609. }
  2610. function mergeIntoListWith(list, merger, iterables) {
  2611. var iters = [];
  2612. var maxSize = 0;
  2613. for (var ii = 0; ii < iterables.length; ii++) {
  2614. var value = iterables[ii];
  2615. var iter = IndexedIterable(value);
  2616. if (iter.size > maxSize) {
  2617. maxSize = iter.size;
  2618. }
  2619. if (!isIterable(value)) {
  2620. iter = iter.map(function(v) {
  2621. return fromJS(v);
  2622. });
  2623. }
  2624. iters.push(iter);
  2625. }
  2626. if (maxSize > list.size) {
  2627. list = list.setSize(maxSize);
  2628. }
  2629. return mergeIntoCollectionWith(list, merger, iters);
  2630. }
  2631. function getTailOffset(size) {
  2632. return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT;
  2633. }
  2634. createClass(OrderedMap, Map);
  2635. // @pragma Construction
  2636. function OrderedMap(value) {
  2637. return value === null || value === undefined
  2638. ? emptyOrderedMap()
  2639. : isOrderedMap(value)
  2640. ? value
  2641. : emptyOrderedMap().withMutations(function(map) {
  2642. var iter = KeyedIterable(value);
  2643. assertNotInfinite(iter.size);
  2644. iter.forEach(function(v, k) {
  2645. return map.set(k, v);
  2646. });
  2647. });
  2648. }
  2649. OrderedMap.of = function(/*...values*/) {
  2650. return this(arguments);
  2651. };
  2652. OrderedMap.prototype.toString = function() {
  2653. return this.__toString("OrderedMap {", "}");
  2654. };
  2655. // @pragma Access
  2656. OrderedMap.prototype.get = function(k, notSetValue) {
  2657. var index = this._map.get(k);
  2658. return index !== undefined ? this._list.get(index)[1] : notSetValue;
  2659. };
  2660. // @pragma Modification
  2661. OrderedMap.prototype.clear = function() {
  2662. if (this.size === 0) {
  2663. return this;
  2664. }
  2665. if (this.__ownerID) {
  2666. this.size = 0;
  2667. this._map.clear();
  2668. this._list.clear();
  2669. return this;
  2670. }
  2671. return emptyOrderedMap();
  2672. };
  2673. OrderedMap.prototype.set = function(k, v) {
  2674. return updateOrderedMap(this, k, v);
  2675. };
  2676. OrderedMap.prototype.remove = function(k) {
  2677. return updateOrderedMap(this, k, NOT_SET);
  2678. };
  2679. OrderedMap.prototype.wasAltered = function() {
  2680. return this._map.wasAltered() || this._list.wasAltered();
  2681. };
  2682. OrderedMap.prototype.__iterate = function(fn, reverse) {
  2683. var this$0 = this;
  2684. return this._list.__iterate(function(entry) {
  2685. return entry && fn(entry[1], entry[0], this$0);
  2686. }, reverse);
  2687. };
  2688. OrderedMap.prototype.__iterator = function(type, reverse) {
  2689. return this._list.fromEntrySeq().__iterator(type, reverse);
  2690. };
  2691. OrderedMap.prototype.__ensureOwner = function(ownerID) {
  2692. if (ownerID === this.__ownerID) {
  2693. return this;
  2694. }
  2695. var newMap = this._map.__ensureOwner(ownerID);
  2696. var newList = this._list.__ensureOwner(ownerID);
  2697. if (!ownerID) {
  2698. this.__ownerID = ownerID;
  2699. this._map = newMap;
  2700. this._list = newList;
  2701. return this;
  2702. }
  2703. return makeOrderedMap(newMap, newList, ownerID, this.__hash);
  2704. };
  2705. function isOrderedMap(maybeOrderedMap) {
  2706. return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
  2707. }
  2708. OrderedMap.isOrderedMap = isOrderedMap;
  2709. OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
  2710. OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
  2711. function makeOrderedMap(map, list, ownerID, hash) {
  2712. var omap = Object.create(OrderedMap.prototype);
  2713. omap.size = map ? map.size : 0;
  2714. omap._map = map;
  2715. omap._list = list;
  2716. omap.__ownerID = ownerID;
  2717. omap.__hash = hash;
  2718. return omap;
  2719. }
  2720. var EMPTY_ORDERED_MAP;
  2721. function emptyOrderedMap() {
  2722. return (
  2723. EMPTY_ORDERED_MAP ||
  2724. (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()))
  2725. );
  2726. }
  2727. function updateOrderedMap(omap, k, v) {
  2728. var map = omap._map;
  2729. var list = omap._list;
  2730. var i = map.get(k);
  2731. var has = i !== undefined;
  2732. var newMap;
  2733. var newList;
  2734. if (v === NOT_SET) {
  2735. // removed
  2736. if (!has) {
  2737. return omap;
  2738. }
  2739. if (list.size >= SIZE && list.size >= map.size * 2) {
  2740. newList = list.filter(function(entry, idx) {
  2741. return entry !== undefined && i !== idx;
  2742. });
  2743. newMap = newList
  2744. .toKeyedSeq()
  2745. .map(function(entry) {
  2746. return entry[0];
  2747. })
  2748. .flip()
  2749. .toMap();
  2750. if (omap.__ownerID) {
  2751. newMap.__ownerID = newList.__ownerID = omap.__ownerID;
  2752. }
  2753. } else {
  2754. newMap = map.remove(k);
  2755. newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
  2756. }
  2757. } else {
  2758. if (has) {
  2759. if (v === list.get(i)[1]) {
  2760. return omap;
  2761. }
  2762. newMap = map;
  2763. newList = list.set(i, [k, v]);
  2764. } else {
  2765. newMap = map.set(k, list.size);
  2766. newList = list.set(list.size, [k, v]);
  2767. }
  2768. }
  2769. if (omap.__ownerID) {
  2770. omap.size = newMap.size;
  2771. omap._map = newMap;
  2772. omap._list = newList;
  2773. omap.__hash = undefined;
  2774. return omap;
  2775. }
  2776. return makeOrderedMap(newMap, newList);
  2777. }
  2778. createClass(ToKeyedSequence, KeyedSeq);
  2779. function ToKeyedSequence(indexed, useKeys) {
  2780. this._iter = indexed;
  2781. this._useKeys = useKeys;
  2782. this.size = indexed.size;
  2783. }
  2784. ToKeyedSequence.prototype.get = function(key, notSetValue) {
  2785. return this._iter.get(key, notSetValue);
  2786. };
  2787. ToKeyedSequence.prototype.has = function(key) {
  2788. return this._iter.has(key);
  2789. };
  2790. ToKeyedSequence.prototype.valueSeq = function() {
  2791. return this._iter.valueSeq();
  2792. };
  2793. ToKeyedSequence.prototype.reverse = function() {
  2794. var this$0 = this;
  2795. var reversedSequence = reverseFactory(this, true);
  2796. if (!this._useKeys) {
  2797. reversedSequence.valueSeq = function() {
  2798. return this$0._iter.toSeq().reverse();
  2799. };
  2800. }
  2801. return reversedSequence;
  2802. };
  2803. ToKeyedSequence.prototype.map = function(mapper, context) {
  2804. var this$0 = this;
  2805. var mappedSequence = mapFactory(this, mapper, context);
  2806. if (!this._useKeys) {
  2807. mappedSequence.valueSeq = function() {
  2808. return this$0._iter.toSeq().map(mapper, context);
  2809. };
  2810. }
  2811. return mappedSequence;
  2812. };
  2813. ToKeyedSequence.prototype.__iterate = function(fn, reverse) {
  2814. var this$0 = this;
  2815. var ii;
  2816. return this._iter.__iterate(
  2817. this._useKeys
  2818. ? function(v, k) {
  2819. return fn(v, k, this$0);
  2820. }
  2821. : ((ii = reverse ? resolveSize(this) : 0),
  2822. function(v) {
  2823. return fn(v, reverse ? --ii : ii++, this$0);
  2824. }),
  2825. reverse
  2826. );
  2827. };
  2828. ToKeyedSequence.prototype.__iterator = function(type, reverse) {
  2829. if (this._useKeys) {
  2830. return this._iter.__iterator(type, reverse);
  2831. }
  2832. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  2833. var ii = reverse ? resolveSize(this) : 0;
  2834. return new Iterator(function() {
  2835. var step = iterator.next();
  2836. return step.done
  2837. ? step
  2838. : iteratorValue(type, reverse ? --ii : ii++, step.value, step);
  2839. });
  2840. };
  2841. ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
  2842. createClass(ToIndexedSequence, IndexedSeq);
  2843. function ToIndexedSequence(iter) {
  2844. this._iter = iter;
  2845. this.size = iter.size;
  2846. }
  2847. ToIndexedSequence.prototype.includes = function(value) {
  2848. return this._iter.includes(value);
  2849. };
  2850. ToIndexedSequence.prototype.__iterate = function(fn, reverse) {
  2851. var this$0 = this;
  2852. var iterations = 0;
  2853. return this._iter.__iterate(function(v) {
  2854. return fn(v, iterations++, this$0);
  2855. }, reverse);
  2856. };
  2857. ToIndexedSequence.prototype.__iterator = function(type, reverse) {
  2858. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  2859. var iterations = 0;
  2860. return new Iterator(function() {
  2861. var step = iterator.next();
  2862. return step.done
  2863. ? step
  2864. : iteratorValue(type, iterations++, step.value, step);
  2865. });
  2866. };
  2867. createClass(ToSetSequence, SetSeq);
  2868. function ToSetSequence(iter) {
  2869. this._iter = iter;
  2870. this.size = iter.size;
  2871. }
  2872. ToSetSequence.prototype.has = function(key) {
  2873. return this._iter.includes(key);
  2874. };
  2875. ToSetSequence.prototype.__iterate = function(fn, reverse) {
  2876. var this$0 = this;
  2877. return this._iter.__iterate(function(v) {
  2878. return fn(v, v, this$0);
  2879. }, reverse);
  2880. };
  2881. ToSetSequence.prototype.__iterator = function(type, reverse) {
  2882. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  2883. return new Iterator(function() {
  2884. var step = iterator.next();
  2885. return step.done
  2886. ? step
  2887. : iteratorValue(type, step.value, step.value, step);
  2888. });
  2889. };
  2890. createClass(FromEntriesSequence, KeyedSeq);
  2891. function FromEntriesSequence(entries) {
  2892. this._iter = entries;
  2893. this.size = entries.size;
  2894. }
  2895. FromEntriesSequence.prototype.entrySeq = function() {
  2896. return this._iter.toSeq();
  2897. };
  2898. FromEntriesSequence.prototype.__iterate = function(fn, reverse) {
  2899. var this$0 = this;
  2900. return this._iter.__iterate(function(entry) {
  2901. // Check if entry exists first so array access doesn't throw for holes
  2902. // in the parent iteration.
  2903. if (entry) {
  2904. validateEntry(entry);
  2905. var indexedIterable = isIterable(entry);
  2906. return fn(
  2907. indexedIterable ? entry.get(1) : entry[1],
  2908. indexedIterable ? entry.get(0) : entry[0],
  2909. this$0
  2910. );
  2911. }
  2912. }, reverse);
  2913. };
  2914. FromEntriesSequence.prototype.__iterator = function(type, reverse) {
  2915. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  2916. return new Iterator(function() {
  2917. while (true) {
  2918. var step = iterator.next();
  2919. if (step.done) {
  2920. return step;
  2921. }
  2922. var entry = step.value;
  2923. // Check if entry exists first so array access doesn't throw for holes
  2924. // in the parent iteration.
  2925. if (entry) {
  2926. validateEntry(entry);
  2927. var indexedIterable = isIterable(entry);
  2928. return iteratorValue(
  2929. type,
  2930. indexedIterable ? entry.get(0) : entry[0],
  2931. indexedIterable ? entry.get(1) : entry[1],
  2932. step
  2933. );
  2934. }
  2935. }
  2936. });
  2937. };
  2938. ToIndexedSequence.prototype.cacheResult = ToKeyedSequence.prototype.cacheResult = ToSetSequence.prototype.cacheResult = FromEntriesSequence.prototype.cacheResult = cacheResultThrough;
  2939. function flipFactory(iterable) {
  2940. var flipSequence = makeSequence(iterable);
  2941. flipSequence._iter = iterable;
  2942. flipSequence.size = iterable.size;
  2943. flipSequence.flip = function() {
  2944. return iterable;
  2945. };
  2946. flipSequence.reverse = function() {
  2947. var reversedSequence = iterable.reverse.apply(this); // super.reverse()
  2948. reversedSequence.flip = function() {
  2949. return iterable.reverse();
  2950. };
  2951. return reversedSequence;
  2952. };
  2953. flipSequence.has = function(key) {
  2954. return iterable.includes(key);
  2955. };
  2956. flipSequence.includes = function(key) {
  2957. return iterable.has(key);
  2958. };
  2959. flipSequence.cacheResult = cacheResultThrough;
  2960. flipSequence.__iterateUncached = function(fn, reverse) {
  2961. var this$0 = this;
  2962. return iterable.__iterate(function(v, k) {
  2963. return fn(k, v, this$0) !== false;
  2964. }, reverse);
  2965. };
  2966. flipSequence.__iteratorUncached = function(type, reverse) {
  2967. if (type === ITERATE_ENTRIES) {
  2968. var iterator = iterable.__iterator(type, reverse);
  2969. return new Iterator(function() {
  2970. var step = iterator.next();
  2971. if (!step.done) {
  2972. var k = step.value[0];
  2973. step.value[0] = step.value[1];
  2974. step.value[1] = k;
  2975. }
  2976. return step;
  2977. });
  2978. }
  2979. return iterable.__iterator(
  2980. type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
  2981. reverse
  2982. );
  2983. };
  2984. return flipSequence;
  2985. }
  2986. function mapFactory(iterable, mapper, context) {
  2987. var mappedSequence = makeSequence(iterable);
  2988. mappedSequence.size = iterable.size;
  2989. mappedSequence.has = function(key) {
  2990. return iterable.has(key);
  2991. };
  2992. mappedSequence.get = function(key, notSetValue) {
  2993. var v = iterable.get(key, NOT_SET);
  2994. return v === NOT_SET
  2995. ? notSetValue
  2996. : mapper.call(context, v, key, iterable);
  2997. };
  2998. mappedSequence.__iterateUncached = function(fn, reverse) {
  2999. var this$0 = this;
  3000. return iterable.__iterate(function(v, k, c) {
  3001. return fn(mapper.call(context, v, k, c), k, this$0) !== false;
  3002. }, reverse);
  3003. };
  3004. mappedSequence.__iteratorUncached = function(type, reverse) {
  3005. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  3006. return new Iterator(function() {
  3007. var step = iterator.next();
  3008. if (step.done) {
  3009. return step;
  3010. }
  3011. var entry = step.value;
  3012. var key = entry[0];
  3013. return iteratorValue(
  3014. type,
  3015. key,
  3016. mapper.call(context, entry[1], key, iterable),
  3017. step
  3018. );
  3019. });
  3020. };
  3021. return mappedSequence;
  3022. }
  3023. function reverseFactory(iterable, useKeys) {
  3024. var reversedSequence = makeSequence(iterable);
  3025. reversedSequence._iter = iterable;
  3026. reversedSequence.size = iterable.size;
  3027. reversedSequence.reverse = function() {
  3028. return iterable;
  3029. };
  3030. if (iterable.flip) {
  3031. reversedSequence.flip = function() {
  3032. var flipSequence = flipFactory(iterable);
  3033. flipSequence.reverse = function() {
  3034. return iterable.flip();
  3035. };
  3036. return flipSequence;
  3037. };
  3038. }
  3039. reversedSequence.get = function(key, notSetValue) {
  3040. return iterable.get(useKeys ? key : -1 - key, notSetValue);
  3041. };
  3042. reversedSequence.has = function(key) {
  3043. return iterable.has(useKeys ? key : -1 - key);
  3044. };
  3045. reversedSequence.includes = function(value) {
  3046. return iterable.includes(value);
  3047. };
  3048. reversedSequence.cacheResult = cacheResultThrough;
  3049. reversedSequence.__iterate = function(fn, reverse) {
  3050. var this$0 = this;
  3051. return iterable.__iterate(function(v, k) {
  3052. return fn(v, k, this$0);
  3053. }, !reverse);
  3054. };
  3055. reversedSequence.__iterator = function(type, reverse) {
  3056. return iterable.__iterator(type, !reverse);
  3057. };
  3058. return reversedSequence;
  3059. }
  3060. function filterFactory(iterable, predicate, context, useKeys) {
  3061. var filterSequence = makeSequence(iterable);
  3062. if (useKeys) {
  3063. filterSequence.has = function(key) {
  3064. var v = iterable.get(key, NOT_SET);
  3065. return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
  3066. };
  3067. filterSequence.get = function(key, notSetValue) {
  3068. var v = iterable.get(key, NOT_SET);
  3069. return v !== NOT_SET && predicate.call(context, v, key, iterable)
  3070. ? v
  3071. : notSetValue;
  3072. };
  3073. }
  3074. filterSequence.__iterateUncached = function(fn, reverse) {
  3075. var this$0 = this;
  3076. var iterations = 0;
  3077. iterable.__iterate(function(v, k, c) {
  3078. if (predicate.call(context, v, k, c)) {
  3079. iterations++;
  3080. return fn(v, useKeys ? k : iterations - 1, this$0);
  3081. }
  3082. }, reverse);
  3083. return iterations;
  3084. };
  3085. filterSequence.__iteratorUncached = function(type, reverse) {
  3086. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  3087. var iterations = 0;
  3088. return new Iterator(function() {
  3089. while (true) {
  3090. var step = iterator.next();
  3091. if (step.done) {
  3092. return step;
  3093. }
  3094. var entry = step.value;
  3095. var key = entry[0];
  3096. var value = entry[1];
  3097. if (predicate.call(context, value, key, iterable)) {
  3098. return iteratorValue(
  3099. type,
  3100. useKeys ? key : iterations++,
  3101. value,
  3102. step
  3103. );
  3104. }
  3105. }
  3106. });
  3107. };
  3108. return filterSequence;
  3109. }
  3110. function countByFactory(iterable, grouper, context) {
  3111. var groups = Map().asMutable();
  3112. iterable.__iterate(function(v, k) {
  3113. groups.update(grouper.call(context, v, k, iterable), 0, function(a) {
  3114. return a + 1;
  3115. });
  3116. });
  3117. return groups.asImmutable();
  3118. }
  3119. function groupByFactory(iterable, grouper, context) {
  3120. var isKeyedIter = isKeyed(iterable);
  3121. var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
  3122. iterable.__iterate(function(v, k) {
  3123. groups.update(grouper.call(context, v, k, iterable), function(a) {
  3124. return (a = a || []), a.push(isKeyedIter ? [k, v] : v), a;
  3125. });
  3126. });
  3127. var coerce = iterableClass(iterable);
  3128. return groups.map(function(arr) {
  3129. return reify(iterable, coerce(arr));
  3130. });
  3131. }
  3132. function sliceFactory(iterable, begin, end, useKeys) {
  3133. var originalSize = iterable.size;
  3134. // Sanitize begin & end using this shorthand for ToInt32(argument)
  3135. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  3136. if (begin !== undefined) {
  3137. begin = begin | 0;
  3138. }
  3139. if (end !== undefined) {
  3140. end = end | 0;
  3141. }
  3142. if (wholeSlice(begin, end, originalSize)) {
  3143. return iterable;
  3144. }
  3145. var resolvedBegin = resolveBegin(begin, originalSize);
  3146. var resolvedEnd = resolveEnd(end, originalSize);
  3147. // begin or end will be NaN if they were provided as negative numbers and
  3148. // this iterable's size is unknown. In that case, cache first so there is
  3149. // a known size and these do not resolve to NaN.
  3150. if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
  3151. return sliceFactory(
  3152. iterable.toSeq().cacheResult(),
  3153. begin,
  3154. end,
  3155. useKeys
  3156. );
  3157. }
  3158. // Note: resolvedEnd is undefined when the original sequence's length is
  3159. // unknown and this slice did not supply an end and should contain all
  3160. // elements after resolvedBegin.
  3161. // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
  3162. var resolvedSize = resolvedEnd - resolvedBegin;
  3163. var sliceSize;
  3164. if (resolvedSize === resolvedSize) {
  3165. sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
  3166. }
  3167. var sliceSeq = makeSequence(iterable);
  3168. // If iterable.size is undefined, the size of the realized sliceSeq is
  3169. // unknown at this point unless the number of items to slice is 0
  3170. sliceSeq.size =
  3171. sliceSize === 0 ? sliceSize : (iterable.size && sliceSize) || undefined;
  3172. if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
  3173. sliceSeq.get = function(index, notSetValue) {
  3174. index = wrapIndex(this, index);
  3175. return index >= 0 && index < sliceSize
  3176. ? iterable.get(index + resolvedBegin, notSetValue)
  3177. : notSetValue;
  3178. };
  3179. }
  3180. sliceSeq.__iterateUncached = function(fn, reverse) {
  3181. var this$0 = this;
  3182. if (sliceSize === 0) {
  3183. return 0;
  3184. }
  3185. if (reverse) {
  3186. return this.cacheResult().__iterate(fn, reverse);
  3187. }
  3188. var skipped = 0;
  3189. var isSkipping = true;
  3190. var iterations = 0;
  3191. iterable.__iterate(function(v, k) {
  3192. if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
  3193. iterations++;
  3194. return (
  3195. fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
  3196. iterations !== sliceSize
  3197. );
  3198. }
  3199. });
  3200. return iterations;
  3201. };
  3202. sliceSeq.__iteratorUncached = function(type, reverse) {
  3203. if (sliceSize !== 0 && reverse) {
  3204. return this.cacheResult().__iterator(type, reverse);
  3205. }
  3206. // Don't bother instantiating parent iterator if taking 0.
  3207. var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
  3208. var skipped = 0;
  3209. var iterations = 0;
  3210. return new Iterator(function() {
  3211. while (skipped++ < resolvedBegin) {
  3212. iterator.next();
  3213. }
  3214. if (++iterations > sliceSize) {
  3215. return iteratorDone();
  3216. }
  3217. var step = iterator.next();
  3218. if (useKeys || type === ITERATE_VALUES) {
  3219. return step;
  3220. } else if (type === ITERATE_KEYS) {
  3221. return iteratorValue(type, iterations - 1, undefined, step);
  3222. } else {
  3223. return iteratorValue(type, iterations - 1, step.value[1], step);
  3224. }
  3225. });
  3226. };
  3227. return sliceSeq;
  3228. }
  3229. function takeWhileFactory(iterable, predicate, context) {
  3230. var takeSequence = makeSequence(iterable);
  3231. takeSequence.__iterateUncached = function(fn, reverse) {
  3232. var this$0 = this;
  3233. if (reverse) {
  3234. return this.cacheResult().__iterate(fn, reverse);
  3235. }
  3236. var iterations = 0;
  3237. iterable.__iterate(function(v, k, c) {
  3238. return (
  3239. predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)
  3240. );
  3241. });
  3242. return iterations;
  3243. };
  3244. takeSequence.__iteratorUncached = function(type, reverse) {
  3245. var this$0 = this;
  3246. if (reverse) {
  3247. return this.cacheResult().__iterator(type, reverse);
  3248. }
  3249. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  3250. var iterating = true;
  3251. return new Iterator(function() {
  3252. if (!iterating) {
  3253. return iteratorDone();
  3254. }
  3255. var step = iterator.next();
  3256. if (step.done) {
  3257. return step;
  3258. }
  3259. var entry = step.value;
  3260. var k = entry[0];
  3261. var v = entry[1];
  3262. if (!predicate.call(context, v, k, this$0)) {
  3263. iterating = false;
  3264. return iteratorDone();
  3265. }
  3266. return type === ITERATE_ENTRIES
  3267. ? step
  3268. : iteratorValue(type, k, v, step);
  3269. });
  3270. };
  3271. return takeSequence;
  3272. }
  3273. function skipWhileFactory(iterable, predicate, context, useKeys) {
  3274. var skipSequence = makeSequence(iterable);
  3275. skipSequence.__iterateUncached = function(fn, reverse) {
  3276. var this$0 = this;
  3277. if (reverse) {
  3278. return this.cacheResult().__iterate(fn, reverse);
  3279. }
  3280. var isSkipping = true;
  3281. var iterations = 0;
  3282. iterable.__iterate(function(v, k, c) {
  3283. if (
  3284. !(isSkipping && (isSkipping = predicate.call(context, v, k, c)))
  3285. ) {
  3286. iterations++;
  3287. return fn(v, useKeys ? k : iterations - 1, this$0);
  3288. }
  3289. });
  3290. return iterations;
  3291. };
  3292. skipSequence.__iteratorUncached = function(type, reverse) {
  3293. var this$0 = this;
  3294. if (reverse) {
  3295. return this.cacheResult().__iterator(type, reverse);
  3296. }
  3297. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  3298. var skipping = true;
  3299. var iterations = 0;
  3300. return new Iterator(function() {
  3301. var step, k, v;
  3302. do {
  3303. step = iterator.next();
  3304. if (step.done) {
  3305. if (useKeys || type === ITERATE_VALUES) {
  3306. return step;
  3307. } else if (type === ITERATE_KEYS) {
  3308. return iteratorValue(type, iterations++, undefined, step);
  3309. } else {
  3310. return iteratorValue(type, iterations++, step.value[1], step);
  3311. }
  3312. }
  3313. var entry = step.value;
  3314. k = entry[0];
  3315. v = entry[1];
  3316. skipping && (skipping = predicate.call(context, v, k, this$0));
  3317. } while (skipping);
  3318. return type === ITERATE_ENTRIES
  3319. ? step
  3320. : iteratorValue(type, k, v, step);
  3321. });
  3322. };
  3323. return skipSequence;
  3324. }
  3325. function concatFactory(iterable, values) {
  3326. var isKeyedIterable = isKeyed(iterable);
  3327. var iters = [iterable]
  3328. .concat(values)
  3329. .map(function(v) {
  3330. if (!isIterable(v)) {
  3331. v = isKeyedIterable
  3332. ? keyedSeqFromValue(v)
  3333. : indexedSeqFromValue(Array.isArray(v) ? v : [v]);
  3334. } else if (isKeyedIterable) {
  3335. v = KeyedIterable(v);
  3336. }
  3337. return v;
  3338. })
  3339. .filter(function(v) {
  3340. return v.size !== 0;
  3341. });
  3342. if (iters.length === 0) {
  3343. return iterable;
  3344. }
  3345. if (iters.length === 1) {
  3346. var singleton = iters[0];
  3347. if (
  3348. singleton === iterable ||
  3349. (isKeyedIterable && isKeyed(singleton)) ||
  3350. (isIndexed(iterable) && isIndexed(singleton))
  3351. ) {
  3352. return singleton;
  3353. }
  3354. }
  3355. var concatSeq = new ArraySeq(iters);
  3356. if (isKeyedIterable) {
  3357. concatSeq = concatSeq.toKeyedSeq();
  3358. } else if (!isIndexed(iterable)) {
  3359. concatSeq = concatSeq.toSetSeq();
  3360. }
  3361. concatSeq = concatSeq.flatten(true);
  3362. concatSeq.size = iters.reduce(function(sum, seq) {
  3363. if (sum !== undefined) {
  3364. var size = seq.size;
  3365. if (size !== undefined) {
  3366. return sum + size;
  3367. }
  3368. }
  3369. }, 0);
  3370. return concatSeq;
  3371. }
  3372. function flattenFactory(iterable, depth, useKeys) {
  3373. var flatSequence = makeSequence(iterable);
  3374. flatSequence.__iterateUncached = function(fn, reverse) {
  3375. var iterations = 0;
  3376. var stopped = false;
  3377. function flatDeep(iter, currentDepth) {
  3378. var this$0 = this;
  3379. iter.__iterate(function(v, k) {
  3380. if ((!depth || currentDepth < depth) && isIterable(v)) {
  3381. flatDeep(v, currentDepth + 1);
  3382. } else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
  3383. stopped = true;
  3384. }
  3385. return !stopped;
  3386. }, reverse);
  3387. }
  3388. flatDeep(iterable, 0);
  3389. return iterations;
  3390. };
  3391. flatSequence.__iteratorUncached = function(type, reverse) {
  3392. var iterator = iterable.__iterator(type, reverse);
  3393. var stack = [];
  3394. var iterations = 0;
  3395. return new Iterator(function() {
  3396. while (iterator) {
  3397. var step = iterator.next();
  3398. if (step.done !== false) {
  3399. iterator = stack.pop();
  3400. continue;
  3401. }
  3402. var v = step.value;
  3403. if (type === ITERATE_ENTRIES) {
  3404. v = v[1];
  3405. }
  3406. if ((!depth || stack.length < depth) && isIterable(v)) {
  3407. stack.push(iterator);
  3408. iterator = v.__iterator(type, reverse);
  3409. } else {
  3410. return useKeys
  3411. ? step
  3412. : iteratorValue(type, iterations++, v, step);
  3413. }
  3414. }
  3415. return iteratorDone();
  3416. });
  3417. };
  3418. return flatSequence;
  3419. }
  3420. function flatMapFactory(iterable, mapper, context) {
  3421. var coerce = iterableClass(iterable);
  3422. return iterable
  3423. .toSeq()
  3424. .map(function(v, k) {
  3425. return coerce(mapper.call(context, v, k, iterable));
  3426. })
  3427. .flatten(true);
  3428. }
  3429. function interposeFactory(iterable, separator) {
  3430. var interposedSequence = makeSequence(iterable);
  3431. interposedSequence.size = iterable.size && iterable.size * 2 - 1;
  3432. interposedSequence.__iterateUncached = function(fn, reverse) {
  3433. var this$0 = this;
  3434. var iterations = 0;
  3435. iterable.__iterate(function(v, k) {
  3436. return (
  3437. (!iterations || fn(separator, iterations++, this$0) !== false) &&
  3438. fn(v, iterations++, this$0) !== false
  3439. );
  3440. }, reverse);
  3441. return iterations;
  3442. };
  3443. interposedSequence.__iteratorUncached = function(type, reverse) {
  3444. var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
  3445. var iterations = 0;
  3446. var step;
  3447. return new Iterator(function() {
  3448. if (!step || iterations % 2) {
  3449. step = iterator.next();
  3450. if (step.done) {
  3451. return step;
  3452. }
  3453. }
  3454. return iterations % 2
  3455. ? iteratorValue(type, iterations++, separator)
  3456. : iteratorValue(type, iterations++, step.value, step);
  3457. });
  3458. };
  3459. return interposedSequence;
  3460. }
  3461. function sortFactory(iterable, comparator, mapper) {
  3462. if (!comparator) {
  3463. comparator = defaultComparator;
  3464. }
  3465. var isKeyedIterable = isKeyed(iterable);
  3466. var index = 0;
  3467. var entries = iterable
  3468. .toSeq()
  3469. .map(function(v, k) {
  3470. return [k, v, index++, mapper ? mapper(v, k, iterable) : v];
  3471. })
  3472. .toArray();
  3473. entries
  3474. .sort(function(a, b) {
  3475. return comparator(a[3], b[3]) || a[2] - b[2];
  3476. })
  3477. .forEach(
  3478. isKeyedIterable
  3479. ? function(v, i) {
  3480. entries[i].length = 2;
  3481. }
  3482. : function(v, i) {
  3483. entries[i] = v[1];
  3484. }
  3485. );
  3486. return isKeyedIterable
  3487. ? KeyedSeq(entries)
  3488. : isIndexed(iterable)
  3489. ? IndexedSeq(entries)
  3490. : SetSeq(entries);
  3491. }
  3492. function maxFactory(iterable, comparator, mapper) {
  3493. if (!comparator) {
  3494. comparator = defaultComparator;
  3495. }
  3496. if (mapper) {
  3497. var entry = iterable
  3498. .toSeq()
  3499. .map(function(v, k) {
  3500. return [v, mapper(v, k, iterable)];
  3501. })
  3502. .reduce(function(a, b) {
  3503. return maxCompare(comparator, a[1], b[1]) ? b : a;
  3504. });
  3505. return entry && entry[0];
  3506. } else {
  3507. return iterable.reduce(function(a, b) {
  3508. return maxCompare(comparator, a, b) ? b : a;
  3509. });
  3510. }
  3511. }
  3512. function maxCompare(comparator, a, b) {
  3513. var comp = comparator(b, a);
  3514. // b is considered the new max if the comparator declares them equal, but
  3515. // they are not equal and b is in fact a nullish value.
  3516. return (
  3517. (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) ||
  3518. comp > 0
  3519. );
  3520. }
  3521. function zipWithFactory(keyIter, zipper, iters) {
  3522. var zipSequence = makeSequence(keyIter);
  3523. zipSequence.size = new ArraySeq(iters)
  3524. .map(function(i) {
  3525. return i.size;
  3526. })
  3527. .min();
  3528. // Note: this a generic base implementation of __iterate in terms of
  3529. // __iterator which may be more generically useful in the future.
  3530. zipSequence.__iterate = function(fn, reverse) {
  3531. /* generic:
  3532. var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
  3533. var step;
  3534. var iterations = 0;
  3535. while (!(step = iterator.next()).done) {
  3536. iterations++;
  3537. if (fn(step.value[1], step.value[0], this) === false) {
  3538. break;
  3539. }
  3540. }
  3541. return iterations;
  3542. */
  3543. // indexed:
  3544. var iterator = this.__iterator(ITERATE_VALUES, reverse);
  3545. var step;
  3546. var iterations = 0;
  3547. while (!(step = iterator.next()).done) {
  3548. if (fn(step.value, iterations++, this) === false) {
  3549. break;
  3550. }
  3551. }
  3552. return iterations;
  3553. };
  3554. zipSequence.__iteratorUncached = function(type, reverse) {
  3555. var iterators = iters.map(function(i) {
  3556. return (i = Iterable(i)), getIterator(reverse ? i.reverse() : i);
  3557. });
  3558. var iterations = 0;
  3559. var isDone = false;
  3560. return new Iterator(function() {
  3561. var steps;
  3562. if (!isDone) {
  3563. steps = iterators.map(function(i) {
  3564. return i.next();
  3565. });
  3566. isDone = steps.some(function(s) {
  3567. return s.done;
  3568. });
  3569. }
  3570. if (isDone) {
  3571. return iteratorDone();
  3572. }
  3573. return iteratorValue(
  3574. type,
  3575. iterations++,
  3576. zipper.apply(
  3577. null,
  3578. steps.map(function(s) {
  3579. return s.value;
  3580. })
  3581. )
  3582. );
  3583. });
  3584. };
  3585. return zipSequence;
  3586. }
  3587. // #pragma Helper Functions
  3588. function reify(iter, seq) {
  3589. return isSeq(iter) ? seq : iter.constructor(seq);
  3590. }
  3591. function validateEntry(entry) {
  3592. if (entry !== Object(entry)) {
  3593. throw new TypeError("Expected [K, V] tuple: " + entry);
  3594. }
  3595. }
  3596. function resolveSize(iter) {
  3597. assertNotInfinite(iter.size);
  3598. return ensureSize(iter);
  3599. }
  3600. function iterableClass(iterable) {
  3601. return isKeyed(iterable)
  3602. ? KeyedIterable
  3603. : isIndexed(iterable)
  3604. ? IndexedIterable
  3605. : SetIterable;
  3606. }
  3607. function makeSequence(iterable) {
  3608. return Object.create(
  3609. (isKeyed(iterable)
  3610. ? KeyedSeq
  3611. : isIndexed(iterable)
  3612. ? IndexedSeq
  3613. : SetSeq
  3614. ).prototype
  3615. );
  3616. }
  3617. function cacheResultThrough() {
  3618. if (this._iter.cacheResult) {
  3619. this._iter.cacheResult();
  3620. this.size = this._iter.size;
  3621. return this;
  3622. } else {
  3623. return Seq.prototype.cacheResult.call(this);
  3624. }
  3625. }
  3626. function defaultComparator(a, b) {
  3627. return a > b ? 1 : a < b ? -1 : 0;
  3628. }
  3629. function forceIterator(keyPath) {
  3630. var iter = getIterator(keyPath);
  3631. if (!iter) {
  3632. // Array might not be iterable in this environment, so we need a fallback
  3633. // to our wrapped type.
  3634. if (!isArrayLike(keyPath)) {
  3635. throw new TypeError("Expected iterable or array-like: " + keyPath);
  3636. }
  3637. iter = getIterator(Iterable(keyPath));
  3638. }
  3639. return iter;
  3640. }
  3641. createClass(Record, KeyedCollection);
  3642. function Record(defaultValues, name) {
  3643. var hasInitialized;
  3644. var RecordType = function Record(values) {
  3645. if (values instanceof RecordType) {
  3646. return values;
  3647. }
  3648. if (!(this instanceof RecordType)) {
  3649. return new RecordType(values);
  3650. }
  3651. if (!hasInitialized) {
  3652. hasInitialized = true;
  3653. var keys = Object.keys(defaultValues);
  3654. setProps(RecordTypePrototype, keys);
  3655. RecordTypePrototype.size = keys.length;
  3656. RecordTypePrototype._name = name;
  3657. RecordTypePrototype._keys = keys;
  3658. RecordTypePrototype._defaultValues = defaultValues;
  3659. }
  3660. this._map = Map(values);
  3661. };
  3662. var RecordTypePrototype = (RecordType.prototype = Object.create(
  3663. RecordPrototype
  3664. ));
  3665. RecordTypePrototype.constructor = RecordType;
  3666. return RecordType;
  3667. }
  3668. Record.prototype.toString = function() {
  3669. return this.__toString(recordName(this) + " {", "}");
  3670. };
  3671. // @pragma Access
  3672. Record.prototype.has = function(k) {
  3673. return this._defaultValues.hasOwnProperty(k);
  3674. };
  3675. Record.prototype.get = function(k, notSetValue) {
  3676. if (!this.has(k)) {
  3677. return notSetValue;
  3678. }
  3679. var defaultVal = this._defaultValues[k];
  3680. return this._map ? this._map.get(k, defaultVal) : defaultVal;
  3681. };
  3682. // @pragma Modification
  3683. Record.prototype.clear = function() {
  3684. if (this.__ownerID) {
  3685. this._map && this._map.clear();
  3686. return this;
  3687. }
  3688. var RecordType = this.constructor;
  3689. return (
  3690. RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()))
  3691. );
  3692. };
  3693. Record.prototype.set = function(k, v) {
  3694. if (!this.has(k)) {
  3695. throw new Error(
  3696. 'Cannot set unknown key "' + k + '" on ' + recordName(this)
  3697. );
  3698. }
  3699. var newMap = this._map && this._map.set(k, v);
  3700. if (this.__ownerID || newMap === this._map) {
  3701. return this;
  3702. }
  3703. return makeRecord(this, newMap);
  3704. };
  3705. Record.prototype.remove = function(k) {
  3706. if (!this.has(k)) {
  3707. return this;
  3708. }
  3709. var newMap = this._map && this._map.remove(k);
  3710. if (this.__ownerID || newMap === this._map) {
  3711. return this;
  3712. }
  3713. return makeRecord(this, newMap);
  3714. };
  3715. Record.prototype.wasAltered = function() {
  3716. return this._map.wasAltered();
  3717. };
  3718. Record.prototype.__iterator = function(type, reverse) {
  3719. var this$0 = this;
  3720. return KeyedIterable(this._defaultValues)
  3721. .map(function(_, k) {
  3722. return this$0.get(k);
  3723. })
  3724. .__iterator(type, reverse);
  3725. };
  3726. Record.prototype.__iterate = function(fn, reverse) {
  3727. var this$0 = this;
  3728. return KeyedIterable(this._defaultValues)
  3729. .map(function(_, k) {
  3730. return this$0.get(k);
  3731. })
  3732. .__iterate(fn, reverse);
  3733. };
  3734. Record.prototype.__ensureOwner = function(ownerID) {
  3735. if (ownerID === this.__ownerID) {
  3736. return this;
  3737. }
  3738. var newMap = this._map && this._map.__ensureOwner(ownerID);
  3739. if (!ownerID) {
  3740. this.__ownerID = ownerID;
  3741. this._map = newMap;
  3742. return this;
  3743. }
  3744. return makeRecord(this, newMap, ownerID);
  3745. };
  3746. var RecordPrototype = Record.prototype;
  3747. RecordPrototype[DELETE] = RecordPrototype.remove;
  3748. RecordPrototype.deleteIn = RecordPrototype.removeIn = MapPrototype.removeIn;
  3749. RecordPrototype.merge = MapPrototype.merge;
  3750. RecordPrototype.mergeWith = MapPrototype.mergeWith;
  3751. RecordPrototype.mergeIn = MapPrototype.mergeIn;
  3752. RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
  3753. RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
  3754. RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  3755. RecordPrototype.setIn = MapPrototype.setIn;
  3756. RecordPrototype.update = MapPrototype.update;
  3757. RecordPrototype.updateIn = MapPrototype.updateIn;
  3758. RecordPrototype.withMutations = MapPrototype.withMutations;
  3759. RecordPrototype.asMutable = MapPrototype.asMutable;
  3760. RecordPrototype.asImmutable = MapPrototype.asImmutable;
  3761. function makeRecord(likeRecord, map, ownerID) {
  3762. var record = Object.create(Object.getPrototypeOf(likeRecord));
  3763. record._map = map;
  3764. record.__ownerID = ownerID;
  3765. return record;
  3766. }
  3767. function recordName(record) {
  3768. return record._name || record.constructor.name || "Record";
  3769. }
  3770. function setProps(prototype, names) {
  3771. try {
  3772. names.forEach(setProp.bind(undefined, prototype));
  3773. } catch (error) {
  3774. // Object.defineProperty failed. Probably IE8.
  3775. }
  3776. }
  3777. function setProp(prototype, name) {
  3778. Object.defineProperty(prototype, name, {
  3779. get: function() {
  3780. return this.get(name);
  3781. },
  3782. set: function(value) {
  3783. invariant(this.__ownerID, "Cannot set on an immutable record.");
  3784. this.set(name, value);
  3785. }
  3786. });
  3787. }
  3788. createClass(Set, SetCollection);
  3789. // @pragma Construction
  3790. function Set(value) {
  3791. return value === null || value === undefined
  3792. ? emptySet()
  3793. : isSet(value) && !isOrdered(value)
  3794. ? value
  3795. : emptySet().withMutations(function(set) {
  3796. var iter = SetIterable(value);
  3797. assertNotInfinite(iter.size);
  3798. iter.forEach(function(v) {
  3799. return set.add(v);
  3800. });
  3801. });
  3802. }
  3803. Set.of = function(/*...values*/) {
  3804. return this(arguments);
  3805. };
  3806. Set.fromKeys = function(value) {
  3807. return this(KeyedIterable(value).keySeq());
  3808. };
  3809. Set.prototype.toString = function() {
  3810. return this.__toString("Set {", "}");
  3811. };
  3812. // @pragma Access
  3813. Set.prototype.has = function(value) {
  3814. return this._map.has(value);
  3815. };
  3816. // @pragma Modification
  3817. Set.prototype.add = function(value) {
  3818. return updateSet(this, this._map.set(value, true));
  3819. };
  3820. Set.prototype.remove = function(value) {
  3821. return updateSet(this, this._map.remove(value));
  3822. };
  3823. Set.prototype.clear = function() {
  3824. return updateSet(this, this._map.clear());
  3825. };
  3826. // @pragma Composition
  3827. Set.prototype.union = function() {
  3828. var iters = SLICE$0.call(arguments, 0);
  3829. iters = iters.filter(function(x) {
  3830. return x.size !== 0;
  3831. });
  3832. if (iters.length === 0) {
  3833. return this;
  3834. }
  3835. if (this.size === 0 && !this.__ownerID && iters.length === 1) {
  3836. return this.constructor(iters[0]);
  3837. }
  3838. return this.withMutations(function(set) {
  3839. for (var ii = 0; ii < iters.length; ii++) {
  3840. SetIterable(iters[ii]).forEach(function(value) {
  3841. return set.add(value);
  3842. });
  3843. }
  3844. });
  3845. };
  3846. Set.prototype.intersect = function() {
  3847. var iters = SLICE$0.call(arguments, 0);
  3848. if (iters.length === 0) {
  3849. return this;
  3850. }
  3851. iters = iters.map(function(iter) {
  3852. return SetIterable(iter);
  3853. });
  3854. var originalSet = this;
  3855. return this.withMutations(function(set) {
  3856. originalSet.forEach(function(value) {
  3857. if (
  3858. !iters.every(function(iter) {
  3859. return iter.includes(value);
  3860. })
  3861. ) {
  3862. set.remove(value);
  3863. }
  3864. });
  3865. });
  3866. };
  3867. Set.prototype.subtract = function() {
  3868. var iters = SLICE$0.call(arguments, 0);
  3869. if (iters.length === 0) {
  3870. return this;
  3871. }
  3872. iters = iters.map(function(iter) {
  3873. return SetIterable(iter);
  3874. });
  3875. var originalSet = this;
  3876. return this.withMutations(function(set) {
  3877. originalSet.forEach(function(value) {
  3878. if (
  3879. iters.some(function(iter) {
  3880. return iter.includes(value);
  3881. })
  3882. ) {
  3883. set.remove(value);
  3884. }
  3885. });
  3886. });
  3887. };
  3888. Set.prototype.merge = function() {
  3889. return this.union.apply(this, arguments);
  3890. };
  3891. Set.prototype.mergeWith = function(merger) {
  3892. var iters = SLICE$0.call(arguments, 1);
  3893. return this.union.apply(this, iters);
  3894. };
  3895. Set.prototype.sort = function(comparator) {
  3896. // Late binding
  3897. return OrderedSet(sortFactory(this, comparator));
  3898. };
  3899. Set.prototype.sortBy = function(mapper, comparator) {
  3900. // Late binding
  3901. return OrderedSet(sortFactory(this, comparator, mapper));
  3902. };
  3903. Set.prototype.wasAltered = function() {
  3904. return this._map.wasAltered();
  3905. };
  3906. Set.prototype.__iterate = function(fn, reverse) {
  3907. var this$0 = this;
  3908. return this._map.__iterate(function(_, k) {
  3909. return fn(k, k, this$0);
  3910. }, reverse);
  3911. };
  3912. Set.prototype.__iterator = function(type, reverse) {
  3913. return this._map
  3914. .map(function(_, k) {
  3915. return k;
  3916. })
  3917. .__iterator(type, reverse);
  3918. };
  3919. Set.prototype.__ensureOwner = function(ownerID) {
  3920. if (ownerID === this.__ownerID) {
  3921. return this;
  3922. }
  3923. var newMap = this._map.__ensureOwner(ownerID);
  3924. if (!ownerID) {
  3925. this.__ownerID = ownerID;
  3926. this._map = newMap;
  3927. return this;
  3928. }
  3929. return this.__make(newMap, ownerID);
  3930. };
  3931. function isSet(maybeSet) {
  3932. return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
  3933. }
  3934. Set.isSet = isSet;
  3935. var IS_SET_SENTINEL = "@@__IMMUTABLE_SET__@@";
  3936. var SetPrototype = Set.prototype;
  3937. SetPrototype[IS_SET_SENTINEL] = true;
  3938. SetPrototype[DELETE] = SetPrototype.remove;
  3939. SetPrototype.mergeDeep = SetPrototype.merge;
  3940. SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
  3941. SetPrototype.withMutations = MapPrototype.withMutations;
  3942. SetPrototype.asMutable = MapPrototype.asMutable;
  3943. SetPrototype.asImmutable = MapPrototype.asImmutable;
  3944. SetPrototype.__empty = emptySet;
  3945. SetPrototype.__make = makeSet;
  3946. function updateSet(set, newMap) {
  3947. if (set.__ownerID) {
  3948. set.size = newMap.size;
  3949. set._map = newMap;
  3950. return set;
  3951. }
  3952. return newMap === set._map
  3953. ? set
  3954. : newMap.size === 0
  3955. ? set.__empty()
  3956. : set.__make(newMap);
  3957. }
  3958. function makeSet(map, ownerID) {
  3959. var set = Object.create(SetPrototype);
  3960. set.size = map ? map.size : 0;
  3961. set._map = map;
  3962. set.__ownerID = ownerID;
  3963. return set;
  3964. }
  3965. var EMPTY_SET;
  3966. function emptySet() {
  3967. return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
  3968. }
  3969. createClass(OrderedSet, Set);
  3970. // @pragma Construction
  3971. function OrderedSet(value) {
  3972. return value === null || value === undefined
  3973. ? emptyOrderedSet()
  3974. : isOrderedSet(value)
  3975. ? value
  3976. : emptyOrderedSet().withMutations(function(set) {
  3977. var iter = SetIterable(value);
  3978. assertNotInfinite(iter.size);
  3979. iter.forEach(function(v) {
  3980. return set.add(v);
  3981. });
  3982. });
  3983. }
  3984. OrderedSet.of = function(/*...values*/) {
  3985. return this(arguments);
  3986. };
  3987. OrderedSet.fromKeys = function(value) {
  3988. return this(KeyedIterable(value).keySeq());
  3989. };
  3990. OrderedSet.prototype.toString = function() {
  3991. return this.__toString("OrderedSet {", "}");
  3992. };
  3993. function isOrderedSet(maybeOrderedSet) {
  3994. return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
  3995. }
  3996. OrderedSet.isOrderedSet = isOrderedSet;
  3997. var OrderedSetPrototype = OrderedSet.prototype;
  3998. OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
  3999. OrderedSetPrototype.__empty = emptyOrderedSet;
  4000. OrderedSetPrototype.__make = makeOrderedSet;
  4001. function makeOrderedSet(map, ownerID) {
  4002. var set = Object.create(OrderedSetPrototype);
  4003. set.size = map ? map.size : 0;
  4004. set._map = map;
  4005. set.__ownerID = ownerID;
  4006. return set;
  4007. }
  4008. var EMPTY_ORDERED_SET;
  4009. function emptyOrderedSet() {
  4010. return (
  4011. EMPTY_ORDERED_SET ||
  4012. (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()))
  4013. );
  4014. }
  4015. createClass(Stack, IndexedCollection);
  4016. // @pragma Construction
  4017. function Stack(value) {
  4018. return value === null || value === undefined
  4019. ? emptyStack()
  4020. : isStack(value)
  4021. ? value
  4022. : emptyStack().unshiftAll(value);
  4023. }
  4024. Stack.of = function(/*...values*/) {
  4025. return this(arguments);
  4026. };
  4027. Stack.prototype.toString = function() {
  4028. return this.__toString("Stack [", "]");
  4029. };
  4030. // @pragma Access
  4031. Stack.prototype.get = function(index, notSetValue) {
  4032. var head = this._head;
  4033. index = wrapIndex(this, index);
  4034. while (head && index--) {
  4035. head = head.next;
  4036. }
  4037. return head ? head.value : notSetValue;
  4038. };
  4039. Stack.prototype.peek = function() {
  4040. return this._head && this._head.value;
  4041. };
  4042. // @pragma Modification
  4043. Stack.prototype.push = function(/*...values*/) {
  4044. if (arguments.length === 0) {
  4045. return this;
  4046. }
  4047. var newSize = this.size + arguments.length;
  4048. var head = this._head;
  4049. for (var ii = arguments.length - 1; ii >= 0; ii--) {
  4050. head = {
  4051. value: arguments[ii],
  4052. next: head
  4053. };
  4054. }
  4055. if (this.__ownerID) {
  4056. this.size = newSize;
  4057. this._head = head;
  4058. this.__hash = undefined;
  4059. this.__altered = true;
  4060. return this;
  4061. }
  4062. return makeStack(newSize, head);
  4063. };
  4064. Stack.prototype.pushAll = function(iter) {
  4065. iter = IndexedIterable(iter);
  4066. if (iter.size === 0) {
  4067. return this;
  4068. }
  4069. assertNotInfinite(iter.size);
  4070. var newSize = this.size;
  4071. var head = this._head;
  4072. iter.reverse().forEach(function(value) {
  4073. newSize++;
  4074. head = {
  4075. value: value,
  4076. next: head
  4077. };
  4078. });
  4079. if (this.__ownerID) {
  4080. this.size = newSize;
  4081. this._head = head;
  4082. this.__hash = undefined;
  4083. this.__altered = true;
  4084. return this;
  4085. }
  4086. return makeStack(newSize, head);
  4087. };
  4088. Stack.prototype.pop = function() {
  4089. return this.slice(1);
  4090. };
  4091. Stack.prototype.unshift = function(/*...values*/) {
  4092. return this.push.apply(this, arguments);
  4093. };
  4094. Stack.prototype.unshiftAll = function(iter) {
  4095. return this.pushAll(iter);
  4096. };
  4097. Stack.prototype.shift = function() {
  4098. return this.pop.apply(this, arguments);
  4099. };
  4100. Stack.prototype.clear = function() {
  4101. if (this.size === 0) {
  4102. return this;
  4103. }
  4104. if (this.__ownerID) {
  4105. this.size = 0;
  4106. this._head = undefined;
  4107. this.__hash = undefined;
  4108. this.__altered = true;
  4109. return this;
  4110. }
  4111. return emptyStack();
  4112. };
  4113. Stack.prototype.slice = function(begin, end) {
  4114. if (wholeSlice(begin, end, this.size)) {
  4115. return this;
  4116. }
  4117. var resolvedBegin = resolveBegin(begin, this.size);
  4118. var resolvedEnd = resolveEnd(end, this.size);
  4119. if (resolvedEnd !== this.size) {
  4120. // super.slice(begin, end);
  4121. return IndexedCollection.prototype.slice.call(this, begin, end);
  4122. }
  4123. var newSize = this.size - resolvedBegin;
  4124. var head = this._head;
  4125. while (resolvedBegin--) {
  4126. head = head.next;
  4127. }
  4128. if (this.__ownerID) {
  4129. this.size = newSize;
  4130. this._head = head;
  4131. this.__hash = undefined;
  4132. this.__altered = true;
  4133. return this;
  4134. }
  4135. return makeStack(newSize, head);
  4136. };
  4137. // @pragma Mutability
  4138. Stack.prototype.__ensureOwner = function(ownerID) {
  4139. if (ownerID === this.__ownerID) {
  4140. return this;
  4141. }
  4142. if (!ownerID) {
  4143. this.__ownerID = ownerID;
  4144. this.__altered = false;
  4145. return this;
  4146. }
  4147. return makeStack(this.size, this._head, ownerID, this.__hash);
  4148. };
  4149. // @pragma Iteration
  4150. Stack.prototype.__iterate = function(fn, reverse) {
  4151. if (reverse) {
  4152. return this.reverse().__iterate(fn);
  4153. }
  4154. var iterations = 0;
  4155. var node = this._head;
  4156. while (node) {
  4157. if (fn(node.value, iterations++, this) === false) {
  4158. break;
  4159. }
  4160. node = node.next;
  4161. }
  4162. return iterations;
  4163. };
  4164. Stack.prototype.__iterator = function(type, reverse) {
  4165. if (reverse) {
  4166. return this.reverse().__iterator(type);
  4167. }
  4168. var iterations = 0;
  4169. var node = this._head;
  4170. return new Iterator(function() {
  4171. if (node) {
  4172. var value = node.value;
  4173. node = node.next;
  4174. return iteratorValue(type, iterations++, value);
  4175. }
  4176. return iteratorDone();
  4177. });
  4178. };
  4179. function isStack(maybeStack) {
  4180. return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
  4181. }
  4182. Stack.isStack = isStack;
  4183. var IS_STACK_SENTINEL = "@@__IMMUTABLE_STACK__@@";
  4184. var StackPrototype = Stack.prototype;
  4185. StackPrototype[IS_STACK_SENTINEL] = true;
  4186. StackPrototype.withMutations = MapPrototype.withMutations;
  4187. StackPrototype.asMutable = MapPrototype.asMutable;
  4188. StackPrototype.asImmutable = MapPrototype.asImmutable;
  4189. StackPrototype.wasAltered = MapPrototype.wasAltered;
  4190. function makeStack(size, head, ownerID, hash) {
  4191. var map = Object.create(StackPrototype);
  4192. map.size = size;
  4193. map._head = head;
  4194. map.__ownerID = ownerID;
  4195. map.__hash = hash;
  4196. map.__altered = false;
  4197. return map;
  4198. }
  4199. var EMPTY_STACK;
  4200. function emptyStack() {
  4201. return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
  4202. }
  4203. /**
  4204. * Contributes additional methods to a constructor
  4205. */
  4206. function mixin(ctor, methods) {
  4207. var keyCopier = function(key) {
  4208. ctor.prototype[key] = methods[key];
  4209. };
  4210. Object.keys(methods).forEach(keyCopier);
  4211. Object.getOwnPropertySymbols &&
  4212. Object.getOwnPropertySymbols(methods).forEach(keyCopier);
  4213. return ctor;
  4214. }
  4215. Iterable.Iterator = Iterator;
  4216. mixin(Iterable, {
  4217. // ### Conversion to other types
  4218. toArray: function() {
  4219. assertNotInfinite(this.size);
  4220. var array = new Array(this.size || 0);
  4221. this.valueSeq().__iterate(function(v, i) {
  4222. array[i] = v;
  4223. });
  4224. return array;
  4225. },
  4226. toIndexedSeq: function() {
  4227. return new ToIndexedSequence(this);
  4228. },
  4229. toJS: function() {
  4230. return this.toSeq()
  4231. .map(function(value) {
  4232. return value && typeof value.toJS === "function"
  4233. ? value.toJS()
  4234. : value;
  4235. })
  4236. .__toJS();
  4237. },
  4238. toJSON: function() {
  4239. return this.toSeq()
  4240. .map(function(value) {
  4241. return value && typeof value.toJSON === "function"
  4242. ? value.toJSON()
  4243. : value;
  4244. })
  4245. .__toJS();
  4246. },
  4247. toKeyedSeq: function() {
  4248. return new ToKeyedSequence(this, true);
  4249. },
  4250. toMap: function() {
  4251. // Use Late Binding here to solve the circular dependency.
  4252. return Map(this.toKeyedSeq());
  4253. },
  4254. toObject: function() {
  4255. assertNotInfinite(this.size);
  4256. var object = {};
  4257. this.__iterate(function(v, k) {
  4258. object[k] = v;
  4259. });
  4260. return object;
  4261. },
  4262. toOrderedMap: function() {
  4263. // Use Late Binding here to solve the circular dependency.
  4264. return OrderedMap(this.toKeyedSeq());
  4265. },
  4266. toOrderedSet: function() {
  4267. // Use Late Binding here to solve the circular dependency.
  4268. return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
  4269. },
  4270. toSet: function() {
  4271. // Use Late Binding here to solve the circular dependency.
  4272. return Set(isKeyed(this) ? this.valueSeq() : this);
  4273. },
  4274. toSetSeq: function() {
  4275. return new ToSetSequence(this);
  4276. },
  4277. toSeq: function() {
  4278. return isIndexed(this)
  4279. ? this.toIndexedSeq()
  4280. : isKeyed(this)
  4281. ? this.toKeyedSeq()
  4282. : this.toSetSeq();
  4283. },
  4284. toStack: function() {
  4285. // Use Late Binding here to solve the circular dependency.
  4286. return Stack(isKeyed(this) ? this.valueSeq() : this);
  4287. },
  4288. toList: function() {
  4289. // Use Late Binding here to solve the circular dependency.
  4290. return List(isKeyed(this) ? this.valueSeq() : this);
  4291. },
  4292. // ### Common JavaScript methods and properties
  4293. toString: function() {
  4294. return "[Iterable]";
  4295. },
  4296. __toString: function(head, tail) {
  4297. if (this.size === 0) {
  4298. return head + tail;
  4299. }
  4300. return (
  4301. head +
  4302. " " +
  4303. this.toSeq()
  4304. .map(this.__toStringMapper)
  4305. .join(", ") +
  4306. " " +
  4307. tail
  4308. );
  4309. },
  4310. // ### ES6 Collection methods (ES6 Array and Map)
  4311. concat: function() {
  4312. var values = SLICE$0.call(arguments, 0);
  4313. return reify(this, concatFactory(this, values));
  4314. },
  4315. includes: function(searchValue) {
  4316. return this.some(function(value) {
  4317. return is(value, searchValue);
  4318. });
  4319. },
  4320. entries: function() {
  4321. return this.__iterator(ITERATE_ENTRIES);
  4322. },
  4323. every: function(predicate, context) {
  4324. assertNotInfinite(this.size);
  4325. var returnValue = true;
  4326. this.__iterate(function(v, k, c) {
  4327. if (!predicate.call(context, v, k, c)) {
  4328. returnValue = false;
  4329. return false;
  4330. }
  4331. });
  4332. return returnValue;
  4333. },
  4334. filter: function(predicate, context) {
  4335. return reify(this, filterFactory(this, predicate, context, true));
  4336. },
  4337. find: function(predicate, context, notSetValue) {
  4338. var entry = this.findEntry(predicate, context);
  4339. return entry ? entry[1] : notSetValue;
  4340. },
  4341. findEntry: function(predicate, context) {
  4342. var found;
  4343. this.__iterate(function(v, k, c) {
  4344. if (predicate.call(context, v, k, c)) {
  4345. found = [k, v];
  4346. return false;
  4347. }
  4348. });
  4349. return found;
  4350. },
  4351. findLastEntry: function(predicate, context) {
  4352. return this.toSeq()
  4353. .reverse()
  4354. .findEntry(predicate, context);
  4355. },
  4356. forEach: function(sideEffect, context) {
  4357. assertNotInfinite(this.size);
  4358. return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
  4359. },
  4360. join: function(separator) {
  4361. assertNotInfinite(this.size);
  4362. separator = separator !== undefined ? "" + separator : ",";
  4363. var joined = "";
  4364. var isFirst = true;
  4365. this.__iterate(function(v) {
  4366. isFirst ? (isFirst = false) : (joined += separator);
  4367. joined += v !== null && v !== undefined ? v.toString() : "";
  4368. });
  4369. return joined;
  4370. },
  4371. keys: function() {
  4372. return this.__iterator(ITERATE_KEYS);
  4373. },
  4374. map: function(mapper, context) {
  4375. return reify(this, mapFactory(this, mapper, context));
  4376. },
  4377. reduce: function(reducer, initialReduction, context) {
  4378. assertNotInfinite(this.size);
  4379. var reduction;
  4380. var useFirst;
  4381. if (arguments.length < 2) {
  4382. useFirst = true;
  4383. } else {
  4384. reduction = initialReduction;
  4385. }
  4386. this.__iterate(function(v, k, c) {
  4387. if (useFirst) {
  4388. useFirst = false;
  4389. reduction = v;
  4390. } else {
  4391. reduction = reducer.call(context, reduction, v, k, c);
  4392. }
  4393. });
  4394. return reduction;
  4395. },
  4396. reduceRight: function(reducer, initialReduction, context) {
  4397. var reversed = this.toKeyedSeq().reverse();
  4398. return reversed.reduce.apply(reversed, arguments);
  4399. },
  4400. reverse: function() {
  4401. return reify(this, reverseFactory(this, true));
  4402. },
  4403. slice: function(begin, end) {
  4404. return reify(this, sliceFactory(this, begin, end, true));
  4405. },
  4406. some: function(predicate, context) {
  4407. return !this.every(not(predicate), context);
  4408. },
  4409. sort: function(comparator) {
  4410. return reify(this, sortFactory(this, comparator));
  4411. },
  4412. values: function() {
  4413. return this.__iterator(ITERATE_VALUES);
  4414. },
  4415. // ### More sequential methods
  4416. butLast: function() {
  4417. return this.slice(0, -1);
  4418. },
  4419. isEmpty: function() {
  4420. return this.size !== undefined
  4421. ? this.size === 0
  4422. : !this.some(function() {
  4423. return true;
  4424. });
  4425. },
  4426. count: function(predicate, context) {
  4427. return ensureSize(
  4428. predicate ? this.toSeq().filter(predicate, context) : this
  4429. );
  4430. },
  4431. countBy: function(grouper, context) {
  4432. return countByFactory(this, grouper, context);
  4433. },
  4434. equals: function(other) {
  4435. return deepEqual(this, other);
  4436. },
  4437. entrySeq: function() {
  4438. var iterable = this;
  4439. if (iterable._cache) {
  4440. // We cache as an entries array, so we can just return the cache!
  4441. return new ArraySeq(iterable._cache);
  4442. }
  4443. var entriesSequence = iterable
  4444. .toSeq()
  4445. .map(entryMapper)
  4446. .toIndexedSeq();
  4447. entriesSequence.fromEntrySeq = function() {
  4448. return iterable.toSeq();
  4449. };
  4450. return entriesSequence;
  4451. },
  4452. filterNot: function(predicate, context) {
  4453. return this.filter(not(predicate), context);
  4454. },
  4455. findLast: function(predicate, context, notSetValue) {
  4456. return this.toKeyedSeq()
  4457. .reverse()
  4458. .find(predicate, context, notSetValue);
  4459. },
  4460. first: function() {
  4461. return this.find(returnTrue);
  4462. },
  4463. flatMap: function(mapper, context) {
  4464. return reify(this, flatMapFactory(this, mapper, context));
  4465. },
  4466. flatten: function(depth) {
  4467. return reify(this, flattenFactory(this, depth, true));
  4468. },
  4469. fromEntrySeq: function() {
  4470. return new FromEntriesSequence(this);
  4471. },
  4472. get: function(searchKey, notSetValue) {
  4473. return this.find(
  4474. function(_, key) {
  4475. return is(key, searchKey);
  4476. },
  4477. undefined,
  4478. notSetValue
  4479. );
  4480. },
  4481. getIn: function(searchKeyPath, notSetValue) {
  4482. var nested = this;
  4483. // Note: in an ES6 environment, we would prefer:
  4484. // for (var key of searchKeyPath) {
  4485. var iter = forceIterator(searchKeyPath);
  4486. var step;
  4487. while (!(step = iter.next()).done) {
  4488. var key = step.value;
  4489. nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
  4490. if (nested === NOT_SET) {
  4491. return notSetValue;
  4492. }
  4493. }
  4494. return nested;
  4495. },
  4496. groupBy: function(grouper, context) {
  4497. return groupByFactory(this, grouper, context);
  4498. },
  4499. has: function(searchKey) {
  4500. return this.get(searchKey, NOT_SET) !== NOT_SET;
  4501. },
  4502. hasIn: function(searchKeyPath) {
  4503. return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
  4504. },
  4505. isSubset: function(iter) {
  4506. iter = typeof iter.includes === "function" ? iter : Iterable(iter);
  4507. return this.every(function(value) {
  4508. return iter.includes(value);
  4509. });
  4510. },
  4511. isSuperset: function(iter) {
  4512. iter = typeof iter.isSubset === "function" ? iter : Iterable(iter);
  4513. return iter.isSubset(this);
  4514. },
  4515. keySeq: function() {
  4516. return this.toSeq()
  4517. .map(keyMapper)
  4518. .toIndexedSeq();
  4519. },
  4520. last: function() {
  4521. return this.toSeq()
  4522. .reverse()
  4523. .first();
  4524. },
  4525. max: function(comparator) {
  4526. return maxFactory(this, comparator);
  4527. },
  4528. maxBy: function(mapper, comparator) {
  4529. return maxFactory(this, comparator, mapper);
  4530. },
  4531. min: function(comparator) {
  4532. return maxFactory(
  4533. this,
  4534. comparator ? neg(comparator) : defaultNegComparator
  4535. );
  4536. },
  4537. minBy: function(mapper, comparator) {
  4538. return maxFactory(
  4539. this,
  4540. comparator ? neg(comparator) : defaultNegComparator,
  4541. mapper
  4542. );
  4543. },
  4544. rest: function() {
  4545. return this.slice(1);
  4546. },
  4547. skip: function(amount) {
  4548. return this.slice(Math.max(0, amount));
  4549. },
  4550. skipLast: function(amount) {
  4551. return reify(
  4552. this,
  4553. this.toSeq()
  4554. .reverse()
  4555. .skip(amount)
  4556. .reverse()
  4557. );
  4558. },
  4559. skipWhile: function(predicate, context) {
  4560. return reify(this, skipWhileFactory(this, predicate, context, true));
  4561. },
  4562. skipUntil: function(predicate, context) {
  4563. return this.skipWhile(not(predicate), context);
  4564. },
  4565. sortBy: function(mapper, comparator) {
  4566. return reify(this, sortFactory(this, comparator, mapper));
  4567. },
  4568. take: function(amount) {
  4569. return this.slice(0, Math.max(0, amount));
  4570. },
  4571. takeLast: function(amount) {
  4572. return reify(
  4573. this,
  4574. this.toSeq()
  4575. .reverse()
  4576. .take(amount)
  4577. .reverse()
  4578. );
  4579. },
  4580. takeWhile: function(predicate, context) {
  4581. return reify(this, takeWhileFactory(this, predicate, context));
  4582. },
  4583. takeUntil: function(predicate, context) {
  4584. return this.takeWhile(not(predicate), context);
  4585. },
  4586. valueSeq: function() {
  4587. return this.toIndexedSeq();
  4588. },
  4589. // ### Hashable Object
  4590. hashCode: function() {
  4591. return this.__hash || (this.__hash = hashIterable(this));
  4592. }
  4593. // ### Internal
  4594. // abstract __iterate(fn, reverse)
  4595. // abstract __iterator(type, reverse)
  4596. });
  4597. // var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  4598. // var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  4599. // var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  4600. // var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  4601. var IterablePrototype = Iterable.prototype;
  4602. IterablePrototype[IS_ITERABLE_SENTINEL] = true;
  4603. IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
  4604. IterablePrototype.__toJS = IterablePrototype.toArray;
  4605. IterablePrototype.__toStringMapper = quoteString;
  4606. IterablePrototype.inspect = IterablePrototype.toSource = function() {
  4607. return this.toString();
  4608. };
  4609. IterablePrototype.chain = IterablePrototype.flatMap;
  4610. IterablePrototype.contains = IterablePrototype.includes;
  4611. // Temporary warning about using length
  4612. (function() {
  4613. try {
  4614. Object.defineProperty(IterablePrototype, "length", {
  4615. get: function() {
  4616. if (!Iterable.noLengthWarning) {
  4617. var stack;
  4618. try {
  4619. throw new Error();
  4620. } catch (error) {
  4621. stack = error.stack;
  4622. }
  4623. if (stack.indexOf("_wrapObject") === -1) {
  4624. console &&
  4625. console.warn &&
  4626. console.warn(
  4627. "iterable.length has been deprecated, " +
  4628. "use iterable.size or iterable.count(). " +
  4629. "This warning will become a silent error in a future version. " +
  4630. stack
  4631. );
  4632. return this.size;
  4633. }
  4634. }
  4635. }
  4636. });
  4637. } catch (e) {}
  4638. })();
  4639. mixin(KeyedIterable, {
  4640. // ### More sequential methods
  4641. flip: function() {
  4642. return reify(this, flipFactory(this));
  4643. },
  4644. findKey: function(predicate, context) {
  4645. var entry = this.findEntry(predicate, context);
  4646. return entry && entry[0];
  4647. },
  4648. findLastKey: function(predicate, context) {
  4649. return this.toSeq()
  4650. .reverse()
  4651. .findKey(predicate, context);
  4652. },
  4653. keyOf: function(searchValue) {
  4654. return this.findKey(function(value) {
  4655. return is(value, searchValue);
  4656. });
  4657. },
  4658. lastKeyOf: function(searchValue) {
  4659. return this.findLastKey(function(value) {
  4660. return is(value, searchValue);
  4661. });
  4662. },
  4663. mapEntries: function(mapper, context) {
  4664. var this$0 = this;
  4665. var iterations = 0;
  4666. return reify(
  4667. this,
  4668. this.toSeq()
  4669. .map(function(v, k) {
  4670. return mapper.call(context, [k, v], iterations++, this$0);
  4671. })
  4672. .fromEntrySeq()
  4673. );
  4674. },
  4675. mapKeys: function(mapper, context) {
  4676. var this$0 = this;
  4677. return reify(
  4678. this,
  4679. this.toSeq()
  4680. .flip()
  4681. .map(function(k, v) {
  4682. return mapper.call(context, k, v, this$0);
  4683. })
  4684. .flip()
  4685. );
  4686. }
  4687. });
  4688. var KeyedIterablePrototype = KeyedIterable.prototype;
  4689. KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
  4690. KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
  4691. KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
  4692. KeyedIterablePrototype.__toStringMapper = function(v, k) {
  4693. return JSON.stringify(k) + ": " + quoteString(v);
  4694. };
  4695. mixin(IndexedIterable, {
  4696. // ### Conversion to other types
  4697. toKeyedSeq: function() {
  4698. return new ToKeyedSequence(this, false);
  4699. },
  4700. // ### ES6 Collection methods (ES6 Array and Map)
  4701. filter: function(predicate, context) {
  4702. return reify(this, filterFactory(this, predicate, context, false));
  4703. },
  4704. findIndex: function(predicate, context) {
  4705. var entry = this.findEntry(predicate, context);
  4706. return entry ? entry[0] : -1;
  4707. },
  4708. indexOf: function(searchValue) {
  4709. var key = this.toKeyedSeq().keyOf(searchValue);
  4710. return key === undefined ? -1 : key;
  4711. },
  4712. lastIndexOf: function(searchValue) {
  4713. var key = this.toKeyedSeq()
  4714. .reverse()
  4715. .keyOf(searchValue);
  4716. return key === undefined ? -1 : key;
  4717. // var index =
  4718. // return this.toSeq().reverse().indexOf(searchValue);
  4719. },
  4720. reverse: function() {
  4721. return reify(this, reverseFactory(this, false));
  4722. },
  4723. slice: function(begin, end) {
  4724. return reify(this, sliceFactory(this, begin, end, false));
  4725. },
  4726. splice: function(index, removeNum /*, ...values*/) {
  4727. var numArgs = arguments.length;
  4728. removeNum = Math.max(removeNum | 0, 0);
  4729. if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
  4730. return this;
  4731. }
  4732. // If index is negative, it should resolve relative to the size of the
  4733. // collection. However size may be expensive to compute if not cached, so
  4734. // only call count() if the number is in fact negative.
  4735. index = resolveBegin(index, index < 0 ? this.count() : this.size);
  4736. var spliced = this.slice(0, index);
  4737. return reify(
  4738. this,
  4739. numArgs === 1
  4740. ? spliced
  4741. : spliced.concat(
  4742. arrCopy(arguments, 2),
  4743. this.slice(index + removeNum)
  4744. )
  4745. );
  4746. },
  4747. // ### More collection methods
  4748. findLastIndex: function(predicate, context) {
  4749. var key = this.toKeyedSeq().findLastKey(predicate, context);
  4750. return key === undefined ? -1 : key;
  4751. },
  4752. first: function() {
  4753. return this.get(0);
  4754. },
  4755. flatten: function(depth) {
  4756. return reify(this, flattenFactory(this, depth, false));
  4757. },
  4758. get: function(index, notSetValue) {
  4759. index = wrapIndex(this, index);
  4760. return index < 0 ||
  4761. this.size === Infinity ||
  4762. (this.size !== undefined && index > this.size)
  4763. ? notSetValue
  4764. : this.find(
  4765. function(_, key) {
  4766. return key === index;
  4767. },
  4768. undefined,
  4769. notSetValue
  4770. );
  4771. },
  4772. has: function(index) {
  4773. index = wrapIndex(this, index);
  4774. return (
  4775. index >= 0 &&
  4776. (this.size !== undefined
  4777. ? this.size === Infinity || index < this.size
  4778. : this.indexOf(index) !== -1)
  4779. );
  4780. },
  4781. interpose: function(separator) {
  4782. return reify(this, interposeFactory(this, separator));
  4783. },
  4784. interleave: function(/*...iterables*/) {
  4785. var iterables = [this].concat(arrCopy(arguments));
  4786. var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
  4787. var interleaved = zipped.flatten(true);
  4788. if (zipped.size) {
  4789. interleaved.size = zipped.size * iterables.length;
  4790. }
  4791. return reify(this, interleaved);
  4792. },
  4793. last: function() {
  4794. return this.get(-1);
  4795. },
  4796. skipWhile: function(predicate, context) {
  4797. return reify(this, skipWhileFactory(this, predicate, context, false));
  4798. },
  4799. zip: function(/*, ...iterables */) {
  4800. var iterables = [this].concat(arrCopy(arguments));
  4801. return reify(this, zipWithFactory(this, defaultZipper, iterables));
  4802. },
  4803. zipWith: function(zipper /*, ...iterables */) {
  4804. var iterables = arrCopy(arguments);
  4805. iterables[0] = this;
  4806. return reify(this, zipWithFactory(this, zipper, iterables));
  4807. }
  4808. });
  4809. IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
  4810. IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
  4811. mixin(SetIterable, {
  4812. // ### ES6 Collection methods (ES6 Array and Map)
  4813. get: function(value, notSetValue) {
  4814. return this.has(value) ? value : notSetValue;
  4815. },
  4816. includes: function(value) {
  4817. return this.has(value);
  4818. },
  4819. // ### More sequential methods
  4820. keySeq: function() {
  4821. return this.valueSeq();
  4822. }
  4823. });
  4824. SetIterable.prototype.has = IterablePrototype.includes;
  4825. // Mixin subclasses
  4826. mixin(KeyedSeq, KeyedIterable.prototype);
  4827. mixin(IndexedSeq, IndexedIterable.prototype);
  4828. mixin(SetSeq, SetIterable.prototype);
  4829. mixin(KeyedCollection, KeyedIterable.prototype);
  4830. mixin(IndexedCollection, IndexedIterable.prototype);
  4831. mixin(SetCollection, SetIterable.prototype);
  4832. // #pragma Helper functions
  4833. function keyMapper(v, k) {
  4834. return k;
  4835. }
  4836. function entryMapper(v, k) {
  4837. return [k, v];
  4838. }
  4839. function not(predicate) {
  4840. return function() {
  4841. return !predicate.apply(this, arguments);
  4842. };
  4843. }
  4844. function neg(predicate) {
  4845. return function() {
  4846. return -predicate.apply(this, arguments);
  4847. };
  4848. }
  4849. function quoteString(value) {
  4850. return typeof value === "string" ? JSON.stringify(value) : value;
  4851. }
  4852. function defaultZipper() {
  4853. return arrCopy(arguments);
  4854. }
  4855. function defaultNegComparator(a, b) {
  4856. return a < b ? 1 : a > b ? -1 : 0;
  4857. }
  4858. function hashIterable(iterable) {
  4859. if (iterable.size === Infinity) {
  4860. return 0;
  4861. }
  4862. var ordered = isOrdered(iterable);
  4863. var keyed = isKeyed(iterable);
  4864. var h = ordered ? 1 : 0;
  4865. var size = iterable.__iterate(
  4866. keyed
  4867. ? ordered
  4868. ? function(v, k) {
  4869. h = (31 * h + hashMerge(hash(v), hash(k))) | 0;
  4870. }
  4871. : function(v, k) {
  4872. h = (h + hashMerge(hash(v), hash(k))) | 0;
  4873. }
  4874. : ordered
  4875. ? function(v) {
  4876. h = (31 * h + hash(v)) | 0;
  4877. }
  4878. : function(v) {
  4879. h = (h + hash(v)) | 0;
  4880. }
  4881. );
  4882. return murmurHashOfSize(size, h);
  4883. }
  4884. function murmurHashOfSize(size, h) {
  4885. h = imul(h, 0xcc9e2d51);
  4886. h = imul((h << 15) | (h >>> -15), 0x1b873593);
  4887. h = imul((h << 13) | (h >>> -13), 5);
  4888. h = ((h + 0xe6546b64) | 0) ^ size;
  4889. h = imul(h ^ (h >>> 16), 0x85ebca6b);
  4890. h = imul(h ^ (h >>> 13), 0xc2b2ae35);
  4891. h = smi(h ^ (h >>> 16));
  4892. return h;
  4893. }
  4894. function hashMerge(a, b) {
  4895. return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int
  4896. }
  4897. var Immutable = {
  4898. Iterable: Iterable,
  4899. Seq: Seq,
  4900. Collection: Collection,
  4901. Map: Map,
  4902. OrderedMap: OrderedMap,
  4903. List: List,
  4904. Stack: Stack,
  4905. Set: Set,
  4906. OrderedSet: OrderedSet,
  4907. Record: Record,
  4908. Range: Range,
  4909. Repeat: Repeat,
  4910. is: is,
  4911. fromJS: fromJS
  4912. };
  4913. return Immutable;
  4914. });
  4915. });
  4916. var OrderedMap = immutable.OrderedMap;
  4917. var BlockMapBuilder = {
  4918. createFromArray: function createFromArray(blocks) {
  4919. return OrderedMap(
  4920. blocks.map(function(block) {
  4921. return [block.getKey(), block];
  4922. })
  4923. );
  4924. }
  4925. };
  4926. var BlockMapBuilder_1 = BlockMapBuilder;
  4927. function _classCallCheck(instance, Constructor) {
  4928. if (!(instance instanceof Constructor)) {
  4929. throw new TypeError("Cannot call a class as a function");
  4930. }
  4931. }
  4932. function _possibleConstructorReturn(self, call) {
  4933. if (!self) {
  4934. throw new ReferenceError(
  4935. "this hasn't been initialised - super() hasn't been called"
  4936. );
  4937. }
  4938. return call && (typeof call === "object" || typeof call === "function")
  4939. ? call
  4940. : self;
  4941. }
  4942. function _inherits(subClass, superClass) {
  4943. if (typeof superClass !== "function" && superClass !== null) {
  4944. throw new TypeError(
  4945. "Super expression must either be null or a function, not " +
  4946. typeof superClass
  4947. );
  4948. }
  4949. subClass.prototype = Object.create(superClass && superClass.prototype, {
  4950. constructor: {
  4951. value: subClass,
  4952. enumerable: false,
  4953. writable: true,
  4954. configurable: true
  4955. }
  4956. });
  4957. if (superClass)
  4958. Object.setPrototypeOf
  4959. ? Object.setPrototypeOf(subClass, superClass)
  4960. : (subClass.__proto__ = superClass);
  4961. }
  4962. var Map = immutable.Map,
  4963. OrderedSet = immutable.OrderedSet,
  4964. Record = immutable.Record;
  4965. // Immutable.map is typed such that the value for every key in the map
  4966. // must be the same type
  4967. var EMPTY_SET = OrderedSet();
  4968. var defaultRecord = {
  4969. style: EMPTY_SET,
  4970. entity: null
  4971. };
  4972. var CharacterMetadataRecord = Record(defaultRecord);
  4973. var CharacterMetadata = (function(_CharacterMetadataRec) {
  4974. _inherits(CharacterMetadata, _CharacterMetadataRec);
  4975. function CharacterMetadata() {
  4976. _classCallCheck(this, CharacterMetadata);
  4977. return _possibleConstructorReturn(
  4978. this,
  4979. _CharacterMetadataRec.apply(this, arguments)
  4980. );
  4981. }
  4982. CharacterMetadata.prototype.getStyle = function getStyle() {
  4983. return this.get("style");
  4984. };
  4985. CharacterMetadata.prototype.getEntity = function getEntity() {
  4986. return this.get("entity");
  4987. };
  4988. CharacterMetadata.prototype.hasStyle = function hasStyle(style) {
  4989. return this.getStyle().includes(style);
  4990. };
  4991. CharacterMetadata.applyStyle = function applyStyle(record, style) {
  4992. var withStyle = record.set("style", record.getStyle().add(style));
  4993. return CharacterMetadata.create(withStyle);
  4994. };
  4995. CharacterMetadata.removeStyle = function removeStyle(record, style) {
  4996. var withoutStyle = record.set("style", record.getStyle().remove(style));
  4997. return CharacterMetadata.create(withoutStyle);
  4998. };
  4999. CharacterMetadata.applyEntity = function applyEntity(record, entityKey) {
  5000. var withEntity =
  5001. record.getEntity() === entityKey
  5002. ? record
  5003. : record.set("entity", entityKey);
  5004. return CharacterMetadata.create(withEntity);
  5005. };
  5006. /**
  5007. * Use this function instead of the `CharacterMetadata` constructor.
  5008. * Since most content generally uses only a very small number of
  5009. * style/entity permutations, we can reuse these objects as often as
  5010. * possible.
  5011. */
  5012. CharacterMetadata.create = function create(config) {
  5013. if (!config) {
  5014. return EMPTY;
  5015. }
  5016. var defaultConfig = {
  5017. style: EMPTY_SET,
  5018. entity: null
  5019. };
  5020. // Fill in unspecified properties, if necessary.
  5021. var configMap = Map(defaultConfig).merge(config);
  5022. var existing = pool.get(configMap);
  5023. if (existing) {
  5024. return existing;
  5025. }
  5026. var newCharacter = new CharacterMetadata(configMap);
  5027. pool = pool.set(configMap, newCharacter);
  5028. return newCharacter;
  5029. };
  5030. return CharacterMetadata;
  5031. })(CharacterMetadataRecord);
  5032. var EMPTY = new CharacterMetadata();
  5033. var pool = Map([[Map(defaultRecord), EMPTY]]);
  5034. CharacterMetadata.EMPTY = EMPTY;
  5035. var CharacterMetadata_1 = CharacterMetadata;
  5036. /**
  5037. * Copyright (c) 2013-present, Facebook, Inc.
  5038. * All rights reserved.
  5039. *
  5040. * This source code is licensed under the BSD-style license found in the
  5041. * LICENSE file in the root directory of this source tree. An additional grant
  5042. * of patent rights can be found in the PATENTS file in the same directory.
  5043. *
  5044. * @providesModule findRangesImmutable
  5045. * @format
  5046. *
  5047. */
  5048. /**
  5049. * Search through an array to find contiguous stretches of elements that
  5050. * match a specified filter function.
  5051. *
  5052. * When ranges are found, execute a specified `found` function to supply
  5053. * the values to the caller.
  5054. */
  5055. function findRangesImmutable(haystack, areEqualFn, filterFn, foundFn) {
  5056. if (!haystack.size) {
  5057. return;
  5058. }
  5059. var cursor = 0;
  5060. haystack.reduce(function(value, nextValue, nextIndex) {
  5061. if (!areEqualFn(value, nextValue)) {
  5062. if (filterFn(value)) {
  5063. foundFn(cursor, nextIndex);
  5064. }
  5065. cursor = nextIndex;
  5066. }
  5067. return nextValue;
  5068. });
  5069. filterFn(haystack.last()) && foundFn(cursor, haystack.count());
  5070. }
  5071. var findRangesImmutable_1 = findRangesImmutable;
  5072. function _classCallCheck$1(instance, Constructor) {
  5073. if (!(instance instanceof Constructor)) {
  5074. throw new TypeError("Cannot call a class as a function");
  5075. }
  5076. }
  5077. function _possibleConstructorReturn$1(self, call) {
  5078. if (!self) {
  5079. throw new ReferenceError(
  5080. "this hasn't been initialised - super() hasn't been called"
  5081. );
  5082. }
  5083. return call && (typeof call === "object" || typeof call === "function")
  5084. ? call
  5085. : self;
  5086. }
  5087. function _inherits$1(subClass, superClass) {
  5088. if (typeof superClass !== "function" && superClass !== null) {
  5089. throw new TypeError(
  5090. "Super expression must either be null or a function, not " +
  5091. typeof superClass
  5092. );
  5093. }
  5094. subClass.prototype = Object.create(superClass && superClass.prototype, {
  5095. constructor: {
  5096. value: subClass,
  5097. enumerable: false,
  5098. writable: true,
  5099. configurable: true
  5100. }
  5101. });
  5102. if (superClass)
  5103. Object.setPrototypeOf
  5104. ? Object.setPrototypeOf(subClass, superClass)
  5105. : (subClass.__proto__ = superClass);
  5106. }
  5107. var List = immutable.List,
  5108. Map$1 = immutable.Map,
  5109. OrderedSet$1 = immutable.OrderedSet,
  5110. Record$1 = immutable.Record,
  5111. Repeat = immutable.Repeat;
  5112. var EMPTY_SET$1 = OrderedSet$1();
  5113. var defaultRecord$1 = {
  5114. key: "",
  5115. type: "unstyled",
  5116. text: "",
  5117. characterList: List(),
  5118. depth: 0,
  5119. data: Map$1()
  5120. };
  5121. var ContentBlockRecord = Record$1(defaultRecord$1);
  5122. var decorateCharacterList = function decorateCharacterList(config) {
  5123. if (!config) {
  5124. return config;
  5125. }
  5126. var characterList = config.characterList,
  5127. text = config.text;
  5128. if (text && !characterList) {
  5129. config.characterList = List(Repeat(CharacterMetadata_1.EMPTY, text.length));
  5130. }
  5131. return config;
  5132. };
  5133. var ContentBlock = (function(_ContentBlockRecord) {
  5134. _inherits$1(ContentBlock, _ContentBlockRecord);
  5135. function ContentBlock(config) {
  5136. _classCallCheck$1(this, ContentBlock);
  5137. return _possibleConstructorReturn$1(
  5138. this,
  5139. _ContentBlockRecord.call(this, decorateCharacterList(config))
  5140. );
  5141. }
  5142. ContentBlock.prototype.getKey = function getKey() {
  5143. return this.get("key");
  5144. };
  5145. ContentBlock.prototype.getType = function getType() {
  5146. return this.get("type");
  5147. };
  5148. ContentBlock.prototype.getText = function getText() {
  5149. return this.get("text");
  5150. };
  5151. ContentBlock.prototype.getCharacterList = function getCharacterList() {
  5152. return this.get("characterList");
  5153. };
  5154. ContentBlock.prototype.getLength = function getLength() {
  5155. return this.getText().length;
  5156. };
  5157. ContentBlock.prototype.getDepth = function getDepth() {
  5158. return this.get("depth");
  5159. };
  5160. ContentBlock.prototype.getData = function getData() {
  5161. return this.get("data");
  5162. };
  5163. ContentBlock.prototype.getInlineStyleAt = function getInlineStyleAt(offset) {
  5164. var character = this.getCharacterList().get(offset);
  5165. return character ? character.getStyle() : EMPTY_SET$1;
  5166. };
  5167. ContentBlock.prototype.getEntityAt = function getEntityAt(offset) {
  5168. var character = this.getCharacterList().get(offset);
  5169. return character ? character.getEntity() : null;
  5170. };
  5171. /**
  5172. * Execute a callback for every contiguous range of styles within the block.
  5173. */
  5174. ContentBlock.prototype.findStyleRanges = function findStyleRanges(
  5175. filterFn,
  5176. callback
  5177. ) {
  5178. findRangesImmutable_1(
  5179. this.getCharacterList(),
  5180. haveEqualStyle,
  5181. filterFn,
  5182. callback
  5183. );
  5184. };
  5185. /**
  5186. * Execute a callback for every contiguous range of entities within the block.
  5187. */
  5188. ContentBlock.prototype.findEntityRanges = function findEntityRanges(
  5189. filterFn,
  5190. callback
  5191. ) {
  5192. findRangesImmutable_1(
  5193. this.getCharacterList(),
  5194. haveEqualEntity,
  5195. filterFn,
  5196. callback
  5197. );
  5198. };
  5199. return ContentBlock;
  5200. })(ContentBlockRecord);
  5201. function haveEqualStyle(charA, charB) {
  5202. return charA.getStyle() === charB.getStyle();
  5203. }
  5204. function haveEqualEntity(charA, charB) {
  5205. return charA.getEntity() === charB.getEntity();
  5206. }
  5207. var ContentBlock_1 = ContentBlock;
  5208. function _classCallCheck$2(instance, Constructor) {
  5209. if (!(instance instanceof Constructor)) {
  5210. throw new TypeError("Cannot call a class as a function");
  5211. }
  5212. }
  5213. function _possibleConstructorReturn$2(self, call) {
  5214. if (!self) {
  5215. throw new ReferenceError(
  5216. "this hasn't been initialised - super() hasn't been called"
  5217. );
  5218. }
  5219. return call && (typeof call === "object" || typeof call === "function")
  5220. ? call
  5221. : self;
  5222. }
  5223. function _inherits$2(subClass, superClass) {
  5224. if (typeof superClass !== "function" && superClass !== null) {
  5225. throw new TypeError(
  5226. "Super expression must either be null or a function, not " +
  5227. typeof superClass
  5228. );
  5229. }
  5230. subClass.prototype = Object.create(superClass && superClass.prototype, {
  5231. constructor: {
  5232. value: subClass,
  5233. enumerable: false,
  5234. writable: true,
  5235. configurable: true
  5236. }
  5237. });
  5238. if (superClass)
  5239. Object.setPrototypeOf
  5240. ? Object.setPrototypeOf(subClass, superClass)
  5241. : (subClass.__proto__ = superClass);
  5242. }
  5243. var List$1 = immutable.List,
  5244. Map$2 = immutable.Map,
  5245. OrderedSet$2 = immutable.OrderedSet,
  5246. Record$2 = immutable.Record,
  5247. Repeat$1 = immutable.Repeat;
  5248. var EMPTY_SET$2 = OrderedSet$2();
  5249. var defaultRecord$2 = {
  5250. parent: null,
  5251. characterList: List$1(),
  5252. data: Map$2(),
  5253. depth: 0,
  5254. key: "",
  5255. text: "",
  5256. type: "unstyled",
  5257. children: List$1(),
  5258. prevSibling: null,
  5259. nextSibling: null
  5260. };
  5261. var haveEqualStyle$1 = function haveEqualStyle(charA, charB) {
  5262. return charA.getStyle() === charB.getStyle();
  5263. };
  5264. var haveEqualEntity$1 = function haveEqualEntity(charA, charB) {
  5265. return charA.getEntity() === charB.getEntity();
  5266. };
  5267. var decorateCharacterList$1 = function decorateCharacterList(config) {
  5268. if (!config) {
  5269. return config;
  5270. }
  5271. var characterList = config.characterList,
  5272. text = config.text;
  5273. if (text && !characterList) {
  5274. config.characterList = List$1(
  5275. Repeat$1(CharacterMetadata_1.EMPTY, text.length)
  5276. );
  5277. }
  5278. return config;
  5279. };
  5280. var ContentBlockNode = (function(_Record) {
  5281. _inherits$2(ContentBlockNode, _Record);
  5282. function ContentBlockNode() {
  5283. var props =
  5284. arguments.length > 0 && arguments[0] !== undefined
  5285. ? arguments[0]
  5286. : defaultRecord$2;
  5287. _classCallCheck$2(this, ContentBlockNode);
  5288. return _possibleConstructorReturn$2(
  5289. this,
  5290. _Record.call(this, decorateCharacterList$1(props))
  5291. );
  5292. }
  5293. ContentBlockNode.prototype.getKey = function getKey() {
  5294. return this.get("key");
  5295. };
  5296. ContentBlockNode.prototype.getType = function getType() {
  5297. return this.get("type");
  5298. };
  5299. ContentBlockNode.prototype.getText = function getText() {
  5300. return this.get("text");
  5301. };
  5302. ContentBlockNode.prototype.getCharacterList = function getCharacterList() {
  5303. return this.get("characterList");
  5304. };
  5305. ContentBlockNode.prototype.getLength = function getLength() {
  5306. return this.getText().length;
  5307. };
  5308. ContentBlockNode.prototype.getDepth = function getDepth() {
  5309. return this.get("depth");
  5310. };
  5311. ContentBlockNode.prototype.getData = function getData() {
  5312. return this.get("data");
  5313. };
  5314. ContentBlockNode.prototype.getInlineStyleAt = function getInlineStyleAt(
  5315. offset
  5316. ) {
  5317. var character = this.getCharacterList().get(offset);
  5318. return character ? character.getStyle() : EMPTY_SET$2;
  5319. };
  5320. ContentBlockNode.prototype.getEntityAt = function getEntityAt(offset) {
  5321. var character = this.getCharacterList().get(offset);
  5322. return character ? character.getEntity() : null;
  5323. };
  5324. ContentBlockNode.prototype.getChildKeys = function getChildKeys() {
  5325. return this.get("children");
  5326. };
  5327. ContentBlockNode.prototype.getParentKey = function getParentKey() {
  5328. return this.get("parent");
  5329. };
  5330. ContentBlockNode.prototype.getPrevSiblingKey = function getPrevSiblingKey() {
  5331. return this.get("prevSibling");
  5332. };
  5333. ContentBlockNode.prototype.getNextSiblingKey = function getNextSiblingKey() {
  5334. return this.get("nextSibling");
  5335. };
  5336. ContentBlockNode.prototype.findStyleRanges = function findStyleRanges(
  5337. filterFn,
  5338. callback
  5339. ) {
  5340. findRangesImmutable_1(
  5341. this.getCharacterList(),
  5342. haveEqualStyle$1,
  5343. filterFn,
  5344. callback
  5345. );
  5346. };
  5347. ContentBlockNode.prototype.findEntityRanges = function findEntityRanges(
  5348. filterFn,
  5349. callback
  5350. ) {
  5351. findRangesImmutable_1(
  5352. this.getCharacterList(),
  5353. haveEqualEntity$1,
  5354. filterFn,
  5355. callback
  5356. );
  5357. };
  5358. return ContentBlockNode;
  5359. })(Record$2(defaultRecord$2));
  5360. var ContentBlockNode_1 = ContentBlockNode;
  5361. /**
  5362. * Copyright 2013-present, Facebook, Inc.
  5363. * All rights reserved.
  5364. *
  5365. * This source code is licensed under the BSD-style license found in the
  5366. * LICENSE file in the root directory of this source tree. An additional grant
  5367. * of patent rights can be found in the PATENTS file in the same directory.
  5368. *
  5369. * @providesModule DraftFeatureFlags-core
  5370. * @format
  5371. *
  5372. */
  5373. var DraftFeatureFlags = {
  5374. draft_killswitch_allow_nontextnodes: false,
  5375. draft_segmented_entities_behavior: false,
  5376. draft_handlebeforeinput_composed_text: false,
  5377. draft_tree_data_support: false
  5378. };
  5379. var DraftFeatureFlagsCore = DraftFeatureFlags;
  5380. var DraftFeatureFlags_1 = DraftFeatureFlagsCore;
  5381. var Map$3 = immutable.Map;
  5382. var ContentStateInlineStyle = {
  5383. add: function add(contentState, selectionState, inlineStyle) {
  5384. return modifyInlineStyle(contentState, selectionState, inlineStyle, true);
  5385. },
  5386. remove: function remove(contentState, selectionState, inlineStyle) {
  5387. return modifyInlineStyle(contentState, selectionState, inlineStyle, false);
  5388. }
  5389. };
  5390. function modifyInlineStyle(
  5391. contentState,
  5392. selectionState,
  5393. inlineStyle,
  5394. addOrRemove
  5395. ) {
  5396. var blockMap = contentState.getBlockMap();
  5397. var startKey = selectionState.getStartKey();
  5398. var startOffset = selectionState.getStartOffset();
  5399. var endKey = selectionState.getEndKey();
  5400. var endOffset = selectionState.getEndOffset();
  5401. var newBlocks = blockMap
  5402. .skipUntil(function(_, k) {
  5403. return k === startKey;
  5404. })
  5405. .takeUntil(function(_, k) {
  5406. return k === endKey;
  5407. })
  5408. .concat(Map$3([[endKey, blockMap.get(endKey)]]))
  5409. .map(function(block, blockKey) {
  5410. var sliceStart;
  5411. var sliceEnd;
  5412. if (startKey === endKey) {
  5413. sliceStart = startOffset;
  5414. sliceEnd = endOffset;
  5415. } else {
  5416. sliceStart = blockKey === startKey ? startOffset : 0;
  5417. sliceEnd = blockKey === endKey ? endOffset : block.getLength();
  5418. }
  5419. var chars = block.getCharacterList();
  5420. var current;
  5421. while (sliceStart < sliceEnd) {
  5422. current = chars.get(sliceStart);
  5423. chars = chars.set(
  5424. sliceStart,
  5425. addOrRemove
  5426. ? CharacterMetadata_1.applyStyle(current, inlineStyle)
  5427. : CharacterMetadata_1.removeStyle(current, inlineStyle)
  5428. );
  5429. sliceStart++;
  5430. }
  5431. return block.set("characterList", chars);
  5432. });
  5433. return contentState.merge({
  5434. blockMap: blockMap.merge(newBlocks),
  5435. selectionBefore: selectionState,
  5436. selectionAfter: selectionState
  5437. });
  5438. }
  5439. var ContentStateInlineStyle_1 = ContentStateInlineStyle;
  5440. function applyEntityToContentBlock(contentBlock, start, end, entityKey) {
  5441. var characterList = contentBlock.getCharacterList();
  5442. while (start < end) {
  5443. characterList = characterList.set(
  5444. start,
  5445. CharacterMetadata_1.applyEntity(characterList.get(start), entityKey)
  5446. );
  5447. start++;
  5448. }
  5449. return contentBlock.set("characterList", characterList);
  5450. }
  5451. var applyEntityToContentBlock_1 = applyEntityToContentBlock;
  5452. function applyEntityToContentState(contentState, selectionState, entityKey) {
  5453. var blockMap = contentState.getBlockMap();
  5454. var startKey = selectionState.getStartKey();
  5455. var startOffset = selectionState.getStartOffset();
  5456. var endKey = selectionState.getEndKey();
  5457. var endOffset = selectionState.getEndOffset();
  5458. var newBlocks = blockMap
  5459. .skipUntil(function(_, k) {
  5460. return k === startKey;
  5461. })
  5462. .takeUntil(function(_, k) {
  5463. return k === endKey;
  5464. })
  5465. .toOrderedMap()
  5466. .merge(immutable.OrderedMap([[endKey, blockMap.get(endKey)]]))
  5467. .map(function(block, blockKey) {
  5468. var sliceStart = blockKey === startKey ? startOffset : 0;
  5469. var sliceEnd = blockKey === endKey ? endOffset : block.getLength();
  5470. return applyEntityToContentBlock_1(
  5471. block,
  5472. sliceStart,
  5473. sliceEnd,
  5474. entityKey
  5475. );
  5476. });
  5477. return contentState.merge({
  5478. blockMap: blockMap.merge(newBlocks),
  5479. selectionBefore: selectionState,
  5480. selectionAfter: selectionState
  5481. });
  5482. }
  5483. var applyEntityToContentState_1 = applyEntityToContentState;
  5484. /**
  5485. * Copyright (c) 2013-present, Facebook, Inc.
  5486. * All rights reserved.
  5487. *
  5488. * This source code is licensed under the BSD-style license found in the
  5489. * LICENSE file in the root directory of this source tree. An additional grant
  5490. * of patent rights can be found in the PATENTS file in the same directory.
  5491. *
  5492. * @providesModule DraftEntitySegments
  5493. * @format
  5494. *
  5495. */
  5496. /**
  5497. * Identify the range to delete from a segmented entity.
  5498. *
  5499. * Rules:
  5500. *
  5501. * Example: 'John F. Kennedy'
  5502. *
  5503. * - Deletion from within any non-whitespace (i.e. ['John', 'F.', 'Kennedy'])
  5504. * will return the range of that text.
  5505. *
  5506. * 'John F. Kennedy' -> 'John F.'
  5507. * ^
  5508. *
  5509. * - Forward deletion of whitespace will remove the following section:
  5510. *
  5511. * 'John F. Kennedy' -> 'John Kennedy'
  5512. * ^
  5513. *
  5514. * - Backward deletion of whitespace will remove the previous section:
  5515. *
  5516. * 'John F. Kennedy' -> 'F. Kennedy'
  5517. * ^
  5518. */
  5519. var DraftEntitySegments = {
  5520. getRemovalRange: function getRemovalRange(
  5521. selectionStart,
  5522. selectionEnd,
  5523. text,
  5524. entityStart,
  5525. direction
  5526. ) {
  5527. var segments = text.split(" ");
  5528. segments = segments.map(function(/*string*/ segment, /*number*/ ii) {
  5529. if (direction === "forward") {
  5530. if (ii > 0) {
  5531. return " " + segment;
  5532. }
  5533. } else if (ii < segments.length - 1) {
  5534. return segment + " ";
  5535. }
  5536. return segment;
  5537. });
  5538. var segmentStart = entityStart;
  5539. var segmentEnd;
  5540. var segment;
  5541. var removalStart = null;
  5542. var removalEnd = null;
  5543. for (var jj = 0; jj < segments.length; jj++) {
  5544. segment = segments[jj];
  5545. segmentEnd = segmentStart + segment.length;
  5546. // Our selection overlaps this segment.
  5547. if (selectionStart < segmentEnd && segmentStart < selectionEnd) {
  5548. if (removalStart !== null) {
  5549. removalEnd = segmentEnd;
  5550. } else {
  5551. removalStart = segmentStart;
  5552. removalEnd = segmentEnd;
  5553. }
  5554. } else if (removalStart !== null) {
  5555. break;
  5556. }
  5557. segmentStart = segmentEnd;
  5558. }
  5559. var entityEnd = entityStart + text.length;
  5560. var atStart = removalStart === entityStart;
  5561. var atEnd = removalEnd === entityEnd;
  5562. if ((!atStart && atEnd) || (atStart && !atEnd)) {
  5563. if (direction === "forward") {
  5564. if (removalEnd !== entityEnd) {
  5565. removalEnd++;
  5566. }
  5567. } else if (removalStart !== entityStart) {
  5568. removalStart--;
  5569. }
  5570. }
  5571. return {
  5572. start: removalStart,
  5573. end: removalEnd
  5574. };
  5575. }
  5576. };
  5577. var DraftEntitySegments_1 = DraftEntitySegments;
  5578. /**
  5579. * Copyright (c) 2013-present, Facebook, Inc.
  5580. *
  5581. * This source code is licensed under the MIT license found in the
  5582. * LICENSE file in the root directory of this source tree.
  5583. *
  5584. */
  5585. /**
  5586. * Use invariant() to assert state which your program assumes to be true.
  5587. *
  5588. * Provide sprintf-style format (only %s is supported) and arguments
  5589. * to provide information about what broke and what you were
  5590. * expecting.
  5591. *
  5592. * The invariant message will be stripped in production, but the invariant
  5593. * will remain to ensure logic does not differ in production.
  5594. */
  5595. var validateFormat = function validateFormat(format) {};
  5596. if (process.env.NODE_ENV !== "production") {
  5597. validateFormat = function validateFormat(format) {
  5598. if (format === undefined) {
  5599. throw new Error("invariant requires an error message argument");
  5600. }
  5601. };
  5602. }
  5603. function invariant(condition, format, a, b, c, d, e, f) {
  5604. validateFormat(format);
  5605. if (!condition) {
  5606. var error;
  5607. if (format === undefined) {
  5608. error = new Error(
  5609. "Minified exception occurred; use the non-minified dev environment " +
  5610. "for the full error message and additional helpful warnings."
  5611. );
  5612. } else {
  5613. var args = [a, b, c, d, e, f];
  5614. var argIndex = 0;
  5615. error = new Error(
  5616. format.replace(/%s/g, function() {
  5617. return args[argIndex++];
  5618. })
  5619. );
  5620. error.name = "Invariant Violation";
  5621. }
  5622. error.framesToPop = 1; // we don't care about invariant's own frame
  5623. throw error;
  5624. }
  5625. }
  5626. var invariant_1 = invariant;
  5627. /**
  5628. * Obtain the start and end positions of the range that has the
  5629. * specified entity applied to it.
  5630. *
  5631. * Entity keys are applied only to contiguous stretches of text, so this
  5632. * method searches for the first instance of the entity key and returns
  5633. * the subsequent range.
  5634. */
  5635. function getRangesForDraftEntity(block, key) {
  5636. var ranges = [];
  5637. block.findEntityRanges(
  5638. function(c) {
  5639. return c.getEntity() === key;
  5640. },
  5641. function(start, end) {
  5642. ranges.push({ start: start, end: end });
  5643. }
  5644. );
  5645. !!!ranges.length
  5646. ? process.env.NODE_ENV !== "production"
  5647. ? invariant_1(false, "Entity key not found in this range.")
  5648. : invariant_1(false)
  5649. : void 0;
  5650. return ranges;
  5651. }
  5652. var getRangesForDraftEntity_1 = getRangesForDraftEntity;
  5653. /**
  5654. * Given a SelectionState and a removal direction, determine the entire range
  5655. * that should be removed from a ContentState. This is based on any entities
  5656. * within the target, with their `mutability` values taken into account.
  5657. *
  5658. * For instance, if we are attempting to remove part of an "immutable" entity
  5659. * range, the entire entity must be removed. The returned `SelectionState`
  5660. * will be adjusted accordingly.
  5661. */
  5662. function getCharacterRemovalRange(
  5663. entityMap,
  5664. startBlock,
  5665. endBlock,
  5666. selectionState,
  5667. direction
  5668. ) {
  5669. var start = selectionState.getStartOffset();
  5670. var end = selectionState.getEndOffset();
  5671. var startEntityKey = startBlock.getEntityAt(start);
  5672. var endEntityKey = endBlock.getEntityAt(end - 1);
  5673. if (!startEntityKey && !endEntityKey) {
  5674. return selectionState;
  5675. }
  5676. var newSelectionState = selectionState;
  5677. if (startEntityKey && startEntityKey === endEntityKey) {
  5678. newSelectionState = getEntityRemovalRange(
  5679. entityMap,
  5680. startBlock,
  5681. newSelectionState,
  5682. direction,
  5683. startEntityKey,
  5684. true,
  5685. true
  5686. );
  5687. } else if (startEntityKey && endEntityKey) {
  5688. var startSelectionState = getEntityRemovalRange(
  5689. entityMap,
  5690. startBlock,
  5691. newSelectionState,
  5692. direction,
  5693. startEntityKey,
  5694. false,
  5695. true
  5696. );
  5697. var endSelectionState = getEntityRemovalRange(
  5698. entityMap,
  5699. endBlock,
  5700. newSelectionState,
  5701. direction,
  5702. endEntityKey,
  5703. false,
  5704. false
  5705. );
  5706. newSelectionState = newSelectionState.merge({
  5707. anchorOffset: startSelectionState.getAnchorOffset(),
  5708. focusOffset: endSelectionState.getFocusOffset(),
  5709. isBackward: false
  5710. });
  5711. } else if (startEntityKey) {
  5712. var _startSelectionState = getEntityRemovalRange(
  5713. entityMap,
  5714. startBlock,
  5715. newSelectionState,
  5716. direction,
  5717. startEntityKey,
  5718. false,
  5719. true
  5720. );
  5721. newSelectionState = newSelectionState.merge({
  5722. anchorOffset: _startSelectionState.getStartOffset(),
  5723. isBackward: false
  5724. });
  5725. } else if (endEntityKey) {
  5726. var _endSelectionState = getEntityRemovalRange(
  5727. entityMap,
  5728. endBlock,
  5729. newSelectionState,
  5730. direction,
  5731. endEntityKey,
  5732. false,
  5733. false
  5734. );
  5735. newSelectionState = newSelectionState.merge({
  5736. focusOffset: _endSelectionState.getEndOffset(),
  5737. isBackward: false
  5738. });
  5739. }
  5740. return newSelectionState;
  5741. }
  5742. function getEntityRemovalRange(
  5743. entityMap,
  5744. block,
  5745. selectionState,
  5746. direction,
  5747. entityKey,
  5748. isEntireSelectionWithinEntity,
  5749. isEntityAtStart
  5750. ) {
  5751. var start = selectionState.getStartOffset();
  5752. var end = selectionState.getEndOffset();
  5753. var entity = entityMap.__get(entityKey);
  5754. var mutability = entity.getMutability();
  5755. var sideToConsider = isEntityAtStart ? start : end;
  5756. // `MUTABLE` entities can just have the specified range of text removed
  5757. // directly. No adjustments are needed.
  5758. if (mutability === "MUTABLE") {
  5759. return selectionState;
  5760. }
  5761. // Find the entity range that overlaps with our removal range.
  5762. var entityRanges = getRangesForDraftEntity_1(block, entityKey).filter(
  5763. function(range) {
  5764. return sideToConsider <= range.end && sideToConsider >= range.start;
  5765. }
  5766. );
  5767. !(entityRanges.length == 1)
  5768. ? process.env.NODE_ENV !== "production"
  5769. ? invariant_1(
  5770. false,
  5771. "There should only be one entity range within this removal range."
  5772. )
  5773. : invariant_1(false)
  5774. : void 0;
  5775. var entityRange = entityRanges[0];
  5776. // For `IMMUTABLE` entity types, we will remove the entire entity range.
  5777. if (mutability === "IMMUTABLE") {
  5778. return selectionState.merge({
  5779. anchorOffset: entityRange.start,
  5780. focusOffset: entityRange.end,
  5781. isBackward: false
  5782. });
  5783. }
  5784. // For `SEGMENTED` entity types, determine the appropriate segment to
  5785. // remove.
  5786. if (!isEntireSelectionWithinEntity) {
  5787. if (isEntityAtStart) {
  5788. end = entityRange.end;
  5789. } else {
  5790. start = entityRange.start;
  5791. }
  5792. }
  5793. var removalRange = DraftEntitySegments_1.getRemovalRange(
  5794. start,
  5795. end,
  5796. block.getText().slice(entityRange.start, entityRange.end),
  5797. entityRange.start,
  5798. direction
  5799. );
  5800. return selectionState.merge({
  5801. anchorOffset: removalRange.start,
  5802. focusOffset: removalRange.end,
  5803. isBackward: false
  5804. });
  5805. }
  5806. var getCharacterRemovalRange_1 = getCharacterRemovalRange;
  5807. /**
  5808. * Copyright (c) 2013-present, Facebook, Inc.
  5809. * All rights reserved.
  5810. *
  5811. * This source code is licensed under the BSD-style license found in the
  5812. * LICENSE file in the root directory of this source tree. An additional grant
  5813. * of patent rights can be found in the PATENTS file in the same directory.
  5814. *
  5815. * @providesModule generateRandomKey
  5816. * @format
  5817. *
  5818. */
  5819. var seenKeys = {};
  5820. var MULTIPLIER = Math.pow(2, 24);
  5821. function generateRandomKey() {
  5822. var key = void 0;
  5823. while (key === undefined || seenKeys.hasOwnProperty(key) || !isNaN(+key)) {
  5824. key = Math.floor(Math.random() * MULTIPLIER).toString(32);
  5825. }
  5826. seenKeys[key] = true;
  5827. return key;
  5828. }
  5829. var generateRandomKey_1 = generateRandomKey;
  5830. var OrderedMap$1 = immutable.OrderedMap;
  5831. var randomizeContentBlockNodeKeys = function randomizeContentBlockNodeKeys(
  5832. blockMap
  5833. ) {
  5834. var newKeysRef = {};
  5835. // we keep track of root blocks in order to update subsequent sibling links
  5836. var lastRootBlock = void 0;
  5837. return OrderedMap$1(
  5838. blockMap
  5839. .withMutations(function(blockMapState) {
  5840. blockMapState.forEach(function(block, index) {
  5841. var oldKey = block.getKey();
  5842. var nextKey = block.getNextSiblingKey();
  5843. var prevKey = block.getPrevSiblingKey();
  5844. var childrenKeys = block.getChildKeys();
  5845. var parentKey = block.getParentKey();
  5846. // new key that we will use to build linking
  5847. var key = generateRandomKey_1();
  5848. // we will add it here to re-use it later
  5849. newKeysRef[oldKey] = key;
  5850. if (nextKey) {
  5851. var nextBlock = blockMapState.get(nextKey);
  5852. if (nextBlock) {
  5853. blockMapState.setIn([nextKey, "prevSibling"], key);
  5854. } else {
  5855. // this can happen when generating random keys for fragments
  5856. blockMapState.setIn([oldKey, "nextSibling"], null);
  5857. }
  5858. }
  5859. if (prevKey) {
  5860. var prevBlock = blockMapState.get(prevKey);
  5861. if (prevBlock) {
  5862. blockMapState.setIn([prevKey, "nextSibling"], key);
  5863. } else {
  5864. // this can happen when generating random keys for fragments
  5865. blockMapState.setIn([oldKey, "prevSibling"], null);
  5866. }
  5867. }
  5868. if (parentKey && blockMapState.get(parentKey)) {
  5869. var parentBlock = blockMapState.get(parentKey);
  5870. var parentChildrenList = parentBlock.getChildKeys();
  5871. blockMapState.setIn(
  5872. [parentKey, "children"],
  5873. parentChildrenList.set(
  5874. parentChildrenList.indexOf(block.getKey()),
  5875. key
  5876. )
  5877. );
  5878. } else {
  5879. // blocks will then be treated as root block nodes
  5880. blockMapState.setIn([oldKey, "parent"], null);
  5881. if (lastRootBlock) {
  5882. blockMapState.setIn([lastRootBlock.getKey(), "nextSibling"], key);
  5883. blockMapState.setIn(
  5884. [oldKey, "prevSibling"],
  5885. newKeysRef[lastRootBlock.getKey()]
  5886. );
  5887. }
  5888. lastRootBlock = blockMapState.get(oldKey);
  5889. }
  5890. childrenKeys.forEach(function(childKey) {
  5891. var childBlock = blockMapState.get(childKey);
  5892. if (childBlock) {
  5893. blockMapState.setIn([childKey, "parent"], key);
  5894. } else {
  5895. blockMapState.setIn(
  5896. [oldKey, "children"],
  5897. block.getChildKeys().filter(function(child) {
  5898. return child !== childKey;
  5899. })
  5900. );
  5901. }
  5902. });
  5903. });
  5904. })
  5905. .toArray()
  5906. .map(function(block) {
  5907. return [
  5908. newKeysRef[block.getKey()],
  5909. block.set("key", newKeysRef[block.getKey()])
  5910. ];
  5911. })
  5912. );
  5913. };
  5914. var randomizeContentBlockKeys = function randomizeContentBlockKeys(blockMap) {
  5915. return OrderedMap$1(
  5916. blockMap.toArray().map(function(block) {
  5917. var key = generateRandomKey_1();
  5918. return [key, block.set("key", key)];
  5919. })
  5920. );
  5921. };
  5922. var randomizeBlockMapKeys = function randomizeBlockMapKeys(blockMap) {
  5923. var isTreeBasedBlockMap = blockMap.first() instanceof ContentBlockNode_1;
  5924. if (!isTreeBasedBlockMap) {
  5925. return randomizeContentBlockKeys(blockMap);
  5926. }
  5927. return randomizeContentBlockNodeKeys(blockMap);
  5928. };
  5929. var randomizeBlockMapKeys_1 = randomizeBlockMapKeys;
  5930. function removeEntitiesAtEdges(contentState, selectionState) {
  5931. var blockMap = contentState.getBlockMap();
  5932. var entityMap = contentState.getEntityMap();
  5933. var updatedBlocks = {};
  5934. var startKey = selectionState.getStartKey();
  5935. var startOffset = selectionState.getStartOffset();
  5936. var startBlock = blockMap.get(startKey);
  5937. var updatedStart = removeForBlock(entityMap, startBlock, startOffset);
  5938. if (updatedStart !== startBlock) {
  5939. updatedBlocks[startKey] = updatedStart;
  5940. }
  5941. var endKey = selectionState.getEndKey();
  5942. var endOffset = selectionState.getEndOffset();
  5943. var endBlock = blockMap.get(endKey);
  5944. if (startKey === endKey) {
  5945. endBlock = updatedStart;
  5946. }
  5947. var updatedEnd = removeForBlock(entityMap, endBlock, endOffset);
  5948. if (updatedEnd !== endBlock) {
  5949. updatedBlocks[endKey] = updatedEnd;
  5950. }
  5951. if (!Object.keys(updatedBlocks).length) {
  5952. return contentState.set("selectionAfter", selectionState);
  5953. }
  5954. return contentState.merge({
  5955. blockMap: blockMap.merge(updatedBlocks),
  5956. selectionAfter: selectionState
  5957. });
  5958. }
  5959. function getRemovalRange(characters, key, offset) {
  5960. var removalRange;
  5961. findRangesImmutable_1(
  5962. characters,
  5963. function(a, b) {
  5964. return a.getEntity() === b.getEntity();
  5965. },
  5966. function(element) {
  5967. return element.getEntity() === key;
  5968. },
  5969. function(start, end) {
  5970. if (start <= offset && end >= offset) {
  5971. removalRange = { start: start, end: end };
  5972. }
  5973. }
  5974. );
  5975. !(typeof removalRange === "object")
  5976. ? process.env.NODE_ENV !== "production"
  5977. ? invariant_1(false, "Removal range must exist within character list.")
  5978. : invariant_1(false)
  5979. : void 0;
  5980. return removalRange;
  5981. }
  5982. function removeForBlock(entityMap, block, offset) {
  5983. var chars = block.getCharacterList();
  5984. var charBefore = offset > 0 ? chars.get(offset - 1) : undefined;
  5985. var charAfter = offset < chars.count() ? chars.get(offset) : undefined;
  5986. var entityBeforeCursor = charBefore ? charBefore.getEntity() : undefined;
  5987. var entityAfterCursor = charAfter ? charAfter.getEntity() : undefined;
  5988. if (entityAfterCursor && entityAfterCursor === entityBeforeCursor) {
  5989. var entity = entityMap.__get(entityAfterCursor);
  5990. if (entity.getMutability() !== "MUTABLE") {
  5991. var _getRemovalRange = getRemovalRange(chars, entityAfterCursor, offset),
  5992. start = _getRemovalRange.start,
  5993. end = _getRemovalRange.end;
  5994. var current;
  5995. while (start < end) {
  5996. current = chars.get(start);
  5997. chars = chars.set(
  5998. start,
  5999. CharacterMetadata_1.applyEntity(current, null)
  6000. );
  6001. start++;
  6002. }
  6003. return block.set("characterList", chars);
  6004. }
  6005. }
  6006. return block;
  6007. }
  6008. var removeEntitiesAtEdges_1 = removeEntitiesAtEdges;
  6009. var getContentStateFragment = function getContentStateFragment(
  6010. contentState,
  6011. selectionState
  6012. ) {
  6013. var startKey = selectionState.getStartKey();
  6014. var startOffset = selectionState.getStartOffset();
  6015. var endKey = selectionState.getEndKey();
  6016. var endOffset = selectionState.getEndOffset();
  6017. // Edge entities should be stripped to ensure that we don't preserve
  6018. // invalid partial entities when the fragment is reused. We do, however,
  6019. // preserve entities that are entirely within the selection range.
  6020. var contentWithoutEdgeEntities = removeEntitiesAtEdges_1(
  6021. contentState,
  6022. selectionState
  6023. );
  6024. var blockMap = contentWithoutEdgeEntities.getBlockMap();
  6025. var blockKeys = blockMap.keySeq();
  6026. var startIndex = blockKeys.indexOf(startKey);
  6027. var endIndex = blockKeys.indexOf(endKey) + 1;
  6028. return randomizeBlockMapKeys_1(
  6029. blockMap.slice(startIndex, endIndex).map(function(block, blockKey) {
  6030. var text = block.getText();
  6031. var chars = block.getCharacterList();
  6032. if (startKey === endKey) {
  6033. return block.merge({
  6034. text: text.slice(startOffset, endOffset),
  6035. characterList: chars.slice(startOffset, endOffset)
  6036. });
  6037. }
  6038. if (blockKey === startKey) {
  6039. return block.merge({
  6040. text: text.slice(startOffset),
  6041. characterList: chars.slice(startOffset)
  6042. });
  6043. }
  6044. if (blockKey === endKey) {
  6045. return block.merge({
  6046. text: text.slice(0, endOffset),
  6047. characterList: chars.slice(0, endOffset)
  6048. });
  6049. }
  6050. return block;
  6051. })
  6052. );
  6053. };
  6054. var getContentStateFragment_1 = getContentStateFragment;
  6055. /**
  6056. * Copyright (c) 2013-present, Facebook, Inc.
  6057. * All rights reserved.
  6058. *
  6059. * This source code is licensed under the BSD-style license found in the
  6060. * LICENSE file in the root directory of this source tree. An additional grant
  6061. * of patent rights can be found in the PATENTS file in the same directory.
  6062. *
  6063. * @providesModule insertIntoList
  6064. * @format
  6065. *
  6066. */
  6067. /**
  6068. * Maintain persistence for target list when appending and prepending.
  6069. */
  6070. function insertIntoList(targetList, toInsert, offset) {
  6071. if (offset === targetList.count()) {
  6072. toInsert.forEach(function(c) {
  6073. targetList = targetList.push(c);
  6074. });
  6075. } else if (offset === 0) {
  6076. toInsert.reverse().forEach(function(c) {
  6077. targetList = targetList.unshift(c);
  6078. });
  6079. } else {
  6080. var head = targetList.slice(0, offset);
  6081. var tail = targetList.slice(offset);
  6082. targetList = head.concat(toInsert, tail).toList();
  6083. }
  6084. return targetList;
  6085. }
  6086. var insertIntoList_1 = insertIntoList;
  6087. var List$2 = immutable.List;
  6088. var updateExistingBlock = function updateExistingBlock(
  6089. contentState,
  6090. selectionState,
  6091. blockMap,
  6092. fragmentBlock,
  6093. targetKey,
  6094. targetOffset
  6095. ) {
  6096. var targetBlock = blockMap.get(targetKey);
  6097. var text = targetBlock.getText();
  6098. var chars = targetBlock.getCharacterList();
  6099. var finalKey = targetKey;
  6100. var finalOffset = targetOffset + fragmentBlock.getText().length;
  6101. var newBlock = targetBlock.merge({
  6102. text:
  6103. text.slice(0, targetOffset) +
  6104. fragmentBlock.getText() +
  6105. text.slice(targetOffset),
  6106. characterList: insertIntoList_1(
  6107. chars,
  6108. fragmentBlock.getCharacterList(),
  6109. targetOffset
  6110. ),
  6111. data: fragmentBlock.getData()
  6112. });
  6113. return contentState.merge({
  6114. blockMap: blockMap.set(targetKey, newBlock),
  6115. selectionBefore: selectionState,
  6116. selectionAfter: selectionState.merge({
  6117. anchorKey: finalKey,
  6118. anchorOffset: finalOffset,
  6119. focusKey: finalKey,
  6120. focusOffset: finalOffset,
  6121. isBackward: false
  6122. })
  6123. });
  6124. };
  6125. /**
  6126. * Appends text/characterList from the fragment first block to
  6127. * target block.
  6128. */
  6129. var updateHead = function updateHead(block, targetOffset, fragment) {
  6130. var text = block.getText();
  6131. var chars = block.getCharacterList();
  6132. // Modify head portion of block.
  6133. var headText = text.slice(0, targetOffset);
  6134. var headCharacters = chars.slice(0, targetOffset);
  6135. var appendToHead = fragment.first();
  6136. return block.merge({
  6137. text: headText + appendToHead.getText(),
  6138. characterList: headCharacters.concat(appendToHead.getCharacterList()),
  6139. type: headText ? block.getType() : appendToHead.getType(),
  6140. data: appendToHead.getData()
  6141. });
  6142. };
  6143. /**
  6144. * Appends offset text/characterList from the target block to the last
  6145. * fragment block.
  6146. */
  6147. var updateTail = function updateTail(block, targetOffset, fragment) {
  6148. // Modify tail portion of block.
  6149. var text = block.getText();
  6150. var chars = block.getCharacterList();
  6151. // Modify head portion of block.
  6152. var blockSize = text.length;
  6153. var tailText = text.slice(targetOffset, blockSize);
  6154. var tailCharacters = chars.slice(targetOffset, blockSize);
  6155. var prependToTail = fragment.last();
  6156. return prependToTail.merge({
  6157. text: prependToTail.getText() + tailText,
  6158. characterList: prependToTail.getCharacterList().concat(tailCharacters),
  6159. data: prependToTail.getData()
  6160. });
  6161. };
  6162. var getRootBlocks = function getRootBlocks(block, blockMap) {
  6163. var headKey = block.getKey();
  6164. var rootBlock = block;
  6165. var rootBlocks = [];
  6166. // sometimes the fragment head block will not be part of the blockMap itself this can happen when
  6167. // the fragment head is used to update the target block, however when this does not happen we need
  6168. // to make sure that we include it on the rootBlocks since the first block of a fragment is always a
  6169. // fragment root block
  6170. if (blockMap.get(headKey)) {
  6171. rootBlocks.push(headKey);
  6172. }
  6173. while (rootBlock && rootBlock.getNextSiblingKey()) {
  6174. var lastSiblingKey = rootBlock.getNextSiblingKey();
  6175. if (!lastSiblingKey) {
  6176. break;
  6177. }
  6178. rootBlocks.push(lastSiblingKey);
  6179. rootBlock = blockMap.get(lastSiblingKey);
  6180. }
  6181. return rootBlocks;
  6182. };
  6183. var updateBlockMapLinks = function updateBlockMapLinks(
  6184. blockMap,
  6185. originalBlockMap,
  6186. targetBlock,
  6187. fragmentHeadBlock
  6188. ) {
  6189. return blockMap.withMutations(function(blockMapState) {
  6190. var targetKey = targetBlock.getKey();
  6191. var headKey = fragmentHeadBlock.getKey();
  6192. var targetNextKey = targetBlock.getNextSiblingKey();
  6193. var targetParentKey = targetBlock.getParentKey();
  6194. var fragmentRootBlocks = getRootBlocks(fragmentHeadBlock, blockMap);
  6195. var lastRootFragmentBlockKey =
  6196. fragmentRootBlocks[fragmentRootBlocks.length - 1];
  6197. if (blockMapState.get(headKey)) {
  6198. // update the fragment head when it is part of the blockMap otherwise
  6199. blockMapState.setIn([targetKey, "nextSibling"], headKey);
  6200. blockMapState.setIn([headKey, "prevSibling"], targetKey);
  6201. } else {
  6202. // update the target block that had the fragment head contents merged into it
  6203. blockMapState.setIn(
  6204. [targetKey, "nextSibling"],
  6205. fragmentHeadBlock.getNextSiblingKey()
  6206. );
  6207. blockMapState.setIn(
  6208. [fragmentHeadBlock.getNextSiblingKey(), "prevSibling"],
  6209. targetKey
  6210. );
  6211. }
  6212. // update the last root block fragment
  6213. blockMapState.setIn(
  6214. [lastRootFragmentBlockKey, "nextSibling"],
  6215. targetNextKey
  6216. );
  6217. // update the original target next block
  6218. if (targetNextKey) {
  6219. blockMapState.setIn(
  6220. [targetNextKey, "prevSibling"],
  6221. lastRootFragmentBlockKey
  6222. );
  6223. }
  6224. // update fragment parent links
  6225. fragmentRootBlocks.forEach(function(blockKey) {
  6226. return blockMapState.setIn([blockKey, "parent"], targetParentKey);
  6227. });
  6228. // update targetBlock parent child links
  6229. if (targetParentKey) {
  6230. var targetParent = blockMap.get(targetParentKey);
  6231. var originalTargetParentChildKeys = targetParent.getChildKeys();
  6232. var targetBlockIndex = originalTargetParentChildKeys.indexOf(targetKey);
  6233. var insertionIndex = targetBlockIndex + 1;
  6234. var newChildrenKeysArray = originalTargetParentChildKeys.toArray();
  6235. // insert fragment children
  6236. newChildrenKeysArray.splice.apply(
  6237. newChildrenKeysArray,
  6238. [insertionIndex, 0].concat(fragmentRootBlocks)
  6239. );
  6240. blockMapState.setIn(
  6241. [targetParentKey, "children"],
  6242. List$2(newChildrenKeysArray)
  6243. );
  6244. }
  6245. });
  6246. };
  6247. var insertFragment = function insertFragment(
  6248. contentState,
  6249. selectionState,
  6250. blockMap,
  6251. fragment,
  6252. targetKey,
  6253. targetOffset
  6254. ) {
  6255. var isTreeBasedBlockMap = blockMap.first() instanceof ContentBlockNode_1;
  6256. var newBlockArr = [];
  6257. var fragmentSize = fragment.size;
  6258. var target = blockMap.get(targetKey);
  6259. var head = fragment.first();
  6260. var tail = fragment.last();
  6261. var finalOffset = tail.getLength();
  6262. var finalKey = tail.getKey();
  6263. var shouldNotUpdateFromFragmentBlock =
  6264. isTreeBasedBlockMap &&
  6265. (!target.getChildKeys().isEmpty() || !head.getChildKeys().isEmpty());
  6266. blockMap.forEach(function(block, blockKey) {
  6267. if (blockKey !== targetKey) {
  6268. newBlockArr.push(block);
  6269. return;
  6270. }
  6271. if (shouldNotUpdateFromFragmentBlock) {
  6272. newBlockArr.push(block);
  6273. } else {
  6274. newBlockArr.push(updateHead(block, targetOffset, fragment));
  6275. }
  6276. // Insert fragment blocks after the head and before the tail.
  6277. fragment
  6278. // when we are updating the target block with the head fragment block we skip the first fragment
  6279. // head since its contents have already been merged with the target block otherwise we include
  6280. // the whole fragment
  6281. .slice(shouldNotUpdateFromFragmentBlock ? 0 : 1, fragmentSize - 1)
  6282. .forEach(function(fragmentBlock) {
  6283. return newBlockArr.push(fragmentBlock);
  6284. });
  6285. // update tail
  6286. newBlockArr.push(updateTail(block, targetOffset, fragment));
  6287. });
  6288. var updatedBlockMap = BlockMapBuilder_1.createFromArray(newBlockArr);
  6289. if (isTreeBasedBlockMap) {
  6290. updatedBlockMap = updateBlockMapLinks(
  6291. updatedBlockMap,
  6292. blockMap,
  6293. target,
  6294. head
  6295. );
  6296. }
  6297. return contentState.merge({
  6298. blockMap: updatedBlockMap,
  6299. selectionBefore: selectionState,
  6300. selectionAfter: selectionState.merge({
  6301. anchorKey: finalKey,
  6302. anchorOffset: finalOffset,
  6303. focusKey: finalKey,
  6304. focusOffset: finalOffset,
  6305. isBackward: false
  6306. })
  6307. });
  6308. };
  6309. var insertFragmentIntoContentState = function insertFragmentIntoContentState(
  6310. contentState,
  6311. selectionState,
  6312. fragmentBlockMap
  6313. ) {
  6314. !selectionState.isCollapsed()
  6315. ? process.env.NODE_ENV !== "production"
  6316. ? invariant_1(
  6317. false,
  6318. "`insertFragment` should only be called with a collapsed selection state."
  6319. )
  6320. : invariant_1(false)
  6321. : void 0;
  6322. var blockMap = contentState.getBlockMap();
  6323. var fragment = randomizeBlockMapKeys_1(fragmentBlockMap);
  6324. var targetKey = selectionState.getStartKey();
  6325. var targetOffset = selectionState.getStartOffset();
  6326. var targetBlock = blockMap.get(targetKey);
  6327. if (targetBlock instanceof ContentBlockNode_1) {
  6328. !targetBlock.getChildKeys().isEmpty()
  6329. ? process.env.NODE_ENV !== "production"
  6330. ? invariant_1(
  6331. false,
  6332. "`insertFragment` should not be called when a container node is selected."
  6333. )
  6334. : invariant_1(false)
  6335. : void 0;
  6336. }
  6337. // When we insert a fragment with a single block we simply update the target block
  6338. // with the contents of the inserted fragment block
  6339. if (fragment.size === 1) {
  6340. return updateExistingBlock(
  6341. contentState,
  6342. selectionState,
  6343. blockMap,
  6344. fragment.first(),
  6345. targetKey,
  6346. targetOffset
  6347. );
  6348. }
  6349. return insertFragment(
  6350. contentState,
  6351. selectionState,
  6352. blockMap,
  6353. fragment,
  6354. targetKey,
  6355. targetOffset
  6356. );
  6357. };
  6358. var insertFragmentIntoContentState_1 = insertFragmentIntoContentState;
  6359. var Repeat$2 = immutable.Repeat;
  6360. function insertTextIntoContentState(
  6361. contentState,
  6362. selectionState,
  6363. text,
  6364. characterMetadata
  6365. ) {
  6366. !selectionState.isCollapsed()
  6367. ? process.env.NODE_ENV !== "production"
  6368. ? invariant_1(
  6369. false,
  6370. "`insertText` should only be called with a collapsed range."
  6371. )
  6372. : invariant_1(false)
  6373. : void 0;
  6374. var len = text.length;
  6375. if (!len) {
  6376. return contentState;
  6377. }
  6378. var blockMap = contentState.getBlockMap();
  6379. var key = selectionState.getStartKey();
  6380. var offset = selectionState.getStartOffset();
  6381. var block = blockMap.get(key);
  6382. var blockText = block.getText();
  6383. var newBlock = block.merge({
  6384. text:
  6385. blockText.slice(0, offset) +
  6386. text +
  6387. blockText.slice(offset, block.getLength()),
  6388. characterList: insertIntoList_1(
  6389. block.getCharacterList(),
  6390. Repeat$2(characterMetadata, len).toList(),
  6391. offset
  6392. )
  6393. });
  6394. var newOffset = offset + len;
  6395. return contentState.merge({
  6396. blockMap: blockMap.set(key, newBlock),
  6397. selectionAfter: selectionState.merge({
  6398. anchorOffset: newOffset,
  6399. focusOffset: newOffset
  6400. })
  6401. });
  6402. }
  6403. var insertTextIntoContentState_1 = insertTextIntoContentState;
  6404. var Map$4 = immutable.Map;
  6405. function modifyBlockForContentState(contentState, selectionState, operation) {
  6406. var startKey = selectionState.getStartKey();
  6407. var endKey = selectionState.getEndKey();
  6408. var blockMap = contentState.getBlockMap();
  6409. var newBlocks = blockMap
  6410. .toSeq()
  6411. .skipUntil(function(_, k) {
  6412. return k === startKey;
  6413. })
  6414. .takeUntil(function(_, k) {
  6415. return k === endKey;
  6416. })
  6417. .concat(Map$4([[endKey, blockMap.get(endKey)]]))
  6418. .map(operation);
  6419. return contentState.merge({
  6420. blockMap: blockMap.merge(newBlocks),
  6421. selectionBefore: selectionState,
  6422. selectionAfter: selectionState
  6423. });
  6424. }
  6425. var modifyBlockForContentState_1 = modifyBlockForContentState;
  6426. /**
  6427. * Copyright (c) 2013-present, Facebook, Inc.
  6428. * All rights reserved.
  6429. *
  6430. * This source code is licensed under the BSD-style license found in the
  6431. * LICENSE file in the root directory of this source tree. An additional grant
  6432. * of patent rights can be found in the PATENTS file in the same directory.
  6433. *
  6434. * @providesModule getNextDelimiterBlockKey
  6435. * @format
  6436. *
  6437. *
  6438. * This is unstable and not part of the public API and should not be used by
  6439. * production systems. This file may be update/removed without notice.
  6440. */
  6441. var getNextDelimiterBlockKey = function getNextDelimiterBlockKey(
  6442. block,
  6443. blockMap
  6444. ) {
  6445. var isExperimentalTreeBlock = block instanceof ContentBlockNode_1;
  6446. if (!isExperimentalTreeBlock) {
  6447. return null;
  6448. }
  6449. var nextSiblingKey = block.getNextSiblingKey();
  6450. if (nextSiblingKey) {
  6451. return nextSiblingKey;
  6452. }
  6453. var parent = block.getParentKey();
  6454. if (!parent) {
  6455. return null;
  6456. }
  6457. var nextNonDescendantBlock = blockMap.get(parent);
  6458. while (
  6459. nextNonDescendantBlock &&
  6460. !nextNonDescendantBlock.getNextSiblingKey()
  6461. ) {
  6462. var parentKey = nextNonDescendantBlock.getParentKey();
  6463. nextNonDescendantBlock = parentKey ? blockMap.get(parentKey) : null;
  6464. }
  6465. if (!nextNonDescendantBlock) {
  6466. return null;
  6467. }
  6468. return nextNonDescendantBlock.getNextSiblingKey();
  6469. };
  6470. var getNextDelimiterBlockKey_1 = getNextDelimiterBlockKey;
  6471. var List$3 = immutable.List,
  6472. Map$5 = immutable.Map;
  6473. var transformBlock = function transformBlock(key, blockMap, func) {
  6474. if (!key) {
  6475. return;
  6476. }
  6477. var block = blockMap.get(key);
  6478. if (!block) {
  6479. return;
  6480. }
  6481. blockMap.set(key, func(block));
  6482. };
  6483. /**
  6484. * Ancestors needs to be preserved when there are non selected
  6485. * children to make sure we do not leave any orphans behind
  6486. */
  6487. var getAncestorsKeys = function getAncestorsKeys(blockKey, blockMap) {
  6488. var parents = [];
  6489. if (!blockKey) {
  6490. return parents;
  6491. }
  6492. var blockNode = blockMap.get(blockKey);
  6493. while (blockNode && blockNode.getParentKey()) {
  6494. var parentKey = blockNode.getParentKey();
  6495. if (parentKey) {
  6496. parents.push(parentKey);
  6497. }
  6498. blockNode = parentKey ? blockMap.get(parentKey) : null;
  6499. }
  6500. return parents;
  6501. };
  6502. /**
  6503. * Get all next delimiter keys until we hit a root delimiter and return
  6504. * an array of key references
  6505. */
  6506. var getNextDelimitersBlockKeys = function getNextDelimitersBlockKeys(
  6507. block,
  6508. blockMap
  6509. ) {
  6510. var nextDelimiters = [];
  6511. if (!block) {
  6512. return nextDelimiters;
  6513. }
  6514. var nextDelimiter = getNextDelimiterBlockKey_1(block, blockMap);
  6515. while (nextDelimiter && blockMap.get(nextDelimiter)) {
  6516. var _block = blockMap.get(nextDelimiter);
  6517. nextDelimiters.push(nextDelimiter);
  6518. // we do not need to keep checking all root node siblings, just the first occurance
  6519. nextDelimiter = _block.getParentKey()
  6520. ? getNextDelimiterBlockKey_1(_block, blockMap)
  6521. : null;
  6522. }
  6523. return nextDelimiters;
  6524. };
  6525. var getNextValidSibling = function getNextValidSibling(
  6526. block,
  6527. blockMap,
  6528. originalBlockMap
  6529. ) {
  6530. if (!block) {
  6531. return null;
  6532. }
  6533. // note that we need to make sure we refer to the original block since this
  6534. // function is called within a withMutations
  6535. var nextValidSiblingKey = originalBlockMap
  6536. .get(block.getKey())
  6537. .getNextSiblingKey();
  6538. while (nextValidSiblingKey && !blockMap.get(nextValidSiblingKey)) {
  6539. nextValidSiblingKey =
  6540. originalBlockMap.get(nextValidSiblingKey).getNextSiblingKey() || null;
  6541. }
  6542. return nextValidSiblingKey;
  6543. };
  6544. var getPrevValidSibling = function getPrevValidSibling(
  6545. block,
  6546. blockMap,
  6547. originalBlockMap
  6548. ) {
  6549. if (!block) {
  6550. return null;
  6551. }
  6552. // note that we need to make sure we refer to the original block since this
  6553. // function is called within a withMutations
  6554. var prevValidSiblingKey = originalBlockMap
  6555. .get(block.getKey())
  6556. .getPrevSiblingKey();
  6557. while (prevValidSiblingKey && !blockMap.get(prevValidSiblingKey)) {
  6558. prevValidSiblingKey =
  6559. originalBlockMap.get(prevValidSiblingKey).getPrevSiblingKey() || null;
  6560. }
  6561. return prevValidSiblingKey;
  6562. };
  6563. var updateBlockMapLinks$1 = function updateBlockMapLinks(
  6564. blockMap,
  6565. startBlock,
  6566. endBlock,
  6567. originalBlockMap
  6568. ) {
  6569. return blockMap.withMutations(function(blocks) {
  6570. // update start block if its retained
  6571. transformBlock(startBlock.getKey(), blocks, function(block) {
  6572. return block.merge({
  6573. nextSibling: getNextValidSibling(startBlock, blocks, originalBlockMap),
  6574. prevSibling: getPrevValidSibling(startBlock, blocks, originalBlockMap)
  6575. });
  6576. });
  6577. // update endblock if its retained
  6578. transformBlock(endBlock.getKey(), blocks, function(block) {
  6579. return block.merge({
  6580. nextSibling: getNextValidSibling(endBlock, blocks, originalBlockMap),
  6581. prevSibling: getPrevValidSibling(endBlock, blocks, originalBlockMap)
  6582. });
  6583. });
  6584. // update start block parent ancestors
  6585. getAncestorsKeys(startBlock.getKey(), originalBlockMap).forEach(function(
  6586. parentKey
  6587. ) {
  6588. return transformBlock(parentKey, blocks, function(block) {
  6589. return block.merge({
  6590. children: block.getChildKeys().filter(function(key) {
  6591. return blocks.get(key);
  6592. }),
  6593. nextSibling: getNextValidSibling(block, blocks, originalBlockMap),
  6594. prevSibling: getPrevValidSibling(block, blocks, originalBlockMap)
  6595. });
  6596. });
  6597. });
  6598. // update start block next - can only happen if startBlock == endBlock
  6599. transformBlock(startBlock.getNextSiblingKey(), blocks, function(block) {
  6600. return block.merge({
  6601. prevSibling: startBlock.getPrevSiblingKey()
  6602. });
  6603. });
  6604. // update start block prev
  6605. transformBlock(startBlock.getPrevSiblingKey(), blocks, function(block) {
  6606. return block.merge({
  6607. nextSibling: getNextValidSibling(startBlock, blocks, originalBlockMap)
  6608. });
  6609. });
  6610. // update end block next
  6611. transformBlock(endBlock.getNextSiblingKey(), blocks, function(block) {
  6612. return block.merge({
  6613. prevSibling: getPrevValidSibling(endBlock, blocks, originalBlockMap)
  6614. });
  6615. });
  6616. // update end block prev
  6617. transformBlock(endBlock.getPrevSiblingKey(), blocks, function(block) {
  6618. return block.merge({
  6619. nextSibling: endBlock.getNextSiblingKey()
  6620. });
  6621. });
  6622. // update end block parent ancestors
  6623. getAncestorsKeys(endBlock.getKey(), originalBlockMap).forEach(function(
  6624. parentKey
  6625. ) {
  6626. transformBlock(parentKey, blocks, function(block) {
  6627. return block.merge({
  6628. children: block.getChildKeys().filter(function(key) {
  6629. return blocks.get(key);
  6630. }),
  6631. nextSibling: getNextValidSibling(block, blocks, originalBlockMap),
  6632. prevSibling: getPrevValidSibling(block, blocks, originalBlockMap)
  6633. });
  6634. });
  6635. });
  6636. // update next delimiters all the way to a root delimiter
  6637. getNextDelimitersBlockKeys(endBlock, originalBlockMap).forEach(function(
  6638. delimiterKey
  6639. ) {
  6640. return transformBlock(delimiterKey, blocks, function(block) {
  6641. return block.merge({
  6642. nextSibling: getNextValidSibling(block, blocks, originalBlockMap),
  6643. prevSibling: getPrevValidSibling(block, blocks, originalBlockMap)
  6644. });
  6645. });
  6646. });
  6647. });
  6648. };
  6649. var removeRangeFromContentState = function removeRangeFromContentState(
  6650. contentState,
  6651. selectionState
  6652. ) {
  6653. if (selectionState.isCollapsed()) {
  6654. return contentState;
  6655. }
  6656. var blockMap = contentState.getBlockMap();
  6657. var startKey = selectionState.getStartKey();
  6658. var startOffset = selectionState.getStartOffset();
  6659. var endKey = selectionState.getEndKey();
  6660. var endOffset = selectionState.getEndOffset();
  6661. var startBlock = blockMap.get(startKey);
  6662. var endBlock = blockMap.get(endKey);
  6663. // we assume that ContentBlockNode and ContentBlocks are not mixed together
  6664. var isExperimentalTreeBlock = startBlock instanceof ContentBlockNode_1;
  6665. // used to retain blocks that should not be deleted to avoid orphan children
  6666. var parentAncestors = [];
  6667. if (isExperimentalTreeBlock) {
  6668. var endBlockchildrenKeys = endBlock.getChildKeys();
  6669. var endBlockAncestors = getAncestorsKeys(endKey, blockMap);
  6670. // endBlock has unselected sibblings so we can not remove its ancestors parents
  6671. if (endBlock.getNextSiblingKey()) {
  6672. parentAncestors = parentAncestors.concat(endBlockAncestors);
  6673. }
  6674. // endBlock has children so can not remove this block or any of its ancestors
  6675. if (!endBlockchildrenKeys.isEmpty()) {
  6676. parentAncestors = parentAncestors.concat(
  6677. endBlockAncestors.concat([endKey])
  6678. );
  6679. }
  6680. // we need to retain all ancestors of the next delimiter block
  6681. parentAncestors = parentAncestors.concat(
  6682. getAncestorsKeys(getNextDelimiterBlockKey_1(endBlock, blockMap), blockMap)
  6683. );
  6684. }
  6685. var characterList = void 0;
  6686. if (startBlock === endBlock) {
  6687. characterList = removeFromList(
  6688. startBlock.getCharacterList(),
  6689. startOffset,
  6690. endOffset
  6691. );
  6692. } else {
  6693. characterList = startBlock
  6694. .getCharacterList()
  6695. .slice(0, startOffset)
  6696. .concat(endBlock.getCharacterList().slice(endOffset));
  6697. }
  6698. var modifiedStart = startBlock.merge({
  6699. text:
  6700. startBlock.getText().slice(0, startOffset) +
  6701. endBlock.getText().slice(endOffset),
  6702. characterList: characterList
  6703. });
  6704. var newBlocks = blockMap
  6705. .toSeq()
  6706. .skipUntil(function(_, k) {
  6707. return k === startKey;
  6708. })
  6709. .takeUntil(function(_, k) {
  6710. return k === endKey;
  6711. })
  6712. .filter(function(_, k) {
  6713. return parentAncestors.indexOf(k) === -1;
  6714. })
  6715. .concat(Map$5([[endKey, null]]))
  6716. .map(function(_, k) {
  6717. return k === startKey ? modifiedStart : null;
  6718. });
  6719. var updatedBlockMap = blockMap.merge(newBlocks).filter(function(block) {
  6720. return !!block;
  6721. });
  6722. if (isExperimentalTreeBlock) {
  6723. updatedBlockMap = updateBlockMapLinks$1(
  6724. updatedBlockMap,
  6725. startBlock,
  6726. endBlock,
  6727. blockMap
  6728. );
  6729. }
  6730. return contentState.merge({
  6731. blockMap: updatedBlockMap,
  6732. selectionBefore: selectionState,
  6733. selectionAfter: selectionState.merge({
  6734. anchorKey: startKey,
  6735. anchorOffset: startOffset,
  6736. focusKey: startKey,
  6737. focusOffset: startOffset,
  6738. isBackward: false
  6739. })
  6740. });
  6741. };
  6742. /**
  6743. * Maintain persistence for target list when removing characters on the
  6744. * head and tail of the character list.
  6745. */
  6746. var removeFromList = function removeFromList(
  6747. targetList,
  6748. startOffset,
  6749. endOffset
  6750. ) {
  6751. if (startOffset === 0) {
  6752. while (startOffset < endOffset) {
  6753. targetList = targetList.shift();
  6754. startOffset++;
  6755. }
  6756. } else if (endOffset === targetList.count()) {
  6757. while (endOffset > startOffset) {
  6758. targetList = targetList.pop();
  6759. endOffset--;
  6760. }
  6761. } else {
  6762. var head = targetList.slice(0, startOffset);
  6763. var tail = targetList.slice(endOffset);
  6764. targetList = head.concat(tail).toList();
  6765. }
  6766. return targetList;
  6767. };
  6768. var removeRangeFromContentState_1 = removeRangeFromContentState;
  6769. var List$4 = immutable.List,
  6770. Map$6 = immutable.Map;
  6771. var transformBlock$1 = function transformBlock(key, blockMap, func) {
  6772. if (!key) {
  6773. return;
  6774. }
  6775. var block = blockMap.get(key);
  6776. if (!block) {
  6777. return;
  6778. }
  6779. blockMap.set(key, func(block));
  6780. };
  6781. var updateBlockMapLinks$2 = function updateBlockMapLinks(
  6782. blockMap,
  6783. originalBlock,
  6784. belowBlock
  6785. ) {
  6786. return blockMap.withMutations(function(blocks) {
  6787. var originalBlockKey = originalBlock.getKey();
  6788. var belowBlockKey = belowBlock.getKey();
  6789. // update block parent
  6790. transformBlock$1(originalBlock.getParentKey(), blocks, function(block) {
  6791. var parentChildrenList = block.getChildKeys();
  6792. var insertionIndex = parentChildrenList.indexOf(originalBlockKey) + 1;
  6793. var newChildrenArray = parentChildrenList.toArray();
  6794. newChildrenArray.splice(insertionIndex, 0, belowBlockKey);
  6795. return block.merge({
  6796. children: List$4(newChildrenArray)
  6797. });
  6798. });
  6799. // update original next block
  6800. transformBlock$1(originalBlock.getNextSiblingKey(), blocks, function(
  6801. block
  6802. ) {
  6803. return block.merge({
  6804. prevSibling: belowBlockKey
  6805. });
  6806. });
  6807. // update original block
  6808. transformBlock$1(originalBlockKey, blocks, function(block) {
  6809. return block.merge({
  6810. nextSibling: belowBlockKey
  6811. });
  6812. });
  6813. // update below block
  6814. transformBlock$1(belowBlockKey, blocks, function(block) {
  6815. return block.merge({
  6816. prevSibling: originalBlockKey
  6817. });
  6818. });
  6819. });
  6820. };
  6821. var splitBlockInContentState = function splitBlockInContentState(
  6822. contentState,
  6823. selectionState
  6824. ) {
  6825. !selectionState.isCollapsed()
  6826. ? process.env.NODE_ENV !== "production"
  6827. ? invariant_1(false, "Selection range must be collapsed.")
  6828. : invariant_1(false)
  6829. : void 0;
  6830. var key = selectionState.getAnchorKey();
  6831. var offset = selectionState.getAnchorOffset();
  6832. var blockMap = contentState.getBlockMap();
  6833. var blockToSplit = blockMap.get(key);
  6834. var text = blockToSplit.getText();
  6835. var chars = blockToSplit.getCharacterList();
  6836. var keyBelow = generateRandomKey_1();
  6837. var isExperimentalTreeBlock = blockToSplit instanceof ContentBlockNode_1;
  6838. var blockAbove = blockToSplit.merge({
  6839. text: text.slice(0, offset),
  6840. characterList: chars.slice(0, offset)
  6841. });
  6842. var blockBelow = blockAbove.merge({
  6843. key: keyBelow,
  6844. text: text.slice(offset),
  6845. characterList: chars.slice(offset),
  6846. data: Map$6()
  6847. });
  6848. var blocksBefore = blockMap.toSeq().takeUntil(function(v) {
  6849. return v === blockToSplit;
  6850. });
  6851. var blocksAfter = blockMap
  6852. .toSeq()
  6853. .skipUntil(function(v) {
  6854. return v === blockToSplit;
  6855. })
  6856. .rest();
  6857. var newBlocks = blocksBefore
  6858. .concat(
  6859. [
  6860. [key, blockAbove],
  6861. [keyBelow, blockBelow]
  6862. ],
  6863. blocksAfter
  6864. )
  6865. .toOrderedMap();
  6866. if (isExperimentalTreeBlock) {
  6867. !blockToSplit.getChildKeys().isEmpty()
  6868. ? process.env.NODE_ENV !== "production"
  6869. ? invariant_1(false, "ContentBlockNode must not have children")
  6870. : invariant_1(false)
  6871. : void 0;
  6872. newBlocks = updateBlockMapLinks$2(newBlocks, blockAbove, blockBelow);
  6873. }
  6874. return contentState.merge({
  6875. blockMap: newBlocks,
  6876. selectionBefore: selectionState,
  6877. selectionAfter: selectionState.merge({
  6878. anchorKey: keyBelow,
  6879. anchorOffset: 0,
  6880. focusKey: keyBelow,
  6881. focusOffset: 0,
  6882. isBackward: false
  6883. })
  6884. });
  6885. };
  6886. var splitBlockInContentState_1 = splitBlockInContentState;
  6887. var OrderedSet$3 = immutable.OrderedSet;
  6888. /**
  6889. * `DraftModifier` provides a set of convenience methods that apply
  6890. * modifications to a `ContentState` object based on a target `SelectionState`.
  6891. *
  6892. * Any change to a `ContentState` should be decomposable into a series of
  6893. * transaction functions that apply the required changes and return output
  6894. * `ContentState` objects.
  6895. *
  6896. * These functions encapsulate some of the most common transaction sequences.
  6897. */
  6898. var DraftModifier = {
  6899. replaceText: function replaceText(
  6900. contentState,
  6901. rangeToReplace,
  6902. text,
  6903. inlineStyle,
  6904. entityKey
  6905. ) {
  6906. var withoutEntities = removeEntitiesAtEdges_1(contentState, rangeToReplace);
  6907. var withoutText = removeRangeFromContentState_1(
  6908. withoutEntities,
  6909. rangeToReplace
  6910. );
  6911. var character = CharacterMetadata_1.create({
  6912. style: inlineStyle || OrderedSet$3(),
  6913. entity: entityKey || null
  6914. });
  6915. return insertTextIntoContentState_1(
  6916. withoutText,
  6917. withoutText.getSelectionAfter(),
  6918. text,
  6919. character
  6920. );
  6921. },
  6922. insertText: function insertText(
  6923. contentState,
  6924. targetRange,
  6925. text,
  6926. inlineStyle,
  6927. entityKey
  6928. ) {
  6929. !targetRange.isCollapsed()
  6930. ? process.env.NODE_ENV !== "production"
  6931. ? invariant_1(false, "Target range must be collapsed for `insertText`.")
  6932. : invariant_1(false)
  6933. : void 0;
  6934. return DraftModifier.replaceText(
  6935. contentState,
  6936. targetRange,
  6937. text,
  6938. inlineStyle,
  6939. entityKey
  6940. );
  6941. },
  6942. moveText: function moveText(contentState, removalRange, targetRange) {
  6943. var movedFragment = getContentStateFragment_1(contentState, removalRange);
  6944. var afterRemoval = DraftModifier.removeRange(
  6945. contentState,
  6946. removalRange,
  6947. "backward"
  6948. );
  6949. return DraftModifier.replaceWithFragment(
  6950. afterRemoval,
  6951. targetRange,
  6952. movedFragment
  6953. );
  6954. },
  6955. replaceWithFragment: function replaceWithFragment(
  6956. contentState,
  6957. targetRange,
  6958. fragment
  6959. ) {
  6960. var withoutEntities = removeEntitiesAtEdges_1(contentState, targetRange);
  6961. var withoutText = removeRangeFromContentState_1(
  6962. withoutEntities,
  6963. targetRange
  6964. );
  6965. return insertFragmentIntoContentState_1(
  6966. withoutText,
  6967. withoutText.getSelectionAfter(),
  6968. fragment
  6969. );
  6970. },
  6971. removeRange: function removeRange(
  6972. contentState,
  6973. rangeToRemove,
  6974. removalDirection
  6975. ) {
  6976. var startKey = void 0,
  6977. endKey = void 0,
  6978. startBlock = void 0,
  6979. endBlock = void 0;
  6980. if (rangeToRemove.getIsBackward()) {
  6981. rangeToRemove = rangeToRemove.merge({
  6982. anchorKey: rangeToRemove.getFocusKey(),
  6983. anchorOffset: rangeToRemove.getFocusOffset(),
  6984. focusKey: rangeToRemove.getAnchorKey(),
  6985. focusOffset: rangeToRemove.getAnchorOffset(),
  6986. isBackward: false
  6987. });
  6988. }
  6989. startKey = rangeToRemove.getAnchorKey();
  6990. endKey = rangeToRemove.getFocusKey();
  6991. startBlock = contentState.getBlockForKey(startKey);
  6992. endBlock = contentState.getBlockForKey(endKey);
  6993. var startOffset = rangeToRemove.getStartOffset();
  6994. var endOffset = rangeToRemove.getEndOffset();
  6995. var startEntityKey = startBlock.getEntityAt(startOffset);
  6996. var endEntityKey = endBlock.getEntityAt(endOffset - 1);
  6997. // Check whether the selection state overlaps with a single entity.
  6998. // If so, try to remove the appropriate substring of the entity text.
  6999. if (startKey === endKey) {
  7000. if (startEntityKey && startEntityKey === endEntityKey) {
  7001. var _adjustedRemovalRange = getCharacterRemovalRange_1(
  7002. contentState.getEntityMap(),
  7003. startBlock,
  7004. endBlock,
  7005. rangeToRemove,
  7006. removalDirection
  7007. );
  7008. return removeRangeFromContentState_1(
  7009. contentState,
  7010. _adjustedRemovalRange
  7011. );
  7012. }
  7013. }
  7014. var adjustedRemovalRange = rangeToRemove;
  7015. var withoutEntities = removeEntitiesAtEdges_1(
  7016. contentState,
  7017. adjustedRemovalRange
  7018. );
  7019. return removeRangeFromContentState_1(withoutEntities, adjustedRemovalRange);
  7020. },
  7021. splitBlock: function splitBlock(contentState, selectionState) {
  7022. var withoutEntities = removeEntitiesAtEdges_1(contentState, selectionState);
  7023. var withoutText = removeRangeFromContentState_1(
  7024. withoutEntities,
  7025. selectionState
  7026. );
  7027. return splitBlockInContentState_1(
  7028. withoutText,
  7029. withoutText.getSelectionAfter()
  7030. );
  7031. },
  7032. applyInlineStyle: function applyInlineStyle(
  7033. contentState,
  7034. selectionState,
  7035. inlineStyle
  7036. ) {
  7037. return ContentStateInlineStyle_1.add(
  7038. contentState,
  7039. selectionState,
  7040. inlineStyle
  7041. );
  7042. },
  7043. removeInlineStyle: function removeInlineStyle(
  7044. contentState,
  7045. selectionState,
  7046. inlineStyle
  7047. ) {
  7048. return ContentStateInlineStyle_1.remove(
  7049. contentState,
  7050. selectionState,
  7051. inlineStyle
  7052. );
  7053. },
  7054. setBlockType: function setBlockType(contentState, selectionState, blockType) {
  7055. return modifyBlockForContentState_1(contentState, selectionState, function(
  7056. block
  7057. ) {
  7058. return block.merge({ type: blockType, depth: 0 });
  7059. });
  7060. },
  7061. setBlockData: function setBlockData(contentState, selectionState, blockData) {
  7062. return modifyBlockForContentState_1(contentState, selectionState, function(
  7063. block
  7064. ) {
  7065. return block.merge({ data: blockData });
  7066. });
  7067. },
  7068. mergeBlockData: function mergeBlockData(
  7069. contentState,
  7070. selectionState,
  7071. blockData
  7072. ) {
  7073. return modifyBlockForContentState_1(contentState, selectionState, function(
  7074. block
  7075. ) {
  7076. return block.merge({ data: block.getData().merge(blockData) });
  7077. });
  7078. },
  7079. applyEntity: function applyEntity(contentState, selectionState, entityKey) {
  7080. var withoutEntities = removeEntitiesAtEdges_1(contentState, selectionState);
  7081. return applyEntityToContentState_1(
  7082. withoutEntities,
  7083. selectionState,
  7084. entityKey
  7085. );
  7086. }
  7087. };
  7088. var DraftModifier_1 = DraftModifier;
  7089. /**
  7090. * Copyright (c) 2013-present, Facebook, Inc.
  7091. *
  7092. * This source code is licensed under the MIT license found in the
  7093. * LICENSE file in the root directory of this source tree.
  7094. *
  7095. *
  7096. */
  7097. function makeEmptyFunction(arg) {
  7098. return function() {
  7099. return arg;
  7100. };
  7101. }
  7102. /**
  7103. * This function accepts and discards inputs; it has no side effects. This is
  7104. * primarily useful idiomatically for overridable function endpoints which
  7105. * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
  7106. */
  7107. var emptyFunction = function emptyFunction() {};
  7108. emptyFunction.thatReturns = makeEmptyFunction;
  7109. emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
  7110. emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
  7111. emptyFunction.thatReturnsNull = makeEmptyFunction(null);
  7112. emptyFunction.thatReturnsThis = function() {
  7113. return this;
  7114. };
  7115. emptyFunction.thatReturnsArgument = function(arg) {
  7116. return arg;
  7117. };
  7118. var emptyFunction_1 = emptyFunction;
  7119. var List$5 = immutable.List,
  7120. Repeat$3 = immutable.Repeat,
  7121. Record$3 = immutable.Record;
  7122. var returnTrue = emptyFunction_1.thatReturnsTrue;
  7123. var FINGERPRINT_DELIMITER = "-";
  7124. var defaultLeafRange = {
  7125. start: null,
  7126. end: null
  7127. };
  7128. var LeafRange = Record$3(defaultLeafRange);
  7129. var defaultDecoratorRange = {
  7130. start: null,
  7131. end: null,
  7132. decoratorKey: null,
  7133. leaves: null
  7134. };
  7135. var DecoratorRange = Record$3(defaultDecoratorRange);
  7136. var BlockTree = {
  7137. /**
  7138. * Generate a block tree for a given ContentBlock/decorator pair.
  7139. */
  7140. generate: function generate(contentState, block, decorator) {
  7141. var textLength = block.getLength();
  7142. if (!textLength) {
  7143. return List$5.of(
  7144. new DecoratorRange({
  7145. start: 0,
  7146. end: 0,
  7147. decoratorKey: null,
  7148. leaves: List$5.of(new LeafRange({ start: 0, end: 0 }))
  7149. })
  7150. );
  7151. }
  7152. var leafSets = [];
  7153. var decorations = decorator
  7154. ? decorator.getDecorations(block, contentState)
  7155. : List$5(Repeat$3(null, textLength));
  7156. var chars = block.getCharacterList();
  7157. findRangesImmutable_1(decorations, areEqual, returnTrue, function(
  7158. start,
  7159. end
  7160. ) {
  7161. leafSets.push(
  7162. new DecoratorRange({
  7163. start: start,
  7164. end: end,
  7165. decoratorKey: decorations.get(start),
  7166. leaves: generateLeaves(chars.slice(start, end).toList(), start)
  7167. })
  7168. );
  7169. });
  7170. return List$5(leafSets);
  7171. },
  7172. /**
  7173. * Create a string representation of the given tree map. This allows us
  7174. * to rapidly determine whether a tree has undergone a significant
  7175. * structural change.
  7176. */
  7177. getFingerprint: function getFingerprint(tree) {
  7178. return tree
  7179. .map(function(leafSet) {
  7180. var decoratorKey = leafSet.get("decoratorKey");
  7181. var fingerprintString =
  7182. decoratorKey !== null
  7183. ? decoratorKey + "." + (leafSet.get("end") - leafSet.get("start"))
  7184. : "";
  7185. return "" + fingerprintString + "." + leafSet.get("leaves").size;
  7186. })
  7187. .join(FINGERPRINT_DELIMITER);
  7188. }
  7189. };
  7190. /**
  7191. * Generate LeafRange records for a given character list.
  7192. */
  7193. function generateLeaves(characters, offset) {
  7194. var leaves = [];
  7195. var inlineStyles = characters
  7196. .map(function(c) {
  7197. return c.getStyle();
  7198. })
  7199. .toList();
  7200. findRangesImmutable_1(inlineStyles, areEqual, returnTrue, function(
  7201. start,
  7202. end
  7203. ) {
  7204. leaves.push(
  7205. new LeafRange({
  7206. start: start + offset,
  7207. end: end + offset
  7208. })
  7209. );
  7210. });
  7211. return List$5(leaves);
  7212. }
  7213. function areEqual(a, b) {
  7214. return a === b;
  7215. }
  7216. var BlockTree_1 = BlockTree;
  7217. function _classCallCheck$3(instance, Constructor) {
  7218. if (!(instance instanceof Constructor)) {
  7219. throw new TypeError("Cannot call a class as a function");
  7220. }
  7221. }
  7222. function _possibleConstructorReturn$3(self, call) {
  7223. if (!self) {
  7224. throw new ReferenceError(
  7225. "this hasn't been initialised - super() hasn't been called"
  7226. );
  7227. }
  7228. return call && (typeof call === "object" || typeof call === "function")
  7229. ? call
  7230. : self;
  7231. }
  7232. function _inherits$3(subClass, superClass) {
  7233. if (typeof superClass !== "function" && superClass !== null) {
  7234. throw new TypeError(
  7235. "Super expression must either be null or a function, not " +
  7236. typeof superClass
  7237. );
  7238. }
  7239. subClass.prototype = Object.create(superClass && superClass.prototype, {
  7240. constructor: {
  7241. value: subClass,
  7242. enumerable: false,
  7243. writable: true,
  7244. configurable: true
  7245. }
  7246. });
  7247. if (superClass)
  7248. Object.setPrototypeOf
  7249. ? Object.setPrototypeOf(subClass, superClass)
  7250. : (subClass.__proto__ = superClass);
  7251. }
  7252. var Record$4 = immutable.Record;
  7253. var DraftEntityInstanceRecord = Record$4({
  7254. type: "TOKEN",
  7255. mutability: "IMMUTABLE",
  7256. data: Object
  7257. });
  7258. /**
  7259. * An instance of a document entity, consisting of a `type` and relevant
  7260. * `data`, metadata about the entity.
  7261. *
  7262. * For instance, a "link" entity might provide a URI, and a "mention"
  7263. * entity might provide the mentioned user's ID. These pieces of data
  7264. * may be used when rendering the entity as part of a ContentBlock DOM
  7265. * representation. For a link, the data would be used as an href for
  7266. * the rendered anchor. For a mention, the ID could be used to retrieve
  7267. * a hovercard.
  7268. */
  7269. var DraftEntityInstance = (function(_DraftEntityInstanceR) {
  7270. _inherits$3(DraftEntityInstance, _DraftEntityInstanceR);
  7271. function DraftEntityInstance() {
  7272. _classCallCheck$3(this, DraftEntityInstance);
  7273. return _possibleConstructorReturn$3(
  7274. this,
  7275. _DraftEntityInstanceR.apply(this, arguments)
  7276. );
  7277. }
  7278. DraftEntityInstance.prototype.getType = function getType() {
  7279. return this.get("type");
  7280. };
  7281. DraftEntityInstance.prototype.getMutability = function getMutability() {
  7282. return this.get("mutability");
  7283. };
  7284. DraftEntityInstance.prototype.getData = function getData() {
  7285. return this.get("data");
  7286. };
  7287. return DraftEntityInstance;
  7288. })(DraftEntityInstanceRecord);
  7289. var DraftEntityInstance_1 = DraftEntityInstance;
  7290. var _extends =
  7291. objectAssign ||
  7292. function(target) {
  7293. for (var i = 1; i < arguments.length; i++) {
  7294. var source = arguments[i];
  7295. for (var key in source) {
  7296. if (Object.prototype.hasOwnProperty.call(source, key)) {
  7297. target[key] = source[key];
  7298. }
  7299. }
  7300. }
  7301. return target;
  7302. };
  7303. /**
  7304. * Copyright (c) 2013-present, Facebook, Inc.
  7305. * All rights reserved.
  7306. *
  7307. * This source code is licensed under the BSD-style license found in the
  7308. * LICENSE file in the root directory of this source tree. An additional grant
  7309. * of patent rights can be found in the PATENTS file in the same directory.
  7310. *
  7311. * @providesModule DraftEntity
  7312. * @format
  7313. *
  7314. */
  7315. var Map$7 = immutable.Map;
  7316. var instances = Map$7();
  7317. var instanceKey = 0;
  7318. /**
  7319. * Temporary utility for generating the warnings
  7320. */
  7321. function logWarning(oldMethodCall, newMethodCall) {
  7322. console.warn(
  7323. "WARNING: " +
  7324. oldMethodCall +
  7325. ' will be deprecated soon!\nPlease use "' +
  7326. newMethodCall +
  7327. '" instead.'
  7328. );
  7329. }
  7330. /**
  7331. * A "document entity" is an object containing metadata associated with a
  7332. * piece of text in a ContentBlock.
  7333. *
  7334. * For example, a `link` entity might include a `uri` property. When a
  7335. * ContentBlock is rendered in the browser, text that refers to that link
  7336. * entity may be rendered as an anchor, with the `uri` as the href value.
  7337. *
  7338. * In a ContentBlock, every position in the text may correspond to zero
  7339. * or one entities. This correspondence is tracked using a key string,
  7340. * generated via DraftEntity.create() and used to obtain entity metadata
  7341. * via DraftEntity.get().
  7342. */
  7343. var DraftEntity = {
  7344. /**
  7345. * WARNING: This method will be deprecated soon!
  7346. * Please use 'contentState.getLastCreatedEntityKey' instead.
  7347. * ---
  7348. * Get the random key string from whatever entity was last created.
  7349. * We need this to support the new API, as part of transitioning to put Entity
  7350. * storage in contentState.
  7351. */
  7352. getLastCreatedEntityKey: function getLastCreatedEntityKey() {
  7353. logWarning(
  7354. "DraftEntity.getLastCreatedEntityKey",
  7355. "contentState.getLastCreatedEntityKey"
  7356. );
  7357. return DraftEntity.__getLastCreatedEntityKey();
  7358. },
  7359. /**
  7360. * WARNING: This method will be deprecated soon!
  7361. * Please use 'contentState.createEntity' instead.
  7362. * ---
  7363. * Create a DraftEntityInstance and store it for later retrieval.
  7364. *
  7365. * A random key string will be generated and returned. This key may
  7366. * be used to track the entity's usage in a ContentBlock, and for
  7367. * retrieving data about the entity at render time.
  7368. */
  7369. create: function create(type, mutability, data) {
  7370. logWarning("DraftEntity.create", "contentState.createEntity");
  7371. return DraftEntity.__create(type, mutability, data);
  7372. },
  7373. /**
  7374. * WARNING: This method will be deprecated soon!
  7375. * Please use 'contentState.addEntity' instead.
  7376. * ---
  7377. * Add an existing DraftEntityInstance to the DraftEntity map. This is
  7378. * useful when restoring instances from the server.
  7379. */
  7380. add: function add(instance) {
  7381. logWarning("DraftEntity.add", "contentState.addEntity");
  7382. return DraftEntity.__add(instance);
  7383. },
  7384. /**
  7385. * WARNING: This method will be deprecated soon!
  7386. * Please use 'contentState.getEntity' instead.
  7387. * ---
  7388. * Retrieve the entity corresponding to the supplied key string.
  7389. */
  7390. get: function get(key) {
  7391. logWarning("DraftEntity.get", "contentState.getEntity");
  7392. return DraftEntity.__get(key);
  7393. },
  7394. /**
  7395. * WARNING: This method will be deprecated soon!
  7396. * Please use 'contentState.mergeEntityData' instead.
  7397. * ---
  7398. * Entity instances are immutable. If you need to update the data for an
  7399. * instance, this method will merge your data updates and return a new
  7400. * instance.
  7401. */
  7402. mergeData: function mergeData(key, toMerge) {
  7403. logWarning("DraftEntity.mergeData", "contentState.mergeEntityData");
  7404. return DraftEntity.__mergeData(key, toMerge);
  7405. },
  7406. /**
  7407. * WARNING: This method will be deprecated soon!
  7408. * Please use 'contentState.replaceEntityData' instead.
  7409. * ---
  7410. * Completely replace the data for a given instance.
  7411. */
  7412. replaceData: function replaceData(key, newData) {
  7413. logWarning("DraftEntity.replaceData", "contentState.replaceEntityData");
  7414. return DraftEntity.__replaceData(key, newData);
  7415. },
  7416. // ***********************************WARNING******************************
  7417. // --- the above public API will be deprecated in the next version of Draft!
  7418. // The methods below this line are private - don't call them directly.
  7419. /**
  7420. * Get the random key string from whatever entity was last created.
  7421. * We need this to support the new API, as part of transitioning to put Entity
  7422. * storage in contentState.
  7423. */
  7424. __getLastCreatedEntityKey: function __getLastCreatedEntityKey() {
  7425. return "" + instanceKey;
  7426. },
  7427. /**
  7428. * Create a DraftEntityInstance and store it for later retrieval.
  7429. *
  7430. * A random key string will be generated and returned. This key may
  7431. * be used to track the entity's usage in a ContentBlock, and for
  7432. * retrieving data about the entity at render time.
  7433. */
  7434. __create: function __create(type, mutability, data) {
  7435. return DraftEntity.__add(
  7436. new DraftEntityInstance_1({
  7437. type: type,
  7438. mutability: mutability,
  7439. data: data || {}
  7440. })
  7441. );
  7442. },
  7443. /**
  7444. * Add an existing DraftEntityInstance to the DraftEntity map. This is
  7445. * useful when restoring instances from the server.
  7446. */
  7447. __add: function __add(instance) {
  7448. var key = "" + ++instanceKey;
  7449. instances = instances.set(key, instance);
  7450. return key;
  7451. },
  7452. /**
  7453. * Retrieve the entity corresponding to the supplied key string.
  7454. */
  7455. __get: function __get(key) {
  7456. var instance = instances.get(key);
  7457. !!!instance
  7458. ? process.env.NODE_ENV !== "production"
  7459. ? invariant_1(false, "Unknown DraftEntity key: %s.", key)
  7460. : invariant_1(false)
  7461. : void 0;
  7462. return instance;
  7463. },
  7464. /**
  7465. * Entity instances are immutable. If you need to update the data for an
  7466. * instance, this method will merge your data updates and return a new
  7467. * instance.
  7468. */
  7469. __mergeData: function __mergeData(key, toMerge) {
  7470. var instance = DraftEntity.__get(key);
  7471. var newData = _extends({}, instance.getData(), toMerge);
  7472. var newInstance = instance.set("data", newData);
  7473. instances = instances.set(key, newInstance);
  7474. return newInstance;
  7475. },
  7476. /**
  7477. * Completely replace the data for a given instance.
  7478. */
  7479. __replaceData: function __replaceData(key, newData) {
  7480. var instance = DraftEntity.__get(key);
  7481. var newInstance = instance.set("data", newData);
  7482. instances = instances.set(key, newInstance);
  7483. return newInstance;
  7484. }
  7485. };
  7486. var DraftEntity_1 = DraftEntity;
  7487. function _classCallCheck$4(instance, Constructor) {
  7488. if (!(instance instanceof Constructor)) {
  7489. throw new TypeError("Cannot call a class as a function");
  7490. }
  7491. }
  7492. function _possibleConstructorReturn$4(self, call) {
  7493. if (!self) {
  7494. throw new ReferenceError(
  7495. "this hasn't been initialised - super() hasn't been called"
  7496. );
  7497. }
  7498. return call && (typeof call === "object" || typeof call === "function")
  7499. ? call
  7500. : self;
  7501. }
  7502. function _inherits$4(subClass, superClass) {
  7503. if (typeof superClass !== "function" && superClass !== null) {
  7504. throw new TypeError(
  7505. "Super expression must either be null or a function, not " +
  7506. typeof superClass
  7507. );
  7508. }
  7509. subClass.prototype = Object.create(superClass && superClass.prototype, {
  7510. constructor: {
  7511. value: subClass,
  7512. enumerable: false,
  7513. writable: true,
  7514. configurable: true
  7515. }
  7516. });
  7517. if (superClass)
  7518. Object.setPrototypeOf
  7519. ? Object.setPrototypeOf(subClass, superClass)
  7520. : (subClass.__proto__ = superClass);
  7521. }
  7522. var Record$5 = immutable.Record;
  7523. var defaultRecord$3 = {
  7524. anchorKey: "",
  7525. anchorOffset: 0,
  7526. focusKey: "",
  7527. focusOffset: 0,
  7528. isBackward: false,
  7529. hasFocus: false
  7530. };
  7531. var SelectionStateRecord = Record$5(defaultRecord$3);
  7532. var SelectionState = (function(_SelectionStateRecord) {
  7533. _inherits$4(SelectionState, _SelectionStateRecord);
  7534. function SelectionState() {
  7535. _classCallCheck$4(this, SelectionState);
  7536. return _possibleConstructorReturn$4(
  7537. this,
  7538. _SelectionStateRecord.apply(this, arguments)
  7539. );
  7540. }
  7541. SelectionState.prototype.serialize = function serialize() {
  7542. return (
  7543. "Anchor: " +
  7544. this.getAnchorKey() +
  7545. ":" +
  7546. this.getAnchorOffset() +
  7547. ", " +
  7548. "Focus: " +
  7549. this.getFocusKey() +
  7550. ":" +
  7551. this.getFocusOffset() +
  7552. ", " +
  7553. "Is Backward: " +
  7554. String(this.getIsBackward()) +
  7555. ", " +
  7556. "Has Focus: " +
  7557. String(this.getHasFocus())
  7558. );
  7559. };
  7560. SelectionState.prototype.getAnchorKey = function getAnchorKey() {
  7561. return this.get("anchorKey");
  7562. };
  7563. SelectionState.prototype.getAnchorOffset = function getAnchorOffset() {
  7564. return this.get("anchorOffset");
  7565. };
  7566. SelectionState.prototype.getFocusKey = function getFocusKey() {
  7567. return this.get("focusKey");
  7568. };
  7569. SelectionState.prototype.getFocusOffset = function getFocusOffset() {
  7570. return this.get("focusOffset");
  7571. };
  7572. SelectionState.prototype.getIsBackward = function getIsBackward() {
  7573. return this.get("isBackward");
  7574. };
  7575. SelectionState.prototype.getHasFocus = function getHasFocus() {
  7576. return this.get("hasFocus");
  7577. };
  7578. /**
  7579. * Return whether the specified range overlaps with an edge of the
  7580. * SelectionState.
  7581. */
  7582. SelectionState.prototype.hasEdgeWithin = function hasEdgeWithin(
  7583. blockKey,
  7584. start,
  7585. end
  7586. ) {
  7587. var anchorKey = this.getAnchorKey();
  7588. var focusKey = this.getFocusKey();
  7589. if (anchorKey === focusKey && anchorKey === blockKey) {
  7590. var selectionStart = this.getStartOffset();
  7591. var selectionEnd = this.getEndOffset();
  7592. return start <= selectionEnd && selectionStart <= end;
  7593. }
  7594. if (blockKey !== anchorKey && blockKey !== focusKey) {
  7595. return false;
  7596. }
  7597. var offsetToCheck =
  7598. blockKey === anchorKey ? this.getAnchorOffset() : this.getFocusOffset();
  7599. return start <= offsetToCheck && end >= offsetToCheck;
  7600. };
  7601. SelectionState.prototype.isCollapsed = function isCollapsed() {
  7602. return (
  7603. this.getAnchorKey() === this.getFocusKey() &&
  7604. this.getAnchorOffset() === this.getFocusOffset()
  7605. );
  7606. };
  7607. SelectionState.prototype.getStartKey = function getStartKey() {
  7608. return this.getIsBackward() ? this.getFocusKey() : this.getAnchorKey();
  7609. };
  7610. SelectionState.prototype.getStartOffset = function getStartOffset() {
  7611. return this.getIsBackward()
  7612. ? this.getFocusOffset()
  7613. : this.getAnchorOffset();
  7614. };
  7615. SelectionState.prototype.getEndKey = function getEndKey() {
  7616. return this.getIsBackward() ? this.getAnchorKey() : this.getFocusKey();
  7617. };
  7618. SelectionState.prototype.getEndOffset = function getEndOffset() {
  7619. return this.getIsBackward()
  7620. ? this.getAnchorOffset()
  7621. : this.getFocusOffset();
  7622. };
  7623. SelectionState.createEmpty = function createEmpty(key) {
  7624. return new SelectionState({
  7625. anchorKey: key,
  7626. anchorOffset: 0,
  7627. focusKey: key,
  7628. focusOffset: 0,
  7629. isBackward: false,
  7630. hasFocus: false
  7631. });
  7632. };
  7633. return SelectionState;
  7634. })(SelectionStateRecord);
  7635. var SelectionState_1 = SelectionState;
  7636. /**
  7637. * Copyright (c) 2013-present, Facebook, Inc.
  7638. * All rights reserved.
  7639. *
  7640. * This source code is licensed under the BSD-style license found in the
  7641. * LICENSE file in the root directory of this source tree. An additional grant
  7642. * of patent rights can be found in the PATENTS file in the same directory.
  7643. *
  7644. * @providesModule sanitizeDraftText
  7645. * @format
  7646. *
  7647. */
  7648. var REGEX_BLOCK_DELIMITER = new RegExp("\r", "g");
  7649. function sanitizeDraftText(input) {
  7650. return input.replace(REGEX_BLOCK_DELIMITER, "");
  7651. }
  7652. var sanitizeDraftText_1 = sanitizeDraftText;
  7653. function _classCallCheck$5(instance, Constructor) {
  7654. if (!(instance instanceof Constructor)) {
  7655. throw new TypeError("Cannot call a class as a function");
  7656. }
  7657. }
  7658. function _possibleConstructorReturn$5(self, call) {
  7659. if (!self) {
  7660. throw new ReferenceError(
  7661. "this hasn't been initialised - super() hasn't been called"
  7662. );
  7663. }
  7664. return call && (typeof call === "object" || typeof call === "function")
  7665. ? call
  7666. : self;
  7667. }
  7668. function _inherits$5(subClass, superClass) {
  7669. if (typeof superClass !== "function" && superClass !== null) {
  7670. throw new TypeError(
  7671. "Super expression must either be null or a function, not " +
  7672. typeof superClass
  7673. );
  7674. }
  7675. subClass.prototype = Object.create(superClass && superClass.prototype, {
  7676. constructor: {
  7677. value: subClass,
  7678. enumerable: false,
  7679. writable: true,
  7680. configurable: true
  7681. }
  7682. });
  7683. if (superClass)
  7684. Object.setPrototypeOf
  7685. ? Object.setPrototypeOf(subClass, superClass)
  7686. : (subClass.__proto__ = superClass);
  7687. }
  7688. var List$6 = immutable.List,
  7689. Record$6 = immutable.Record,
  7690. Repeat$4 = immutable.Repeat;
  7691. var defaultRecord$4 = {
  7692. entityMap: null,
  7693. blockMap: null,
  7694. selectionBefore: null,
  7695. selectionAfter: null
  7696. };
  7697. var ContentBlockNodeRecord = ContentBlock_1;
  7698. var ContentStateRecord = Record$6(defaultRecord$4);
  7699. var ContentState = (function(_ContentStateRecord) {
  7700. _inherits$5(ContentState, _ContentStateRecord);
  7701. function ContentState() {
  7702. _classCallCheck$5(this, ContentState);
  7703. return _possibleConstructorReturn$5(
  7704. this,
  7705. _ContentStateRecord.apply(this, arguments)
  7706. );
  7707. }
  7708. ContentState.prototype.getEntityMap = function getEntityMap() {
  7709. // TODO: update this when we fully remove DraftEntity
  7710. return DraftEntity_1;
  7711. };
  7712. ContentState.prototype.getBlockMap = function getBlockMap() {
  7713. return this.get("blockMap");
  7714. };
  7715. ContentState.prototype.getSelectionBefore = function getSelectionBefore() {
  7716. return this.get("selectionBefore");
  7717. };
  7718. ContentState.prototype.getSelectionAfter = function getSelectionAfter() {
  7719. return this.get("selectionAfter");
  7720. };
  7721. ContentState.prototype.getBlockForKey = function getBlockForKey(key) {
  7722. var block = this.getBlockMap().get(key);
  7723. return block;
  7724. };
  7725. ContentState.prototype.getKeyBefore = function getKeyBefore(key) {
  7726. return this.getBlockMap()
  7727. .reverse()
  7728. .keySeq()
  7729. .skipUntil(function(v) {
  7730. return v === key;
  7731. })
  7732. .skip(1)
  7733. .first();
  7734. };
  7735. ContentState.prototype.getKeyAfter = function getKeyAfter(key) {
  7736. return this.getBlockMap()
  7737. .keySeq()
  7738. .skipUntil(function(v) {
  7739. return v === key;
  7740. })
  7741. .skip(1)
  7742. .first();
  7743. };
  7744. ContentState.prototype.getBlockAfter = function getBlockAfter(key) {
  7745. return this.getBlockMap()
  7746. .skipUntil(function(_, k) {
  7747. return k === key;
  7748. })
  7749. .skip(1)
  7750. .first();
  7751. };
  7752. ContentState.prototype.getBlockBefore = function getBlockBefore(key) {
  7753. return this.getBlockMap()
  7754. .reverse()
  7755. .skipUntil(function(_, k) {
  7756. return k === key;
  7757. })
  7758. .skip(1)
  7759. .first();
  7760. };
  7761. ContentState.prototype.getBlocksAsArray = function getBlocksAsArray() {
  7762. return this.getBlockMap().toArray();
  7763. };
  7764. ContentState.prototype.getFirstBlock = function getFirstBlock() {
  7765. return this.getBlockMap().first();
  7766. };
  7767. ContentState.prototype.getLastBlock = function getLastBlock() {
  7768. return this.getBlockMap().last();
  7769. };
  7770. ContentState.prototype.getPlainText = function getPlainText(delimiter) {
  7771. return this.getBlockMap()
  7772. .map(function(block) {
  7773. return block ? block.getText() : "";
  7774. })
  7775. .join(delimiter || "\n");
  7776. };
  7777. ContentState.prototype.getLastCreatedEntityKey = function getLastCreatedEntityKey() {
  7778. // TODO: update this when we fully remove DraftEntity
  7779. return DraftEntity_1.__getLastCreatedEntityKey();
  7780. };
  7781. ContentState.prototype.hasText = function hasText() {
  7782. var blockMap = this.getBlockMap();
  7783. return blockMap.size > 1 || blockMap.first().getLength() > 0;
  7784. };
  7785. ContentState.prototype.createEntity = function createEntity(
  7786. type,
  7787. mutability,
  7788. data
  7789. ) {
  7790. // TODO: update this when we fully remove DraftEntity
  7791. DraftEntity_1.__create(type, mutability, data);
  7792. return this;
  7793. };
  7794. ContentState.prototype.mergeEntityData = function mergeEntityData(
  7795. key,
  7796. toMerge
  7797. ) {
  7798. // TODO: update this when we fully remove DraftEntity
  7799. DraftEntity_1.__mergeData(key, toMerge);
  7800. return this;
  7801. };
  7802. ContentState.prototype.replaceEntityData = function replaceEntityData(
  7803. key,
  7804. newData
  7805. ) {
  7806. // TODO: update this when we fully remove DraftEntity
  7807. DraftEntity_1.__replaceData(key, newData);
  7808. return this;
  7809. };
  7810. ContentState.prototype.addEntity = function addEntity(instance) {
  7811. // TODO: update this when we fully remove DraftEntity
  7812. DraftEntity_1.__add(instance);
  7813. return this;
  7814. };
  7815. ContentState.prototype.getEntity = function getEntity(key) {
  7816. // TODO: update this when we fully remove DraftEntity
  7817. return DraftEntity_1.__get(key);
  7818. };
  7819. ContentState.createFromBlockArray = function createFromBlockArray(
  7820. // TODO: update flow type when we completely deprecate the old entity API
  7821. blocks,
  7822. entityMap
  7823. ) {
  7824. // TODO: remove this when we completely deprecate the old entity API
  7825. var theBlocks = Array.isArray(blocks) ? blocks : blocks.contentBlocks;
  7826. var blockMap = BlockMapBuilder_1.createFromArray(theBlocks);
  7827. var selectionState = blockMap.isEmpty()
  7828. ? new SelectionState_1()
  7829. : SelectionState_1.createEmpty(blockMap.first().getKey());
  7830. return new ContentState({
  7831. blockMap: blockMap,
  7832. entityMap: entityMap || DraftEntity_1,
  7833. selectionBefore: selectionState,
  7834. selectionAfter: selectionState
  7835. });
  7836. };
  7837. ContentState.createFromText = function createFromText(text) {
  7838. var delimiter =
  7839. arguments.length > 1 && arguments[1] !== undefined
  7840. ? arguments[1]
  7841. : /\r\n?|\n/g;
  7842. var strings = text.split(delimiter);
  7843. var blocks = strings.map(function(block) {
  7844. block = sanitizeDraftText_1(block);
  7845. return new ContentBlockNodeRecord({
  7846. key: generateRandomKey_1(),
  7847. text: block,
  7848. type: "unstyled",
  7849. characterList: List$6(Repeat$4(CharacterMetadata_1.EMPTY, block.length))
  7850. });
  7851. });
  7852. return ContentState.createFromBlockArray(blocks);
  7853. };
  7854. return ContentState;
  7855. })(ContentStateRecord);
  7856. var ContentState_1 = ContentState;
  7857. var NEUTRAL = "NEUTRAL"; // No strong direction
  7858. var LTR = "LTR"; // Left-to-Right direction
  7859. var RTL = "RTL"; // Right-to-Left direction
  7860. var globalDir = null;
  7861. // == Helpers ==
  7862. /**
  7863. * Check if a directionality value is a Strong one
  7864. */
  7865. function isStrong(dir) {
  7866. return dir === LTR || dir === RTL;
  7867. }
  7868. /**
  7869. * Get string value to be used for `dir` HTML attribute or `direction` CSS
  7870. * property.
  7871. */
  7872. function getHTMLDir(dir) {
  7873. !isStrong(dir)
  7874. ? process.env.NODE_ENV !== "production"
  7875. ? invariant_1(
  7876. false,
  7877. "`dir` must be a strong direction to be converted to HTML Direction"
  7878. )
  7879. : invariant_1(false)
  7880. : void 0;
  7881. return dir === LTR ? "ltr" : "rtl";
  7882. }
  7883. /**
  7884. * Get string value to be used for `dir` HTML attribute or `direction` CSS
  7885. * property, but returns null if `dir` has same value as `otherDir`.
  7886. * `null`.
  7887. */
  7888. function getHTMLDirIfDifferent(dir, otherDir) {
  7889. !isStrong(dir)
  7890. ? process.env.NODE_ENV !== "production"
  7891. ? invariant_1(
  7892. false,
  7893. "`dir` must be a strong direction to be converted to HTML Direction"
  7894. )
  7895. : invariant_1(false)
  7896. : void 0;
  7897. !isStrong(otherDir)
  7898. ? process.env.NODE_ENV !== "production"
  7899. ? invariant_1(
  7900. false,
  7901. "`otherDir` must be a strong direction to be converted to HTML Direction"
  7902. )
  7903. : invariant_1(false)
  7904. : void 0;
  7905. return dir === otherDir ? null : getHTMLDir(dir);
  7906. }
  7907. // == Global Direction ==
  7908. /**
  7909. * Set the global direction.
  7910. */
  7911. function setGlobalDir(dir) {
  7912. globalDir = dir;
  7913. }
  7914. /**
  7915. * Initialize the global direction
  7916. */
  7917. function initGlobalDir() {
  7918. setGlobalDir(LTR);
  7919. }
  7920. /**
  7921. * Get the global direction
  7922. */
  7923. function getGlobalDir() {
  7924. if (!globalDir) {
  7925. this.initGlobalDir();
  7926. }
  7927. !globalDir
  7928. ? process.env.NODE_ENV !== "production"
  7929. ? invariant_1(false, "Global direction not set.")
  7930. : invariant_1(false)
  7931. : void 0;
  7932. return globalDir;
  7933. }
  7934. var UnicodeBidiDirection = {
  7935. // Values
  7936. NEUTRAL: NEUTRAL,
  7937. LTR: LTR,
  7938. RTL: RTL,
  7939. // Helpers
  7940. isStrong: isStrong,
  7941. getHTMLDir: getHTMLDir,
  7942. getHTMLDirIfDifferent: getHTMLDirIfDifferent,
  7943. // Global Direction
  7944. setGlobalDir: setGlobalDir,
  7945. initGlobalDir: initGlobalDir,
  7946. getGlobalDir: getGlobalDir
  7947. };
  7948. var UnicodeBidiDirection_1 = UnicodeBidiDirection;
  7949. /**
  7950. * RegExp ranges of characters with a *Strong* Bidi_Class value.
  7951. *
  7952. * Data is based on DerivedBidiClass.txt in UCD version 7.0.0.
  7953. *
  7954. * NOTE: For performance reasons, we only support Unicode's
  7955. * Basic Multilingual Plane (BMP) for now.
  7956. */
  7957. var RANGE_BY_BIDI_TYPE = {
  7958. L:
  7959. "A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u01BA\u01BB" +
  7960. "\u01BC-\u01BF\u01C0-\u01C3\u01C4-\u0293\u0294\u0295-\u02AF\u02B0-\u02B8" +
  7961. "\u02BB-\u02C1\u02D0-\u02D1\u02E0-\u02E4\u02EE\u0370-\u0373\u0376-\u0377" +
  7962. "\u037A\u037B-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1" +
  7963. "\u03A3-\u03F5\u03F7-\u0481\u0482\u048A-\u052F\u0531-\u0556\u0559" +
  7964. "\u055A-\u055F\u0561-\u0587\u0589\u0903\u0904-\u0939\u093B\u093D" +
  7965. "\u093E-\u0940\u0949-\u094C\u094E-\u094F\u0950\u0958-\u0961\u0964-\u0965" +
  7966. "\u0966-\u096F\u0970\u0971\u0972-\u0980\u0982-\u0983\u0985-\u098C" +
  7967. "\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD" +
  7968. "\u09BE-\u09C0\u09C7-\u09C8\u09CB-\u09CC\u09CE\u09D7\u09DC-\u09DD" +
  7969. "\u09DF-\u09E1\u09E6-\u09EF\u09F0-\u09F1\u09F4-\u09F9\u09FA\u0A03" +
  7970. "\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33" +
  7971. "\u0A35-\u0A36\u0A38-\u0A39\u0A3E-\u0A40\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F" +
  7972. "\u0A72-\u0A74\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0" +
  7973. "\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0ABE-\u0AC0\u0AC9\u0ACB-\u0ACC\u0AD0" +
  7974. "\u0AE0-\u0AE1\u0AE6-\u0AEF\u0AF0\u0B02-\u0B03\u0B05-\u0B0C\u0B0F-\u0B10" +
  7975. "\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B35-\u0B39\u0B3D\u0B3E\u0B40" +
  7976. "\u0B47-\u0B48\u0B4B-\u0B4C\u0B57\u0B5C-\u0B5D\u0B5F-\u0B61\u0B66-\u0B6F" +
  7977. "\u0B70\u0B71\u0B72-\u0B77\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95" +
  7978. "\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9" +
  7979. "\u0BBE-\u0BBF\u0BC1-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0BD0\u0BD7" +
  7980. "\u0BE6-\u0BEF\u0BF0-\u0BF2\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10" +
  7981. "\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C41-\u0C44\u0C58-\u0C59\u0C60-\u0C61" +
  7982. "\u0C66-\u0C6F\u0C7F\u0C82-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8" +
  7983. "\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CBE\u0CBF\u0CC0-\u0CC4\u0CC6" +
  7984. "\u0CC7-\u0CC8\u0CCA-\u0CCB\u0CD5-\u0CD6\u0CDE\u0CE0-\u0CE1\u0CE6-\u0CEF" +
  7985. "\u0CF1-\u0CF2\u0D02-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D" +
  7986. "\u0D3E-\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D4E\u0D57\u0D60-\u0D61" +
  7987. "\u0D66-\u0D6F\u0D70-\u0D75\u0D79\u0D7A-\u0D7F\u0D82-\u0D83\u0D85-\u0D96" +
  7988. "\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCF-\u0DD1\u0DD8-\u0DDF" +
  7989. "\u0DE6-\u0DEF\u0DF2-\u0DF3\u0DF4\u0E01-\u0E30\u0E32-\u0E33\u0E40-\u0E45" +
  7990. "\u0E46\u0E4F\u0E50-\u0E59\u0E5A-\u0E5B\u0E81-\u0E82\u0E84\u0E87-\u0E88" +
  7991. "\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7" +
  7992. "\u0EAA-\u0EAB\u0EAD-\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6" +
  7993. "\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F01-\u0F03\u0F04-\u0F12\u0F13\u0F14" +
  7994. "\u0F15-\u0F17\u0F1A-\u0F1F\u0F20-\u0F29\u0F2A-\u0F33\u0F34\u0F36\u0F38" +
  7995. "\u0F3E-\u0F3F\u0F40-\u0F47\u0F49-\u0F6C\u0F7F\u0F85\u0F88-\u0F8C" +
  7996. "\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE-\u0FCF\u0FD0-\u0FD4\u0FD5-\u0FD8" +
  7997. "\u0FD9-\u0FDA\u1000-\u102A\u102B-\u102C\u1031\u1038\u103B-\u103C\u103F" +
  7998. "\u1040-\u1049\u104A-\u104F\u1050-\u1055\u1056-\u1057\u105A-\u105D\u1061" +
  7999. "\u1062-\u1064\u1065-\u1066\u1067-\u106D\u106E-\u1070\u1075-\u1081" +
  8000. "\u1083-\u1084\u1087-\u108C\u108E\u108F\u1090-\u1099\u109A-\u109C" +
  8001. "\u109E-\u109F\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FB\u10FC" +
  8002. "\u10FD-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288" +
  8003. "\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5" +
  8004. "\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1360-\u1368" +
  8005. "\u1369-\u137C\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166D-\u166E" +
  8006. "\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EB-\u16ED\u16EE-\u16F0" +
  8007. "\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1735-\u1736" +
  8008. "\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17B6\u17BE-\u17C5" +
  8009. "\u17C7-\u17C8\u17D4-\u17D6\u17D7\u17D8-\u17DA\u17DC\u17E0-\u17E9" +
  8010. "\u1810-\u1819\u1820-\u1842\u1843\u1844-\u1877\u1880-\u18A8\u18AA" +
  8011. "\u18B0-\u18F5\u1900-\u191E\u1923-\u1926\u1929-\u192B\u1930-\u1931" +
  8012. "\u1933-\u1938\u1946-\u194F\u1950-\u196D\u1970-\u1974\u1980-\u19AB" +
  8013. "\u19B0-\u19C0\u19C1-\u19C7\u19C8-\u19C9\u19D0-\u19D9\u19DA\u1A00-\u1A16" +
  8014. "\u1A19-\u1A1A\u1A1E-\u1A1F\u1A20-\u1A54\u1A55\u1A57\u1A61\u1A63-\u1A64" +
  8015. "\u1A6D-\u1A72\u1A80-\u1A89\u1A90-\u1A99\u1AA0-\u1AA6\u1AA7\u1AA8-\u1AAD" +
  8016. "\u1B04\u1B05-\u1B33\u1B35\u1B3B\u1B3D-\u1B41\u1B43-\u1B44\u1B45-\u1B4B" +
  8017. "\u1B50-\u1B59\u1B5A-\u1B60\u1B61-\u1B6A\u1B74-\u1B7C\u1B82\u1B83-\u1BA0" +
  8018. "\u1BA1\u1BA6-\u1BA7\u1BAA\u1BAE-\u1BAF\u1BB0-\u1BB9\u1BBA-\u1BE5\u1BE7" +
  8019. "\u1BEA-\u1BEC\u1BEE\u1BF2-\u1BF3\u1BFC-\u1BFF\u1C00-\u1C23\u1C24-\u1C2B" +
  8020. "\u1C34-\u1C35\u1C3B-\u1C3F\u1C40-\u1C49\u1C4D-\u1C4F\u1C50-\u1C59" +
  8021. "\u1C5A-\u1C77\u1C78-\u1C7D\u1C7E-\u1C7F\u1CC0-\u1CC7\u1CD3\u1CE1" +
  8022. "\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF2-\u1CF3\u1CF5-\u1CF6\u1D00-\u1D2B" +
  8023. "\u1D2C-\u1D6A\u1D6B-\u1D77\u1D78\u1D79-\u1D9A\u1D9B-\u1DBF\u1E00-\u1F15" +
  8024. "\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D" +
  8025. "\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC" +
  8026. "\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200E" +
  8027. "\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D" +
  8028. "\u2124\u2126\u2128\u212A-\u212D\u212F-\u2134\u2135-\u2138\u2139" +
  8029. "\u213C-\u213F\u2145-\u2149\u214E\u214F\u2160-\u2182\u2183-\u2184" +
  8030. "\u2185-\u2188\u2336-\u237A\u2395\u249C-\u24E9\u26AC\u2800-\u28FF" +
  8031. "\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2C7B\u2C7C-\u2C7D\u2C7E-\u2CE4" +
  8032. "\u2CEB-\u2CEE\u2CF2-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F" +
  8033. "\u2D70\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE" +
  8034. "\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005\u3006\u3007" +
  8035. "\u3021-\u3029\u302E-\u302F\u3031-\u3035\u3038-\u303A\u303B\u303C" +
  8036. "\u3041-\u3096\u309D-\u309E\u309F\u30A1-\u30FA\u30FC-\u30FE\u30FF" +
  8037. "\u3105-\u312D\u3131-\u318E\u3190-\u3191\u3192-\u3195\u3196-\u319F" +
  8038. "\u31A0-\u31BA\u31F0-\u31FF\u3200-\u321C\u3220-\u3229\u322A-\u3247" +
  8039. "\u3248-\u324F\u3260-\u327B\u327F\u3280-\u3289\u328A-\u32B0\u32C0-\u32CB" +
  8040. "\u32D0-\u32FE\u3300-\u3376\u337B-\u33DD\u33E0-\u33FE\u3400-\u4DB5" +
  8041. "\u4E00-\u9FCC\uA000-\uA014\uA015\uA016-\uA48C\uA4D0-\uA4F7\uA4F8-\uA4FD" +
  8042. "\uA4FE-\uA4FF\uA500-\uA60B\uA60C\uA610-\uA61F\uA620-\uA629\uA62A-\uA62B" +
  8043. "\uA640-\uA66D\uA66E\uA680-\uA69B\uA69C-\uA69D\uA6A0-\uA6E5\uA6E6-\uA6EF" +
  8044. "\uA6F2-\uA6F7\uA722-\uA76F\uA770\uA771-\uA787\uA789-\uA78A\uA78B-\uA78E" +
  8045. "\uA790-\uA7AD\uA7B0-\uA7B1\uA7F7\uA7F8-\uA7F9\uA7FA\uA7FB-\uA801" +
  8046. "\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA823-\uA824\uA827\uA830-\uA835" +
  8047. "\uA836-\uA837\uA840-\uA873\uA880-\uA881\uA882-\uA8B3\uA8B4-\uA8C3" +
  8048. "\uA8CE-\uA8CF\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8F8-\uA8FA\uA8FB\uA900-\uA909" +
  8049. "\uA90A-\uA925\uA92E-\uA92F\uA930-\uA946\uA952-\uA953\uA95F\uA960-\uA97C" +
  8050. "\uA983\uA984-\uA9B2\uA9B4-\uA9B5\uA9BA-\uA9BB\uA9BD-\uA9C0\uA9C1-\uA9CD" +
  8051. "\uA9CF\uA9D0-\uA9D9\uA9DE-\uA9DF\uA9E0-\uA9E4\uA9E6\uA9E7-\uA9EF" +
  8052. "\uA9F0-\uA9F9\uA9FA-\uA9FE\uAA00-\uAA28\uAA2F-\uAA30\uAA33-\uAA34" +
  8053. "\uAA40-\uAA42\uAA44-\uAA4B\uAA4D\uAA50-\uAA59\uAA5C-\uAA5F\uAA60-\uAA6F" +
  8054. "\uAA70\uAA71-\uAA76\uAA77-\uAA79\uAA7A\uAA7B\uAA7D\uAA7E-\uAAAF\uAAB1" +
  8055. "\uAAB5-\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADC\uAADD\uAADE-\uAADF" +
  8056. "\uAAE0-\uAAEA\uAAEB\uAAEE-\uAAEF\uAAF0-\uAAF1\uAAF2\uAAF3-\uAAF4\uAAF5" +
  8057. "\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E" +
  8058. "\uAB30-\uAB5A\uAB5B\uAB5C-\uAB5F\uAB64-\uAB65\uABC0-\uABE2\uABE3-\uABE4" +
  8059. "\uABE6-\uABE7\uABE9-\uABEA\uABEB\uABEC\uABF0-\uABF9\uAC00-\uD7A3" +
  8060. "\uD7B0-\uD7C6\uD7CB-\uD7FB\uE000-\uF8FF\uF900-\uFA6D\uFA70-\uFAD9" +
  8061. "\uFB00-\uFB06\uFB13-\uFB17\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFF6F\uFF70" +
  8062. "\uFF71-\uFF9D\uFF9E-\uFF9F\uFFA0-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF" +
  8063. "\uFFD2-\uFFD7\uFFDA-\uFFDC",
  8064. R:
  8065. "\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05D0-\u05EA\u05EB-\u05EF" +
  8066. "\u05F0-\u05F2\u05F3-\u05F4\u05F5-\u05FF\u07C0-\u07C9\u07CA-\u07EA" +
  8067. "\u07F4-\u07F5\u07FA\u07FB-\u07FF\u0800-\u0815\u081A\u0824\u0828" +
  8068. "\u082E-\u082F\u0830-\u083E\u083F\u0840-\u0858\u085C-\u085D\u085E" +
  8069. "\u085F-\u089F\u200F\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB37\uFB38-\uFB3C" +
  8070. "\uFB3D\uFB3E\uFB3F\uFB40-\uFB41\uFB42\uFB43-\uFB44\uFB45\uFB46-\uFB4F",
  8071. AL:
  8072. "\u0608\u060B\u060D\u061B\u061C\u061D\u061E-\u061F\u0620-\u063F\u0640" +
  8073. "\u0641-\u064A\u066D\u066E-\u066F\u0671-\u06D3\u06D4\u06D5\u06E5-\u06E6" +
  8074. "\u06EE-\u06EF\u06FA-\u06FC\u06FD-\u06FE\u06FF\u0700-\u070D\u070E\u070F" +
  8075. "\u0710\u0712-\u072F\u074B-\u074C\u074D-\u07A5\u07B1\u07B2-\u07BF" +
  8076. "\u08A0-\u08B2\u08B3-\u08E3\uFB50-\uFBB1\uFBB2-\uFBC1\uFBC2-\uFBD2" +
  8077. "\uFBD3-\uFD3D\uFD40-\uFD4F\uFD50-\uFD8F\uFD90-\uFD91\uFD92-\uFDC7" +
  8078. "\uFDC8-\uFDCF\uFDF0-\uFDFB\uFDFC\uFDFE-\uFDFF\uFE70-\uFE74\uFE75" +
  8079. "\uFE76-\uFEFC\uFEFD-\uFEFE"
  8080. };
  8081. var REGEX_STRONG = new RegExp(
  8082. "[" +
  8083. RANGE_BY_BIDI_TYPE.L +
  8084. RANGE_BY_BIDI_TYPE.R +
  8085. RANGE_BY_BIDI_TYPE.AL +
  8086. "]"
  8087. );
  8088. var REGEX_RTL = new RegExp(
  8089. "[" + RANGE_BY_BIDI_TYPE.R + RANGE_BY_BIDI_TYPE.AL + "]"
  8090. );
  8091. /**
  8092. * Returns the first strong character (has Bidi_Class value of L, R, or AL).
  8093. *
  8094. * @param str A text block; e.g. paragraph, table cell, tag
  8095. * @return A character with strong bidi direction, or null if not found
  8096. */
  8097. function firstStrongChar(str) {
  8098. var match = REGEX_STRONG.exec(str);
  8099. return match == null ? null : match[0];
  8100. }
  8101. /**
  8102. * Returns the direction of a block of text, based on the direction of its
  8103. * first strong character (has Bidi_Class value of L, R, or AL).
  8104. *
  8105. * @param str A text block; e.g. paragraph, table cell, tag
  8106. * @return The resolved direction
  8107. */
  8108. function firstStrongCharDir(str) {
  8109. var strongChar = firstStrongChar(str);
  8110. if (strongChar == null) {
  8111. return UnicodeBidiDirection_1.NEUTRAL;
  8112. }
  8113. return REGEX_RTL.exec(strongChar)
  8114. ? UnicodeBidiDirection_1.RTL
  8115. : UnicodeBidiDirection_1.LTR;
  8116. }
  8117. /**
  8118. * Returns the direction of a block of text, based on the direction of its
  8119. * first strong character (has Bidi_Class value of L, R, or AL), or a fallback
  8120. * direction, if no strong character is found.
  8121. *
  8122. * This function is supposed to be used in respect to Higher-Level Protocol
  8123. * rule HL1. (http://www.unicode.org/reports/tr9/#HL1)
  8124. *
  8125. * @param str A text block; e.g. paragraph, table cell, tag
  8126. * @param fallback Fallback direction, used if no strong direction detected
  8127. * for the block (default = NEUTRAL)
  8128. * @return The resolved direction
  8129. */
  8130. function resolveBlockDir(str, fallback) {
  8131. fallback = fallback || UnicodeBidiDirection_1.NEUTRAL;
  8132. if (!str.length) {
  8133. return fallback;
  8134. }
  8135. var blockDir = firstStrongCharDir(str);
  8136. return blockDir === UnicodeBidiDirection_1.NEUTRAL ? fallback : blockDir;
  8137. }
  8138. /**
  8139. * Returns the direction of a block of text, based on the direction of its
  8140. * first strong character (has Bidi_Class value of L, R, or AL), or a fallback
  8141. * direction, if no strong character is found.
  8142. *
  8143. * NOTE: This function is similar to resolveBlockDir(), but uses the global
  8144. * direction as the fallback, so it *always* returns a Strong direction,
  8145. * making it useful for integration in places that you need to make the final
  8146. * decision, like setting some CSS class.
  8147. *
  8148. * This function is supposed to be used in respect to Higher-Level Protocol
  8149. * rule HL1. (http://www.unicode.org/reports/tr9/#HL1)
  8150. *
  8151. * @param str A text block; e.g. paragraph, table cell
  8152. * @param strongFallback Fallback direction, used if no strong direction
  8153. * detected for the block (default = global direction)
  8154. * @return The resolved Strong direction
  8155. */
  8156. function getDirection(str, strongFallback) {
  8157. if (!strongFallback) {
  8158. strongFallback = UnicodeBidiDirection_1.getGlobalDir();
  8159. }
  8160. !UnicodeBidiDirection_1.isStrong(strongFallback)
  8161. ? process.env.NODE_ENV !== "production"
  8162. ? invariant_1(false, "Fallback direction must be a strong direction")
  8163. : invariant_1(false)
  8164. : void 0;
  8165. return resolveBlockDir(str, strongFallback);
  8166. }
  8167. /**
  8168. * Returns true if getDirection(arguments...) returns LTR.
  8169. *
  8170. * @param str A text block; e.g. paragraph, table cell
  8171. * @param strongFallback Fallback direction, used if no strong direction
  8172. * detected for the block (default = global direction)
  8173. * @return True if the resolved direction is LTR
  8174. */
  8175. function isDirectionLTR(str, strongFallback) {
  8176. return getDirection(str, strongFallback) === UnicodeBidiDirection_1.LTR;
  8177. }
  8178. /**
  8179. * Returns true if getDirection(arguments...) returns RTL.
  8180. *
  8181. * @param str A text block; e.g. paragraph, table cell
  8182. * @param strongFallback Fallback direction, used if no strong direction
  8183. * detected for the block (default = global direction)
  8184. * @return True if the resolved direction is RTL
  8185. */
  8186. function isDirectionRTL(str, strongFallback) {
  8187. return getDirection(str, strongFallback) === UnicodeBidiDirection_1.RTL;
  8188. }
  8189. var UnicodeBidi = {
  8190. firstStrongChar: firstStrongChar,
  8191. firstStrongCharDir: firstStrongCharDir,
  8192. resolveBlockDir: resolveBlockDir,
  8193. getDirection: getDirection,
  8194. isDirectionLTR: isDirectionLTR,
  8195. isDirectionRTL: isDirectionRTL
  8196. };
  8197. var UnicodeBidi_1 = UnicodeBidi;
  8198. function _classCallCheck$6(instance, Constructor) {
  8199. if (!(instance instanceof Constructor)) {
  8200. throw new TypeError("Cannot call a class as a function");
  8201. }
  8202. }
  8203. var UnicodeBidiService = (function() {
  8204. /**
  8205. * Stateful class for paragraph direction detection
  8206. *
  8207. * @param defaultDir Default direction of the service
  8208. */
  8209. function UnicodeBidiService(defaultDir) {
  8210. _classCallCheck$6(this, UnicodeBidiService);
  8211. if (!defaultDir) {
  8212. defaultDir = UnicodeBidiDirection_1.getGlobalDir();
  8213. } else {
  8214. !UnicodeBidiDirection_1.isStrong(defaultDir)
  8215. ? process.env.NODE_ENV !== "production"
  8216. ? invariant_1(
  8217. false,
  8218. "Default direction must be a strong direction (LTR or RTL)"
  8219. )
  8220. : invariant_1(false)
  8221. : void 0;
  8222. }
  8223. this._defaultDir = defaultDir;
  8224. this.reset();
  8225. }
  8226. /**
  8227. * Reset the internal state
  8228. *
  8229. * Instead of creating a new instance, you can just reset() your instance
  8230. * everytime you start a new loop.
  8231. */
  8232. UnicodeBidiService.prototype.reset = function reset() {
  8233. this._lastDir = this._defaultDir;
  8234. };
  8235. /**
  8236. * Returns the direction of a block of text, and remembers it as the
  8237. * fall-back direction for the next paragraph.
  8238. *
  8239. * @param str A text block, e.g. paragraph, table cell, tag
  8240. * @return The resolved direction
  8241. */
  8242. UnicodeBidiService.prototype.getDirection = function getDirection(str) {
  8243. this._lastDir = UnicodeBidi_1.getDirection(str, this._lastDir);
  8244. return this._lastDir;
  8245. };
  8246. return UnicodeBidiService;
  8247. })();
  8248. var UnicodeBidiService_1 = UnicodeBidiService;
  8249. /**
  8250. * Copyright (c) 2013-present, Facebook, Inc.
  8251. *
  8252. * This source code is licensed under the MIT license found in the
  8253. * LICENSE file in the root directory of this source tree.
  8254. *
  8255. *
  8256. */
  8257. var nullthrows = function nullthrows(x) {
  8258. if (x != null) {
  8259. return x;
  8260. }
  8261. throw new Error("Got unexpected null or undefined");
  8262. };
  8263. var nullthrows_1 = nullthrows;
  8264. var OrderedMap$2 = immutable.OrderedMap;
  8265. var bidiService;
  8266. var EditorBidiService = {
  8267. getDirectionMap: function getDirectionMap(content, prevBidiMap) {
  8268. if (!bidiService) {
  8269. bidiService = new UnicodeBidiService_1();
  8270. } else {
  8271. bidiService.reset();
  8272. }
  8273. var blockMap = content.getBlockMap();
  8274. var nextBidi = blockMap.valueSeq().map(function(block) {
  8275. return nullthrows_1(bidiService).getDirection(block.getText());
  8276. });
  8277. var bidiMap = OrderedMap$2(blockMap.keySeq().zip(nextBidi));
  8278. if (prevBidiMap != null && immutable.is(prevBidiMap, bidiMap)) {
  8279. return prevBidiMap;
  8280. }
  8281. return bidiMap;
  8282. }
  8283. };
  8284. var EditorBidiService_1 = EditorBidiService;
  8285. var _extends$1 =
  8286. objectAssign ||
  8287. function(target) {
  8288. for (var i = 1; i < arguments.length; i++) {
  8289. var source = arguments[i];
  8290. for (var key in source) {
  8291. if (Object.prototype.hasOwnProperty.call(source, key)) {
  8292. target[key] = source[key];
  8293. }
  8294. }
  8295. }
  8296. return target;
  8297. };
  8298. function _classCallCheck$7(instance, Constructor) {
  8299. if (!(instance instanceof Constructor)) {
  8300. throw new TypeError("Cannot call a class as a function");
  8301. }
  8302. }
  8303. var OrderedSet$4 = immutable.OrderedSet,
  8304. Record$7 = immutable.Record,
  8305. Stack = immutable.Stack;
  8306. var defaultRecord$5 = {
  8307. allowUndo: true,
  8308. currentContent: null,
  8309. decorator: null,
  8310. directionMap: null,
  8311. forceSelection: false,
  8312. inCompositionMode: false,
  8313. inlineStyleOverride: null,
  8314. lastChangeType: null,
  8315. nativelyRenderedContent: null,
  8316. redoStack: Stack(),
  8317. selection: null,
  8318. treeMap: null,
  8319. undoStack: Stack()
  8320. };
  8321. var EditorStateRecord = Record$7(defaultRecord$5);
  8322. var EditorState = (function() {
  8323. EditorState.createEmpty = function createEmpty(decorator) {
  8324. return EditorState.createWithContent(
  8325. ContentState_1.createFromText(""),
  8326. decorator
  8327. );
  8328. };
  8329. EditorState.createWithContent = function createWithContent(
  8330. contentState,
  8331. decorator
  8332. ) {
  8333. var firstKey = contentState
  8334. .getBlockMap()
  8335. .first()
  8336. .getKey();
  8337. return EditorState.create({
  8338. currentContent: contentState,
  8339. undoStack: Stack(),
  8340. redoStack: Stack(),
  8341. decorator: decorator || null,
  8342. selection: SelectionState_1.createEmpty(firstKey)
  8343. });
  8344. };
  8345. EditorState.create = function create(config) {
  8346. var currentContent = config.currentContent,
  8347. decorator = config.decorator;
  8348. var recordConfig = _extends$1({}, config, {
  8349. treeMap: generateNewTreeMap(currentContent, decorator),
  8350. directionMap: EditorBidiService_1.getDirectionMap(currentContent)
  8351. });
  8352. return new EditorState(new EditorStateRecord(recordConfig));
  8353. };
  8354. EditorState.set = function set(editorState, put) {
  8355. var map = editorState.getImmutable().withMutations(function(state) {
  8356. var existingDecorator = state.get("decorator");
  8357. var decorator = existingDecorator;
  8358. if (put.decorator === null) {
  8359. decorator = null;
  8360. } else if (put.decorator) {
  8361. decorator = put.decorator;
  8362. }
  8363. var newContent = put.currentContent || editorState.getCurrentContent();
  8364. if (decorator !== existingDecorator) {
  8365. var treeMap = state.get("treeMap");
  8366. var newTreeMap;
  8367. if (decorator && existingDecorator) {
  8368. newTreeMap = regenerateTreeForNewDecorator(
  8369. newContent,
  8370. newContent.getBlockMap(),
  8371. treeMap,
  8372. decorator,
  8373. existingDecorator
  8374. );
  8375. } else {
  8376. newTreeMap = generateNewTreeMap(newContent, decorator);
  8377. }
  8378. state.merge({
  8379. decorator: decorator,
  8380. treeMap: newTreeMap,
  8381. nativelyRenderedContent: null
  8382. });
  8383. return;
  8384. }
  8385. var existingContent = editorState.getCurrentContent();
  8386. if (newContent !== existingContent) {
  8387. state.set(
  8388. "treeMap",
  8389. regenerateTreeForNewBlocks(
  8390. editorState,
  8391. newContent.getBlockMap(),
  8392. newContent.getEntityMap(),
  8393. decorator
  8394. )
  8395. );
  8396. }
  8397. state.merge(put);
  8398. });
  8399. return new EditorState(map);
  8400. };
  8401. EditorState.prototype.toJS = function toJS() {
  8402. return this.getImmutable().toJS();
  8403. };
  8404. EditorState.prototype.getAllowUndo = function getAllowUndo() {
  8405. return this.getImmutable().get("allowUndo");
  8406. };
  8407. EditorState.prototype.getCurrentContent = function getCurrentContent() {
  8408. return this.getImmutable().get("currentContent");
  8409. };
  8410. EditorState.prototype.getUndoStack = function getUndoStack() {
  8411. return this.getImmutable().get("undoStack");
  8412. };
  8413. EditorState.prototype.getRedoStack = function getRedoStack() {
  8414. return this.getImmutable().get("redoStack");
  8415. };
  8416. EditorState.prototype.getSelection = function getSelection() {
  8417. return this.getImmutable().get("selection");
  8418. };
  8419. EditorState.prototype.getDecorator = function getDecorator() {
  8420. return this.getImmutable().get("decorator");
  8421. };
  8422. EditorState.prototype.isInCompositionMode = function isInCompositionMode() {
  8423. return this.getImmutable().get("inCompositionMode");
  8424. };
  8425. EditorState.prototype.mustForceSelection = function mustForceSelection() {
  8426. return this.getImmutable().get("forceSelection");
  8427. };
  8428. EditorState.prototype.getNativelyRenderedContent = function getNativelyRenderedContent() {
  8429. return this.getImmutable().get("nativelyRenderedContent");
  8430. };
  8431. EditorState.prototype.getLastChangeType = function getLastChangeType() {
  8432. return this.getImmutable().get("lastChangeType");
  8433. };
  8434. /**
  8435. * While editing, the user may apply inline style commands with a collapsed
  8436. * cursor, intending to type text that adopts the specified style. In this
  8437. * case, we track the specified style as an "override" that takes precedence
  8438. * over the inline style of the text adjacent to the cursor.
  8439. *
  8440. * If null, there is no override in place.
  8441. */
  8442. EditorState.prototype.getInlineStyleOverride = function getInlineStyleOverride() {
  8443. return this.getImmutable().get("inlineStyleOverride");
  8444. };
  8445. EditorState.setInlineStyleOverride = function setInlineStyleOverride(
  8446. editorState,
  8447. inlineStyleOverride
  8448. ) {
  8449. return EditorState.set(editorState, {
  8450. inlineStyleOverride: inlineStyleOverride
  8451. });
  8452. };
  8453. /**
  8454. * Get the appropriate inline style for the editor state. If an
  8455. * override is in place, use it. Otherwise, the current style is
  8456. * based on the location of the selection state.
  8457. */
  8458. EditorState.prototype.getCurrentInlineStyle = function getCurrentInlineStyle() {
  8459. var override = this.getInlineStyleOverride();
  8460. if (override != null) {
  8461. return override;
  8462. }
  8463. var content = this.getCurrentContent();
  8464. var selection = this.getSelection();
  8465. if (selection.isCollapsed()) {
  8466. return getInlineStyleForCollapsedSelection(content, selection);
  8467. }
  8468. return getInlineStyleForNonCollapsedSelection(content, selection);
  8469. };
  8470. EditorState.prototype.getBlockTree = function getBlockTree(blockKey) {
  8471. return this.getImmutable().getIn(["treeMap", blockKey]);
  8472. };
  8473. EditorState.prototype.isSelectionAtStartOfContent = function isSelectionAtStartOfContent() {
  8474. var firstKey = this.getCurrentContent()
  8475. .getBlockMap()
  8476. .first()
  8477. .getKey();
  8478. return this.getSelection().hasEdgeWithin(firstKey, 0, 0);
  8479. };
  8480. EditorState.prototype.isSelectionAtEndOfContent = function isSelectionAtEndOfContent() {
  8481. var content = this.getCurrentContent();
  8482. var blockMap = content.getBlockMap();
  8483. var last = blockMap.last();
  8484. var end = last.getLength();
  8485. return this.getSelection().hasEdgeWithin(last.getKey(), end, end);
  8486. };
  8487. EditorState.prototype.getDirectionMap = function getDirectionMap() {
  8488. return this.getImmutable().get("directionMap");
  8489. };
  8490. /**
  8491. * Incorporate native DOM selection changes into the EditorState. This
  8492. * method can be used when we simply want to accept whatever the DOM
  8493. * has given us to represent selection, and we do not need to re-render
  8494. * the editor.
  8495. *
  8496. * To forcibly move the DOM selection, see `EditorState.forceSelection`.
  8497. */
  8498. EditorState.acceptSelection = function acceptSelection(
  8499. editorState,
  8500. selection
  8501. ) {
  8502. return updateSelection(editorState, selection, false);
  8503. };
  8504. /**
  8505. * At times, we need to force the DOM selection to be where we
  8506. * need it to be. This can occur when the anchor or focus nodes
  8507. * are non-text nodes, for instance. In this case, we want to trigger
  8508. * a re-render of the editor, which in turn forces selection into
  8509. * the correct place in the DOM. The `forceSelection` method
  8510. * accomplishes this.
  8511. *
  8512. * This method should be used in cases where you need to explicitly
  8513. * move the DOM selection from one place to another without a change
  8514. * in ContentState.
  8515. */
  8516. EditorState.forceSelection = function forceSelection(editorState, selection) {
  8517. if (!selection.getHasFocus()) {
  8518. selection = selection.set("hasFocus", true);
  8519. }
  8520. return updateSelection(editorState, selection, true);
  8521. };
  8522. /**
  8523. * Move selection to the end of the editor without forcing focus.
  8524. */
  8525. EditorState.moveSelectionToEnd = function moveSelectionToEnd(editorState) {
  8526. var content = editorState.getCurrentContent();
  8527. var lastBlock = content.getLastBlock();
  8528. var lastKey = lastBlock.getKey();
  8529. var length = lastBlock.getLength();
  8530. return EditorState.acceptSelection(
  8531. editorState,
  8532. new SelectionState_1({
  8533. anchorKey: lastKey,
  8534. anchorOffset: length,
  8535. focusKey: lastKey,
  8536. focusOffset: length,
  8537. isBackward: false
  8538. })
  8539. );
  8540. };
  8541. /**
  8542. * Force focus to the end of the editor. This is useful in scenarios
  8543. * where we want to programmatically focus the input and it makes sense
  8544. * to allow the user to continue working seamlessly.
  8545. */
  8546. EditorState.moveFocusToEnd = function moveFocusToEnd(editorState) {
  8547. var afterSelectionMove = EditorState.moveSelectionToEnd(editorState);
  8548. return EditorState.forceSelection(
  8549. afterSelectionMove,
  8550. afterSelectionMove.getSelection()
  8551. );
  8552. };
  8553. /**
  8554. * Push the current ContentState onto the undo stack if it should be
  8555. * considered a boundary state, and set the provided ContentState as the
  8556. * new current content.
  8557. */
  8558. EditorState.push = function push(editorState, contentState, changeType) {
  8559. if (editorState.getCurrentContent() === contentState) {
  8560. return editorState;
  8561. }
  8562. var forceSelection = changeType !== "insert-characters";
  8563. var directionMap = EditorBidiService_1.getDirectionMap(
  8564. contentState,
  8565. editorState.getDirectionMap()
  8566. );
  8567. if (!editorState.getAllowUndo()) {
  8568. return EditorState.set(editorState, {
  8569. currentContent: contentState,
  8570. directionMap: directionMap,
  8571. lastChangeType: changeType,
  8572. selection: contentState.getSelectionAfter(),
  8573. forceSelection: forceSelection,
  8574. inlineStyleOverride: null
  8575. });
  8576. }
  8577. var selection = editorState.getSelection();
  8578. var currentContent = editorState.getCurrentContent();
  8579. var undoStack = editorState.getUndoStack();
  8580. var newContent = contentState;
  8581. if (
  8582. selection !== currentContent.getSelectionAfter() ||
  8583. mustBecomeBoundary(editorState, changeType)
  8584. ) {
  8585. undoStack = undoStack.push(currentContent);
  8586. newContent = newContent.set("selectionBefore", selection);
  8587. } else if (
  8588. changeType === "insert-characters" ||
  8589. changeType === "backspace-character" ||
  8590. changeType === "delete-character"
  8591. ) {
  8592. // Preserve the previous selection.
  8593. newContent = newContent.set(
  8594. "selectionBefore",
  8595. currentContent.getSelectionBefore()
  8596. );
  8597. }
  8598. var inlineStyleOverride = editorState.getInlineStyleOverride();
  8599. // Don't discard inline style overrides for the following change types:
  8600. var overrideChangeTypes = [
  8601. "adjust-depth",
  8602. "change-block-type",
  8603. "split-block"
  8604. ];
  8605. if (overrideChangeTypes.indexOf(changeType) === -1) {
  8606. inlineStyleOverride = null;
  8607. }
  8608. var editorStateChanges = {
  8609. currentContent: newContent,
  8610. directionMap: directionMap,
  8611. undoStack: undoStack,
  8612. redoStack: Stack(),
  8613. lastChangeType: changeType,
  8614. selection: contentState.getSelectionAfter(),
  8615. forceSelection: forceSelection,
  8616. inlineStyleOverride: inlineStyleOverride
  8617. };
  8618. return EditorState.set(editorState, editorStateChanges);
  8619. };
  8620. /**
  8621. * Make the top ContentState in the undo stack the new current content and
  8622. * push the current content onto the redo stack.
  8623. */
  8624. EditorState.undo = function undo(editorState) {
  8625. if (!editorState.getAllowUndo()) {
  8626. return editorState;
  8627. }
  8628. var undoStack = editorState.getUndoStack();
  8629. var newCurrentContent = undoStack.peek();
  8630. if (!newCurrentContent) {
  8631. return editorState;
  8632. }
  8633. var currentContent = editorState.getCurrentContent();
  8634. var directionMap = EditorBidiService_1.getDirectionMap(
  8635. newCurrentContent,
  8636. editorState.getDirectionMap()
  8637. );
  8638. return EditorState.set(editorState, {
  8639. currentContent: newCurrentContent,
  8640. directionMap: directionMap,
  8641. undoStack: undoStack.shift(),
  8642. redoStack: editorState.getRedoStack().push(currentContent),
  8643. forceSelection: true,
  8644. inlineStyleOverride: null,
  8645. lastChangeType: "undo",
  8646. nativelyRenderedContent: null,
  8647. selection: currentContent.getSelectionBefore()
  8648. });
  8649. };
  8650. /**
  8651. * Make the top ContentState in the redo stack the new current content and
  8652. * push the current content onto the undo stack.
  8653. */
  8654. EditorState.redo = function redo(editorState) {
  8655. if (!editorState.getAllowUndo()) {
  8656. return editorState;
  8657. }
  8658. var redoStack = editorState.getRedoStack();
  8659. var newCurrentContent = redoStack.peek();
  8660. if (!newCurrentContent) {
  8661. return editorState;
  8662. }
  8663. var currentContent = editorState.getCurrentContent();
  8664. var directionMap = EditorBidiService_1.getDirectionMap(
  8665. newCurrentContent,
  8666. editorState.getDirectionMap()
  8667. );
  8668. return EditorState.set(editorState, {
  8669. currentContent: newCurrentContent,
  8670. directionMap: directionMap,
  8671. undoStack: editorState.getUndoStack().push(currentContent),
  8672. redoStack: redoStack.shift(),
  8673. forceSelection: true,
  8674. inlineStyleOverride: null,
  8675. lastChangeType: "redo",
  8676. nativelyRenderedContent: null,
  8677. selection: newCurrentContent.getSelectionAfter()
  8678. });
  8679. };
  8680. /**
  8681. * Not for public consumption.
  8682. */
  8683. function EditorState(immutable) {
  8684. _classCallCheck$7(this, EditorState);
  8685. this._immutable = immutable;
  8686. }
  8687. /**
  8688. * Not for public consumption.
  8689. */
  8690. EditorState.prototype.getImmutable = function getImmutable() {
  8691. return this._immutable;
  8692. };
  8693. return EditorState;
  8694. })();
  8695. /**
  8696. * Set the supplied SelectionState as the new current selection, and set
  8697. * the `force` flag to trigger manual selection placement by the view.
  8698. */
  8699. function updateSelection(editorState, selection, forceSelection) {
  8700. return EditorState.set(editorState, {
  8701. selection: selection,
  8702. forceSelection: forceSelection,
  8703. nativelyRenderedContent: null,
  8704. inlineStyleOverride: null
  8705. });
  8706. }
  8707. /**
  8708. * Regenerate the entire tree map for a given ContentState and decorator.
  8709. * Returns an OrderedMap that maps all available ContentBlock objects.
  8710. */
  8711. function generateNewTreeMap(contentState, decorator) {
  8712. return contentState
  8713. .getBlockMap()
  8714. .map(function(block) {
  8715. return BlockTree_1.generate(contentState, block, decorator);
  8716. })
  8717. .toOrderedMap();
  8718. }
  8719. /**
  8720. * Regenerate tree map objects for all ContentBlocks that have changed
  8721. * between the current editorState and newContent. Returns an OrderedMap
  8722. * with only changed regenerated tree map objects.
  8723. */
  8724. function regenerateTreeForNewBlocks(
  8725. editorState,
  8726. newBlockMap,
  8727. newEntityMap,
  8728. decorator
  8729. ) {
  8730. var contentState = editorState
  8731. .getCurrentContent()
  8732. .set("entityMap", newEntityMap);
  8733. var prevBlockMap = contentState.getBlockMap();
  8734. var prevTreeMap = editorState.getImmutable().get("treeMap");
  8735. return prevTreeMap.merge(
  8736. newBlockMap
  8737. .toSeq()
  8738. .filter(function(block, key) {
  8739. return block !== prevBlockMap.get(key);
  8740. })
  8741. .map(function(block) {
  8742. return BlockTree_1.generate(contentState, block, decorator);
  8743. })
  8744. );
  8745. }
  8746. /**
  8747. * Generate tree map objects for a new decorator object, preserving any
  8748. * decorations that are unchanged from the previous decorator.
  8749. *
  8750. * Note that in order for this to perform optimally, decoration Lists for
  8751. * decorators should be preserved when possible to allow for direct immutable
  8752. * List comparison.
  8753. */
  8754. function regenerateTreeForNewDecorator(
  8755. content,
  8756. blockMap,
  8757. previousTreeMap,
  8758. decorator,
  8759. existingDecorator
  8760. ) {
  8761. return previousTreeMap.merge(
  8762. blockMap
  8763. .toSeq()
  8764. .filter(function(block) {
  8765. return (
  8766. decorator.getDecorations(block, content) !==
  8767. existingDecorator.getDecorations(block, content)
  8768. );
  8769. })
  8770. .map(function(block) {
  8771. return BlockTree_1.generate(content, block, decorator);
  8772. })
  8773. );
  8774. }
  8775. /**
  8776. * Return whether a change should be considered a boundary state, given
  8777. * the previous change type. Allows us to discard potential boundary states
  8778. * during standard typing or deletion behavior.
  8779. */
  8780. function mustBecomeBoundary(editorState, changeType) {
  8781. var lastChangeType = editorState.getLastChangeType();
  8782. return (
  8783. changeType !== lastChangeType ||
  8784. (changeType !== "insert-characters" &&
  8785. changeType !== "backspace-character" &&
  8786. changeType !== "delete-character")
  8787. );
  8788. }
  8789. function getInlineStyleForCollapsedSelection(content, selection) {
  8790. var startKey = selection.getStartKey();
  8791. var startOffset = selection.getStartOffset();
  8792. var startBlock = content.getBlockForKey(startKey);
  8793. // If the cursor is not at the start of the block, look backward to
  8794. // preserve the style of the preceding character.
  8795. if (startOffset > 0) {
  8796. return startBlock.getInlineStyleAt(startOffset - 1);
  8797. }
  8798. // The caret is at position zero in this block. If the block has any
  8799. // text at all, use the style of the first character.
  8800. if (startBlock.getLength()) {
  8801. return startBlock.getInlineStyleAt(0);
  8802. }
  8803. // Otherwise, look upward in the document to find the closest character.
  8804. return lookUpwardForInlineStyle(content, startKey);
  8805. }
  8806. function getInlineStyleForNonCollapsedSelection(content, selection) {
  8807. var startKey = selection.getStartKey();
  8808. var startOffset = selection.getStartOffset();
  8809. var startBlock = content.getBlockForKey(startKey);
  8810. // If there is a character just inside the selection, use its style.
  8811. if (startOffset < startBlock.getLength()) {
  8812. return startBlock.getInlineStyleAt(startOffset);
  8813. }
  8814. // Check if the selection at the end of a non-empty block. Use the last
  8815. // style in the block.
  8816. if (startOffset > 0) {
  8817. return startBlock.getInlineStyleAt(startOffset - 1);
  8818. }
  8819. // Otherwise, look upward in the document to find the closest character.
  8820. return lookUpwardForInlineStyle(content, startKey);
  8821. }
  8822. function lookUpwardForInlineStyle(content, fromKey) {
  8823. var lastNonEmpty = content
  8824. .getBlockMap()
  8825. .reverse()
  8826. .skipUntil(function(_, k) {
  8827. return k === fromKey;
  8828. })
  8829. .skip(1)
  8830. .skipUntil(function(block, _) {
  8831. return block.getLength();
  8832. })
  8833. .first();
  8834. if (lastNonEmpty)
  8835. return lastNonEmpty.getInlineStyleAt(lastNonEmpty.getLength() - 1);
  8836. return OrderedSet$4();
  8837. }
  8838. var EditorState_1 = EditorState;
  8839. var OrderedMap$3 = immutable.OrderedMap,
  8840. List$7 = immutable.List;
  8841. var transformBlock$2 = function transformBlock(key, blockMap, func) {
  8842. if (!key) {
  8843. return;
  8844. }
  8845. var block = blockMap.get(key);
  8846. if (!block) {
  8847. return;
  8848. }
  8849. blockMap.set(key, func(block));
  8850. };
  8851. var updateBlockMapLinks$3 = function updateBlockMapLinks(
  8852. blockMap,
  8853. originalBlockToBeMoved,
  8854. originalTargetBlock,
  8855. insertionMode,
  8856. isExperimentalTreeBlock
  8857. ) {
  8858. if (!isExperimentalTreeBlock) {
  8859. return blockMap;
  8860. }
  8861. // possible values of 'insertionMode' are: 'after', 'before'
  8862. var isInsertedAfterTarget = insertionMode === "after";
  8863. var originalBlockKey = originalBlockToBeMoved.getKey();
  8864. var originalTargetKey = originalTargetBlock.getKey();
  8865. var originalParentKey = originalBlockToBeMoved.getParentKey();
  8866. var originalNextSiblingKey = originalBlockToBeMoved.getNextSiblingKey();
  8867. var originalPrevSiblingKey = originalBlockToBeMoved.getPrevSiblingKey();
  8868. var newParentKey = originalTargetBlock.getParentKey();
  8869. var newNextSiblingKey = isInsertedAfterTarget
  8870. ? originalTargetBlock.getNextSiblingKey()
  8871. : originalTargetKey;
  8872. var newPrevSiblingKey = isInsertedAfterTarget
  8873. ? originalTargetKey
  8874. : originalTargetBlock.getPrevSiblingKey();
  8875. return blockMap.withMutations(function(blocks) {
  8876. // update old parent
  8877. transformBlock$2(originalParentKey, blocks, function(block) {
  8878. var parentChildrenList = block.getChildKeys();
  8879. return block.merge({
  8880. children: parentChildrenList["delete"](
  8881. parentChildrenList.indexOf(originalBlockKey)
  8882. )
  8883. });
  8884. });
  8885. // update old prev
  8886. transformBlock$2(originalPrevSiblingKey, blocks, function(block) {
  8887. return block.merge({
  8888. nextSibling: originalNextSiblingKey
  8889. });
  8890. });
  8891. // update old next
  8892. transformBlock$2(originalNextSiblingKey, blocks, function(block) {
  8893. return block.merge({
  8894. prevSibling: originalPrevSiblingKey
  8895. });
  8896. });
  8897. // update new next
  8898. transformBlock$2(newNextSiblingKey, blocks, function(block) {
  8899. return block.merge({
  8900. prevSibling: originalBlockKey
  8901. });
  8902. });
  8903. // update new prev
  8904. transformBlock$2(newPrevSiblingKey, blocks, function(block) {
  8905. return block.merge({
  8906. nextSibling: originalBlockKey
  8907. });
  8908. });
  8909. // update new parent
  8910. transformBlock$2(newParentKey, blocks, function(block) {
  8911. var newParentChildrenList = block.getChildKeys();
  8912. var targetBlockIndex = newParentChildrenList.indexOf(originalTargetKey);
  8913. var insertionIndex = isInsertedAfterTarget
  8914. ? targetBlockIndex + 1
  8915. : targetBlockIndex !== 0
  8916. ? targetBlockIndex - 1
  8917. : 0;
  8918. var newChildrenArray = newParentChildrenList.toArray();
  8919. newChildrenArray.splice(insertionIndex, 0, originalBlockKey);
  8920. return block.merge({
  8921. children: List$7(newChildrenArray)
  8922. });
  8923. });
  8924. // update block
  8925. transformBlock$2(originalBlockKey, blocks, function(block) {
  8926. return block.merge({
  8927. nextSibling: newNextSiblingKey,
  8928. prevSibling: newPrevSiblingKey,
  8929. parent: newParentKey
  8930. });
  8931. });
  8932. });
  8933. };
  8934. var moveBlockInContentState = function moveBlockInContentState(
  8935. contentState,
  8936. blockToBeMoved,
  8937. targetBlock,
  8938. insertionMode
  8939. ) {
  8940. !(insertionMode !== "replace")
  8941. ? process.env.NODE_ENV !== "production"
  8942. ? invariant_1(false, "Replacing blocks is not supported.")
  8943. : invariant_1(false)
  8944. : void 0;
  8945. var targetKey = targetBlock.getKey();
  8946. var blockKey = blockToBeMoved.getKey();
  8947. !(blockKey !== targetKey)
  8948. ? process.env.NODE_ENV !== "production"
  8949. ? invariant_1(false, "Block cannot be moved next to itself.")
  8950. : invariant_1(false)
  8951. : void 0;
  8952. var blockMap = contentState.getBlockMap();
  8953. var isExperimentalTreeBlock = blockToBeMoved instanceof ContentBlockNode_1;
  8954. var blocksToBeMoved = [blockToBeMoved];
  8955. var blockMapWithoutBlocksToBeMoved = blockMap["delete"](blockKey);
  8956. if (isExperimentalTreeBlock) {
  8957. blocksToBeMoved = [];
  8958. blockMapWithoutBlocksToBeMoved = blockMap.withMutations(function(blocks) {
  8959. var nextSiblingKey = blockToBeMoved.getNextSiblingKey();
  8960. var nextDelimiterBlockKey = getNextDelimiterBlockKey_1(
  8961. blockToBeMoved,
  8962. blocks
  8963. );
  8964. blocks
  8965. .toSeq()
  8966. .skipUntil(function(block) {
  8967. return block.getKey() === blockKey;
  8968. })
  8969. .takeWhile(function(block) {
  8970. var key = block.getKey();
  8971. var isBlockToBeMoved = key === blockKey;
  8972. var hasNextSiblingAndIsNotNextSibling =
  8973. nextSiblingKey && key !== nextSiblingKey;
  8974. var doesNotHaveNextSiblingAndIsNotDelimiter =
  8975. !nextSiblingKey &&
  8976. block.getParentKey() &&
  8977. (!nextDelimiterBlockKey || key !== nextDelimiterBlockKey);
  8978. return !!(
  8979. isBlockToBeMoved ||
  8980. hasNextSiblingAndIsNotNextSibling ||
  8981. doesNotHaveNextSiblingAndIsNotDelimiter
  8982. );
  8983. })
  8984. .forEach(function(block) {
  8985. blocksToBeMoved.push(block);
  8986. blocks["delete"](block.getKey());
  8987. });
  8988. });
  8989. }
  8990. var blocksBefore = blockMapWithoutBlocksToBeMoved
  8991. .toSeq()
  8992. .takeUntil(function(v) {
  8993. return v === targetBlock;
  8994. });
  8995. var blocksAfter = blockMapWithoutBlocksToBeMoved
  8996. .toSeq()
  8997. .skipUntil(function(v) {
  8998. return v === targetBlock;
  8999. })
  9000. .skip(1);
  9001. var slicedBlocks = blocksToBeMoved.map(function(block) {
  9002. return [block.getKey(), block];
  9003. });
  9004. var newBlocks = OrderedMap$3();
  9005. if (insertionMode === "before") {
  9006. var blockBefore = contentState.getBlockBefore(targetKey);
  9007. !(!blockBefore || blockBefore.getKey() !== blockToBeMoved.getKey())
  9008. ? process.env.NODE_ENV !== "production"
  9009. ? invariant_1(false, "Block cannot be moved next to itself.")
  9010. : invariant_1(false)
  9011. : void 0;
  9012. newBlocks = blocksBefore
  9013. .concat([].concat(slicedBlocks, [[targetKey, targetBlock]]), blocksAfter)
  9014. .toOrderedMap();
  9015. } else if (insertionMode === "after") {
  9016. var blockAfter = contentState.getBlockAfter(targetKey);
  9017. !(!blockAfter || blockAfter.getKey() !== blockKey)
  9018. ? process.env.NODE_ENV !== "production"
  9019. ? invariant_1(false, "Block cannot be moved next to itself.")
  9020. : invariant_1(false)
  9021. : void 0;
  9022. newBlocks = blocksBefore
  9023. .concat([[targetKey, targetBlock]].concat(slicedBlocks), blocksAfter)
  9024. .toOrderedMap();
  9025. }
  9026. return contentState.merge({
  9027. blockMap: updateBlockMapLinks$3(
  9028. newBlocks,
  9029. blockToBeMoved,
  9030. targetBlock,
  9031. insertionMode,
  9032. isExperimentalTreeBlock
  9033. ),
  9034. selectionBefore: contentState.getSelectionAfter(),
  9035. selectionAfter: contentState.getSelectionAfter().merge({
  9036. anchorKey: blockKey,
  9037. focusKey: blockKey
  9038. })
  9039. });
  9040. };
  9041. var moveBlockInContentState_1 = moveBlockInContentState;
  9042. var ContentBlockRecord$1 = ContentBlock_1;
  9043. var List$8 = immutable.List,
  9044. Repeat$5 = immutable.Repeat;
  9045. var AtomicBlockUtils = {
  9046. insertAtomicBlock: function insertAtomicBlock(
  9047. editorState,
  9048. entityKey,
  9049. character
  9050. ) {
  9051. var contentState = editorState.getCurrentContent();
  9052. var selectionState = editorState.getSelection();
  9053. var afterRemoval = DraftModifier_1.removeRange(
  9054. contentState,
  9055. selectionState,
  9056. "backward"
  9057. );
  9058. var targetSelection = afterRemoval.getSelectionAfter();
  9059. var afterSplit = DraftModifier_1.splitBlock(afterRemoval, targetSelection);
  9060. var insertionTarget = afterSplit.getSelectionAfter();
  9061. var asAtomicBlock = DraftModifier_1.setBlockType(
  9062. afterSplit,
  9063. insertionTarget,
  9064. "atomic"
  9065. );
  9066. var charData = CharacterMetadata_1.create({ entity: entityKey });
  9067. var atomicBlockConfig = {
  9068. key: generateRandomKey_1(),
  9069. type: "atomic",
  9070. text: character,
  9071. characterList: List$8(Repeat$5(charData, character.length))
  9072. };
  9073. var atomicDividerBlockConfig = {
  9074. key: generateRandomKey_1(),
  9075. type: "unstyled"
  9076. };
  9077. var fragmentArray = [
  9078. new ContentBlockRecord$1(atomicBlockConfig),
  9079. new ContentBlockRecord$1(atomicDividerBlockConfig)
  9080. ];
  9081. var fragment = BlockMapBuilder_1.createFromArray(fragmentArray);
  9082. var withAtomicBlock = DraftModifier_1.replaceWithFragment(
  9083. asAtomicBlock,
  9084. insertionTarget,
  9085. fragment
  9086. );
  9087. var newContent = withAtomicBlock.merge({
  9088. selectionBefore: selectionState,
  9089. selectionAfter: withAtomicBlock.getSelectionAfter().set("hasFocus", true)
  9090. });
  9091. return EditorState_1.push(editorState, newContent, "insert-fragment");
  9092. },
  9093. moveAtomicBlock: function moveAtomicBlock(
  9094. editorState,
  9095. atomicBlock,
  9096. targetRange,
  9097. insertionMode
  9098. ) {
  9099. var contentState = editorState.getCurrentContent();
  9100. var selectionState = editorState.getSelection();
  9101. var withMovedAtomicBlock = void 0;
  9102. if (insertionMode === "before" || insertionMode === "after") {
  9103. var targetBlock = contentState.getBlockForKey(
  9104. insertionMode === "before"
  9105. ? targetRange.getStartKey()
  9106. : targetRange.getEndKey()
  9107. );
  9108. withMovedAtomicBlock = moveBlockInContentState_1(
  9109. contentState,
  9110. atomicBlock,
  9111. targetBlock,
  9112. insertionMode
  9113. );
  9114. } else {
  9115. var afterRemoval = DraftModifier_1.removeRange(
  9116. contentState,
  9117. targetRange,
  9118. "backward"
  9119. );
  9120. var selectionAfterRemoval = afterRemoval.getSelectionAfter();
  9121. var _targetBlock = afterRemoval.getBlockForKey(
  9122. selectionAfterRemoval.getFocusKey()
  9123. );
  9124. if (selectionAfterRemoval.getStartOffset() === 0) {
  9125. withMovedAtomicBlock = moveBlockInContentState_1(
  9126. afterRemoval,
  9127. atomicBlock,
  9128. _targetBlock,
  9129. "before"
  9130. );
  9131. } else if (
  9132. selectionAfterRemoval.getEndOffset() === _targetBlock.getLength()
  9133. ) {
  9134. withMovedAtomicBlock = moveBlockInContentState_1(
  9135. afterRemoval,
  9136. atomicBlock,
  9137. _targetBlock,
  9138. "after"
  9139. );
  9140. } else {
  9141. var afterSplit = DraftModifier_1.splitBlock(
  9142. afterRemoval,
  9143. selectionAfterRemoval
  9144. );
  9145. var selectionAfterSplit = afterSplit.getSelectionAfter();
  9146. var _targetBlock2 = afterSplit.getBlockForKey(
  9147. selectionAfterSplit.getFocusKey()
  9148. );
  9149. withMovedAtomicBlock = moveBlockInContentState_1(
  9150. afterSplit,
  9151. atomicBlock,
  9152. _targetBlock2,
  9153. "before"
  9154. );
  9155. }
  9156. }
  9157. var newContent = withMovedAtomicBlock.merge({
  9158. selectionBefore: selectionState,
  9159. selectionAfter: withMovedAtomicBlock
  9160. .getSelectionAfter()
  9161. .set("hasFocus", true)
  9162. });
  9163. return EditorState_1.push(editorState, newContent, "move-block");
  9164. }
  9165. };
  9166. var AtomicBlockUtils_1 = AtomicBlockUtils;
  9167. function _classCallCheck$8(instance, Constructor) {
  9168. if (!(instance instanceof Constructor)) {
  9169. throw new TypeError("Cannot call a class as a function");
  9170. }
  9171. }
  9172. var List$9 = immutable.List;
  9173. var DELIMITER = ".";
  9174. /**
  9175. * A CompositeDraftDecorator traverses through a list of DraftDecorator
  9176. * instances to identify sections of a ContentBlock that should be rendered
  9177. * in a "decorated" manner. For example, hashtags, mentions, and links may
  9178. * be intended to stand out visually, be rendered as anchors, etc.
  9179. *
  9180. * The list of decorators supplied to the constructor will be used in the
  9181. * order they are provided. This allows the caller to specify a priority for
  9182. * string matching, in case of match collisions among decorators.
  9183. *
  9184. * For instance, I may have a link with a `#` in its text. Though this section
  9185. * of text may match our hashtag decorator, it should not be treated as a
  9186. * hashtag. I should therefore list my link DraftDecorator
  9187. * before my hashtag DraftDecorator when constructing this composite
  9188. * decorator instance.
  9189. *
  9190. * Thus, when a collision like this is encountered, the earlier match is
  9191. * preserved and the new match is discarded.
  9192. */
  9193. var CompositeDraftDecorator = (function() {
  9194. function CompositeDraftDecorator(decorators) {
  9195. _classCallCheck$8(this, CompositeDraftDecorator);
  9196. // Copy the decorator array, since we use this array order to determine
  9197. // precedence of decoration matching. If the array is mutated externally,
  9198. // we don't want to be affected here.
  9199. this._decorators = decorators.slice();
  9200. }
  9201. CompositeDraftDecorator.prototype.getDecorations = function getDecorations(
  9202. block,
  9203. contentState
  9204. ) {
  9205. var decorations = Array(block.getText().length).fill(null);
  9206. this._decorators.forEach(function(/*object*/ decorator, /*number*/ ii) {
  9207. var counter = 0;
  9208. var strategy = decorator.strategy;
  9209. var callback = function callback(/*number*/ start, /*number*/ end) {
  9210. // Find out if any of our matching range is already occupied
  9211. // by another decorator. If so, discard the match. Otherwise, store
  9212. // the component key for rendering.
  9213. if (canOccupySlice(decorations, start, end)) {
  9214. occupySlice(decorations, start, end, ii + DELIMITER + counter);
  9215. counter++;
  9216. }
  9217. };
  9218. strategy(block, callback, contentState);
  9219. });
  9220. return List$9(decorations);
  9221. };
  9222. CompositeDraftDecorator.prototype.getComponentForKey = function getComponentForKey(
  9223. key
  9224. ) {
  9225. var componentKey = parseInt(key.split(DELIMITER)[0], 10);
  9226. return this._decorators[componentKey].component;
  9227. };
  9228. CompositeDraftDecorator.prototype.getPropsForKey = function getPropsForKey(
  9229. key
  9230. ) {
  9231. var componentKey = parseInt(key.split(DELIMITER)[0], 10);
  9232. return this._decorators[componentKey].props;
  9233. };
  9234. return CompositeDraftDecorator;
  9235. })();
  9236. /**
  9237. * Determine whether we can occupy the specified slice of the decorations
  9238. * array.
  9239. */
  9240. function canOccupySlice(decorations, start, end) {
  9241. for (var ii = start; ii < end; ii++) {
  9242. if (decorations[ii] != null) {
  9243. return false;
  9244. }
  9245. }
  9246. return true;
  9247. }
  9248. /**
  9249. * Splice the specified component into our decoration array at the desired
  9250. * range.
  9251. */
  9252. function occupySlice(targetArr, start, end, componentKey) {
  9253. for (var ii = start; ii < end; ii++) {
  9254. targetArr[ii] = componentKey;
  9255. }
  9256. }
  9257. var CompositeDraftDecorator_1 = CompositeDraftDecorator;
  9258. /**
  9259. * Copyright (c) 2013-present, Facebook, Inc.
  9260. *
  9261. * This source code is licensed under the MIT license found in the
  9262. * LICENSE file in the root directory of this source tree.
  9263. *
  9264. */
  9265. /**
  9266. * This function is used to mark string literals representing CSS class names
  9267. * so that they can be transformed statically. This allows for modularization
  9268. * and minification of CSS class names.
  9269. *
  9270. * In static_upstream, this function is actually implemented, but it should
  9271. * eventually be replaced with something more descriptive, and the transform
  9272. * that is used in the main stack should be ported for use elsewhere.
  9273. *
  9274. * @param string|object className to modularize, or an object of key/values.
  9275. * In the object case, the values are conditions that
  9276. * determine if the className keys should be included.
  9277. * @param [string ...] Variable list of classNames in the string case.
  9278. * @return string Renderable space-separated CSS className.
  9279. */
  9280. function cx(classNames) {
  9281. if (typeof classNames == "object") {
  9282. return Object.keys(classNames)
  9283. .filter(function(className) {
  9284. return classNames[className];
  9285. })
  9286. .map(replace)
  9287. .join(" ");
  9288. }
  9289. return Array.prototype.map.call(arguments, replace).join(" ");
  9290. }
  9291. function replace(str) {
  9292. return str.replace(/\//g, "-");
  9293. }
  9294. var cx_1 = cx;
  9295. var Map$8 = immutable.Map;
  9296. var UL_WRAP = React__default.createElement("ul", {
  9297. className: cx_1("public/DraftStyleDefault/ul")
  9298. });
  9299. var OL_WRAP = React__default.createElement("ol", {
  9300. className: cx_1("public/DraftStyleDefault/ol")
  9301. });
  9302. var PRE_WRAP = React__default.createElement("pre", {
  9303. className: cx_1("public/DraftStyleDefault/pre")
  9304. });
  9305. var DefaultDraftBlockRenderMap = Map$8({
  9306. "header-one": {
  9307. element: "h1"
  9308. },
  9309. "header-two": {
  9310. element: "h2"
  9311. },
  9312. "header-three": {
  9313. element: "h3"
  9314. },
  9315. "header-four": {
  9316. element: "h4"
  9317. },
  9318. "header-five": {
  9319. element: "h5"
  9320. },
  9321. "header-six": {
  9322. element: "h6"
  9323. },
  9324. "unordered-list-item": {
  9325. element: "li",
  9326. wrapper: UL_WRAP
  9327. },
  9328. "ordered-list-item": {
  9329. element: "li",
  9330. wrapper: OL_WRAP
  9331. },
  9332. blockquote: {
  9333. element: "blockquote"
  9334. },
  9335. atomic: {
  9336. element: "figure"
  9337. },
  9338. "code-block": {
  9339. element: "pre",
  9340. wrapper: PRE_WRAP
  9341. },
  9342. unstyled: {
  9343. element: "div",
  9344. aliasedElements: ["p"]
  9345. }
  9346. });
  9347. var DefaultDraftBlockRenderMap_1 = DefaultDraftBlockRenderMap;
  9348. /**
  9349. * Copyright (c) 2013-present, Facebook, Inc.
  9350. * All rights reserved.
  9351. *
  9352. * This source code is licensed under the BSD-style license found in the
  9353. * LICENSE file in the root directory of this source tree. An additional grant
  9354. * of patent rights can be found in the PATENTS file in the same directory.
  9355. *
  9356. * @providesModule DefaultDraftInlineStyle
  9357. * @format
  9358. *
  9359. */
  9360. var DefaultDraftInlineStyle = {
  9361. BOLD: {
  9362. fontWeight: "bold"
  9363. },
  9364. CODE: {
  9365. fontFamily: "monospace",
  9366. wordWrap: "break-word"
  9367. },
  9368. ITALIC: {
  9369. fontStyle: "italic"
  9370. },
  9371. STRIKETHROUGH: {
  9372. textDecoration: "line-through"
  9373. },
  9374. UNDERLINE: {
  9375. textDecoration: "underline"
  9376. }
  9377. };
  9378. /**
  9379. * Copyright (c) 2013-present, Facebook, Inc.
  9380. *
  9381. * This source code is licensed under the MIT license found in the
  9382. * LICENSE file in the root directory of this source tree.
  9383. *
  9384. */
  9385. var Keys = {
  9386. BACKSPACE: 8,
  9387. TAB: 9,
  9388. RETURN: 13,
  9389. ALT: 18,
  9390. ESC: 27,
  9391. SPACE: 32,
  9392. PAGE_UP: 33,
  9393. PAGE_DOWN: 34,
  9394. END: 35,
  9395. HOME: 36,
  9396. LEFT: 37,
  9397. UP: 38,
  9398. RIGHT: 39,
  9399. DOWN: 40,
  9400. DELETE: 46,
  9401. COMMA: 188,
  9402. PERIOD: 190,
  9403. A: 65,
  9404. Z: 90,
  9405. ZERO: 48,
  9406. NUMPAD_0: 96,
  9407. NUMPAD_9: 105
  9408. };
  9409. /**
  9410. * Copyright (c) 2013-present, Facebook, Inc.
  9411. * All rights reserved.
  9412. *
  9413. * This source code is licensed under the BSD-style license found in the
  9414. * LICENSE file in the root directory of this source tree. An additional grant
  9415. * of patent rights can be found in the PATENTS file in the same directory.
  9416. *
  9417. * @providesModule getEntityKeyForSelection
  9418. * @format
  9419. *
  9420. */
  9421. /**
  9422. * Return the entity key that should be used when inserting text for the
  9423. * specified target selection, only if the entity is `MUTABLE`. `IMMUTABLE`
  9424. * and `SEGMENTED` entities should not be used for insertion behavior.
  9425. */
  9426. function getEntityKeyForSelection(contentState, targetSelection) {
  9427. var entityKey;
  9428. if (targetSelection.isCollapsed()) {
  9429. var key = targetSelection.getAnchorKey();
  9430. var offset = targetSelection.getAnchorOffset();
  9431. if (offset > 0) {
  9432. entityKey = contentState.getBlockForKey(key).getEntityAt(offset - 1);
  9433. if (entityKey !== contentState.getBlockForKey(key).getEntityAt(offset)) {
  9434. return null;
  9435. }
  9436. return filterKey(contentState.getEntityMap(), entityKey);
  9437. }
  9438. return null;
  9439. }
  9440. var startKey = targetSelection.getStartKey();
  9441. var startOffset = targetSelection.getStartOffset();
  9442. var startBlock = contentState.getBlockForKey(startKey);
  9443. entityKey =
  9444. startOffset === startBlock.getLength()
  9445. ? null
  9446. : startBlock.getEntityAt(startOffset);
  9447. return filterKey(contentState.getEntityMap(), entityKey);
  9448. }
  9449. /**
  9450. * Determine whether an entity key corresponds to a `MUTABLE` entity. If so,
  9451. * return it. If not, return null.
  9452. */
  9453. function filterKey(entityMap, entityKey) {
  9454. if (entityKey) {
  9455. var entity = entityMap.__get(entityKey);
  9456. return entity.getMutability() === "MUTABLE" ? entityKey : null;
  9457. }
  9458. return null;
  9459. }
  9460. var getEntityKeyForSelection_1 = getEntityKeyForSelection;
  9461. /**
  9462. * Copyright (c) 2013-present, Facebook, Inc.
  9463. * All rights reserved.
  9464. *
  9465. * This source code is licensed under the BSD-style license found in the
  9466. * LICENSE file in the root directory of this source tree. An additional grant
  9467. * of patent rights can be found in the PATENTS file in the same directory.
  9468. *
  9469. * @providesModule isEventHandled
  9470. * @format
  9471. *
  9472. */
  9473. /**
  9474. * Utility method for determining whether or not the value returned
  9475. * from a handler indicates that it was handled.
  9476. */
  9477. function isEventHandled(value) {
  9478. return value === "handled" || value === true;
  9479. }
  9480. var isEventHandled_1 = isEventHandled;
  9481. /**
  9482. * Copyright (c) 2013-present, Facebook, Inc.
  9483. * All rights reserved.
  9484. *
  9485. * This source code is licensed under the BSD-style license found in the
  9486. * LICENSE file in the root directory of this source tree. An additional grant
  9487. * of patent rights can be found in the PATENTS file in the same directory.
  9488. *
  9489. * @providesModule isSelectionAtLeafStart
  9490. * @format
  9491. *
  9492. */
  9493. function isSelectionAtLeafStart(editorState) {
  9494. var selection = editorState.getSelection();
  9495. var anchorKey = selection.getAnchorKey();
  9496. var blockTree = editorState.getBlockTree(anchorKey);
  9497. var offset = selection.getStartOffset();
  9498. var isAtStart = false;
  9499. blockTree.some(function(leafSet) {
  9500. if (offset === leafSet.get("start")) {
  9501. isAtStart = true;
  9502. return true;
  9503. }
  9504. if (offset < leafSet.get("end")) {
  9505. return leafSet.get("leaves").some(function(leaf) {
  9506. var leafStart = leaf.get("start");
  9507. if (offset === leafStart) {
  9508. isAtStart = true;
  9509. return true;
  9510. }
  9511. return false;
  9512. });
  9513. }
  9514. return false;
  9515. });
  9516. return isAtStart;
  9517. }
  9518. var isSelectionAtLeafStart_1 = isSelectionAtLeafStart;
  9519. /**
  9520. * Millisecond delay to allow `compositionstart` to fire again upon
  9521. * `compositionend`.
  9522. *
  9523. * This is used for Korean input to ensure that typing can continue without
  9524. * the editor trying to render too quickly. More specifically, Safari 7.1+
  9525. * triggers `compositionstart` a little slower than Chrome/FF, which
  9526. * leads to composed characters being resolved and re-render occurring
  9527. * sooner than we want.
  9528. */
  9529. var RESOLVE_DELAY = 20;
  9530. /**
  9531. * A handful of variables used to track the current composition and its
  9532. * resolution status. These exist at the module level because it is not
  9533. * possible to have compositions occurring in multiple editors simultaneously,
  9534. * and it simplifies state management with respect to the DraftEditor component.
  9535. */
  9536. var resolved = false;
  9537. var stillComposing = false;
  9538. var textInputData = "";
  9539. var DraftEditorCompositionHandler = {
  9540. onBeforeInput: function onBeforeInput(editor, e) {
  9541. textInputData = (textInputData || "") + e.data;
  9542. },
  9543. /**
  9544. * A `compositionstart` event has fired while we're still in composition
  9545. * mode. Continue the current composition session to prevent a re-render.
  9546. */
  9547. onCompositionStart: function onCompositionStart(editor) {
  9548. stillComposing = true;
  9549. },
  9550. /**
  9551. * Attempt to end the current composition session.
  9552. *
  9553. * Defer handling because browser will still insert the chars into active
  9554. * element after `compositionend`. If a `compositionstart` event fires
  9555. * before `resolveComposition` executes, our composition session will
  9556. * continue.
  9557. *
  9558. * The `resolved` flag is useful because certain IME interfaces fire the
  9559. * `compositionend` event multiple times, thus queueing up multiple attempts
  9560. * at handling the composition. Since handling the same composition event
  9561. * twice could break the DOM, we only use the first event. Example: Arabic
  9562. * Google Input Tools on Windows 8.1 fires `compositionend` three times.
  9563. */
  9564. onCompositionEnd: function onCompositionEnd(editor) {
  9565. resolved = false;
  9566. stillComposing = false;
  9567. setTimeout(function() {
  9568. if (!resolved) {
  9569. DraftEditorCompositionHandler.resolveComposition(editor);
  9570. }
  9571. }, RESOLVE_DELAY);
  9572. },
  9573. /**
  9574. * In Safari, keydown events may fire when committing compositions. If
  9575. * the arrow keys are used to commit, prevent default so that the cursor
  9576. * doesn't move, otherwise it will jump back noticeably on re-render.
  9577. */
  9578. onKeyDown: function onKeyDown(editor, e) {
  9579. if (!stillComposing) {
  9580. // If a keydown event is received after compositionend but before the
  9581. // 20ms timer expires (ex: type option-E then backspace, or type A then
  9582. // backspace in 2-Set Korean), we should immediately resolve the
  9583. // composition and reinterpret the key press in edit mode.
  9584. DraftEditorCompositionHandler.resolveComposition(editor);
  9585. editor._onKeyDown(e);
  9586. return;
  9587. }
  9588. if (e.which === Keys.RIGHT || e.which === Keys.LEFT) {
  9589. e.preventDefault();
  9590. }
  9591. },
  9592. /**
  9593. * Keypress events may fire when committing compositions. In Firefox,
  9594. * pressing RETURN commits the composition and inserts extra newline
  9595. * characters that we do not want. `preventDefault` allows the composition
  9596. * to be committed while preventing the extra characters.
  9597. */
  9598. onKeyPress: function onKeyPress(editor, e) {
  9599. if (e.which === Keys.RETURN) {
  9600. e.preventDefault();
  9601. }
  9602. },
  9603. /**
  9604. * Attempt to insert composed characters into the document.
  9605. *
  9606. * If we are still in a composition session, do nothing. Otherwise, insert
  9607. * the characters into the document and terminate the composition session.
  9608. *
  9609. * If no characters were composed -- for instance, the user
  9610. * deleted all composed characters and committed nothing new --
  9611. * force a re-render. We also re-render when the composition occurs
  9612. * at the beginning of a leaf, to ensure that if the browser has
  9613. * created a new text node for the composition, we will discard it.
  9614. *
  9615. * Resetting innerHTML will move focus to the beginning of the editor,
  9616. * so we update to force it back to the correct place.
  9617. */
  9618. resolveComposition: function resolveComposition(editor) {
  9619. if (stillComposing) {
  9620. return;
  9621. }
  9622. resolved = true;
  9623. var composedChars = textInputData;
  9624. textInputData = "";
  9625. var editorState = EditorState_1.set(editor._latestEditorState, {
  9626. inCompositionMode: false
  9627. });
  9628. var currentStyle = editorState.getCurrentInlineStyle();
  9629. var entityKey = getEntityKeyForSelection_1(
  9630. editorState.getCurrentContent(),
  9631. editorState.getSelection()
  9632. );
  9633. var mustReset =
  9634. !composedChars ||
  9635. isSelectionAtLeafStart_1(editorState) ||
  9636. currentStyle.size > 0 ||
  9637. entityKey !== null;
  9638. if (mustReset) {
  9639. editor.restoreEditorDOM();
  9640. }
  9641. editor.exitCurrentMode();
  9642. if (composedChars) {
  9643. // If characters have been composed, re-rendering with the update
  9644. // is sufficient to reset the editor.
  9645. var contentState = DraftModifier_1.replaceText(
  9646. editorState.getCurrentContent(),
  9647. editorState.getSelection(),
  9648. composedChars,
  9649. currentStyle,
  9650. entityKey
  9651. );
  9652. editor.update(
  9653. EditorState_1.push(editorState, contentState, "insert-characters")
  9654. );
  9655. return;
  9656. }
  9657. if (mustReset) {
  9658. editor.update(
  9659. EditorState_1.set(editorState, {
  9660. nativelyRenderedContent: null,
  9661. forceSelection: true
  9662. })
  9663. );
  9664. }
  9665. }
  9666. };
  9667. var DraftEditorCompositionHandler_1 = DraftEditorCompositionHandler;
  9668. var uaParser = _commonjsHelpers.createCommonjsModule(function(module, exports) {
  9669. /*!
  9670. * UAParser.js v0.7.21
  9671. * Lightweight JavaScript-based User-Agent string parser
  9672. * https://github.com/faisalman/ua-parser-js
  9673. *
  9674. * Copyright © 2012-2019 Faisal Salman <f@faisalman.com>
  9675. * Licensed under MIT License
  9676. */
  9677. (function(window, undefined$1) {
  9678. //////////////
  9679. // Constants
  9680. /////////////
  9681. var LIBVERSION = "0.7.21",
  9682. EMPTY = "",
  9683. UNKNOWN = "?",
  9684. FUNC_TYPE = "function",
  9685. OBJ_TYPE = "object",
  9686. STR_TYPE = "string",
  9687. MAJOR = "major", // deprecated
  9688. MODEL = "model",
  9689. NAME = "name",
  9690. TYPE = "type",
  9691. VENDOR = "vendor",
  9692. VERSION = "version",
  9693. ARCHITECTURE = "architecture",
  9694. CONSOLE = "console",
  9695. MOBILE = "mobile",
  9696. TABLET = "tablet",
  9697. SMARTTV = "smarttv",
  9698. WEARABLE = "wearable",
  9699. EMBEDDED = "embedded";
  9700. ///////////
  9701. // Helper
  9702. //////////
  9703. var util = {
  9704. extend: function(regexes, extensions) {
  9705. var mergedRegexes = {};
  9706. for (var i in regexes) {
  9707. if (extensions[i] && extensions[i].length % 2 === 0) {
  9708. mergedRegexes[i] = extensions[i].concat(regexes[i]);
  9709. } else {
  9710. mergedRegexes[i] = regexes[i];
  9711. }
  9712. }
  9713. return mergedRegexes;
  9714. },
  9715. has: function(str1, str2) {
  9716. if (typeof str1 === "string") {
  9717. return str2.toLowerCase().indexOf(str1.toLowerCase()) !== -1;
  9718. } else {
  9719. return false;
  9720. }
  9721. },
  9722. lowerize: function(str) {
  9723. return str.toLowerCase();
  9724. },
  9725. major: function(version) {
  9726. return typeof version === STR_TYPE
  9727. ? version.replace(/[^\d\.]/g, "").split(".")[0]
  9728. : undefined$1;
  9729. },
  9730. trim: function(str) {
  9731. return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
  9732. }
  9733. };
  9734. ///////////////
  9735. // Map helper
  9736. //////////////
  9737. var mapper = {
  9738. rgx: function(ua, arrays) {
  9739. var i = 0,
  9740. j,
  9741. k,
  9742. p,
  9743. q,
  9744. matches,
  9745. match;
  9746. // loop through all regexes maps
  9747. while (i < arrays.length && !matches) {
  9748. var regex = arrays[i], // even sequence (0,2,4,..)
  9749. props = arrays[i + 1]; // odd sequence (1,3,5,..)
  9750. j = k = 0;
  9751. // try matching uastring with regexes
  9752. while (j < regex.length && !matches) {
  9753. matches = regex[j++].exec(ua);
  9754. if (!!matches) {
  9755. for (p = 0; p < props.length; p++) {
  9756. match = matches[++k];
  9757. q = props[p];
  9758. // check if given property is actually array
  9759. if (typeof q === OBJ_TYPE && q.length > 0) {
  9760. if (q.length == 2) {
  9761. if (typeof q[1] == FUNC_TYPE) {
  9762. // assign modified match
  9763. this[q[0]] = q[1].call(this, match);
  9764. } else {
  9765. // assign given value, ignore regex match
  9766. this[q[0]] = q[1];
  9767. }
  9768. } else if (q.length == 3) {
  9769. // check whether function or regex
  9770. if (
  9771. typeof q[1] === FUNC_TYPE &&
  9772. !(q[1].exec && q[1].test)
  9773. ) {
  9774. // call function (usually string mapper)
  9775. this[q[0]] = match
  9776. ? q[1].call(this, match, q[2])
  9777. : undefined$1;
  9778. } else {
  9779. // sanitize match using given regex
  9780. this[q[0]] = match
  9781. ? match.replace(q[1], q[2])
  9782. : undefined$1;
  9783. }
  9784. } else if (q.length == 4) {
  9785. this[q[0]] = match
  9786. ? q[3].call(this, match.replace(q[1], q[2]))
  9787. : undefined$1;
  9788. }
  9789. } else {
  9790. this[q] = match ? match : undefined$1;
  9791. }
  9792. }
  9793. }
  9794. }
  9795. i += 2;
  9796. }
  9797. },
  9798. str: function(str, map) {
  9799. for (var i in map) {
  9800. // check if array
  9801. if (typeof map[i] === OBJ_TYPE && map[i].length > 0) {
  9802. for (var j = 0; j < map[i].length; j++) {
  9803. if (util.has(map[i][j], str)) {
  9804. return i === UNKNOWN ? undefined$1 : i;
  9805. }
  9806. }
  9807. } else if (util.has(map[i], str)) {
  9808. return i === UNKNOWN ? undefined$1 : i;
  9809. }
  9810. }
  9811. return str;
  9812. }
  9813. };
  9814. ///////////////
  9815. // String map
  9816. //////////////
  9817. var maps = {
  9818. browser: {
  9819. oldsafari: {
  9820. version: {
  9821. "1.0": "/8",
  9822. "1.2": "/1",
  9823. "1.3": "/3",
  9824. "2.0": "/412",
  9825. "2.0.2": "/416",
  9826. "2.0.3": "/417",
  9827. "2.0.4": "/419",
  9828. "?": "/"
  9829. }
  9830. }
  9831. },
  9832. device: {
  9833. amazon: {
  9834. model: {
  9835. "Fire Phone": ["SD", "KF"]
  9836. }
  9837. },
  9838. sprint: {
  9839. model: {
  9840. "Evo Shift 4G": "7373KT"
  9841. },
  9842. vendor: {
  9843. HTC: "APA",
  9844. Sprint: "Sprint"
  9845. }
  9846. }
  9847. },
  9848. os: {
  9849. windows: {
  9850. version: {
  9851. ME: "4.90",
  9852. "NT 3.11": "NT3.51",
  9853. "NT 4.0": "NT4.0",
  9854. "2000": "NT 5.0",
  9855. XP: ["NT 5.1", "NT 5.2"],
  9856. Vista: "NT 6.0",
  9857. "7": "NT 6.1",
  9858. "8": "NT 6.2",
  9859. "8.1": "NT 6.3",
  9860. "10": ["NT 6.4", "NT 10.0"],
  9861. RT: "ARM"
  9862. }
  9863. }
  9864. }
  9865. };
  9866. //////////////
  9867. // Regex map
  9868. /////////////
  9869. var regexes = {
  9870. browser: [
  9871. [
  9872. // Presto based
  9873. /(opera\smini)\/([\w\.-]+)/i, // Opera Mini
  9874. /(opera\s[mobiletab]+).+version\/([\w\.-]+)/i, // Opera Mobi/Tablet
  9875. /(opera).+version\/([\w\.]+)/i, // Opera > 9.80
  9876. /(opera)[\/\s]+([\w\.]+)/i // Opera < 9.80
  9877. ],
  9878. [NAME, VERSION],
  9879. [
  9880. /(opios)[\/\s]+([\w\.]+)/i // Opera mini on iphone >= 8.0
  9881. ],
  9882. [[NAME, "Opera Mini"], VERSION],
  9883. [
  9884. /\s(opr)\/([\w\.]+)/i // Opera Webkit
  9885. ],
  9886. [[NAME, "Opera"], VERSION],
  9887. [
  9888. // Mixed
  9889. /(kindle)\/([\w\.]+)/i, // Kindle
  9890. /(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?([\w\.]*)/i,
  9891. // Lunascape/Maxthon/Netfront/Jasmine/Blazer
  9892. // Trident based
  9893. /(avant\s|iemobile|slim)(?:browser)?[\/\s]?([\w\.]*)/i,
  9894. // Avant/IEMobile/SlimBrowser
  9895. /(bidubrowser|baidubrowser)[\/\s]?([\w\.]+)/i, // Baidu Browser
  9896. /(?:ms|\()(ie)\s([\w\.]+)/i, // Internet Explorer
  9897. // Webkit/KHTML based
  9898. /(rekonq)\/([\w\.]*)/i, // Rekonq
  9899. /(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon)\/([\w\.-]+)/i
  9900. // Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium/PhantomJS/Bowser/QupZilla/Falkon
  9901. ],
  9902. [NAME, VERSION],
  9903. [
  9904. /(konqueror)\/([\w\.]+)/i // Konqueror
  9905. ],
  9906. [[NAME, "Konqueror"], VERSION],
  9907. [
  9908. /(trident).+rv[:\s]([\w\.]+).+like\sgecko/i // IE11
  9909. ],
  9910. [[NAME, "IE"], VERSION],
  9911. [
  9912. /(edge|edgios|edga|edg)\/((\d+)?[\w\.]+)/i // Microsoft Edge
  9913. ],
  9914. [[NAME, "Edge"], VERSION],
  9915. [
  9916. /(yabrowser)\/([\w\.]+)/i // Yandex
  9917. ],
  9918. [[NAME, "Yandex"], VERSION],
  9919. [
  9920. /(Avast)\/([\w\.]+)/i // Avast Secure Browser
  9921. ],
  9922. [[NAME, "Avast Secure Browser"], VERSION],
  9923. [
  9924. /(AVG)\/([\w\.]+)/i // AVG Secure Browser
  9925. ],
  9926. [[NAME, "AVG Secure Browser"], VERSION],
  9927. [
  9928. /(puffin)\/([\w\.]+)/i // Puffin
  9929. ],
  9930. [[NAME, "Puffin"], VERSION],
  9931. [
  9932. /(focus)\/([\w\.]+)/i // Firefox Focus
  9933. ],
  9934. [[NAME, "Firefox Focus"], VERSION],
  9935. [
  9936. /(opt)\/([\w\.]+)/i // Opera Touch
  9937. ],
  9938. [[NAME, "Opera Touch"], VERSION],
  9939. [
  9940. /((?:[\s\/])uc?\s?browser|(?:juc.+)ucweb)[\/\s]?([\w\.]+)/i // UCBrowser
  9941. ],
  9942. [[NAME, "UCBrowser"], VERSION],
  9943. [
  9944. /(comodo_dragon)\/([\w\.]+)/i // Comodo Dragon
  9945. ],
  9946. [[NAME, /_/g, " "], VERSION],
  9947. [
  9948. /(windowswechat qbcore)\/([\w\.]+)/i // WeChat Desktop for Windows Built-in Browser
  9949. ],
  9950. [[NAME, "WeChat(Win) Desktop"], VERSION],
  9951. [
  9952. /(micromessenger)\/([\w\.]+)/i // WeChat
  9953. ],
  9954. [[NAME, "WeChat"], VERSION],
  9955. [
  9956. /(brave)\/([\w\.]+)/i // Brave browser
  9957. ],
  9958. [[NAME, "Brave"], VERSION],
  9959. [
  9960. /(qqbrowserlite)\/([\w\.]+)/i // QQBrowserLite
  9961. ],
  9962. [NAME, VERSION],
  9963. [
  9964. /(QQ)\/([\d\.]+)/i // QQ, aka ShouQ
  9965. ],
  9966. [NAME, VERSION],
  9967. [
  9968. /m?(qqbrowser)[\/\s]?([\w\.]+)/i // QQBrowser
  9969. ],
  9970. [NAME, VERSION],
  9971. [
  9972. /(baiduboxapp)[\/\s]?([\w\.]+)/i // Baidu App
  9973. ],
  9974. [NAME, VERSION],
  9975. [
  9976. /(2345Explorer)[\/\s]?([\w\.]+)/i // 2345 Browser
  9977. ],
  9978. [NAME, VERSION],
  9979. [
  9980. /(MetaSr)[\/\s]?([\w\.]+)/i // SouGouBrowser
  9981. ],
  9982. [NAME],
  9983. [
  9984. /(LBBROWSER)/i // LieBao Browser
  9985. ],
  9986. [NAME],
  9987. [
  9988. /xiaomi\/miuibrowser\/([\w\.]+)/i // MIUI Browser
  9989. ],
  9990. [VERSION, [NAME, "MIUI Browser"]],
  9991. [
  9992. /;fbav\/([\w\.]+);/i // Facebook App for iOS & Android
  9993. ],
  9994. [VERSION, [NAME, "Facebook"]],
  9995. [
  9996. /safari\s(line)\/([\w\.]+)/i, // Line App for iOS
  9997. /android.+(line)\/([\w\.]+)\/iab/i // Line App for Android
  9998. ],
  9999. [NAME, VERSION],
  10000. [
  10001. /headlesschrome(?:\/([\w\.]+)|\s)/i // Chrome Headless
  10002. ],
  10003. [VERSION, [NAME, "Chrome Headless"]],
  10004. [
  10005. /\swv\).+(chrome)\/([\w\.]+)/i // Chrome WebView
  10006. ],
  10007. [[NAME, /(.+)/, "$1 WebView"], VERSION],
  10008. [/((?:oculus|samsung)browser)\/([\w\.]+)/i],
  10009. [[NAME, /(.+(?:g|us))(.+)/, "$1 $2"], VERSION],
  10010. [
  10011. // Oculus / Samsung Browser
  10012. /android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)*/i // Android Browser
  10013. ],
  10014. [VERSION, [NAME, "Android Browser"]],
  10015. [
  10016. /(sailfishbrowser)\/([\w\.]+)/i // Sailfish Browser
  10017. ],
  10018. [[NAME, "Sailfish Browser"], VERSION],
  10019. [
  10020. /(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?([\w\.]+)/i
  10021. // Chrome/OmniWeb/Arora/Tizen/Nokia
  10022. ],
  10023. [NAME, VERSION],
  10024. [
  10025. /(dolfin)\/([\w\.]+)/i // Dolphin
  10026. ],
  10027. [[NAME, "Dolphin"], VERSION],
  10028. [
  10029. /(qihu|qhbrowser|qihoobrowser|360browser)/i // 360
  10030. ],
  10031. [[NAME, "360 Browser"]],
  10032. [
  10033. /((?:android.+)crmo|crios)\/([\w\.]+)/i // Chrome for Android/iOS
  10034. ],
  10035. [[NAME, "Chrome"], VERSION],
  10036. [
  10037. /(coast)\/([\w\.]+)/i // Opera Coast
  10038. ],
  10039. [[NAME, "Opera Coast"], VERSION],
  10040. [
  10041. /fxios\/([\w\.-]+)/i // Firefox for iOS
  10042. ],
  10043. [VERSION, [NAME, "Firefox"]],
  10044. [
  10045. /version\/([\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari
  10046. ],
  10047. [VERSION, [NAME, "Mobile Safari"]],
  10048. [
  10049. /version\/([\w\.]+).+?(mobile\s?safari|safari)/i // Safari & Safari Mobile
  10050. ],
  10051. [VERSION, NAME],
  10052. [
  10053. /webkit.+?(gsa)\/([\w\.]+).+?(mobile\s?safari|safari)(\/[\w\.]+)/i // Google Search Appliance on iOS
  10054. ],
  10055. [[NAME, "GSA"], VERSION],
  10056. [
  10057. /webkit.+?(mobile\s?safari|safari)(\/[\w\.]+)/i // Safari < 3.0
  10058. ],
  10059. [NAME, [VERSION, mapper.str, maps.browser.oldsafari.version]],
  10060. [/(webkit|khtml)\/([\w\.]+)/i],
  10061. [NAME, VERSION],
  10062. [
  10063. // Gecko based
  10064. /(navigator|netscape)\/([\w\.-]+)/i // Netscape
  10065. ],
  10066. [[NAME, "Netscape"], VERSION],
  10067. [
  10068. /(swiftfox)/i, // Swiftfox
  10069. /(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?([\w\.\+]+)/i,
  10070. // IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror
  10071. /(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([\w\.-]+)$/i,
  10072. // Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix
  10073. /(mozilla)\/([\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla
  10074. // Other
  10075. /(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir)[\/\s]?([\w\.]+)/i,
  10076. // Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/Sleipnir
  10077. /(links)\s\(([\w\.]+)/i, // Links
  10078. /(gobrowser)\/?([\w\.]*)/i, // GoBrowser
  10079. /(ice\s?browser)\/v?([\w\._]+)/i, // ICE Browser
  10080. /(mosaic)[\/\s]([\w\.]+)/i // Mosaic
  10081. ],
  10082. [NAME, VERSION]
  10083. ],
  10084. cpu: [
  10085. [
  10086. /(?:(amd|x(?:(?:86|64)[_-])?|wow|win)64)[;\)]/i // AMD64
  10087. ],
  10088. [[ARCHITECTURE, "amd64"]],
  10089. [
  10090. /(ia32(?=;))/i // IA32 (quicktime)
  10091. ],
  10092. [[ARCHITECTURE, util.lowerize]],
  10093. [
  10094. /((?:i[346]|x)86)[;\)]/i // IA32
  10095. ],
  10096. [[ARCHITECTURE, "ia32"]],
  10097. [
  10098. // PocketPC mistakenly identified as PowerPC
  10099. /windows\s(ce|mobile);\sppc;/i
  10100. ],
  10101. [[ARCHITECTURE, "arm"]],
  10102. [
  10103. /((?:ppc|powerpc)(?:64)?)(?:\smac|;|\))/i // PowerPC
  10104. ],
  10105. [[ARCHITECTURE, /ower/, "", util.lowerize]],
  10106. [
  10107. /(sun4\w)[;\)]/i // SPARC
  10108. ],
  10109. [[ARCHITECTURE, "sparc"]],
  10110. [
  10111. /((?:avr32|ia64(?=;))|68k(?=\))|arm(?:64|(?=v\d+[;l]))|(?=atmel\s)avr|(?:irix|mips|sparc)(?:64)?(?=;)|pa-risc)/i
  10112. // IA64, 68K, ARM/64, AVR/32, IRIX/64, MIPS/64, SPARC/64, PA-RISC
  10113. ],
  10114. [[ARCHITECTURE, util.lowerize]]
  10115. ],
  10116. device: [
  10117. [
  10118. /\((ipad|playbook);[\w\s\),;-]+(rim|apple)/i // iPad/PlayBook
  10119. ],
  10120. [MODEL, VENDOR, [TYPE, TABLET]],
  10121. [
  10122. /applecoremedia\/[\w\.]+ \((ipad)/ // iPad
  10123. ],
  10124. [MODEL, [VENDOR, "Apple"], [TYPE, TABLET]],
  10125. [
  10126. /(apple\s{0,1}tv)/i // Apple TV
  10127. ],
  10128. [
  10129. [MODEL, "Apple TV"],
  10130. [VENDOR, "Apple"],
  10131. [TYPE, SMARTTV]
  10132. ],
  10133. [
  10134. /(archos)\s(gamepad2?)/i, // Archos
  10135. /(hp).+(touchpad)/i, // HP TouchPad
  10136. /(hp).+(tablet)/i, // HP Tablet
  10137. /(kindle)\/([\w\.]+)/i, // Kindle
  10138. /\s(nook)[\w\s]+build\/(\w+)/i, // Nook
  10139. /(dell)\s(strea[kpr\s\d]*[\dko])/i // Dell Streak
  10140. ],
  10141. [VENDOR, MODEL, [TYPE, TABLET]],
  10142. [
  10143. /(kf[A-z]+)\sbuild\/.+silk\//i // Kindle Fire HD
  10144. ],
  10145. [MODEL, [VENDOR, "Amazon"], [TYPE, TABLET]],
  10146. [
  10147. /(sd|kf)[0349hijorstuw]+\sbuild\/.+silk\//i // Fire Phone
  10148. ],
  10149. [
  10150. [MODEL, mapper.str, maps.device.amazon.model],
  10151. [VENDOR, "Amazon"],
  10152. [TYPE, MOBILE]
  10153. ],
  10154. [
  10155. /android.+aft([bms])\sbuild/i // Fire TV
  10156. ],
  10157. [MODEL, [VENDOR, "Amazon"], [TYPE, SMARTTV]],
  10158. [
  10159. /\((ip[honed|\s\w*]+);.+(apple)/i // iPod/iPhone
  10160. ],
  10161. [MODEL, VENDOR, [TYPE, MOBILE]],
  10162. [
  10163. /\((ip[honed|\s\w*]+);/i // iPod/iPhone
  10164. ],
  10165. [MODEL, [VENDOR, "Apple"], [TYPE, MOBILE]],
  10166. [
  10167. /(blackberry)[\s-]?(\w+)/i, // BlackBerry
  10168. /(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[\s_-]?([\w-]*)/i,
  10169. // BenQ/Palm/Sony-Ericsson/Acer/Asus/Dell/Meizu/Motorola/Polytron
  10170. /(hp)\s([\w\s]+\w)/i, // HP iPAQ
  10171. /(asus)-?(\w+)/i // Asus
  10172. ],
  10173. [VENDOR, MODEL, [TYPE, MOBILE]],
  10174. [
  10175. /\(bb10;\s(\w+)/i // BlackBerry 10
  10176. ],
  10177. [MODEL, [VENDOR, "BlackBerry"], [TYPE, MOBILE]],
  10178. [
  10179. // Asus Tablets
  10180. /android.+(transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+|nexus 7|padfone|p00c)/i
  10181. ],
  10182. [MODEL, [VENDOR, "Asus"], [TYPE, TABLET]],
  10183. [
  10184. /(sony)\s(tablet\s[ps])\sbuild\//i, // Sony
  10185. /(sony)?(?:sgp.+)\sbuild\//i
  10186. ],
  10187. [
  10188. [VENDOR, "Sony"],
  10189. [MODEL, "Xperia Tablet"],
  10190. [TYPE, TABLET]
  10191. ],
  10192. [
  10193. /android.+\s([c-g]\d{4}|so[-l]\w+)(?=\sbuild\/|\).+chrome\/(?![1-6]{0,1}\d\.))/i
  10194. ],
  10195. [MODEL, [VENDOR, "Sony"], [TYPE, MOBILE]],
  10196. [
  10197. /\s(ouya)\s/i, // Ouya
  10198. /(nintendo)\s([wids3u]+)/i // Nintendo
  10199. ],
  10200. [VENDOR, MODEL, [TYPE, CONSOLE]],
  10201. [
  10202. /android.+;\s(shield)\sbuild/i // Nvidia
  10203. ],
  10204. [MODEL, [VENDOR, "Nvidia"], [TYPE, CONSOLE]],
  10205. [
  10206. /(playstation\s[34portablevi]+)/i // Playstation
  10207. ],
  10208. [MODEL, [VENDOR, "Sony"], [TYPE, CONSOLE]],
  10209. [
  10210. /(sprint\s(\w+))/i // Sprint Phones
  10211. ],
  10212. [
  10213. [VENDOR, mapper.str, maps.device.sprint.vendor],
  10214. [MODEL, mapper.str, maps.device.sprint.model],
  10215. [TYPE, MOBILE]
  10216. ],
  10217. [
  10218. /(htc)[;_\s-]+([\w\s]+(?=\)|\sbuild)|\w+)/i, // HTC
  10219. /(zte)-(\w*)/i, // ZTE
  10220. /(alcatel|geeksphone|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]*)/i
  10221. // Alcatel/GeeksPhone/Nexian/Panasonic/Sony
  10222. ],
  10223. [VENDOR, [MODEL, /_/g, " "], [TYPE, MOBILE]],
  10224. [
  10225. /(nexus\s9)/i // HTC Nexus 9
  10226. ],
  10227. [MODEL, [VENDOR, "HTC"], [TYPE, TABLET]],
  10228. [
  10229. /d\/huawei([\w\s-]+)[;\)]/i,
  10230. /(nexus\s6p|vog-l29|ane-lx1|eml-l29)/i // Huawei
  10231. ],
  10232. [MODEL, [VENDOR, "Huawei"], [TYPE, MOBILE]],
  10233. [
  10234. /android.+(bah2?-a?[lw]\d{2})/i // Huawei MediaPad
  10235. ],
  10236. [MODEL, [VENDOR, "Huawei"], [TYPE, TABLET]],
  10237. [
  10238. /(microsoft);\s(lumia[\s\w]+)/i // Microsoft Lumia
  10239. ],
  10240. [VENDOR, MODEL, [TYPE, MOBILE]],
  10241. [
  10242. /[\s\(;](xbox(?:\sone)?)[\s\);]/i // Microsoft Xbox
  10243. ],
  10244. [MODEL, [VENDOR, "Microsoft"], [TYPE, CONSOLE]],
  10245. [
  10246. /(kin\.[onetw]{3})/i // Microsoft Kin
  10247. ],
  10248. [
  10249. [MODEL, /\./g, " "],
  10250. [VENDOR, "Microsoft"],
  10251. [TYPE, MOBILE]
  10252. ],
  10253. [
  10254. // Motorola
  10255. /\s(milestone|droid(?:[2-4x]|\s(?:bionic|x2|pro|razr))?:?(\s4g)?)[\w\s]+build\//i,
  10256. /mot[\s-]?(\w*)/i,
  10257. /(XT\d{3,4}) build\//i,
  10258. /(nexus\s6)/i
  10259. ],
  10260. [MODEL, [VENDOR, "Motorola"], [TYPE, MOBILE]],
  10261. [/android.+\s(mz60\d|xoom[\s2]{0,2})\sbuild\//i],
  10262. [MODEL, [VENDOR, "Motorola"], [TYPE, TABLET]],
  10263. [
  10264. /hbbtv\/\d+\.\d+\.\d+\s+\([\w\s]*;\s*(\w[^;]*);([^;]*)/i // HbbTV devices
  10265. ],
  10266. [
  10267. [VENDOR, util.trim],
  10268. [MODEL, util.trim],
  10269. [TYPE, SMARTTV]
  10270. ],
  10271. [/hbbtv.+maple;(\d+)/i],
  10272. [
  10273. [MODEL, /^/, "SmartTV"],
  10274. [VENDOR, "Samsung"],
  10275. [TYPE, SMARTTV]
  10276. ],
  10277. [
  10278. /\(dtv[\);].+(aquos)/i // Sharp
  10279. ],
  10280. [MODEL, [VENDOR, "Sharp"], [TYPE, SMARTTV]],
  10281. [
  10282. /android.+((sch-i[89]0\d|shw-m380s|gt-p\d{4}|gt-n\d+|sgh-t8[56]9|nexus 10))/i,
  10283. /((SM-T\w+))/i
  10284. ],
  10285. [[VENDOR, "Samsung"], MODEL, [TYPE, TABLET]],
  10286. [
  10287. // Samsung
  10288. /smart-tv.+(samsung)/i
  10289. ],
  10290. [VENDOR, [TYPE, SMARTTV], MODEL],
  10291. [
  10292. /((s[cgp]h-\w+|gt-\w+|galaxy\snexus|sm-\w[\w\d]+))/i,
  10293. /(sam[sung]*)[\s-]*(\w+-?[\w-]*)/i,
  10294. /sec-((sgh\w+))/i
  10295. ],
  10296. [[VENDOR, "Samsung"], MODEL, [TYPE, MOBILE]],
  10297. [
  10298. /sie-(\w*)/i // Siemens
  10299. ],
  10300. [MODEL, [VENDOR, "Siemens"], [TYPE, MOBILE]],
  10301. [
  10302. /(maemo|nokia).*(n900|lumia\s\d+)/i, // Nokia
  10303. /(nokia)[\s_-]?([\w-]*)/i
  10304. ],
  10305. [[VENDOR, "Nokia"], MODEL, [TYPE, MOBILE]],
  10306. [
  10307. /android[x\d\.\s;]+\s([ab][1-7]\-?[0178a]\d\d?)/i // Acer
  10308. ],
  10309. [MODEL, [VENDOR, "Acer"], [TYPE, TABLET]],
  10310. [
  10311. /android.+([vl]k\-?\d{3})\s+build/i // LG Tablet
  10312. ],
  10313. [MODEL, [VENDOR, "LG"], [TYPE, TABLET]],
  10314. [
  10315. /android\s3\.[\s\w;-]{10}(lg?)-([06cv9]{3,4})/i // LG Tablet
  10316. ],
  10317. [[VENDOR, "LG"], MODEL, [TYPE, TABLET]],
  10318. [
  10319. /(lg) netcast\.tv/i // LG SmartTV
  10320. ],
  10321. [VENDOR, MODEL, [TYPE, SMARTTV]],
  10322. [
  10323. /(nexus\s[45])/i, // LG
  10324. /lg[e;\s\/-]+(\w*)/i,
  10325. /android.+lg(\-?[\d\w]+)\s+build/i
  10326. ],
  10327. [MODEL, [VENDOR, "LG"], [TYPE, MOBILE]],
  10328. [
  10329. /(lenovo)\s?(s(?:5000|6000)(?:[\w-]+)|tab(?:[\s\w]+))/i // Lenovo tablets
  10330. ],
  10331. [VENDOR, MODEL, [TYPE, TABLET]],
  10332. [
  10333. /android.+(ideatab[a-z0-9\-\s]+)/i // Lenovo
  10334. ],
  10335. [MODEL, [VENDOR, "Lenovo"], [TYPE, TABLET]],
  10336. [/(lenovo)[_\s-]?([\w-]+)/i],
  10337. [VENDOR, MODEL, [TYPE, MOBILE]],
  10338. [
  10339. /linux;.+((jolla));/i // Jolla
  10340. ],
  10341. [VENDOR, MODEL, [TYPE, MOBILE]],
  10342. [
  10343. /((pebble))app\/[\d\.]+\s/i // Pebble
  10344. ],
  10345. [VENDOR, MODEL, [TYPE, WEARABLE]],
  10346. [
  10347. /android.+;\s(oppo)\s?([\w\s]+)\sbuild/i // OPPO
  10348. ],
  10349. [VENDOR, MODEL, [TYPE, MOBILE]],
  10350. [
  10351. /crkey/i // Google Chromecast
  10352. ],
  10353. [
  10354. [MODEL, "Chromecast"],
  10355. [VENDOR, "Google"],
  10356. [TYPE, SMARTTV]
  10357. ],
  10358. [
  10359. /android.+;\s(glass)\s\d/i // Google Glass
  10360. ],
  10361. [MODEL, [VENDOR, "Google"], [TYPE, WEARABLE]],
  10362. [
  10363. /android.+;\s(pixel c)[\s)]/i // Google Pixel C
  10364. ],
  10365. [MODEL, [VENDOR, "Google"], [TYPE, TABLET]],
  10366. [
  10367. /android.+;\s(pixel( [23])?( xl)?)[\s)]/i // Google Pixel
  10368. ],
  10369. [MODEL, [VENDOR, "Google"], [TYPE, MOBILE]],
  10370. [
  10371. /android.+;\s(\w+)\s+build\/hm\1/i, // Xiaomi Hongmi 'numeric' models
  10372. /android.+(hm[\s\-_]*note?[\s_]*(?:\d\w)?)\s+build/i, // Xiaomi Hongmi
  10373. /android.+(mi[\s\-_]*(?:a\d|one|one[\s_]plus|note lte)?[\s_]*(?:\d?\w?)[\s_]*(?:plus)?)\s+build/i,
  10374. // Xiaomi Mi
  10375. /android.+(redmi[\s\-_]*(?:note)?(?:[\s_]*[\w\s]+))\s+build/i // Redmi Phones
  10376. ],
  10377. [
  10378. [MODEL, /_/g, " "],
  10379. [VENDOR, "Xiaomi"],
  10380. [TYPE, MOBILE]
  10381. ],
  10382. [
  10383. /android.+(mi[\s\-_]*(?:pad)(?:[\s_]*[\w\s]+))\s+build/i // Mi Pad tablets
  10384. ],
  10385. [
  10386. [MODEL, /_/g, " "],
  10387. [VENDOR, "Xiaomi"],
  10388. [TYPE, TABLET]
  10389. ],
  10390. [
  10391. /android.+;\s(m[1-5]\snote)\sbuild/i // Meizu
  10392. ],
  10393. [MODEL, [VENDOR, "Meizu"], [TYPE, MOBILE]],
  10394. [/(mz)-([\w-]{2,})/i],
  10395. [[VENDOR, "Meizu"], MODEL, [TYPE, MOBILE]],
  10396. [
  10397. /android.+a000(1)\s+build/i, // OnePlus
  10398. /android.+oneplus\s(a\d{4})[\s)]/i
  10399. ],
  10400. [MODEL, [VENDOR, "OnePlus"], [TYPE, MOBILE]],
  10401. [
  10402. /android.+[;\/]\s*(RCT[\d\w]+)\s+build/i // RCA Tablets
  10403. ],
  10404. [MODEL, [VENDOR, "RCA"], [TYPE, TABLET]],
  10405. [
  10406. /android.+[;\/\s]+(Venue[\d\s]{2,7})\s+build/i // Dell Venue Tablets
  10407. ],
  10408. [MODEL, [VENDOR, "Dell"], [TYPE, TABLET]],
  10409. [
  10410. /android.+[;\/]\s*(Q[T|M][\d\w]+)\s+build/i // Verizon Tablet
  10411. ],
  10412. [MODEL, [VENDOR, "Verizon"], [TYPE, TABLET]],
  10413. [
  10414. /android.+[;\/]\s+(Barnes[&\s]+Noble\s+|BN[RT])(V?.*)\s+build/i // Barnes & Noble Tablet
  10415. ],
  10416. [[VENDOR, "Barnes & Noble"], MODEL, [TYPE, TABLET]],
  10417. [
  10418. /android.+[;\/]\s+(TM\d{3}.*\b)\s+build/i // Barnes & Noble Tablet
  10419. ],
  10420. [MODEL, [VENDOR, "NuVision"], [TYPE, TABLET]],
  10421. [
  10422. /android.+;\s(k88)\sbuild/i // ZTE K Series Tablet
  10423. ],
  10424. [MODEL, [VENDOR, "ZTE"], [TYPE, TABLET]],
  10425. [
  10426. /android.+[;\/]\s*(gen\d{3})\s+build.*49h/i // Swiss GEN Mobile
  10427. ],
  10428. [MODEL, [VENDOR, "Swiss"], [TYPE, MOBILE]],
  10429. [
  10430. /android.+[;\/]\s*(zur\d{3})\s+build/i // Swiss ZUR Tablet
  10431. ],
  10432. [MODEL, [VENDOR, "Swiss"], [TYPE, TABLET]],
  10433. [
  10434. /android.+[;\/]\s*((Zeki)?TB.*\b)\s+build/i // Zeki Tablets
  10435. ],
  10436. [MODEL, [VENDOR, "Zeki"], [TYPE, TABLET]],
  10437. [
  10438. /(android).+[;\/]\s+([YR]\d{2})\s+build/i,
  10439. /android.+[;\/]\s+(Dragon[\-\s]+Touch\s+|DT)(\w{5})\sbuild/i // Dragon Touch Tablet
  10440. ],
  10441. [[VENDOR, "Dragon Touch"], MODEL, [TYPE, TABLET]],
  10442. [
  10443. /android.+[;\/]\s*(NS-?\w{0,9})\sbuild/i // Insignia Tablets
  10444. ],
  10445. [MODEL, [VENDOR, "Insignia"], [TYPE, TABLET]],
  10446. [
  10447. /android.+[;\/]\s*((NX|Next)-?\w{0,9})\s+build/i // NextBook Tablets
  10448. ],
  10449. [MODEL, [VENDOR, "NextBook"], [TYPE, TABLET]],
  10450. [
  10451. /android.+[;\/]\s*(Xtreme\_)?(V(1[045]|2[015]|30|40|60|7[05]|90))\s+build/i
  10452. ],
  10453. [[VENDOR, "Voice"], MODEL, [TYPE, MOBILE]],
  10454. [
  10455. // Voice Xtreme Phones
  10456. /android.+[;\/]\s*(LVTEL\-)?(V1[12])\s+build/i // LvTel Phones
  10457. ],
  10458. [[VENDOR, "LvTel"], MODEL, [TYPE, MOBILE]],
  10459. [/android.+;\s(PH-1)\s/i],
  10460. [MODEL, [VENDOR, "Essential"], [TYPE, MOBILE]],
  10461. [
  10462. // Essential PH-1
  10463. /android.+[;\/]\s*(V(100MD|700NA|7011|917G).*\b)\s+build/i // Envizen Tablets
  10464. ],
  10465. [MODEL, [VENDOR, "Envizen"], [TYPE, TABLET]],
  10466. [
  10467. /android.+[;\/]\s*(Le[\s\-]+Pan)[\s\-]+(\w{1,9})\s+build/i // Le Pan Tablets
  10468. ],
  10469. [VENDOR, MODEL, [TYPE, TABLET]],
  10470. [
  10471. /android.+[;\/]\s*(Trio[\s\-]*.*)\s+build/i // MachSpeed Tablets
  10472. ],
  10473. [MODEL, [VENDOR, "MachSpeed"], [TYPE, TABLET]],
  10474. [
  10475. /android.+[;\/]\s*(Trinity)[\-\s]*(T\d{3})\s+build/i // Trinity Tablets
  10476. ],
  10477. [VENDOR, MODEL, [TYPE, TABLET]],
  10478. [
  10479. /android.+[;\/]\s*TU_(1491)\s+build/i // Rotor Tablets
  10480. ],
  10481. [MODEL, [VENDOR, "Rotor"], [TYPE, TABLET]],
  10482. [
  10483. /android.+(KS(.+))\s+build/i // Amazon Kindle Tablets
  10484. ],
  10485. [MODEL, [VENDOR, "Amazon"], [TYPE, TABLET]],
  10486. [
  10487. /android.+(Gigaset)[\s\-]+(Q\w{1,9})\s+build/i // Gigaset Tablets
  10488. ],
  10489. [VENDOR, MODEL, [TYPE, TABLET]],
  10490. [
  10491. /\s(tablet|tab)[;\/]/i, // Unidentifiable Tablet
  10492. /\s(mobile)(?:[;\/]|\ssafari)/i // Unidentifiable Mobile
  10493. ],
  10494. [[TYPE, util.lowerize], VENDOR, MODEL],
  10495. [
  10496. /[\s\/\(](smart-?tv)[;\)]/i // SmartTV
  10497. ],
  10498. [[TYPE, SMARTTV]],
  10499. [
  10500. /(android[\w\.\s\-]{0,9});.+build/i // Generic Android Device
  10501. ],
  10502. [MODEL, [VENDOR, "Generic"]]
  10503. ],
  10504. engine: [
  10505. [
  10506. /windows.+\sedge\/([\w\.]+)/i // EdgeHTML
  10507. ],
  10508. [VERSION, [NAME, "EdgeHTML"]],
  10509. [
  10510. /webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i // Blink
  10511. ],
  10512. [VERSION, [NAME, "Blink"]],
  10513. [
  10514. /(presto)\/([\w\.]+)/i, // Presto
  10515. /(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,
  10516. // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m/Goanna
  10517. /(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i, // KHTML/Tasman/Links
  10518. /(icab)[\/\s]([23]\.[\d\.]+)/i // iCab
  10519. ],
  10520. [NAME, VERSION],
  10521. [
  10522. /rv\:([\w\.]{1,9}).+(gecko)/i // Gecko
  10523. ],
  10524. [VERSION, NAME]
  10525. ],
  10526. os: [
  10527. [
  10528. // Windows based
  10529. /microsoft\s(windows)\s(vista|xp)/i // Windows (iTunes)
  10530. ],
  10531. [NAME, VERSION],
  10532. [
  10533. /(windows)\snt\s6\.2;\s(arm)/i, // Windows RT
  10534. /(windows\sphone(?:\sos)*)[\s\/]?([\d\.\s\w]*)/i, // Windows Phone
  10535. /(windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i
  10536. ],
  10537. [NAME, [VERSION, mapper.str, maps.os.windows.version]],
  10538. [/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i],
  10539. [
  10540. [NAME, "Windows"],
  10541. [VERSION, mapper.str, maps.os.windows.version]
  10542. ],
  10543. [
  10544. // Mobile/Embedded OS
  10545. /\((bb)(10);/i // BlackBerry 10
  10546. ],
  10547. [[NAME, "BlackBerry"], VERSION],
  10548. [
  10549. /(blackberry)\w*\/?([\w\.]*)/i, // Blackberry
  10550. /(tizen|kaios)[\/\s]([\w\.]+)/i, // Tizen/KaiOS
  10551. /(android|webos|palm\sos|qnx|bada|rim\stablet\sos|meego|sailfish|contiki)[\/\s-]?([\w\.]*)/i
  10552. // Android/WebOS/Palm/QNX/Bada/RIM/MeeGo/Contiki/Sailfish OS
  10553. ],
  10554. [NAME, VERSION],
  10555. [
  10556. /(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]*)/i // Symbian
  10557. ],
  10558. [[NAME, "Symbian"], VERSION],
  10559. [
  10560. /\((series40);/i // Series 40
  10561. ],
  10562. [NAME],
  10563. [
  10564. /mozilla.+\(mobile;.+gecko.+firefox/i // Firefox OS
  10565. ],
  10566. [[NAME, "Firefox OS"], VERSION],
  10567. [
  10568. // Console
  10569. /(nintendo|playstation)\s([wids34portablevu]+)/i, // Nintendo/Playstation
  10570. // GNU/Linux based
  10571. /(mint)[\/\s\(]?(\w*)/i, // Mint
  10572. /(mageia|vectorlinux)[;\s]/i, // Mageia/VectorLinux
  10573. /(joli|[kxln]?ubuntu|debian|suse|opensuse|gentoo|(?=\s)arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus)[\/\s-]?(?!chrom)([\w\.-]*)/i,
  10574. // Joli/Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware
  10575. // Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk/Linpus
  10576. /(hurd|linux)\s?([\w\.]*)/i, // Hurd/Linux
  10577. /(gnu)\s?([\w\.]*)/i // GNU
  10578. ],
  10579. [NAME, VERSION],
  10580. [
  10581. /(cros)\s[\w]+\s([\w\.]+\w)/i // Chromium OS
  10582. ],
  10583. [[NAME, "Chromium OS"], VERSION],
  10584. [
  10585. // Solaris
  10586. /(sunos)\s?([\w\.\d]*)/i // Solaris
  10587. ],
  10588. [[NAME, "Solaris"], VERSION],
  10589. [
  10590. // BSD based
  10591. /\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]*)/i // FreeBSD/NetBSD/OpenBSD/PC-BSD/DragonFly
  10592. ],
  10593. [NAME, VERSION],
  10594. [
  10595. /(haiku)\s(\w+)/i // Haiku
  10596. ],
  10597. [NAME, VERSION],
  10598. [
  10599. /cfnetwork\/.+darwin/i,
  10600. /ip[honead]{2,4}(?:.*os\s([\w]+)\slike\smac|;\sopera)/i // iOS
  10601. ],
  10602. [
  10603. [VERSION, /_/g, "."],
  10604. [NAME, "iOS"]
  10605. ],
  10606. [
  10607. /(mac\sos\sx)\s?([\w\s\.]*)/i,
  10608. /(macintosh|mac(?=_powerpc)\s)/i // Mac OS
  10609. ],
  10610. [
  10611. [NAME, "Mac OS"],
  10612. [VERSION, /_/g, "."]
  10613. ],
  10614. [
  10615. // Other
  10616. /((?:open)?solaris)[\/\s-]?([\w\.]*)/i, // Solaris
  10617. /(aix)\s((\d)(?=\.|\)|\s)[\w\.])*/i, // AIX
  10618. /(plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos|openvms|fuchsia)/i,
  10619. // Plan9/Minix/BeOS/OS2/AmigaOS/MorphOS/RISCOS/OpenVMS/Fuchsia
  10620. /(unix)\s?([\w\.]*)/i // UNIX
  10621. ],
  10622. [NAME, VERSION]
  10623. ]
  10624. };
  10625. /////////////////
  10626. // Constructor
  10627. ////////////////
  10628. var UAParser = function(uastring, extensions) {
  10629. if (typeof uastring === "object") {
  10630. extensions = uastring;
  10631. uastring = undefined$1;
  10632. }
  10633. if (!(this instanceof UAParser)) {
  10634. return new UAParser(uastring, extensions).getResult();
  10635. }
  10636. var ua =
  10637. uastring ||
  10638. (window && window.navigator && window.navigator.userAgent
  10639. ? window.navigator.userAgent
  10640. : EMPTY);
  10641. var rgxmap = extensions ? util.extend(regexes, extensions) : regexes;
  10642. this.getBrowser = function() {
  10643. var browser = { name: undefined$1, version: undefined$1 };
  10644. mapper.rgx.call(browser, ua, rgxmap.browser);
  10645. browser.major = util.major(browser.version); // deprecated
  10646. return browser;
  10647. };
  10648. this.getCPU = function() {
  10649. var cpu = { architecture: undefined$1 };
  10650. mapper.rgx.call(cpu, ua, rgxmap.cpu);
  10651. return cpu;
  10652. };
  10653. this.getDevice = function() {
  10654. var device = {
  10655. vendor: undefined$1,
  10656. model: undefined$1,
  10657. type: undefined$1
  10658. };
  10659. mapper.rgx.call(device, ua, rgxmap.device);
  10660. return device;
  10661. };
  10662. this.getEngine = function() {
  10663. var engine = { name: undefined$1, version: undefined$1 };
  10664. mapper.rgx.call(engine, ua, rgxmap.engine);
  10665. return engine;
  10666. };
  10667. this.getOS = function() {
  10668. var os = { name: undefined$1, version: undefined$1 };
  10669. mapper.rgx.call(os, ua, rgxmap.os);
  10670. return os;
  10671. };
  10672. this.getResult = function() {
  10673. return {
  10674. ua: this.getUA(),
  10675. browser: this.getBrowser(),
  10676. engine: this.getEngine(),
  10677. os: this.getOS(),
  10678. device: this.getDevice(),
  10679. cpu: this.getCPU()
  10680. };
  10681. };
  10682. this.getUA = function() {
  10683. return ua;
  10684. };
  10685. this.setUA = function(uastring) {
  10686. ua = uastring;
  10687. return this;
  10688. };
  10689. return this;
  10690. };
  10691. UAParser.VERSION = LIBVERSION;
  10692. UAParser.BROWSER = {
  10693. NAME: NAME,
  10694. MAJOR: MAJOR, // deprecated
  10695. VERSION: VERSION
  10696. };
  10697. UAParser.CPU = {
  10698. ARCHITECTURE: ARCHITECTURE
  10699. };
  10700. UAParser.DEVICE = {
  10701. MODEL: MODEL,
  10702. VENDOR: VENDOR,
  10703. TYPE: TYPE,
  10704. CONSOLE: CONSOLE,
  10705. MOBILE: MOBILE,
  10706. SMARTTV: SMARTTV,
  10707. TABLET: TABLET,
  10708. WEARABLE: WEARABLE,
  10709. EMBEDDED: EMBEDDED
  10710. };
  10711. UAParser.ENGINE = {
  10712. NAME: NAME,
  10713. VERSION: VERSION
  10714. };
  10715. UAParser.OS = {
  10716. NAME: NAME,
  10717. VERSION: VERSION
  10718. };
  10719. ///////////
  10720. // Export
  10721. //////////
  10722. // check js environment
  10723. {
  10724. // nodejs env
  10725. if (module.exports) {
  10726. exports = module.exports = UAParser;
  10727. }
  10728. exports.UAParser = UAParser;
  10729. }
  10730. // jQuery/Zepto specific (optional)
  10731. // Note:
  10732. // In AMD env the global scope should be kept clean, but jQuery is an exception.
  10733. // jQuery always exports to global scope, unless jQuery.noConflict(true) is used,
  10734. // and we should catch that.
  10735. var $ = window && (window.jQuery || window.Zepto);
  10736. if ($ && !$.ua) {
  10737. var parser = new UAParser();
  10738. $.ua = parser.getResult();
  10739. $.ua.get = function() {
  10740. return parser.getUA();
  10741. };
  10742. $.ua.set = function(uastring) {
  10743. parser.setUA(uastring);
  10744. var result = parser.getResult();
  10745. for (var prop in result) {
  10746. $.ua[prop] = result[prop];
  10747. }
  10748. };
  10749. }
  10750. })(typeof window === "object" ? window : _commonjsHelpers.commonjsGlobal);
  10751. });
  10752. var uaParser_1 = uaParser.UAParser;
  10753. var UNKNOWN = "Unknown";
  10754. var PLATFORM_MAP = {
  10755. "Mac OS": "Mac OS X"
  10756. };
  10757. /**
  10758. * Convert from UAParser platform name to what we expect.
  10759. */
  10760. function convertPlatformName(name) {
  10761. return PLATFORM_MAP[name] || name;
  10762. }
  10763. /**
  10764. * Get the version number in parts. This is very naive. We actually get major
  10765. * version as a part of UAParser already, which is generally good enough, but
  10766. * let's get the minor just in case.
  10767. */
  10768. function getBrowserVersion(version) {
  10769. if (!version) {
  10770. return {
  10771. major: "",
  10772. minor: ""
  10773. };
  10774. }
  10775. var parts = version.split(".");
  10776. return {
  10777. major: parts[0],
  10778. minor: parts[1]
  10779. };
  10780. }
  10781. /**
  10782. * Get the UA data fom UAParser and then convert it to the format we're
  10783. * expecting for our APIS.
  10784. */
  10785. var parser = new uaParser();
  10786. var results = parser.getResult();
  10787. // Do some conversion first.
  10788. var browserVersionData = getBrowserVersion(results.browser.version);
  10789. var uaData = {
  10790. browserArchitecture: results.cpu.architecture || UNKNOWN,
  10791. browserFullVersion: results.browser.version || UNKNOWN,
  10792. browserMinorVersion: browserVersionData.minor || UNKNOWN,
  10793. browserName: results.browser.name || UNKNOWN,
  10794. browserVersion: results.browser.major || UNKNOWN,
  10795. deviceName: results.device.model || UNKNOWN,
  10796. engineName: results.engine.name || UNKNOWN,
  10797. engineVersion: results.engine.version || UNKNOWN,
  10798. platformArchitecture: results.cpu.architecture || UNKNOWN,
  10799. platformName: convertPlatformName(results.os.name) || UNKNOWN,
  10800. platformVersion: results.os.version || UNKNOWN,
  10801. platformFullVersion: results.os.version || UNKNOWN
  10802. };
  10803. var UserAgentData = uaData;
  10804. var componentRegex = /\./;
  10805. var orRegex = /\|\|/;
  10806. var rangeRegex = /\s+\-\s+/;
  10807. var modifierRegex = /^(<=|<|=|>=|~>|~|>|)?\s*(.+)/;
  10808. var numericRegex = /^(\d*)(.*)/;
  10809. /**
  10810. * Splits input `range` on "||" and returns true if any subrange matches
  10811. * `version`.
  10812. *
  10813. * @param {string} range
  10814. * @param {string} version
  10815. * @returns {boolean}
  10816. */
  10817. function checkOrExpression(range, version) {
  10818. var expressions = range.split(orRegex);
  10819. if (expressions.length > 1) {
  10820. return expressions.some(function(range) {
  10821. return VersionRange.contains(range, version);
  10822. });
  10823. } else {
  10824. range = expressions[0].trim();
  10825. return checkRangeExpression(range, version);
  10826. }
  10827. }
  10828. /**
  10829. * Splits input `range` on " - " (the surrounding whitespace is required) and
  10830. * returns true if version falls between the two operands.
  10831. *
  10832. * @param {string} range
  10833. * @param {string} version
  10834. * @returns {boolean}
  10835. */
  10836. function checkRangeExpression(range, version) {
  10837. var expressions = range.split(rangeRegex);
  10838. !(expressions.length > 0 && expressions.length <= 2)
  10839. ? process.env.NODE_ENV !== "production"
  10840. ? invariant_1(false, 'the "-" operator expects exactly 2 operands')
  10841. : invariant_1(false)
  10842. : void 0;
  10843. if (expressions.length === 1) {
  10844. return checkSimpleExpression(expressions[0], version);
  10845. } else {
  10846. var startVersion = expressions[0],
  10847. endVersion = expressions[1];
  10848. !(isSimpleVersion(startVersion) && isSimpleVersion(endVersion))
  10849. ? process.env.NODE_ENV !== "production"
  10850. ? invariant_1(
  10851. false,
  10852. 'operands to the "-" operator must be simple (no modifiers)'
  10853. )
  10854. : invariant_1(false)
  10855. : void 0;
  10856. return (
  10857. checkSimpleExpression(">=" + startVersion, version) &&
  10858. checkSimpleExpression("<=" + endVersion, version)
  10859. );
  10860. }
  10861. }
  10862. /**
  10863. * Checks if `range` matches `version`. `range` should be a "simple" range (ie.
  10864. * not a compound range using the " - " or "||" operators).
  10865. *
  10866. * @param {string} range
  10867. * @param {string} version
  10868. * @returns {boolean}
  10869. */
  10870. function checkSimpleExpression(range, version) {
  10871. range = range.trim();
  10872. if (range === "") {
  10873. return true;
  10874. }
  10875. var versionComponents = version.split(componentRegex);
  10876. var _getModifierAndCompon = getModifierAndComponents(range),
  10877. modifier = _getModifierAndCompon.modifier,
  10878. rangeComponents = _getModifierAndCompon.rangeComponents;
  10879. switch (modifier) {
  10880. case "<":
  10881. return checkLessThan(versionComponents, rangeComponents);
  10882. case "<=":
  10883. return checkLessThanOrEqual(versionComponents, rangeComponents);
  10884. case ">=":
  10885. return checkGreaterThanOrEqual(versionComponents, rangeComponents);
  10886. case ">":
  10887. return checkGreaterThan(versionComponents, rangeComponents);
  10888. case "~":
  10889. case "~>":
  10890. return checkApproximateVersion(versionComponents, rangeComponents);
  10891. default:
  10892. return checkEqual(versionComponents, rangeComponents);
  10893. }
  10894. }
  10895. /**
  10896. * Checks whether `a` is less than `b`.
  10897. *
  10898. * @param {array<string>} a
  10899. * @param {array<string>} b
  10900. * @returns {boolean}
  10901. */
  10902. function checkLessThan(a, b) {
  10903. return compareComponents(a, b) === -1;
  10904. }
  10905. /**
  10906. * Checks whether `a` is less than or equal to `b`.
  10907. *
  10908. * @param {array<string>} a
  10909. * @param {array<string>} b
  10910. * @returns {boolean}
  10911. */
  10912. function checkLessThanOrEqual(a, b) {
  10913. var result = compareComponents(a, b);
  10914. return result === -1 || result === 0;
  10915. }
  10916. /**
  10917. * Checks whether `a` is equal to `b`.
  10918. *
  10919. * @param {array<string>} a
  10920. * @param {array<string>} b
  10921. * @returns {boolean}
  10922. */
  10923. function checkEqual(a, b) {
  10924. return compareComponents(a, b) === 0;
  10925. }
  10926. /**
  10927. * Checks whether `a` is greater than or equal to `b`.
  10928. *
  10929. * @param {array<string>} a
  10930. * @param {array<string>} b
  10931. * @returns {boolean}
  10932. */
  10933. function checkGreaterThanOrEqual(a, b) {
  10934. var result = compareComponents(a, b);
  10935. return result === 1 || result === 0;
  10936. }
  10937. /**
  10938. * Checks whether `a` is greater than `b`.
  10939. *
  10940. * @param {array<string>} a
  10941. * @param {array<string>} b
  10942. * @returns {boolean}
  10943. */
  10944. function checkGreaterThan(a, b) {
  10945. return compareComponents(a, b) === 1;
  10946. }
  10947. /**
  10948. * Checks whether `a` is "reasonably close" to `b` (as described in
  10949. * https://www.npmjs.org/doc/misc/semver.html). For example, if `b` is "1.3.1"
  10950. * then "reasonably close" is defined as ">= 1.3.1 and < 1.4".
  10951. *
  10952. * @param {array<string>} a
  10953. * @param {array<string>} b
  10954. * @returns {boolean}
  10955. */
  10956. function checkApproximateVersion(a, b) {
  10957. var lowerBound = b.slice();
  10958. var upperBound = b.slice();
  10959. if (upperBound.length > 1) {
  10960. upperBound.pop();
  10961. }
  10962. var lastIndex = upperBound.length - 1;
  10963. var numeric = parseInt(upperBound[lastIndex], 10);
  10964. if (isNumber(numeric)) {
  10965. upperBound[lastIndex] = numeric + 1 + "";
  10966. }
  10967. return checkGreaterThanOrEqual(a, lowerBound) && checkLessThan(a, upperBound);
  10968. }
  10969. /**
  10970. * Extracts the optional modifier (<, <=, =, >=, >, ~, ~>) and version
  10971. * components from `range`.
  10972. *
  10973. * For example, given `range` ">= 1.2.3" returns an object with a `modifier` of
  10974. * `">="` and `components` of `[1, 2, 3]`.
  10975. *
  10976. * @param {string} range
  10977. * @returns {object}
  10978. */
  10979. function getModifierAndComponents(range) {
  10980. var rangeComponents = range.split(componentRegex);
  10981. var matches = rangeComponents[0].match(modifierRegex);
  10982. !matches
  10983. ? process.env.NODE_ENV !== "production"
  10984. ? invariant_1(false, "expected regex to match but it did not")
  10985. : invariant_1(false)
  10986. : void 0;
  10987. return {
  10988. modifier: matches[1],
  10989. rangeComponents: [matches[2]].concat(rangeComponents.slice(1))
  10990. };
  10991. }
  10992. /**
  10993. * Determines if `number` is a number.
  10994. *
  10995. * @param {mixed} number
  10996. * @returns {boolean}
  10997. */
  10998. function isNumber(number) {
  10999. return !isNaN(number) && isFinite(number);
  11000. }
  11001. /**
  11002. * Tests whether `range` is a "simple" version number without any modifiers
  11003. * (">", "~" etc).
  11004. *
  11005. * @param {string} range
  11006. * @returns {boolean}
  11007. */
  11008. function isSimpleVersion(range) {
  11009. return !getModifierAndComponents(range).modifier;
  11010. }
  11011. /**
  11012. * Zero-pads array `array` until it is at least `length` long.
  11013. *
  11014. * @param {array} array
  11015. * @param {number} length
  11016. */
  11017. function zeroPad(array, length) {
  11018. for (var i = array.length; i < length; i++) {
  11019. array[i] = "0";
  11020. }
  11021. }
  11022. /**
  11023. * Normalizes `a` and `b` in preparation for comparison by doing the following:
  11024. *
  11025. * - zero-pads `a` and `b`
  11026. * - marks any "x", "X" or "*" component in `b` as equivalent by zero-ing it out
  11027. * in both `a` and `b`
  11028. * - marks any final "*" component in `b` as a greedy wildcard by zero-ing it
  11029. * and all of its successors in `a`
  11030. *
  11031. * @param {array<string>} a
  11032. * @param {array<string>} b
  11033. * @returns {array<array<string>>}
  11034. */
  11035. function normalizeVersions(a, b) {
  11036. a = a.slice();
  11037. b = b.slice();
  11038. zeroPad(a, b.length);
  11039. // mark "x" and "*" components as equal
  11040. for (var i = 0; i < b.length; i++) {
  11041. var matches = b[i].match(/^[x*]$/i);
  11042. if (matches) {
  11043. b[i] = a[i] = "0";
  11044. // final "*" greedily zeros all remaining components
  11045. if (matches[0] === "*" && i === b.length - 1) {
  11046. for (var j = i; j < a.length; j++) {
  11047. a[j] = "0";
  11048. }
  11049. }
  11050. }
  11051. }
  11052. zeroPad(b, a.length);
  11053. return [a, b];
  11054. }
  11055. /**
  11056. * Returns the numerical -- not the lexicographical -- ordering of `a` and `b`.
  11057. *
  11058. * For example, `10-alpha` is greater than `2-beta`.
  11059. *
  11060. * @param {string} a
  11061. * @param {string} b
  11062. * @returns {number} -1, 0 or 1 to indicate whether `a` is less than, equal to,
  11063. * or greater than `b`, respectively
  11064. */
  11065. function compareNumeric(a, b) {
  11066. var aPrefix = a.match(numericRegex)[1];
  11067. var bPrefix = b.match(numericRegex)[1];
  11068. var aNumeric = parseInt(aPrefix, 10);
  11069. var bNumeric = parseInt(bPrefix, 10);
  11070. if (isNumber(aNumeric) && isNumber(bNumeric) && aNumeric !== bNumeric) {
  11071. return compare(aNumeric, bNumeric);
  11072. } else {
  11073. return compare(a, b);
  11074. }
  11075. }
  11076. /**
  11077. * Returns the ordering of `a` and `b`.
  11078. *
  11079. * @param {string|number} a
  11080. * @param {string|number} b
  11081. * @returns {number} -1, 0 or 1 to indicate whether `a` is less than, equal to,
  11082. * or greater than `b`, respectively
  11083. */
  11084. function compare(a, b) {
  11085. !(typeof a === typeof b)
  11086. ? process.env.NODE_ENV !== "production"
  11087. ? invariant_1(false, '"a" and "b" must be of the same type')
  11088. : invariant_1(false)
  11089. : void 0;
  11090. if (a > b) {
  11091. return 1;
  11092. } else if (a < b) {
  11093. return -1;
  11094. } else {
  11095. return 0;
  11096. }
  11097. }
  11098. /**
  11099. * Compares arrays of version components.
  11100. *
  11101. * @param {array<string>} a
  11102. * @param {array<string>} b
  11103. * @returns {number} -1, 0 or 1 to indicate whether `a` is less than, equal to,
  11104. * or greater than `b`, respectively
  11105. */
  11106. function compareComponents(a, b) {
  11107. var _normalizeVersions = normalizeVersions(a, b),
  11108. aNormalized = _normalizeVersions[0],
  11109. bNormalized = _normalizeVersions[1];
  11110. for (var i = 0; i < bNormalized.length; i++) {
  11111. var result = compareNumeric(aNormalized[i], bNormalized[i]);
  11112. if (result) {
  11113. return result;
  11114. }
  11115. }
  11116. return 0;
  11117. }
  11118. var VersionRange = {
  11119. /**
  11120. * Checks whether `version` satisfies the `range` specification.
  11121. *
  11122. * We support a subset of the expressions defined in
  11123. * https://www.npmjs.org/doc/misc/semver.html:
  11124. *
  11125. * version Must match version exactly
  11126. * =version Same as just version
  11127. * >version Must be greater than version
  11128. * >=version Must be greater than or equal to version
  11129. * <version Must be less than version
  11130. * <=version Must be less than or equal to version
  11131. * ~version Must be at least version, but less than the next significant
  11132. * revision above version:
  11133. * "~1.2.3" is equivalent to ">= 1.2.3 and < 1.3"
  11134. * ~>version Equivalent to ~version
  11135. * 1.2.x Must match "1.2.x", where "x" is a wildcard that matches
  11136. * anything
  11137. * 1.2.* Similar to "1.2.x", but "*" in the trailing position is a
  11138. * "greedy" wildcard, so will match any number of additional
  11139. * components:
  11140. * "1.2.*" will match "1.2.1", "1.2.1.1", "1.2.1.1.1" etc
  11141. * * Any version
  11142. * "" (Empty string) Same as *
  11143. * v1 - v2 Equivalent to ">= v1 and <= v2"
  11144. * r1 || r2 Passes if either r1 or r2 are satisfied
  11145. *
  11146. * @param {string} range
  11147. * @param {string} version
  11148. * @returns {boolean}
  11149. */
  11150. contains: function contains(range, version) {
  11151. return checkOrExpression(range.trim(), version.trim());
  11152. }
  11153. };
  11154. var VersionRange_1 = VersionRange;
  11155. /**
  11156. * Copyright (c) 2013-present, Facebook, Inc.
  11157. *
  11158. * This source code is licensed under the MIT license found in the
  11159. * LICENSE file in the root directory of this source tree.
  11160. *
  11161. */
  11162. var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  11163. /**
  11164. * Executes the provided `callback` once for each enumerable own property in the
  11165. * object and constructs a new object from the results. The `callback` is
  11166. * invoked with three arguments:
  11167. *
  11168. * - the property value
  11169. * - the property name
  11170. * - the object being traversed
  11171. *
  11172. * Properties that are added after the call to `mapObject` will not be visited
  11173. * by `callback`. If the values of existing properties are changed, the value
  11174. * passed to `callback` will be the value at the time `mapObject` visits them.
  11175. * Properties that are deleted before being visited are not visited.
  11176. *
  11177. * @grep function objectMap()
  11178. * @grep function objMap()
  11179. *
  11180. * @param {?object} object
  11181. * @param {function} callback
  11182. * @param {*} context
  11183. * @return {?object}
  11184. */
  11185. function mapObject(object, callback, context) {
  11186. if (!object) {
  11187. return null;
  11188. }
  11189. var result = {};
  11190. for (var name in object) {
  11191. if (hasOwnProperty$1.call(object, name)) {
  11192. result[name] = callback.call(context, object[name], name, object);
  11193. }
  11194. }
  11195. return result;
  11196. }
  11197. var mapObject_1 = mapObject;
  11198. /**
  11199. * Copyright (c) 2013-present, Facebook, Inc.
  11200. *
  11201. * This source code is licensed under the MIT license found in the
  11202. * LICENSE file in the root directory of this source tree.
  11203. *
  11204. *
  11205. * @typechecks static-only
  11206. */
  11207. /**
  11208. * Memoizes the return value of a function that accepts one string argument.
  11209. */
  11210. function memoizeStringOnly(callback) {
  11211. var cache = {};
  11212. return function(string) {
  11213. if (!cache.hasOwnProperty(string)) {
  11214. cache[string] = callback.call(this, string);
  11215. }
  11216. return cache[string];
  11217. };
  11218. }
  11219. var memoizeStringOnly_1 = memoizeStringOnly;
  11220. /**
  11221. * Checks to see whether `name` and `version` satisfy `query`.
  11222. *
  11223. * @param {string} name Name of the browser, device, engine or platform
  11224. * @param {?string} version Version of the browser, engine or platform
  11225. * @param {string} query Query of form "Name [range expression]"
  11226. * @param {?function} normalizer Optional pre-processor for range expression
  11227. * @return {boolean}
  11228. */
  11229. function compare$1(name, version, query, normalizer) {
  11230. // check for exact match with no version
  11231. if (name === query) {
  11232. return true;
  11233. }
  11234. // check for non-matching names
  11235. if (!query.startsWith(name)) {
  11236. return false;
  11237. }
  11238. // full comparison with version
  11239. var range = query.slice(name.length);
  11240. if (version) {
  11241. range = normalizer ? normalizer(range) : range;
  11242. return VersionRange_1.contains(range, version);
  11243. }
  11244. return false;
  11245. }
  11246. /**
  11247. * Normalizes `version` by stripping any "NT" prefix, but only on the Windows
  11248. * platform.
  11249. *
  11250. * Mimics the stripping performed by the `UserAgentWindowsPlatform` PHP class.
  11251. *
  11252. * @param {string} version
  11253. * @return {string}
  11254. */
  11255. function normalizePlatformVersion(version) {
  11256. if (UserAgentData.platformName === "Windows") {
  11257. return version.replace(/^\s*NT/, "");
  11258. }
  11259. return version;
  11260. }
  11261. /**
  11262. * Provides client-side access to the authoritative PHP-generated User Agent
  11263. * information supplied by the server.
  11264. */
  11265. var UserAgent = {
  11266. /**
  11267. * Check if the User Agent browser matches `query`.
  11268. *
  11269. * `query` should be a string like "Chrome" or "Chrome > 33".
  11270. *
  11271. * Valid browser names include:
  11272. *
  11273. * - ACCESS NetFront
  11274. * - AOL
  11275. * - Amazon Silk
  11276. * - Android
  11277. * - BlackBerry
  11278. * - BlackBerry PlayBook
  11279. * - Chrome
  11280. * - Chrome for iOS
  11281. * - Chrome frame
  11282. * - Facebook PHP SDK
  11283. * - Facebook for iOS
  11284. * - Firefox
  11285. * - IE
  11286. * - IE Mobile
  11287. * - Mobile Safari
  11288. * - Motorola Internet Browser
  11289. * - Nokia
  11290. * - Openwave Mobile Browser
  11291. * - Opera
  11292. * - Opera Mini
  11293. * - Opera Mobile
  11294. * - Safari
  11295. * - UIWebView
  11296. * - Unknown
  11297. * - webOS
  11298. * - etc...
  11299. *
  11300. * An authoritative list can be found in the PHP `BrowserDetector` class and
  11301. * related classes in the same file (see calls to `new UserAgentBrowser` here:
  11302. * https://fburl.com/50728104).
  11303. *
  11304. * @note Function results are memoized
  11305. *
  11306. * @param {string} query Query of the form "Name [range expression]"
  11307. * @return {boolean}
  11308. */
  11309. isBrowser: function isBrowser(query) {
  11310. return compare$1(
  11311. UserAgentData.browserName,
  11312. UserAgentData.browserFullVersion,
  11313. query
  11314. );
  11315. },
  11316. /**
  11317. * Check if the User Agent browser uses a 32 or 64 bit architecture.
  11318. *
  11319. * @note Function results are memoized
  11320. *
  11321. * @param {string} query Query of the form "32" or "64".
  11322. * @return {boolean}
  11323. */
  11324. isBrowserArchitecture: function isBrowserArchitecture(query) {
  11325. return compare$1(UserAgentData.browserArchitecture, null, query);
  11326. },
  11327. /**
  11328. * Check if the User Agent device matches `query`.
  11329. *
  11330. * `query` should be a string like "iPhone" or "iPad".
  11331. *
  11332. * Valid device names include:
  11333. *
  11334. * - Kindle
  11335. * - Kindle Fire
  11336. * - Unknown
  11337. * - iPad
  11338. * - iPhone
  11339. * - iPod
  11340. * - etc...
  11341. *
  11342. * An authoritative list can be found in the PHP `DeviceDetector` class and
  11343. * related classes in the same file (see calls to `new UserAgentDevice` here:
  11344. * https://fburl.com/50728332).
  11345. *
  11346. * @note Function results are memoized
  11347. *
  11348. * @param {string} query Query of the form "Name"
  11349. * @return {boolean}
  11350. */
  11351. isDevice: function isDevice(query) {
  11352. return compare$1(UserAgentData.deviceName, null, query);
  11353. },
  11354. /**
  11355. * Check if the User Agent rendering engine matches `query`.
  11356. *
  11357. * `query` should be a string like "WebKit" or "WebKit >= 537".
  11358. *
  11359. * Valid engine names include:
  11360. *
  11361. * - Gecko
  11362. * - Presto
  11363. * - Trident
  11364. * - WebKit
  11365. * - etc...
  11366. *
  11367. * An authoritative list can be found in the PHP `RenderingEngineDetector`
  11368. * class related classes in the same file (see calls to `new
  11369. * UserAgentRenderingEngine` here: https://fburl.com/50728617).
  11370. *
  11371. * @note Function results are memoized
  11372. *
  11373. * @param {string} query Query of the form "Name [range expression]"
  11374. * @return {boolean}
  11375. */
  11376. isEngine: function isEngine(query) {
  11377. return compare$1(
  11378. UserAgentData.engineName,
  11379. UserAgentData.engineVersion,
  11380. query
  11381. );
  11382. },
  11383. /**
  11384. * Check if the User Agent platform matches `query`.
  11385. *
  11386. * `query` should be a string like "Windows" or "iOS 5 - 6".
  11387. *
  11388. * Valid platform names include:
  11389. *
  11390. * - Android
  11391. * - BlackBerry OS
  11392. * - Java ME
  11393. * - Linux
  11394. * - Mac OS X
  11395. * - Mac OS X Calendar
  11396. * - Mac OS X Internet Account
  11397. * - Symbian
  11398. * - SymbianOS
  11399. * - Windows
  11400. * - Windows Mobile
  11401. * - Windows Phone
  11402. * - iOS
  11403. * - iOS Facebook Integration Account
  11404. * - iOS Facebook Social Sharing UI
  11405. * - webOS
  11406. * - Chrome OS
  11407. * - etc...
  11408. *
  11409. * An authoritative list can be found in the PHP `PlatformDetector` class and
  11410. * related classes in the same file (see calls to `new UserAgentPlatform`
  11411. * here: https://fburl.com/50729226).
  11412. *
  11413. * @note Function results are memoized
  11414. *
  11415. * @param {string} query Query of the form "Name [range expression]"
  11416. * @return {boolean}
  11417. */
  11418. isPlatform: function isPlatform(query) {
  11419. return compare$1(
  11420. UserAgentData.platformName,
  11421. UserAgentData.platformFullVersion,
  11422. query,
  11423. normalizePlatformVersion
  11424. );
  11425. },
  11426. /**
  11427. * Check if the User Agent platform is a 32 or 64 bit architecture.
  11428. *
  11429. * @note Function results are memoized
  11430. *
  11431. * @param {string} query Query of the form "32" or "64".
  11432. * @return {boolean}
  11433. */
  11434. isPlatformArchitecture: function isPlatformArchitecture(query) {
  11435. return compare$1(UserAgentData.platformArchitecture, null, query);
  11436. }
  11437. };
  11438. var UserAgent_1 = mapObject_1(UserAgent, memoizeStringOnly_1);
  11439. function _classCallCheck$9(instance, Constructor) {
  11440. if (!(instance instanceof Constructor)) {
  11441. throw new TypeError("Cannot call a class as a function");
  11442. }
  11443. }
  11444. function _possibleConstructorReturn$6(self, call) {
  11445. if (!self) {
  11446. throw new ReferenceError(
  11447. "this hasn't been initialised - super() hasn't been called"
  11448. );
  11449. }
  11450. return call && (typeof call === "object" || typeof call === "function")
  11451. ? call
  11452. : self;
  11453. }
  11454. function _inherits$6(subClass, superClass) {
  11455. if (typeof superClass !== "function" && superClass !== null) {
  11456. throw new TypeError(
  11457. "Super expression must either be null or a function, not " +
  11458. typeof superClass
  11459. );
  11460. }
  11461. subClass.prototype = Object.create(superClass && superClass.prototype, {
  11462. constructor: {
  11463. value: subClass,
  11464. enumerable: false,
  11465. writable: true,
  11466. configurable: true
  11467. }
  11468. });
  11469. if (superClass)
  11470. Object.setPrototypeOf
  11471. ? Object.setPrototypeOf(subClass, superClass)
  11472. : (subClass.__proto__ = superClass);
  11473. }
  11474. // In IE, spans with <br> tags render as two newlines. By rendering a span
  11475. // with only a newline character, we can be sure to render a single line.
  11476. var useNewlineChar = UserAgent_1.isBrowser("IE <= 11");
  11477. /**
  11478. * Check whether the node should be considered a newline.
  11479. */
  11480. function isNewline(node) {
  11481. return useNewlineChar ? node.textContent === "\n" : node.tagName === "BR";
  11482. }
  11483. /**
  11484. * Placeholder elements for empty text content.
  11485. *
  11486. * What is this `data-text` attribute, anyway? It turns out that we need to
  11487. * put an attribute on the lowest-level text node in order to preserve correct
  11488. * spellcheck handling. If the <span> is naked, Chrome and Safari may do
  11489. * bizarre things to do the DOM -- split text nodes, create extra spans, etc.
  11490. * If the <span> has an attribute, this appears not to happen.
  11491. * See http://jsfiddle.net/9khdavod/ for the failure case, and
  11492. * http://jsfiddle.net/7pg143f7/ for the fixed case.
  11493. */
  11494. var NEWLINE_A = useNewlineChar
  11495. ? React__default.createElement(
  11496. "span",
  11497. { key: "A", "data-text": "true" },
  11498. "\n"
  11499. )
  11500. : React__default.createElement("br", { key: "A", "data-text": "true" });
  11501. var NEWLINE_B = useNewlineChar
  11502. ? React__default.createElement(
  11503. "span",
  11504. { key: "B", "data-text": "true" },
  11505. "\n"
  11506. )
  11507. : React__default.createElement("br", { key: "B", "data-text": "true" });
  11508. /**
  11509. * The lowest-level component in a `DraftEditor`, the text node component
  11510. * replaces the default React text node implementation. This allows us to
  11511. * perform custom handling of newline behavior and avoid re-rendering text
  11512. * nodes with DOM state that already matches the expectations of our immutable
  11513. * editor state.
  11514. */
  11515. var DraftEditorTextNode = (function(_React$Component) {
  11516. _inherits$6(DraftEditorTextNode, _React$Component);
  11517. function DraftEditorTextNode(props) {
  11518. _classCallCheck$9(this, DraftEditorTextNode);
  11519. // By flipping this flag, we also keep flipping keys which forces
  11520. // React to remount this node every time it rerenders.
  11521. var _this = _possibleConstructorReturn$6(
  11522. this,
  11523. _React$Component.call(this, props)
  11524. );
  11525. _this._forceFlag = false;
  11526. return _this;
  11527. }
  11528. DraftEditorTextNode.prototype.shouldComponentUpdate = function shouldComponentUpdate(
  11529. nextProps
  11530. ) {
  11531. var node = reactDom__default.findDOMNode(this);
  11532. var shouldBeNewline = nextProps.children === "";
  11533. !(node instanceof Element)
  11534. ? process.env.NODE_ENV !== "production"
  11535. ? invariant_1(false, "node is not an Element")
  11536. : invariant_1(false)
  11537. : void 0;
  11538. if (shouldBeNewline) {
  11539. return !isNewline(node);
  11540. }
  11541. return node.textContent !== nextProps.children;
  11542. };
  11543. DraftEditorTextNode.prototype.componentDidMount = function componentDidMount() {
  11544. this._forceFlag = !this._forceFlag;
  11545. };
  11546. DraftEditorTextNode.prototype.componentDidUpdate = function componentDidUpdate() {
  11547. this._forceFlag = !this._forceFlag;
  11548. };
  11549. DraftEditorTextNode.prototype.render = function render() {
  11550. if (this.props.children === "") {
  11551. return this._forceFlag ? NEWLINE_A : NEWLINE_B;
  11552. }
  11553. return React__default.createElement(
  11554. "span",
  11555. { key: this._forceFlag ? "A" : "B", "data-text": "true" },
  11556. this.props.children
  11557. );
  11558. };
  11559. return DraftEditorTextNode;
  11560. })(React__default.Component);
  11561. var DraftEditorTextNode_react = DraftEditorTextNode;
  11562. /**
  11563. * Copyright (c) 2013-present, Facebook, Inc.
  11564. * All rights reserved.
  11565. *
  11566. * This source code is licensed under the BSD-style license found in the
  11567. * LICENSE file in the root directory of this source tree. An additional grant
  11568. * of patent rights can be found in the PATENTS file in the same directory.
  11569. *
  11570. * @providesModule DraftJsDebugLogging
  11571. */
  11572. var DraftJsDebugLogging = {
  11573. logSelectionStateFailure: function logSelectionStateFailure() {
  11574. return null;
  11575. }
  11576. };
  11577. /**
  11578. * Copyright (c) 2013-present, Facebook, Inc.
  11579. *
  11580. * This source code is licensed under the MIT license found in the
  11581. * LICENSE file in the root directory of this source tree.
  11582. *
  11583. * @typechecks
  11584. */
  11585. /**
  11586. * @param {*} object The object to check.
  11587. * @return {boolean} Whether or not the object is a DOM node.
  11588. */
  11589. function isNode(object) {
  11590. var doc = object ? object.ownerDocument || object : document;
  11591. var defaultView = doc.defaultView || window;
  11592. return !!(
  11593. object &&
  11594. (typeof defaultView.Node === "function"
  11595. ? object instanceof defaultView.Node
  11596. : typeof object === "object" &&
  11597. typeof object.nodeType === "number" &&
  11598. typeof object.nodeName === "string")
  11599. );
  11600. }
  11601. var isNode_1 = isNode;
  11602. /**
  11603. * Copyright (c) 2013-present, Facebook, Inc.
  11604. *
  11605. * This source code is licensed under the MIT license found in the
  11606. * LICENSE file in the root directory of this source tree.
  11607. *
  11608. * @typechecks
  11609. */
  11610. /**
  11611. * @param {*} object The object to check.
  11612. * @return {boolean} Whether or not the object is a DOM text node.
  11613. */
  11614. function isTextNode(object) {
  11615. return isNode_1(object) && object.nodeType == 3;
  11616. }
  11617. var isTextNode_1 = isTextNode;
  11618. /**
  11619. * Copyright (c) 2013-present, Facebook, Inc.
  11620. *
  11621. * This source code is licensed under the MIT license found in the
  11622. * LICENSE file in the root directory of this source tree.
  11623. *
  11624. *
  11625. */
  11626. /*eslint-disable no-bitwise */
  11627. /**
  11628. * Checks if a given DOM node contains or is another DOM node.
  11629. */
  11630. function containsNode(outerNode, innerNode) {
  11631. if (!outerNode || !innerNode) {
  11632. return false;
  11633. } else if (outerNode === innerNode) {
  11634. return true;
  11635. } else if (isTextNode_1(outerNode)) {
  11636. return false;
  11637. } else if (isTextNode_1(innerNode)) {
  11638. return containsNode(outerNode, innerNode.parentNode);
  11639. } else if ("contains" in outerNode) {
  11640. return outerNode.contains(innerNode);
  11641. } else if (outerNode.compareDocumentPosition) {
  11642. return !!(outerNode.compareDocumentPosition(innerNode) & 16);
  11643. } else {
  11644. return false;
  11645. }
  11646. }
  11647. var containsNode_1 = containsNode;
  11648. /**
  11649. * Copyright (c) 2013-present, Facebook, Inc.
  11650. *
  11651. * This source code is licensed under the MIT license found in the
  11652. * LICENSE file in the root directory of this source tree.
  11653. *
  11654. * @typechecks
  11655. */
  11656. /* eslint-disable fb-www/typeof-undefined */
  11657. /**
  11658. * Same as document.activeElement but wraps in a try-catch block. In IE it is
  11659. * not safe to call document.activeElement if there is nothing focused.
  11660. *
  11661. * The activeElement will be null only if the document or document body is not
  11662. * yet defined.
  11663. *
  11664. * @param {?DOMDocument} doc Defaults to current document.
  11665. * @return {?DOMElement}
  11666. */
  11667. function getActiveElement(doc) /*?DOMElement*/ {
  11668. doc = doc || (typeof document !== "undefined" ? document : undefined);
  11669. if (typeof doc === "undefined") {
  11670. return null;
  11671. }
  11672. try {
  11673. return doc.activeElement || doc.body;
  11674. } catch (e) {
  11675. return doc.body;
  11676. }
  11677. }
  11678. var getActiveElement_1 = getActiveElement;
  11679. function getAnonymizedDOM(node, getNodeLabels) {
  11680. if (!node) {
  11681. return "[empty]";
  11682. }
  11683. var anonymized = anonymizeTextWithin(node, getNodeLabels);
  11684. if (anonymized.nodeType === Node.TEXT_NODE) {
  11685. return anonymized.textContent;
  11686. }
  11687. !(anonymized instanceof Element)
  11688. ? process.env.NODE_ENV !== "production"
  11689. ? invariant_1(false, "Node must be an Element if it is not a text node.")
  11690. : invariant_1(false)
  11691. : void 0;
  11692. return anonymized.outerHTML;
  11693. }
  11694. function anonymizeTextWithin(node, getNodeLabels) {
  11695. var labels = getNodeLabels !== undefined ? getNodeLabels(node) : [];
  11696. if (node.nodeType === Node.TEXT_NODE) {
  11697. var length = node.textContent.length;
  11698. return document.createTextNode(
  11699. "[text " + length + (labels.length ? " | " + labels.join(", ") : "") + "]"
  11700. );
  11701. }
  11702. var clone = node.cloneNode();
  11703. if (clone.nodeType === 1 && labels.length) {
  11704. clone.setAttribute("data-labels", labels.join(", "));
  11705. }
  11706. var childNodes = node.childNodes;
  11707. for (var ii = 0; ii < childNodes.length; ii++) {
  11708. clone.appendChild(anonymizeTextWithin(childNodes[ii], getNodeLabels));
  11709. }
  11710. return clone;
  11711. }
  11712. function getAnonymizedEditorDOM(node, getNodeLabels) {
  11713. // grabbing the DOM content of the Draft editor
  11714. var currentNode = node;
  11715. while (currentNode) {
  11716. if (
  11717. currentNode instanceof Element &&
  11718. currentNode.hasAttribute("contenteditable")
  11719. ) {
  11720. // found the Draft editor container
  11721. return getAnonymizedDOM(currentNode, getNodeLabels);
  11722. } else {
  11723. currentNode = currentNode.parentNode;
  11724. }
  11725. }
  11726. return "Could not find contentEditable parent of node";
  11727. }
  11728. function getNodeLength(node) {
  11729. return node.nodeValue === null
  11730. ? node.childNodes.length
  11731. : node.nodeValue.length;
  11732. }
  11733. /**
  11734. * In modern non-IE browsers, we can support both forward and backward
  11735. * selections.
  11736. *
  11737. * Note: IE10+ supports the Selection object, but it does not support
  11738. * the `extend` method, which means that even in modern IE, it's not possible
  11739. * to programatically create a backward selection. Thus, for all IE
  11740. * versions, we use the old IE API to create our selections.
  11741. */
  11742. function setDraftEditorSelection(
  11743. selectionState,
  11744. node,
  11745. blockKey,
  11746. nodeStart,
  11747. nodeEnd
  11748. ) {
  11749. // It's possible that the editor has been removed from the DOM but
  11750. // our selection code doesn't know it yet. Forcing selection in
  11751. // this case may lead to errors, so just bail now.
  11752. if (!containsNode_1(document.documentElement, node)) {
  11753. return;
  11754. }
  11755. var selection = _commonjsHelpers.commonjsGlobal.getSelection();
  11756. var anchorKey = selectionState.getAnchorKey();
  11757. var anchorOffset = selectionState.getAnchorOffset();
  11758. var focusKey = selectionState.getFocusKey();
  11759. var focusOffset = selectionState.getFocusOffset();
  11760. var isBackward = selectionState.getIsBackward();
  11761. // IE doesn't support backward selection. Swap key/offset pairs.
  11762. if (!selection.extend && isBackward) {
  11763. var tempKey = anchorKey;
  11764. var tempOffset = anchorOffset;
  11765. anchorKey = focusKey;
  11766. anchorOffset = focusOffset;
  11767. focusKey = tempKey;
  11768. focusOffset = tempOffset;
  11769. isBackward = false;
  11770. }
  11771. var hasAnchor =
  11772. anchorKey === blockKey &&
  11773. nodeStart <= anchorOffset &&
  11774. nodeEnd >= anchorOffset;
  11775. var hasFocus =
  11776. focusKey === blockKey && nodeStart <= focusOffset && nodeEnd >= focusOffset;
  11777. // If the selection is entirely bound within this node, set the selection
  11778. // and be done.
  11779. if (hasAnchor && hasFocus) {
  11780. selection.removeAllRanges();
  11781. addPointToSelection(
  11782. selection,
  11783. node,
  11784. anchorOffset - nodeStart,
  11785. selectionState
  11786. );
  11787. addFocusToSelection(
  11788. selection,
  11789. node,
  11790. focusOffset - nodeStart,
  11791. selectionState
  11792. );
  11793. return;
  11794. }
  11795. if (!isBackward) {
  11796. // If the anchor is within this node, set the range start.
  11797. if (hasAnchor) {
  11798. selection.removeAllRanges();
  11799. addPointToSelection(
  11800. selection,
  11801. node,
  11802. anchorOffset - nodeStart,
  11803. selectionState
  11804. );
  11805. }
  11806. // If the focus is within this node, we can assume that we have
  11807. // already set the appropriate start range on the selection, and
  11808. // can simply extend the selection.
  11809. if (hasFocus) {
  11810. addFocusToSelection(
  11811. selection,
  11812. node,
  11813. focusOffset - nodeStart,
  11814. selectionState
  11815. );
  11816. }
  11817. } else {
  11818. // If this node has the focus, set the selection range to be a
  11819. // collapsed range beginning here. Later, when we encounter the anchor,
  11820. // we'll use this information to extend the selection.
  11821. if (hasFocus) {
  11822. selection.removeAllRanges();
  11823. addPointToSelection(
  11824. selection,
  11825. node,
  11826. focusOffset - nodeStart,
  11827. selectionState
  11828. );
  11829. }
  11830. // If this node has the anchor, we may assume that the correct
  11831. // focus information is already stored on the selection object.
  11832. // We keep track of it, reset the selection range, and extend it
  11833. // back to the focus point.
  11834. if (hasAnchor) {
  11835. var storedFocusNode = selection.focusNode;
  11836. var storedFocusOffset = selection.focusOffset;
  11837. selection.removeAllRanges();
  11838. addPointToSelection(
  11839. selection,
  11840. node,
  11841. anchorOffset - nodeStart,
  11842. selectionState
  11843. );
  11844. addFocusToSelection(
  11845. selection,
  11846. storedFocusNode,
  11847. storedFocusOffset,
  11848. selectionState
  11849. );
  11850. }
  11851. }
  11852. }
  11853. /**
  11854. * Extend selection towards focus point.
  11855. */
  11856. function addFocusToSelection(selection, node, offset, selectionState) {
  11857. var activeElement = getActiveElement_1();
  11858. if (selection.extend && containsNode_1(activeElement, node)) {
  11859. // If `extend` is called while another element has focus, an error is
  11860. // thrown. We therefore disable `extend` if the active element is somewhere
  11861. // other than the node we are selecting. This should only occur in Firefox,
  11862. // since it is the only browser to support multiple selections.
  11863. // See https://bugzilla.mozilla.org/show_bug.cgi?id=921444.
  11864. // logging to catch bug that is being reported in t16250795
  11865. if (offset > getNodeLength(node)) {
  11866. // the call to 'selection.extend' is about to throw
  11867. DraftJsDebugLogging.logSelectionStateFailure({
  11868. anonymizedDom: getAnonymizedEditorDOM(node),
  11869. extraParams: JSON.stringify({ offset: offset }),
  11870. selectionState: JSON.stringify(selectionState.toJS())
  11871. });
  11872. }
  11873. // logging to catch bug that is being reported in t18110632
  11874. var nodeWasFocus = node === selection.focusNode;
  11875. try {
  11876. selection.extend(node, offset);
  11877. } catch (e) {
  11878. DraftJsDebugLogging.logSelectionStateFailure({
  11879. anonymizedDom: getAnonymizedEditorDOM(node, function(n) {
  11880. var labels = [];
  11881. if (n === activeElement) {
  11882. labels.push("active element");
  11883. }
  11884. if (n === selection.anchorNode) {
  11885. labels.push("selection anchor node");
  11886. }
  11887. if (n === selection.focusNode) {
  11888. labels.push("selection focus node");
  11889. }
  11890. return labels;
  11891. }),
  11892. extraParams: JSON.stringify(
  11893. {
  11894. activeElementName: activeElement ? activeElement.nodeName : null,
  11895. nodeIsFocus: node === selection.focusNode,
  11896. nodeWasFocus: nodeWasFocus,
  11897. selectionRangeCount: selection.rangeCount,
  11898. selectionAnchorNodeName: selection.anchorNode
  11899. ? selection.anchorNode.nodeName
  11900. : null,
  11901. selectionAnchorOffset: selection.anchorOffset,
  11902. selectionFocusNodeName: selection.focusNode
  11903. ? selection.focusNode.nodeName
  11904. : null,
  11905. selectionFocusOffset: selection.focusOffset,
  11906. message: e ? "" + e : null,
  11907. offset: offset
  11908. },
  11909. null,
  11910. 2
  11911. ),
  11912. selectionState: JSON.stringify(selectionState.toJS(), null, 2)
  11913. });
  11914. // allow the error to be thrown -
  11915. // better than continuing in a broken state
  11916. throw e;
  11917. }
  11918. } else {
  11919. // IE doesn't support extend. This will mean no backward selection.
  11920. // Extract the existing selection range and add focus to it.
  11921. // Additionally, clone the selection range. IE11 throws an
  11922. // InvalidStateError when attempting to access selection properties
  11923. // after the range is detached.
  11924. var range = selection.getRangeAt(0);
  11925. range.setEnd(node, offset);
  11926. selection.addRange(range.cloneRange());
  11927. }
  11928. }
  11929. function addPointToSelection(selection, node, offset, selectionState) {
  11930. var range = document.createRange();
  11931. // logging to catch bug that is being reported in t16250795
  11932. if (offset > getNodeLength(node)) {
  11933. // in this case we know that the call to 'range.setStart' is about to throw
  11934. DraftJsDebugLogging.logSelectionStateFailure({
  11935. anonymizedDom: getAnonymizedEditorDOM(node),
  11936. extraParams: JSON.stringify({ offset: offset }),
  11937. selectionState: JSON.stringify(selectionState.toJS())
  11938. });
  11939. }
  11940. range.setStart(node, offset);
  11941. selection.addRange(range);
  11942. }
  11943. var setDraftEditorSelection_1 = setDraftEditorSelection;
  11944. function _classCallCheck$a(instance, Constructor) {
  11945. if (!(instance instanceof Constructor)) {
  11946. throw new TypeError("Cannot call a class as a function");
  11947. }
  11948. }
  11949. function _possibleConstructorReturn$7(self, call) {
  11950. if (!self) {
  11951. throw new ReferenceError(
  11952. "this hasn't been initialised - super() hasn't been called"
  11953. );
  11954. }
  11955. return call && (typeof call === "object" || typeof call === "function")
  11956. ? call
  11957. : self;
  11958. }
  11959. function _inherits$7(subClass, superClass) {
  11960. if (typeof superClass !== "function" && superClass !== null) {
  11961. throw new TypeError(
  11962. "Super expression must either be null or a function, not " +
  11963. typeof superClass
  11964. );
  11965. }
  11966. subClass.prototype = Object.create(superClass && superClass.prototype, {
  11967. constructor: {
  11968. value: subClass,
  11969. enumerable: false,
  11970. writable: true,
  11971. configurable: true
  11972. }
  11973. });
  11974. if (superClass)
  11975. Object.setPrototypeOf
  11976. ? Object.setPrototypeOf(subClass, superClass)
  11977. : (subClass.__proto__ = superClass);
  11978. }
  11979. /**
  11980. * All leaf nodes in the editor are spans with single text nodes. Leaf
  11981. * elements are styled based on the merging of an optional custom style map
  11982. * and a default style map.
  11983. *
  11984. * `DraftEditorLeaf` also provides a wrapper for calling into the imperative
  11985. * DOM Selection API. In this way, top-level components can declaratively
  11986. * maintain the selection state.
  11987. */
  11988. var DraftEditorLeaf = (function(_React$Component) {
  11989. _inherits$7(DraftEditorLeaf, _React$Component);
  11990. function DraftEditorLeaf() {
  11991. _classCallCheck$a(this, DraftEditorLeaf);
  11992. return _possibleConstructorReturn$7(
  11993. this,
  11994. _React$Component.apply(this, arguments)
  11995. );
  11996. }
  11997. DraftEditorLeaf.prototype._setSelection = function _setSelection() {
  11998. var selection = this.props.selection;
  11999. // If selection state is irrelevant to the parent block, no-op.
  12000. if (selection == null || !selection.getHasFocus()) {
  12001. return;
  12002. }
  12003. var _props = this.props,
  12004. block = _props.block,
  12005. start = _props.start,
  12006. text = _props.text;
  12007. var blockKey = block.getKey();
  12008. var end = start + text.length;
  12009. if (!selection.hasEdgeWithin(blockKey, start, end)) {
  12010. return;
  12011. }
  12012. // Determine the appropriate target node for selection. If the child
  12013. // is not a text node, it is a <br /> spacer. In this case, use the
  12014. // <span> itself as the selection target.
  12015. var node = reactDom__default.findDOMNode(this);
  12016. !node
  12017. ? process.env.NODE_ENV !== "production"
  12018. ? invariant_1(false, "Missing node")
  12019. : invariant_1(false)
  12020. : void 0;
  12021. var child = node.firstChild;
  12022. !child
  12023. ? process.env.NODE_ENV !== "production"
  12024. ? invariant_1(false, "Missing child")
  12025. : invariant_1(false)
  12026. : void 0;
  12027. var targetNode = void 0;
  12028. if (child.nodeType === Node.TEXT_NODE) {
  12029. targetNode = child;
  12030. } else if (child.tagName === "BR") {
  12031. targetNode = node;
  12032. } else {
  12033. targetNode = child.firstChild;
  12034. !targetNode
  12035. ? process.env.NODE_ENV !== "production"
  12036. ? invariant_1(false, "Missing targetNode")
  12037. : invariant_1(false)
  12038. : void 0;
  12039. }
  12040. setDraftEditorSelection_1(selection, targetNode, blockKey, start, end);
  12041. };
  12042. /**
  12043. * By making individual leaf instances aware of their context within
  12044. * the text of the editor, we can set our selection range more
  12045. * easily than we could in the non-React world.
  12046. *
  12047. * Note that this depends on our maintaining tight control over the
  12048. * DOM structure of the DraftEditor component. If leaves had multiple
  12049. * text nodes, this would be harder.
  12050. */
  12051. DraftEditorLeaf.prototype.shouldComponentUpdate = function shouldComponentUpdate(
  12052. nextProps
  12053. ) {
  12054. var leafNode = reactDom__default.findDOMNode(this.leaf);
  12055. !leafNode
  12056. ? process.env.NODE_ENV !== "production"
  12057. ? invariant_1(false, "Missing leafNode")
  12058. : invariant_1(false)
  12059. : void 0;
  12060. return (
  12061. leafNode.textContent !== nextProps.text ||
  12062. nextProps.styleSet !== this.props.styleSet ||
  12063. nextProps.forceSelection
  12064. );
  12065. };
  12066. DraftEditorLeaf.prototype.componentDidUpdate = function componentDidUpdate() {
  12067. this._setSelection();
  12068. };
  12069. DraftEditorLeaf.prototype.componentDidMount = function componentDidMount() {
  12070. this._setSelection();
  12071. };
  12072. DraftEditorLeaf.prototype.render = function render() {
  12073. var _this2 = this;
  12074. var block = this.props.block;
  12075. var text = this.props.text;
  12076. // If the leaf is at the end of its block and ends in a soft newline, append
  12077. // an extra line feed character. Browsers collapse trailing newline
  12078. // characters, which leaves the cursor in the wrong place after a
  12079. // shift+enter. The extra character repairs this.
  12080. if (text.endsWith("\n") && this.props.isLast) {
  12081. text += "\n";
  12082. }
  12083. var _props2 = this.props,
  12084. customStyleMap = _props2.customStyleMap,
  12085. customStyleFn = _props2.customStyleFn,
  12086. offsetKey = _props2.offsetKey,
  12087. styleSet = _props2.styleSet;
  12088. var styleObj = styleSet.reduce(function(map, styleName) {
  12089. var mergedStyles = {};
  12090. var style = customStyleMap[styleName];
  12091. if (style !== undefined && map.textDecoration !== style.textDecoration) {
  12092. // .trim() is necessary for IE9/10/11 and Edge
  12093. mergedStyles.textDecoration = [map.textDecoration, style.textDecoration]
  12094. .join(" ")
  12095. .trim();
  12096. }
  12097. return objectAssign(map, style, mergedStyles);
  12098. }, {});
  12099. if (customStyleFn) {
  12100. var newStyles = customStyleFn(styleSet, block);
  12101. styleObj = objectAssign(styleObj, newStyles);
  12102. }
  12103. return React__default.createElement(
  12104. "span",
  12105. {
  12106. "data-offset-key": offsetKey,
  12107. ref: function ref(_ref) {
  12108. return (_this2.leaf = _ref);
  12109. },
  12110. style: styleObj
  12111. },
  12112. React__default.createElement(DraftEditorTextNode_react, null, text)
  12113. );
  12114. };
  12115. return DraftEditorLeaf;
  12116. })(React__default.Component);
  12117. var DraftEditorLeaf_react = DraftEditorLeaf;
  12118. /**
  12119. * Copyright (c) 2013-present, Facebook, Inc.
  12120. * All rights reserved.
  12121. *
  12122. * This source code is licensed under the BSD-style license found in the
  12123. * LICENSE file in the root directory of this source tree. An additional grant
  12124. * of patent rights can be found in the PATENTS file in the same directory.
  12125. *
  12126. * @providesModule DraftOffsetKey
  12127. * @format
  12128. *
  12129. */
  12130. var KEY_DELIMITER = "-";
  12131. var DraftOffsetKey = {
  12132. encode: function encode(blockKey, decoratorKey, leafKey) {
  12133. return blockKey + KEY_DELIMITER + decoratorKey + KEY_DELIMITER + leafKey;
  12134. },
  12135. decode: function decode(offsetKey) {
  12136. var _offsetKey$split = offsetKey.split(KEY_DELIMITER),
  12137. blockKey = _offsetKey$split[0],
  12138. decoratorKey = _offsetKey$split[1],
  12139. leafKey = _offsetKey$split[2];
  12140. return {
  12141. blockKey: blockKey,
  12142. decoratorKey: parseInt(decoratorKey, 10),
  12143. leafKey: parseInt(leafKey, 10)
  12144. };
  12145. }
  12146. };
  12147. var DraftOffsetKey_1 = DraftOffsetKey;
  12148. /**
  12149. * Copyright (c) 2013-present, Facebook, Inc.
  12150. *
  12151. * This source code is licensed under the MIT license found in the
  12152. * LICENSE file in the root directory of this source tree.
  12153. *
  12154. */
  12155. /**
  12156. * @param {DOMElement} element
  12157. * @param {DOMDocument} doc
  12158. * @return {boolean}
  12159. */
  12160. function _isViewportScrollElement(element, doc) {
  12161. return !!doc && (element === doc.documentElement || element === doc.body);
  12162. }
  12163. /**
  12164. * Scroll Module. This class contains 4 simple static functions
  12165. * to be used to access Element.scrollTop/scrollLeft properties.
  12166. * To solve the inconsistencies between browsers when either
  12167. * document.body or document.documentElement is supplied,
  12168. * below logic will be used to alleviate the issue:
  12169. *
  12170. * 1. If 'element' is either 'document.body' or 'document.documentElement,
  12171. * get whichever element's 'scroll{Top,Left}' is larger.
  12172. * 2. If 'element' is either 'document.body' or 'document.documentElement',
  12173. * set the 'scroll{Top,Left}' on both elements.
  12174. */
  12175. var Scroll = {
  12176. /**
  12177. * @param {DOMElement} element
  12178. * @return {number}
  12179. */
  12180. getTop: function getTop(element) {
  12181. var doc = element.ownerDocument;
  12182. return _isViewportScrollElement(element, doc)
  12183. ? // In practice, they will either both have the same value,
  12184. // or one will be zero and the other will be the scroll position
  12185. // of the viewport. So we can use `X || Y` instead of `Math.max(X, Y)`
  12186. doc.body.scrollTop || doc.documentElement.scrollTop
  12187. : element.scrollTop;
  12188. },
  12189. /**
  12190. * @param {DOMElement} element
  12191. * @param {number} newTop
  12192. */
  12193. setTop: function setTop(element, newTop) {
  12194. var doc = element.ownerDocument;
  12195. if (_isViewportScrollElement(element, doc)) {
  12196. doc.body.scrollTop = doc.documentElement.scrollTop = newTop;
  12197. } else {
  12198. element.scrollTop = newTop;
  12199. }
  12200. },
  12201. /**
  12202. * @param {DOMElement} element
  12203. * @return {number}
  12204. */
  12205. getLeft: function getLeft(element) {
  12206. var doc = element.ownerDocument;
  12207. return _isViewportScrollElement(element, doc)
  12208. ? doc.body.scrollLeft || doc.documentElement.scrollLeft
  12209. : element.scrollLeft;
  12210. },
  12211. /**
  12212. * @param {DOMElement} element
  12213. * @param {number} newLeft
  12214. */
  12215. setLeft: function setLeft(element, newLeft) {
  12216. var doc = element.ownerDocument;
  12217. if (_isViewportScrollElement(element, doc)) {
  12218. doc.body.scrollLeft = doc.documentElement.scrollLeft = newLeft;
  12219. } else {
  12220. element.scrollLeft = newLeft;
  12221. }
  12222. }
  12223. };
  12224. var Scroll_1 = Scroll;
  12225. /**
  12226. * Copyright (c) 2013-present, Facebook, Inc.
  12227. *
  12228. * This source code is licensed under the MIT license found in the
  12229. * LICENSE file in the root directory of this source tree.
  12230. *
  12231. * @typechecks
  12232. */
  12233. var _hyphenPattern = /-(.)/g;
  12234. /**
  12235. * Camelcases a hyphenated string, for example:
  12236. *
  12237. * > camelize('background-color')
  12238. * < "backgroundColor"
  12239. *
  12240. * @param {string} string
  12241. * @return {string}
  12242. */
  12243. function camelize(string) {
  12244. return string.replace(_hyphenPattern, function(_, character) {
  12245. return character.toUpperCase();
  12246. });
  12247. }
  12248. var camelize_1 = camelize;
  12249. /**
  12250. * Copyright (c) 2013-present, Facebook, Inc.
  12251. *
  12252. * This source code is licensed under the MIT license found in the
  12253. * LICENSE file in the root directory of this source tree.
  12254. *
  12255. * @typechecks
  12256. */
  12257. var _uppercasePattern = /([A-Z])/g;
  12258. /**
  12259. * Hyphenates a camelcased string, for example:
  12260. *
  12261. * > hyphenate('backgroundColor')
  12262. * < "background-color"
  12263. *
  12264. * For CSS style names, use `hyphenateStyleName` instead which works properly
  12265. * with all vendor prefixes, including `ms`.
  12266. *
  12267. * @param {string} string
  12268. * @return {string}
  12269. */
  12270. function hyphenate(string) {
  12271. return string.replace(_uppercasePattern, "-$1").toLowerCase();
  12272. }
  12273. var hyphenate_1 = hyphenate;
  12274. /**
  12275. * Copyright (c) 2013-present, Facebook, Inc.
  12276. *
  12277. * This source code is licensed under the MIT license found in the
  12278. * LICENSE file in the root directory of this source tree.
  12279. *
  12280. * @typechecks
  12281. */
  12282. function asString(value) /*?string*/ {
  12283. return value == null ? value : String(value);
  12284. }
  12285. function getStyleProperty(/*DOMNode*/ node, /*string*/ name) /*?string*/ {
  12286. var computedStyle = void 0;
  12287. // W3C Standard
  12288. if (window.getComputedStyle) {
  12289. // In certain cases such as within an iframe in FF3, this returns null.
  12290. computedStyle = window.getComputedStyle(node, null);
  12291. if (computedStyle) {
  12292. return asString(computedStyle.getPropertyValue(hyphenate_1(name)));
  12293. }
  12294. }
  12295. // Safari
  12296. if (document.defaultView && document.defaultView.getComputedStyle) {
  12297. computedStyle = document.defaultView.getComputedStyle(node, null);
  12298. // A Safari bug causes this to return null for `display: none` elements.
  12299. if (computedStyle) {
  12300. return asString(computedStyle.getPropertyValue(hyphenate_1(name)));
  12301. }
  12302. if (name === "display") {
  12303. return "none";
  12304. }
  12305. }
  12306. // Internet Explorer
  12307. if (node.currentStyle) {
  12308. if (name === "float") {
  12309. return asString(
  12310. node.currentStyle.cssFloat || node.currentStyle.styleFloat
  12311. );
  12312. }
  12313. return asString(node.currentStyle[camelize_1(name)]);
  12314. }
  12315. return asString(node.style && node.style[camelize_1(name)]);
  12316. }
  12317. var getStyleProperty_1 = getStyleProperty;
  12318. /**
  12319. * Copyright (c) 2013-present, Facebook, Inc.
  12320. *
  12321. * This source code is licensed under the MIT license found in the
  12322. * LICENSE file in the root directory of this source tree.
  12323. *
  12324. * @typechecks
  12325. */
  12326. /**
  12327. * @param {DOMNode} element [description]
  12328. * @param {string} name Overflow style property name.
  12329. * @return {boolean} True if the supplied ndoe is scrollable.
  12330. */
  12331. function _isNodeScrollable(element, name) {
  12332. var overflow = Style.get(element, name);
  12333. return overflow === "auto" || overflow === "scroll";
  12334. }
  12335. /**
  12336. * Utilities for querying and mutating style properties.
  12337. */
  12338. var Style = {
  12339. /**
  12340. * Gets the style property for the supplied node. This will return either the
  12341. * computed style, if available, or the declared style.
  12342. *
  12343. * @param {DOMNode} node
  12344. * @param {string} name Style property name.
  12345. * @return {?string} Style property value.
  12346. */
  12347. get: getStyleProperty_1,
  12348. /**
  12349. * Determines the nearest ancestor of a node that is scrollable.
  12350. *
  12351. * NOTE: This can be expensive if used repeatedly or on a node nested deeply.
  12352. *
  12353. * @param {?DOMNode} node Node from which to start searching.
  12354. * @return {?DOMWindow|DOMElement} Scroll parent of the supplied node.
  12355. */
  12356. getScrollParent: function getScrollParent(node) {
  12357. if (!node) {
  12358. return null;
  12359. }
  12360. var ownerDocument = node.ownerDocument;
  12361. while (node && node !== ownerDocument.body) {
  12362. if (
  12363. _isNodeScrollable(node, "overflow") ||
  12364. _isNodeScrollable(node, "overflowY") ||
  12365. _isNodeScrollable(node, "overflowX")
  12366. ) {
  12367. return node;
  12368. }
  12369. node = node.parentNode;
  12370. }
  12371. return ownerDocument.defaultView || ownerDocument.parentWindow;
  12372. }
  12373. };
  12374. var Style_1 = Style;
  12375. /**
  12376. * Copyright (c) 2013-present, Facebook, Inc.
  12377. *
  12378. * This source code is licensed under the MIT license found in the
  12379. * LICENSE file in the root directory of this source tree.
  12380. *
  12381. * @typechecks
  12382. */
  12383. /**
  12384. * Gets an element's bounding rect in pixels relative to the viewport.
  12385. *
  12386. * @param {DOMElement} elem
  12387. * @return {object}
  12388. */
  12389. function getElementRect(elem) {
  12390. var docElem = elem.ownerDocument.documentElement;
  12391. // FF 2, Safari 3 and Opera 9.5- do not support getBoundingClientRect().
  12392. // IE9- will throw if the element is not in the document.
  12393. if (!("getBoundingClientRect" in elem) || !containsNode_1(docElem, elem)) {
  12394. return {
  12395. left: 0,
  12396. right: 0,
  12397. top: 0,
  12398. bottom: 0
  12399. };
  12400. }
  12401. // Subtracts clientTop/Left because IE8- added a 2px border to the
  12402. // <html> element (see http://fburl.com/1493213). IE 7 in
  12403. // Quicksmode does not report clientLeft/clientTop so there
  12404. // will be an unaccounted offset of 2px when in quirksmode
  12405. var rect = elem.getBoundingClientRect();
  12406. return {
  12407. left: Math.round(rect.left) - docElem.clientLeft,
  12408. right: Math.round(rect.right) - docElem.clientLeft,
  12409. top: Math.round(rect.top) - docElem.clientTop,
  12410. bottom: Math.round(rect.bottom) - docElem.clientTop
  12411. };
  12412. }
  12413. var getElementRect_1 = getElementRect;
  12414. /**
  12415. * Copyright (c) 2013-present, Facebook, Inc.
  12416. *
  12417. * This source code is licensed under the MIT license found in the
  12418. * LICENSE file in the root directory of this source tree.
  12419. *
  12420. * @typechecks
  12421. */
  12422. /**
  12423. * Gets an element's position in pixels relative to the viewport. The returned
  12424. * object represents the position of the element's top left corner.
  12425. *
  12426. * @param {DOMElement} element
  12427. * @return {object}
  12428. */
  12429. function getElementPosition(element) {
  12430. var rect = getElementRect_1(element);
  12431. return {
  12432. x: rect.left,
  12433. y: rect.top,
  12434. width: rect.right - rect.left,
  12435. height: rect.bottom - rect.top
  12436. };
  12437. }
  12438. var getElementPosition_1 = getElementPosition;
  12439. /**
  12440. * Copyright (c) 2013-present, Facebook, Inc.
  12441. *
  12442. * This source code is licensed under the MIT license found in the
  12443. * LICENSE file in the root directory of this source tree.
  12444. *
  12445. * @typechecks
  12446. */
  12447. var isWebkit =
  12448. typeof navigator !== "undefined" &&
  12449. navigator.userAgent.indexOf("AppleWebKit") > -1;
  12450. /**
  12451. * Gets the element with the document scroll properties such as `scrollLeft` and
  12452. * `scrollHeight`. This may differ across different browsers.
  12453. *
  12454. * NOTE: The return value can be null if the DOM is not yet ready.
  12455. *
  12456. * @param {?DOMDocument} doc Defaults to current document.
  12457. * @return {?DOMElement}
  12458. */
  12459. function getDocumentScrollElement(doc) {
  12460. doc = doc || document;
  12461. if (doc.scrollingElement) {
  12462. return doc.scrollingElement;
  12463. }
  12464. return !isWebkit && doc.compatMode === "CSS1Compat"
  12465. ? doc.documentElement
  12466. : doc.body;
  12467. }
  12468. var getDocumentScrollElement_1 = getDocumentScrollElement;
  12469. /**
  12470. * Copyright (c) 2013-present, Facebook, Inc.
  12471. *
  12472. * This source code is licensed under the MIT license found in the
  12473. * LICENSE file in the root directory of this source tree.
  12474. *
  12475. * @typechecks
  12476. */
  12477. /**
  12478. * Gets the scroll position of the supplied element or window.
  12479. *
  12480. * The return values are unbounded, unlike `getScrollPosition`. This means they
  12481. * may be negative or exceed the element boundaries (which is possible using
  12482. * inertial scrolling).
  12483. *
  12484. * @param {DOMWindow|DOMElement} scrollable
  12485. * @return {object} Map with `x` and `y` keys.
  12486. */
  12487. function getUnboundedScrollPosition(scrollable) {
  12488. if (scrollable.Window && scrollable instanceof scrollable.Window) {
  12489. return {
  12490. x:
  12491. scrollable.pageXOffset ||
  12492. scrollable.document.documentElement.scrollLeft,
  12493. y: scrollable.pageYOffset || scrollable.document.documentElement.scrollTop
  12494. };
  12495. }
  12496. return {
  12497. x: scrollable.scrollLeft,
  12498. y: scrollable.scrollTop
  12499. };
  12500. }
  12501. var getUnboundedScrollPosition_1 = getUnboundedScrollPosition;
  12502. /**
  12503. * Gets the scroll position of the supplied element or window.
  12504. *
  12505. * The return values are bounded. This means that if the scroll position is
  12506. * negative or exceeds the element boundaries (which is possible using inertial
  12507. * scrolling), you will get zero or the maximum scroll position, respectively.
  12508. *
  12509. * If you need the unbound scroll position, use `getUnboundedScrollPosition`.
  12510. *
  12511. * @param {DOMWindow|DOMElement} scrollable
  12512. * @return {object} Map with `x` and `y` keys.
  12513. */
  12514. function getScrollPosition(scrollable) {
  12515. var documentScrollElement = getDocumentScrollElement_1(
  12516. scrollable.ownerDocument || scrollable.document
  12517. );
  12518. if (scrollable.Window && scrollable instanceof scrollable.Window) {
  12519. scrollable = documentScrollElement;
  12520. }
  12521. var scrollPosition = getUnboundedScrollPosition_1(scrollable);
  12522. var viewport =
  12523. scrollable === documentScrollElement
  12524. ? scrollable.ownerDocument.documentElement
  12525. : scrollable;
  12526. var xMax = scrollable.scrollWidth - viewport.clientWidth;
  12527. var yMax = scrollable.scrollHeight - viewport.clientHeight;
  12528. scrollPosition.x = Math.max(0, Math.min(scrollPosition.x, xMax));
  12529. scrollPosition.y = Math.max(0, Math.min(scrollPosition.y, yMax));
  12530. return scrollPosition;
  12531. }
  12532. var getScrollPosition_1 = getScrollPosition;
  12533. function getViewportWidth() {
  12534. var width = void 0;
  12535. if (document.documentElement) {
  12536. width = document.documentElement.clientWidth;
  12537. }
  12538. if (!width && document.body) {
  12539. width = document.body.clientWidth;
  12540. }
  12541. return width || 0;
  12542. }
  12543. /**
  12544. * Copyright (c) 2013-present, Facebook, Inc.
  12545. *
  12546. * This source code is licensed under the MIT license found in the
  12547. * LICENSE file in the root directory of this source tree.
  12548. *
  12549. *
  12550. * @typechecks
  12551. */
  12552. function getViewportHeight() {
  12553. var height = void 0;
  12554. if (document.documentElement) {
  12555. height = document.documentElement.clientHeight;
  12556. }
  12557. if (!height && document.body) {
  12558. height = document.body.clientHeight;
  12559. }
  12560. return height || 0;
  12561. }
  12562. /**
  12563. * Gets the viewport dimensions including any scrollbars.
  12564. */
  12565. function getViewportDimensions() {
  12566. return {
  12567. width: window.innerWidth || getViewportWidth(),
  12568. height: window.innerHeight || getViewportHeight()
  12569. };
  12570. }
  12571. /**
  12572. * Gets the viewport dimensions excluding any scrollbars.
  12573. */
  12574. getViewportDimensions.withoutScrollbars = function() {
  12575. return {
  12576. width: getViewportWidth(),
  12577. height: getViewportHeight()
  12578. };
  12579. };
  12580. var getViewportDimensions_1 = getViewportDimensions;
  12581. var _extends$2 =
  12582. objectAssign ||
  12583. function(target) {
  12584. for (var i = 1; i < arguments.length; i++) {
  12585. var source = arguments[i];
  12586. for (var key in source) {
  12587. if (Object.prototype.hasOwnProperty.call(source, key)) {
  12588. target[key] = source[key];
  12589. }
  12590. }
  12591. }
  12592. return target;
  12593. };
  12594. function _classCallCheck$b(instance, Constructor) {
  12595. if (!(instance instanceof Constructor)) {
  12596. throw new TypeError("Cannot call a class as a function");
  12597. }
  12598. }
  12599. function _possibleConstructorReturn$8(self, call) {
  12600. if (!self) {
  12601. throw new ReferenceError(
  12602. "this hasn't been initialised - super() hasn't been called"
  12603. );
  12604. }
  12605. return call && (typeof call === "object" || typeof call === "function")
  12606. ? call
  12607. : self;
  12608. }
  12609. function _inherits$8(subClass, superClass) {
  12610. if (typeof superClass !== "function" && superClass !== null) {
  12611. throw new TypeError(
  12612. "Super expression must either be null or a function, not " +
  12613. typeof superClass
  12614. );
  12615. }
  12616. subClass.prototype = Object.create(superClass && superClass.prototype, {
  12617. constructor: {
  12618. value: subClass,
  12619. enumerable: false,
  12620. writable: true,
  12621. configurable: true
  12622. }
  12623. });
  12624. if (superClass)
  12625. Object.setPrototypeOf
  12626. ? Object.setPrototypeOf(subClass, superClass)
  12627. : (subClass.__proto__ = superClass);
  12628. }
  12629. var SCROLL_BUFFER = 10;
  12630. /**
  12631. * Return whether a block overlaps with either edge of the `SelectionState`.
  12632. */
  12633. var isBlockOnSelectionEdge = function isBlockOnSelectionEdge(selection, key) {
  12634. return selection.getAnchorKey() === key || selection.getFocusKey() === key;
  12635. };
  12636. /**
  12637. * The default block renderer for a `DraftEditor` component.
  12638. *
  12639. * A `DraftEditorBlock` is able to render a given `ContentBlock` to its
  12640. * appropriate decorator and inline style components.
  12641. */
  12642. var DraftEditorBlock = (function(_React$Component) {
  12643. _inherits$8(DraftEditorBlock, _React$Component);
  12644. function DraftEditorBlock() {
  12645. _classCallCheck$b(this, DraftEditorBlock);
  12646. return _possibleConstructorReturn$8(
  12647. this,
  12648. _React$Component.apply(this, arguments)
  12649. );
  12650. }
  12651. DraftEditorBlock.prototype.shouldComponentUpdate = function shouldComponentUpdate(
  12652. nextProps
  12653. ) {
  12654. return (
  12655. this.props.block !== nextProps.block ||
  12656. this.props.tree !== nextProps.tree ||
  12657. this.props.direction !== nextProps.direction ||
  12658. (isBlockOnSelectionEdge(nextProps.selection, nextProps.block.getKey()) &&
  12659. nextProps.forceSelection)
  12660. );
  12661. };
  12662. /**
  12663. * When a block is mounted and overlaps the selection state, we need to make
  12664. * sure that the cursor is visible to match native behavior. This may not
  12665. * be the case if the user has pressed `RETURN` or pasted some content, since
  12666. * programatically creating these new blocks and setting the DOM selection
  12667. * will miss out on the browser natively scrolling to that position.
  12668. *
  12669. * To replicate native behavior, if the block overlaps the selection state
  12670. * on mount, force the scroll position. Check the scroll state of the scroll
  12671. * parent, and adjust it to align the entire block to the bottom of the
  12672. * scroll parent.
  12673. */
  12674. DraftEditorBlock.prototype.componentDidMount = function componentDidMount() {
  12675. var selection = this.props.selection;
  12676. var endKey = selection.getEndKey();
  12677. if (!selection.getHasFocus() || endKey !== this.props.block.getKey()) {
  12678. return;
  12679. }
  12680. var blockNode = reactDom__default.findDOMNode(this);
  12681. var scrollParent = Style_1.getScrollParent(blockNode);
  12682. var scrollPosition = getScrollPosition_1(scrollParent);
  12683. var scrollDelta = void 0;
  12684. if (scrollParent === window) {
  12685. var nodePosition = getElementPosition_1(blockNode);
  12686. var nodeBottom = nodePosition.y + nodePosition.height;
  12687. var viewportHeight = getViewportDimensions_1().height;
  12688. scrollDelta = nodeBottom - viewportHeight;
  12689. if (scrollDelta > 0) {
  12690. window.scrollTo(
  12691. scrollPosition.x,
  12692. scrollPosition.y + scrollDelta + SCROLL_BUFFER
  12693. );
  12694. }
  12695. } else {
  12696. !(blockNode instanceof HTMLElement)
  12697. ? process.env.NODE_ENV !== "production"
  12698. ? invariant_1(false, "blockNode is not an HTMLElement")
  12699. : invariant_1(false)
  12700. : void 0;
  12701. var blockBottom = blockNode.offsetHeight + blockNode.offsetTop;
  12702. var scrollBottom = scrollParent.offsetHeight + scrollPosition.y;
  12703. scrollDelta = blockBottom - scrollBottom;
  12704. if (scrollDelta > 0) {
  12705. Scroll_1.setTop(
  12706. scrollParent,
  12707. Scroll_1.getTop(scrollParent) + scrollDelta + SCROLL_BUFFER
  12708. );
  12709. }
  12710. }
  12711. };
  12712. DraftEditorBlock.prototype._renderChildren = function _renderChildren() {
  12713. var _this2 = this;
  12714. var block = this.props.block;
  12715. var blockKey = block.getKey();
  12716. var text = block.getText();
  12717. var lastLeafSet = this.props.tree.size - 1;
  12718. var hasSelection = isBlockOnSelectionEdge(this.props.selection, blockKey);
  12719. return this.props.tree
  12720. .map(function(leafSet, ii) {
  12721. var leavesForLeafSet = leafSet.get("leaves");
  12722. var lastLeaf = leavesForLeafSet.size - 1;
  12723. var leaves = leavesForLeafSet
  12724. .map(function(leaf, jj) {
  12725. var offsetKey = DraftOffsetKey_1.encode(blockKey, ii, jj);
  12726. var start = leaf.get("start");
  12727. var end = leaf.get("end");
  12728. return React__default.createElement(DraftEditorLeaf_react, {
  12729. key: offsetKey,
  12730. offsetKey: offsetKey,
  12731. block: block,
  12732. start: start,
  12733. selection: hasSelection ? _this2.props.selection : null,
  12734. forceSelection: _this2.props.forceSelection,
  12735. text: text.slice(start, end),
  12736. styleSet: block.getInlineStyleAt(start),
  12737. customStyleMap: _this2.props.customStyleMap,
  12738. customStyleFn: _this2.props.customStyleFn,
  12739. isLast: ii === lastLeafSet && jj === lastLeaf
  12740. });
  12741. })
  12742. .toArray();
  12743. var decoratorKey = leafSet.get("decoratorKey");
  12744. if (decoratorKey == null) {
  12745. return leaves;
  12746. }
  12747. if (!_this2.props.decorator) {
  12748. return leaves;
  12749. }
  12750. var decorator = nullthrows_1(_this2.props.decorator);
  12751. var DecoratorComponent = decorator.getComponentForKey(decoratorKey);
  12752. if (!DecoratorComponent) {
  12753. return leaves;
  12754. }
  12755. var decoratorProps = decorator.getPropsForKey(decoratorKey);
  12756. var decoratorOffsetKey = DraftOffsetKey_1.encode(blockKey, ii, 0);
  12757. var decoratedText = text.slice(
  12758. leavesForLeafSet.first().get("start"),
  12759. leavesForLeafSet.last().get("end")
  12760. );
  12761. // Resetting dir to the same value on a child node makes Chrome/Firefox
  12762. // confused on cursor movement. See http://jsfiddle.net/d157kLck/3/
  12763. var dir = UnicodeBidiDirection_1.getHTMLDirIfDifferent(
  12764. UnicodeBidi_1.getDirection(decoratedText),
  12765. _this2.props.direction
  12766. );
  12767. return React__default.createElement(
  12768. DecoratorComponent,
  12769. _extends$2({}, decoratorProps, {
  12770. contentState: _this2.props.contentState,
  12771. decoratedText: decoratedText,
  12772. dir: dir,
  12773. key: decoratorOffsetKey,
  12774. entityKey: block.getEntityAt(leafSet.get("start")),
  12775. offsetKey: decoratorOffsetKey
  12776. }),
  12777. leaves
  12778. );
  12779. })
  12780. .toArray();
  12781. };
  12782. DraftEditorBlock.prototype.render = function render() {
  12783. var _props = this.props,
  12784. direction = _props.direction,
  12785. offsetKey = _props.offsetKey;
  12786. var className = cx_1({
  12787. "public/DraftStyleDefault/block": true,
  12788. "public/DraftStyleDefault/ltr": direction === "LTR",
  12789. "public/DraftStyleDefault/rtl": direction === "RTL"
  12790. });
  12791. return React__default.createElement(
  12792. "div",
  12793. { "data-offset-key": offsetKey, className: className },
  12794. this._renderChildren()
  12795. );
  12796. };
  12797. return DraftEditorBlock;
  12798. })(React__default.Component);
  12799. var DraftEditorBlock_react = DraftEditorBlock;
  12800. /**
  12801. * Copyright (c) 2013-present, Facebook, Inc.
  12802. *
  12803. * This source code is licensed under the MIT license found in the
  12804. * LICENSE file in the root directory of this source tree.
  12805. *
  12806. * @typechecks static-only
  12807. */
  12808. /**
  12809. * Combines multiple className strings into one.
  12810. * http://jsperf.com/joinclasses-args-vs-array
  12811. *
  12812. * @param {...?string} className
  12813. * @return {string}
  12814. */
  12815. function joinClasses(className /*, ... */) {
  12816. if (!className) {
  12817. className = "";
  12818. }
  12819. var nextClass = void 0;
  12820. var argLength = arguments.length;
  12821. if (argLength > 1) {
  12822. for (var ii = 1; ii < argLength; ii++) {
  12823. nextClass = arguments[ii];
  12824. if (nextClass) {
  12825. className = (className ? className + " " : "") + nextClass;
  12826. }
  12827. }
  12828. }
  12829. return className;
  12830. }
  12831. var joinClasses_1 = joinClasses;
  12832. var _extends$3 =
  12833. objectAssign ||
  12834. function(target) {
  12835. for (var i = 1; i < arguments.length; i++) {
  12836. var source = arguments[i];
  12837. for (var key in source) {
  12838. if (Object.prototype.hasOwnProperty.call(source, key)) {
  12839. target[key] = source[key];
  12840. }
  12841. }
  12842. }
  12843. return target;
  12844. };
  12845. function _classCallCheck$c(instance, Constructor) {
  12846. if (!(instance instanceof Constructor)) {
  12847. throw new TypeError("Cannot call a class as a function");
  12848. }
  12849. }
  12850. function _possibleConstructorReturn$9(self, call) {
  12851. if (!self) {
  12852. throw new ReferenceError(
  12853. "this hasn't been initialised - super() hasn't been called"
  12854. );
  12855. }
  12856. return call && (typeof call === "object" || typeof call === "function")
  12857. ? call
  12858. : self;
  12859. }
  12860. function _inherits$9(subClass, superClass) {
  12861. if (typeof superClass !== "function" && superClass !== null) {
  12862. throw new TypeError(
  12863. "Super expression must either be null or a function, not " +
  12864. typeof superClass
  12865. );
  12866. }
  12867. subClass.prototype = Object.create(superClass && superClass.prototype, {
  12868. constructor: {
  12869. value: subClass,
  12870. enumerable: false,
  12871. writable: true,
  12872. configurable: true
  12873. }
  12874. });
  12875. if (superClass)
  12876. Object.setPrototypeOf
  12877. ? Object.setPrototypeOf(subClass, superClass)
  12878. : (subClass.__proto__ = superClass);
  12879. }
  12880. /**
  12881. * Provide default styling for list items. This way, lists will be styled with
  12882. * proper counters and indentation even if the caller does not specify
  12883. * their own styling at all. If more than five levels of nesting are needed,
  12884. * the necessary CSS classes can be provided via `blockStyleFn` configuration.
  12885. */
  12886. var getListItemClasses = function getListItemClasses(
  12887. type,
  12888. depth,
  12889. shouldResetCount,
  12890. direction
  12891. ) {
  12892. return cx_1({
  12893. "public/DraftStyleDefault/unorderedListItem":
  12894. type === "unordered-list-item",
  12895. "public/DraftStyleDefault/orderedListItem": type === "ordered-list-item",
  12896. "public/DraftStyleDefault/reset": shouldResetCount,
  12897. "public/DraftStyleDefault/depth0": depth === 0,
  12898. "public/DraftStyleDefault/depth1": depth === 1,
  12899. "public/DraftStyleDefault/depth2": depth === 2,
  12900. "public/DraftStyleDefault/depth3": depth === 3,
  12901. "public/DraftStyleDefault/depth4": depth === 4,
  12902. "public/DraftStyleDefault/listLTR": direction === "LTR",
  12903. "public/DraftStyleDefault/listRTL": direction === "RTL"
  12904. });
  12905. };
  12906. /**
  12907. * `DraftEditorContents` is the container component for all block components
  12908. * rendered for a `DraftEditor`. It is optimized to aggressively avoid
  12909. * re-rendering blocks whenever possible.
  12910. *
  12911. * This component is separate from `DraftEditor` because certain props
  12912. * (for instance, ARIA props) must be allowed to update without affecting
  12913. * the contents of the editor.
  12914. */
  12915. var DraftEditorContents = (function(_React$Component) {
  12916. _inherits$9(DraftEditorContents, _React$Component);
  12917. function DraftEditorContents() {
  12918. _classCallCheck$c(this, DraftEditorContents);
  12919. return _possibleConstructorReturn$9(
  12920. this,
  12921. _React$Component.apply(this, arguments)
  12922. );
  12923. }
  12924. DraftEditorContents.prototype.shouldComponentUpdate = function shouldComponentUpdate(
  12925. nextProps
  12926. ) {
  12927. var prevEditorState = this.props.editorState;
  12928. var nextEditorState = nextProps.editorState;
  12929. var prevDirectionMap = prevEditorState.getDirectionMap();
  12930. var nextDirectionMap = nextEditorState.getDirectionMap();
  12931. // Text direction has changed for one or more blocks. We must re-render.
  12932. if (prevDirectionMap !== nextDirectionMap) {
  12933. return true;
  12934. }
  12935. var didHaveFocus = prevEditorState.getSelection().getHasFocus();
  12936. var nowHasFocus = nextEditorState.getSelection().getHasFocus();
  12937. if (didHaveFocus !== nowHasFocus) {
  12938. return true;
  12939. }
  12940. var nextNativeContent = nextEditorState.getNativelyRenderedContent();
  12941. var wasComposing = prevEditorState.isInCompositionMode();
  12942. var nowComposing = nextEditorState.isInCompositionMode();
  12943. // If the state is unchanged or we're currently rendering a natively
  12944. // rendered state, there's nothing new to be done.
  12945. if (
  12946. prevEditorState === nextEditorState ||
  12947. (nextNativeContent !== null &&
  12948. nextEditorState.getCurrentContent() === nextNativeContent) ||
  12949. (wasComposing && nowComposing)
  12950. ) {
  12951. return false;
  12952. }
  12953. var prevContent = prevEditorState.getCurrentContent();
  12954. var nextContent = nextEditorState.getCurrentContent();
  12955. var prevDecorator = prevEditorState.getDecorator();
  12956. var nextDecorator = nextEditorState.getDecorator();
  12957. return (
  12958. wasComposing !== nowComposing ||
  12959. prevContent !== nextContent ||
  12960. prevDecorator !== nextDecorator ||
  12961. nextEditorState.mustForceSelection()
  12962. );
  12963. };
  12964. DraftEditorContents.prototype.render = function render() {
  12965. var _props = this.props,
  12966. blockRenderMap = _props.blockRenderMap,
  12967. blockRendererFn = _props.blockRendererFn,
  12968. blockStyleFn = _props.blockStyleFn,
  12969. customStyleMap = _props.customStyleMap,
  12970. customStyleFn = _props.customStyleFn,
  12971. editorState = _props.editorState,
  12972. editorKey = _props.editorKey,
  12973. textDirectionality = _props.textDirectionality;
  12974. var content = editorState.getCurrentContent();
  12975. var selection = editorState.getSelection();
  12976. var forceSelection = editorState.mustForceSelection();
  12977. var decorator = editorState.getDecorator();
  12978. var directionMap = nullthrows_1(editorState.getDirectionMap());
  12979. var blocksAsArray = content.getBlocksAsArray();
  12980. var processedBlocks = [];
  12981. var currentDepth = null;
  12982. var lastWrapperTemplate = null;
  12983. for (var ii = 0; ii < blocksAsArray.length; ii++) {
  12984. var _block = blocksAsArray[ii];
  12985. var key = _block.getKey();
  12986. var blockType = _block.getType();
  12987. var customRenderer = blockRendererFn(_block);
  12988. var CustomComponent = void 0,
  12989. customProps = void 0,
  12990. customEditable = void 0;
  12991. if (customRenderer) {
  12992. CustomComponent = customRenderer.component;
  12993. customProps = customRenderer.props;
  12994. customEditable = customRenderer.editable;
  12995. }
  12996. var direction = textDirectionality
  12997. ? textDirectionality
  12998. : directionMap.get(key);
  12999. var offsetKey = DraftOffsetKey_1.encode(key, 0, 0);
  13000. var componentProps = {
  13001. contentState: content,
  13002. block: _block,
  13003. blockProps: customProps,
  13004. blockStyleFn: blockStyleFn,
  13005. customStyleMap: customStyleMap,
  13006. customStyleFn: customStyleFn,
  13007. decorator: decorator,
  13008. direction: direction,
  13009. forceSelection: forceSelection,
  13010. key: key,
  13011. offsetKey: offsetKey,
  13012. selection: selection,
  13013. tree: editorState.getBlockTree(key)
  13014. };
  13015. var configForType =
  13016. blockRenderMap.get(blockType) || blockRenderMap.get("unstyled");
  13017. var wrapperTemplate = configForType.wrapper;
  13018. var Element =
  13019. configForType.element || blockRenderMap.get("unstyled").element;
  13020. var depth = _block.getDepth();
  13021. var className = "";
  13022. if (blockStyleFn) {
  13023. className = blockStyleFn(_block);
  13024. }
  13025. // List items are special snowflakes, since we handle nesting and
  13026. // counters manually.
  13027. if (Element === "li") {
  13028. var shouldResetCount =
  13029. lastWrapperTemplate !== wrapperTemplate ||
  13030. currentDepth === null ||
  13031. depth > currentDepth;
  13032. className = joinClasses_1(
  13033. className,
  13034. getListItemClasses(blockType, depth, shouldResetCount, direction)
  13035. );
  13036. }
  13037. var Component = CustomComponent || DraftEditorBlock_react;
  13038. var childProps = {
  13039. className: className,
  13040. "data-block": true,
  13041. "data-editor": editorKey,
  13042. "data-offset-key": offsetKey,
  13043. key: key
  13044. };
  13045. if (customEditable !== undefined) {
  13046. childProps = _extends$3({}, childProps, {
  13047. contentEditable: customEditable,
  13048. suppressContentEditableWarning: true
  13049. });
  13050. }
  13051. var child = React__default.createElement(
  13052. Element,
  13053. childProps,
  13054. React__default.createElement(Component, componentProps)
  13055. );
  13056. processedBlocks.push({
  13057. block: child,
  13058. wrapperTemplate: wrapperTemplate,
  13059. key: key,
  13060. offsetKey: offsetKey
  13061. });
  13062. if (wrapperTemplate) {
  13063. currentDepth = _block.getDepth();
  13064. } else {
  13065. currentDepth = null;
  13066. }
  13067. lastWrapperTemplate = wrapperTemplate;
  13068. }
  13069. // Group contiguous runs of blocks that have the same wrapperTemplate
  13070. var outputBlocks = [];
  13071. for (var _ii = 0; _ii < processedBlocks.length; ) {
  13072. var info = processedBlocks[_ii];
  13073. if (info.wrapperTemplate) {
  13074. var blocks = [];
  13075. do {
  13076. blocks.push(processedBlocks[_ii].block);
  13077. _ii++;
  13078. } while (
  13079. _ii < processedBlocks.length &&
  13080. processedBlocks[_ii].wrapperTemplate === info.wrapperTemplate
  13081. );
  13082. var wrapperElement = React__default.cloneElement(
  13083. info.wrapperTemplate,
  13084. {
  13085. key: info.key + "-wrap",
  13086. "data-offset-key": info.offsetKey
  13087. },
  13088. blocks
  13089. );
  13090. outputBlocks.push(wrapperElement);
  13091. } else {
  13092. outputBlocks.push(info.block);
  13093. _ii++;
  13094. }
  13095. }
  13096. return React__default.createElement(
  13097. "div",
  13098. { "data-contents": "true" },
  13099. outputBlocks
  13100. );
  13101. };
  13102. return DraftEditorContents;
  13103. })(React__default.Component);
  13104. var DraftEditorContentsCore_react = DraftEditorContents;
  13105. var DraftEditorContents_react = DraftEditorContentsCore_react;
  13106. /**
  13107. * Copyright (c) 2013-present, Facebook, Inc.
  13108. *
  13109. * This source code is licensed under the MIT license found in the
  13110. * LICENSE file in the root directory of this source tree.
  13111. *
  13112. */
  13113. var PhotosMimeType = {
  13114. isImage: function isImage(mimeString) {
  13115. return getParts(mimeString)[0] === "image";
  13116. },
  13117. isJpeg: function isJpeg(mimeString) {
  13118. var parts = getParts(mimeString);
  13119. return (
  13120. PhotosMimeType.isImage(mimeString) &&
  13121. // see http://fburl.com/10972194
  13122. (parts[1] === "jpeg" || parts[1] === "pjpeg")
  13123. );
  13124. }
  13125. };
  13126. function getParts(mimeString) {
  13127. return mimeString.split("/");
  13128. }
  13129. var PhotosMimeType_1 = PhotosMimeType;
  13130. /**
  13131. * Copyright (c) 2013-present, Facebook, Inc.
  13132. *
  13133. * This source code is licensed under the MIT license found in the
  13134. * LICENSE file in the root directory of this source tree.
  13135. *
  13136. * @typechecks
  13137. */
  13138. /**
  13139. * Convert array-like objects to arrays.
  13140. *
  13141. * This API assumes the caller knows the contents of the data type. For less
  13142. * well defined inputs use createArrayFromMixed.
  13143. *
  13144. * @param {object|function|filelist} obj
  13145. * @return {array}
  13146. */
  13147. function toArray(obj) {
  13148. var length = obj.length;
  13149. // Some browsers builtin objects can report typeof 'function' (e.g. NodeList
  13150. // in old versions of Safari).
  13151. !(
  13152. !Array.isArray(obj) &&
  13153. (typeof obj === "object" || typeof obj === "function")
  13154. )
  13155. ? process.env.NODE_ENV !== "production"
  13156. ? invariant_1(false, "toArray: Array-like object expected")
  13157. : invariant_1(false)
  13158. : void 0;
  13159. !(typeof length === "number")
  13160. ? process.env.NODE_ENV !== "production"
  13161. ? invariant_1(false, "toArray: Object needs a length property")
  13162. : invariant_1(false)
  13163. : void 0;
  13164. !(length === 0 || length - 1 in obj)
  13165. ? process.env.NODE_ENV !== "production"
  13166. ? invariant_1(false, "toArray: Object should have keys for indices")
  13167. : invariant_1(false)
  13168. : void 0;
  13169. !(typeof obj.callee !== "function")
  13170. ? process.env.NODE_ENV !== "production"
  13171. ? invariant_1(
  13172. false,
  13173. "toArray: Object can't be `arguments`. Use rest params " +
  13174. "(function(...args) {}) or Array.from() instead."
  13175. )
  13176. : invariant_1(false)
  13177. : void 0;
  13178. // Old IE doesn't give collections access to hasOwnProperty. Assume inputs
  13179. // without method will throw during the slice call and skip straight to the
  13180. // fallback.
  13181. if (obj.hasOwnProperty) {
  13182. try {
  13183. return Array.prototype.slice.call(obj);
  13184. } catch (e) {
  13185. // IE < 9 does not support Array#slice on collections objects
  13186. }
  13187. }
  13188. // Fall back to copying key by key. This assumes all keys have a value,
  13189. // so will not preserve sparsely populated inputs.
  13190. var ret = Array(length);
  13191. for (var ii = 0; ii < length; ii++) {
  13192. ret[ii] = obj[ii];
  13193. }
  13194. return ret;
  13195. }
  13196. /**
  13197. * Perform a heuristic test to determine if an object is "array-like".
  13198. *
  13199. * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?"
  13200. * Joshu replied: "Mu."
  13201. *
  13202. * This function determines if its argument has "array nature": it returns
  13203. * true if the argument is an actual array, an `arguments' object, or an
  13204. * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()).
  13205. *
  13206. * It will return false for other array-like objects like Filelist.
  13207. *
  13208. * @param {*} obj
  13209. * @return {boolean}
  13210. */
  13211. function hasArrayNature(obj) {
  13212. return (
  13213. // not null/false
  13214. !!obj &&
  13215. // arrays are objects, NodeLists are functions in Safari
  13216. (typeof obj == "object" || typeof obj == "function") &&
  13217. // quacks like an array
  13218. "length" in obj &&
  13219. // not window
  13220. !("setInterval" in obj) &&
  13221. // no DOM node should be considered an array-like
  13222. // a 'select' element has 'length' and 'item' properties on IE8
  13223. typeof obj.nodeType != "number" &&
  13224. // a real array
  13225. (Array.isArray(obj) ||
  13226. // arguments
  13227. "callee" in obj ||
  13228. // HTMLCollection/NodeList
  13229. "item" in obj)
  13230. );
  13231. }
  13232. /**
  13233. * Ensure that the argument is an array by wrapping it in an array if it is not.
  13234. * Creates a copy of the argument if it is already an array.
  13235. *
  13236. * This is mostly useful idiomatically:
  13237. *
  13238. * var createArrayFromMixed = require('createArrayFromMixed');
  13239. *
  13240. * function takesOneOrMoreThings(things) {
  13241. * things = createArrayFromMixed(things);
  13242. * ...
  13243. * }
  13244. *
  13245. * This allows you to treat `things' as an array, but accept scalars in the API.
  13246. *
  13247. * If you need to convert an array-like object, like `arguments`, into an array
  13248. * use toArray instead.
  13249. *
  13250. * @param {*} obj
  13251. * @return {array}
  13252. */
  13253. function createArrayFromMixed(obj) {
  13254. if (!hasArrayNature(obj)) {
  13255. return [obj];
  13256. } else if (Array.isArray(obj)) {
  13257. return obj.slice();
  13258. } else {
  13259. return toArray(obj);
  13260. }
  13261. }
  13262. var createArrayFromMixed_1 = createArrayFromMixed;
  13263. function _classCallCheck$d(instance, Constructor) {
  13264. if (!(instance instanceof Constructor)) {
  13265. throw new TypeError("Cannot call a class as a function");
  13266. }
  13267. }
  13268. /**
  13269. * Copyright (c) 2013-present, Facebook, Inc.
  13270. *
  13271. * This source code is licensed under the MIT license found in the
  13272. * LICENSE file in the root directory of this source tree.
  13273. *
  13274. * @typechecks
  13275. */
  13276. var CR_LF_REGEX = new RegExp("\r\n", "g");
  13277. var LF_ONLY = "\n";
  13278. var RICH_TEXT_TYPES = {
  13279. "text/rtf": 1,
  13280. "text/html": 1
  13281. };
  13282. /**
  13283. * If DataTransferItem is a file then return the Blob of data.
  13284. *
  13285. * @param {object} item
  13286. * @return {?blob}
  13287. */
  13288. function getFileFromDataTransfer(item) {
  13289. if (item.kind == "file") {
  13290. return item.getAsFile();
  13291. }
  13292. }
  13293. var DataTransfer = (function() {
  13294. /**
  13295. * @param {object} data
  13296. */
  13297. function DataTransfer(data) {
  13298. _classCallCheck$d(this, DataTransfer);
  13299. this.data = data;
  13300. // Types could be DOMStringList or array
  13301. this.types = data.types ? createArrayFromMixed_1(data.types) : [];
  13302. }
  13303. /**
  13304. * Is this likely to be a rich text data transfer?
  13305. *
  13306. * @return {boolean}
  13307. */
  13308. DataTransfer.prototype.isRichText = function isRichText() {
  13309. // If HTML is available, treat this data as rich text. This way, we avoid
  13310. // using a pasted image if it is packaged with HTML -- this may occur with
  13311. // pastes from MS Word, for example. However this is only rich text if
  13312. // there's accompanying text.
  13313. if (this.getHTML() && this.getText()) {
  13314. return true;
  13315. }
  13316. // When an image is copied from a preview window, you end up with two
  13317. // DataTransferItems one of which is a file's metadata as text. Skip those.
  13318. if (this.isImage()) {
  13319. return false;
  13320. }
  13321. return this.types.some(function(type) {
  13322. return RICH_TEXT_TYPES[type];
  13323. });
  13324. };
  13325. /**
  13326. * Get raw text.
  13327. *
  13328. * @return {?string}
  13329. */
  13330. DataTransfer.prototype.getText = function getText() {
  13331. var text;
  13332. if (this.data.getData) {
  13333. if (!this.types.length) {
  13334. text = this.data.getData("Text");
  13335. } else if (this.types.indexOf("text/plain") != -1) {
  13336. text = this.data.getData("text/plain");
  13337. }
  13338. }
  13339. return text ? text.replace(CR_LF_REGEX, LF_ONLY) : null;
  13340. };
  13341. /**
  13342. * Get HTML paste data
  13343. *
  13344. * @return {?string}
  13345. */
  13346. DataTransfer.prototype.getHTML = function getHTML() {
  13347. if (this.data.getData) {
  13348. if (!this.types.length) {
  13349. return this.data.getData("Text");
  13350. } else if (this.types.indexOf("text/html") != -1) {
  13351. return this.data.getData("text/html");
  13352. }
  13353. }
  13354. };
  13355. /**
  13356. * Is this a link data transfer?
  13357. *
  13358. * @return {boolean}
  13359. */
  13360. DataTransfer.prototype.isLink = function isLink() {
  13361. return this.types.some(function(type) {
  13362. return (
  13363. type.indexOf("Url") != -1 ||
  13364. type.indexOf("text/uri-list") != -1 ||
  13365. type.indexOf("text/x-moz-url")
  13366. );
  13367. });
  13368. };
  13369. /**
  13370. * Get a link url.
  13371. *
  13372. * @return {?string}
  13373. */
  13374. DataTransfer.prototype.getLink = function getLink() {
  13375. if (this.data.getData) {
  13376. if (this.types.indexOf("text/x-moz-url") != -1) {
  13377. var url = this.data.getData("text/x-moz-url").split("\n");
  13378. return url[0];
  13379. }
  13380. return this.types.indexOf("text/uri-list") != -1
  13381. ? this.data.getData("text/uri-list")
  13382. : this.data.getData("url");
  13383. }
  13384. return null;
  13385. };
  13386. /**
  13387. * Is this an image data transfer?
  13388. *
  13389. * @return {boolean}
  13390. */
  13391. DataTransfer.prototype.isImage = function isImage() {
  13392. var isImage = this.types.some(function(type) {
  13393. // Firefox will have a type of application/x-moz-file for images during
  13394. // dragging
  13395. return type.indexOf("application/x-moz-file") != -1;
  13396. });
  13397. if (isImage) {
  13398. return true;
  13399. }
  13400. var items = this.getFiles();
  13401. for (var i = 0; i < items.length; i++) {
  13402. var type = items[i].type;
  13403. if (!PhotosMimeType_1.isImage(type)) {
  13404. return false;
  13405. }
  13406. }
  13407. return true;
  13408. };
  13409. DataTransfer.prototype.getCount = function getCount() {
  13410. if (this.data.hasOwnProperty("items")) {
  13411. return this.data.items.length;
  13412. } else if (this.data.hasOwnProperty("mozItemCount")) {
  13413. return this.data.mozItemCount;
  13414. } else if (this.data.files) {
  13415. return this.data.files.length;
  13416. }
  13417. return null;
  13418. };
  13419. /**
  13420. * Get files.
  13421. *
  13422. * @return {array}
  13423. */
  13424. DataTransfer.prototype.getFiles = function getFiles() {
  13425. if (this.data.items) {
  13426. // createArrayFromMixed doesn't properly handle DataTransferItemLists.
  13427. return Array.prototype.slice
  13428. .call(this.data.items)
  13429. .map(getFileFromDataTransfer)
  13430. .filter(emptyFunction_1.thatReturnsArgument);
  13431. } else if (this.data.files) {
  13432. return Array.prototype.slice.call(this.data.files);
  13433. } else {
  13434. return [];
  13435. }
  13436. };
  13437. /**
  13438. * Are there any files to fetch?
  13439. *
  13440. * @return {boolean}
  13441. */
  13442. DataTransfer.prototype.hasFiles = function hasFiles() {
  13443. return this.getFiles().length > 0;
  13444. };
  13445. return DataTransfer;
  13446. })();
  13447. var DataTransfer_1 = DataTransfer;
  13448. /**
  13449. * Copyright (c) 2013-present, Facebook, Inc.
  13450. * All rights reserved.
  13451. *
  13452. * This source code is licensed under the BSD-style license found in the
  13453. * LICENSE file in the root directory of this source tree. An additional grant
  13454. * of patent rights can be found in the PATENTS file in the same directory.
  13455. *
  13456. * @providesModule getSelectionOffsetKeyForNode
  13457. * @format
  13458. *
  13459. */
  13460. /**
  13461. * Get offset key from a node or it's child nodes. Return the first offset key
  13462. * found on the DOM tree of given node.
  13463. */
  13464. function getSelectionOffsetKeyForNode(node) {
  13465. if (node instanceof Element) {
  13466. var offsetKey = node.getAttribute("data-offset-key");
  13467. if (offsetKey) {
  13468. return offsetKey;
  13469. }
  13470. for (var ii = 0; ii < node.childNodes.length; ii++) {
  13471. var childOffsetKey = getSelectionOffsetKeyForNode(node.childNodes[ii]);
  13472. if (childOffsetKey) {
  13473. return childOffsetKey;
  13474. }
  13475. }
  13476. }
  13477. return null;
  13478. }
  13479. var getSelectionOffsetKeyForNode_1 = getSelectionOffsetKeyForNode;
  13480. /**
  13481. * Get the key from the node's nearest offset-aware ancestor.
  13482. */
  13483. function findAncestorOffsetKey(node) {
  13484. var searchNode = node;
  13485. while (searchNode && searchNode !== document.documentElement) {
  13486. var key = getSelectionOffsetKeyForNode_1(searchNode);
  13487. if (key != null) {
  13488. return key;
  13489. }
  13490. searchNode = searchNode.parentNode;
  13491. }
  13492. return null;
  13493. }
  13494. var findAncestorOffsetKey_1 = findAncestorOffsetKey;
  13495. var TEXT_CLIPPING_REGEX = /\.textClipping$/;
  13496. var TEXT_TYPES = {
  13497. "text/plain": true,
  13498. "text/html": true,
  13499. "text/rtf": true
  13500. };
  13501. // Somewhat arbitrary upper bound on text size. Let's not lock up the browser.
  13502. var TEXT_SIZE_UPPER_BOUND = 5000;
  13503. /**
  13504. * Extract the text content from a file list.
  13505. */
  13506. function getTextContentFromFiles(files, callback) {
  13507. var readCount = 0;
  13508. var results = [];
  13509. files.forEach(function(/*blob*/ file) {
  13510. readFile(file, function(/*string*/ text) {
  13511. readCount++;
  13512. text && results.push(text.slice(0, TEXT_SIZE_UPPER_BOUND));
  13513. if (readCount == files.length) {
  13514. callback(results.join("\r"));
  13515. }
  13516. });
  13517. });
  13518. }
  13519. /**
  13520. * todo isaac: Do work to turn html/rtf into a content fragment.
  13521. */
  13522. function readFile(file, callback) {
  13523. if (
  13524. !_commonjsHelpers.commonjsGlobal.FileReader ||
  13525. (file.type && !(file.type in TEXT_TYPES))
  13526. ) {
  13527. callback("");
  13528. return;
  13529. }
  13530. if (file.type === "") {
  13531. var contents = "";
  13532. // Special-case text clippings, which have an empty type but include
  13533. // `.textClipping` in the file name. `readAsText` results in an empty
  13534. // string for text clippings, so we force the file name to serve
  13535. // as the text value for the file.
  13536. if (TEXT_CLIPPING_REGEX.test(file.name)) {
  13537. contents = file.name.replace(TEXT_CLIPPING_REGEX, "");
  13538. }
  13539. callback(contents);
  13540. return;
  13541. }
  13542. var reader = new FileReader();
  13543. reader.onload = function() {
  13544. var result = reader.result;
  13545. !(typeof result === "string")
  13546. ? process.env.NODE_ENV !== "production"
  13547. ? invariant_1(
  13548. false,
  13549. 'We should be calling "FileReader.readAsText" which returns a string'
  13550. )
  13551. : invariant_1(false)
  13552. : void 0;
  13553. callback(result);
  13554. };
  13555. reader.onerror = function() {
  13556. callback("");
  13557. };
  13558. reader.readAsText(file);
  13559. }
  13560. var getTextContentFromFiles_1 = getTextContentFromFiles;
  13561. function getUpdatedSelectionState(
  13562. editorState,
  13563. anchorKey,
  13564. anchorOffset,
  13565. focusKey,
  13566. focusOffset
  13567. ) {
  13568. var selection = nullthrows_1(editorState.getSelection());
  13569. if (process.env.NODE_ENV !== "production") {
  13570. if (!anchorKey || !focusKey) {
  13571. /*eslint-disable no-console */
  13572. console.warn("Invalid selection state.", arguments, editorState.toJS());
  13573. /*eslint-enable no-console */
  13574. return selection;
  13575. }
  13576. }
  13577. var anchorPath = DraftOffsetKey_1.decode(anchorKey);
  13578. var anchorBlockKey = anchorPath.blockKey;
  13579. var anchorLeaf = editorState
  13580. .getBlockTree(anchorBlockKey)
  13581. .getIn([anchorPath.decoratorKey, "leaves", anchorPath.leafKey]);
  13582. var focusPath = DraftOffsetKey_1.decode(focusKey);
  13583. var focusBlockKey = focusPath.blockKey;
  13584. var focusLeaf = editorState
  13585. .getBlockTree(focusBlockKey)
  13586. .getIn([focusPath.decoratorKey, "leaves", focusPath.leafKey]);
  13587. var anchorLeafStart = anchorLeaf.get("start");
  13588. var focusLeafStart = focusLeaf.get("start");
  13589. var anchorBlockOffset = anchorLeaf ? anchorLeafStart + anchorOffset : null;
  13590. var focusBlockOffset = focusLeaf ? focusLeafStart + focusOffset : null;
  13591. var areEqual =
  13592. selection.getAnchorKey() === anchorBlockKey &&
  13593. selection.getAnchorOffset() === anchorBlockOffset &&
  13594. selection.getFocusKey() === focusBlockKey &&
  13595. selection.getFocusOffset() === focusBlockOffset;
  13596. if (areEqual) {
  13597. return selection;
  13598. }
  13599. var isBackward = false;
  13600. if (anchorBlockKey === focusBlockKey) {
  13601. var anchorLeafEnd = anchorLeaf.get("end");
  13602. var focusLeafEnd = focusLeaf.get("end");
  13603. if (focusLeafStart === anchorLeafStart && focusLeafEnd === anchorLeafEnd) {
  13604. isBackward = focusOffset < anchorOffset;
  13605. } else {
  13606. isBackward = focusLeafStart < anchorLeafStart;
  13607. }
  13608. } else {
  13609. var startKey = editorState
  13610. .getCurrentContent()
  13611. .getBlockMap()
  13612. .keySeq()
  13613. .skipUntil(function(v) {
  13614. return v === anchorBlockKey || v === focusBlockKey;
  13615. })
  13616. .first();
  13617. isBackward = startKey === focusBlockKey;
  13618. }
  13619. return selection.merge({
  13620. anchorKey: anchorBlockKey,
  13621. anchorOffset: anchorBlockOffset,
  13622. focusKey: focusBlockKey,
  13623. focusOffset: focusBlockOffset,
  13624. isBackward: isBackward
  13625. });
  13626. }
  13627. var getUpdatedSelectionState_1 = getUpdatedSelectionState;
  13628. /**
  13629. * Get a SelectionState for the supplied mouse event.
  13630. */
  13631. function getSelectionForEvent(event, editorState) {
  13632. var node = null;
  13633. var offset = null;
  13634. if (typeof document.caretRangeFromPoint === "function") {
  13635. var dropRange = document.caretRangeFromPoint(event.x, event.y);
  13636. node = dropRange.startContainer;
  13637. offset = dropRange.startOffset;
  13638. } else if (event.rangeParent) {
  13639. node = event.rangeParent;
  13640. offset = event.rangeOffset;
  13641. } else {
  13642. return null;
  13643. }
  13644. node = nullthrows_1(node);
  13645. offset = nullthrows_1(offset);
  13646. var offsetKey = nullthrows_1(findAncestorOffsetKey_1(node));
  13647. return getUpdatedSelectionState_1(
  13648. editorState,
  13649. offsetKey,
  13650. offset,
  13651. offsetKey,
  13652. offset
  13653. );
  13654. }
  13655. var DraftEditorDragHandler = {
  13656. /**
  13657. * Drag originating from input terminated.
  13658. */
  13659. onDragEnd: function onDragEnd(editor) {
  13660. editor.exitCurrentMode();
  13661. },
  13662. /**
  13663. * Handle data being dropped.
  13664. */
  13665. onDrop: function onDrop(editor, e) {
  13666. var data = new DataTransfer_1(e.nativeEvent.dataTransfer);
  13667. var editorState = editor._latestEditorState;
  13668. var dropSelection = getSelectionForEvent(e.nativeEvent, editorState);
  13669. e.preventDefault();
  13670. editor.exitCurrentMode();
  13671. if (dropSelection == null) {
  13672. return;
  13673. }
  13674. var files = data.getFiles();
  13675. if (files.length > 0) {
  13676. if (
  13677. editor.props.handleDroppedFiles &&
  13678. isEventHandled_1(editor.props.handleDroppedFiles(dropSelection, files))
  13679. ) {
  13680. return;
  13681. }
  13682. getTextContentFromFiles_1(files, function(fileText) {
  13683. fileText &&
  13684. editor.update(
  13685. insertTextAtSelection(editorState, dropSelection, fileText)
  13686. );
  13687. });
  13688. return;
  13689. }
  13690. var dragType = editor._internalDrag ? "internal" : "external";
  13691. if (
  13692. editor.props.handleDrop &&
  13693. isEventHandled_1(editor.props.handleDrop(dropSelection, data, dragType))
  13694. ) {
  13695. return;
  13696. }
  13697. if (editor._internalDrag) {
  13698. editor.update(moveText(editorState, dropSelection));
  13699. return;
  13700. }
  13701. editor.update(
  13702. insertTextAtSelection(editorState, dropSelection, data.getText())
  13703. );
  13704. }
  13705. };
  13706. function moveText(editorState, targetSelection) {
  13707. var newContentState = DraftModifier_1.moveText(
  13708. editorState.getCurrentContent(),
  13709. editorState.getSelection(),
  13710. targetSelection
  13711. );
  13712. return EditorState_1.push(editorState, newContentState, "insert-fragment");
  13713. }
  13714. /**
  13715. * Insert text at a specified selection.
  13716. */
  13717. function insertTextAtSelection(editorState, selection, text) {
  13718. var newContentState = DraftModifier_1.insertText(
  13719. editorState.getCurrentContent(),
  13720. selection,
  13721. text,
  13722. editorState.getCurrentInlineStyle()
  13723. );
  13724. return EditorState_1.push(editorState, newContentState, "insert-fragment");
  13725. }
  13726. var DraftEditorDragHandler_1 = DraftEditorDragHandler;
  13727. (function(global, undefined$1) {
  13728. if (global.setImmediate) {
  13729. return;
  13730. }
  13731. var nextHandle = 1; // Spec says greater than zero
  13732. var tasksByHandle = {};
  13733. var currentlyRunningATask = false;
  13734. var doc = global.document;
  13735. var registerImmediate;
  13736. function setImmediate(callback) {
  13737. // Callback can either be a function or a string
  13738. if (typeof callback !== "function") {
  13739. callback = new Function("" + callback);
  13740. }
  13741. // Copy function arguments
  13742. var args = new Array(arguments.length - 1);
  13743. for (var i = 0; i < args.length; i++) {
  13744. args[i] = arguments[i + 1];
  13745. }
  13746. // Store and register the task
  13747. var task = { callback: callback, args: args };
  13748. tasksByHandle[nextHandle] = task;
  13749. registerImmediate(nextHandle);
  13750. return nextHandle++;
  13751. }
  13752. function clearImmediate(handle) {
  13753. delete tasksByHandle[handle];
  13754. }
  13755. function run(task) {
  13756. var callback = task.callback;
  13757. var args = task.args;
  13758. switch (args.length) {
  13759. case 0:
  13760. callback();
  13761. break;
  13762. case 1:
  13763. callback(args[0]);
  13764. break;
  13765. case 2:
  13766. callback(args[0], args[1]);
  13767. break;
  13768. case 3:
  13769. callback(args[0], args[1], args[2]);
  13770. break;
  13771. default:
  13772. callback.apply(undefined$1, args);
  13773. break;
  13774. }
  13775. }
  13776. function runIfPresent(handle) {
  13777. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  13778. // So if we're currently running a task, we'll need to delay this invocation.
  13779. if (currentlyRunningATask) {
  13780. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  13781. // "too much recursion" error.
  13782. setTimeout(runIfPresent, 0, handle);
  13783. } else {
  13784. var task = tasksByHandle[handle];
  13785. if (task) {
  13786. currentlyRunningATask = true;
  13787. try {
  13788. run(task);
  13789. } finally {
  13790. clearImmediate(handle);
  13791. currentlyRunningATask = false;
  13792. }
  13793. }
  13794. }
  13795. }
  13796. function installNextTickImplementation() {
  13797. registerImmediate = function(handle) {
  13798. process.nextTick(function() {
  13799. runIfPresent(handle);
  13800. });
  13801. };
  13802. }
  13803. function canUsePostMessage() {
  13804. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  13805. // where `global.postMessage` means something completely different and can't be used for this purpose.
  13806. if (global.postMessage && !global.importScripts) {
  13807. var postMessageIsAsynchronous = true;
  13808. var oldOnMessage = global.onmessage;
  13809. global.onmessage = function() {
  13810. postMessageIsAsynchronous = false;
  13811. };
  13812. global.postMessage("", "*");
  13813. global.onmessage = oldOnMessage;
  13814. return postMessageIsAsynchronous;
  13815. }
  13816. }
  13817. function installPostMessageImplementation() {
  13818. // Installs an event handler on `global` for the `message` event: see
  13819. // * https://developer.mozilla.org/en/DOM/window.postMessage
  13820. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  13821. var messagePrefix = "setImmediate$" + Math.random() + "$";
  13822. var onGlobalMessage = function(event) {
  13823. if (
  13824. event.source === global &&
  13825. typeof event.data === "string" &&
  13826. event.data.indexOf(messagePrefix) === 0
  13827. ) {
  13828. runIfPresent(+event.data.slice(messagePrefix.length));
  13829. }
  13830. };
  13831. if (global.addEventListener) {
  13832. global.addEventListener("message", onGlobalMessage, false);
  13833. } else {
  13834. global.attachEvent("onmessage", onGlobalMessage);
  13835. }
  13836. registerImmediate = function(handle) {
  13837. global.postMessage(messagePrefix + handle, "*");
  13838. };
  13839. }
  13840. function installMessageChannelImplementation() {
  13841. var channel = new MessageChannel();
  13842. channel.port1.onmessage = function(event) {
  13843. var handle = event.data;
  13844. runIfPresent(handle);
  13845. };
  13846. registerImmediate = function(handle) {
  13847. channel.port2.postMessage(handle);
  13848. };
  13849. }
  13850. function installReadyStateChangeImplementation() {
  13851. var html = doc.documentElement;
  13852. registerImmediate = function(handle) {
  13853. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  13854. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  13855. var script = doc.createElement("script");
  13856. script.onreadystatechange = function() {
  13857. runIfPresent(handle);
  13858. script.onreadystatechange = null;
  13859. html.removeChild(script);
  13860. script = null;
  13861. };
  13862. html.appendChild(script);
  13863. };
  13864. }
  13865. function installSetTimeoutImplementation() {
  13866. registerImmediate = function(handle) {
  13867. setTimeout(runIfPresent, 0, handle);
  13868. };
  13869. }
  13870. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  13871. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  13872. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  13873. // Don't get fooled by e.g. browserify environments.
  13874. if ({}.toString.call(global.process) === "[object process]") {
  13875. // For Node.js before 0.9
  13876. installNextTickImplementation();
  13877. } else if (canUsePostMessage()) {
  13878. // For non-IE10 modern browsers
  13879. installPostMessageImplementation();
  13880. } else if (global.MessageChannel) {
  13881. // For web workers, where supported
  13882. installMessageChannelImplementation();
  13883. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  13884. // For IE 6–8
  13885. installReadyStateChangeImplementation();
  13886. } else {
  13887. // For older browsers
  13888. installSetTimeoutImplementation();
  13889. }
  13890. attachTo.setImmediate = setImmediate;
  13891. attachTo.clearImmediate = clearImmediate;
  13892. })(
  13893. typeof self === "undefined"
  13894. ? typeof _commonjsHelpers.commonjsGlobal === "undefined"
  13895. ? _commonjsHelpers.commonjsGlobal
  13896. : _commonjsHelpers.commonjsGlobal
  13897. : self
  13898. );
  13899. // setimmediate adds setImmediate to the global. We want to make sure we export
  13900. // the actual function.
  13901. var setImmediate = _commonjsHelpers.commonjsGlobal.setImmediate;
  13902. // When nothing is focused, Firefox regards two characters, `'` and `/`, as
  13903. // commands that should open and focus the "quickfind" search bar. This should
  13904. // *never* happen while a contenteditable is focused, but as of v28, it
  13905. // sometimes does, even when the keypress event target is the contenteditable.
  13906. // This breaks the input. Special case these characters to ensure that when
  13907. // they are typed, we prevent default on the event to make sure not to
  13908. // trigger quickfind.
  13909. var FF_QUICKFIND_CHAR = "'";
  13910. var FF_QUICKFIND_LINK_CHAR = "/";
  13911. var isFirefox = UserAgent_1.isBrowser("Firefox");
  13912. function mustPreventDefaultForCharacter(character) {
  13913. return (
  13914. isFirefox &&
  13915. (character == FF_QUICKFIND_CHAR || character == FF_QUICKFIND_LINK_CHAR)
  13916. );
  13917. }
  13918. /**
  13919. * Replace the current selection with the specified text string, with the
  13920. * inline style and entity key applied to the newly inserted text.
  13921. */
  13922. function replaceText(editorState, text, inlineStyle, entityKey) {
  13923. var contentState = DraftModifier_1.replaceText(
  13924. editorState.getCurrentContent(),
  13925. editorState.getSelection(),
  13926. text,
  13927. inlineStyle,
  13928. entityKey
  13929. );
  13930. return EditorState_1.push(editorState, contentState, "insert-characters");
  13931. }
  13932. /**
  13933. * When `onBeforeInput` executes, the browser is attempting to insert a
  13934. * character into the editor. Apply this character data to the document,
  13935. * allowing native insertion if possible.
  13936. *
  13937. * Native insertion is encouraged in order to limit re-rendering and to
  13938. * preserve spellcheck highlighting, which disappears or flashes if re-render
  13939. * occurs on the relevant text nodes.
  13940. */
  13941. function editOnBeforeInput(editor, e) {
  13942. if (editor._pendingStateFromBeforeInput !== undefined) {
  13943. editor.update(editor._pendingStateFromBeforeInput);
  13944. editor._pendingStateFromBeforeInput = undefined;
  13945. }
  13946. var editorState = editor._latestEditorState;
  13947. var chars = e.data;
  13948. // In some cases (ex: IE ideographic space insertion) no character data
  13949. // is provided. There's nothing to do when this happens.
  13950. if (!chars) {
  13951. return;
  13952. }
  13953. // Allow the top-level component to handle the insertion manually. This is
  13954. // useful when triggering interesting behaviors for a character insertion,
  13955. // Simple examples: replacing a raw text ':)' with a smile emoji or image
  13956. // decorator, or setting a block to be a list item after typing '- ' at the
  13957. // start of the block.
  13958. if (
  13959. editor.props.handleBeforeInput &&
  13960. isEventHandled_1(editor.props.handleBeforeInput(chars, editorState))
  13961. ) {
  13962. e.preventDefault();
  13963. return;
  13964. }
  13965. // If selection is collapsed, conditionally allow native behavior. This
  13966. // reduces re-renders and preserves spellcheck highlighting. If the selection
  13967. // is not collapsed, we will re-render.
  13968. var selection = editorState.getSelection();
  13969. var selectionStart = selection.getStartOffset();
  13970. var selectionEnd = selection.getEndOffset();
  13971. var anchorKey = selection.getAnchorKey();
  13972. if (!selection.isCollapsed()) {
  13973. e.preventDefault();
  13974. // If the currently selected text matches what the user is trying to
  13975. // replace it with, let's just update the `SelectionState`. If not, update
  13976. // the `ContentState` with the new text.
  13977. var currentlySelectedChars = editorState
  13978. .getCurrentContent()
  13979. .getPlainText()
  13980. .slice(selectionStart, selectionEnd);
  13981. if (chars === currentlySelectedChars) {
  13982. editor.update(
  13983. EditorState_1.forceSelection(
  13984. editorState,
  13985. selection.merge({
  13986. focusOffset: selectionEnd
  13987. })
  13988. )
  13989. );
  13990. } else {
  13991. editor.update(
  13992. replaceText(
  13993. editorState,
  13994. chars,
  13995. editorState.getCurrentInlineStyle(),
  13996. getEntityKeyForSelection_1(
  13997. editorState.getCurrentContent(),
  13998. editorState.getSelection()
  13999. )
  14000. )
  14001. );
  14002. }
  14003. return;
  14004. }
  14005. var newEditorState = replaceText(
  14006. editorState,
  14007. chars,
  14008. editorState.getCurrentInlineStyle(),
  14009. getEntityKeyForSelection_1(
  14010. editorState.getCurrentContent(),
  14011. editorState.getSelection()
  14012. )
  14013. );
  14014. // Bunch of different cases follow where we need to prevent native insertion.
  14015. var mustPreventNative = false;
  14016. if (!mustPreventNative) {
  14017. // Browsers tend to insert text in weird places in the DOM when typing at
  14018. // the start of a leaf, so we'll handle it ourselves.
  14019. mustPreventNative = isSelectionAtLeafStart_1(
  14020. editor._latestCommittedEditorState
  14021. );
  14022. }
  14023. if (!mustPreventNative) {
  14024. // Chrome will also split up a node into two pieces if it contains a Tab
  14025. // char, for no explicable reason. Seemingly caused by this commit:
  14026. // https://chromium.googlesource.com/chromium/src/+/013ac5eaf3%5E%21/
  14027. var nativeSelection = _commonjsHelpers.commonjsGlobal.getSelection();
  14028. // Selection is necessarily collapsed at this point due to earlier check.
  14029. if (
  14030. nativeSelection.anchorNode &&
  14031. nativeSelection.anchorNode.nodeType === Node.TEXT_NODE
  14032. ) {
  14033. // See isTabHTMLSpanElement in chromium EditingUtilities.cpp.
  14034. var parentNode = nativeSelection.anchorNode.parentNode;
  14035. mustPreventNative =
  14036. parentNode.nodeName === "SPAN" &&
  14037. parentNode.firstChild.nodeType === Node.TEXT_NODE &&
  14038. parentNode.firstChild.nodeValue.indexOf("\t") !== -1;
  14039. }
  14040. }
  14041. if (!mustPreventNative) {
  14042. // Check the old and new "fingerprints" of the current block to determine
  14043. // whether this insertion requires any addition or removal of text nodes,
  14044. // in which case we would prevent the native character insertion.
  14045. var originalFingerprint = BlockTree_1.getFingerprint(
  14046. editorState.getBlockTree(anchorKey)
  14047. );
  14048. var newFingerprint = BlockTree_1.getFingerprint(
  14049. newEditorState.getBlockTree(anchorKey)
  14050. );
  14051. mustPreventNative = originalFingerprint !== newFingerprint;
  14052. }
  14053. if (!mustPreventNative) {
  14054. mustPreventNative = mustPreventDefaultForCharacter(chars);
  14055. }
  14056. if (!mustPreventNative) {
  14057. mustPreventNative =
  14058. nullthrows_1(newEditorState.getDirectionMap()).get(anchorKey) !==
  14059. nullthrows_1(editorState.getDirectionMap()).get(anchorKey);
  14060. }
  14061. if (mustPreventNative) {
  14062. e.preventDefault();
  14063. editor.update(newEditorState);
  14064. return;
  14065. }
  14066. // We made it all the way! Let the browser do its thing and insert the char.
  14067. newEditorState = EditorState_1.set(newEditorState, {
  14068. nativelyRenderedContent: newEditorState.getCurrentContent()
  14069. });
  14070. // The native event is allowed to occur. To allow user onChange handlers to
  14071. // change the inserted text, we wait until the text is actually inserted
  14072. // before we actually update our state. That way when we rerender, the text
  14073. // we see in the DOM will already have been inserted properly.
  14074. editor._pendingStateFromBeforeInput = newEditorState;
  14075. setImmediate(function() {
  14076. if (editor._pendingStateFromBeforeInput !== undefined) {
  14077. editor.update(editor._pendingStateFromBeforeInput);
  14078. editor._pendingStateFromBeforeInput = undefined;
  14079. }
  14080. });
  14081. }
  14082. var editOnBeforeInput_1 = editOnBeforeInput;
  14083. function editOnBlur(editor, e) {
  14084. // In a contentEditable element, when you select a range and then click
  14085. // another active element, this does trigger a `blur` event but will not
  14086. // remove the DOM selection from the contenteditable.
  14087. // This is consistent across all browsers, but we prefer that the editor
  14088. // behave like a textarea, where a `blur` event clears the DOM selection.
  14089. // We therefore force the issue to be certain, checking whether the active
  14090. // element is `body` to force it when blurring occurs within the window (as
  14091. // opposed to clicking to another tab or window).
  14092. if (getActiveElement_1() === document.body) {
  14093. var _selection = _commonjsHelpers.commonjsGlobal.getSelection();
  14094. var editorNode = editor.editor;
  14095. if (
  14096. _selection.rangeCount === 1 &&
  14097. containsNode_1(editorNode, _selection.anchorNode) &&
  14098. containsNode_1(editorNode, _selection.focusNode)
  14099. ) {
  14100. _selection.removeAllRanges();
  14101. }
  14102. }
  14103. var editorState = editor._latestEditorState;
  14104. var currentSelection = editorState.getSelection();
  14105. if (!currentSelection.getHasFocus()) {
  14106. return;
  14107. }
  14108. var selection = currentSelection.set("hasFocus", false);
  14109. editor.props.onBlur && editor.props.onBlur(e);
  14110. editor.update(EditorState_1.acceptSelection(editorState, selection));
  14111. }
  14112. var editOnBlur_1 = editOnBlur;
  14113. /**
  14114. * The user has begun using an IME input system. Switching to `composite` mode
  14115. * allows handling composition input and disables other edit behavior.
  14116. */
  14117. function editOnCompositionStart(editor, e) {
  14118. editor.setMode("composite");
  14119. editor.update(
  14120. EditorState_1.set(editor._latestEditorState, { inCompositionMode: true })
  14121. );
  14122. // Allow composition handler to interpret the compositionstart event
  14123. editor._onCompositionStart(e);
  14124. }
  14125. var editOnCompositionStart_1 = editOnCompositionStart;
  14126. function getFragmentFromSelection(editorState) {
  14127. var selectionState = editorState.getSelection();
  14128. if (selectionState.isCollapsed()) {
  14129. return null;
  14130. }
  14131. return getContentStateFragment_1(
  14132. editorState.getCurrentContent(),
  14133. selectionState
  14134. );
  14135. }
  14136. var getFragmentFromSelection_1 = getFragmentFromSelection;
  14137. /**
  14138. * If we have a selection, create a ContentState fragment and store
  14139. * it in our internal clipboard. Subsequent paste events will use this
  14140. * fragment if no external clipboard data is supplied.
  14141. */
  14142. function editOnCopy(editor, e) {
  14143. var editorState = editor._latestEditorState;
  14144. var selection = editorState.getSelection();
  14145. // No selection, so there's nothing to copy.
  14146. if (selection.isCollapsed()) {
  14147. e.preventDefault();
  14148. return;
  14149. }
  14150. editor.setClipboard(getFragmentFromSelection_1(editor._latestEditorState));
  14151. }
  14152. var editOnCopy_1 = editOnCopy;
  14153. /**
  14154. * On `cut` events, native behavior is allowed to occur so that the system
  14155. * clipboard is set properly. This means that we need to take steps to recover
  14156. * the editor DOM state after the `cut` has occurred in order to maintain
  14157. * control of the component.
  14158. *
  14159. * In addition, we can keep a copy of the removed fragment, including all
  14160. * styles and entities, for use as an internal paste.
  14161. */
  14162. function editOnCut(editor, e) {
  14163. var editorState = editor._latestEditorState;
  14164. var selection = editorState.getSelection();
  14165. var element = e.target;
  14166. var scrollPosition = void 0;
  14167. // No selection, so there's nothing to cut.
  14168. if (selection.isCollapsed()) {
  14169. e.preventDefault();
  14170. return;
  14171. }
  14172. // Track the current scroll position so that it can be forced back in place
  14173. // after the editor regains control of the DOM.
  14174. if (element instanceof Node) {
  14175. scrollPosition = getScrollPosition_1(Style_1.getScrollParent(element));
  14176. }
  14177. var fragment = getFragmentFromSelection_1(editorState);
  14178. editor.setClipboard(fragment);
  14179. // Set `cut` mode to disable all event handling temporarily.
  14180. editor.setMode("cut");
  14181. // Let native `cut` behavior occur, then recover control.
  14182. setTimeout(function() {
  14183. editor.restoreEditorDOM(scrollPosition);
  14184. editor.exitCurrentMode();
  14185. editor.update(removeFragment(editorState));
  14186. }, 0);
  14187. }
  14188. function removeFragment(editorState) {
  14189. var newContent = DraftModifier_1.removeRange(
  14190. editorState.getCurrentContent(),
  14191. editorState.getSelection(),
  14192. "forward"
  14193. );
  14194. return EditorState_1.push(editorState, newContent, "remove-range");
  14195. }
  14196. var editOnCut_1 = editOnCut;
  14197. /**
  14198. * Copyright (c) 2013-present, Facebook, Inc.
  14199. * All rights reserved.
  14200. *
  14201. * This source code is licensed under the BSD-style license found in the
  14202. * LICENSE file in the root directory of this source tree. An additional grant
  14203. * of patent rights can be found in the PATENTS file in the same directory.
  14204. *
  14205. * @providesModule editOnDragOver
  14206. * @format
  14207. *
  14208. */
  14209. /**
  14210. * Drag behavior has begun from outside the editor element.
  14211. */
  14212. function editOnDragOver(editor, e) {
  14213. editor._internalDrag = false;
  14214. editor.setMode("drag");
  14215. e.preventDefault();
  14216. }
  14217. var editOnDragOver_1 = editOnDragOver;
  14218. /**
  14219. * Copyright (c) 2013-present, Facebook, Inc.
  14220. * All rights reserved.
  14221. *
  14222. * This source code is licensed under the BSD-style license found in the
  14223. * LICENSE file in the root directory of this source tree. An additional grant
  14224. * of patent rights can be found in the PATENTS file in the same directory.
  14225. *
  14226. * @providesModule editOnDragStart
  14227. * @format
  14228. *
  14229. */
  14230. /**
  14231. * A `dragstart` event has begun within the text editor component.
  14232. */
  14233. function editOnDragStart(editor) {
  14234. editor._internalDrag = true;
  14235. editor.setMode("drag");
  14236. }
  14237. var editOnDragStart_1 = editOnDragStart;
  14238. function editOnFocus(editor, e) {
  14239. var editorState = editor._latestEditorState;
  14240. var currentSelection = editorState.getSelection();
  14241. if (currentSelection.getHasFocus()) {
  14242. return;
  14243. }
  14244. var selection = currentSelection.set("hasFocus", true);
  14245. editor.props.onFocus && editor.props.onFocus(e);
  14246. // When the tab containing this text editor is hidden and the user does a
  14247. // find-in-page in a _different_ tab, Chrome on Mac likes to forget what the
  14248. // selection was right after sending this focus event and (if you let it)
  14249. // moves the cursor back to the beginning of the editor, so we force the
  14250. // selection here instead of simply accepting it in order to preserve the
  14251. // old cursor position. See https://crbug.com/540004.
  14252. // But it looks like this is fixed in Chrome 60.0.3081.0.
  14253. // Other browsers also don't have this bug, so we prefer to acceptSelection
  14254. // when possible, to ensure that unfocusing and refocusing a Draft editor
  14255. // doesn't preserve the selection, matching how textareas work.
  14256. if (UserAgent_1.isBrowser("Chrome < 60.0.3081.0")) {
  14257. editor.update(EditorState_1.forceSelection(editorState, selection));
  14258. } else {
  14259. editor.update(EditorState_1.acceptSelection(editorState, selection));
  14260. }
  14261. }
  14262. var editOnFocus_1 = editOnFocus;
  14263. var isGecko = UserAgent_1.isEngine("Gecko");
  14264. var DOUBLE_NEWLINE = "\n\n";
  14265. /**
  14266. * This function is intended to handle spellcheck and autocorrect changes,
  14267. * which occur in the DOM natively without any opportunity to observe or
  14268. * interpret the changes before they occur.
  14269. *
  14270. * The `input` event fires in contentEditable elements reliably for non-IE
  14271. * browsers, immediately after changes occur to the editor DOM. Since our other
  14272. * handlers override or otherwise handle cover other varieties of text input,
  14273. * the DOM state should match the model in all controlled input cases. Thus,
  14274. * when an `input` change leads to a DOM/model mismatch, the change should be
  14275. * due to a spellcheck change, and we can incorporate it into our model.
  14276. */
  14277. function editOnInput(editor) {
  14278. if (editor._pendingStateFromBeforeInput !== undefined) {
  14279. editor.update(editor._pendingStateFromBeforeInput);
  14280. editor._pendingStateFromBeforeInput = undefined;
  14281. }
  14282. var domSelection = _commonjsHelpers.commonjsGlobal.getSelection();
  14283. var anchorNode = domSelection.anchorNode,
  14284. isCollapsed = domSelection.isCollapsed;
  14285. var isNotTextNode = anchorNode.nodeType !== Node.TEXT_NODE;
  14286. var isNotTextOrElementNode =
  14287. anchorNode.nodeType !== Node.TEXT_NODE &&
  14288. anchorNode.nodeType !== Node.ELEMENT_NODE;
  14289. {
  14290. if (isNotTextOrElementNode) {
  14291. // TODO: (t16149272) figure out context for this change
  14292. return;
  14293. }
  14294. }
  14295. if (
  14296. anchorNode.nodeType === Node.TEXT_NODE &&
  14297. (anchorNode.previousSibling !== null || anchorNode.nextSibling !== null)
  14298. ) {
  14299. // When typing at the beginning of a visual line, Chrome splits the text
  14300. // nodes into two. Why? No one knows. This commit is suspicious:
  14301. // https://chromium.googlesource.com/chromium/src/+/a3b600981286b135632371477f902214c55a1724
  14302. // To work around, we'll merge the sibling text nodes back into this one.
  14303. var span = anchorNode.parentNode;
  14304. anchorNode.nodeValue = span.textContent;
  14305. for (
  14306. var child = span.firstChild;
  14307. child !== null;
  14308. child = child.nextSibling
  14309. ) {
  14310. if (child !== anchorNode) {
  14311. span.removeChild(child);
  14312. }
  14313. }
  14314. }
  14315. var domText = anchorNode.textContent;
  14316. var editorState = editor._latestEditorState;
  14317. var offsetKey = nullthrows_1(findAncestorOffsetKey_1(anchorNode));
  14318. var _DraftOffsetKey$decod = DraftOffsetKey_1.decode(offsetKey),
  14319. blockKey = _DraftOffsetKey$decod.blockKey,
  14320. decoratorKey = _DraftOffsetKey$decod.decoratorKey,
  14321. leafKey = _DraftOffsetKey$decod.leafKey;
  14322. var _editorState$getBlock = editorState
  14323. .getBlockTree(blockKey)
  14324. .getIn([decoratorKey, "leaves", leafKey]),
  14325. start = _editorState$getBlock.start,
  14326. end = _editorState$getBlock.end;
  14327. var content = editorState.getCurrentContent();
  14328. var block = content.getBlockForKey(blockKey);
  14329. var modelText = block.getText().slice(start, end);
  14330. // Special-case soft newlines here. If the DOM text ends in a soft newline,
  14331. // we will have manually inserted an extra soft newline in DraftEditorLeaf.
  14332. // We want to remove this extra newline for the purpose of our comparison
  14333. // of DOM and model text.
  14334. if (domText.endsWith(DOUBLE_NEWLINE)) {
  14335. domText = domText.slice(0, -1);
  14336. }
  14337. // No change -- the DOM is up to date. Nothing to do here.
  14338. if (domText === modelText) {
  14339. // This can be buggy for some Android keyboards because they don't fire
  14340. // standard onkeydown/pressed events and only fired editOnInput
  14341. // so domText is already changed by the browser and ends up being equal
  14342. // to modelText unexpectedly
  14343. return;
  14344. }
  14345. var selection = editorState.getSelection();
  14346. // We'll replace the entire leaf with the text content of the target.
  14347. var targetRange = selection.merge({
  14348. anchorOffset: start,
  14349. focusOffset: end,
  14350. isBackward: false
  14351. });
  14352. var entityKey = block.getEntityAt(start);
  14353. var entity = entityKey && content.getEntity(entityKey);
  14354. var entityType = entity && entity.getMutability();
  14355. var preserveEntity = entityType === "MUTABLE";
  14356. // Immutable or segmented entities cannot properly be handled by the
  14357. // default browser undo, so we have to use a different change type to
  14358. // force using our internal undo method instead of falling through to the
  14359. // native browser undo.
  14360. var changeType = preserveEntity ? "spellcheck-change" : "apply-entity";
  14361. var newContent = DraftModifier_1.replaceText(
  14362. content,
  14363. targetRange,
  14364. domText,
  14365. block.getInlineStyleAt(start),
  14366. preserveEntity ? block.getEntityAt(start) : null
  14367. );
  14368. var anchorOffset, focusOffset, startOffset, endOffset;
  14369. if (isGecko) {
  14370. // Firefox selection does not change while the context menu is open, so
  14371. // we preserve the anchor and focus values of the DOM selection.
  14372. anchorOffset = domSelection.anchorOffset;
  14373. focusOffset = domSelection.focusOffset;
  14374. startOffset = start + Math.min(anchorOffset, focusOffset);
  14375. endOffset = startOffset + Math.abs(anchorOffset - focusOffset);
  14376. anchorOffset = startOffset;
  14377. focusOffset = endOffset;
  14378. } else {
  14379. // Browsers other than Firefox may adjust DOM selection while the context
  14380. // menu is open, and Safari autocorrect is prone to providing an inaccurate
  14381. // DOM selection. Don't trust it. Instead, use our existing SelectionState
  14382. // and adjust it based on the number of characters changed during the
  14383. // mutation.
  14384. var charDelta = domText.length - modelText.length;
  14385. startOffset = selection.getStartOffset();
  14386. endOffset = selection.getEndOffset();
  14387. anchorOffset = isCollapsed ? endOffset + charDelta : startOffset;
  14388. focusOffset = endOffset + charDelta;
  14389. }
  14390. // Segmented entities are completely or partially removed when their
  14391. // text content changes. For this case we do not want any text to be selected
  14392. // after the change, so we are not merging the selection.
  14393. var contentWithAdjustedDOMSelection = newContent.merge({
  14394. selectionBefore: content.getSelectionAfter(),
  14395. selectionAfter: selection.merge({
  14396. anchorOffset: anchorOffset,
  14397. focusOffset: focusOffset
  14398. })
  14399. });
  14400. editor.update(
  14401. EditorState_1.push(editorState, contentWithAdjustedDOMSelection, changeType)
  14402. );
  14403. }
  14404. var editOnInput_1 = editOnInput;
  14405. var isOSX = UserAgent_1.isPlatform("Mac OS X");
  14406. var KeyBindingUtil = {
  14407. /**
  14408. * Check whether the ctrlKey modifier is *not* being used in conjunction with
  14409. * the altKey modifier. If they are combined, the result is an `altGraph`
  14410. * key modifier, which should not be handled by this set of key bindings.
  14411. */
  14412. isCtrlKeyCommand: function isCtrlKeyCommand(e) {
  14413. return !!e.ctrlKey && !e.altKey;
  14414. },
  14415. isOptionKeyCommand: function isOptionKeyCommand(e) {
  14416. return isOSX && e.altKey;
  14417. },
  14418. hasCommandModifier: function hasCommandModifier(e) {
  14419. return isOSX
  14420. ? !!e.metaKey && !e.altKey
  14421. : KeyBindingUtil.isCtrlKeyCommand(e);
  14422. }
  14423. };
  14424. var KeyBindingUtil_1 = KeyBindingUtil;
  14425. var clipboard = null;
  14426. /**
  14427. * Some systems offer a "secondary" clipboard to allow quick internal cut
  14428. * and paste behavior. For instance, Ctrl+K (cut) and Ctrl+Y (paste).
  14429. */
  14430. var SecondaryClipboard = {
  14431. cut: function cut(editorState) {
  14432. var content = editorState.getCurrentContent();
  14433. var selection = editorState.getSelection();
  14434. var targetRange = null;
  14435. if (selection.isCollapsed()) {
  14436. var anchorKey = selection.getAnchorKey();
  14437. var blockEnd = content.getBlockForKey(anchorKey).getLength();
  14438. if (blockEnd === selection.getAnchorOffset()) {
  14439. return editorState;
  14440. }
  14441. targetRange = selection.set("focusOffset", blockEnd);
  14442. } else {
  14443. targetRange = selection;
  14444. }
  14445. targetRange = nullthrows_1(targetRange);
  14446. clipboard = getContentStateFragment_1(content, targetRange);
  14447. var afterRemoval = DraftModifier_1.removeRange(
  14448. content,
  14449. targetRange,
  14450. "forward"
  14451. );
  14452. if (afterRemoval === content) {
  14453. return editorState;
  14454. }
  14455. return EditorState_1.push(editorState, afterRemoval, "remove-range");
  14456. },
  14457. paste: function paste(editorState) {
  14458. if (!clipboard) {
  14459. return editorState;
  14460. }
  14461. var newContent = DraftModifier_1.replaceWithFragment(
  14462. editorState.getCurrentContent(),
  14463. editorState.getSelection(),
  14464. clipboard
  14465. );
  14466. return EditorState_1.push(editorState, newContent, "insert-fragment");
  14467. }
  14468. };
  14469. var SecondaryClipboard_1 = SecondaryClipboard;
  14470. // These two ranges are consecutive so anything in [HIGH_START, LOW_END] is a
  14471. // surrogate code unit.
  14472. var SURROGATE_HIGH_START = 0xd800;
  14473. var SURROGATE_HIGH_END = 0xdbff;
  14474. var SURROGATE_LOW_START = 0xdc00;
  14475. var SURROGATE_LOW_END = 0xdfff;
  14476. var SURROGATE_UNITS_REGEX = /[\uD800-\uDFFF]/;
  14477. /**
  14478. * @param {number} codeUnit A Unicode code-unit, in range [0, 0x10FFFF]
  14479. * @return {boolean} Whether code-unit is in a surrogate (hi/low) range
  14480. */
  14481. function isCodeUnitInSurrogateRange(codeUnit) {
  14482. return SURROGATE_HIGH_START <= codeUnit && codeUnit <= SURROGATE_LOW_END;
  14483. }
  14484. /**
  14485. * Returns whether the two characters starting at `index` form a surrogate pair.
  14486. * For example, given the string s = "\uD83D\uDE0A", (s, 0) returns true and
  14487. * (s, 1) returns false.
  14488. *
  14489. * @param {string} str
  14490. * @param {number} index
  14491. * @return {boolean}
  14492. */
  14493. function isSurrogatePair(str, index) {
  14494. !(0 <= index && index < str.length)
  14495. ? process.env.NODE_ENV !== "production"
  14496. ? invariant_1(
  14497. false,
  14498. "isSurrogatePair: Invalid index %s for string length %s.",
  14499. index,
  14500. str.length
  14501. )
  14502. : invariant_1(false)
  14503. : void 0;
  14504. if (index + 1 === str.length) {
  14505. return false;
  14506. }
  14507. var first = str.charCodeAt(index);
  14508. var second = str.charCodeAt(index + 1);
  14509. return (
  14510. SURROGATE_HIGH_START <= first &&
  14511. first <= SURROGATE_HIGH_END &&
  14512. SURROGATE_LOW_START <= second &&
  14513. second <= SURROGATE_LOW_END
  14514. );
  14515. }
  14516. /**
  14517. * @param {string} str Non-empty string
  14518. * @return {boolean} True if the input includes any surrogate code units
  14519. */
  14520. function hasSurrogateUnit(str) {
  14521. return SURROGATE_UNITS_REGEX.test(str);
  14522. }
  14523. /**
  14524. * Return the length of the original Unicode character at given position in the
  14525. * String by looking into the UTF-16 code unit; that is equal to 1 for any
  14526. * non-surrogate characters in BMP ([U+0000..U+D7FF] and [U+E000, U+FFFF]); and
  14527. * returns 2 for the hi/low surrogates ([U+D800..U+DFFF]), which are in fact
  14528. * representing non-BMP characters ([U+10000..U+10FFFF]).
  14529. *
  14530. * Examples:
  14531. * - '\u0020' => 1
  14532. * - '\u3020' => 1
  14533. * - '\uD835' => 2
  14534. * - '\uD835\uDDEF' => 2
  14535. * - '\uDDEF' => 2
  14536. *
  14537. * @param {string} str Non-empty string
  14538. * @param {number} pos Position in the string to look for one code unit
  14539. * @return {number} Number 1 or 2
  14540. */
  14541. function getUTF16Length(str, pos) {
  14542. return 1 + isCodeUnitInSurrogateRange(str.charCodeAt(pos));
  14543. }
  14544. /**
  14545. * Fully Unicode-enabled replacement for String#length
  14546. *
  14547. * @param {string} str Valid Unicode string
  14548. * @return {number} The number of Unicode characters in the string
  14549. */
  14550. function strlen(str) {
  14551. // Call the native functions if there's no surrogate char
  14552. if (!hasSurrogateUnit(str)) {
  14553. return str.length;
  14554. }
  14555. var len = 0;
  14556. for (var pos = 0; pos < str.length; pos += getUTF16Length(str, pos)) {
  14557. len++;
  14558. }
  14559. return len;
  14560. }
  14561. /**
  14562. * Fully Unicode-enabled replacement for String#substr()
  14563. *
  14564. * @param {string} str Valid Unicode string
  14565. * @param {number} start Location in Unicode sequence to begin extracting
  14566. * @param {?number} length The number of Unicode characters to extract
  14567. * (default: to the end of the string)
  14568. * @return {string} Extracted sub-string
  14569. */
  14570. function substr(str, start, length) {
  14571. start = start || 0;
  14572. length = length === undefined ? Infinity : length || 0;
  14573. // Call the native functions if there's no surrogate char
  14574. if (!hasSurrogateUnit(str)) {
  14575. return str.substr(start, length);
  14576. }
  14577. // Obvious cases
  14578. var size = str.length;
  14579. if (size <= 0 || start > size || length <= 0) {
  14580. return "";
  14581. }
  14582. // Find the actual starting position
  14583. var posA = 0;
  14584. if (start > 0) {
  14585. for (; start > 0 && posA < size; start--) {
  14586. posA += getUTF16Length(str, posA);
  14587. }
  14588. if (posA >= size) {
  14589. return "";
  14590. }
  14591. } else if (start < 0) {
  14592. for (posA = size; start < 0 && 0 < posA; start++) {
  14593. posA -= getUTF16Length(str, posA - 1);
  14594. }
  14595. if (posA < 0) {
  14596. posA = 0;
  14597. }
  14598. }
  14599. // Find the actual ending position
  14600. var posB = size;
  14601. if (length < size) {
  14602. for (posB = posA; length > 0 && posB < size; length--) {
  14603. posB += getUTF16Length(str, posB);
  14604. }
  14605. }
  14606. return str.substring(posA, posB);
  14607. }
  14608. /**
  14609. * Fully Unicode-enabled replacement for String#substring()
  14610. *
  14611. * @param {string} str Valid Unicode string
  14612. * @param {number} start Location in Unicode sequence to begin extracting
  14613. * @param {?number} end Location in Unicode sequence to end extracting
  14614. * (default: end of the string)
  14615. * @return {string} Extracted sub-string
  14616. */
  14617. function substring(str, start, end) {
  14618. start = start || 0;
  14619. end = end === undefined ? Infinity : end || 0;
  14620. if (start < 0) {
  14621. start = 0;
  14622. }
  14623. if (end < 0) {
  14624. end = 0;
  14625. }
  14626. var length = Math.abs(end - start);
  14627. start = start < end ? start : end;
  14628. return substr(str, start, length);
  14629. }
  14630. /**
  14631. * Get a list of Unicode code-points from a String
  14632. *
  14633. * @param {string} str Valid Unicode string
  14634. * @return {array<number>} A list of code-points in [0..0x10FFFF]
  14635. */
  14636. function getCodePoints(str) {
  14637. var codePoints = [];
  14638. for (var pos = 0; pos < str.length; pos += getUTF16Length(str, pos)) {
  14639. codePoints.push(str.codePointAt(pos));
  14640. }
  14641. return codePoints;
  14642. }
  14643. var UnicodeUtils = {
  14644. getCodePoints: getCodePoints,
  14645. getUTF16Length: getUTF16Length,
  14646. hasSurrogateUnit: hasSurrogateUnit,
  14647. isCodeUnitInSurrogateRange: isCodeUnitInSurrogateRange,
  14648. isSurrogatePair: isSurrogatePair,
  14649. strlen: strlen,
  14650. substring: substring,
  14651. substr: substr
  14652. };
  14653. var UnicodeUtils_1 = UnicodeUtils;
  14654. var isChrome = UserAgent_1.isBrowser("Chrome");
  14655. // In Chrome, the client rects will include the entire bounds of all nodes that
  14656. // begin (have a start tag) within the selection, even if the selection does
  14657. // not overlap the entire node. To resolve this, we split the range at each
  14658. // start tag and join the client rects together.
  14659. // https://code.google.com/p/chromium/issues/detail?id=324437
  14660. /* eslint-disable consistent-return */
  14661. function getRangeClientRectsChrome(range) {
  14662. var tempRange = range.cloneRange();
  14663. var clientRects = [];
  14664. for (
  14665. var ancestor = range.endContainer;
  14666. ancestor != null;
  14667. ancestor = ancestor.parentNode
  14668. ) {
  14669. // If we've climbed up to the common ancestor, we can now use the
  14670. // original start point and stop climbing the tree.
  14671. var atCommonAncestor = ancestor === range.commonAncestorContainer;
  14672. if (atCommonAncestor) {
  14673. tempRange.setStart(range.startContainer, range.startOffset);
  14674. } else {
  14675. tempRange.setStart(tempRange.endContainer, 0);
  14676. }
  14677. var rects = Array.from(tempRange.getClientRects());
  14678. clientRects.push(rects);
  14679. if (atCommonAncestor) {
  14680. var _ref;
  14681. clientRects.reverse();
  14682. return (_ref = []).concat.apply(_ref, clientRects);
  14683. }
  14684. tempRange.setEndBefore(ancestor);
  14685. }
  14686. process.env.NODE_ENV !== "production"
  14687. ? invariant_1(
  14688. false,
  14689. "Found an unexpected detached subtree when getting range client rects."
  14690. )
  14691. : invariant_1(false);
  14692. }
  14693. /* eslint-enable consistent-return */
  14694. /**
  14695. * Like range.getClientRects() but normalizes for browser bugs.
  14696. */
  14697. var getRangeClientRects = isChrome
  14698. ? getRangeClientRectsChrome
  14699. : function(range) {
  14700. return Array.from(range.getClientRects());
  14701. };
  14702. var getRangeClientRects_1 = getRangeClientRects;
  14703. /**
  14704. * Copyright (c) 2013-present, Facebook, Inc.
  14705. * All rights reserved.
  14706. *
  14707. * This source code is licensed under the BSD-style license found in the
  14708. * LICENSE file in the root directory of this source tree. An additional grant
  14709. * of patent rights can be found in the PATENTS file in the same directory.
  14710. *
  14711. * @providesModule expandRangeToStartOfLine
  14712. * @format
  14713. *
  14714. */
  14715. /**
  14716. * Return the computed line height, in pixels, for the provided element.
  14717. */
  14718. function getLineHeightPx(element) {
  14719. var computed = getComputedStyle(element);
  14720. var div = document.createElement("div");
  14721. div.style.fontFamily = computed.fontFamily;
  14722. div.style.fontSize = computed.fontSize;
  14723. div.style.fontStyle = computed.fontStyle;
  14724. div.style.fontWeight = computed.fontWeight;
  14725. div.style.lineHeight = computed.lineHeight;
  14726. div.style.position = "absolute";
  14727. div.textContent = "M";
  14728. var documentBody = document.body;
  14729. !documentBody
  14730. ? process.env.NODE_ENV !== "production"
  14731. ? invariant_1(false, "Missing document.body")
  14732. : invariant_1(false)
  14733. : void 0;
  14734. // forced layout here
  14735. documentBody.appendChild(div);
  14736. var rect = div.getBoundingClientRect();
  14737. documentBody.removeChild(div);
  14738. return rect.height;
  14739. }
  14740. /**
  14741. * Return whether every ClientRect in the provided list lies on the same line.
  14742. *
  14743. * We assume that the rects on the same line all contain the baseline, so the
  14744. * lowest top line needs to be above the highest bottom line (i.e., if you were
  14745. * to project the rects onto the y-axis, their intersection would be nonempty).
  14746. *
  14747. * In addition, we require that no two boxes are lineHeight (or more) apart at
  14748. * either top or bottom, which helps protect against false positives for fonts
  14749. * with extremely large glyph heights (e.g., with a font size of 17px, Zapfino
  14750. * produces rects of height 58px!).
  14751. */
  14752. function areRectsOnOneLine(rects, lineHeight) {
  14753. var minTop = Infinity;
  14754. var minBottom = Infinity;
  14755. var maxTop = -Infinity;
  14756. var maxBottom = -Infinity;
  14757. for (var ii = 0; ii < rects.length; ii++) {
  14758. var rect = rects[ii];
  14759. if (rect.width === 0 || rect.width === 1) {
  14760. // When a range starts or ends a soft wrap, many browsers (Chrome, IE,
  14761. // Safari) include an empty rect on the previous or next line. When the
  14762. // text lies in a container whose position is not integral (e.g., from
  14763. // margin: auto), Safari makes these empty rects have width 1 (instead of
  14764. // 0). Having one-pixel-wide characters seems unlikely (and most browsers
  14765. // report widths in subpixel precision anyway) so it's relatively safe to
  14766. // skip over them.
  14767. continue;
  14768. }
  14769. minTop = Math.min(minTop, rect.top);
  14770. minBottom = Math.min(minBottom, rect.bottom);
  14771. maxTop = Math.max(maxTop, rect.top);
  14772. maxBottom = Math.max(maxBottom, rect.bottom);
  14773. }
  14774. return (
  14775. maxTop <= minBottom &&
  14776. maxTop - minTop < lineHeight &&
  14777. maxBottom - minBottom < lineHeight
  14778. );
  14779. }
  14780. /**
  14781. * Return the length of a node, as used by Range offsets.
  14782. */
  14783. function getNodeLength$1(node) {
  14784. // http://www.w3.org/TR/dom/#concept-node-length
  14785. switch (node.nodeType) {
  14786. case Node.DOCUMENT_TYPE_NODE:
  14787. return 0;
  14788. case Node.TEXT_NODE:
  14789. case Node.PROCESSING_INSTRUCTION_NODE:
  14790. case Node.COMMENT_NODE:
  14791. return node.length;
  14792. default:
  14793. return node.childNodes.length;
  14794. }
  14795. }
  14796. /**
  14797. * Given a collapsed range, move the start position backwards as far as
  14798. * possible while the range still spans only a single line.
  14799. */
  14800. function expandRangeToStartOfLine(range) {
  14801. !range.collapsed
  14802. ? process.env.NODE_ENV !== "production"
  14803. ? invariant_1(
  14804. false,
  14805. "expandRangeToStartOfLine: Provided range is not collapsed."
  14806. )
  14807. : invariant_1(false)
  14808. : void 0;
  14809. range = range.cloneRange();
  14810. var containingElement = range.startContainer;
  14811. if (containingElement.nodeType !== 1) {
  14812. containingElement = containingElement.parentNode;
  14813. }
  14814. var lineHeight = getLineHeightPx(containingElement);
  14815. // Imagine our text looks like:
  14816. // <div><span>once upon a time, there was a <em>boy
  14817. // who lived</em> </span><q><strong>under^ the
  14818. // stairs</strong> in a small closet.</q></div>
  14819. // where the caret represents the cursor. First, we crawl up the tree until
  14820. // the range spans multiple lines (setting the start point to before
  14821. // "<strong>", then before "<div>"), then at each level we do a search to
  14822. // find the latest point which is still on a previous line. We'll find that
  14823. // the break point is inside the span, then inside the <em>, then in its text
  14824. // node child, the actual break point before "who".
  14825. var bestContainer = range.endContainer;
  14826. var bestOffset = range.endOffset;
  14827. range.setStart(range.startContainer, 0);
  14828. while (areRectsOnOneLine(getRangeClientRects_1(range), lineHeight)) {
  14829. bestContainer = range.startContainer;
  14830. bestOffset = range.startOffset;
  14831. !bestContainer.parentNode
  14832. ? process.env.NODE_ENV !== "production"
  14833. ? invariant_1(
  14834. false,
  14835. "Found unexpected detached subtree when traversing."
  14836. )
  14837. : invariant_1(false)
  14838. : void 0;
  14839. range.setStartBefore(bestContainer);
  14840. if (
  14841. bestContainer.nodeType === 1 &&
  14842. getComputedStyle(bestContainer).display !== "inline"
  14843. ) {
  14844. // The start of the line is never in a different block-level container.
  14845. break;
  14846. }
  14847. }
  14848. // In the above example, range now spans from "<div>" to "under",
  14849. // bestContainer is <div>, and bestOffset is 1 (index of <q> inside <div>)].
  14850. // Picking out which child to recurse into here is a special case since we
  14851. // don't want to check past <q> -- once we find that the final range starts
  14852. // in <span>, we can look at all of its children (and all of their children)
  14853. // to find the break point.
  14854. // At all times, (bestContainer, bestOffset) is the latest single-line start
  14855. // point that we know of.
  14856. var currentContainer = bestContainer;
  14857. var maxIndexToConsider = bestOffset - 1;
  14858. do {
  14859. var nodeValue = currentContainer.nodeValue;
  14860. for (var ii = maxIndexToConsider; ii >= 0; ii--) {
  14861. if (
  14862. nodeValue != null &&
  14863. ii > 0 &&
  14864. UnicodeUtils_1.isSurrogatePair(nodeValue, ii - 1)
  14865. ) {
  14866. // We're in the middle of a surrogate pair -- skip over so we never
  14867. // return a range with an endpoint in the middle of a code point.
  14868. continue;
  14869. }
  14870. range.setStart(currentContainer, ii);
  14871. if (areRectsOnOneLine(getRangeClientRects_1(range), lineHeight)) {
  14872. bestContainer = currentContainer;
  14873. bestOffset = ii;
  14874. } else {
  14875. break;
  14876. }
  14877. }
  14878. if (ii === -1 || currentContainer.childNodes.length === 0) {
  14879. // If ii === -1, then (bestContainer, bestOffset), which is equal to
  14880. // (currentContainer, 0), was a single-line start point but a start
  14881. // point before currentContainer wasn't, so the line break seems to
  14882. // have occurred immediately after currentContainer's start tag
  14883. //
  14884. // If currentContainer.childNodes.length === 0, we're already at a
  14885. // terminal node (e.g., text node) and should return our current best.
  14886. break;
  14887. }
  14888. currentContainer = currentContainer.childNodes[ii];
  14889. maxIndexToConsider = getNodeLength$1(currentContainer);
  14890. } while (true);
  14891. range.setStart(bestContainer, bestOffset);
  14892. return range;
  14893. }
  14894. var expandRangeToStartOfLine_1 = expandRangeToStartOfLine;
  14895. /**
  14896. * Convert the current selection range to an anchor/focus pair of offset keys
  14897. * and values that can be interpreted by components.
  14898. */
  14899. function getDraftEditorSelectionWithNodes(
  14900. editorState,
  14901. root,
  14902. anchorNode,
  14903. anchorOffset,
  14904. focusNode,
  14905. focusOffset
  14906. ) {
  14907. var anchorIsTextNode = anchorNode.nodeType === Node.TEXT_NODE;
  14908. var focusIsTextNode = focusNode.nodeType === Node.TEXT_NODE;
  14909. // If the selection range lies only on text nodes, the task is simple.
  14910. // Find the nearest offset-aware elements and use the
  14911. // offset values supplied by the selection range.
  14912. if (anchorIsTextNode && focusIsTextNode) {
  14913. return {
  14914. selectionState: getUpdatedSelectionState_1(
  14915. editorState,
  14916. nullthrows_1(findAncestorOffsetKey_1(anchorNode)),
  14917. anchorOffset,
  14918. nullthrows_1(findAncestorOffsetKey_1(focusNode)),
  14919. focusOffset
  14920. ),
  14921. needsRecovery: false
  14922. };
  14923. }
  14924. var anchorPoint = null;
  14925. var focusPoint = null;
  14926. var needsRecovery = true;
  14927. // An element is selected. Convert this selection range into leaf offset
  14928. // keys and offset values for consumption at the component level. This
  14929. // is common in Firefox, where select-all and triple click behavior leads
  14930. // to entire elements being selected.
  14931. //
  14932. // Note that we use the `needsRecovery` parameter in the callback here. This
  14933. // is because when certain elements are selected, the behavior for subsequent
  14934. // cursor movement (e.g. via arrow keys) is uncertain and may not match
  14935. // expectations at the component level. For example, if an entire <div> is
  14936. // selected and the user presses the right arrow, Firefox keeps the selection
  14937. // on the <div>. If we allow subsequent keypresses to insert characters
  14938. // natively, they will be inserted into a browser-created text node to the
  14939. // right of that <div>. This is obviously undesirable.
  14940. //
  14941. // With the `needsRecovery` flag, we inform the caller that it is responsible
  14942. // for manually setting the selection state on the rendered document to
  14943. // ensure proper selection state maintenance.
  14944. if (anchorIsTextNode) {
  14945. anchorPoint = {
  14946. key: nullthrows_1(findAncestorOffsetKey_1(anchorNode)),
  14947. offset: anchorOffset
  14948. };
  14949. focusPoint = getPointForNonTextNode(root, focusNode, focusOffset);
  14950. } else if (focusIsTextNode) {
  14951. focusPoint = {
  14952. key: nullthrows_1(findAncestorOffsetKey_1(focusNode)),
  14953. offset: focusOffset
  14954. };
  14955. anchorPoint = getPointForNonTextNode(root, anchorNode, anchorOffset);
  14956. } else {
  14957. anchorPoint = getPointForNonTextNode(root, anchorNode, anchorOffset);
  14958. focusPoint = getPointForNonTextNode(root, focusNode, focusOffset);
  14959. // If the selection is collapsed on an empty block, don't force recovery.
  14960. // This way, on arrow key selection changes, the browser can move the
  14961. // cursor from a non-zero offset on one block, through empty blocks,
  14962. // to a matching non-zero offset on other text blocks.
  14963. if (anchorNode === focusNode && anchorOffset === focusOffset) {
  14964. needsRecovery =
  14965. !!anchorNode.firstChild && anchorNode.firstChild.nodeName !== "BR";
  14966. }
  14967. }
  14968. return {
  14969. selectionState: getUpdatedSelectionState_1(
  14970. editorState,
  14971. anchorPoint.key,
  14972. anchorPoint.offset,
  14973. focusPoint.key,
  14974. focusPoint.offset
  14975. ),
  14976. needsRecovery: needsRecovery
  14977. };
  14978. }
  14979. /**
  14980. * Identify the first leaf descendant for the given node.
  14981. */
  14982. function getFirstLeaf(node) {
  14983. while (
  14984. node.firstChild &&
  14985. // data-blocks has no offset
  14986. ((node.firstChild instanceof Element &&
  14987. node.firstChild.getAttribute("data-blocks") === "true") ||
  14988. getSelectionOffsetKeyForNode_1(node.firstChild))
  14989. ) {
  14990. node = node.firstChild;
  14991. }
  14992. return node;
  14993. }
  14994. /**
  14995. * Identify the last leaf descendant for the given node.
  14996. */
  14997. function getLastLeaf(node) {
  14998. while (
  14999. node.lastChild &&
  15000. // data-blocks has no offset
  15001. ((node.lastChild instanceof Element &&
  15002. node.lastChild.getAttribute("data-blocks") === "true") ||
  15003. getSelectionOffsetKeyForNode_1(node.lastChild))
  15004. ) {
  15005. node = node.lastChild;
  15006. }
  15007. return node;
  15008. }
  15009. function getPointForNonTextNode(editorRoot, startNode, childOffset) {
  15010. var node = startNode;
  15011. var offsetKey = findAncestorOffsetKey_1(node);
  15012. !(
  15013. offsetKey != null ||
  15014. (editorRoot && (editorRoot === node || editorRoot.firstChild === node))
  15015. )
  15016. ? process.env.NODE_ENV !== "production"
  15017. ? invariant_1(false, "Unknown node in selection range.")
  15018. : invariant_1(false)
  15019. : void 0;
  15020. // If the editorRoot is the selection, step downward into the content
  15021. // wrapper.
  15022. if (editorRoot === node) {
  15023. node = node.firstChild;
  15024. !(node instanceof Element && node.getAttribute("data-contents") === "true")
  15025. ? process.env.NODE_ENV !== "production"
  15026. ? invariant_1(false, "Invalid DraftEditorContents structure.")
  15027. : invariant_1(false)
  15028. : void 0;
  15029. if (childOffset > 0) {
  15030. childOffset = node.childNodes.length;
  15031. }
  15032. }
  15033. // If the child offset is zero and we have an offset key, we're done.
  15034. // If there's no offset key because the entire editor is selected,
  15035. // find the leftmost ("first") leaf in the tree and use that as the offset
  15036. // key.
  15037. if (childOffset === 0) {
  15038. var key = null;
  15039. if (offsetKey != null) {
  15040. key = offsetKey;
  15041. } else {
  15042. var firstLeaf = getFirstLeaf(node);
  15043. key = nullthrows_1(getSelectionOffsetKeyForNode_1(firstLeaf));
  15044. }
  15045. return { key: key, offset: 0 };
  15046. }
  15047. var nodeBeforeCursor = node.childNodes[childOffset - 1];
  15048. var leafKey = null;
  15049. var textLength = null;
  15050. if (!getSelectionOffsetKeyForNode_1(nodeBeforeCursor)) {
  15051. // Our target node may be a leaf or a text node, in which case we're
  15052. // already where we want to be and can just use the child's length as
  15053. // our offset.
  15054. leafKey = nullthrows_1(offsetKey);
  15055. textLength = getTextContentLength(nodeBeforeCursor);
  15056. } else {
  15057. // Otherwise, we'll look at the child to the left of the cursor and find
  15058. // the last leaf node in its subtree.
  15059. var lastLeaf = getLastLeaf(nodeBeforeCursor);
  15060. leafKey = nullthrows_1(getSelectionOffsetKeyForNode_1(lastLeaf));
  15061. textLength = getTextContentLength(lastLeaf);
  15062. }
  15063. return {
  15064. key: leafKey,
  15065. offset: textLength
  15066. };
  15067. }
  15068. /**
  15069. * Return the length of a node's textContent, regarding single newline
  15070. * characters as zero-length. This allows us to avoid problems with identifying
  15071. * the correct selection offset for empty blocks in IE, in which we
  15072. * render newlines instead of break tags.
  15073. */
  15074. function getTextContentLength(node) {
  15075. var textContent = node.textContent;
  15076. return textContent === "\n" ? 0 : textContent.length;
  15077. }
  15078. var getDraftEditorSelectionWithNodes_1 = getDraftEditorSelectionWithNodes;
  15079. /**
  15080. * Copyright (c) 2013-present, Facebook, Inc.
  15081. * All rights reserved.
  15082. *
  15083. * This source code is licensed under the BSD-style license found in the
  15084. * LICENSE file in the root directory of this source tree. An additional grant
  15085. * of patent rights can be found in the PATENTS file in the same directory.
  15086. *
  15087. * @providesModule moveSelectionBackward
  15088. * @format
  15089. *
  15090. */
  15091. /**
  15092. * Given a collapsed selection, move the focus `maxDistance` backward within
  15093. * the selected block. If the selection will go beyond the start of the block,
  15094. * move focus to the end of the previous block, but no further.
  15095. *
  15096. * This function is not Unicode-aware, so surrogate pairs will be treated
  15097. * as having length 2.
  15098. */
  15099. function moveSelectionBackward(editorState, maxDistance) {
  15100. var selection = editorState.getSelection();
  15101. var content = editorState.getCurrentContent();
  15102. var key = selection.getStartKey();
  15103. var offset = selection.getStartOffset();
  15104. var focusKey = key;
  15105. var focusOffset = 0;
  15106. if (maxDistance > offset) {
  15107. var keyBefore = content.getKeyBefore(key);
  15108. if (keyBefore == null) {
  15109. focusKey = key;
  15110. } else {
  15111. focusKey = keyBefore;
  15112. var blockBefore = content.getBlockForKey(keyBefore);
  15113. focusOffset = blockBefore.getText().length;
  15114. }
  15115. } else {
  15116. focusOffset = offset - maxDistance;
  15117. }
  15118. return selection.merge({
  15119. focusKey: focusKey,
  15120. focusOffset: focusOffset,
  15121. isBackward: true
  15122. });
  15123. }
  15124. var moveSelectionBackward_1 = moveSelectionBackward;
  15125. /**
  15126. * For a collapsed selection state, remove text based on the specified strategy.
  15127. * If the selection state is not collapsed, remove the entire selected range.
  15128. */
  15129. function removeTextWithStrategy(editorState, strategy, direction) {
  15130. var selection = editorState.getSelection();
  15131. var content = editorState.getCurrentContent();
  15132. var target = selection;
  15133. if (selection.isCollapsed()) {
  15134. if (direction === "forward") {
  15135. if (editorState.isSelectionAtEndOfContent()) {
  15136. return content;
  15137. }
  15138. } else if (editorState.isSelectionAtStartOfContent()) {
  15139. return content;
  15140. }
  15141. target = strategy(editorState);
  15142. if (target === selection) {
  15143. return content;
  15144. }
  15145. }
  15146. return DraftModifier_1.removeRange(content, target, direction);
  15147. }
  15148. var removeTextWithStrategy_1 = removeTextWithStrategy;
  15149. function keyCommandBackspaceToStartOfLine(editorState) {
  15150. var afterRemoval = removeTextWithStrategy_1(
  15151. editorState,
  15152. function(strategyState) {
  15153. var selection = strategyState.getSelection();
  15154. if (selection.isCollapsed() && selection.getAnchorOffset() === 0) {
  15155. return moveSelectionBackward_1(strategyState, 1);
  15156. }
  15157. var domSelection = _commonjsHelpers.commonjsGlobal.getSelection();
  15158. var range = domSelection.getRangeAt(0);
  15159. range = expandRangeToStartOfLine_1(range);
  15160. return getDraftEditorSelectionWithNodes_1(
  15161. strategyState,
  15162. null,
  15163. range.endContainer,
  15164. range.endOffset,
  15165. range.startContainer,
  15166. range.startOffset
  15167. ).selectionState;
  15168. },
  15169. "backward"
  15170. );
  15171. if (afterRemoval === editorState.getCurrentContent()) {
  15172. return editorState;
  15173. }
  15174. return EditorState_1.push(editorState, afterRemoval, "remove-range");
  15175. }
  15176. var keyCommandBackspaceToStartOfLine_1 = keyCommandBackspaceToStartOfLine;
  15177. /**
  15178. * Copyright (c) 2013-present, Facebook, Inc.
  15179. *
  15180. * This source code is licensed under the MIT license found in the
  15181. * LICENSE file in the root directory of this source tree.
  15182. *
  15183. * @typechecks
  15184. * @stub
  15185. *
  15186. */
  15187. // \u00a1-\u00b1\u00b4-\u00b8\u00ba\u00bb\u00bf
  15188. // is latin supplement punctuation except fractions and superscript
  15189. // numbers
  15190. // \u2010-\u2027\u2030-\u205e
  15191. // is punctuation from the general punctuation block:
  15192. // weird quotes, commas, bullets, dashes, etc.
  15193. // \u30fb\u3001\u3002\u3008-\u3011\u3014-\u301f
  15194. // is CJK punctuation
  15195. // \uff1a-\uff1f\uff01-\uff0f\uff3b-\uff40\uff5b-\uff65
  15196. // is some full-width/half-width punctuation
  15197. // \u2E2E\u061f\u066a-\u066c\u061b\u060c\u060d\uFD3e\uFD3F
  15198. // is some Arabic punctuation marks
  15199. // \u1801\u0964\u104a\u104b
  15200. // is misc. other language punctuation marks
  15201. var PUNCTUATION =
  15202. "[.,+*?$|#{}()'\\^\\-\\[\\]\\\\\\/!@%\"~=<>_:;" +
  15203. "\u30FB\u3001\u3002\u3008-\u3011\u3014-\u301F\uFF1A-\uFF1F\uFF01-\uFF0F" +
  15204. "\uFF3B-\uFF40\uFF5B-\uFF65\u2E2E\u061F\u066A-\u066C\u061B\u060C\u060D" +
  15205. "\uFD3E\uFD3F\u1801\u0964\u104A\u104B\u2010-\u2027\u2030-\u205E" +
  15206. "\xA1-\xB1\xB4-\xB8\xBA\xBB\xBF]";
  15207. var TokenizeUtil = {
  15208. getPunctuation: function getPunctuation() {
  15209. return PUNCTUATION;
  15210. }
  15211. };
  15212. var punctuation = TokenizeUtil.getPunctuation();
  15213. // The apostrophe and curly single quotes behave in a curious way: when
  15214. // surrounded on both sides by word characters, they behave as word chars; when
  15215. // either neighbor is punctuation or an end of the string, they behave as
  15216. // punctuation.
  15217. var CHAMELEON_CHARS = "['\u2018\u2019]";
  15218. // Remove the underscore, which should count as part of the removable word. The
  15219. // "chameleon chars" also count as punctuation in this regex.
  15220. var WHITESPACE_AND_PUNCTUATION = "\\s|(?![_])" + punctuation;
  15221. var DELETE_STRING =
  15222. "^" +
  15223. "(?:" +
  15224. WHITESPACE_AND_PUNCTUATION +
  15225. ")*" +
  15226. "(?:" +
  15227. CHAMELEON_CHARS +
  15228. "|(?!" +
  15229. WHITESPACE_AND_PUNCTUATION +
  15230. ").)*" +
  15231. "(?:(?!" +
  15232. WHITESPACE_AND_PUNCTUATION +
  15233. ").)";
  15234. var DELETE_REGEX = new RegExp(DELETE_STRING);
  15235. var BACKSPACE_STRING =
  15236. "(?:(?!" +
  15237. WHITESPACE_AND_PUNCTUATION +
  15238. ").)" +
  15239. "(?:" +
  15240. CHAMELEON_CHARS +
  15241. "|(?!" +
  15242. WHITESPACE_AND_PUNCTUATION +
  15243. ").)*" +
  15244. "(?:" +
  15245. WHITESPACE_AND_PUNCTUATION +
  15246. ")*" +
  15247. "$";
  15248. var BACKSPACE_REGEX = new RegExp(BACKSPACE_STRING);
  15249. function getRemovableWord(text, isBackward) {
  15250. var matches = isBackward
  15251. ? BACKSPACE_REGEX.exec(text)
  15252. : DELETE_REGEX.exec(text);
  15253. return matches ? matches[0] : text;
  15254. }
  15255. var DraftRemovableWord = {
  15256. getBackward: function getBackward(text) {
  15257. return getRemovableWord(text, true);
  15258. },
  15259. getForward: function getForward(text) {
  15260. return getRemovableWord(text, false);
  15261. }
  15262. };
  15263. var DraftRemovableWord_1 = DraftRemovableWord;
  15264. /**
  15265. * Delete the word that is left of the cursor, as well as any spaces or
  15266. * punctuation after the word.
  15267. */
  15268. function keyCommandBackspaceWord(editorState) {
  15269. var afterRemoval = removeTextWithStrategy_1(
  15270. editorState,
  15271. function(strategyState) {
  15272. var selection = strategyState.getSelection();
  15273. var offset = selection.getStartOffset();
  15274. // If there are no words before the cursor, remove the preceding newline.
  15275. if (offset === 0) {
  15276. return moveSelectionBackward_1(strategyState, 1);
  15277. }
  15278. var key = selection.getStartKey();
  15279. var content = strategyState.getCurrentContent();
  15280. var text = content
  15281. .getBlockForKey(key)
  15282. .getText()
  15283. .slice(0, offset);
  15284. var toRemove = DraftRemovableWord_1.getBackward(text);
  15285. return moveSelectionBackward_1(strategyState, toRemove.length || 1);
  15286. },
  15287. "backward"
  15288. );
  15289. if (afterRemoval === editorState.getCurrentContent()) {
  15290. return editorState;
  15291. }
  15292. return EditorState_1.push(editorState, afterRemoval, "remove-range");
  15293. }
  15294. var keyCommandBackspaceWord_1 = keyCommandBackspaceWord;
  15295. /**
  15296. * Copyright (c) 2013-present, Facebook, Inc.
  15297. * All rights reserved.
  15298. *
  15299. * This source code is licensed under the BSD-style license found in the
  15300. * LICENSE file in the root directory of this source tree. An additional grant
  15301. * of patent rights can be found in the PATENTS file in the same directory.
  15302. *
  15303. * @providesModule moveSelectionForward
  15304. * @format
  15305. *
  15306. */
  15307. /**
  15308. * Given a collapsed selection, move the focus `maxDistance` forward within
  15309. * the selected block. If the selection will go beyond the end of the block,
  15310. * move focus to the start of the next block, but no further.
  15311. *
  15312. * This function is not Unicode-aware, so surrogate pairs will be treated
  15313. * as having length 2.
  15314. */
  15315. function moveSelectionForward(editorState, maxDistance) {
  15316. var selection = editorState.getSelection();
  15317. var key = selection.getStartKey();
  15318. var offset = selection.getStartOffset();
  15319. var content = editorState.getCurrentContent();
  15320. var focusKey = key;
  15321. var focusOffset;
  15322. var block = content.getBlockForKey(key);
  15323. if (maxDistance > block.getText().length - offset) {
  15324. focusKey = content.getKeyAfter(key);
  15325. focusOffset = 0;
  15326. } else {
  15327. focusOffset = offset + maxDistance;
  15328. }
  15329. return selection.merge({ focusKey: focusKey, focusOffset: focusOffset });
  15330. }
  15331. var moveSelectionForward_1 = moveSelectionForward;
  15332. /**
  15333. * Delete the word that is right of the cursor, as well as any spaces or
  15334. * punctuation before the word.
  15335. */
  15336. function keyCommandDeleteWord(editorState) {
  15337. var afterRemoval = removeTextWithStrategy_1(
  15338. editorState,
  15339. function(strategyState) {
  15340. var selection = strategyState.getSelection();
  15341. var offset = selection.getStartOffset();
  15342. var key = selection.getStartKey();
  15343. var content = strategyState.getCurrentContent();
  15344. var text = content
  15345. .getBlockForKey(key)
  15346. .getText()
  15347. .slice(offset);
  15348. var toRemove = DraftRemovableWord_1.getForward(text);
  15349. // If there are no words in front of the cursor, remove the newline.
  15350. return moveSelectionForward_1(strategyState, toRemove.length || 1);
  15351. },
  15352. "forward"
  15353. );
  15354. if (afterRemoval === editorState.getCurrentContent()) {
  15355. return editorState;
  15356. }
  15357. return EditorState_1.push(editorState, afterRemoval, "remove-range");
  15358. }
  15359. var keyCommandDeleteWord_1 = keyCommandDeleteWord;
  15360. function keyCommandInsertNewline(editorState) {
  15361. var contentState = DraftModifier_1.splitBlock(
  15362. editorState.getCurrentContent(),
  15363. editorState.getSelection()
  15364. );
  15365. return EditorState_1.push(editorState, contentState, "split-block");
  15366. }
  15367. var keyCommandInsertNewline_1 = keyCommandInsertNewline;
  15368. /**
  15369. * See comment for `moveSelectionToStartOfBlock`.
  15370. */
  15371. function keyCommandMoveSelectionToEndOfBlock(editorState) {
  15372. var selection = editorState.getSelection();
  15373. var endKey = selection.getEndKey();
  15374. var content = editorState.getCurrentContent();
  15375. var textLength = content.getBlockForKey(endKey).getLength();
  15376. return EditorState_1.set(editorState, {
  15377. selection: selection.merge({
  15378. anchorKey: endKey,
  15379. anchorOffset: textLength,
  15380. focusKey: endKey,
  15381. focusOffset: textLength,
  15382. isBackward: false
  15383. }),
  15384. forceSelection: true
  15385. });
  15386. }
  15387. var keyCommandMoveSelectionToEndOfBlock_1 = keyCommandMoveSelectionToEndOfBlock;
  15388. /**
  15389. * Collapse selection at the start of the first selected block. This is used
  15390. * for Firefox versions that attempt to navigate forward/backward instead of
  15391. * moving the cursor. Other browsers are able to move the cursor natively.
  15392. */
  15393. function keyCommandMoveSelectionToStartOfBlock(editorState) {
  15394. var selection = editorState.getSelection();
  15395. var startKey = selection.getStartKey();
  15396. return EditorState_1.set(editorState, {
  15397. selection: selection.merge({
  15398. anchorKey: startKey,
  15399. anchorOffset: 0,
  15400. focusKey: startKey,
  15401. focusOffset: 0,
  15402. isBackward: false
  15403. }),
  15404. forceSelection: true
  15405. });
  15406. }
  15407. var keyCommandMoveSelectionToStartOfBlock_1 = keyCommandMoveSelectionToStartOfBlock;
  15408. /**
  15409. * Remove the selected range. If the cursor is collapsed, remove the preceding
  15410. * character. This operation is Unicode-aware, so removing a single character
  15411. * will remove a surrogate pair properly as well.
  15412. */
  15413. function keyCommandPlainBackspace(editorState) {
  15414. var afterRemoval = removeTextWithStrategy_1(
  15415. editorState,
  15416. function(strategyState) {
  15417. var selection = strategyState.getSelection();
  15418. var content = strategyState.getCurrentContent();
  15419. var key = selection.getAnchorKey();
  15420. var offset = selection.getAnchorOffset();
  15421. var charBehind = content.getBlockForKey(key).getText()[offset - 1];
  15422. return moveSelectionBackward_1(
  15423. strategyState,
  15424. charBehind ? UnicodeUtils_1.getUTF16Length(charBehind, 0) : 1
  15425. );
  15426. },
  15427. "backward"
  15428. );
  15429. if (afterRemoval === editorState.getCurrentContent()) {
  15430. return editorState;
  15431. }
  15432. var selection = editorState.getSelection();
  15433. return EditorState_1.push(
  15434. editorState,
  15435. afterRemoval.set("selectionBefore", selection),
  15436. selection.isCollapsed() ? "backspace-character" : "remove-range"
  15437. );
  15438. }
  15439. var keyCommandPlainBackspace_1 = keyCommandPlainBackspace;
  15440. /**
  15441. * Remove the selected range. If the cursor is collapsed, remove the following
  15442. * character. This operation is Unicode-aware, so removing a single character
  15443. * will remove a surrogate pair properly as well.
  15444. */
  15445. function keyCommandPlainDelete(editorState) {
  15446. var afterRemoval = removeTextWithStrategy_1(
  15447. editorState,
  15448. function(strategyState) {
  15449. var selection = strategyState.getSelection();
  15450. var content = strategyState.getCurrentContent();
  15451. var key = selection.getAnchorKey();
  15452. var offset = selection.getAnchorOffset();
  15453. var charAhead = content.getBlockForKey(key).getText()[offset];
  15454. return moveSelectionForward_1(
  15455. strategyState,
  15456. charAhead ? UnicodeUtils_1.getUTF16Length(charAhead, 0) : 1
  15457. );
  15458. },
  15459. "forward"
  15460. );
  15461. if (afterRemoval === editorState.getCurrentContent()) {
  15462. return editorState;
  15463. }
  15464. var selection = editorState.getSelection();
  15465. return EditorState_1.push(
  15466. editorState,
  15467. afterRemoval.set("selectionBefore", selection),
  15468. selection.isCollapsed() ? "delete-character" : "remove-range"
  15469. );
  15470. }
  15471. var keyCommandPlainDelete_1 = keyCommandPlainDelete;
  15472. /**
  15473. * Transpose the characters on either side of a collapsed cursor, or
  15474. * if the cursor is at the end of the block, transpose the last two
  15475. * characters.
  15476. */
  15477. function keyCommandTransposeCharacters(editorState) {
  15478. var selection = editorState.getSelection();
  15479. if (!selection.isCollapsed()) {
  15480. return editorState;
  15481. }
  15482. var offset = selection.getAnchorOffset();
  15483. if (offset === 0) {
  15484. return editorState;
  15485. }
  15486. var blockKey = selection.getAnchorKey();
  15487. var content = editorState.getCurrentContent();
  15488. var block = content.getBlockForKey(blockKey);
  15489. var length = block.getLength();
  15490. // Nothing to transpose if there aren't two characters.
  15491. if (length <= 1) {
  15492. return editorState;
  15493. }
  15494. var removalRange;
  15495. var finalSelection;
  15496. if (offset === length) {
  15497. // The cursor is at the end of the block. Swap the last two characters.
  15498. removalRange = selection.set("anchorOffset", offset - 1);
  15499. finalSelection = selection;
  15500. } else {
  15501. removalRange = selection.set("focusOffset", offset + 1);
  15502. finalSelection = removalRange.set("anchorOffset", offset + 1);
  15503. }
  15504. // Extract the character to move as a fragment. This preserves its
  15505. // styling and entity, if any.
  15506. var movedFragment = getContentStateFragment_1(content, removalRange);
  15507. var afterRemoval = DraftModifier_1.removeRange(
  15508. content,
  15509. removalRange,
  15510. "backward"
  15511. );
  15512. // After the removal, the insertion target is one character back.
  15513. var selectionAfter = afterRemoval.getSelectionAfter();
  15514. var targetOffset = selectionAfter.getAnchorOffset() - 1;
  15515. var targetRange = selectionAfter.merge({
  15516. anchorOffset: targetOffset,
  15517. focusOffset: targetOffset
  15518. });
  15519. var afterInsert = DraftModifier_1.replaceWithFragment(
  15520. afterRemoval,
  15521. targetRange,
  15522. movedFragment
  15523. );
  15524. var newEditorState = EditorState_1.push(
  15525. editorState,
  15526. afterInsert,
  15527. "insert-fragment"
  15528. );
  15529. return EditorState_1.acceptSelection(newEditorState, finalSelection);
  15530. }
  15531. var keyCommandTransposeCharacters_1 = keyCommandTransposeCharacters;
  15532. function keyCommandUndo(e, editorState, updateFn) {
  15533. var undoneState = EditorState_1.undo(editorState);
  15534. // If the last change to occur was a spellcheck change, allow the undo
  15535. // event to fall through to the browser. This allows the browser to record
  15536. // the unwanted change, which should soon lead it to learn not to suggest
  15537. // the correction again.
  15538. if (editorState.getLastChangeType() === "spellcheck-change") {
  15539. var nativelyRenderedContent = undoneState.getCurrentContent();
  15540. updateFn(
  15541. EditorState_1.set(undoneState, {
  15542. nativelyRenderedContent: nativelyRenderedContent
  15543. })
  15544. );
  15545. return;
  15546. }
  15547. // Otheriwse, manage the undo behavior manually.
  15548. e.preventDefault();
  15549. if (!editorState.getNativelyRenderedContent()) {
  15550. updateFn(undoneState);
  15551. return;
  15552. }
  15553. // Trigger a re-render with the current content state to ensure that the
  15554. // component tree has up-to-date props for comparison.
  15555. updateFn(EditorState_1.set(editorState, { nativelyRenderedContent: null }));
  15556. // Wait to ensure that the re-render has occurred before performing
  15557. // the undo action.
  15558. setTimeout(function() {
  15559. updateFn(undoneState);
  15560. }, 0);
  15561. }
  15562. var keyCommandUndo_1 = keyCommandUndo;
  15563. var isOptionKeyCommand = KeyBindingUtil_1.isOptionKeyCommand;
  15564. var isChrome$1 = UserAgent_1.isBrowser("Chrome");
  15565. /**
  15566. * Map a `DraftEditorCommand` command value to a corresponding function.
  15567. */
  15568. function onKeyCommand(command, editorState) {
  15569. switch (command) {
  15570. case "redo":
  15571. return EditorState_1.redo(editorState);
  15572. case "delete":
  15573. return keyCommandPlainDelete_1(editorState);
  15574. case "delete-word":
  15575. return keyCommandDeleteWord_1(editorState);
  15576. case "backspace":
  15577. return keyCommandPlainBackspace_1(editorState);
  15578. case "backspace-word":
  15579. return keyCommandBackspaceWord_1(editorState);
  15580. case "backspace-to-start-of-line":
  15581. return keyCommandBackspaceToStartOfLine_1(editorState);
  15582. case "split-block":
  15583. return keyCommandInsertNewline_1(editorState);
  15584. case "transpose-characters":
  15585. return keyCommandTransposeCharacters_1(editorState);
  15586. case "move-selection-to-start-of-block":
  15587. return keyCommandMoveSelectionToStartOfBlock_1(editorState);
  15588. case "move-selection-to-end-of-block":
  15589. return keyCommandMoveSelectionToEndOfBlock_1(editorState);
  15590. case "secondary-cut":
  15591. return SecondaryClipboard_1.cut(editorState);
  15592. case "secondary-paste":
  15593. return SecondaryClipboard_1.paste(editorState);
  15594. default:
  15595. return editorState;
  15596. }
  15597. }
  15598. /**
  15599. * Intercept keydown behavior to handle keys and commands manually, if desired.
  15600. *
  15601. * Keydown combinations may be mapped to `DraftCommand` values, which may
  15602. * correspond to command functions that modify the editor or its contents.
  15603. *
  15604. * See `getDefaultKeyBinding` for defaults. Alternatively, the top-level
  15605. * component may provide a custom mapping via the `keyBindingFn` prop.
  15606. */
  15607. function editOnKeyDown(editor, e) {
  15608. var keyCode = e.which;
  15609. var editorState = editor._latestEditorState;
  15610. switch (keyCode) {
  15611. case Keys.RETURN:
  15612. e.preventDefault();
  15613. // The top-level component may manually handle newline insertion. If
  15614. // no special handling is performed, fall through to command handling.
  15615. if (
  15616. editor.props.handleReturn &&
  15617. isEventHandled_1(editor.props.handleReturn(e, editorState))
  15618. ) {
  15619. return;
  15620. }
  15621. break;
  15622. case Keys.ESC:
  15623. e.preventDefault();
  15624. editor.props.onEscape && editor.props.onEscape(e);
  15625. return;
  15626. case Keys.TAB:
  15627. editor.props.onTab && editor.props.onTab(e);
  15628. return;
  15629. case Keys.UP:
  15630. editor.props.onUpArrow && editor.props.onUpArrow(e);
  15631. return;
  15632. case Keys.RIGHT:
  15633. editor.props.onRightArrow && editor.props.onRightArrow(e);
  15634. return;
  15635. case Keys.DOWN:
  15636. editor.props.onDownArrow && editor.props.onDownArrow(e);
  15637. return;
  15638. case Keys.LEFT:
  15639. editor.props.onLeftArrow && editor.props.onLeftArrow(e);
  15640. return;
  15641. case Keys.SPACE:
  15642. // Handling for OSX where option + space scrolls.
  15643. if (isChrome$1 && isOptionKeyCommand(e)) {
  15644. e.preventDefault();
  15645. // Insert a nbsp into the editor.
  15646. var contentState = DraftModifier_1.replaceText(
  15647. editorState.getCurrentContent(),
  15648. editorState.getSelection(),
  15649. "\xA0"
  15650. );
  15651. editor.update(
  15652. EditorState_1.push(editorState, contentState, "insert-characters")
  15653. );
  15654. return;
  15655. }
  15656. }
  15657. var command = editor.props.keyBindingFn(e);
  15658. // If no command is specified, allow keydown event to continue.
  15659. if (!command) {
  15660. return;
  15661. }
  15662. if (command === "undo") {
  15663. // Since undo requires some special updating behavior to keep the editor
  15664. // in sync, handle it separately.
  15665. keyCommandUndo_1(e, editorState, editor.update);
  15666. return;
  15667. }
  15668. // At this point, we know that we're handling a command of some kind, so
  15669. // we don't want to insert a character following the keydown.
  15670. e.preventDefault();
  15671. // Allow components higher up the tree to handle the command first.
  15672. if (
  15673. editor.props.handleKeyCommand &&
  15674. isEventHandled_1(editor.props.handleKeyCommand(command, editorState))
  15675. ) {
  15676. return;
  15677. }
  15678. var newState = onKeyCommand(command, editorState);
  15679. if (newState !== editorState) {
  15680. editor.update(newState);
  15681. }
  15682. }
  15683. var editOnKeyDown_1 = editOnKeyDown;
  15684. /**
  15685. * Copyright (c) 2013-present, Facebook, Inc.
  15686. *
  15687. * This source code is licensed under the MIT license found in the
  15688. * LICENSE file in the root directory of this source tree.
  15689. *
  15690. *
  15691. */
  15692. function _classCallCheck$e(instance, Constructor) {
  15693. if (!(instance instanceof Constructor)) {
  15694. throw new TypeError("Cannot call a class as a function");
  15695. }
  15696. }
  15697. var URI = (function() {
  15698. function URI(uri) {
  15699. _classCallCheck$e(this, URI);
  15700. this._uri = uri;
  15701. }
  15702. URI.prototype.toString = function toString() {
  15703. return this._uri;
  15704. };
  15705. return URI;
  15706. })();
  15707. var URI_1 = URI;
  15708. var isOldIE = UserAgent_1.isBrowser("IE <= 9");
  15709. // Provides a dom node that will not execute scripts
  15710. // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation.createHTMLDocument
  15711. // https://developer.mozilla.org/en-US/Add-ons/Code_snippets/HTML_to_DOM
  15712. function getSafeBodyFromHTML(html) {
  15713. var doc;
  15714. var root = null;
  15715. // Provides a safe context
  15716. if (
  15717. !isOldIE &&
  15718. document.implementation &&
  15719. document.implementation.createHTMLDocument
  15720. ) {
  15721. doc = document.implementation.createHTMLDocument("foo");
  15722. !doc.documentElement
  15723. ? process.env.NODE_ENV !== "production"
  15724. ? invariant_1(false, "Missing doc.documentElement")
  15725. : invariant_1(false)
  15726. : void 0;
  15727. doc.documentElement.innerHTML = html;
  15728. root = doc.getElementsByTagName("body")[0];
  15729. }
  15730. return root;
  15731. }
  15732. var getSafeBodyFromHTML_1 = getSafeBodyFromHTML;
  15733. var _extends$4 =
  15734. objectAssign ||
  15735. function(target) {
  15736. for (var i = 1; i < arguments.length; i++) {
  15737. var source = arguments[i];
  15738. for (var key in source) {
  15739. if (Object.prototype.hasOwnProperty.call(source, key)) {
  15740. target[key] = source[key];
  15741. }
  15742. }
  15743. }
  15744. return target;
  15745. };
  15746. var _knownListItemDepthCl;
  15747. function _defineProperty(obj, key, value) {
  15748. if (key in obj) {
  15749. Object.defineProperty(obj, key, {
  15750. value: value,
  15751. enumerable: true,
  15752. configurable: true,
  15753. writable: true
  15754. });
  15755. } else {
  15756. obj[key] = value;
  15757. }
  15758. return obj;
  15759. }
  15760. var _require = immutable,
  15761. Set = _require.Set;
  15762. var experimentalTreeDataSupport = DraftFeatureFlags_1.draft_tree_data_support;
  15763. var List$a = immutable.List,
  15764. OrderedSet$5 = immutable.OrderedSet;
  15765. var NBSP = "&nbsp;";
  15766. var SPACE = " ";
  15767. // Arbitrary max indent
  15768. var MAX_DEPTH = 4;
  15769. // used for replacing characters in HTML
  15770. var REGEX_CR = new RegExp("\r", "g");
  15771. var REGEX_LF = new RegExp("\n", "g");
  15772. var REGEX_NBSP = new RegExp(NBSP, "g");
  15773. var REGEX_CARRIAGE = new RegExp("&#13;?", "g");
  15774. var REGEX_ZWS = new RegExp("&#8203;?", "g");
  15775. // https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
  15776. var boldValues = ["bold", "bolder", "500", "600", "700", "800", "900"];
  15777. var notBoldValues = ["light", "lighter", "100", "200", "300", "400"];
  15778. // Block tag flow is different because LIs do not have
  15779. // a deterministic style ;_;
  15780. var inlineTags = {
  15781. b: "BOLD",
  15782. code: "CODE",
  15783. del: "STRIKETHROUGH",
  15784. em: "ITALIC",
  15785. i: "ITALIC",
  15786. s: "STRIKETHROUGH",
  15787. strike: "STRIKETHROUGH",
  15788. strong: "BOLD",
  15789. u: "UNDERLINE"
  15790. };
  15791. var knownListItemDepthClasses =
  15792. ((_knownListItemDepthCl = {}),
  15793. _defineProperty(
  15794. _knownListItemDepthCl,
  15795. cx_1("public/DraftStyleDefault/depth0"),
  15796. 0
  15797. ),
  15798. _defineProperty(
  15799. _knownListItemDepthCl,
  15800. cx_1("public/DraftStyleDefault/depth1"),
  15801. 1
  15802. ),
  15803. _defineProperty(
  15804. _knownListItemDepthCl,
  15805. cx_1("public/DraftStyleDefault/depth2"),
  15806. 2
  15807. ),
  15808. _defineProperty(
  15809. _knownListItemDepthCl,
  15810. cx_1("public/DraftStyleDefault/depth3"),
  15811. 3
  15812. ),
  15813. _defineProperty(
  15814. _knownListItemDepthCl,
  15815. cx_1("public/DraftStyleDefault/depth4"),
  15816. 4
  15817. ),
  15818. _knownListItemDepthCl);
  15819. var anchorAttr = ["className", "href", "rel", "target", "title"];
  15820. var imgAttr = ["alt", "className", "height", "src", "width"];
  15821. var lastBlock = void 0;
  15822. var EMPTY_CHUNK = {
  15823. text: "",
  15824. inlines: [],
  15825. entities: [],
  15826. blocks: []
  15827. };
  15828. var EMPTY_BLOCK = {
  15829. children: List$a(),
  15830. depth: 0,
  15831. key: "",
  15832. type: ""
  15833. };
  15834. var getListBlockType = function getListBlockType(tag, lastList) {
  15835. if (tag === "li") {
  15836. return lastList === "ol" ? "ordered-list-item" : "unordered-list-item";
  15837. }
  15838. return null;
  15839. };
  15840. var getBlockMapSupportedTags = function getBlockMapSupportedTags(
  15841. blockRenderMap
  15842. ) {
  15843. var unstyledElement = blockRenderMap.get("unstyled").element;
  15844. var tags = Set([]);
  15845. blockRenderMap.forEach(function(draftBlock) {
  15846. if (draftBlock.aliasedElements) {
  15847. draftBlock.aliasedElements.forEach(function(tag) {
  15848. tags = tags.add(tag);
  15849. });
  15850. }
  15851. tags = tags.add(draftBlock.element);
  15852. });
  15853. return tags
  15854. .filter(function(tag) {
  15855. return tag && tag !== unstyledElement;
  15856. })
  15857. .toArray()
  15858. .sort();
  15859. };
  15860. // custom element conversions
  15861. var getMultiMatchedType = function getMultiMatchedType(
  15862. tag,
  15863. lastList,
  15864. multiMatchExtractor
  15865. ) {
  15866. for (var ii = 0; ii < multiMatchExtractor.length; ii++) {
  15867. var matchType = multiMatchExtractor[ii](tag, lastList);
  15868. if (matchType) {
  15869. return matchType;
  15870. }
  15871. }
  15872. return null;
  15873. };
  15874. var getBlockTypeForTag = function getBlockTypeForTag(
  15875. tag,
  15876. lastList,
  15877. blockRenderMap
  15878. ) {
  15879. var matchedTypes = blockRenderMap
  15880. .filter(function(draftBlock) {
  15881. return (
  15882. draftBlock.element === tag ||
  15883. draftBlock.wrapper === tag ||
  15884. (draftBlock.aliasedElements &&
  15885. draftBlock.aliasedElements.some(function(alias) {
  15886. return alias === tag;
  15887. }))
  15888. );
  15889. })
  15890. .keySeq()
  15891. .toSet()
  15892. .toArray()
  15893. .sort();
  15894. // if we dont have any matched type, return unstyled
  15895. // if we have one matched type return it
  15896. // if we have multi matched types use the multi-match function to gather type
  15897. switch (matchedTypes.length) {
  15898. case 0:
  15899. return "unstyled";
  15900. case 1:
  15901. return matchedTypes[0];
  15902. default:
  15903. return (
  15904. getMultiMatchedType(tag, lastList, [getListBlockType]) || "unstyled"
  15905. );
  15906. }
  15907. };
  15908. var processInlineTag = function processInlineTag(tag, node, currentStyle) {
  15909. var styleToCheck = inlineTags[tag];
  15910. if (styleToCheck) {
  15911. currentStyle = currentStyle.add(styleToCheck).toOrderedSet();
  15912. } else if (node instanceof HTMLElement) {
  15913. var htmlElement = node;
  15914. currentStyle = currentStyle
  15915. .withMutations(function(style) {
  15916. var fontWeight = htmlElement.style.fontWeight;
  15917. var fontStyle = htmlElement.style.fontStyle;
  15918. var textDecoration = htmlElement.style.textDecoration;
  15919. if (boldValues.indexOf(fontWeight) >= 0) {
  15920. style.add("BOLD");
  15921. } else if (notBoldValues.indexOf(fontWeight) >= 0) {
  15922. style.remove("BOLD");
  15923. }
  15924. if (fontStyle === "italic") {
  15925. style.add("ITALIC");
  15926. } else if (fontStyle === "normal") {
  15927. style.remove("ITALIC");
  15928. }
  15929. if (textDecoration === "underline") {
  15930. style.add("UNDERLINE");
  15931. }
  15932. if (textDecoration === "line-through") {
  15933. style.add("STRIKETHROUGH");
  15934. }
  15935. if (textDecoration === "none") {
  15936. style.remove("UNDERLINE");
  15937. style.remove("STRIKETHROUGH");
  15938. }
  15939. })
  15940. .toOrderedSet();
  15941. }
  15942. return currentStyle;
  15943. };
  15944. var joinChunks = function joinChunks(A, B, experimentalHasNestedBlocks) {
  15945. // Sometimes two blocks will touch in the DOM and we need to strip the
  15946. // extra delimiter to preserve niceness.
  15947. var lastInA = A.text.slice(-1);
  15948. var firstInB = B.text.slice(0, 1);
  15949. if (lastInA === "\r" && firstInB === "\r" && !experimentalHasNestedBlocks) {
  15950. A.text = A.text.slice(0, -1);
  15951. A.inlines.pop();
  15952. A.entities.pop();
  15953. A.blocks.pop();
  15954. }
  15955. // Kill whitespace after blocks
  15956. if (lastInA === "\r") {
  15957. if (B.text === SPACE || B.text === "\n") {
  15958. return A;
  15959. } else if (firstInB === SPACE || firstInB === "\n") {
  15960. B.text = B.text.slice(1);
  15961. B.inlines.shift();
  15962. B.entities.shift();
  15963. }
  15964. }
  15965. return {
  15966. text: A.text + B.text,
  15967. inlines: A.inlines.concat(B.inlines),
  15968. entities: A.entities.concat(B.entities),
  15969. blocks: A.blocks.concat(B.blocks)
  15970. };
  15971. };
  15972. /**
  15973. * Check to see if we have anything like <p> <blockquote> <h1>... to create
  15974. * block tags from. If we do, we can use those and ignore <div> tags. If we
  15975. * don't, we can treat <div> tags as meaningful (unstyled) blocks.
  15976. */
  15977. var containsSemanticBlockMarkup = function containsSemanticBlockMarkup(
  15978. html,
  15979. blockTags
  15980. ) {
  15981. return blockTags.some(function(tag) {
  15982. return html.indexOf("<" + tag) !== -1;
  15983. });
  15984. };
  15985. var hasValidLinkText = function hasValidLinkText(link) {
  15986. !(link instanceof HTMLAnchorElement)
  15987. ? process.env.NODE_ENV !== "production"
  15988. ? invariant_1(false, "Link must be an HTMLAnchorElement.")
  15989. : invariant_1(false)
  15990. : void 0;
  15991. var protocol = link.protocol;
  15992. return (
  15993. protocol === "http:" || protocol === "https:" || protocol === "mailto:"
  15994. );
  15995. };
  15996. var getWhitespaceChunk = function getWhitespaceChunk(inEntity) {
  15997. var entities = new Array(1);
  15998. if (inEntity) {
  15999. entities[0] = inEntity;
  16000. }
  16001. return _extends$4({}, EMPTY_CHUNK, {
  16002. text: SPACE,
  16003. inlines: [OrderedSet$5()],
  16004. entities: entities
  16005. });
  16006. };
  16007. var getSoftNewlineChunk = function getSoftNewlineChunk() {
  16008. return _extends$4({}, EMPTY_CHUNK, {
  16009. text: "\n",
  16010. inlines: [OrderedSet$5()],
  16011. entities: new Array(1)
  16012. });
  16013. };
  16014. var getChunkedBlock = function getChunkedBlock() {
  16015. var props =
  16016. arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  16017. return _extends$4({}, EMPTY_BLOCK, props);
  16018. };
  16019. var getBlockDividerChunk = function getBlockDividerChunk(block, depth) {
  16020. var parentKey =
  16021. arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  16022. return {
  16023. text: "\r",
  16024. inlines: [OrderedSet$5()],
  16025. entities: new Array(1),
  16026. blocks: [
  16027. getChunkedBlock({
  16028. parent: parentKey,
  16029. key: generateRandomKey_1(),
  16030. type: block,
  16031. depth: Math.max(0, Math.min(MAX_DEPTH, depth))
  16032. })
  16033. ]
  16034. };
  16035. };
  16036. /**
  16037. * If we're pasting from one DraftEditor to another we can check to see if
  16038. * existing list item depth classes are being used and preserve this style
  16039. */
  16040. var getListItemDepth = function getListItemDepth(node) {
  16041. var depth =
  16042. arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  16043. Object.keys(knownListItemDepthClasses).some(function(depthClass) {
  16044. if (node.classList.contains(depthClass)) {
  16045. depth = knownListItemDepthClasses[depthClass];
  16046. }
  16047. });
  16048. return depth;
  16049. };
  16050. var genFragment = function genFragment(
  16051. entityMap,
  16052. node,
  16053. inlineStyle,
  16054. lastList,
  16055. inBlock,
  16056. blockTags,
  16057. depth,
  16058. blockRenderMap,
  16059. inEntity,
  16060. parentKey
  16061. ) {
  16062. var lastLastBlock = lastBlock;
  16063. var nodeName = node.nodeName.toLowerCase();
  16064. var newEntityMap = entityMap;
  16065. var nextBlockType = "unstyled";
  16066. var newBlock = false;
  16067. var inBlockType =
  16068. inBlock && getBlockTypeForTag(inBlock, lastList, blockRenderMap);
  16069. var chunk = _extends$4({}, EMPTY_CHUNK);
  16070. var newChunk = null;
  16071. var blockKey = void 0;
  16072. // Base Case
  16073. if (nodeName === "#text") {
  16074. var _text = node.textContent;
  16075. var nodeTextContent = _text.trim();
  16076. // We should not create blocks for leading spaces that are
  16077. // existing around ol/ul and their children list items
  16078. if (lastList && nodeTextContent === "" && node.parentElement) {
  16079. var parentNodeName = node.parentElement.nodeName.toLowerCase();
  16080. if (parentNodeName === "ol" || parentNodeName === "ul") {
  16081. return { chunk: _extends$4({}, EMPTY_CHUNK), entityMap: entityMap };
  16082. }
  16083. }
  16084. if (nodeTextContent === "" && inBlock !== "pre") {
  16085. return { chunk: getWhitespaceChunk(inEntity), entityMap: entityMap };
  16086. }
  16087. if (inBlock !== "pre") {
  16088. // Can't use empty string because MSWord
  16089. _text = _text.replace(REGEX_LF, SPACE);
  16090. }
  16091. // save the last block so we can use it later
  16092. lastBlock = nodeName;
  16093. return {
  16094. chunk: {
  16095. text: _text,
  16096. inlines: Array(_text.length).fill(inlineStyle),
  16097. entities: Array(_text.length).fill(inEntity),
  16098. blocks: []
  16099. },
  16100. entityMap: entityMap
  16101. };
  16102. }
  16103. // save the last block so we can use it later
  16104. lastBlock = nodeName;
  16105. // BR tags
  16106. if (nodeName === "br") {
  16107. if (lastLastBlock === "br" && (!inBlock || inBlockType === "unstyled")) {
  16108. return {
  16109. chunk: getBlockDividerChunk("unstyled", depth, parentKey),
  16110. entityMap: entityMap
  16111. };
  16112. }
  16113. return { chunk: getSoftNewlineChunk(), entityMap: entityMap };
  16114. }
  16115. // IMG tags
  16116. if (
  16117. nodeName === "img" &&
  16118. node instanceof HTMLImageElement &&
  16119. node.attributes.getNamedItem("src") &&
  16120. node.attributes.getNamedItem("src").value
  16121. ) {
  16122. var image = node;
  16123. var entityConfig = {};
  16124. imgAttr.forEach(function(attr) {
  16125. var imageAttribute = image.getAttribute(attr);
  16126. if (imageAttribute) {
  16127. entityConfig[attr] = imageAttribute;
  16128. }
  16129. });
  16130. // Forcing this node to have children because otherwise no entity will be
  16131. // created for this node.
  16132. // The child text node cannot just have a space or return as content -
  16133. // we strip those out.
  16134. // See https://github.com/facebook/draft-js/issues/231 for some context.
  16135. node.textContent = "\uD83D\uDCF7";
  16136. // TODO: update this when we remove DraftEntity entirely
  16137. inEntity = DraftEntity_1.__create("IMAGE", "MUTABLE", entityConfig || {});
  16138. }
  16139. // Inline tags
  16140. inlineStyle = processInlineTag(nodeName, node, inlineStyle);
  16141. // Handle lists
  16142. if (nodeName === "ul" || nodeName === "ol") {
  16143. if (lastList) {
  16144. depth += 1;
  16145. }
  16146. lastList = nodeName;
  16147. }
  16148. if (nodeName === "li" && node instanceof HTMLElement) {
  16149. depth = getListItemDepth(node, depth);
  16150. }
  16151. var blockType = getBlockTypeForTag(nodeName, lastList, blockRenderMap);
  16152. var inListBlock = lastList && inBlock === "li" && nodeName === "li";
  16153. var inBlockOrHasNestedBlocks =
  16154. (!inBlock || experimentalTreeDataSupport) &&
  16155. blockTags.indexOf(nodeName) !== -1;
  16156. // Block Tags
  16157. if (inListBlock || inBlockOrHasNestedBlocks) {
  16158. chunk = getBlockDividerChunk(blockType, depth, parentKey);
  16159. blockKey = chunk.blocks[0].key;
  16160. inBlock = nodeName;
  16161. newBlock = !experimentalTreeDataSupport;
  16162. }
  16163. // this is required so that we can handle 'ul' and 'ol'
  16164. if (inListBlock) {
  16165. nextBlockType =
  16166. lastList === "ul" ? "unordered-list-item" : "ordered-list-item";
  16167. }
  16168. // Recurse through children
  16169. var child = node.firstChild;
  16170. if (child != null) {
  16171. nodeName = child.nodeName.toLowerCase();
  16172. }
  16173. var entityId = null;
  16174. while (child) {
  16175. if (
  16176. child instanceof HTMLAnchorElement &&
  16177. child.href &&
  16178. hasValidLinkText(child)
  16179. ) {
  16180. (function() {
  16181. var anchor = child;
  16182. var entityConfig = {};
  16183. anchorAttr.forEach(function(attr) {
  16184. var anchorAttribute = anchor.getAttribute(attr);
  16185. if (anchorAttribute) {
  16186. entityConfig[attr] = anchorAttribute;
  16187. }
  16188. });
  16189. entityConfig.url = new URI_1(anchor.href).toString();
  16190. // TODO: update this when we remove DraftEntity completely
  16191. entityId = DraftEntity_1.__create(
  16192. "LINK",
  16193. "MUTABLE",
  16194. entityConfig || {}
  16195. );
  16196. })();
  16197. } else {
  16198. entityId = undefined;
  16199. }
  16200. var _genFragment = genFragment(
  16201. newEntityMap,
  16202. child,
  16203. inlineStyle,
  16204. lastList,
  16205. inBlock,
  16206. blockTags,
  16207. depth,
  16208. blockRenderMap,
  16209. entityId || inEntity,
  16210. null
  16211. ),
  16212. generatedChunk = _genFragment.chunk,
  16213. maybeUpdatedEntityMap = _genFragment.entityMap;
  16214. newChunk = generatedChunk;
  16215. newEntityMap = maybeUpdatedEntityMap;
  16216. chunk = joinChunks(chunk, newChunk, experimentalTreeDataSupport);
  16217. var sibling = child.nextSibling;
  16218. // Put in a newline to break up blocks inside blocks
  16219. if (!parentKey && sibling && blockTags.indexOf(nodeName) >= 0 && inBlock) {
  16220. chunk = joinChunks(chunk, getSoftNewlineChunk());
  16221. }
  16222. if (sibling) {
  16223. nodeName = sibling.nodeName.toLowerCase();
  16224. }
  16225. child = sibling;
  16226. }
  16227. if (newBlock) {
  16228. chunk = joinChunks(
  16229. chunk,
  16230. getBlockDividerChunk(nextBlockType, depth, parentKey)
  16231. );
  16232. }
  16233. return { chunk: chunk, entityMap: newEntityMap };
  16234. };
  16235. var getChunkForHTML = function getChunkForHTML(
  16236. html,
  16237. DOMBuilder,
  16238. blockRenderMap,
  16239. entityMap
  16240. ) {
  16241. html = html
  16242. .trim()
  16243. .replace(REGEX_CR, "")
  16244. .replace(REGEX_NBSP, SPACE)
  16245. .replace(REGEX_CARRIAGE, "")
  16246. .replace(REGEX_ZWS, "");
  16247. var supportedBlockTags = getBlockMapSupportedTags(blockRenderMap);
  16248. var safeBody = DOMBuilder(html);
  16249. if (!safeBody) {
  16250. return null;
  16251. }
  16252. lastBlock = null;
  16253. // Sometimes we aren't dealing with content that contains nice semantic
  16254. // tags. In this case, use divs to separate everything out into paragraphs
  16255. // and hope for the best.
  16256. var workingBlocks = containsSemanticBlockMarkup(html, supportedBlockTags)
  16257. ? supportedBlockTags
  16258. : ["div"];
  16259. // Start with -1 block depth to offset the fact that we are passing in a fake
  16260. // UL block to start with.
  16261. var fragment = genFragment(
  16262. entityMap,
  16263. safeBody,
  16264. OrderedSet$5(),
  16265. "ul",
  16266. null,
  16267. workingBlocks,
  16268. -1,
  16269. blockRenderMap
  16270. );
  16271. var chunk = fragment.chunk;
  16272. var newEntityMap = fragment.entityMap;
  16273. // join with previous block to prevent weirdness on paste
  16274. if (chunk.text.indexOf("\r") === 0) {
  16275. chunk = {
  16276. text: chunk.text.slice(1),
  16277. inlines: chunk.inlines.slice(1),
  16278. entities: chunk.entities.slice(1),
  16279. blocks: chunk.blocks
  16280. };
  16281. }
  16282. // Kill block delimiter at the end
  16283. if (chunk.text.slice(-1) === "\r") {
  16284. chunk.text = chunk.text.slice(0, -1);
  16285. chunk.inlines = chunk.inlines.slice(0, -1);
  16286. chunk.entities = chunk.entities.slice(0, -1);
  16287. chunk.blocks.pop();
  16288. }
  16289. // If we saw no block tags, put an unstyled one in
  16290. if (chunk.blocks.length === 0) {
  16291. chunk.blocks.push(
  16292. _extends$4({}, EMPTY_CHUNK, {
  16293. type: "unstyled",
  16294. depth: 0
  16295. })
  16296. );
  16297. }
  16298. // Sometimes we start with text that isn't in a block, which is then
  16299. // followed by blocks. Need to fix up the blocks to add in
  16300. // an unstyled block for this content
  16301. if (chunk.text.split("\r").length === chunk.blocks.length + 1) {
  16302. chunk.blocks.unshift({ type: "unstyled", depth: 0 });
  16303. }
  16304. return { chunk: chunk, entityMap: newEntityMap };
  16305. };
  16306. var convertChunkToContentBlocks = function convertChunkToContentBlocks(chunk) {
  16307. if (!chunk || !chunk.text || !Array.isArray(chunk.blocks)) {
  16308. return null;
  16309. }
  16310. var initialState = {
  16311. cacheRef: {},
  16312. contentBlocks: []
  16313. };
  16314. var start = 0;
  16315. var rawBlocks = chunk.blocks,
  16316. rawInlines = chunk.inlines,
  16317. rawEntities = chunk.entities;
  16318. var BlockNodeRecord = ContentBlock_1;
  16319. return chunk.text.split("\r").reduce(function(acc, textBlock, index) {
  16320. // Make absolutely certain that our text is acceptable.
  16321. textBlock = sanitizeDraftText_1(textBlock);
  16322. var block = rawBlocks[index];
  16323. var end = start + textBlock.length;
  16324. var inlines = rawInlines.slice(start, end);
  16325. var entities = rawEntities.slice(start, end);
  16326. var characterList = List$a(
  16327. inlines.map(function(style, index) {
  16328. var data = { style: style, entity: null };
  16329. if (entities[index]) {
  16330. data.entity = entities[index];
  16331. }
  16332. return CharacterMetadata_1.create(data);
  16333. })
  16334. );
  16335. start = end + 1;
  16336. var depth = block.depth,
  16337. type = block.type,
  16338. parent = block.parent;
  16339. var key = block.key || generateRandomKey_1();
  16340. var parentTextNodeKey = null; // will be used to store container text nodes
  16341. // childrens add themselves to their parents since we are iterating in order
  16342. if (parent) {
  16343. var parentIndex = acc.cacheRef[parent];
  16344. var parentRecord = acc.contentBlocks[parentIndex];
  16345. // if parent has text we need to split it into a separate unstyled element
  16346. if (parentRecord.getChildKeys().isEmpty() && parentRecord.getText()) {
  16347. var parentCharacterList = parentRecord.getCharacterList();
  16348. var parentText = parentRecord.getText();
  16349. parentTextNodeKey = generateRandomKey_1();
  16350. var textNode = new ContentBlockNode_1({
  16351. key: parentTextNodeKey,
  16352. text: parentText,
  16353. characterList: parentCharacterList,
  16354. parent: parent,
  16355. nextSibling: key
  16356. });
  16357. acc.contentBlocks.push(textNode);
  16358. parentRecord = parentRecord.withMutations(function(block) {
  16359. block
  16360. .set("characterList", List$a())
  16361. .set("text", "")
  16362. .set("children", parentRecord.children.push(textNode.getKey()));
  16363. });
  16364. }
  16365. acc.contentBlocks[parentIndex] = parentRecord.set(
  16366. "children",
  16367. parentRecord.children.push(key)
  16368. );
  16369. }
  16370. var blockNode = new BlockNodeRecord({
  16371. key: key,
  16372. parent: parent,
  16373. type: type,
  16374. depth: depth,
  16375. text: textBlock,
  16376. characterList: characterList,
  16377. prevSibling:
  16378. parentTextNodeKey ||
  16379. (index === 0 || rawBlocks[index - 1].parent !== parent
  16380. ? null
  16381. : rawBlocks[index - 1].key),
  16382. nextSibling:
  16383. index === rawBlocks.length - 1 || rawBlocks[index + 1].parent !== parent
  16384. ? null
  16385. : rawBlocks[index + 1].key
  16386. });
  16387. // insert node
  16388. acc.contentBlocks.push(blockNode);
  16389. // cache ref for building links
  16390. acc.cacheRef[blockNode.key] = index;
  16391. return acc;
  16392. }, initialState).contentBlocks;
  16393. };
  16394. var convertFromHTMLtoContentBlocks = function convertFromHTMLtoContentBlocks(
  16395. html
  16396. ) {
  16397. var DOMBuilder =
  16398. arguments.length > 1 && arguments[1] !== undefined
  16399. ? arguments[1]
  16400. : getSafeBodyFromHTML_1;
  16401. var blockRenderMap =
  16402. arguments.length > 2 && arguments[2] !== undefined
  16403. ? arguments[2]
  16404. : DefaultDraftBlockRenderMap_1;
  16405. // Be ABSOLUTELY SURE that the dom builder you pass here won't execute
  16406. // arbitrary code in whatever environment you're running this in. For an
  16407. // example of how we try to do this in-browser, see getSafeBodyFromHTML.
  16408. // TODO: replace DraftEntity with an OrderedMap here
  16409. var chunkData = getChunkForHTML(
  16410. html,
  16411. DOMBuilder,
  16412. blockRenderMap,
  16413. DraftEntity_1
  16414. );
  16415. if (chunkData == null) {
  16416. return null;
  16417. }
  16418. var chunk = chunkData.chunk,
  16419. entityMap = chunkData.entityMap;
  16420. var contentBlocks = convertChunkToContentBlocks(chunk);
  16421. return {
  16422. contentBlocks: contentBlocks,
  16423. entityMap: entityMap
  16424. };
  16425. };
  16426. var convertFromHTMLToContentBlocks = convertFromHTMLtoContentBlocks;
  16427. var List$b = immutable.List,
  16428. Repeat$6 = immutable.Repeat;
  16429. var ContentBlockRecord$2 = ContentBlock_1;
  16430. var DraftPasteProcessor = {
  16431. processHTML: function processHTML(html, blockRenderMap) {
  16432. return convertFromHTMLToContentBlocks(
  16433. html,
  16434. getSafeBodyFromHTML_1,
  16435. blockRenderMap
  16436. );
  16437. },
  16438. processText: function processText(textBlocks, character, type) {
  16439. return textBlocks.reduce(function(acc, textLine, index) {
  16440. textLine = sanitizeDraftText_1(textLine);
  16441. var key = generateRandomKey_1();
  16442. var blockNodeConfig = {
  16443. key: key,
  16444. type: type,
  16445. text: textLine,
  16446. characterList: List$b(Repeat$6(character, textLine.length))
  16447. };
  16448. acc.push(new ContentBlockRecord$2(blockNodeConfig));
  16449. return acc;
  16450. }, []);
  16451. }
  16452. };
  16453. var DraftPasteProcessor_1 = DraftPasteProcessor;
  16454. /**
  16455. * Copyright (c) 2013-present, Facebook, Inc.
  16456. * All rights reserved.
  16457. *
  16458. * This source code is licensed under the BSD-style license found in the
  16459. * LICENSE file in the root directory of this source tree. An additional grant
  16460. * of patent rights can be found in the PATENTS file in the same directory.
  16461. *
  16462. * @providesModule adjustBlockDepthForContentState
  16463. * @format
  16464. *
  16465. */
  16466. function adjustBlockDepthForContentState(
  16467. contentState,
  16468. selectionState,
  16469. adjustment,
  16470. maxDepth
  16471. ) {
  16472. var startKey = selectionState.getStartKey();
  16473. var endKey = selectionState.getEndKey();
  16474. var blockMap = contentState.getBlockMap();
  16475. var blocks = blockMap
  16476. .toSeq()
  16477. .skipUntil(function(_, k) {
  16478. return k === startKey;
  16479. })
  16480. .takeUntil(function(_, k) {
  16481. return k === endKey;
  16482. })
  16483. .concat([[endKey, blockMap.get(endKey)]])
  16484. .map(function(block) {
  16485. var depth = block.getDepth() + adjustment;
  16486. depth = Math.max(0, Math.min(depth, maxDepth));
  16487. return block.set("depth", depth);
  16488. });
  16489. blockMap = blockMap.merge(blocks);
  16490. return contentState.merge({
  16491. blockMap: blockMap,
  16492. selectionBefore: selectionState,
  16493. selectionAfter: selectionState
  16494. });
  16495. }
  16496. var adjustBlockDepthForContentState_1 = adjustBlockDepthForContentState;
  16497. var RichTextEditorUtil = {
  16498. currentBlockContainsLink: function currentBlockContainsLink(editorState) {
  16499. var selection = editorState.getSelection();
  16500. var contentState = editorState.getCurrentContent();
  16501. var entityMap = contentState.getEntityMap();
  16502. return contentState
  16503. .getBlockForKey(selection.getAnchorKey())
  16504. .getCharacterList()
  16505. .slice(selection.getStartOffset(), selection.getEndOffset())
  16506. .some(function(v) {
  16507. var entity = v.getEntity();
  16508. return !!entity && entityMap.__get(entity).getType() === "LINK";
  16509. });
  16510. },
  16511. getCurrentBlockType: function getCurrentBlockType(editorState) {
  16512. var selection = editorState.getSelection();
  16513. return editorState
  16514. .getCurrentContent()
  16515. .getBlockForKey(selection.getStartKey())
  16516. .getType();
  16517. },
  16518. getDataObjectForLinkURL: function getDataObjectForLinkURL(uri) {
  16519. return { url: uri.toString() };
  16520. },
  16521. handleKeyCommand: function handleKeyCommand(editorState, command) {
  16522. switch (command) {
  16523. case "bold":
  16524. return RichTextEditorUtil.toggleInlineStyle(editorState, "BOLD");
  16525. case "italic":
  16526. return RichTextEditorUtil.toggleInlineStyle(editorState, "ITALIC");
  16527. case "underline":
  16528. return RichTextEditorUtil.toggleInlineStyle(editorState, "UNDERLINE");
  16529. case "code":
  16530. return RichTextEditorUtil.toggleCode(editorState);
  16531. case "backspace":
  16532. case "backspace-word":
  16533. case "backspace-to-start-of-line":
  16534. return RichTextEditorUtil.onBackspace(editorState);
  16535. case "delete":
  16536. case "delete-word":
  16537. case "delete-to-end-of-block":
  16538. return RichTextEditorUtil.onDelete(editorState);
  16539. default:
  16540. // they may have custom editor commands; ignore those
  16541. return null;
  16542. }
  16543. },
  16544. insertSoftNewline: function insertSoftNewline(editorState) {
  16545. var contentState = DraftModifier_1.insertText(
  16546. editorState.getCurrentContent(),
  16547. editorState.getSelection(),
  16548. "\n",
  16549. editorState.getCurrentInlineStyle(),
  16550. null
  16551. );
  16552. var newEditorState = EditorState_1.push(
  16553. editorState,
  16554. contentState,
  16555. "insert-characters"
  16556. );
  16557. return EditorState_1.forceSelection(
  16558. newEditorState,
  16559. contentState.getSelectionAfter()
  16560. );
  16561. },
  16562. /**
  16563. * For collapsed selections at the start of styled blocks, backspace should
  16564. * just remove the existing style.
  16565. */
  16566. onBackspace: function onBackspace(editorState) {
  16567. var selection = editorState.getSelection();
  16568. if (
  16569. !selection.isCollapsed() ||
  16570. selection.getAnchorOffset() ||
  16571. selection.getFocusOffset()
  16572. ) {
  16573. return null;
  16574. }
  16575. // First, try to remove a preceding atomic block.
  16576. var content = editorState.getCurrentContent();
  16577. var startKey = selection.getStartKey();
  16578. var blockBefore = content.getBlockBefore(startKey);
  16579. if (blockBefore && blockBefore.getType() === "atomic") {
  16580. var blockMap = content.getBlockMap()["delete"](blockBefore.getKey());
  16581. var withoutAtomicBlock = content.merge({
  16582. blockMap: blockMap,
  16583. selectionAfter: selection
  16584. });
  16585. if (withoutAtomicBlock !== content) {
  16586. return EditorState_1.push(
  16587. editorState,
  16588. withoutAtomicBlock,
  16589. "remove-range"
  16590. );
  16591. }
  16592. }
  16593. // If that doesn't succeed, try to remove the current block style.
  16594. var withoutBlockStyle = RichTextEditorUtil.tryToRemoveBlockStyle(
  16595. editorState
  16596. );
  16597. if (withoutBlockStyle) {
  16598. return EditorState_1.push(
  16599. editorState,
  16600. withoutBlockStyle,
  16601. "change-block-type"
  16602. );
  16603. }
  16604. return null;
  16605. },
  16606. onDelete: function onDelete(editorState) {
  16607. var selection = editorState.getSelection();
  16608. if (!selection.isCollapsed()) {
  16609. return null;
  16610. }
  16611. var content = editorState.getCurrentContent();
  16612. var startKey = selection.getStartKey();
  16613. var block = content.getBlockForKey(startKey);
  16614. var length = block.getLength();
  16615. // The cursor is somewhere within the text. Behave normally.
  16616. if (selection.getStartOffset() < length) {
  16617. return null;
  16618. }
  16619. var blockAfter = content.getBlockAfter(startKey);
  16620. if (!blockAfter || blockAfter.getType() !== "atomic") {
  16621. return null;
  16622. }
  16623. var atomicBlockTarget = selection.merge({
  16624. focusKey: blockAfter.getKey(),
  16625. focusOffset: blockAfter.getLength()
  16626. });
  16627. var withoutAtomicBlock = DraftModifier_1.removeRange(
  16628. content,
  16629. atomicBlockTarget,
  16630. "forward"
  16631. );
  16632. if (withoutAtomicBlock !== content) {
  16633. return EditorState_1.push(
  16634. editorState,
  16635. withoutAtomicBlock,
  16636. "remove-range"
  16637. );
  16638. }
  16639. return null;
  16640. },
  16641. onTab: function onTab(event, editorState, maxDepth) {
  16642. var selection = editorState.getSelection();
  16643. var key = selection.getAnchorKey();
  16644. if (key !== selection.getFocusKey()) {
  16645. return editorState;
  16646. }
  16647. var content = editorState.getCurrentContent();
  16648. var block = content.getBlockForKey(key);
  16649. var type = block.getType();
  16650. if (type !== "unordered-list-item" && type !== "ordered-list-item") {
  16651. return editorState;
  16652. }
  16653. event.preventDefault();
  16654. // Only allow indenting one level beyond the block above, and only if
  16655. // the block above is a list item as well.
  16656. var blockAbove = content.getBlockBefore(key);
  16657. if (!blockAbove) {
  16658. return editorState;
  16659. }
  16660. var typeAbove = blockAbove.getType();
  16661. if (
  16662. typeAbove !== "unordered-list-item" &&
  16663. typeAbove !== "ordered-list-item"
  16664. ) {
  16665. return editorState;
  16666. }
  16667. var depth = block.getDepth();
  16668. if (!event.shiftKey && depth === maxDepth) {
  16669. return editorState;
  16670. }
  16671. maxDepth = Math.min(blockAbove.getDepth() + 1, maxDepth);
  16672. var withAdjustment = adjustBlockDepthForContentState_1(
  16673. content,
  16674. selection,
  16675. event.shiftKey ? -1 : 1,
  16676. maxDepth
  16677. );
  16678. return EditorState_1.push(editorState, withAdjustment, "adjust-depth");
  16679. },
  16680. toggleBlockType: function toggleBlockType(editorState, blockType) {
  16681. var selection = editorState.getSelection();
  16682. var startKey = selection.getStartKey();
  16683. var endKey = selection.getEndKey();
  16684. var content = editorState.getCurrentContent();
  16685. var target = selection;
  16686. // Triple-click can lead to a selection that includes offset 0 of the
  16687. // following block. The `SelectionState` for this case is accurate, but
  16688. // we should avoid toggling block type for the trailing block because it
  16689. // is a confusing interaction.
  16690. if (startKey !== endKey && selection.getEndOffset() === 0) {
  16691. var blockBefore = nullthrows_1(content.getBlockBefore(endKey));
  16692. endKey = blockBefore.getKey();
  16693. target = target.merge({
  16694. anchorKey: startKey,
  16695. anchorOffset: selection.getStartOffset(),
  16696. focusKey: endKey,
  16697. focusOffset: blockBefore.getLength(),
  16698. isBackward: false
  16699. });
  16700. }
  16701. var hasAtomicBlock = content
  16702. .getBlockMap()
  16703. .skipWhile(function(_, k) {
  16704. return k !== startKey;
  16705. })
  16706. .reverse()
  16707. .skipWhile(function(_, k) {
  16708. return k !== endKey;
  16709. })
  16710. .some(function(v) {
  16711. return v.getType() === "atomic";
  16712. });
  16713. if (hasAtomicBlock) {
  16714. return editorState;
  16715. }
  16716. var typeToSet =
  16717. content.getBlockForKey(startKey).getType() === blockType
  16718. ? "unstyled"
  16719. : blockType;
  16720. return EditorState_1.push(
  16721. editorState,
  16722. DraftModifier_1.setBlockType(content, target, typeToSet),
  16723. "change-block-type"
  16724. );
  16725. },
  16726. toggleCode: function toggleCode(editorState) {
  16727. var selection = editorState.getSelection();
  16728. var anchorKey = selection.getAnchorKey();
  16729. var focusKey = selection.getFocusKey();
  16730. if (selection.isCollapsed() || anchorKey !== focusKey) {
  16731. return RichTextEditorUtil.toggleBlockType(editorState, "code-block");
  16732. }
  16733. return RichTextEditorUtil.toggleInlineStyle(editorState, "CODE");
  16734. },
  16735. /**
  16736. * Toggle the specified inline style for the selection. If the
  16737. * user's selection is collapsed, apply or remove the style for the
  16738. * internal state. If it is not collapsed, apply the change directly
  16739. * to the document state.
  16740. */
  16741. toggleInlineStyle: function toggleInlineStyle(editorState, inlineStyle) {
  16742. var selection = editorState.getSelection();
  16743. var currentStyle = editorState.getCurrentInlineStyle();
  16744. // If the selection is collapsed, toggle the specified style on or off and
  16745. // set the result as the new inline style override. This will then be
  16746. // used as the inline style for the next character to be inserted.
  16747. if (selection.isCollapsed()) {
  16748. return EditorState_1.setInlineStyleOverride(
  16749. editorState,
  16750. currentStyle.has(inlineStyle)
  16751. ? currentStyle.remove(inlineStyle)
  16752. : currentStyle.add(inlineStyle)
  16753. );
  16754. }
  16755. // If characters are selected, immediately apply or remove the
  16756. // inline style on the document state itself.
  16757. var content = editorState.getCurrentContent();
  16758. var newContent;
  16759. // If the style is already present for the selection range, remove it.
  16760. // Otherwise, apply it.
  16761. if (currentStyle.has(inlineStyle)) {
  16762. newContent = DraftModifier_1.removeInlineStyle(
  16763. content,
  16764. selection,
  16765. inlineStyle
  16766. );
  16767. } else {
  16768. newContent = DraftModifier_1.applyInlineStyle(
  16769. content,
  16770. selection,
  16771. inlineStyle
  16772. );
  16773. }
  16774. return EditorState_1.push(editorState, newContent, "change-inline-style");
  16775. },
  16776. toggleLink: function toggleLink(editorState, targetSelection, entityKey) {
  16777. var withoutLink = DraftModifier_1.applyEntity(
  16778. editorState.getCurrentContent(),
  16779. targetSelection,
  16780. entityKey
  16781. );
  16782. return EditorState_1.push(editorState, withoutLink, "apply-entity");
  16783. },
  16784. /**
  16785. * When a collapsed cursor is at the start of the first styled block, or
  16786. * an empty styled block, changes block to 'unstyled'. Returns null if
  16787. * block or selection does not meet that criteria.
  16788. */
  16789. tryToRemoveBlockStyle: function tryToRemoveBlockStyle(editorState) {
  16790. var selection = editorState.getSelection();
  16791. var offset = selection.getAnchorOffset();
  16792. if (selection.isCollapsed() && offset === 0) {
  16793. var key = selection.getAnchorKey();
  16794. var content = editorState.getCurrentContent();
  16795. var block = content.getBlockForKey(key);
  16796. var firstBlock = content.getFirstBlock();
  16797. if (block.getLength() > 0 && block !== firstBlock) {
  16798. return null;
  16799. }
  16800. var type = block.getType();
  16801. var blockBefore = content.getBlockBefore(key);
  16802. if (
  16803. type === "code-block" &&
  16804. blockBefore &&
  16805. blockBefore.getType() === "code-block" &&
  16806. blockBefore.getLength() !== 0
  16807. ) {
  16808. return null;
  16809. }
  16810. if (type !== "unstyled") {
  16811. return DraftModifier_1.setBlockType(content, selection, "unstyled");
  16812. }
  16813. }
  16814. return null;
  16815. }
  16816. };
  16817. var RichTextEditorUtil_1 = RichTextEditorUtil;
  16818. /**
  16819. * Copyright (c) 2013-present, Facebook, Inc.
  16820. * All rights reserved.
  16821. *
  16822. * This source code is licensed under the BSD-style license found in the
  16823. * LICENSE file in the root directory of this source tree. An additional grant
  16824. * of patent rights can be found in the PATENTS file in the same directory.
  16825. *
  16826. * @providesModule splitTextIntoTextBlocks
  16827. * @format
  16828. *
  16829. */
  16830. var NEWLINE_REGEX = /\r\n?|\n/g;
  16831. function splitTextIntoTextBlocks(text) {
  16832. return text.split(NEWLINE_REGEX);
  16833. }
  16834. var splitTextIntoTextBlocks_1 = splitTextIntoTextBlocks;
  16835. /**
  16836. * Paste content.
  16837. */
  16838. function editOnPaste(editor, e) {
  16839. e.preventDefault();
  16840. var data = new DataTransfer_1(e.clipboardData);
  16841. // Get files, unless this is likely to be a string the user wants inline.
  16842. if (!data.isRichText()) {
  16843. var files = data.getFiles();
  16844. var defaultFileText = data.getText();
  16845. if (files.length > 0) {
  16846. // Allow customized paste handling for images, etc. Otherwise, fall
  16847. // through to insert text contents into the editor.
  16848. if (
  16849. editor.props.handlePastedFiles &&
  16850. isEventHandled_1(editor.props.handlePastedFiles(files))
  16851. ) {
  16852. return;
  16853. }
  16854. getTextContentFromFiles_1(files, function(/*string*/ fileText) {
  16855. fileText = fileText || defaultFileText;
  16856. if (!fileText) {
  16857. return;
  16858. }
  16859. var editorState = editor._latestEditorState;
  16860. var blocks = splitTextIntoTextBlocks_1(fileText);
  16861. var character = CharacterMetadata_1.create({
  16862. style: editorState.getCurrentInlineStyle(),
  16863. entity: getEntityKeyForSelection_1(
  16864. editorState.getCurrentContent(),
  16865. editorState.getSelection()
  16866. )
  16867. });
  16868. var currentBlockType = RichTextEditorUtil_1.getCurrentBlockType(
  16869. editorState
  16870. );
  16871. var text = DraftPasteProcessor_1.processText(
  16872. blocks,
  16873. character,
  16874. currentBlockType
  16875. );
  16876. var fragment = BlockMapBuilder_1.createFromArray(text);
  16877. var withInsertedText = DraftModifier_1.replaceWithFragment(
  16878. editorState.getCurrentContent(),
  16879. editorState.getSelection(),
  16880. fragment
  16881. );
  16882. editor.update(
  16883. EditorState_1.push(editorState, withInsertedText, "insert-fragment")
  16884. );
  16885. });
  16886. return;
  16887. }
  16888. }
  16889. var textBlocks = [];
  16890. var text = data.getText();
  16891. var html = data.getHTML();
  16892. var editorState = editor._latestEditorState;
  16893. if (
  16894. editor.props.handlePastedText &&
  16895. isEventHandled_1(editor.props.handlePastedText(text, html, editorState))
  16896. ) {
  16897. return;
  16898. }
  16899. if (text) {
  16900. textBlocks = splitTextIntoTextBlocks_1(text);
  16901. }
  16902. if (!editor.props.stripPastedStyles) {
  16903. // If the text from the paste event is rich content that matches what we
  16904. // already have on the internal clipboard, assume that we should just use
  16905. // the clipboard fragment for the paste. This will allow us to preserve
  16906. // styling and entities, if any are present. Note that newlines are
  16907. // stripped during comparison -- this is because copy/paste within the
  16908. // editor in Firefox and IE will not include empty lines. The resulting
  16909. // paste will preserve the newlines correctly.
  16910. var internalClipboard = editor.getClipboard();
  16911. if (data.isRichText() && internalClipboard) {
  16912. if (
  16913. // If the editorKey is present in the pasted HTML, it should be safe to
  16914. // assume this is an internal paste.
  16915. html.indexOf(editor.getEditorKey()) !== -1 ||
  16916. // The copy may have been made within a single block, in which case the
  16917. // editor key won't be part of the paste. In this case, just check
  16918. // whether the pasted text matches the internal clipboard.
  16919. (textBlocks.length === 1 &&
  16920. internalClipboard.size === 1 &&
  16921. internalClipboard.first().getText() === text)
  16922. ) {
  16923. editor.update(
  16924. insertFragment$1(editor._latestEditorState, internalClipboard)
  16925. );
  16926. return;
  16927. }
  16928. } else if (
  16929. internalClipboard &&
  16930. data.types.includes("com.apple.webarchive") &&
  16931. !data.types.includes("text/html") &&
  16932. areTextBlocksAndClipboardEqual(textBlocks, internalClipboard)
  16933. ) {
  16934. // Safari does not properly store text/html in some cases.
  16935. // Use the internalClipboard if present and equal to what is on
  16936. // the clipboard. See https://bugs.webkit.org/show_bug.cgi?id=19893.
  16937. editor.update(
  16938. insertFragment$1(editor._latestEditorState, internalClipboard)
  16939. );
  16940. return;
  16941. }
  16942. // If there is html paste data, try to parse that.
  16943. if (html) {
  16944. var htmlFragment = DraftPasteProcessor_1.processHTML(
  16945. html,
  16946. editor.props.blockRenderMap
  16947. );
  16948. if (htmlFragment) {
  16949. var contentBlocks = htmlFragment.contentBlocks,
  16950. entityMap = htmlFragment.entityMap;
  16951. if (contentBlocks) {
  16952. var htmlMap = BlockMapBuilder_1.createFromArray(contentBlocks);
  16953. editor.update(
  16954. insertFragment$1(editor._latestEditorState, htmlMap, entityMap)
  16955. );
  16956. return;
  16957. }
  16958. }
  16959. }
  16960. // Otherwise, create a new fragment from our pasted text. Also
  16961. // empty the internal clipboard, since it's no longer valid.
  16962. editor.setClipboard(null);
  16963. }
  16964. if (textBlocks.length) {
  16965. var character = CharacterMetadata_1.create({
  16966. style: editorState.getCurrentInlineStyle(),
  16967. entity: getEntityKeyForSelection_1(
  16968. editorState.getCurrentContent(),
  16969. editorState.getSelection()
  16970. )
  16971. });
  16972. var currentBlockType = RichTextEditorUtil_1.getCurrentBlockType(
  16973. editorState
  16974. );
  16975. var textFragment = DraftPasteProcessor_1.processText(
  16976. textBlocks,
  16977. character,
  16978. currentBlockType
  16979. );
  16980. var textMap = BlockMapBuilder_1.createFromArray(textFragment);
  16981. editor.update(insertFragment$1(editor._latestEditorState, textMap));
  16982. }
  16983. }
  16984. function insertFragment$1(editorState, fragment, entityMap) {
  16985. var newContent = DraftModifier_1.replaceWithFragment(
  16986. editorState.getCurrentContent(),
  16987. editorState.getSelection(),
  16988. fragment
  16989. );
  16990. // TODO: merge the entity map once we stop using DraftEntity
  16991. // like this:
  16992. // const mergedEntityMap = newContent.getEntityMap().merge(entityMap);
  16993. return EditorState_1.push(
  16994. editorState,
  16995. newContent.set("entityMap", entityMap),
  16996. "insert-fragment"
  16997. );
  16998. }
  16999. function areTextBlocksAndClipboardEqual(textBlocks, blockMap) {
  17000. return (
  17001. textBlocks.length === blockMap.size &&
  17002. blockMap.valueSeq().every(function(block, ii) {
  17003. return block.getText() === textBlocks[ii];
  17004. })
  17005. );
  17006. }
  17007. var editOnPaste_1 = editOnPaste;
  17008. /**
  17009. * Convert the current selection range to an anchor/focus pair of offset keys
  17010. * and values that can be interpreted by components.
  17011. */
  17012. function getDraftEditorSelection(editorState, root) {
  17013. var selection = _commonjsHelpers.commonjsGlobal.getSelection();
  17014. // No active selection.
  17015. if (selection.rangeCount === 0) {
  17016. return {
  17017. selectionState: editorState.getSelection().set("hasFocus", false),
  17018. needsRecovery: false
  17019. };
  17020. }
  17021. return getDraftEditorSelectionWithNodes_1(
  17022. editorState,
  17023. root,
  17024. selection.anchorNode,
  17025. selection.anchorOffset,
  17026. selection.focusNode,
  17027. selection.focusOffset
  17028. );
  17029. }
  17030. var getDraftEditorSelection_1 = getDraftEditorSelection;
  17031. function editOnSelect(editor) {
  17032. if (
  17033. editor._blockSelectEvents ||
  17034. editor._latestEditorState !== editor.props.editorState
  17035. ) {
  17036. return;
  17037. }
  17038. var editorState = editor.props.editorState;
  17039. var editorNode = reactDom__default.findDOMNode(editor.editorContainer);
  17040. !editorNode
  17041. ? process.env.NODE_ENV !== "production"
  17042. ? invariant_1(false, "Missing editorNode")
  17043. : invariant_1(false)
  17044. : void 0;
  17045. !(editorNode.firstChild instanceof HTMLElement)
  17046. ? process.env.NODE_ENV !== "production"
  17047. ? invariant_1(false, "editorNode.firstChild is not an HTMLElement")
  17048. : invariant_1(false)
  17049. : void 0;
  17050. var documentSelection = getDraftEditorSelection_1(
  17051. editorState,
  17052. editorNode.firstChild
  17053. );
  17054. var updatedSelectionState = documentSelection.selectionState;
  17055. if (updatedSelectionState !== editorState.getSelection()) {
  17056. if (documentSelection.needsRecovery) {
  17057. editorState = EditorState_1.forceSelection(
  17058. editorState,
  17059. updatedSelectionState
  17060. );
  17061. } else {
  17062. editorState = EditorState_1.acceptSelection(
  17063. editorState,
  17064. updatedSelectionState
  17065. );
  17066. }
  17067. editor.update(editorState);
  17068. }
  17069. }
  17070. var editOnSelect_1 = editOnSelect;
  17071. var DraftEditorEditHandler = {
  17072. onBeforeInput: editOnBeforeInput_1,
  17073. onBlur: editOnBlur_1,
  17074. onCompositionStart: editOnCompositionStart_1,
  17075. onCopy: editOnCopy_1,
  17076. onCut: editOnCut_1,
  17077. onDragOver: editOnDragOver_1,
  17078. onDragStart: editOnDragStart_1,
  17079. onFocus: editOnFocus_1,
  17080. onInput: editOnInput_1,
  17081. onKeyDown: editOnKeyDown_1,
  17082. onPaste: editOnPaste_1,
  17083. onSelect: editOnSelect_1
  17084. };
  17085. var DraftEditorEditHandler_1 = DraftEditorEditHandler;
  17086. function _classCallCheck$f(instance, Constructor) {
  17087. if (!(instance instanceof Constructor)) {
  17088. throw new TypeError("Cannot call a class as a function");
  17089. }
  17090. }
  17091. function _possibleConstructorReturn$a(self, call) {
  17092. if (!self) {
  17093. throw new ReferenceError(
  17094. "this hasn't been initialised - super() hasn't been called"
  17095. );
  17096. }
  17097. return call && (typeof call === "object" || typeof call === "function")
  17098. ? call
  17099. : self;
  17100. }
  17101. function _inherits$a(subClass, superClass) {
  17102. if (typeof superClass !== "function" && superClass !== null) {
  17103. throw new TypeError(
  17104. "Super expression must either be null or a function, not " +
  17105. typeof superClass
  17106. );
  17107. }
  17108. subClass.prototype = Object.create(superClass && superClass.prototype, {
  17109. constructor: {
  17110. value: subClass,
  17111. enumerable: false,
  17112. writable: true,
  17113. configurable: true
  17114. }
  17115. });
  17116. if (superClass)
  17117. Object.setPrototypeOf
  17118. ? Object.setPrototypeOf(subClass, superClass)
  17119. : (subClass.__proto__ = superClass);
  17120. }
  17121. /**
  17122. * This component is responsible for rendering placeholder text for the
  17123. * `DraftEditor` component.
  17124. *
  17125. * Override placeholder style via CSS.
  17126. */
  17127. var DraftEditorPlaceholder = (function(_React$Component) {
  17128. _inherits$a(DraftEditorPlaceholder, _React$Component);
  17129. function DraftEditorPlaceholder() {
  17130. _classCallCheck$f(this, DraftEditorPlaceholder);
  17131. return _possibleConstructorReturn$a(
  17132. this,
  17133. _React$Component.apply(this, arguments)
  17134. );
  17135. }
  17136. DraftEditorPlaceholder.prototype.shouldComponentUpdate = function shouldComponentUpdate(
  17137. nextProps
  17138. ) {
  17139. return (
  17140. this.props.text !== nextProps.text ||
  17141. this.props.editorState.getSelection().getHasFocus() !==
  17142. nextProps.editorState.getSelection().getHasFocus()
  17143. );
  17144. };
  17145. DraftEditorPlaceholder.prototype.render = function render() {
  17146. var hasFocus = this.props.editorState.getSelection().getHasFocus();
  17147. var className = cx_1({
  17148. "public/DraftEditorPlaceholder/root": true,
  17149. "public/DraftEditorPlaceholder/hasFocus": hasFocus
  17150. });
  17151. var contentStyle = {
  17152. whiteSpace: "pre-wrap"
  17153. };
  17154. return React__default.createElement(
  17155. "div",
  17156. { className: className },
  17157. React__default.createElement(
  17158. "div",
  17159. {
  17160. className: cx_1("public/DraftEditorPlaceholder/inner"),
  17161. id: this.props.accessibilityID,
  17162. style: contentStyle
  17163. },
  17164. this.props.text
  17165. )
  17166. );
  17167. };
  17168. return DraftEditorPlaceholder;
  17169. })(React__default.Component);
  17170. var DraftEditorPlaceholder_react = DraftEditorPlaceholder;
  17171. var isOSX$1 = UserAgent_1.isPlatform("Mac OS X");
  17172. var isWindows = UserAgent_1.isPlatform("Windows");
  17173. // Firefox on OSX had a bug resulting in navigation instead of cursor movement.
  17174. // This bug was fixed in Firefox 29. Feature detection is virtually impossible
  17175. // so we just check the version number. See #342765.
  17176. var shouldFixFirefoxMovement = isOSX$1 && UserAgent_1.isBrowser("Firefox < 29");
  17177. var hasCommandModifier = KeyBindingUtil_1.hasCommandModifier,
  17178. isCtrlKeyCommand = KeyBindingUtil_1.isCtrlKeyCommand;
  17179. function shouldRemoveWord(e) {
  17180. return (isOSX$1 && e.altKey) || isCtrlKeyCommand(e);
  17181. }
  17182. /**
  17183. * Get the appropriate undo/redo command for a Z key command.
  17184. */
  17185. function getZCommand(e) {
  17186. if (!hasCommandModifier(e)) {
  17187. return null;
  17188. }
  17189. return e.shiftKey ? "redo" : "undo";
  17190. }
  17191. function getDeleteCommand(e) {
  17192. // Allow default "cut" behavior for Windows on Shift + Delete.
  17193. if (isWindows && e.shiftKey) {
  17194. return null;
  17195. }
  17196. return shouldRemoveWord(e) ? "delete-word" : "delete";
  17197. }
  17198. function getBackspaceCommand(e) {
  17199. if (hasCommandModifier(e) && isOSX$1) {
  17200. return "backspace-to-start-of-line";
  17201. }
  17202. return shouldRemoveWord(e) ? "backspace-word" : "backspace";
  17203. }
  17204. /**
  17205. * Retrieve a bound key command for the given event.
  17206. */
  17207. function getDefaultKeyBinding(e) {
  17208. switch (e.keyCode) {
  17209. case 66:
  17210. // B
  17211. return hasCommandModifier(e) ? "bold" : null;
  17212. case 68:
  17213. // D
  17214. return isCtrlKeyCommand(e) ? "delete" : null;
  17215. case 72:
  17216. // H
  17217. return isCtrlKeyCommand(e) ? "backspace" : null;
  17218. case 73:
  17219. // I
  17220. return hasCommandModifier(e) ? "italic" : null;
  17221. case 74:
  17222. // J
  17223. return hasCommandModifier(e) ? "code" : null;
  17224. case 75:
  17225. // K
  17226. return !isWindows && isCtrlKeyCommand(e) ? "secondary-cut" : null;
  17227. case 77:
  17228. // M
  17229. return isCtrlKeyCommand(e) ? "split-block" : null;
  17230. case 79:
  17231. // O
  17232. return isCtrlKeyCommand(e) ? "split-block" : null;
  17233. case 84:
  17234. // T
  17235. return isOSX$1 && isCtrlKeyCommand(e) ? "transpose-characters" : null;
  17236. case 85:
  17237. // U
  17238. return hasCommandModifier(e) ? "underline" : null;
  17239. case 87:
  17240. // W
  17241. return isOSX$1 && isCtrlKeyCommand(e) ? "backspace-word" : null;
  17242. case 89:
  17243. // Y
  17244. if (isCtrlKeyCommand(e)) {
  17245. return isWindows ? "redo" : "secondary-paste";
  17246. }
  17247. return null;
  17248. case 90:
  17249. // Z
  17250. return getZCommand(e) || null;
  17251. case Keys.RETURN:
  17252. return "split-block";
  17253. case Keys.DELETE:
  17254. return getDeleteCommand(e);
  17255. case Keys.BACKSPACE:
  17256. return getBackspaceCommand(e);
  17257. // LEFT/RIGHT handlers serve as a workaround for a Firefox bug.
  17258. case Keys.LEFT:
  17259. return shouldFixFirefoxMovement && hasCommandModifier(e)
  17260. ? "move-selection-to-start-of-block"
  17261. : null;
  17262. case Keys.RIGHT:
  17263. return shouldFixFirefoxMovement && hasCommandModifier(e)
  17264. ? "move-selection-to-end-of-block"
  17265. : null;
  17266. default:
  17267. return null;
  17268. }
  17269. }
  17270. var getDefaultKeyBinding_1 = getDefaultKeyBinding;
  17271. var _extends$5 =
  17272. objectAssign ||
  17273. function(target) {
  17274. for (var i = 1; i < arguments.length; i++) {
  17275. var source = arguments[i];
  17276. for (var key in source) {
  17277. if (Object.prototype.hasOwnProperty.call(source, key)) {
  17278. target[key] = source[key];
  17279. }
  17280. }
  17281. }
  17282. return target;
  17283. };
  17284. function _classCallCheck$g(instance, Constructor) {
  17285. if (!(instance instanceof Constructor)) {
  17286. throw new TypeError("Cannot call a class as a function");
  17287. }
  17288. }
  17289. function _possibleConstructorReturn$b(self, call) {
  17290. if (!self) {
  17291. throw new ReferenceError(
  17292. "this hasn't been initialised - super() hasn't been called"
  17293. );
  17294. }
  17295. return call && (typeof call === "object" || typeof call === "function")
  17296. ? call
  17297. : self;
  17298. }
  17299. function _inherits$b(subClass, superClass) {
  17300. if (typeof superClass !== "function" && superClass !== null) {
  17301. throw new TypeError(
  17302. "Super expression must either be null or a function, not " +
  17303. typeof superClass
  17304. );
  17305. }
  17306. subClass.prototype = Object.create(superClass && superClass.prototype, {
  17307. constructor: {
  17308. value: subClass,
  17309. enumerable: false,
  17310. writable: true,
  17311. configurable: true
  17312. }
  17313. });
  17314. if (superClass)
  17315. Object.setPrototypeOf
  17316. ? Object.setPrototypeOf(subClass, superClass)
  17317. : (subClass.__proto__ = superClass);
  17318. }
  17319. var isIE = UserAgent_1.isBrowser("IE");
  17320. // IE does not support the `input` event on contentEditable, so we can't
  17321. // observe spellcheck behavior.
  17322. var allowSpellCheck = !isIE;
  17323. // Define a set of handler objects to correspond to each possible `mode`
  17324. // of editor behavior.
  17325. var handlerMap = {
  17326. edit: DraftEditorEditHandler_1,
  17327. composite: DraftEditorCompositionHandler_1,
  17328. drag: DraftEditorDragHandler_1,
  17329. cut: null,
  17330. render: null
  17331. };
  17332. /**
  17333. * `DraftEditor` is the root editor component. It composes a `contentEditable`
  17334. * div, and provides a wide variety of useful function props for managing the
  17335. * state of the editor. See `DraftEditorProps` for details.
  17336. */
  17337. var DraftEditor = (function(_React$Component) {
  17338. _inherits$b(DraftEditor, _React$Component);
  17339. function DraftEditor(props) {
  17340. _classCallCheck$g(this, DraftEditor);
  17341. var _this = _possibleConstructorReturn$b(
  17342. this,
  17343. _React$Component.call(this, props)
  17344. );
  17345. _this.focus = function(scrollPosition) {
  17346. var editorState = _this.props.editorState;
  17347. var alreadyHasFocus = editorState.getSelection().getHasFocus();
  17348. var editorNode = reactDom__default.findDOMNode(_this.editor);
  17349. if (!editorNode) {
  17350. // once in a while people call 'focus' in a setTimeout, and the node has
  17351. // been deleted, so it can be null in that case.
  17352. return;
  17353. }
  17354. var scrollParent = Style_1.getScrollParent(editorNode);
  17355. var _ref = scrollPosition || getScrollPosition_1(scrollParent),
  17356. x = _ref.x,
  17357. y = _ref.y;
  17358. !(editorNode instanceof HTMLElement)
  17359. ? process.env.NODE_ENV !== "production"
  17360. ? invariant_1(false, "editorNode is not an HTMLElement")
  17361. : invariant_1(false)
  17362. : void 0;
  17363. editorNode.focus();
  17364. // Restore scroll position
  17365. if (scrollParent === window) {
  17366. window.scrollTo(x, y);
  17367. } else {
  17368. Scroll_1.setTop(scrollParent, y);
  17369. }
  17370. // On Chrome and Safari, calling focus on contenteditable focuses the
  17371. // cursor at the first character. This is something you don't expect when
  17372. // you're clicking on an input element but not directly on a character.
  17373. // Put the cursor back where it was before the blur.
  17374. if (!alreadyHasFocus) {
  17375. _this.update(
  17376. EditorState_1.forceSelection(editorState, editorState.getSelection())
  17377. );
  17378. }
  17379. };
  17380. _this.blur = function() {
  17381. var editorNode = reactDom__default.findDOMNode(_this.editor);
  17382. !(editorNode instanceof HTMLElement)
  17383. ? process.env.NODE_ENV !== "production"
  17384. ? invariant_1(false, "editorNode is not an HTMLElement")
  17385. : invariant_1(false)
  17386. : void 0;
  17387. editorNode.blur();
  17388. };
  17389. _this.setMode = function(mode) {
  17390. _this._handler = handlerMap[mode];
  17391. };
  17392. _this.exitCurrentMode = function() {
  17393. _this.setMode("edit");
  17394. };
  17395. _this.restoreEditorDOM = function(scrollPosition) {
  17396. _this.setState({ contentsKey: _this.state.contentsKey + 1 }, function() {
  17397. _this.focus(scrollPosition);
  17398. });
  17399. };
  17400. _this.setClipboard = function(clipboard) {
  17401. _this._clipboard = clipboard;
  17402. };
  17403. _this.getClipboard = function() {
  17404. return _this._clipboard;
  17405. };
  17406. _this.update = function(editorState) {
  17407. _this._latestEditorState = editorState;
  17408. _this.props.onChange(editorState);
  17409. };
  17410. _this.onDragEnter = function() {
  17411. _this._dragCount++;
  17412. };
  17413. _this.onDragLeave = function() {
  17414. _this._dragCount--;
  17415. if (_this._dragCount === 0) {
  17416. _this.exitCurrentMode();
  17417. }
  17418. };
  17419. _this._blockSelectEvents = false;
  17420. _this._clipboard = null;
  17421. _this._handler = null;
  17422. _this._dragCount = 0;
  17423. _this._editorKey = props.editorKey || generateRandomKey_1();
  17424. _this._placeholderAccessibilityID = "placeholder-" + _this._editorKey;
  17425. _this._latestEditorState = props.editorState;
  17426. _this._latestCommittedEditorState = props.editorState;
  17427. _this._onBeforeInput = _this._buildHandler("onBeforeInput");
  17428. _this._onBlur = _this._buildHandler("onBlur");
  17429. _this._onCharacterData = _this._buildHandler("onCharacterData");
  17430. _this._onCompositionEnd = _this._buildHandler("onCompositionEnd");
  17431. _this._onCompositionStart = _this._buildHandler("onCompositionStart");
  17432. _this._onCopy = _this._buildHandler("onCopy");
  17433. _this._onCut = _this._buildHandler("onCut");
  17434. _this._onDragEnd = _this._buildHandler("onDragEnd");
  17435. _this._onDragOver = _this._buildHandler("onDragOver");
  17436. _this._onDragStart = _this._buildHandler("onDragStart");
  17437. _this._onDrop = _this._buildHandler("onDrop");
  17438. _this._onInput = _this._buildHandler("onInput");
  17439. _this._onFocus = _this._buildHandler("onFocus");
  17440. _this._onKeyDown = _this._buildHandler("onKeyDown");
  17441. _this._onKeyPress = _this._buildHandler("onKeyPress");
  17442. _this._onKeyUp = _this._buildHandler("onKeyUp");
  17443. _this._onMouseDown = _this._buildHandler("onMouseDown");
  17444. _this._onMouseUp = _this._buildHandler("onMouseUp");
  17445. _this._onPaste = _this._buildHandler("onPaste");
  17446. _this._onSelect = _this._buildHandler("onSelect");
  17447. _this.getEditorKey = function() {
  17448. return _this._editorKey;
  17449. };
  17450. // See `restoreEditorDOM()`.
  17451. _this.state = { contentsKey: 0 };
  17452. return _this;
  17453. }
  17454. /**
  17455. * Build a method that will pass the event to the specified handler method.
  17456. * This allows us to look up the correct handler function for the current
  17457. * editor mode, if any has been specified.
  17458. */
  17459. /**
  17460. * Define proxies that can route events to the current handler.
  17461. */
  17462. DraftEditor.prototype._buildHandler = function _buildHandler(eventName) {
  17463. var _this2 = this;
  17464. return function(e) {
  17465. if (!_this2.props.readOnly) {
  17466. var method = _this2._handler && _this2._handler[eventName];
  17467. method && method(_this2, e);
  17468. }
  17469. };
  17470. };
  17471. DraftEditor.prototype._showPlaceholder = function _showPlaceholder() {
  17472. return (
  17473. !!this.props.placeholder &&
  17474. !this.props.editorState.isInCompositionMode() &&
  17475. !this.props.editorState.getCurrentContent().hasText()
  17476. );
  17477. };
  17478. DraftEditor.prototype._renderPlaceholder = function _renderPlaceholder() {
  17479. if (this._showPlaceholder()) {
  17480. var placeHolderProps = {
  17481. text: nullthrows_1(this.props.placeholder),
  17482. editorState: this.props.editorState,
  17483. textAlignment: this.props.textAlignment,
  17484. accessibilityID: this._placeholderAccessibilityID
  17485. };
  17486. return React__default.createElement(
  17487. DraftEditorPlaceholder_react,
  17488. placeHolderProps
  17489. );
  17490. }
  17491. return null;
  17492. };
  17493. DraftEditor.prototype.render = function render() {
  17494. var _this3 = this;
  17495. var _props = this.props,
  17496. blockRenderMap = _props.blockRenderMap,
  17497. blockRendererFn = _props.blockRendererFn,
  17498. blockStyleFn = _props.blockStyleFn,
  17499. customStyleFn = _props.customStyleFn,
  17500. customStyleMap = _props.customStyleMap,
  17501. editorState = _props.editorState,
  17502. readOnly = _props.readOnly,
  17503. textAlignment = _props.textAlignment,
  17504. textDirectionality = _props.textDirectionality;
  17505. var rootClass = cx_1({
  17506. "DraftEditor/root": true,
  17507. "DraftEditor/alignLeft": textAlignment === "left",
  17508. "DraftEditor/alignRight": textAlignment === "right",
  17509. "DraftEditor/alignCenter": textAlignment === "center"
  17510. });
  17511. var contentStyle = {
  17512. outline: "none",
  17513. // fix parent-draggable Safari bug. #1326
  17514. userSelect: "text",
  17515. WebkitUserSelect: "text",
  17516. whiteSpace: "pre-wrap",
  17517. wordWrap: "break-word"
  17518. };
  17519. // The aria-expanded and aria-haspopup properties should only be rendered
  17520. // for a combobox.
  17521. var ariaRole = this.props.role || "textbox";
  17522. var ariaExpanded =
  17523. ariaRole === "combobox" ? !!this.props.ariaExpanded : null;
  17524. var editorContentsProps = {
  17525. blockRenderMap: blockRenderMap,
  17526. blockRendererFn: blockRendererFn,
  17527. blockStyleFn: blockStyleFn,
  17528. customStyleMap: _extends$5({}, DefaultDraftInlineStyle, customStyleMap),
  17529. customStyleFn: customStyleFn,
  17530. editorKey: this._editorKey,
  17531. editorState: editorState,
  17532. key: "contents" + this.state.contentsKey,
  17533. textDirectionality: textDirectionality
  17534. };
  17535. return React__default.createElement(
  17536. "div",
  17537. { className: rootClass },
  17538. this._renderPlaceholder(),
  17539. React__default.createElement(
  17540. "div",
  17541. {
  17542. className: cx_1("DraftEditor/editorContainer"),
  17543. ref: function ref(_ref3) {
  17544. return (_this3.editorContainer = _ref3);
  17545. }
  17546. },
  17547. React__default.createElement(
  17548. "div",
  17549. {
  17550. "aria-activedescendant": readOnly
  17551. ? null
  17552. : this.props.ariaActiveDescendantID,
  17553. "aria-autocomplete": readOnly ? null : this.props.ariaAutoComplete,
  17554. "aria-controls": readOnly ? null : this.props.ariaControls,
  17555. "aria-describedby":
  17556. this.props.ariaDescribedBy || this._placeholderAccessibilityID,
  17557. "aria-expanded": readOnly ? null : ariaExpanded,
  17558. "aria-label": this.props.ariaLabel,
  17559. "aria-labelledby": this.props.ariaLabelledBy,
  17560. "aria-multiline": this.props.ariaMultiline,
  17561. autoCapitalize: this.props.autoCapitalize,
  17562. autoComplete: this.props.autoComplete,
  17563. autoCorrect: this.props.autoCorrect,
  17564. className: cx_1({
  17565. // Chrome's built-in translation feature mutates the DOM in ways
  17566. // that Draft doesn't expect (ex: adding <font> tags inside
  17567. // DraftEditorLeaf spans) and causes problems. We add notranslate
  17568. // here which makes its autotranslation skip over this subtree.
  17569. notranslate: !readOnly,
  17570. "public/DraftEditor/content": true
  17571. }),
  17572. contentEditable: !readOnly,
  17573. "data-testid": this.props.webDriverTestID,
  17574. onBeforeInput: this._onBeforeInput,
  17575. onBlur: this._onBlur,
  17576. onCompositionEnd: this._onCompositionEnd,
  17577. onCompositionStart: this._onCompositionStart,
  17578. onCopy: this._onCopy,
  17579. onCut: this._onCut,
  17580. onDragEnd: this._onDragEnd,
  17581. onDragEnter: this.onDragEnter,
  17582. onDragLeave: this.onDragLeave,
  17583. onDragOver: this._onDragOver,
  17584. onDragStart: this._onDragStart,
  17585. onDrop: this._onDrop,
  17586. onFocus: this._onFocus,
  17587. onInput: this._onInput,
  17588. onKeyDown: this._onKeyDown,
  17589. onKeyPress: this._onKeyPress,
  17590. onKeyUp: this._onKeyUp,
  17591. onMouseUp: this._onMouseUp,
  17592. onPaste: this._onPaste,
  17593. onSelect: this._onSelect,
  17594. ref: function ref(_ref2) {
  17595. return (_this3.editor = _ref2);
  17596. },
  17597. role: readOnly ? null : ariaRole,
  17598. spellCheck: allowSpellCheck && this.props.spellCheck,
  17599. style: contentStyle,
  17600. suppressContentEditableWarning: true,
  17601. tabIndex: this.props.tabIndex
  17602. },
  17603. React__default.createElement(
  17604. DraftEditorContents_react,
  17605. editorContentsProps
  17606. )
  17607. )
  17608. )
  17609. );
  17610. };
  17611. DraftEditor.prototype.componentDidMount = function componentDidMount() {
  17612. this.setMode("edit");
  17613. /**
  17614. * IE has a hardcoded "feature" that attempts to convert link text into
  17615. * anchors in contentEditable DOM. This breaks the editor's expectations of
  17616. * the DOM, and control is lost. Disable it to make IE behave.
  17617. * See: http://blogs.msdn.com/b/ieinternals/archive/2010/09/15/
  17618. * ie9-beta-minor-change-list.aspx
  17619. */
  17620. if (isIE) {
  17621. document.execCommand("AutoUrlDetect", false, false);
  17622. }
  17623. };
  17624. /**
  17625. * Prevent selection events from affecting the current editor state. This
  17626. * is mostly intended to defend against IE, which fires off `selectionchange`
  17627. * events regardless of whether the selection is set via the browser or
  17628. * programmatically. We only care about selection events that occur because
  17629. * of browser interaction, not re-renders and forced selections.
  17630. */
  17631. DraftEditor.prototype.componentWillUpdate = function componentWillUpdate(
  17632. nextProps
  17633. ) {
  17634. this._blockSelectEvents = true;
  17635. this._latestEditorState = nextProps.editorState;
  17636. };
  17637. DraftEditor.prototype.componentDidUpdate = function componentDidUpdate() {
  17638. this._blockSelectEvents = false;
  17639. this._latestCommittedEditorState = this.props.editorState;
  17640. };
  17641. /**
  17642. * Used via `this.focus()`.
  17643. *
  17644. * Force focus back onto the editor node.
  17645. *
  17646. * We attempt to preserve scroll position when focusing. You can also pass
  17647. * a specified scroll position (for cases like `cut` behavior where it should
  17648. * be restored to a known position).
  17649. */
  17650. /**
  17651. * Used via `this.setMode(...)`.
  17652. *
  17653. * Set the behavior mode for the editor component. This switches the current
  17654. * handler module to ensure that DOM events are managed appropriately for
  17655. * the active mode.
  17656. */
  17657. /**
  17658. * Used via `this.restoreEditorDOM()`.
  17659. *
  17660. * Force a complete re-render of the DraftEditorContents based on the current
  17661. * EditorState. This is useful when we know we are going to lose control of
  17662. * the DOM state (cut command, IME) and we want to make sure that
  17663. * reconciliation occurs on a version of the DOM that is synchronized with
  17664. * our EditorState.
  17665. */
  17666. /**
  17667. * Used via `this.setClipboard(...)`.
  17668. *
  17669. * Set the clipboard state for a cut/copy event.
  17670. */
  17671. /**
  17672. * Used via `this.getClipboard()`.
  17673. *
  17674. * Retrieve the clipboard state for a cut/copy event.
  17675. */
  17676. /**
  17677. * Used via `this.update(...)`.
  17678. *
  17679. * Propagate a new `EditorState` object to higher-level components. This is
  17680. * the method by which event handlers inform the `DraftEditor` component of
  17681. * state changes. A component that composes a `DraftEditor` **must** provide
  17682. * an `onChange` prop to receive state updates passed along from this
  17683. * function.
  17684. */
  17685. /**
  17686. * Used in conjunction with `onDragLeave()`, by counting the number of times
  17687. * a dragged element enters and leaves the editor (or any of its children),
  17688. * to determine when the dragged element absolutely leaves the editor.
  17689. */
  17690. /**
  17691. * See `onDragEnter()`.
  17692. */
  17693. return DraftEditor;
  17694. })(React__default.Component);
  17695. DraftEditor.defaultProps = {
  17696. blockRenderMap: DefaultDraftBlockRenderMap_1,
  17697. blockRendererFn: emptyFunction_1.thatReturnsNull,
  17698. blockStyleFn: emptyFunction_1.thatReturns(""),
  17699. keyBindingFn: getDefaultKeyBinding_1,
  17700. readOnly: false,
  17701. spellCheck: false,
  17702. stripPastedStyles: false
  17703. };
  17704. var DraftEditor_react = DraftEditor;
  17705. /**
  17706. * Copyright (c) 2013-present, Facebook, Inc.
  17707. * All rights reserved.
  17708. *
  17709. * This source code is licensed under the BSD-style license found in the
  17710. * LICENSE file in the root directory of this source tree. An additional grant
  17711. * of patent rights can be found in the PATENTS file in the same directory.
  17712. *
  17713. * @providesModule DraftStringKey
  17714. * @format
  17715. *
  17716. */
  17717. var DraftStringKey = {
  17718. stringify: function stringify(key) {
  17719. return "_" + String(key);
  17720. },
  17721. unstringify: function unstringify(key) {
  17722. return key.slice(1);
  17723. }
  17724. };
  17725. var DraftStringKey_1 = DraftStringKey;
  17726. var strlen$1 = UnicodeUtils_1.strlen;
  17727. /**
  17728. * Convert to UTF-8 character counts for storage.
  17729. */
  17730. function encodeEntityRanges(block, storageMap) {
  17731. var encoded = [];
  17732. block.findEntityRanges(
  17733. function(character) {
  17734. return !!character.getEntity();
  17735. },
  17736. function(/*number*/ start, /*number*/ end) {
  17737. var text = block.getText();
  17738. var key = block.getEntityAt(start);
  17739. encoded.push({
  17740. offset: strlen$1(text.slice(0, start)),
  17741. length: strlen$1(text.slice(start, end)),
  17742. // Encode the key as a number for range storage.
  17743. key: Number(storageMap[DraftStringKey_1.stringify(key)])
  17744. });
  17745. }
  17746. );
  17747. return encoded;
  17748. }
  17749. var encodeEntityRanges_1 = encodeEntityRanges;
  17750. var areEqual$1 = function areEqual(a, b) {
  17751. return a === b;
  17752. };
  17753. var isTruthy = function isTruthy(a) {
  17754. return !!a;
  17755. };
  17756. var EMPTY_ARRAY = [];
  17757. /**
  17758. * Helper function for getting encoded styles for each inline style. Convert
  17759. * to UTF-8 character counts for storage.
  17760. */
  17761. function getEncodedInlinesForType(block, styleList, styleToEncode) {
  17762. var ranges = [];
  17763. // Obtain an array with ranges for only the specified style.
  17764. var filteredInlines = styleList
  17765. .map(function(style) {
  17766. return style.has(styleToEncode);
  17767. })
  17768. .toList();
  17769. findRangesImmutable_1(
  17770. filteredInlines,
  17771. areEqual$1,
  17772. // We only want to keep ranges with nonzero style values.
  17773. isTruthy,
  17774. function(start, end) {
  17775. var text = block.getText();
  17776. ranges.push({
  17777. offset: UnicodeUtils_1.strlen(text.slice(0, start)),
  17778. length: UnicodeUtils_1.strlen(text.slice(start, end)),
  17779. style: styleToEncode
  17780. });
  17781. }
  17782. );
  17783. return ranges;
  17784. }
  17785. /*
  17786. * Retrieve the encoded arrays of inline styles, with each individual style
  17787. * treated separately.
  17788. */
  17789. function encodeInlineStyleRanges(block) {
  17790. var styleList = block
  17791. .getCharacterList()
  17792. .map(function(c) {
  17793. return c.getStyle();
  17794. })
  17795. .toList();
  17796. var ranges = styleList
  17797. .flatten()
  17798. .toSet()
  17799. .map(function(style) {
  17800. return getEncodedInlinesForType(block, styleList, style);
  17801. });
  17802. return Array.prototype.concat.apply(EMPTY_ARRAY, ranges.toJS());
  17803. }
  17804. var encodeInlineStyleRanges_1 = encodeInlineStyleRanges;
  17805. var _extends$6 =
  17806. objectAssign ||
  17807. function(target) {
  17808. for (var i = 1; i < arguments.length; i++) {
  17809. var source = arguments[i];
  17810. for (var key in source) {
  17811. if (Object.prototype.hasOwnProperty.call(source, key)) {
  17812. target[key] = source[key];
  17813. }
  17814. }
  17815. }
  17816. return target;
  17817. };
  17818. var createRawBlock = function createRawBlock(block, entityStorageMap) {
  17819. return {
  17820. key: block.getKey(),
  17821. text: block.getText(),
  17822. type: block.getType(),
  17823. depth: block.getDepth(),
  17824. inlineStyleRanges: encodeInlineStyleRanges_1(block),
  17825. entityRanges: encodeEntityRanges_1(block, entityStorageMap),
  17826. data: block.getData().toObject()
  17827. };
  17828. };
  17829. var insertRawBlock = function insertRawBlock(
  17830. block,
  17831. entityMap,
  17832. rawBlocks,
  17833. blockCacheRef
  17834. ) {
  17835. if (block instanceof ContentBlock_1) {
  17836. rawBlocks.push(createRawBlock(block, entityMap));
  17837. return;
  17838. }
  17839. !(block instanceof ContentBlockNode_1)
  17840. ? process.env.NODE_ENV !== "production"
  17841. ? invariant_1(false, "block is not a BlockNode")
  17842. : invariant_1(false)
  17843. : void 0;
  17844. var parentKey = block.getParentKey();
  17845. var rawBlock = (blockCacheRef[block.getKey()] = _extends$6(
  17846. {},
  17847. createRawBlock(block, entityMap),
  17848. {
  17849. children: []
  17850. }
  17851. ));
  17852. if (parentKey) {
  17853. blockCacheRef[parentKey].children.push(rawBlock);
  17854. return;
  17855. }
  17856. rawBlocks.push(rawBlock);
  17857. };
  17858. var encodeRawBlocks = function encodeRawBlocks(contentState, rawState) {
  17859. var entityMap = rawState.entityMap;
  17860. var rawBlocks = [];
  17861. var blockCacheRef = {};
  17862. var entityCacheRef = {};
  17863. var entityStorageKey = 0;
  17864. contentState.getBlockMap().forEach(function(block) {
  17865. block.findEntityRanges(
  17866. function(character) {
  17867. return character.getEntity() !== null;
  17868. },
  17869. function(start) {
  17870. var entityKey = block.getEntityAt(start);
  17871. // Stringify to maintain order of otherwise numeric keys.
  17872. var stringifiedEntityKey = DraftStringKey_1.stringify(entityKey);
  17873. // This makes this function resilient to two entities
  17874. // erroneously having the same key
  17875. if (entityCacheRef[stringifiedEntityKey]) {
  17876. return;
  17877. }
  17878. entityCacheRef[stringifiedEntityKey] = entityKey;
  17879. // we need the `any` casting here since this is a temporary state
  17880. // where we will later on flip the entity map and populate it with
  17881. // real entity, at this stage we just need to map back the entity
  17882. // key used by the BlockNode
  17883. entityMap[stringifiedEntityKey] = "" + entityStorageKey;
  17884. entityStorageKey++;
  17885. }
  17886. );
  17887. insertRawBlock(block, entityMap, rawBlocks, blockCacheRef);
  17888. });
  17889. return {
  17890. blocks: rawBlocks,
  17891. entityMap: entityMap
  17892. };
  17893. };
  17894. // Flip storage map so that our storage keys map to global
  17895. // DraftEntity keys.
  17896. var encodeRawEntityMap = function encodeRawEntityMap(contentState, rawState) {
  17897. var blocks = rawState.blocks,
  17898. entityMap = rawState.entityMap;
  17899. var rawEntityMap = {};
  17900. Object.keys(entityMap).forEach(function(key, index) {
  17901. var entity = contentState.getEntity(DraftStringKey_1.unstringify(key));
  17902. rawEntityMap[index] = {
  17903. type: entity.getType(),
  17904. mutability: entity.getMutability(),
  17905. data: entity.getData()
  17906. };
  17907. });
  17908. return {
  17909. blocks: blocks,
  17910. entityMap: rawEntityMap
  17911. };
  17912. };
  17913. var convertFromDraftStateToRaw = function convertFromDraftStateToRaw(
  17914. contentState
  17915. ) {
  17916. var rawDraftContentState = {
  17917. entityMap: {},
  17918. blocks: []
  17919. };
  17920. // add blocks
  17921. rawDraftContentState = encodeRawBlocks(contentState, rawDraftContentState);
  17922. // add entities
  17923. rawDraftContentState = encodeRawEntityMap(contentState, rawDraftContentState);
  17924. return rawDraftContentState;
  17925. };
  17926. var convertFromDraftStateToRaw_1 = convertFromDraftStateToRaw;
  17927. var _extends$7 =
  17928. objectAssign ||
  17929. function(target) {
  17930. for (var i = 1; i < arguments.length; i++) {
  17931. var source = arguments[i];
  17932. for (var key in source) {
  17933. if (Object.prototype.hasOwnProperty.call(source, key)) {
  17934. target[key] = source[key];
  17935. }
  17936. }
  17937. }
  17938. return target;
  17939. };
  17940. /**
  17941. * Copyright (c) 2013-present, Facebook, Inc.
  17942. * All rights reserved.
  17943. *
  17944. * This source code is licensed under the BSD-style license found in the
  17945. * LICENSE file in the root directory of this source tree. An additional grant
  17946. * of patent rights can be found in the PATENTS file in the same directory.
  17947. *
  17948. * @providesModule DraftTreeAdapter
  17949. * @format
  17950. *
  17951. *
  17952. * This is unstable and not part of the public API and should not be used by
  17953. * production systems. This file may be update/removed without notice.
  17954. */
  17955. var traverseInDepthOrder = function traverseInDepthOrder(blocks, fn) {
  17956. var stack = [].concat(blocks).reverse();
  17957. while (stack.length) {
  17958. var _block = stack.pop();
  17959. fn(_block);
  17960. var children = _block.children;
  17961. !Array.isArray(children)
  17962. ? process.env.NODE_ENV !== "production"
  17963. ? invariant_1(false, "Invalid tree raw block")
  17964. : invariant_1(false)
  17965. : void 0;
  17966. stack = stack.concat([].concat(children.reverse()));
  17967. }
  17968. };
  17969. var isListBlock = function isListBlock(block) {
  17970. if (!(block && block.type)) {
  17971. return false;
  17972. }
  17973. var type = block.type;
  17974. return type === "unordered-list-item" || type === "ordered-list-item";
  17975. };
  17976. var addDepthToChildren = function addDepthToChildren(block) {
  17977. if (Array.isArray(block.children)) {
  17978. block.children = block.children.map(function(child) {
  17979. return child.type === block.type
  17980. ? _extends$7({}, child, { depth: (block.depth || 0) + 1 })
  17981. : child;
  17982. });
  17983. }
  17984. };
  17985. /**
  17986. * This adapter is intended to be be used as an adapter to draft tree data
  17987. *
  17988. * draft state <=====> draft tree state
  17989. */
  17990. var DraftTreeAdapter = {
  17991. /**
  17992. * Converts from a tree raw state back to draft raw state
  17993. */
  17994. fromRawTreeStateToRawState: function fromRawTreeStateToRawState(
  17995. draftTreeState
  17996. ) {
  17997. var blocks = draftTreeState.blocks;
  17998. var transformedBlocks = [];
  17999. !Array.isArray(blocks)
  18000. ? process.env.NODE_ENV !== "production"
  18001. ? invariant_1(false, "Invalid raw state")
  18002. : invariant_1(false)
  18003. : void 0;
  18004. if (!Array.isArray(blocks) || !blocks.length) {
  18005. return draftTreeState;
  18006. }
  18007. traverseInDepthOrder(blocks, function(block) {
  18008. var newBlock = _extends$7({}, block);
  18009. if (isListBlock(block)) {
  18010. newBlock.depth = newBlock.depth || 0;
  18011. addDepthToChildren(block);
  18012. }
  18013. delete newBlock.children;
  18014. transformedBlocks.push(newBlock);
  18015. });
  18016. draftTreeState.blocks = transformedBlocks;
  18017. return _extends$7({}, draftTreeState, {
  18018. blocks: transformedBlocks
  18019. });
  18020. },
  18021. /**
  18022. * Converts from draft raw state to tree draft state
  18023. */
  18024. fromRawStateToRawTreeState: function fromRawStateToRawTreeState(draftState) {
  18025. var lastListDepthCacheRef = {};
  18026. var transformedBlocks = [];
  18027. draftState.blocks.forEach(function(block) {
  18028. var isList = isListBlock(block);
  18029. var depth = block.depth || 0;
  18030. var treeBlock = _extends$7({}, block, {
  18031. children: []
  18032. });
  18033. if (!isList) {
  18034. // reset the cache path
  18035. lastListDepthCacheRef = {};
  18036. transformedBlocks.push(treeBlock);
  18037. return;
  18038. }
  18039. // update our depth cache reference path
  18040. lastListDepthCacheRef[depth] = treeBlock;
  18041. // if we are greater than zero we must have seen a parent already
  18042. if (depth > 0) {
  18043. var parent = lastListDepthCacheRef[depth - 1];
  18044. !parent
  18045. ? process.env.NODE_ENV !== "production"
  18046. ? invariant_1(false, "Invalid depth for RawDraftContentBlock")
  18047. : invariant_1(false)
  18048. : void 0;
  18049. // push nested list blocks
  18050. parent.children.push(treeBlock);
  18051. return;
  18052. }
  18053. // push root list blocks
  18054. transformedBlocks.push(treeBlock);
  18055. });
  18056. return _extends$7({}, draftState, {
  18057. blocks: transformedBlocks
  18058. });
  18059. }
  18060. };
  18061. var DraftTreeAdapter_1 = DraftTreeAdapter;
  18062. var List$c = immutable.List;
  18063. function createCharacterList(inlineStyles, entities) {
  18064. var characterArray = inlineStyles.map(function(style, ii) {
  18065. var entity = entities[ii];
  18066. return CharacterMetadata_1.create({ style: style, entity: entity });
  18067. });
  18068. return List$c(characterArray);
  18069. }
  18070. var createCharacterList_1 = createCharacterList;
  18071. var substr$1 = UnicodeUtils_1.substr;
  18072. /**
  18073. * Convert to native JavaScript string lengths to determine ranges.
  18074. */
  18075. function decodeEntityRanges(text, ranges) {
  18076. var entities = Array(text.length).fill(null);
  18077. if (ranges) {
  18078. ranges.forEach(function(range) {
  18079. // Using Unicode-enabled substrings converted to JavaScript lengths,
  18080. // fill the output array with entity keys.
  18081. var start = substr$1(text, 0, range.offset).length;
  18082. var end = start + substr$1(text, range.offset, range.length).length;
  18083. for (var ii = start; ii < end; ii++) {
  18084. entities[ii] = range.key;
  18085. }
  18086. });
  18087. }
  18088. return entities;
  18089. }
  18090. var decodeEntityRanges_1 = decodeEntityRanges;
  18091. var OrderedSet$6 = immutable.OrderedSet;
  18092. var substr$2 = UnicodeUtils_1.substr;
  18093. var EMPTY_SET$3 = OrderedSet$6();
  18094. /**
  18095. * Convert to native JavaScript string lengths to determine ranges.
  18096. */
  18097. function decodeInlineStyleRanges(text, ranges) {
  18098. var styles = Array(text.length).fill(EMPTY_SET$3);
  18099. if (ranges) {
  18100. ranges.forEach(function(/*object*/ range) {
  18101. var cursor = substr$2(text, 0, range.offset).length;
  18102. var end = cursor + substr$2(text, range.offset, range.length).length;
  18103. while (cursor < end) {
  18104. styles[cursor] = styles[cursor].add(range.style);
  18105. cursor++;
  18106. }
  18107. });
  18108. }
  18109. return styles;
  18110. }
  18111. var decodeInlineStyleRanges_1 = decodeInlineStyleRanges;
  18112. var _extends$8 =
  18113. objectAssign ||
  18114. function(target) {
  18115. for (var i = 1; i < arguments.length; i++) {
  18116. var source = arguments[i];
  18117. for (var key in source) {
  18118. if (Object.prototype.hasOwnProperty.call(source, key)) {
  18119. target[key] = source[key];
  18120. }
  18121. }
  18122. }
  18123. return target;
  18124. };
  18125. var List$d = immutable.List,
  18126. Map$9 = immutable.Map,
  18127. OrderedMap$4 = immutable.OrderedMap;
  18128. var decodeBlockNodeConfig = function decodeBlockNodeConfig(block, entityMap) {
  18129. var key = block.key,
  18130. type = block.type,
  18131. data = block.data,
  18132. text = block.text,
  18133. depth = block.depth;
  18134. var blockNodeConfig = {
  18135. text: text,
  18136. depth: depth || 0,
  18137. type: type || "unstyled",
  18138. key: key || generateRandomKey_1(),
  18139. data: Map$9(data),
  18140. characterList: decodeCharacterList(block, entityMap)
  18141. };
  18142. return blockNodeConfig;
  18143. };
  18144. var decodeCharacterList = function decodeCharacterList(block, entityMap) {
  18145. var text = block.text,
  18146. rawEntityRanges = block.entityRanges,
  18147. rawInlineStyleRanges = block.inlineStyleRanges;
  18148. var entityRanges = rawEntityRanges || [];
  18149. var inlineStyleRanges = rawInlineStyleRanges || [];
  18150. // Translate entity range keys to the DraftEntity map.
  18151. return createCharacterList_1(
  18152. decodeInlineStyleRanges_1(text, inlineStyleRanges),
  18153. decodeEntityRanges_1(
  18154. text,
  18155. entityRanges
  18156. .filter(function(range) {
  18157. return entityMap.hasOwnProperty(range.key);
  18158. })
  18159. .map(function(range) {
  18160. return _extends$8({}, range, { key: entityMap[range.key] });
  18161. })
  18162. )
  18163. );
  18164. };
  18165. var decodeContentBlocks = function decodeContentBlocks(blocks, entityMap) {
  18166. return OrderedMap$4(
  18167. blocks.map(function(block) {
  18168. var contentBlock = new ContentBlock_1(
  18169. decodeBlockNodeConfig(block, entityMap)
  18170. );
  18171. return [contentBlock.getKey(), contentBlock];
  18172. })
  18173. );
  18174. };
  18175. var decodeRawBlocks = function decodeRawBlocks(rawState, entityMap) {
  18176. var isTreeRawBlock = Array.isArray(rawState.blocks[0].children);
  18177. var rawBlocks = rawState.blocks;
  18178. {
  18179. return decodeContentBlocks(
  18180. isTreeRawBlock
  18181. ? DraftTreeAdapter_1.fromRawTreeStateToRawState(rawState).blocks
  18182. : rawBlocks,
  18183. entityMap
  18184. );
  18185. }
  18186. };
  18187. var decodeRawEntityMap = function decodeRawEntityMap(rawState) {
  18188. var rawEntityMap = rawState.entityMap;
  18189. var entityMap = {};
  18190. // TODO: Update this once we completely remove DraftEntity
  18191. Object.keys(rawEntityMap).forEach(function(rawEntityKey) {
  18192. var _rawEntityMap$rawEnti = rawEntityMap[rawEntityKey],
  18193. type = _rawEntityMap$rawEnti.type,
  18194. mutability = _rawEntityMap$rawEnti.mutability,
  18195. data = _rawEntityMap$rawEnti.data;
  18196. // get the key reference to created entity
  18197. entityMap[rawEntityKey] = DraftEntity_1.__create(
  18198. type,
  18199. mutability,
  18200. data || {}
  18201. );
  18202. });
  18203. return entityMap;
  18204. };
  18205. var convertFromRawToDraftState = function convertFromRawToDraftState(rawState) {
  18206. !Array.isArray(rawState.blocks)
  18207. ? process.env.NODE_ENV !== "production"
  18208. ? invariant_1(false, "invalid RawDraftContentState")
  18209. : invariant_1(false)
  18210. : void 0;
  18211. // decode entities
  18212. var entityMap = decodeRawEntityMap(rawState);
  18213. // decode blockMap
  18214. var blockMap = decodeRawBlocks(rawState, entityMap);
  18215. // create initial selection
  18216. var selectionState = blockMap.isEmpty()
  18217. ? new SelectionState_1()
  18218. : SelectionState_1.createEmpty(blockMap.first().getKey());
  18219. return new ContentState_1({
  18220. blockMap: blockMap,
  18221. entityMap: entityMap,
  18222. selectionBefore: selectionState,
  18223. selectionAfter: selectionState
  18224. });
  18225. };
  18226. var convertFromRawToDraftState_1 = convertFromRawToDraftState;
  18227. /**
  18228. * Like range.getBoundingClientRect() but normalizes for browser bugs.
  18229. */
  18230. function getRangeBoundingClientRect(range) {
  18231. // "Return a DOMRect object describing the smallest rectangle that includes
  18232. // the first rectangle in list and all of the remaining rectangles of which
  18233. // the height or width is not zero."
  18234. // http://www.w3.org/TR/cssom-view/#dom-range-getboundingclientrect
  18235. var rects = getRangeClientRects_1(range);
  18236. var top = 0;
  18237. var right = 0;
  18238. var bottom = 0;
  18239. var left = 0;
  18240. if (rects.length) {
  18241. // If the first rectangle has 0 width, we use the second, this is needed
  18242. // because Chrome renders a 0 width rectangle when the selection contains
  18243. // a line break.
  18244. if (rects.length > 1 && rects[0].width === 0) {
  18245. var _rects$ = rects[1];
  18246. top = _rects$.top;
  18247. right = _rects$.right;
  18248. bottom = _rects$.bottom;
  18249. left = _rects$.left;
  18250. } else {
  18251. var _rects$2 = rects[0];
  18252. top = _rects$2.top;
  18253. right = _rects$2.right;
  18254. bottom = _rects$2.bottom;
  18255. left = _rects$2.left;
  18256. }
  18257. for (var ii = 1; ii < rects.length; ii++) {
  18258. var rect = rects[ii];
  18259. if (rect.height !== 0 && rect.width !== 0) {
  18260. top = Math.min(top, rect.top);
  18261. right = Math.max(right, rect.right);
  18262. bottom = Math.max(bottom, rect.bottom);
  18263. left = Math.min(left, rect.left);
  18264. }
  18265. }
  18266. }
  18267. return {
  18268. top: top,
  18269. right: right,
  18270. bottom: bottom,
  18271. left: left,
  18272. width: right - left,
  18273. height: bottom - top
  18274. };
  18275. }
  18276. var getRangeBoundingClientRect_1 = getRangeBoundingClientRect;
  18277. /**
  18278. * Return the bounding ClientRect for the visible DOM selection, if any.
  18279. * In cases where there are no selected ranges or the bounding rect is
  18280. * temporarily invalid, return null.
  18281. */
  18282. function getVisibleSelectionRect(global) {
  18283. var selection = global.getSelection();
  18284. if (!selection.rangeCount) {
  18285. return null;
  18286. }
  18287. var range = selection.getRangeAt(0);
  18288. var boundingRect = getRangeBoundingClientRect_1(range);
  18289. var top = boundingRect.top,
  18290. right = boundingRect.right,
  18291. bottom = boundingRect.bottom,
  18292. left = boundingRect.left;
  18293. // When a re-render leads to a node being removed, the DOM selection will
  18294. // temporarily be placed on an ancestor node, which leads to an invalid
  18295. // bounding rect. Discard this state.
  18296. if (top === 0 && right === 0 && bottom === 0 && left === 0) {
  18297. return null;
  18298. }
  18299. return boundingRect;
  18300. }
  18301. var getVisibleSelectionRect_1 = getVisibleSelectionRect;
  18302. var DraftPublic = {
  18303. Editor: DraftEditor_react,
  18304. EditorBlock: DraftEditorBlock_react,
  18305. EditorState: EditorState_1,
  18306. CompositeDecorator: CompositeDraftDecorator_1,
  18307. Entity: DraftEntity_1,
  18308. EntityInstance: DraftEntityInstance_1,
  18309. BlockMapBuilder: BlockMapBuilder_1,
  18310. CharacterMetadata: CharacterMetadata_1,
  18311. ContentBlock: ContentBlock_1,
  18312. ContentState: ContentState_1,
  18313. SelectionState: SelectionState_1,
  18314. AtomicBlockUtils: AtomicBlockUtils_1,
  18315. KeyBindingUtil: KeyBindingUtil_1,
  18316. Modifier: DraftModifier_1,
  18317. RichUtils: RichTextEditorUtil_1,
  18318. DefaultDraftBlockRenderMap: DefaultDraftBlockRenderMap_1,
  18319. DefaultDraftInlineStyle: DefaultDraftInlineStyle,
  18320. convertFromHTML: convertFromHTMLToContentBlocks,
  18321. convertFromRaw: convertFromRawToDraftState_1,
  18322. convertToRaw: convertFromDraftStateToRaw_1,
  18323. genKey: generateRandomKey_1,
  18324. getDefaultKeyBinding: getDefaultKeyBinding_1,
  18325. getVisibleSelectionRect: getVisibleSelectionRect_1
  18326. };
  18327. var Draft = DraftPublic;
  18328. var immutable$1 = _commonjsHelpers.createCommonjsModule(function(
  18329. module,
  18330. exports
  18331. ) {
  18332. /**
  18333. * Copyright (c) 2014-2015, Facebook, Inc.
  18334. * All rights reserved.
  18335. *
  18336. * This source code is licensed under the BSD-style license found in the
  18337. * LICENSE file in the root directory of this source tree. An additional grant
  18338. * of patent rights can be found in the PATENTS file in the same directory.
  18339. */
  18340. (function(global, factory) {
  18341. module.exports = factory();
  18342. })(_commonjsHelpers.commonjsGlobal, function() {
  18343. var SLICE$0 = Array.prototype.slice;
  18344. function createClass(ctor, superClass) {
  18345. if (superClass) {
  18346. ctor.prototype = Object.create(superClass.prototype);
  18347. }
  18348. ctor.prototype.constructor = ctor;
  18349. }
  18350. function Iterable(value) {
  18351. return isIterable(value) ? value : Seq(value);
  18352. }
  18353. createClass(KeyedIterable, Iterable);
  18354. function KeyedIterable(value) {
  18355. return isKeyed(value) ? value : KeyedSeq(value);
  18356. }
  18357. createClass(IndexedIterable, Iterable);
  18358. function IndexedIterable(value) {
  18359. return isIndexed(value) ? value : IndexedSeq(value);
  18360. }
  18361. createClass(SetIterable, Iterable);
  18362. function SetIterable(value) {
  18363. return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
  18364. }
  18365. function isIterable(maybeIterable) {
  18366. return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
  18367. }
  18368. function isKeyed(maybeKeyed) {
  18369. return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
  18370. }
  18371. function isIndexed(maybeIndexed) {
  18372. return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
  18373. }
  18374. function isAssociative(maybeAssociative) {
  18375. return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
  18376. }
  18377. function isOrdered(maybeOrdered) {
  18378. return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
  18379. }
  18380. Iterable.isIterable = isIterable;
  18381. Iterable.isKeyed = isKeyed;
  18382. Iterable.isIndexed = isIndexed;
  18383. Iterable.isAssociative = isAssociative;
  18384. Iterable.isOrdered = isOrdered;
  18385. Iterable.Keyed = KeyedIterable;
  18386. Iterable.Indexed = IndexedIterable;
  18387. Iterable.Set = SetIterable;
  18388. var IS_ITERABLE_SENTINEL = "@@__IMMUTABLE_ITERABLE__@@";
  18389. var IS_KEYED_SENTINEL = "@@__IMMUTABLE_KEYED__@@";
  18390. var IS_INDEXED_SENTINEL = "@@__IMMUTABLE_INDEXED__@@";
  18391. var IS_ORDERED_SENTINEL = "@@__IMMUTABLE_ORDERED__@@";
  18392. // Used for setting prototype methods that IE8 chokes on.
  18393. var DELETE = "delete";
  18394. // Constants describing the size of trie nodes.
  18395. var SHIFT = 5; // Resulted in best performance after ______?
  18396. var SIZE = 1 << SHIFT;
  18397. var MASK = SIZE - 1;
  18398. // A consistent shared value representing "not set" which equals nothing other
  18399. // than itself, and nothing that could be provided externally.
  18400. var NOT_SET = {};
  18401. // Boolean references, Rough equivalent of `bool &`.
  18402. var CHANGE_LENGTH = { value: false };
  18403. var DID_ALTER = { value: false };
  18404. function MakeRef(ref) {
  18405. ref.value = false;
  18406. return ref;
  18407. }
  18408. function SetRef(ref) {
  18409. ref && (ref.value = true);
  18410. }
  18411. // A function which returns a value representing an "owner" for transient writes
  18412. // to tries. The return value will only ever equal itself, and will not equal
  18413. // the return of any subsequent call of this function.
  18414. function OwnerID() {}
  18415. // http://jsperf.com/copy-array-inline
  18416. function arrCopy(arr, offset) {
  18417. offset = offset || 0;
  18418. var len = Math.max(0, arr.length - offset);
  18419. var newArr = new Array(len);
  18420. for (var ii = 0; ii < len; ii++) {
  18421. newArr[ii] = arr[ii + offset];
  18422. }
  18423. return newArr;
  18424. }
  18425. function ensureSize(iter) {
  18426. if (iter.size === undefined) {
  18427. iter.size = iter.__iterate(returnTrue);
  18428. }
  18429. return iter.size;
  18430. }
  18431. function wrapIndex(iter, index) {
  18432. // This implements "is array index" which the ECMAString spec defines as:
  18433. //
  18434. // A String property name P is an array index if and only if
  18435. // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
  18436. // to 2^32−1.
  18437. //
  18438. // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
  18439. if (typeof index !== "number") {
  18440. var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
  18441. if ("" + uint32Index !== index || uint32Index === 4294967295) {
  18442. return NaN;
  18443. }
  18444. index = uint32Index;
  18445. }
  18446. return index < 0 ? ensureSize(iter) + index : index;
  18447. }
  18448. function returnTrue() {
  18449. return true;
  18450. }
  18451. function wholeSlice(begin, end, size) {
  18452. return (
  18453. (begin === 0 || (size !== undefined && begin <= -size)) &&
  18454. (end === undefined || (size !== undefined && end >= size))
  18455. );
  18456. }
  18457. function resolveBegin(begin, size) {
  18458. return resolveIndex(begin, size, 0);
  18459. }
  18460. function resolveEnd(end, size) {
  18461. return resolveIndex(end, size, size);
  18462. }
  18463. function resolveIndex(index, size, defaultIndex) {
  18464. return index === undefined
  18465. ? defaultIndex
  18466. : index < 0
  18467. ? Math.max(0, size + index)
  18468. : size === undefined
  18469. ? index
  18470. : Math.min(size, index);
  18471. }
  18472. /* global Symbol */
  18473. var ITERATE_KEYS = 0;
  18474. var ITERATE_VALUES = 1;
  18475. var ITERATE_ENTRIES = 2;
  18476. var REAL_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
  18477. var FAUX_ITERATOR_SYMBOL = "@@iterator";
  18478. var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
  18479. function Iterator(next) {
  18480. this.next = next;
  18481. }
  18482. Iterator.prototype.toString = function() {
  18483. return "[Iterator]";
  18484. };
  18485. Iterator.KEYS = ITERATE_KEYS;
  18486. Iterator.VALUES = ITERATE_VALUES;
  18487. Iterator.ENTRIES = ITERATE_ENTRIES;
  18488. Iterator.prototype.inspect = Iterator.prototype.toSource = function() {
  18489. return this.toString();
  18490. };
  18491. Iterator.prototype[ITERATOR_SYMBOL] = function() {
  18492. return this;
  18493. };
  18494. function iteratorValue(type, k, v, iteratorResult) {
  18495. var value = type === 0 ? k : type === 1 ? v : [k, v];
  18496. iteratorResult
  18497. ? (iteratorResult.value = value)
  18498. : (iteratorResult = {
  18499. value: value,
  18500. done: false
  18501. });
  18502. return iteratorResult;
  18503. }
  18504. function iteratorDone() {
  18505. return { value: undefined, done: true };
  18506. }
  18507. function hasIterator(maybeIterable) {
  18508. return !!getIteratorFn(maybeIterable);
  18509. }
  18510. function isIterator(maybeIterator) {
  18511. return maybeIterator && typeof maybeIterator.next === "function";
  18512. }
  18513. function getIterator(iterable) {
  18514. var iteratorFn = getIteratorFn(iterable);
  18515. return iteratorFn && iteratorFn.call(iterable);
  18516. }
  18517. function getIteratorFn(iterable) {
  18518. var iteratorFn =
  18519. iterable &&
  18520. ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
  18521. iterable[FAUX_ITERATOR_SYMBOL]);
  18522. if (typeof iteratorFn === "function") {
  18523. return iteratorFn;
  18524. }
  18525. }
  18526. function isArrayLike(value) {
  18527. return value && typeof value.length === "number";
  18528. }
  18529. createClass(Seq, Iterable);
  18530. function Seq(value) {
  18531. return value === null || value === undefined
  18532. ? emptySequence()
  18533. : isIterable(value)
  18534. ? value.toSeq()
  18535. : seqFromValue(value);
  18536. }
  18537. Seq.of = function(/*...values*/) {
  18538. return Seq(arguments);
  18539. };
  18540. Seq.prototype.toSeq = function() {
  18541. return this;
  18542. };
  18543. Seq.prototype.toString = function() {
  18544. return this.__toString("Seq {", "}");
  18545. };
  18546. Seq.prototype.cacheResult = function() {
  18547. if (!this._cache && this.__iterateUncached) {
  18548. this._cache = this.entrySeq().toArray();
  18549. this.size = this._cache.length;
  18550. }
  18551. return this;
  18552. };
  18553. // abstract __iterateUncached(fn, reverse)
  18554. Seq.prototype.__iterate = function(fn, reverse) {
  18555. return seqIterate(this, fn, reverse, true);
  18556. };
  18557. // abstract __iteratorUncached(type, reverse)
  18558. Seq.prototype.__iterator = function(type, reverse) {
  18559. return seqIterator(this, type, reverse, true);
  18560. };
  18561. createClass(KeyedSeq, Seq);
  18562. function KeyedSeq(value) {
  18563. return value === null || value === undefined
  18564. ? emptySequence().toKeyedSeq()
  18565. : isIterable(value)
  18566. ? isKeyed(value)
  18567. ? value.toSeq()
  18568. : value.fromEntrySeq()
  18569. : keyedSeqFromValue(value);
  18570. }
  18571. KeyedSeq.prototype.toKeyedSeq = function() {
  18572. return this;
  18573. };
  18574. createClass(IndexedSeq, Seq);
  18575. function IndexedSeq(value) {
  18576. return value === null || value === undefined
  18577. ? emptySequence()
  18578. : !isIterable(value)
  18579. ? indexedSeqFromValue(value)
  18580. : isKeyed(value)
  18581. ? value.entrySeq()
  18582. : value.toIndexedSeq();
  18583. }
  18584. IndexedSeq.of = function(/*...values*/) {
  18585. return IndexedSeq(arguments);
  18586. };
  18587. IndexedSeq.prototype.toIndexedSeq = function() {
  18588. return this;
  18589. };
  18590. IndexedSeq.prototype.toString = function() {
  18591. return this.__toString("Seq [", "]");
  18592. };
  18593. IndexedSeq.prototype.__iterate = function(fn, reverse) {
  18594. return seqIterate(this, fn, reverse, false);
  18595. };
  18596. IndexedSeq.prototype.__iterator = function(type, reverse) {
  18597. return seqIterator(this, type, reverse, false);
  18598. };
  18599. createClass(SetSeq, Seq);
  18600. function SetSeq(value) {
  18601. return (value === null || value === undefined
  18602. ? emptySequence()
  18603. : !isIterable(value)
  18604. ? indexedSeqFromValue(value)
  18605. : isKeyed(value)
  18606. ? value.entrySeq()
  18607. : value
  18608. ).toSetSeq();
  18609. }
  18610. SetSeq.of = function(/*...values*/) {
  18611. return SetSeq(arguments);
  18612. };
  18613. SetSeq.prototype.toSetSeq = function() {
  18614. return this;
  18615. };
  18616. Seq.isSeq = isSeq;
  18617. Seq.Keyed = KeyedSeq;
  18618. Seq.Set = SetSeq;
  18619. Seq.Indexed = IndexedSeq;
  18620. var IS_SEQ_SENTINEL = "@@__IMMUTABLE_SEQ__@@";
  18621. Seq.prototype[IS_SEQ_SENTINEL] = true;
  18622. createClass(ArraySeq, IndexedSeq);
  18623. function ArraySeq(array) {
  18624. this._array = array;
  18625. this.size = array.length;
  18626. }
  18627. ArraySeq.prototype.get = function(index, notSetValue) {
  18628. return this.has(index)
  18629. ? this._array[wrapIndex(this, index)]
  18630. : notSetValue;
  18631. };
  18632. ArraySeq.prototype.__iterate = function(fn, reverse) {
  18633. var array = this._array;
  18634. var maxIndex = array.length - 1;
  18635. for (var ii = 0; ii <= maxIndex; ii++) {
  18636. if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
  18637. return ii + 1;
  18638. }
  18639. }
  18640. return ii;
  18641. };
  18642. ArraySeq.prototype.__iterator = function(type, reverse) {
  18643. var array = this._array;
  18644. var maxIndex = array.length - 1;
  18645. var ii = 0;
  18646. return new Iterator(function() {
  18647. return ii > maxIndex
  18648. ? iteratorDone()
  18649. : iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++]);
  18650. });
  18651. };
  18652. createClass(ObjectSeq, KeyedSeq);
  18653. function ObjectSeq(object) {
  18654. var keys = Object.keys(object);
  18655. this._object = object;
  18656. this._keys = keys;
  18657. this.size = keys.length;
  18658. }
  18659. ObjectSeq.prototype.get = function(key, notSetValue) {
  18660. if (notSetValue !== undefined && !this.has(key)) {
  18661. return notSetValue;
  18662. }
  18663. return this._object[key];
  18664. };
  18665. ObjectSeq.prototype.has = function(key) {
  18666. return this._object.hasOwnProperty(key);
  18667. };
  18668. ObjectSeq.prototype.__iterate = function(fn, reverse) {
  18669. var object = this._object;
  18670. var keys = this._keys;
  18671. var maxIndex = keys.length - 1;
  18672. for (var ii = 0; ii <= maxIndex; ii++) {
  18673. var key = keys[reverse ? maxIndex - ii : ii];
  18674. if (fn(object[key], key, this) === false) {
  18675. return ii + 1;
  18676. }
  18677. }
  18678. return ii;
  18679. };
  18680. ObjectSeq.prototype.__iterator = function(type, reverse) {
  18681. var object = this._object;
  18682. var keys = this._keys;
  18683. var maxIndex = keys.length - 1;
  18684. var ii = 0;
  18685. return new Iterator(function() {
  18686. var key = keys[reverse ? maxIndex - ii : ii];
  18687. return ii++ > maxIndex
  18688. ? iteratorDone()
  18689. : iteratorValue(type, key, object[key]);
  18690. });
  18691. };
  18692. ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
  18693. createClass(IterableSeq, IndexedSeq);
  18694. function IterableSeq(iterable) {
  18695. this._iterable = iterable;
  18696. this.size = iterable.length || iterable.size;
  18697. }
  18698. IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
  18699. if (reverse) {
  18700. return this.cacheResult().__iterate(fn, reverse);
  18701. }
  18702. var iterable = this._iterable;
  18703. var iterator = getIterator(iterable);
  18704. var iterations = 0;
  18705. if (isIterator(iterator)) {
  18706. var step;
  18707. while (!(step = iterator.next()).done) {
  18708. if (fn(step.value, iterations++, this) === false) {
  18709. break;
  18710. }
  18711. }
  18712. }
  18713. return iterations;
  18714. };
  18715. IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
  18716. if (reverse) {
  18717. return this.cacheResult().__iterator(type, reverse);
  18718. }
  18719. var iterable = this._iterable;
  18720. var iterator = getIterator(iterable);
  18721. if (!isIterator(iterator)) {
  18722. return new Iterator(iteratorDone);
  18723. }
  18724. var iterations = 0;
  18725. return new Iterator(function() {
  18726. var step = iterator.next();
  18727. return step.done ? step : iteratorValue(type, iterations++, step.value);
  18728. });
  18729. };
  18730. createClass(IteratorSeq, IndexedSeq);
  18731. function IteratorSeq(iterator) {
  18732. this._iterator = iterator;
  18733. this._iteratorCache = [];
  18734. }
  18735. IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
  18736. if (reverse) {
  18737. return this.cacheResult().__iterate(fn, reverse);
  18738. }
  18739. var iterator = this._iterator;
  18740. var cache = this._iteratorCache;
  18741. var iterations = 0;
  18742. while (iterations < cache.length) {
  18743. if (fn(cache[iterations], iterations++, this) === false) {
  18744. return iterations;
  18745. }
  18746. }
  18747. var step;
  18748. while (!(step = iterator.next()).done) {
  18749. var val = step.value;
  18750. cache[iterations] = val;
  18751. if (fn(val, iterations++, this) === false) {
  18752. break;
  18753. }
  18754. }
  18755. return iterations;
  18756. };
  18757. IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
  18758. if (reverse) {
  18759. return this.cacheResult().__iterator(type, reverse);
  18760. }
  18761. var iterator = this._iterator;
  18762. var cache = this._iteratorCache;
  18763. var iterations = 0;
  18764. return new Iterator(function() {
  18765. if (iterations >= cache.length) {
  18766. var step = iterator.next();
  18767. if (step.done) {
  18768. return step;
  18769. }
  18770. cache[iterations] = step.value;
  18771. }
  18772. return iteratorValue(type, iterations, cache[iterations++]);
  18773. });
  18774. };
  18775. // # pragma Helper functions
  18776. function isSeq(maybeSeq) {
  18777. return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
  18778. }
  18779. var EMPTY_SEQ;
  18780. function emptySequence() {
  18781. return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
  18782. }
  18783. function keyedSeqFromValue(value) {
  18784. var seq = Array.isArray(value)
  18785. ? new ArraySeq(value).fromEntrySeq()
  18786. : isIterator(value)
  18787. ? new IteratorSeq(value).fromEntrySeq()
  18788. : hasIterator(value)
  18789. ? new IterableSeq(value).fromEntrySeq()
  18790. : typeof value === "object"
  18791. ? new ObjectSeq(value)
  18792. : undefined;
  18793. if (!seq) {
  18794. throw new TypeError(
  18795. "Expected Array or iterable object of [k, v] entries, " +
  18796. "or keyed object: " +
  18797. value
  18798. );
  18799. }
  18800. return seq;
  18801. }
  18802. function indexedSeqFromValue(value) {
  18803. var seq = maybeIndexedSeqFromValue(value);
  18804. if (!seq) {
  18805. throw new TypeError(
  18806. "Expected Array or iterable object of values: " + value
  18807. );
  18808. }
  18809. return seq;
  18810. }
  18811. function seqFromValue(value) {
  18812. var seq =
  18813. maybeIndexedSeqFromValue(value) ||
  18814. (typeof value === "object" && new ObjectSeq(value));
  18815. if (!seq) {
  18816. throw new TypeError(
  18817. "Expected Array or iterable object of values, or keyed object: " +
  18818. value
  18819. );
  18820. }
  18821. return seq;
  18822. }
  18823. function maybeIndexedSeqFromValue(value) {
  18824. return isArrayLike(value)
  18825. ? new ArraySeq(value)
  18826. : isIterator(value)
  18827. ? new IteratorSeq(value)
  18828. : hasIterator(value)
  18829. ? new IterableSeq(value)
  18830. : undefined;
  18831. }
  18832. function seqIterate(seq, fn, reverse, useKeys) {
  18833. var cache = seq._cache;
  18834. if (cache) {
  18835. var maxIndex = cache.length - 1;
  18836. for (var ii = 0; ii <= maxIndex; ii++) {
  18837. var entry = cache[reverse ? maxIndex - ii : ii];
  18838. if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
  18839. return ii + 1;
  18840. }
  18841. }
  18842. return ii;
  18843. }
  18844. return seq.__iterateUncached(fn, reverse);
  18845. }
  18846. function seqIterator(seq, type, reverse, useKeys) {
  18847. var cache = seq._cache;
  18848. if (cache) {
  18849. var maxIndex = cache.length - 1;
  18850. var ii = 0;
  18851. return new Iterator(function() {
  18852. var entry = cache[reverse ? maxIndex - ii : ii];
  18853. return ii++ > maxIndex
  18854. ? iteratorDone()
  18855. : iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
  18856. });
  18857. }
  18858. return seq.__iteratorUncached(type, reverse);
  18859. }
  18860. function fromJS(json, converter) {
  18861. return converter
  18862. ? fromJSWith(converter, json, "", { "": json })
  18863. : fromJSDefault(json);
  18864. }
  18865. function fromJSWith(converter, json, key, parentJSON) {
  18866. if (Array.isArray(json)) {
  18867. return converter.call(
  18868. parentJSON,
  18869. key,
  18870. IndexedSeq(json).map(function(v, k) {
  18871. return fromJSWith(converter, v, k, json);
  18872. })
  18873. );
  18874. }
  18875. if (isPlainObj(json)) {
  18876. return converter.call(
  18877. parentJSON,
  18878. key,
  18879. KeyedSeq(json).map(function(v, k) {
  18880. return fromJSWith(converter, v, k, json);
  18881. })
  18882. );
  18883. }
  18884. return json;
  18885. }
  18886. function fromJSDefault(json) {
  18887. if (Array.isArray(json)) {
  18888. return IndexedSeq(json)
  18889. .map(fromJSDefault)
  18890. .toList();
  18891. }
  18892. if (isPlainObj(json)) {
  18893. return KeyedSeq(json)
  18894. .map(fromJSDefault)
  18895. .toMap();
  18896. }
  18897. return json;
  18898. }
  18899. function isPlainObj(value) {
  18900. return (
  18901. value &&
  18902. (value.constructor === Object || value.constructor === undefined)
  18903. );
  18904. }
  18905. /**
  18906. * An extension of the "same-value" algorithm as [described for use by ES6 Map
  18907. * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
  18908. *
  18909. * NaN is considered the same as NaN, however -0 and 0 are considered the same
  18910. * value, which is different from the algorithm described by
  18911. * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
  18912. *
  18913. * This is extended further to allow Objects to describe the values they
  18914. * represent, by way of `valueOf` or `equals` (and `hashCode`).
  18915. *
  18916. * Note: because of this extension, the key equality of Immutable.Map and the
  18917. * value equality of Immutable.Set will differ from ES6 Map and Set.
  18918. *
  18919. * ### Defining custom values
  18920. *
  18921. * The easiest way to describe the value an object represents is by implementing
  18922. * `valueOf`. For example, `Date` represents a value by returning a unix
  18923. * timestamp for `valueOf`:
  18924. *
  18925. * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
  18926. * var date2 = new Date(1234567890000);
  18927. * date1.valueOf(); // 1234567890000
  18928. * assert( date1 !== date2 );
  18929. * assert( Immutable.is( date1, date2 ) );
  18930. *
  18931. * Note: overriding `valueOf` may have other implications if you use this object
  18932. * where JavaScript expects a primitive, such as implicit string coercion.
  18933. *
  18934. * For more complex types, especially collections, implementing `valueOf` may
  18935. * not be performant. An alternative is to implement `equals` and `hashCode`.
  18936. *
  18937. * `equals` takes another object, presumably of similar type, and returns true
  18938. * if the it is equal. Equality is symmetrical, so the same result should be
  18939. * returned if this and the argument are flipped.
  18940. *
  18941. * assert( a.equals(b) === b.equals(a) );
  18942. *
  18943. * `hashCode` returns a 32bit integer number representing the object which will
  18944. * be used to determine how to store the value object in a Map or Set. You must
  18945. * provide both or neither methods, one must not exist without the other.
  18946. *
  18947. * Also, an important relationship between these methods must be upheld: if two
  18948. * values are equal, they *must* return the same hashCode. If the values are not
  18949. * equal, they might have the same hashCode; this is called a hash collision,
  18950. * and while undesirable for performance reasons, it is acceptable.
  18951. *
  18952. * if (a.equals(b)) {
  18953. * assert( a.hashCode() === b.hashCode() );
  18954. * }
  18955. *
  18956. * All Immutable collections implement `equals` and `hashCode`.
  18957. *
  18958. */
  18959. function is(valueA, valueB) {
  18960. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  18961. return true;
  18962. }
  18963. if (!valueA || !valueB) {
  18964. return false;
  18965. }
  18966. if (
  18967. typeof valueA.valueOf === "function" &&
  18968. typeof valueB.valueOf === "function"
  18969. ) {
  18970. valueA = valueA.valueOf();
  18971. valueB = valueB.valueOf();
  18972. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  18973. return true;
  18974. }
  18975. if (!valueA || !valueB) {
  18976. return false;
  18977. }
  18978. }
  18979. if (
  18980. typeof valueA.equals === "function" &&
  18981. typeof valueB.equals === "function" &&
  18982. valueA.equals(valueB)
  18983. ) {
  18984. return true;
  18985. }
  18986. return false;
  18987. }
  18988. function deepEqual(a, b) {
  18989. if (a === b) {
  18990. return true;
  18991. }
  18992. if (
  18993. !isIterable(b) ||
  18994. (a.size !== undefined && b.size !== undefined && a.size !== b.size) ||
  18995. (a.__hash !== undefined &&
  18996. b.__hash !== undefined &&
  18997. a.__hash !== b.__hash) ||
  18998. isKeyed(a) !== isKeyed(b) ||
  18999. isIndexed(a) !== isIndexed(b) ||
  19000. isOrdered(a) !== isOrdered(b)
  19001. ) {
  19002. return false;
  19003. }
  19004. if (a.size === 0 && b.size === 0) {
  19005. return true;
  19006. }
  19007. var notAssociative = !isAssociative(a);
  19008. if (isOrdered(a)) {
  19009. var entries = a.entries();
  19010. return (
  19011. b.every(function(v, k) {
  19012. var entry = entries.next().value;
  19013. return (
  19014. entry && is(entry[1], v) && (notAssociative || is(entry[0], k))
  19015. );
  19016. }) && entries.next().done
  19017. );
  19018. }
  19019. var flipped = false;
  19020. if (a.size === undefined) {
  19021. if (b.size === undefined) {
  19022. if (typeof a.cacheResult === "function") {
  19023. a.cacheResult();
  19024. }
  19025. } else {
  19026. flipped = true;
  19027. var _ = a;
  19028. a = b;
  19029. b = _;
  19030. }
  19031. }
  19032. var allEqual = true;
  19033. var bSize = b.__iterate(function(v, k) {
  19034. if (
  19035. notAssociative
  19036. ? !a.has(v)
  19037. : flipped
  19038. ? !is(v, a.get(k, NOT_SET))
  19039. : !is(a.get(k, NOT_SET), v)
  19040. ) {
  19041. allEqual = false;
  19042. return false;
  19043. }
  19044. });
  19045. return allEqual && a.size === bSize;
  19046. }
  19047. createClass(Repeat, IndexedSeq);
  19048. function Repeat(value, times) {
  19049. if (!(this instanceof Repeat)) {
  19050. return new Repeat(value, times);
  19051. }
  19052. this._value = value;
  19053. this.size = times === undefined ? Infinity : Math.max(0, times);
  19054. if (this.size === 0) {
  19055. if (EMPTY_REPEAT) {
  19056. return EMPTY_REPEAT;
  19057. }
  19058. EMPTY_REPEAT = this;
  19059. }
  19060. }
  19061. Repeat.prototype.toString = function() {
  19062. if (this.size === 0) {
  19063. return "Repeat []";
  19064. }
  19065. return "Repeat [ " + this._value + " " + this.size + " times ]";
  19066. };
  19067. Repeat.prototype.get = function(index, notSetValue) {
  19068. return this.has(index) ? this._value : notSetValue;
  19069. };
  19070. Repeat.prototype.includes = function(searchValue) {
  19071. return is(this._value, searchValue);
  19072. };
  19073. Repeat.prototype.slice = function(begin, end) {
  19074. var size = this.size;
  19075. return wholeSlice(begin, end, size)
  19076. ? this
  19077. : new Repeat(
  19078. this._value,
  19079. resolveEnd(end, size) - resolveBegin(begin, size)
  19080. );
  19081. };
  19082. Repeat.prototype.reverse = function() {
  19083. return this;
  19084. };
  19085. Repeat.prototype.indexOf = function(searchValue) {
  19086. if (is(this._value, searchValue)) {
  19087. return 0;
  19088. }
  19089. return -1;
  19090. };
  19091. Repeat.prototype.lastIndexOf = function(searchValue) {
  19092. if (is(this._value, searchValue)) {
  19093. return this.size;
  19094. }
  19095. return -1;
  19096. };
  19097. Repeat.prototype.__iterate = function(fn, reverse) {
  19098. for (var ii = 0; ii < this.size; ii++) {
  19099. if (fn(this._value, ii, this) === false) {
  19100. return ii + 1;
  19101. }
  19102. }
  19103. return ii;
  19104. };
  19105. Repeat.prototype.__iterator = function(type, reverse) {
  19106. var this$0 = this;
  19107. var ii = 0;
  19108. return new Iterator(function() {
  19109. return ii < this$0.size
  19110. ? iteratorValue(type, ii++, this$0._value)
  19111. : iteratorDone();
  19112. });
  19113. };
  19114. Repeat.prototype.equals = function(other) {
  19115. return other instanceof Repeat
  19116. ? is(this._value, other._value)
  19117. : deepEqual(other);
  19118. };
  19119. var EMPTY_REPEAT;
  19120. function invariant(condition, error) {
  19121. if (!condition) throw new Error(error);
  19122. }
  19123. createClass(Range, IndexedSeq);
  19124. function Range(start, end, step) {
  19125. if (!(this instanceof Range)) {
  19126. return new Range(start, end, step);
  19127. }
  19128. invariant(step !== 0, "Cannot step a Range by 0");
  19129. start = start || 0;
  19130. if (end === undefined) {
  19131. end = Infinity;
  19132. }
  19133. step = step === undefined ? 1 : Math.abs(step);
  19134. if (end < start) {
  19135. step = -step;
  19136. }
  19137. this._start = start;
  19138. this._end = end;
  19139. this._step = step;
  19140. this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
  19141. if (this.size === 0) {
  19142. if (EMPTY_RANGE) {
  19143. return EMPTY_RANGE;
  19144. }
  19145. EMPTY_RANGE = this;
  19146. }
  19147. }
  19148. Range.prototype.toString = function() {
  19149. if (this.size === 0) {
  19150. return "Range []";
  19151. }
  19152. return (
  19153. "Range [ " +
  19154. this._start +
  19155. "..." +
  19156. this._end +
  19157. (this._step > 1 ? " by " + this._step : "") +
  19158. " ]"
  19159. );
  19160. };
  19161. Range.prototype.get = function(index, notSetValue) {
  19162. return this.has(index)
  19163. ? this._start + wrapIndex(this, index) * this._step
  19164. : notSetValue;
  19165. };
  19166. Range.prototype.includes = function(searchValue) {
  19167. var possibleIndex = (searchValue - this._start) / this._step;
  19168. return (
  19169. possibleIndex >= 0 &&
  19170. possibleIndex < this.size &&
  19171. possibleIndex === Math.floor(possibleIndex)
  19172. );
  19173. };
  19174. Range.prototype.slice = function(begin, end) {
  19175. if (wholeSlice(begin, end, this.size)) {
  19176. return this;
  19177. }
  19178. begin = resolveBegin(begin, this.size);
  19179. end = resolveEnd(end, this.size);
  19180. if (end <= begin) {
  19181. return new Range(0, 0);
  19182. }
  19183. return new Range(
  19184. this.get(begin, this._end),
  19185. this.get(end, this._end),
  19186. this._step
  19187. );
  19188. };
  19189. Range.prototype.indexOf = function(searchValue) {
  19190. var offsetValue = searchValue - this._start;
  19191. if (offsetValue % this._step === 0) {
  19192. var index = offsetValue / this._step;
  19193. if (index >= 0 && index < this.size) {
  19194. return index;
  19195. }
  19196. }
  19197. return -1;
  19198. };
  19199. Range.prototype.lastIndexOf = function(searchValue) {
  19200. return this.indexOf(searchValue);
  19201. };
  19202. Range.prototype.__iterate = function(fn, reverse) {
  19203. var maxIndex = this.size - 1;
  19204. var step = this._step;
  19205. var value = reverse ? this._start + maxIndex * step : this._start;
  19206. for (var ii = 0; ii <= maxIndex; ii++) {
  19207. if (fn(value, ii, this) === false) {
  19208. return ii + 1;
  19209. }
  19210. value += reverse ? -step : step;
  19211. }
  19212. return ii;
  19213. };
  19214. Range.prototype.__iterator = function(type, reverse) {
  19215. var maxIndex = this.size - 1;
  19216. var step = this._step;
  19217. var value = reverse ? this._start + maxIndex * step : this._start;
  19218. var ii = 0;
  19219. return new Iterator(function() {
  19220. var v = value;
  19221. value += reverse ? -step : step;
  19222. return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
  19223. });
  19224. };
  19225. Range.prototype.equals = function(other) {
  19226. return other instanceof Range
  19227. ? this._start === other._start &&
  19228. this._end === other._end &&
  19229. this._step === other._step
  19230. : deepEqual(this, other);
  19231. };
  19232. var EMPTY_RANGE;
  19233. createClass(Collection, Iterable);
  19234. function Collection() {
  19235. throw TypeError("Abstract");
  19236. }
  19237. createClass(KeyedCollection, Collection);
  19238. function KeyedCollection() {}
  19239. createClass(IndexedCollection, Collection);
  19240. function IndexedCollection() {}
  19241. createClass(SetCollection, Collection);
  19242. function SetCollection() {}
  19243. Collection.Keyed = KeyedCollection;
  19244. Collection.Indexed = IndexedCollection;
  19245. Collection.Set = SetCollection;
  19246. var imul =
  19247. typeof Math.imul === "function" && Math.imul(0xffffffff, 2) === -2
  19248. ? Math.imul
  19249. : function imul(a, b) {
  19250. a = a | 0; // int
  19251. b = b | 0; // int
  19252. var c = a & 0xffff;
  19253. var d = b & 0xffff;
  19254. // Shift by 0 fixes the sign on the high part.
  19255. return (
  19256. (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0
  19257. ); // int
  19258. };
  19259. // v8 has an optimization for storing 31-bit signed numbers.
  19260. // Values which have either 00 or 11 as the high order bits qualify.
  19261. // This function drops the highest order bit in a signed number, maintaining
  19262. // the sign bit.
  19263. function smi(i32) {
  19264. return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff);
  19265. }
  19266. function hash(o) {
  19267. if (o === false || o === null || o === undefined) {
  19268. return 0;
  19269. }
  19270. if (typeof o.valueOf === "function") {
  19271. o = o.valueOf();
  19272. if (o === false || o === null || o === undefined) {
  19273. return 0;
  19274. }
  19275. }
  19276. if (o === true) {
  19277. return 1;
  19278. }
  19279. var type = typeof o;
  19280. if (type === "number") {
  19281. var h = o | 0;
  19282. if (h !== o) {
  19283. h ^= o * 0xffffffff;
  19284. }
  19285. while (o > 0xffffffff) {
  19286. o /= 0xffffffff;
  19287. h ^= o;
  19288. }
  19289. return smi(h);
  19290. }
  19291. if (type === "string") {
  19292. return o.length > STRING_HASH_CACHE_MIN_STRLEN
  19293. ? cachedHashString(o)
  19294. : hashString(o);
  19295. }
  19296. if (typeof o.hashCode === "function") {
  19297. return o.hashCode();
  19298. }
  19299. if (type === "object") {
  19300. return hashJSObj(o);
  19301. }
  19302. if (typeof o.toString === "function") {
  19303. return hashString(o.toString());
  19304. }
  19305. throw new Error("Value type " + type + " cannot be hashed.");
  19306. }
  19307. function cachedHashString(string) {
  19308. var hash = stringHashCache[string];
  19309. if (hash === undefined) {
  19310. hash = hashString(string);
  19311. if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
  19312. STRING_HASH_CACHE_SIZE = 0;
  19313. stringHashCache = {};
  19314. }
  19315. STRING_HASH_CACHE_SIZE++;
  19316. stringHashCache[string] = hash;
  19317. }
  19318. return hash;
  19319. }
  19320. // http://jsperf.com/hashing-strings
  19321. function hashString(string) {
  19322. // This is the hash from JVM
  19323. // The hash code for a string is computed as
  19324. // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  19325. // where s[i] is the ith character of the string and n is the length of
  19326. // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  19327. // (exclusive) by dropping high bits.
  19328. var hash = 0;
  19329. for (var ii = 0; ii < string.length; ii++) {
  19330. hash = (31 * hash + string.charCodeAt(ii)) | 0;
  19331. }
  19332. return smi(hash);
  19333. }
  19334. function hashJSObj(obj) {
  19335. var hash;
  19336. if (usingWeakMap) {
  19337. hash = weakMap.get(obj);
  19338. if (hash !== undefined) {
  19339. return hash;
  19340. }
  19341. }
  19342. hash = obj[UID_HASH_KEY];
  19343. if (hash !== undefined) {
  19344. return hash;
  19345. }
  19346. if (!canDefineProperty) {
  19347. hash =
  19348. obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
  19349. if (hash !== undefined) {
  19350. return hash;
  19351. }
  19352. hash = getIENodeHash(obj);
  19353. if (hash !== undefined) {
  19354. return hash;
  19355. }
  19356. }
  19357. hash = ++objHashUID;
  19358. if (objHashUID & 0x40000000) {
  19359. objHashUID = 0;
  19360. }
  19361. if (usingWeakMap) {
  19362. weakMap.set(obj, hash);
  19363. } else if (isExtensible !== undefined && isExtensible(obj) === false) {
  19364. throw new Error("Non-extensible objects are not allowed as keys.");
  19365. } else if (canDefineProperty) {
  19366. Object.defineProperty(obj, UID_HASH_KEY, {
  19367. enumerable: false,
  19368. configurable: false,
  19369. writable: false,
  19370. value: hash
  19371. });
  19372. } else if (
  19373. obj.propertyIsEnumerable !== undefined &&
  19374. obj.propertyIsEnumerable ===
  19375. obj.constructor.prototype.propertyIsEnumerable
  19376. ) {
  19377. // Since we can't define a non-enumerable property on the object
  19378. // we'll hijack one of the less-used non-enumerable properties to
  19379. // save our hash on it. Since this is a function it will not show up in
  19380. // `JSON.stringify` which is what we want.
  19381. obj.propertyIsEnumerable = function() {
  19382. return this.constructor.prototype.propertyIsEnumerable.apply(
  19383. this,
  19384. arguments
  19385. );
  19386. };
  19387. obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
  19388. } else if (obj.nodeType !== undefined) {
  19389. // At this point we couldn't get the IE `uniqueID` to use as a hash
  19390. // and we couldn't use a non-enumerable property to exploit the
  19391. // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
  19392. // itself.
  19393. obj[UID_HASH_KEY] = hash;
  19394. } else {
  19395. throw new Error("Unable to set a non-enumerable property on object.");
  19396. }
  19397. return hash;
  19398. }
  19399. // Get references to ES5 object methods.
  19400. var isExtensible = Object.isExtensible;
  19401. // True if Object.defineProperty works as expected. IE8 fails this test.
  19402. var canDefineProperty = (function() {
  19403. try {
  19404. Object.defineProperty({}, "@", {});
  19405. return true;
  19406. } catch (e) {
  19407. return false;
  19408. }
  19409. })();
  19410. // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
  19411. // and avoid memory leaks from the IE cloneNode bug.
  19412. function getIENodeHash(node) {
  19413. if (node && node.nodeType > 0) {
  19414. switch (node.nodeType) {
  19415. case 1: // Element
  19416. return node.uniqueID;
  19417. case 9: // Document
  19418. return node.documentElement && node.documentElement.uniqueID;
  19419. }
  19420. }
  19421. }
  19422. // If possible, use a WeakMap.
  19423. var usingWeakMap = typeof WeakMap === "function";
  19424. var weakMap;
  19425. if (usingWeakMap) {
  19426. weakMap = new WeakMap();
  19427. }
  19428. var objHashUID = 0;
  19429. var UID_HASH_KEY = "__immutablehash__";
  19430. if (typeof Symbol === "function") {
  19431. UID_HASH_KEY = Symbol(UID_HASH_KEY);
  19432. }
  19433. var STRING_HASH_CACHE_MIN_STRLEN = 16;
  19434. var STRING_HASH_CACHE_MAX_SIZE = 255;
  19435. var STRING_HASH_CACHE_SIZE = 0;
  19436. var stringHashCache = {};
  19437. function assertNotInfinite(size) {
  19438. invariant(
  19439. size !== Infinity,
  19440. "Cannot perform this action with an infinite size."
  19441. );
  19442. }
  19443. createClass(Map, KeyedCollection);
  19444. // @pragma Construction
  19445. function Map(value) {
  19446. return value === null || value === undefined
  19447. ? emptyMap()
  19448. : isMap(value) && !isOrdered(value)
  19449. ? value
  19450. : emptyMap().withMutations(function(map) {
  19451. var iter = KeyedIterable(value);
  19452. assertNotInfinite(iter.size);
  19453. iter.forEach(function(v, k) {
  19454. return map.set(k, v);
  19455. });
  19456. });
  19457. }
  19458. Map.prototype.toString = function() {
  19459. return this.__toString("Map {", "}");
  19460. };
  19461. // @pragma Access
  19462. Map.prototype.get = function(k, notSetValue) {
  19463. return this._root
  19464. ? this._root.get(0, undefined, k, notSetValue)
  19465. : notSetValue;
  19466. };
  19467. // @pragma Modification
  19468. Map.prototype.set = function(k, v) {
  19469. return updateMap(this, k, v);
  19470. };
  19471. Map.prototype.setIn = function(keyPath, v) {
  19472. return this.updateIn(keyPath, NOT_SET, function() {
  19473. return v;
  19474. });
  19475. };
  19476. Map.prototype.remove = function(k) {
  19477. return updateMap(this, k, NOT_SET);
  19478. };
  19479. Map.prototype.deleteIn = function(keyPath) {
  19480. return this.updateIn(keyPath, function() {
  19481. return NOT_SET;
  19482. });
  19483. };
  19484. Map.prototype.update = function(k, notSetValue, updater) {
  19485. return arguments.length === 1
  19486. ? k(this)
  19487. : this.updateIn([k], notSetValue, updater);
  19488. };
  19489. Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
  19490. if (!updater) {
  19491. updater = notSetValue;
  19492. notSetValue = undefined;
  19493. }
  19494. var updatedValue = updateInDeepMap(
  19495. this,
  19496. forceIterator(keyPath),
  19497. notSetValue,
  19498. updater
  19499. );
  19500. return updatedValue === NOT_SET ? undefined : updatedValue;
  19501. };
  19502. Map.prototype.clear = function() {
  19503. if (this.size === 0) {
  19504. return this;
  19505. }
  19506. if (this.__ownerID) {
  19507. this.size = 0;
  19508. this._root = null;
  19509. this.__hash = undefined;
  19510. this.__altered = true;
  19511. return this;
  19512. }
  19513. return emptyMap();
  19514. };
  19515. // @pragma Composition
  19516. Map.prototype.merge = function(/*...iters*/) {
  19517. return mergeIntoMapWith(this, undefined, arguments);
  19518. };
  19519. Map.prototype.mergeWith = function(merger) {
  19520. var iters = SLICE$0.call(arguments, 1);
  19521. return mergeIntoMapWith(this, merger, iters);
  19522. };
  19523. Map.prototype.mergeIn = function(keyPath) {
  19524. var iters = SLICE$0.call(arguments, 1);
  19525. return this.updateIn(keyPath, emptyMap(), function(m) {
  19526. return typeof m.merge === "function"
  19527. ? m.merge.apply(m, iters)
  19528. : iters[iters.length - 1];
  19529. });
  19530. };
  19531. Map.prototype.mergeDeep = function(/*...iters*/) {
  19532. return mergeIntoMapWith(this, deepMerger, arguments);
  19533. };
  19534. Map.prototype.mergeDeepWith = function(merger) {
  19535. var iters = SLICE$0.call(arguments, 1);
  19536. return mergeIntoMapWith(this, deepMergerWith(merger), iters);
  19537. };
  19538. Map.prototype.mergeDeepIn = function(keyPath) {
  19539. var iters = SLICE$0.call(arguments, 1);
  19540. return this.updateIn(keyPath, emptyMap(), function(m) {
  19541. return typeof m.mergeDeep === "function"
  19542. ? m.mergeDeep.apply(m, iters)
  19543. : iters[iters.length - 1];
  19544. });
  19545. };
  19546. Map.prototype.sort = function(comparator) {
  19547. // Late binding
  19548. return OrderedMap(sortFactory(this, comparator));
  19549. };
  19550. Map.prototype.sortBy = function(mapper, comparator) {
  19551. // Late binding
  19552. return OrderedMap(sortFactory(this, comparator, mapper));
  19553. };
  19554. // @pragma Mutability
  19555. Map.prototype.withMutations = function(fn) {
  19556. var mutable = this.asMutable();
  19557. fn(mutable);
  19558. return mutable.wasAltered()
  19559. ? mutable.__ensureOwner(this.__ownerID)
  19560. : this;
  19561. };
  19562. Map.prototype.asMutable = function() {
  19563. return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
  19564. };
  19565. Map.prototype.asImmutable = function() {
  19566. return this.__ensureOwner();
  19567. };
  19568. Map.prototype.wasAltered = function() {
  19569. return this.__altered;
  19570. };
  19571. Map.prototype.__iterator = function(type, reverse) {
  19572. return new MapIterator(this, type, reverse);
  19573. };
  19574. Map.prototype.__iterate = function(fn, reverse) {
  19575. var this$0 = this;
  19576. var iterations = 0;
  19577. this._root &&
  19578. this._root.iterate(function(entry) {
  19579. iterations++;
  19580. return fn(entry[1], entry[0], this$0);
  19581. }, reverse);
  19582. return iterations;
  19583. };
  19584. Map.prototype.__ensureOwner = function(ownerID) {
  19585. if (ownerID === this.__ownerID) {
  19586. return this;
  19587. }
  19588. if (!ownerID) {
  19589. this.__ownerID = ownerID;
  19590. this.__altered = false;
  19591. return this;
  19592. }
  19593. return makeMap(this.size, this._root, ownerID, this.__hash);
  19594. };
  19595. function isMap(maybeMap) {
  19596. return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
  19597. }
  19598. Map.isMap = isMap;
  19599. var IS_MAP_SENTINEL = "@@__IMMUTABLE_MAP__@@";
  19600. var MapPrototype = Map.prototype;
  19601. MapPrototype[IS_MAP_SENTINEL] = true;
  19602. MapPrototype[DELETE] = MapPrototype.remove;
  19603. MapPrototype.removeIn = MapPrototype.deleteIn;
  19604. // #pragma Trie Nodes
  19605. function ArrayMapNode(ownerID, entries) {
  19606. this.ownerID = ownerID;
  19607. this.entries = entries;
  19608. }
  19609. ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  19610. var entries = this.entries;
  19611. for (var ii = 0, len = entries.length; ii < len; ii++) {
  19612. if (is(key, entries[ii][0])) {
  19613. return entries[ii][1];
  19614. }
  19615. }
  19616. return notSetValue;
  19617. };
  19618. ArrayMapNode.prototype.update = function(
  19619. ownerID,
  19620. shift,
  19621. keyHash,
  19622. key,
  19623. value,
  19624. didChangeSize,
  19625. didAlter
  19626. ) {
  19627. var removed = value === NOT_SET;
  19628. var entries = this.entries;
  19629. var idx = 0;
  19630. for (var len = entries.length; idx < len; idx++) {
  19631. if (is(key, entries[idx][0])) {
  19632. break;
  19633. }
  19634. }
  19635. var exists = idx < len;
  19636. if (exists ? entries[idx][1] === value : removed) {
  19637. return this;
  19638. }
  19639. SetRef(didAlter);
  19640. (removed || !exists) && SetRef(didChangeSize);
  19641. if (removed && entries.length === 1) {
  19642. return; // undefined
  19643. }
  19644. if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
  19645. return createNodes(ownerID, entries, key, value);
  19646. }
  19647. var isEditable = ownerID && ownerID === this.ownerID;
  19648. var newEntries = isEditable ? entries : arrCopy(entries);
  19649. if (exists) {
  19650. if (removed) {
  19651. idx === len - 1
  19652. ? newEntries.pop()
  19653. : (newEntries[idx] = newEntries.pop());
  19654. } else {
  19655. newEntries[idx] = [key, value];
  19656. }
  19657. } else {
  19658. newEntries.push([key, value]);
  19659. }
  19660. if (isEditable) {
  19661. this.entries = newEntries;
  19662. return this;
  19663. }
  19664. return new ArrayMapNode(ownerID, newEntries);
  19665. };
  19666. function BitmapIndexedNode(ownerID, bitmap, nodes) {
  19667. this.ownerID = ownerID;
  19668. this.bitmap = bitmap;
  19669. this.nodes = nodes;
  19670. }
  19671. BitmapIndexedNode.prototype.get = function(
  19672. shift,
  19673. keyHash,
  19674. key,
  19675. notSetValue
  19676. ) {
  19677. if (keyHash === undefined) {
  19678. keyHash = hash(key);
  19679. }
  19680. var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK);
  19681. var bitmap = this.bitmap;
  19682. return (bitmap & bit) === 0
  19683. ? notSetValue
  19684. : this.nodes[popCount(bitmap & (bit - 1))].get(
  19685. shift + SHIFT,
  19686. keyHash,
  19687. key,
  19688. notSetValue
  19689. );
  19690. };
  19691. BitmapIndexedNode.prototype.update = function(
  19692. ownerID,
  19693. shift,
  19694. keyHash,
  19695. key,
  19696. value,
  19697. didChangeSize,
  19698. didAlter
  19699. ) {
  19700. if (keyHash === undefined) {
  19701. keyHash = hash(key);
  19702. }
  19703. var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  19704. var bit = 1 << keyHashFrag;
  19705. var bitmap = this.bitmap;
  19706. var exists = (bitmap & bit) !== 0;
  19707. if (!exists && value === NOT_SET) {
  19708. return this;
  19709. }
  19710. var idx = popCount(bitmap & (bit - 1));
  19711. var nodes = this.nodes;
  19712. var node = exists ? nodes[idx] : undefined;
  19713. var newNode = updateNode(
  19714. node,
  19715. ownerID,
  19716. shift + SHIFT,
  19717. keyHash,
  19718. key,
  19719. value,
  19720. didChangeSize,
  19721. didAlter
  19722. );
  19723. if (newNode === node) {
  19724. return this;
  19725. }
  19726. if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
  19727. return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
  19728. }
  19729. if (
  19730. exists &&
  19731. !newNode &&
  19732. nodes.length === 2 &&
  19733. isLeafNode(nodes[idx ^ 1])
  19734. ) {
  19735. return nodes[idx ^ 1];
  19736. }
  19737. if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
  19738. return newNode;
  19739. }
  19740. var isEditable = ownerID && ownerID === this.ownerID;
  19741. var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit;
  19742. var newNodes = exists
  19743. ? newNode
  19744. ? setIn(nodes, idx, newNode, isEditable)
  19745. : spliceOut(nodes, idx, isEditable)
  19746. : spliceIn(nodes, idx, newNode, isEditable);
  19747. if (isEditable) {
  19748. this.bitmap = newBitmap;
  19749. this.nodes = newNodes;
  19750. return this;
  19751. }
  19752. return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
  19753. };
  19754. function HashArrayMapNode(ownerID, count, nodes) {
  19755. this.ownerID = ownerID;
  19756. this.count = count;
  19757. this.nodes = nodes;
  19758. }
  19759. HashArrayMapNode.prototype.get = function(
  19760. shift,
  19761. keyHash,
  19762. key,
  19763. notSetValue
  19764. ) {
  19765. if (keyHash === undefined) {
  19766. keyHash = hash(key);
  19767. }
  19768. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  19769. var node = this.nodes[idx];
  19770. return node
  19771. ? node.get(shift + SHIFT, keyHash, key, notSetValue)
  19772. : notSetValue;
  19773. };
  19774. HashArrayMapNode.prototype.update = function(
  19775. ownerID,
  19776. shift,
  19777. keyHash,
  19778. key,
  19779. value,
  19780. didChangeSize,
  19781. didAlter
  19782. ) {
  19783. if (keyHash === undefined) {
  19784. keyHash = hash(key);
  19785. }
  19786. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  19787. var removed = value === NOT_SET;
  19788. var nodes = this.nodes;
  19789. var node = nodes[idx];
  19790. if (removed && !node) {
  19791. return this;
  19792. }
  19793. var newNode = updateNode(
  19794. node,
  19795. ownerID,
  19796. shift + SHIFT,
  19797. keyHash,
  19798. key,
  19799. value,
  19800. didChangeSize,
  19801. didAlter
  19802. );
  19803. if (newNode === node) {
  19804. return this;
  19805. }
  19806. var newCount = this.count;
  19807. if (!node) {
  19808. newCount++;
  19809. } else if (!newNode) {
  19810. newCount--;
  19811. if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
  19812. return packNodes(ownerID, nodes, newCount, idx);
  19813. }
  19814. }
  19815. var isEditable = ownerID && ownerID === this.ownerID;
  19816. var newNodes = setIn(nodes, idx, newNode, isEditable);
  19817. if (isEditable) {
  19818. this.count = newCount;
  19819. this.nodes = newNodes;
  19820. return this;
  19821. }
  19822. return new HashArrayMapNode(ownerID, newCount, newNodes);
  19823. };
  19824. function HashCollisionNode(ownerID, keyHash, entries) {
  19825. this.ownerID = ownerID;
  19826. this.keyHash = keyHash;
  19827. this.entries = entries;
  19828. }
  19829. HashCollisionNode.prototype.get = function(
  19830. shift,
  19831. keyHash,
  19832. key,
  19833. notSetValue
  19834. ) {
  19835. var entries = this.entries;
  19836. for (var ii = 0, len = entries.length; ii < len; ii++) {
  19837. if (is(key, entries[ii][0])) {
  19838. return entries[ii][1];
  19839. }
  19840. }
  19841. return notSetValue;
  19842. };
  19843. HashCollisionNode.prototype.update = function(
  19844. ownerID,
  19845. shift,
  19846. keyHash,
  19847. key,
  19848. value,
  19849. didChangeSize,
  19850. didAlter
  19851. ) {
  19852. if (keyHash === undefined) {
  19853. keyHash = hash(key);
  19854. }
  19855. var removed = value === NOT_SET;
  19856. if (keyHash !== this.keyHash) {
  19857. if (removed) {
  19858. return this;
  19859. }
  19860. SetRef(didAlter);
  19861. SetRef(didChangeSize);
  19862. return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
  19863. }
  19864. var entries = this.entries;
  19865. var idx = 0;
  19866. for (var len = entries.length; idx < len; idx++) {
  19867. if (is(key, entries[idx][0])) {
  19868. break;
  19869. }
  19870. }
  19871. var exists = idx < len;
  19872. if (exists ? entries[idx][1] === value : removed) {
  19873. return this;
  19874. }
  19875. SetRef(didAlter);
  19876. (removed || !exists) && SetRef(didChangeSize);
  19877. if (removed && len === 2) {
  19878. return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
  19879. }
  19880. var isEditable = ownerID && ownerID === this.ownerID;
  19881. var newEntries = isEditable ? entries : arrCopy(entries);
  19882. if (exists) {
  19883. if (removed) {
  19884. idx === len - 1
  19885. ? newEntries.pop()
  19886. : (newEntries[idx] = newEntries.pop());
  19887. } else {
  19888. newEntries[idx] = [key, value];
  19889. }
  19890. } else {
  19891. newEntries.push([key, value]);
  19892. }
  19893. if (isEditable) {
  19894. this.entries = newEntries;
  19895. return this;
  19896. }
  19897. return new HashCollisionNode(ownerID, this.keyHash, newEntries);
  19898. };
  19899. function ValueNode(ownerID, keyHash, entry) {
  19900. this.ownerID = ownerID;
  19901. this.keyHash = keyHash;
  19902. this.entry = entry;
  19903. }
  19904. ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  19905. return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
  19906. };
  19907. ValueNode.prototype.update = function(
  19908. ownerID,
  19909. shift,
  19910. keyHash,
  19911. key,
  19912. value,
  19913. didChangeSize,
  19914. didAlter
  19915. ) {
  19916. var removed = value === NOT_SET;
  19917. var keyMatch = is(key, this.entry[0]);
  19918. if (keyMatch ? value === this.entry[1] : removed) {
  19919. return this;
  19920. }
  19921. SetRef(didAlter);
  19922. if (removed) {
  19923. SetRef(didChangeSize);
  19924. return; // undefined
  19925. }
  19926. if (keyMatch) {
  19927. if (ownerID && ownerID === this.ownerID) {
  19928. this.entry[1] = value;
  19929. return this;
  19930. }
  19931. return new ValueNode(ownerID, this.keyHash, [key, value]);
  19932. }
  19933. SetRef(didChangeSize);
  19934. return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
  19935. };
  19936. // #pragma Iterators
  19937. ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = function(
  19938. fn,
  19939. reverse
  19940. ) {
  19941. var entries = this.entries;
  19942. for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
  19943. if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
  19944. return false;
  19945. }
  19946. }
  19947. };
  19948. BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = function(
  19949. fn,
  19950. reverse
  19951. ) {
  19952. var nodes = this.nodes;
  19953. for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
  19954. var node = nodes[reverse ? maxIndex - ii : ii];
  19955. if (node && node.iterate(fn, reverse) === false) {
  19956. return false;
  19957. }
  19958. }
  19959. };
  19960. ValueNode.prototype.iterate = function(fn, reverse) {
  19961. return fn(this.entry);
  19962. };
  19963. createClass(MapIterator, Iterator);
  19964. function MapIterator(map, type, reverse) {
  19965. this._type = type;
  19966. this._reverse = reverse;
  19967. this._stack = map._root && mapIteratorFrame(map._root);
  19968. }
  19969. MapIterator.prototype.next = function() {
  19970. var type = this._type;
  19971. var stack = this._stack;
  19972. while (stack) {
  19973. var node = stack.node;
  19974. var index = stack.index++;
  19975. var maxIndex;
  19976. if (node.entry) {
  19977. if (index === 0) {
  19978. return mapIteratorValue(type, node.entry);
  19979. }
  19980. } else if (node.entries) {
  19981. maxIndex = node.entries.length - 1;
  19982. if (index <= maxIndex) {
  19983. return mapIteratorValue(
  19984. type,
  19985. node.entries[this._reverse ? maxIndex - index : index]
  19986. );
  19987. }
  19988. } else {
  19989. maxIndex = node.nodes.length - 1;
  19990. if (index <= maxIndex) {
  19991. var subNode = node.nodes[this._reverse ? maxIndex - index : index];
  19992. if (subNode) {
  19993. if (subNode.entry) {
  19994. return mapIteratorValue(type, subNode.entry);
  19995. }
  19996. stack = this._stack = mapIteratorFrame(subNode, stack);
  19997. }
  19998. continue;
  19999. }
  20000. }
  20001. stack = this._stack = this._stack.__prev;
  20002. }
  20003. return iteratorDone();
  20004. };
  20005. function mapIteratorValue(type, entry) {
  20006. return iteratorValue(type, entry[0], entry[1]);
  20007. }
  20008. function mapIteratorFrame(node, prev) {
  20009. return {
  20010. node: node,
  20011. index: 0,
  20012. __prev: prev
  20013. };
  20014. }
  20015. function makeMap(size, root, ownerID, hash) {
  20016. var map = Object.create(MapPrototype);
  20017. map.size = size;
  20018. map._root = root;
  20019. map.__ownerID = ownerID;
  20020. map.__hash = hash;
  20021. map.__altered = false;
  20022. return map;
  20023. }
  20024. var EMPTY_MAP;
  20025. function emptyMap() {
  20026. return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
  20027. }
  20028. function updateMap(map, k, v) {
  20029. var newRoot;
  20030. var newSize;
  20031. if (!map._root) {
  20032. if (v === NOT_SET) {
  20033. return map;
  20034. }
  20035. newSize = 1;
  20036. newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
  20037. } else {
  20038. var didChangeSize = MakeRef(CHANGE_LENGTH);
  20039. var didAlter = MakeRef(DID_ALTER);
  20040. newRoot = updateNode(
  20041. map._root,
  20042. map.__ownerID,
  20043. 0,
  20044. undefined,
  20045. k,
  20046. v,
  20047. didChangeSize,
  20048. didAlter
  20049. );
  20050. if (!didAlter.value) {
  20051. return map;
  20052. }
  20053. newSize =
  20054. map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0);
  20055. }
  20056. if (map.__ownerID) {
  20057. map.size = newSize;
  20058. map._root = newRoot;
  20059. map.__hash = undefined;
  20060. map.__altered = true;
  20061. return map;
  20062. }
  20063. return newRoot ? makeMap(newSize, newRoot) : emptyMap();
  20064. }
  20065. function updateNode(
  20066. node,
  20067. ownerID,
  20068. shift,
  20069. keyHash,
  20070. key,
  20071. value,
  20072. didChangeSize,
  20073. didAlter
  20074. ) {
  20075. if (!node) {
  20076. if (value === NOT_SET) {
  20077. return node;
  20078. }
  20079. SetRef(didAlter);
  20080. SetRef(didChangeSize);
  20081. return new ValueNode(ownerID, keyHash, [key, value]);
  20082. }
  20083. return node.update(
  20084. ownerID,
  20085. shift,
  20086. keyHash,
  20087. key,
  20088. value,
  20089. didChangeSize,
  20090. didAlter
  20091. );
  20092. }
  20093. function isLeafNode(node) {
  20094. return (
  20095. node.constructor === ValueNode || node.constructor === HashCollisionNode
  20096. );
  20097. }
  20098. function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
  20099. if (node.keyHash === keyHash) {
  20100. return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
  20101. }
  20102. var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
  20103. var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  20104. var newNode;
  20105. var nodes =
  20106. idx1 === idx2
  20107. ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)]
  20108. : ((newNode = new ValueNode(ownerID, keyHash, entry)),
  20109. idx1 < idx2 ? [node, newNode] : [newNode, node]);
  20110. return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
  20111. }
  20112. function createNodes(ownerID, entries, key, value) {
  20113. if (!ownerID) {
  20114. ownerID = new OwnerID();
  20115. }
  20116. var node = new ValueNode(ownerID, hash(key), [key, value]);
  20117. for (var ii = 0; ii < entries.length; ii++) {
  20118. var entry = entries[ii];
  20119. node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
  20120. }
  20121. return node;
  20122. }
  20123. function packNodes(ownerID, nodes, count, excluding) {
  20124. var bitmap = 0;
  20125. var packedII = 0;
  20126. var packedNodes = new Array(count);
  20127. for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
  20128. var node = nodes[ii];
  20129. if (node !== undefined && ii !== excluding) {
  20130. bitmap |= bit;
  20131. packedNodes[packedII++] = node;
  20132. }
  20133. }
  20134. return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
  20135. }
  20136. function expandNodes(ownerID, nodes, bitmap, including, node) {
  20137. var count = 0;
  20138. var expandedNodes = new Array(SIZE);
  20139. for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
  20140. expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
  20141. }
  20142. expandedNodes[including] = node;
  20143. return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
  20144. }
  20145. function mergeIntoMapWith(map, merger, iterables) {
  20146. var iters = [];
  20147. for (var ii = 0; ii < iterables.length; ii++) {
  20148. var value = iterables[ii];
  20149. var iter = KeyedIterable(value);
  20150. if (!isIterable(value)) {
  20151. iter = iter.map(function(v) {
  20152. return fromJS(v);
  20153. });
  20154. }
  20155. iters.push(iter);
  20156. }
  20157. return mergeIntoCollectionWith(map, merger, iters);
  20158. }
  20159. function deepMerger(existing, value, key) {
  20160. return existing && existing.mergeDeep && isIterable(value)
  20161. ? existing.mergeDeep(value)
  20162. : is(existing, value)
  20163. ? existing
  20164. : value;
  20165. }
  20166. function deepMergerWith(merger) {
  20167. return function(existing, value, key) {
  20168. if (existing && existing.mergeDeepWith && isIterable(value)) {
  20169. return existing.mergeDeepWith(merger, value);
  20170. }
  20171. var nextValue = merger(existing, value, key);
  20172. return is(existing, nextValue) ? existing : nextValue;
  20173. };
  20174. }
  20175. function mergeIntoCollectionWith(collection, merger, iters) {
  20176. iters = iters.filter(function(x) {
  20177. return x.size !== 0;
  20178. });
  20179. if (iters.length === 0) {
  20180. return collection;
  20181. }
  20182. if (
  20183. collection.size === 0 &&
  20184. !collection.__ownerID &&
  20185. iters.length === 1
  20186. ) {
  20187. return collection.constructor(iters[0]);
  20188. }
  20189. return collection.withMutations(function(collection) {
  20190. var mergeIntoMap = merger
  20191. ? function(value, key) {
  20192. collection.update(key, NOT_SET, function(existing) {
  20193. return existing === NOT_SET
  20194. ? value
  20195. : merger(existing, value, key);
  20196. });
  20197. }
  20198. : function(value, key) {
  20199. collection.set(key, value);
  20200. };
  20201. for (var ii = 0; ii < iters.length; ii++) {
  20202. iters[ii].forEach(mergeIntoMap);
  20203. }
  20204. });
  20205. }
  20206. function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
  20207. var isNotSet = existing === NOT_SET;
  20208. var step = keyPathIter.next();
  20209. if (step.done) {
  20210. var existingValue = isNotSet ? notSetValue : existing;
  20211. var newValue = updater(existingValue);
  20212. return newValue === existingValue ? existing : newValue;
  20213. }
  20214. invariant(isNotSet || (existing && existing.set), "invalid keyPath");
  20215. var key = step.value;
  20216. var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
  20217. var nextUpdated = updateInDeepMap(
  20218. nextExisting,
  20219. keyPathIter,
  20220. notSetValue,
  20221. updater
  20222. );
  20223. return nextUpdated === nextExisting
  20224. ? existing
  20225. : nextUpdated === NOT_SET
  20226. ? existing.remove(key)
  20227. : (isNotSet ? emptyMap() : existing).set(key, nextUpdated);
  20228. }
  20229. function popCount(x) {
  20230. x = x - ((x >> 1) & 0x55555555);
  20231. x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  20232. x = (x + (x >> 4)) & 0x0f0f0f0f;
  20233. x = x + (x >> 8);
  20234. x = x + (x >> 16);
  20235. return x & 0x7f;
  20236. }
  20237. function setIn(array, idx, val, canEdit) {
  20238. var newArray = canEdit ? array : arrCopy(array);
  20239. newArray[idx] = val;
  20240. return newArray;
  20241. }
  20242. function spliceIn(array, idx, val, canEdit) {
  20243. var newLen = array.length + 1;
  20244. if (canEdit && idx + 1 === newLen) {
  20245. array[idx] = val;
  20246. return array;
  20247. }
  20248. var newArray = new Array(newLen);
  20249. var after = 0;
  20250. for (var ii = 0; ii < newLen; ii++) {
  20251. if (ii === idx) {
  20252. newArray[ii] = val;
  20253. after = -1;
  20254. } else {
  20255. newArray[ii] = array[ii + after];
  20256. }
  20257. }
  20258. return newArray;
  20259. }
  20260. function spliceOut(array, idx, canEdit) {
  20261. var newLen = array.length - 1;
  20262. if (canEdit && idx === newLen) {
  20263. array.pop();
  20264. return array;
  20265. }
  20266. var newArray = new Array(newLen);
  20267. var after = 0;
  20268. for (var ii = 0; ii < newLen; ii++) {
  20269. if (ii === idx) {
  20270. after = 1;
  20271. }
  20272. newArray[ii] = array[ii + after];
  20273. }
  20274. return newArray;
  20275. }
  20276. var MAX_ARRAY_MAP_SIZE = SIZE / 4;
  20277. var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
  20278. var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
  20279. createClass(List, IndexedCollection);
  20280. // @pragma Construction
  20281. function List(value) {
  20282. var empty = emptyList();
  20283. if (value === null || value === undefined) {
  20284. return empty;
  20285. }
  20286. if (isList(value)) {
  20287. return value;
  20288. }
  20289. var iter = IndexedIterable(value);
  20290. var size = iter.size;
  20291. if (size === 0) {
  20292. return empty;
  20293. }
  20294. assertNotInfinite(size);
  20295. if (size > 0 && size < SIZE) {
  20296. return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
  20297. }
  20298. return empty.withMutations(function(list) {
  20299. list.setSize(size);
  20300. iter.forEach(function(v, i) {
  20301. return list.set(i, v);
  20302. });
  20303. });
  20304. }
  20305. List.of = function(/*...values*/) {
  20306. return this(arguments);
  20307. };
  20308. List.prototype.toString = function() {
  20309. return this.__toString("List [", "]");
  20310. };
  20311. // @pragma Access
  20312. List.prototype.get = function(index, notSetValue) {
  20313. index = wrapIndex(this, index);
  20314. if (index >= 0 && index < this.size) {
  20315. index += this._origin;
  20316. var node = listNodeFor(this, index);
  20317. return node && node.array[index & MASK];
  20318. }
  20319. return notSetValue;
  20320. };
  20321. // @pragma Modification
  20322. List.prototype.set = function(index, value) {
  20323. return updateList(this, index, value);
  20324. };
  20325. List.prototype.remove = function(index) {
  20326. return !this.has(index)
  20327. ? this
  20328. : index === 0
  20329. ? this.shift()
  20330. : index === this.size - 1
  20331. ? this.pop()
  20332. : this.splice(index, 1);
  20333. };
  20334. List.prototype.insert = function(index, value) {
  20335. return this.splice(index, 0, value);
  20336. };
  20337. List.prototype.clear = function() {
  20338. if (this.size === 0) {
  20339. return this;
  20340. }
  20341. if (this.__ownerID) {
  20342. this.size = this._origin = this._capacity = 0;
  20343. this._level = SHIFT;
  20344. this._root = this._tail = null;
  20345. this.__hash = undefined;
  20346. this.__altered = true;
  20347. return this;
  20348. }
  20349. return emptyList();
  20350. };
  20351. List.prototype.push = function(/*...values*/) {
  20352. var values = arguments;
  20353. var oldSize = this.size;
  20354. return this.withMutations(function(list) {
  20355. setListBounds(list, 0, oldSize + values.length);
  20356. for (var ii = 0; ii < values.length; ii++) {
  20357. list.set(oldSize + ii, values[ii]);
  20358. }
  20359. });
  20360. };
  20361. List.prototype.pop = function() {
  20362. return setListBounds(this, 0, -1);
  20363. };
  20364. List.prototype.unshift = function(/*...values*/) {
  20365. var values = arguments;
  20366. return this.withMutations(function(list) {
  20367. setListBounds(list, -values.length);
  20368. for (var ii = 0; ii < values.length; ii++) {
  20369. list.set(ii, values[ii]);
  20370. }
  20371. });
  20372. };
  20373. List.prototype.shift = function() {
  20374. return setListBounds(this, 1);
  20375. };
  20376. // @pragma Composition
  20377. List.prototype.merge = function(/*...iters*/) {
  20378. return mergeIntoListWith(this, undefined, arguments);
  20379. };
  20380. List.prototype.mergeWith = function(merger) {
  20381. var iters = SLICE$0.call(arguments, 1);
  20382. return mergeIntoListWith(this, merger, iters);
  20383. };
  20384. List.prototype.mergeDeep = function(/*...iters*/) {
  20385. return mergeIntoListWith(this, deepMerger, arguments);
  20386. };
  20387. List.prototype.mergeDeepWith = function(merger) {
  20388. var iters = SLICE$0.call(arguments, 1);
  20389. return mergeIntoListWith(this, deepMergerWith(merger), iters);
  20390. };
  20391. List.prototype.setSize = function(size) {
  20392. return setListBounds(this, 0, size);
  20393. };
  20394. // @pragma Iteration
  20395. List.prototype.slice = function(begin, end) {
  20396. var size = this.size;
  20397. if (wholeSlice(begin, end, size)) {
  20398. return this;
  20399. }
  20400. return setListBounds(
  20401. this,
  20402. resolveBegin(begin, size),
  20403. resolveEnd(end, size)
  20404. );
  20405. };
  20406. List.prototype.__iterator = function(type, reverse) {
  20407. var index = 0;
  20408. var values = iterateList(this, reverse);
  20409. return new Iterator(function() {
  20410. var value = values();
  20411. return value === DONE
  20412. ? iteratorDone()
  20413. : iteratorValue(type, index++, value);
  20414. });
  20415. };
  20416. List.prototype.__iterate = function(fn, reverse) {
  20417. var index = 0;
  20418. var values = iterateList(this, reverse);
  20419. var value;
  20420. while ((value = values()) !== DONE) {
  20421. if (fn(value, index++, this) === false) {
  20422. break;
  20423. }
  20424. }
  20425. return index;
  20426. };
  20427. List.prototype.__ensureOwner = function(ownerID) {
  20428. if (ownerID === this.__ownerID) {
  20429. return this;
  20430. }
  20431. if (!ownerID) {
  20432. this.__ownerID = ownerID;
  20433. return this;
  20434. }
  20435. return makeList(
  20436. this._origin,
  20437. this._capacity,
  20438. this._level,
  20439. this._root,
  20440. this._tail,
  20441. ownerID,
  20442. this.__hash
  20443. );
  20444. };
  20445. function isList(maybeList) {
  20446. return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
  20447. }
  20448. List.isList = isList;
  20449. var IS_LIST_SENTINEL = "@@__IMMUTABLE_LIST__@@";
  20450. var ListPrototype = List.prototype;
  20451. ListPrototype[IS_LIST_SENTINEL] = true;
  20452. ListPrototype[DELETE] = ListPrototype.remove;
  20453. ListPrototype.setIn = MapPrototype.setIn;
  20454. ListPrototype.deleteIn = ListPrototype.removeIn = MapPrototype.removeIn;
  20455. ListPrototype.update = MapPrototype.update;
  20456. ListPrototype.updateIn = MapPrototype.updateIn;
  20457. ListPrototype.mergeIn = MapPrototype.mergeIn;
  20458. ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  20459. ListPrototype.withMutations = MapPrototype.withMutations;
  20460. ListPrototype.asMutable = MapPrototype.asMutable;
  20461. ListPrototype.asImmutable = MapPrototype.asImmutable;
  20462. ListPrototype.wasAltered = MapPrototype.wasAltered;
  20463. function VNode(array, ownerID) {
  20464. this.array = array;
  20465. this.ownerID = ownerID;
  20466. }
  20467. // TODO: seems like these methods are very similar
  20468. VNode.prototype.removeBefore = function(ownerID, level, index) {
  20469. if (index === level ? 1 << level : this.array.length === 0) {
  20470. return this;
  20471. }
  20472. var originIndex = (index >>> level) & MASK;
  20473. if (originIndex >= this.array.length) {
  20474. return new VNode([], ownerID);
  20475. }
  20476. var removingFirst = originIndex === 0;
  20477. var newChild;
  20478. if (level > 0) {
  20479. var oldChild = this.array[originIndex];
  20480. newChild =
  20481. oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
  20482. if (newChild === oldChild && removingFirst) {
  20483. return this;
  20484. }
  20485. }
  20486. if (removingFirst && !newChild) {
  20487. return this;
  20488. }
  20489. var editable = editableVNode(this, ownerID);
  20490. if (!removingFirst) {
  20491. for (var ii = 0; ii < originIndex; ii++) {
  20492. editable.array[ii] = undefined;
  20493. }
  20494. }
  20495. if (newChild) {
  20496. editable.array[originIndex] = newChild;
  20497. }
  20498. return editable;
  20499. };
  20500. VNode.prototype.removeAfter = function(ownerID, level, index) {
  20501. if (index === (level ? 1 << level : 0) || this.array.length === 0) {
  20502. return this;
  20503. }
  20504. var sizeIndex = ((index - 1) >>> level) & MASK;
  20505. if (sizeIndex >= this.array.length) {
  20506. return this;
  20507. }
  20508. var newChild;
  20509. if (level > 0) {
  20510. var oldChild = this.array[sizeIndex];
  20511. newChild =
  20512. oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
  20513. if (newChild === oldChild && sizeIndex === this.array.length - 1) {
  20514. return this;
  20515. }
  20516. }
  20517. var editable = editableVNode(this, ownerID);
  20518. editable.array.splice(sizeIndex + 1);
  20519. if (newChild) {
  20520. editable.array[sizeIndex] = newChild;
  20521. }
  20522. return editable;
  20523. };
  20524. var DONE = {};
  20525. function iterateList(list, reverse) {
  20526. var left = list._origin;
  20527. var right = list._capacity;
  20528. var tailPos = getTailOffset(right);
  20529. var tail = list._tail;
  20530. return iterateNodeOrLeaf(list._root, list._level, 0);
  20531. function iterateNodeOrLeaf(node, level, offset) {
  20532. return level === 0
  20533. ? iterateLeaf(node, offset)
  20534. : iterateNode(node, level, offset);
  20535. }
  20536. function iterateLeaf(node, offset) {
  20537. var array =
  20538. offset === tailPos ? tail && tail.array : node && node.array;
  20539. var from = offset > left ? 0 : left - offset;
  20540. var to = right - offset;
  20541. if (to > SIZE) {
  20542. to = SIZE;
  20543. }
  20544. return function() {
  20545. if (from === to) {
  20546. return DONE;
  20547. }
  20548. var idx = reverse ? --to : from++;
  20549. return array && array[idx];
  20550. };
  20551. }
  20552. function iterateNode(node, level, offset) {
  20553. var values;
  20554. var array = node && node.array;
  20555. var from = offset > left ? 0 : (left - offset) >> level;
  20556. var to = ((right - offset) >> level) + 1;
  20557. if (to > SIZE) {
  20558. to = SIZE;
  20559. }
  20560. return function() {
  20561. do {
  20562. if (values) {
  20563. var value = values();
  20564. if (value !== DONE) {
  20565. return value;
  20566. }
  20567. values = null;
  20568. }
  20569. if (from === to) {
  20570. return DONE;
  20571. }
  20572. var idx = reverse ? --to : from++;
  20573. values = iterateNodeOrLeaf(
  20574. array && array[idx],
  20575. level - SHIFT,
  20576. offset + (idx << level)
  20577. );
  20578. } while (true);
  20579. };
  20580. }
  20581. }
  20582. function makeList(origin, capacity, level, root, tail, ownerID, hash) {
  20583. var list = Object.create(ListPrototype);
  20584. list.size = capacity - origin;
  20585. list._origin = origin;
  20586. list._capacity = capacity;
  20587. list._level = level;
  20588. list._root = root;
  20589. list._tail = tail;
  20590. list.__ownerID = ownerID;
  20591. list.__hash = hash;
  20592. list.__altered = false;
  20593. return list;
  20594. }
  20595. var EMPTY_LIST;
  20596. function emptyList() {
  20597. return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
  20598. }
  20599. function updateList(list, index, value) {
  20600. index = wrapIndex(list, index);
  20601. if (index !== index) {
  20602. return list;
  20603. }
  20604. if (index >= list.size || index < 0) {
  20605. return list.withMutations(function(list) {
  20606. index < 0
  20607. ? setListBounds(list, index).set(0, value)
  20608. : setListBounds(list, 0, index + 1).set(index, value);
  20609. });
  20610. }
  20611. index += list._origin;
  20612. var newTail = list._tail;
  20613. var newRoot = list._root;
  20614. var didAlter = MakeRef(DID_ALTER);
  20615. if (index >= getTailOffset(list._capacity)) {
  20616. newTail = updateVNode(
  20617. newTail,
  20618. list.__ownerID,
  20619. 0,
  20620. index,
  20621. value,
  20622. didAlter
  20623. );
  20624. } else {
  20625. newRoot = updateVNode(
  20626. newRoot,
  20627. list.__ownerID,
  20628. list._level,
  20629. index,
  20630. value,
  20631. didAlter
  20632. );
  20633. }
  20634. if (!didAlter.value) {
  20635. return list;
  20636. }
  20637. if (list.__ownerID) {
  20638. list._root = newRoot;
  20639. list._tail = newTail;
  20640. list.__hash = undefined;
  20641. list.__altered = true;
  20642. return list;
  20643. }
  20644. return makeList(
  20645. list._origin,
  20646. list._capacity,
  20647. list._level,
  20648. newRoot,
  20649. newTail
  20650. );
  20651. }
  20652. function updateVNode(node, ownerID, level, index, value, didAlter) {
  20653. var idx = (index >>> level) & MASK;
  20654. var nodeHas = node && idx < node.array.length;
  20655. if (!nodeHas && value === undefined) {
  20656. return node;
  20657. }
  20658. var newNode;
  20659. if (level > 0) {
  20660. var lowerNode = node && node.array[idx];
  20661. var newLowerNode = updateVNode(
  20662. lowerNode,
  20663. ownerID,
  20664. level - SHIFT,
  20665. index,
  20666. value,
  20667. didAlter
  20668. );
  20669. if (newLowerNode === lowerNode) {
  20670. return node;
  20671. }
  20672. newNode = editableVNode(node, ownerID);
  20673. newNode.array[idx] = newLowerNode;
  20674. return newNode;
  20675. }
  20676. if (nodeHas && node.array[idx] === value) {
  20677. return node;
  20678. }
  20679. SetRef(didAlter);
  20680. newNode = editableVNode(node, ownerID);
  20681. if (value === undefined && idx === newNode.array.length - 1) {
  20682. newNode.array.pop();
  20683. } else {
  20684. newNode.array[idx] = value;
  20685. }
  20686. return newNode;
  20687. }
  20688. function editableVNode(node, ownerID) {
  20689. if (ownerID && node && ownerID === node.ownerID) {
  20690. return node;
  20691. }
  20692. return new VNode(node ? node.array.slice() : [], ownerID);
  20693. }
  20694. function listNodeFor(list, rawIndex) {
  20695. if (rawIndex >= getTailOffset(list._capacity)) {
  20696. return list._tail;
  20697. }
  20698. if (rawIndex < 1 << (list._level + SHIFT)) {
  20699. var node = list._root;
  20700. var level = list._level;
  20701. while (node && level > 0) {
  20702. node = node.array[(rawIndex >>> level) & MASK];
  20703. level -= SHIFT;
  20704. }
  20705. return node;
  20706. }
  20707. }
  20708. function setListBounds(list, begin, end) {
  20709. // Sanitize begin & end using this shorthand for ToInt32(argument)
  20710. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  20711. if (begin !== undefined) {
  20712. begin = begin | 0;
  20713. }
  20714. if (end !== undefined) {
  20715. end = end | 0;
  20716. }
  20717. var owner = list.__ownerID || new OwnerID();
  20718. var oldOrigin = list._origin;
  20719. var oldCapacity = list._capacity;
  20720. var newOrigin = oldOrigin + begin;
  20721. var newCapacity =
  20722. end === undefined
  20723. ? oldCapacity
  20724. : end < 0
  20725. ? oldCapacity + end
  20726. : oldOrigin + end;
  20727. if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
  20728. return list;
  20729. }
  20730. // If it's going to end after it starts, it's empty.
  20731. if (newOrigin >= newCapacity) {
  20732. return list.clear();
  20733. }
  20734. var newLevel = list._level;
  20735. var newRoot = list._root;
  20736. // New origin might need creating a higher root.
  20737. var offsetShift = 0;
  20738. while (newOrigin + offsetShift < 0) {
  20739. newRoot = new VNode(
  20740. newRoot && newRoot.array.length ? [undefined, newRoot] : [],
  20741. owner
  20742. );
  20743. newLevel += SHIFT;
  20744. offsetShift += 1 << newLevel;
  20745. }
  20746. if (offsetShift) {
  20747. newOrigin += offsetShift;
  20748. oldOrigin += offsetShift;
  20749. newCapacity += offsetShift;
  20750. oldCapacity += offsetShift;
  20751. }
  20752. var oldTailOffset = getTailOffset(oldCapacity);
  20753. var newTailOffset = getTailOffset(newCapacity);
  20754. // New size might need creating a higher root.
  20755. while (newTailOffset >= 1 << (newLevel + SHIFT)) {
  20756. newRoot = new VNode(
  20757. newRoot && newRoot.array.length ? [newRoot] : [],
  20758. owner
  20759. );
  20760. newLevel += SHIFT;
  20761. }
  20762. // Locate or create the new tail.
  20763. var oldTail = list._tail;
  20764. var newTail =
  20765. newTailOffset < oldTailOffset
  20766. ? listNodeFor(list, newCapacity - 1)
  20767. : newTailOffset > oldTailOffset
  20768. ? new VNode([], owner)
  20769. : oldTail;
  20770. // Merge Tail into tree.
  20771. if (
  20772. oldTail &&
  20773. newTailOffset > oldTailOffset &&
  20774. newOrigin < oldCapacity &&
  20775. oldTail.array.length
  20776. ) {
  20777. newRoot = editableVNode(newRoot, owner);
  20778. var node = newRoot;
  20779. for (var level = newLevel; level > SHIFT; level -= SHIFT) {
  20780. var idx = (oldTailOffset >>> level) & MASK;
  20781. node = node.array[idx] = editableVNode(node.array[idx], owner);
  20782. }
  20783. node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
  20784. }
  20785. // If the size has been reduced, there's a chance the tail needs to be trimmed.
  20786. if (newCapacity < oldCapacity) {
  20787. newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
  20788. }
  20789. // If the new origin is within the tail, then we do not need a root.
  20790. if (newOrigin >= newTailOffset) {
  20791. newOrigin -= newTailOffset;
  20792. newCapacity -= newTailOffset;
  20793. newLevel = SHIFT;
  20794. newRoot = null;
  20795. newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
  20796. // Otherwise, if the root has been trimmed, garbage collect.
  20797. } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
  20798. offsetShift = 0;
  20799. // Identify the new top root node of the subtree of the old root.
  20800. while (newRoot) {
  20801. var beginIndex = (newOrigin >>> newLevel) & MASK;
  20802. if ((beginIndex !== newTailOffset >>> newLevel) & MASK) {
  20803. break;
  20804. }
  20805. if (beginIndex) {
  20806. offsetShift += (1 << newLevel) * beginIndex;
  20807. }
  20808. newLevel -= SHIFT;
  20809. newRoot = newRoot.array[beginIndex];
  20810. }
  20811. // Trim the new sides of the new root.
  20812. if (newRoot && newOrigin > oldOrigin) {
  20813. newRoot = newRoot.removeBefore(
  20814. owner,
  20815. newLevel,
  20816. newOrigin - offsetShift
  20817. );
  20818. }
  20819. if (newRoot && newTailOffset < oldTailOffset) {
  20820. newRoot = newRoot.removeAfter(
  20821. owner,
  20822. newLevel,
  20823. newTailOffset - offsetShift
  20824. );
  20825. }
  20826. if (offsetShift) {
  20827. newOrigin -= offsetShift;
  20828. newCapacity -= offsetShift;
  20829. }
  20830. }
  20831. if (list.__ownerID) {
  20832. list.size = newCapacity - newOrigin;
  20833. list._origin = newOrigin;
  20834. list._capacity = newCapacity;
  20835. list._level = newLevel;
  20836. list._root = newRoot;
  20837. list._tail = newTail;
  20838. list.__hash = undefined;
  20839. list.__altered = true;
  20840. return list;
  20841. }
  20842. return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
  20843. }
  20844. function mergeIntoListWith(list, merger, iterables) {
  20845. var iters = [];
  20846. var maxSize = 0;
  20847. for (var ii = 0; ii < iterables.length; ii++) {
  20848. var value = iterables[ii];
  20849. var iter = IndexedIterable(value);
  20850. if (iter.size > maxSize) {
  20851. maxSize = iter.size;
  20852. }
  20853. if (!isIterable(value)) {
  20854. iter = iter.map(function(v) {
  20855. return fromJS(v);
  20856. });
  20857. }
  20858. iters.push(iter);
  20859. }
  20860. if (maxSize > list.size) {
  20861. list = list.setSize(maxSize);
  20862. }
  20863. return mergeIntoCollectionWith(list, merger, iters);
  20864. }
  20865. function getTailOffset(size) {
  20866. return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT;
  20867. }
  20868. createClass(OrderedMap, Map);
  20869. // @pragma Construction
  20870. function OrderedMap(value) {
  20871. return value === null || value === undefined
  20872. ? emptyOrderedMap()
  20873. : isOrderedMap(value)
  20874. ? value
  20875. : emptyOrderedMap().withMutations(function(map) {
  20876. var iter = KeyedIterable(value);
  20877. assertNotInfinite(iter.size);
  20878. iter.forEach(function(v, k) {
  20879. return map.set(k, v);
  20880. });
  20881. });
  20882. }
  20883. OrderedMap.of = function(/*...values*/) {
  20884. return this(arguments);
  20885. };
  20886. OrderedMap.prototype.toString = function() {
  20887. return this.__toString("OrderedMap {", "}");
  20888. };
  20889. // @pragma Access
  20890. OrderedMap.prototype.get = function(k, notSetValue) {
  20891. var index = this._map.get(k);
  20892. return index !== undefined ? this._list.get(index)[1] : notSetValue;
  20893. };
  20894. // @pragma Modification
  20895. OrderedMap.prototype.clear = function() {
  20896. if (this.size === 0) {
  20897. return this;
  20898. }
  20899. if (this.__ownerID) {
  20900. this.size = 0;
  20901. this._map.clear();
  20902. this._list.clear();
  20903. return this;
  20904. }
  20905. return emptyOrderedMap();
  20906. };
  20907. OrderedMap.prototype.set = function(k, v) {
  20908. return updateOrderedMap(this, k, v);
  20909. };
  20910. OrderedMap.prototype.remove = function(k) {
  20911. return updateOrderedMap(this, k, NOT_SET);
  20912. };
  20913. OrderedMap.prototype.wasAltered = function() {
  20914. return this._map.wasAltered() || this._list.wasAltered();
  20915. };
  20916. OrderedMap.prototype.__iterate = function(fn, reverse) {
  20917. var this$0 = this;
  20918. return this._list.__iterate(function(entry) {
  20919. return entry && fn(entry[1], entry[0], this$0);
  20920. }, reverse);
  20921. };
  20922. OrderedMap.prototype.__iterator = function(type, reverse) {
  20923. return this._list.fromEntrySeq().__iterator(type, reverse);
  20924. };
  20925. OrderedMap.prototype.__ensureOwner = function(ownerID) {
  20926. if (ownerID === this.__ownerID) {
  20927. return this;
  20928. }
  20929. var newMap = this._map.__ensureOwner(ownerID);
  20930. var newList = this._list.__ensureOwner(ownerID);
  20931. if (!ownerID) {
  20932. this.__ownerID = ownerID;
  20933. this._map = newMap;
  20934. this._list = newList;
  20935. return this;
  20936. }
  20937. return makeOrderedMap(newMap, newList, ownerID, this.__hash);
  20938. };
  20939. function isOrderedMap(maybeOrderedMap) {
  20940. return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
  20941. }
  20942. OrderedMap.isOrderedMap = isOrderedMap;
  20943. OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
  20944. OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
  20945. function makeOrderedMap(map, list, ownerID, hash) {
  20946. var omap = Object.create(OrderedMap.prototype);
  20947. omap.size = map ? map.size : 0;
  20948. omap._map = map;
  20949. omap._list = list;
  20950. omap.__ownerID = ownerID;
  20951. omap.__hash = hash;
  20952. return omap;
  20953. }
  20954. var EMPTY_ORDERED_MAP;
  20955. function emptyOrderedMap() {
  20956. return (
  20957. EMPTY_ORDERED_MAP ||
  20958. (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()))
  20959. );
  20960. }
  20961. function updateOrderedMap(omap, k, v) {
  20962. var map = omap._map;
  20963. var list = omap._list;
  20964. var i = map.get(k);
  20965. var has = i !== undefined;
  20966. var newMap;
  20967. var newList;
  20968. if (v === NOT_SET) {
  20969. // removed
  20970. if (!has) {
  20971. return omap;
  20972. }
  20973. if (list.size >= SIZE && list.size >= map.size * 2) {
  20974. newList = list.filter(function(entry, idx) {
  20975. return entry !== undefined && i !== idx;
  20976. });
  20977. newMap = newList
  20978. .toKeyedSeq()
  20979. .map(function(entry) {
  20980. return entry[0];
  20981. })
  20982. .flip()
  20983. .toMap();
  20984. if (omap.__ownerID) {
  20985. newMap.__ownerID = newList.__ownerID = omap.__ownerID;
  20986. }
  20987. } else {
  20988. newMap = map.remove(k);
  20989. newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
  20990. }
  20991. } else {
  20992. if (has) {
  20993. if (v === list.get(i)[1]) {
  20994. return omap;
  20995. }
  20996. newMap = map;
  20997. newList = list.set(i, [k, v]);
  20998. } else {
  20999. newMap = map.set(k, list.size);
  21000. newList = list.set(list.size, [k, v]);
  21001. }
  21002. }
  21003. if (omap.__ownerID) {
  21004. omap.size = newMap.size;
  21005. omap._map = newMap;
  21006. omap._list = newList;
  21007. omap.__hash = undefined;
  21008. return omap;
  21009. }
  21010. return makeOrderedMap(newMap, newList);
  21011. }
  21012. createClass(ToKeyedSequence, KeyedSeq);
  21013. function ToKeyedSequence(indexed, useKeys) {
  21014. this._iter = indexed;
  21015. this._useKeys = useKeys;
  21016. this.size = indexed.size;
  21017. }
  21018. ToKeyedSequence.prototype.get = function(key, notSetValue) {
  21019. return this._iter.get(key, notSetValue);
  21020. };
  21021. ToKeyedSequence.prototype.has = function(key) {
  21022. return this._iter.has(key);
  21023. };
  21024. ToKeyedSequence.prototype.valueSeq = function() {
  21025. return this._iter.valueSeq();
  21026. };
  21027. ToKeyedSequence.prototype.reverse = function() {
  21028. var this$0 = this;
  21029. var reversedSequence = reverseFactory(this, true);
  21030. if (!this._useKeys) {
  21031. reversedSequence.valueSeq = function() {
  21032. return this$0._iter.toSeq().reverse();
  21033. };
  21034. }
  21035. return reversedSequence;
  21036. };
  21037. ToKeyedSequence.prototype.map = function(mapper, context) {
  21038. var this$0 = this;
  21039. var mappedSequence = mapFactory(this, mapper, context);
  21040. if (!this._useKeys) {
  21041. mappedSequence.valueSeq = function() {
  21042. return this$0._iter.toSeq().map(mapper, context);
  21043. };
  21044. }
  21045. return mappedSequence;
  21046. };
  21047. ToKeyedSequence.prototype.__iterate = function(fn, reverse) {
  21048. var this$0 = this;
  21049. var ii;
  21050. return this._iter.__iterate(
  21051. this._useKeys
  21052. ? function(v, k) {
  21053. return fn(v, k, this$0);
  21054. }
  21055. : ((ii = reverse ? resolveSize(this) : 0),
  21056. function(v) {
  21057. return fn(v, reverse ? --ii : ii++, this$0);
  21058. }),
  21059. reverse
  21060. );
  21061. };
  21062. ToKeyedSequence.prototype.__iterator = function(type, reverse) {
  21063. if (this._useKeys) {
  21064. return this._iter.__iterator(type, reverse);
  21065. }
  21066. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  21067. var ii = reverse ? resolveSize(this) : 0;
  21068. return new Iterator(function() {
  21069. var step = iterator.next();
  21070. return step.done
  21071. ? step
  21072. : iteratorValue(type, reverse ? --ii : ii++, step.value, step);
  21073. });
  21074. };
  21075. ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
  21076. createClass(ToIndexedSequence, IndexedSeq);
  21077. function ToIndexedSequence(iter) {
  21078. this._iter = iter;
  21079. this.size = iter.size;
  21080. }
  21081. ToIndexedSequence.prototype.includes = function(value) {
  21082. return this._iter.includes(value);
  21083. };
  21084. ToIndexedSequence.prototype.__iterate = function(fn, reverse) {
  21085. var this$0 = this;
  21086. var iterations = 0;
  21087. return this._iter.__iterate(function(v) {
  21088. return fn(v, iterations++, this$0);
  21089. }, reverse);
  21090. };
  21091. ToIndexedSequence.prototype.__iterator = function(type, reverse) {
  21092. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  21093. var iterations = 0;
  21094. return new Iterator(function() {
  21095. var step = iterator.next();
  21096. return step.done
  21097. ? step
  21098. : iteratorValue(type, iterations++, step.value, step);
  21099. });
  21100. };
  21101. createClass(ToSetSequence, SetSeq);
  21102. function ToSetSequence(iter) {
  21103. this._iter = iter;
  21104. this.size = iter.size;
  21105. }
  21106. ToSetSequence.prototype.has = function(key) {
  21107. return this._iter.includes(key);
  21108. };
  21109. ToSetSequence.prototype.__iterate = function(fn, reverse) {
  21110. var this$0 = this;
  21111. return this._iter.__iterate(function(v) {
  21112. return fn(v, v, this$0);
  21113. }, reverse);
  21114. };
  21115. ToSetSequence.prototype.__iterator = function(type, reverse) {
  21116. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  21117. return new Iterator(function() {
  21118. var step = iterator.next();
  21119. return step.done
  21120. ? step
  21121. : iteratorValue(type, step.value, step.value, step);
  21122. });
  21123. };
  21124. createClass(FromEntriesSequence, KeyedSeq);
  21125. function FromEntriesSequence(entries) {
  21126. this._iter = entries;
  21127. this.size = entries.size;
  21128. }
  21129. FromEntriesSequence.prototype.entrySeq = function() {
  21130. return this._iter.toSeq();
  21131. };
  21132. FromEntriesSequence.prototype.__iterate = function(fn, reverse) {
  21133. var this$0 = this;
  21134. return this._iter.__iterate(function(entry) {
  21135. // Check if entry exists first so array access doesn't throw for holes
  21136. // in the parent iteration.
  21137. if (entry) {
  21138. validateEntry(entry);
  21139. var indexedIterable = isIterable(entry);
  21140. return fn(
  21141. indexedIterable ? entry.get(1) : entry[1],
  21142. indexedIterable ? entry.get(0) : entry[0],
  21143. this$0
  21144. );
  21145. }
  21146. }, reverse);
  21147. };
  21148. FromEntriesSequence.prototype.__iterator = function(type, reverse) {
  21149. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  21150. return new Iterator(function() {
  21151. while (true) {
  21152. var step = iterator.next();
  21153. if (step.done) {
  21154. return step;
  21155. }
  21156. var entry = step.value;
  21157. // Check if entry exists first so array access doesn't throw for holes
  21158. // in the parent iteration.
  21159. if (entry) {
  21160. validateEntry(entry);
  21161. var indexedIterable = isIterable(entry);
  21162. return iteratorValue(
  21163. type,
  21164. indexedIterable ? entry.get(0) : entry[0],
  21165. indexedIterable ? entry.get(1) : entry[1],
  21166. step
  21167. );
  21168. }
  21169. }
  21170. });
  21171. };
  21172. ToIndexedSequence.prototype.cacheResult = ToKeyedSequence.prototype.cacheResult = ToSetSequence.prototype.cacheResult = FromEntriesSequence.prototype.cacheResult = cacheResultThrough;
  21173. function flipFactory(iterable) {
  21174. var flipSequence = makeSequence(iterable);
  21175. flipSequence._iter = iterable;
  21176. flipSequence.size = iterable.size;
  21177. flipSequence.flip = function() {
  21178. return iterable;
  21179. };
  21180. flipSequence.reverse = function() {
  21181. var reversedSequence = iterable.reverse.apply(this); // super.reverse()
  21182. reversedSequence.flip = function() {
  21183. return iterable.reverse();
  21184. };
  21185. return reversedSequence;
  21186. };
  21187. flipSequence.has = function(key) {
  21188. return iterable.includes(key);
  21189. };
  21190. flipSequence.includes = function(key) {
  21191. return iterable.has(key);
  21192. };
  21193. flipSequence.cacheResult = cacheResultThrough;
  21194. flipSequence.__iterateUncached = function(fn, reverse) {
  21195. var this$0 = this;
  21196. return iterable.__iterate(function(v, k) {
  21197. return fn(k, v, this$0) !== false;
  21198. }, reverse);
  21199. };
  21200. flipSequence.__iteratorUncached = function(type, reverse) {
  21201. if (type === ITERATE_ENTRIES) {
  21202. var iterator = iterable.__iterator(type, reverse);
  21203. return new Iterator(function() {
  21204. var step = iterator.next();
  21205. if (!step.done) {
  21206. var k = step.value[0];
  21207. step.value[0] = step.value[1];
  21208. step.value[1] = k;
  21209. }
  21210. return step;
  21211. });
  21212. }
  21213. return iterable.__iterator(
  21214. type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
  21215. reverse
  21216. );
  21217. };
  21218. return flipSequence;
  21219. }
  21220. function mapFactory(iterable, mapper, context) {
  21221. var mappedSequence = makeSequence(iterable);
  21222. mappedSequence.size = iterable.size;
  21223. mappedSequence.has = function(key) {
  21224. return iterable.has(key);
  21225. };
  21226. mappedSequence.get = function(key, notSetValue) {
  21227. var v = iterable.get(key, NOT_SET);
  21228. return v === NOT_SET
  21229. ? notSetValue
  21230. : mapper.call(context, v, key, iterable);
  21231. };
  21232. mappedSequence.__iterateUncached = function(fn, reverse) {
  21233. var this$0 = this;
  21234. return iterable.__iterate(function(v, k, c) {
  21235. return fn(mapper.call(context, v, k, c), k, this$0) !== false;
  21236. }, reverse);
  21237. };
  21238. mappedSequence.__iteratorUncached = function(type, reverse) {
  21239. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  21240. return new Iterator(function() {
  21241. var step = iterator.next();
  21242. if (step.done) {
  21243. return step;
  21244. }
  21245. var entry = step.value;
  21246. var key = entry[0];
  21247. return iteratorValue(
  21248. type,
  21249. key,
  21250. mapper.call(context, entry[1], key, iterable),
  21251. step
  21252. );
  21253. });
  21254. };
  21255. return mappedSequence;
  21256. }
  21257. function reverseFactory(iterable, useKeys) {
  21258. var reversedSequence = makeSequence(iterable);
  21259. reversedSequence._iter = iterable;
  21260. reversedSequence.size = iterable.size;
  21261. reversedSequence.reverse = function() {
  21262. return iterable;
  21263. };
  21264. if (iterable.flip) {
  21265. reversedSequence.flip = function() {
  21266. var flipSequence = flipFactory(iterable);
  21267. flipSequence.reverse = function() {
  21268. return iterable.flip();
  21269. };
  21270. return flipSequence;
  21271. };
  21272. }
  21273. reversedSequence.get = function(key, notSetValue) {
  21274. return iterable.get(useKeys ? key : -1 - key, notSetValue);
  21275. };
  21276. reversedSequence.has = function(key) {
  21277. return iterable.has(useKeys ? key : -1 - key);
  21278. };
  21279. reversedSequence.includes = function(value) {
  21280. return iterable.includes(value);
  21281. };
  21282. reversedSequence.cacheResult = cacheResultThrough;
  21283. reversedSequence.__iterate = function(fn, reverse) {
  21284. var this$0 = this;
  21285. return iterable.__iterate(function(v, k) {
  21286. return fn(v, k, this$0);
  21287. }, !reverse);
  21288. };
  21289. reversedSequence.__iterator = function(type, reverse) {
  21290. return iterable.__iterator(type, !reverse);
  21291. };
  21292. return reversedSequence;
  21293. }
  21294. function filterFactory(iterable, predicate, context, useKeys) {
  21295. var filterSequence = makeSequence(iterable);
  21296. if (useKeys) {
  21297. filterSequence.has = function(key) {
  21298. var v = iterable.get(key, NOT_SET);
  21299. return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
  21300. };
  21301. filterSequence.get = function(key, notSetValue) {
  21302. var v = iterable.get(key, NOT_SET);
  21303. return v !== NOT_SET && predicate.call(context, v, key, iterable)
  21304. ? v
  21305. : notSetValue;
  21306. };
  21307. }
  21308. filterSequence.__iterateUncached = function(fn, reverse) {
  21309. var this$0 = this;
  21310. var iterations = 0;
  21311. iterable.__iterate(function(v, k, c) {
  21312. if (predicate.call(context, v, k, c)) {
  21313. iterations++;
  21314. return fn(v, useKeys ? k : iterations - 1, this$0);
  21315. }
  21316. }, reverse);
  21317. return iterations;
  21318. };
  21319. filterSequence.__iteratorUncached = function(type, reverse) {
  21320. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  21321. var iterations = 0;
  21322. return new Iterator(function() {
  21323. while (true) {
  21324. var step = iterator.next();
  21325. if (step.done) {
  21326. return step;
  21327. }
  21328. var entry = step.value;
  21329. var key = entry[0];
  21330. var value = entry[1];
  21331. if (predicate.call(context, value, key, iterable)) {
  21332. return iteratorValue(
  21333. type,
  21334. useKeys ? key : iterations++,
  21335. value,
  21336. step
  21337. );
  21338. }
  21339. }
  21340. });
  21341. };
  21342. return filterSequence;
  21343. }
  21344. function countByFactory(iterable, grouper, context) {
  21345. var groups = Map().asMutable();
  21346. iterable.__iterate(function(v, k) {
  21347. groups.update(grouper.call(context, v, k, iterable), 0, function(a) {
  21348. return a + 1;
  21349. });
  21350. });
  21351. return groups.asImmutable();
  21352. }
  21353. function groupByFactory(iterable, grouper, context) {
  21354. var isKeyedIter = isKeyed(iterable);
  21355. var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
  21356. iterable.__iterate(function(v, k) {
  21357. groups.update(grouper.call(context, v, k, iterable), function(a) {
  21358. return (a = a || []), a.push(isKeyedIter ? [k, v] : v), a;
  21359. });
  21360. });
  21361. var coerce = iterableClass(iterable);
  21362. return groups.map(function(arr) {
  21363. return reify(iterable, coerce(arr));
  21364. });
  21365. }
  21366. function sliceFactory(iterable, begin, end, useKeys) {
  21367. var originalSize = iterable.size;
  21368. // Sanitize begin & end using this shorthand for ToInt32(argument)
  21369. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  21370. if (begin !== undefined) {
  21371. begin = begin | 0;
  21372. }
  21373. if (end !== undefined) {
  21374. end = end | 0;
  21375. }
  21376. if (wholeSlice(begin, end, originalSize)) {
  21377. return iterable;
  21378. }
  21379. var resolvedBegin = resolveBegin(begin, originalSize);
  21380. var resolvedEnd = resolveEnd(end, originalSize);
  21381. // begin or end will be NaN if they were provided as negative numbers and
  21382. // this iterable's size is unknown. In that case, cache first so there is
  21383. // a known size and these do not resolve to NaN.
  21384. if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
  21385. return sliceFactory(
  21386. iterable.toSeq().cacheResult(),
  21387. begin,
  21388. end,
  21389. useKeys
  21390. );
  21391. }
  21392. // Note: resolvedEnd is undefined when the original sequence's length is
  21393. // unknown and this slice did not supply an end and should contain all
  21394. // elements after resolvedBegin.
  21395. // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
  21396. var resolvedSize = resolvedEnd - resolvedBegin;
  21397. var sliceSize;
  21398. if (resolvedSize === resolvedSize) {
  21399. sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
  21400. }
  21401. var sliceSeq = makeSequence(iterable);
  21402. // If iterable.size is undefined, the size of the realized sliceSeq is
  21403. // unknown at this point unless the number of items to slice is 0
  21404. sliceSeq.size =
  21405. sliceSize === 0 ? sliceSize : (iterable.size && sliceSize) || undefined;
  21406. if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
  21407. sliceSeq.get = function(index, notSetValue) {
  21408. index = wrapIndex(this, index);
  21409. return index >= 0 && index < sliceSize
  21410. ? iterable.get(index + resolvedBegin, notSetValue)
  21411. : notSetValue;
  21412. };
  21413. }
  21414. sliceSeq.__iterateUncached = function(fn, reverse) {
  21415. var this$0 = this;
  21416. if (sliceSize === 0) {
  21417. return 0;
  21418. }
  21419. if (reverse) {
  21420. return this.cacheResult().__iterate(fn, reverse);
  21421. }
  21422. var skipped = 0;
  21423. var isSkipping = true;
  21424. var iterations = 0;
  21425. iterable.__iterate(function(v, k) {
  21426. if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
  21427. iterations++;
  21428. return (
  21429. fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
  21430. iterations !== sliceSize
  21431. );
  21432. }
  21433. });
  21434. return iterations;
  21435. };
  21436. sliceSeq.__iteratorUncached = function(type, reverse) {
  21437. if (sliceSize !== 0 && reverse) {
  21438. return this.cacheResult().__iterator(type, reverse);
  21439. }
  21440. // Don't bother instantiating parent iterator if taking 0.
  21441. var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
  21442. var skipped = 0;
  21443. var iterations = 0;
  21444. return new Iterator(function() {
  21445. while (skipped++ < resolvedBegin) {
  21446. iterator.next();
  21447. }
  21448. if (++iterations > sliceSize) {
  21449. return iteratorDone();
  21450. }
  21451. var step = iterator.next();
  21452. if (useKeys || type === ITERATE_VALUES) {
  21453. return step;
  21454. } else if (type === ITERATE_KEYS) {
  21455. return iteratorValue(type, iterations - 1, undefined, step);
  21456. } else {
  21457. return iteratorValue(type, iterations - 1, step.value[1], step);
  21458. }
  21459. });
  21460. };
  21461. return sliceSeq;
  21462. }
  21463. function takeWhileFactory(iterable, predicate, context) {
  21464. var takeSequence = makeSequence(iterable);
  21465. takeSequence.__iterateUncached = function(fn, reverse) {
  21466. var this$0 = this;
  21467. if (reverse) {
  21468. return this.cacheResult().__iterate(fn, reverse);
  21469. }
  21470. var iterations = 0;
  21471. iterable.__iterate(function(v, k, c) {
  21472. return (
  21473. predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)
  21474. );
  21475. });
  21476. return iterations;
  21477. };
  21478. takeSequence.__iteratorUncached = function(type, reverse) {
  21479. var this$0 = this;
  21480. if (reverse) {
  21481. return this.cacheResult().__iterator(type, reverse);
  21482. }
  21483. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  21484. var iterating = true;
  21485. return new Iterator(function() {
  21486. if (!iterating) {
  21487. return iteratorDone();
  21488. }
  21489. var step = iterator.next();
  21490. if (step.done) {
  21491. return step;
  21492. }
  21493. var entry = step.value;
  21494. var k = entry[0];
  21495. var v = entry[1];
  21496. if (!predicate.call(context, v, k, this$0)) {
  21497. iterating = false;
  21498. return iteratorDone();
  21499. }
  21500. return type === ITERATE_ENTRIES
  21501. ? step
  21502. : iteratorValue(type, k, v, step);
  21503. });
  21504. };
  21505. return takeSequence;
  21506. }
  21507. function skipWhileFactory(iterable, predicate, context, useKeys) {
  21508. var skipSequence = makeSequence(iterable);
  21509. skipSequence.__iterateUncached = function(fn, reverse) {
  21510. var this$0 = this;
  21511. if (reverse) {
  21512. return this.cacheResult().__iterate(fn, reverse);
  21513. }
  21514. var isSkipping = true;
  21515. var iterations = 0;
  21516. iterable.__iterate(function(v, k, c) {
  21517. if (
  21518. !(isSkipping && (isSkipping = predicate.call(context, v, k, c)))
  21519. ) {
  21520. iterations++;
  21521. return fn(v, useKeys ? k : iterations - 1, this$0);
  21522. }
  21523. });
  21524. return iterations;
  21525. };
  21526. skipSequence.__iteratorUncached = function(type, reverse) {
  21527. var this$0 = this;
  21528. if (reverse) {
  21529. return this.cacheResult().__iterator(type, reverse);
  21530. }
  21531. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  21532. var skipping = true;
  21533. var iterations = 0;
  21534. return new Iterator(function() {
  21535. var step, k, v;
  21536. do {
  21537. step = iterator.next();
  21538. if (step.done) {
  21539. if (useKeys || type === ITERATE_VALUES) {
  21540. return step;
  21541. } else if (type === ITERATE_KEYS) {
  21542. return iteratorValue(type, iterations++, undefined, step);
  21543. } else {
  21544. return iteratorValue(type, iterations++, step.value[1], step);
  21545. }
  21546. }
  21547. var entry = step.value;
  21548. k = entry[0];
  21549. v = entry[1];
  21550. skipping && (skipping = predicate.call(context, v, k, this$0));
  21551. } while (skipping);
  21552. return type === ITERATE_ENTRIES
  21553. ? step
  21554. : iteratorValue(type, k, v, step);
  21555. });
  21556. };
  21557. return skipSequence;
  21558. }
  21559. function concatFactory(iterable, values) {
  21560. var isKeyedIterable = isKeyed(iterable);
  21561. var iters = [iterable]
  21562. .concat(values)
  21563. .map(function(v) {
  21564. if (!isIterable(v)) {
  21565. v = isKeyedIterable
  21566. ? keyedSeqFromValue(v)
  21567. : indexedSeqFromValue(Array.isArray(v) ? v : [v]);
  21568. } else if (isKeyedIterable) {
  21569. v = KeyedIterable(v);
  21570. }
  21571. return v;
  21572. })
  21573. .filter(function(v) {
  21574. return v.size !== 0;
  21575. });
  21576. if (iters.length === 0) {
  21577. return iterable;
  21578. }
  21579. if (iters.length === 1) {
  21580. var singleton = iters[0];
  21581. if (
  21582. singleton === iterable ||
  21583. (isKeyedIterable && isKeyed(singleton)) ||
  21584. (isIndexed(iterable) && isIndexed(singleton))
  21585. ) {
  21586. return singleton;
  21587. }
  21588. }
  21589. var concatSeq = new ArraySeq(iters);
  21590. if (isKeyedIterable) {
  21591. concatSeq = concatSeq.toKeyedSeq();
  21592. } else if (!isIndexed(iterable)) {
  21593. concatSeq = concatSeq.toSetSeq();
  21594. }
  21595. concatSeq = concatSeq.flatten(true);
  21596. concatSeq.size = iters.reduce(function(sum, seq) {
  21597. if (sum !== undefined) {
  21598. var size = seq.size;
  21599. if (size !== undefined) {
  21600. return sum + size;
  21601. }
  21602. }
  21603. }, 0);
  21604. return concatSeq;
  21605. }
  21606. function flattenFactory(iterable, depth, useKeys) {
  21607. var flatSequence = makeSequence(iterable);
  21608. flatSequence.__iterateUncached = function(fn, reverse) {
  21609. var iterations = 0;
  21610. var stopped = false;
  21611. function flatDeep(iter, currentDepth) {
  21612. var this$0 = this;
  21613. iter.__iterate(function(v, k) {
  21614. if ((!depth || currentDepth < depth) && isIterable(v)) {
  21615. flatDeep(v, currentDepth + 1);
  21616. } else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
  21617. stopped = true;
  21618. }
  21619. return !stopped;
  21620. }, reverse);
  21621. }
  21622. flatDeep(iterable, 0);
  21623. return iterations;
  21624. };
  21625. flatSequence.__iteratorUncached = function(type, reverse) {
  21626. var iterator = iterable.__iterator(type, reverse);
  21627. var stack = [];
  21628. var iterations = 0;
  21629. return new Iterator(function() {
  21630. while (iterator) {
  21631. var step = iterator.next();
  21632. if (step.done !== false) {
  21633. iterator = stack.pop();
  21634. continue;
  21635. }
  21636. var v = step.value;
  21637. if (type === ITERATE_ENTRIES) {
  21638. v = v[1];
  21639. }
  21640. if ((!depth || stack.length < depth) && isIterable(v)) {
  21641. stack.push(iterator);
  21642. iterator = v.__iterator(type, reverse);
  21643. } else {
  21644. return useKeys
  21645. ? step
  21646. : iteratorValue(type, iterations++, v, step);
  21647. }
  21648. }
  21649. return iteratorDone();
  21650. });
  21651. };
  21652. return flatSequence;
  21653. }
  21654. function flatMapFactory(iterable, mapper, context) {
  21655. var coerce = iterableClass(iterable);
  21656. return iterable
  21657. .toSeq()
  21658. .map(function(v, k) {
  21659. return coerce(mapper.call(context, v, k, iterable));
  21660. })
  21661. .flatten(true);
  21662. }
  21663. function interposeFactory(iterable, separator) {
  21664. var interposedSequence = makeSequence(iterable);
  21665. interposedSequence.size = iterable.size && iterable.size * 2 - 1;
  21666. interposedSequence.__iterateUncached = function(fn, reverse) {
  21667. var this$0 = this;
  21668. var iterations = 0;
  21669. iterable.__iterate(function(v, k) {
  21670. return (
  21671. (!iterations || fn(separator, iterations++, this$0) !== false) &&
  21672. fn(v, iterations++, this$0) !== false
  21673. );
  21674. }, reverse);
  21675. return iterations;
  21676. };
  21677. interposedSequence.__iteratorUncached = function(type, reverse) {
  21678. var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
  21679. var iterations = 0;
  21680. var step;
  21681. return new Iterator(function() {
  21682. if (!step || iterations % 2) {
  21683. step = iterator.next();
  21684. if (step.done) {
  21685. return step;
  21686. }
  21687. }
  21688. return iterations % 2
  21689. ? iteratorValue(type, iterations++, separator)
  21690. : iteratorValue(type, iterations++, step.value, step);
  21691. });
  21692. };
  21693. return interposedSequence;
  21694. }
  21695. function sortFactory(iterable, comparator, mapper) {
  21696. if (!comparator) {
  21697. comparator = defaultComparator;
  21698. }
  21699. var isKeyedIterable = isKeyed(iterable);
  21700. var index = 0;
  21701. var entries = iterable
  21702. .toSeq()
  21703. .map(function(v, k) {
  21704. return [k, v, index++, mapper ? mapper(v, k, iterable) : v];
  21705. })
  21706. .toArray();
  21707. entries
  21708. .sort(function(a, b) {
  21709. return comparator(a[3], b[3]) || a[2] - b[2];
  21710. })
  21711. .forEach(
  21712. isKeyedIterable
  21713. ? function(v, i) {
  21714. entries[i].length = 2;
  21715. }
  21716. : function(v, i) {
  21717. entries[i] = v[1];
  21718. }
  21719. );
  21720. return isKeyedIterable
  21721. ? KeyedSeq(entries)
  21722. : isIndexed(iterable)
  21723. ? IndexedSeq(entries)
  21724. : SetSeq(entries);
  21725. }
  21726. function maxFactory(iterable, comparator, mapper) {
  21727. if (!comparator) {
  21728. comparator = defaultComparator;
  21729. }
  21730. if (mapper) {
  21731. var entry = iterable
  21732. .toSeq()
  21733. .map(function(v, k) {
  21734. return [v, mapper(v, k, iterable)];
  21735. })
  21736. .reduce(function(a, b) {
  21737. return maxCompare(comparator, a[1], b[1]) ? b : a;
  21738. });
  21739. return entry && entry[0];
  21740. } else {
  21741. return iterable.reduce(function(a, b) {
  21742. return maxCompare(comparator, a, b) ? b : a;
  21743. });
  21744. }
  21745. }
  21746. function maxCompare(comparator, a, b) {
  21747. var comp = comparator(b, a);
  21748. // b is considered the new max if the comparator declares them equal, but
  21749. // they are not equal and b is in fact a nullish value.
  21750. return (
  21751. (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) ||
  21752. comp > 0
  21753. );
  21754. }
  21755. function zipWithFactory(keyIter, zipper, iters) {
  21756. var zipSequence = makeSequence(keyIter);
  21757. zipSequence.size = new ArraySeq(iters)
  21758. .map(function(i) {
  21759. return i.size;
  21760. })
  21761. .min();
  21762. // Note: this a generic base implementation of __iterate in terms of
  21763. // __iterator which may be more generically useful in the future.
  21764. zipSequence.__iterate = function(fn, reverse) {
  21765. /* generic:
  21766. var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
  21767. var step;
  21768. var iterations = 0;
  21769. while (!(step = iterator.next()).done) {
  21770. iterations++;
  21771. if (fn(step.value[1], step.value[0], this) === false) {
  21772. break;
  21773. }
  21774. }
  21775. return iterations;
  21776. */
  21777. // indexed:
  21778. var iterator = this.__iterator(ITERATE_VALUES, reverse);
  21779. var step;
  21780. var iterations = 0;
  21781. while (!(step = iterator.next()).done) {
  21782. if (fn(step.value, iterations++, this) === false) {
  21783. break;
  21784. }
  21785. }
  21786. return iterations;
  21787. };
  21788. zipSequence.__iteratorUncached = function(type, reverse) {
  21789. var iterators = iters.map(function(i) {
  21790. return (i = Iterable(i)), getIterator(reverse ? i.reverse() : i);
  21791. });
  21792. var iterations = 0;
  21793. var isDone = false;
  21794. return new Iterator(function() {
  21795. var steps;
  21796. if (!isDone) {
  21797. steps = iterators.map(function(i) {
  21798. return i.next();
  21799. });
  21800. isDone = steps.some(function(s) {
  21801. return s.done;
  21802. });
  21803. }
  21804. if (isDone) {
  21805. return iteratorDone();
  21806. }
  21807. return iteratorValue(
  21808. type,
  21809. iterations++,
  21810. zipper.apply(
  21811. null,
  21812. steps.map(function(s) {
  21813. return s.value;
  21814. })
  21815. )
  21816. );
  21817. });
  21818. };
  21819. return zipSequence;
  21820. }
  21821. // #pragma Helper Functions
  21822. function reify(iter, seq) {
  21823. return isSeq(iter) ? seq : iter.constructor(seq);
  21824. }
  21825. function validateEntry(entry) {
  21826. if (entry !== Object(entry)) {
  21827. throw new TypeError("Expected [K, V] tuple: " + entry);
  21828. }
  21829. }
  21830. function resolveSize(iter) {
  21831. assertNotInfinite(iter.size);
  21832. return ensureSize(iter);
  21833. }
  21834. function iterableClass(iterable) {
  21835. return isKeyed(iterable)
  21836. ? KeyedIterable
  21837. : isIndexed(iterable)
  21838. ? IndexedIterable
  21839. : SetIterable;
  21840. }
  21841. function makeSequence(iterable) {
  21842. return Object.create(
  21843. (isKeyed(iterable)
  21844. ? KeyedSeq
  21845. : isIndexed(iterable)
  21846. ? IndexedSeq
  21847. : SetSeq
  21848. ).prototype
  21849. );
  21850. }
  21851. function cacheResultThrough() {
  21852. if (this._iter.cacheResult) {
  21853. this._iter.cacheResult();
  21854. this.size = this._iter.size;
  21855. return this;
  21856. } else {
  21857. return Seq.prototype.cacheResult.call(this);
  21858. }
  21859. }
  21860. function defaultComparator(a, b) {
  21861. return a > b ? 1 : a < b ? -1 : 0;
  21862. }
  21863. function forceIterator(keyPath) {
  21864. var iter = getIterator(keyPath);
  21865. if (!iter) {
  21866. // Array might not be iterable in this environment, so we need a fallback
  21867. // to our wrapped type.
  21868. if (!isArrayLike(keyPath)) {
  21869. throw new TypeError("Expected iterable or array-like: " + keyPath);
  21870. }
  21871. iter = getIterator(Iterable(keyPath));
  21872. }
  21873. return iter;
  21874. }
  21875. createClass(Record, KeyedCollection);
  21876. function Record(defaultValues, name) {
  21877. var hasInitialized;
  21878. var RecordType = function Record(values) {
  21879. if (values instanceof RecordType) {
  21880. return values;
  21881. }
  21882. if (!(this instanceof RecordType)) {
  21883. return new RecordType(values);
  21884. }
  21885. if (!hasInitialized) {
  21886. hasInitialized = true;
  21887. var keys = Object.keys(defaultValues);
  21888. setProps(RecordTypePrototype, keys);
  21889. RecordTypePrototype.size = keys.length;
  21890. RecordTypePrototype._name = name;
  21891. RecordTypePrototype._keys = keys;
  21892. RecordTypePrototype._defaultValues = defaultValues;
  21893. }
  21894. this._map = Map(values);
  21895. };
  21896. var RecordTypePrototype = (RecordType.prototype = Object.create(
  21897. RecordPrototype
  21898. ));
  21899. RecordTypePrototype.constructor = RecordType;
  21900. return RecordType;
  21901. }
  21902. Record.prototype.toString = function() {
  21903. return this.__toString(recordName(this) + " {", "}");
  21904. };
  21905. // @pragma Access
  21906. Record.prototype.has = function(k) {
  21907. return this._defaultValues.hasOwnProperty(k);
  21908. };
  21909. Record.prototype.get = function(k, notSetValue) {
  21910. if (!this.has(k)) {
  21911. return notSetValue;
  21912. }
  21913. var defaultVal = this._defaultValues[k];
  21914. return this._map ? this._map.get(k, defaultVal) : defaultVal;
  21915. };
  21916. // @pragma Modification
  21917. Record.prototype.clear = function() {
  21918. if (this.__ownerID) {
  21919. this._map && this._map.clear();
  21920. return this;
  21921. }
  21922. var RecordType = this.constructor;
  21923. return (
  21924. RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()))
  21925. );
  21926. };
  21927. Record.prototype.set = function(k, v) {
  21928. if (!this.has(k)) {
  21929. throw new Error(
  21930. 'Cannot set unknown key "' + k + '" on ' + recordName(this)
  21931. );
  21932. }
  21933. var newMap = this._map && this._map.set(k, v);
  21934. if (this.__ownerID || newMap === this._map) {
  21935. return this;
  21936. }
  21937. return makeRecord(this, newMap);
  21938. };
  21939. Record.prototype.remove = function(k) {
  21940. if (!this.has(k)) {
  21941. return this;
  21942. }
  21943. var newMap = this._map && this._map.remove(k);
  21944. if (this.__ownerID || newMap === this._map) {
  21945. return this;
  21946. }
  21947. return makeRecord(this, newMap);
  21948. };
  21949. Record.prototype.wasAltered = function() {
  21950. return this._map.wasAltered();
  21951. };
  21952. Record.prototype.__iterator = function(type, reverse) {
  21953. var this$0 = this;
  21954. return KeyedIterable(this._defaultValues)
  21955. .map(function(_, k) {
  21956. return this$0.get(k);
  21957. })
  21958. .__iterator(type, reverse);
  21959. };
  21960. Record.prototype.__iterate = function(fn, reverse) {
  21961. var this$0 = this;
  21962. return KeyedIterable(this._defaultValues)
  21963. .map(function(_, k) {
  21964. return this$0.get(k);
  21965. })
  21966. .__iterate(fn, reverse);
  21967. };
  21968. Record.prototype.__ensureOwner = function(ownerID) {
  21969. if (ownerID === this.__ownerID) {
  21970. return this;
  21971. }
  21972. var newMap = this._map && this._map.__ensureOwner(ownerID);
  21973. if (!ownerID) {
  21974. this.__ownerID = ownerID;
  21975. this._map = newMap;
  21976. return this;
  21977. }
  21978. return makeRecord(this, newMap, ownerID);
  21979. };
  21980. var RecordPrototype = Record.prototype;
  21981. RecordPrototype[DELETE] = RecordPrototype.remove;
  21982. RecordPrototype.deleteIn = RecordPrototype.removeIn = MapPrototype.removeIn;
  21983. RecordPrototype.merge = MapPrototype.merge;
  21984. RecordPrototype.mergeWith = MapPrototype.mergeWith;
  21985. RecordPrototype.mergeIn = MapPrototype.mergeIn;
  21986. RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
  21987. RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
  21988. RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  21989. RecordPrototype.setIn = MapPrototype.setIn;
  21990. RecordPrototype.update = MapPrototype.update;
  21991. RecordPrototype.updateIn = MapPrototype.updateIn;
  21992. RecordPrototype.withMutations = MapPrototype.withMutations;
  21993. RecordPrototype.asMutable = MapPrototype.asMutable;
  21994. RecordPrototype.asImmutable = MapPrototype.asImmutable;
  21995. function makeRecord(likeRecord, map, ownerID) {
  21996. var record = Object.create(Object.getPrototypeOf(likeRecord));
  21997. record._map = map;
  21998. record.__ownerID = ownerID;
  21999. return record;
  22000. }
  22001. function recordName(record) {
  22002. return record._name || record.constructor.name || "Record";
  22003. }
  22004. function setProps(prototype, names) {
  22005. try {
  22006. names.forEach(setProp.bind(undefined, prototype));
  22007. } catch (error) {
  22008. // Object.defineProperty failed. Probably IE8.
  22009. }
  22010. }
  22011. function setProp(prototype, name) {
  22012. Object.defineProperty(prototype, name, {
  22013. get: function() {
  22014. return this.get(name);
  22015. },
  22016. set: function(value) {
  22017. invariant(this.__ownerID, "Cannot set on an immutable record.");
  22018. this.set(name, value);
  22019. }
  22020. });
  22021. }
  22022. createClass(Set, SetCollection);
  22023. // @pragma Construction
  22024. function Set(value) {
  22025. return value === null || value === undefined
  22026. ? emptySet()
  22027. : isSet(value) && !isOrdered(value)
  22028. ? value
  22029. : emptySet().withMutations(function(set) {
  22030. var iter = SetIterable(value);
  22031. assertNotInfinite(iter.size);
  22032. iter.forEach(function(v) {
  22033. return set.add(v);
  22034. });
  22035. });
  22036. }
  22037. Set.of = function(/*...values*/) {
  22038. return this(arguments);
  22039. };
  22040. Set.fromKeys = function(value) {
  22041. return this(KeyedIterable(value).keySeq());
  22042. };
  22043. Set.prototype.toString = function() {
  22044. return this.__toString("Set {", "}");
  22045. };
  22046. // @pragma Access
  22047. Set.prototype.has = function(value) {
  22048. return this._map.has(value);
  22049. };
  22050. // @pragma Modification
  22051. Set.prototype.add = function(value) {
  22052. return updateSet(this, this._map.set(value, true));
  22053. };
  22054. Set.prototype.remove = function(value) {
  22055. return updateSet(this, this._map.remove(value));
  22056. };
  22057. Set.prototype.clear = function() {
  22058. return updateSet(this, this._map.clear());
  22059. };
  22060. // @pragma Composition
  22061. Set.prototype.union = function() {
  22062. var iters = SLICE$0.call(arguments, 0);
  22063. iters = iters.filter(function(x) {
  22064. return x.size !== 0;
  22065. });
  22066. if (iters.length === 0) {
  22067. return this;
  22068. }
  22069. if (this.size === 0 && !this.__ownerID && iters.length === 1) {
  22070. return this.constructor(iters[0]);
  22071. }
  22072. return this.withMutations(function(set) {
  22073. for (var ii = 0; ii < iters.length; ii++) {
  22074. SetIterable(iters[ii]).forEach(function(value) {
  22075. return set.add(value);
  22076. });
  22077. }
  22078. });
  22079. };
  22080. Set.prototype.intersect = function() {
  22081. var iters = SLICE$0.call(arguments, 0);
  22082. if (iters.length === 0) {
  22083. return this;
  22084. }
  22085. iters = iters.map(function(iter) {
  22086. return SetIterable(iter);
  22087. });
  22088. var originalSet = this;
  22089. return this.withMutations(function(set) {
  22090. originalSet.forEach(function(value) {
  22091. if (
  22092. !iters.every(function(iter) {
  22093. return iter.includes(value);
  22094. })
  22095. ) {
  22096. set.remove(value);
  22097. }
  22098. });
  22099. });
  22100. };
  22101. Set.prototype.subtract = function() {
  22102. var iters = SLICE$0.call(arguments, 0);
  22103. if (iters.length === 0) {
  22104. return this;
  22105. }
  22106. iters = iters.map(function(iter) {
  22107. return SetIterable(iter);
  22108. });
  22109. var originalSet = this;
  22110. return this.withMutations(function(set) {
  22111. originalSet.forEach(function(value) {
  22112. if (
  22113. iters.some(function(iter) {
  22114. return iter.includes(value);
  22115. })
  22116. ) {
  22117. set.remove(value);
  22118. }
  22119. });
  22120. });
  22121. };
  22122. Set.prototype.merge = function() {
  22123. return this.union.apply(this, arguments);
  22124. };
  22125. Set.prototype.mergeWith = function(merger) {
  22126. var iters = SLICE$0.call(arguments, 1);
  22127. return this.union.apply(this, iters);
  22128. };
  22129. Set.prototype.sort = function(comparator) {
  22130. // Late binding
  22131. return OrderedSet(sortFactory(this, comparator));
  22132. };
  22133. Set.prototype.sortBy = function(mapper, comparator) {
  22134. // Late binding
  22135. return OrderedSet(sortFactory(this, comparator, mapper));
  22136. };
  22137. Set.prototype.wasAltered = function() {
  22138. return this._map.wasAltered();
  22139. };
  22140. Set.prototype.__iterate = function(fn, reverse) {
  22141. var this$0 = this;
  22142. return this._map.__iterate(function(_, k) {
  22143. return fn(k, k, this$0);
  22144. }, reverse);
  22145. };
  22146. Set.prototype.__iterator = function(type, reverse) {
  22147. return this._map
  22148. .map(function(_, k) {
  22149. return k;
  22150. })
  22151. .__iterator(type, reverse);
  22152. };
  22153. Set.prototype.__ensureOwner = function(ownerID) {
  22154. if (ownerID === this.__ownerID) {
  22155. return this;
  22156. }
  22157. var newMap = this._map.__ensureOwner(ownerID);
  22158. if (!ownerID) {
  22159. this.__ownerID = ownerID;
  22160. this._map = newMap;
  22161. return this;
  22162. }
  22163. return this.__make(newMap, ownerID);
  22164. };
  22165. function isSet(maybeSet) {
  22166. return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
  22167. }
  22168. Set.isSet = isSet;
  22169. var IS_SET_SENTINEL = "@@__IMMUTABLE_SET__@@";
  22170. var SetPrototype = Set.prototype;
  22171. SetPrototype[IS_SET_SENTINEL] = true;
  22172. SetPrototype[DELETE] = SetPrototype.remove;
  22173. SetPrototype.mergeDeep = SetPrototype.merge;
  22174. SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
  22175. SetPrototype.withMutations = MapPrototype.withMutations;
  22176. SetPrototype.asMutable = MapPrototype.asMutable;
  22177. SetPrototype.asImmutable = MapPrototype.asImmutable;
  22178. SetPrototype.__empty = emptySet;
  22179. SetPrototype.__make = makeSet;
  22180. function updateSet(set, newMap) {
  22181. if (set.__ownerID) {
  22182. set.size = newMap.size;
  22183. set._map = newMap;
  22184. return set;
  22185. }
  22186. return newMap === set._map
  22187. ? set
  22188. : newMap.size === 0
  22189. ? set.__empty()
  22190. : set.__make(newMap);
  22191. }
  22192. function makeSet(map, ownerID) {
  22193. var set = Object.create(SetPrototype);
  22194. set.size = map ? map.size : 0;
  22195. set._map = map;
  22196. set.__ownerID = ownerID;
  22197. return set;
  22198. }
  22199. var EMPTY_SET;
  22200. function emptySet() {
  22201. return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
  22202. }
  22203. createClass(OrderedSet, Set);
  22204. // @pragma Construction
  22205. function OrderedSet(value) {
  22206. return value === null || value === undefined
  22207. ? emptyOrderedSet()
  22208. : isOrderedSet(value)
  22209. ? value
  22210. : emptyOrderedSet().withMutations(function(set) {
  22211. var iter = SetIterable(value);
  22212. assertNotInfinite(iter.size);
  22213. iter.forEach(function(v) {
  22214. return set.add(v);
  22215. });
  22216. });
  22217. }
  22218. OrderedSet.of = function(/*...values*/) {
  22219. return this(arguments);
  22220. };
  22221. OrderedSet.fromKeys = function(value) {
  22222. return this(KeyedIterable(value).keySeq());
  22223. };
  22224. OrderedSet.prototype.toString = function() {
  22225. return this.__toString("OrderedSet {", "}");
  22226. };
  22227. function isOrderedSet(maybeOrderedSet) {
  22228. return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
  22229. }
  22230. OrderedSet.isOrderedSet = isOrderedSet;
  22231. var OrderedSetPrototype = OrderedSet.prototype;
  22232. OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
  22233. OrderedSetPrototype.__empty = emptyOrderedSet;
  22234. OrderedSetPrototype.__make = makeOrderedSet;
  22235. function makeOrderedSet(map, ownerID) {
  22236. var set = Object.create(OrderedSetPrototype);
  22237. set.size = map ? map.size : 0;
  22238. set._map = map;
  22239. set.__ownerID = ownerID;
  22240. return set;
  22241. }
  22242. var EMPTY_ORDERED_SET;
  22243. function emptyOrderedSet() {
  22244. return (
  22245. EMPTY_ORDERED_SET ||
  22246. (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()))
  22247. );
  22248. }
  22249. createClass(Stack, IndexedCollection);
  22250. // @pragma Construction
  22251. function Stack(value) {
  22252. return value === null || value === undefined
  22253. ? emptyStack()
  22254. : isStack(value)
  22255. ? value
  22256. : emptyStack().unshiftAll(value);
  22257. }
  22258. Stack.of = function(/*...values*/) {
  22259. return this(arguments);
  22260. };
  22261. Stack.prototype.toString = function() {
  22262. return this.__toString("Stack [", "]");
  22263. };
  22264. // @pragma Access
  22265. Stack.prototype.get = function(index, notSetValue) {
  22266. var head = this._head;
  22267. index = wrapIndex(this, index);
  22268. while (head && index--) {
  22269. head = head.next;
  22270. }
  22271. return head ? head.value : notSetValue;
  22272. };
  22273. Stack.prototype.peek = function() {
  22274. return this._head && this._head.value;
  22275. };
  22276. // @pragma Modification
  22277. Stack.prototype.push = function(/*...values*/) {
  22278. if (arguments.length === 0) {
  22279. return this;
  22280. }
  22281. var newSize = this.size + arguments.length;
  22282. var head = this._head;
  22283. for (var ii = arguments.length - 1; ii >= 0; ii--) {
  22284. head = {
  22285. value: arguments[ii],
  22286. next: head
  22287. };
  22288. }
  22289. if (this.__ownerID) {
  22290. this.size = newSize;
  22291. this._head = head;
  22292. this.__hash = undefined;
  22293. this.__altered = true;
  22294. return this;
  22295. }
  22296. return makeStack(newSize, head);
  22297. };
  22298. Stack.prototype.pushAll = function(iter) {
  22299. iter = IndexedIterable(iter);
  22300. if (iter.size === 0) {
  22301. return this;
  22302. }
  22303. assertNotInfinite(iter.size);
  22304. var newSize = this.size;
  22305. var head = this._head;
  22306. iter.reverse().forEach(function(value) {
  22307. newSize++;
  22308. head = {
  22309. value: value,
  22310. next: head
  22311. };
  22312. });
  22313. if (this.__ownerID) {
  22314. this.size = newSize;
  22315. this._head = head;
  22316. this.__hash = undefined;
  22317. this.__altered = true;
  22318. return this;
  22319. }
  22320. return makeStack(newSize, head);
  22321. };
  22322. Stack.prototype.pop = function() {
  22323. return this.slice(1);
  22324. };
  22325. Stack.prototype.unshift = function(/*...values*/) {
  22326. return this.push.apply(this, arguments);
  22327. };
  22328. Stack.prototype.unshiftAll = function(iter) {
  22329. return this.pushAll(iter);
  22330. };
  22331. Stack.prototype.shift = function() {
  22332. return this.pop.apply(this, arguments);
  22333. };
  22334. Stack.prototype.clear = function() {
  22335. if (this.size === 0) {
  22336. return this;
  22337. }
  22338. if (this.__ownerID) {
  22339. this.size = 0;
  22340. this._head = undefined;
  22341. this.__hash = undefined;
  22342. this.__altered = true;
  22343. return this;
  22344. }
  22345. return emptyStack();
  22346. };
  22347. Stack.prototype.slice = function(begin, end) {
  22348. if (wholeSlice(begin, end, this.size)) {
  22349. return this;
  22350. }
  22351. var resolvedBegin = resolveBegin(begin, this.size);
  22352. var resolvedEnd = resolveEnd(end, this.size);
  22353. if (resolvedEnd !== this.size) {
  22354. // super.slice(begin, end);
  22355. return IndexedCollection.prototype.slice.call(this, begin, end);
  22356. }
  22357. var newSize = this.size - resolvedBegin;
  22358. var head = this._head;
  22359. while (resolvedBegin--) {
  22360. head = head.next;
  22361. }
  22362. if (this.__ownerID) {
  22363. this.size = newSize;
  22364. this._head = head;
  22365. this.__hash = undefined;
  22366. this.__altered = true;
  22367. return this;
  22368. }
  22369. return makeStack(newSize, head);
  22370. };
  22371. // @pragma Mutability
  22372. Stack.prototype.__ensureOwner = function(ownerID) {
  22373. if (ownerID === this.__ownerID) {
  22374. return this;
  22375. }
  22376. if (!ownerID) {
  22377. this.__ownerID = ownerID;
  22378. this.__altered = false;
  22379. return this;
  22380. }
  22381. return makeStack(this.size, this._head, ownerID, this.__hash);
  22382. };
  22383. // @pragma Iteration
  22384. Stack.prototype.__iterate = function(fn, reverse) {
  22385. if (reverse) {
  22386. return this.reverse().__iterate(fn);
  22387. }
  22388. var iterations = 0;
  22389. var node = this._head;
  22390. while (node) {
  22391. if (fn(node.value, iterations++, this) === false) {
  22392. break;
  22393. }
  22394. node = node.next;
  22395. }
  22396. return iterations;
  22397. };
  22398. Stack.prototype.__iterator = function(type, reverse) {
  22399. if (reverse) {
  22400. return this.reverse().__iterator(type);
  22401. }
  22402. var iterations = 0;
  22403. var node = this._head;
  22404. return new Iterator(function() {
  22405. if (node) {
  22406. var value = node.value;
  22407. node = node.next;
  22408. return iteratorValue(type, iterations++, value);
  22409. }
  22410. return iteratorDone();
  22411. });
  22412. };
  22413. function isStack(maybeStack) {
  22414. return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
  22415. }
  22416. Stack.isStack = isStack;
  22417. var IS_STACK_SENTINEL = "@@__IMMUTABLE_STACK__@@";
  22418. var StackPrototype = Stack.prototype;
  22419. StackPrototype[IS_STACK_SENTINEL] = true;
  22420. StackPrototype.withMutations = MapPrototype.withMutations;
  22421. StackPrototype.asMutable = MapPrototype.asMutable;
  22422. StackPrototype.asImmutable = MapPrototype.asImmutable;
  22423. StackPrototype.wasAltered = MapPrototype.wasAltered;
  22424. function makeStack(size, head, ownerID, hash) {
  22425. var map = Object.create(StackPrototype);
  22426. map.size = size;
  22427. map._head = head;
  22428. map.__ownerID = ownerID;
  22429. map.__hash = hash;
  22430. map.__altered = false;
  22431. return map;
  22432. }
  22433. var EMPTY_STACK;
  22434. function emptyStack() {
  22435. return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
  22436. }
  22437. /**
  22438. * Contributes additional methods to a constructor
  22439. */
  22440. function mixin(ctor, methods) {
  22441. var keyCopier = function(key) {
  22442. ctor.prototype[key] = methods[key];
  22443. };
  22444. Object.keys(methods).forEach(keyCopier);
  22445. Object.getOwnPropertySymbols &&
  22446. Object.getOwnPropertySymbols(methods).forEach(keyCopier);
  22447. return ctor;
  22448. }
  22449. Iterable.Iterator = Iterator;
  22450. mixin(Iterable, {
  22451. // ### Conversion to other types
  22452. toArray: function() {
  22453. assertNotInfinite(this.size);
  22454. var array = new Array(this.size || 0);
  22455. this.valueSeq().__iterate(function(v, i) {
  22456. array[i] = v;
  22457. });
  22458. return array;
  22459. },
  22460. toIndexedSeq: function() {
  22461. return new ToIndexedSequence(this);
  22462. },
  22463. toJS: function() {
  22464. return this.toSeq()
  22465. .map(function(value) {
  22466. return value && typeof value.toJS === "function"
  22467. ? value.toJS()
  22468. : value;
  22469. })
  22470. .__toJS();
  22471. },
  22472. toJSON: function() {
  22473. return this.toSeq()
  22474. .map(function(value) {
  22475. return value && typeof value.toJSON === "function"
  22476. ? value.toJSON()
  22477. : value;
  22478. })
  22479. .__toJS();
  22480. },
  22481. toKeyedSeq: function() {
  22482. return new ToKeyedSequence(this, true);
  22483. },
  22484. toMap: function() {
  22485. // Use Late Binding here to solve the circular dependency.
  22486. return Map(this.toKeyedSeq());
  22487. },
  22488. toObject: function() {
  22489. assertNotInfinite(this.size);
  22490. var object = {};
  22491. this.__iterate(function(v, k) {
  22492. object[k] = v;
  22493. });
  22494. return object;
  22495. },
  22496. toOrderedMap: function() {
  22497. // Use Late Binding here to solve the circular dependency.
  22498. return OrderedMap(this.toKeyedSeq());
  22499. },
  22500. toOrderedSet: function() {
  22501. // Use Late Binding here to solve the circular dependency.
  22502. return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
  22503. },
  22504. toSet: function() {
  22505. // Use Late Binding here to solve the circular dependency.
  22506. return Set(isKeyed(this) ? this.valueSeq() : this);
  22507. },
  22508. toSetSeq: function() {
  22509. return new ToSetSequence(this);
  22510. },
  22511. toSeq: function() {
  22512. return isIndexed(this)
  22513. ? this.toIndexedSeq()
  22514. : isKeyed(this)
  22515. ? this.toKeyedSeq()
  22516. : this.toSetSeq();
  22517. },
  22518. toStack: function() {
  22519. // Use Late Binding here to solve the circular dependency.
  22520. return Stack(isKeyed(this) ? this.valueSeq() : this);
  22521. },
  22522. toList: function() {
  22523. // Use Late Binding here to solve the circular dependency.
  22524. return List(isKeyed(this) ? this.valueSeq() : this);
  22525. },
  22526. // ### Common JavaScript methods and properties
  22527. toString: function() {
  22528. return "[Iterable]";
  22529. },
  22530. __toString: function(head, tail) {
  22531. if (this.size === 0) {
  22532. return head + tail;
  22533. }
  22534. return (
  22535. head +
  22536. " " +
  22537. this.toSeq()
  22538. .map(this.__toStringMapper)
  22539. .join(", ") +
  22540. " " +
  22541. tail
  22542. );
  22543. },
  22544. // ### ES6 Collection methods (ES6 Array and Map)
  22545. concat: function() {
  22546. var values = SLICE$0.call(arguments, 0);
  22547. return reify(this, concatFactory(this, values));
  22548. },
  22549. includes: function(searchValue) {
  22550. return this.some(function(value) {
  22551. return is(value, searchValue);
  22552. });
  22553. },
  22554. entries: function() {
  22555. return this.__iterator(ITERATE_ENTRIES);
  22556. },
  22557. every: function(predicate, context) {
  22558. assertNotInfinite(this.size);
  22559. var returnValue = true;
  22560. this.__iterate(function(v, k, c) {
  22561. if (!predicate.call(context, v, k, c)) {
  22562. returnValue = false;
  22563. return false;
  22564. }
  22565. });
  22566. return returnValue;
  22567. },
  22568. filter: function(predicate, context) {
  22569. return reify(this, filterFactory(this, predicate, context, true));
  22570. },
  22571. find: function(predicate, context, notSetValue) {
  22572. var entry = this.findEntry(predicate, context);
  22573. return entry ? entry[1] : notSetValue;
  22574. },
  22575. findEntry: function(predicate, context) {
  22576. var found;
  22577. this.__iterate(function(v, k, c) {
  22578. if (predicate.call(context, v, k, c)) {
  22579. found = [k, v];
  22580. return false;
  22581. }
  22582. });
  22583. return found;
  22584. },
  22585. findLastEntry: function(predicate, context) {
  22586. return this.toSeq()
  22587. .reverse()
  22588. .findEntry(predicate, context);
  22589. },
  22590. forEach: function(sideEffect, context) {
  22591. assertNotInfinite(this.size);
  22592. return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
  22593. },
  22594. join: function(separator) {
  22595. assertNotInfinite(this.size);
  22596. separator = separator !== undefined ? "" + separator : ",";
  22597. var joined = "";
  22598. var isFirst = true;
  22599. this.__iterate(function(v) {
  22600. isFirst ? (isFirst = false) : (joined += separator);
  22601. joined += v !== null && v !== undefined ? v.toString() : "";
  22602. });
  22603. return joined;
  22604. },
  22605. keys: function() {
  22606. return this.__iterator(ITERATE_KEYS);
  22607. },
  22608. map: function(mapper, context) {
  22609. return reify(this, mapFactory(this, mapper, context));
  22610. },
  22611. reduce: function(reducer, initialReduction, context) {
  22612. assertNotInfinite(this.size);
  22613. var reduction;
  22614. var useFirst;
  22615. if (arguments.length < 2) {
  22616. useFirst = true;
  22617. } else {
  22618. reduction = initialReduction;
  22619. }
  22620. this.__iterate(function(v, k, c) {
  22621. if (useFirst) {
  22622. useFirst = false;
  22623. reduction = v;
  22624. } else {
  22625. reduction = reducer.call(context, reduction, v, k, c);
  22626. }
  22627. });
  22628. return reduction;
  22629. },
  22630. reduceRight: function(reducer, initialReduction, context) {
  22631. var reversed = this.toKeyedSeq().reverse();
  22632. return reversed.reduce.apply(reversed, arguments);
  22633. },
  22634. reverse: function() {
  22635. return reify(this, reverseFactory(this, true));
  22636. },
  22637. slice: function(begin, end) {
  22638. return reify(this, sliceFactory(this, begin, end, true));
  22639. },
  22640. some: function(predicate, context) {
  22641. return !this.every(not(predicate), context);
  22642. },
  22643. sort: function(comparator) {
  22644. return reify(this, sortFactory(this, comparator));
  22645. },
  22646. values: function() {
  22647. return this.__iterator(ITERATE_VALUES);
  22648. },
  22649. // ### More sequential methods
  22650. butLast: function() {
  22651. return this.slice(0, -1);
  22652. },
  22653. isEmpty: function() {
  22654. return this.size !== undefined
  22655. ? this.size === 0
  22656. : !this.some(function() {
  22657. return true;
  22658. });
  22659. },
  22660. count: function(predicate, context) {
  22661. return ensureSize(
  22662. predicate ? this.toSeq().filter(predicate, context) : this
  22663. );
  22664. },
  22665. countBy: function(grouper, context) {
  22666. return countByFactory(this, grouper, context);
  22667. },
  22668. equals: function(other) {
  22669. return deepEqual(this, other);
  22670. },
  22671. entrySeq: function() {
  22672. var iterable = this;
  22673. if (iterable._cache) {
  22674. // We cache as an entries array, so we can just return the cache!
  22675. return new ArraySeq(iterable._cache);
  22676. }
  22677. var entriesSequence = iterable
  22678. .toSeq()
  22679. .map(entryMapper)
  22680. .toIndexedSeq();
  22681. entriesSequence.fromEntrySeq = function() {
  22682. return iterable.toSeq();
  22683. };
  22684. return entriesSequence;
  22685. },
  22686. filterNot: function(predicate, context) {
  22687. return this.filter(not(predicate), context);
  22688. },
  22689. findLast: function(predicate, context, notSetValue) {
  22690. return this.toKeyedSeq()
  22691. .reverse()
  22692. .find(predicate, context, notSetValue);
  22693. },
  22694. first: function() {
  22695. return this.find(returnTrue);
  22696. },
  22697. flatMap: function(mapper, context) {
  22698. return reify(this, flatMapFactory(this, mapper, context));
  22699. },
  22700. flatten: function(depth) {
  22701. return reify(this, flattenFactory(this, depth, true));
  22702. },
  22703. fromEntrySeq: function() {
  22704. return new FromEntriesSequence(this);
  22705. },
  22706. get: function(searchKey, notSetValue) {
  22707. return this.find(
  22708. function(_, key) {
  22709. return is(key, searchKey);
  22710. },
  22711. undefined,
  22712. notSetValue
  22713. );
  22714. },
  22715. getIn: function(searchKeyPath, notSetValue) {
  22716. var nested = this;
  22717. // Note: in an ES6 environment, we would prefer:
  22718. // for (var key of searchKeyPath) {
  22719. var iter = forceIterator(searchKeyPath);
  22720. var step;
  22721. while (!(step = iter.next()).done) {
  22722. var key = step.value;
  22723. nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
  22724. if (nested === NOT_SET) {
  22725. return notSetValue;
  22726. }
  22727. }
  22728. return nested;
  22729. },
  22730. groupBy: function(grouper, context) {
  22731. return groupByFactory(this, grouper, context);
  22732. },
  22733. has: function(searchKey) {
  22734. return this.get(searchKey, NOT_SET) !== NOT_SET;
  22735. },
  22736. hasIn: function(searchKeyPath) {
  22737. return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
  22738. },
  22739. isSubset: function(iter) {
  22740. iter = typeof iter.includes === "function" ? iter : Iterable(iter);
  22741. return this.every(function(value) {
  22742. return iter.includes(value);
  22743. });
  22744. },
  22745. isSuperset: function(iter) {
  22746. iter = typeof iter.isSubset === "function" ? iter : Iterable(iter);
  22747. return iter.isSubset(this);
  22748. },
  22749. keySeq: function() {
  22750. return this.toSeq()
  22751. .map(keyMapper)
  22752. .toIndexedSeq();
  22753. },
  22754. last: function() {
  22755. return this.toSeq()
  22756. .reverse()
  22757. .first();
  22758. },
  22759. max: function(comparator) {
  22760. return maxFactory(this, comparator);
  22761. },
  22762. maxBy: function(mapper, comparator) {
  22763. return maxFactory(this, comparator, mapper);
  22764. },
  22765. min: function(comparator) {
  22766. return maxFactory(
  22767. this,
  22768. comparator ? neg(comparator) : defaultNegComparator
  22769. );
  22770. },
  22771. minBy: function(mapper, comparator) {
  22772. return maxFactory(
  22773. this,
  22774. comparator ? neg(comparator) : defaultNegComparator,
  22775. mapper
  22776. );
  22777. },
  22778. rest: function() {
  22779. return this.slice(1);
  22780. },
  22781. skip: function(amount) {
  22782. return this.slice(Math.max(0, amount));
  22783. },
  22784. skipLast: function(amount) {
  22785. return reify(
  22786. this,
  22787. this.toSeq()
  22788. .reverse()
  22789. .skip(amount)
  22790. .reverse()
  22791. );
  22792. },
  22793. skipWhile: function(predicate, context) {
  22794. return reify(this, skipWhileFactory(this, predicate, context, true));
  22795. },
  22796. skipUntil: function(predicate, context) {
  22797. return this.skipWhile(not(predicate), context);
  22798. },
  22799. sortBy: function(mapper, comparator) {
  22800. return reify(this, sortFactory(this, comparator, mapper));
  22801. },
  22802. take: function(amount) {
  22803. return this.slice(0, Math.max(0, amount));
  22804. },
  22805. takeLast: function(amount) {
  22806. return reify(
  22807. this,
  22808. this.toSeq()
  22809. .reverse()
  22810. .take(amount)
  22811. .reverse()
  22812. );
  22813. },
  22814. takeWhile: function(predicate, context) {
  22815. return reify(this, takeWhileFactory(this, predicate, context));
  22816. },
  22817. takeUntil: function(predicate, context) {
  22818. return this.takeWhile(not(predicate), context);
  22819. },
  22820. valueSeq: function() {
  22821. return this.toIndexedSeq();
  22822. },
  22823. // ### Hashable Object
  22824. hashCode: function() {
  22825. return this.__hash || (this.__hash = hashIterable(this));
  22826. }
  22827. // ### Internal
  22828. // abstract __iterate(fn, reverse)
  22829. // abstract __iterator(type, reverse)
  22830. });
  22831. // var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  22832. // var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  22833. // var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  22834. // var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  22835. var IterablePrototype = Iterable.prototype;
  22836. IterablePrototype[IS_ITERABLE_SENTINEL] = true;
  22837. IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
  22838. IterablePrototype.__toJS = IterablePrototype.toArray;
  22839. IterablePrototype.__toStringMapper = quoteString;
  22840. IterablePrototype.inspect = IterablePrototype.toSource = function() {
  22841. return this.toString();
  22842. };
  22843. IterablePrototype.chain = IterablePrototype.flatMap;
  22844. IterablePrototype.contains = IterablePrototype.includes;
  22845. // Temporary warning about using length
  22846. (function() {
  22847. try {
  22848. Object.defineProperty(IterablePrototype, "length", {
  22849. get: function() {
  22850. if (!Iterable.noLengthWarning) {
  22851. var stack;
  22852. try {
  22853. throw new Error();
  22854. } catch (error) {
  22855. stack = error.stack;
  22856. }
  22857. if (stack.indexOf("_wrapObject") === -1) {
  22858. console &&
  22859. console.warn &&
  22860. console.warn(
  22861. "iterable.length has been deprecated, " +
  22862. "use iterable.size or iterable.count(). " +
  22863. "This warning will become a silent error in a future version. " +
  22864. stack
  22865. );
  22866. return this.size;
  22867. }
  22868. }
  22869. }
  22870. });
  22871. } catch (e) {}
  22872. })();
  22873. mixin(KeyedIterable, {
  22874. // ### More sequential methods
  22875. flip: function() {
  22876. return reify(this, flipFactory(this));
  22877. },
  22878. findKey: function(predicate, context) {
  22879. var entry = this.findEntry(predicate, context);
  22880. return entry && entry[0];
  22881. },
  22882. findLastKey: function(predicate, context) {
  22883. return this.toSeq()
  22884. .reverse()
  22885. .findKey(predicate, context);
  22886. },
  22887. keyOf: function(searchValue) {
  22888. return this.findKey(function(value) {
  22889. return is(value, searchValue);
  22890. });
  22891. },
  22892. lastKeyOf: function(searchValue) {
  22893. return this.findLastKey(function(value) {
  22894. return is(value, searchValue);
  22895. });
  22896. },
  22897. mapEntries: function(mapper, context) {
  22898. var this$0 = this;
  22899. var iterations = 0;
  22900. return reify(
  22901. this,
  22902. this.toSeq()
  22903. .map(function(v, k) {
  22904. return mapper.call(context, [k, v], iterations++, this$0);
  22905. })
  22906. .fromEntrySeq()
  22907. );
  22908. },
  22909. mapKeys: function(mapper, context) {
  22910. var this$0 = this;
  22911. return reify(
  22912. this,
  22913. this.toSeq()
  22914. .flip()
  22915. .map(function(k, v) {
  22916. return mapper.call(context, k, v, this$0);
  22917. })
  22918. .flip()
  22919. );
  22920. }
  22921. });
  22922. var KeyedIterablePrototype = KeyedIterable.prototype;
  22923. KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
  22924. KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
  22925. KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
  22926. KeyedIterablePrototype.__toStringMapper = function(v, k) {
  22927. return JSON.stringify(k) + ": " + quoteString(v);
  22928. };
  22929. mixin(IndexedIterable, {
  22930. // ### Conversion to other types
  22931. toKeyedSeq: function() {
  22932. return new ToKeyedSequence(this, false);
  22933. },
  22934. // ### ES6 Collection methods (ES6 Array and Map)
  22935. filter: function(predicate, context) {
  22936. return reify(this, filterFactory(this, predicate, context, false));
  22937. },
  22938. findIndex: function(predicate, context) {
  22939. var entry = this.findEntry(predicate, context);
  22940. return entry ? entry[0] : -1;
  22941. },
  22942. indexOf: function(searchValue) {
  22943. var key = this.toKeyedSeq().keyOf(searchValue);
  22944. return key === undefined ? -1 : key;
  22945. },
  22946. lastIndexOf: function(searchValue) {
  22947. var key = this.toKeyedSeq()
  22948. .reverse()
  22949. .keyOf(searchValue);
  22950. return key === undefined ? -1 : key;
  22951. // var index =
  22952. // return this.toSeq().reverse().indexOf(searchValue);
  22953. },
  22954. reverse: function() {
  22955. return reify(this, reverseFactory(this, false));
  22956. },
  22957. slice: function(begin, end) {
  22958. return reify(this, sliceFactory(this, begin, end, false));
  22959. },
  22960. splice: function(index, removeNum /*, ...values*/) {
  22961. var numArgs = arguments.length;
  22962. removeNum = Math.max(removeNum | 0, 0);
  22963. if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
  22964. return this;
  22965. }
  22966. // If index is negative, it should resolve relative to the size of the
  22967. // collection. However size may be expensive to compute if not cached, so
  22968. // only call count() if the number is in fact negative.
  22969. index = resolveBegin(index, index < 0 ? this.count() : this.size);
  22970. var spliced = this.slice(0, index);
  22971. return reify(
  22972. this,
  22973. numArgs === 1
  22974. ? spliced
  22975. : spliced.concat(
  22976. arrCopy(arguments, 2),
  22977. this.slice(index + removeNum)
  22978. )
  22979. );
  22980. },
  22981. // ### More collection methods
  22982. findLastIndex: function(predicate, context) {
  22983. var key = this.toKeyedSeq().findLastKey(predicate, context);
  22984. return key === undefined ? -1 : key;
  22985. },
  22986. first: function() {
  22987. return this.get(0);
  22988. },
  22989. flatten: function(depth) {
  22990. return reify(this, flattenFactory(this, depth, false));
  22991. },
  22992. get: function(index, notSetValue) {
  22993. index = wrapIndex(this, index);
  22994. return index < 0 ||
  22995. this.size === Infinity ||
  22996. (this.size !== undefined && index > this.size)
  22997. ? notSetValue
  22998. : this.find(
  22999. function(_, key) {
  23000. return key === index;
  23001. },
  23002. undefined,
  23003. notSetValue
  23004. );
  23005. },
  23006. has: function(index) {
  23007. index = wrapIndex(this, index);
  23008. return (
  23009. index >= 0 &&
  23010. (this.size !== undefined
  23011. ? this.size === Infinity || index < this.size
  23012. : this.indexOf(index) !== -1)
  23013. );
  23014. },
  23015. interpose: function(separator) {
  23016. return reify(this, interposeFactory(this, separator));
  23017. },
  23018. interleave: function(/*...iterables*/) {
  23019. var iterables = [this].concat(arrCopy(arguments));
  23020. var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
  23021. var interleaved = zipped.flatten(true);
  23022. if (zipped.size) {
  23023. interleaved.size = zipped.size * iterables.length;
  23024. }
  23025. return reify(this, interleaved);
  23026. },
  23027. last: function() {
  23028. return this.get(-1);
  23029. },
  23030. skipWhile: function(predicate, context) {
  23031. return reify(this, skipWhileFactory(this, predicate, context, false));
  23032. },
  23033. zip: function(/*, ...iterables */) {
  23034. var iterables = [this].concat(arrCopy(arguments));
  23035. return reify(this, zipWithFactory(this, defaultZipper, iterables));
  23036. },
  23037. zipWith: function(zipper /*, ...iterables */) {
  23038. var iterables = arrCopy(arguments);
  23039. iterables[0] = this;
  23040. return reify(this, zipWithFactory(this, zipper, iterables));
  23041. }
  23042. });
  23043. IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
  23044. IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
  23045. mixin(SetIterable, {
  23046. // ### ES6 Collection methods (ES6 Array and Map)
  23047. get: function(value, notSetValue) {
  23048. return this.has(value) ? value : notSetValue;
  23049. },
  23050. includes: function(value) {
  23051. return this.has(value);
  23052. },
  23053. // ### More sequential methods
  23054. keySeq: function() {
  23055. return this.valueSeq();
  23056. }
  23057. });
  23058. SetIterable.prototype.has = IterablePrototype.includes;
  23059. // Mixin subclasses
  23060. mixin(KeyedSeq, KeyedIterable.prototype);
  23061. mixin(IndexedSeq, IndexedIterable.prototype);
  23062. mixin(SetSeq, SetIterable.prototype);
  23063. mixin(KeyedCollection, KeyedIterable.prototype);
  23064. mixin(IndexedCollection, IndexedIterable.prototype);
  23065. mixin(SetCollection, SetIterable.prototype);
  23066. // #pragma Helper functions
  23067. function keyMapper(v, k) {
  23068. return k;
  23069. }
  23070. function entryMapper(v, k) {
  23071. return [k, v];
  23072. }
  23073. function not(predicate) {
  23074. return function() {
  23075. return !predicate.apply(this, arguments);
  23076. };
  23077. }
  23078. function neg(predicate) {
  23079. return function() {
  23080. return -predicate.apply(this, arguments);
  23081. };
  23082. }
  23083. function quoteString(value) {
  23084. return typeof value === "string" ? JSON.stringify(value) : value;
  23085. }
  23086. function defaultZipper() {
  23087. return arrCopy(arguments);
  23088. }
  23089. function defaultNegComparator(a, b) {
  23090. return a < b ? 1 : a > b ? -1 : 0;
  23091. }
  23092. function hashIterable(iterable) {
  23093. if (iterable.size === Infinity) {
  23094. return 0;
  23095. }
  23096. var ordered = isOrdered(iterable);
  23097. var keyed = isKeyed(iterable);
  23098. var h = ordered ? 1 : 0;
  23099. var size = iterable.__iterate(
  23100. keyed
  23101. ? ordered
  23102. ? function(v, k) {
  23103. h = (31 * h + hashMerge(hash(v), hash(k))) | 0;
  23104. }
  23105. : function(v, k) {
  23106. h = (h + hashMerge(hash(v), hash(k))) | 0;
  23107. }
  23108. : ordered
  23109. ? function(v) {
  23110. h = (31 * h + hash(v)) | 0;
  23111. }
  23112. : function(v) {
  23113. h = (h + hash(v)) | 0;
  23114. }
  23115. );
  23116. return murmurHashOfSize(size, h);
  23117. }
  23118. function murmurHashOfSize(size, h) {
  23119. h = imul(h, 0xcc9e2d51);
  23120. h = imul((h << 15) | (h >>> -15), 0x1b873593);
  23121. h = imul((h << 13) | (h >>> -13), 5);
  23122. h = ((h + 0xe6546b64) | 0) ^ size;
  23123. h = imul(h ^ (h >>> 16), 0x85ebca6b);
  23124. h = imul(h ^ (h >>> 13), 0xc2b2ae35);
  23125. h = smi(h ^ (h >>> 16));
  23126. return h;
  23127. }
  23128. function hashMerge(a, b) {
  23129. return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int
  23130. }
  23131. var Immutable = {
  23132. Iterable: Iterable,
  23133. Seq: Seq,
  23134. Collection: Collection,
  23135. Map: Map,
  23136. OrderedMap: OrderedMap,
  23137. List: List,
  23138. Stack: Stack,
  23139. Set: Set,
  23140. OrderedSet: OrderedSet,
  23141. Record: Record,
  23142. Range: Range,
  23143. Repeat: Repeat,
  23144. is: is,
  23145. fromJS: fromJS
  23146. };
  23147. return Immutable;
  23148. });
  23149. });
  23150. var draftjsUtils = _commonjsHelpers.createCommonjsModule(function(
  23151. module,
  23152. exports
  23153. ) {
  23154. !(function(e, t) {
  23155. module.exports = t(Draft, immutable$1);
  23156. })(
  23157. "undefined" != typeof self ? self : _commonjsHelpers.commonjsGlobal,
  23158. function(e, t) {
  23159. return (function(e) {
  23160. function t(r) {
  23161. if (n[r]) return n[r].exports;
  23162. var o = (n[r] = { i: r, l: !1, exports: {} });
  23163. return e[r].call(o.exports, o, o.exports, t), (o.l = !0), o.exports;
  23164. }
  23165. var n = {};
  23166. return (
  23167. (t.m = e),
  23168. (t.c = n),
  23169. (t.d = function(e, n, r) {
  23170. t.o(e, n) ||
  23171. Object.defineProperty(e, n, {
  23172. configurable: !1,
  23173. enumerable: !0,
  23174. get: r
  23175. });
  23176. }),
  23177. (t.n = function(e) {
  23178. var n =
  23179. e && e.__esModule
  23180. ? function() {
  23181. return e.default;
  23182. }
  23183. : function() {
  23184. return e;
  23185. };
  23186. return t.d(n, "a", n), n;
  23187. }),
  23188. (t.o = function(e, t) {
  23189. return Object.prototype.hasOwnProperty.call(e, t);
  23190. }),
  23191. (t.p = ""),
  23192. t((t.s = 3))
  23193. );
  23194. })([
  23195. function(t, n) {
  23196. t.exports = e;
  23197. },
  23198. function(e, t, n) {
  23199. function r(e) {
  23200. var t = e.getSelection(),
  23201. n = e.getCurrentContent(),
  23202. r = t.getStartKey(),
  23203. o = t.getEndKey(),
  23204. i = n.getBlockMap();
  23205. return i
  23206. .toSeq()
  23207. .skipUntil(function(e, t) {
  23208. return t === r;
  23209. })
  23210. .takeUntil(function(e, t) {
  23211. return t === o;
  23212. })
  23213. .concat([[o, i.get(o)]]);
  23214. }
  23215. function o(e) {
  23216. return r(e).toList();
  23217. }
  23218. function i(e) {
  23219. if (e) return o(e).get(0);
  23220. }
  23221. function l(e) {
  23222. if (e) {
  23223. var t = i(e),
  23224. n = e.getCurrentContent(),
  23225. r = n
  23226. .getBlockMap()
  23227. .toSeq()
  23228. .toList(),
  23229. o = 0;
  23230. if (
  23231. (r.forEach(function(e, n) {
  23232. e.get("key") === t.get("key") && (o = n - 1);
  23233. }),
  23234. o > -1)
  23235. )
  23236. return r.get(o);
  23237. }
  23238. }
  23239. function c(e) {
  23240. return e
  23241. ? e
  23242. .getCurrentContent()
  23243. .getBlockMap()
  23244. .toList()
  23245. : new v.List();
  23246. }
  23247. function a(e) {
  23248. var t = o(e);
  23249. if (
  23250. !t.some(function(e) {
  23251. return e.type !== t.get(0).type;
  23252. })
  23253. )
  23254. return t.get(0).type;
  23255. }
  23256. function f(e) {
  23257. var t = p.RichUtils.tryToRemoveBlockStyle(e);
  23258. return t ? p.EditorState.push(e, t, "change-block-type") : e;
  23259. }
  23260. function u(e) {
  23261. var t = "",
  23262. n = e.getSelection(),
  23263. r = n.getAnchorOffset(),
  23264. i = n.getFocusOffset(),
  23265. l = o(e);
  23266. if (l.size > 0) {
  23267. if (n.getIsBackward()) {
  23268. var c = r;
  23269. (r = i), (i = c);
  23270. }
  23271. for (var a = 0; a < l.size; a += 1) {
  23272. var f = 0 === a ? r : 0,
  23273. u = a === l.size - 1 ? i : l.get(a).getText().length;
  23274. t += l
  23275. .get(a)
  23276. .getText()
  23277. .slice(f, u);
  23278. }
  23279. }
  23280. return t;
  23281. }
  23282. function s(e) {
  23283. var t = e.getCurrentContent(),
  23284. n = e.getSelection(),
  23285. r = p.Modifier.removeRange(t, n, "forward"),
  23286. o = r.getSelectionAfter(),
  23287. i = r.getBlockForKey(o.getStartKey());
  23288. return (
  23289. (r = p.Modifier.insertText(
  23290. r,
  23291. o,
  23292. "\n",
  23293. i.getInlineStyleAt(o.getStartOffset()),
  23294. null
  23295. )),
  23296. p.EditorState.push(e, r, "insert-fragment")
  23297. );
  23298. }
  23299. function g(e) {
  23300. var t = p.Modifier.splitBlock(
  23301. e.getCurrentContent(),
  23302. e.getSelection()
  23303. );
  23304. return f(p.EditorState.push(e, t, "split-block"));
  23305. }
  23306. function d(e) {
  23307. var t = e
  23308. .getCurrentContent()
  23309. .getBlockMap()
  23310. .toList(),
  23311. n = e
  23312. .getSelection()
  23313. .merge({
  23314. anchorKey: t.first().get("key"),
  23315. anchorOffset: 0,
  23316. focusKey: t.last().get("key"),
  23317. focusOffset: t.last().getLength()
  23318. }),
  23319. r = p.Modifier.removeRange(e.getCurrentContent(), n, "forward");
  23320. return p.EditorState.push(e, r, "remove-range");
  23321. }
  23322. function S(e, t) {
  23323. var n = p.Modifier.setBlockData(
  23324. e.getCurrentContent(),
  23325. e.getSelection(),
  23326. t
  23327. );
  23328. return p.EditorState.push(e, n, "change-block-data");
  23329. }
  23330. function y(e) {
  23331. var t = new v.Map({}),
  23332. n = o(e);
  23333. if (n && n.size > 0)
  23334. for (var r = 0; r < n.size; r += 1) {
  23335. var i = (function(e) {
  23336. var r = n.get(e).getData();
  23337. if (!r || 0 === r.size) return (t = t.clear()), "break";
  23338. if (0 === e) t = r;
  23339. else if (
  23340. (t.forEach(function(e, n) {
  23341. (r.get(n) && r.get(n) === e) || (t = t.delete(n));
  23342. }),
  23343. 0 === t.size)
  23344. )
  23345. return (t = t.clear()), "break";
  23346. })(r);
  23347. if ("break" === i) break;
  23348. }
  23349. return t;
  23350. }
  23351. Object.defineProperty(t, "__esModule", { value: !0 }),
  23352. (t.blockRenderMap = void 0),
  23353. (t.getSelectedBlocksMap = r),
  23354. (t.getSelectedBlocksList = o),
  23355. (t.getSelectedBlock = i),
  23356. (t.getBlockBeforeSelectedBlock = l),
  23357. (t.getAllBlocks = c),
  23358. (t.getSelectedBlocksType = a),
  23359. (t.removeSelectedBlocksStyle = f),
  23360. (t.getSelectionText = u),
  23361. (t.addLineBreakRemovingSelection = s),
  23362. (t.insertNewUnstyledBlock = g),
  23363. (t.clearEditorContent = d),
  23364. (t.setBlockData = S),
  23365. (t.getSelectedBlocksMetadata = y);
  23366. var p = n(0),
  23367. v = n(6),
  23368. k = (0, v.Map)({ code: { element: "pre" } });
  23369. t.blockRenderMap = p.DefaultDraftBlockRenderMap.merge(k);
  23370. },
  23371. function(e, t, n) {
  23372. function r(e) {
  23373. if (e) {
  23374. var t = e.getType();
  23375. return "unordered-list-item" === t || "ordered-list-item" === t;
  23376. }
  23377. return !1;
  23378. }
  23379. function o(e, t, n) {
  23380. var r = e.getSelection(),
  23381. o = e.getCurrentContent(),
  23382. i = o.getBlockMap(),
  23383. l = (0, c.getSelectedBlocksMap)(e).map(function(e) {
  23384. var r = e.getDepth() + t;
  23385. return (r = Math.max(0, Math.min(r, n))), e.set("depth", r);
  23386. });
  23387. return (
  23388. (i = i.merge(l)),
  23389. o.merge({ blockMap: i, selectionBefore: r, selectionAfter: r })
  23390. );
  23391. }
  23392. function i(e, t, n) {
  23393. var r = e.getSelection(),
  23394. i = void 0;
  23395. i = r.getIsBackward() ? r.getFocusKey() : r.getAnchorKey();
  23396. var c = e.getCurrentContent(),
  23397. a = c.getBlockForKey(i),
  23398. f = a.getType();
  23399. if ("unordered-list-item" !== f && "ordered-list-item" !== f)
  23400. return e;
  23401. var u = c.getBlockBefore(i);
  23402. if (!u) return e;
  23403. if (u.getType() !== f) return e;
  23404. var s = a.getDepth();
  23405. if (1 === t && s === n) return e;
  23406. var g = Math.min(u.getDepth() + 1, n),
  23407. d = o(e, t, g);
  23408. return l.EditorState.push(e, d, "adjust-depth");
  23409. }
  23410. Object.defineProperty(t, "__esModule", { value: !0 }),
  23411. (t.isListBlock = r),
  23412. (t.changeDepth = i);
  23413. var l = n(0),
  23414. c = n(1);
  23415. },
  23416. function(e, t, n) {
  23417. e.exports = n(4);
  23418. },
  23419. function(e, t, n) {
  23420. var r = n(5),
  23421. o = n(1),
  23422. i = n(7),
  23423. l = (function(e) {
  23424. return e && e.__esModule ? e : { default: e };
  23425. })(i),
  23426. c = n(2);
  23427. e.exports = {
  23428. getSelectedBlocksMap: o.getSelectedBlocksMap,
  23429. getSelectedBlocksList: o.getSelectedBlocksList,
  23430. getSelectedBlock: o.getSelectedBlock,
  23431. getBlockBeforeSelectedBlock: o.getBlockBeforeSelectedBlock,
  23432. getAllBlocks: o.getAllBlocks,
  23433. getSelectedBlocksType: o.getSelectedBlocksType,
  23434. removeSelectedBlocksStyle: o.removeSelectedBlocksStyle,
  23435. getSelectionText: o.getSelectionText,
  23436. addLineBreakRemovingSelection: o.addLineBreakRemovingSelection,
  23437. insertNewUnstyledBlock: o.insertNewUnstyledBlock,
  23438. clearEditorContent: o.clearEditorContent,
  23439. setBlockData: o.setBlockData,
  23440. getSelectedBlocksMetadata: o.getSelectedBlocksMetadata,
  23441. blockRenderMap: o.blockRenderMap,
  23442. getEntityRange: r.getEntityRange,
  23443. getCustomStyleMap: r.getCustomStyleMap,
  23444. toggleCustomInlineStyle: r.toggleCustomInlineStyle,
  23445. getSelectionEntity: r.getSelectionEntity,
  23446. extractInlineStyle: r.extractInlineStyle,
  23447. removeAllInlineStyles: r.removeAllInlineStyles,
  23448. getSelectionInlineStyle: r.getSelectionInlineStyle,
  23449. getSelectionCustomInlineStyle: r.getSelectionCustomInlineStyle,
  23450. handleNewLine: l.default,
  23451. isListBlock: c.isListBlock,
  23452. changeDepth: c.changeDepth
  23453. };
  23454. },
  23455. function(e, t, n) {
  23456. function r(e, t, n) {
  23457. return (
  23458. t in e
  23459. ? Object.defineProperty(e, t, {
  23460. value: n,
  23461. enumerable: !0,
  23462. configurable: !0,
  23463. writable: !0
  23464. })
  23465. : (e[t] = n),
  23466. e
  23467. );
  23468. }
  23469. function o(e) {
  23470. var t = e.getSelection();
  23471. if (t.isCollapsed()) {
  23472. var n = {},
  23473. r = e
  23474. .getCurrentInlineStyle()
  23475. .toList()
  23476. .toJS();
  23477. if (r)
  23478. return (
  23479. [
  23480. "BOLD",
  23481. "ITALIC",
  23482. "UNDERLINE",
  23483. "STRIKETHROUGH",
  23484. "CODE",
  23485. "SUPERSCRIPT",
  23486. "SUBSCRIPT"
  23487. ].forEach(function(e) {
  23488. n[e] = r.indexOf(e) >= 0;
  23489. }),
  23490. n
  23491. );
  23492. }
  23493. var o = t.getStartOffset(),
  23494. i = t.getEndOffset(),
  23495. l = (0, p.getSelectedBlocksList)(e);
  23496. if (l.size > 0) {
  23497. var c = (function() {
  23498. for (
  23499. var e = {
  23500. BOLD: !0,
  23501. ITALIC: !0,
  23502. UNDERLINE: !0,
  23503. STRIKETHROUGH: !0,
  23504. CODE: !0,
  23505. SUPERSCRIPT: !0,
  23506. SUBSCRIPT: !0
  23507. },
  23508. t = 0;
  23509. t < l.size;
  23510. t += 1
  23511. ) {
  23512. var n = 0 === t ? o : 0,
  23513. r = t === l.size - 1 ? i : l.get(t).getText().length;
  23514. n === r && 0 === n ? ((n = 1), (r = 2)) : n === r && (n -= 1);
  23515. for (var c = n; c < r; c += 1)
  23516. !(function(n) {
  23517. var r = l.get(t).getInlineStyleAt(n);
  23518. [
  23519. "BOLD",
  23520. "ITALIC",
  23521. "UNDERLINE",
  23522. "STRIKETHROUGH",
  23523. "CODE",
  23524. "SUPERSCRIPT",
  23525. "SUBSCRIPT"
  23526. ].forEach(function(t) {
  23527. e[t] = e[t] && r.get(t) === t;
  23528. });
  23529. })(c);
  23530. }
  23531. return { v: e };
  23532. })();
  23533. if ("object" === (void 0 === c ? "undefined" : S(c))) return c.v;
  23534. }
  23535. return {};
  23536. }
  23537. function i(e) {
  23538. var t = void 0,
  23539. n = e.getSelection(),
  23540. r = n.getStartOffset(),
  23541. o = n.getEndOffset();
  23542. r === o && 0 === r ? (o = 1) : r === o && (r -= 1);
  23543. for (var i = (0, p.getSelectedBlock)(e), l = r; l < o; l += 1) {
  23544. var c = i.getEntityAt(l);
  23545. if (!c) {
  23546. t = void 0;
  23547. break;
  23548. }
  23549. if (l === r) t = c;
  23550. else if (t !== c) {
  23551. t = void 0;
  23552. break;
  23553. }
  23554. }
  23555. return t;
  23556. }
  23557. function l(e, t) {
  23558. var n = (0, p.getSelectedBlock)(e),
  23559. r = void 0;
  23560. return (
  23561. n.findEntityRanges(
  23562. function(e) {
  23563. return e.get("entity") === t;
  23564. },
  23565. function(e, t) {
  23566. r = { start: e, end: t, text: n.get("text").slice(e, t) };
  23567. }
  23568. ),
  23569. r
  23570. );
  23571. }
  23572. function c(e, t, n) {
  23573. var r = e.getSelection(),
  23574. o = Object.keys(v[t]).reduce(function(e, t) {
  23575. return y.Modifier.removeInlineStyle(e, r, t);
  23576. }, e.getCurrentContent()),
  23577. i = y.EditorState.push(e, o, "changeinline-style"),
  23578. l = e.getCurrentInlineStyle();
  23579. if (
  23580. (r.isCollapsed() &&
  23581. (i = l.reduce(function(e, t) {
  23582. return y.RichUtils.toggleInlineStyle(e, t);
  23583. }, i)),
  23584. "SUPERSCRIPT" === t || "SUBSCRIPT" == t)
  23585. )
  23586. l.has(n) || (i = y.RichUtils.toggleInlineStyle(i, n));
  23587. else {
  23588. var c = "bgcolor" === t ? "backgroundColor" : t;
  23589. l.has(c + "-" + n) ||
  23590. ((i = y.RichUtils.toggleInlineStyle(
  23591. i,
  23592. t.toLowerCase() + "-" + n
  23593. )),
  23594. k(t, c, n));
  23595. }
  23596. return i;
  23597. }
  23598. function a(e) {
  23599. if (e) {
  23600. e.getCurrentContent()
  23601. .getBlockMap()
  23602. .map(function(e) {
  23603. return e.get("characterList");
  23604. })
  23605. .toList()
  23606. .flatten()
  23607. .forEach(function(e) {
  23608. e && 0 === e.indexOf("color-")
  23609. ? k("color", "color", e.substr(6))
  23610. : e && 0 === e.indexOf("bgcolor-")
  23611. ? k("bgcolor", "backgroundColor", e.substr(8))
  23612. : e && 0 === e.indexOf("fontsize-")
  23613. ? k("fontSize", "fontSize", +e.substr(9))
  23614. : e &&
  23615. 0 === e.indexOf("fontfamily-") &&
  23616. k("fontFamily", "fontFamily", e.substr(11));
  23617. });
  23618. }
  23619. }
  23620. function f(e, t, n) {
  23621. var r = e.getInlineStyleAt(n).toList(),
  23622. o = r.filter(function(e) {
  23623. return e.startsWith(t.toLowerCase());
  23624. });
  23625. if (o && o.size > 0) return o.get(0);
  23626. }
  23627. function u(e, t) {
  23628. var n = e.getCurrentInlineStyle().toList(),
  23629. r = n.filter(function(e) {
  23630. return e.startsWith(t.toLowerCase());
  23631. });
  23632. if (r && r.size > 0) return r.get(0);
  23633. }
  23634. function s(e, t) {
  23635. if (e && t && t.length > 0) {
  23636. var n = (function() {
  23637. var n = e.getSelection(),
  23638. r = {};
  23639. if (n.isCollapsed())
  23640. return (
  23641. t.forEach(function(t) {
  23642. r[t] = u(e, t);
  23643. }),
  23644. { v: r }
  23645. );
  23646. var o = n.getStartOffset(),
  23647. i = n.getEndOffset(),
  23648. l = (0, p.getSelectedBlocksList)(e);
  23649. if (l.size > 0) {
  23650. for (var c = 0; c < l.size; c += 1)
  23651. !(function(e) {
  23652. var n = 0 === e ? o : 0,
  23653. c = e === l.size - 1 ? i : l.get(e).getText().length;
  23654. n === c && 0 === n
  23655. ? ((n = 1), (c = 2))
  23656. : n === c && (n -= 1);
  23657. for (var a = n; a < c; a += 1)
  23658. !(function(o) {
  23659. o === n
  23660. ? t.forEach(function(t) {
  23661. r[t] = f(l.get(e), t, o);
  23662. })
  23663. : t.forEach(function(t) {
  23664. r[t] &&
  23665. r[t] !== f(l.get(e), t, o) &&
  23666. (r[t] = void 0);
  23667. });
  23668. })(a);
  23669. })(c);
  23670. return { v: r };
  23671. }
  23672. })();
  23673. if ("object" === (void 0 === n ? "undefined" : S(n))) return n.v;
  23674. }
  23675. return {};
  23676. }
  23677. function g(e) {
  23678. var t = e.getCurrentInlineStyle(),
  23679. n = e.getCurrentContent();
  23680. return (
  23681. t.forEach(function(t) {
  23682. n = y.Modifier.removeInlineStyle(n, e.getSelection(), t);
  23683. }),
  23684. y.EditorState.push(e, n, "change-inline-style")
  23685. );
  23686. }
  23687. Object.defineProperty(t, "__esModule", { value: !0 }),
  23688. (t.getCustomStyleMap = void 0);
  23689. var d =
  23690. Object.assign ||
  23691. function(e) {
  23692. for (var t = 1; t < arguments.length; t++) {
  23693. var n = arguments[t];
  23694. for (var r in n)
  23695. Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
  23696. }
  23697. return e;
  23698. },
  23699. S =
  23700. "function" == typeof Symbol && "symbol" == typeof Symbol.iterator
  23701. ? function(e) {
  23702. return typeof e;
  23703. }
  23704. : function(e) {
  23705. return e &&
  23706. "function" == typeof Symbol &&
  23707. e.constructor === Symbol &&
  23708. e !== Symbol.prototype
  23709. ? "symbol"
  23710. : typeof e;
  23711. };
  23712. (t.getSelectionInlineStyle = o),
  23713. (t.getSelectionEntity = i),
  23714. (t.getEntityRange = l),
  23715. (t.toggleCustomInlineStyle = c),
  23716. (t.extractInlineStyle = a),
  23717. (t.getSelectionCustomInlineStyle = s),
  23718. (t.removeAllInlineStyles = g);
  23719. var y = n(0),
  23720. p = n(1),
  23721. v = {
  23722. color: {},
  23723. bgcolor: {},
  23724. fontSize: {},
  23725. fontFamily: {},
  23726. CODE: {
  23727. fontFamily: "monospace",
  23728. wordWrap: "break-word",
  23729. background: "#f1f1f1",
  23730. borderRadius: 3,
  23731. padding: "1px 3px"
  23732. },
  23733. SUPERSCRIPT: {
  23734. fontSize: 11,
  23735. position: "relative",
  23736. top: -8,
  23737. display: "inline-flex"
  23738. },
  23739. SUBSCRIPT: {
  23740. fontSize: 11,
  23741. position: "relative",
  23742. bottom: -8,
  23743. display: "inline-flex"
  23744. }
  23745. },
  23746. k = function(e, t, n) {
  23747. v[e][e.toLowerCase() + "-" + n] = r({}, "" + t, n);
  23748. };
  23749. t.getCustomStyleMap = function() {
  23750. return d({}, v.color, v.bgcolor, v.fontSize, v.fontFamily, {
  23751. CODE: v.CODE,
  23752. SUPERSCRIPT: v.SUPERSCRIPT,
  23753. SUBSCRIPT: v.SUBSCRIPT
  23754. });
  23755. };
  23756. },
  23757. function(e, n) {
  23758. e.exports = t;
  23759. },
  23760. function(e, t, n) {
  23761. function r(e) {
  23762. var t = e.getSelection();
  23763. if (t.isCollapsed()) {
  23764. var n = e.getCurrentContent(),
  23765. r = t.getStartKey(),
  23766. o = n.getBlockForKey(r);
  23767. if (
  23768. !(0, a.isListBlock)(o) &&
  23769. "unstyled" !== o.getType() &&
  23770. o.getLength() === t.getStartOffset()
  23771. )
  23772. return (0, c.insertNewUnstyledBlock)(e);
  23773. if ((0, a.isListBlock)(o) && 0 === o.getLength()) {
  23774. var i = o.getDepth();
  23775. if (0 === i) return (0, c.removeSelectedBlocksStyle)(e);
  23776. if (i > 0) return (0, a.changeDepth)(e, -1, i);
  23777. }
  23778. }
  23779. }
  23780. function o(e) {
  23781. return (
  23782. 13 === e.which &&
  23783. (e.getModifierState("Shift") ||
  23784. e.getModifierState("Alt") ||
  23785. e.getModifierState("Control"))
  23786. );
  23787. }
  23788. function i(e, t) {
  23789. if (o(t)) {
  23790. return e.getSelection().isCollapsed()
  23791. ? l.RichUtils.insertSoftNewline(e)
  23792. : (0, c.addLineBreakRemovingSelection)(e);
  23793. }
  23794. return r(e);
  23795. }
  23796. Object.defineProperty(t, "__esModule", { value: !0 }),
  23797. (t.default = i);
  23798. var l = n(0),
  23799. c = n(1),
  23800. a = n(2);
  23801. }
  23802. ]);
  23803. }
  23804. );
  23805. });
  23806. _commonjsHelpers.unwrapExports(draftjsUtils);
  23807. var draftjsUtils_1 = draftjsUtils.draftjsUtils;
  23808. var interopRequireDefault = _commonjsHelpers.createCommonjsModule(function(
  23809. module
  23810. ) {
  23811. function _interopRequireDefault(obj) {
  23812. return obj && obj.__esModule
  23813. ? obj
  23814. : {
  23815. default: obj
  23816. };
  23817. }
  23818. module.exports = _interopRequireDefault;
  23819. });
  23820. _commonjsHelpers.unwrapExports(interopRequireDefault);
  23821. /**
  23822. * Copyright (c) 2013-present, Facebook, Inc.
  23823. *
  23824. * This source code is licensed under the MIT license found in the
  23825. * LICENSE file in the root directory of this source tree.
  23826. */
  23827. /**
  23828. * Use invariant() to assert state which your program assumes to be true.
  23829. *
  23830. * Provide sprintf-style format (only %s is supported) and arguments
  23831. * to provide information about what broke and what you were
  23832. * expecting.
  23833. *
  23834. * The invariant message will be stripped in production, but the invariant
  23835. * will remain to ensure logic does not differ in production.
  23836. */
  23837. var invariant$1 = function(condition, format, a, b, c, d, e, f) {
  23838. if (process.env.NODE_ENV !== "production") {
  23839. if (format === undefined) {
  23840. throw new Error("invariant requires an error message argument");
  23841. }
  23842. }
  23843. if (!condition) {
  23844. var error;
  23845. if (format === undefined) {
  23846. error = new Error(
  23847. "Minified exception occurred; use the non-minified dev environment " +
  23848. "for the full error message and additional helpful warnings."
  23849. );
  23850. } else {
  23851. var args = [a, b, c, d, e, f];
  23852. var argIndex = 0;
  23853. error = new Error(
  23854. format.replace(/%s/g, function() {
  23855. return args[argIndex++];
  23856. })
  23857. );
  23858. error.name = "Invariant Violation";
  23859. }
  23860. error.framesToPop = 1; // we don't care about invariant's own frame
  23861. throw error;
  23862. }
  23863. };
  23864. var browser = invariant$1;
  23865. function _arrayWithoutHoles(arr) {
  23866. if (Array.isArray(arr)) {
  23867. for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
  23868. arr2[i] = arr[i];
  23869. }
  23870. return arr2;
  23871. }
  23872. }
  23873. var arrayWithoutHoles = _arrayWithoutHoles;
  23874. function _iterableToArray(iter) {
  23875. if (
  23876. Symbol.iterator in Object(iter) ||
  23877. Object.prototype.toString.call(iter) === "[object Arguments]"
  23878. )
  23879. return Array.from(iter);
  23880. }
  23881. var iterableToArray = _iterableToArray;
  23882. function _nonIterableSpread() {
  23883. throw new TypeError("Invalid attempt to spread non-iterable instance");
  23884. }
  23885. var nonIterableSpread = _nonIterableSpread;
  23886. function _toConsumableArray(arr) {
  23887. return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();
  23888. }
  23889. var toConsumableArray = _toConsumableArray;
  23890. var updateMutation_1 = _commonjsHelpers.createCommonjsModule(function(
  23891. module,
  23892. exports
  23893. ) {
  23894. Object.defineProperty(exports, "__esModule", {
  23895. value: true
  23896. });
  23897. exports["default"] = updateMutation;
  23898. function updateMutation(
  23899. mutation,
  23900. originalOffset,
  23901. originalLength,
  23902. newLength,
  23903. prefixLength,
  23904. suffixLength
  23905. ) {
  23906. // three cases we can reasonably adjust - disjoint mutations that
  23907. // happen later on where the offset will need to be changed,
  23908. // mutations that completely contain the new one where we can adjust
  23909. // the length, and mutations that occur partially within the new one.
  23910. var lengthDiff = newLength - originalLength;
  23911. var mutationAfterChange =
  23912. originalOffset + originalLength <= mutation.offset;
  23913. if (mutationAfterChange) {
  23914. return Object.assign({}, mutation, {
  23915. offset: mutation.offset + lengthDiff
  23916. });
  23917. }
  23918. var mutationContainsChange =
  23919. originalOffset >= mutation.offset &&
  23920. originalOffset + originalLength <= mutation.offset + mutation.length;
  23921. if (mutationContainsChange) {
  23922. return Object.assign({}, mutation, {
  23923. length: mutation.length + lengthDiff
  23924. });
  23925. }
  23926. var mutationWithinPrefixChange =
  23927. mutation.offset >= originalOffset &&
  23928. mutation.offset + mutation.length <= originalOffset + originalLength &&
  23929. prefixLength > 0;
  23930. if (mutationWithinPrefixChange) {
  23931. return Object.assign({}, mutation, {
  23932. offset: mutation.offset + prefixLength
  23933. });
  23934. }
  23935. var mutationContainsPrefix =
  23936. mutation.offset < originalOffset &&
  23937. mutation.offset + mutation.length <= originalOffset + originalLength &&
  23938. mutation.offset + mutation.length > originalOffset &&
  23939. prefixLength > 0;
  23940. if (mutationContainsPrefix) {
  23941. return [
  23942. Object.assign({}, mutation, {
  23943. length: originalOffset - mutation.offset
  23944. }),
  23945. Object.assign({}, mutation, {
  23946. offset: originalOffset + prefixLength,
  23947. length: mutation.offset - originalOffset + mutation.length
  23948. })
  23949. ];
  23950. }
  23951. var mutationContainsSuffix =
  23952. mutation.offset >= originalOffset &&
  23953. mutation.offset + mutation.length > originalOffset + originalLength &&
  23954. originalOffset + originalLength > mutation.offset &&
  23955. suffixLength > 0;
  23956. if (mutationContainsSuffix) {
  23957. return [
  23958. Object.assign({}, mutation, {
  23959. offset: mutation.offset + prefixLength,
  23960. length: originalOffset + originalLength - mutation.offset
  23961. }),
  23962. Object.assign({}, mutation, {
  23963. offset: originalOffset + originalLength + prefixLength + suffixLength,
  23964. length:
  23965. mutation.offset +
  23966. mutation.length -
  23967. (originalOffset + originalLength)
  23968. })
  23969. ];
  23970. }
  23971. return mutation;
  23972. }
  23973. });
  23974. _commonjsHelpers.unwrapExports(updateMutation_1);
  23975. var rangeSort = _commonjsHelpers.createCommonjsModule(function(
  23976. module,
  23977. exports
  23978. ) {
  23979. Object.defineProperty(exports, "__esModule", {
  23980. value: true
  23981. });
  23982. exports["default"] = void 0;
  23983. var _default = function _default(r1, r2) {
  23984. if (r1.offset === r2.offset) {
  23985. return r2.length - r1.length;
  23986. }
  23987. return r1.offset - r2.offset;
  23988. };
  23989. exports["default"] = _default;
  23990. });
  23991. _commonjsHelpers.unwrapExports(rangeSort);
  23992. var encodeBlock = _commonjsHelpers.createCommonjsModule(function(
  23993. module,
  23994. exports
  23995. ) {
  23996. Object.defineProperty(exports, "__esModule", {
  23997. value: true
  23998. });
  23999. exports["default"] = void 0;
  24000. var _toConsumableArray2 = interopRequireDefault(toConsumableArray);
  24001. var _updateMutation = interopRequireDefault(updateMutation_1);
  24002. var _rangeSort = interopRequireDefault(rangeSort);
  24003. var ENTITY_MAP = {
  24004. "&": "&amp;",
  24005. "<": "&lt;",
  24006. ">": "&gt;",
  24007. '"': "&quot;",
  24008. "'": "&#x27;",
  24009. "`": "&#x60;",
  24010. "\n": "<br/>"
  24011. };
  24012. var _default = function _default(block) {
  24013. var blockText = (0, _toConsumableArray2["default"])(block.text);
  24014. var entities = block.entityRanges.sort(_rangeSort["default"]);
  24015. var styles = block.inlineStyleRanges.sort(_rangeSort["default"]);
  24016. var resultText = "";
  24017. var _loop = function _loop(index) {
  24018. var _char = blockText[index];
  24019. if (ENTITY_MAP[_char] !== undefined) {
  24020. var encoded = ENTITY_MAP[_char];
  24021. var resultIndex = (0, _toConsumableArray2["default"])(resultText)
  24022. .length;
  24023. resultText += encoded;
  24024. var updateForChar = function updateForChar(mutation) {
  24025. return (0, _updateMutation["default"])(
  24026. mutation,
  24027. resultIndex,
  24028. _char.length,
  24029. encoded.length,
  24030. 0,
  24031. 0
  24032. );
  24033. };
  24034. entities = entities.map(updateForChar);
  24035. styles = styles.map(updateForChar);
  24036. } else {
  24037. resultText += _char;
  24038. }
  24039. };
  24040. for (var index = 0; index < blockText.length; index++) {
  24041. _loop(index);
  24042. }
  24043. return Object.assign({}, block, {
  24044. text: resultText,
  24045. inlineStyleRanges: styles,
  24046. entityRanges: entities
  24047. });
  24048. };
  24049. exports["default"] = _default;
  24050. });
  24051. _commonjsHelpers.unwrapExports(encodeBlock);
  24052. var _typeof_1 = _commonjsHelpers.createCommonjsModule(function(module) {
  24053. function _typeof(obj) {
  24054. "@babel/helpers - typeof";
  24055. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  24056. module.exports = _typeof = function _typeof(obj) {
  24057. return typeof obj;
  24058. };
  24059. } else {
  24060. module.exports = _typeof = function _typeof(obj) {
  24061. return obj &&
  24062. typeof Symbol === "function" &&
  24063. obj.constructor === Symbol &&
  24064. obj !== Symbol.prototype
  24065. ? "symbol"
  24066. : typeof obj;
  24067. };
  24068. }
  24069. return _typeof(obj);
  24070. }
  24071. module.exports = _typeof;
  24072. });
  24073. var splitReactElement_1 = _commonjsHelpers.createCommonjsModule(function(
  24074. module,
  24075. exports
  24076. ) {
  24077. Object.defineProperty(exports, "__esModule", {
  24078. value: true
  24079. });
  24080. exports["default"] = splitReactElement;
  24081. var _invariant = interopRequireDefault(browser);
  24082. var _react = interopRequireDefault(React__default);
  24083. var _server = interopRequireDefault(server);
  24084. // see http://w3c.github.io/html/syntax.html#writing-html-documents-elements
  24085. var VOID_TAGS = [
  24086. "area",
  24087. "base",
  24088. "br",
  24089. "col",
  24090. "embed",
  24091. "hr",
  24092. "img",
  24093. "input",
  24094. "link",
  24095. "meta",
  24096. "param",
  24097. "source",
  24098. "track",
  24099. "wbr"
  24100. ];
  24101. function splitReactElement(element) {
  24102. if (VOID_TAGS.indexOf(element.type) !== -1) {
  24103. return _server["default"].renderToStaticMarkup(element);
  24104. }
  24105. var tags = _server["default"]
  24106. .renderToStaticMarkup(_react["default"].cloneElement(element, {}, "\r"))
  24107. .split("\r");
  24108. (0, _invariant["default"])(
  24109. tags.length > 1,
  24110. "convertToHTML: Element of type ".concat(
  24111. element.type,
  24112. " must render children"
  24113. )
  24114. );
  24115. (0, _invariant["default"])(
  24116. tags.length < 3,
  24117. "convertToHTML: Element of type ".concat(
  24118. element.type,
  24119. " cannot use carriage return character"
  24120. )
  24121. );
  24122. return {
  24123. start: tags[0],
  24124. end: tags[1]
  24125. };
  24126. }
  24127. });
  24128. _commonjsHelpers.unwrapExports(splitReactElement_1);
  24129. var getElementHTML_1 = _commonjsHelpers.createCommonjsModule(function(
  24130. module,
  24131. exports
  24132. ) {
  24133. Object.defineProperty(exports, "__esModule", {
  24134. value: true
  24135. });
  24136. exports["default"] = getElementHTML;
  24137. var _typeof2 = interopRequireDefault(_typeof_1);
  24138. var _invariant = interopRequireDefault(browser);
  24139. var _react = interopRequireDefault(React__default);
  24140. var _server = interopRequireDefault(server);
  24141. var _splitReactElement = interopRequireDefault(splitReactElement_1);
  24142. function hasChildren(element) {
  24143. return (
  24144. _react["default"].isValidElement(element) &&
  24145. _react["default"].Children.count(element.props.children) > 0
  24146. );
  24147. }
  24148. function getElementHTML(element) {
  24149. var text =
  24150. arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  24151. if (element === undefined || element === null) {
  24152. return element;
  24153. }
  24154. if (typeof element === "string") {
  24155. return element;
  24156. }
  24157. if (_react["default"].isValidElement(element)) {
  24158. if (hasChildren(element)) {
  24159. return _server["default"].renderToStaticMarkup(element);
  24160. }
  24161. var tags = (0, _splitReactElement["default"])(element);
  24162. if (text !== null && (0, _typeof2["default"])(tags) === "object") {
  24163. var start = tags.start,
  24164. end = tags.end;
  24165. return start + text + end;
  24166. }
  24167. return tags;
  24168. }
  24169. (0, _invariant["default"])(
  24170. Object.prototype.hasOwnProperty.call(element, "start") &&
  24171. Object.prototype.hasOwnProperty.call(element, "end"),
  24172. "convertToHTML: received conversion data without either an HTML string, ReactElement or an object with start/end tags"
  24173. );
  24174. if (text !== null) {
  24175. var _start = element.start,
  24176. _end = element.end;
  24177. return _start + text + _end;
  24178. }
  24179. return element;
  24180. }
  24181. });
  24182. _commonjsHelpers.unwrapExports(getElementHTML_1);
  24183. var getElementTagLength_1 = _commonjsHelpers.createCommonjsModule(function(
  24184. module,
  24185. exports
  24186. ) {
  24187. Object.defineProperty(exports, "__esModule", {
  24188. value: true
  24189. });
  24190. exports["default"] = void 0;
  24191. var _typeof2 = interopRequireDefault(_typeof_1);
  24192. var _react = interopRequireDefault(React__default);
  24193. var _splitReactElement = interopRequireDefault(splitReactElement_1);
  24194. var getElementTagLength = function getElementTagLength(element) {
  24195. var type =
  24196. arguments.length > 1 && arguments[1] !== undefined
  24197. ? arguments[1]
  24198. : "start";
  24199. if (_react["default"].isValidElement(element)) {
  24200. var splitElement = (0, _splitReactElement["default"])(element);
  24201. if (typeof splitElement === "string") {
  24202. return 0;
  24203. }
  24204. var length = splitElement[type].length;
  24205. var child = _react["default"].Children.toArray(element.props.children)[0];
  24206. return (
  24207. length +
  24208. (child && _react["default"].isValidElement(child)
  24209. ? getElementTagLength(child, type)
  24210. : 0)
  24211. );
  24212. }
  24213. if ((0, _typeof2["default"])(element) === "object") {
  24214. return element[type] ? element[type].length : 0;
  24215. }
  24216. return 0;
  24217. };
  24218. var _default = getElementTagLength;
  24219. exports["default"] = _default;
  24220. });
  24221. _commonjsHelpers.unwrapExports(getElementTagLength_1);
  24222. var blockEntities = _commonjsHelpers.createCommonjsModule(function(
  24223. module,
  24224. exports
  24225. ) {
  24226. Object.defineProperty(exports, "__esModule", {
  24227. value: true
  24228. });
  24229. exports["default"] = void 0;
  24230. var _toConsumableArray2 = interopRequireDefault(toConsumableArray);
  24231. var _updateMutation = interopRequireDefault(updateMutation_1);
  24232. var _rangeSort = interopRequireDefault(rangeSort);
  24233. var _getElementHTML = interopRequireDefault(getElementHTML_1);
  24234. var _getElementTagLength = interopRequireDefault(getElementTagLength_1);
  24235. var converter = function converter() {
  24236. var originalText = arguments.length > 1 ? arguments[1] : undefined;
  24237. return originalText;
  24238. };
  24239. var _default = function _default(block, entityMap) {
  24240. var entityConverter =
  24241. arguments.length > 2 && arguments[2] !== undefined
  24242. ? arguments[2]
  24243. : converter;
  24244. var resultText = (0, _toConsumableArray2["default"])(block.text);
  24245. var getEntityHTML = entityConverter;
  24246. if (entityConverter.__isMiddleware) {
  24247. getEntityHTML = entityConverter(converter);
  24248. }
  24249. if (
  24250. Object.prototype.hasOwnProperty.call(block, "entityRanges") &&
  24251. block.entityRanges.length > 0
  24252. ) {
  24253. var entities = block.entityRanges.sort(_rangeSort["default"]);
  24254. var styles = block.inlineStyleRanges;
  24255. var _loop = function _loop(index) {
  24256. var entityRange = entities[index];
  24257. var entity = entityMap[entityRange.key];
  24258. var originalText = resultText
  24259. .slice(entityRange.offset, entityRange.offset + entityRange.length)
  24260. .join("");
  24261. var entityHTML = getEntityHTML(entity, originalText);
  24262. var converted = (0, _toConsumableArray2["default"])(
  24263. (0, _getElementHTML["default"])(entityHTML, originalText) ||
  24264. originalText
  24265. );
  24266. var prefixLength = (0, _getElementTagLength["default"])(
  24267. entityHTML,
  24268. "start"
  24269. );
  24270. var suffixLength = (0, _getElementTagLength["default"])(
  24271. entityHTML,
  24272. "end"
  24273. );
  24274. var updateLaterMutation = function updateLaterMutation(
  24275. mutation,
  24276. mutationIndex
  24277. ) {
  24278. if (
  24279. mutationIndex > index ||
  24280. Object.prototype.hasOwnProperty.call(mutation, "style")
  24281. ) {
  24282. return (0, _updateMutation["default"])(
  24283. mutation,
  24284. entityRange.offset,
  24285. entityRange.length,
  24286. converted.length,
  24287. prefixLength,
  24288. suffixLength
  24289. );
  24290. }
  24291. return mutation;
  24292. };
  24293. var updateLaterMutations = function updateLaterMutations(mutationList) {
  24294. return mutationList.reduce(function(acc, mutation, mutationIndex) {
  24295. var updatedMutation = updateLaterMutation(mutation, mutationIndex);
  24296. if (Array.isArray(updatedMutation)) {
  24297. return acc.concat(updatedMutation);
  24298. }
  24299. return acc.concat([updatedMutation]);
  24300. }, []);
  24301. };
  24302. entities = updateLaterMutations(entities);
  24303. styles = updateLaterMutations(styles);
  24304. resultText = [].concat(
  24305. (0, _toConsumableArray2["default"])(
  24306. resultText.slice(0, entityRange.offset)
  24307. ),
  24308. (0, _toConsumableArray2["default"])(converted),
  24309. (0, _toConsumableArray2["default"])(
  24310. resultText.slice(entityRange.offset + entityRange.length)
  24311. )
  24312. );
  24313. };
  24314. for (var index = 0; index < entities.length; index++) {
  24315. _loop(index);
  24316. }
  24317. return Object.assign({}, block, {
  24318. text: resultText.join(""),
  24319. inlineStyleRanges: styles,
  24320. entityRanges: entities
  24321. });
  24322. }
  24323. return block;
  24324. };
  24325. exports["default"] = _default;
  24326. });
  24327. _commonjsHelpers.unwrapExports(blockEntities);
  24328. var styleObjectFunction = _commonjsHelpers.createCommonjsModule(function(
  24329. module,
  24330. exports
  24331. ) {
  24332. Object.defineProperty(exports, "__esModule", {
  24333. value: true
  24334. });
  24335. exports["default"] = void 0;
  24336. var _default = function _default(object) {
  24337. return function(style) {
  24338. if (typeof object === "function") {
  24339. return object(style);
  24340. }
  24341. return object[style];
  24342. };
  24343. };
  24344. exports["default"] = _default;
  24345. });
  24346. _commonjsHelpers.unwrapExports(styleObjectFunction);
  24347. var accumulateFunction = _commonjsHelpers.createCommonjsModule(function(
  24348. module,
  24349. exports
  24350. ) {
  24351. Object.defineProperty(exports, "__esModule", {
  24352. value: true
  24353. });
  24354. exports["default"] = void 0;
  24355. var _default = function _default(newFn, rest) {
  24356. return function() {
  24357. var newResult = newFn.apply(void 0, arguments);
  24358. if (newResult !== undefined && newResult !== null) {
  24359. return newResult;
  24360. }
  24361. return rest.apply(void 0, arguments);
  24362. };
  24363. };
  24364. exports["default"] = _default;
  24365. });
  24366. _commonjsHelpers.unwrapExports(accumulateFunction);
  24367. var defaultInlineHTML_1 = _commonjsHelpers.createCommonjsModule(function(
  24368. module,
  24369. exports
  24370. ) {
  24371. Object.defineProperty(exports, "__esModule", {
  24372. value: true
  24373. });
  24374. exports["default"] = defaultInlineHTML;
  24375. var _react = interopRequireDefault(React__default);
  24376. function defaultInlineHTML(style) {
  24377. switch (style) {
  24378. case "BOLD":
  24379. return _react["default"].createElement("strong", null);
  24380. case "ITALIC":
  24381. return _react["default"].createElement("em", null);
  24382. case "UNDERLINE":
  24383. return _react["default"].createElement("u", null);
  24384. case "CODE":
  24385. return _react["default"].createElement("code", null);
  24386. default:
  24387. return {
  24388. start: "",
  24389. end: ""
  24390. };
  24391. }
  24392. }
  24393. });
  24394. _commonjsHelpers.unwrapExports(defaultInlineHTML_1);
  24395. var blockInlineStyles = _commonjsHelpers.createCommonjsModule(function(
  24396. module,
  24397. exports
  24398. ) {
  24399. Object.defineProperty(exports, "__esModule", {
  24400. value: true
  24401. });
  24402. exports["default"] = void 0;
  24403. var _toConsumableArray2 = interopRequireDefault(toConsumableArray);
  24404. var _invariant = interopRequireDefault(browser);
  24405. var _styleObjectFunction = interopRequireDefault(styleObjectFunction);
  24406. var _accumulateFunction = interopRequireDefault(accumulateFunction);
  24407. var _getElementHTML = interopRequireDefault(getElementHTML_1);
  24408. var _rangeSort = interopRequireDefault(rangeSort);
  24409. var _defaultInlineHTML = interopRequireDefault(defaultInlineHTML_1);
  24410. var subtractStyles = function subtractStyles(original, toRemove) {
  24411. return original.filter(function(el) {
  24412. return !toRemove.some(function(elToRemove) {
  24413. return elToRemove.style === el.style;
  24414. });
  24415. });
  24416. };
  24417. var popEndingStyles = function popEndingStyles(styleStack, endingStyles) {
  24418. return endingStyles.reduceRight(function(stack, style) {
  24419. var styleToRemove = stack[stack.length - 1];
  24420. (0,
  24421. _invariant[
  24422. "default"
  24423. ])(styleToRemove.style === style.style, "Style ".concat(styleToRemove.style, " to be removed doesn't match expected ").concat(style.style));
  24424. return stack.slice(0, -1);
  24425. }, styleStack);
  24426. };
  24427. var characterStyles = function characterStyles(offset, ranges) {
  24428. return ranges.filter(function(range) {
  24429. return offset >= range.offset && offset < range.offset + range.length;
  24430. });
  24431. };
  24432. var rangeIsSubset = function rangeIsSubset(firstRange, secondRange) {
  24433. // returns true if the second range is a subset of the first
  24434. var secondStartWithinFirst = firstRange.offset <= secondRange.offset;
  24435. var secondEndWithinFirst =
  24436. firstRange.offset + firstRange.length >=
  24437. secondRange.offset + secondRange.length;
  24438. return secondStartWithinFirst && secondEndWithinFirst;
  24439. };
  24440. var latestStyleLast = function latestStyleLast(s1, s2) {
  24441. // make sure longer-lasting styles are added first
  24442. var s2endIndex = s2.offset + s2.length;
  24443. var s1endIndex = s1.offset + s1.length;
  24444. return s2endIndex - s1endIndex;
  24445. };
  24446. var getStylesToReset = function getStylesToReset(remainingStyles, newStyles) {
  24447. var i = 0;
  24448. while (i < remainingStyles.length) {
  24449. if (newStyles.every(rangeIsSubset.bind(null, remainingStyles[i]))) {
  24450. i++;
  24451. } else {
  24452. return remainingStyles.slice(i);
  24453. }
  24454. }
  24455. return [];
  24456. };
  24457. var appendStartMarkup = function appendStartMarkup(
  24458. inlineHTML,
  24459. string,
  24460. styleRange
  24461. ) {
  24462. return (
  24463. string +
  24464. (0, _getElementHTML["default"])(inlineHTML(styleRange.style)).start
  24465. );
  24466. };
  24467. var prependEndMarkup = function prependEndMarkup(
  24468. inlineHTML,
  24469. string,
  24470. styleRange
  24471. ) {
  24472. return (
  24473. (0, _getElementHTML["default"])(inlineHTML(styleRange.style)).end + string
  24474. );
  24475. };
  24476. var defaultCustomInlineHTML = function defaultCustomInlineHTML(next) {
  24477. return function(style) {
  24478. return next(style);
  24479. };
  24480. };
  24481. defaultCustomInlineHTML.__isMiddleware = true;
  24482. var _default = function _default(rawBlock) {
  24483. var customInlineHTML =
  24484. arguments.length > 1 && arguments[1] !== undefined
  24485. ? arguments[1]
  24486. : defaultCustomInlineHTML;
  24487. (0, _invariant["default"])(
  24488. rawBlock !== null && rawBlock !== undefined,
  24489. "Expected raw block to be non-null"
  24490. );
  24491. var inlineHTML;
  24492. if (customInlineHTML.__isMiddleware === true) {
  24493. inlineHTML = customInlineHTML(_defaultInlineHTML["default"]);
  24494. } else {
  24495. inlineHTML = (0, _accumulateFunction["default"])(
  24496. (0, _styleObjectFunction["default"])(customInlineHTML),
  24497. (0, _styleObjectFunction["default"])(_defaultInlineHTML["default"])
  24498. );
  24499. }
  24500. var result = "";
  24501. var styleStack = [];
  24502. var sortedRanges = rawBlock.inlineStyleRanges.sort(_rangeSort["default"]);
  24503. var originalTextArray = (0, _toConsumableArray2["default"])(rawBlock.text);
  24504. for (var i = 0; i < originalTextArray.length; i++) {
  24505. var styles = characterStyles(i, sortedRanges);
  24506. var endingStyles = subtractStyles(styleStack, styles);
  24507. var newStyles = subtractStyles(styles, styleStack);
  24508. var remainingStyles = subtractStyles(styleStack, endingStyles); // reset styles: look for any already existing styles that will need to
  24509. // end before styles that are being added on this character. to solve this
  24510. // close out those current tags and all nested children,
  24511. // then open new ones nested within the new styles.
  24512. var resetStyles = getStylesToReset(remainingStyles, newStyles);
  24513. var openingStyles = resetStyles.concat(newStyles).sort(latestStyleLast);
  24514. var openingStyleTags = openingStyles.reduce(
  24515. appendStartMarkup.bind(null, inlineHTML),
  24516. ""
  24517. );
  24518. var endingStyleTags = endingStyles
  24519. .concat(resetStyles)
  24520. .reduce(prependEndMarkup.bind(null, inlineHTML), "");
  24521. result += endingStyleTags + openingStyleTags + originalTextArray[i];
  24522. styleStack = popEndingStyles(
  24523. styleStack,
  24524. resetStyles.concat(endingStyles)
  24525. );
  24526. styleStack = styleStack.concat(openingStyles);
  24527. (0, _invariant["default"])(
  24528. styleStack.length === styles.length,
  24529. "Character "
  24530. .concat(i, ": ")
  24531. .concat(
  24532. styleStack.length - styles.length,
  24533. " styles left on stack that should no longer be there"
  24534. )
  24535. );
  24536. }
  24537. result = styleStack.reduceRight(function(res, openStyle) {
  24538. return (
  24539. res + (0, _getElementHTML["default"])(inlineHTML(openStyle.style)).end
  24540. );
  24541. }, result);
  24542. return result;
  24543. };
  24544. exports["default"] = _default;
  24545. });
  24546. _commonjsHelpers.unwrapExports(blockInlineStyles);
  24547. var blockTypeObjectFunction = _commonjsHelpers.createCommonjsModule(function(
  24548. module,
  24549. exports
  24550. ) {
  24551. Object.defineProperty(exports, "__esModule", {
  24552. value: true
  24553. });
  24554. exports["default"] = void 0;
  24555. var _default = function _default(typeObject) {
  24556. return function(block) {
  24557. if (typeof typeObject === "function") {
  24558. // handle case where typeObject is already a function
  24559. return typeObject(block);
  24560. }
  24561. return typeObject[block.type];
  24562. };
  24563. };
  24564. exports["default"] = _default;
  24565. });
  24566. _commonjsHelpers.unwrapExports(blockTypeObjectFunction);
  24567. var getBlockTags_1 = _commonjsHelpers.createCommonjsModule(function(
  24568. module,
  24569. exports
  24570. ) {
  24571. Object.defineProperty(exports, "__esModule", {
  24572. value: true
  24573. });
  24574. exports["default"] = getBlockTags;
  24575. var _invariant = interopRequireDefault(browser);
  24576. var _react = interopRequireDefault(React__default);
  24577. var _server = interopRequireDefault(server);
  24578. var _splitReactElement = interopRequireDefault(splitReactElement_1);
  24579. function hasChildren(element) {
  24580. return (
  24581. _react["default"].isValidElement(element) &&
  24582. _react["default"].Children.count(element.props.children) > 0
  24583. );
  24584. }
  24585. function getBlockTags(blockHTML) {
  24586. (0, _invariant["default"])(
  24587. blockHTML !== null && blockHTML !== undefined,
  24588. "Expected block HTML value to be non-null"
  24589. );
  24590. if (typeof blockHTML === "string") {
  24591. return blockHTML;
  24592. }
  24593. if (_react["default"].isValidElement(blockHTML)) {
  24594. if (hasChildren(blockHTML)) {
  24595. return _server["default"].renderToStaticMarkup(blockHTML);
  24596. }
  24597. return (0, _splitReactElement["default"])(blockHTML);
  24598. }
  24599. if (
  24600. Object.prototype.hasOwnProperty.call(blockHTML, "element") &&
  24601. _react["default"].isValidElement(blockHTML.element)
  24602. ) {
  24603. return Object.assign(
  24604. {},
  24605. blockHTML,
  24606. (0, _splitReactElement["default"])(blockHTML.element)
  24607. );
  24608. }
  24609. (0, _invariant["default"])(
  24610. Object.prototype.hasOwnProperty.call(blockHTML, "start") &&
  24611. Object.prototype.hasOwnProperty.call(blockHTML, "end"),
  24612. "convertToHTML: received block information without either a ReactElement or an object with start/end tags"
  24613. );
  24614. return blockHTML;
  24615. }
  24616. });
  24617. _commonjsHelpers.unwrapExports(getBlockTags_1);
  24618. var getNestedBlockTags_1 = _commonjsHelpers.createCommonjsModule(function(
  24619. module,
  24620. exports
  24621. ) {
  24622. Object.defineProperty(exports, "__esModule", {
  24623. value: true
  24624. });
  24625. exports["default"] = getNestedBlockTags;
  24626. var _invariant = interopRequireDefault(browser);
  24627. var _react = interopRequireDefault(React__default);
  24628. var _splitReactElement2 = interopRequireDefault(splitReactElement_1);
  24629. function getNestedBlockTags(blockHTML) {
  24630. (0, _invariant["default"])(
  24631. blockHTML !== null && blockHTML !== undefined,
  24632. "Expected block HTML value to be non-null"
  24633. );
  24634. if (_react["default"].isValidElement(blockHTML.nest)) {
  24635. var _splitReactElement = (0, _splitReactElement2["default"])(
  24636. blockHTML.nest
  24637. ),
  24638. start = _splitReactElement.start,
  24639. end = _splitReactElement.end;
  24640. return Object.assign({}, blockHTML, {
  24641. nestStart: start,
  24642. nestEnd: end
  24643. });
  24644. }
  24645. (0, _invariant["default"])(
  24646. Object.prototype.hasOwnProperty.call(blockHTML, "nestStart") &&
  24647. Object.prototype.hasOwnProperty.call(blockHTML, "nestEnd"),
  24648. "convertToHTML: received block information without either a ReactElement or an object with start/end tags"
  24649. );
  24650. return blockHTML;
  24651. }
  24652. });
  24653. _commonjsHelpers.unwrapExports(getNestedBlockTags_1);
  24654. var defaultBlockHTML = _commonjsHelpers.createCommonjsModule(function(
  24655. module,
  24656. exports
  24657. ) {
  24658. Object.defineProperty(exports, "__esModule", {
  24659. value: true
  24660. });
  24661. exports["default"] = void 0;
  24662. var _react = interopRequireDefault(React__default);
  24663. var _default = {
  24664. unstyled: _react["default"].createElement("p", null),
  24665. paragraph: _react["default"].createElement("p", null),
  24666. "header-one": _react["default"].createElement("h1", null),
  24667. "header-two": _react["default"].createElement("h2", null),
  24668. "header-three": _react["default"].createElement("h3", null),
  24669. "header-four": _react["default"].createElement("h4", null),
  24670. "header-five": _react["default"].createElement("h5", null),
  24671. "header-six": _react["default"].createElement("h6", null),
  24672. blockquote: _react["default"].createElement("blockquote", null),
  24673. "unordered-list-item": {
  24674. element: _react["default"].createElement("li", null),
  24675. nest: _react["default"].createElement("ul", null)
  24676. },
  24677. "ordered-list-item": {
  24678. element: _react["default"].createElement("li", null),
  24679. nest: _react["default"].createElement("ol", null)
  24680. },
  24681. media: _react["default"].createElement("figure", null),
  24682. atomic: _react["default"].createElement("figure", null)
  24683. };
  24684. exports["default"] = _default;
  24685. });
  24686. _commonjsHelpers.unwrapExports(defaultBlockHTML);
  24687. var convertToHTML_1 = _commonjsHelpers.createCommonjsModule(function(
  24688. module,
  24689. exports
  24690. ) {
  24691. Object.defineProperty(exports, "__esModule", {
  24692. value: true
  24693. });
  24694. exports["default"] = void 0;
  24695. var _invariant = interopRequireDefault(browser);
  24696. var _react = interopRequireDefault(React__default);
  24697. var _server = interopRequireDefault(server);
  24698. var _encodeBlock = interopRequireDefault(encodeBlock);
  24699. var _blockEntities = interopRequireDefault(blockEntities);
  24700. var _blockInlineStyles = interopRequireDefault(blockInlineStyles);
  24701. var _accumulateFunction = interopRequireDefault(accumulateFunction);
  24702. var _blockTypeObjectFunction = interopRequireDefault(blockTypeObjectFunction);
  24703. var _getBlockTags = interopRequireDefault(getBlockTags_1);
  24704. var _getNestedBlockTags = interopRequireDefault(getNestedBlockTags_1);
  24705. var _defaultBlockHTML = interopRequireDefault(defaultBlockHTML);
  24706. // import Immutable from 'immutable'; // eslint-disable-line no-unused-vars
  24707. var defaultEntityToHTML = function defaultEntityToHTML(entity, originalText) {
  24708. return originalText;
  24709. };
  24710. var convertToHTML = function convertToHTML(_ref) {
  24711. var _ref$styleToHTML = _ref.styleToHTML,
  24712. styleToHTML = _ref$styleToHTML === void 0 ? {} : _ref$styleToHTML,
  24713. _ref$blockToHTML = _ref.blockToHTML,
  24714. blockToHTML = _ref$blockToHTML === void 0 ? {} : _ref$blockToHTML,
  24715. _ref$entityToHTML = _ref.entityToHTML,
  24716. entityToHTML =
  24717. _ref$entityToHTML === void 0 ? defaultEntityToHTML : _ref$entityToHTML;
  24718. return function(contentState) {
  24719. (0, _invariant["default"])(
  24720. contentState !== null && contentState !== undefined,
  24721. "Expected contentState to be non-null"
  24722. );
  24723. var getBlockHTML;
  24724. if (blockToHTML.__isMiddleware === true) {
  24725. getBlockHTML = blockToHTML(
  24726. (0, _blockTypeObjectFunction["default"])(_defaultBlockHTML["default"])
  24727. );
  24728. } else {
  24729. getBlockHTML = (0, _accumulateFunction["default"])(
  24730. (0, _blockTypeObjectFunction["default"])(blockToHTML),
  24731. (0, _blockTypeObjectFunction["default"])(_defaultBlockHTML["default"])
  24732. );
  24733. }
  24734. var rawState = (0, Draft.convertToRaw)(contentState);
  24735. var listStack = [];
  24736. var result = rawState.blocks
  24737. .map(function(block) {
  24738. var type = block.type,
  24739. depth = block.depth;
  24740. var closeNestTags = "";
  24741. var openNestTags = "";
  24742. var blockHTMLResult = getBlockHTML(block);
  24743. if (!blockHTMLResult) {
  24744. throw new Error(
  24745. "convertToHTML: missing HTML definition for block with type ".concat(
  24746. block.type
  24747. )
  24748. );
  24749. }
  24750. if (!blockHTMLResult.nest) {
  24751. // this block can't be nested, so reset all nesting if necessary
  24752. closeNestTags = listStack.reduceRight(function(
  24753. string,
  24754. nestedBlock
  24755. ) {
  24756. return (
  24757. string +
  24758. (0, _getNestedBlockTags["default"])(getBlockHTML(nestedBlock))
  24759. .nestEnd
  24760. );
  24761. },
  24762. "");
  24763. listStack = [];
  24764. } else {
  24765. while (
  24766. depth + 1 !== listStack.length ||
  24767. type !== listStack[depth].type
  24768. ) {
  24769. if (depth + 1 === listStack.length) {
  24770. // depth is right but doesn't match type
  24771. var blockToClose = listStack[depth];
  24772. closeNestTags += (0, _getNestedBlockTags["default"])(
  24773. getBlockHTML(blockToClose)
  24774. ).nestEnd;
  24775. openNestTags += (0, _getNestedBlockTags["default"])(
  24776. getBlockHTML(block)
  24777. ).nestStart;
  24778. listStack[depth] = block;
  24779. } else if (depth + 1 < listStack.length) {
  24780. var _blockToClose = listStack[listStack.length - 1];
  24781. closeNestTags += (0, _getNestedBlockTags["default"])(
  24782. getBlockHTML(_blockToClose)
  24783. ).nestEnd;
  24784. listStack = listStack.slice(0, -1);
  24785. } else {
  24786. openNestTags += (0, _getNestedBlockTags["default"])(
  24787. getBlockHTML(block)
  24788. ).nestStart;
  24789. listStack.push(block);
  24790. }
  24791. }
  24792. }
  24793. var innerHTML = (0, _blockInlineStyles["default"])(
  24794. (0, _blockEntities["default"])(
  24795. (0, _encodeBlock["default"])(block),
  24796. rawState.entityMap,
  24797. entityToHTML
  24798. ),
  24799. styleToHTML
  24800. );
  24801. var blockHTML = (0, _getBlockTags["default"])(getBlockHTML(block));
  24802. var html;
  24803. if (typeof blockHTML === "string") {
  24804. html = blockHTML;
  24805. } else {
  24806. html = blockHTML.start + innerHTML + blockHTML.end;
  24807. }
  24808. if (
  24809. innerHTML.length === 0 &&
  24810. Object.prototype.hasOwnProperty.call(blockHTML, "empty")
  24811. ) {
  24812. if (_react["default"].isValidElement(blockHTML.empty)) {
  24813. html = _server["default"].renderToStaticMarkup(blockHTML.empty);
  24814. } else {
  24815. html = blockHTML.empty;
  24816. }
  24817. }
  24818. return closeNestTags + openNestTags + html;
  24819. })
  24820. .join("");
  24821. result = listStack.reduce(function(res, nestBlock) {
  24822. return (
  24823. res +
  24824. (0, _getNestedBlockTags["default"])(getBlockHTML(nestBlock)).nestEnd
  24825. );
  24826. }, result);
  24827. return result;
  24828. };
  24829. };
  24830. var _default = function _default() {
  24831. for (
  24832. var _len = arguments.length, args = new Array(_len), _key = 0;
  24833. _key < _len;
  24834. _key++
  24835. ) {
  24836. args[_key] = arguments[_key];
  24837. }
  24838. if (
  24839. args.length === 1 &&
  24840. Object.prototype.hasOwnProperty.call(args[0], "_map") &&
  24841. args[0].getBlockMap != null
  24842. ) {
  24843. // skip higher-order function and use defaults
  24844. return convertToHTML({}).apply(void 0, args);
  24845. }
  24846. return convertToHTML.apply(void 0, args);
  24847. };
  24848. exports["default"] = _default;
  24849. });
  24850. _commonjsHelpers.unwrapExports(convertToHTML_1);
  24851. var immutable$2 = _commonjsHelpers.createCommonjsModule(function(
  24852. module,
  24853. exports
  24854. ) {
  24855. /**
  24856. * Copyright (c) 2014-2015, Facebook, Inc.
  24857. * All rights reserved.
  24858. *
  24859. * This source code is licensed under the BSD-style license found in the
  24860. * LICENSE file in the root directory of this source tree. An additional grant
  24861. * of patent rights can be found in the PATENTS file in the same directory.
  24862. */
  24863. (function(global, factory) {
  24864. module.exports = factory();
  24865. })(_commonjsHelpers.commonjsGlobal, function() {
  24866. var SLICE$0 = Array.prototype.slice;
  24867. function createClass(ctor, superClass) {
  24868. if (superClass) {
  24869. ctor.prototype = Object.create(superClass.prototype);
  24870. }
  24871. ctor.prototype.constructor = ctor;
  24872. }
  24873. function Iterable(value) {
  24874. return isIterable(value) ? value : Seq(value);
  24875. }
  24876. createClass(KeyedIterable, Iterable);
  24877. function KeyedIterable(value) {
  24878. return isKeyed(value) ? value : KeyedSeq(value);
  24879. }
  24880. createClass(IndexedIterable, Iterable);
  24881. function IndexedIterable(value) {
  24882. return isIndexed(value) ? value : IndexedSeq(value);
  24883. }
  24884. createClass(SetIterable, Iterable);
  24885. function SetIterable(value) {
  24886. return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
  24887. }
  24888. function isIterable(maybeIterable) {
  24889. return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
  24890. }
  24891. function isKeyed(maybeKeyed) {
  24892. return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
  24893. }
  24894. function isIndexed(maybeIndexed) {
  24895. return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
  24896. }
  24897. function isAssociative(maybeAssociative) {
  24898. return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
  24899. }
  24900. function isOrdered(maybeOrdered) {
  24901. return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
  24902. }
  24903. Iterable.isIterable = isIterable;
  24904. Iterable.isKeyed = isKeyed;
  24905. Iterable.isIndexed = isIndexed;
  24906. Iterable.isAssociative = isAssociative;
  24907. Iterable.isOrdered = isOrdered;
  24908. Iterable.Keyed = KeyedIterable;
  24909. Iterable.Indexed = IndexedIterable;
  24910. Iterable.Set = SetIterable;
  24911. var IS_ITERABLE_SENTINEL = "@@__IMMUTABLE_ITERABLE__@@";
  24912. var IS_KEYED_SENTINEL = "@@__IMMUTABLE_KEYED__@@";
  24913. var IS_INDEXED_SENTINEL = "@@__IMMUTABLE_INDEXED__@@";
  24914. var IS_ORDERED_SENTINEL = "@@__IMMUTABLE_ORDERED__@@";
  24915. // Used for setting prototype methods that IE8 chokes on.
  24916. var DELETE = "delete";
  24917. // Constants describing the size of trie nodes.
  24918. var SHIFT = 5; // Resulted in best performance after ______?
  24919. var SIZE = 1 << SHIFT;
  24920. var MASK = SIZE - 1;
  24921. // A consistent shared value representing "not set" which equals nothing other
  24922. // than itself, and nothing that could be provided externally.
  24923. var NOT_SET = {};
  24924. // Boolean references, Rough equivalent of `bool &`.
  24925. var CHANGE_LENGTH = { value: false };
  24926. var DID_ALTER = { value: false };
  24927. function MakeRef(ref) {
  24928. ref.value = false;
  24929. return ref;
  24930. }
  24931. function SetRef(ref) {
  24932. ref && (ref.value = true);
  24933. }
  24934. // A function which returns a value representing an "owner" for transient writes
  24935. // to tries. The return value will only ever equal itself, and will not equal
  24936. // the return of any subsequent call of this function.
  24937. function OwnerID() {}
  24938. // http://jsperf.com/copy-array-inline
  24939. function arrCopy(arr, offset) {
  24940. offset = offset || 0;
  24941. var len = Math.max(0, arr.length - offset);
  24942. var newArr = new Array(len);
  24943. for (var ii = 0; ii < len; ii++) {
  24944. newArr[ii] = arr[ii + offset];
  24945. }
  24946. return newArr;
  24947. }
  24948. function ensureSize(iter) {
  24949. if (iter.size === undefined) {
  24950. iter.size = iter.__iterate(returnTrue);
  24951. }
  24952. return iter.size;
  24953. }
  24954. function wrapIndex(iter, index) {
  24955. // This implements "is array index" which the ECMAString spec defines as:
  24956. //
  24957. // A String property name P is an array index if and only if
  24958. // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
  24959. // to 2^32−1.
  24960. //
  24961. // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
  24962. if (typeof index !== "number") {
  24963. var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
  24964. if ("" + uint32Index !== index || uint32Index === 4294967295) {
  24965. return NaN;
  24966. }
  24967. index = uint32Index;
  24968. }
  24969. return index < 0 ? ensureSize(iter) + index : index;
  24970. }
  24971. function returnTrue() {
  24972. return true;
  24973. }
  24974. function wholeSlice(begin, end, size) {
  24975. return (
  24976. (begin === 0 || (size !== undefined && begin <= -size)) &&
  24977. (end === undefined || (size !== undefined && end >= size))
  24978. );
  24979. }
  24980. function resolveBegin(begin, size) {
  24981. return resolveIndex(begin, size, 0);
  24982. }
  24983. function resolveEnd(end, size) {
  24984. return resolveIndex(end, size, size);
  24985. }
  24986. function resolveIndex(index, size, defaultIndex) {
  24987. return index === undefined
  24988. ? defaultIndex
  24989. : index < 0
  24990. ? Math.max(0, size + index)
  24991. : size === undefined
  24992. ? index
  24993. : Math.min(size, index);
  24994. }
  24995. /* global Symbol */
  24996. var ITERATE_KEYS = 0;
  24997. var ITERATE_VALUES = 1;
  24998. var ITERATE_ENTRIES = 2;
  24999. var REAL_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
  25000. var FAUX_ITERATOR_SYMBOL = "@@iterator";
  25001. var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
  25002. function Iterator(next) {
  25003. this.next = next;
  25004. }
  25005. Iterator.prototype.toString = function() {
  25006. return "[Iterator]";
  25007. };
  25008. Iterator.KEYS = ITERATE_KEYS;
  25009. Iterator.VALUES = ITERATE_VALUES;
  25010. Iterator.ENTRIES = ITERATE_ENTRIES;
  25011. Iterator.prototype.inspect = Iterator.prototype.toSource = function() {
  25012. return this.toString();
  25013. };
  25014. Iterator.prototype[ITERATOR_SYMBOL] = function() {
  25015. return this;
  25016. };
  25017. function iteratorValue(type, k, v, iteratorResult) {
  25018. var value = type === 0 ? k : type === 1 ? v : [k, v];
  25019. iteratorResult
  25020. ? (iteratorResult.value = value)
  25021. : (iteratorResult = {
  25022. value: value,
  25023. done: false
  25024. });
  25025. return iteratorResult;
  25026. }
  25027. function iteratorDone() {
  25028. return { value: undefined, done: true };
  25029. }
  25030. function hasIterator(maybeIterable) {
  25031. return !!getIteratorFn(maybeIterable);
  25032. }
  25033. function isIterator(maybeIterator) {
  25034. return maybeIterator && typeof maybeIterator.next === "function";
  25035. }
  25036. function getIterator(iterable) {
  25037. var iteratorFn = getIteratorFn(iterable);
  25038. return iteratorFn && iteratorFn.call(iterable);
  25039. }
  25040. function getIteratorFn(iterable) {
  25041. var iteratorFn =
  25042. iterable &&
  25043. ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
  25044. iterable[FAUX_ITERATOR_SYMBOL]);
  25045. if (typeof iteratorFn === "function") {
  25046. return iteratorFn;
  25047. }
  25048. }
  25049. function isArrayLike(value) {
  25050. return value && typeof value.length === "number";
  25051. }
  25052. createClass(Seq, Iterable);
  25053. function Seq(value) {
  25054. return value === null || value === undefined
  25055. ? emptySequence()
  25056. : isIterable(value)
  25057. ? value.toSeq()
  25058. : seqFromValue(value);
  25059. }
  25060. Seq.of = function(/*...values*/) {
  25061. return Seq(arguments);
  25062. };
  25063. Seq.prototype.toSeq = function() {
  25064. return this;
  25065. };
  25066. Seq.prototype.toString = function() {
  25067. return this.__toString("Seq {", "}");
  25068. };
  25069. Seq.prototype.cacheResult = function() {
  25070. if (!this._cache && this.__iterateUncached) {
  25071. this._cache = this.entrySeq().toArray();
  25072. this.size = this._cache.length;
  25073. }
  25074. return this;
  25075. };
  25076. // abstract __iterateUncached(fn, reverse)
  25077. Seq.prototype.__iterate = function(fn, reverse) {
  25078. return seqIterate(this, fn, reverse, true);
  25079. };
  25080. // abstract __iteratorUncached(type, reverse)
  25081. Seq.prototype.__iterator = function(type, reverse) {
  25082. return seqIterator(this, type, reverse, true);
  25083. };
  25084. createClass(KeyedSeq, Seq);
  25085. function KeyedSeq(value) {
  25086. return value === null || value === undefined
  25087. ? emptySequence().toKeyedSeq()
  25088. : isIterable(value)
  25089. ? isKeyed(value)
  25090. ? value.toSeq()
  25091. : value.fromEntrySeq()
  25092. : keyedSeqFromValue(value);
  25093. }
  25094. KeyedSeq.prototype.toKeyedSeq = function() {
  25095. return this;
  25096. };
  25097. createClass(IndexedSeq, Seq);
  25098. function IndexedSeq(value) {
  25099. return value === null || value === undefined
  25100. ? emptySequence()
  25101. : !isIterable(value)
  25102. ? indexedSeqFromValue(value)
  25103. : isKeyed(value)
  25104. ? value.entrySeq()
  25105. : value.toIndexedSeq();
  25106. }
  25107. IndexedSeq.of = function(/*...values*/) {
  25108. return IndexedSeq(arguments);
  25109. };
  25110. IndexedSeq.prototype.toIndexedSeq = function() {
  25111. return this;
  25112. };
  25113. IndexedSeq.prototype.toString = function() {
  25114. return this.__toString("Seq [", "]");
  25115. };
  25116. IndexedSeq.prototype.__iterate = function(fn, reverse) {
  25117. return seqIterate(this, fn, reverse, false);
  25118. };
  25119. IndexedSeq.prototype.__iterator = function(type, reverse) {
  25120. return seqIterator(this, type, reverse, false);
  25121. };
  25122. createClass(SetSeq, Seq);
  25123. function SetSeq(value) {
  25124. return (value === null || value === undefined
  25125. ? emptySequence()
  25126. : !isIterable(value)
  25127. ? indexedSeqFromValue(value)
  25128. : isKeyed(value)
  25129. ? value.entrySeq()
  25130. : value
  25131. ).toSetSeq();
  25132. }
  25133. SetSeq.of = function(/*...values*/) {
  25134. return SetSeq(arguments);
  25135. };
  25136. SetSeq.prototype.toSetSeq = function() {
  25137. return this;
  25138. };
  25139. Seq.isSeq = isSeq;
  25140. Seq.Keyed = KeyedSeq;
  25141. Seq.Set = SetSeq;
  25142. Seq.Indexed = IndexedSeq;
  25143. var IS_SEQ_SENTINEL = "@@__IMMUTABLE_SEQ__@@";
  25144. Seq.prototype[IS_SEQ_SENTINEL] = true;
  25145. createClass(ArraySeq, IndexedSeq);
  25146. function ArraySeq(array) {
  25147. this._array = array;
  25148. this.size = array.length;
  25149. }
  25150. ArraySeq.prototype.get = function(index, notSetValue) {
  25151. return this.has(index)
  25152. ? this._array[wrapIndex(this, index)]
  25153. : notSetValue;
  25154. };
  25155. ArraySeq.prototype.__iterate = function(fn, reverse) {
  25156. var array = this._array;
  25157. var maxIndex = array.length - 1;
  25158. for (var ii = 0; ii <= maxIndex; ii++) {
  25159. if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
  25160. return ii + 1;
  25161. }
  25162. }
  25163. return ii;
  25164. };
  25165. ArraySeq.prototype.__iterator = function(type, reverse) {
  25166. var array = this._array;
  25167. var maxIndex = array.length - 1;
  25168. var ii = 0;
  25169. return new Iterator(function() {
  25170. return ii > maxIndex
  25171. ? iteratorDone()
  25172. : iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++]);
  25173. });
  25174. };
  25175. createClass(ObjectSeq, KeyedSeq);
  25176. function ObjectSeq(object) {
  25177. var keys = Object.keys(object);
  25178. this._object = object;
  25179. this._keys = keys;
  25180. this.size = keys.length;
  25181. }
  25182. ObjectSeq.prototype.get = function(key, notSetValue) {
  25183. if (notSetValue !== undefined && !this.has(key)) {
  25184. return notSetValue;
  25185. }
  25186. return this._object[key];
  25187. };
  25188. ObjectSeq.prototype.has = function(key) {
  25189. return this._object.hasOwnProperty(key);
  25190. };
  25191. ObjectSeq.prototype.__iterate = function(fn, reverse) {
  25192. var object = this._object;
  25193. var keys = this._keys;
  25194. var maxIndex = keys.length - 1;
  25195. for (var ii = 0; ii <= maxIndex; ii++) {
  25196. var key = keys[reverse ? maxIndex - ii : ii];
  25197. if (fn(object[key], key, this) === false) {
  25198. return ii + 1;
  25199. }
  25200. }
  25201. return ii;
  25202. };
  25203. ObjectSeq.prototype.__iterator = function(type, reverse) {
  25204. var object = this._object;
  25205. var keys = this._keys;
  25206. var maxIndex = keys.length - 1;
  25207. var ii = 0;
  25208. return new Iterator(function() {
  25209. var key = keys[reverse ? maxIndex - ii : ii];
  25210. return ii++ > maxIndex
  25211. ? iteratorDone()
  25212. : iteratorValue(type, key, object[key]);
  25213. });
  25214. };
  25215. ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
  25216. createClass(IterableSeq, IndexedSeq);
  25217. function IterableSeq(iterable) {
  25218. this._iterable = iterable;
  25219. this.size = iterable.length || iterable.size;
  25220. }
  25221. IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
  25222. if (reverse) {
  25223. return this.cacheResult().__iterate(fn, reverse);
  25224. }
  25225. var iterable = this._iterable;
  25226. var iterator = getIterator(iterable);
  25227. var iterations = 0;
  25228. if (isIterator(iterator)) {
  25229. var step;
  25230. while (!(step = iterator.next()).done) {
  25231. if (fn(step.value, iterations++, this) === false) {
  25232. break;
  25233. }
  25234. }
  25235. }
  25236. return iterations;
  25237. };
  25238. IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
  25239. if (reverse) {
  25240. return this.cacheResult().__iterator(type, reverse);
  25241. }
  25242. var iterable = this._iterable;
  25243. var iterator = getIterator(iterable);
  25244. if (!isIterator(iterator)) {
  25245. return new Iterator(iteratorDone);
  25246. }
  25247. var iterations = 0;
  25248. return new Iterator(function() {
  25249. var step = iterator.next();
  25250. return step.done ? step : iteratorValue(type, iterations++, step.value);
  25251. });
  25252. };
  25253. createClass(IteratorSeq, IndexedSeq);
  25254. function IteratorSeq(iterator) {
  25255. this._iterator = iterator;
  25256. this._iteratorCache = [];
  25257. }
  25258. IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
  25259. if (reverse) {
  25260. return this.cacheResult().__iterate(fn, reverse);
  25261. }
  25262. var iterator = this._iterator;
  25263. var cache = this._iteratorCache;
  25264. var iterations = 0;
  25265. while (iterations < cache.length) {
  25266. if (fn(cache[iterations], iterations++, this) === false) {
  25267. return iterations;
  25268. }
  25269. }
  25270. var step;
  25271. while (!(step = iterator.next()).done) {
  25272. var val = step.value;
  25273. cache[iterations] = val;
  25274. if (fn(val, iterations++, this) === false) {
  25275. break;
  25276. }
  25277. }
  25278. return iterations;
  25279. };
  25280. IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
  25281. if (reverse) {
  25282. return this.cacheResult().__iterator(type, reverse);
  25283. }
  25284. var iterator = this._iterator;
  25285. var cache = this._iteratorCache;
  25286. var iterations = 0;
  25287. return new Iterator(function() {
  25288. if (iterations >= cache.length) {
  25289. var step = iterator.next();
  25290. if (step.done) {
  25291. return step;
  25292. }
  25293. cache[iterations] = step.value;
  25294. }
  25295. return iteratorValue(type, iterations, cache[iterations++]);
  25296. });
  25297. };
  25298. // # pragma Helper functions
  25299. function isSeq(maybeSeq) {
  25300. return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
  25301. }
  25302. var EMPTY_SEQ;
  25303. function emptySequence() {
  25304. return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
  25305. }
  25306. function keyedSeqFromValue(value) {
  25307. var seq = Array.isArray(value)
  25308. ? new ArraySeq(value).fromEntrySeq()
  25309. : isIterator(value)
  25310. ? new IteratorSeq(value).fromEntrySeq()
  25311. : hasIterator(value)
  25312. ? new IterableSeq(value).fromEntrySeq()
  25313. : typeof value === "object"
  25314. ? new ObjectSeq(value)
  25315. : undefined;
  25316. if (!seq) {
  25317. throw new TypeError(
  25318. "Expected Array or iterable object of [k, v] entries, " +
  25319. "or keyed object: " +
  25320. value
  25321. );
  25322. }
  25323. return seq;
  25324. }
  25325. function indexedSeqFromValue(value) {
  25326. var seq = maybeIndexedSeqFromValue(value);
  25327. if (!seq) {
  25328. throw new TypeError(
  25329. "Expected Array or iterable object of values: " + value
  25330. );
  25331. }
  25332. return seq;
  25333. }
  25334. function seqFromValue(value) {
  25335. var seq =
  25336. maybeIndexedSeqFromValue(value) ||
  25337. (typeof value === "object" && new ObjectSeq(value));
  25338. if (!seq) {
  25339. throw new TypeError(
  25340. "Expected Array or iterable object of values, or keyed object: " +
  25341. value
  25342. );
  25343. }
  25344. return seq;
  25345. }
  25346. function maybeIndexedSeqFromValue(value) {
  25347. return isArrayLike(value)
  25348. ? new ArraySeq(value)
  25349. : isIterator(value)
  25350. ? new IteratorSeq(value)
  25351. : hasIterator(value)
  25352. ? new IterableSeq(value)
  25353. : undefined;
  25354. }
  25355. function seqIterate(seq, fn, reverse, useKeys) {
  25356. var cache = seq._cache;
  25357. if (cache) {
  25358. var maxIndex = cache.length - 1;
  25359. for (var ii = 0; ii <= maxIndex; ii++) {
  25360. var entry = cache[reverse ? maxIndex - ii : ii];
  25361. if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
  25362. return ii + 1;
  25363. }
  25364. }
  25365. return ii;
  25366. }
  25367. return seq.__iterateUncached(fn, reverse);
  25368. }
  25369. function seqIterator(seq, type, reverse, useKeys) {
  25370. var cache = seq._cache;
  25371. if (cache) {
  25372. var maxIndex = cache.length - 1;
  25373. var ii = 0;
  25374. return new Iterator(function() {
  25375. var entry = cache[reverse ? maxIndex - ii : ii];
  25376. return ii++ > maxIndex
  25377. ? iteratorDone()
  25378. : iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
  25379. });
  25380. }
  25381. return seq.__iteratorUncached(type, reverse);
  25382. }
  25383. function fromJS(json, converter) {
  25384. return converter
  25385. ? fromJSWith(converter, json, "", { "": json })
  25386. : fromJSDefault(json);
  25387. }
  25388. function fromJSWith(converter, json, key, parentJSON) {
  25389. if (Array.isArray(json)) {
  25390. return converter.call(
  25391. parentJSON,
  25392. key,
  25393. IndexedSeq(json).map(function(v, k) {
  25394. return fromJSWith(converter, v, k, json);
  25395. })
  25396. );
  25397. }
  25398. if (isPlainObj(json)) {
  25399. return converter.call(
  25400. parentJSON,
  25401. key,
  25402. KeyedSeq(json).map(function(v, k) {
  25403. return fromJSWith(converter, v, k, json);
  25404. })
  25405. );
  25406. }
  25407. return json;
  25408. }
  25409. function fromJSDefault(json) {
  25410. if (Array.isArray(json)) {
  25411. return IndexedSeq(json)
  25412. .map(fromJSDefault)
  25413. .toList();
  25414. }
  25415. if (isPlainObj(json)) {
  25416. return KeyedSeq(json)
  25417. .map(fromJSDefault)
  25418. .toMap();
  25419. }
  25420. return json;
  25421. }
  25422. function isPlainObj(value) {
  25423. return (
  25424. value &&
  25425. (value.constructor === Object || value.constructor === undefined)
  25426. );
  25427. }
  25428. /**
  25429. * An extension of the "same-value" algorithm as [described for use by ES6 Map
  25430. * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
  25431. *
  25432. * NaN is considered the same as NaN, however -0 and 0 are considered the same
  25433. * value, which is different from the algorithm described by
  25434. * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
  25435. *
  25436. * This is extended further to allow Objects to describe the values they
  25437. * represent, by way of `valueOf` or `equals` (and `hashCode`).
  25438. *
  25439. * Note: because of this extension, the key equality of Immutable.Map and the
  25440. * value equality of Immutable.Set will differ from ES6 Map and Set.
  25441. *
  25442. * ### Defining custom values
  25443. *
  25444. * The easiest way to describe the value an object represents is by implementing
  25445. * `valueOf`. For example, `Date` represents a value by returning a unix
  25446. * timestamp for `valueOf`:
  25447. *
  25448. * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
  25449. * var date2 = new Date(1234567890000);
  25450. * date1.valueOf(); // 1234567890000
  25451. * assert( date1 !== date2 );
  25452. * assert( Immutable.is( date1, date2 ) );
  25453. *
  25454. * Note: overriding `valueOf` may have other implications if you use this object
  25455. * where JavaScript expects a primitive, such as implicit string coercion.
  25456. *
  25457. * For more complex types, especially collections, implementing `valueOf` may
  25458. * not be performant. An alternative is to implement `equals` and `hashCode`.
  25459. *
  25460. * `equals` takes another object, presumably of similar type, and returns true
  25461. * if the it is equal. Equality is symmetrical, so the same result should be
  25462. * returned if this and the argument are flipped.
  25463. *
  25464. * assert( a.equals(b) === b.equals(a) );
  25465. *
  25466. * `hashCode` returns a 32bit integer number representing the object which will
  25467. * be used to determine how to store the value object in a Map or Set. You must
  25468. * provide both or neither methods, one must not exist without the other.
  25469. *
  25470. * Also, an important relationship between these methods must be upheld: if two
  25471. * values are equal, they *must* return the same hashCode. If the values are not
  25472. * equal, they might have the same hashCode; this is called a hash collision,
  25473. * and while undesirable for performance reasons, it is acceptable.
  25474. *
  25475. * if (a.equals(b)) {
  25476. * assert( a.hashCode() === b.hashCode() );
  25477. * }
  25478. *
  25479. * All Immutable collections implement `equals` and `hashCode`.
  25480. *
  25481. */
  25482. function is(valueA, valueB) {
  25483. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  25484. return true;
  25485. }
  25486. if (!valueA || !valueB) {
  25487. return false;
  25488. }
  25489. if (
  25490. typeof valueA.valueOf === "function" &&
  25491. typeof valueB.valueOf === "function"
  25492. ) {
  25493. valueA = valueA.valueOf();
  25494. valueB = valueB.valueOf();
  25495. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  25496. return true;
  25497. }
  25498. if (!valueA || !valueB) {
  25499. return false;
  25500. }
  25501. }
  25502. if (
  25503. typeof valueA.equals === "function" &&
  25504. typeof valueB.equals === "function" &&
  25505. valueA.equals(valueB)
  25506. ) {
  25507. return true;
  25508. }
  25509. return false;
  25510. }
  25511. function deepEqual(a, b) {
  25512. if (a === b) {
  25513. return true;
  25514. }
  25515. if (
  25516. !isIterable(b) ||
  25517. (a.size !== undefined && b.size !== undefined && a.size !== b.size) ||
  25518. (a.__hash !== undefined &&
  25519. b.__hash !== undefined &&
  25520. a.__hash !== b.__hash) ||
  25521. isKeyed(a) !== isKeyed(b) ||
  25522. isIndexed(a) !== isIndexed(b) ||
  25523. isOrdered(a) !== isOrdered(b)
  25524. ) {
  25525. return false;
  25526. }
  25527. if (a.size === 0 && b.size === 0) {
  25528. return true;
  25529. }
  25530. var notAssociative = !isAssociative(a);
  25531. if (isOrdered(a)) {
  25532. var entries = a.entries();
  25533. return (
  25534. b.every(function(v, k) {
  25535. var entry = entries.next().value;
  25536. return (
  25537. entry && is(entry[1], v) && (notAssociative || is(entry[0], k))
  25538. );
  25539. }) && entries.next().done
  25540. );
  25541. }
  25542. var flipped = false;
  25543. if (a.size === undefined) {
  25544. if (b.size === undefined) {
  25545. if (typeof a.cacheResult === "function") {
  25546. a.cacheResult();
  25547. }
  25548. } else {
  25549. flipped = true;
  25550. var _ = a;
  25551. a = b;
  25552. b = _;
  25553. }
  25554. }
  25555. var allEqual = true;
  25556. var bSize = b.__iterate(function(v, k) {
  25557. if (
  25558. notAssociative
  25559. ? !a.has(v)
  25560. : flipped
  25561. ? !is(v, a.get(k, NOT_SET))
  25562. : !is(a.get(k, NOT_SET), v)
  25563. ) {
  25564. allEqual = false;
  25565. return false;
  25566. }
  25567. });
  25568. return allEqual && a.size === bSize;
  25569. }
  25570. createClass(Repeat, IndexedSeq);
  25571. function Repeat(value, times) {
  25572. if (!(this instanceof Repeat)) {
  25573. return new Repeat(value, times);
  25574. }
  25575. this._value = value;
  25576. this.size = times === undefined ? Infinity : Math.max(0, times);
  25577. if (this.size === 0) {
  25578. if (EMPTY_REPEAT) {
  25579. return EMPTY_REPEAT;
  25580. }
  25581. EMPTY_REPEAT = this;
  25582. }
  25583. }
  25584. Repeat.prototype.toString = function() {
  25585. if (this.size === 0) {
  25586. return "Repeat []";
  25587. }
  25588. return "Repeat [ " + this._value + " " + this.size + " times ]";
  25589. };
  25590. Repeat.prototype.get = function(index, notSetValue) {
  25591. return this.has(index) ? this._value : notSetValue;
  25592. };
  25593. Repeat.prototype.includes = function(searchValue) {
  25594. return is(this._value, searchValue);
  25595. };
  25596. Repeat.prototype.slice = function(begin, end) {
  25597. var size = this.size;
  25598. return wholeSlice(begin, end, size)
  25599. ? this
  25600. : new Repeat(
  25601. this._value,
  25602. resolveEnd(end, size) - resolveBegin(begin, size)
  25603. );
  25604. };
  25605. Repeat.prototype.reverse = function() {
  25606. return this;
  25607. };
  25608. Repeat.prototype.indexOf = function(searchValue) {
  25609. if (is(this._value, searchValue)) {
  25610. return 0;
  25611. }
  25612. return -1;
  25613. };
  25614. Repeat.prototype.lastIndexOf = function(searchValue) {
  25615. if (is(this._value, searchValue)) {
  25616. return this.size;
  25617. }
  25618. return -1;
  25619. };
  25620. Repeat.prototype.__iterate = function(fn, reverse) {
  25621. for (var ii = 0; ii < this.size; ii++) {
  25622. if (fn(this._value, ii, this) === false) {
  25623. return ii + 1;
  25624. }
  25625. }
  25626. return ii;
  25627. };
  25628. Repeat.prototype.__iterator = function(type, reverse) {
  25629. var this$0 = this;
  25630. var ii = 0;
  25631. return new Iterator(function() {
  25632. return ii < this$0.size
  25633. ? iteratorValue(type, ii++, this$0._value)
  25634. : iteratorDone();
  25635. });
  25636. };
  25637. Repeat.prototype.equals = function(other) {
  25638. return other instanceof Repeat
  25639. ? is(this._value, other._value)
  25640. : deepEqual(other);
  25641. };
  25642. var EMPTY_REPEAT;
  25643. function invariant(condition, error) {
  25644. if (!condition) throw new Error(error);
  25645. }
  25646. createClass(Range, IndexedSeq);
  25647. function Range(start, end, step) {
  25648. if (!(this instanceof Range)) {
  25649. return new Range(start, end, step);
  25650. }
  25651. invariant(step !== 0, "Cannot step a Range by 0");
  25652. start = start || 0;
  25653. if (end === undefined) {
  25654. end = Infinity;
  25655. }
  25656. step = step === undefined ? 1 : Math.abs(step);
  25657. if (end < start) {
  25658. step = -step;
  25659. }
  25660. this._start = start;
  25661. this._end = end;
  25662. this._step = step;
  25663. this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
  25664. if (this.size === 0) {
  25665. if (EMPTY_RANGE) {
  25666. return EMPTY_RANGE;
  25667. }
  25668. EMPTY_RANGE = this;
  25669. }
  25670. }
  25671. Range.prototype.toString = function() {
  25672. if (this.size === 0) {
  25673. return "Range []";
  25674. }
  25675. return (
  25676. "Range [ " +
  25677. this._start +
  25678. "..." +
  25679. this._end +
  25680. (this._step > 1 ? " by " + this._step : "") +
  25681. " ]"
  25682. );
  25683. };
  25684. Range.prototype.get = function(index, notSetValue) {
  25685. return this.has(index)
  25686. ? this._start + wrapIndex(this, index) * this._step
  25687. : notSetValue;
  25688. };
  25689. Range.prototype.includes = function(searchValue) {
  25690. var possibleIndex = (searchValue - this._start) / this._step;
  25691. return (
  25692. possibleIndex >= 0 &&
  25693. possibleIndex < this.size &&
  25694. possibleIndex === Math.floor(possibleIndex)
  25695. );
  25696. };
  25697. Range.prototype.slice = function(begin, end) {
  25698. if (wholeSlice(begin, end, this.size)) {
  25699. return this;
  25700. }
  25701. begin = resolveBegin(begin, this.size);
  25702. end = resolveEnd(end, this.size);
  25703. if (end <= begin) {
  25704. return new Range(0, 0);
  25705. }
  25706. return new Range(
  25707. this.get(begin, this._end),
  25708. this.get(end, this._end),
  25709. this._step
  25710. );
  25711. };
  25712. Range.prototype.indexOf = function(searchValue) {
  25713. var offsetValue = searchValue - this._start;
  25714. if (offsetValue % this._step === 0) {
  25715. var index = offsetValue / this._step;
  25716. if (index >= 0 && index < this.size) {
  25717. return index;
  25718. }
  25719. }
  25720. return -1;
  25721. };
  25722. Range.prototype.lastIndexOf = function(searchValue) {
  25723. return this.indexOf(searchValue);
  25724. };
  25725. Range.prototype.__iterate = function(fn, reverse) {
  25726. var maxIndex = this.size - 1;
  25727. var step = this._step;
  25728. var value = reverse ? this._start + maxIndex * step : this._start;
  25729. for (var ii = 0; ii <= maxIndex; ii++) {
  25730. if (fn(value, ii, this) === false) {
  25731. return ii + 1;
  25732. }
  25733. value += reverse ? -step : step;
  25734. }
  25735. return ii;
  25736. };
  25737. Range.prototype.__iterator = function(type, reverse) {
  25738. var maxIndex = this.size - 1;
  25739. var step = this._step;
  25740. var value = reverse ? this._start + maxIndex * step : this._start;
  25741. var ii = 0;
  25742. return new Iterator(function() {
  25743. var v = value;
  25744. value += reverse ? -step : step;
  25745. return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
  25746. });
  25747. };
  25748. Range.prototype.equals = function(other) {
  25749. return other instanceof Range
  25750. ? this._start === other._start &&
  25751. this._end === other._end &&
  25752. this._step === other._step
  25753. : deepEqual(this, other);
  25754. };
  25755. var EMPTY_RANGE;
  25756. createClass(Collection, Iterable);
  25757. function Collection() {
  25758. throw TypeError("Abstract");
  25759. }
  25760. createClass(KeyedCollection, Collection);
  25761. function KeyedCollection() {}
  25762. createClass(IndexedCollection, Collection);
  25763. function IndexedCollection() {}
  25764. createClass(SetCollection, Collection);
  25765. function SetCollection() {}
  25766. Collection.Keyed = KeyedCollection;
  25767. Collection.Indexed = IndexedCollection;
  25768. Collection.Set = SetCollection;
  25769. var imul =
  25770. typeof Math.imul === "function" && Math.imul(0xffffffff, 2) === -2
  25771. ? Math.imul
  25772. : function imul(a, b) {
  25773. a = a | 0; // int
  25774. b = b | 0; // int
  25775. var c = a & 0xffff;
  25776. var d = b & 0xffff;
  25777. // Shift by 0 fixes the sign on the high part.
  25778. return (
  25779. (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0
  25780. ); // int
  25781. };
  25782. // v8 has an optimization for storing 31-bit signed numbers.
  25783. // Values which have either 00 or 11 as the high order bits qualify.
  25784. // This function drops the highest order bit in a signed number, maintaining
  25785. // the sign bit.
  25786. function smi(i32) {
  25787. return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff);
  25788. }
  25789. function hash(o) {
  25790. if (o === false || o === null || o === undefined) {
  25791. return 0;
  25792. }
  25793. if (typeof o.valueOf === "function") {
  25794. o = o.valueOf();
  25795. if (o === false || o === null || o === undefined) {
  25796. return 0;
  25797. }
  25798. }
  25799. if (o === true) {
  25800. return 1;
  25801. }
  25802. var type = typeof o;
  25803. if (type === "number") {
  25804. var h = o | 0;
  25805. if (h !== o) {
  25806. h ^= o * 0xffffffff;
  25807. }
  25808. while (o > 0xffffffff) {
  25809. o /= 0xffffffff;
  25810. h ^= o;
  25811. }
  25812. return smi(h);
  25813. }
  25814. if (type === "string") {
  25815. return o.length > STRING_HASH_CACHE_MIN_STRLEN
  25816. ? cachedHashString(o)
  25817. : hashString(o);
  25818. }
  25819. if (typeof o.hashCode === "function") {
  25820. return o.hashCode();
  25821. }
  25822. if (type === "object") {
  25823. return hashJSObj(o);
  25824. }
  25825. if (typeof o.toString === "function") {
  25826. return hashString(o.toString());
  25827. }
  25828. throw new Error("Value type " + type + " cannot be hashed.");
  25829. }
  25830. function cachedHashString(string) {
  25831. var hash = stringHashCache[string];
  25832. if (hash === undefined) {
  25833. hash = hashString(string);
  25834. if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
  25835. STRING_HASH_CACHE_SIZE = 0;
  25836. stringHashCache = {};
  25837. }
  25838. STRING_HASH_CACHE_SIZE++;
  25839. stringHashCache[string] = hash;
  25840. }
  25841. return hash;
  25842. }
  25843. // http://jsperf.com/hashing-strings
  25844. function hashString(string) {
  25845. // This is the hash from JVM
  25846. // The hash code for a string is computed as
  25847. // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  25848. // where s[i] is the ith character of the string and n is the length of
  25849. // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  25850. // (exclusive) by dropping high bits.
  25851. var hash = 0;
  25852. for (var ii = 0; ii < string.length; ii++) {
  25853. hash = (31 * hash + string.charCodeAt(ii)) | 0;
  25854. }
  25855. return smi(hash);
  25856. }
  25857. function hashJSObj(obj) {
  25858. var hash;
  25859. if (usingWeakMap) {
  25860. hash = weakMap.get(obj);
  25861. if (hash !== undefined) {
  25862. return hash;
  25863. }
  25864. }
  25865. hash = obj[UID_HASH_KEY];
  25866. if (hash !== undefined) {
  25867. return hash;
  25868. }
  25869. if (!canDefineProperty) {
  25870. hash =
  25871. obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
  25872. if (hash !== undefined) {
  25873. return hash;
  25874. }
  25875. hash = getIENodeHash(obj);
  25876. if (hash !== undefined) {
  25877. return hash;
  25878. }
  25879. }
  25880. hash = ++objHashUID;
  25881. if (objHashUID & 0x40000000) {
  25882. objHashUID = 0;
  25883. }
  25884. if (usingWeakMap) {
  25885. weakMap.set(obj, hash);
  25886. } else if (isExtensible !== undefined && isExtensible(obj) === false) {
  25887. throw new Error("Non-extensible objects are not allowed as keys.");
  25888. } else if (canDefineProperty) {
  25889. Object.defineProperty(obj, UID_HASH_KEY, {
  25890. enumerable: false,
  25891. configurable: false,
  25892. writable: false,
  25893. value: hash
  25894. });
  25895. } else if (
  25896. obj.propertyIsEnumerable !== undefined &&
  25897. obj.propertyIsEnumerable ===
  25898. obj.constructor.prototype.propertyIsEnumerable
  25899. ) {
  25900. // Since we can't define a non-enumerable property on the object
  25901. // we'll hijack one of the less-used non-enumerable properties to
  25902. // save our hash on it. Since this is a function it will not show up in
  25903. // `JSON.stringify` which is what we want.
  25904. obj.propertyIsEnumerable = function() {
  25905. return this.constructor.prototype.propertyIsEnumerable.apply(
  25906. this,
  25907. arguments
  25908. );
  25909. };
  25910. obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
  25911. } else if (obj.nodeType !== undefined) {
  25912. // At this point we couldn't get the IE `uniqueID` to use as a hash
  25913. // and we couldn't use a non-enumerable property to exploit the
  25914. // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
  25915. // itself.
  25916. obj[UID_HASH_KEY] = hash;
  25917. } else {
  25918. throw new Error("Unable to set a non-enumerable property on object.");
  25919. }
  25920. return hash;
  25921. }
  25922. // Get references to ES5 object methods.
  25923. var isExtensible = Object.isExtensible;
  25924. // True if Object.defineProperty works as expected. IE8 fails this test.
  25925. var canDefineProperty = (function() {
  25926. try {
  25927. Object.defineProperty({}, "@", {});
  25928. return true;
  25929. } catch (e) {
  25930. return false;
  25931. }
  25932. })();
  25933. // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
  25934. // and avoid memory leaks from the IE cloneNode bug.
  25935. function getIENodeHash(node) {
  25936. if (node && node.nodeType > 0) {
  25937. switch (node.nodeType) {
  25938. case 1: // Element
  25939. return node.uniqueID;
  25940. case 9: // Document
  25941. return node.documentElement && node.documentElement.uniqueID;
  25942. }
  25943. }
  25944. }
  25945. // If possible, use a WeakMap.
  25946. var usingWeakMap = typeof WeakMap === "function";
  25947. var weakMap;
  25948. if (usingWeakMap) {
  25949. weakMap = new WeakMap();
  25950. }
  25951. var objHashUID = 0;
  25952. var UID_HASH_KEY = "__immutablehash__";
  25953. if (typeof Symbol === "function") {
  25954. UID_HASH_KEY = Symbol(UID_HASH_KEY);
  25955. }
  25956. var STRING_HASH_CACHE_MIN_STRLEN = 16;
  25957. var STRING_HASH_CACHE_MAX_SIZE = 255;
  25958. var STRING_HASH_CACHE_SIZE = 0;
  25959. var stringHashCache = {};
  25960. function assertNotInfinite(size) {
  25961. invariant(
  25962. size !== Infinity,
  25963. "Cannot perform this action with an infinite size."
  25964. );
  25965. }
  25966. createClass(Map, KeyedCollection);
  25967. // @pragma Construction
  25968. function Map(value) {
  25969. return value === null || value === undefined
  25970. ? emptyMap()
  25971. : isMap(value) && !isOrdered(value)
  25972. ? value
  25973. : emptyMap().withMutations(function(map) {
  25974. var iter = KeyedIterable(value);
  25975. assertNotInfinite(iter.size);
  25976. iter.forEach(function(v, k) {
  25977. return map.set(k, v);
  25978. });
  25979. });
  25980. }
  25981. Map.prototype.toString = function() {
  25982. return this.__toString("Map {", "}");
  25983. };
  25984. // @pragma Access
  25985. Map.prototype.get = function(k, notSetValue) {
  25986. return this._root
  25987. ? this._root.get(0, undefined, k, notSetValue)
  25988. : notSetValue;
  25989. };
  25990. // @pragma Modification
  25991. Map.prototype.set = function(k, v) {
  25992. return updateMap(this, k, v);
  25993. };
  25994. Map.prototype.setIn = function(keyPath, v) {
  25995. return this.updateIn(keyPath, NOT_SET, function() {
  25996. return v;
  25997. });
  25998. };
  25999. Map.prototype.remove = function(k) {
  26000. return updateMap(this, k, NOT_SET);
  26001. };
  26002. Map.prototype.deleteIn = function(keyPath) {
  26003. return this.updateIn(keyPath, function() {
  26004. return NOT_SET;
  26005. });
  26006. };
  26007. Map.prototype.update = function(k, notSetValue, updater) {
  26008. return arguments.length === 1
  26009. ? k(this)
  26010. : this.updateIn([k], notSetValue, updater);
  26011. };
  26012. Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
  26013. if (!updater) {
  26014. updater = notSetValue;
  26015. notSetValue = undefined;
  26016. }
  26017. var updatedValue = updateInDeepMap(
  26018. this,
  26019. forceIterator(keyPath),
  26020. notSetValue,
  26021. updater
  26022. );
  26023. return updatedValue === NOT_SET ? undefined : updatedValue;
  26024. };
  26025. Map.prototype.clear = function() {
  26026. if (this.size === 0) {
  26027. return this;
  26028. }
  26029. if (this.__ownerID) {
  26030. this.size = 0;
  26031. this._root = null;
  26032. this.__hash = undefined;
  26033. this.__altered = true;
  26034. return this;
  26035. }
  26036. return emptyMap();
  26037. };
  26038. // @pragma Composition
  26039. Map.prototype.merge = function(/*...iters*/) {
  26040. return mergeIntoMapWith(this, undefined, arguments);
  26041. };
  26042. Map.prototype.mergeWith = function(merger) {
  26043. var iters = SLICE$0.call(arguments, 1);
  26044. return mergeIntoMapWith(this, merger, iters);
  26045. };
  26046. Map.prototype.mergeIn = function(keyPath) {
  26047. var iters = SLICE$0.call(arguments, 1);
  26048. return this.updateIn(keyPath, emptyMap(), function(m) {
  26049. return typeof m.merge === "function"
  26050. ? m.merge.apply(m, iters)
  26051. : iters[iters.length - 1];
  26052. });
  26053. };
  26054. Map.prototype.mergeDeep = function(/*...iters*/) {
  26055. return mergeIntoMapWith(this, deepMerger, arguments);
  26056. };
  26057. Map.prototype.mergeDeepWith = function(merger) {
  26058. var iters = SLICE$0.call(arguments, 1);
  26059. return mergeIntoMapWith(this, deepMergerWith(merger), iters);
  26060. };
  26061. Map.prototype.mergeDeepIn = function(keyPath) {
  26062. var iters = SLICE$0.call(arguments, 1);
  26063. return this.updateIn(keyPath, emptyMap(), function(m) {
  26064. return typeof m.mergeDeep === "function"
  26065. ? m.mergeDeep.apply(m, iters)
  26066. : iters[iters.length - 1];
  26067. });
  26068. };
  26069. Map.prototype.sort = function(comparator) {
  26070. // Late binding
  26071. return OrderedMap(sortFactory(this, comparator));
  26072. };
  26073. Map.prototype.sortBy = function(mapper, comparator) {
  26074. // Late binding
  26075. return OrderedMap(sortFactory(this, comparator, mapper));
  26076. };
  26077. // @pragma Mutability
  26078. Map.prototype.withMutations = function(fn) {
  26079. var mutable = this.asMutable();
  26080. fn(mutable);
  26081. return mutable.wasAltered()
  26082. ? mutable.__ensureOwner(this.__ownerID)
  26083. : this;
  26084. };
  26085. Map.prototype.asMutable = function() {
  26086. return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
  26087. };
  26088. Map.prototype.asImmutable = function() {
  26089. return this.__ensureOwner();
  26090. };
  26091. Map.prototype.wasAltered = function() {
  26092. return this.__altered;
  26093. };
  26094. Map.prototype.__iterator = function(type, reverse) {
  26095. return new MapIterator(this, type, reverse);
  26096. };
  26097. Map.prototype.__iterate = function(fn, reverse) {
  26098. var this$0 = this;
  26099. var iterations = 0;
  26100. this._root &&
  26101. this._root.iterate(function(entry) {
  26102. iterations++;
  26103. return fn(entry[1], entry[0], this$0);
  26104. }, reverse);
  26105. return iterations;
  26106. };
  26107. Map.prototype.__ensureOwner = function(ownerID) {
  26108. if (ownerID === this.__ownerID) {
  26109. return this;
  26110. }
  26111. if (!ownerID) {
  26112. this.__ownerID = ownerID;
  26113. this.__altered = false;
  26114. return this;
  26115. }
  26116. return makeMap(this.size, this._root, ownerID, this.__hash);
  26117. };
  26118. function isMap(maybeMap) {
  26119. return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
  26120. }
  26121. Map.isMap = isMap;
  26122. var IS_MAP_SENTINEL = "@@__IMMUTABLE_MAP__@@";
  26123. var MapPrototype = Map.prototype;
  26124. MapPrototype[IS_MAP_SENTINEL] = true;
  26125. MapPrototype[DELETE] = MapPrototype.remove;
  26126. MapPrototype.removeIn = MapPrototype.deleteIn;
  26127. // #pragma Trie Nodes
  26128. function ArrayMapNode(ownerID, entries) {
  26129. this.ownerID = ownerID;
  26130. this.entries = entries;
  26131. }
  26132. ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  26133. var entries = this.entries;
  26134. for (var ii = 0, len = entries.length; ii < len; ii++) {
  26135. if (is(key, entries[ii][0])) {
  26136. return entries[ii][1];
  26137. }
  26138. }
  26139. return notSetValue;
  26140. };
  26141. ArrayMapNode.prototype.update = function(
  26142. ownerID,
  26143. shift,
  26144. keyHash,
  26145. key,
  26146. value,
  26147. didChangeSize,
  26148. didAlter
  26149. ) {
  26150. var removed = value === NOT_SET;
  26151. var entries = this.entries;
  26152. var idx = 0;
  26153. for (var len = entries.length; idx < len; idx++) {
  26154. if (is(key, entries[idx][0])) {
  26155. break;
  26156. }
  26157. }
  26158. var exists = idx < len;
  26159. if (exists ? entries[idx][1] === value : removed) {
  26160. return this;
  26161. }
  26162. SetRef(didAlter);
  26163. (removed || !exists) && SetRef(didChangeSize);
  26164. if (removed && entries.length === 1) {
  26165. return; // undefined
  26166. }
  26167. if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
  26168. return createNodes(ownerID, entries, key, value);
  26169. }
  26170. var isEditable = ownerID && ownerID === this.ownerID;
  26171. var newEntries = isEditable ? entries : arrCopy(entries);
  26172. if (exists) {
  26173. if (removed) {
  26174. idx === len - 1
  26175. ? newEntries.pop()
  26176. : (newEntries[idx] = newEntries.pop());
  26177. } else {
  26178. newEntries[idx] = [key, value];
  26179. }
  26180. } else {
  26181. newEntries.push([key, value]);
  26182. }
  26183. if (isEditable) {
  26184. this.entries = newEntries;
  26185. return this;
  26186. }
  26187. return new ArrayMapNode(ownerID, newEntries);
  26188. };
  26189. function BitmapIndexedNode(ownerID, bitmap, nodes) {
  26190. this.ownerID = ownerID;
  26191. this.bitmap = bitmap;
  26192. this.nodes = nodes;
  26193. }
  26194. BitmapIndexedNode.prototype.get = function(
  26195. shift,
  26196. keyHash,
  26197. key,
  26198. notSetValue
  26199. ) {
  26200. if (keyHash === undefined) {
  26201. keyHash = hash(key);
  26202. }
  26203. var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK);
  26204. var bitmap = this.bitmap;
  26205. return (bitmap & bit) === 0
  26206. ? notSetValue
  26207. : this.nodes[popCount(bitmap & (bit - 1))].get(
  26208. shift + SHIFT,
  26209. keyHash,
  26210. key,
  26211. notSetValue
  26212. );
  26213. };
  26214. BitmapIndexedNode.prototype.update = function(
  26215. ownerID,
  26216. shift,
  26217. keyHash,
  26218. key,
  26219. value,
  26220. didChangeSize,
  26221. didAlter
  26222. ) {
  26223. if (keyHash === undefined) {
  26224. keyHash = hash(key);
  26225. }
  26226. var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  26227. var bit = 1 << keyHashFrag;
  26228. var bitmap = this.bitmap;
  26229. var exists = (bitmap & bit) !== 0;
  26230. if (!exists && value === NOT_SET) {
  26231. return this;
  26232. }
  26233. var idx = popCount(bitmap & (bit - 1));
  26234. var nodes = this.nodes;
  26235. var node = exists ? nodes[idx] : undefined;
  26236. var newNode = updateNode(
  26237. node,
  26238. ownerID,
  26239. shift + SHIFT,
  26240. keyHash,
  26241. key,
  26242. value,
  26243. didChangeSize,
  26244. didAlter
  26245. );
  26246. if (newNode === node) {
  26247. return this;
  26248. }
  26249. if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
  26250. return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
  26251. }
  26252. if (
  26253. exists &&
  26254. !newNode &&
  26255. nodes.length === 2 &&
  26256. isLeafNode(nodes[idx ^ 1])
  26257. ) {
  26258. return nodes[idx ^ 1];
  26259. }
  26260. if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
  26261. return newNode;
  26262. }
  26263. var isEditable = ownerID && ownerID === this.ownerID;
  26264. var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit;
  26265. var newNodes = exists
  26266. ? newNode
  26267. ? setIn(nodes, idx, newNode, isEditable)
  26268. : spliceOut(nodes, idx, isEditable)
  26269. : spliceIn(nodes, idx, newNode, isEditable);
  26270. if (isEditable) {
  26271. this.bitmap = newBitmap;
  26272. this.nodes = newNodes;
  26273. return this;
  26274. }
  26275. return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
  26276. };
  26277. function HashArrayMapNode(ownerID, count, nodes) {
  26278. this.ownerID = ownerID;
  26279. this.count = count;
  26280. this.nodes = nodes;
  26281. }
  26282. HashArrayMapNode.prototype.get = function(
  26283. shift,
  26284. keyHash,
  26285. key,
  26286. notSetValue
  26287. ) {
  26288. if (keyHash === undefined) {
  26289. keyHash = hash(key);
  26290. }
  26291. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  26292. var node = this.nodes[idx];
  26293. return node
  26294. ? node.get(shift + SHIFT, keyHash, key, notSetValue)
  26295. : notSetValue;
  26296. };
  26297. HashArrayMapNode.prototype.update = function(
  26298. ownerID,
  26299. shift,
  26300. keyHash,
  26301. key,
  26302. value,
  26303. didChangeSize,
  26304. didAlter
  26305. ) {
  26306. if (keyHash === undefined) {
  26307. keyHash = hash(key);
  26308. }
  26309. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  26310. var removed = value === NOT_SET;
  26311. var nodes = this.nodes;
  26312. var node = nodes[idx];
  26313. if (removed && !node) {
  26314. return this;
  26315. }
  26316. var newNode = updateNode(
  26317. node,
  26318. ownerID,
  26319. shift + SHIFT,
  26320. keyHash,
  26321. key,
  26322. value,
  26323. didChangeSize,
  26324. didAlter
  26325. );
  26326. if (newNode === node) {
  26327. return this;
  26328. }
  26329. var newCount = this.count;
  26330. if (!node) {
  26331. newCount++;
  26332. } else if (!newNode) {
  26333. newCount--;
  26334. if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
  26335. return packNodes(ownerID, nodes, newCount, idx);
  26336. }
  26337. }
  26338. var isEditable = ownerID && ownerID === this.ownerID;
  26339. var newNodes = setIn(nodes, idx, newNode, isEditable);
  26340. if (isEditable) {
  26341. this.count = newCount;
  26342. this.nodes = newNodes;
  26343. return this;
  26344. }
  26345. return new HashArrayMapNode(ownerID, newCount, newNodes);
  26346. };
  26347. function HashCollisionNode(ownerID, keyHash, entries) {
  26348. this.ownerID = ownerID;
  26349. this.keyHash = keyHash;
  26350. this.entries = entries;
  26351. }
  26352. HashCollisionNode.prototype.get = function(
  26353. shift,
  26354. keyHash,
  26355. key,
  26356. notSetValue
  26357. ) {
  26358. var entries = this.entries;
  26359. for (var ii = 0, len = entries.length; ii < len; ii++) {
  26360. if (is(key, entries[ii][0])) {
  26361. return entries[ii][1];
  26362. }
  26363. }
  26364. return notSetValue;
  26365. };
  26366. HashCollisionNode.prototype.update = function(
  26367. ownerID,
  26368. shift,
  26369. keyHash,
  26370. key,
  26371. value,
  26372. didChangeSize,
  26373. didAlter
  26374. ) {
  26375. if (keyHash === undefined) {
  26376. keyHash = hash(key);
  26377. }
  26378. var removed = value === NOT_SET;
  26379. if (keyHash !== this.keyHash) {
  26380. if (removed) {
  26381. return this;
  26382. }
  26383. SetRef(didAlter);
  26384. SetRef(didChangeSize);
  26385. return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
  26386. }
  26387. var entries = this.entries;
  26388. var idx = 0;
  26389. for (var len = entries.length; idx < len; idx++) {
  26390. if (is(key, entries[idx][0])) {
  26391. break;
  26392. }
  26393. }
  26394. var exists = idx < len;
  26395. if (exists ? entries[idx][1] === value : removed) {
  26396. return this;
  26397. }
  26398. SetRef(didAlter);
  26399. (removed || !exists) && SetRef(didChangeSize);
  26400. if (removed && len === 2) {
  26401. return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
  26402. }
  26403. var isEditable = ownerID && ownerID === this.ownerID;
  26404. var newEntries = isEditable ? entries : arrCopy(entries);
  26405. if (exists) {
  26406. if (removed) {
  26407. idx === len - 1
  26408. ? newEntries.pop()
  26409. : (newEntries[idx] = newEntries.pop());
  26410. } else {
  26411. newEntries[idx] = [key, value];
  26412. }
  26413. } else {
  26414. newEntries.push([key, value]);
  26415. }
  26416. if (isEditable) {
  26417. this.entries = newEntries;
  26418. return this;
  26419. }
  26420. return new HashCollisionNode(ownerID, this.keyHash, newEntries);
  26421. };
  26422. function ValueNode(ownerID, keyHash, entry) {
  26423. this.ownerID = ownerID;
  26424. this.keyHash = keyHash;
  26425. this.entry = entry;
  26426. }
  26427. ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  26428. return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
  26429. };
  26430. ValueNode.prototype.update = function(
  26431. ownerID,
  26432. shift,
  26433. keyHash,
  26434. key,
  26435. value,
  26436. didChangeSize,
  26437. didAlter
  26438. ) {
  26439. var removed = value === NOT_SET;
  26440. var keyMatch = is(key, this.entry[0]);
  26441. if (keyMatch ? value === this.entry[1] : removed) {
  26442. return this;
  26443. }
  26444. SetRef(didAlter);
  26445. if (removed) {
  26446. SetRef(didChangeSize);
  26447. return; // undefined
  26448. }
  26449. if (keyMatch) {
  26450. if (ownerID && ownerID === this.ownerID) {
  26451. this.entry[1] = value;
  26452. return this;
  26453. }
  26454. return new ValueNode(ownerID, this.keyHash, [key, value]);
  26455. }
  26456. SetRef(didChangeSize);
  26457. return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
  26458. };
  26459. // #pragma Iterators
  26460. ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = function(
  26461. fn,
  26462. reverse
  26463. ) {
  26464. var entries = this.entries;
  26465. for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
  26466. if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
  26467. return false;
  26468. }
  26469. }
  26470. };
  26471. BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = function(
  26472. fn,
  26473. reverse
  26474. ) {
  26475. var nodes = this.nodes;
  26476. for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
  26477. var node = nodes[reverse ? maxIndex - ii : ii];
  26478. if (node && node.iterate(fn, reverse) === false) {
  26479. return false;
  26480. }
  26481. }
  26482. };
  26483. ValueNode.prototype.iterate = function(fn, reverse) {
  26484. return fn(this.entry);
  26485. };
  26486. createClass(MapIterator, Iterator);
  26487. function MapIterator(map, type, reverse) {
  26488. this._type = type;
  26489. this._reverse = reverse;
  26490. this._stack = map._root && mapIteratorFrame(map._root);
  26491. }
  26492. MapIterator.prototype.next = function() {
  26493. var type = this._type;
  26494. var stack = this._stack;
  26495. while (stack) {
  26496. var node = stack.node;
  26497. var index = stack.index++;
  26498. var maxIndex;
  26499. if (node.entry) {
  26500. if (index === 0) {
  26501. return mapIteratorValue(type, node.entry);
  26502. }
  26503. } else if (node.entries) {
  26504. maxIndex = node.entries.length - 1;
  26505. if (index <= maxIndex) {
  26506. return mapIteratorValue(
  26507. type,
  26508. node.entries[this._reverse ? maxIndex - index : index]
  26509. );
  26510. }
  26511. } else {
  26512. maxIndex = node.nodes.length - 1;
  26513. if (index <= maxIndex) {
  26514. var subNode = node.nodes[this._reverse ? maxIndex - index : index];
  26515. if (subNode) {
  26516. if (subNode.entry) {
  26517. return mapIteratorValue(type, subNode.entry);
  26518. }
  26519. stack = this._stack = mapIteratorFrame(subNode, stack);
  26520. }
  26521. continue;
  26522. }
  26523. }
  26524. stack = this._stack = this._stack.__prev;
  26525. }
  26526. return iteratorDone();
  26527. };
  26528. function mapIteratorValue(type, entry) {
  26529. return iteratorValue(type, entry[0], entry[1]);
  26530. }
  26531. function mapIteratorFrame(node, prev) {
  26532. return {
  26533. node: node,
  26534. index: 0,
  26535. __prev: prev
  26536. };
  26537. }
  26538. function makeMap(size, root, ownerID, hash) {
  26539. var map = Object.create(MapPrototype);
  26540. map.size = size;
  26541. map._root = root;
  26542. map.__ownerID = ownerID;
  26543. map.__hash = hash;
  26544. map.__altered = false;
  26545. return map;
  26546. }
  26547. var EMPTY_MAP;
  26548. function emptyMap() {
  26549. return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
  26550. }
  26551. function updateMap(map, k, v) {
  26552. var newRoot;
  26553. var newSize;
  26554. if (!map._root) {
  26555. if (v === NOT_SET) {
  26556. return map;
  26557. }
  26558. newSize = 1;
  26559. newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
  26560. } else {
  26561. var didChangeSize = MakeRef(CHANGE_LENGTH);
  26562. var didAlter = MakeRef(DID_ALTER);
  26563. newRoot = updateNode(
  26564. map._root,
  26565. map.__ownerID,
  26566. 0,
  26567. undefined,
  26568. k,
  26569. v,
  26570. didChangeSize,
  26571. didAlter
  26572. );
  26573. if (!didAlter.value) {
  26574. return map;
  26575. }
  26576. newSize =
  26577. map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0);
  26578. }
  26579. if (map.__ownerID) {
  26580. map.size = newSize;
  26581. map._root = newRoot;
  26582. map.__hash = undefined;
  26583. map.__altered = true;
  26584. return map;
  26585. }
  26586. return newRoot ? makeMap(newSize, newRoot) : emptyMap();
  26587. }
  26588. function updateNode(
  26589. node,
  26590. ownerID,
  26591. shift,
  26592. keyHash,
  26593. key,
  26594. value,
  26595. didChangeSize,
  26596. didAlter
  26597. ) {
  26598. if (!node) {
  26599. if (value === NOT_SET) {
  26600. return node;
  26601. }
  26602. SetRef(didAlter);
  26603. SetRef(didChangeSize);
  26604. return new ValueNode(ownerID, keyHash, [key, value]);
  26605. }
  26606. return node.update(
  26607. ownerID,
  26608. shift,
  26609. keyHash,
  26610. key,
  26611. value,
  26612. didChangeSize,
  26613. didAlter
  26614. );
  26615. }
  26616. function isLeafNode(node) {
  26617. return (
  26618. node.constructor === ValueNode || node.constructor === HashCollisionNode
  26619. );
  26620. }
  26621. function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
  26622. if (node.keyHash === keyHash) {
  26623. return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
  26624. }
  26625. var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
  26626. var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  26627. var newNode;
  26628. var nodes =
  26629. idx1 === idx2
  26630. ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)]
  26631. : ((newNode = new ValueNode(ownerID, keyHash, entry)),
  26632. idx1 < idx2 ? [node, newNode] : [newNode, node]);
  26633. return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
  26634. }
  26635. function createNodes(ownerID, entries, key, value) {
  26636. if (!ownerID) {
  26637. ownerID = new OwnerID();
  26638. }
  26639. var node = new ValueNode(ownerID, hash(key), [key, value]);
  26640. for (var ii = 0; ii < entries.length; ii++) {
  26641. var entry = entries[ii];
  26642. node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
  26643. }
  26644. return node;
  26645. }
  26646. function packNodes(ownerID, nodes, count, excluding) {
  26647. var bitmap = 0;
  26648. var packedII = 0;
  26649. var packedNodes = new Array(count);
  26650. for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
  26651. var node = nodes[ii];
  26652. if (node !== undefined && ii !== excluding) {
  26653. bitmap |= bit;
  26654. packedNodes[packedII++] = node;
  26655. }
  26656. }
  26657. return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
  26658. }
  26659. function expandNodes(ownerID, nodes, bitmap, including, node) {
  26660. var count = 0;
  26661. var expandedNodes = new Array(SIZE);
  26662. for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
  26663. expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
  26664. }
  26665. expandedNodes[including] = node;
  26666. return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
  26667. }
  26668. function mergeIntoMapWith(map, merger, iterables) {
  26669. var iters = [];
  26670. for (var ii = 0; ii < iterables.length; ii++) {
  26671. var value = iterables[ii];
  26672. var iter = KeyedIterable(value);
  26673. if (!isIterable(value)) {
  26674. iter = iter.map(function(v) {
  26675. return fromJS(v);
  26676. });
  26677. }
  26678. iters.push(iter);
  26679. }
  26680. return mergeIntoCollectionWith(map, merger, iters);
  26681. }
  26682. function deepMerger(existing, value, key) {
  26683. return existing && existing.mergeDeep && isIterable(value)
  26684. ? existing.mergeDeep(value)
  26685. : is(existing, value)
  26686. ? existing
  26687. : value;
  26688. }
  26689. function deepMergerWith(merger) {
  26690. return function(existing, value, key) {
  26691. if (existing && existing.mergeDeepWith && isIterable(value)) {
  26692. return existing.mergeDeepWith(merger, value);
  26693. }
  26694. var nextValue = merger(existing, value, key);
  26695. return is(existing, nextValue) ? existing : nextValue;
  26696. };
  26697. }
  26698. function mergeIntoCollectionWith(collection, merger, iters) {
  26699. iters = iters.filter(function(x) {
  26700. return x.size !== 0;
  26701. });
  26702. if (iters.length === 0) {
  26703. return collection;
  26704. }
  26705. if (
  26706. collection.size === 0 &&
  26707. !collection.__ownerID &&
  26708. iters.length === 1
  26709. ) {
  26710. return collection.constructor(iters[0]);
  26711. }
  26712. return collection.withMutations(function(collection) {
  26713. var mergeIntoMap = merger
  26714. ? function(value, key) {
  26715. collection.update(key, NOT_SET, function(existing) {
  26716. return existing === NOT_SET
  26717. ? value
  26718. : merger(existing, value, key);
  26719. });
  26720. }
  26721. : function(value, key) {
  26722. collection.set(key, value);
  26723. };
  26724. for (var ii = 0; ii < iters.length; ii++) {
  26725. iters[ii].forEach(mergeIntoMap);
  26726. }
  26727. });
  26728. }
  26729. function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
  26730. var isNotSet = existing === NOT_SET;
  26731. var step = keyPathIter.next();
  26732. if (step.done) {
  26733. var existingValue = isNotSet ? notSetValue : existing;
  26734. var newValue = updater(existingValue);
  26735. return newValue === existingValue ? existing : newValue;
  26736. }
  26737. invariant(isNotSet || (existing && existing.set), "invalid keyPath");
  26738. var key = step.value;
  26739. var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
  26740. var nextUpdated = updateInDeepMap(
  26741. nextExisting,
  26742. keyPathIter,
  26743. notSetValue,
  26744. updater
  26745. );
  26746. return nextUpdated === nextExisting
  26747. ? existing
  26748. : nextUpdated === NOT_SET
  26749. ? existing.remove(key)
  26750. : (isNotSet ? emptyMap() : existing).set(key, nextUpdated);
  26751. }
  26752. function popCount(x) {
  26753. x = x - ((x >> 1) & 0x55555555);
  26754. x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  26755. x = (x + (x >> 4)) & 0x0f0f0f0f;
  26756. x = x + (x >> 8);
  26757. x = x + (x >> 16);
  26758. return x & 0x7f;
  26759. }
  26760. function setIn(array, idx, val, canEdit) {
  26761. var newArray = canEdit ? array : arrCopy(array);
  26762. newArray[idx] = val;
  26763. return newArray;
  26764. }
  26765. function spliceIn(array, idx, val, canEdit) {
  26766. var newLen = array.length + 1;
  26767. if (canEdit && idx + 1 === newLen) {
  26768. array[idx] = val;
  26769. return array;
  26770. }
  26771. var newArray = new Array(newLen);
  26772. var after = 0;
  26773. for (var ii = 0; ii < newLen; ii++) {
  26774. if (ii === idx) {
  26775. newArray[ii] = val;
  26776. after = -1;
  26777. } else {
  26778. newArray[ii] = array[ii + after];
  26779. }
  26780. }
  26781. return newArray;
  26782. }
  26783. function spliceOut(array, idx, canEdit) {
  26784. var newLen = array.length - 1;
  26785. if (canEdit && idx === newLen) {
  26786. array.pop();
  26787. return array;
  26788. }
  26789. var newArray = new Array(newLen);
  26790. var after = 0;
  26791. for (var ii = 0; ii < newLen; ii++) {
  26792. if (ii === idx) {
  26793. after = 1;
  26794. }
  26795. newArray[ii] = array[ii + after];
  26796. }
  26797. return newArray;
  26798. }
  26799. var MAX_ARRAY_MAP_SIZE = SIZE / 4;
  26800. var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
  26801. var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
  26802. createClass(List, IndexedCollection);
  26803. // @pragma Construction
  26804. function List(value) {
  26805. var empty = emptyList();
  26806. if (value === null || value === undefined) {
  26807. return empty;
  26808. }
  26809. if (isList(value)) {
  26810. return value;
  26811. }
  26812. var iter = IndexedIterable(value);
  26813. var size = iter.size;
  26814. if (size === 0) {
  26815. return empty;
  26816. }
  26817. assertNotInfinite(size);
  26818. if (size > 0 && size < SIZE) {
  26819. return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
  26820. }
  26821. return empty.withMutations(function(list) {
  26822. list.setSize(size);
  26823. iter.forEach(function(v, i) {
  26824. return list.set(i, v);
  26825. });
  26826. });
  26827. }
  26828. List.of = function(/*...values*/) {
  26829. return this(arguments);
  26830. };
  26831. List.prototype.toString = function() {
  26832. return this.__toString("List [", "]");
  26833. };
  26834. // @pragma Access
  26835. List.prototype.get = function(index, notSetValue) {
  26836. index = wrapIndex(this, index);
  26837. if (index >= 0 && index < this.size) {
  26838. index += this._origin;
  26839. var node = listNodeFor(this, index);
  26840. return node && node.array[index & MASK];
  26841. }
  26842. return notSetValue;
  26843. };
  26844. // @pragma Modification
  26845. List.prototype.set = function(index, value) {
  26846. return updateList(this, index, value);
  26847. };
  26848. List.prototype.remove = function(index) {
  26849. return !this.has(index)
  26850. ? this
  26851. : index === 0
  26852. ? this.shift()
  26853. : index === this.size - 1
  26854. ? this.pop()
  26855. : this.splice(index, 1);
  26856. };
  26857. List.prototype.insert = function(index, value) {
  26858. return this.splice(index, 0, value);
  26859. };
  26860. List.prototype.clear = function() {
  26861. if (this.size === 0) {
  26862. return this;
  26863. }
  26864. if (this.__ownerID) {
  26865. this.size = this._origin = this._capacity = 0;
  26866. this._level = SHIFT;
  26867. this._root = this._tail = null;
  26868. this.__hash = undefined;
  26869. this.__altered = true;
  26870. return this;
  26871. }
  26872. return emptyList();
  26873. };
  26874. List.prototype.push = function(/*...values*/) {
  26875. var values = arguments;
  26876. var oldSize = this.size;
  26877. return this.withMutations(function(list) {
  26878. setListBounds(list, 0, oldSize + values.length);
  26879. for (var ii = 0; ii < values.length; ii++) {
  26880. list.set(oldSize + ii, values[ii]);
  26881. }
  26882. });
  26883. };
  26884. List.prototype.pop = function() {
  26885. return setListBounds(this, 0, -1);
  26886. };
  26887. List.prototype.unshift = function(/*...values*/) {
  26888. var values = arguments;
  26889. return this.withMutations(function(list) {
  26890. setListBounds(list, -values.length);
  26891. for (var ii = 0; ii < values.length; ii++) {
  26892. list.set(ii, values[ii]);
  26893. }
  26894. });
  26895. };
  26896. List.prototype.shift = function() {
  26897. return setListBounds(this, 1);
  26898. };
  26899. // @pragma Composition
  26900. List.prototype.merge = function(/*...iters*/) {
  26901. return mergeIntoListWith(this, undefined, arguments);
  26902. };
  26903. List.prototype.mergeWith = function(merger) {
  26904. var iters = SLICE$0.call(arguments, 1);
  26905. return mergeIntoListWith(this, merger, iters);
  26906. };
  26907. List.prototype.mergeDeep = function(/*...iters*/) {
  26908. return mergeIntoListWith(this, deepMerger, arguments);
  26909. };
  26910. List.prototype.mergeDeepWith = function(merger) {
  26911. var iters = SLICE$0.call(arguments, 1);
  26912. return mergeIntoListWith(this, deepMergerWith(merger), iters);
  26913. };
  26914. List.prototype.setSize = function(size) {
  26915. return setListBounds(this, 0, size);
  26916. };
  26917. // @pragma Iteration
  26918. List.prototype.slice = function(begin, end) {
  26919. var size = this.size;
  26920. if (wholeSlice(begin, end, size)) {
  26921. return this;
  26922. }
  26923. return setListBounds(
  26924. this,
  26925. resolveBegin(begin, size),
  26926. resolveEnd(end, size)
  26927. );
  26928. };
  26929. List.prototype.__iterator = function(type, reverse) {
  26930. var index = 0;
  26931. var values = iterateList(this, reverse);
  26932. return new Iterator(function() {
  26933. var value = values();
  26934. return value === DONE
  26935. ? iteratorDone()
  26936. : iteratorValue(type, index++, value);
  26937. });
  26938. };
  26939. List.prototype.__iterate = function(fn, reverse) {
  26940. var index = 0;
  26941. var values = iterateList(this, reverse);
  26942. var value;
  26943. while ((value = values()) !== DONE) {
  26944. if (fn(value, index++, this) === false) {
  26945. break;
  26946. }
  26947. }
  26948. return index;
  26949. };
  26950. List.prototype.__ensureOwner = function(ownerID) {
  26951. if (ownerID === this.__ownerID) {
  26952. return this;
  26953. }
  26954. if (!ownerID) {
  26955. this.__ownerID = ownerID;
  26956. return this;
  26957. }
  26958. return makeList(
  26959. this._origin,
  26960. this._capacity,
  26961. this._level,
  26962. this._root,
  26963. this._tail,
  26964. ownerID,
  26965. this.__hash
  26966. );
  26967. };
  26968. function isList(maybeList) {
  26969. return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
  26970. }
  26971. List.isList = isList;
  26972. var IS_LIST_SENTINEL = "@@__IMMUTABLE_LIST__@@";
  26973. var ListPrototype = List.prototype;
  26974. ListPrototype[IS_LIST_SENTINEL] = true;
  26975. ListPrototype[DELETE] = ListPrototype.remove;
  26976. ListPrototype.setIn = MapPrototype.setIn;
  26977. ListPrototype.deleteIn = ListPrototype.removeIn = MapPrototype.removeIn;
  26978. ListPrototype.update = MapPrototype.update;
  26979. ListPrototype.updateIn = MapPrototype.updateIn;
  26980. ListPrototype.mergeIn = MapPrototype.mergeIn;
  26981. ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  26982. ListPrototype.withMutations = MapPrototype.withMutations;
  26983. ListPrototype.asMutable = MapPrototype.asMutable;
  26984. ListPrototype.asImmutable = MapPrototype.asImmutable;
  26985. ListPrototype.wasAltered = MapPrototype.wasAltered;
  26986. function VNode(array, ownerID) {
  26987. this.array = array;
  26988. this.ownerID = ownerID;
  26989. }
  26990. // TODO: seems like these methods are very similar
  26991. VNode.prototype.removeBefore = function(ownerID, level, index) {
  26992. if (index === level ? 1 << level : this.array.length === 0) {
  26993. return this;
  26994. }
  26995. var originIndex = (index >>> level) & MASK;
  26996. if (originIndex >= this.array.length) {
  26997. return new VNode([], ownerID);
  26998. }
  26999. var removingFirst = originIndex === 0;
  27000. var newChild;
  27001. if (level > 0) {
  27002. var oldChild = this.array[originIndex];
  27003. newChild =
  27004. oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
  27005. if (newChild === oldChild && removingFirst) {
  27006. return this;
  27007. }
  27008. }
  27009. if (removingFirst && !newChild) {
  27010. return this;
  27011. }
  27012. var editable = editableVNode(this, ownerID);
  27013. if (!removingFirst) {
  27014. for (var ii = 0; ii < originIndex; ii++) {
  27015. editable.array[ii] = undefined;
  27016. }
  27017. }
  27018. if (newChild) {
  27019. editable.array[originIndex] = newChild;
  27020. }
  27021. return editable;
  27022. };
  27023. VNode.prototype.removeAfter = function(ownerID, level, index) {
  27024. if (index === (level ? 1 << level : 0) || this.array.length === 0) {
  27025. return this;
  27026. }
  27027. var sizeIndex = ((index - 1) >>> level) & MASK;
  27028. if (sizeIndex >= this.array.length) {
  27029. return this;
  27030. }
  27031. var newChild;
  27032. if (level > 0) {
  27033. var oldChild = this.array[sizeIndex];
  27034. newChild =
  27035. oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
  27036. if (newChild === oldChild && sizeIndex === this.array.length - 1) {
  27037. return this;
  27038. }
  27039. }
  27040. var editable = editableVNode(this, ownerID);
  27041. editable.array.splice(sizeIndex + 1);
  27042. if (newChild) {
  27043. editable.array[sizeIndex] = newChild;
  27044. }
  27045. return editable;
  27046. };
  27047. var DONE = {};
  27048. function iterateList(list, reverse) {
  27049. var left = list._origin;
  27050. var right = list._capacity;
  27051. var tailPos = getTailOffset(right);
  27052. var tail = list._tail;
  27053. return iterateNodeOrLeaf(list._root, list._level, 0);
  27054. function iterateNodeOrLeaf(node, level, offset) {
  27055. return level === 0
  27056. ? iterateLeaf(node, offset)
  27057. : iterateNode(node, level, offset);
  27058. }
  27059. function iterateLeaf(node, offset) {
  27060. var array =
  27061. offset === tailPos ? tail && tail.array : node && node.array;
  27062. var from = offset > left ? 0 : left - offset;
  27063. var to = right - offset;
  27064. if (to > SIZE) {
  27065. to = SIZE;
  27066. }
  27067. return function() {
  27068. if (from === to) {
  27069. return DONE;
  27070. }
  27071. var idx = reverse ? --to : from++;
  27072. return array && array[idx];
  27073. };
  27074. }
  27075. function iterateNode(node, level, offset) {
  27076. var values;
  27077. var array = node && node.array;
  27078. var from = offset > left ? 0 : (left - offset) >> level;
  27079. var to = ((right - offset) >> level) + 1;
  27080. if (to > SIZE) {
  27081. to = SIZE;
  27082. }
  27083. return function() {
  27084. do {
  27085. if (values) {
  27086. var value = values();
  27087. if (value !== DONE) {
  27088. return value;
  27089. }
  27090. values = null;
  27091. }
  27092. if (from === to) {
  27093. return DONE;
  27094. }
  27095. var idx = reverse ? --to : from++;
  27096. values = iterateNodeOrLeaf(
  27097. array && array[idx],
  27098. level - SHIFT,
  27099. offset + (idx << level)
  27100. );
  27101. } while (true);
  27102. };
  27103. }
  27104. }
  27105. function makeList(origin, capacity, level, root, tail, ownerID, hash) {
  27106. var list = Object.create(ListPrototype);
  27107. list.size = capacity - origin;
  27108. list._origin = origin;
  27109. list._capacity = capacity;
  27110. list._level = level;
  27111. list._root = root;
  27112. list._tail = tail;
  27113. list.__ownerID = ownerID;
  27114. list.__hash = hash;
  27115. list.__altered = false;
  27116. return list;
  27117. }
  27118. var EMPTY_LIST;
  27119. function emptyList() {
  27120. return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
  27121. }
  27122. function updateList(list, index, value) {
  27123. index = wrapIndex(list, index);
  27124. if (index !== index) {
  27125. return list;
  27126. }
  27127. if (index >= list.size || index < 0) {
  27128. return list.withMutations(function(list) {
  27129. index < 0
  27130. ? setListBounds(list, index).set(0, value)
  27131. : setListBounds(list, 0, index + 1).set(index, value);
  27132. });
  27133. }
  27134. index += list._origin;
  27135. var newTail = list._tail;
  27136. var newRoot = list._root;
  27137. var didAlter = MakeRef(DID_ALTER);
  27138. if (index >= getTailOffset(list._capacity)) {
  27139. newTail = updateVNode(
  27140. newTail,
  27141. list.__ownerID,
  27142. 0,
  27143. index,
  27144. value,
  27145. didAlter
  27146. );
  27147. } else {
  27148. newRoot = updateVNode(
  27149. newRoot,
  27150. list.__ownerID,
  27151. list._level,
  27152. index,
  27153. value,
  27154. didAlter
  27155. );
  27156. }
  27157. if (!didAlter.value) {
  27158. return list;
  27159. }
  27160. if (list.__ownerID) {
  27161. list._root = newRoot;
  27162. list._tail = newTail;
  27163. list.__hash = undefined;
  27164. list.__altered = true;
  27165. return list;
  27166. }
  27167. return makeList(
  27168. list._origin,
  27169. list._capacity,
  27170. list._level,
  27171. newRoot,
  27172. newTail
  27173. );
  27174. }
  27175. function updateVNode(node, ownerID, level, index, value, didAlter) {
  27176. var idx = (index >>> level) & MASK;
  27177. var nodeHas = node && idx < node.array.length;
  27178. if (!nodeHas && value === undefined) {
  27179. return node;
  27180. }
  27181. var newNode;
  27182. if (level > 0) {
  27183. var lowerNode = node && node.array[idx];
  27184. var newLowerNode = updateVNode(
  27185. lowerNode,
  27186. ownerID,
  27187. level - SHIFT,
  27188. index,
  27189. value,
  27190. didAlter
  27191. );
  27192. if (newLowerNode === lowerNode) {
  27193. return node;
  27194. }
  27195. newNode = editableVNode(node, ownerID);
  27196. newNode.array[idx] = newLowerNode;
  27197. return newNode;
  27198. }
  27199. if (nodeHas && node.array[idx] === value) {
  27200. return node;
  27201. }
  27202. SetRef(didAlter);
  27203. newNode = editableVNode(node, ownerID);
  27204. if (value === undefined && idx === newNode.array.length - 1) {
  27205. newNode.array.pop();
  27206. } else {
  27207. newNode.array[idx] = value;
  27208. }
  27209. return newNode;
  27210. }
  27211. function editableVNode(node, ownerID) {
  27212. if (ownerID && node && ownerID === node.ownerID) {
  27213. return node;
  27214. }
  27215. return new VNode(node ? node.array.slice() : [], ownerID);
  27216. }
  27217. function listNodeFor(list, rawIndex) {
  27218. if (rawIndex >= getTailOffset(list._capacity)) {
  27219. return list._tail;
  27220. }
  27221. if (rawIndex < 1 << (list._level + SHIFT)) {
  27222. var node = list._root;
  27223. var level = list._level;
  27224. while (node && level > 0) {
  27225. node = node.array[(rawIndex >>> level) & MASK];
  27226. level -= SHIFT;
  27227. }
  27228. return node;
  27229. }
  27230. }
  27231. function setListBounds(list, begin, end) {
  27232. // Sanitize begin & end using this shorthand for ToInt32(argument)
  27233. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  27234. if (begin !== undefined) {
  27235. begin = begin | 0;
  27236. }
  27237. if (end !== undefined) {
  27238. end = end | 0;
  27239. }
  27240. var owner = list.__ownerID || new OwnerID();
  27241. var oldOrigin = list._origin;
  27242. var oldCapacity = list._capacity;
  27243. var newOrigin = oldOrigin + begin;
  27244. var newCapacity =
  27245. end === undefined
  27246. ? oldCapacity
  27247. : end < 0
  27248. ? oldCapacity + end
  27249. : oldOrigin + end;
  27250. if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
  27251. return list;
  27252. }
  27253. // If it's going to end after it starts, it's empty.
  27254. if (newOrigin >= newCapacity) {
  27255. return list.clear();
  27256. }
  27257. var newLevel = list._level;
  27258. var newRoot = list._root;
  27259. // New origin might need creating a higher root.
  27260. var offsetShift = 0;
  27261. while (newOrigin + offsetShift < 0) {
  27262. newRoot = new VNode(
  27263. newRoot && newRoot.array.length ? [undefined, newRoot] : [],
  27264. owner
  27265. );
  27266. newLevel += SHIFT;
  27267. offsetShift += 1 << newLevel;
  27268. }
  27269. if (offsetShift) {
  27270. newOrigin += offsetShift;
  27271. oldOrigin += offsetShift;
  27272. newCapacity += offsetShift;
  27273. oldCapacity += offsetShift;
  27274. }
  27275. var oldTailOffset = getTailOffset(oldCapacity);
  27276. var newTailOffset = getTailOffset(newCapacity);
  27277. // New size might need creating a higher root.
  27278. while (newTailOffset >= 1 << (newLevel + SHIFT)) {
  27279. newRoot = new VNode(
  27280. newRoot && newRoot.array.length ? [newRoot] : [],
  27281. owner
  27282. );
  27283. newLevel += SHIFT;
  27284. }
  27285. // Locate or create the new tail.
  27286. var oldTail = list._tail;
  27287. var newTail =
  27288. newTailOffset < oldTailOffset
  27289. ? listNodeFor(list, newCapacity - 1)
  27290. : newTailOffset > oldTailOffset
  27291. ? new VNode([], owner)
  27292. : oldTail;
  27293. // Merge Tail into tree.
  27294. if (
  27295. oldTail &&
  27296. newTailOffset > oldTailOffset &&
  27297. newOrigin < oldCapacity &&
  27298. oldTail.array.length
  27299. ) {
  27300. newRoot = editableVNode(newRoot, owner);
  27301. var node = newRoot;
  27302. for (var level = newLevel; level > SHIFT; level -= SHIFT) {
  27303. var idx = (oldTailOffset >>> level) & MASK;
  27304. node = node.array[idx] = editableVNode(node.array[idx], owner);
  27305. }
  27306. node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
  27307. }
  27308. // If the size has been reduced, there's a chance the tail needs to be trimmed.
  27309. if (newCapacity < oldCapacity) {
  27310. newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
  27311. }
  27312. // If the new origin is within the tail, then we do not need a root.
  27313. if (newOrigin >= newTailOffset) {
  27314. newOrigin -= newTailOffset;
  27315. newCapacity -= newTailOffset;
  27316. newLevel = SHIFT;
  27317. newRoot = null;
  27318. newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
  27319. // Otherwise, if the root has been trimmed, garbage collect.
  27320. } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
  27321. offsetShift = 0;
  27322. // Identify the new top root node of the subtree of the old root.
  27323. while (newRoot) {
  27324. var beginIndex = (newOrigin >>> newLevel) & MASK;
  27325. if ((beginIndex !== newTailOffset >>> newLevel) & MASK) {
  27326. break;
  27327. }
  27328. if (beginIndex) {
  27329. offsetShift += (1 << newLevel) * beginIndex;
  27330. }
  27331. newLevel -= SHIFT;
  27332. newRoot = newRoot.array[beginIndex];
  27333. }
  27334. // Trim the new sides of the new root.
  27335. if (newRoot && newOrigin > oldOrigin) {
  27336. newRoot = newRoot.removeBefore(
  27337. owner,
  27338. newLevel,
  27339. newOrigin - offsetShift
  27340. );
  27341. }
  27342. if (newRoot && newTailOffset < oldTailOffset) {
  27343. newRoot = newRoot.removeAfter(
  27344. owner,
  27345. newLevel,
  27346. newTailOffset - offsetShift
  27347. );
  27348. }
  27349. if (offsetShift) {
  27350. newOrigin -= offsetShift;
  27351. newCapacity -= offsetShift;
  27352. }
  27353. }
  27354. if (list.__ownerID) {
  27355. list.size = newCapacity - newOrigin;
  27356. list._origin = newOrigin;
  27357. list._capacity = newCapacity;
  27358. list._level = newLevel;
  27359. list._root = newRoot;
  27360. list._tail = newTail;
  27361. list.__hash = undefined;
  27362. list.__altered = true;
  27363. return list;
  27364. }
  27365. return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
  27366. }
  27367. function mergeIntoListWith(list, merger, iterables) {
  27368. var iters = [];
  27369. var maxSize = 0;
  27370. for (var ii = 0; ii < iterables.length; ii++) {
  27371. var value = iterables[ii];
  27372. var iter = IndexedIterable(value);
  27373. if (iter.size > maxSize) {
  27374. maxSize = iter.size;
  27375. }
  27376. if (!isIterable(value)) {
  27377. iter = iter.map(function(v) {
  27378. return fromJS(v);
  27379. });
  27380. }
  27381. iters.push(iter);
  27382. }
  27383. if (maxSize > list.size) {
  27384. list = list.setSize(maxSize);
  27385. }
  27386. return mergeIntoCollectionWith(list, merger, iters);
  27387. }
  27388. function getTailOffset(size) {
  27389. return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT;
  27390. }
  27391. createClass(OrderedMap, Map);
  27392. // @pragma Construction
  27393. function OrderedMap(value) {
  27394. return value === null || value === undefined
  27395. ? emptyOrderedMap()
  27396. : isOrderedMap(value)
  27397. ? value
  27398. : emptyOrderedMap().withMutations(function(map) {
  27399. var iter = KeyedIterable(value);
  27400. assertNotInfinite(iter.size);
  27401. iter.forEach(function(v, k) {
  27402. return map.set(k, v);
  27403. });
  27404. });
  27405. }
  27406. OrderedMap.of = function(/*...values*/) {
  27407. return this(arguments);
  27408. };
  27409. OrderedMap.prototype.toString = function() {
  27410. return this.__toString("OrderedMap {", "}");
  27411. };
  27412. // @pragma Access
  27413. OrderedMap.prototype.get = function(k, notSetValue) {
  27414. var index = this._map.get(k);
  27415. return index !== undefined ? this._list.get(index)[1] : notSetValue;
  27416. };
  27417. // @pragma Modification
  27418. OrderedMap.prototype.clear = function() {
  27419. if (this.size === 0) {
  27420. return this;
  27421. }
  27422. if (this.__ownerID) {
  27423. this.size = 0;
  27424. this._map.clear();
  27425. this._list.clear();
  27426. return this;
  27427. }
  27428. return emptyOrderedMap();
  27429. };
  27430. OrderedMap.prototype.set = function(k, v) {
  27431. return updateOrderedMap(this, k, v);
  27432. };
  27433. OrderedMap.prototype.remove = function(k) {
  27434. return updateOrderedMap(this, k, NOT_SET);
  27435. };
  27436. OrderedMap.prototype.wasAltered = function() {
  27437. return this._map.wasAltered() || this._list.wasAltered();
  27438. };
  27439. OrderedMap.prototype.__iterate = function(fn, reverse) {
  27440. var this$0 = this;
  27441. return this._list.__iterate(function(entry) {
  27442. return entry && fn(entry[1], entry[0], this$0);
  27443. }, reverse);
  27444. };
  27445. OrderedMap.prototype.__iterator = function(type, reverse) {
  27446. return this._list.fromEntrySeq().__iterator(type, reverse);
  27447. };
  27448. OrderedMap.prototype.__ensureOwner = function(ownerID) {
  27449. if (ownerID === this.__ownerID) {
  27450. return this;
  27451. }
  27452. var newMap = this._map.__ensureOwner(ownerID);
  27453. var newList = this._list.__ensureOwner(ownerID);
  27454. if (!ownerID) {
  27455. this.__ownerID = ownerID;
  27456. this._map = newMap;
  27457. this._list = newList;
  27458. return this;
  27459. }
  27460. return makeOrderedMap(newMap, newList, ownerID, this.__hash);
  27461. };
  27462. function isOrderedMap(maybeOrderedMap) {
  27463. return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
  27464. }
  27465. OrderedMap.isOrderedMap = isOrderedMap;
  27466. OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
  27467. OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
  27468. function makeOrderedMap(map, list, ownerID, hash) {
  27469. var omap = Object.create(OrderedMap.prototype);
  27470. omap.size = map ? map.size : 0;
  27471. omap._map = map;
  27472. omap._list = list;
  27473. omap.__ownerID = ownerID;
  27474. omap.__hash = hash;
  27475. return omap;
  27476. }
  27477. var EMPTY_ORDERED_MAP;
  27478. function emptyOrderedMap() {
  27479. return (
  27480. EMPTY_ORDERED_MAP ||
  27481. (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()))
  27482. );
  27483. }
  27484. function updateOrderedMap(omap, k, v) {
  27485. var map = omap._map;
  27486. var list = omap._list;
  27487. var i = map.get(k);
  27488. var has = i !== undefined;
  27489. var newMap;
  27490. var newList;
  27491. if (v === NOT_SET) {
  27492. // removed
  27493. if (!has) {
  27494. return omap;
  27495. }
  27496. if (list.size >= SIZE && list.size >= map.size * 2) {
  27497. newList = list.filter(function(entry, idx) {
  27498. return entry !== undefined && i !== idx;
  27499. });
  27500. newMap = newList
  27501. .toKeyedSeq()
  27502. .map(function(entry) {
  27503. return entry[0];
  27504. })
  27505. .flip()
  27506. .toMap();
  27507. if (omap.__ownerID) {
  27508. newMap.__ownerID = newList.__ownerID = omap.__ownerID;
  27509. }
  27510. } else {
  27511. newMap = map.remove(k);
  27512. newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
  27513. }
  27514. } else {
  27515. if (has) {
  27516. if (v === list.get(i)[1]) {
  27517. return omap;
  27518. }
  27519. newMap = map;
  27520. newList = list.set(i, [k, v]);
  27521. } else {
  27522. newMap = map.set(k, list.size);
  27523. newList = list.set(list.size, [k, v]);
  27524. }
  27525. }
  27526. if (omap.__ownerID) {
  27527. omap.size = newMap.size;
  27528. omap._map = newMap;
  27529. omap._list = newList;
  27530. omap.__hash = undefined;
  27531. return omap;
  27532. }
  27533. return makeOrderedMap(newMap, newList);
  27534. }
  27535. createClass(ToKeyedSequence, KeyedSeq);
  27536. function ToKeyedSequence(indexed, useKeys) {
  27537. this._iter = indexed;
  27538. this._useKeys = useKeys;
  27539. this.size = indexed.size;
  27540. }
  27541. ToKeyedSequence.prototype.get = function(key, notSetValue) {
  27542. return this._iter.get(key, notSetValue);
  27543. };
  27544. ToKeyedSequence.prototype.has = function(key) {
  27545. return this._iter.has(key);
  27546. };
  27547. ToKeyedSequence.prototype.valueSeq = function() {
  27548. return this._iter.valueSeq();
  27549. };
  27550. ToKeyedSequence.prototype.reverse = function() {
  27551. var this$0 = this;
  27552. var reversedSequence = reverseFactory(this, true);
  27553. if (!this._useKeys) {
  27554. reversedSequence.valueSeq = function() {
  27555. return this$0._iter.toSeq().reverse();
  27556. };
  27557. }
  27558. return reversedSequence;
  27559. };
  27560. ToKeyedSequence.prototype.map = function(mapper, context) {
  27561. var this$0 = this;
  27562. var mappedSequence = mapFactory(this, mapper, context);
  27563. if (!this._useKeys) {
  27564. mappedSequence.valueSeq = function() {
  27565. return this$0._iter.toSeq().map(mapper, context);
  27566. };
  27567. }
  27568. return mappedSequence;
  27569. };
  27570. ToKeyedSequence.prototype.__iterate = function(fn, reverse) {
  27571. var this$0 = this;
  27572. var ii;
  27573. return this._iter.__iterate(
  27574. this._useKeys
  27575. ? function(v, k) {
  27576. return fn(v, k, this$0);
  27577. }
  27578. : ((ii = reverse ? resolveSize(this) : 0),
  27579. function(v) {
  27580. return fn(v, reverse ? --ii : ii++, this$0);
  27581. }),
  27582. reverse
  27583. );
  27584. };
  27585. ToKeyedSequence.prototype.__iterator = function(type, reverse) {
  27586. if (this._useKeys) {
  27587. return this._iter.__iterator(type, reverse);
  27588. }
  27589. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  27590. var ii = reverse ? resolveSize(this) : 0;
  27591. return new Iterator(function() {
  27592. var step = iterator.next();
  27593. return step.done
  27594. ? step
  27595. : iteratorValue(type, reverse ? --ii : ii++, step.value, step);
  27596. });
  27597. };
  27598. ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
  27599. createClass(ToIndexedSequence, IndexedSeq);
  27600. function ToIndexedSequence(iter) {
  27601. this._iter = iter;
  27602. this.size = iter.size;
  27603. }
  27604. ToIndexedSequence.prototype.includes = function(value) {
  27605. return this._iter.includes(value);
  27606. };
  27607. ToIndexedSequence.prototype.__iterate = function(fn, reverse) {
  27608. var this$0 = this;
  27609. var iterations = 0;
  27610. return this._iter.__iterate(function(v) {
  27611. return fn(v, iterations++, this$0);
  27612. }, reverse);
  27613. };
  27614. ToIndexedSequence.prototype.__iterator = function(type, reverse) {
  27615. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  27616. var iterations = 0;
  27617. return new Iterator(function() {
  27618. var step = iterator.next();
  27619. return step.done
  27620. ? step
  27621. : iteratorValue(type, iterations++, step.value, step);
  27622. });
  27623. };
  27624. createClass(ToSetSequence, SetSeq);
  27625. function ToSetSequence(iter) {
  27626. this._iter = iter;
  27627. this.size = iter.size;
  27628. }
  27629. ToSetSequence.prototype.has = function(key) {
  27630. return this._iter.includes(key);
  27631. };
  27632. ToSetSequence.prototype.__iterate = function(fn, reverse) {
  27633. var this$0 = this;
  27634. return this._iter.__iterate(function(v) {
  27635. return fn(v, v, this$0);
  27636. }, reverse);
  27637. };
  27638. ToSetSequence.prototype.__iterator = function(type, reverse) {
  27639. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  27640. return new Iterator(function() {
  27641. var step = iterator.next();
  27642. return step.done
  27643. ? step
  27644. : iteratorValue(type, step.value, step.value, step);
  27645. });
  27646. };
  27647. createClass(FromEntriesSequence, KeyedSeq);
  27648. function FromEntriesSequence(entries) {
  27649. this._iter = entries;
  27650. this.size = entries.size;
  27651. }
  27652. FromEntriesSequence.prototype.entrySeq = function() {
  27653. return this._iter.toSeq();
  27654. };
  27655. FromEntriesSequence.prototype.__iterate = function(fn, reverse) {
  27656. var this$0 = this;
  27657. return this._iter.__iterate(function(entry) {
  27658. // Check if entry exists first so array access doesn't throw for holes
  27659. // in the parent iteration.
  27660. if (entry) {
  27661. validateEntry(entry);
  27662. var indexedIterable = isIterable(entry);
  27663. return fn(
  27664. indexedIterable ? entry.get(1) : entry[1],
  27665. indexedIterable ? entry.get(0) : entry[0],
  27666. this$0
  27667. );
  27668. }
  27669. }, reverse);
  27670. };
  27671. FromEntriesSequence.prototype.__iterator = function(type, reverse) {
  27672. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  27673. return new Iterator(function() {
  27674. while (true) {
  27675. var step = iterator.next();
  27676. if (step.done) {
  27677. return step;
  27678. }
  27679. var entry = step.value;
  27680. // Check if entry exists first so array access doesn't throw for holes
  27681. // in the parent iteration.
  27682. if (entry) {
  27683. validateEntry(entry);
  27684. var indexedIterable = isIterable(entry);
  27685. return iteratorValue(
  27686. type,
  27687. indexedIterable ? entry.get(0) : entry[0],
  27688. indexedIterable ? entry.get(1) : entry[1],
  27689. step
  27690. );
  27691. }
  27692. }
  27693. });
  27694. };
  27695. ToIndexedSequence.prototype.cacheResult = ToKeyedSequence.prototype.cacheResult = ToSetSequence.prototype.cacheResult = FromEntriesSequence.prototype.cacheResult = cacheResultThrough;
  27696. function flipFactory(iterable) {
  27697. var flipSequence = makeSequence(iterable);
  27698. flipSequence._iter = iterable;
  27699. flipSequence.size = iterable.size;
  27700. flipSequence.flip = function() {
  27701. return iterable;
  27702. };
  27703. flipSequence.reverse = function() {
  27704. var reversedSequence = iterable.reverse.apply(this); // super.reverse()
  27705. reversedSequence.flip = function() {
  27706. return iterable.reverse();
  27707. };
  27708. return reversedSequence;
  27709. };
  27710. flipSequence.has = function(key) {
  27711. return iterable.includes(key);
  27712. };
  27713. flipSequence.includes = function(key) {
  27714. return iterable.has(key);
  27715. };
  27716. flipSequence.cacheResult = cacheResultThrough;
  27717. flipSequence.__iterateUncached = function(fn, reverse) {
  27718. var this$0 = this;
  27719. return iterable.__iterate(function(v, k) {
  27720. return fn(k, v, this$0) !== false;
  27721. }, reverse);
  27722. };
  27723. flipSequence.__iteratorUncached = function(type, reverse) {
  27724. if (type === ITERATE_ENTRIES) {
  27725. var iterator = iterable.__iterator(type, reverse);
  27726. return new Iterator(function() {
  27727. var step = iterator.next();
  27728. if (!step.done) {
  27729. var k = step.value[0];
  27730. step.value[0] = step.value[1];
  27731. step.value[1] = k;
  27732. }
  27733. return step;
  27734. });
  27735. }
  27736. return iterable.__iterator(
  27737. type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
  27738. reverse
  27739. );
  27740. };
  27741. return flipSequence;
  27742. }
  27743. function mapFactory(iterable, mapper, context) {
  27744. var mappedSequence = makeSequence(iterable);
  27745. mappedSequence.size = iterable.size;
  27746. mappedSequence.has = function(key) {
  27747. return iterable.has(key);
  27748. };
  27749. mappedSequence.get = function(key, notSetValue) {
  27750. var v = iterable.get(key, NOT_SET);
  27751. return v === NOT_SET
  27752. ? notSetValue
  27753. : mapper.call(context, v, key, iterable);
  27754. };
  27755. mappedSequence.__iterateUncached = function(fn, reverse) {
  27756. var this$0 = this;
  27757. return iterable.__iterate(function(v, k, c) {
  27758. return fn(mapper.call(context, v, k, c), k, this$0) !== false;
  27759. }, reverse);
  27760. };
  27761. mappedSequence.__iteratorUncached = function(type, reverse) {
  27762. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  27763. return new Iterator(function() {
  27764. var step = iterator.next();
  27765. if (step.done) {
  27766. return step;
  27767. }
  27768. var entry = step.value;
  27769. var key = entry[0];
  27770. return iteratorValue(
  27771. type,
  27772. key,
  27773. mapper.call(context, entry[1], key, iterable),
  27774. step
  27775. );
  27776. });
  27777. };
  27778. return mappedSequence;
  27779. }
  27780. function reverseFactory(iterable, useKeys) {
  27781. var reversedSequence = makeSequence(iterable);
  27782. reversedSequence._iter = iterable;
  27783. reversedSequence.size = iterable.size;
  27784. reversedSequence.reverse = function() {
  27785. return iterable;
  27786. };
  27787. if (iterable.flip) {
  27788. reversedSequence.flip = function() {
  27789. var flipSequence = flipFactory(iterable);
  27790. flipSequence.reverse = function() {
  27791. return iterable.flip();
  27792. };
  27793. return flipSequence;
  27794. };
  27795. }
  27796. reversedSequence.get = function(key, notSetValue) {
  27797. return iterable.get(useKeys ? key : -1 - key, notSetValue);
  27798. };
  27799. reversedSequence.has = function(key) {
  27800. return iterable.has(useKeys ? key : -1 - key);
  27801. };
  27802. reversedSequence.includes = function(value) {
  27803. return iterable.includes(value);
  27804. };
  27805. reversedSequence.cacheResult = cacheResultThrough;
  27806. reversedSequence.__iterate = function(fn, reverse) {
  27807. var this$0 = this;
  27808. return iterable.__iterate(function(v, k) {
  27809. return fn(v, k, this$0);
  27810. }, !reverse);
  27811. };
  27812. reversedSequence.__iterator = function(type, reverse) {
  27813. return iterable.__iterator(type, !reverse);
  27814. };
  27815. return reversedSequence;
  27816. }
  27817. function filterFactory(iterable, predicate, context, useKeys) {
  27818. var filterSequence = makeSequence(iterable);
  27819. if (useKeys) {
  27820. filterSequence.has = function(key) {
  27821. var v = iterable.get(key, NOT_SET);
  27822. return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
  27823. };
  27824. filterSequence.get = function(key, notSetValue) {
  27825. var v = iterable.get(key, NOT_SET);
  27826. return v !== NOT_SET && predicate.call(context, v, key, iterable)
  27827. ? v
  27828. : notSetValue;
  27829. };
  27830. }
  27831. filterSequence.__iterateUncached = function(fn, reverse) {
  27832. var this$0 = this;
  27833. var iterations = 0;
  27834. iterable.__iterate(function(v, k, c) {
  27835. if (predicate.call(context, v, k, c)) {
  27836. iterations++;
  27837. return fn(v, useKeys ? k : iterations - 1, this$0);
  27838. }
  27839. }, reverse);
  27840. return iterations;
  27841. };
  27842. filterSequence.__iteratorUncached = function(type, reverse) {
  27843. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  27844. var iterations = 0;
  27845. return new Iterator(function() {
  27846. while (true) {
  27847. var step = iterator.next();
  27848. if (step.done) {
  27849. return step;
  27850. }
  27851. var entry = step.value;
  27852. var key = entry[0];
  27853. var value = entry[1];
  27854. if (predicate.call(context, value, key, iterable)) {
  27855. return iteratorValue(
  27856. type,
  27857. useKeys ? key : iterations++,
  27858. value,
  27859. step
  27860. );
  27861. }
  27862. }
  27863. });
  27864. };
  27865. return filterSequence;
  27866. }
  27867. function countByFactory(iterable, grouper, context) {
  27868. var groups = Map().asMutable();
  27869. iterable.__iterate(function(v, k) {
  27870. groups.update(grouper.call(context, v, k, iterable), 0, function(a) {
  27871. return a + 1;
  27872. });
  27873. });
  27874. return groups.asImmutable();
  27875. }
  27876. function groupByFactory(iterable, grouper, context) {
  27877. var isKeyedIter = isKeyed(iterable);
  27878. var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
  27879. iterable.__iterate(function(v, k) {
  27880. groups.update(grouper.call(context, v, k, iterable), function(a) {
  27881. return (a = a || []), a.push(isKeyedIter ? [k, v] : v), a;
  27882. });
  27883. });
  27884. var coerce = iterableClass(iterable);
  27885. return groups.map(function(arr) {
  27886. return reify(iterable, coerce(arr));
  27887. });
  27888. }
  27889. function sliceFactory(iterable, begin, end, useKeys) {
  27890. var originalSize = iterable.size;
  27891. // Sanitize begin & end using this shorthand for ToInt32(argument)
  27892. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  27893. if (begin !== undefined) {
  27894. begin = begin | 0;
  27895. }
  27896. if (end !== undefined) {
  27897. end = end | 0;
  27898. }
  27899. if (wholeSlice(begin, end, originalSize)) {
  27900. return iterable;
  27901. }
  27902. var resolvedBegin = resolveBegin(begin, originalSize);
  27903. var resolvedEnd = resolveEnd(end, originalSize);
  27904. // begin or end will be NaN if they were provided as negative numbers and
  27905. // this iterable's size is unknown. In that case, cache first so there is
  27906. // a known size and these do not resolve to NaN.
  27907. if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
  27908. return sliceFactory(
  27909. iterable.toSeq().cacheResult(),
  27910. begin,
  27911. end,
  27912. useKeys
  27913. );
  27914. }
  27915. // Note: resolvedEnd is undefined when the original sequence's length is
  27916. // unknown and this slice did not supply an end and should contain all
  27917. // elements after resolvedBegin.
  27918. // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
  27919. var resolvedSize = resolvedEnd - resolvedBegin;
  27920. var sliceSize;
  27921. if (resolvedSize === resolvedSize) {
  27922. sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
  27923. }
  27924. var sliceSeq = makeSequence(iterable);
  27925. // If iterable.size is undefined, the size of the realized sliceSeq is
  27926. // unknown at this point unless the number of items to slice is 0
  27927. sliceSeq.size =
  27928. sliceSize === 0 ? sliceSize : (iterable.size && sliceSize) || undefined;
  27929. if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
  27930. sliceSeq.get = function(index, notSetValue) {
  27931. index = wrapIndex(this, index);
  27932. return index >= 0 && index < sliceSize
  27933. ? iterable.get(index + resolvedBegin, notSetValue)
  27934. : notSetValue;
  27935. };
  27936. }
  27937. sliceSeq.__iterateUncached = function(fn, reverse) {
  27938. var this$0 = this;
  27939. if (sliceSize === 0) {
  27940. return 0;
  27941. }
  27942. if (reverse) {
  27943. return this.cacheResult().__iterate(fn, reverse);
  27944. }
  27945. var skipped = 0;
  27946. var isSkipping = true;
  27947. var iterations = 0;
  27948. iterable.__iterate(function(v, k) {
  27949. if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
  27950. iterations++;
  27951. return (
  27952. fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
  27953. iterations !== sliceSize
  27954. );
  27955. }
  27956. });
  27957. return iterations;
  27958. };
  27959. sliceSeq.__iteratorUncached = function(type, reverse) {
  27960. if (sliceSize !== 0 && reverse) {
  27961. return this.cacheResult().__iterator(type, reverse);
  27962. }
  27963. // Don't bother instantiating parent iterator if taking 0.
  27964. var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
  27965. var skipped = 0;
  27966. var iterations = 0;
  27967. return new Iterator(function() {
  27968. while (skipped++ < resolvedBegin) {
  27969. iterator.next();
  27970. }
  27971. if (++iterations > sliceSize) {
  27972. return iteratorDone();
  27973. }
  27974. var step = iterator.next();
  27975. if (useKeys || type === ITERATE_VALUES) {
  27976. return step;
  27977. } else if (type === ITERATE_KEYS) {
  27978. return iteratorValue(type, iterations - 1, undefined, step);
  27979. } else {
  27980. return iteratorValue(type, iterations - 1, step.value[1], step);
  27981. }
  27982. });
  27983. };
  27984. return sliceSeq;
  27985. }
  27986. function takeWhileFactory(iterable, predicate, context) {
  27987. var takeSequence = makeSequence(iterable);
  27988. takeSequence.__iterateUncached = function(fn, reverse) {
  27989. var this$0 = this;
  27990. if (reverse) {
  27991. return this.cacheResult().__iterate(fn, reverse);
  27992. }
  27993. var iterations = 0;
  27994. iterable.__iterate(function(v, k, c) {
  27995. return (
  27996. predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)
  27997. );
  27998. });
  27999. return iterations;
  28000. };
  28001. takeSequence.__iteratorUncached = function(type, reverse) {
  28002. var this$0 = this;
  28003. if (reverse) {
  28004. return this.cacheResult().__iterator(type, reverse);
  28005. }
  28006. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  28007. var iterating = true;
  28008. return new Iterator(function() {
  28009. if (!iterating) {
  28010. return iteratorDone();
  28011. }
  28012. var step = iterator.next();
  28013. if (step.done) {
  28014. return step;
  28015. }
  28016. var entry = step.value;
  28017. var k = entry[0];
  28018. var v = entry[1];
  28019. if (!predicate.call(context, v, k, this$0)) {
  28020. iterating = false;
  28021. return iteratorDone();
  28022. }
  28023. return type === ITERATE_ENTRIES
  28024. ? step
  28025. : iteratorValue(type, k, v, step);
  28026. });
  28027. };
  28028. return takeSequence;
  28029. }
  28030. function skipWhileFactory(iterable, predicate, context, useKeys) {
  28031. var skipSequence = makeSequence(iterable);
  28032. skipSequence.__iterateUncached = function(fn, reverse) {
  28033. var this$0 = this;
  28034. if (reverse) {
  28035. return this.cacheResult().__iterate(fn, reverse);
  28036. }
  28037. var isSkipping = true;
  28038. var iterations = 0;
  28039. iterable.__iterate(function(v, k, c) {
  28040. if (
  28041. !(isSkipping && (isSkipping = predicate.call(context, v, k, c)))
  28042. ) {
  28043. iterations++;
  28044. return fn(v, useKeys ? k : iterations - 1, this$0);
  28045. }
  28046. });
  28047. return iterations;
  28048. };
  28049. skipSequence.__iteratorUncached = function(type, reverse) {
  28050. var this$0 = this;
  28051. if (reverse) {
  28052. return this.cacheResult().__iterator(type, reverse);
  28053. }
  28054. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  28055. var skipping = true;
  28056. var iterations = 0;
  28057. return new Iterator(function() {
  28058. var step, k, v;
  28059. do {
  28060. step = iterator.next();
  28061. if (step.done) {
  28062. if (useKeys || type === ITERATE_VALUES) {
  28063. return step;
  28064. } else if (type === ITERATE_KEYS) {
  28065. return iteratorValue(type, iterations++, undefined, step);
  28066. } else {
  28067. return iteratorValue(type, iterations++, step.value[1], step);
  28068. }
  28069. }
  28070. var entry = step.value;
  28071. k = entry[0];
  28072. v = entry[1];
  28073. skipping && (skipping = predicate.call(context, v, k, this$0));
  28074. } while (skipping);
  28075. return type === ITERATE_ENTRIES
  28076. ? step
  28077. : iteratorValue(type, k, v, step);
  28078. });
  28079. };
  28080. return skipSequence;
  28081. }
  28082. function concatFactory(iterable, values) {
  28083. var isKeyedIterable = isKeyed(iterable);
  28084. var iters = [iterable]
  28085. .concat(values)
  28086. .map(function(v) {
  28087. if (!isIterable(v)) {
  28088. v = isKeyedIterable
  28089. ? keyedSeqFromValue(v)
  28090. : indexedSeqFromValue(Array.isArray(v) ? v : [v]);
  28091. } else if (isKeyedIterable) {
  28092. v = KeyedIterable(v);
  28093. }
  28094. return v;
  28095. })
  28096. .filter(function(v) {
  28097. return v.size !== 0;
  28098. });
  28099. if (iters.length === 0) {
  28100. return iterable;
  28101. }
  28102. if (iters.length === 1) {
  28103. var singleton = iters[0];
  28104. if (
  28105. singleton === iterable ||
  28106. (isKeyedIterable && isKeyed(singleton)) ||
  28107. (isIndexed(iterable) && isIndexed(singleton))
  28108. ) {
  28109. return singleton;
  28110. }
  28111. }
  28112. var concatSeq = new ArraySeq(iters);
  28113. if (isKeyedIterable) {
  28114. concatSeq = concatSeq.toKeyedSeq();
  28115. } else if (!isIndexed(iterable)) {
  28116. concatSeq = concatSeq.toSetSeq();
  28117. }
  28118. concatSeq = concatSeq.flatten(true);
  28119. concatSeq.size = iters.reduce(function(sum, seq) {
  28120. if (sum !== undefined) {
  28121. var size = seq.size;
  28122. if (size !== undefined) {
  28123. return sum + size;
  28124. }
  28125. }
  28126. }, 0);
  28127. return concatSeq;
  28128. }
  28129. function flattenFactory(iterable, depth, useKeys) {
  28130. var flatSequence = makeSequence(iterable);
  28131. flatSequence.__iterateUncached = function(fn, reverse) {
  28132. var iterations = 0;
  28133. var stopped = false;
  28134. function flatDeep(iter, currentDepth) {
  28135. var this$0 = this;
  28136. iter.__iterate(function(v, k) {
  28137. if ((!depth || currentDepth < depth) && isIterable(v)) {
  28138. flatDeep(v, currentDepth + 1);
  28139. } else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
  28140. stopped = true;
  28141. }
  28142. return !stopped;
  28143. }, reverse);
  28144. }
  28145. flatDeep(iterable, 0);
  28146. return iterations;
  28147. };
  28148. flatSequence.__iteratorUncached = function(type, reverse) {
  28149. var iterator = iterable.__iterator(type, reverse);
  28150. var stack = [];
  28151. var iterations = 0;
  28152. return new Iterator(function() {
  28153. while (iterator) {
  28154. var step = iterator.next();
  28155. if (step.done !== false) {
  28156. iterator = stack.pop();
  28157. continue;
  28158. }
  28159. var v = step.value;
  28160. if (type === ITERATE_ENTRIES) {
  28161. v = v[1];
  28162. }
  28163. if ((!depth || stack.length < depth) && isIterable(v)) {
  28164. stack.push(iterator);
  28165. iterator = v.__iterator(type, reverse);
  28166. } else {
  28167. return useKeys
  28168. ? step
  28169. : iteratorValue(type, iterations++, v, step);
  28170. }
  28171. }
  28172. return iteratorDone();
  28173. });
  28174. };
  28175. return flatSequence;
  28176. }
  28177. function flatMapFactory(iterable, mapper, context) {
  28178. var coerce = iterableClass(iterable);
  28179. return iterable
  28180. .toSeq()
  28181. .map(function(v, k) {
  28182. return coerce(mapper.call(context, v, k, iterable));
  28183. })
  28184. .flatten(true);
  28185. }
  28186. function interposeFactory(iterable, separator) {
  28187. var interposedSequence = makeSequence(iterable);
  28188. interposedSequence.size = iterable.size && iterable.size * 2 - 1;
  28189. interposedSequence.__iterateUncached = function(fn, reverse) {
  28190. var this$0 = this;
  28191. var iterations = 0;
  28192. iterable.__iterate(function(v, k) {
  28193. return (
  28194. (!iterations || fn(separator, iterations++, this$0) !== false) &&
  28195. fn(v, iterations++, this$0) !== false
  28196. );
  28197. }, reverse);
  28198. return iterations;
  28199. };
  28200. interposedSequence.__iteratorUncached = function(type, reverse) {
  28201. var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
  28202. var iterations = 0;
  28203. var step;
  28204. return new Iterator(function() {
  28205. if (!step || iterations % 2) {
  28206. step = iterator.next();
  28207. if (step.done) {
  28208. return step;
  28209. }
  28210. }
  28211. return iterations % 2
  28212. ? iteratorValue(type, iterations++, separator)
  28213. : iteratorValue(type, iterations++, step.value, step);
  28214. });
  28215. };
  28216. return interposedSequence;
  28217. }
  28218. function sortFactory(iterable, comparator, mapper) {
  28219. if (!comparator) {
  28220. comparator = defaultComparator;
  28221. }
  28222. var isKeyedIterable = isKeyed(iterable);
  28223. var index = 0;
  28224. var entries = iterable
  28225. .toSeq()
  28226. .map(function(v, k) {
  28227. return [k, v, index++, mapper ? mapper(v, k, iterable) : v];
  28228. })
  28229. .toArray();
  28230. entries
  28231. .sort(function(a, b) {
  28232. return comparator(a[3], b[3]) || a[2] - b[2];
  28233. })
  28234. .forEach(
  28235. isKeyedIterable
  28236. ? function(v, i) {
  28237. entries[i].length = 2;
  28238. }
  28239. : function(v, i) {
  28240. entries[i] = v[1];
  28241. }
  28242. );
  28243. return isKeyedIterable
  28244. ? KeyedSeq(entries)
  28245. : isIndexed(iterable)
  28246. ? IndexedSeq(entries)
  28247. : SetSeq(entries);
  28248. }
  28249. function maxFactory(iterable, comparator, mapper) {
  28250. if (!comparator) {
  28251. comparator = defaultComparator;
  28252. }
  28253. if (mapper) {
  28254. var entry = iterable
  28255. .toSeq()
  28256. .map(function(v, k) {
  28257. return [v, mapper(v, k, iterable)];
  28258. })
  28259. .reduce(function(a, b) {
  28260. return maxCompare(comparator, a[1], b[1]) ? b : a;
  28261. });
  28262. return entry && entry[0];
  28263. } else {
  28264. return iterable.reduce(function(a, b) {
  28265. return maxCompare(comparator, a, b) ? b : a;
  28266. });
  28267. }
  28268. }
  28269. function maxCompare(comparator, a, b) {
  28270. var comp = comparator(b, a);
  28271. // b is considered the new max if the comparator declares them equal, but
  28272. // they are not equal and b is in fact a nullish value.
  28273. return (
  28274. (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) ||
  28275. comp > 0
  28276. );
  28277. }
  28278. function zipWithFactory(keyIter, zipper, iters) {
  28279. var zipSequence = makeSequence(keyIter);
  28280. zipSequence.size = new ArraySeq(iters)
  28281. .map(function(i) {
  28282. return i.size;
  28283. })
  28284. .min();
  28285. // Note: this a generic base implementation of __iterate in terms of
  28286. // __iterator which may be more generically useful in the future.
  28287. zipSequence.__iterate = function(fn, reverse) {
  28288. /* generic:
  28289. var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
  28290. var step;
  28291. var iterations = 0;
  28292. while (!(step = iterator.next()).done) {
  28293. iterations++;
  28294. if (fn(step.value[1], step.value[0], this) === false) {
  28295. break;
  28296. }
  28297. }
  28298. return iterations;
  28299. */
  28300. // indexed:
  28301. var iterator = this.__iterator(ITERATE_VALUES, reverse);
  28302. var step;
  28303. var iterations = 0;
  28304. while (!(step = iterator.next()).done) {
  28305. if (fn(step.value, iterations++, this) === false) {
  28306. break;
  28307. }
  28308. }
  28309. return iterations;
  28310. };
  28311. zipSequence.__iteratorUncached = function(type, reverse) {
  28312. var iterators = iters.map(function(i) {
  28313. return (i = Iterable(i)), getIterator(reverse ? i.reverse() : i);
  28314. });
  28315. var iterations = 0;
  28316. var isDone = false;
  28317. return new Iterator(function() {
  28318. var steps;
  28319. if (!isDone) {
  28320. steps = iterators.map(function(i) {
  28321. return i.next();
  28322. });
  28323. isDone = steps.some(function(s) {
  28324. return s.done;
  28325. });
  28326. }
  28327. if (isDone) {
  28328. return iteratorDone();
  28329. }
  28330. return iteratorValue(
  28331. type,
  28332. iterations++,
  28333. zipper.apply(
  28334. null,
  28335. steps.map(function(s) {
  28336. return s.value;
  28337. })
  28338. )
  28339. );
  28340. });
  28341. };
  28342. return zipSequence;
  28343. }
  28344. // #pragma Helper Functions
  28345. function reify(iter, seq) {
  28346. return isSeq(iter) ? seq : iter.constructor(seq);
  28347. }
  28348. function validateEntry(entry) {
  28349. if (entry !== Object(entry)) {
  28350. throw new TypeError("Expected [K, V] tuple: " + entry);
  28351. }
  28352. }
  28353. function resolveSize(iter) {
  28354. assertNotInfinite(iter.size);
  28355. return ensureSize(iter);
  28356. }
  28357. function iterableClass(iterable) {
  28358. return isKeyed(iterable)
  28359. ? KeyedIterable
  28360. : isIndexed(iterable)
  28361. ? IndexedIterable
  28362. : SetIterable;
  28363. }
  28364. function makeSequence(iterable) {
  28365. return Object.create(
  28366. (isKeyed(iterable)
  28367. ? KeyedSeq
  28368. : isIndexed(iterable)
  28369. ? IndexedSeq
  28370. : SetSeq
  28371. ).prototype
  28372. );
  28373. }
  28374. function cacheResultThrough() {
  28375. if (this._iter.cacheResult) {
  28376. this._iter.cacheResult();
  28377. this.size = this._iter.size;
  28378. return this;
  28379. } else {
  28380. return Seq.prototype.cacheResult.call(this);
  28381. }
  28382. }
  28383. function defaultComparator(a, b) {
  28384. return a > b ? 1 : a < b ? -1 : 0;
  28385. }
  28386. function forceIterator(keyPath) {
  28387. var iter = getIterator(keyPath);
  28388. if (!iter) {
  28389. // Array might not be iterable in this environment, so we need a fallback
  28390. // to our wrapped type.
  28391. if (!isArrayLike(keyPath)) {
  28392. throw new TypeError("Expected iterable or array-like: " + keyPath);
  28393. }
  28394. iter = getIterator(Iterable(keyPath));
  28395. }
  28396. return iter;
  28397. }
  28398. createClass(Record, KeyedCollection);
  28399. function Record(defaultValues, name) {
  28400. var hasInitialized;
  28401. var RecordType = function Record(values) {
  28402. if (values instanceof RecordType) {
  28403. return values;
  28404. }
  28405. if (!(this instanceof RecordType)) {
  28406. return new RecordType(values);
  28407. }
  28408. if (!hasInitialized) {
  28409. hasInitialized = true;
  28410. var keys = Object.keys(defaultValues);
  28411. setProps(RecordTypePrototype, keys);
  28412. RecordTypePrototype.size = keys.length;
  28413. RecordTypePrototype._name = name;
  28414. RecordTypePrototype._keys = keys;
  28415. RecordTypePrototype._defaultValues = defaultValues;
  28416. }
  28417. this._map = Map(values);
  28418. };
  28419. var RecordTypePrototype = (RecordType.prototype = Object.create(
  28420. RecordPrototype
  28421. ));
  28422. RecordTypePrototype.constructor = RecordType;
  28423. return RecordType;
  28424. }
  28425. Record.prototype.toString = function() {
  28426. return this.__toString(recordName(this) + " {", "}");
  28427. };
  28428. // @pragma Access
  28429. Record.prototype.has = function(k) {
  28430. return this._defaultValues.hasOwnProperty(k);
  28431. };
  28432. Record.prototype.get = function(k, notSetValue) {
  28433. if (!this.has(k)) {
  28434. return notSetValue;
  28435. }
  28436. var defaultVal = this._defaultValues[k];
  28437. return this._map ? this._map.get(k, defaultVal) : defaultVal;
  28438. };
  28439. // @pragma Modification
  28440. Record.prototype.clear = function() {
  28441. if (this.__ownerID) {
  28442. this._map && this._map.clear();
  28443. return this;
  28444. }
  28445. var RecordType = this.constructor;
  28446. return (
  28447. RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()))
  28448. );
  28449. };
  28450. Record.prototype.set = function(k, v) {
  28451. if (!this.has(k)) {
  28452. throw new Error(
  28453. 'Cannot set unknown key "' + k + '" on ' + recordName(this)
  28454. );
  28455. }
  28456. var newMap = this._map && this._map.set(k, v);
  28457. if (this.__ownerID || newMap === this._map) {
  28458. return this;
  28459. }
  28460. return makeRecord(this, newMap);
  28461. };
  28462. Record.prototype.remove = function(k) {
  28463. if (!this.has(k)) {
  28464. return this;
  28465. }
  28466. var newMap = this._map && this._map.remove(k);
  28467. if (this.__ownerID || newMap === this._map) {
  28468. return this;
  28469. }
  28470. return makeRecord(this, newMap);
  28471. };
  28472. Record.prototype.wasAltered = function() {
  28473. return this._map.wasAltered();
  28474. };
  28475. Record.prototype.__iterator = function(type, reverse) {
  28476. var this$0 = this;
  28477. return KeyedIterable(this._defaultValues)
  28478. .map(function(_, k) {
  28479. return this$0.get(k);
  28480. })
  28481. .__iterator(type, reverse);
  28482. };
  28483. Record.prototype.__iterate = function(fn, reverse) {
  28484. var this$0 = this;
  28485. return KeyedIterable(this._defaultValues)
  28486. .map(function(_, k) {
  28487. return this$0.get(k);
  28488. })
  28489. .__iterate(fn, reverse);
  28490. };
  28491. Record.prototype.__ensureOwner = function(ownerID) {
  28492. if (ownerID === this.__ownerID) {
  28493. return this;
  28494. }
  28495. var newMap = this._map && this._map.__ensureOwner(ownerID);
  28496. if (!ownerID) {
  28497. this.__ownerID = ownerID;
  28498. this._map = newMap;
  28499. return this;
  28500. }
  28501. return makeRecord(this, newMap, ownerID);
  28502. };
  28503. var RecordPrototype = Record.prototype;
  28504. RecordPrototype[DELETE] = RecordPrototype.remove;
  28505. RecordPrototype.deleteIn = RecordPrototype.removeIn = MapPrototype.removeIn;
  28506. RecordPrototype.merge = MapPrototype.merge;
  28507. RecordPrototype.mergeWith = MapPrototype.mergeWith;
  28508. RecordPrototype.mergeIn = MapPrototype.mergeIn;
  28509. RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
  28510. RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
  28511. RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  28512. RecordPrototype.setIn = MapPrototype.setIn;
  28513. RecordPrototype.update = MapPrototype.update;
  28514. RecordPrototype.updateIn = MapPrototype.updateIn;
  28515. RecordPrototype.withMutations = MapPrototype.withMutations;
  28516. RecordPrototype.asMutable = MapPrototype.asMutable;
  28517. RecordPrototype.asImmutable = MapPrototype.asImmutable;
  28518. function makeRecord(likeRecord, map, ownerID) {
  28519. var record = Object.create(Object.getPrototypeOf(likeRecord));
  28520. record._map = map;
  28521. record.__ownerID = ownerID;
  28522. return record;
  28523. }
  28524. function recordName(record) {
  28525. return record._name || record.constructor.name || "Record";
  28526. }
  28527. function setProps(prototype, names) {
  28528. try {
  28529. names.forEach(setProp.bind(undefined, prototype));
  28530. } catch (error) {
  28531. // Object.defineProperty failed. Probably IE8.
  28532. }
  28533. }
  28534. function setProp(prototype, name) {
  28535. Object.defineProperty(prototype, name, {
  28536. get: function() {
  28537. return this.get(name);
  28538. },
  28539. set: function(value) {
  28540. invariant(this.__ownerID, "Cannot set on an immutable record.");
  28541. this.set(name, value);
  28542. }
  28543. });
  28544. }
  28545. createClass(Set, SetCollection);
  28546. // @pragma Construction
  28547. function Set(value) {
  28548. return value === null || value === undefined
  28549. ? emptySet()
  28550. : isSet(value) && !isOrdered(value)
  28551. ? value
  28552. : emptySet().withMutations(function(set) {
  28553. var iter = SetIterable(value);
  28554. assertNotInfinite(iter.size);
  28555. iter.forEach(function(v) {
  28556. return set.add(v);
  28557. });
  28558. });
  28559. }
  28560. Set.of = function(/*...values*/) {
  28561. return this(arguments);
  28562. };
  28563. Set.fromKeys = function(value) {
  28564. return this(KeyedIterable(value).keySeq());
  28565. };
  28566. Set.prototype.toString = function() {
  28567. return this.__toString("Set {", "}");
  28568. };
  28569. // @pragma Access
  28570. Set.prototype.has = function(value) {
  28571. return this._map.has(value);
  28572. };
  28573. // @pragma Modification
  28574. Set.prototype.add = function(value) {
  28575. return updateSet(this, this._map.set(value, true));
  28576. };
  28577. Set.prototype.remove = function(value) {
  28578. return updateSet(this, this._map.remove(value));
  28579. };
  28580. Set.prototype.clear = function() {
  28581. return updateSet(this, this._map.clear());
  28582. };
  28583. // @pragma Composition
  28584. Set.prototype.union = function() {
  28585. var iters = SLICE$0.call(arguments, 0);
  28586. iters = iters.filter(function(x) {
  28587. return x.size !== 0;
  28588. });
  28589. if (iters.length === 0) {
  28590. return this;
  28591. }
  28592. if (this.size === 0 && !this.__ownerID && iters.length === 1) {
  28593. return this.constructor(iters[0]);
  28594. }
  28595. return this.withMutations(function(set) {
  28596. for (var ii = 0; ii < iters.length; ii++) {
  28597. SetIterable(iters[ii]).forEach(function(value) {
  28598. return set.add(value);
  28599. });
  28600. }
  28601. });
  28602. };
  28603. Set.prototype.intersect = function() {
  28604. var iters = SLICE$0.call(arguments, 0);
  28605. if (iters.length === 0) {
  28606. return this;
  28607. }
  28608. iters = iters.map(function(iter) {
  28609. return SetIterable(iter);
  28610. });
  28611. var originalSet = this;
  28612. return this.withMutations(function(set) {
  28613. originalSet.forEach(function(value) {
  28614. if (
  28615. !iters.every(function(iter) {
  28616. return iter.includes(value);
  28617. })
  28618. ) {
  28619. set.remove(value);
  28620. }
  28621. });
  28622. });
  28623. };
  28624. Set.prototype.subtract = function() {
  28625. var iters = SLICE$0.call(arguments, 0);
  28626. if (iters.length === 0) {
  28627. return this;
  28628. }
  28629. iters = iters.map(function(iter) {
  28630. return SetIterable(iter);
  28631. });
  28632. var originalSet = this;
  28633. return this.withMutations(function(set) {
  28634. originalSet.forEach(function(value) {
  28635. if (
  28636. iters.some(function(iter) {
  28637. return iter.includes(value);
  28638. })
  28639. ) {
  28640. set.remove(value);
  28641. }
  28642. });
  28643. });
  28644. };
  28645. Set.prototype.merge = function() {
  28646. return this.union.apply(this, arguments);
  28647. };
  28648. Set.prototype.mergeWith = function(merger) {
  28649. var iters = SLICE$0.call(arguments, 1);
  28650. return this.union.apply(this, iters);
  28651. };
  28652. Set.prototype.sort = function(comparator) {
  28653. // Late binding
  28654. return OrderedSet(sortFactory(this, comparator));
  28655. };
  28656. Set.prototype.sortBy = function(mapper, comparator) {
  28657. // Late binding
  28658. return OrderedSet(sortFactory(this, comparator, mapper));
  28659. };
  28660. Set.prototype.wasAltered = function() {
  28661. return this._map.wasAltered();
  28662. };
  28663. Set.prototype.__iterate = function(fn, reverse) {
  28664. var this$0 = this;
  28665. return this._map.__iterate(function(_, k) {
  28666. return fn(k, k, this$0);
  28667. }, reverse);
  28668. };
  28669. Set.prototype.__iterator = function(type, reverse) {
  28670. return this._map
  28671. .map(function(_, k) {
  28672. return k;
  28673. })
  28674. .__iterator(type, reverse);
  28675. };
  28676. Set.prototype.__ensureOwner = function(ownerID) {
  28677. if (ownerID === this.__ownerID) {
  28678. return this;
  28679. }
  28680. var newMap = this._map.__ensureOwner(ownerID);
  28681. if (!ownerID) {
  28682. this.__ownerID = ownerID;
  28683. this._map = newMap;
  28684. return this;
  28685. }
  28686. return this.__make(newMap, ownerID);
  28687. };
  28688. function isSet(maybeSet) {
  28689. return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
  28690. }
  28691. Set.isSet = isSet;
  28692. var IS_SET_SENTINEL = "@@__IMMUTABLE_SET__@@";
  28693. var SetPrototype = Set.prototype;
  28694. SetPrototype[IS_SET_SENTINEL] = true;
  28695. SetPrototype[DELETE] = SetPrototype.remove;
  28696. SetPrototype.mergeDeep = SetPrototype.merge;
  28697. SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
  28698. SetPrototype.withMutations = MapPrototype.withMutations;
  28699. SetPrototype.asMutable = MapPrototype.asMutable;
  28700. SetPrototype.asImmutable = MapPrototype.asImmutable;
  28701. SetPrototype.__empty = emptySet;
  28702. SetPrototype.__make = makeSet;
  28703. function updateSet(set, newMap) {
  28704. if (set.__ownerID) {
  28705. set.size = newMap.size;
  28706. set._map = newMap;
  28707. return set;
  28708. }
  28709. return newMap === set._map
  28710. ? set
  28711. : newMap.size === 0
  28712. ? set.__empty()
  28713. : set.__make(newMap);
  28714. }
  28715. function makeSet(map, ownerID) {
  28716. var set = Object.create(SetPrototype);
  28717. set.size = map ? map.size : 0;
  28718. set._map = map;
  28719. set.__ownerID = ownerID;
  28720. return set;
  28721. }
  28722. var EMPTY_SET;
  28723. function emptySet() {
  28724. return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
  28725. }
  28726. createClass(OrderedSet, Set);
  28727. // @pragma Construction
  28728. function OrderedSet(value) {
  28729. return value === null || value === undefined
  28730. ? emptyOrderedSet()
  28731. : isOrderedSet(value)
  28732. ? value
  28733. : emptyOrderedSet().withMutations(function(set) {
  28734. var iter = SetIterable(value);
  28735. assertNotInfinite(iter.size);
  28736. iter.forEach(function(v) {
  28737. return set.add(v);
  28738. });
  28739. });
  28740. }
  28741. OrderedSet.of = function(/*...values*/) {
  28742. return this(arguments);
  28743. };
  28744. OrderedSet.fromKeys = function(value) {
  28745. return this(KeyedIterable(value).keySeq());
  28746. };
  28747. OrderedSet.prototype.toString = function() {
  28748. return this.__toString("OrderedSet {", "}");
  28749. };
  28750. function isOrderedSet(maybeOrderedSet) {
  28751. return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
  28752. }
  28753. OrderedSet.isOrderedSet = isOrderedSet;
  28754. var OrderedSetPrototype = OrderedSet.prototype;
  28755. OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
  28756. OrderedSetPrototype.__empty = emptyOrderedSet;
  28757. OrderedSetPrototype.__make = makeOrderedSet;
  28758. function makeOrderedSet(map, ownerID) {
  28759. var set = Object.create(OrderedSetPrototype);
  28760. set.size = map ? map.size : 0;
  28761. set._map = map;
  28762. set.__ownerID = ownerID;
  28763. return set;
  28764. }
  28765. var EMPTY_ORDERED_SET;
  28766. function emptyOrderedSet() {
  28767. return (
  28768. EMPTY_ORDERED_SET ||
  28769. (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()))
  28770. );
  28771. }
  28772. createClass(Stack, IndexedCollection);
  28773. // @pragma Construction
  28774. function Stack(value) {
  28775. return value === null || value === undefined
  28776. ? emptyStack()
  28777. : isStack(value)
  28778. ? value
  28779. : emptyStack().unshiftAll(value);
  28780. }
  28781. Stack.of = function(/*...values*/) {
  28782. return this(arguments);
  28783. };
  28784. Stack.prototype.toString = function() {
  28785. return this.__toString("Stack [", "]");
  28786. };
  28787. // @pragma Access
  28788. Stack.prototype.get = function(index, notSetValue) {
  28789. var head = this._head;
  28790. index = wrapIndex(this, index);
  28791. while (head && index--) {
  28792. head = head.next;
  28793. }
  28794. return head ? head.value : notSetValue;
  28795. };
  28796. Stack.prototype.peek = function() {
  28797. return this._head && this._head.value;
  28798. };
  28799. // @pragma Modification
  28800. Stack.prototype.push = function(/*...values*/) {
  28801. if (arguments.length === 0) {
  28802. return this;
  28803. }
  28804. var newSize = this.size + arguments.length;
  28805. var head = this._head;
  28806. for (var ii = arguments.length - 1; ii >= 0; ii--) {
  28807. head = {
  28808. value: arguments[ii],
  28809. next: head
  28810. };
  28811. }
  28812. if (this.__ownerID) {
  28813. this.size = newSize;
  28814. this._head = head;
  28815. this.__hash = undefined;
  28816. this.__altered = true;
  28817. return this;
  28818. }
  28819. return makeStack(newSize, head);
  28820. };
  28821. Stack.prototype.pushAll = function(iter) {
  28822. iter = IndexedIterable(iter);
  28823. if (iter.size === 0) {
  28824. return this;
  28825. }
  28826. assertNotInfinite(iter.size);
  28827. var newSize = this.size;
  28828. var head = this._head;
  28829. iter.reverse().forEach(function(value) {
  28830. newSize++;
  28831. head = {
  28832. value: value,
  28833. next: head
  28834. };
  28835. });
  28836. if (this.__ownerID) {
  28837. this.size = newSize;
  28838. this._head = head;
  28839. this.__hash = undefined;
  28840. this.__altered = true;
  28841. return this;
  28842. }
  28843. return makeStack(newSize, head);
  28844. };
  28845. Stack.prototype.pop = function() {
  28846. return this.slice(1);
  28847. };
  28848. Stack.prototype.unshift = function(/*...values*/) {
  28849. return this.push.apply(this, arguments);
  28850. };
  28851. Stack.prototype.unshiftAll = function(iter) {
  28852. return this.pushAll(iter);
  28853. };
  28854. Stack.prototype.shift = function() {
  28855. return this.pop.apply(this, arguments);
  28856. };
  28857. Stack.prototype.clear = function() {
  28858. if (this.size === 0) {
  28859. return this;
  28860. }
  28861. if (this.__ownerID) {
  28862. this.size = 0;
  28863. this._head = undefined;
  28864. this.__hash = undefined;
  28865. this.__altered = true;
  28866. return this;
  28867. }
  28868. return emptyStack();
  28869. };
  28870. Stack.prototype.slice = function(begin, end) {
  28871. if (wholeSlice(begin, end, this.size)) {
  28872. return this;
  28873. }
  28874. var resolvedBegin = resolveBegin(begin, this.size);
  28875. var resolvedEnd = resolveEnd(end, this.size);
  28876. if (resolvedEnd !== this.size) {
  28877. // super.slice(begin, end);
  28878. return IndexedCollection.prototype.slice.call(this, begin, end);
  28879. }
  28880. var newSize = this.size - resolvedBegin;
  28881. var head = this._head;
  28882. while (resolvedBegin--) {
  28883. head = head.next;
  28884. }
  28885. if (this.__ownerID) {
  28886. this.size = newSize;
  28887. this._head = head;
  28888. this.__hash = undefined;
  28889. this.__altered = true;
  28890. return this;
  28891. }
  28892. return makeStack(newSize, head);
  28893. };
  28894. // @pragma Mutability
  28895. Stack.prototype.__ensureOwner = function(ownerID) {
  28896. if (ownerID === this.__ownerID) {
  28897. return this;
  28898. }
  28899. if (!ownerID) {
  28900. this.__ownerID = ownerID;
  28901. this.__altered = false;
  28902. return this;
  28903. }
  28904. return makeStack(this.size, this._head, ownerID, this.__hash);
  28905. };
  28906. // @pragma Iteration
  28907. Stack.prototype.__iterate = function(fn, reverse) {
  28908. if (reverse) {
  28909. return this.reverse().__iterate(fn);
  28910. }
  28911. var iterations = 0;
  28912. var node = this._head;
  28913. while (node) {
  28914. if (fn(node.value, iterations++, this) === false) {
  28915. break;
  28916. }
  28917. node = node.next;
  28918. }
  28919. return iterations;
  28920. };
  28921. Stack.prototype.__iterator = function(type, reverse) {
  28922. if (reverse) {
  28923. return this.reverse().__iterator(type);
  28924. }
  28925. var iterations = 0;
  28926. var node = this._head;
  28927. return new Iterator(function() {
  28928. if (node) {
  28929. var value = node.value;
  28930. node = node.next;
  28931. return iteratorValue(type, iterations++, value);
  28932. }
  28933. return iteratorDone();
  28934. });
  28935. };
  28936. function isStack(maybeStack) {
  28937. return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
  28938. }
  28939. Stack.isStack = isStack;
  28940. var IS_STACK_SENTINEL = "@@__IMMUTABLE_STACK__@@";
  28941. var StackPrototype = Stack.prototype;
  28942. StackPrototype[IS_STACK_SENTINEL] = true;
  28943. StackPrototype.withMutations = MapPrototype.withMutations;
  28944. StackPrototype.asMutable = MapPrototype.asMutable;
  28945. StackPrototype.asImmutable = MapPrototype.asImmutable;
  28946. StackPrototype.wasAltered = MapPrototype.wasAltered;
  28947. function makeStack(size, head, ownerID, hash) {
  28948. var map = Object.create(StackPrototype);
  28949. map.size = size;
  28950. map._head = head;
  28951. map.__ownerID = ownerID;
  28952. map.__hash = hash;
  28953. map.__altered = false;
  28954. return map;
  28955. }
  28956. var EMPTY_STACK;
  28957. function emptyStack() {
  28958. return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
  28959. }
  28960. /**
  28961. * Contributes additional methods to a constructor
  28962. */
  28963. function mixin(ctor, methods) {
  28964. var keyCopier = function(key) {
  28965. ctor.prototype[key] = methods[key];
  28966. };
  28967. Object.keys(methods).forEach(keyCopier);
  28968. Object.getOwnPropertySymbols &&
  28969. Object.getOwnPropertySymbols(methods).forEach(keyCopier);
  28970. return ctor;
  28971. }
  28972. Iterable.Iterator = Iterator;
  28973. mixin(Iterable, {
  28974. // ### Conversion to other types
  28975. toArray: function() {
  28976. assertNotInfinite(this.size);
  28977. var array = new Array(this.size || 0);
  28978. this.valueSeq().__iterate(function(v, i) {
  28979. array[i] = v;
  28980. });
  28981. return array;
  28982. },
  28983. toIndexedSeq: function() {
  28984. return new ToIndexedSequence(this);
  28985. },
  28986. toJS: function() {
  28987. return this.toSeq()
  28988. .map(function(value) {
  28989. return value && typeof value.toJS === "function"
  28990. ? value.toJS()
  28991. : value;
  28992. })
  28993. .__toJS();
  28994. },
  28995. toJSON: function() {
  28996. return this.toSeq()
  28997. .map(function(value) {
  28998. return value && typeof value.toJSON === "function"
  28999. ? value.toJSON()
  29000. : value;
  29001. })
  29002. .__toJS();
  29003. },
  29004. toKeyedSeq: function() {
  29005. return new ToKeyedSequence(this, true);
  29006. },
  29007. toMap: function() {
  29008. // Use Late Binding here to solve the circular dependency.
  29009. return Map(this.toKeyedSeq());
  29010. },
  29011. toObject: function() {
  29012. assertNotInfinite(this.size);
  29013. var object = {};
  29014. this.__iterate(function(v, k) {
  29015. object[k] = v;
  29016. });
  29017. return object;
  29018. },
  29019. toOrderedMap: function() {
  29020. // Use Late Binding here to solve the circular dependency.
  29021. return OrderedMap(this.toKeyedSeq());
  29022. },
  29023. toOrderedSet: function() {
  29024. // Use Late Binding here to solve the circular dependency.
  29025. return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
  29026. },
  29027. toSet: function() {
  29028. // Use Late Binding here to solve the circular dependency.
  29029. return Set(isKeyed(this) ? this.valueSeq() : this);
  29030. },
  29031. toSetSeq: function() {
  29032. return new ToSetSequence(this);
  29033. },
  29034. toSeq: function() {
  29035. return isIndexed(this)
  29036. ? this.toIndexedSeq()
  29037. : isKeyed(this)
  29038. ? this.toKeyedSeq()
  29039. : this.toSetSeq();
  29040. },
  29041. toStack: function() {
  29042. // Use Late Binding here to solve the circular dependency.
  29043. return Stack(isKeyed(this) ? this.valueSeq() : this);
  29044. },
  29045. toList: function() {
  29046. // Use Late Binding here to solve the circular dependency.
  29047. return List(isKeyed(this) ? this.valueSeq() : this);
  29048. },
  29049. // ### Common JavaScript methods and properties
  29050. toString: function() {
  29051. return "[Iterable]";
  29052. },
  29053. __toString: function(head, tail) {
  29054. if (this.size === 0) {
  29055. return head + tail;
  29056. }
  29057. return (
  29058. head +
  29059. " " +
  29060. this.toSeq()
  29061. .map(this.__toStringMapper)
  29062. .join(", ") +
  29063. " " +
  29064. tail
  29065. );
  29066. },
  29067. // ### ES6 Collection methods (ES6 Array and Map)
  29068. concat: function() {
  29069. var values = SLICE$0.call(arguments, 0);
  29070. return reify(this, concatFactory(this, values));
  29071. },
  29072. includes: function(searchValue) {
  29073. return this.some(function(value) {
  29074. return is(value, searchValue);
  29075. });
  29076. },
  29077. entries: function() {
  29078. return this.__iterator(ITERATE_ENTRIES);
  29079. },
  29080. every: function(predicate, context) {
  29081. assertNotInfinite(this.size);
  29082. var returnValue = true;
  29083. this.__iterate(function(v, k, c) {
  29084. if (!predicate.call(context, v, k, c)) {
  29085. returnValue = false;
  29086. return false;
  29087. }
  29088. });
  29089. return returnValue;
  29090. },
  29091. filter: function(predicate, context) {
  29092. return reify(this, filterFactory(this, predicate, context, true));
  29093. },
  29094. find: function(predicate, context, notSetValue) {
  29095. var entry = this.findEntry(predicate, context);
  29096. return entry ? entry[1] : notSetValue;
  29097. },
  29098. findEntry: function(predicate, context) {
  29099. var found;
  29100. this.__iterate(function(v, k, c) {
  29101. if (predicate.call(context, v, k, c)) {
  29102. found = [k, v];
  29103. return false;
  29104. }
  29105. });
  29106. return found;
  29107. },
  29108. findLastEntry: function(predicate, context) {
  29109. return this.toSeq()
  29110. .reverse()
  29111. .findEntry(predicate, context);
  29112. },
  29113. forEach: function(sideEffect, context) {
  29114. assertNotInfinite(this.size);
  29115. return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
  29116. },
  29117. join: function(separator) {
  29118. assertNotInfinite(this.size);
  29119. separator = separator !== undefined ? "" + separator : ",";
  29120. var joined = "";
  29121. var isFirst = true;
  29122. this.__iterate(function(v) {
  29123. isFirst ? (isFirst = false) : (joined += separator);
  29124. joined += v !== null && v !== undefined ? v.toString() : "";
  29125. });
  29126. return joined;
  29127. },
  29128. keys: function() {
  29129. return this.__iterator(ITERATE_KEYS);
  29130. },
  29131. map: function(mapper, context) {
  29132. return reify(this, mapFactory(this, mapper, context));
  29133. },
  29134. reduce: function(reducer, initialReduction, context) {
  29135. assertNotInfinite(this.size);
  29136. var reduction;
  29137. var useFirst;
  29138. if (arguments.length < 2) {
  29139. useFirst = true;
  29140. } else {
  29141. reduction = initialReduction;
  29142. }
  29143. this.__iterate(function(v, k, c) {
  29144. if (useFirst) {
  29145. useFirst = false;
  29146. reduction = v;
  29147. } else {
  29148. reduction = reducer.call(context, reduction, v, k, c);
  29149. }
  29150. });
  29151. return reduction;
  29152. },
  29153. reduceRight: function(reducer, initialReduction, context) {
  29154. var reversed = this.toKeyedSeq().reverse();
  29155. return reversed.reduce.apply(reversed, arguments);
  29156. },
  29157. reverse: function() {
  29158. return reify(this, reverseFactory(this, true));
  29159. },
  29160. slice: function(begin, end) {
  29161. return reify(this, sliceFactory(this, begin, end, true));
  29162. },
  29163. some: function(predicate, context) {
  29164. return !this.every(not(predicate), context);
  29165. },
  29166. sort: function(comparator) {
  29167. return reify(this, sortFactory(this, comparator));
  29168. },
  29169. values: function() {
  29170. return this.__iterator(ITERATE_VALUES);
  29171. },
  29172. // ### More sequential methods
  29173. butLast: function() {
  29174. return this.slice(0, -1);
  29175. },
  29176. isEmpty: function() {
  29177. return this.size !== undefined
  29178. ? this.size === 0
  29179. : !this.some(function() {
  29180. return true;
  29181. });
  29182. },
  29183. count: function(predicate, context) {
  29184. return ensureSize(
  29185. predicate ? this.toSeq().filter(predicate, context) : this
  29186. );
  29187. },
  29188. countBy: function(grouper, context) {
  29189. return countByFactory(this, grouper, context);
  29190. },
  29191. equals: function(other) {
  29192. return deepEqual(this, other);
  29193. },
  29194. entrySeq: function() {
  29195. var iterable = this;
  29196. if (iterable._cache) {
  29197. // We cache as an entries array, so we can just return the cache!
  29198. return new ArraySeq(iterable._cache);
  29199. }
  29200. var entriesSequence = iterable
  29201. .toSeq()
  29202. .map(entryMapper)
  29203. .toIndexedSeq();
  29204. entriesSequence.fromEntrySeq = function() {
  29205. return iterable.toSeq();
  29206. };
  29207. return entriesSequence;
  29208. },
  29209. filterNot: function(predicate, context) {
  29210. return this.filter(not(predicate), context);
  29211. },
  29212. findLast: function(predicate, context, notSetValue) {
  29213. return this.toKeyedSeq()
  29214. .reverse()
  29215. .find(predicate, context, notSetValue);
  29216. },
  29217. first: function() {
  29218. return this.find(returnTrue);
  29219. },
  29220. flatMap: function(mapper, context) {
  29221. return reify(this, flatMapFactory(this, mapper, context));
  29222. },
  29223. flatten: function(depth) {
  29224. return reify(this, flattenFactory(this, depth, true));
  29225. },
  29226. fromEntrySeq: function() {
  29227. return new FromEntriesSequence(this);
  29228. },
  29229. get: function(searchKey, notSetValue) {
  29230. return this.find(
  29231. function(_, key) {
  29232. return is(key, searchKey);
  29233. },
  29234. undefined,
  29235. notSetValue
  29236. );
  29237. },
  29238. getIn: function(searchKeyPath, notSetValue) {
  29239. var nested = this;
  29240. // Note: in an ES6 environment, we would prefer:
  29241. // for (var key of searchKeyPath) {
  29242. var iter = forceIterator(searchKeyPath);
  29243. var step;
  29244. while (!(step = iter.next()).done) {
  29245. var key = step.value;
  29246. nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
  29247. if (nested === NOT_SET) {
  29248. return notSetValue;
  29249. }
  29250. }
  29251. return nested;
  29252. },
  29253. groupBy: function(grouper, context) {
  29254. return groupByFactory(this, grouper, context);
  29255. },
  29256. has: function(searchKey) {
  29257. return this.get(searchKey, NOT_SET) !== NOT_SET;
  29258. },
  29259. hasIn: function(searchKeyPath) {
  29260. return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
  29261. },
  29262. isSubset: function(iter) {
  29263. iter = typeof iter.includes === "function" ? iter : Iterable(iter);
  29264. return this.every(function(value) {
  29265. return iter.includes(value);
  29266. });
  29267. },
  29268. isSuperset: function(iter) {
  29269. iter = typeof iter.isSubset === "function" ? iter : Iterable(iter);
  29270. return iter.isSubset(this);
  29271. },
  29272. keySeq: function() {
  29273. return this.toSeq()
  29274. .map(keyMapper)
  29275. .toIndexedSeq();
  29276. },
  29277. last: function() {
  29278. return this.toSeq()
  29279. .reverse()
  29280. .first();
  29281. },
  29282. max: function(comparator) {
  29283. return maxFactory(this, comparator);
  29284. },
  29285. maxBy: function(mapper, comparator) {
  29286. return maxFactory(this, comparator, mapper);
  29287. },
  29288. min: function(comparator) {
  29289. return maxFactory(
  29290. this,
  29291. comparator ? neg(comparator) : defaultNegComparator
  29292. );
  29293. },
  29294. minBy: function(mapper, comparator) {
  29295. return maxFactory(
  29296. this,
  29297. comparator ? neg(comparator) : defaultNegComparator,
  29298. mapper
  29299. );
  29300. },
  29301. rest: function() {
  29302. return this.slice(1);
  29303. },
  29304. skip: function(amount) {
  29305. return this.slice(Math.max(0, amount));
  29306. },
  29307. skipLast: function(amount) {
  29308. return reify(
  29309. this,
  29310. this.toSeq()
  29311. .reverse()
  29312. .skip(amount)
  29313. .reverse()
  29314. );
  29315. },
  29316. skipWhile: function(predicate, context) {
  29317. return reify(this, skipWhileFactory(this, predicate, context, true));
  29318. },
  29319. skipUntil: function(predicate, context) {
  29320. return this.skipWhile(not(predicate), context);
  29321. },
  29322. sortBy: function(mapper, comparator) {
  29323. return reify(this, sortFactory(this, comparator, mapper));
  29324. },
  29325. take: function(amount) {
  29326. return this.slice(0, Math.max(0, amount));
  29327. },
  29328. takeLast: function(amount) {
  29329. return reify(
  29330. this,
  29331. this.toSeq()
  29332. .reverse()
  29333. .take(amount)
  29334. .reverse()
  29335. );
  29336. },
  29337. takeWhile: function(predicate, context) {
  29338. return reify(this, takeWhileFactory(this, predicate, context));
  29339. },
  29340. takeUntil: function(predicate, context) {
  29341. return this.takeWhile(not(predicate), context);
  29342. },
  29343. valueSeq: function() {
  29344. return this.toIndexedSeq();
  29345. },
  29346. // ### Hashable Object
  29347. hashCode: function() {
  29348. return this.__hash || (this.__hash = hashIterable(this));
  29349. }
  29350. // ### Internal
  29351. // abstract __iterate(fn, reverse)
  29352. // abstract __iterator(type, reverse)
  29353. });
  29354. // var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  29355. // var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  29356. // var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  29357. // var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  29358. var IterablePrototype = Iterable.prototype;
  29359. IterablePrototype[IS_ITERABLE_SENTINEL] = true;
  29360. IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
  29361. IterablePrototype.__toJS = IterablePrototype.toArray;
  29362. IterablePrototype.__toStringMapper = quoteString;
  29363. IterablePrototype.inspect = IterablePrototype.toSource = function() {
  29364. return this.toString();
  29365. };
  29366. IterablePrototype.chain = IterablePrototype.flatMap;
  29367. IterablePrototype.contains = IterablePrototype.includes;
  29368. // Temporary warning about using length
  29369. (function() {
  29370. try {
  29371. Object.defineProperty(IterablePrototype, "length", {
  29372. get: function() {
  29373. if (!Iterable.noLengthWarning) {
  29374. var stack;
  29375. try {
  29376. throw new Error();
  29377. } catch (error) {
  29378. stack = error.stack;
  29379. }
  29380. if (stack.indexOf("_wrapObject") === -1) {
  29381. console &&
  29382. console.warn &&
  29383. console.warn(
  29384. "iterable.length has been deprecated, " +
  29385. "use iterable.size or iterable.count(). " +
  29386. "This warning will become a silent error in a future version. " +
  29387. stack
  29388. );
  29389. return this.size;
  29390. }
  29391. }
  29392. }
  29393. });
  29394. } catch (e) {}
  29395. })();
  29396. mixin(KeyedIterable, {
  29397. // ### More sequential methods
  29398. flip: function() {
  29399. return reify(this, flipFactory(this));
  29400. },
  29401. findKey: function(predicate, context) {
  29402. var entry = this.findEntry(predicate, context);
  29403. return entry && entry[0];
  29404. },
  29405. findLastKey: function(predicate, context) {
  29406. return this.toSeq()
  29407. .reverse()
  29408. .findKey(predicate, context);
  29409. },
  29410. keyOf: function(searchValue) {
  29411. return this.findKey(function(value) {
  29412. return is(value, searchValue);
  29413. });
  29414. },
  29415. lastKeyOf: function(searchValue) {
  29416. return this.findLastKey(function(value) {
  29417. return is(value, searchValue);
  29418. });
  29419. },
  29420. mapEntries: function(mapper, context) {
  29421. var this$0 = this;
  29422. var iterations = 0;
  29423. return reify(
  29424. this,
  29425. this.toSeq()
  29426. .map(function(v, k) {
  29427. return mapper.call(context, [k, v], iterations++, this$0);
  29428. })
  29429. .fromEntrySeq()
  29430. );
  29431. },
  29432. mapKeys: function(mapper, context) {
  29433. var this$0 = this;
  29434. return reify(
  29435. this,
  29436. this.toSeq()
  29437. .flip()
  29438. .map(function(k, v) {
  29439. return mapper.call(context, k, v, this$0);
  29440. })
  29441. .flip()
  29442. );
  29443. }
  29444. });
  29445. var KeyedIterablePrototype = KeyedIterable.prototype;
  29446. KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
  29447. KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
  29448. KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
  29449. KeyedIterablePrototype.__toStringMapper = function(v, k) {
  29450. return JSON.stringify(k) + ": " + quoteString(v);
  29451. };
  29452. mixin(IndexedIterable, {
  29453. // ### Conversion to other types
  29454. toKeyedSeq: function() {
  29455. return new ToKeyedSequence(this, false);
  29456. },
  29457. // ### ES6 Collection methods (ES6 Array and Map)
  29458. filter: function(predicate, context) {
  29459. return reify(this, filterFactory(this, predicate, context, false));
  29460. },
  29461. findIndex: function(predicate, context) {
  29462. var entry = this.findEntry(predicate, context);
  29463. return entry ? entry[0] : -1;
  29464. },
  29465. indexOf: function(searchValue) {
  29466. var key = this.toKeyedSeq().keyOf(searchValue);
  29467. return key === undefined ? -1 : key;
  29468. },
  29469. lastIndexOf: function(searchValue) {
  29470. var key = this.toKeyedSeq()
  29471. .reverse()
  29472. .keyOf(searchValue);
  29473. return key === undefined ? -1 : key;
  29474. // var index =
  29475. // return this.toSeq().reverse().indexOf(searchValue);
  29476. },
  29477. reverse: function() {
  29478. return reify(this, reverseFactory(this, false));
  29479. },
  29480. slice: function(begin, end) {
  29481. return reify(this, sliceFactory(this, begin, end, false));
  29482. },
  29483. splice: function(index, removeNum /*, ...values*/) {
  29484. var numArgs = arguments.length;
  29485. removeNum = Math.max(removeNum | 0, 0);
  29486. if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
  29487. return this;
  29488. }
  29489. // If index is negative, it should resolve relative to the size of the
  29490. // collection. However size may be expensive to compute if not cached, so
  29491. // only call count() if the number is in fact negative.
  29492. index = resolveBegin(index, index < 0 ? this.count() : this.size);
  29493. var spliced = this.slice(0, index);
  29494. return reify(
  29495. this,
  29496. numArgs === 1
  29497. ? spliced
  29498. : spliced.concat(
  29499. arrCopy(arguments, 2),
  29500. this.slice(index + removeNum)
  29501. )
  29502. );
  29503. },
  29504. // ### More collection methods
  29505. findLastIndex: function(predicate, context) {
  29506. var key = this.toKeyedSeq().findLastKey(predicate, context);
  29507. return key === undefined ? -1 : key;
  29508. },
  29509. first: function() {
  29510. return this.get(0);
  29511. },
  29512. flatten: function(depth) {
  29513. return reify(this, flattenFactory(this, depth, false));
  29514. },
  29515. get: function(index, notSetValue) {
  29516. index = wrapIndex(this, index);
  29517. return index < 0 ||
  29518. this.size === Infinity ||
  29519. (this.size !== undefined && index > this.size)
  29520. ? notSetValue
  29521. : this.find(
  29522. function(_, key) {
  29523. return key === index;
  29524. },
  29525. undefined,
  29526. notSetValue
  29527. );
  29528. },
  29529. has: function(index) {
  29530. index = wrapIndex(this, index);
  29531. return (
  29532. index >= 0 &&
  29533. (this.size !== undefined
  29534. ? this.size === Infinity || index < this.size
  29535. : this.indexOf(index) !== -1)
  29536. );
  29537. },
  29538. interpose: function(separator) {
  29539. return reify(this, interposeFactory(this, separator));
  29540. },
  29541. interleave: function(/*...iterables*/) {
  29542. var iterables = [this].concat(arrCopy(arguments));
  29543. var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
  29544. var interleaved = zipped.flatten(true);
  29545. if (zipped.size) {
  29546. interleaved.size = zipped.size * iterables.length;
  29547. }
  29548. return reify(this, interleaved);
  29549. },
  29550. last: function() {
  29551. return this.get(-1);
  29552. },
  29553. skipWhile: function(predicate, context) {
  29554. return reify(this, skipWhileFactory(this, predicate, context, false));
  29555. },
  29556. zip: function(/*, ...iterables */) {
  29557. var iterables = [this].concat(arrCopy(arguments));
  29558. return reify(this, zipWithFactory(this, defaultZipper, iterables));
  29559. },
  29560. zipWith: function(zipper /*, ...iterables */) {
  29561. var iterables = arrCopy(arguments);
  29562. iterables[0] = this;
  29563. return reify(this, zipWithFactory(this, zipper, iterables));
  29564. }
  29565. });
  29566. IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
  29567. IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
  29568. mixin(SetIterable, {
  29569. // ### ES6 Collection methods (ES6 Array and Map)
  29570. get: function(value, notSetValue) {
  29571. return this.has(value) ? value : notSetValue;
  29572. },
  29573. includes: function(value) {
  29574. return this.has(value);
  29575. },
  29576. // ### More sequential methods
  29577. keySeq: function() {
  29578. return this.valueSeq();
  29579. }
  29580. });
  29581. SetIterable.prototype.has = IterablePrototype.includes;
  29582. // Mixin subclasses
  29583. mixin(KeyedSeq, KeyedIterable.prototype);
  29584. mixin(IndexedSeq, IndexedIterable.prototype);
  29585. mixin(SetSeq, SetIterable.prototype);
  29586. mixin(KeyedCollection, KeyedIterable.prototype);
  29587. mixin(IndexedCollection, IndexedIterable.prototype);
  29588. mixin(SetCollection, SetIterable.prototype);
  29589. // #pragma Helper functions
  29590. function keyMapper(v, k) {
  29591. return k;
  29592. }
  29593. function entryMapper(v, k) {
  29594. return [k, v];
  29595. }
  29596. function not(predicate) {
  29597. return function() {
  29598. return !predicate.apply(this, arguments);
  29599. };
  29600. }
  29601. function neg(predicate) {
  29602. return function() {
  29603. return -predicate.apply(this, arguments);
  29604. };
  29605. }
  29606. function quoteString(value) {
  29607. return typeof value === "string" ? JSON.stringify(value) : value;
  29608. }
  29609. function defaultZipper() {
  29610. return arrCopy(arguments);
  29611. }
  29612. function defaultNegComparator(a, b) {
  29613. return a < b ? 1 : a > b ? -1 : 0;
  29614. }
  29615. function hashIterable(iterable) {
  29616. if (iterable.size === Infinity) {
  29617. return 0;
  29618. }
  29619. var ordered = isOrdered(iterable);
  29620. var keyed = isKeyed(iterable);
  29621. var h = ordered ? 1 : 0;
  29622. var size = iterable.__iterate(
  29623. keyed
  29624. ? ordered
  29625. ? function(v, k) {
  29626. h = (31 * h + hashMerge(hash(v), hash(k))) | 0;
  29627. }
  29628. : function(v, k) {
  29629. h = (h + hashMerge(hash(v), hash(k))) | 0;
  29630. }
  29631. : ordered
  29632. ? function(v) {
  29633. h = (31 * h + hash(v)) | 0;
  29634. }
  29635. : function(v) {
  29636. h = (h + hash(v)) | 0;
  29637. }
  29638. );
  29639. return murmurHashOfSize(size, h);
  29640. }
  29641. function murmurHashOfSize(size, h) {
  29642. h = imul(h, 0xcc9e2d51);
  29643. h = imul((h << 15) | (h >>> -15), 0x1b873593);
  29644. h = imul((h << 13) | (h >>> -13), 5);
  29645. h = ((h + 0xe6546b64) | 0) ^ size;
  29646. h = imul(h ^ (h >>> 16), 0x85ebca6b);
  29647. h = imul(h ^ (h >>> 13), 0xc2b2ae35);
  29648. h = smi(h ^ (h >>> 16));
  29649. return h;
  29650. }
  29651. function hashMerge(a, b) {
  29652. return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int
  29653. }
  29654. var Immutable = {
  29655. Iterable: Iterable,
  29656. Seq: Seq,
  29657. Collection: Collection,
  29658. Map: Map,
  29659. OrderedMap: OrderedMap,
  29660. List: List,
  29661. Stack: Stack,
  29662. Set: Set,
  29663. OrderedSet: OrderedSet,
  29664. Record: Record,
  29665. Range: Range,
  29666. Repeat: Repeat,
  29667. is: is,
  29668. fromJS: fromJS
  29669. };
  29670. return Immutable;
  29671. });
  29672. });
  29673. var parseHTML_1 = _commonjsHelpers.createCommonjsModule(function(
  29674. module,
  29675. exports
  29676. ) {
  29677. Object.defineProperty(exports, "__esModule", {
  29678. value: true
  29679. });
  29680. exports["default"] = parseHTML;
  29681. var fallback = function fallback(html) {
  29682. var doc = document.implementation.createHTMLDocument("");
  29683. doc.documentElement.innerHTML = html;
  29684. return doc;
  29685. };
  29686. function parseHTML(html) {
  29687. var doc;
  29688. if (typeof DOMParser !== "undefined") {
  29689. var parser = new DOMParser();
  29690. doc = parser.parseFromString(html, "text/html");
  29691. if (doc === null || doc.body === null) {
  29692. doc = fallback(html);
  29693. }
  29694. } else {
  29695. doc = fallback(html);
  29696. }
  29697. return doc.body;
  29698. }
  29699. });
  29700. _commonjsHelpers.unwrapExports(parseHTML_1);
  29701. var convertFromHTML_1 = _commonjsHelpers.createCommonjsModule(function(
  29702. module,
  29703. exports
  29704. ) {
  29705. Object.defineProperty(exports, "__esModule", {
  29706. value: true
  29707. });
  29708. exports["default"] = void 0;
  29709. var _parseHTML = interopRequireDefault(parseHTML_1);
  29710. var _rangeSort = interopRequireDefault(rangeSort);
  29711. /**
  29712. * Copyright (c) 2013-present, Facebook, Inc.
  29713. * All rights reserved.
  29714. *
  29715. * Copyright (c) 2013-present, Facebook, Inc.
  29716. * All rights reserved.
  29717. *
  29718. * This source code is licensed under the BSD-style license found in the
  29719. * LICENSE file in the /src directory of this source tree. An additional grant
  29720. * of patent rights can be found in the PATENTS file in the same directory.
  29721. */
  29722. var NBSP = "&nbsp;";
  29723. var SPACE = " "; // Arbitrary max indent
  29724. var MAX_DEPTH = 4; // used for replacing characters in HTML
  29725. /* eslint-disable no-control-regex */
  29726. var REGEX_CR = new RegExp("\r", "g");
  29727. var REGEX_LF = new RegExp("\n", "g");
  29728. var REGEX_NBSP = new RegExp(NBSP, "g");
  29729. var REGEX_BLOCK_DELIMITER = new RegExp("\r", "g");
  29730. /* eslint-enable no-control-regex */
  29731. // Block tag flow is different because LIs do not have
  29732. // a deterministic style ;_;
  29733. var blockTags = [
  29734. "p",
  29735. "h1",
  29736. "h2",
  29737. "h3",
  29738. "h4",
  29739. "h5",
  29740. "h6",
  29741. "li",
  29742. "blockquote",
  29743. "pre"
  29744. ];
  29745. var inlineTags = {
  29746. b: "BOLD",
  29747. code: "CODE",
  29748. del: "STRIKETHROUGH",
  29749. em: "ITALIC",
  29750. i: "ITALIC",
  29751. s: "STRIKETHROUGH",
  29752. strike: "STRIKETHROUGH",
  29753. strong: "BOLD",
  29754. u: "UNDERLINE"
  29755. };
  29756. var handleMiddleware = function handleMiddleware(maybeMiddleware, base) {
  29757. if (maybeMiddleware && maybeMiddleware.__isMiddleware === true) {
  29758. return maybeMiddleware(base);
  29759. }
  29760. return maybeMiddleware;
  29761. };
  29762. var defaultHTMLToBlock = function defaultHTMLToBlock(
  29763. nodeName,
  29764. node,
  29765. lastList
  29766. ) {
  29767. return undefined;
  29768. };
  29769. var defaultHTMLToStyle = function defaultHTMLToStyle(
  29770. nodeName,
  29771. node,
  29772. currentStyle
  29773. ) {
  29774. return currentStyle;
  29775. };
  29776. var defaultHTMLToEntity = function defaultHTMLToEntity(nodeName, node) {
  29777. return undefined;
  29778. };
  29779. var defaultTextToEntity = function defaultTextToEntity(text) {
  29780. return [];
  29781. };
  29782. var nullthrows = function nullthrows(x) {
  29783. if (x != null) {
  29784. return x;
  29785. }
  29786. throw new Error("Got unexpected null or undefined");
  29787. };
  29788. var sanitizeDraftText = function sanitizeDraftText(input) {
  29789. return input.replace(REGEX_BLOCK_DELIMITER, "");
  29790. };
  29791. function getEmptyChunk() {
  29792. return {
  29793. text: "",
  29794. inlines: [],
  29795. entities: [],
  29796. blocks: []
  29797. };
  29798. }
  29799. function getWhitespaceChunk(inEntity) {
  29800. var entities = new Array(1);
  29801. if (inEntity) {
  29802. entities[0] = inEntity;
  29803. }
  29804. return {
  29805. text: SPACE,
  29806. inlines: [(0, immutable$2.OrderedSet)()],
  29807. entities: entities,
  29808. blocks: []
  29809. };
  29810. }
  29811. function getSoftNewlineChunk(block, depth) {
  29812. var flat =
  29813. arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  29814. var data =
  29815. arguments.length > 3 && arguments[3] !== undefined
  29816. ? arguments[3]
  29817. : (0, immutable$2.Map)();
  29818. if (flat === true) {
  29819. return {
  29820. text: "\r",
  29821. inlines: [(0, immutable$2.OrderedSet)()],
  29822. entities: new Array(1),
  29823. blocks: [
  29824. {
  29825. type: block,
  29826. data: data,
  29827. depth: Math.max(0, Math.min(MAX_DEPTH, depth))
  29828. }
  29829. ],
  29830. isNewline: true
  29831. };
  29832. }
  29833. return {
  29834. text: "\n",
  29835. inlines: [(0, immutable$2.OrderedSet)()],
  29836. entities: new Array(1),
  29837. blocks: []
  29838. };
  29839. }
  29840. function getBlockDividerChunk(block, depth) {
  29841. var data =
  29842. arguments.length > 2 && arguments[2] !== undefined
  29843. ? arguments[2]
  29844. : (0, immutable$2.Map)();
  29845. return {
  29846. text: "\r",
  29847. inlines: [(0, immutable$2.OrderedSet)()],
  29848. entities: new Array(1),
  29849. blocks: [
  29850. {
  29851. type: block,
  29852. data: data,
  29853. depth: Math.max(0, Math.min(MAX_DEPTH, depth))
  29854. }
  29855. ]
  29856. };
  29857. }
  29858. function getBlockTypeForTag(tag, lastList) {
  29859. switch (tag) {
  29860. case "h1":
  29861. return "header-one";
  29862. case "h2":
  29863. return "header-two";
  29864. case "h3":
  29865. return "header-three";
  29866. case "h4":
  29867. return "header-four";
  29868. case "h5":
  29869. return "header-five";
  29870. case "h6":
  29871. return "header-six";
  29872. case "li":
  29873. if (lastList === "ol") {
  29874. return "ordered-list-item";
  29875. }
  29876. return "unordered-list-item";
  29877. case "blockquote":
  29878. return "blockquote";
  29879. case "pre":
  29880. return "code-block";
  29881. case "div":
  29882. case "p":
  29883. return "unstyled";
  29884. default:
  29885. return null;
  29886. }
  29887. }
  29888. function baseCheckBlockType(nodeName, node, lastList) {
  29889. return getBlockTypeForTag(nodeName, lastList);
  29890. }
  29891. function processInlineTag(tag, node, currentStyle) {
  29892. var styleToCheck = inlineTags[tag];
  29893. if (styleToCheck) {
  29894. currentStyle = currentStyle.add(styleToCheck).toOrderedSet();
  29895. } else if (node instanceof HTMLElement) {
  29896. var htmlElement = node;
  29897. currentStyle = currentStyle
  29898. .withMutations(function(style) {
  29899. if (htmlElement.style.fontWeight === "bold") {
  29900. style.add("BOLD");
  29901. }
  29902. if (htmlElement.style.fontStyle === "italic") {
  29903. style.add("ITALIC");
  29904. }
  29905. if (htmlElement.style.textDecoration === "underline") {
  29906. style.add("UNDERLINE");
  29907. }
  29908. if (htmlElement.style.textDecoration === "line-through") {
  29909. style.add("STRIKETHROUGH");
  29910. }
  29911. })
  29912. .toOrderedSet();
  29913. }
  29914. return currentStyle;
  29915. }
  29916. function baseProcessInlineTag(tag, node) {
  29917. var inlineStyles =
  29918. arguments.length > 2 && arguments[2] !== undefined
  29919. ? arguments[2]
  29920. : (0, immutable$2.OrderedSet)();
  29921. return processInlineTag(tag, node, inlineStyles);
  29922. }
  29923. function joinChunks(A, B) {
  29924. var flat =
  29925. arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  29926. // Sometimes two blocks will touch in the DOM and we need to strip the
  29927. // extra delimiter to preserve niceness.
  29928. var firstInB = B.text.slice(0, 1);
  29929. var lastInA = A.text.slice(-1);
  29930. var adjacentDividers = lastInA === "\r" && firstInB === "\r";
  29931. var isJoiningBlocks = A.text !== "\r" && B.text !== "\r"; // when joining two full blocks like this we want to pop one divider
  29932. var addingNewlineToEmptyBlock =
  29933. A.text === "\r" && !A.isNewline && B.isNewline; // when joining a newline to an empty block we want to remove the newline
  29934. if (adjacentDividers && (isJoiningBlocks || addingNewlineToEmptyBlock)) {
  29935. A.text = A.text.slice(0, -1);
  29936. A.inlines.pop();
  29937. A.entities.pop();
  29938. A.blocks.pop();
  29939. } // Kill whitespace after blocks if flat mode is on
  29940. if (A.text.slice(-1) === "\r" && flat === true) {
  29941. if (B.text === SPACE || B.text === "\n") {
  29942. return A;
  29943. } else if (firstInB === SPACE || firstInB === "\n") {
  29944. B.text = B.text.slice(1);
  29945. B.inlines.shift();
  29946. B.entities.shift();
  29947. }
  29948. }
  29949. var isNewline = A.text.length === 0 && B.isNewline;
  29950. return {
  29951. text: A.text + B.text,
  29952. inlines: A.inlines.concat(B.inlines),
  29953. entities: A.entities.concat(B.entities),
  29954. blocks: A.blocks.concat(B.blocks),
  29955. isNewline: isNewline
  29956. };
  29957. }
  29958. /*
  29959. * Check to see if we have anything like <p> <blockquote> <h1>... to create
  29960. * block tags from. If we do, we can use those and ignore <div> tags. If we
  29961. * don't, we can treat <div> tags as meaningful (unstyled) blocks.
  29962. */
  29963. function containsSemanticBlockMarkup(html) {
  29964. return blockTags.some(function(tag) {
  29965. return html.indexOf("<".concat(tag)) !== -1;
  29966. });
  29967. }
  29968. function genFragment(
  29969. node,
  29970. inlineStyle,
  29971. lastList,
  29972. inBlock,
  29973. fragmentBlockTags,
  29974. depth,
  29975. processCustomInlineStyles,
  29976. checkEntityNode,
  29977. checkEntityText,
  29978. checkBlockType,
  29979. createEntity,
  29980. getEntity,
  29981. mergeEntityData,
  29982. replaceEntityData,
  29983. options,
  29984. inEntity
  29985. ) {
  29986. var nodeName = node.nodeName.toLowerCase();
  29987. var newBlock = false;
  29988. var nextBlockType = "unstyled"; // Base Case
  29989. if (nodeName === "#text") {
  29990. var text = node.textContent;
  29991. if (text.trim() === "" && inBlock === null) {
  29992. return getEmptyChunk();
  29993. }
  29994. if (text.trim() === "" && inBlock !== "code-block") {
  29995. return getWhitespaceChunk(inEntity);
  29996. }
  29997. if (inBlock !== "code-block") {
  29998. // Can't use empty string because MSWord
  29999. text = text.replace(REGEX_LF, SPACE);
  30000. }
  30001. var entities = Array(text.length).fill(inEntity);
  30002. var offsetChange = 0;
  30003. var textEntities = checkEntityText(
  30004. text,
  30005. createEntity,
  30006. getEntity,
  30007. mergeEntityData,
  30008. replaceEntityData
  30009. ).sort(_rangeSort["default"]);
  30010. textEntities.forEach(function(_ref) {
  30011. var entity = _ref.entity,
  30012. offset = _ref.offset,
  30013. length = _ref.length,
  30014. result = _ref.result;
  30015. var adjustedOffset = offset + offsetChange;
  30016. if (result === null || result === undefined) {
  30017. result = text.substr(adjustedOffset, length);
  30018. }
  30019. var textArray = text.split("");
  30020. textArray.splice
  30021. .bind(textArray, adjustedOffset, length)
  30022. .apply(textArray, result.split(""));
  30023. text = textArray.join("");
  30024. entities.splice
  30025. .bind(entities, adjustedOffset, length)
  30026. .apply(entities, Array(result.length).fill(entity));
  30027. offsetChange += result.length - length;
  30028. });
  30029. return {
  30030. text: text,
  30031. inlines: Array(text.length).fill(inlineStyle),
  30032. entities: entities,
  30033. blocks: []
  30034. };
  30035. } // BR tags
  30036. if (nodeName === "br") {
  30037. var _blockType = inBlock;
  30038. if (_blockType === null) {
  30039. // BR tag is at top level, treat it as an unstyled block
  30040. return getSoftNewlineChunk("unstyled", depth, true);
  30041. }
  30042. return getSoftNewlineChunk(_blockType || "unstyled", depth, options.flat);
  30043. }
  30044. var chunk = getEmptyChunk();
  30045. var newChunk = null; // Inline tags
  30046. inlineStyle = processInlineTag(nodeName, node, inlineStyle);
  30047. inlineStyle = processCustomInlineStyles(nodeName, node, inlineStyle); // Handle lists
  30048. if (nodeName === "ul" || nodeName === "ol") {
  30049. if (lastList) {
  30050. depth += 1;
  30051. }
  30052. lastList = nodeName;
  30053. inBlock = null;
  30054. } // Block Tags
  30055. var blockInfo = checkBlockType(nodeName, node, lastList, inBlock);
  30056. var blockType;
  30057. var blockDataMap;
  30058. if (blockInfo === false) {
  30059. return getEmptyChunk();
  30060. }
  30061. blockInfo = blockInfo || {};
  30062. if (typeof blockInfo === "string") {
  30063. blockType = blockInfo;
  30064. blockDataMap = (0, immutable$2.Map)();
  30065. } else {
  30066. blockType = typeof blockInfo === "string" ? blockInfo : blockInfo.type;
  30067. blockDataMap = blockInfo.data
  30068. ? (0, immutable$2.Map)(blockInfo.data)
  30069. : (0, immutable$2.Map)();
  30070. }
  30071. if (!inBlock && (fragmentBlockTags.indexOf(nodeName) !== -1 || blockType)) {
  30072. chunk = getBlockDividerChunk(
  30073. blockType || getBlockTypeForTag(nodeName, lastList),
  30074. depth,
  30075. blockDataMap
  30076. );
  30077. inBlock = blockType || getBlockTypeForTag(nodeName, lastList);
  30078. newBlock = true;
  30079. } else if (
  30080. lastList &&
  30081. (inBlock === "ordered-list-item" || inBlock === "unordered-list-item") &&
  30082. nodeName === "li"
  30083. ) {
  30084. var listItemBlockType = getBlockTypeForTag(nodeName, lastList);
  30085. chunk = getBlockDividerChunk(listItemBlockType, depth);
  30086. inBlock = listItemBlockType;
  30087. newBlock = true;
  30088. nextBlockType =
  30089. lastList === "ul" ? "unordered-list-item" : "ordered-list-item";
  30090. } else if (inBlock && inBlock !== "atomic" && blockType === "atomic") {
  30091. inBlock = blockType;
  30092. newBlock = true;
  30093. chunk = getSoftNewlineChunk(
  30094. blockType,
  30095. depth,
  30096. true, // atomic blocks within non-atomic blocks must always be split out
  30097. blockDataMap
  30098. );
  30099. } // Recurse through children
  30100. var child = node.firstChild; // hack to allow conversion of atomic blocks from HTML (e.g. <figure><img
  30101. // src="..." /></figure>). since metadata must be stored on an entity text
  30102. // must exist for the entity to apply to. the way chunks are joined strips
  30103. // whitespace at the end so it cannot be a space character.
  30104. if (
  30105. child == null &&
  30106. inEntity &&
  30107. (blockType === "atomic" || inBlock === "atomic")
  30108. ) {
  30109. child = document.createTextNode("a");
  30110. }
  30111. if (child != null) {
  30112. nodeName = child.nodeName.toLowerCase();
  30113. }
  30114. var entityId = null;
  30115. while (child) {
  30116. entityId = checkEntityNode(
  30117. nodeName,
  30118. child,
  30119. createEntity,
  30120. getEntity,
  30121. mergeEntityData,
  30122. replaceEntityData
  30123. );
  30124. newChunk = genFragment(
  30125. child,
  30126. inlineStyle,
  30127. lastList,
  30128. inBlock,
  30129. fragmentBlockTags,
  30130. depth,
  30131. processCustomInlineStyles,
  30132. checkEntityNode,
  30133. checkEntityText,
  30134. checkBlockType,
  30135. createEntity,
  30136. getEntity,
  30137. mergeEntityData,
  30138. replaceEntityData,
  30139. options,
  30140. entityId || inEntity
  30141. );
  30142. chunk = joinChunks(chunk, newChunk, options.flat);
  30143. var sibling = child.nextSibling; // Put in a newline to break up blocks inside blocks
  30144. if (sibling && fragmentBlockTags.indexOf(nodeName) >= 0 && inBlock) {
  30145. var newBlockInfo = checkBlockType(nodeName, child, lastList, inBlock);
  30146. var newBlockType = void 0;
  30147. var newBlockData = void 0;
  30148. if (newBlockInfo !== false) {
  30149. newBlockInfo = newBlockInfo || {};
  30150. if (typeof newBlockInfo === "string") {
  30151. newBlockType = newBlockInfo;
  30152. newBlockData = (0, immutable$2.Map)();
  30153. } else {
  30154. newBlockType =
  30155. newBlockInfo.type || getBlockTypeForTag(nodeName, lastList);
  30156. newBlockData = newBlockInfo.data
  30157. ? (0, immutable$2.Map)(newBlockInfo.data)
  30158. : (0, immutable$2.Map)();
  30159. }
  30160. chunk = joinChunks(
  30161. chunk,
  30162. getSoftNewlineChunk(
  30163. newBlockType,
  30164. depth,
  30165. options.flat,
  30166. newBlockData
  30167. ),
  30168. options.flat
  30169. );
  30170. }
  30171. }
  30172. if (sibling) {
  30173. nodeName = sibling.nodeName.toLowerCase();
  30174. }
  30175. child = sibling;
  30176. }
  30177. if (newBlock) {
  30178. chunk = joinChunks(
  30179. chunk,
  30180. getBlockDividerChunk(nextBlockType, depth, (0, immutable$2.Map)()),
  30181. options.flat
  30182. );
  30183. }
  30184. return chunk;
  30185. }
  30186. function getChunkForHTML(
  30187. html,
  30188. processCustomInlineStyles,
  30189. checkEntityNode,
  30190. checkEntityText,
  30191. checkBlockType,
  30192. createEntity,
  30193. getEntity,
  30194. mergeEntityData,
  30195. replaceEntityData,
  30196. options,
  30197. DOMBuilder
  30198. ) {
  30199. html = html
  30200. .trim()
  30201. .replace(REGEX_CR, "")
  30202. .replace(REGEX_NBSP, SPACE);
  30203. var safeBody = DOMBuilder(html);
  30204. if (!safeBody) {
  30205. return null;
  30206. } // Sometimes we aren't dealing with content that contains nice semantic
  30207. // tags. In this case, use divs to separate everything out into paragraphs
  30208. // and hope for the best.
  30209. var workingBlocks = containsSemanticBlockMarkup(html)
  30210. ? blockTags.concat(["div"])
  30211. : ["div"]; // Start with -1 block depth to offset the fact that we are passing in a fake
  30212. // UL block to sta rt with.
  30213. var chunk = genFragment(
  30214. safeBody,
  30215. (0, immutable$2.OrderedSet)(),
  30216. "ul",
  30217. null,
  30218. workingBlocks,
  30219. -1,
  30220. processCustomInlineStyles,
  30221. checkEntityNode,
  30222. checkEntityText,
  30223. checkBlockType,
  30224. createEntity,
  30225. getEntity,
  30226. mergeEntityData,
  30227. replaceEntityData,
  30228. options
  30229. ); // join with previous block to prevent weirdness on paste
  30230. if (chunk.text.indexOf("\r") === 0) {
  30231. chunk = {
  30232. text: chunk.text.slice(1),
  30233. inlines: chunk.inlines.slice(1),
  30234. entities: chunk.entities.slice(1),
  30235. blocks: chunk.blocks
  30236. };
  30237. } // Kill block delimiter at the end
  30238. if (chunk.text.slice(-1) === "\r") {
  30239. chunk.text = chunk.text.slice(0, -1);
  30240. chunk.inlines = chunk.inlines.slice(0, -1);
  30241. chunk.entities = chunk.entities.slice(0, -1);
  30242. chunk.blocks.pop();
  30243. } // If we saw no block tags, put an unstyled one in
  30244. if (chunk.blocks.length === 0) {
  30245. chunk.blocks.push({
  30246. type: "unstyled",
  30247. data: (0, immutable$2.Map)(),
  30248. depth: 0
  30249. });
  30250. } // Sometimes we start with text that isn't in a block, which is then
  30251. // followed by blocks. Need to fix up the blocks to add in
  30252. // an unstyled block for this content
  30253. if (chunk.text.split("\r").length === chunk.blocks.length + 1) {
  30254. chunk.blocks.unshift({
  30255. type: "unstyled",
  30256. data: (0, immutable$2.Map)(),
  30257. depth: 0
  30258. });
  30259. }
  30260. return chunk;
  30261. }
  30262. function convertFromHTMLtoContentBlocks(
  30263. html,
  30264. processCustomInlineStyles,
  30265. checkEntityNode,
  30266. checkEntityText,
  30267. checkBlockType,
  30268. createEntity,
  30269. getEntity,
  30270. mergeEntityData,
  30271. replaceEntityData,
  30272. options,
  30273. DOMBuilder,
  30274. generateKey
  30275. ) {
  30276. // Be ABSOLUTELY SURE that the dom builder you pass hare won't execute
  30277. // arbitrary code in whatever environment you're running this in. For an
  30278. // example of how we try to do this in-browser, see getSafeBodyFromHTML.
  30279. var chunk = getChunkForHTML(
  30280. html,
  30281. processCustomInlineStyles,
  30282. checkEntityNode,
  30283. checkEntityText,
  30284. checkBlockType,
  30285. createEntity,
  30286. getEntity,
  30287. mergeEntityData,
  30288. replaceEntityData,
  30289. options,
  30290. DOMBuilder
  30291. );
  30292. if (chunk == null) {
  30293. return [];
  30294. }
  30295. var start = 0;
  30296. return chunk.text.split("\r").map(function(textBlock, blockIndex) {
  30297. // Make absolutely certain that our text is acceptable.
  30298. textBlock = sanitizeDraftText(textBlock);
  30299. var end = start + textBlock.length;
  30300. var inlines = nullthrows(chunk).inlines.slice(start, end);
  30301. var entities = nullthrows(chunk).entities.slice(start, end);
  30302. var characterList = (0, immutable$2.List)(
  30303. inlines.map(function(style, entityIndex) {
  30304. var data = {
  30305. style: style,
  30306. entity: null
  30307. };
  30308. if (entities[entityIndex]) {
  30309. data.entity = entities[entityIndex];
  30310. }
  30311. return Draft.CharacterMetadata.create(data);
  30312. })
  30313. );
  30314. start = end + 1;
  30315. return new Draft.ContentBlock({
  30316. key: generateKey(),
  30317. type: nullthrows(chunk).blocks[blockIndex].type,
  30318. data: nullthrows(chunk).blocks[blockIndex].data,
  30319. depth: nullthrows(chunk).blocks[blockIndex].depth,
  30320. text: textBlock,
  30321. characterList: characterList
  30322. });
  30323. });
  30324. }
  30325. var convertFromHTML = function convertFromHTML(_ref2) {
  30326. var _ref2$htmlToStyle = _ref2.htmlToStyle,
  30327. htmlToStyle =
  30328. _ref2$htmlToStyle === void 0 ? defaultHTMLToStyle : _ref2$htmlToStyle,
  30329. _ref2$htmlToEntity = _ref2.htmlToEntity,
  30330. htmlToEntity =
  30331. _ref2$htmlToEntity === void 0
  30332. ? defaultHTMLToEntity
  30333. : _ref2$htmlToEntity,
  30334. _ref2$textToEntity = _ref2.textToEntity,
  30335. textToEntity =
  30336. _ref2$textToEntity === void 0
  30337. ? defaultTextToEntity
  30338. : _ref2$textToEntity,
  30339. _ref2$htmlToBlock = _ref2.htmlToBlock,
  30340. htmlToBlock =
  30341. _ref2$htmlToBlock === void 0 ? defaultHTMLToBlock : _ref2$htmlToBlock;
  30342. return function(html) {
  30343. var options =
  30344. arguments.length > 1 && arguments[1] !== undefined
  30345. ? arguments[1]
  30346. : {
  30347. flat: false
  30348. };
  30349. var DOMBuilder =
  30350. arguments.length > 2 && arguments[2] !== undefined
  30351. ? arguments[2]
  30352. : _parseHTML["default"];
  30353. var generateKey =
  30354. arguments.length > 3 && arguments[3] !== undefined
  30355. ? arguments[3]
  30356. : Draft.genKey;
  30357. var contentState = Draft.ContentState.createFromText("");
  30358. var createEntityWithContentState = function createEntityWithContentState() {
  30359. if (contentState.createEntity) {
  30360. var _contentState;
  30361. contentState = (_contentState = contentState).createEntity.apply(
  30362. _contentState,
  30363. arguments
  30364. );
  30365. return contentState.getLastCreatedEntityKey();
  30366. }
  30367. return Draft.Entity.create.apply(Draft.Entity, arguments);
  30368. };
  30369. var getEntityWithContentState = function getEntityWithContentState() {
  30370. if (contentState.getEntity) {
  30371. var _contentState2;
  30372. return (_contentState2 = contentState).getEntity.apply(
  30373. _contentState2,
  30374. arguments
  30375. );
  30376. }
  30377. return Draft.Entity.get.apply(Draft.Entity, arguments);
  30378. };
  30379. var mergeEntityDataWithContentState = function mergeEntityDataWithContentState() {
  30380. if (contentState.mergeEntityData) {
  30381. var _contentState3;
  30382. contentState = (_contentState3 = contentState).mergeEntityData.apply(
  30383. _contentState3,
  30384. arguments
  30385. );
  30386. return;
  30387. }
  30388. Draft.Entity.mergeData.apply(Draft.Entity, arguments);
  30389. };
  30390. var replaceEntityDataWithContentState = function replaceEntityDataWithContentState() {
  30391. if (contentState.replaceEntityData) {
  30392. var _contentState4;
  30393. contentState = (_contentState4 = contentState).replaceEntityData.apply(
  30394. _contentState4,
  30395. arguments
  30396. );
  30397. return;
  30398. }
  30399. Draft.Entity.replaceData.apply(Draft.Entity, arguments);
  30400. };
  30401. var contentBlocks = convertFromHTMLtoContentBlocks(
  30402. html,
  30403. handleMiddleware(htmlToStyle, baseProcessInlineTag),
  30404. handleMiddleware(htmlToEntity, defaultHTMLToEntity),
  30405. handleMiddleware(textToEntity, defaultTextToEntity),
  30406. handleMiddleware(htmlToBlock, baseCheckBlockType),
  30407. createEntityWithContentState,
  30408. getEntityWithContentState,
  30409. mergeEntityDataWithContentState,
  30410. replaceEntityDataWithContentState,
  30411. options,
  30412. DOMBuilder,
  30413. generateKey
  30414. );
  30415. var blockMap = Draft.BlockMapBuilder.createFromArray(contentBlocks);
  30416. var firstBlockKey = contentBlocks[0].getKey();
  30417. return contentState.merge({
  30418. blockMap: blockMap,
  30419. selectionBefore: Draft.SelectionState.createEmpty(firstBlockKey),
  30420. selectionAfter: Draft.SelectionState.createEmpty(firstBlockKey)
  30421. });
  30422. };
  30423. };
  30424. var _default = function _default() {
  30425. if (
  30426. arguments.length >= 1 &&
  30427. typeof (arguments.length <= 0 ? undefined : arguments[0]) === "string"
  30428. ) {
  30429. return convertFromHTML({}).apply(void 0, arguments);
  30430. }
  30431. return convertFromHTML.apply(void 0, arguments);
  30432. };
  30433. exports["default"] = _default;
  30434. });
  30435. _commonjsHelpers.unwrapExports(convertFromHTML_1);
  30436. var lib = _commonjsHelpers.createCommonjsModule(function(module, exports) {
  30437. Object.defineProperty(exports, "__esModule", {
  30438. value: true
  30439. });
  30440. Object.defineProperty(exports, "convertToHTML", {
  30441. enumerable: true,
  30442. get: function get() {
  30443. return _convertToHTML["default"];
  30444. }
  30445. });
  30446. Object.defineProperty(exports, "convertFromHTML", {
  30447. enumerable: true,
  30448. get: function get() {
  30449. return _convertFromHTML["default"];
  30450. }
  30451. });
  30452. Object.defineProperty(exports, "parseHTML", {
  30453. enumerable: true,
  30454. get: function get() {
  30455. return _parseHTML["default"];
  30456. }
  30457. });
  30458. var _convertToHTML = interopRequireDefault(convertToHTML_1);
  30459. var _convertFromHTML = interopRequireDefault(convertFromHTML_1);
  30460. var _parseHTML = interopRequireDefault(parseHTML_1);
  30461. });
  30462. _commonjsHelpers.unwrapExports(lib);
  30463. var configs = _commonjsHelpers.createCommonjsModule(function(module, exports) {
  30464. Object.defineProperty(exports, "__esModule", {
  30465. value: true
  30466. });
  30467. exports.getFromHTMLConfig = exports.getToHTMLConfig = exports.blocks = exports.getHexColor = exports.defaultFontFamilies = exports.namedColors = undefined;
  30468. var _extends =
  30469. Object.assign ||
  30470. function(target) {
  30471. for (var i = 1; i < arguments.length; i++) {
  30472. var source = arguments[i];
  30473. for (var key in source) {
  30474. if (Object.prototype.hasOwnProperty.call(source, key)) {
  30475. target[key] = source[key];
  30476. }
  30477. }
  30478. }
  30479. return target;
  30480. };
  30481. var _react2 = _interopRequireDefault(React__default);
  30482. function _interopRequireDefault(obj) {
  30483. return obj && obj.__esModule ? obj : { default: obj };
  30484. }
  30485. function _objectWithoutProperties(obj, keys) {
  30486. var target = {};
  30487. for (var i in obj) {
  30488. if (keys.indexOf(i) >= 0) continue;
  30489. if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
  30490. target[i] = obj[i];
  30491. }
  30492. return target;
  30493. }
  30494. var namedColors = (exports.namedColors = {
  30495. aliceblue: "#f0f8ff",
  30496. antiquewhite: "#faebd7",
  30497. aqua: "#00ffff",
  30498. aquamarine: "#7fffd4",
  30499. azure: "#f0ffff",
  30500. beige: "#f5f5dc",
  30501. bisque: "#ffe4c4",
  30502. black: "#000000",
  30503. blanchedalmond: "#ffebcd",
  30504. blue: "#0000ff",
  30505. blueviolet: "#8a2be2",
  30506. brown: "#a52a2a",
  30507. burlywood: "#deb887",
  30508. cadetblue: "#5f9ea0",
  30509. chartreuse: "#7fff00",
  30510. chocolate: "#d2691e",
  30511. coral: "#ff7f50",
  30512. cornflowerblue: "#6495ed",
  30513. cornsilk: "#fff8dc",
  30514. crimson: "#dc143c",
  30515. cyan: "#00ffff",
  30516. darkblue: "#00008b",
  30517. darkcyan: "#008b8b",
  30518. darkgoldenrod: "#b8860b",
  30519. darkgray: "#a9a9a9",
  30520. darkgreen: "#006400",
  30521. darkkhaki: "#bdb76b",
  30522. darkmagenta: "#8b008b",
  30523. darkolivegreen: "#556b2f",
  30524. darkorange: "#ff8c00",
  30525. darkorchid: "#9932cc",
  30526. darkred: "#8b0000",
  30527. darksalmon: "#e9967a",
  30528. darkseagreen: "#8fbc8f",
  30529. darkslateblue: "#483d8b",
  30530. darkslategray: "#2f4f4f",
  30531. darkturquoise: "#00ced1",
  30532. darkviolet: "#9400d3",
  30533. deeppink: "#ff1493",
  30534. deepskyblue: "#00bfff",
  30535. dimgray: "#696969",
  30536. dodgerblue: "#1e90ff",
  30537. firebrick: "#b22222",
  30538. floralwhite: "#fffaf0",
  30539. forestgreen: "#228b22",
  30540. fuchsia: "#ff00ff",
  30541. gainsboro: "#dcdcdc",
  30542. ghostwhite: "#f8f8ff",
  30543. gold: "#ffd700",
  30544. goldenrod: "#daa520",
  30545. gray: "#808080",
  30546. green: "#008000",
  30547. greenyellow: "#adff2f",
  30548. honeydew: "#f0fff0",
  30549. hotpink: "#ff69b4",
  30550. "indianred ": "#cd5c5c",
  30551. indigo: "#4b0082",
  30552. ivory: "#fffff0",
  30553. khaki: "#f0e68c",
  30554. lavender: "#e6e6fa",
  30555. lavenderblush: "#fff0f5",
  30556. lawngreen: "#7cfc00",
  30557. lemonchiffon: "#fffacd",
  30558. lightblue: "#add8e6",
  30559. lightcoral: "#f08080",
  30560. lightcyan: "#e0ffff",
  30561. lightgoldenrodyellow: "#fafad2",
  30562. lightgrey: "#d3d3d3",
  30563. lightgreen: "#90ee90",
  30564. lightpink: "#ffb6c1",
  30565. lightsalmon: "#ffa07a",
  30566. lightseagreen: "#20b2aa",
  30567. lightskyblue: "#87cefa",
  30568. lightslategray: "#778899",
  30569. lightsteelblue: "#b0c4de",
  30570. lightyellow: "#ffffe0",
  30571. lime: "#00ff00",
  30572. limegreen: "#32cd32",
  30573. linen: "#faf0e6",
  30574. magenta: "#ff00ff",
  30575. maroon: "#800000",
  30576. mediumaquamarine: "#66cdaa",
  30577. mediumblue: "#0000cd",
  30578. mediumorchid: "#ba55d3",
  30579. mediumpurple: "#9370d8",
  30580. mediumseagreen: "#3cb371",
  30581. mediumslateblue: "#7b68ee",
  30582. mediumspringgreen: "#00fa9a",
  30583. mediumturquoise: "#48d1cc",
  30584. mediumvioletred: "#c71585",
  30585. midnightblue: "#191970",
  30586. mintcream: "#f5fffa",
  30587. mistyrose: "#ffe4e1",
  30588. moccasin: "#ffe4b5",
  30589. navajowhite: "#ffdead",
  30590. navy: "#000080",
  30591. oldlace: "#fdf5e6",
  30592. olive: "#808000",
  30593. olivedrab: "#6b8e23",
  30594. orange: "#ffa500",
  30595. orangered: "#ff4500",
  30596. orchid: "#da70d6",
  30597. palegoldenrod: "#eee8aa",
  30598. palegreen: "#98fb98",
  30599. paleturquoise: "#afeeee",
  30600. palevioletred: "#d87093",
  30601. papayawhip: "#ffefd5",
  30602. peachpuff: "#ffdab9",
  30603. peru: "#cd853f",
  30604. pink: "#ffc0cb",
  30605. plum: "#dda0dd",
  30606. powderblue: "#b0e0e6",
  30607. purple: "#800080",
  30608. rebeccapurple: "#663399",
  30609. red: "#ff0000",
  30610. rosybrown: "#bc8f8f",
  30611. royalblue: "#4169e1",
  30612. saddlebrown: "#8b4513",
  30613. salmon: "#fa8072",
  30614. sandybrown: "#f4a460",
  30615. seagreen: "#2e8b57",
  30616. seashell: "#fff5ee",
  30617. sienna: "#a0522d",
  30618. silver: "#c0c0c0",
  30619. skyblue: "#87ceeb",
  30620. slateblue: "#6a5acd",
  30621. slategray: "#708090",
  30622. snow: "#fffafa",
  30623. springgreen: "#00ff7f",
  30624. steelblue: "#4682b4",
  30625. tan: "#d2b48c",
  30626. teal: "#008080",
  30627. thistle: "#d8bfd8",
  30628. tomato: "#ff6347",
  30629. turquoise: "#40e0d0",
  30630. violet: "#ee82ee",
  30631. wheat: "#f5deb3",
  30632. white: "#ffffff",
  30633. whitesmoke: "#f5f5f5",
  30634. yellow: "#ffff00",
  30635. yellowgreen: "#9acd32"
  30636. });
  30637. var getStyleValue = function getStyleValue(style) {
  30638. return style.split("-")[1];
  30639. };
  30640. var defaultUnitExportFn = function defaultUnitExportFn(unit) {
  30641. return unit + "px";
  30642. };
  30643. var defaultUnitImportFn = function defaultUnitImportFn(unit) {
  30644. return unit.replace("px", "");
  30645. };
  30646. var ignoredNodeAttributes = ["style"];
  30647. var ignoredEntityNodeAttributes = [
  30648. "style",
  30649. "href",
  30650. "target",
  30651. "alt",
  30652. "title",
  30653. "id",
  30654. "controls",
  30655. "autoplay",
  30656. "loop",
  30657. "poster"
  30658. ];
  30659. var spreadNodeAttributes = function spreadNodeAttributes(attributesObject) {
  30660. return Object.keys(attributesObject)
  30661. .reduce(function(attributeString, attributeName) {
  30662. return (
  30663. attributeString +
  30664. " " +
  30665. attributeName +
  30666. '="' +
  30667. attributesObject[attributeName] +
  30668. '"'
  30669. );
  30670. }, "")
  30671. .replace(/^\s$/, "");
  30672. };
  30673. var defaultFontFamilies = (exports.defaultFontFamilies = [
  30674. {
  30675. name: "Araial",
  30676. family: "Arial, Helvetica, sans-serif"
  30677. },
  30678. {
  30679. name: "Georgia",
  30680. family: "Georgia, serif"
  30681. },
  30682. {
  30683. name: "Impact",
  30684. family: "Impact, serif"
  30685. },
  30686. {
  30687. name: "Monospace",
  30688. family: '"Courier New", Courier, monospace'
  30689. },
  30690. {
  30691. name: "Tahoma",
  30692. family: "tahoma, arial, 'Hiragino Sans GB', 宋体, sans-serif"
  30693. }
  30694. ]);
  30695. var getHexColor = (exports.getHexColor = function getHexColor(color) {
  30696. color = color
  30697. .replace("color:", "")
  30698. .replace(";", "")
  30699. .replace(" ", "");
  30700. if (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(color)) {
  30701. return color;
  30702. } else if (namedColors[color]) {
  30703. return namedColors[color];
  30704. } else if (color.indexOf("rgb") === 0) {
  30705. var rgbArray = color.split(",");
  30706. var convertedColor =
  30707. rgbArray.length < 3
  30708. ? null
  30709. : "#" +
  30710. [rgbArray[0], rgbArray[1], rgbArray[2]]
  30711. .map(function(x) {
  30712. var hex = parseInt(x.replace(/\D/g, ""), 10).toString(16);
  30713. return hex.length === 1 ? "0" + hex : hex;
  30714. })
  30715. .join("");
  30716. return /^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(convertedColor)
  30717. ? convertedColor
  30718. : null;
  30719. } else {
  30720. return null;
  30721. }
  30722. });
  30723. var blocks = (exports.blocks = {
  30724. "header-one": "h1",
  30725. "header-two": "h2",
  30726. "header-three": "h3",
  30727. "header-four": "h4",
  30728. "header-five": "h5",
  30729. "header-six": "h6",
  30730. unstyled: "p",
  30731. blockquote: "blockquote"
  30732. });
  30733. var blockTypes = Object.keys(blocks);
  30734. var blockNames = blockTypes.map(function(key) {
  30735. return blocks[key];
  30736. });
  30737. var convertAtomicBlock = function convertAtomicBlock(
  30738. block,
  30739. contentState,
  30740. blockNodeAttributes
  30741. ) {
  30742. if (!block || !block.key) {
  30743. return _react2.default.createElement("p", null);
  30744. }
  30745. var contentBlock = contentState.getBlockForKey(block.key);
  30746. var className = blockNodeAttributes.class,
  30747. nodeAttrAsProps = _objectWithoutProperties(blockNodeAttributes, [
  30748. "class"
  30749. ]);
  30750. nodeAttrAsProps.className = className;
  30751. if (!contentBlock) {
  30752. return _react2.default.createElement("p", null);
  30753. }
  30754. var entityKey = contentBlock.getEntityAt(0);
  30755. if (!entityKey) {
  30756. return _react2.default.createElement("p", null);
  30757. }
  30758. var entity = contentState.getEntity(entityKey);
  30759. var mediaType = entity.getType().toLowerCase();
  30760. var _block$data = block.data,
  30761. float = _block$data.float,
  30762. alignment = _block$data.alignment;
  30763. var _entity$getData = entity.getData(),
  30764. url = _entity$getData.url,
  30765. link = _entity$getData.link,
  30766. link_target = _entity$getData.link_target,
  30767. width = _entity$getData.width,
  30768. height = _entity$getData.height,
  30769. meta = _entity$getData.meta;
  30770. if (mediaType === "image") {
  30771. var imageWrapStyle = {};
  30772. var styledClassName = "";
  30773. if (float) {
  30774. imageWrapStyle.float = float;
  30775. styledClassName += " float-" + float;
  30776. } else if (alignment) {
  30777. imageWrapStyle.textAlign = alignment;
  30778. styledClassName += " align-" + alignment;
  30779. }
  30780. if (link) {
  30781. return _react2.default.createElement(
  30782. "div",
  30783. {
  30784. className: "media-wrap image-wrap" + styledClassName,
  30785. style: imageWrapStyle
  30786. },
  30787. _react2.default.createElement(
  30788. "a",
  30789. {
  30790. style: { display: "inline-block" },
  30791. href: link,
  30792. target: link_target
  30793. },
  30794. _react2.default.createElement(
  30795. "img",
  30796. _extends({}, nodeAttrAsProps, meta, {
  30797. src: url,
  30798. width: width,
  30799. height: height,
  30800. style: { width: width, height: height }
  30801. })
  30802. )
  30803. )
  30804. );
  30805. } else {
  30806. return _react2.default.createElement(
  30807. "div",
  30808. {
  30809. className: "media-wrap image-wrap" + styledClassName,
  30810. style: imageWrapStyle
  30811. },
  30812. _react2.default.createElement(
  30813. "img",
  30814. _extends({}, nodeAttrAsProps, meta, {
  30815. src: url,
  30816. width: width,
  30817. height: height,
  30818. style: { width: width, height: height }
  30819. })
  30820. )
  30821. );
  30822. }
  30823. } else if (mediaType === "audio") {
  30824. return _react2.default.createElement(
  30825. "div",
  30826. { className: "media-wrap audio-wrap" },
  30827. _react2.default.createElement(
  30828. "audio",
  30829. _extends({ controls: true }, nodeAttrAsProps, meta, { src: url })
  30830. )
  30831. );
  30832. } else if (mediaType === "video") {
  30833. return _react2.default.createElement(
  30834. "div",
  30835. { className: "media-wrap video-wrap" },
  30836. _react2.default.createElement(
  30837. "video",
  30838. _extends({ controls: true }, nodeAttrAsProps, meta, {
  30839. src: url,
  30840. width: width,
  30841. height: height
  30842. })
  30843. )
  30844. );
  30845. } else if (mediaType === "embed") {
  30846. return _react2.default.createElement(
  30847. "div",
  30848. { className: "media-wrap embed-wrap" },
  30849. _react2.default.createElement("div", {
  30850. dangerouslySetInnerHTML: { __html: url }
  30851. })
  30852. );
  30853. } else if (mediaType === "hr") {
  30854. return _react2.default.createElement("hr", null);
  30855. } else {
  30856. return _react2.default.createElement("p", null);
  30857. }
  30858. };
  30859. var entityToHTML = function entityToHTML(options) {
  30860. return function(entity, originalText) {
  30861. var entityExportFn = options.entityExportFn;
  30862. var entityType = entity.type.toLowerCase();
  30863. if (entityExportFn) {
  30864. var customOutput = entityExportFn(entity, originalText);
  30865. if (customOutput) {
  30866. return customOutput;
  30867. }
  30868. }
  30869. if (entityType === "link") {
  30870. var _ref = entity.data.nodeAttributes || {},
  30871. className = _ref.class,
  30872. nodeAttrAsProps = _objectWithoutProperties(_ref, ["class"]);
  30873. nodeAttrAsProps.className = className;
  30874. return _react2.default.createElement(
  30875. "a",
  30876. _extends(
  30877. { href: entity.data.href, target: entity.data.target },
  30878. nodeAttrAsProps
  30879. )
  30880. );
  30881. }
  30882. };
  30883. };
  30884. var styleToHTML = function styleToHTML(options) {
  30885. return function(style) {
  30886. var unitExportFn = options.unitExportFn || defaultUnitExportFn;
  30887. if (options.styleExportFn) {
  30888. var customOutput = options.styleExportFn(style, options);
  30889. if (customOutput) {
  30890. return customOutput;
  30891. }
  30892. }
  30893. style = style.toLowerCase();
  30894. if (style === "strikethrough") {
  30895. return _react2.default.createElement("span", {
  30896. style: { textDecoration: "line-through" }
  30897. });
  30898. } else if (style === "superscript") {
  30899. return _react2.default.createElement("sup", null);
  30900. } else if (style === "subscript") {
  30901. return _react2.default.createElement("sub", null);
  30902. } else if (style.indexOf("color-") === 0) {
  30903. return _react2.default.createElement("span", {
  30904. style: { color: "#" + getStyleValue(style) }
  30905. });
  30906. } else if (style.indexOf("bgcolor-") === 0) {
  30907. return _react2.default.createElement("span", {
  30908. style: { backgroundColor: "#" + getStyleValue(style) }
  30909. });
  30910. } else if (style.indexOf("fontsize-") === 0) {
  30911. return _react2.default.createElement("span", {
  30912. style: {
  30913. fontSize: unitExportFn(getStyleValue(style), "font-size", "html")
  30914. }
  30915. });
  30916. } else if (style.indexOf("lineheight-") === 0) {
  30917. return _react2.default.createElement("span", {
  30918. style: {
  30919. lineHeight: unitExportFn(
  30920. getStyleValue(style),
  30921. "line-height",
  30922. "html"
  30923. )
  30924. }
  30925. });
  30926. } else if (style.indexOf("letterspacing-") === 0) {
  30927. return _react2.default.createElement("span", {
  30928. style: {
  30929. letterSpacing: unitExportFn(
  30930. getStyleValue(style),
  30931. "letter-spacing",
  30932. "html"
  30933. )
  30934. }
  30935. });
  30936. } else if (style.indexOf("fontfamily-") === 0) {
  30937. var fontFamily = options.fontFamilies.find(function(item) {
  30938. return item.name.toLowerCase() === getStyleValue(style);
  30939. });
  30940. if (!fontFamily) return;
  30941. return _react2.default.createElement("span", {
  30942. style: { fontFamily: fontFamily.family }
  30943. });
  30944. }
  30945. };
  30946. };
  30947. var blockToHTML = function blockToHTML(options) {
  30948. return function(block) {
  30949. var blockExportFn = options.blockExportFn,
  30950. contentState = options.contentState;
  30951. if (blockExportFn) {
  30952. var customOutput = blockExportFn(contentState, block);
  30953. if (customOutput) {
  30954. return customOutput;
  30955. }
  30956. }
  30957. var blockStyle = "";
  30958. var blockType = block.type.toLowerCase();
  30959. var _block$data2 = block.data,
  30960. textAlign = _block$data2.textAlign,
  30961. textIndent = _block$data2.textIndent,
  30962. _block$data2$nodeAttr = _block$data2.nodeAttributes,
  30963. nodeAttributes =
  30964. _block$data2$nodeAttr === undefined ? {} : _block$data2$nodeAttr;
  30965. var attributeString = spreadNodeAttributes(nodeAttributes);
  30966. if (textAlign || textIndent) {
  30967. blockStyle = ' style="';
  30968. if (textAlign) {
  30969. blockStyle += "text-align:" + textAlign + ";";
  30970. }
  30971. if (textIndent && !isNaN(textIndent) && textIndent > 0) {
  30972. blockStyle += "text-indent:" + textIndent * 2 + "em;";
  30973. }
  30974. blockStyle += '"';
  30975. }
  30976. if (blockType === "atomic") {
  30977. return convertAtomicBlock(block, contentState, nodeAttributes);
  30978. } else if (blockType === "code-block") {
  30979. var previousBlock = contentState.getBlockBefore(block.key);
  30980. var nextBlock = contentState.getBlockAfter(block.key);
  30981. var previousBlockType = previousBlock && previousBlock.getType();
  30982. var nextBlockType = nextBlock && nextBlock.getType();
  30983. var start = "";
  30984. var end = "";
  30985. if (previousBlockType !== "code-block") {
  30986. start = "<pre" + attributeString + "><code>";
  30987. } else {
  30988. start = "";
  30989. }
  30990. if (nextBlockType !== "code-block") {
  30991. end = "</code></pre>";
  30992. } else {
  30993. end = "<br/>";
  30994. }
  30995. return { start: start, end: end };
  30996. } else if (blocks[blockType]) {
  30997. return {
  30998. start: "<" + blocks[blockType] + blockStyle + attributeString + ">",
  30999. end: "</" + blocks[blockType] + ">"
  31000. };
  31001. } else if (blockType === "unordered-list-item") {
  31002. return {
  31003. start: "<li" + blockStyle + attributeString + ">",
  31004. end: "</li>",
  31005. nest: _react2.default.createElement("ul", null)
  31006. };
  31007. } else if (blockType === "ordered-list-item") {
  31008. return {
  31009. start: "<li" + blockStyle + attributeString + ">",
  31010. end: "</li>",
  31011. nest: _react2.default.createElement("ol", null)
  31012. };
  31013. }
  31014. };
  31015. };
  31016. var htmlToStyle = function htmlToStyle(options, source) {
  31017. return function(nodeName, node, currentStyle) {
  31018. if (!node || !node.style) {
  31019. return currentStyle;
  31020. }
  31021. var unitImportFn = options.unitImportFn || defaultUnitImportFn;
  31022. var newStyle = currentStyle;
  31023. [].forEach.call(node.style, function(style) {
  31024. if (nodeName === "span" && style === "color") {
  31025. var color = getHexColor(node.style.color);
  31026. newStyle = color
  31027. ? newStyle.add("COLOR-" + color.replace("#", "").toUpperCase())
  31028. : newStyle;
  31029. } else if (nodeName === "span" && style === "background-color") {
  31030. var _color = getHexColor(node.style.backgroundColor);
  31031. newStyle = _color
  31032. ? newStyle.add("BGCOLOR-" + _color.replace("#", "").toUpperCase())
  31033. : newStyle;
  31034. } else if (nodeName === "span" && style === "font-size") {
  31035. newStyle = newStyle.add(
  31036. "FONTSIZE-" + unitImportFn(node.style.fontSize, "font-size", source)
  31037. );
  31038. } else if (
  31039. nodeName === "span" &&
  31040. style === "line-height" &&
  31041. !isNaN(parseFloat(node.style.lineHeight, 10))
  31042. ) {
  31043. newStyle = newStyle.add(
  31044. "LINEHEIGHT-" +
  31045. unitImportFn(node.style.lineHeight, "line-height", source)
  31046. );
  31047. } else if (
  31048. nodeName === "span" &&
  31049. style === "letter-spacing" &&
  31050. !isNaN(parseFloat(node.style.letterSpacing, 10))
  31051. ) {
  31052. newStyle = newStyle.add(
  31053. "LETTERSPACING-" +
  31054. unitImportFn(node.style.letterSpacing, "letter-spacing", source)
  31055. );
  31056. } else if (nodeName === "span" && style === "text-decoration") {
  31057. if (node.style.textDecoration === "line-through") {
  31058. newStyle = newStyle.add("STRIKETHROUGH");
  31059. } else if (node.style.textDecoration === "underline") {
  31060. newStyle = newStyle.add("UNDERLINE");
  31061. }
  31062. } else if (nodeName === "span" && style === "font-family") {
  31063. var fontFamily = options.fontFamilies.find(function(item) {
  31064. return (
  31065. item.family.toLowerCase() === node.style.fontFamily.toLowerCase()
  31066. );
  31067. });
  31068. if (!fontFamily) return;
  31069. newStyle = newStyle.add(
  31070. "FONTFAMILY-" + fontFamily.name.toUpperCase()
  31071. );
  31072. }
  31073. });
  31074. if (nodeName === "sup") {
  31075. newStyle = newStyle.add("SUPERSCRIPT");
  31076. } else if (nodeName === "sub") {
  31077. newStyle = newStyle.add("SUBSCRIPT");
  31078. }
  31079. options.styleImportFn &&
  31080. (newStyle =
  31081. options.styleImportFn(nodeName, node, newStyle, source) || newStyle);
  31082. return newStyle;
  31083. };
  31084. };
  31085. var htmlToEntity = function htmlToEntity(options, source) {
  31086. return function(nodeName, node, createEntity) {
  31087. if (options && options.entityImportFn) {
  31088. var customInput = options.entityImportFn(
  31089. nodeName,
  31090. node,
  31091. createEntity,
  31092. source
  31093. );
  31094. if (customInput) {
  31095. return customInput;
  31096. }
  31097. }
  31098. nodeName = nodeName.toLowerCase();
  31099. var alt = node.alt,
  31100. title = node.title,
  31101. id = node.id,
  31102. controls = node.controls,
  31103. autoplay = node.autoplay,
  31104. loop = node.loop,
  31105. poster = node.poster;
  31106. var meta = {};
  31107. var nodeAttributes = {};
  31108. id && (meta.id = id);
  31109. alt && (meta.alt = alt);
  31110. title && (meta.title = title);
  31111. controls && (meta.controls = controls);
  31112. autoplay && (meta.autoPlay = autoplay);
  31113. loop && (meta.loop = loop);
  31114. poster && (meta.poster = poster);
  31115. node.attributes &&
  31116. Object.keys(node.attributes).forEach(function(key) {
  31117. var attr = node.attributes[key];
  31118. ignoredEntityNodeAttributes.indexOf(attr.name) === -1 &&
  31119. (nodeAttributes[attr.name] = attr.value);
  31120. });
  31121. if (nodeName === "a" && !node.querySelectorAll("img").length) {
  31122. var href = node.getAttribute("href");
  31123. var _target = node.getAttribute("target");
  31124. return createEntity("LINK", "MUTABLE", {
  31125. href: href,
  31126. target: _target,
  31127. nodeAttributes: nodeAttributes
  31128. });
  31129. } else if (nodeName === "audio") {
  31130. return createEntity("AUDIO", "IMMUTABLE", {
  31131. url: node.getAttribute("src"),
  31132. meta: meta,
  31133. nodeAttributes: nodeAttributes
  31134. });
  31135. } else if (nodeName === "video") {
  31136. return createEntity("VIDEO", "IMMUTABLE", {
  31137. url: node.getAttribute("src"),
  31138. meta: meta,
  31139. nodeAttributes: nodeAttributes
  31140. });
  31141. } else if (nodeName === "img") {
  31142. var parentNode = node.parentNode;
  31143. var entityData = { meta: meta };
  31144. var _node$style = node.style,
  31145. width = _node$style.width,
  31146. height = _node$style.height;
  31147. entityData.url = node.getAttribute("src");
  31148. width && (entityData.width = width);
  31149. height && (entityData.height = height);
  31150. if (parentNode.nodeName.toLowerCase() === "a") {
  31151. entityData.link = parentNode.getAttribute("href");
  31152. entityData.link_target = parentNode.getAttribute("target");
  31153. }
  31154. return createEntity("IMAGE", "IMMUTABLE", entityData);
  31155. } else if (nodeName === "hr") {
  31156. return createEntity("HR", "IMMUTABLE", {});
  31157. } else if (
  31158. node.parentNode &&
  31159. node.parentNode.classList.contains("embed-wrap")
  31160. ) {
  31161. var embedContent = node.innerHTML || node.outerHTML;
  31162. if (embedContent) {
  31163. return createEntity("EMBED", "IMMUTABLE", {
  31164. url: embedContent
  31165. });
  31166. }
  31167. }
  31168. };
  31169. };
  31170. var htmlToBlock = function htmlToBlock(options, source) {
  31171. return function(nodeName, node) {
  31172. if (options && options.blockImportFn) {
  31173. var customInput = options.blockImportFn(nodeName, node, source);
  31174. if (customInput) {
  31175. return customInput;
  31176. }
  31177. }
  31178. var nodeAttributes = {};
  31179. var nodeStyle = node.style || {};
  31180. node.attributes &&
  31181. Object.keys(node.attributes).forEach(function(key) {
  31182. var attr = node.attributes[key];
  31183. ignoredNodeAttributes.indexOf(attr.name) === -1 &&
  31184. (nodeAttributes[attr.name] = attr.value);
  31185. });
  31186. if (node.classList && node.classList.contains("media-wrap")) {
  31187. return {
  31188. type: "atomic",
  31189. data: {
  31190. nodeAttributes: nodeAttributes,
  31191. float: nodeStyle.float,
  31192. alignment: nodeStyle.textAlign
  31193. }
  31194. };
  31195. } else if (nodeName === "img") {
  31196. return {
  31197. type: "atomic",
  31198. data: {
  31199. nodeAttributes: nodeAttributes,
  31200. float: nodeStyle.float,
  31201. alignment: nodeStyle.textAlign
  31202. }
  31203. };
  31204. } else if (nodeName === "hr") {
  31205. return {
  31206. type: "atomic",
  31207. data: { nodeAttributes: nodeAttributes }
  31208. };
  31209. } else if (nodeName === "pre") {
  31210. node.innerHTML = node.innerHTML
  31211. .replace(/<code(.*?)>/g, "")
  31212. .replace(/<\/code>/g, "");
  31213. return {
  31214. type: "code-block",
  31215. data: { nodeAttributes: nodeAttributes }
  31216. };
  31217. } else if (blockNames.indexOf(nodeName) !== -1) {
  31218. var blockData = { nodeAttributes: nodeAttributes };
  31219. if (nodeStyle.textAlign) {
  31220. blockData.textAlign = nodeStyle.textAlign;
  31221. }
  31222. if (nodeStyle.textIndent) {
  31223. blockData.textIndent = /^\d+em$/.test(nodeStyle.textIndent)
  31224. ? Math.ceil(parseInt(nodeStyle.textIndent, 10) / 2)
  31225. : 1;
  31226. }
  31227. return {
  31228. type: blockTypes[blockNames.indexOf(nodeName)],
  31229. data: blockData
  31230. };
  31231. }
  31232. };
  31233. };
  31234. var getToHTMLConfig = (exports.getToHTMLConfig = function getToHTMLConfig(
  31235. options
  31236. ) {
  31237. return {
  31238. styleToHTML: styleToHTML(options),
  31239. entityToHTML: entityToHTML(options),
  31240. blockToHTML: blockToHTML(options)
  31241. };
  31242. });
  31243. var getFromHTMLConfig = (exports.getFromHTMLConfig = function getFromHTMLConfig(
  31244. options
  31245. ) {
  31246. var source =
  31247. arguments.length > 1 && arguments[1] !== undefined
  31248. ? arguments[1]
  31249. : "unknow";
  31250. return {
  31251. htmlToStyle: htmlToStyle(options, source),
  31252. htmlToEntity: htmlToEntity(options, source),
  31253. htmlToBlock: htmlToBlock(options, source)
  31254. };
  31255. });
  31256. });
  31257. _commonjsHelpers.unwrapExports(configs);
  31258. var configs_1 = configs.getFromHTMLConfig;
  31259. var configs_2 = configs.getToHTMLConfig;
  31260. var configs_3 = configs.blocks;
  31261. var configs_4 = configs.getHexColor;
  31262. var configs_5 = configs.defaultFontFamilies;
  31263. var configs_6 = configs.namedColors;
  31264. var dist = _commonjsHelpers.createCommonjsModule(function(module, exports) {
  31265. Object.defineProperty(exports, "__esModule", {
  31266. value: true
  31267. });
  31268. exports.convertRawToEditorState = exports.convertEditorStateToRaw = exports.convertHTMLToEditorState = exports.convertEditorStateToHTML = exports.convertHTMLToRaw = exports.convertRawToHTML = undefined;
  31269. var _extends =
  31270. Object.assign ||
  31271. function(target) {
  31272. for (var i = 1; i < arguments.length; i++) {
  31273. var source = arguments[i];
  31274. for (var key in source) {
  31275. if (Object.prototype.hasOwnProperty.call(source, key)) {
  31276. target[key] = source[key];
  31277. }
  31278. }
  31279. }
  31280. return target;
  31281. };
  31282. var defaultConvertOptions = {
  31283. fontFamilies: configs.defaultFontFamilies
  31284. };
  31285. var convertRawToHTML = (exports.convertRawToHTML = function convertRawToHTML(
  31286. rawContent,
  31287. options
  31288. ) {
  31289. options = _extends({}, defaultConvertOptions, options);
  31290. try {
  31291. var contentState = (0, Draft.convertFromRaw)(rawContent);
  31292. options.contentState = contentState;
  31293. return (0, lib.convertToHTML)((0, configs.getToHTMLConfig)(options))(
  31294. contentState
  31295. );
  31296. } catch (error) {
  31297. console.warn(error);
  31298. return "";
  31299. }
  31300. });
  31301. var convertHTMLToRaw = (exports.convertHTMLToRaw = function convertHTMLToRaw(
  31302. HTMLString,
  31303. options,
  31304. source
  31305. ) {
  31306. options = _extends({}, defaultConvertOptions, options);
  31307. try {
  31308. var contentState = (0, lib.convertFromHTML)(
  31309. (0, configs.getFromHTMLConfig)(options, source)
  31310. )(HTMLString);
  31311. return (0, Draft.convertToRaw)(contentState);
  31312. } catch (error) {
  31313. console.warn(error);
  31314. return {};
  31315. }
  31316. });
  31317. var convertEditorStateToHTML = (exports.convertEditorStateToHTML = function convertEditorStateToHTML(
  31318. editorState,
  31319. options
  31320. ) {
  31321. options = _extends({}, defaultConvertOptions, options);
  31322. try {
  31323. var contentState = editorState.getCurrentContent();
  31324. options.contentState = contentState;
  31325. return (0, lib.convertToHTML)((0, configs.getToHTMLConfig)(options))(
  31326. contentState
  31327. );
  31328. } catch (error) {
  31329. console.warn(error);
  31330. return "";
  31331. }
  31332. });
  31333. var convertHTMLToEditorState = (exports.convertHTMLToEditorState = function convertHTMLToEditorState(
  31334. HTMLString,
  31335. editorDecorators,
  31336. options,
  31337. source
  31338. ) {
  31339. options = _extends({}, defaultConvertOptions, options);
  31340. try {
  31341. return Draft.EditorState.createWithContent(
  31342. (0, lib.convertFromHTML)(
  31343. (0, configs.getFromHTMLConfig)(options, source)
  31344. )(HTMLString),
  31345. editorDecorators
  31346. );
  31347. } catch (error) {
  31348. console.warn(error);
  31349. return Draft.EditorState.createEmpty(editorDecorators);
  31350. }
  31351. });
  31352. var convertEditorStateToRaw = (exports.convertEditorStateToRaw = function convertEditorStateToRaw(
  31353. editorState
  31354. ) {
  31355. return (0, Draft.convertToRaw)(editorState.getCurrentContent());
  31356. });
  31357. var convertRawToEditorState = (exports.convertRawToEditorState = function convertRawToEditorState(
  31358. rawContent,
  31359. editorDecorators
  31360. ) {
  31361. try {
  31362. return Draft.EditorState.createWithContent(
  31363. (0, Draft.convertFromRaw)(rawContent),
  31364. editorDecorators
  31365. );
  31366. } catch (error) {
  31367. console.warn(error);
  31368. return Draft.EditorState.createEmpty(editorDecorators);
  31369. }
  31370. });
  31371. });
  31372. _commonjsHelpers.unwrapExports(dist);
  31373. var dist_1 = dist.convertRawToEditorState;
  31374. var dist_2 = dist.convertEditorStateToRaw;
  31375. var dist_3 = dist.convertHTMLToEditorState;
  31376. var dist_4 = dist.convertEditorStateToHTML;
  31377. var dist_5 = dist.convertHTMLToRaw;
  31378. var dist_6 = dist.convertRawToHTML;
  31379. var content = _commonjsHelpers.createCommonjsModule(function(module, exports) {
  31380. Object.defineProperty(exports, "__esModule", {
  31381. value: true
  31382. });
  31383. 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;
  31384. var _immutable2 = _interopRequireDefault(immutable$1);
  31385. function _interopRequireDefault(obj) {
  31386. return obj && obj.__esModule ? obj : { default: obj };
  31387. }
  31388. var strictBlockTypes = ["atomic"];
  31389. var registerStrictBlockType = (exports.registerStrictBlockType = function registerStrictBlockType(
  31390. blockType
  31391. ) {
  31392. strictBlockTypes.indexOf(blockType) === -1 &&
  31393. strictBlockTypes.push(blockType);
  31394. });
  31395. var isEditorState = (exports.isEditorState = function isEditorState(
  31396. editorState
  31397. ) {
  31398. return editorState instanceof Draft.EditorState;
  31399. });
  31400. var createEmptyEditorState = (exports.createEmptyEditorState = function createEmptyEditorState(
  31401. editorDecorators
  31402. ) {
  31403. return Draft.EditorState.createEmpty(editorDecorators);
  31404. });
  31405. var createEditorState = (exports.createEditorState = function createEditorState(
  31406. contentState,
  31407. editorDecorators
  31408. ) {
  31409. return Draft.EditorState.createWithContent(contentState, editorDecorators);
  31410. });
  31411. var isSelectionCollapsed = (exports.isSelectionCollapsed = function isSelectionCollapsed(
  31412. editorState
  31413. ) {
  31414. return editorState.getSelection().isCollapsed();
  31415. });
  31416. var selectionContainsBlockType = (exports.selectionContainsBlockType = function selectionContainsBlockType(
  31417. editorState,
  31418. blockType
  31419. ) {
  31420. return getSelectedBlocks(editorState).find(function(block) {
  31421. return block.getType() === blockType;
  31422. });
  31423. });
  31424. var selectionContainsStrictBlock = (exports.selectionContainsStrictBlock = function selectionContainsStrictBlock(
  31425. editorState
  31426. ) {
  31427. return getSelectedBlocks(editorState).find(function(block) {
  31428. return ~strictBlockTypes.indexOf(block.getType());
  31429. });
  31430. });
  31431. var selectBlock = (exports.selectBlock = function selectBlock(
  31432. editorState,
  31433. block
  31434. ) {
  31435. var blockKey = block.getKey();
  31436. return Draft.EditorState.forceSelection(
  31437. editorState,
  31438. new Draft.SelectionState({
  31439. anchorKey: blockKey,
  31440. anchorOffset: 0,
  31441. focusKey: blockKey,
  31442. focusOffset: block.getLength()
  31443. })
  31444. );
  31445. });
  31446. var selectNextBlock = (exports.selectNextBlock = function selectNextBlock(
  31447. editorState,
  31448. block
  31449. ) {
  31450. var nextBlock = editorState
  31451. .getCurrentContent()
  31452. .getBlockAfter(block.getKey());
  31453. return nextBlock ? selectBlock(editorState, nextBlock) : editorState;
  31454. });
  31455. var removeBlock = (exports.removeBlock = function removeBlock(
  31456. editorState,
  31457. block
  31458. ) {
  31459. var lastSelection =
  31460. arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  31461. var nextContentState = void 0,
  31462. nextEditorState = void 0;
  31463. var blockKey = block.getKey();
  31464. nextContentState = Draft.Modifier.removeRange(
  31465. editorState.getCurrentContent(),
  31466. new Draft.SelectionState({
  31467. anchorKey: blockKey,
  31468. anchorOffset: 0,
  31469. focusKey: blockKey,
  31470. focusOffset: block.getLength()
  31471. }),
  31472. "backward"
  31473. );
  31474. nextContentState = Draft.Modifier.setBlockType(
  31475. nextContentState,
  31476. nextContentState.getSelectionAfter(),
  31477. "unstyled"
  31478. );
  31479. nextEditorState = Draft.EditorState.push(
  31480. editorState,
  31481. nextContentState,
  31482. "remove-range"
  31483. );
  31484. return Draft.EditorState.forceSelection(
  31485. nextEditorState,
  31486. lastSelection || nextContentState.getSelectionAfter()
  31487. );
  31488. });
  31489. var getSelectionBlock = (exports.getSelectionBlock = function getSelectionBlock(
  31490. editorState
  31491. ) {
  31492. return editorState
  31493. .getCurrentContent()
  31494. .getBlockForKey(editorState.getSelection().getAnchorKey());
  31495. });
  31496. var updateEachCharacterOfSelection = (exports.updateEachCharacterOfSelection = function updateEachCharacterOfSelection(
  31497. editorState,
  31498. callback
  31499. ) {
  31500. var selectionState = editorState.getSelection();
  31501. var contentState = editorState.getCurrentContent();
  31502. var contentBlocks = contentState.getBlockMap();
  31503. var selectedBlocks = getSelectedBlocks(editorState);
  31504. if (selectedBlocks.length === 0) {
  31505. return editorState;
  31506. }
  31507. var startKey = selectionState.getStartKey();
  31508. var startOffset = selectionState.getStartOffset();
  31509. var endKey = selectionState.getEndKey();
  31510. var endOffset = selectionState.getEndOffset();
  31511. var nextContentBlocks = contentBlocks.map(function(block) {
  31512. if (selectedBlocks.indexOf(block) === -1) {
  31513. return block;
  31514. }
  31515. var blockKey = block.getKey();
  31516. var charactersList = block.getCharacterList();
  31517. var nextCharactersList = null;
  31518. if (blockKey === startKey && blockKey === endKey) {
  31519. nextCharactersList = charactersList.map(function(character, index) {
  31520. if (index >= startOffset && index < endOffset) {
  31521. return callback(character);
  31522. }
  31523. return character;
  31524. });
  31525. } else if (blockKey === startKey) {
  31526. nextCharactersList = charactersList.map(function(character, index) {
  31527. if (index >= startOffset) {
  31528. return callback(character);
  31529. }
  31530. return character;
  31531. });
  31532. } else if (blockKey === endKey) {
  31533. nextCharactersList = charactersList.map(function(character, index) {
  31534. if (index < endOffset) {
  31535. return callback(character);
  31536. }
  31537. return character;
  31538. });
  31539. } else {
  31540. nextCharactersList = charactersList.map(function(character) {
  31541. return callback(character);
  31542. });
  31543. }
  31544. return block.merge({
  31545. characterList: nextCharactersList
  31546. });
  31547. });
  31548. return Draft.EditorState.push(
  31549. editorState,
  31550. contentState.merge({
  31551. blockMap: nextContentBlocks,
  31552. selectionBefore: selectionState,
  31553. selectionAfter: selectionState
  31554. }),
  31555. "update-selection-character-list"
  31556. );
  31557. });
  31558. var getSelectedBlocks = (exports.getSelectedBlocks = function getSelectedBlocks(
  31559. editorState
  31560. ) {
  31561. var selectionState = editorState.getSelection();
  31562. var contentState = editorState.getCurrentContent();
  31563. var startKey = selectionState.getStartKey();
  31564. var endKey = selectionState.getEndKey();
  31565. var isSameBlock = startKey === endKey;
  31566. var startingBlock = contentState.getBlockForKey(startKey);
  31567. var selectedBlocks = [startingBlock];
  31568. if (!isSameBlock) {
  31569. var blockKey = startKey;
  31570. while (blockKey !== endKey) {
  31571. var nextBlock = contentState.getBlockAfter(blockKey);
  31572. selectedBlocks.push(nextBlock);
  31573. blockKey = nextBlock.getKey();
  31574. }
  31575. }
  31576. return selectedBlocks;
  31577. });
  31578. var setSelectionBlockData = (exports.setSelectionBlockData = function setSelectionBlockData(
  31579. editorState,
  31580. blockData,
  31581. override
  31582. ) {
  31583. var newBlockData = override
  31584. ? blockData
  31585. : Object.assign({}, getSelectionBlockData(editorState).toJS(), blockData);
  31586. Object.keys(newBlockData).forEach(function(key) {
  31587. if (newBlockData.hasOwnProperty(key) && newBlockData[key] === undefined) {
  31588. delete newBlockData[key];
  31589. }
  31590. });
  31591. return (0, draftjsUtils.setBlockData)(editorState, newBlockData);
  31592. });
  31593. var getSelectionBlockData = (exports.getSelectionBlockData = function getSelectionBlockData(
  31594. editorState,
  31595. name
  31596. ) {
  31597. var blockData = getSelectionBlock(editorState).getData();
  31598. return name ? blockData.get(name) : blockData;
  31599. });
  31600. var getSelectionBlockType = (exports.getSelectionBlockType = function getSelectionBlockType(
  31601. editorState
  31602. ) {
  31603. return getSelectionBlock(editorState).getType();
  31604. });
  31605. var getSelectionText = (exports.getSelectionText = function getSelectionText(
  31606. editorState
  31607. ) {
  31608. var selectionState = editorState.getSelection();
  31609. var contentState = editorState.getCurrentContent();
  31610. if (
  31611. selectionState.isCollapsed() ||
  31612. getSelectionBlockType(editorState) === "atomic"
  31613. ) {
  31614. return "";
  31615. }
  31616. var anchorKey = selectionState.getAnchorKey();
  31617. var currentContentBlock = contentState.getBlockForKey(anchorKey);
  31618. var start = selectionState.getStartOffset();
  31619. var end = selectionState.getEndOffset();
  31620. return currentContentBlock.getText().slice(start, end);
  31621. });
  31622. var toggleSelectionBlockType = (exports.toggleSelectionBlockType = function toggleSelectionBlockType(
  31623. editorState,
  31624. blockType
  31625. ) {
  31626. if (selectionContainsStrictBlock(editorState)) {
  31627. return editorState;
  31628. }
  31629. return Draft.RichUtils.toggleBlockType(editorState, blockType);
  31630. });
  31631. var getSelectionEntityType = (exports.getSelectionEntityType = function getSelectionEntityType(
  31632. editorState
  31633. ) {
  31634. var entityKey = (0, draftjsUtils.getSelectionEntity)(editorState);
  31635. if (entityKey) {
  31636. var entity = editorState.getCurrentContent().getEntity(entityKey);
  31637. return entity ? entity.get("type") : null;
  31638. }
  31639. return null;
  31640. });
  31641. var getSelectionEntityData = (exports.getSelectionEntityData = function getSelectionEntityData(
  31642. editorState,
  31643. type
  31644. ) {
  31645. var entityKey = (0, draftjsUtils.getSelectionEntity)(editorState);
  31646. if (entityKey) {
  31647. var entity = editorState.getCurrentContent().getEntity(entityKey);
  31648. if (entity && entity.get("type") === type) {
  31649. return entity.getData();
  31650. } else {
  31651. return {};
  31652. }
  31653. } else {
  31654. return {};
  31655. }
  31656. });
  31657. var toggleSelectionEntity = (exports.toggleSelectionEntity = function toggleSelectionEntity(
  31658. editorState,
  31659. entity
  31660. ) {
  31661. var contentState = editorState.getCurrentContent();
  31662. var selectionState = editorState.getSelection();
  31663. if (
  31664. selectionState.isCollapsed() ||
  31665. getSelectionBlockType(editorState) === "atomic"
  31666. ) {
  31667. return editorState;
  31668. }
  31669. if (
  31670. !entity ||
  31671. !entity.type ||
  31672. getSelectionEntityType(editorState) === entity.type
  31673. ) {
  31674. return Draft.EditorState.push(
  31675. editorState,
  31676. Draft.Modifier.applyEntity(contentState, selectionState, null),
  31677. "apply-entity"
  31678. );
  31679. }
  31680. try {
  31681. var nextContentState = contentState.createEntity(
  31682. entity.type,
  31683. entity.mutability,
  31684. entity.data
  31685. );
  31686. var entityKey = nextContentState.getLastCreatedEntityKey();
  31687. var nextEditorState = Draft.EditorState.set(editorState, {
  31688. currentContent: nextContentState
  31689. });
  31690. return Draft.EditorState.push(
  31691. nextEditorState,
  31692. Draft.Modifier.applyEntity(nextContentState, selectionState, entityKey),
  31693. "apply-entity"
  31694. );
  31695. } catch (error) {
  31696. console.warn(error);
  31697. return editorState;
  31698. }
  31699. });
  31700. var toggleSelectionLink = (exports.toggleSelectionLink = function toggleSelectionLink(
  31701. editorState,
  31702. href,
  31703. target
  31704. ) {
  31705. var contentState = editorState.getCurrentContent();
  31706. var selectionState = editorState.getSelection();
  31707. var entityData = { href: href, target: target };
  31708. if (
  31709. selectionState.isCollapsed() ||
  31710. getSelectionBlockType(editorState) === "atomic"
  31711. ) {
  31712. return editorState;
  31713. }
  31714. if (href === false) {
  31715. return Draft.RichUtils.toggleLink(editorState, selectionState, null);
  31716. }
  31717. if (href === null) {
  31718. delete entityData.href;
  31719. }
  31720. try {
  31721. var nextContentState = contentState.createEntity(
  31722. "LINK",
  31723. "MUTABLE",
  31724. entityData
  31725. );
  31726. var entityKey = nextContentState.getLastCreatedEntityKey();
  31727. var nextEditorState = Draft.EditorState.set(editorState, {
  31728. currentContent: nextContentState
  31729. });
  31730. nextEditorState = Draft.RichUtils.toggleLink(
  31731. nextEditorState,
  31732. selectionState,
  31733. entityKey
  31734. );
  31735. nextEditorState = Draft.EditorState.forceSelection(
  31736. nextEditorState,
  31737. selectionState.merge({
  31738. anchorOffset: selectionState.getEndOffset(),
  31739. focusOffset: selectionState.getEndOffset()
  31740. })
  31741. );
  31742. nextEditorState = Draft.EditorState.push(
  31743. nextEditorState,
  31744. Draft.Modifier.insertText(
  31745. nextEditorState.getCurrentContent(),
  31746. nextEditorState.getSelection(),
  31747. ""
  31748. ),
  31749. "insert-text"
  31750. );
  31751. return nextEditorState;
  31752. } catch (error) {
  31753. console.warn(error);
  31754. return editorState;
  31755. }
  31756. });
  31757. var getSelectionInlineStyle = (exports.getSelectionInlineStyle = function getSelectionInlineStyle(
  31758. editorState
  31759. ) {
  31760. return editorState.getCurrentInlineStyle();
  31761. });
  31762. var selectionHasInlineStyle = (exports.selectionHasInlineStyle = function selectionHasInlineStyle(
  31763. editorState,
  31764. style
  31765. ) {
  31766. return getSelectionInlineStyle(editorState).has(style.toUpperCase());
  31767. });
  31768. var toggleSelectionInlineStyle = (exports.toggleSelectionInlineStyle = function toggleSelectionInlineStyle(
  31769. editorState,
  31770. style
  31771. ) {
  31772. var prefix =
  31773. arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
  31774. var nextEditorState = editorState;
  31775. style = prefix + style.toUpperCase();
  31776. if (prefix) {
  31777. nextEditorState = updateEachCharacterOfSelection(
  31778. nextEditorState,
  31779. function(characterMetadata) {
  31780. return characterMetadata
  31781. .toJS()
  31782. .style.reduce(function(characterMetadata, characterStyle) {
  31783. if (
  31784. characterStyle.indexOf(prefix) === 0 &&
  31785. style !== characterStyle
  31786. ) {
  31787. return Draft.CharacterMetadata.removeStyle(
  31788. characterMetadata,
  31789. characterStyle
  31790. );
  31791. } else {
  31792. return characterMetadata;
  31793. }
  31794. }, characterMetadata);
  31795. }
  31796. );
  31797. }
  31798. return Draft.RichUtils.toggleInlineStyle(nextEditorState, style);
  31799. });
  31800. var removeSelectionInlineStyles = (exports.removeSelectionInlineStyles = function removeSelectionInlineStyles(
  31801. editorState
  31802. ) {
  31803. return updateEachCharacterOfSelection(editorState, function(
  31804. characterMetadata
  31805. ) {
  31806. return characterMetadata.merge({
  31807. style: _immutable2.default.OrderedSet([])
  31808. });
  31809. });
  31810. });
  31811. var toggleSelectionAlignment = (exports.toggleSelectionAlignment = function toggleSelectionAlignment(
  31812. editorState,
  31813. alignment
  31814. ) {
  31815. return setSelectionBlockData(editorState, {
  31816. textAlign:
  31817. getSelectionBlockData(editorState, "textAlign") !== alignment
  31818. ? alignment
  31819. : undefined
  31820. });
  31821. });
  31822. var toggleSelectionIndent = (exports.toggleSelectionIndent = function toggleSelectionIndent(
  31823. editorState,
  31824. textIndent
  31825. ) {
  31826. var maxIndent =
  31827. arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 6;
  31828. return textIndent < 0 || textIndent > maxIndent || isNaN(textIndent)
  31829. ? editorState
  31830. : setSelectionBlockData(editorState, {
  31831. textIndent: textIndent || undefined
  31832. });
  31833. });
  31834. var increaseSelectionIndent = (exports.increaseSelectionIndent = function increaseSelectionIndent(
  31835. editorState
  31836. ) {
  31837. var maxIndent =
  31838. arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
  31839. var currentIndent = getSelectionBlockData(editorState, "textIndent") || 0;
  31840. return toggleSelectionIndent(editorState, currentIndent + 1, maxIndent);
  31841. });
  31842. var decreaseSelectionIndent = (exports.decreaseSelectionIndent = function decreaseSelectionIndent(
  31843. editorState
  31844. ) {
  31845. var currentIndent = getSelectionBlockData(editorState, "textIndent") || 0;
  31846. return toggleSelectionIndent(editorState, currentIndent - 1);
  31847. });
  31848. var toggleSelectionColor = (exports.toggleSelectionColor = function toggleSelectionColor(
  31849. editorState,
  31850. color
  31851. ) {
  31852. return toggleSelectionInlineStyle(
  31853. editorState,
  31854. color.replace("#", ""),
  31855. "COLOR-"
  31856. );
  31857. });
  31858. var toggleSelectionBackgroundColor = (exports.toggleSelectionBackgroundColor = function toggleSelectionBackgroundColor(
  31859. editorState,
  31860. color
  31861. ) {
  31862. return toggleSelectionInlineStyle(
  31863. editorState,
  31864. color.replace("#", ""),
  31865. "BGCOLOR-"
  31866. );
  31867. });
  31868. var toggleSelectionFontSize = (exports.toggleSelectionFontSize = function toggleSelectionFontSize(
  31869. editorState,
  31870. fontSize
  31871. ) {
  31872. return toggleSelectionInlineStyle(editorState, fontSize, "FONTSIZE-");
  31873. });
  31874. var toggleSelectionLineHeight = (exports.toggleSelectionLineHeight = function toggleSelectionLineHeight(
  31875. editorState,
  31876. lineHeight
  31877. ) {
  31878. return toggleSelectionInlineStyle(editorState, lineHeight, "LINEHEIGHT-");
  31879. });
  31880. var toggleSelectionFontFamily = (exports.toggleSelectionFontFamily = function toggleSelectionFontFamily(
  31881. editorState,
  31882. fontFamily
  31883. ) {
  31884. return toggleSelectionInlineStyle(editorState, fontFamily, "FONTFAMILY-");
  31885. });
  31886. var toggleSelectionLetterSpacing = (exports.toggleSelectionLetterSpacing = function toggleSelectionLetterSpacing(
  31887. editorState,
  31888. letterSpacing
  31889. ) {
  31890. return toggleSelectionInlineStyle(
  31891. editorState,
  31892. letterSpacing,
  31893. "LETTERSPACING-"
  31894. );
  31895. });
  31896. var insertText = (exports.insertText = function insertText(
  31897. editorState,
  31898. text,
  31899. inlineStyle,
  31900. entity
  31901. ) {
  31902. var selectionState = editorState.getSelection();
  31903. var currentSelectedBlockType = getSelectionBlockType(editorState);
  31904. if (currentSelectedBlockType === "atomic") {
  31905. return editorState;
  31906. }
  31907. var entityKey = void 0;
  31908. var contentState = editorState.getCurrentContent();
  31909. if (entity && entity.type) {
  31910. contentState = contentState.createEntity(
  31911. entity.type,
  31912. entity.mutability || "MUTABLE",
  31913. entity.data || entityData
  31914. );
  31915. entityKey = contentState.getLastCreatedEntityKey();
  31916. }
  31917. if (!selectionState.isCollapsed()) {
  31918. return Draft.EditorState.push(
  31919. editorState,
  31920. Draft.Modifier.replaceText(
  31921. contentState,
  31922. selectionState,
  31923. text,
  31924. inlineStyle,
  31925. entityKey
  31926. ),
  31927. "replace-text"
  31928. );
  31929. } else {
  31930. return Draft.EditorState.push(
  31931. editorState,
  31932. Draft.Modifier.insertText(
  31933. contentState,
  31934. selectionState,
  31935. text,
  31936. inlineStyle,
  31937. entityKey
  31938. ),
  31939. "insert-text"
  31940. );
  31941. }
  31942. });
  31943. var insertHTML = (exports.insertHTML = function insertHTML(
  31944. editorState,
  31945. htmlString,
  31946. source
  31947. ) {
  31948. if (!htmlString) {
  31949. return editorState;
  31950. }
  31951. var selectionState = editorState.getSelection();
  31952. var contentState = editorState.getCurrentContent();
  31953. var options = editorState.convertOptions || {};
  31954. try {
  31955. var _convertFromRaw = (0, Draft.convertFromRaw)(
  31956. (0, dist.convertHTMLToRaw)(htmlString, options, source)
  31957. ),
  31958. blockMap = _convertFromRaw.blockMap;
  31959. return Draft.EditorState.push(
  31960. editorState,
  31961. Draft.Modifier.replaceWithFragment(
  31962. contentState,
  31963. selectionState,
  31964. blockMap
  31965. ),
  31966. "insert-fragment"
  31967. );
  31968. } catch (error) {
  31969. console.warn(error);
  31970. return editorState;
  31971. }
  31972. });
  31973. var insertAtomicBlock = (exports.insertAtomicBlock = function insertAtomicBlock(
  31974. editorState,
  31975. type
  31976. ) {
  31977. var immutable =
  31978. arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  31979. var data =
  31980. arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  31981. if (selectionContainsStrictBlock(editorState)) {
  31982. return insertAtomicBlock(
  31983. selectNextBlock(editorState, getSelectionBlock(editorState)),
  31984. type,
  31985. immutable,
  31986. data
  31987. );
  31988. }
  31989. var selectionState = editorState.getSelection();
  31990. var contentState = editorState.getCurrentContent();
  31991. if (
  31992. !selectionState.isCollapsed() ||
  31993. getSelectionBlockType(editorState) === "atomic"
  31994. ) {
  31995. return editorState;
  31996. }
  31997. var contentStateWithEntity = contentState.createEntity(
  31998. type,
  31999. immutable ? "IMMUTABLE" : "MUTABLE",
  32000. data
  32001. );
  32002. var entityKey = contentStateWithEntity.getLastCreatedEntityKey();
  32003. var newEditorState = Draft.AtomicBlockUtils.insertAtomicBlock(
  32004. editorState,
  32005. entityKey,
  32006. " "
  32007. );
  32008. return newEditorState;
  32009. });
  32010. var insertHorizontalLine = (exports.insertHorizontalLine = function insertHorizontalLine(
  32011. editorState
  32012. ) {
  32013. return insertAtomicBlock(editorState, "HR");
  32014. });
  32015. var insertMedias = (exports.insertMedias = function insertMedias(
  32016. editorState
  32017. ) {
  32018. var medias =
  32019. arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  32020. if (!medias.length) {
  32021. return editorState;
  32022. }
  32023. return medias.reduce(function(editorState, media) {
  32024. var url = media.url,
  32025. link = media.link,
  32026. link_target = media.link_target,
  32027. name = media.name,
  32028. type = media.type,
  32029. width = media.width,
  32030. height = media.height,
  32031. meta = media.meta;
  32032. return insertAtomicBlock(editorState, type, true, {
  32033. url: url,
  32034. link: link,
  32035. link_target: link_target,
  32036. name: name,
  32037. type: type,
  32038. width: width,
  32039. height: height,
  32040. meta: meta
  32041. });
  32042. }, editorState);
  32043. });
  32044. var setMediaData = (exports.setMediaData = function setMediaData(
  32045. editorState,
  32046. entityKey,
  32047. data
  32048. ) {
  32049. return Draft.EditorState.push(
  32050. editorState,
  32051. editorState.getCurrentContent().mergeEntityData(entityKey, data),
  32052. "change-block-data"
  32053. );
  32054. });
  32055. var removeMedia = (exports.removeMedia = function removeMedia(
  32056. editorState,
  32057. mediaBlock
  32058. ) {
  32059. return removeBlock(editorState, mediaBlock);
  32060. });
  32061. var setMediaPosition = (exports.setMediaPosition = function setMediaPosition(
  32062. editorState,
  32063. mediaBlock,
  32064. position
  32065. ) {
  32066. var newPosition = {};
  32067. var float = position.float,
  32068. alignment = position.alignment;
  32069. if (typeof float !== "undefined") {
  32070. newPosition.float =
  32071. mediaBlock.getData().get("float") === float ? null : float;
  32072. }
  32073. if (typeof alignment !== "undefined") {
  32074. newPosition.alignment =
  32075. mediaBlock.getData().get("alignment") === alignment ? null : alignment;
  32076. }
  32077. return setSelectionBlockData(
  32078. selectBlock(editorState, mediaBlock),
  32079. newPosition
  32080. );
  32081. });
  32082. var clear = (exports.clear = function clear(editorState) {
  32083. var contentState = editorState.getCurrentContent();
  32084. var firstBlock = contentState.getFirstBlock();
  32085. var lastBlock = contentState.getLastBlock();
  32086. var allSelected = new Draft.SelectionState({
  32087. anchorKey: firstBlock.getKey(),
  32088. anchorOffset: 0,
  32089. focusKey: lastBlock.getKey(),
  32090. focusOffset: lastBlock.getLength(),
  32091. hasFocus: true
  32092. });
  32093. return Draft.RichUtils.toggleBlockType(
  32094. Draft.EditorState.push(
  32095. editorState,
  32096. Draft.Modifier.removeRange(contentState, allSelected, "backward"),
  32097. "remove-range"
  32098. ),
  32099. "unstyled"
  32100. );
  32101. });
  32102. var handleKeyCommand = (exports.handleKeyCommand = function handleKeyCommand(
  32103. editorState,
  32104. command
  32105. ) {
  32106. return Draft.RichUtils.handleKeyCommand(editorState, command);
  32107. });
  32108. var undo = (exports.undo = function undo(editorState) {
  32109. return Draft.EditorState.undo(editorState);
  32110. });
  32111. var redo = (exports.redo = function redo(editorState) {
  32112. return Draft.EditorState.redo(editorState);
  32113. });
  32114. });
  32115. _commonjsHelpers.unwrapExports(content);
  32116. var content_1 = content.redo;
  32117. var content_2 = content.undo;
  32118. var content_3 = content.handleKeyCommand;
  32119. var content_4 = content.clear;
  32120. var content_5 = content.setMediaPosition;
  32121. var content_6 = content.removeMedia;
  32122. var content_7 = content.setMediaData;
  32123. var content_8 = content.insertMedias;
  32124. var content_9 = content.insertHorizontalLine;
  32125. var content_10 = content.insertAtomicBlock;
  32126. var content_11 = content.insertHTML;
  32127. var content_12 = content.insertText;
  32128. var content_13 = content.toggleSelectionLetterSpacing;
  32129. var content_14 = content.toggleSelectionFontFamily;
  32130. var content_15 = content.toggleSelectionLineHeight;
  32131. var content_16 = content.toggleSelectionFontSize;
  32132. var content_17 = content.toggleSelectionBackgroundColor;
  32133. var content_18 = content.toggleSelectionColor;
  32134. var content_19 = content.decreaseSelectionIndent;
  32135. var content_20 = content.increaseSelectionIndent;
  32136. var content_21 = content.toggleSelectionIndent;
  32137. var content_22 = content.toggleSelectionAlignment;
  32138. var content_23 = content.removeSelectionInlineStyles;
  32139. var content_24 = content.toggleSelectionInlineStyle;
  32140. var content_25 = content.selectionHasInlineStyle;
  32141. var content_26 = content.getSelectionInlineStyle;
  32142. var content_27 = content.toggleSelectionLink;
  32143. var content_28 = content.toggleSelectionEntity;
  32144. var content_29 = content.getSelectionEntityData;
  32145. var content_30 = content.getSelectionEntityType;
  32146. var content_31 = content.toggleSelectionBlockType;
  32147. var content_32 = content.getSelectionText;
  32148. var content_33 = content.getSelectionBlockType;
  32149. var content_34 = content.getSelectionBlockData;
  32150. var content_35 = content.setSelectionBlockData;
  32151. var content_36 = content.getSelectedBlocks;
  32152. var content_37 = content.updateEachCharacterOfSelection;
  32153. var content_38 = content.getSelectionBlock;
  32154. var content_39 = content.removeBlock;
  32155. var content_40 = content.selectNextBlock;
  32156. var content_41 = content.selectBlock;
  32157. var content_42 = content.selectionContainsStrictBlock;
  32158. var content_43 = content.selectionContainsBlockType;
  32159. var content_44 = content.isSelectionCollapsed;
  32160. var content_45 = content.createEditorState;
  32161. var content_46 = content.createEmptyEditorState;
  32162. var content_47 = content.isEditorState;
  32163. var content_48 = content.registerStrictBlockType;
  32164. var base = _commonjsHelpers.createCommonjsModule(function(module, exports) {
  32165. Object.defineProperty(exports, "__esModule", {
  32166. value: true
  32167. });
  32168. var braftUniqueIndex = 0;
  32169. var UniqueIndex = (exports.UniqueIndex = function UniqueIndex() {
  32170. return (braftUniqueIndex += 1);
  32171. });
  32172. });
  32173. _commonjsHelpers.unwrapExports(base);
  32174. var base_1 = base.UniqueIndex;
  32175. var color = _commonjsHelpers.createCommonjsModule(function(module, exports) {
  32176. Object.defineProperty(exports, "__esModule", {
  32177. value: true
  32178. });
  32179. var _namedColors = {
  32180. aliceblue: "#f0f8ff",
  32181. antiquewhite: "#faebd7",
  32182. aqua: "#00ffff",
  32183. aquamarine: "#7fffd4",
  32184. azure: "#f0ffff",
  32185. beige: "#f5f5dc",
  32186. bisque: "#ffe4c4",
  32187. black: "#000000",
  32188. blanchedalmond: "#ffebcd",
  32189. blue: "#0000ff",
  32190. blueviolet: "#8a2be2",
  32191. brown: "#a52a2a",
  32192. burlywood: "#deb887",
  32193. cadetblue: "#5f9ea0",
  32194. chartreuse: "#7fff00",
  32195. chocolate: "#d2691e",
  32196. coral: "#ff7f50",
  32197. cornflowerblue: "#6495ed",
  32198. cornsilk: "#fff8dc",
  32199. crimson: "#dc143c",
  32200. cyan: "#00ffff",
  32201. darkblue: "#00008b",
  32202. darkcyan: "#008b8b",
  32203. darkgoldenrod: "#b8860b",
  32204. darkgray: "#a9a9a9",
  32205. darkgreen: "#006400",
  32206. darkkhaki: "#bdb76b",
  32207. darkmagenta: "#8b008b",
  32208. darkolivegreen: "#556b2f",
  32209. darkorange: "#ff8c00",
  32210. darkorchid: "#9932cc",
  32211. darkred: "#8b0000",
  32212. darksalmon: "#e9967a",
  32213. darkseagreen: "#8fbc8f",
  32214. darkslateblue: "#483d8b",
  32215. darkslategray: "#2f4f4f",
  32216. darkturquoise: "#00ced1",
  32217. darkviolet: "#9400d3",
  32218. deeppink: "#ff1493",
  32219. deepskyblue: "#00bfff",
  32220. dimgray: "#696969",
  32221. dodgerblue: "#1e90ff",
  32222. firebrick: "#b22222",
  32223. floralwhite: "#fffaf0",
  32224. forestgreen: "#228b22",
  32225. fuchsia: "#ff00ff",
  32226. gainsboro: "#dcdcdc",
  32227. ghostwhite: "#f8f8ff",
  32228. gold: "#ffd700",
  32229. goldenrod: "#daa520",
  32230. gray: "#808080",
  32231. green: "#008000",
  32232. greenyellow: "#adff2f",
  32233. honeydew: "#f0fff0",
  32234. hotpink: "#ff69b4",
  32235. "indianred ": "#cd5c5c",
  32236. indigo: "#4b0082",
  32237. ivory: "#fffff0",
  32238. khaki: "#f0e68c",
  32239. lavender: "#e6e6fa",
  32240. lavenderblush: "#fff0f5",
  32241. lawngreen: "#7cfc00",
  32242. lemonchiffon: "#fffacd",
  32243. lightblue: "#add8e6",
  32244. lightcoral: "#f08080",
  32245. lightcyan: "#e0ffff",
  32246. lightgoldenrodyellow: "#fafad2",
  32247. lightgrey: "#d3d3d3",
  32248. lightgreen: "#90ee90",
  32249. lightpink: "#ffb6c1",
  32250. lightsalmon: "#ffa07a",
  32251. lightseagreen: "#20b2aa",
  32252. lightskyblue: "#87cefa",
  32253. lightslategray: "#778899",
  32254. lightsteelblue: "#b0c4de",
  32255. lightyellow: "#ffffe0",
  32256. lime: "#00ff00",
  32257. limegreen: "#32cd32",
  32258. linen: "#faf0e6",
  32259. magenta: "#ff00ff",
  32260. maroon: "#800000",
  32261. mediumaquamarine: "#66cdaa",
  32262. mediumblue: "#0000cd",
  32263. mediumorchid: "#ba55d3",
  32264. mediumpurple: "#9370d8",
  32265. mediumseagreen: "#3cb371",
  32266. mediumslateblue: "#7b68ee",
  32267. mediumspringgreen: "#00fa9a",
  32268. mediumturquoise: "#48d1cc",
  32269. mediumvioletred: "#c71585",
  32270. midnightblue: "#191970",
  32271. mintcream: "#f5fffa",
  32272. mistyrose: "#ffe4e1",
  32273. moccasin: "#ffe4b5",
  32274. navajowhite: "#ffdead",
  32275. navy: "#000080",
  32276. oldlace: "#fdf5e6",
  32277. olive: "#808000",
  32278. olivedrab: "#6b8e23",
  32279. orange: "#ffa500",
  32280. orangered: "#ff4500",
  32281. orchid: "#da70d6",
  32282. palegoldenrod: "#eee8aa",
  32283. palegreen: "#98fb98",
  32284. paleturquoise: "#afeeee",
  32285. palevioletred: "#d87093",
  32286. papayawhip: "#ffefd5",
  32287. peachpuff: "#ffdab9",
  32288. peru: "#cd853f",
  32289. pink: "#ffc0cb",
  32290. plum: "#dda0dd",
  32291. powderblue: "#b0e0e6",
  32292. purple: "#800080",
  32293. rebeccapurple: "#663399",
  32294. red: "#ff0000",
  32295. rosybrown: "#bc8f8f",
  32296. royalblue: "#4169e1",
  32297. saddlebrown: "#8b4513",
  32298. salmon: "#fa8072",
  32299. sandybrown: "#f4a460",
  32300. seagreen: "#2e8b57",
  32301. seashell: "#fff5ee",
  32302. sienna: "#a0522d",
  32303. silver: "#c0c0c0",
  32304. skyblue: "#87ceeb",
  32305. slateblue: "#6a5acd",
  32306. slategray: "#708090",
  32307. snow: "#fffafa",
  32308. springgreen: "#00ff7f",
  32309. steelblue: "#4682b4",
  32310. tan: "#d2b48c",
  32311. teal: "#008080",
  32312. thistle: "#d8bfd8",
  32313. tomato: "#ff6347",
  32314. turquoise: "#40e0d0",
  32315. violet: "#ee82ee",
  32316. wheat: "#f5deb3",
  32317. white: "#ffffff",
  32318. whitesmoke: "#f5f5f5",
  32319. yellow: "#ffff00",
  32320. yellowgreen: "#9acd32"
  32321. };
  32322. var _getHexColor = function _getHexColor(color) {
  32323. color = color
  32324. .replace("color:", "")
  32325. .replace(";", "")
  32326. .replace(" ", "");
  32327. if (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(color)) {
  32328. return color;
  32329. } else if (namedColors[color]) {
  32330. return namedColors[color];
  32331. } else if (color.indexOf("rgb") === 0) {
  32332. var rgbArray = color.split(",");
  32333. var convertedColor =
  32334. rgbArray.length < 3
  32335. ? null
  32336. : "#" +
  32337. [rgbArray[0], rgbArray[1], rgbArray[2]]
  32338. .map(function(x) {
  32339. var hex = parseInt(x.replace(/\D/g, ""), 10).toString(16);
  32340. return hex.length === 1 ? "0" + hex : hex;
  32341. })
  32342. .join("");
  32343. return /^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(convertedColor)
  32344. ? convertedColor
  32345. : null;
  32346. } else {
  32347. return null;
  32348. }
  32349. };
  32350. var namedColors = (exports.namedColors = _namedColors);
  32351. var getHexColor = (exports.getHexColor = _getHexColor);
  32352. var detectColorsFromHTMLString = (exports.detectColorsFromHTMLString = function detectColorsFromHTMLString(
  32353. html
  32354. ) {
  32355. return typeof html !== "string"
  32356. ? []
  32357. : (html.match(/color:[^;]{3,24};/g) || [])
  32358. .map(getHexColor)
  32359. .filter(function(color) {
  32360. return color;
  32361. });
  32362. });
  32363. var detectColorsFromDraftState = (exports.detectColorsFromDraftState = function detectColorsFromDraftState(
  32364. draftState
  32365. ) {
  32366. var result = [];
  32367. if (!draftState || !draftState.blocks || !draftState.blocks.length) {
  32368. return result;
  32369. }
  32370. draftState.blocks.forEach(function(block) {
  32371. if (block && block.inlineStyleRanges && block.inlineStyleRanges.length) {
  32372. block.inlineStyleRanges.forEach(function(inlineStyle) {
  32373. if (inlineStyle.style && inlineStyle.style.indexOf("COLOR-") >= 0) {
  32374. result.push("#" + inlineStyle.style.split("COLOR-")[1]);
  32375. }
  32376. });
  32377. }
  32378. });
  32379. return result.filter(function(color) {
  32380. return color;
  32381. });
  32382. });
  32383. });
  32384. _commonjsHelpers.unwrapExports(color);
  32385. var color_1 = color.namedColors;
  32386. var color_2 = color.getHexColor;
  32387. var color_3 = color.detectColorsFromHTMLString;
  32388. var color_4 = color.detectColorsFromDraftState;
  32389. var dist$1 = _commonjsHelpers.createCommonjsModule(function(module, exports) {
  32390. Object.defineProperty(exports, "__esModule", {
  32391. value: true
  32392. });
  32393. exports.ColorUtils = exports.BaseUtils = exports.ContentUtils = undefined;
  32394. var _ContentUtils = _interopRequireWildcard(content);
  32395. var _BaseUtils = _interopRequireWildcard(base);
  32396. var _ColorUtils = _interopRequireWildcard(color);
  32397. function _interopRequireWildcard(obj) {
  32398. if (obj && obj.__esModule) {
  32399. return obj;
  32400. } else {
  32401. var newObj = {};
  32402. if (obj != null) {
  32403. for (var key in obj) {
  32404. if (Object.prototype.hasOwnProperty.call(obj, key))
  32405. newObj[key] = obj[key];
  32406. }
  32407. }
  32408. newObj.default = obj;
  32409. return newObj;
  32410. }
  32411. }
  32412. var ContentUtils = (exports.ContentUtils = _ContentUtils);
  32413. var BaseUtils = (exports.BaseUtils = _BaseUtils);
  32414. var ColorUtils = (exports.ColorUtils = _ColorUtils);
  32415. });
  32416. _commonjsHelpers.unwrapExports(dist$1);
  32417. var dist_1$1 = dist$1.ColorUtils;
  32418. var dist_2$1 = dist$1.BaseUtils;
  32419. var dist_3$1 = dist$1.ContentUtils;
  32420. var dist$2 = _commonjsHelpers.createCommonjsModule(function(module, exports) {
  32421. (function webpackUniversalModuleDefinition(root, factory) {
  32422. module.exports = factory(React__default);
  32423. })(window, function(__WEBPACK_EXTERNAL_MODULE__2__) {
  32424. return /******/ (function(modules) {
  32425. // webpackBootstrap
  32426. /******/ // The module cache
  32427. /******/ var installedModules = {}; // The require function
  32428. /******/
  32429. /******/ /******/ function __webpack_require__(moduleId) {
  32430. /******/
  32431. /******/ // Check if module is in cache
  32432. /******/ if (installedModules[moduleId]) {
  32433. /******/ return installedModules[moduleId].exports;
  32434. /******/
  32435. } // Create a new module (and put it into the cache)
  32436. /******/ /******/ var module = (installedModules[moduleId] = {
  32437. /******/ i: moduleId,
  32438. /******/ l: false,
  32439. /******/ exports: {}
  32440. /******/
  32441. }); // Execute the module function
  32442. /******/
  32443. /******/ /******/ modules[moduleId].call(
  32444. module.exports,
  32445. module,
  32446. module.exports,
  32447. __webpack_require__
  32448. ); // Flag the module as loaded
  32449. /******/
  32450. /******/ /******/ module.l = true; // Return the exports of the module
  32451. /******/
  32452. /******/ /******/ return module.exports;
  32453. /******/
  32454. } // expose the modules object (__webpack_modules__)
  32455. /******/
  32456. /******/
  32457. /******/ /******/ __webpack_require__.m = modules; // expose the module cache
  32458. /******/
  32459. /******/ /******/ __webpack_require__.c = installedModules; // define getter function for harmony exports
  32460. /******/
  32461. /******/ /******/ __webpack_require__.d = function(
  32462. exports,
  32463. name,
  32464. getter
  32465. ) {
  32466. /******/ if (!__webpack_require__.o(exports, name)) {
  32467. /******/ Object.defineProperty(exports, name, {
  32468. enumerable: true,
  32469. get: getter
  32470. });
  32471. /******/
  32472. }
  32473. /******/
  32474. }; // define __esModule on exports
  32475. /******/
  32476. /******/ /******/ __webpack_require__.r = function(exports) {
  32477. /******/ if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
  32478. /******/ Object.defineProperty(exports, Symbol.toStringTag, {
  32479. value: "Module"
  32480. });
  32481. /******/
  32482. }
  32483. /******/ Object.defineProperty(exports, "__esModule", { value: true });
  32484. /******/
  32485. }; // create a fake namespace object // mode & 1: value is a module id, require it // mode & 2: merge all properties of value into the ns // mode & 4: return value when already ns object // mode & 8|1: behave like require
  32486. /******/
  32487. /******/ /******/ /******/ /******/ /******/ /******/ __webpack_require__.t = function(
  32488. value,
  32489. mode
  32490. ) {
  32491. /******/ if (mode & 1) value = __webpack_require__(value);
  32492. /******/ if (mode & 8) return value;
  32493. /******/ if (
  32494. mode & 4 &&
  32495. typeof value === "object" &&
  32496. value &&
  32497. value.__esModule
  32498. )
  32499. return value;
  32500. /******/ var ns = Object.create(null);
  32501. /******/ __webpack_require__.r(ns);
  32502. /******/ Object.defineProperty(ns, "default", {
  32503. enumerable: true,
  32504. value: value
  32505. });
  32506. /******/ if (mode & 2 && typeof value != "string")
  32507. for (var key in value)
  32508. __webpack_require__.d(
  32509. ns,
  32510. key,
  32511. function(key) {
  32512. return value[key];
  32513. }.bind(null, key)
  32514. );
  32515. /******/ return ns;
  32516. /******/
  32517. }; // getDefaultExport function for compatibility with non-harmony modules
  32518. /******/
  32519. /******/ /******/ __webpack_require__.n = function(module) {
  32520. /******/ var getter =
  32521. module && module.__esModule
  32522. ? /******/ function getDefault() {
  32523. return module["default"];
  32524. }
  32525. : /******/ function getModuleExports() {
  32526. return module;
  32527. };
  32528. /******/ __webpack_require__.d(getter, "a", getter);
  32529. /******/ return getter;
  32530. /******/
  32531. }; // Object.prototype.hasOwnProperty.call
  32532. /******/
  32533. /******/ /******/ __webpack_require__.o = function(object, property) {
  32534. return Object.prototype.hasOwnProperty.call(object, property);
  32535. }; // __webpack_public_path__
  32536. /******/
  32537. /******/ /******/ __webpack_require__.p = "/"; // Load entry module and return exports
  32538. /******/
  32539. /******/
  32540. /******/ /******/ return __webpack_require__(
  32541. (__webpack_require__.s = 20)
  32542. );
  32543. /******/
  32544. })(
  32545. /************************************************************************/
  32546. /******/ [
  32547. /* 0 */
  32548. /***/ function(module, exports, __webpack_require__) {
  32549. Object.defineProperty(exports, "__esModule", {
  32550. value: true
  32551. });
  32552. var compressImage = (exports.compressImage = function compressImage(
  32553. url
  32554. ) {
  32555. var width =
  32556. arguments.length > 1 && arguments[1] !== undefined
  32557. ? arguments[1]
  32558. : 1280;
  32559. var height =
  32560. arguments.length > 2 && arguments[2] !== undefined
  32561. ? arguments[2]
  32562. : 800;
  32563. return new Promise(function(resolve, reject) {
  32564. var image = new Image();
  32565. image.src = url;
  32566. image.onerror = function(error) {
  32567. reject(error);
  32568. };
  32569. image.onload = function() {
  32570. try {
  32571. var compressCanvas = document.createElement("canvas");
  32572. var scale =
  32573. this.width > width || this.height > height
  32574. ? this.width > this.height
  32575. ? width / this.width
  32576. : height / this.height
  32577. : 1;
  32578. compressCanvas.width = this.width * scale;
  32579. compressCanvas.height = this.height * scale;
  32580. var canvasContext = compressCanvas.getContext("2d");
  32581. canvasContext.drawImage(
  32582. this,
  32583. 0,
  32584. 0,
  32585. compressCanvas.width,
  32586. compressCanvas.height
  32587. );
  32588. resolve({
  32589. url: compressCanvas.toDataURL("image/png", 1),
  32590. width: compressCanvas.width,
  32591. height: compressCanvas.height
  32592. });
  32593. } catch (error) {
  32594. reject(error);
  32595. }
  32596. };
  32597. });
  32598. });
  32599. /***/
  32600. },
  32601. /* 1 */
  32602. /***/ function(module, exports, __webpack_require__) {
  32603. Object.defineProperty(exports, "__esModule", {
  32604. value: true
  32605. });
  32606. var UniqueIndex = (exports.UniqueIndex = function UniqueIndex() {
  32607. if (isNaN(window.__BRAFT_MM_UNIQUE_INDEX__)) {
  32608. window.__BRAFT_MM_UNIQUE_INDEX__ = 1;
  32609. } else {
  32610. window.__BRAFT_MM_UNIQUE_INDEX__ += 1;
  32611. }
  32612. return window.__BRAFT_MM_UNIQUE_INDEX__;
  32613. });
  32614. /***/
  32615. },
  32616. /* 2 */
  32617. /***/ function(module, exports) {
  32618. module.exports = __WEBPACK_EXTERNAL_MODULE__2__;
  32619. /***/
  32620. },
  32621. /* 3 */
  32622. /***/ function(module, exports, __webpack_require__) {
  32623. Object.defineProperty(exports, "__esModule", {
  32624. value: true
  32625. });
  32626. exports.default = {
  32627. remove: "Kaldır",
  32628. cancel: "İptal",
  32629. confirm: "Onayla",
  32630. insert: "Seçilenleri ekle",
  32631. width: "Genişlik",
  32632. height: "Yükseklik",
  32633. image: "Resim",
  32634. video: "Görüntü",
  32635. audio: "Ses",
  32636. embed: "Nesne göm",
  32637. caption: "Kitaplık",
  32638. dragTip: "Tıkla ya da dosya sürükle",
  32639. dropTip: "Yüklemek için sürükleyin",
  32640. selectAll: "Tümünü seç",
  32641. deselect: "Seçimi kaldır",
  32642. removeSelected: "Seçilenleri kaldır",
  32643. externalInputPlaceHolder: "Kaynak adı|Kaynak bağlantısı",
  32644. externalInputTip:
  32645. 'Kaynak asını ve bağlantısını "|" ile ayırın ve Enter\' a basın.',
  32646. addLocalFile: "Yerel' den ekle",
  32647. addExternalSource: "Harici kaynaktan ekle",
  32648. unnamedItem: "Adlandırılmamış giriş",
  32649. confirmInsert: "Seçilenleri ekle"
  32650. };
  32651. /***/
  32652. },
  32653. /* 4 */
  32654. /***/ function(module, exports, __webpack_require__) {
  32655. Object.defineProperty(exports, "__esModule", {
  32656. value: true
  32657. });
  32658. exports.default = {
  32659. remove: "削除する",
  32660. cancel: "キャンセル",
  32661. confirm: "確認する",
  32662. insert: "選択したアイテムを挿入",
  32663. width: "幅",
  32664. height: "身長",
  32665. image: "絵",
  32666. video: "ビデオ",
  32667. audio: "音声",
  32668. embed: "埋め込みメディア",
  32669. caption: "メディアライブラリー",
  32670. dragTip: "ファイルをこの位置までクリックまたはドラッグします",
  32671. dropTip: "アップロードするマウスを放します",
  32672. selectAll: "すべて選択",
  32673. deselect: "選択を解除",
  32674. removeSelected: "選択したアイテムを削除",
  32675. externalInputPlaceHolder: "リソース名|リソースアドレス",
  32676. externalInputTip:
  32677. 'リソース名とリソースアドレスは "|"で区切ります。',
  32678. addLocalFile: "ローカルリソースを追加する",
  32679. addExternalSource: "ネットワークリソースを追加する",
  32680. unnamedItem: "名前のないアイテム",
  32681. confirmInsert: "選択したアイテムを挿入"
  32682. };
  32683. /***/
  32684. },
  32685. /* 5 */
  32686. /***/ function(module, exports, __webpack_require__) {
  32687. Object.defineProperty(exports, "__esModule", {
  32688. value: true
  32689. });
  32690. exports.default = {
  32691. remove: "삭제",
  32692. cancel: "취소",
  32693. confirm: "확인",
  32694. insert: "선택한항목삽입",
  32695. width: "너비",
  32696. height: "높이",
  32697. image: "그림",
  32698. video: "비디오",
  32699. audio: "오디오",
  32700. embed: "임베디드미디어",
  32701. caption: "미디어라이브러리",
  32702. dragTip: "파일을 클릭하거나이 지점으로 드래그하십시오.",
  32703. dropTip: "업로드하려면마우스를놓으십시오.",
  32704. selectAll: "모두 선택",
  32705. deselect: "선택 취소",
  32706. removeSelected: "선택한 항목 삭제",
  32707. externalInputPlaceHolder: "리소스 이름 | 리소스 주소",
  32708. externalInputTip: '자원 이름과 자원 주소를 "|"',
  32709. addLocalFile: "로컬 리소스 추가",
  32710. addExternalSource: "네트워크 리소스 추가",
  32711. unnamedItem: "이름없는 항목",
  32712. confirmInsert: "선택한 항목 삽입"
  32713. };
  32714. /***/
  32715. },
  32716. /* 6 */
  32717. /***/ function(module, exports, __webpack_require__) {
  32718. Object.defineProperty(exports, "__esModule", {
  32719. value: true
  32720. });
  32721. exports.default = {
  32722. remove: "Usuń",
  32723. cancel: "Anuluj",
  32724. confirm: "Potwierdź",
  32725. insert: "Wstaw wybrane elementy",
  32726. width: "Szerokość",
  32727. height: "Wysokość",
  32728. image: "Obraz",
  32729. video: "Wideo",
  32730. audio: "Dźwięk",
  32731. embed: "Obiekt",
  32732. caption: "Biblioteka mediów",
  32733. dragTip: "Kliknij lub przenieś tu pliki",
  32734. dropTip: "Upuść aby dodać plik",
  32735. selectAll: "Zaznacz wszystko",
  32736. deselect: "Odznacz",
  32737. removeSelected: "Usuń wybrane",
  32738. externalInputPlaceHolder: "Nazwa źródła|Adres URL",
  32739. externalInputTip:
  32740. 'Oddziel nazwę i adres URL źródła z pomocą "|", Potwierdź Enter-em',
  32741. addLocalFile: "Dodaj z komputera",
  32742. addExternalSource: "Dodaj z Internetu",
  32743. unnamedItem: "Bez nazwy",
  32744. confirmInsert: "Dodaj wybrane elementy"
  32745. };
  32746. /***/
  32747. },
  32748. /* 7 */
  32749. /***/ function(module, exports, __webpack_require__) {
  32750. Object.defineProperty(exports, "__esModule", {
  32751. value: true
  32752. });
  32753. exports.default = {
  32754. remove: "删除",
  32755. cancel: "取消",
  32756. confirm: "确认",
  32757. insert: "插入所选项目",
  32758. width: "宽度",
  32759. height: "高度",
  32760. image: "图片",
  32761. video: "视频",
  32762. audio: "音频",
  32763. embed: "嵌入式媒体",
  32764. caption: "媒体库",
  32765. dragTip: "点击或拖动文件至此",
  32766. dropTip: "放开鼠标以上传",
  32767. selectAll: "选择全部",
  32768. deselect: "取消选择",
  32769. removeSelected: "删除选中项目",
  32770. externalInputPlaceHolder: "资源名称|资源地址",
  32771. externalInputTip: "使用“|”分隔资源名称和资源地址",
  32772. addLocalFile: "添加本地资源",
  32773. addExternalSource: "添加网络资源",
  32774. unnamedItem: "未命名项目",
  32775. confirmInsert: "插入选中项目"
  32776. };
  32777. /***/
  32778. },
  32779. /* 8 */
  32780. /***/ function(module, exports, __webpack_require__) {
  32781. Object.defineProperty(exports, "__esModule", {
  32782. value: true
  32783. });
  32784. exports.default = {
  32785. remove: "删除",
  32786. cancel: "取消",
  32787. confirm: "确认",
  32788. insert: "插入所选项目",
  32789. width: "宽度",
  32790. height: "高度",
  32791. image: "图片",
  32792. video: "视频",
  32793. audio: "音频",
  32794. embed: "嵌入式媒体",
  32795. caption: "媒体库",
  32796. dragTip: "点击或拖动文件至此",
  32797. dropTip: "放开鼠标以上传",
  32798. selectAll: "选择全部",
  32799. deselect: "取消选择",
  32800. removeSelected: "删除选中项目",
  32801. externalInputPlaceHolder: "资源名称|资源地址",
  32802. externalInputTip: "使用“|”分隔资源名称和资源地址",
  32803. addLocalFile: "添加本地资源",
  32804. addExternalSource: "添加网络资源",
  32805. unnamedItem: "未命名项目",
  32806. confirmInsert: "插入选中项目"
  32807. };
  32808. /***/
  32809. },
  32810. /* 9 */
  32811. /***/ function(module, exports, __webpack_require__) {
  32812. Object.defineProperty(exports, "__esModule", {
  32813. value: true
  32814. });
  32815. exports.default = {
  32816. remove: "Remove",
  32817. cancel: "Cancel",
  32818. confirm: "Confirm",
  32819. insert: "Insert Selected Items",
  32820. width: "Width",
  32821. height: "Height",
  32822. image: "Image",
  32823. video: "Video",
  32824. audio: "Audio",
  32825. embed: "Embed",
  32826. caption: "Media Library",
  32827. dragTip: "Click Or Drag Files Here",
  32828. dropTip: "Drop To Upload",
  32829. selectAll: "Select All",
  32830. deselect: "Deselect",
  32831. removeSelected: "Remove Selected Items",
  32832. externalInputPlaceHolder: "Source Name|Source URL",
  32833. externalInputTip:
  32834. 'Split source name and source URL with "|", confirm by hit Enter.',
  32835. addLocalFile: "Add from local",
  32836. addExternalSource: "Add from Internet",
  32837. unnamedItem: "Unnamed Item",
  32838. confirmInsert: "Insert selected items"
  32839. };
  32840. /***/
  32841. },
  32842. /* 10 */
  32843. /***/ function(module, exports, __webpack_require__) {
  32844. Object.defineProperty(exports, "__esModule", {
  32845. value: true
  32846. });
  32847. var _en = __webpack_require__(9);
  32848. var _en2 = _interopRequireDefault(_en);
  32849. var _zh = __webpack_require__(8);
  32850. var _zh2 = _interopRequireDefault(_zh);
  32851. var _zhHant = __webpack_require__(7);
  32852. var _zhHant2 = _interopRequireDefault(_zhHant);
  32853. var _pl = __webpack_require__(6);
  32854. var _pl2 = _interopRequireDefault(_pl);
  32855. var _kr = __webpack_require__(5);
  32856. var _kr2 = _interopRequireDefault(_kr);
  32857. var _jpn = __webpack_require__(4);
  32858. var _jpn2 = _interopRequireDefault(_jpn);
  32859. var _tr = __webpack_require__(3);
  32860. var _tr2 = _interopRequireDefault(_tr);
  32861. function _interopRequireDefault(obj) {
  32862. return obj && obj.__esModule ? obj : { default: obj };
  32863. }
  32864. exports.default = {
  32865. en: _en2.default,
  32866. zh: _zh2.default,
  32867. "zh-hant": _zhHant2.default,
  32868. pl: _pl2.default,
  32869. kr: _kr2.default,
  32870. jpn: _jpn2.default,
  32871. tr: _tr2.default
  32872. };
  32873. /***/
  32874. },
  32875. /* 11 */
  32876. /***/ function(module, exports) {
  32877. /**
  32878. * When source maps are enabled, `style-loader` uses a link element with a data-uri to
  32879. * embed the css on the page. This breaks all relative urls because now they are relative to a
  32880. * bundle instead of the current page.
  32881. *
  32882. * One solution is to only use full urls, but that may be impossible.
  32883. *
  32884. * Instead, this function "fixes" the relative urls to be absolute according to the current page location.
  32885. *
  32886. * A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command.
  32887. *
  32888. */
  32889. module.exports = function(css) {
  32890. // get current location
  32891. var location = typeof window !== "undefined" && window.location;
  32892. if (!location) {
  32893. throw new Error("fixUrls requires window.location");
  32894. }
  32895. // blank or null?
  32896. if (!css || typeof css !== "string") {
  32897. return css;
  32898. }
  32899. var baseUrl = location.protocol + "//" + location.host;
  32900. var currentDir =
  32901. baseUrl + location.pathname.replace(/\/[^\/]*$/, "/");
  32902. // convert each url(...)
  32903. /*
  32904. This regular expression is just a way to recursively match brackets within
  32905. a string.
  32906. /url\s*\( = Match on the word "url" with any whitespace after it and then a parens
  32907. ( = Start a capturing group
  32908. (?: = Start a non-capturing group
  32909. [^)(] = Match anything that isn't a parentheses
  32910. | = OR
  32911. \( = Match a start parentheses
  32912. (?: = Start another non-capturing groups
  32913. [^)(]+ = Match anything that isn't a parentheses
  32914. | = OR
  32915. \( = Match a start parentheses
  32916. [^)(]* = Match anything that isn't a parentheses
  32917. \) = Match a end parentheses
  32918. ) = End Group
  32919. *\) = Match anything and then a close parens
  32920. ) = Close non-capturing group
  32921. * = Match anything
  32922. ) = Close capturing group
  32923. \) = Match a close parens
  32924. /gi = Get all matches, not the first. Be case insensitive.
  32925. */
  32926. var fixedCss = css.replace(
  32927. /url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,
  32928. function(fullMatch, origUrl) {
  32929. // strip quotes (if they exist)
  32930. var unquotedOrigUrl = origUrl
  32931. .trim()
  32932. .replace(/^"(.*)"$/, function(o, $1) {
  32933. return $1;
  32934. })
  32935. .replace(/^'(.*)'$/, function(o, $1) {
  32936. return $1;
  32937. });
  32938. // already a full url? no change
  32939. if (
  32940. /^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(
  32941. unquotedOrigUrl
  32942. )
  32943. ) {
  32944. return fullMatch;
  32945. }
  32946. // convert the url to a full url
  32947. var newUrl;
  32948. if (unquotedOrigUrl.indexOf("//") === 0) {
  32949. //TODO: should we add protocol?
  32950. newUrl = unquotedOrigUrl;
  32951. } else if (unquotedOrigUrl.indexOf("/") === 0) {
  32952. // path should be relative to the base url
  32953. newUrl = baseUrl + unquotedOrigUrl; // already starts with '/'
  32954. } else {
  32955. // path should be relative to current directory
  32956. newUrl = currentDir + unquotedOrigUrl.replace(/^\.\//, ""); // Strip leading './'
  32957. }
  32958. // send back the fixed url(...)
  32959. return "url(" + JSON.stringify(newUrl) + ")";
  32960. }
  32961. );
  32962. // send back the fixed css
  32963. return fixedCss;
  32964. };
  32965. /***/
  32966. },
  32967. /* 12 */
  32968. /***/ function(module, exports, __webpack_require__) {
  32969. /*
  32970. MIT License http://www.opensource.org/licenses/mit-license.php
  32971. Author Tobias Koppers @sokra
  32972. */
  32973. var stylesInDom = {};
  32974. var memoize = function(fn) {
  32975. var memo;
  32976. return function() {
  32977. if (typeof memo === "undefined") memo = fn.apply(this, arguments);
  32978. return memo;
  32979. };
  32980. };
  32981. var isOldIE = memoize(function() {
  32982. // Test for IE <= 9 as proposed by Browserhacks
  32983. // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
  32984. // Tests for existence of standard globals is to allow style-loader
  32985. // to operate correctly into non-standard environments
  32986. // @see https://github.com/webpack-contrib/style-loader/issues/177
  32987. return window && document && document.all && !window.atob;
  32988. });
  32989. var getTarget = function(target) {
  32990. return document.querySelector(target);
  32991. };
  32992. var getElement = (function(fn) {
  32993. var memo = {};
  32994. return function(target) {
  32995. // If passing function in options, then use it for resolve "head" element.
  32996. // Useful for Shadow Root style i.e
  32997. // {
  32998. // insertInto: function () { return document.querySelector("#foo").shadowRoot }
  32999. // }
  33000. if (typeof target === "function") {
  33001. return target();
  33002. }
  33003. if (typeof memo[target] === "undefined") {
  33004. var styleTarget = getTarget.call(this, target);
  33005. // Special case to return head of iframe instead of iframe itself
  33006. if (
  33007. window.HTMLIFrameElement &&
  33008. styleTarget instanceof window.HTMLIFrameElement
  33009. ) {
  33010. try {
  33011. // This will throw an exception if access to iframe is blocked
  33012. // due to cross-origin restrictions
  33013. styleTarget = styleTarget.contentDocument.head;
  33014. } catch (e) {
  33015. styleTarget = null;
  33016. }
  33017. }
  33018. memo[target] = styleTarget;
  33019. }
  33020. return memo[target];
  33021. };
  33022. })();
  33023. var singleton = null;
  33024. var singletonCounter = 0;
  33025. var stylesInsertedAtTop = [];
  33026. var fixUrls = __webpack_require__(11);
  33027. module.exports = function(list, options) {
  33028. if (typeof DEBUG !== "undefined" && DEBUG) {
  33029. if (typeof document !== "object")
  33030. throw new Error(
  33031. "The style-loader cannot be used in a non-browser environment"
  33032. );
  33033. }
  33034. options = options || {};
  33035. options.attrs =
  33036. typeof options.attrs === "object" ? options.attrs : {};
  33037. // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
  33038. // tags it will allow on a page
  33039. if (!options.singleton && typeof options.singleton !== "boolean")
  33040. options.singleton = isOldIE();
  33041. // By default, add <style> tags to the <head> element
  33042. if (!options.insertInto) options.insertInto = "head";
  33043. // By default, add <style> tags to the bottom of the target
  33044. if (!options.insertAt) options.insertAt = "bottom";
  33045. var styles = listToStyles(list, options);
  33046. addStylesToDom(styles, options);
  33047. return function update(newList) {
  33048. var mayRemove = [];
  33049. for (var i = 0; i < styles.length; i++) {
  33050. var item = styles[i];
  33051. var domStyle = stylesInDom[item.id];
  33052. domStyle.refs--;
  33053. mayRemove.push(domStyle);
  33054. }
  33055. if (newList) {
  33056. var newStyles = listToStyles(newList, options);
  33057. addStylesToDom(newStyles, options);
  33058. }
  33059. for (var i = 0; i < mayRemove.length; i++) {
  33060. var domStyle = mayRemove[i];
  33061. if (domStyle.refs === 0) {
  33062. for (var j = 0; j < domStyle.parts.length; j++)
  33063. domStyle.parts[j]();
  33064. delete stylesInDom[domStyle.id];
  33065. }
  33066. }
  33067. };
  33068. };
  33069. function addStylesToDom(styles, options) {
  33070. for (var i = 0; i < styles.length; i++) {
  33071. var item = styles[i];
  33072. var domStyle = stylesInDom[item.id];
  33073. if (domStyle) {
  33074. domStyle.refs++;
  33075. for (var j = 0; j < domStyle.parts.length; j++) {
  33076. domStyle.parts[j](item.parts[j]);
  33077. }
  33078. for (; j < item.parts.length; j++) {
  33079. domStyle.parts.push(addStyle(item.parts[j], options));
  33080. }
  33081. } else {
  33082. var parts = [];
  33083. for (var j = 0; j < item.parts.length; j++) {
  33084. parts.push(addStyle(item.parts[j], options));
  33085. }
  33086. stylesInDom[item.id] = { id: item.id, refs: 1, parts: parts };
  33087. }
  33088. }
  33089. }
  33090. function listToStyles(list, options) {
  33091. var styles = [];
  33092. var newStyles = {};
  33093. for (var i = 0; i < list.length; i++) {
  33094. var item = list[i];
  33095. var id = options.base ? item[0] + options.base : item[0];
  33096. var css = item[1];
  33097. var media = item[2];
  33098. var sourceMap = item[3];
  33099. var part = { css: css, media: media, sourceMap: sourceMap };
  33100. if (!newStyles[id])
  33101. styles.push((newStyles[id] = { id: id, parts: [part] }));
  33102. else newStyles[id].parts.push(part);
  33103. }
  33104. return styles;
  33105. }
  33106. function insertStyleElement(options, style) {
  33107. var target = getElement(options.insertInto);
  33108. if (!target) {
  33109. throw new Error(
  33110. "Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid."
  33111. );
  33112. }
  33113. var lastStyleElementInsertedAtTop =
  33114. stylesInsertedAtTop[stylesInsertedAtTop.length - 1];
  33115. if (options.insertAt === "top") {
  33116. if (!lastStyleElementInsertedAtTop) {
  33117. target.insertBefore(style, target.firstChild);
  33118. } else if (lastStyleElementInsertedAtTop.nextSibling) {
  33119. target.insertBefore(
  33120. style,
  33121. lastStyleElementInsertedAtTop.nextSibling
  33122. );
  33123. } else {
  33124. target.appendChild(style);
  33125. }
  33126. stylesInsertedAtTop.push(style);
  33127. } else if (options.insertAt === "bottom") {
  33128. target.appendChild(style);
  33129. } else if (
  33130. typeof options.insertAt === "object" &&
  33131. options.insertAt.before
  33132. ) {
  33133. var nextSibling = getElement(
  33134. options.insertInto + " " + options.insertAt.before
  33135. );
  33136. target.insertBefore(style, nextSibling);
  33137. } else {
  33138. throw new Error(
  33139. "[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"
  33140. );
  33141. }
  33142. }
  33143. function removeStyleElement(style) {
  33144. if (style.parentNode === null) return false;
  33145. style.parentNode.removeChild(style);
  33146. var idx = stylesInsertedAtTop.indexOf(style);
  33147. if (idx >= 0) {
  33148. stylesInsertedAtTop.splice(idx, 1);
  33149. }
  33150. }
  33151. function createStyleElement(options) {
  33152. var style = document.createElement("style");
  33153. if (options.attrs.type === undefined) {
  33154. options.attrs.type = "text/css";
  33155. }
  33156. addAttrs(style, options.attrs);
  33157. insertStyleElement(options, style);
  33158. return style;
  33159. }
  33160. function createLinkElement(options) {
  33161. var link = document.createElement("link");
  33162. if (options.attrs.type === undefined) {
  33163. options.attrs.type = "text/css";
  33164. }
  33165. options.attrs.rel = "stylesheet";
  33166. addAttrs(link, options.attrs);
  33167. insertStyleElement(options, link);
  33168. return link;
  33169. }
  33170. function addAttrs(el, attrs) {
  33171. Object.keys(attrs).forEach(function(key) {
  33172. el.setAttribute(key, attrs[key]);
  33173. });
  33174. }
  33175. function addStyle(obj, options) {
  33176. var style, update, remove, result;
  33177. // If a transform function was defined, run it on the css
  33178. if (options.transform && obj.css) {
  33179. result = options.transform(obj.css);
  33180. if (result) {
  33181. // If transform returns a value, use that instead of the original css.
  33182. // This allows running runtime transformations on the css.
  33183. obj.css = result;
  33184. } else {
  33185. // If the transform function returns a falsy value, don't add this css.
  33186. // This allows conditional loading of css
  33187. return function() {
  33188. // noop
  33189. };
  33190. }
  33191. }
  33192. if (options.singleton) {
  33193. var styleIndex = singletonCounter++;
  33194. style = singleton || (singleton = createStyleElement(options));
  33195. update = applyToSingletonTag.bind(null, style, styleIndex, false);
  33196. remove = applyToSingletonTag.bind(null, style, styleIndex, true);
  33197. } else if (
  33198. obj.sourceMap &&
  33199. typeof URL === "function" &&
  33200. typeof URL.createObjectURL === "function" &&
  33201. typeof URL.revokeObjectURL === "function" &&
  33202. typeof Blob === "function" &&
  33203. typeof btoa === "function"
  33204. ) {
  33205. style = createLinkElement(options);
  33206. update = updateLink.bind(null, style, options);
  33207. remove = function() {
  33208. removeStyleElement(style);
  33209. if (style.href) URL.revokeObjectURL(style.href);
  33210. };
  33211. } else {
  33212. style = createStyleElement(options);
  33213. update = applyToTag.bind(null, style);
  33214. remove = function() {
  33215. removeStyleElement(style);
  33216. };
  33217. }
  33218. update(obj);
  33219. return function updateStyle(newObj) {
  33220. if (newObj) {
  33221. if (
  33222. newObj.css === obj.css &&
  33223. newObj.media === obj.media &&
  33224. newObj.sourceMap === obj.sourceMap
  33225. ) {
  33226. return;
  33227. }
  33228. update((obj = newObj));
  33229. } else {
  33230. remove();
  33231. }
  33232. };
  33233. }
  33234. var replaceText = (function() {
  33235. var textStore = [];
  33236. return function(index, replacement) {
  33237. textStore[index] = replacement;
  33238. return textStore.filter(Boolean).join("\n");
  33239. };
  33240. })();
  33241. function applyToSingletonTag(style, index, remove, obj) {
  33242. var css = remove ? "" : obj.css;
  33243. if (style.styleSheet) {
  33244. style.styleSheet.cssText = replaceText(index, css);
  33245. } else {
  33246. var cssNode = document.createTextNode(css);
  33247. var childNodes = style.childNodes;
  33248. if (childNodes[index]) style.removeChild(childNodes[index]);
  33249. if (childNodes.length) {
  33250. style.insertBefore(cssNode, childNodes[index]);
  33251. } else {
  33252. style.appendChild(cssNode);
  33253. }
  33254. }
  33255. }
  33256. function applyToTag(style, obj) {
  33257. var css = obj.css;
  33258. var media = obj.media;
  33259. if (media) {
  33260. style.setAttribute("media", media);
  33261. }
  33262. if (style.styleSheet) {
  33263. style.styleSheet.cssText = css;
  33264. } else {
  33265. while (style.firstChild) {
  33266. style.removeChild(style.firstChild);
  33267. }
  33268. style.appendChild(document.createTextNode(css));
  33269. }
  33270. }
  33271. function updateLink(link, options, obj) {
  33272. var css = obj.css;
  33273. var sourceMap = obj.sourceMap;
  33274. /*
  33275. If convertToAbsoluteUrls isn't defined, but sourcemaps are enabled
  33276. and there is no publicPath defined then lets turn convertToAbsoluteUrls
  33277. on by default. Otherwise default to the convertToAbsoluteUrls option
  33278. directly
  33279. */
  33280. var autoFixUrls =
  33281. options.convertToAbsoluteUrls === undefined && sourceMap;
  33282. if (options.convertToAbsoluteUrls || autoFixUrls) {
  33283. css = fixUrls(css);
  33284. }
  33285. if (sourceMap) {
  33286. // http://stackoverflow.com/a/26603875
  33287. css +=
  33288. "\n/*# sourceMappingURL=data:application/json;base64," +
  33289. btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) +
  33290. " */";
  33291. }
  33292. var blob = new Blob([css], { type: "text/css" });
  33293. var oldSrc = link.href;
  33294. link.href = URL.createObjectURL(blob);
  33295. if (oldSrc) URL.revokeObjectURL(oldSrc);
  33296. }
  33297. /***/
  33298. },
  33299. /* 13 */
  33300. /***/ function(module, exports) {
  33301. module.exports =
  33302. "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=";
  33303. /***/
  33304. },
  33305. /* 14 */
  33306. /***/ function(module, exports) {
  33307. /*
  33308. MIT License http://www.opensource.org/licenses/mit-license.php
  33309. Author Tobias Koppers @sokra
  33310. */
  33311. // css base code, injected by the css-loader
  33312. module.exports = function(useSourceMap) {
  33313. var list = [];
  33314. // return the list of modules as css string
  33315. list.toString = function toString() {
  33316. return this.map(function(item) {
  33317. var content = cssWithMappingToString(item, useSourceMap);
  33318. if (item[2]) {
  33319. return "@media " + item[2] + "{" + content + "}";
  33320. } else {
  33321. return content;
  33322. }
  33323. }).join("");
  33324. };
  33325. // import a list of modules into the list
  33326. list.i = function(modules, mediaQuery) {
  33327. if (typeof modules === "string") modules = [[null, modules, ""]];
  33328. var alreadyImportedModules = {};
  33329. for (var i = 0; i < this.length; i++) {
  33330. var id = this[i][0];
  33331. if (typeof id === "number") alreadyImportedModules[id] = true;
  33332. }
  33333. for (i = 0; i < modules.length; i++) {
  33334. var item = modules[i];
  33335. // skip already imported module
  33336. // this implementation is not 100% perfect for weird media query combinations
  33337. // when a module is imported multiple times with different media queries.
  33338. // I hope this will never occur (Hey this way we have smaller bundles)
  33339. if (
  33340. typeof item[0] !== "number" ||
  33341. !alreadyImportedModules[item[0]]
  33342. ) {
  33343. if (mediaQuery && !item[2]) {
  33344. item[2] = mediaQuery;
  33345. } else if (mediaQuery) {
  33346. item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
  33347. }
  33348. list.push(item);
  33349. }
  33350. }
  33351. };
  33352. return list;
  33353. };
  33354. function cssWithMappingToString(item, useSourceMap) {
  33355. var content = item[1] || "";
  33356. var cssMapping = item[3];
  33357. if (!cssMapping) {
  33358. return content;
  33359. }
  33360. if (useSourceMap && typeof btoa === "function") {
  33361. var sourceMapping = toComment(cssMapping);
  33362. var sourceURLs = cssMapping.sources.map(function(source) {
  33363. return (
  33364. "/*# sourceURL=" + cssMapping.sourceRoot + source + " */"
  33365. );
  33366. });
  33367. return [content]
  33368. .concat(sourceURLs)
  33369. .concat([sourceMapping])
  33370. .join("\n");
  33371. }
  33372. return [content].join("\n");
  33373. }
  33374. // Adapted from convert-source-map (MIT)
  33375. function toComment(sourceMap) {
  33376. // eslint-disable-next-line no-undef
  33377. var base64 = btoa(
  33378. unescape(encodeURIComponent(JSON.stringify(sourceMap)))
  33379. );
  33380. var data =
  33381. "sourceMappingURL=data:application/json;charset=utf-8;base64," +
  33382. base64;
  33383. return "/*# " + data + " */";
  33384. }
  33385. /***/
  33386. },
  33387. /* 15 */
  33388. /***/ function(module, exports) {
  33389. module.exports = function escape(url) {
  33390. if (typeof url !== "string") {
  33391. return url;
  33392. }
  33393. // If url is already wrapped in quotes, remove them
  33394. if (/^['"].*['"]$/.test(url)) {
  33395. url = url.slice(1, -1);
  33396. }
  33397. // Should url be wrapped?
  33398. // See https://drafts.csswg.org/css-values-3/#urls
  33399. if (/["'() \t\n]/.test(url)) {
  33400. return '"' + url.replace(/"/g, '\\"').replace(/\n/g, "\\n") + '"';
  33401. }
  33402. return url;
  33403. };
  33404. /***/
  33405. },
  33406. /* 16 */
  33407. /***/ function(module, exports, __webpack_require__) {
  33408. var escape = __webpack_require__(15);
  33409. exports = module.exports = __webpack_require__(14)(false);
  33410. // imports
  33411. // module
  33412. exports.push([
  33413. module.i,
  33414. "@font-face {\n font-family: 'bf-icons';\n src: url(" +
  33415. escape(__webpack_require__(13)) +
  33416. ') 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',
  33417. ""
  33418. ]);
  33419. // exports
  33420. /***/
  33421. },
  33422. /* 17 */
  33423. /***/ function(module, exports, __webpack_require__) {
  33424. var content = __webpack_require__(16);
  33425. if (typeof content === "string") content = [[module.i, content, ""]];
  33426. var transform;
  33427. var options = { hmr: true };
  33428. options.transform = transform;
  33429. options.insertInto = undefined;
  33430. var update = __webpack_require__(12)(content, options);
  33431. if (content.locals) module.exports = content.locals;
  33432. /***/
  33433. },
  33434. /* 18 */
  33435. /***/ function(module, exports, __webpack_require__) {
  33436. Object.defineProperty(exports, "__esModule", {
  33437. value: true
  33438. });
  33439. var _extends =
  33440. Object.assign ||
  33441. function(target) {
  33442. for (var i = 1; i < arguments.length; i++) {
  33443. var source = arguments[i];
  33444. for (var key in source) {
  33445. if (Object.prototype.hasOwnProperty.call(source, key)) {
  33446. target[key] = source[key];
  33447. }
  33448. }
  33449. }
  33450. return target;
  33451. };
  33452. var _createClass = (function() {
  33453. function defineProperties(target, props) {
  33454. for (var i = 0; i < props.length; i++) {
  33455. var descriptor = props[i];
  33456. descriptor.enumerable = descriptor.enumerable || false;
  33457. descriptor.configurable = true;
  33458. if ("value" in descriptor) descriptor.writable = true;
  33459. Object.defineProperty(target, descriptor.key, descriptor);
  33460. }
  33461. }
  33462. return function(Constructor, protoProps, staticProps) {
  33463. if (protoProps)
  33464. defineProperties(Constructor.prototype, protoProps);
  33465. if (staticProps) defineProperties(Constructor, staticProps);
  33466. return Constructor;
  33467. };
  33468. })();
  33469. __webpack_require__(17);
  33470. var _react = __webpack_require__(2);
  33471. var _react2 = _interopRequireDefault(_react);
  33472. var _base = __webpack_require__(1);
  33473. function _interopRequireDefault(obj) {
  33474. return obj && obj.__esModule ? obj : { default: obj };
  33475. }
  33476. function _classCallCheck(instance, Constructor) {
  33477. if (!(instance instanceof Constructor)) {
  33478. throw new TypeError("Cannot call a class as a function");
  33479. }
  33480. }
  33481. function _possibleConstructorReturn(self, call) {
  33482. if (!self) {
  33483. throw new ReferenceError(
  33484. "this hasn't been initialised - super() hasn't been called"
  33485. );
  33486. }
  33487. return call &&
  33488. (typeof call === "object" || typeof call === "function")
  33489. ? call
  33490. : self;
  33491. }
  33492. function _inherits(subClass, superClass) {
  33493. if (typeof superClass !== "function" && superClass !== null) {
  33494. throw new TypeError(
  33495. "Super expression must either be null or a function, not " +
  33496. typeof superClass
  33497. );
  33498. }
  33499. subClass.prototype = Object.create(
  33500. superClass && superClass.prototype,
  33501. {
  33502. constructor: {
  33503. value: subClass,
  33504. enumerable: false,
  33505. writable: true,
  33506. configurable: true
  33507. }
  33508. }
  33509. );
  33510. if (superClass)
  33511. Object.setPrototypeOf
  33512. ? Object.setPrototypeOf(subClass, superClass)
  33513. : (subClass.__proto__ = superClass);
  33514. }
  33515. var defaultAccepts = {
  33516. image:
  33517. "image/png,image/jpeg,image/gif,image/webp,image/apng,image/svg",
  33518. video: "video/mp4",
  33519. audio: "audio/mp3"
  33520. };
  33521. var BraftFinderView = (function(_React$Component) {
  33522. _inherits(BraftFinderView, _React$Component);
  33523. function BraftFinderView(props) {
  33524. _classCallCheck(this, BraftFinderView);
  33525. var _this = _possibleConstructorReturn(
  33526. this,
  33527. (
  33528. BraftFinderView.__proto__ ||
  33529. Object.getPrototypeOf(BraftFinderView)
  33530. ).call(this, props)
  33531. );
  33532. _this.toggleSelectItem = function(event) {
  33533. var itemId = event.currentTarget.dataset.id;
  33534. var item = _this.controller.getMediaItem(itemId);
  33535. if (!item) {
  33536. return false;
  33537. }
  33538. if (item.selected) {
  33539. if (
  33540. !_this.props.onBeforeDeselect ||
  33541. _this.props.onBeforeDeselect(
  33542. [item],
  33543. _this.controller.getItems()
  33544. ) !== false
  33545. ) {
  33546. _this.controller.deselectMediaItem(itemId);
  33547. _this.props.onDeselect &&
  33548. _this.props.onDeselect(
  33549. [item],
  33550. _this.controller.getItems()
  33551. );
  33552. }
  33553. } else {
  33554. if (
  33555. !_this.props.onBeforeSelect ||
  33556. _this.props.onBeforeSelect(
  33557. [item],
  33558. _this.controller.getItems()
  33559. ) !== false
  33560. ) {
  33561. _this.controller.selectMediaItem(itemId);
  33562. _this.props.onSelect &&
  33563. _this.props.onSelect([item], _this.controller.getItems());
  33564. }
  33565. }
  33566. };
  33567. _this.removeItem = function(event) {
  33568. var itemId = event.currentTarget.dataset.id;
  33569. var item = _this.controller.getMediaItem(itemId);
  33570. if (!item) {
  33571. return false;
  33572. }
  33573. if (
  33574. !_this.props.onBeforeRemove ||
  33575. _this.props.onBeforeRemove(
  33576. [item],
  33577. _this.controller.getItems()
  33578. ) !== false
  33579. ) {
  33580. _this.controller.removeMediaItem(itemId);
  33581. _this.props.onRemove &&
  33582. _this.props.onRemove([item], _this.controller.getItems());
  33583. }
  33584. event.stopPropagation();
  33585. };
  33586. _this.selectAllItems = function() {
  33587. var allItems = _this.controller.getItems();
  33588. if (
  33589. !_this.props.onBeforeSelect ||
  33590. _this.props.onBeforeSelect(allItems, allItems) !== false
  33591. ) {
  33592. _this.controller.selectAllItems();
  33593. _this.props.onSelect &&
  33594. _this.props.onSelect(allItems, allItems);
  33595. }
  33596. };
  33597. _this.deselectAllItems = function() {
  33598. var allItems = _this.controller.getItems();
  33599. if (
  33600. !_this.props.onBeforeDeselect ||
  33601. _this.props.onBeforeDeselect(allItems, allItems) !== false
  33602. ) {
  33603. _this.controller.deselectAllItems();
  33604. _this.props.onDeselect &&
  33605. _this.props.onDeselect(allItems, allItems);
  33606. }
  33607. };
  33608. _this.removeSelectedItems = function() {
  33609. var selectedItems = _this.controller.getSelectedItems();
  33610. if (
  33611. !_this.props.onBeforeRemove ||
  33612. _this.props.onBeforeRemove(
  33613. selectedItems,
  33614. _this.controller.getItems()
  33615. ) !== false
  33616. ) {
  33617. _this.controller.removeSelectedItems();
  33618. _this.props.onRemove &&
  33619. _this.props.onRemove(
  33620. selectedItems,
  33621. _this.controller.getItems()
  33622. );
  33623. }
  33624. };
  33625. _this.handleDragLeave = function(event) {
  33626. event.preventDefault();
  33627. _this.dragCounter--;
  33628. _this.dragCounter === 0 &&
  33629. _this.setState({
  33630. draging: false
  33631. });
  33632. };
  33633. _this.handleDragDrop = function(event) {
  33634. event.preventDefault();
  33635. _this.dragCounter = 0;
  33636. _this.setState({ draging: false });
  33637. _this.reslovePickedFiles(event);
  33638. };
  33639. _this.handleDragEnter = function(event) {
  33640. event.preventDefault();
  33641. _this.dragCounter++;
  33642. _this.setState({ draging: true });
  33643. };
  33644. _this.reslovePickedFiles = function(event) {
  33645. event.persist();
  33646. var _ref =
  33647. event.type === "drop" ? event.dataTransfer : event.target,
  33648. files = _ref.files;
  33649. if (_this.props.onFileSelect) {
  33650. var result = _this.props.onFileSelect(files);
  33651. if (result === false) {
  33652. return false;
  33653. } else if (
  33654. result instanceof FileList ||
  33655. result instanceof Array
  33656. ) {
  33657. files = result;
  33658. }
  33659. }
  33660. var accepts = _extends({}, defaultAccepts, _this.props.accepts);
  33661. _this.controller.resolveFiles(
  33662. {
  33663. files: files,
  33664. onItemReady: function onItemReady(_ref2) {
  33665. var id = _ref2.id;
  33666. return _this.controller.selectMediaItem(id);
  33667. },
  33668. onAllReady: function onAllReady() {
  33669. return (event.target.value = null);
  33670. }
  33671. },
  33672. 0,
  33673. accepts
  33674. );
  33675. };
  33676. _this.inputExternal = function(event) {
  33677. _this.setState({
  33678. external: _extends({}, _this.state.external, {
  33679. url: event.target.value
  33680. })
  33681. });
  33682. };
  33683. _this.switchExternalType = function(event) {
  33684. _this.setState({
  33685. external: _extends({}, _this.state.external, {
  33686. type: event.target.dataset.type
  33687. })
  33688. });
  33689. };
  33690. _this.confirmAddExternal = function(event) {
  33691. if (
  33692. event.target.nodeName.toLowerCase() === "button" ||
  33693. event.keyCode === 13
  33694. ) {
  33695. var _this$state$external = _this.state.external,
  33696. url = _this$state$external.url,
  33697. type = _this$state$external.type;
  33698. url = url.split("|");
  33699. var name =
  33700. url.length > 1 ? url[0] : _this.props.language.unnamedItem;
  33701. url = url.length > 1 ? url[1] : url[0];
  33702. var thumbnail = type === "IMAGE" ? url : null;
  33703. _this.controller.addItems([
  33704. {
  33705. thumbnail: thumbnail,
  33706. url: url,
  33707. name: name,
  33708. type: type,
  33709. id: new Date().getTime() + "_" + (0, _base.UniqueIndex)(),
  33710. uploading: false,
  33711. uploadProgress: 1,
  33712. selected: true
  33713. }
  33714. ]);
  33715. _this.setState({
  33716. showExternalForm: false,
  33717. external: {
  33718. url: "",
  33719. type: "IMAGE"
  33720. }
  33721. });
  33722. }
  33723. };
  33724. _this.toggleExternalForm = function() {
  33725. _this.setState({
  33726. showExternalForm: !_this.state.showExternalForm
  33727. });
  33728. };
  33729. _this.cancelInsert = function() {
  33730. _this.props.onCancel && _this.props.onCancel();
  33731. };
  33732. _this.confirmInsert = function() {
  33733. var selectedItems = _this.controller.getSelectedItems();
  33734. if (_this.props.onBeforeInsert) {
  33735. var filteredItems = _this.props.onBeforeInsert(selectedItems);
  33736. if (filteredItems && filteredItems instanceof Array) {
  33737. _this.controller.deselectAllItems();
  33738. _this.props.onInsert && _this.props.onInsert(filteredItems);
  33739. } else if (filteredItems !== false) {
  33740. _this.controller.deselectAllItems();
  33741. _this.props.onInsert && _this.props.onInsert(selectedItems);
  33742. }
  33743. } else {
  33744. _this.controller.deselectAllItems();
  33745. _this.props.onInsert && _this.props.onInsert(selectedItems);
  33746. }
  33747. };
  33748. _this.dragCounter = 0;
  33749. _this.controller = _this.props.controller;
  33750. var initialItems = _this.controller.getItems();
  33751. _this.state = {
  33752. draging: false,
  33753. error: false,
  33754. confirmable: initialItems.find(function(_ref3) {
  33755. var selected = _ref3.selected;
  33756. return selected;
  33757. }),
  33758. external: {
  33759. url: "",
  33760. type: "IMAGE"
  33761. },
  33762. fileAccept: "",
  33763. showExternalForm: false,
  33764. allowExternal: false,
  33765. items: initialItems
  33766. };
  33767. _this.changeListenerId = _this.controller.onChange(function(
  33768. items
  33769. ) {
  33770. _this.setState({
  33771. items: items,
  33772. confirmable: items.find(function(_ref4) {
  33773. var selected = _ref4.selected;
  33774. return selected;
  33775. })
  33776. });
  33777. _this.props.onChange && _this.props.onChange(items);
  33778. });
  33779. return _this;
  33780. }
  33781. _createClass(BraftFinderView, [
  33782. {
  33783. key: "mapPropsToState",
  33784. value: function mapPropsToState(props) {
  33785. var accepts = props.accepts,
  33786. externals = props.externals;
  33787. accepts = _extends({}, defaultAccepts, accepts);
  33788. var fileAccept = !accepts
  33789. ? [
  33790. defaultAccepts.image,
  33791. defaultAccepts.video,
  33792. defaultAccepts.audio
  33793. ].join(",")
  33794. : [accepts.image, accepts.video, accepts.audio]
  33795. .filter(function(item) {
  33796. return item;
  33797. })
  33798. .join(",");
  33799. var external = {
  33800. url: "",
  33801. type: externals.image
  33802. ? "IMAGE"
  33803. : externals.audio
  33804. ? "AUDIO"
  33805. : externals.video
  33806. ? "VIDEO"
  33807. : externals.embed
  33808. ? "EMBED"
  33809. : ""
  33810. };
  33811. return {
  33812. fileAccept: fileAccept,
  33813. external: external,
  33814. allowExternal:
  33815. externals &&
  33816. (externals.image ||
  33817. externals.audio ||
  33818. externals.video ||
  33819. externals.embed)
  33820. };
  33821. }
  33822. },
  33823. {
  33824. key: "componentDidMount",
  33825. value: function componentDidMount() {
  33826. this.setState(this.mapPropsToState(this.props));
  33827. }
  33828. },
  33829. {
  33830. key: "componentWillReceiveProps",
  33831. value: function componentWillReceiveProps(nextProps) {
  33832. this.setState(this.mapPropsToState(nextProps));
  33833. }
  33834. },
  33835. {
  33836. key: "componentWillUnmount",
  33837. value: function componentWillUnmount() {
  33838. this.controller.offChange(this.changeListenerId);
  33839. }
  33840. },
  33841. {
  33842. key: "render",
  33843. value: function render() {
  33844. var _props = this.props,
  33845. language = _props.language,
  33846. externals = _props.externals;
  33847. var _state = this.state,
  33848. items = _state.items,
  33849. draging = _state.draging,
  33850. confirmable = _state.confirmable,
  33851. fileAccept = _state.fileAccept,
  33852. external = _state.external,
  33853. showExternalForm = _state.showExternalForm,
  33854. allowExternal = _state.allowExternal;
  33855. return _react2.default.createElement(
  33856. "div",
  33857. { className: "braft-finder" },
  33858. _react2.default.createElement(
  33859. "div",
  33860. {
  33861. onDragEnter: this.handleDragEnter,
  33862. onDragOver: this.handleDragEnter,
  33863. onDragLeave: this.handleDragLeave,
  33864. onDrop: this.handleDragDrop,
  33865. className: "bf-uploader"
  33866. },
  33867. _react2.default.createElement(
  33868. "div",
  33869. {
  33870. className:
  33871. "bf-drag-uploader " +
  33872. (draging || !items.length ? "active " : " ") +
  33873. (draging ? "draging" : "")
  33874. },
  33875. _react2.default.createElement(
  33876. "span",
  33877. { className: "bf-drag-tip" },
  33878. _react2.default.createElement("input", {
  33879. accept: fileAccept,
  33880. onChange: this.reslovePickedFiles,
  33881. multiple: true,
  33882. type: "file"
  33883. }),
  33884. draging ? language.dropTip : language.dragTip
  33885. )
  33886. ),
  33887. items.length
  33888. ? _react2.default.createElement(
  33889. "div",
  33890. { className: "bf-list-wrap" },
  33891. _react2.default.createElement(
  33892. "div",
  33893. { className: "bf-list-tools" },
  33894. _react2.default.createElement(
  33895. "span",
  33896. {
  33897. onClick: this.selectAllItems,
  33898. className: "bf-select-all"
  33899. },
  33900. _react2.default.createElement("i", {
  33901. className: "braft-icon-done"
  33902. }),
  33903. " ",
  33904. language.selectAll
  33905. ),
  33906. _react2.default.createElement(
  33907. "span",
  33908. {
  33909. onClick: this.deselectAllItems,
  33910. disabled: !confirmable,
  33911. className: "bf-deselect-all"
  33912. },
  33913. _react2.default.createElement("i", {
  33914. className: "braft-icon-close"
  33915. }),
  33916. " ",
  33917. language.deselect
  33918. ),
  33919. _react2.default.createElement(
  33920. "span",
  33921. {
  33922. onClick: this.removeSelectedItems,
  33923. disabled: !confirmable,
  33924. className: "bf-remove-selected"
  33925. },
  33926. _react2.default.createElement("i", {
  33927. className: "braft-icon-bin"
  33928. }),
  33929. " ",
  33930. language.removeSelected
  33931. )
  33932. ),
  33933. this.buildItemList()
  33934. )
  33935. : null,
  33936. showExternalForm && allowExternal
  33937. ? _react2.default.createElement(
  33938. "div",
  33939. { className: "bf-add-external" },
  33940. _react2.default.createElement(
  33941. "div",
  33942. { className: "bf-external-form" },
  33943. _react2.default.createElement(
  33944. "div",
  33945. { className: "bf-external-input" },
  33946. _react2.default.createElement(
  33947. "div",
  33948. null,
  33949. _react2.default.createElement("input", {
  33950. onKeyDown: this.confirmAddExternal,
  33951. value: external.url,
  33952. onChange: this.inputExternal,
  33953. placeholder:
  33954. language.externalInputPlaceHolder
  33955. })
  33956. ),
  33957. _react2.default.createElement(
  33958. "button",
  33959. {
  33960. type: "button",
  33961. onClick: this.confirmAddExternal,
  33962. disabled: !external.url.trim().length
  33963. },
  33964. language.confirm
  33965. )
  33966. ),
  33967. _react2.default.createElement(
  33968. "div",
  33969. {
  33970. "data-type": external.type,
  33971. className: "bf-switch-external-type"
  33972. },
  33973. externals.image
  33974. ? _react2.default.createElement(
  33975. "button",
  33976. {
  33977. type: "button",
  33978. onClick: this.switchExternalType,
  33979. "data-type": "IMAGE"
  33980. },
  33981. language.image
  33982. )
  33983. : null,
  33984. externals.audio
  33985. ? _react2.default.createElement(
  33986. "button",
  33987. {
  33988. type: "button",
  33989. onClick: this.switchExternalType,
  33990. "data-type": "AUDIO"
  33991. },
  33992. language.audio
  33993. )
  33994. : null,
  33995. externals.video
  33996. ? _react2.default.createElement(
  33997. "button",
  33998. {
  33999. type: "button",
  34000. onClick: this.switchExternalType,
  34001. "data-type": "VIDEO"
  34002. },
  34003. language.video
  34004. )
  34005. : null,
  34006. externals.embed
  34007. ? _react2.default.createElement(
  34008. "button",
  34009. {
  34010. type: "button",
  34011. onClick: this.switchExternalType,
  34012. "data-type": "EMBED"
  34013. },
  34014. language.embed
  34015. )
  34016. : null
  34017. ),
  34018. _react2.default.createElement(
  34019. "span",
  34020. { className: "bf-external-tip" },
  34021. language.externalInputTip
  34022. )
  34023. )
  34024. )
  34025. : null
  34026. ),
  34027. _react2.default.createElement(
  34028. "footer",
  34029. { className: "bf-manager-footer" },
  34030. _react2.default.createElement(
  34031. "div",
  34032. { className: "pull-left" },
  34033. allowExternal
  34034. ? _react2.default.createElement(
  34035. "span",
  34036. {
  34037. onClick: this.toggleExternalForm,
  34038. className: "bf-toggle-external-form"
  34039. },
  34040. showExternalForm
  34041. ? _react2.default.createElement(
  34042. "span",
  34043. { className: "bf-bottom-text" },
  34044. _react2.default.createElement("i", {
  34045. className: "braft-icon-add"
  34046. }),
  34047. " ",
  34048. language.addLocalFile
  34049. )
  34050. : _react2.default.createElement(
  34051. "span",
  34052. { className: "bf-bottom-text" },
  34053. _react2.default.createElement("i", {
  34054. className: "braft-icon-add"
  34055. }),
  34056. " ",
  34057. language.addExternalSource
  34058. )
  34059. )
  34060. : null
  34061. ),
  34062. _react2.default.createElement(
  34063. "div",
  34064. { className: "pull-right" },
  34065. _react2.default.createElement(
  34066. "button",
  34067. {
  34068. onClick: this.confirmInsert,
  34069. className: "button button-insert",
  34070. disabled: !confirmable
  34071. },
  34072. language.insert
  34073. ),
  34074. _react2.default.createElement(
  34075. "button",
  34076. {
  34077. onClick: this.cancelInsert,
  34078. className: "button button-cancel"
  34079. },
  34080. language.cancel
  34081. )
  34082. )
  34083. )
  34084. );
  34085. }
  34086. },
  34087. {
  34088. key: "buildItemList",
  34089. value: function buildItemList() {
  34090. var _this2 = this;
  34091. return _react2.default.createElement(
  34092. "ul",
  34093. { className: "bf-list" },
  34094. _react2.default.createElement(
  34095. "li",
  34096. { className: "bf-add-item" },
  34097. _react2.default.createElement("i", {
  34098. className: "braft-icon-add"
  34099. }),
  34100. _react2.default.createElement("input", {
  34101. accept: this.state.fileAccept,
  34102. onChange: this.reslovePickedFiles,
  34103. multiple: true,
  34104. type: "file"
  34105. })
  34106. ),
  34107. this.state.items.map(function(item, index) {
  34108. var previewerComponents = null;
  34109. var progressMarker =
  34110. item.uploading && !_this2.props.hideProgress
  34111. ? _react2.default.createElement(
  34112. "div",
  34113. { className: "bf-item-uploading" },
  34114. _react2.default.createElement("div", {
  34115. className: "bf-item-uploading-bar",
  34116. style: { width: item.uploadProgress / 1 + "%" }
  34117. })
  34118. )
  34119. : "";
  34120. switch (item.type) {
  34121. case "IMAGE":
  34122. previewerComponents = _react2.default.createElement(
  34123. "div",
  34124. { className: "bf-image" },
  34125. progressMarker,
  34126. _react2.default.createElement("img", {
  34127. src: item.thumbnail || item.url
  34128. })
  34129. );
  34130. break;
  34131. case "VIDEO":
  34132. previewerComponents = _react2.default.createElement(
  34133. "div",
  34134. { className: "bf-icon bf-video", title: item.url },
  34135. progressMarker,
  34136. _react2.default.createElement("i", {
  34137. className: "braft-icon-film"
  34138. }),
  34139. _react2.default.createElement(
  34140. "span",
  34141. null,
  34142. item.name || item.url
  34143. )
  34144. );
  34145. break;
  34146. case "AUDIO":
  34147. previewerComponents = _react2.default.createElement(
  34148. "div",
  34149. { className: "bf-icon bf-audio", title: item.url },
  34150. progressMarker,
  34151. _react2.default.createElement("i", {
  34152. className: "braft-icon-music"
  34153. }),
  34154. _react2.default.createElement(
  34155. "span",
  34156. null,
  34157. item.name || item.url
  34158. )
  34159. );
  34160. break;
  34161. case "EMBED":
  34162. previewerComponents = _react2.default.createElement(
  34163. "div",
  34164. { className: "bf-icon bf-embed", title: item.url },
  34165. progressMarker,
  34166. _react2.default.createElement("i", {
  34167. className: "braft-icon-code"
  34168. }),
  34169. _react2.default.createElement(
  34170. "span",
  34171. null,
  34172. item.name || _this2.props.language.embed
  34173. )
  34174. );
  34175. break;
  34176. default:
  34177. previewerComponents = _react2.default.createElement(
  34178. "a",
  34179. {
  34180. className: "bf-icon bf-file",
  34181. title: item.url,
  34182. href: item.url
  34183. },
  34184. progressMarker,
  34185. _react2.default.createElement("i", {
  34186. className: "braft-icon-file-text"
  34187. }),
  34188. _react2.default.createElement(
  34189. "span",
  34190. null,
  34191. item.name || item.url
  34192. )
  34193. );
  34194. break;
  34195. }
  34196. var className = ["bf-item"];
  34197. item.selected && className.push("active");
  34198. item.uploading && className.push("uploading");
  34199. item.error && className.push("error");
  34200. return _react2.default.createElement(
  34201. "li",
  34202. {
  34203. key: index,
  34204. title: item.name,
  34205. "data-id": item.id,
  34206. className: className.join(" "),
  34207. onClick: _this2.toggleSelectItem
  34208. },
  34209. previewerComponents,
  34210. _react2.default.createElement("span", {
  34211. "data-id": item.id,
  34212. onClick: _this2.removeItem,
  34213. className: "bf-item-remove braft-icon-close"
  34214. }),
  34215. _react2.default.createElement(
  34216. "span",
  34217. { className: "bf-item-title" },
  34218. item.name
  34219. )
  34220. );
  34221. })
  34222. );
  34223. }
  34224. }
  34225. ]);
  34226. return BraftFinderView;
  34227. })(_react2.default.Component);
  34228. BraftFinderView.defaultProps = {
  34229. accepts: defaultAccepts,
  34230. externals: {
  34231. image: true,
  34232. video: true,
  34233. audio: true,
  34234. embed: true
  34235. }
  34236. };
  34237. exports.default = BraftFinderView;
  34238. /***/
  34239. },
  34240. /* 19 */
  34241. /***/ function(module, exports, __webpack_require__) {
  34242. Object.defineProperty(exports, "__esModule", {
  34243. value: true
  34244. });
  34245. var _extends =
  34246. Object.assign ||
  34247. function(target) {
  34248. for (var i = 1; i < arguments.length; i++) {
  34249. var source = arguments[i];
  34250. for (var key in source) {
  34251. if (Object.prototype.hasOwnProperty.call(source, key)) {
  34252. target[key] = source[key];
  34253. }
  34254. }
  34255. }
  34256. return target;
  34257. };
  34258. var _base = __webpack_require__(1);
  34259. var _image = __webpack_require__(0);
  34260. function _toConsumableArray(arr) {
  34261. if (Array.isArray(arr)) {
  34262. for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
  34263. arr2[i] = arr[i];
  34264. }
  34265. return arr2;
  34266. } else {
  34267. return Array.from(arr);
  34268. }
  34269. }
  34270. function _classCallCheck(instance, Constructor) {
  34271. if (!(instance instanceof Constructor)) {
  34272. throw new TypeError("Cannot call a class as a function");
  34273. }
  34274. }
  34275. var defaultValidator = function defaultValidator() {
  34276. return true;
  34277. };
  34278. var BraftFinderController = function BraftFinderController() {
  34279. var props =
  34280. arguments.length > 0 && arguments[0] !== undefined
  34281. ? arguments[0]
  34282. : {};
  34283. _classCallCheck(this, BraftFinderController);
  34284. _initialiseProps.call(this);
  34285. this.items = props.items || [];
  34286. this.uploadFn = props.uploader;
  34287. this.validateFn = props.validator || defaultValidator;
  34288. this.changeListeners = [];
  34289. };
  34290. // resolvePastedFiles ({ clipboardData }, callback) {
  34291. // if (clipboardData && clipboardData.items && clipboardData.items[0].type.indexOf('image') > -1) {
  34292. // this.uploadImage(clipboardData.items[0].getAsFile(), callback)
  34293. // }
  34294. // }
  34295. var _initialiseProps = function _initialiseProps() {
  34296. var _this = this;
  34297. this.setProps = function() {
  34298. var props =
  34299. arguments.length > 0 && arguments[0] !== undefined
  34300. ? arguments[0]
  34301. : {};
  34302. _this.items = props.items || _this.items || [];
  34303. _this.uploadFn = props.uploader;
  34304. _this.validateFn = props.validator || defaultValidator;
  34305. };
  34306. this.getMediaItem = function(id) {
  34307. return _this.items.find(function(item) {
  34308. return item.id === id;
  34309. });
  34310. };
  34311. this.getSelectedItems = function() {
  34312. return _this.items.filter(function(item) {
  34313. return item.selected;
  34314. });
  34315. };
  34316. this.getItems = function() {
  34317. return _this.items;
  34318. };
  34319. this.setItems = function(items) {
  34320. _this.items =
  34321. items.map(function(item) {
  34322. return _extends({}, item, { id: item.id.toString() });
  34323. }) || [];
  34324. _this.applyChange();
  34325. _this.uploadItems();
  34326. };
  34327. this.addMediaItem = function(item) {
  34328. _this.addItems([item]);
  34329. };
  34330. this.addItems = function(items) {
  34331. _this.items = [].concat(
  34332. _toConsumableArray(_this.items),
  34333. _toConsumableArray(
  34334. items.map(function(item) {
  34335. return _extends({}, item, { id: item.id.toString() });
  34336. })
  34337. )
  34338. );
  34339. _this.applyChange();
  34340. _this.uploadItems();
  34341. };
  34342. this.selectMediaItem = function(id) {
  34343. var item = _this.getMediaItem(id);
  34344. if (item && (item.uploading || item.error)) {
  34345. return false;
  34346. }
  34347. _this.setMediaItemState(id, {
  34348. selected: true
  34349. });
  34350. };
  34351. this.selectAllItems = function() {
  34352. _this.items = _this.items
  34353. .filter(function(item) {
  34354. return !item.error && !item.uploading;
  34355. })
  34356. .map(function(item) {
  34357. return _extends({}, item, { selected: true });
  34358. });
  34359. _this.applyChange();
  34360. };
  34361. this.deselectMediaItem = function(id) {
  34362. _this.setMediaItemState(id, {
  34363. selected: false
  34364. });
  34365. };
  34366. this.deselectAllItems = function() {
  34367. _this.items = _this.items.map(function(item) {
  34368. return _extends({}, item, { selected: false });
  34369. });
  34370. _this.applyChange();
  34371. };
  34372. this.removeMediaItem = function(id) {
  34373. _this.items = _this.items.filter(function(item) {
  34374. return item.id !== id;
  34375. });
  34376. _this.applyChange();
  34377. };
  34378. this.removeItems = function() {
  34379. var ids =
  34380. arguments.length > 0 && arguments[0] !== undefined
  34381. ? arguments[0]
  34382. : [];
  34383. _this.items = _this.items.filter(function(item) {
  34384. return !ids.includes(item.id);
  34385. });
  34386. _this.applyChange();
  34387. };
  34388. this.removeSelectedItems = function() {
  34389. _this.items = _this.items.filter(function(item) {
  34390. return !item.selected;
  34391. });
  34392. _this.applyChange();
  34393. };
  34394. this.removeErrorItems = function() {
  34395. _this.items = _this.items.filter(function(item) {
  34396. return !item.error;
  34397. });
  34398. _this.applyChange();
  34399. };
  34400. this.removeAllItems = function() {
  34401. _this.items = [];
  34402. _this.applyChange();
  34403. };
  34404. this.setMediaItemState = function(id, state) {
  34405. _this.items = _this.items.map(function(item) {
  34406. return item.id === id ? _extends({}, item, state) : item;
  34407. });
  34408. _this.applyChange();
  34409. };
  34410. this.reuploadErrorItems = function() {
  34411. _this.uploadItems(true);
  34412. };
  34413. this.uploadItems = function() {
  34414. var ignoreError =
  34415. arguments.length > 0 && arguments[0] !== undefined
  34416. ? arguments[0]
  34417. : false;
  34418. _this.items.forEach(function(item, index) {
  34419. if (item.uploading || item.url) {
  34420. return false;
  34421. }
  34422. if (!ignoreError && item.error) {
  34423. return false;
  34424. }
  34425. if (item.type === "IMAGE") {
  34426. _this.createThumbnail(item);
  34427. _this.uploadFn = _this.uploadFn || _this.createInlineImage;
  34428. } else if (!_this.uploadFn) {
  34429. _this.setMediaItemState(item.id, { error: 1 });
  34430. return false;
  34431. }
  34432. _this.setMediaItemState(item.id, {
  34433. uploading: true,
  34434. uploadProgress: 0,
  34435. error: 0
  34436. });
  34437. _this.uploadFn({
  34438. id: item.id,
  34439. file: item.file,
  34440. success: function success(res) {
  34441. _this.handleUploadSuccess(item.id, res);
  34442. },
  34443. progress: function progress(_progress) {
  34444. _this.setMediaItemState(item.id, {
  34445. uploading: true,
  34446. uploadProgress: _progress
  34447. });
  34448. },
  34449. error: function error(_error) {
  34450. _this.setMediaItemState(item.id, {
  34451. uploading: false,
  34452. error: 2
  34453. });
  34454. }
  34455. });
  34456. });
  34457. };
  34458. this.createThumbnail = function(_ref) {
  34459. var id = _ref.id,
  34460. file = _ref.file;
  34461. (0, _image.compressImage)(
  34462. URL.createObjectURL(file),
  34463. 226,
  34464. 226
  34465. ).then(function(result) {
  34466. _this.setMediaItemState(id, { thumbnail: result.url });
  34467. });
  34468. };
  34469. this.createInlineImage = function(param) {
  34470. (0, _image.compressImage)(
  34471. URL.createObjectURL(param.file),
  34472. 1280,
  34473. 800
  34474. )
  34475. .then(function(result) {
  34476. param.success({ url: result.url });
  34477. })
  34478. .catch(function(error) {
  34479. param.error(error);
  34480. });
  34481. };
  34482. this.handleUploadSuccess = function(id, data) {
  34483. _this.setMediaItemState(
  34484. id,
  34485. _extends({}, data, {
  34486. file: null,
  34487. uploadProgress: 1,
  34488. uploading: false,
  34489. selected: false
  34490. })
  34491. );
  34492. var item = _this.getMediaItem(data.id || id);
  34493. item.onReady && item.onReady(item);
  34494. };
  34495. this.applyChange = function() {
  34496. _this.changeListeners.forEach(function(_ref2) {
  34497. var callback = _ref2.callback;
  34498. return callback(_this.items);
  34499. });
  34500. };
  34501. this.uploadImage = function(file, callback) {
  34502. var fileId =
  34503. new Date().getTime() + "_" + (0, _base.UniqueIndex)();
  34504. _this.addMediaItem({
  34505. type: "IMAGE",
  34506. id: fileId,
  34507. file: file,
  34508. name: fileId,
  34509. size: file.size,
  34510. uploadProgress: 0,
  34511. uploading: false,
  34512. selected: false,
  34513. error: 0,
  34514. onReady: callback
  34515. });
  34516. };
  34517. this.uploadImageRecursively = function(files, callback) {
  34518. var index =
  34519. arguments.length > 2 && arguments[2] !== undefined
  34520. ? arguments[2]
  34521. : 0;
  34522. if (files[index] && files[index].type.indexOf("image") > -1) {
  34523. _this.uploadImage(files[index], function(image) {
  34524. callback && callback(image);
  34525. index < files.length - 1 &&
  34526. _this.uploadImageRecursively(files, callback, index + 1);
  34527. });
  34528. } else {
  34529. index < files.length - 1 &&
  34530. _this.uploadImageRecursively(files, callback, index + 1);
  34531. }
  34532. };
  34533. this.addResolvedFiles = function(param, index, accepts) {
  34534. var data = {
  34535. id: new Date().getTime() + "_" + (0, _base.UniqueIndex)(),
  34536. file: param.files[index],
  34537. name: param.files[index].name,
  34538. size: param.files[index].size,
  34539. uploadProgress: 0,
  34540. uploading: false,
  34541. selected: false,
  34542. error: 0,
  34543. onReady: function onReady(item) {
  34544. param.onItemReady && param.onItemReady(item);
  34545. }
  34546. };
  34547. if (
  34548. param.files[index].type.indexOf("image/") === 0 &&
  34549. accepts.image
  34550. ) {
  34551. data.type = "IMAGE";
  34552. _this.addMediaItem(data);
  34553. } else if (
  34554. param.files[index].type.indexOf("video/") === 0 &&
  34555. accepts.video
  34556. ) {
  34557. data.type = "VIDEO";
  34558. _this.addMediaItem(data);
  34559. } else if (
  34560. param.files[index].type.indexOf("audio/") === 0 &&
  34561. accepts.audio
  34562. ) {
  34563. data.type = "AUDIO";
  34564. _this.addMediaItem(data);
  34565. }
  34566. setTimeout(function() {
  34567. _this.resolveFiles(param, index + 1, accepts);
  34568. }, 60);
  34569. };
  34570. this.resolveFiles = function(param, index, accepts) {
  34571. if (index < param.files.length) {
  34572. var validateResult = _this.validateFn(param.files[index]);
  34573. if (validateResult instanceof Promise) {
  34574. validateResult.then(function() {
  34575. _this.addResolvedFiles(param, index, accepts);
  34576. });
  34577. } else if (validateResult) {
  34578. _this.addResolvedFiles(param, index, accepts);
  34579. }
  34580. } else {
  34581. param.onAllReady && param.onAllReady();
  34582. }
  34583. };
  34584. this.onChange = function(callback) {
  34585. var listenerId = (0, _base.UniqueIndex)();
  34586. _this.changeListeners.push({
  34587. id: listenerId,
  34588. callback: callback
  34589. });
  34590. return listenerId;
  34591. };
  34592. this.offChange = function(listenerId) {
  34593. _this.changeListeners = _this.changeListeners.filter(function(
  34594. _ref3
  34595. ) {
  34596. var id = _ref3.id;
  34597. return id !== listenerId;
  34598. });
  34599. };
  34600. };
  34601. exports.default = BraftFinderController;
  34602. /***/
  34603. },
  34604. /* 20 */
  34605. /***/ function(module, exports, __webpack_require__) {
  34606. Object.defineProperty(exports, "__esModule", {
  34607. value: true
  34608. });
  34609. exports.ImageUtils = undefined;
  34610. var _extends =
  34611. Object.assign ||
  34612. function(target) {
  34613. for (var i = 1; i < arguments.length; i++) {
  34614. var source = arguments[i];
  34615. for (var key in source) {
  34616. if (Object.prototype.hasOwnProperty.call(source, key)) {
  34617. target[key] = source[key];
  34618. }
  34619. }
  34620. }
  34621. return target;
  34622. };
  34623. var _react = __webpack_require__(2);
  34624. var _react2 = _interopRequireDefault(_react);
  34625. var _controller = __webpack_require__(19);
  34626. var _controller2 = _interopRequireDefault(_controller);
  34627. var _view = __webpack_require__(18);
  34628. var _view2 = _interopRequireDefault(_view);
  34629. var _languages = __webpack_require__(10);
  34630. var _languages2 = _interopRequireDefault(_languages);
  34631. var _image = __webpack_require__(0);
  34632. var ImageUtils = _interopRequireWildcard(_image);
  34633. function _interopRequireWildcard(obj) {
  34634. if (obj && obj.__esModule) {
  34635. return obj;
  34636. } else {
  34637. var newObj = {};
  34638. if (obj != null) {
  34639. for (var key in obj) {
  34640. if (Object.prototype.hasOwnProperty.call(obj, key))
  34641. newObj[key] = obj[key];
  34642. }
  34643. }
  34644. newObj.default = obj;
  34645. return newObj;
  34646. }
  34647. }
  34648. function _interopRequireDefault(obj) {
  34649. return obj && obj.__esModule ? obj : { default: obj };
  34650. }
  34651. function _classCallCheck(instance, Constructor) {
  34652. if (!(instance instanceof Constructor)) {
  34653. throw new TypeError("Cannot call a class as a function");
  34654. }
  34655. }
  34656. function _possibleConstructorReturn(self, call) {
  34657. if (!self) {
  34658. throw new ReferenceError(
  34659. "this hasn't been initialised - super() hasn't been called"
  34660. );
  34661. }
  34662. return call &&
  34663. (typeof call === "object" || typeof call === "function")
  34664. ? call
  34665. : self;
  34666. }
  34667. function _inherits(subClass, superClass) {
  34668. if (typeof superClass !== "function" && superClass !== null) {
  34669. throw new TypeError(
  34670. "Super expression must either be null or a function, not " +
  34671. typeof superClass
  34672. );
  34673. }
  34674. subClass.prototype = Object.create(
  34675. superClass && superClass.prototype,
  34676. {
  34677. constructor: {
  34678. value: subClass,
  34679. enumerable: false,
  34680. writable: true,
  34681. configurable: true
  34682. }
  34683. }
  34684. );
  34685. if (superClass)
  34686. Object.setPrototypeOf
  34687. ? Object.setPrototypeOf(subClass, superClass)
  34688. : (subClass.__proto__ = superClass);
  34689. }
  34690. var BraftFinder = (function(_FinderController) {
  34691. _inherits(BraftFinder, _FinderController);
  34692. function BraftFinder(props) {
  34693. _classCallCheck(this, BraftFinder);
  34694. var _this = _possibleConstructorReturn(
  34695. this,
  34696. (
  34697. BraftFinder.__proto__ || Object.getPrototypeOf(BraftFinder)
  34698. ).call(this, props)
  34699. );
  34700. _initialiseProps.call(_this);
  34701. _this.superProps = props;
  34702. return _this;
  34703. }
  34704. return BraftFinder;
  34705. })(_controller2.default);
  34706. var _initialiseProps = function _initialiseProps() {
  34707. var _this2 = this;
  34708. this.ReactComponent = function() {
  34709. var props =
  34710. arguments.length > 0 && arguments[0] !== undefined
  34711. ? arguments[0]
  34712. : {};
  34713. var componentProps = _extends({}, _this2.superProps, props);
  34714. var language =
  34715. (typeof componentProps.language === "function"
  34716. ? componentProps.language(_languages2.default, "braft-finder")
  34717. : _languages2.default[componentProps.language]) ||
  34718. _languages2.default["zh"];
  34719. return _react2.default.createElement(
  34720. _view2.default,
  34721. _extends({}, componentProps, {
  34722. language: language,
  34723. controller: _this2
  34724. })
  34725. );
  34726. };
  34727. };
  34728. exports.default = BraftFinder;
  34729. exports.ImageUtils = ImageUtils;
  34730. /***/
  34731. }
  34732. /******/
  34733. ]
  34734. );
  34735. });
  34736. });
  34737. _commonjsHelpers.unwrapExports(dist$2);
  34738. var dist$3 = _commonjsHelpers.createCommonjsModule(function(module, exports) {
  34739. (function webpackUniversalModuleDefinition(root, factory) {
  34740. module.exports = factory(
  34741. React__default,
  34742. dist$1,
  34743. Draft,
  34744. immutable$1,
  34745. dist,
  34746. reactDom__default,
  34747. dist$2,
  34748. draftjsUtils
  34749. );
  34750. })(window, function(
  34751. __WEBPACK_EXTERNAL_MODULE__0__,
  34752. __WEBPACK_EXTERNAL_MODULE__3__,
  34753. __WEBPACK_EXTERNAL_MODULE__6__,
  34754. __WEBPACK_EXTERNAL_MODULE__13__,
  34755. __WEBPACK_EXTERNAL_MODULE__14__,
  34756. __WEBPACK_EXTERNAL_MODULE__16__,
  34757. __WEBPACK_EXTERNAL_MODULE__17__,
  34758. __WEBPACK_EXTERNAL_MODULE__23__
  34759. ) {
  34760. return /******/ (function(modules) {
  34761. // webpackBootstrap
  34762. /******/ // The module cache
  34763. /******/ var installedModules = {}; // The require function
  34764. /******/
  34765. /******/ /******/ function __webpack_require__(moduleId) {
  34766. /******/
  34767. /******/ // Check if module is in cache
  34768. /******/ if (installedModules[moduleId]) {
  34769. /******/ return installedModules[moduleId].exports;
  34770. /******/
  34771. } // Create a new module (and put it into the cache)
  34772. /******/ /******/ var module = (installedModules[moduleId] = {
  34773. /******/ i: moduleId,
  34774. /******/ l: false,
  34775. /******/ exports: {}
  34776. /******/
  34777. }); // Execute the module function
  34778. /******/
  34779. /******/ /******/ modules[moduleId].call(
  34780. module.exports,
  34781. module,
  34782. module.exports,
  34783. __webpack_require__
  34784. ); // Flag the module as loaded
  34785. /******/
  34786. /******/ /******/ module.l = true; // Return the exports of the module
  34787. /******/
  34788. /******/ /******/ return module.exports;
  34789. /******/
  34790. } // expose the modules object (__webpack_modules__)
  34791. /******/
  34792. /******/
  34793. /******/ /******/ __webpack_require__.m = modules; // expose the module cache
  34794. /******/
  34795. /******/ /******/ __webpack_require__.c = installedModules; // define getter function for harmony exports
  34796. /******/
  34797. /******/ /******/ __webpack_require__.d = function(
  34798. exports,
  34799. name,
  34800. getter
  34801. ) {
  34802. /******/ if (!__webpack_require__.o(exports, name)) {
  34803. /******/ Object.defineProperty(exports, name, {
  34804. enumerable: true,
  34805. get: getter
  34806. });
  34807. /******/
  34808. }
  34809. /******/
  34810. }; // define __esModule on exports
  34811. /******/
  34812. /******/ /******/ __webpack_require__.r = function(exports) {
  34813. /******/ if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
  34814. /******/ Object.defineProperty(exports, Symbol.toStringTag, {
  34815. value: "Module"
  34816. });
  34817. /******/
  34818. }
  34819. /******/ Object.defineProperty(exports, "__esModule", { value: true });
  34820. /******/
  34821. }; // create a fake namespace object // mode & 1: value is a module id, require it // mode & 2: merge all properties of value into the ns // mode & 4: return value when already ns object // mode & 8|1: behave like require
  34822. /******/
  34823. /******/ /******/ /******/ /******/ /******/ /******/ __webpack_require__.t = function(
  34824. value,
  34825. mode
  34826. ) {
  34827. /******/ if (mode & 1) value = __webpack_require__(value);
  34828. /******/ if (mode & 8) return value;
  34829. /******/ if (
  34830. mode & 4 &&
  34831. typeof value === "object" &&
  34832. value &&
  34833. value.__esModule
  34834. )
  34835. return value;
  34836. /******/ var ns = Object.create(null);
  34837. /******/ __webpack_require__.r(ns);
  34838. /******/ Object.defineProperty(ns, "default", {
  34839. enumerable: true,
  34840. value: value
  34841. });
  34842. /******/ if (mode & 2 && typeof value != "string")
  34843. for (var key in value)
  34844. __webpack_require__.d(
  34845. ns,
  34846. key,
  34847. function(key) {
  34848. return value[key];
  34849. }.bind(null, key)
  34850. );
  34851. /******/ return ns;
  34852. /******/
  34853. }; // getDefaultExport function for compatibility with non-harmony modules
  34854. /******/
  34855. /******/ /******/ __webpack_require__.n = function(module) {
  34856. /******/ var getter =
  34857. module && module.__esModule
  34858. ? /******/ function getDefault() {
  34859. return module["default"];
  34860. }
  34861. : /******/ function getModuleExports() {
  34862. return module;
  34863. };
  34864. /******/ __webpack_require__.d(getter, "a", getter);
  34865. /******/ return getter;
  34866. /******/
  34867. }; // Object.prototype.hasOwnProperty.call
  34868. /******/
  34869. /******/ /******/ __webpack_require__.o = function(object, property) {
  34870. return Object.prototype.hasOwnProperty.call(object, property);
  34871. }; // __webpack_public_path__
  34872. /******/
  34873. /******/ /******/ __webpack_require__.p = "/"; // Load entry module and return exports
  34874. /******/
  34875. /******/
  34876. /******/ /******/ return __webpack_require__(
  34877. (__webpack_require__.s = 39)
  34878. );
  34879. /******/
  34880. })(
  34881. /************************************************************************/
  34882. /******/ [
  34883. /* 0 */
  34884. /***/ function(module, exports) {
  34885. module.exports = __WEBPACK_EXTERNAL_MODULE__0__;
  34886. /***/
  34887. },
  34888. /* 1 */
  34889. /***/ function(module, exports) {
  34890. function _assertThisInitialized(self) {
  34891. if (self === void 0) {
  34892. throw new ReferenceError(
  34893. "this hasn't been initialised - super() hasn't been called"
  34894. );
  34895. }
  34896. return self;
  34897. }
  34898. module.exports = _assertThisInitialized;
  34899. /***/
  34900. },
  34901. /* 2 */
  34902. /***/ function(module, exports) {
  34903. function _defineProperty(obj, key, value) {
  34904. if (key in obj) {
  34905. Object.defineProperty(obj, key, {
  34906. value: value,
  34907. enumerable: true,
  34908. configurable: true,
  34909. writable: true
  34910. });
  34911. } else {
  34912. obj[key] = value;
  34913. }
  34914. return obj;
  34915. }
  34916. module.exports = _defineProperty;
  34917. /***/
  34918. },
  34919. /* 3 */
  34920. /***/ function(module, exports) {
  34921. module.exports = __WEBPACK_EXTERNAL_MODULE__3__;
  34922. /***/
  34923. },
  34924. /* 4 */
  34925. /***/ function(module, exports) {
  34926. function _classCallCheck(instance, Constructor) {
  34927. if (!(instance instanceof Constructor)) {
  34928. throw new TypeError("Cannot call a class as a function");
  34929. }
  34930. }
  34931. module.exports = _classCallCheck;
  34932. /***/
  34933. },
  34934. /* 5 */
  34935. /***/ function(module, exports, __webpack_require__) {
  34936. var defineProperty = __webpack_require__(2);
  34937. function _objectSpread(target) {
  34938. for (var i = 1; i < arguments.length; i++) {
  34939. var source = arguments[i] != null ? arguments[i] : {};
  34940. var ownKeys = Object.keys(source);
  34941. if (typeof Object.getOwnPropertySymbols === "function") {
  34942. ownKeys = ownKeys.concat(
  34943. Object.getOwnPropertySymbols(source).filter(function(sym) {
  34944. return Object.getOwnPropertyDescriptor(
  34945. source,
  34946. sym
  34947. ).enumerable;
  34948. })
  34949. );
  34950. }
  34951. ownKeys.forEach(function(key) {
  34952. defineProperty(target, key, source[key]);
  34953. });
  34954. }
  34955. return target;
  34956. }
  34957. module.exports = _objectSpread;
  34958. /***/
  34959. },
  34960. /* 6 */
  34961. /***/ function(module, exports) {
  34962. module.exports = __WEBPACK_EXTERNAL_MODULE__6__;
  34963. /***/
  34964. },
  34965. /* 7 */
  34966. /***/ function(module, exports) {
  34967. function _defineProperties(target, props) {
  34968. for (var i = 0; i < props.length; i++) {
  34969. var descriptor = props[i];
  34970. descriptor.enumerable = descriptor.enumerable || false;
  34971. descriptor.configurable = true;
  34972. if ("value" in descriptor) descriptor.writable = true;
  34973. Object.defineProperty(target, descriptor.key, descriptor);
  34974. }
  34975. }
  34976. function _createClass(Constructor, protoProps, staticProps) {
  34977. if (protoProps)
  34978. _defineProperties(Constructor.prototype, protoProps);
  34979. if (staticProps) _defineProperties(Constructor, staticProps);
  34980. return Constructor;
  34981. }
  34982. module.exports = _createClass;
  34983. /***/
  34984. },
  34985. /* 8 */
  34986. /***/ function(module, exports, __webpack_require__) {
  34987. var _typeof = __webpack_require__(15);
  34988. var assertThisInitialized = __webpack_require__(1);
  34989. function _possibleConstructorReturn(self, call) {
  34990. if (
  34991. call &&
  34992. (_typeof(call) === "object" || typeof call === "function")
  34993. ) {
  34994. return call;
  34995. }
  34996. return assertThisInitialized(self);
  34997. }
  34998. module.exports = _possibleConstructorReturn;
  34999. /***/
  35000. },
  35001. /* 9 */
  35002. /***/ function(module, exports) {
  35003. function _getPrototypeOf(o) {
  35004. module.exports = _getPrototypeOf = Object.setPrototypeOf
  35005. ? Object.getPrototypeOf
  35006. : function _getPrototypeOf(o) {
  35007. return o.__proto__ || Object.getPrototypeOf(o);
  35008. };
  35009. return _getPrototypeOf(o);
  35010. }
  35011. module.exports = _getPrototypeOf;
  35012. /***/
  35013. },
  35014. /* 10 */
  35015. /***/ function(module, exports, __webpack_require__) {
  35016. var setPrototypeOf = __webpack_require__(26);
  35017. function _inherits(subClass, superClass) {
  35018. if (typeof superClass !== "function" && superClass !== null) {
  35019. throw new TypeError(
  35020. "Super expression must either be null or a function"
  35021. );
  35022. }
  35023. subClass.prototype = Object.create(
  35024. superClass && superClass.prototype,
  35025. {
  35026. constructor: {
  35027. value: subClass,
  35028. writable: true,
  35029. configurable: true
  35030. }
  35031. }
  35032. );
  35033. if (superClass) setPrototypeOf(subClass, superClass);
  35034. }
  35035. module.exports = _inherits;
  35036. /***/
  35037. },
  35038. /* 11 */
  35039. /***/ function(module, exports) {
  35040. function _extends() {
  35041. module.exports = _extends =
  35042. Object.assign ||
  35043. function(target) {
  35044. for (var i = 1; i < arguments.length; i++) {
  35045. var source = arguments[i];
  35046. for (var key in source) {
  35047. if (Object.prototype.hasOwnProperty.call(source, key)) {
  35048. target[key] = source[key];
  35049. }
  35050. }
  35051. }
  35052. return target;
  35053. };
  35054. return _extends.apply(this, arguments);
  35055. }
  35056. module.exports = _extends;
  35057. /***/
  35058. },
  35059. /* 12 */
  35060. /***/ function(module, exports, __webpack_require__) {
  35061. var arrayWithoutHoles = __webpack_require__(27);
  35062. var iterableToArray = __webpack_require__(28);
  35063. var nonIterableSpread = __webpack_require__(29);
  35064. function _toConsumableArray(arr) {
  35065. return (
  35066. arrayWithoutHoles(arr) ||
  35067. iterableToArray(arr) ||
  35068. nonIterableSpread()
  35069. );
  35070. }
  35071. module.exports = _toConsumableArray;
  35072. /***/
  35073. },
  35074. /* 13 */
  35075. /***/ function(module, exports) {
  35076. module.exports = __WEBPACK_EXTERNAL_MODULE__13__;
  35077. /***/
  35078. },
  35079. /* 14 */
  35080. /***/ function(module, exports) {
  35081. module.exports = __WEBPACK_EXTERNAL_MODULE__14__;
  35082. /***/
  35083. },
  35084. /* 15 */
  35085. /***/ function(module, exports) {
  35086. function _typeof2(obj) {
  35087. if (
  35088. typeof Symbol === "function" &&
  35089. typeof Symbol.iterator === "symbol"
  35090. ) {
  35091. _typeof2 = function _typeof2(obj) {
  35092. return typeof obj;
  35093. };
  35094. } else {
  35095. _typeof2 = function _typeof2(obj) {
  35096. return obj &&
  35097. typeof Symbol === "function" &&
  35098. obj.constructor === Symbol &&
  35099. obj !== Symbol.prototype
  35100. ? "symbol"
  35101. : typeof obj;
  35102. };
  35103. }
  35104. return _typeof2(obj);
  35105. }
  35106. function _typeof(obj) {
  35107. if (
  35108. typeof Symbol === "function" &&
  35109. _typeof2(Symbol.iterator) === "symbol"
  35110. ) {
  35111. module.exports = _typeof = function _typeof(obj) {
  35112. return _typeof2(obj);
  35113. };
  35114. } else {
  35115. module.exports = _typeof = function _typeof(obj) {
  35116. return obj &&
  35117. typeof Symbol === "function" &&
  35118. obj.constructor === Symbol &&
  35119. obj !== Symbol.prototype
  35120. ? "symbol"
  35121. : _typeof2(obj);
  35122. };
  35123. }
  35124. return _typeof(obj);
  35125. }
  35126. module.exports = _typeof;
  35127. /***/
  35128. },
  35129. /* 16 */
  35130. /***/ function(module, exports) {
  35131. module.exports = __WEBPACK_EXTERNAL_MODULE__16__;
  35132. /***/
  35133. },
  35134. /* 17 */
  35135. /***/ function(module, exports) {
  35136. module.exports = __WEBPACK_EXTERNAL_MODULE__17__;
  35137. /***/
  35138. },
  35139. /* 18 */
  35140. /***/ function(module, exports, __webpack_require__) {
  35141. var Immutable = __webpack_require__(13);
  35142. var KEY_SEPARATOR = "-";
  35143. function MultiDecorator(decorators) {
  35144. this.decorators = Immutable.List(decorators);
  35145. }
  35146. /**
  35147. Return list of decoration IDs per character
  35148. @param {ContentBlock}
  35149. @return {List<String>}
  35150. */
  35151. MultiDecorator.prototype.getDecorations = function(block) {
  35152. var decorations = Array(block.getText().length).fill(null);
  35153. this.decorators.forEach(function(decorator, i) {
  35154. var _decorations = decorator.getDecorations(block);
  35155. _decorations.forEach(function(key, offset) {
  35156. if (!key) {
  35157. return;
  35158. }
  35159. key = i + KEY_SEPARATOR + key;
  35160. decorations[offset] = key;
  35161. });
  35162. });
  35163. return Immutable.List(decorations);
  35164. };
  35165. /**
  35166. Return component to render a decoration
  35167. @param {String}
  35168. @return {Function}
  35169. */
  35170. MultiDecorator.prototype.getComponentForKey = function(key) {
  35171. var decorator = this.getDecoratorForKey(key);
  35172. return decorator.getComponentForKey(this.getInnerKey(key));
  35173. };
  35174. /**
  35175. Return props to render a decoration
  35176. @param {String}
  35177. @return {Object}
  35178. */
  35179. MultiDecorator.prototype.getPropsForKey = function(key) {
  35180. var decorator = this.getDecoratorForKey(key);
  35181. return decorator.getPropsForKey(this.getInnerKey(key));
  35182. };
  35183. /**
  35184. Return a decorator for a specific key
  35185. @param {String}
  35186. @return {Decorator}
  35187. */
  35188. MultiDecorator.prototype.getDecoratorForKey = function(key) {
  35189. var parts = key.split(KEY_SEPARATOR);
  35190. var index = Number(parts[0]);
  35191. return this.decorators.get(index);
  35192. };
  35193. /**
  35194. Return inner key for a decorator
  35195. @param {String}
  35196. @return {String}
  35197. */
  35198. MultiDecorator.prototype.getInnerKey = function(key) {
  35199. var parts = key.split(KEY_SEPARATOR);
  35200. return parts.slice(1).join(KEY_SEPARATOR);
  35201. };
  35202. module.exports = MultiDecorator;
  35203. /***/
  35204. },
  35205. /* 19 */
  35206. /***/ function(module, exports, __webpack_require__) {
  35207. /**
  35208. * Copyright (c) 2013-present, Facebook, Inc.
  35209. * All rights reserved.
  35210. *
  35211. * This source code is licensed under the BSD-style license found in the
  35212. * LICENSE file in the root directory of this source tree. An additional grant
  35213. * of patent rights can be found in the PATENTS file in the same directory.
  35214. *
  35215. * @providesModule CharacterMetadata
  35216. * @format
  35217. *
  35218. */
  35219. function _classCallCheck(instance, Constructor) {
  35220. if (!(instance instanceof Constructor)) {
  35221. throw new TypeError("Cannot call a class as a function");
  35222. }
  35223. }
  35224. function _possibleConstructorReturn(self, call) {
  35225. if (!self) {
  35226. throw new ReferenceError(
  35227. "this hasn't been initialised - super() hasn't been called"
  35228. );
  35229. }
  35230. return call &&
  35231. (typeof call === "object" || typeof call === "function")
  35232. ? call
  35233. : self;
  35234. }
  35235. function _inherits(subClass, superClass) {
  35236. if (typeof superClass !== "function" && superClass !== null) {
  35237. throw new TypeError(
  35238. "Super expression must either be null or a function, not " +
  35239. typeof superClass
  35240. );
  35241. }
  35242. subClass.prototype = Object.create(
  35243. superClass && superClass.prototype,
  35244. {
  35245. constructor: {
  35246. value: subClass,
  35247. enumerable: false,
  35248. writable: true,
  35249. configurable: true
  35250. }
  35251. }
  35252. );
  35253. if (superClass)
  35254. Object.setPrototypeOf
  35255. ? Object.setPrototypeOf(subClass, superClass)
  35256. : (subClass.__proto__ = superClass);
  35257. }
  35258. var _require = __webpack_require__(13),
  35259. Map = _require.Map,
  35260. OrderedSet = _require.OrderedSet,
  35261. Record = _require.Record;
  35262. // Immutable.map is typed such that the value for every key in the map
  35263. // must be the same type
  35264. var EMPTY_SET = OrderedSet();
  35265. var defaultRecord = {
  35266. style: EMPTY_SET,
  35267. entity: null
  35268. };
  35269. var CharacterMetadataRecord = Record(defaultRecord);
  35270. var CharacterMetadata = (function(_CharacterMetadataRec) {
  35271. _inherits(CharacterMetadata, _CharacterMetadataRec);
  35272. function CharacterMetadata() {
  35273. _classCallCheck(this, CharacterMetadata);
  35274. return _possibleConstructorReturn(
  35275. this,
  35276. _CharacterMetadataRec.apply(this, arguments)
  35277. );
  35278. }
  35279. CharacterMetadata.prototype.getStyle = function getStyle() {
  35280. return this.get("style");
  35281. };
  35282. CharacterMetadata.prototype.getEntity = function getEntity() {
  35283. return this.get("entity");
  35284. };
  35285. CharacterMetadata.prototype.hasStyle = function hasStyle(style) {
  35286. return this.getStyle().includes(style);
  35287. };
  35288. CharacterMetadata.applyStyle = function applyStyle(record, style) {
  35289. var withStyle = record.set("style", record.getStyle().add(style));
  35290. return CharacterMetadata.create(withStyle);
  35291. };
  35292. CharacterMetadata.removeStyle = function removeStyle(
  35293. record,
  35294. style
  35295. ) {
  35296. var withoutStyle = record.set(
  35297. "style",
  35298. record.getStyle().remove(style)
  35299. );
  35300. return CharacterMetadata.create(withoutStyle);
  35301. };
  35302. CharacterMetadata.applyEntity = function applyEntity(
  35303. record,
  35304. entityKey
  35305. ) {
  35306. var withEntity =
  35307. record.getEntity() === entityKey
  35308. ? record
  35309. : record.set("entity", entityKey);
  35310. return CharacterMetadata.create(withEntity);
  35311. };
  35312. /**
  35313. * Use this function instead of the `CharacterMetadata` constructor.
  35314. * Since most content generally uses only a very small number of
  35315. * style/entity permutations, we can reuse these objects as often as
  35316. * possible.
  35317. */
  35318. CharacterMetadata.create = function create(config) {
  35319. if (!config) {
  35320. return EMPTY;
  35321. }
  35322. var defaultConfig = {
  35323. style: EMPTY_SET,
  35324. entity: null
  35325. };
  35326. // Fill in unspecified properties, if necessary.
  35327. var configMap = Map(defaultConfig).merge(config);
  35328. var existing = pool.get(configMap);
  35329. if (existing) {
  35330. return existing;
  35331. }
  35332. var newCharacter = new CharacterMetadata(configMap);
  35333. pool = pool.set(configMap, newCharacter);
  35334. return newCharacter;
  35335. };
  35336. return CharacterMetadata;
  35337. })(CharacterMetadataRecord);
  35338. var EMPTY = new CharacterMetadata();
  35339. var pool = Map([[Map(defaultRecord), EMPTY]]);
  35340. CharacterMetadata.EMPTY = EMPTY;
  35341. module.exports = CharacterMetadata;
  35342. /***/
  35343. },
  35344. /* 20 */
  35345. /***/ function(module, exports, __webpack_require__) {
  35346. /**
  35347. * Copyright (c) 2013-present, Facebook, Inc.
  35348. * All rights reserved.
  35349. *
  35350. * This source code is licensed under the BSD-style license found in the
  35351. * LICENSE file in the root directory of this source tree. An additional grant
  35352. * of patent rights can be found in the PATENTS file in the same directory.
  35353. *
  35354. * @providesModule findRangesImmutable
  35355. * @format
  35356. *
  35357. */
  35358. /**
  35359. * Search through an array to find contiguous stretches of elements that
  35360. * match a specified filter function.
  35361. *
  35362. * When ranges are found, execute a specified `found` function to supply
  35363. * the values to the caller.
  35364. */
  35365. function findRangesImmutable(
  35366. haystack,
  35367. areEqualFn,
  35368. filterFn,
  35369. foundFn
  35370. ) {
  35371. if (!haystack.size) {
  35372. return;
  35373. }
  35374. var cursor = 0;
  35375. haystack.reduce(function(value, nextValue, nextIndex) {
  35376. if (!areEqualFn(value, nextValue)) {
  35377. if (filterFn(value)) {
  35378. foundFn(cursor, nextIndex);
  35379. }
  35380. cursor = nextIndex;
  35381. }
  35382. return nextValue;
  35383. });
  35384. filterFn(haystack.last()) && foundFn(cursor, haystack.count());
  35385. }
  35386. module.exports = findRangesImmutable;
  35387. /***/
  35388. },
  35389. /* 21 */
  35390. /***/ function(module, exports, __webpack_require__) {
  35391. var objectWithoutPropertiesLoose = __webpack_require__(25);
  35392. function _objectWithoutProperties(source, excluded) {
  35393. if (source == null) return {};
  35394. var target = objectWithoutPropertiesLoose(source, excluded);
  35395. var key, i;
  35396. if (Object.getOwnPropertySymbols) {
  35397. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  35398. for (i = 0; i < sourceSymbolKeys.length; i++) {
  35399. key = sourceSymbolKeys[i];
  35400. if (excluded.indexOf(key) >= 0) continue;
  35401. if (!Object.prototype.propertyIsEnumerable.call(source, key))
  35402. continue;
  35403. target[key] = source[key];
  35404. }
  35405. }
  35406. return target;
  35407. }
  35408. module.exports = _objectWithoutProperties;
  35409. /***/
  35410. },
  35411. /* 22 */
  35412. /***/ function(module, exports, __webpack_require__) {
  35413. /**
  35414. * Copyright (c) 2013-present, Facebook, Inc.
  35415. * All rights reserved.
  35416. *
  35417. * This source code is licensed under the BSD-style license found in the
  35418. * LICENSE file in the root directory of this source tree. An additional grant
  35419. * of patent rights can be found in the PATENTS file in the same directory.
  35420. *
  35421. * @providesModule getFragmentFromSelection
  35422. * @format
  35423. *
  35424. */
  35425. var getContentStateFragment = __webpack_require__(30);
  35426. function getFragmentFromSelection(editorState) {
  35427. var selectionState = editorState.getSelection();
  35428. if (selectionState.isCollapsed()) {
  35429. return null;
  35430. }
  35431. return getContentStateFragment(
  35432. editorState.getCurrentContent(),
  35433. selectionState
  35434. );
  35435. }
  35436. module.exports = getFragmentFromSelection;
  35437. /***/
  35438. },
  35439. /* 23 */
  35440. /***/ function(module, exports) {
  35441. module.exports = __WEBPACK_EXTERNAL_MODULE__23__;
  35442. /***/
  35443. },
  35444. /* 24 */
  35445. /***/ function(module, exports, __webpack_require__) {
  35446. var arrayWithHoles = __webpack_require__(36);
  35447. var iterableToArrayLimit = __webpack_require__(37);
  35448. var nonIterableRest = __webpack_require__(38);
  35449. function _slicedToArray(arr, i) {
  35450. return (
  35451. arrayWithHoles(arr) ||
  35452. iterableToArrayLimit(arr, i) ||
  35453. nonIterableRest()
  35454. );
  35455. }
  35456. module.exports = _slicedToArray;
  35457. /***/
  35458. },
  35459. /* 25 */
  35460. /***/ function(module, exports) {
  35461. function _objectWithoutPropertiesLoose(source, excluded) {
  35462. if (source == null) return {};
  35463. var target = {};
  35464. var sourceKeys = Object.keys(source);
  35465. var key, i;
  35466. for (i = 0; i < sourceKeys.length; i++) {
  35467. key = sourceKeys[i];
  35468. if (excluded.indexOf(key) >= 0) continue;
  35469. target[key] = source[key];
  35470. }
  35471. return target;
  35472. }
  35473. module.exports = _objectWithoutPropertiesLoose;
  35474. /***/
  35475. },
  35476. /* 26 */
  35477. /***/ function(module, exports) {
  35478. function _setPrototypeOf(o, p) {
  35479. module.exports = _setPrototypeOf =
  35480. Object.setPrototypeOf ||
  35481. function _setPrototypeOf(o, p) {
  35482. o.__proto__ = p;
  35483. return o;
  35484. };
  35485. return _setPrototypeOf(o, p);
  35486. }
  35487. module.exports = _setPrototypeOf;
  35488. /***/
  35489. },
  35490. /* 27 */
  35491. /***/ function(module, exports) {
  35492. function _arrayWithoutHoles(arr) {
  35493. if (Array.isArray(arr)) {
  35494. for (
  35495. var i = 0, arr2 = new Array(arr.length);
  35496. i < arr.length;
  35497. i++
  35498. ) {
  35499. arr2[i] = arr[i];
  35500. }
  35501. return arr2;
  35502. }
  35503. }
  35504. module.exports = _arrayWithoutHoles;
  35505. /***/
  35506. },
  35507. /* 28 */
  35508. /***/ function(module, exports) {
  35509. function _iterableToArray(iter) {
  35510. if (
  35511. Symbol.iterator in Object(iter) ||
  35512. Object.prototype.toString.call(iter) === "[object Arguments]"
  35513. )
  35514. return Array.from(iter);
  35515. }
  35516. module.exports = _iterableToArray;
  35517. /***/
  35518. },
  35519. /* 29 */
  35520. /***/ function(module, exports) {
  35521. function _nonIterableSpread() {
  35522. throw new TypeError(
  35523. "Invalid attempt to spread non-iterable instance"
  35524. );
  35525. }
  35526. module.exports = _nonIterableSpread;
  35527. /***/
  35528. },
  35529. /* 30 */
  35530. /***/ function(module, exports, __webpack_require__) {
  35531. /**
  35532. * Copyright (c) 2013-present, Facebook, Inc.
  35533. * All rights reserved.
  35534. *
  35535. * This source code is licensed under the BSD-style license found in the
  35536. * LICENSE file in the root directory of this source tree. An additional grant
  35537. * of patent rights can be found in the PATENTS file in the same directory.
  35538. *
  35539. * @providesModule getContentStateFragment
  35540. * @format
  35541. *
  35542. */
  35543. var randomizeBlockMapKeys = __webpack_require__(31);
  35544. var removeEntitiesAtEdges = __webpack_require__(34);
  35545. var getContentStateFragment = function getContentStateFragment(
  35546. contentState,
  35547. selectionState
  35548. ) {
  35549. var startKey = selectionState.getStartKey();
  35550. var startOffset = selectionState.getStartOffset();
  35551. var endKey = selectionState.getEndKey();
  35552. var endOffset = selectionState.getEndOffset();
  35553. // Edge entities should be stripped to ensure that we don't preserve
  35554. // invalid partial entities when the fragment is reused. We do, however,
  35555. // preserve entities that are entirely within the selection range.
  35556. var contentWithoutEdgeEntities = removeEntitiesAtEdges(
  35557. contentState,
  35558. selectionState
  35559. );
  35560. var blockMap = contentWithoutEdgeEntities.getBlockMap();
  35561. var blockKeys = blockMap.keySeq();
  35562. var startIndex = blockKeys.indexOf(startKey);
  35563. var endIndex = blockKeys.indexOf(endKey) + 1;
  35564. return randomizeBlockMapKeys(
  35565. blockMap
  35566. .slice(startIndex, endIndex)
  35567. .map(function(block, blockKey) {
  35568. var text = block.getText();
  35569. var chars = block.getCharacterList();
  35570. if (startKey === endKey) {
  35571. return block.merge({
  35572. text: text.slice(startOffset, endOffset),
  35573. characterList: chars.slice(startOffset, endOffset)
  35574. });
  35575. }
  35576. if (blockKey === startKey) {
  35577. return block.merge({
  35578. text: text.slice(startOffset),
  35579. characterList: chars.slice(startOffset)
  35580. });
  35581. }
  35582. if (blockKey === endKey) {
  35583. return block.merge({
  35584. text: text.slice(0, endOffset),
  35585. characterList: chars.slice(0, endOffset)
  35586. });
  35587. }
  35588. return block;
  35589. })
  35590. );
  35591. };
  35592. module.exports = getContentStateFragment;
  35593. /***/
  35594. },
  35595. /* 31 */
  35596. /***/ function(module, exports, __webpack_require__) {
  35597. /**
  35598. * Copyright (c) 2013-present, Facebook, Inc.
  35599. * All rights reserved.
  35600. *
  35601. * This source code is licensed under the BSD-style license found in the
  35602. * LICENSE file in the root directory of this source tree. An additional grant
  35603. * of patent rights can be found in the PATENTS file in the same directory.
  35604. *
  35605. * @providesModule randomizeBlockMapKeys
  35606. * @format
  35607. *
  35608. */
  35609. var ContentBlockNode = __webpack_require__(32);
  35610. var Immutable = __webpack_require__(13);
  35611. var generateRandomKey = __webpack_require__(33);
  35612. var OrderedMap = Immutable.OrderedMap;
  35613. var randomizeContentBlockNodeKeys = function randomizeContentBlockNodeKeys(
  35614. blockMap
  35615. ) {
  35616. var newKeysRef = {};
  35617. // we keep track of root blocks in order to update subsequent sibling links
  35618. var lastRootBlock = void 0;
  35619. return OrderedMap(
  35620. blockMap
  35621. .withMutations(function(blockMapState) {
  35622. blockMapState.forEach(function(block, index) {
  35623. var oldKey = block.getKey();
  35624. var nextKey = block.getNextSiblingKey();
  35625. var prevKey = block.getPrevSiblingKey();
  35626. var childrenKeys = block.getChildKeys();
  35627. var parentKey = block.getParentKey();
  35628. // new key that we will use to build linking
  35629. var key = generateRandomKey();
  35630. // we will add it here to re-use it later
  35631. newKeysRef[oldKey] = key;
  35632. if (nextKey) {
  35633. var nextBlock = blockMapState.get(nextKey);
  35634. if (nextBlock) {
  35635. blockMapState.setIn([nextKey, "prevSibling"], key);
  35636. } else {
  35637. // this can happen when generating random keys for fragments
  35638. blockMapState.setIn([oldKey, "nextSibling"], null);
  35639. }
  35640. }
  35641. if (prevKey) {
  35642. var prevBlock = blockMapState.get(prevKey);
  35643. if (prevBlock) {
  35644. blockMapState.setIn([prevKey, "nextSibling"], key);
  35645. } else {
  35646. // this can happen when generating random keys for fragments
  35647. blockMapState.setIn([oldKey, "prevSibling"], null);
  35648. }
  35649. }
  35650. if (parentKey && blockMapState.get(parentKey)) {
  35651. var parentBlock = blockMapState.get(parentKey);
  35652. var parentChildrenList = parentBlock.getChildKeys();
  35653. blockMapState.setIn(
  35654. [parentKey, "children"],
  35655. parentChildrenList.set(
  35656. parentChildrenList.indexOf(block.getKey()),
  35657. key
  35658. )
  35659. );
  35660. } else {
  35661. // blocks will then be treated as root block nodes
  35662. blockMapState.setIn([oldKey, "parent"], null);
  35663. if (lastRootBlock) {
  35664. blockMapState.setIn(
  35665. [lastRootBlock.getKey(), "nextSibling"],
  35666. key
  35667. );
  35668. blockMapState.setIn(
  35669. [oldKey, "prevSibling"],
  35670. newKeysRef[lastRootBlock.getKey()]
  35671. );
  35672. }
  35673. lastRootBlock = blockMapState.get(oldKey);
  35674. }
  35675. childrenKeys.forEach(function(childKey) {
  35676. var childBlock = blockMapState.get(childKey);
  35677. if (childBlock) {
  35678. blockMapState.setIn([childKey, "parent"], key);
  35679. } else {
  35680. blockMapState.setIn(
  35681. [oldKey, "children"],
  35682. block.getChildKeys().filter(function(child) {
  35683. return child !== childKey;
  35684. })
  35685. );
  35686. }
  35687. });
  35688. });
  35689. })
  35690. .toArray()
  35691. .map(function(block) {
  35692. return [
  35693. newKeysRef[block.getKey()],
  35694. block.set("key", newKeysRef[block.getKey()])
  35695. ];
  35696. })
  35697. );
  35698. };
  35699. var randomizeContentBlockKeys = function randomizeContentBlockKeys(
  35700. blockMap
  35701. ) {
  35702. return OrderedMap(
  35703. blockMap.toArray().map(function(block) {
  35704. var key = generateRandomKey();
  35705. return [key, block.set("key", key)];
  35706. })
  35707. );
  35708. };
  35709. var randomizeBlockMapKeys = function randomizeBlockMapKeys(blockMap) {
  35710. var isTreeBasedBlockMap =
  35711. blockMap.first() instanceof ContentBlockNode;
  35712. if (!isTreeBasedBlockMap) {
  35713. return randomizeContentBlockKeys(blockMap);
  35714. }
  35715. return randomizeContentBlockNodeKeys(blockMap);
  35716. };
  35717. module.exports = randomizeBlockMapKeys;
  35718. /***/
  35719. },
  35720. /* 32 */
  35721. /***/ function(module, exports, __webpack_require__) {
  35722. /**
  35723. * Copyright (c) 2013-present, Facebook, Inc.
  35724. * All rights reserved.
  35725. *
  35726. * This source code is licensed under the BSD-style license found in the
  35727. * LICENSE file in the root directory of this source tree. An additional grant
  35728. * of patent rights can be found in the PATENTS file in the same directory.
  35729. *
  35730. * @providesModule ContentBlockNode
  35731. * @format
  35732. *
  35733. *
  35734. * This file is a fork of ContentBlock adding support for nesting references by
  35735. * providing links to children, parent, prevSibling, and nextSibling.
  35736. *
  35737. * This is unstable and not part of the public API and should not be used by
  35738. * production systems. This file may be update/removed without notice.
  35739. */
  35740. function _classCallCheck(instance, Constructor) {
  35741. if (!(instance instanceof Constructor)) {
  35742. throw new TypeError("Cannot call a class as a function");
  35743. }
  35744. }
  35745. function _possibleConstructorReturn(self, call) {
  35746. if (!self) {
  35747. throw new ReferenceError(
  35748. "this hasn't been initialised - super() hasn't been called"
  35749. );
  35750. }
  35751. return call &&
  35752. (typeof call === "object" || typeof call === "function")
  35753. ? call
  35754. : self;
  35755. }
  35756. function _inherits(subClass, superClass) {
  35757. if (typeof superClass !== "function" && superClass !== null) {
  35758. throw new TypeError(
  35759. "Super expression must either be null or a function, not " +
  35760. typeof superClass
  35761. );
  35762. }
  35763. subClass.prototype = Object.create(
  35764. superClass && superClass.prototype,
  35765. {
  35766. constructor: {
  35767. value: subClass,
  35768. enumerable: false,
  35769. writable: true,
  35770. configurable: true
  35771. }
  35772. }
  35773. );
  35774. if (superClass)
  35775. Object.setPrototypeOf
  35776. ? Object.setPrototypeOf(subClass, superClass)
  35777. : (subClass.__proto__ = superClass);
  35778. }
  35779. var CharacterMetadata = __webpack_require__(19);
  35780. var Immutable = __webpack_require__(13);
  35781. var findRangesImmutable = __webpack_require__(20);
  35782. var List = Immutable.List,
  35783. Map = Immutable.Map,
  35784. OrderedSet = Immutable.OrderedSet,
  35785. Record = Immutable.Record,
  35786. Repeat = Immutable.Repeat;
  35787. var EMPTY_SET = OrderedSet();
  35788. var defaultRecord = {
  35789. parent: null,
  35790. characterList: List(),
  35791. data: Map(),
  35792. depth: 0,
  35793. key: "",
  35794. text: "",
  35795. type: "unstyled",
  35796. children: List(),
  35797. prevSibling: null,
  35798. nextSibling: null
  35799. };
  35800. var haveEqualStyle = function haveEqualStyle(charA, charB) {
  35801. return charA.getStyle() === charB.getStyle();
  35802. };
  35803. var haveEqualEntity = function haveEqualEntity(charA, charB) {
  35804. return charA.getEntity() === charB.getEntity();
  35805. };
  35806. var decorateCharacterList = function decorateCharacterList(config) {
  35807. if (!config) {
  35808. return config;
  35809. }
  35810. var characterList = config.characterList,
  35811. text = config.text;
  35812. if (text && !characterList) {
  35813. config.characterList = List(
  35814. Repeat(CharacterMetadata.EMPTY, text.length)
  35815. );
  35816. }
  35817. return config;
  35818. };
  35819. var ContentBlockNode = (function(_Record) {
  35820. _inherits(ContentBlockNode, _Record);
  35821. function ContentBlockNode() {
  35822. var props =
  35823. arguments.length > 0 && arguments[0] !== undefined
  35824. ? arguments[0]
  35825. : defaultRecord;
  35826. _classCallCheck(this, ContentBlockNode);
  35827. return _possibleConstructorReturn(
  35828. this,
  35829. _Record.call(this, decorateCharacterList(props))
  35830. );
  35831. }
  35832. ContentBlockNode.prototype.getKey = function getKey() {
  35833. return this.get("key");
  35834. };
  35835. ContentBlockNode.prototype.getType = function getType() {
  35836. return this.get("type");
  35837. };
  35838. ContentBlockNode.prototype.getText = function getText() {
  35839. return this.get("text");
  35840. };
  35841. ContentBlockNode.prototype.getCharacterList = function getCharacterList() {
  35842. return this.get("characterList");
  35843. };
  35844. ContentBlockNode.prototype.getLength = function getLength() {
  35845. return this.getText().length;
  35846. };
  35847. ContentBlockNode.prototype.getDepth = function getDepth() {
  35848. return this.get("depth");
  35849. };
  35850. ContentBlockNode.prototype.getData = function getData() {
  35851. return this.get("data");
  35852. };
  35853. ContentBlockNode.prototype.getInlineStyleAt = function getInlineStyleAt(
  35854. offset
  35855. ) {
  35856. var character = this.getCharacterList().get(offset);
  35857. return character ? character.getStyle() : EMPTY_SET;
  35858. };
  35859. ContentBlockNode.prototype.getEntityAt = function getEntityAt(
  35860. offset
  35861. ) {
  35862. var character = this.getCharacterList().get(offset);
  35863. return character ? character.getEntity() : null;
  35864. };
  35865. ContentBlockNode.prototype.getChildKeys = function getChildKeys() {
  35866. return this.get("children");
  35867. };
  35868. ContentBlockNode.prototype.getParentKey = function getParentKey() {
  35869. return this.get("parent");
  35870. };
  35871. ContentBlockNode.prototype.getPrevSiblingKey = function getPrevSiblingKey() {
  35872. return this.get("prevSibling");
  35873. };
  35874. ContentBlockNode.prototype.getNextSiblingKey = function getNextSiblingKey() {
  35875. return this.get("nextSibling");
  35876. };
  35877. ContentBlockNode.prototype.findStyleRanges = function findStyleRanges(
  35878. filterFn,
  35879. callback
  35880. ) {
  35881. findRangesImmutable(
  35882. this.getCharacterList(),
  35883. haveEqualStyle,
  35884. filterFn,
  35885. callback
  35886. );
  35887. };
  35888. ContentBlockNode.prototype.findEntityRanges = function findEntityRanges(
  35889. filterFn,
  35890. callback
  35891. ) {
  35892. findRangesImmutable(
  35893. this.getCharacterList(),
  35894. haveEqualEntity,
  35895. filterFn,
  35896. callback
  35897. );
  35898. };
  35899. return ContentBlockNode;
  35900. })(Record(defaultRecord));
  35901. module.exports = ContentBlockNode;
  35902. /***/
  35903. },
  35904. /* 33 */
  35905. /***/ function(module, exports, __webpack_require__) {
  35906. /**
  35907. * Copyright (c) 2013-present, Facebook, Inc.
  35908. * All rights reserved.
  35909. *
  35910. * This source code is licensed under the BSD-style license found in the
  35911. * LICENSE file in the root directory of this source tree. An additional grant
  35912. * of patent rights can be found in the PATENTS file in the same directory.
  35913. *
  35914. * @providesModule generateRandomKey
  35915. * @format
  35916. *
  35917. */
  35918. var seenKeys = {};
  35919. var MULTIPLIER = Math.pow(2, 24);
  35920. function generateRandomKey() {
  35921. var key = void 0;
  35922. while (
  35923. key === undefined ||
  35924. seenKeys.hasOwnProperty(key) ||
  35925. !isNaN(+key)
  35926. ) {
  35927. key = Math.floor(Math.random() * MULTIPLIER).toString(32);
  35928. }
  35929. seenKeys[key] = true;
  35930. return key;
  35931. }
  35932. module.exports = generateRandomKey;
  35933. /***/
  35934. },
  35935. /* 34 */
  35936. /***/ function(module, exports, __webpack_require__) {
  35937. /**
  35938. * Copyright (c) 2013-present, Facebook, Inc.
  35939. * All rights reserved.
  35940. *
  35941. * This source code is licensed under the BSD-style license found in the
  35942. * LICENSE file in the root directory of this source tree. An additional grant
  35943. * of patent rights can be found in the PATENTS file in the same directory.
  35944. *
  35945. * @providesModule removeEntitiesAtEdges
  35946. * @format
  35947. *
  35948. */
  35949. var CharacterMetadata = __webpack_require__(19);
  35950. var findRangesImmutable = __webpack_require__(20);
  35951. var invariant = __webpack_require__(35);
  35952. function removeEntitiesAtEdges(contentState, selectionState) {
  35953. var blockMap = contentState.getBlockMap();
  35954. var entityMap = contentState.getEntityMap();
  35955. var updatedBlocks = {};
  35956. var startKey = selectionState.getStartKey();
  35957. var startOffset = selectionState.getStartOffset();
  35958. var startBlock = blockMap.get(startKey);
  35959. var updatedStart = removeForBlock(
  35960. entityMap,
  35961. startBlock,
  35962. startOffset
  35963. );
  35964. if (updatedStart !== startBlock) {
  35965. updatedBlocks[startKey] = updatedStart;
  35966. }
  35967. var endKey = selectionState.getEndKey();
  35968. var endOffset = selectionState.getEndOffset();
  35969. var endBlock = blockMap.get(endKey);
  35970. if (startKey === endKey) {
  35971. endBlock = updatedStart;
  35972. }
  35973. var updatedEnd = removeForBlock(entityMap, endBlock, endOffset);
  35974. if (updatedEnd !== endBlock) {
  35975. updatedBlocks[endKey] = updatedEnd;
  35976. }
  35977. if (!Object.keys(updatedBlocks).length) {
  35978. return contentState.set("selectionAfter", selectionState);
  35979. }
  35980. return contentState.merge({
  35981. blockMap: blockMap.merge(updatedBlocks),
  35982. selectionAfter: selectionState
  35983. });
  35984. }
  35985. function getRemovalRange(characters, key, offset) {
  35986. var removalRange;
  35987. findRangesImmutable(
  35988. characters,
  35989. function(a, b) {
  35990. return a.getEntity() === b.getEntity();
  35991. },
  35992. function(element) {
  35993. return element.getEntity() === key;
  35994. },
  35995. function(start, end) {
  35996. if (start <= offset && end >= offset) {
  35997. removalRange = { start: start, end: end };
  35998. }
  35999. }
  36000. );
  36001. !(typeof removalRange === "object") ? invariant(false) : void 0;
  36002. return removalRange;
  36003. }
  36004. function removeForBlock(entityMap, block, offset) {
  36005. var chars = block.getCharacterList();
  36006. var charBefore = offset > 0 ? chars.get(offset - 1) : undefined;
  36007. var charAfter =
  36008. offset < chars.count() ? chars.get(offset) : undefined;
  36009. var entityBeforeCursor = charBefore
  36010. ? charBefore.getEntity()
  36011. : undefined;
  36012. var entityAfterCursor = charAfter
  36013. ? charAfter.getEntity()
  36014. : undefined;
  36015. if (entityAfterCursor && entityAfterCursor === entityBeforeCursor) {
  36016. var entity = entityMap.__get(entityAfterCursor);
  36017. if (entity.getMutability() !== "MUTABLE") {
  36018. var _getRemovalRange = getRemovalRange(
  36019. chars,
  36020. entityAfterCursor,
  36021. offset
  36022. ),
  36023. start = _getRemovalRange.start,
  36024. end = _getRemovalRange.end;
  36025. var current;
  36026. while (start < end) {
  36027. current = chars.get(start);
  36028. chars = chars.set(
  36029. start,
  36030. CharacterMetadata.applyEntity(current, null)
  36031. );
  36032. start++;
  36033. }
  36034. return block.set("characterList", chars);
  36035. }
  36036. }
  36037. return block;
  36038. }
  36039. module.exports = removeEntitiesAtEdges;
  36040. /***/
  36041. },
  36042. /* 35 */
  36043. /***/ function(module, exports, __webpack_require__) {
  36044. function invariant(condition, format, a, b, c, d, e, f) {
  36045. if (!condition) {
  36046. var error;
  36047. if (format === undefined) {
  36048. error = new Error(
  36049. "Minified exception occurred; use the non-minified dev environment " +
  36050. "for the full error message and additional helpful warnings."
  36051. );
  36052. } else {
  36053. var args = [a, b, c, d, e, f];
  36054. var argIndex = 0;
  36055. error = new Error(
  36056. format.replace(/%s/g, function() {
  36057. return args[argIndex++];
  36058. })
  36059. );
  36060. error.name = "Invariant Violation";
  36061. }
  36062. error.framesToPop = 1; // we don't care about invariant's own frame
  36063. throw error;
  36064. }
  36065. }
  36066. module.exports = invariant;
  36067. /***/
  36068. },
  36069. /* 36 */
  36070. /***/ function(module, exports) {
  36071. function _arrayWithHoles(arr) {
  36072. if (Array.isArray(arr)) return arr;
  36073. }
  36074. module.exports = _arrayWithHoles;
  36075. /***/
  36076. },
  36077. /* 37 */
  36078. /***/ function(module, exports) {
  36079. function _iterableToArrayLimit(arr, i) {
  36080. var _arr = [];
  36081. var _n = true;
  36082. var _d = false;
  36083. var _e = undefined;
  36084. try {
  36085. for (
  36086. var _i = arr[Symbol.iterator](), _s;
  36087. !(_n = (_s = _i.next()).done);
  36088. _n = true
  36089. ) {
  36090. _arr.push(_s.value);
  36091. if (i && _arr.length === i) break;
  36092. }
  36093. } catch (err) {
  36094. _d = true;
  36095. _e = err;
  36096. } finally {
  36097. try {
  36098. if (!_n && _i["return"] != null) _i["return"]();
  36099. } finally {
  36100. if (_d) throw _e;
  36101. }
  36102. }
  36103. return _arr;
  36104. }
  36105. module.exports = _iterableToArrayLimit;
  36106. /***/
  36107. },
  36108. /* 38 */
  36109. /***/ function(module, exports) {
  36110. function _nonIterableRest() {
  36111. throw new TypeError(
  36112. "Invalid attempt to destructure non-iterable instance"
  36113. );
  36114. }
  36115. module.exports = _nonIterableRest;
  36116. /***/
  36117. },
  36118. /* 39 */
  36119. /***/ function(module, __webpack_exports__, __webpack_require__) {
  36120. __webpack_require__.r(__webpack_exports__);
  36121. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/typeof.js
  36122. var helpers_typeof = __webpack_require__(15);
  36123. var typeof_default = /*#__PURE__*/ __webpack_require__.n(
  36124. helpers_typeof
  36125. );
  36126. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/objectSpread.js
  36127. var objectSpread = __webpack_require__(5);
  36128. var objectSpread_default = /*#__PURE__*/ __webpack_require__.n(
  36129. objectSpread
  36130. );
  36131. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/objectWithoutProperties.js
  36132. var objectWithoutProperties = __webpack_require__(21);
  36133. var objectWithoutProperties_default = /*#__PURE__*/ __webpack_require__.n(
  36134. objectWithoutProperties
  36135. );
  36136. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/classCallCheck.js
  36137. var classCallCheck = __webpack_require__(4);
  36138. var classCallCheck_default = /*#__PURE__*/ __webpack_require__.n(
  36139. classCallCheck
  36140. );
  36141. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/createClass.js
  36142. var createClass = __webpack_require__(7);
  36143. var createClass_default = /*#__PURE__*/ __webpack_require__.n(
  36144. createClass
  36145. );
  36146. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js
  36147. var possibleConstructorReturn = __webpack_require__(8);
  36148. var possibleConstructorReturn_default = /*#__PURE__*/ __webpack_require__.n(
  36149. possibleConstructorReturn
  36150. );
  36151. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/getPrototypeOf.js
  36152. var getPrototypeOf = __webpack_require__(9);
  36153. var getPrototypeOf_default = /*#__PURE__*/ __webpack_require__.n(
  36154. getPrototypeOf
  36155. );
  36156. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/inherits.js
  36157. var inherits = __webpack_require__(10);
  36158. var inherits_default = /*#__PURE__*/ __webpack_require__.n(inherits);
  36159. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/assertThisInitialized.js
  36160. var assertThisInitialized = __webpack_require__(1);
  36161. var assertThisInitialized_default = /*#__PURE__*/ __webpack_require__.n(
  36162. assertThisInitialized
  36163. );
  36164. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/defineProperty.js
  36165. var defineProperty = __webpack_require__(2);
  36166. var defineProperty_default = /*#__PURE__*/ __webpack_require__.n(
  36167. defineProperty
  36168. );
  36169. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/toConsumableArray.js
  36170. var toConsumableArray = __webpack_require__(12);
  36171. var toConsumableArray_default = /*#__PURE__*/ __webpack_require__.n(
  36172. toConsumableArray
  36173. );
  36174. // EXTERNAL MODULE: ../node_modules/draft-js/dist/Draft.css
  36175. var Draft = __webpack_require__(40);
  36176. // EXTERNAL MODULE: ./assets/scss/_base.scss
  36177. var _base = __webpack_require__(42);
  36178. // EXTERNAL MODULE: external "react"
  36179. var external_react_ = __webpack_require__(0);
  36180. var external_react_default = /*#__PURE__*/ __webpack_require__.n(
  36181. external_react_
  36182. );
  36183. // CONCATENATED MODULE: ./languages/en.js
  36184. /* harmony default export */ var en = {
  36185. base: {
  36186. remove: "Remove",
  36187. cancel: "Cancel",
  36188. confirm: "Confirm",
  36189. inert: "Insert",
  36190. width: "Width",
  36191. height: "Height"
  36192. },
  36193. controls: {
  36194. clear: "Clear",
  36195. undo: "Undo",
  36196. redo: "Redo",
  36197. fontSize: "Font Size",
  36198. color: "Color",
  36199. textColor: "Text",
  36200. tempColors: "Temp Colors",
  36201. backgroundColor: "Background",
  36202. bold: "Bold",
  36203. lineHeight: "Line Height",
  36204. letterSpacing: "Letter Spacing",
  36205. textIndent: "Text Indent",
  36206. increaseIndent: "Increase Indent",
  36207. decreaseIndent: "Decrease Indent",
  36208. italic: "Italic",
  36209. underline: "Underline",
  36210. strikeThrough: "Strike Through",
  36211. fontFamily: "Font Family",
  36212. textAlign: "Text Alignment",
  36213. alignLeft: "Left Alignment",
  36214. alignCenter: "Center Alignment",
  36215. alignRight: "Right Alignment",
  36216. alignJustify: "Justify Alignment",
  36217. floatLeft: "Left Float",
  36218. floatRight: "Right Float",
  36219. superScript: "Super Script",
  36220. subScript: "Sub Script",
  36221. removeStyles: "Remove Styles",
  36222. headings: "Headings",
  36223. header: "Header",
  36224. normal: "Normal",
  36225. orderedList: "Ordered List",
  36226. unorderedList: "Unordered List",
  36227. blockQuote: "Quote",
  36228. code: "Code",
  36229. link: "Link",
  36230. unlink: "Unlink",
  36231. hr: "Horizontal Line",
  36232. media: "Media",
  36233. mediaLibirary: "Media Library",
  36234. emoji: "Emoji",
  36235. fullscreen: "Fullscreen",
  36236. exitFullscreen: "Exit Fullscreen"
  36237. },
  36238. linkEditor: {
  36239. textInputPlaceHolder: "Input link text",
  36240. linkInputPlaceHolder: "Input link URL",
  36241. inputWithEnterPlaceHolder: "Input link URL and press Enter",
  36242. openInNewWindow: "Open in new window",
  36243. removeLink: "Remove Link"
  36244. },
  36245. audioPlayer: {
  36246. title: "Play Audio"
  36247. },
  36248. videoPlayer: {
  36249. title: "Play Video",
  36250. embedTitle: "Embed Media"
  36251. },
  36252. media: {
  36253. image: "Image",
  36254. video: "Video",
  36255. audio: "Audio",
  36256. embed: "Embed"
  36257. }
  36258. };
  36259. // CONCATENATED MODULE: ./languages/zh.js
  36260. /* harmony default export */ var zh = {
  36261. base: {
  36262. remove: "删除",
  36263. cancel: "取消",
  36264. confirm: "确定",
  36265. inert: "插入",
  36266. width: "宽度",
  36267. height: "高度"
  36268. },
  36269. controls: {
  36270. clear: "清除内容",
  36271. undo: "撤销",
  36272. redo: "重做",
  36273. fontSize: "字号",
  36274. lineHeight: "行高",
  36275. letterSpacing: "字间距",
  36276. textIndent: "段落缩进",
  36277. increaseIndent: "增加缩进",
  36278. decreaseIndent: "减少缩进",
  36279. border: "边框",
  36280. color: "颜色",
  36281. textColor: "文字颜色",
  36282. backgroundColor: "背景颜色",
  36283. tempColors: "临时颜色",
  36284. bold: "加粗",
  36285. italic: "斜体",
  36286. underline: "下划线",
  36287. strikeThrough: "删除线",
  36288. fontFamily: "字体",
  36289. textAlign: "文本对齐",
  36290. alignLeft: "居左",
  36291. alignCenter: "居中",
  36292. alignRight: "居右",
  36293. alignJustify: "两端",
  36294. floatLeft: "左浮动",
  36295. floatRight: "右浮动",
  36296. superScript: "上标",
  36297. subScript: "下标",
  36298. removeStyles: "清除样式",
  36299. headings: "标题",
  36300. header: "标题",
  36301. normal: "常规",
  36302. orderedList: "有序列表",
  36303. unorderedList: "无序列表",
  36304. blockQuote: "引用",
  36305. code: "代码",
  36306. link: "链接",
  36307. unlink: "清除链接",
  36308. hr: "水平线",
  36309. media: "媒体",
  36310. mediaLibirary: "媒体库",
  36311. emoji: "小表情",
  36312. fullscreen: "全屏",
  36313. exitFullscreen: "退出全屏"
  36314. },
  36315. linkEditor: {
  36316. textInputPlaceHolder: "输入链接文字",
  36317. linkInputPlaceHolder: "输入链接地址",
  36318. inputWithEnterPlaceHolder: "输入链接地址并回车",
  36319. openInNewWindow: "在新窗口打开",
  36320. removeLink: "移除链接"
  36321. },
  36322. audioPlayer: {
  36323. title: "播放音频文件"
  36324. },
  36325. videoPlayer: {
  36326. title: "播放视频文件",
  36327. embedTitle: "嵌入式媒体"
  36328. },
  36329. media: {
  36330. image: "图像",
  36331. video: "视频",
  36332. audio: "音频",
  36333. embed: "嵌入式媒体"
  36334. }
  36335. };
  36336. // CONCATENATED MODULE: ./languages/zh-hant.js
  36337. /* harmony default export */ var zh_hant = {
  36338. base: {
  36339. remove: "刪除",
  36340. cancel: "取消",
  36341. confirm: "確定",
  36342. inert: "插入",
  36343. width: "宽度",
  36344. height: "高度"
  36345. },
  36346. controls: {
  36347. clear: "清除内容",
  36348. undo: "撤銷",
  36349. redo: "重做",
  36350. fontSize: "字號",
  36351. color: "顏色",
  36352. textColor: "文字顏色",
  36353. backgroundColor: "背景顏色",
  36354. tempColors: "臨時顏色",
  36355. bold: "加粗",
  36356. lineHeight: "行高",
  36357. letterSpacing: "字間距",
  36358. textIndent: "段落縮進",
  36359. increaseIndent: "增加縮進",
  36360. decreaseIndent: "减少縮進",
  36361. border: "邊框",
  36362. italic: "斜體",
  36363. underline: "下劃線",
  36364. strikeThrough: "刪除線",
  36365. fontFamily: "字體",
  36366. textAlign: "文本對齊",
  36367. alignLeft: "居左",
  36368. alignCenter: "居中",
  36369. alignRight: "居右",
  36370. alignJustify: "兩端對齊",
  36371. floatLeft: "左浮動",
  36372. floatRight: "右浮動",
  36373. superScript: "上標",
  36374. subScript: "下標",
  36375. removeStyles: "清除样式",
  36376. headings: "標題",
  36377. header: "標題",
  36378. normal: "常規",
  36379. orderedList: "有序列表",
  36380. unorderedList: "無序列表",
  36381. blockQuote: "引用",
  36382. code: "代碼",
  36383. link: "鏈接",
  36384. unlink: "清除鏈接",
  36385. hr: "水平线",
  36386. media: "媒體",
  36387. mediaLibirary: "媒體库",
  36388. emoji: "小表情",
  36389. fullscreen: "全熒幕",
  36390. exitFullscreen: "退出全熒幕"
  36391. },
  36392. linkEditor: {
  36393. textInputPlaceHolder: "輸入鏈接文字",
  36394. linkInputPlaceHolder: "輸入鏈接地址",
  36395. inputWithEnterPlaceHolder: "輸入鏈接地址並回車",
  36396. openInNewWindow: "在新窗口打開",
  36397. removeLink: "移除鏈接"
  36398. },
  36399. audioPlayer: {
  36400. title: "播放音頻文件"
  36401. },
  36402. videoPlayer: {
  36403. title: "播放視頻文件",
  36404. embedTitle: "嵌入式媒體"
  36405. },
  36406. media: {
  36407. image: "圖像",
  36408. video: "視頻",
  36409. audio: "音頻",
  36410. embed: "嵌入式媒體"
  36411. }
  36412. };
  36413. // CONCATENATED MODULE: ./languages/pl.js
  36414. /* harmony default export */ var pl = {
  36415. base: {
  36416. remove: "Usuń",
  36417. cancel: "Anuluj",
  36418. confirm: "Potwierdź",
  36419. inert: "Wstaw",
  36420. width: "Szerokość",
  36421. height: "Wysokość"
  36422. },
  36423. controls: {
  36424. clear: "Wyczyść",
  36425. undo: "Cofnij",
  36426. redo: "Przywróć",
  36427. fontSize: "Wielkość",
  36428. color: "Kolor",
  36429. textColor: "Kolor tekstu",
  36430. tempColors: "Kolory",
  36431. backgroundColor: "Tło",
  36432. bold: "Pogrubienie",
  36433. lineHeight: "Wysokość linii",
  36434. letterSpacing: "Odstęp znaków",
  36435. textIndent: "Wcięcie tekstu",
  36436. increaseIndent: "Zwiększ wcięcie",
  36437. decreaseIndent: "Zmniejsz wcięcie",
  36438. italic: "Italiki",
  36439. underline: "Podkreślenie",
  36440. strikeThrough: "Przekreślenie",
  36441. fontFamily: "Czcionka",
  36442. textAlign: "Wyrównanie tekstu",
  36443. alignLeft: "Do lewej",
  36444. alignCenter: "Wycentruj",
  36445. alignRight: "Do prawej",
  36446. alignJustify: "Wyjustuj",
  36447. floatLeft: "Do lewej",
  36448. floatRight: "Do prawej",
  36449. superScript: "Superskrypt",
  36450. subScript: "Subskrypt",
  36451. removeStyles: "Usuń stylowanie",
  36452. headings: "Nagłówki",
  36453. header: "Nagłówek",
  36454. normal: "Normalny",
  36455. orderedList: "Lista uporządkowana",
  36456. unorderedList: "Lista nieuporządkowana",
  36457. blockQuote: "Cytat",
  36458. code: "Kod",
  36459. link: "Link",
  36460. unlink: "Usuń link",
  36461. hr: "Linia pozioma",
  36462. media: "Media",
  36463. mediaLibirary: "Biblioteka mediów",
  36464. emoji: "Emoji"
  36465. },
  36466. linkEditor: {
  36467. textInputPlaceHolder: "Wpisz tekst linku",
  36468. linkInputPlaceHolder: "Wpisz Adres URL",
  36469. inputWithEnterPlaceHolder: "Wpisz adres URL i naciśnij Enter",
  36470. openInNewWindow: "Otwórz w nowym oknie",
  36471. removeLink: "Usuń link"
  36472. },
  36473. audioPlayer: {
  36474. title: "Odtwórz audio"
  36475. },
  36476. videoPlayer: {
  36477. title: "Odtwórz wideo",
  36478. embedTitle: "Tytuł"
  36479. },
  36480. media: {
  36481. image: "Obraz",
  36482. video: "Wideo",
  36483. audio: "Audio",
  36484. embed: "Obiekt osadzony"
  36485. }
  36486. };
  36487. // CONCATENATED MODULE: ./languages/kr.js
  36488. /* harmony default export */ var kr = {
  36489. base: {
  36490. remove: "삭제",
  36491. cancel: "취소",
  36492. confirm: "결정",
  36493. inert: "삽입",
  36494. width: "너비",
  36495. height: "높이"
  36496. },
  36497. controls: {
  36498. clear: "콘텐츠지우기",
  36499. undo: "취소",
  36500. redo: "다시하기",
  36501. fontSize: "글자크기",
  36502. lineHeight: "행높이",
  36503. letterSpacing: "단어간격",
  36504. textIndent: "단락들여쓰기",
  36505. increaseIndent: "들여쓰기늘리기",
  36506. decreaseIndent: "들여쓰기줄이기",
  36507. border: "국경",
  36508. color: "색상",
  36509. textColor: "텍스트색상",
  36510. backgroundColor: "배경색상",
  36511. tempColors: "임시색",
  36512. bold: "굵게",
  36513. italic: "기울임꼴",
  36514. underline: "밑줄",
  36515. strikeThrough: "취소선",
  36516. fontFamily: "글꼴",
  36517. textAlign: "텍스트정렬",
  36518. alignLeft: "왼쪽",
  36519. alignCenter: "중심",
  36520. alignRight: "오른쪽",
  36521. alignJustify: "양쪽끝",
  36522. floatLeft: "떠다니기",
  36523. floatRight: "오른쪽부동",
  36524. superScript: "위첨자",
  36525. subScript: "첨자",
  36526. removeStyles: "스타일지우기",
  36527. headings: "제목",
  36528. header: "제목",
  36529. normal: "재래식",
  36530. orderedList: "순서가지정된목록",
  36531. unorderedList: "정렬되지않은목록",
  36532. blockQuote: "참고문헌",
  36533. code: "코드",
  36534. link: "링크",
  36535. unlink: "링크삭제",
  36536. hr: "수평선",
  36537. media: "미디어",
  36538. mediaLibirary: "미디어라이브러리",
  36539. emoji: "작은표현",
  36540. fullscreen: "전체화면",
  36541. exitFullscreen: "전체화면종료"
  36542. },
  36543. linkEditor: {
  36544. textInputPlaceHolder: "링크텍스트입력",
  36545. linkInputPlaceHolder: "링크주소입력",
  36546. inputWithEnterPlaceHolder: "링크주소입력.",
  36547. openInNewWindow: "새창열기",
  36548. removeLink: "링크삭제"
  36549. },
  36550. audioPlayer: {
  36551. title: "오디오파일재생"
  36552. },
  36553. videoPlayer: {
  36554. title: "비디오파일재생",
  36555. embedTitle: "임베디드미디어"
  36556. },
  36557. media: {
  36558. image: "이미지",
  36559. video: "비디오",
  36560. audio: "오디오",
  36561. embed: "임베디드미디어"
  36562. }
  36563. };
  36564. // CONCATENATED MODULE: ./languages/tr.js
  36565. /* harmony default export */ var tr = {
  36566. base: {
  36567. remove: "Kaldır",
  36568. cancel: "İptal",
  36569. confirm: "Onayla",
  36570. inert: "Ekle",
  36571. width: "Genişlik",
  36572. height: "Yükseklik"
  36573. },
  36574. controls: {
  36575. clear: "Temizle",
  36576. undo: "Geri al",
  36577. redo: "İleri al",
  36578. fontSize: "Yazı boyutu",
  36579. color: "Renk",
  36580. textColor: "Yazı rengi",
  36581. tempColors: "Geçici renkler",
  36582. backgroundColor: "Arkaplan",
  36583. bold: "Kalın",
  36584. lineHeight: "Satır yüksekliği",
  36585. letterSpacing: "Harf aralığı",
  36586. textIndent: "Çentik aralığı",
  36587. increaseIndent: "Çentiği genişlet",
  36588. decreaseIndent: "Çentiği daralt",
  36589. italic: "Eğik",
  36590. underline: "Altı çizili",
  36591. strikeThrough: "Üstü çizili",
  36592. fontFamily: "Yazı tipi",
  36593. textAlign: "Metin Hizalama",
  36594. alignLeft: "Sola hizala",
  36595. alignCenter: "Ortaya hizala",
  36596. alignRight: "Sağa hizala",
  36597. alignJustify: "Her iki tarafa hizala",
  36598. floatLeft: "Sola yatır",
  36599. floatRight: "Sağa yatır",
  36600. superScript: "Ana kod",
  36601. subScript: "Alt kod",
  36602. removeStyles: "Stilleri kaldır",
  36603. headings: "Başlıklar",
  36604. header: "Başlık",
  36605. normal: "Normal",
  36606. orderedList: "Sıralı liste",
  36607. unorderedList: "Sırasız liste",
  36608. blockQuote: "Alıntı",
  36609. code: "Kod",
  36610. link: "Bağlantı",
  36611. unlink: "Bağlantıyı kaldır",
  36612. hr: "Yatay çizgi",
  36613. media: "Medya",
  36614. mediaLibirary: "Kütüphane",
  36615. emoji: "İfade",
  36616. fullscreen: "Tam ekran",
  36617. exitFullscreen: "Tam ekrandan çık"
  36618. },
  36619. linkEditor: {
  36620. textInputPlaceHolder: "Bağlantı metnini girin",
  36621. linkInputPlaceHolder: "Bağlantı URL' si girin",
  36622. inputWithEnterPlaceHolder:
  36623. "Bağlantı URL'si girin ve Enter' a basın",
  36624. openInNewWindow: "Yeni pencerede aç",
  36625. removeLink: "Bağlantıyı kaldır"
  36626. },
  36627. audioPlayer: {
  36628. title: "Ses çal"
  36629. },
  36630. videoPlayer: {
  36631. title: "Görüntü oynat",
  36632. embedTitle: "Görüntüyü göm"
  36633. },
  36634. media: {
  36635. image: "Resim",
  36636. video: "Görüntü",
  36637. audio: "Ses",
  36638. embed: "Gömülü nesne"
  36639. }
  36640. };
  36641. // CONCATENATED MODULE: ./languages/jpn.js
  36642. /* harmony default export */ var jpn = {
  36643. base: {
  36644. remove: "削除",
  36645. cancel: "キャンセル",
  36646. confirm: "決定",
  36647. inert: "挿入",
  36648. width: "幅",
  36649. height: "高さ"
  36650. },
  36651. controls: {
  36652. clear: "クリアコンテンツ",
  36653. undo: "キャンセル",
  36654. redo: "キャンセル",
  36655. fontSize: "フォントサイズ",
  36656. lineHeight: "フォントサイズ",
  36657. letterSpacing: "ワード間隔",
  36658. textIndent: "段落のインデント",
  36659. increaseIndent: "インデントを増やす",
  36660. decreaseIndent: "インデントを減らす",
  36661. border: "国境",
  36662. color: "色",
  36663. textColor: "テキストの色",
  36664. backgroundColor: "背景色",
  36665. tempColors: "仮色",
  36666. bold: "太字",
  36667. italic: "イタリック体",
  36668. underline: "下線",
  36669. strikeThrough: "取り消し線",
  36670. fontFamily: "フォント",
  36671. textAlign: "テキストの配置",
  36672. alignLeft: "左",
  36673. alignCenter: "中央揃え",
  36674. alignRight: "右に立つ",
  36675. alignJustify: "両端",
  36676. floatLeft: "左フローティング",
  36677. floatRight: "右フローティング",
  36678. superScript: "上付き",
  36679. subScript: "下付き文字",
  36680. removeStyles: "クリアスタイル",
  36681. headings: "役職",
  36682. header: "役職",
  36683. normal: "従来の",
  36684. orderedList: "順序付きリスト",
  36685. unorderedList: "番号なしリスト",
  36686. blockQuote: "参照",
  36687. code: "コード",
  36688. link: "リンク",
  36689. unlink: "リンクを解除",
  36690. hr: "横線",
  36691. media: "メディア",
  36692. mediaLibirary: "メディアライブラリー",
  36693. emoji: "小さな表現",
  36694. fullscreen: "全画面",
  36695. exitFullscreen: "全画面を退く"
  36696. },
  36697. linkEditor: {
  36698. textInputPlaceHolder: "リンクテキストを入力",
  36699. linkInputPlaceHolder: "リンクアドレスを入力",
  36700. inputWithEnterPlaceHolder: "リンクアドレスを入力して戻ります",
  36701. openInNewWindow: "新しいウィンドウで開く",
  36702. removeLink: "新しいウィンドウで開く"
  36703. },
  36704. audioPlayer: {
  36705. title: "オーディオファイルを再生する"
  36706. },
  36707. videoPlayer: {
  36708. title: "ビデオファイルを再生する",
  36709. embedTitle: "埋め込みメディア"
  36710. },
  36711. media: {
  36712. image: "画像",
  36713. video: "ビデオ",
  36714. audio: "音声",
  36715. embed: "埋め込みメディア"
  36716. }
  36717. };
  36718. // CONCATENATED MODULE: ./languages/ru.js
  36719. /* harmony default export */ var ru = {
  36720. base: {
  36721. remove: "Удалить",
  36722. cancel: "Отмена",
  36723. confirm: "Подтвердить",
  36724. insert: "Вставить",
  36725. width: "Ширина",
  36726. height: "Высота"
  36727. },
  36728. controls: {
  36729. clear: "Очистить",
  36730. undo: "Отменить",
  36731. redo: "Повторить",
  36732. fontSize: "Размер шрифта",
  36733. color: "Цвет",
  36734. textColor: "Цвет текста",
  36735. tempColors: "Temp Colors",
  36736. backgroundColor: "Цвет фона",
  36737. bold: "Жирный",
  36738. lineHeight: "Межстрочный интервал",
  36739. letterSpacing: "Межбуквенный интервал",
  36740. textIndent: "Отступ",
  36741. increaseIndent: "Увеличить отступ",
  36742. decreaseIndent: "Уменьшить отступ",
  36743. italic: "Курсив",
  36744. underline: "Подчеркнутый",
  36745. strikeThrough: "Перечеркнутый",
  36746. fontFamily: "Шрифт",
  36747. textAlign: "Расположение текста",
  36748. alignLeft: "По левому краю",
  36749. alignCenter: "По центру",
  36750. alignRight: "По правому краю",
  36751. alignJustify: "По ширине",
  36752. floatLeft: "Обтекание слева",
  36753. floatRight: "Обтекание справа",
  36754. superScript: "Надстрочный индекс",
  36755. subScript: "Подстрочный индекс",
  36756. removeStyles: "Убрать стили",
  36757. headings: "Заголовки",
  36758. header: "Заголовок",
  36759. normal: "Обычный",
  36760. orderedList: "Упорядоченный список",
  36761. unorderedList: "Неупорядоченный список",
  36762. blockQuote: "Цитата",
  36763. code: "Код",
  36764. link: "Вставить ссылку",
  36765. unlink: "Убрать ссылку",
  36766. hr: "Горизонтальная линия",
  36767. media: "Медиа",
  36768. mediaLibirary: "Медиа библиотека",
  36769. emoji: "Emoji",
  36770. fullscreen: "Полноэкранный режим",
  36771. exitFullscreen: "Выйти из полноэкранного режима"
  36772. },
  36773. linkEditor: {
  36774. textInputPlaceHolder: "Введите текст ссылки",
  36775. linkInputPlaceHolder: "Вставить ссылку",
  36776. inputWithEnterPlaceHolder: "Вставить ссылку и нажать Enter",
  36777. openInNewWindow: "Открыть в новом окне",
  36778. removeLink: "Убрать ссылку"
  36779. },
  36780. audioPlayer: {
  36781. title: "Воспроизвести аудиофайл"
  36782. },
  36783. videoPlayer: {
  36784. title: "Воспроизвести видеофайл",
  36785. embedTitle: "Embed Media"
  36786. },
  36787. media: {
  36788. image: "Картинка",
  36789. video: "Видео",
  36790. audio: "Аудио",
  36791. embed: "Встроенное"
  36792. }
  36793. };
  36794. // CONCATENATED MODULE: ./languages/fr.js
  36795. /* harmony default export */ var fr = {
  36796. base: {
  36797. remove: "Supprimer",
  36798. cancel: "Annuler",
  36799. confirm: "Confirmer",
  36800. inert: "Insérer",
  36801. width: "Largeur",
  36802. height: "Hauteur"
  36803. },
  36804. controls: {
  36805. clear: "Effacer",
  36806. undo: "Annuler",
  36807. redo: "Refaire",
  36808. fontSize: "Taille de police",
  36809. color: "Couleur",
  36810. textColor: "Texte",
  36811. tempColors: "Couleurs temporaire",
  36812. backgroundColor: "Couleur d'arrière plan",
  36813. bold: "Gras",
  36814. lineHeight: "Hauteur de ligne",
  36815. letterSpacing: "Espacement des lettres",
  36816. textIndent: "Indentation du texte",
  36817. increaseIndent: "Augmenter l'indentation",
  36818. decreaseIndent: "Réduire l'indentation",
  36819. italic: "Italique",
  36820. underline: "Souligner",
  36821. strikeThrough: "Barrer",
  36822. fontFamily: "Police d'écriture",
  36823. textAlign: "Alignement du texte",
  36824. alignLeft: "Aligner à gauche",
  36825. alignCenter: "Aligner au centre",
  36826. alignRight: "Aligner à droite",
  36827. alignJustify: "Justifier",
  36828. floatLeft: "Déplacer à gauche",
  36829. floatRight: "Déplacer à droite",
  36830. superScript: "Super-script",
  36831. subScript: "Sous-script",
  36832. removeStyles: "Supprimer les styles",
  36833. headings: "Titres",
  36834. header: "Entêtes",
  36835. normal: "Normal",
  36836. orderedList: "Liste ordonnée",
  36837. unorderedList: "Liste non-ordonnée",
  36838. blockQuote: "Citation",
  36839. code: "Code",
  36840. link: "Insérer un lien",
  36841. unlink: "Supprimer le lien",
  36842. hr: "Ligne horizontale",
  36843. media: "Média",
  36844. mediaLibirary: "Bibliothêque",
  36845. emoji: "Emoji",
  36846. fullscreen: "Plein écran",
  36847. exitFullscreen: "Quitter le plein écran"
  36848. },
  36849. linkEditor: {
  36850. textInputPlaceHolder: "Insérer le texte à afficher",
  36851. linkInputPlaceHolder: "Insérer le lien URL",
  36852. inputWithEnterPlaceHolder:
  36853. "Insérer le lien URL puis appuyer sur Entrée",
  36854. openInNewWindow: "Ouvrir dans une nouvelle fenêtre",
  36855. removeLink: "Supprimer le lien"
  36856. },
  36857. audioPlayer: {
  36858. title: "Lancer le son audio"
  36859. },
  36860. videoPlayer: {
  36861. title: "Lancer la video",
  36862. embedTitle: "Intégrer média"
  36863. },
  36864. media: {
  36865. image: "Image",
  36866. video: "Vidéo",
  36867. audio: "Audio",
  36868. embed: "Intégré"
  36869. }
  36870. };
  36871. // CONCATENATED MODULE: ./languages/pt-br.js
  36872. /* harmony default export */ var pt_br = {
  36873. base: {
  36874. remove: "Remover",
  36875. cancel: "Cancelar",
  36876. confirm: "Confirmar",
  36877. inert: "Inserir",
  36878. width: "Largura",
  36879. height: "Altura"
  36880. },
  36881. controls: {
  36882. clear: "Limpar",
  36883. undo: "Desfazer",
  36884. redo: "Refazer",
  36885. fontSize: "Tamanho da Fonte",
  36886. color: "Cor",
  36887. textColor: "Texto",
  36888. tempColors: "Temp Colors",
  36889. backgroundColor: "Cor de Fundo",
  36890. bold: "Negrito",
  36891. lineHeight: "Altura da LinhaLine Height",
  36892. letterSpacing: "Espaçamento entre Letras",
  36893. textIndent: "Identação de Texto",
  36894. increaseIndent: "Aumentar Identação",
  36895. decreaseIndent: "Diminuir Identção",
  36896. italic: "Itálico",
  36897. underline: "Sublinhado",
  36898. strikeThrough: "Riscado",
  36899. fontFamily: "Família da Fonte",
  36900. textAlign: "Alinhamento de Texto",
  36901. alignLeft: "Alinhamento à Esquerda",
  36902. alignCenter: "Alinhamento Centralizado",
  36903. alignRight: "Alinhamento à Direita",
  36904. alignJustify: "Alinhamento Justificado",
  36905. floatLeft: "Flutuação à Esquerda",
  36906. floatRight: "Flutuação à Direita",
  36907. superScript: "Sobrescrito",
  36908. subScript: "Subscrito",
  36909. removeStyles: "Remover Estilos",
  36910. headings: "Cabeçalhos",
  36911. header: "Cabeçalho",
  36912. normal: "Normal",
  36913. orderedList: "Lista Ordenada",
  36914. unorderedList: "Lista Não Ordenada",
  36915. blockQuote: "Citação",
  36916. code: "Código",
  36917. link: "Link",
  36918. unlink: "Remover Link",
  36919. hr: "Linha Horizontal",
  36920. media: "Mídia",
  36921. mediaLibirary: "Biblioteca de Mídia",
  36922. emoji: "Emoji",
  36923. fullscreen: "Tela Cheia",
  36924. exitFullscreen: "Sair de Tela Cheia"
  36925. },
  36926. linkEditor: {
  36927. textInputPlaceHolder: "Insira o texto do link",
  36928. linkInputPlaceHolder: "Insira a URL do link",
  36929. inputWithEnterPlaceHolder: "Insira a URL do link e aperte Enter",
  36930. openInNewWindow: "Abrir em nova janela",
  36931. removeLink: "Remover Link"
  36932. },
  36933. audioPlayer: {
  36934. title: "Tocar Áudio"
  36935. },
  36936. videoPlayer: {
  36937. title: "Tocar Vídeo",
  36938. embedTitle: "Mídia Embutida"
  36939. },
  36940. media: {
  36941. image: "Imagem",
  36942. video: "Vídeo",
  36943. audio: "Áudio",
  36944. embed: "Embutido"
  36945. }
  36946. };
  36947. // CONCATENATED MODULE: ./languages/index.js
  36948. /* harmony default export */ var languages = {
  36949. en: en,
  36950. zh: zh,
  36951. "zh-hant": zh_hant,
  36952. pl: pl,
  36953. kr: kr,
  36954. tr: tr,
  36955. jpn: jpn,
  36956. ru: ru,
  36957. fr: fr,
  36958. "pt-br": pt_br
  36959. };
  36960. // EXTERNAL MODULE: external "braft-finder"
  36961. var external_braft_finder_ = __webpack_require__(17);
  36962. var external_braft_finder_default = /*#__PURE__*/ __webpack_require__.n(
  36963. external_braft_finder_
  36964. );
  36965. // EXTERNAL MODULE: external "braft-utils"
  36966. var external_braft_utils_ = __webpack_require__(3);
  36967. // EXTERNAL MODULE: external "draft-js"
  36968. var external_draft_js_ = __webpack_require__(6);
  36969. // EXTERNAL MODULE: external "immutable"
  36970. var external_immutable_ = __webpack_require__(13);
  36971. var external_immutable_default = /*#__PURE__*/ __webpack_require__.n(
  36972. external_immutable_
  36973. );
  36974. // CONCATENATED MODULE: ./configs/keybindings.js
  36975. // TODO
  36976. // 允许自定义的快捷键设置
  36977. /* harmony default export */ var keybindings = function(
  36978. customKeyBindingFn
  36979. ) {
  36980. return function(event) {
  36981. if (
  36982. event.keyCode === 83 &&
  36983. (external_draft_js_["KeyBindingUtil"].hasCommandModifier(
  36984. event
  36985. ) ||
  36986. external_draft_js_["KeyBindingUtil"].isCtrlKeyCommand(event))
  36987. ) {
  36988. return "braft-save";
  36989. }
  36990. if (customKeyBindingFn) {
  36991. return (
  36992. customKeyBindingFn(event) ||
  36993. Object(external_draft_js_["getDefaultKeyBinding"])(event)
  36994. );
  36995. }
  36996. return Object(external_draft_js_["getDefaultKeyBinding"])(event);
  36997. };
  36998. };
  36999. // CONCATENATED MODULE: ./configs/props.js
  37000. /* harmony default export */ var configs_props = {
  37001. language: "zh",
  37002. controls: [
  37003. "undo",
  37004. "redo",
  37005. "separator",
  37006. "font-size",
  37007. "line-height",
  37008. "letter-spacing",
  37009. "separator",
  37010. "text-color",
  37011. "bold",
  37012. "italic",
  37013. "underline",
  37014. "strike-through",
  37015. "separator",
  37016. "superscript",
  37017. "subscript",
  37018. "remove-styles",
  37019. "emoji",
  37020. "separator",
  37021. "text-indent",
  37022. "text-align",
  37023. "separator",
  37024. "headings",
  37025. "list-ul",
  37026. "list-ol",
  37027. "blockquote",
  37028. "code",
  37029. "separator",
  37030. "media",
  37031. "link",
  37032. "table",
  37033. "split",
  37034. "hr",
  37035. "separator",
  37036. "clear",
  37037. "separator",
  37038. "fullscreen"
  37039. ],
  37040. excludeControls: [],
  37041. extendControls: [],
  37042. extendAtomics: [],
  37043. componentBelowControlBar: null,
  37044. media: {
  37045. pasteImage: true,
  37046. imagePasteLimit: 5,
  37047. image: true,
  37048. video: true,
  37049. audio: true,
  37050. uploadFn: null,
  37051. validateFn: null,
  37052. onBeforeDeselect: null,
  37053. onDeselect: null,
  37054. onBeforeSelect: null,
  37055. onSelect: null,
  37056. onBeforeRemove: null,
  37057. onRemove: null,
  37058. onCancel: null,
  37059. onFileSelect: null,
  37060. onBeforeInsert: null,
  37061. onInsert: null,
  37062. onChange: null,
  37063. accepts: {
  37064. image:
  37065. "image/png,image/jpeg,image/gif,image/webp,image/apng,image/svg",
  37066. video: "video/mp4",
  37067. audio: "audio/mp3"
  37068. },
  37069. externals: {
  37070. audio: true,
  37071. video: true,
  37072. image: true,
  37073. embed: true
  37074. }
  37075. },
  37076. imageControls: [
  37077. "float-left",
  37078. "float-right",
  37079. "align-left",
  37080. "align-center",
  37081. "align-right",
  37082. "link",
  37083. "size",
  37084. "remove"
  37085. ],
  37086. imageResizable: true,
  37087. colors: [
  37088. "#000000",
  37089. "#333333",
  37090. "#666666",
  37091. "#999999",
  37092. "#cccccc",
  37093. "#ffffff",
  37094. "#61a951",
  37095. "#16a085",
  37096. "#07a9fe",
  37097. "#003ba5",
  37098. "#8e44ad",
  37099. "#f32784",
  37100. "#c0392b",
  37101. "#d35400",
  37102. "#f39c12",
  37103. "#fdda00"
  37104. ],
  37105. colorPicker: null,
  37106. colorPickerTheme: "dark",
  37107. colorPickerAutoHide: true,
  37108. codeTabIndents: 2,
  37109. headings: [
  37110. "header-one",
  37111. "header-two",
  37112. "header-three",
  37113. "header-four",
  37114. "header-five",
  37115. "header-six",
  37116. "unstyled"
  37117. ],
  37118. textAligns: ["left", "center", "right", "justify"],
  37119. textBackgroundColor: true,
  37120. allowInsertLinkText: false,
  37121. defaultLinkTarget: "",
  37122. letterSpacings: [0, 1, 2, 3, 4, 5, 6],
  37123. lineHeights: [1, 1.2, 1.5, 1.75, 2, 2.5, 3, 4],
  37124. fontSizes: [
  37125. 12,
  37126. 14,
  37127. 16,
  37128. 18,
  37129. 20,
  37130. 24,
  37131. 28,
  37132. 30,
  37133. 32,
  37134. 36,
  37135. 40,
  37136. 48,
  37137. 56,
  37138. 64,
  37139. 72,
  37140. 96,
  37141. 120,
  37142. 144
  37143. ],
  37144. fontFamilies: [
  37145. {
  37146. name: "Araial",
  37147. family: "Arial, Helvetica, sans-serif"
  37148. },
  37149. {
  37150. name: "Georgia",
  37151. family: "Georgia, serif"
  37152. },
  37153. {
  37154. name: "Impact",
  37155. family: "Impact, serif"
  37156. },
  37157. {
  37158. name: "Monospace",
  37159. family: '"Courier New", Courier, monospace'
  37160. },
  37161. {
  37162. name: "Tahoma",
  37163. family: 'tahoma, arial, "Hiragino Sans GB", 宋体, sans-serif'
  37164. }
  37165. ],
  37166. converts: {
  37167. unitExportFn: function unitExportFn(value, type) {
  37168. return type === "line-height" ? value : "".concat(value, "px");
  37169. }
  37170. },
  37171. emojis: [
  37172. "🤣",
  37173. "🙌",
  37174. "💚",
  37175. "💛",
  37176. "👏",
  37177. "😉",
  37178. "💯",
  37179. "💕",
  37180. "💞",
  37181. "💘",
  37182. "💙",
  37183. "💝",
  37184. "🖤",
  37185. "💜",
  37186. "❤️",
  37187. "😍",
  37188. "😻",
  37189. "💓",
  37190. "💗",
  37191. "😋",
  37192. "😇",
  37193. "😂",
  37194. "😹",
  37195. "😘",
  37196. "💖",
  37197. "😁",
  37198. "😀",
  37199. "🤞",
  37200. "😲",
  37201. "😄",
  37202. "😊",
  37203. "👍",
  37204. "😌",
  37205. "😃",
  37206. "😅",
  37207. "✌️",
  37208. "🤗",
  37209. "💋",
  37210. "😗",
  37211. "😽",
  37212. "😚",
  37213. "🤠",
  37214. "😙",
  37215. "😺",
  37216. "👄",
  37217. "😸",
  37218. "😏",
  37219. "😼",
  37220. "👌",
  37221. "😎",
  37222. "😆",
  37223. "😛",
  37224. "🙏",
  37225. "🤝",
  37226. "🙂",
  37227. "🤑",
  37228. "😝",
  37229. "😐",
  37230. "😑",
  37231. "🤤",
  37232. "😤",
  37233. "🙃",
  37234. "🤡",
  37235. "😶",
  37236. "😪",
  37237. "😴",
  37238. "😵",
  37239. "😓",
  37240. "👊",
  37241. "😦",
  37242. "😷",
  37243. "🤐",
  37244. "😜",
  37245. "🤓",
  37246. "👻",
  37247. "😥",
  37248. "🙄",
  37249. "🤔",
  37250. "🤒",
  37251. "🙁",
  37252. "😔",
  37253. "😯",
  37254. "☹️",
  37255. "☠️",
  37256. "😰",
  37257. "😩",
  37258. "😖",
  37259. "😕",
  37260. "😒",
  37261. "😣",
  37262. "😢",
  37263. "😮",
  37264. "😿",
  37265. "🤧",
  37266. "😫",
  37267. "🤥",
  37268. "😞",
  37269. "😬",
  37270. "👎",
  37271. "💀",
  37272. "😳",
  37273. "😨",
  37274. "🤕",
  37275. "🤢",
  37276. "😱",
  37277. "😭",
  37278. "😠",
  37279. "😈",
  37280. "😧",
  37281. "💔",
  37282. "😟",
  37283. "🙀",
  37284. "💩",
  37285. "👿",
  37286. "😡",
  37287. "😾",
  37288. "🖕"
  37289. ],
  37290. stripPastedStyles: false,
  37291. triggerChangeOnMount: true,
  37292. className: "",
  37293. style: {},
  37294. controlBarClassName: "",
  37295. controlBarStyle: {},
  37296. contentClassName: "",
  37297. contentStyle: {},
  37298. draftProps: {},
  37299. hooks: {},
  37300. onChange: null,
  37301. onFocus: null,
  37302. onBlur: null,
  37303. onTab: null,
  37304. onDelete: null,
  37305. onSave: null,
  37306. fixPlaceholder: false
  37307. };
  37308. // EXTERNAL MODULE: ../node_modules/draft-js/lib/getFragmentFromSelection.js
  37309. var getFragmentFromSelection = __webpack_require__(22);
  37310. var getFragmentFromSelection_default = /*#__PURE__*/ __webpack_require__.n(
  37311. getFragmentFromSelection
  37312. );
  37313. // EXTERNAL MODULE: external "draftjs-utils"
  37314. var external_draftjs_utils_ = __webpack_require__(23);
  37315. // CONCATENATED MODULE: ./configs/handlers.js
  37316. var handlers_keyCommandHandlers = function keyCommandHandlers(
  37317. command,
  37318. editorState,
  37319. editor
  37320. ) {
  37321. if (
  37322. editor.editorProps.handleKeyCommand &&
  37323. editor.editorProps.handleKeyCommand(
  37324. command,
  37325. editorState,
  37326. editor
  37327. ) === "handled"
  37328. ) {
  37329. return "handled";
  37330. }
  37331. if (command === "braft-save") {
  37332. editor.editorProps.onSave &&
  37333. editor.editorProps.onSave(editorState);
  37334. return "handled";
  37335. }
  37336. var _editor$editorProps = editor.editorProps,
  37337. controls = _editor$editorProps.controls,
  37338. excludeControls = _editor$editorProps.excludeControls;
  37339. var allowIndent =
  37340. (controls.indexOf("text-indent") !== 0 ||
  37341. controls.find(function(item) {
  37342. return item.key === "text-indent";
  37343. })) &&
  37344. excludeControls.indexOf("text-indent") === -1;
  37345. var cursorStart = editorState.getSelection().getStartOffset();
  37346. var cursorEnd = editorState.getSelection().getEndOffset();
  37347. var cursorIsAtFirst = cursorStart === 0 && cursorEnd === 0;
  37348. if (command === "backspace") {
  37349. if (
  37350. editor.editorProps.onDelete &&
  37351. editor.editorProps.onDelete(editorState) === false
  37352. ) {
  37353. return "handled";
  37354. }
  37355. var blockType = external_braft_utils_[
  37356. "ContentUtils"
  37357. ].getSelectionBlockType(editorState);
  37358. if (
  37359. allowIndent &&
  37360. cursorIsAtFirst &&
  37361. blockType !== "code-block"
  37362. ) {
  37363. editor.setValue(
  37364. external_braft_utils_["ContentUtils"].decreaseSelectionIndent(
  37365. editorState
  37366. )
  37367. );
  37368. }
  37369. }
  37370. if (command === "tab") {
  37371. var _blockType = external_braft_utils_[
  37372. "ContentUtils"
  37373. ].getSelectionBlockType(editorState);
  37374. if (_blockType === "code-block") {
  37375. editor.setValue(
  37376. external_braft_utils_["ContentUtils"].insertText(
  37377. editorState,
  37378. " ".repeat(editor.editorProps.codeTabIndents)
  37379. )
  37380. );
  37381. return "handled";
  37382. } else if (
  37383. _blockType === "ordered-list-item" ||
  37384. _blockType === "unordered-list-item"
  37385. ) {
  37386. var newEditorState = external_draft_js_["RichUtils"].onTab(
  37387. event,
  37388. editorState,
  37389. 4
  37390. );
  37391. if (newEditorState !== editorState) {
  37392. editor.setValue(newEditorState);
  37393. }
  37394. return "handled";
  37395. } else if (
  37396. _blockType !== "atomic" &&
  37397. allowIndent &&
  37398. cursorIsAtFirst
  37399. ) {
  37400. editor.setValue(
  37401. external_braft_utils_["ContentUtils"].increaseSelectionIndent(
  37402. editorState
  37403. )
  37404. );
  37405. return "handled";
  37406. }
  37407. }
  37408. var nextEditorState = external_braft_utils_[
  37409. "ContentUtils"
  37410. ].handleKeyCommand(editorState, command);
  37411. if (nextEditorState) {
  37412. editor.setValue(nextEditorState);
  37413. return "handled";
  37414. }
  37415. return "not-handled";
  37416. };
  37417. var handlers_returnHandlers = function returnHandlers(
  37418. event,
  37419. editorState,
  37420. editor
  37421. ) {
  37422. if (
  37423. editor.editorProps.handleReturn &&
  37424. editor.editorProps.handleReturn(event, editorState, editor) ===
  37425. "handled"
  37426. ) {
  37427. return "handled";
  37428. }
  37429. var currentBlock = external_braft_utils_[
  37430. "ContentUtils"
  37431. ].getSelectionBlock(editorState);
  37432. var currentBlockType = currentBlock.getType();
  37433. if (
  37434. currentBlockType === "unordered-list-item" ||
  37435. currentBlockType === "ordered-list-item"
  37436. ) {
  37437. if (currentBlock.getLength() === 0) {
  37438. editor.setValue(
  37439. external_braft_utils_[
  37440. "ContentUtils"
  37441. ].toggleSelectionBlockType(editorState, "unstyled")
  37442. );
  37443. return "handled";
  37444. }
  37445. return "not-handled";
  37446. } else if (currentBlockType === "code-block") {
  37447. if (
  37448. event.which === 13 &&
  37449. (event.getModifierState("Shift") ||
  37450. event.getModifierState("Alt") ||
  37451. event.getModifierState("Control"))
  37452. ) {
  37453. editor.setValue(
  37454. external_braft_utils_[
  37455. "ContentUtils"
  37456. ].toggleSelectionBlockType(editorState, "unstyled")
  37457. );
  37458. return "handled";
  37459. }
  37460. return "not-handled";
  37461. } else if (currentBlockType === "blockquote") {
  37462. if (event.which === 13) {
  37463. if (
  37464. event.getModifierState("Shift") ||
  37465. event.getModifierState("Alt") ||
  37466. event.getModifierState("Control")
  37467. ) {
  37468. event.which = 0;
  37469. } else {
  37470. editor.setValue(
  37471. external_draft_js_["RichUtils"].insertSoftNewline(
  37472. editorState
  37473. )
  37474. );
  37475. return "handled";
  37476. }
  37477. }
  37478. }
  37479. var nextEditorState = Object(
  37480. external_draftjs_utils_["handleNewLine"]
  37481. )(editorState, event);
  37482. if (nextEditorState) {
  37483. editor.setValue(nextEditorState);
  37484. return "handled";
  37485. }
  37486. return "not-handled";
  37487. };
  37488. var beforeInputHandlers = function beforeInputHandlers(
  37489. chars,
  37490. editorState,
  37491. editor
  37492. ) {
  37493. if (
  37494. editor.editorProps.handleBeforeInput &&
  37495. editor.editorProps.handleBeforeInput(
  37496. chars,
  37497. editorState,
  37498. editor
  37499. ) === "handled"
  37500. ) {
  37501. return "handled";
  37502. }
  37503. return "not-handled";
  37504. };
  37505. var handlers_compositionStartHandler = function compositionStartHandler(
  37506. _,
  37507. editor
  37508. ) {
  37509. var editorState = editor.state.editorState;
  37510. var selectedBlocks = external_braft_utils_[
  37511. "ContentUtils"
  37512. ].getSelectedBlocks(editorState);
  37513. if (selectedBlocks && selectedBlocks.length > 1) {
  37514. var nextEditorState = external_draft_js_["EditorState"].push(
  37515. editorState,
  37516. external_draft_js_["Modifier"].removeRange(
  37517. editorState.getCurrentContent(),
  37518. editorState.getSelection(),
  37519. "backward"
  37520. ),
  37521. "remove-range"
  37522. );
  37523. editor.setValue(nextEditorState);
  37524. }
  37525. };
  37526. var handlers_dropHandlers = function dropHandlers(
  37527. selectionState,
  37528. dataTransfer,
  37529. editor
  37530. ) {
  37531. if (editor.editorProps.readOnly || editor.editorProps.disabled) {
  37532. return "handled";
  37533. }
  37534. if (window && window.__BRAFT_DRAGING__IMAGE__) {
  37535. var nextEditorState = external_draft_js_[
  37536. "EditorState"
  37537. ].forceSelection(editor.state.editorState, selectionState);
  37538. nextEditorState = external_braft_utils_[
  37539. "ContentUtils"
  37540. ].insertMedias(nextEditorState, [
  37541. window.__BRAFT_DRAGING__IMAGE__.mediaData
  37542. ]);
  37543. nextEditorState = external_braft_utils_[
  37544. "ContentUtils"
  37545. ].removeBlock(
  37546. nextEditorState,
  37547. window.__BRAFT_DRAGING__IMAGE__.block,
  37548. nextEditorState.getSelection()
  37549. );
  37550. window.__BRAFT_DRAGING__IMAGE__ = null;
  37551. editor.lockOrUnlockEditor(true);
  37552. editor.setValue(nextEditorState);
  37553. return "handled";
  37554. } else if (!dataTransfer || !dataTransfer.getText()) {
  37555. return "handled";
  37556. }
  37557. return "not-handled";
  37558. };
  37559. var handlers_handleFiles = function handleFiles(files, editor) {
  37560. var _editor$constructor$d = objectSpread_default()(
  37561. {},
  37562. editor.constructor.defaultProps.media,
  37563. editor.editorProps.media
  37564. ),
  37565. pasteImage = _editor$constructor$d.pasteImage,
  37566. validateFn = _editor$constructor$d.validateFn,
  37567. imagePasteLimit = _editor$constructor$d.imagePasteLimit;
  37568. pasteImage &&
  37569. files.slice(0, imagePasteLimit).forEach(function(file) {
  37570. if (
  37571. file &&
  37572. file.type.indexOf("image") > -1 &&
  37573. editor.braftFinder
  37574. ) {
  37575. var validateResult = validateFn ? validateFn(file) : true;
  37576. if (validateResult instanceof Promise) {
  37577. validateResult.then(function() {
  37578. editor.braftFinder.uploadImage(file, function(image) {
  37579. editor.isLiving &&
  37580. editor.setValue(
  37581. external_braft_utils_[
  37582. "ContentUtils"
  37583. ].insertMedias(editor.state.editorState, [image])
  37584. );
  37585. });
  37586. });
  37587. } else if (validateResult) {
  37588. editor.braftFinder.uploadImage(file, function(image) {
  37589. editor.isLiving &&
  37590. editor.setValue(
  37591. external_braft_utils_[
  37592. "ContentUtils"
  37593. ].insertMedias(editor.state.editorState, [image])
  37594. );
  37595. });
  37596. }
  37597. }
  37598. });
  37599. if (files[0] && files[0].type.indexOf("image") > -1 && pasteImage) {
  37600. return "handled";
  37601. }
  37602. return "not-handled";
  37603. };
  37604. var droppedFilesHandlers = function droppedFilesHandlers(
  37605. selectionState,
  37606. files,
  37607. editor
  37608. ) {
  37609. if (
  37610. editor.editorProps.handleDroppedFiles &&
  37611. editor.editorProps.handleDroppedFiles(
  37612. selectionState,
  37613. files,
  37614. editor
  37615. ) === "handled"
  37616. ) {
  37617. return "handled";
  37618. }
  37619. return handlers_handleFiles(files, editor);
  37620. };
  37621. var pastedFilesHandlers = function pastedFilesHandlers(
  37622. files,
  37623. editor
  37624. ) {
  37625. if (
  37626. editor.editorProps.handlePastedFiles &&
  37627. editor.editorProps.handlePastedFiles(files, editor) === "handled"
  37628. ) {
  37629. return "handled";
  37630. }
  37631. return handlers_handleFiles(files, editor);
  37632. };
  37633. var handlers_copyHandlers = function copyHandlers(event, editor) {
  37634. var blockMap = getFragmentFromSelection_default()(
  37635. editor.state.editorState
  37636. );
  37637. if (blockMap && blockMap.toArray) {
  37638. try {
  37639. var tempContentState = external_draft_js_[
  37640. "ContentState"
  37641. ].createFromBlockArray(blockMap.toArray());
  37642. var tempEditorState = external_draft_js_[
  37643. "EditorState"
  37644. ].createWithContent(tempContentState);
  37645. var clipboardData =
  37646. event.clipboardData ||
  37647. window.clipboardData ||
  37648. event.originalEvent.clipboardData;
  37649. tempEditorState.setConvertOptions(
  37650. editor.state.editorState.convertOptions
  37651. );
  37652. clipboardData.setData("text/html", tempEditorState.toHTML());
  37653. clipboardData.setData("text/plain", tempEditorState.toText());
  37654. event.preventDefault();
  37655. } catch (error) {
  37656. console.warn(error);
  37657. }
  37658. }
  37659. };
  37660. var handlers_pastedTextHandlers = function pastedTextHandlers(
  37661. text,
  37662. html,
  37663. editorState,
  37664. editor
  37665. ) {
  37666. if (
  37667. editor.editorProps.handlePastedText &&
  37668. editor.editorProps.handlePastedText(
  37669. text,
  37670. html,
  37671. editorState,
  37672. editor
  37673. ) === "handled"
  37674. ) {
  37675. return "handled";
  37676. }
  37677. if (!html || editor.editorProps.stripPastedStyles) {
  37678. return false;
  37679. }
  37680. var tempColors = external_braft_utils_[
  37681. "ColorUtils"
  37682. ].detectColorsFromHTMLString(html);
  37683. editor.setState(
  37684. {
  37685. tempColors: toConsumableArray_default()(editor.state.tempColors)
  37686. .concat(toConsumableArray_default()(tempColors))
  37687. .filter(function(item) {
  37688. return editor.editorProps.colors.indexOf(item) === -1;
  37689. })
  37690. .filter(function(item, index, array) {
  37691. return array.indexOf(item) === index;
  37692. })
  37693. },
  37694. function() {
  37695. editor.setValue(
  37696. external_braft_utils_["ContentUtils"].insertHTML(
  37697. editorState,
  37698. html,
  37699. "paste"
  37700. )
  37701. );
  37702. }
  37703. );
  37704. return "handled";
  37705. };
  37706. // CONCATENATED MODULE: ./helpers/extension.js
  37707. // TODO
  37708. // - block-style和atomic类型的扩展支持
  37709. var extension_extensionControls = [];
  37710. var extension_extensionDecorators = [];
  37711. var extension_propInterceptors = [];
  37712. var extension_extensionBlockRenderMaps = [];
  37713. var extension_extensionBlockRendererFns = [];
  37714. var extensionInlineStyleMaps = [];
  37715. var extension_extensionInlineStyleFns = [];
  37716. var extensionEntities = [];
  37717. var inlineStyleImporters = [];
  37718. var inlineStyleExporters = [];
  37719. var blockImporters = [];
  37720. var blockExporters = [];
  37721. var filterByEditorId = function filterByEditorId(items, editorId) {
  37722. if (!editorId) {
  37723. return items
  37724. .filter(function(item) {
  37725. return !item.includeEditors;
  37726. })
  37727. .map(function(item) {
  37728. return item.data;
  37729. });
  37730. }
  37731. return items
  37732. .map(function(item) {
  37733. if (!item.includeEditors && !item.excludeEditors) {
  37734. return item.data;
  37735. }
  37736. if (item.includeEditors) {
  37737. return item.includeEditors.indexOf(editorId) !== -1
  37738. ? item.data
  37739. : false;
  37740. }
  37741. if (item.excludeEditors) {
  37742. return item.excludeEditors.indexOf(editorId) !== -1
  37743. ? false
  37744. : item.data;
  37745. }
  37746. return false;
  37747. })
  37748. .filter(function(item) {
  37749. return item;
  37750. });
  37751. };
  37752. var getPropInterceptors = function getPropInterceptors(editorId) {
  37753. return filterByEditorId(extension_propInterceptors, editorId);
  37754. };
  37755. var getExtensionControls = function getExtensionControls(editorId) {
  37756. return filterByEditorId(extension_extensionControls, editorId);
  37757. };
  37758. var getExtensionDecorators = function getExtensionDecorators(
  37759. editorId
  37760. ) {
  37761. return filterByEditorId(extension_extensionDecorators, editorId);
  37762. };
  37763. var getExtensionBlockRenderMaps = function getExtensionBlockRenderMaps(
  37764. editorId
  37765. ) {
  37766. return filterByEditorId(
  37767. extension_extensionBlockRenderMaps,
  37768. editorId
  37769. );
  37770. };
  37771. var getExtensionBlockRendererFns = function getExtensionBlockRendererFns(
  37772. editorId
  37773. ) {
  37774. return filterByEditorId(
  37775. extension_extensionBlockRendererFns,
  37776. editorId
  37777. );
  37778. };
  37779. var getExtensionInlineStyleMap = function getExtensionInlineStyleMap(
  37780. editorId
  37781. ) {
  37782. var inlineStyleMap = {};
  37783. filterByEditorId(extensionInlineStyleMaps, editorId).forEach(
  37784. function(item) {
  37785. inlineStyleMap[item.inlineStyleName] = item.styleMap;
  37786. }
  37787. );
  37788. return inlineStyleMap;
  37789. };
  37790. var getExtensionInlineStyleFns = function getExtensionInlineStyleFns(
  37791. editorId
  37792. ) {
  37793. return filterByEditorId(
  37794. extension_extensionInlineStyleFns,
  37795. editorId
  37796. );
  37797. };
  37798. var compositeStyleImportFn = function compositeStyleImportFn(
  37799. styleImportFn,
  37800. editorId
  37801. ) {
  37802. return function(nodeName, node, style) {
  37803. filterByEditorId(inlineStyleImporters, editorId).forEach(function(
  37804. styleImporter
  37805. ) {
  37806. if (
  37807. styleImporter.importer &&
  37808. styleImporter.importer(nodeName, node)
  37809. ) {
  37810. style = style.add(styleImporter.inlineStyleName);
  37811. }
  37812. });
  37813. return styleImportFn
  37814. ? styleImportFn(nodeName, node, style)
  37815. : style;
  37816. };
  37817. };
  37818. var compositeStyleExportFn = function compositeStyleExportFn(
  37819. styleExportFn,
  37820. editorId
  37821. ) {
  37822. return function(style) {
  37823. style = style.toUpperCase();
  37824. var result = styleExportFn ? styleExportFn(style) : undefined;
  37825. if (result) {
  37826. return result;
  37827. }
  37828. filterByEditorId(inlineStyleExporters, editorId).find(function(
  37829. item
  37830. ) {
  37831. if (item.inlineStyleName === style) {
  37832. result = item.exporter;
  37833. return true;
  37834. }
  37835. });
  37836. return result;
  37837. };
  37838. };
  37839. var compositeEntityImportFn = function compositeEntityImportFn(
  37840. entityImportFn,
  37841. editorId
  37842. ) {
  37843. return function(nodeName, node, createEntity, source) {
  37844. var result = entityImportFn
  37845. ? entityImportFn(nodeName, node, createEntity, source)
  37846. : null;
  37847. if (result) {
  37848. return result;
  37849. }
  37850. filterByEditorId(extensionEntities, editorId).find(function(
  37851. entityItem
  37852. ) {
  37853. var matched = entityItem.importer
  37854. ? entityItem.importer(nodeName, node, source)
  37855. : null;
  37856. matched &&
  37857. (result = createEntity(
  37858. entityItem.entityType,
  37859. matched.mutability || "MUTABLE",
  37860. matched.data || {}
  37861. ));
  37862. return !!matched;
  37863. });
  37864. return result;
  37865. };
  37866. };
  37867. var compositeEntityExportFn = function compositeEntityExportFn(
  37868. entityExportFn,
  37869. editorId
  37870. ) {
  37871. return function(entity, originalText) {
  37872. var result = entityExportFn
  37873. ? entityExportFn(entity, originalText)
  37874. : undefined;
  37875. if (result) {
  37876. return result;
  37877. }
  37878. var entityType = entity.type.toUpperCase();
  37879. filterByEditorId(extensionEntities, editorId).find(function(
  37880. entityItem
  37881. ) {
  37882. if (entityItem.entityType === entityType) {
  37883. result = entityItem.exporter
  37884. ? entityItem.exporter(entity, originalText)
  37885. : undefined;
  37886. return true;
  37887. }
  37888. });
  37889. return result;
  37890. };
  37891. };
  37892. var compositeBlockImportFn = function compositeBlockImportFn(
  37893. blockImportFn,
  37894. editorId
  37895. ) {
  37896. return function(nodeName, node, source) {
  37897. var result = blockImportFn
  37898. ? blockImportFn(nodeName, node, source)
  37899. : null;
  37900. if (result) {
  37901. return result;
  37902. }
  37903. filterByEditorId(blockImporters, editorId).find(function(
  37904. blockImporter
  37905. ) {
  37906. var matched = blockImporter.importer
  37907. ? blockImporter.importer(nodeName, node, source)
  37908. : undefined;
  37909. matched && (result = matched);
  37910. return !!matched;
  37911. });
  37912. return result;
  37913. };
  37914. };
  37915. var compositeBlockExportFn = function compositeBlockExportFn(
  37916. blockExportFn,
  37917. editorId
  37918. ) {
  37919. return function(contentState, block) {
  37920. var result = blockExportFn
  37921. ? blockExportFn(contentState, block)
  37922. : null;
  37923. if (result) {
  37924. return result;
  37925. }
  37926. filterByEditorId(blockExporters, editorId).find(function(
  37927. blockExporter
  37928. ) {
  37929. var matched = blockExporter.exporter
  37930. ? blockExporter.exporter(contentState, block)
  37931. : undefined;
  37932. matched && (result = matched);
  37933. return !!matched;
  37934. });
  37935. return result;
  37936. };
  37937. };
  37938. var extension_useExtension = function useExtension(extension) {
  37939. if (extension instanceof Array) {
  37940. extension.forEach(useExtension);
  37941. return false;
  37942. }
  37943. if (
  37944. !extension ||
  37945. !extension.type ||
  37946. typeof extension.type !== "string"
  37947. ) {
  37948. return false;
  37949. }
  37950. var includeEditors = extension.includeEditors,
  37951. excludeEditors = extension.excludeEditors;
  37952. if (extension.type === "control") {
  37953. extension_extensionControls.push({
  37954. includeEditors: includeEditors,
  37955. excludeEditors: excludeEditors,
  37956. data: extension.control
  37957. });
  37958. } else if (extension.type === "inline-style") {
  37959. var inlineStyleName = extension.name.toUpperCase();
  37960. if (extension.control) {
  37961. extension_extensionControls.push({
  37962. includeEditors: includeEditors,
  37963. excludeEditors: excludeEditors,
  37964. data: objectSpread_default()(
  37965. {
  37966. key: inlineStyleName,
  37967. type: "inline-style",
  37968. command: inlineStyleName
  37969. },
  37970. extension.control
  37971. )
  37972. });
  37973. }
  37974. if (extension.style) {
  37975. extensionInlineStyleMaps.push({
  37976. includeEditors: includeEditors,
  37977. excludeEditors: excludeEditors,
  37978. data: {
  37979. inlineStyleName: inlineStyleName,
  37980. styleMap: extension.style
  37981. }
  37982. });
  37983. }
  37984. if (extension.styleFn) {
  37985. extension_extensionInlineStyleFns.push({
  37986. includeEditors: includeEditors,
  37987. excludeEditors: excludeEditors,
  37988. data: {
  37989. inlineStyleName: inlineStyleName,
  37990. styleFn: extension.styleFn
  37991. }
  37992. });
  37993. }
  37994. if (extension.importer) {
  37995. inlineStyleImporters.push({
  37996. includeEditors: includeEditors,
  37997. excludeEditors: excludeEditors,
  37998. data: {
  37999. inlineStyleName: inlineStyleName,
  38000. importer: extension.importer
  38001. }
  38002. });
  38003. }
  38004. inlineStyleExporters.push({
  38005. includeEditors: includeEditors,
  38006. excludeEditors: excludeEditors,
  38007. data: {
  38008. inlineStyleName: inlineStyleName,
  38009. exporter: extension.exporter
  38010. ? extension.exporter(extension)
  38011. : external_react_default.a.createElement("span", {
  38012. style: extension.style
  38013. })
  38014. }
  38015. });
  38016. } else if (extension.type === "block-style");
  38017. else if (extension.type === "entity") {
  38018. var entityType = extension.name.toUpperCase();
  38019. if (extension.control) {
  38020. extension_extensionControls.push({
  38021. includeEditors: includeEditors,
  38022. excludeEditors: excludeEditors,
  38023. data:
  38024. typeof extension.control === "function"
  38025. ? extension.control
  38026. : objectSpread_default()(
  38027. {
  38028. key: entityType,
  38029. type: "entity",
  38030. command: entityType,
  38031. data: {
  38032. mutability: extension.mutability || "MUTABLE",
  38033. data: extension.data || {}
  38034. }
  38035. },
  38036. extension.control
  38037. )
  38038. });
  38039. }
  38040. extensionEntities.push({
  38041. includeEditors: includeEditors,
  38042. excludeEditors: excludeEditors,
  38043. data: {
  38044. entityType: entityType,
  38045. importer: extension.importer,
  38046. exporter: extension.exporter
  38047. }
  38048. });
  38049. extension_extensionDecorators.push({
  38050. includeEditors: includeEditors,
  38051. excludeEditors: excludeEditors,
  38052. data: {
  38053. type: "entity",
  38054. decorator: {
  38055. key: entityType,
  38056. component: extension.component
  38057. }
  38058. }
  38059. });
  38060. } else if (extension.type === "block") {
  38061. var blockType = extension.name;
  38062. if (extension.renderMap) {
  38063. extension_extensionBlockRenderMaps.push({
  38064. includeEditors: includeEditors,
  38065. excludeEditors: excludeEditors,
  38066. data: {
  38067. blockType: blockType,
  38068. renderMap: extension.renderMap
  38069. }
  38070. });
  38071. }
  38072. if (extension.rendererFn) {
  38073. extension_extensionBlockRendererFns.push({
  38074. includeEditors: includeEditors,
  38075. excludeEditors: excludeEditors,
  38076. data: {
  38077. blockType: blockType,
  38078. rendererFn: extension.rendererFn
  38079. }
  38080. });
  38081. }
  38082. if (extension.importer) {
  38083. blockImporters.push({
  38084. includeEditors: includeEditors,
  38085. excludeEditors: excludeEditors,
  38086. data: {
  38087. blockType: blockType,
  38088. importer: extension.importer
  38089. }
  38090. });
  38091. }
  38092. if (extension.exporter) {
  38093. blockExporters.push({
  38094. includeEditors: includeEditors,
  38095. excludeEditors: excludeEditors,
  38096. data: {
  38097. blockType: blockType,
  38098. exporter: extension.exporter
  38099. }
  38100. });
  38101. }
  38102. } else if (extension.type === "atomic");
  38103. else if (extension.type === "decorator") {
  38104. var decorator = extension.decorator;
  38105. if (decorator && decorator.strategy && decorator.component) {
  38106. extension_extensionDecorators.push({
  38107. includeEditors: includeEditors,
  38108. excludeEditors: excludeEditors,
  38109. data: {
  38110. type: "strategy",
  38111. decorator: decorator
  38112. }
  38113. });
  38114. } else if (decorator && decorator.getDecorations) {
  38115. extension_extensionDecorators.push({
  38116. includeEditors: includeEditors,
  38117. excludeEditors: excludeEditors,
  38118. data: {
  38119. type: "class",
  38120. decorator: decorator
  38121. }
  38122. });
  38123. }
  38124. } else if (extension.type === "prop-interception") {
  38125. extension_propInterceptors.push({
  38126. includeEditors: includeEditors,
  38127. excludeEditors: excludeEditors,
  38128. data: extension.interceptor
  38129. });
  38130. }
  38131. };
  38132. var createExtensibleEditor = function createExtensibleEditor(
  38133. BraftEditor
  38134. ) {
  38135. BraftEditor.use = extension_useExtension;
  38136. return BraftEditor;
  38137. };
  38138. // CONCATENATED MODULE: ./renderers/block/blockRenderMap.js
  38139. /* harmony default export */ var block_blockRenderMap = function(
  38140. props,
  38141. blockRenderMap
  38142. ) {
  38143. var customBlockRenderMap = Object(external_immutable_["Map"])({
  38144. atomic: {
  38145. element: ""
  38146. },
  38147. "code-block": {
  38148. element: "code",
  38149. wrapper: external_react_default.a.createElement("pre", {
  38150. className: "braft-code-block"
  38151. })
  38152. }
  38153. });
  38154. try {
  38155. var extensionBlockRenderMaps = getExtensionBlockRenderMaps(
  38156. props.editorId
  38157. );
  38158. customBlockRenderMap = extensionBlockRenderMaps.reduce(function(
  38159. customBlockRenderMap,
  38160. item
  38161. ) {
  38162. return customBlockRenderMap.merge(
  38163. typeof item.renderMap === "function"
  38164. ? item.renderMap(props)
  38165. : item.renderMap
  38166. );
  38167. },
  38168. customBlockRenderMap);
  38169. if (blockRenderMap) {
  38170. if (typeof blockRenderMap === "function") {
  38171. customBlockRenderMap = customBlockRenderMap.merge(
  38172. blockRenderMap(props)
  38173. );
  38174. } else {
  38175. customBlockRenderMap = customBlockRenderMap.merge(
  38176. blockRenderMap
  38177. );
  38178. }
  38179. }
  38180. customBlockRenderMap = external_draft_js_[
  38181. "DefaultDraftBlockRenderMap"
  38182. ].merge(customBlockRenderMap);
  38183. } catch (error) {
  38184. console.warn(error);
  38185. }
  38186. return customBlockRenderMap;
  38187. };
  38188. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/extends.js
  38189. var helpers_extends = __webpack_require__(11);
  38190. var extends_default = /*#__PURE__*/ __webpack_require__.n(
  38191. helpers_extends
  38192. );
  38193. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/slicedToArray.js
  38194. var slicedToArray = __webpack_require__(24);
  38195. var slicedToArray_default = /*#__PURE__*/ __webpack_require__.n(
  38196. slicedToArray
  38197. );
  38198. // EXTERNAL MODULE: ./renderers/atomics/Image/style.scss
  38199. var Image_style = __webpack_require__(45);
  38200. // EXTERNAL MODULE: ./components/common/Switch/style.scss
  38201. var Switch_style = __webpack_require__(46);
  38202. // CONCATENATED MODULE: ./components/common/Switch/index.jsx
  38203. /* harmony default export */ var Switch = function(props) {
  38204. var active = props.active,
  38205. _onClick = props.onClick,
  38206. className = props.className;
  38207. return external_react_default.a.createElement("div", {
  38208. onClick: function onClick() {
  38209. return _onClick();
  38210. },
  38211. className: "bf-switch " + className + (active ? " active" : "")
  38212. });
  38213. };
  38214. // CONCATENATED MODULE: ./configs/controls.js
  38215. /* harmony default export */ var configs_controls = function(
  38216. lang,
  38217. editor
  38218. ) {
  38219. return [
  38220. {
  38221. key: "undo",
  38222. title: lang.controls.undo,
  38223. text: external_react_default.a.createElement("i", {
  38224. className: "bfi-undo"
  38225. }),
  38226. type: "editor-method",
  38227. command: "undo"
  38228. },
  38229. {
  38230. key: "redo",
  38231. title: lang.controls.redo,
  38232. text: external_react_default.a.createElement("i", {
  38233. className: "bfi-redo"
  38234. }),
  38235. type: "editor-method",
  38236. command: "redo"
  38237. },
  38238. {
  38239. key: "remove-styles",
  38240. title: lang.controls.removeStyles,
  38241. text: external_react_default.a.createElement("i", {
  38242. className: "bfi-format_clear"
  38243. }),
  38244. type: "editor-method",
  38245. command: "removeSelectionInlineStyles"
  38246. },
  38247. {
  38248. key: "hr",
  38249. title: lang.controls.hr,
  38250. text: external_react_default.a.createElement("i", {
  38251. className: "bfi-hr"
  38252. }),
  38253. type: "editor-method",
  38254. command: "insertHorizontalLine"
  38255. },
  38256. {
  38257. key: "bold",
  38258. title: lang.controls.bold,
  38259. text: external_react_default.a.createElement("i", {
  38260. className: "bfi-bold"
  38261. }),
  38262. type: "inline-style",
  38263. command: "bold"
  38264. },
  38265. {
  38266. key: "italic",
  38267. title: lang.controls.italic,
  38268. text: external_react_default.a.createElement("i", {
  38269. className: "bfi-italic"
  38270. }),
  38271. type: "inline-style",
  38272. command: "italic"
  38273. },
  38274. {
  38275. key: "underline",
  38276. title: lang.controls.underline,
  38277. text: external_react_default.a.createElement("i", {
  38278. className: "bfi-underlined"
  38279. }),
  38280. type: "inline-style",
  38281. command: "underline"
  38282. },
  38283. {
  38284. key: "strike-through",
  38285. title: lang.controls.strikeThrough,
  38286. text: external_react_default.a.createElement("i", {
  38287. className: "bfi-strikethrough"
  38288. }),
  38289. type: "inline-style",
  38290. command: "strikethrough"
  38291. },
  38292. {
  38293. key: "superscript",
  38294. title: lang.controls.superScript,
  38295. text: external_react_default.a.createElement("i", {
  38296. className: "bfi-superscript"
  38297. }),
  38298. type: "inline-style",
  38299. command: "superscript"
  38300. },
  38301. {
  38302. key: "subscript",
  38303. title: lang.controls.subScript,
  38304. text: external_react_default.a.createElement("i", {
  38305. className: "bfi-subscript"
  38306. }),
  38307. type: "inline-style",
  38308. command: "subscript"
  38309. },
  38310. {
  38311. key: "headings",
  38312. title: lang.controls.headings,
  38313. type: "headings"
  38314. },
  38315. {
  38316. key: "blockquote",
  38317. title: lang.controls.blockQuote,
  38318. text: external_react_default.a.createElement("i", {
  38319. className: "bfi-quote"
  38320. }),
  38321. type: "block-type",
  38322. command: "blockquote"
  38323. },
  38324. {
  38325. key: "code",
  38326. title: lang.controls.code,
  38327. text: external_react_default.a.createElement("i", {
  38328. className: "bfi-code"
  38329. }),
  38330. type: "block-type",
  38331. command: "code-block"
  38332. },
  38333. {
  38334. key: "list-ul",
  38335. title: lang.controls.unorderedList,
  38336. text: external_react_default.a.createElement("i", {
  38337. className: "bfi-list"
  38338. }),
  38339. type: "block-type",
  38340. command: "unordered-list-item"
  38341. },
  38342. {
  38343. key: "list-ol",
  38344. title: lang.controls.orderedList,
  38345. text: external_react_default.a.createElement("i", {
  38346. className: "bfi-list-numbered"
  38347. }),
  38348. type: "block-type",
  38349. command: "ordered-list-item"
  38350. },
  38351. {
  38352. key: "link",
  38353. title: lang.controls.link,
  38354. type: "link"
  38355. },
  38356. {
  38357. key: "text-color",
  38358. title: lang.controls.color,
  38359. type: "text-color"
  38360. },
  38361. {
  38362. key: "line-height",
  38363. title: lang.controls.lineHeight,
  38364. type: "line-height"
  38365. },
  38366. {
  38367. key: "letter-spacing",
  38368. title: lang.controls.letterSpacing,
  38369. type: "letter-spacing"
  38370. },
  38371. {
  38372. key: "text-indent",
  38373. title: lang.controls.textIndent,
  38374. type: "text-indent"
  38375. },
  38376. {
  38377. key: "font-size",
  38378. title: lang.controls.fontSize,
  38379. type: "font-size"
  38380. },
  38381. {
  38382. key: "font-family",
  38383. title: lang.controls.fontFamily,
  38384. type: "font-family"
  38385. },
  38386. {
  38387. key: "text-align",
  38388. title: lang.controls.textAlign,
  38389. type: "text-align"
  38390. },
  38391. {
  38392. key: "media",
  38393. title: lang.controls.media,
  38394. text: external_react_default.a.createElement("i", {
  38395. className: "bfi-media"
  38396. }),
  38397. type: "media"
  38398. },
  38399. {
  38400. key: "emoji",
  38401. title: lang.controls.emoji,
  38402. text: external_react_default.a.createElement("i", {
  38403. className: "bfi-emoji"
  38404. }),
  38405. type: "emoji"
  38406. },
  38407. {
  38408. key: "clear",
  38409. title: lang.controls.clear,
  38410. text: external_react_default.a.createElement("i", {
  38411. className: "bfi-clear_all"
  38412. }),
  38413. type: "editor-method",
  38414. command: "clearEditorContent"
  38415. },
  38416. {
  38417. key: "fullscreen",
  38418. title: editor.state.isFullscreen
  38419. ? lang.controls.exitFullscreen
  38420. : lang.controls.fullscreen,
  38421. text: external_react_default.a.createElement("i", {
  38422. className: editor.state.isFullscreen
  38423. ? "bfi-fullscreen-exit"
  38424. : "bfi-fullscreen"
  38425. }),
  38426. type: "editor-method",
  38427. command: "toggleFullscreen"
  38428. },
  38429. {
  38430. key: "modal",
  38431. type: "modal"
  38432. },
  38433. {
  38434. key: "button",
  38435. type: "button"
  38436. },
  38437. {
  38438. key: "dropdown",
  38439. type: "dropdown"
  38440. },
  38441. {
  38442. key: "component",
  38443. type: "component"
  38444. }
  38445. ];
  38446. };
  38447. var imageControlItems = {
  38448. "float-left": {
  38449. text: external_react_default.a.createElement(
  38450. "span",
  38451. {
  38452. "data-float": "left"
  38453. },
  38454. "\uE91E"
  38455. ),
  38456. command: "setImageFloat|left"
  38457. },
  38458. "float-right": {
  38459. text: external_react_default.a.createElement(
  38460. "span",
  38461. {
  38462. "data-float": "right"
  38463. },
  38464. "\uE914"
  38465. ),
  38466. command: "setImageFloat|right"
  38467. },
  38468. "align-left": {
  38469. text: external_react_default.a.createElement(
  38470. "span",
  38471. {
  38472. "data-align": "left"
  38473. },
  38474. "\uE027"
  38475. ),
  38476. command: "setImageAlignment|left"
  38477. },
  38478. "align-center": {
  38479. text: external_react_default.a.createElement(
  38480. "span",
  38481. {
  38482. "data-align": "center"
  38483. },
  38484. "\uE028"
  38485. ),
  38486. command: "setImageAlignment|center"
  38487. },
  38488. "align-right": {
  38489. text: external_react_default.a.createElement(
  38490. "span",
  38491. {
  38492. "data-align": "right"
  38493. },
  38494. "\uE029"
  38495. ),
  38496. command: "setImageAlignment|right"
  38497. },
  38498. size: {
  38499. text: external_react_default.a.createElement(
  38500. "span",
  38501. null,
  38502. "\uE3C2"
  38503. ),
  38504. command: "toggleSizeEditor"
  38505. },
  38506. link: {
  38507. text: external_react_default.a.createElement(
  38508. "span",
  38509. null,
  38510. "\uE91A"
  38511. ),
  38512. command: "toggleLinkEditor"
  38513. },
  38514. remove: {
  38515. text: external_react_default.a.createElement(
  38516. "span",
  38517. null,
  38518. "\uE9AC"
  38519. ),
  38520. command: "removeImage"
  38521. }
  38522. };
  38523. // CONCATENATED MODULE: ./renderers/atomics/Image/index.jsx
  38524. var Image_Image =
  38525. /*#__PURE__*/
  38526. (function(_React$Component) {
  38527. inherits_default()(Image, _React$Component);
  38528. function Image() {
  38529. var _getPrototypeOf2;
  38530. var _this;
  38531. classCallCheck_default()(this, Image);
  38532. for (
  38533. var _len = arguments.length, args = new Array(_len), _key = 0;
  38534. _key < _len;
  38535. _key++
  38536. ) {
  38537. args[_key] = arguments[_key];
  38538. }
  38539. _this = possibleConstructorReturn_default()(
  38540. this,
  38541. (_getPrototypeOf2 = getPrototypeOf_default()(
  38542. Image
  38543. )).call.apply(_getPrototypeOf2, [this].concat(args))
  38544. );
  38545. defineProperty_default()(
  38546. assertThisInitialized_default()(
  38547. assertThisInitialized_default()(_this)
  38548. ),
  38549. "state",
  38550. {
  38551. toolbarVisible: false,
  38552. toolbarOffset: 0,
  38553. linkEditorVisible: false,
  38554. sizeEditorVisible: false,
  38555. tempLink: null,
  38556. tempWidth: null,
  38557. tempHeight: null
  38558. }
  38559. );
  38560. defineProperty_default()(
  38561. assertThisInitialized_default()(
  38562. assertThisInitialized_default()(_this)
  38563. ),
  38564. "initialLeft",
  38565. void 0
  38566. );
  38567. defineProperty_default()(
  38568. assertThisInitialized_default()(
  38569. assertThisInitialized_default()(_this)
  38570. ),
  38571. "initialTop",
  38572. void 0
  38573. );
  38574. defineProperty_default()(
  38575. assertThisInitialized_default()(
  38576. assertThisInitialized_default()(_this)
  38577. ),
  38578. "initialWidth",
  38579. void 0
  38580. );
  38581. defineProperty_default()(
  38582. assertThisInitialized_default()(
  38583. assertThisInitialized_default()(_this)
  38584. ),
  38585. "initialHeight",
  38586. void 0
  38587. );
  38588. defineProperty_default()(
  38589. assertThisInitialized_default()(
  38590. assertThisInitialized_default()(_this)
  38591. ),
  38592. "reSizeType",
  38593. void 0
  38594. );
  38595. defineProperty_default()(
  38596. assertThisInitialized_default()(
  38597. assertThisInitialized_default()(_this)
  38598. ),
  38599. "changeSize",
  38600. function(e) {
  38601. var type = _this.reSizeType;
  38602. if (!_this.initialLeft) {
  38603. _this.initialLeft = e.screenX;
  38604. _this.initialTop = e.screenY;
  38605. }
  38606. if (type === "rightbottom") {
  38607. _this.initialHeight += e.screenY - _this.initialTop;
  38608. _this.initialWidth += e.screenX - _this.initialLeft;
  38609. }
  38610. if (type === "leftbottom") {
  38611. _this.initialHeight += e.screenY - _this.initialTop;
  38612. _this.initialWidth += -e.screenX + _this.initialLeft;
  38613. }
  38614. _this.initialLeft = e.screenX;
  38615. _this.initialTop = e.screenY;
  38616. }
  38617. );
  38618. defineProperty_default()(
  38619. assertThisInitialized_default()(
  38620. assertThisInitialized_default()(_this)
  38621. ),
  38622. "moveImage",
  38623. function(e) {
  38624. _this.changeSize(e);
  38625. _this.setState({
  38626. tempWidth: Math.abs(_this.initialWidth),
  38627. tempHeight: Math.abs(_this.initialHeight)
  38628. });
  38629. }
  38630. );
  38631. defineProperty_default()(
  38632. assertThisInitialized_default()(
  38633. assertThisInitialized_default()(_this)
  38634. ),
  38635. "upImage",
  38636. function() {
  38637. _this.confirmImageSize();
  38638. document.removeEventListener("mousemove", _this.moveImage);
  38639. document.removeEventListener("mouseup", _this.upImage);
  38640. }
  38641. );
  38642. defineProperty_default()(
  38643. assertThisInitialized_default()(
  38644. assertThisInitialized_default()(_this)
  38645. ),
  38646. "repareChangeSize",
  38647. function(type) {
  38648. return function(e) {
  38649. _this.reSizeType = type;
  38650. var imageRect = _this.imageElement.getBoundingClientRect();
  38651. _this.initialLeft = _this.initialTop = 0;
  38652. _this.initialWidth = imageRect.width;
  38653. _this.initialHeight = imageRect.height;
  38654. e.preventDefault();
  38655. document.addEventListener("mousemove", _this.moveImage);
  38656. document.addEventListener("mouseup", _this.upImage);
  38657. };
  38658. }
  38659. );
  38660. defineProperty_default()(
  38661. assertThisInitialized_default()(
  38662. assertThisInitialized_default()(_this)
  38663. ),
  38664. "preventDragEvent",
  38665. function(event) {
  38666. event.stopPropagation();
  38667. event.preventDefault();
  38668. }
  38669. );
  38670. defineProperty_default()(
  38671. assertThisInitialized_default()(
  38672. assertThisInitialized_default()(_this)
  38673. ),
  38674. "handleDragStart",
  38675. function() {
  38676. if (
  38677. _this.props.editor.editorProps.readOnly ||
  38678. _this.props.editor.editorProps.disabled
  38679. ) {
  38680. return false;
  38681. }
  38682. window.__BRAFT_DRAGING__IMAGE__ = {
  38683. block: _this.props.block,
  38684. mediaData: objectSpread_default()(
  38685. {
  38686. type: "IMAGE"
  38687. },
  38688. _this.props.mediaData
  38689. )
  38690. };
  38691. _this.setState(
  38692. {
  38693. toolbarVisible: false
  38694. },
  38695. function() {
  38696. _this.unlockEditor();
  38697. }
  38698. );
  38699. return true;
  38700. }
  38701. );
  38702. defineProperty_default()(
  38703. assertThisInitialized_default()(
  38704. assertThisInitialized_default()(_this)
  38705. ),
  38706. "handleDragEnd",
  38707. function() {
  38708. window.__BRAFT_DRAGING__IMAGE__ = null;
  38709. return false;
  38710. }
  38711. );
  38712. defineProperty_default()(
  38713. assertThisInitialized_default()(
  38714. assertThisInitialized_default()(_this)
  38715. ),
  38716. "executeCommand",
  38717. function(command) {
  38718. if (typeof command === "string") {
  38719. var _command$split = command.split("|"),
  38720. _command$split2 = slicedToArray_default()(
  38721. _command$split,
  38722. 2
  38723. ),
  38724. method = _command$split2[0],
  38725. param = _command$split2[1];
  38726. _this[method] && _this[method](param);
  38727. } else if (typeof command === "function") {
  38728. command(
  38729. _this.props.block,
  38730. _this.props.mediaData,
  38731. _this.props.editor.getValue()
  38732. );
  38733. }
  38734. }
  38735. );
  38736. defineProperty_default()(
  38737. assertThisInitialized_default()(
  38738. assertThisInitialized_default()(_this)
  38739. ),
  38740. "removeImage",
  38741. function() {
  38742. _this.props.editor.setValue(
  38743. external_braft_utils_["ContentUtils"].removeBlock(
  38744. _this.props.editor.getValue(),
  38745. _this.props.block
  38746. )
  38747. );
  38748. _this.unlockEditor();
  38749. }
  38750. );
  38751. defineProperty_default()(
  38752. assertThisInitialized_default()(
  38753. assertThisInitialized_default()(_this)
  38754. ),
  38755. "toggleLinkEditor",
  38756. function() {
  38757. _this.setState({
  38758. linkEditorVisible: !_this.state.linkEditorVisible,
  38759. sizeEditorVisible: false
  38760. });
  38761. }
  38762. );
  38763. defineProperty_default()(
  38764. assertThisInitialized_default()(
  38765. assertThisInitialized_default()(_this)
  38766. ),
  38767. "toggleSizeEditor",
  38768. function() {
  38769. _this.setState({
  38770. linkEditorVisible: false,
  38771. sizeEditorVisible: !_this.state.sizeEditorVisible
  38772. });
  38773. }
  38774. );
  38775. defineProperty_default()(
  38776. assertThisInitialized_default()(
  38777. assertThisInitialized_default()(_this)
  38778. ),
  38779. "handleLinkInputKeyDown",
  38780. function(e) {
  38781. if (e.keyCode === 13) {
  38782. _this.confirmImageLink();
  38783. } else {
  38784. return;
  38785. }
  38786. }
  38787. );
  38788. defineProperty_default()(
  38789. assertThisInitialized_default()(
  38790. assertThisInitialized_default()(_this)
  38791. ),
  38792. "setImageLink",
  38793. function(e) {
  38794. _this.setState({
  38795. tempLink: e.currentTarget.value
  38796. });
  38797. return;
  38798. }
  38799. );
  38800. defineProperty_default()(
  38801. assertThisInitialized_default()(
  38802. assertThisInitialized_default()(_this)
  38803. ),
  38804. "confirmImageLink",
  38805. function() {
  38806. var link = _this.state.tempLink;
  38807. var hookReturns = _this.props.hooks(
  38808. "set-image-link",
  38809. link
  38810. )(link);
  38811. if (hookReturns === false) {
  38812. return false;
  38813. }
  38814. if (typeof hookReturns === "string") {
  38815. link = hookReturns;
  38816. }
  38817. if (link !== null) {
  38818. _this.props.editor.setValue(
  38819. external_braft_utils_["ContentUtils"].setMediaData(
  38820. _this.props.editor.getValue(),
  38821. _this.props.entityKey,
  38822. {
  38823. link: link
  38824. }
  38825. )
  38826. );
  38827. window.setImmediate(_this.props.editor.forceRender);
  38828. }
  38829. }
  38830. );
  38831. defineProperty_default()(
  38832. assertThisInitialized_default()(
  38833. assertThisInitialized_default()(_this)
  38834. ),
  38835. "handleSizeInputKeyDown",
  38836. function(e) {
  38837. if (e.keyCode === 13) {
  38838. _this.confirmImageSize();
  38839. } else {
  38840. return;
  38841. }
  38842. }
  38843. );
  38844. defineProperty_default()(
  38845. assertThisInitialized_default()(
  38846. assertThisInitialized_default()(_this)
  38847. ),
  38848. "setImageWidth",
  38849. function(_ref) {
  38850. var currentTarget = _ref.currentTarget;
  38851. var value = currentTarget.value;
  38852. value && !isNaN(value) && (value = value + "px");
  38853. _this.setState({
  38854. tempWidth: value
  38855. });
  38856. return;
  38857. }
  38858. );
  38859. defineProperty_default()(
  38860. assertThisInitialized_default()(
  38861. assertThisInitialized_default()(_this)
  38862. ),
  38863. "setImageHeight",
  38864. function(_ref2) {
  38865. var currentTarget = _ref2.currentTarget;
  38866. var value = currentTarget.value;
  38867. value && !isNaN(value) && (value = value + "px");
  38868. _this.setState({
  38869. tempHeight: value
  38870. });
  38871. return;
  38872. }
  38873. );
  38874. defineProperty_default()(
  38875. assertThisInitialized_default()(
  38876. assertThisInitialized_default()(_this)
  38877. ),
  38878. "confirmImageSize",
  38879. function() {
  38880. var _this$state = _this.state,
  38881. width = _this$state.tempWidth,
  38882. height = _this$state.tempHeight;
  38883. var newImageSize = {};
  38884. width !== null && (newImageSize.width = width);
  38885. height !== null && (newImageSize.height = height);
  38886. var hookReturns = _this.props.hooks(
  38887. "set-image-size",
  38888. newImageSize
  38889. )(newImageSize);
  38890. if (hookReturns === false) {
  38891. return false;
  38892. }
  38893. if (
  38894. hookReturns &&
  38895. (hookReturns.width || hookReturns.height)
  38896. ) {
  38897. newImageSize = hookReturns;
  38898. }
  38899. _this.props.editor.setValue(
  38900. external_braft_utils_["ContentUtils"].setMediaData(
  38901. _this.props.editor.getValue(),
  38902. _this.props.entityKey,
  38903. newImageSize
  38904. )
  38905. );
  38906. window.setImmediate(_this.props.editor.forceRender);
  38907. }
  38908. );
  38909. defineProperty_default()(
  38910. assertThisInitialized_default()(
  38911. assertThisInitialized_default()(_this)
  38912. ),
  38913. "setImageFloat",
  38914. function(float) {
  38915. var hookReturns = _this.props.hooks(
  38916. "set-image-float",
  38917. float
  38918. )(float);
  38919. if (hookReturns === false) {
  38920. return false;
  38921. }
  38922. if (typeof hookReturns === "string") {
  38923. float = hookReturns;
  38924. }
  38925. _this.props.editor.setValue(
  38926. external_braft_utils_["ContentUtils"].setMediaPosition(
  38927. _this.props.editor.getValue(),
  38928. _this.props.block,
  38929. {
  38930. float: float
  38931. }
  38932. )
  38933. );
  38934. _this.unlockEditor();
  38935. }
  38936. );
  38937. defineProperty_default()(
  38938. assertThisInitialized_default()(
  38939. assertThisInitialized_default()(_this)
  38940. ),
  38941. "setImageAlignment",
  38942. function(alignment) {
  38943. var hookReturns = _this.props.hooks(
  38944. "set-image-alignment",
  38945. alignment
  38946. )(alignment);
  38947. if (hookReturns === false) {
  38948. return false;
  38949. }
  38950. if (typeof hookReturns === "string") {
  38951. alignment = hookReturns;
  38952. }
  38953. _this.props.editor.setValue(
  38954. external_braft_utils_["ContentUtils"].setMediaPosition(
  38955. _this.props.editor.getValue(),
  38956. _this.props.block,
  38957. {
  38958. alignment: alignment
  38959. }
  38960. )
  38961. );
  38962. _this.unlockEditor();
  38963. }
  38964. );
  38965. defineProperty_default()(
  38966. assertThisInitialized_default()(
  38967. assertThisInitialized_default()(_this)
  38968. ),
  38969. "showToolbar",
  38970. function(event) {
  38971. if (
  38972. _this.props.editor.editorProps.readOnly ||
  38973. _this.props.editor.editorProps.disabled
  38974. ) {
  38975. return false;
  38976. }
  38977. event.preventDefault();
  38978. if (!_this.state.toolbarVisible) {
  38979. _this.setState(
  38980. {
  38981. toolbarVisible: true
  38982. },
  38983. function() {
  38984. _this.lockEditor();
  38985. _this.setState({
  38986. toolbarOffset: _this.calcToolbarOffset()
  38987. });
  38988. }
  38989. );
  38990. }
  38991. }
  38992. );
  38993. defineProperty_default()(
  38994. assertThisInitialized_default()(
  38995. assertThisInitialized_default()(_this)
  38996. ),
  38997. "hideToolbar",
  38998. function(event) {
  38999. event.preventDefault();
  39000. _this.setState(
  39001. {
  39002. toolbarVisible: false
  39003. },
  39004. function() {
  39005. _this.unlockEditor(); // this.props.editor.requestFocus()
  39006. }
  39007. );
  39008. }
  39009. );
  39010. return _this;
  39011. }
  39012. createClass_default()(Image, [
  39013. {
  39014. key: "render",
  39015. value: function render() {
  39016. var _this2 = this;
  39017. var _this$props = this.props,
  39018. mediaData = _this$props.mediaData,
  39019. language = _this$props.language,
  39020. imageControls = _this$props.imageControls,
  39021. imageResizable = _this$props.imageResizable;
  39022. var _this$state2 = this.state,
  39023. toolbarVisible = _this$state2.toolbarVisible,
  39024. toolbarOffset = _this$state2.toolbarOffset,
  39025. linkEditorVisible = _this$state2.linkEditorVisible,
  39026. sizeEditorVisible = _this$state2.sizeEditorVisible,
  39027. tempWidth = _this$state2.tempWidth,
  39028. tempHeight = _this$state2.tempHeight;
  39029. var blockData = this.props.block.getData();
  39030. var float = blockData.get("float");
  39031. var alignment = blockData.get("alignment");
  39032. var url = mediaData.url,
  39033. link = mediaData.link,
  39034. link_target = mediaData.link_target,
  39035. width = mediaData.width,
  39036. height = mediaData.height,
  39037. meta = mediaData.meta;
  39038. var imageStyles = {};
  39039. var clearFix = false;
  39040. if (float) {
  39041. alignment = null;
  39042. } else if (alignment === "left") {
  39043. imageStyles.float = "left";
  39044. clearFix = true;
  39045. } else if (alignment === "right") {
  39046. imageStyles.float = "right";
  39047. clearFix = true;
  39048. } else if (alignment === "center") {
  39049. imageStyles.textAlign = "center";
  39050. } else {
  39051. imageStyles.float = "left";
  39052. clearFix = true;
  39053. }
  39054. var renderedControlItems = imageControls.map(function(
  39055. item,
  39056. index
  39057. ) {
  39058. if (typeof item === "string" && imageControlItems[item]) {
  39059. return external_react_default.a.createElement(
  39060. "a",
  39061. {
  39062. className: item === "link" && link ? "active" : "",
  39063. key: index,
  39064. onClick: function onClick() {
  39065. return _this2.executeCommand(
  39066. imageControlItems[item].command
  39067. );
  39068. }
  39069. },
  39070. imageControlItems[item].text
  39071. );
  39072. } else if (item && (item.render || item.text)) {
  39073. return item.render
  39074. ? item.render(mediaData, _this2.props.block)
  39075. : external_react_default.a.createElement(
  39076. "a",
  39077. {
  39078. key: index,
  39079. onClick: function onClick() {
  39080. return (
  39081. item.onClick &&
  39082. _this2.executeCommand(item.onClick)
  39083. );
  39084. }
  39085. },
  39086. item.text
  39087. );
  39088. } else {
  39089. return null;
  39090. }
  39091. });
  39092. return external_react_default.a.createElement(
  39093. "div",
  39094. {
  39095. className: "bf-media"
  39096. },
  39097. external_react_default.a.createElement(
  39098. "div",
  39099. {
  39100. style: imageStyles,
  39101. draggable: true,
  39102. onMouseEnter: this.showToolbar,
  39103. onMouseMove: this.showToolbar,
  39104. onMouseLeave: this.hideToolbar,
  39105. onDragStart: this.handleDragStart,
  39106. onDragEnd: this.handleDragEnd,
  39107. ref: function ref(instance) {
  39108. return (_this2.mediaEmbederInstance = instance);
  39109. },
  39110. className: "bf-image"
  39111. },
  39112. toolbarVisible
  39113. ? external_react_default.a.createElement(
  39114. "div",
  39115. {
  39116. style: {
  39117. marginLeft: toolbarOffset
  39118. },
  39119. ref: function ref(instance) {
  39120. return (_this2.toolbarElement = instance);
  39121. },
  39122. "data-float": float,
  39123. "data-align": alignment,
  39124. className: "bf-media-toolbar"
  39125. },
  39126. linkEditorVisible
  39127. ? external_react_default.a.createElement(
  39128. "div",
  39129. {
  39130. className: "bf-image-link-editor"
  39131. },
  39132. external_react_default.a.createElement(
  39133. "div",
  39134. {
  39135. className: "editor-input-group"
  39136. },
  39137. external_react_default.a.createElement(
  39138. "input",
  39139. {
  39140. type: "text",
  39141. placeholder:
  39142. language.linkEditor
  39143. .inputWithEnterPlaceHolder,
  39144. onKeyDown: this
  39145. .handleLinkInputKeyDown,
  39146. onChange: this.setImageLink,
  39147. defaultValue: link
  39148. }
  39149. ),
  39150. external_react_default.a.createElement(
  39151. "button",
  39152. {
  39153. type: "button",
  39154. onClick: this.confirmImageLink
  39155. },
  39156. language.base.confirm
  39157. )
  39158. ),
  39159. external_react_default.a.createElement(
  39160. "div",
  39161. {
  39162. className: "switch-group"
  39163. },
  39164. external_react_default.a.createElement(
  39165. Switch,
  39166. {
  39167. active: link_target === "_blank",
  39168. onClick: function onClick() {
  39169. return _this2.setImageLinkTarget(
  39170. link_target
  39171. );
  39172. }
  39173. }
  39174. ),
  39175. external_react_default.a.createElement(
  39176. "label",
  39177. null,
  39178. language.linkEditor.openInNewWindow
  39179. )
  39180. )
  39181. )
  39182. : null,
  39183. sizeEditorVisible
  39184. ? external_react_default.a.createElement(
  39185. "div",
  39186. {
  39187. className: "bf-image-size-editor"
  39188. },
  39189. external_react_default.a.createElement(
  39190. "div",
  39191. {
  39192. className: "editor-input-group"
  39193. },
  39194. external_react_default.a.createElement(
  39195. "input",
  39196. {
  39197. type: "text",
  39198. placeholder: language.base.width,
  39199. onKeyDown: this
  39200. .handleSizeInputKeyDown,
  39201. onChange: this.setImageWidth,
  39202. defaultValue: width
  39203. }
  39204. ),
  39205. external_react_default.a.createElement(
  39206. "input",
  39207. {
  39208. type: "text",
  39209. placeholder: language.base.height,
  39210. onKeyDown: this
  39211. .handleSizeInputKeyDown,
  39212. onChange: this.setImageHeight,
  39213. defaultValue: height
  39214. }
  39215. ),
  39216. external_react_default.a.createElement(
  39217. "button",
  39218. {
  39219. type: "button",
  39220. onClick: this.confirmImageSize
  39221. },
  39222. language.base.confirm
  39223. )
  39224. )
  39225. )
  39226. : null,
  39227. renderedControlItems,
  39228. external_react_default.a.createElement("i", {
  39229. style: {
  39230. marginLeft: toolbarOffset * -1
  39231. },
  39232. className: "bf-media-toolbar-arrow"
  39233. })
  39234. )
  39235. : null,
  39236. external_react_default.a.createElement(
  39237. "div",
  39238. {
  39239. style: {
  39240. position: "relative",
  39241. width: "".concat(width, "px"),
  39242. height: "".concat(height, "px"),
  39243. display: "inline-block"
  39244. }
  39245. },
  39246. external_react_default.a.createElement(
  39247. "img",
  39248. extends_default()(
  39249. {
  39250. ref: function ref(instance) {
  39251. return (_this2.imageElement = instance);
  39252. },
  39253. src: url,
  39254. width: width,
  39255. height: height
  39256. },
  39257. meta
  39258. )
  39259. ),
  39260. toolbarVisible && imageResizable
  39261. ? external_react_default.a.createElement("div", {
  39262. className: "bf-csize-icon right-bottom",
  39263. onMouseDown: this.repareChangeSize(
  39264. "rightbottom"
  39265. )
  39266. })
  39267. : null,
  39268. toolbarVisible && imageResizable
  39269. ? external_react_default.a.createElement("div", {
  39270. className: "bf-csize-icon left-bottom",
  39271. onMouseDown: this.repareChangeSize("leftbottom")
  39272. })
  39273. : null,
  39274. external_react_default.a.createElement("div", {
  39275. className: "bf-pre-csize ".concat(this.reSizeType),
  39276. style: {
  39277. width: "".concat(tempWidth, "px"),
  39278. height: "".concat(tempHeight, "px")
  39279. }
  39280. })
  39281. )
  39282. ),
  39283. clearFix &&
  39284. external_react_default.a.createElement("div", {
  39285. className: "clearfix",
  39286. style: {
  39287. clear: "both",
  39288. height: 0,
  39289. lineHeight: 0,
  39290. float: "none"
  39291. }
  39292. })
  39293. );
  39294. }
  39295. },
  39296. {
  39297. key: "lockEditor",
  39298. value: function lockEditor() {
  39299. this.props.editor.lockOrUnlockEditor(true);
  39300. }
  39301. },
  39302. {
  39303. key: "unlockEditor",
  39304. value: function unlockEditor() {
  39305. this.props.editor.lockOrUnlockEditor(false);
  39306. }
  39307. },
  39308. {
  39309. key: "calcToolbarOffset",
  39310. value: function calcToolbarOffset() {
  39311. var _this$props2 = this.props,
  39312. getContainerNode = _this$props2.getContainerNode,
  39313. containerNode = _this$props2.containerNode;
  39314. var container = getContainerNode
  39315. ? getContainerNode()
  39316. : containerNode;
  39317. if (!container) {
  39318. return 0;
  39319. }
  39320. var viewRect = container
  39321. .querySelector(".bf-content")
  39322. .getBoundingClientRect();
  39323. var toolbarRect = this.toolbarElement.getBoundingClientRect();
  39324. var imageRect = this.imageElement.getBoundingClientRect();
  39325. var right =
  39326. viewRect.right -
  39327. (imageRect.right -
  39328. imageRect.width / 2 +
  39329. toolbarRect.width / 2);
  39330. var left =
  39331. imageRect.left +
  39332. imageRect.width / 2 -
  39333. toolbarRect.width / 2 -
  39334. viewRect.left;
  39335. if (right < 10) {
  39336. return right - 10;
  39337. } else if (left < 10) {
  39338. return left * -1 + 10;
  39339. } else {
  39340. return 0;
  39341. }
  39342. }
  39343. },
  39344. {
  39345. key: "setImageLinkTarget",
  39346. value: function setImageLinkTarget(link_target) {
  39347. var hookReturns = this.props.hooks(
  39348. "set-image-link-target",
  39349. link_target
  39350. )(link_target);
  39351. if (hookReturns === false) {
  39352. return false;
  39353. }
  39354. if (typeof hookReturns === "string") {
  39355. link_target = hookReturns;
  39356. }
  39357. link_target = link_target === "_blank" ? "" : "_blank";
  39358. this.props.editor.setValue(
  39359. external_braft_utils_["ContentUtils"].setMediaData(
  39360. this.props.editor.getValue(),
  39361. this.props.entityKey,
  39362. {
  39363. link_target: link_target
  39364. }
  39365. )
  39366. );
  39367. window.setImmediate(this.props.editor.forceRender);
  39368. }
  39369. }
  39370. ]);
  39371. return Image;
  39372. })(external_react_default.a.Component);
  39373. // EXTERNAL MODULE: ./renderers/atomics/Video/style.scss
  39374. var Video_style = __webpack_require__(47);
  39375. // EXTERNAL MODULE: ./components/common/Modal/style.scss
  39376. var Modal_style = __webpack_require__(48);
  39377. // EXTERNAL MODULE: external "react-dom"
  39378. var external_react_dom_ = __webpack_require__(16);
  39379. var external_react_dom_default = /*#__PURE__*/ __webpack_require__.n(
  39380. external_react_dom_
  39381. );
  39382. // CONCATENATED MODULE: ./components/common/Modal/index.jsx
  39383. var Modal_Modal =
  39384. /*#__PURE__*/
  39385. (function(_React$Component) {
  39386. inherits_default()(Modal, _React$Component);
  39387. function Modal(props) {
  39388. var _this;
  39389. classCallCheck_default()(this, Modal);
  39390. _this = possibleConstructorReturn_default()(
  39391. this,
  39392. getPrototypeOf_default()(Modal).call(this, props)
  39393. );
  39394. defineProperty_default()(
  39395. assertThisInitialized_default()(
  39396. assertThisInitialized_default()(_this)
  39397. ),
  39398. "handleTransitionEnd",
  39399. function() {
  39400. if (!_this.rootElement || !_this.rootElement.classList) {
  39401. return false;
  39402. }
  39403. if (!_this.rootElement.classList.contains("active")) {
  39404. external_react_dom_default.a.unmountComponentAtNode(
  39405. _this.rootElement
  39406. ) &&
  39407. _this.rootElement.parentNode.removeChild(
  39408. _this.rootElement
  39409. );
  39410. }
  39411. }
  39412. );
  39413. defineProperty_default()(
  39414. assertThisInitialized_default()(
  39415. assertThisInitialized_default()(_this)
  39416. ),
  39417. "handleMouseDown",
  39418. function(event) {
  39419. var tagName = event.target.tagName.toLowerCase();
  39420. if (tagName === "input" || tagName === "textarea") {
  39421. return false;
  39422. }
  39423. event.preventDefault();
  39424. }
  39425. );
  39426. defineProperty_default()(
  39427. assertThisInitialized_default()(
  39428. assertThisInitialized_default()(_this)
  39429. ),
  39430. "handleCancel",
  39431. function() {
  39432. _this.props.closeOnCancel && _this.close();
  39433. _this.props.onCancel && _this.props.onCancel();
  39434. }
  39435. );
  39436. defineProperty_default()(
  39437. assertThisInitialized_default()(
  39438. assertThisInitialized_default()(_this)
  39439. ),
  39440. "handleConfirm",
  39441. function() {
  39442. _this.props.closeOnConfirm && _this.close();
  39443. _this.props.onConfirm && _this.props.onConfirm();
  39444. }
  39445. );
  39446. defineProperty_default()(
  39447. assertThisInitialized_default()(
  39448. assertThisInitialized_default()(_this)
  39449. ),
  39450. "handleMaskClick",
  39451. function() {
  39452. _this.props.closeOnBlur && _this.close();
  39453. _this.props.onBlue && _this.props.onBlue();
  39454. }
  39455. );
  39456. defineProperty_default()(
  39457. assertThisInitialized_default()(
  39458. assertThisInitialized_default()(_this)
  39459. ),
  39460. "close",
  39461. function() {
  39462. _this.unrenderComponent();
  39463. _this.props.onClose && _this.props.onClose();
  39464. }
  39465. );
  39466. _this.active = false;
  39467. _this.componentId =
  39468. "BRAFT-MODAL-" +
  39469. external_braft_utils_["BaseUtils"].UniqueIndex();
  39470. return _this;
  39471. }
  39472. createClass_default()(Modal, [
  39473. {
  39474. key: "componentDidMount",
  39475. value: function componentDidMount() {
  39476. if (this.props.visible) {
  39477. this.active = true;
  39478. this.renderComponent(this.props);
  39479. }
  39480. }
  39481. },
  39482. {
  39483. key: "componentWillReceiveProps",
  39484. value: function componentWillReceiveProps(next) {
  39485. if (this.props.visible && !next.visible) {
  39486. this.unrenderComponent();
  39487. } else if (this.props.visible || next.visible) {
  39488. this.active = true;
  39489. this.renderComponent(next);
  39490. }
  39491. }
  39492. },
  39493. {
  39494. key: "render",
  39495. value: function render() {
  39496. return null;
  39497. }
  39498. },
  39499. {
  39500. key: "unrenderComponent",
  39501. value: function unrenderComponent() {
  39502. this.active = false;
  39503. this.activeId && window.clearImmediate(this.activeId);
  39504. if (this.rootElement && this.rootElement.classList) {
  39505. this.rootElement.classList.remove("active");
  39506. }
  39507. }
  39508. },
  39509. {
  39510. key: "renderComponent",
  39511. value: function renderComponent(props) {
  39512. var _this2 = this;
  39513. if (!this.active) {
  39514. return false;
  39515. }
  39516. var title = props.title,
  39517. className = props.className,
  39518. width = props.width,
  39519. height = props.height,
  39520. children = props.children,
  39521. component = props.component,
  39522. confirmable = props.confirmable,
  39523. showFooter = props.showFooter,
  39524. showCancel = props.showCancel,
  39525. showConfirm = props.showConfirm,
  39526. showClose = props.showClose,
  39527. cancelText = props.cancelText,
  39528. confirmText = props.confirmText,
  39529. bottomText = props.bottomText,
  39530. language = props.language;
  39531. typeof showCancel === "undefined" && (showCancel = true);
  39532. typeof showClose === "undefined" && (showClose = true);
  39533. typeof showConfirm === "undefined" && (showConfirm = true);
  39534. typeof showFooter === "undefined" && (showFooter = true);
  39535. var childComponent = external_react_default.a.createElement(
  39536. "div",
  39537. {
  39538. onMouseDown: this.handleMouseDown,
  39539. className: "bf-modal " + (className || "")
  39540. },
  39541. external_react_default.a.createElement("div", {
  39542. className: "bf-modal-mask",
  39543. onClick: this.handleMaskClick
  39544. }),
  39545. external_react_default.a.createElement(
  39546. "div",
  39547. {
  39548. onTransitionEnd: this.handleTransitionEnd,
  39549. style: {
  39550. width: width,
  39551. height: height
  39552. },
  39553. className: "bf-modal-content"
  39554. },
  39555. external_react_default.a.createElement(
  39556. "div",
  39557. {
  39558. className: "bf-modal-header"
  39559. },
  39560. external_react_default.a.createElement(
  39561. "h3",
  39562. {
  39563. className: "bf-modal-caption"
  39564. },
  39565. title
  39566. ),
  39567. showClose &&
  39568. external_react_default.a.createElement(
  39569. "button",
  39570. {
  39571. type: "button",
  39572. onClick: this.close,
  39573. className: "bf-modal-close-button"
  39574. },
  39575. external_react_default.a.createElement("i", {
  39576. className: "bfi-close"
  39577. })
  39578. )
  39579. ),
  39580. external_react_default.a.createElement(
  39581. "div",
  39582. {
  39583. className: "bf-modal-body"
  39584. },
  39585. children || component
  39586. ),
  39587. showFooter
  39588. ? external_react_default.a.createElement(
  39589. "div",
  39590. {
  39591. className: "bf-modal-footer"
  39592. },
  39593. external_react_default.a.createElement(
  39594. "div",
  39595. {
  39596. className: "bf-modal-addon-text"
  39597. },
  39598. bottomText
  39599. ),
  39600. external_react_default.a.createElement(
  39601. "div",
  39602. {
  39603. className: "bf-modal-buttons"
  39604. },
  39605. showCancel &&
  39606. external_react_default.a.createElement(
  39607. "button",
  39608. {
  39609. type: "button",
  39610. onClick: this.handleCancel,
  39611. className: "bf-modal-cancel"
  39612. },
  39613. cancelText || language.base.cancel
  39614. ),
  39615. showConfirm &&
  39616. external_react_default.a.createElement(
  39617. "button",
  39618. {
  39619. type: "button",
  39620. onClick: this.handleConfirm,
  39621. className:
  39622. "bf-modal-confirm " +
  39623. (!confirmable ? "disabled" : "")
  39624. },
  39625. confirmText || language.base.confirm
  39626. )
  39627. )
  39628. )
  39629. : null
  39630. )
  39631. );
  39632. this.rootElement = document.querySelector(
  39633. "#" + this.componentId
  39634. );
  39635. if (!this.rootElement) {
  39636. this.rootElement = document.createElement("div");
  39637. this.rootElement.id = this.componentId;
  39638. this.rootElement.className = "bf-modal-root";
  39639. document.body.appendChild(this.rootElement);
  39640. }
  39641. external_react_dom_default.a.render(
  39642. childComponent,
  39643. this.rootElement
  39644. );
  39645. this.activeId = window.setImmediate(function() {
  39646. _this2.rootElement.classList.add("active");
  39647. });
  39648. }
  39649. }
  39650. ]);
  39651. return Modal;
  39652. })(external_react_default.a.Component);
  39653. defineProperty_default()(Modal_Modal, "defaultProps", {
  39654. showFooter: true,
  39655. closeOnBlur: true
  39656. });
  39657. var Modal_showModal = function showModal(props) {
  39658. var hostNode = document.createElement("div");
  39659. hostNode.style.display = "none";
  39660. document.body.appendChild(hostNode);
  39661. props = objectSpread_default()(
  39662. {
  39663. visible: true,
  39664. closeOnConfirm: true,
  39665. closeOnCancel: true
  39666. },
  39667. props
  39668. );
  39669. var close = function close() {
  39670. external_react_dom_default.a.unmountComponentAtNode(hostNode) &&
  39671. hostNode.parentNode.removeChild(hostNode);
  39672. };
  39673. var onConfirm = function onConfirm() {
  39674. props.onConfirm && props.onConfirm();
  39675. };
  39676. var onCancel = function onCancel() {
  39677. props.onCancel && props.onCancel();
  39678. };
  39679. var onClose = function onClose() {
  39680. close();
  39681. props.onClose && props.onClose();
  39682. };
  39683. var modalInstance = external_react_dom_default.a.render(
  39684. external_react_default.a.createElement(
  39685. Modal_Modal,
  39686. extends_default()({}, props, {
  39687. onConfirm: onConfirm,
  39688. onCancel: onCancel,
  39689. onClose: onClose
  39690. })
  39691. ),
  39692. hostNode
  39693. );
  39694. modalInstance.destroy = close;
  39695. modalInstance.update = modalInstance.renderComponent;
  39696. return modalInstance;
  39697. };
  39698. // EXTERNAL MODULE: ./components/business/PlayerModal/style.scss
  39699. var PlayerModal_style = __webpack_require__(49);
  39700. // CONCATENATED MODULE: ./components/business/PlayerModal/index.jsx
  39701. var PlayerModal_playViaModal = function playViaModal(
  39702. title,
  39703. component,
  39704. language
  39705. ) {
  39706. return Modal_showModal({
  39707. title: title,
  39708. component: component,
  39709. language: language,
  39710. showFooter: false
  39711. });
  39712. };
  39713. var typeIconsMap = {
  39714. video: "bfi-film",
  39715. audio: "bfi-music",
  39716. embed: "bfi-code"
  39717. };
  39718. /* harmony default export */ var PlayerModal = function(_ref) {
  39719. var title = _ref.title,
  39720. type = _ref.type,
  39721. language = _ref.language,
  39722. name = _ref.name,
  39723. url = _ref.url,
  39724. poster = _ref.poster,
  39725. children = _ref.children,
  39726. onRemove = _ref.onRemove;
  39727. return external_react_default.a.createElement(
  39728. "div",
  39729. {
  39730. className: "bf-player-holder ".concat(type)
  39731. },
  39732. external_react_default.a.createElement(
  39733. "div",
  39734. {
  39735. className: "icon-badge"
  39736. },
  39737. external_react_default.a.createElement("i", {
  39738. className: typeIconsMap[type]
  39739. }),
  39740. external_react_default.a.createElement(
  39741. "span",
  39742. {
  39743. className: "text"
  39744. },
  39745. language.media[type]
  39746. )
  39747. ),
  39748. external_react_default.a.createElement(
  39749. "button",
  39750. {
  39751. onMouseDown: onRemove,
  39752. className: "button-remove"
  39753. },
  39754. external_react_default.a.createElement("i", {
  39755. className: "bfi-close"
  39756. })
  39757. ),
  39758. external_react_default.a.createElement(
  39759. "button",
  39760. {
  39761. onMouseDown: function onMouseDown() {
  39762. return PlayerModal_playViaModal(
  39763. name ? "".concat(title, ":").concat(name) : title,
  39764. children,
  39765. language
  39766. );
  39767. },
  39768. className: "button-play"
  39769. },
  39770. external_react_default.a.createElement("i", {
  39771. className: "bfi-play_arrow"
  39772. })
  39773. ),
  39774. name
  39775. ? external_react_default.a.createElement(
  39776. "h5",
  39777. {
  39778. className: "bf-name"
  39779. },
  39780. name
  39781. )
  39782. : null,
  39783. external_react_default.a.createElement(
  39784. "h6",
  39785. {
  39786. className: "bf-url"
  39787. },
  39788. url
  39789. ),
  39790. poster
  39791. ? external_react_default.a.createElement("div", {
  39792. className: "bf-poster",
  39793. style: {
  39794. backgroundImage: "url(".concat(poster, ")")
  39795. }
  39796. })
  39797. : null
  39798. );
  39799. };
  39800. // CONCATENATED MODULE: ./renderers/atomics/Video/index.jsx
  39801. var Video_Video =
  39802. /*#__PURE__*/
  39803. (function(_React$Component) {
  39804. inherits_default()(Video, _React$Component);
  39805. function Video() {
  39806. var _getPrototypeOf2;
  39807. var _this;
  39808. classCallCheck_default()(this, Video);
  39809. for (
  39810. var _len = arguments.length, args = new Array(_len), _key = 0;
  39811. _key < _len;
  39812. _key++
  39813. ) {
  39814. args[_key] = arguments[_key];
  39815. }
  39816. _this = possibleConstructorReturn_default()(
  39817. this,
  39818. (_getPrototypeOf2 = getPrototypeOf_default()(
  39819. Video
  39820. )).call.apply(_getPrototypeOf2, [this].concat(args))
  39821. );
  39822. defineProperty_default()(
  39823. assertThisInitialized_default()(
  39824. assertThisInitialized_default()(_this)
  39825. ),
  39826. "removeVideo",
  39827. function() {
  39828. _this.props.editor.setValue(
  39829. external_braft_utils_["ContentUtils"].removeBlock(
  39830. _this.props.editorState,
  39831. _this.props.block
  39832. )
  39833. );
  39834. }
  39835. );
  39836. return _this;
  39837. }
  39838. createClass_default()(Video, [
  39839. {
  39840. key: "render",
  39841. value: function render() {
  39842. var _this$props = this.props,
  39843. mediaData = _this$props.mediaData,
  39844. language = _this$props.language;
  39845. var url = mediaData.url,
  39846. name = mediaData.name,
  39847. meta = mediaData.meta;
  39848. return external_react_default.a.createElement(
  39849. "div",
  39850. {
  39851. className: "bf-video-wrap"
  39852. },
  39853. external_react_default.a.createElement(
  39854. PlayerModal,
  39855. {
  39856. type: "video",
  39857. onRemove: this.removeVideo,
  39858. poster: meta ? meta.poster || "" : "",
  39859. language: language,
  39860. url: url,
  39861. name: name,
  39862. title: language.videoPlayer.title
  39863. },
  39864. external_react_default.a.createElement(
  39865. "div",
  39866. {
  39867. className: "bf-video-player"
  39868. },
  39869. external_react_default.a.createElement(
  39870. "video",
  39871. {
  39872. controls: true,
  39873. poster: meta ? meta.poster || "" : ""
  39874. },
  39875. external_react_default.a.createElement("source", {
  39876. src: url
  39877. })
  39878. )
  39879. )
  39880. )
  39881. );
  39882. }
  39883. }
  39884. ]);
  39885. return Video;
  39886. })(external_react_default.a.Component);
  39887. // EXTERNAL MODULE: ./renderers/atomics/Audio/style.scss
  39888. var Audio_style = __webpack_require__(50);
  39889. // CONCATENATED MODULE: ./renderers/atomics/Audio/index.jsx
  39890. var Audio_Audio =
  39891. /*#__PURE__*/
  39892. (function(_React$Component) {
  39893. inherits_default()(Audio, _React$Component);
  39894. function Audio() {
  39895. var _getPrototypeOf2;
  39896. var _this;
  39897. classCallCheck_default()(this, Audio);
  39898. for (
  39899. var _len = arguments.length, args = new Array(_len), _key = 0;
  39900. _key < _len;
  39901. _key++
  39902. ) {
  39903. args[_key] = arguments[_key];
  39904. }
  39905. _this = possibleConstructorReturn_default()(
  39906. this,
  39907. (_getPrototypeOf2 = getPrototypeOf_default()(
  39908. Audio
  39909. )).call.apply(_getPrototypeOf2, [this].concat(args))
  39910. );
  39911. defineProperty_default()(
  39912. assertThisInitialized_default()(
  39913. assertThisInitialized_default()(_this)
  39914. ),
  39915. "removeAudio",
  39916. function() {
  39917. _this.props.editor.setValue(
  39918. external_braft_utils_["ContentUtils"].removeBlock(
  39919. _this.props.editorState,
  39920. _this.props.block
  39921. )
  39922. );
  39923. }
  39924. );
  39925. return _this;
  39926. }
  39927. createClass_default()(Audio, [
  39928. {
  39929. key: "render",
  39930. value: function render() {
  39931. var _this$props = this.props,
  39932. mediaData = _this$props.mediaData,
  39933. language = _this$props.language;
  39934. var url = mediaData.url,
  39935. name = mediaData.name,
  39936. meta = mediaData.meta;
  39937. return external_react_default.a.createElement(
  39938. "div",
  39939. {
  39940. className: "bf-audio-wrap"
  39941. },
  39942. external_react_default.a.createElement(
  39943. PlayerModal,
  39944. {
  39945. type: "audio",
  39946. onRemove: this.removeAudio,
  39947. poster: meta ? meta.poster || "" : "",
  39948. language: language,
  39949. url: url,
  39950. name: name,
  39951. title: language.audioPlayer.title
  39952. },
  39953. external_react_default.a.createElement(
  39954. "div",
  39955. {
  39956. className: "bf-audio-player"
  39957. },
  39958. external_react_default.a.createElement("audio", {
  39959. controls: true,
  39960. src: url
  39961. })
  39962. )
  39963. )
  39964. );
  39965. }
  39966. }
  39967. ]);
  39968. return Audio;
  39969. })(external_react_default.a.Component);
  39970. // EXTERNAL MODULE: ./renderers/atomics/Embed/style.scss
  39971. var Embed_style = __webpack_require__(51);
  39972. // CONCATENATED MODULE: ./renderers/atomics/Embed/index.jsx
  39973. var Embed_Embed =
  39974. /*#__PURE__*/
  39975. (function(_React$Component) {
  39976. inherits_default()(Embed, _React$Component);
  39977. function Embed() {
  39978. var _getPrototypeOf2;
  39979. var _this;
  39980. classCallCheck_default()(this, Embed);
  39981. for (
  39982. var _len = arguments.length, args = new Array(_len), _key = 0;
  39983. _key < _len;
  39984. _key++
  39985. ) {
  39986. args[_key] = arguments[_key];
  39987. }
  39988. _this = possibleConstructorReturn_default()(
  39989. this,
  39990. (_getPrototypeOf2 = getPrototypeOf_default()(
  39991. Embed
  39992. )).call.apply(_getPrototypeOf2, [this].concat(args))
  39993. );
  39994. defineProperty_default()(
  39995. assertThisInitialized_default()(
  39996. assertThisInitialized_default()(_this)
  39997. ),
  39998. "removeEmbed",
  39999. function() {
  40000. _this.props.editor.setValue(
  40001. external_braft_utils_["ContentUtils"].removeBlock(
  40002. _this.props.editorState,
  40003. _this.props.block
  40004. )
  40005. );
  40006. }
  40007. );
  40008. return _this;
  40009. }
  40010. createClass_default()(Embed, [
  40011. {
  40012. key: "render",
  40013. value: function render() {
  40014. var _this$props = this.props,
  40015. mediaData = _this$props.mediaData,
  40016. language = _this$props.language;
  40017. var name = mediaData.name,
  40018. url = mediaData.url,
  40019. meta = mediaData.meta;
  40020. return external_react_default.a.createElement(
  40021. "div",
  40022. {
  40023. className: "bf-embed-wrap"
  40024. },
  40025. external_react_default.a.createElement(
  40026. PlayerModal,
  40027. {
  40028. type: "embed",
  40029. onRemove: this.removeEmbed,
  40030. poster: meta ? meta.poster || "" : "",
  40031. language: language,
  40032. url: url,
  40033. name: name,
  40034. title: language.videoPlayer.embedTitle
  40035. },
  40036. external_react_default.a.createElement("div", {
  40037. className: "bf-embed-player",
  40038. dangerouslySetInnerHTML: {
  40039. __html: url
  40040. }
  40041. })
  40042. )
  40043. );
  40044. }
  40045. }
  40046. ]);
  40047. return Embed;
  40048. })(external_react_default.a.Component);
  40049. // EXTERNAL MODULE: ./renderers/atomics/HorizontalLine/style.scss
  40050. var HorizontalLine_style = __webpack_require__(52);
  40051. // CONCATENATED MODULE: ./renderers/atomics/HorizontalLine/index.jsx
  40052. var HorizontalLine_HorizontalLine =
  40053. /*#__PURE__*/
  40054. (function(_React$Component) {
  40055. inherits_default()(HorizontalLine, _React$Component);
  40056. function HorizontalLine() {
  40057. var _getPrototypeOf2;
  40058. var _this;
  40059. classCallCheck_default()(this, HorizontalLine);
  40060. for (
  40061. var _len = arguments.length, args = new Array(_len), _key = 0;
  40062. _key < _len;
  40063. _key++
  40064. ) {
  40065. args[_key] = arguments[_key];
  40066. }
  40067. _this = possibleConstructorReturn_default()(
  40068. this,
  40069. (_getPrototypeOf2 = getPrototypeOf_default()(
  40070. HorizontalLine
  40071. )).call.apply(_getPrototypeOf2, [this].concat(args))
  40072. );
  40073. defineProperty_default()(
  40074. assertThisInitialized_default()(
  40075. assertThisInitialized_default()(_this)
  40076. ),
  40077. "removeHorizontalLine",
  40078. function() {
  40079. _this.props.editor.setValue(
  40080. external_braft_utils_["ContentUtils"].removeBlock(
  40081. _this.props.editorState,
  40082. _this.props.block
  40083. )
  40084. );
  40085. }
  40086. );
  40087. return _this;
  40088. }
  40089. createClass_default()(HorizontalLine, [
  40090. {
  40091. key: "render",
  40092. value: function render() {
  40093. return external_react_default.a.createElement(
  40094. "div",
  40095. {
  40096. className: "bf-hr"
  40097. },
  40098. external_react_default.a.createElement(
  40099. "div",
  40100. {
  40101. className: "bf-media-toolbar"
  40102. },
  40103. external_react_default.a.createElement(
  40104. "a",
  40105. {
  40106. onClick: this.removeHorizontalLine
  40107. },
  40108. "\uE9AC"
  40109. )
  40110. )
  40111. );
  40112. }
  40113. }
  40114. ]);
  40115. return HorizontalLine;
  40116. })(external_react_default.a.Component);
  40117. // CONCATENATED MODULE: ./renderers/block/blockRendererFn.js
  40118. var blockRendererFn_BlockRenderFnContext = function BlockRenderFnContext() {
  40119. var _this = this;
  40120. classCallCheck_default()(this, BlockRenderFnContext);
  40121. defineProperty_default()(this, "superProps", void 0);
  40122. defineProperty_default()(this, "customBlockRendererFn", void 0);
  40123. defineProperty_default()(this, "getRenderFn", function(
  40124. superProps,
  40125. customBlockRendererFn
  40126. ) {
  40127. _this.superProps = superProps;
  40128. _this.customBlockRendererFn = customBlockRendererFn;
  40129. return _this.blockRendererFn;
  40130. });
  40131. defineProperty_default()(this, "renderAtomicBlock", function(
  40132. props
  40133. ) {
  40134. var superProps = _this.superProps;
  40135. var entityKey = props.block.getEntityAt(0);
  40136. if (!entityKey) {
  40137. return null;
  40138. }
  40139. var entity = props.contentState.getEntity(entityKey);
  40140. var mediaData = entity.getData();
  40141. var mediaType = entity.getType();
  40142. var mediaProps = objectSpread_default()({}, superProps, {
  40143. block: props.block,
  40144. mediaData: mediaData,
  40145. entityKey: entityKey
  40146. });
  40147. if (mediaType === "IMAGE") {
  40148. return external_react_default.a.createElement(
  40149. Image_Image,
  40150. mediaProps
  40151. );
  40152. } else if (mediaType === "AUDIO") {
  40153. return external_react_default.a.createElement(
  40154. Audio_Audio,
  40155. mediaProps
  40156. );
  40157. } else if (mediaType === "VIDEO") {
  40158. return external_react_default.a.createElement(
  40159. Video_Video,
  40160. mediaProps
  40161. );
  40162. } else if (mediaType === "EMBED") {
  40163. return external_react_default.a.createElement(
  40164. Embed_Embed,
  40165. mediaProps
  40166. );
  40167. } else if (mediaType === "HR") {
  40168. return external_react_default.a.createElement(
  40169. HorizontalLine_HorizontalLine,
  40170. mediaProps
  40171. );
  40172. }
  40173. if (superProps.extendAtomics) {
  40174. var atomics = superProps.extendAtomics;
  40175. for (var i = 0; i < atomics.length; i++) {
  40176. if (mediaType === atomics[i].type) {
  40177. var Component = atomics[i].component;
  40178. return external_react_default.a.createElement(
  40179. Component,
  40180. mediaProps
  40181. );
  40182. }
  40183. }
  40184. }
  40185. return null;
  40186. });
  40187. defineProperty_default()(this, "blockRendererFn", function(block) {
  40188. var customBlockRendererFn = _this.customBlockRendererFn,
  40189. superProps = _this.superProps;
  40190. var blockType = block.getType();
  40191. var blockRenderer = null;
  40192. if (customBlockRendererFn) {
  40193. blockRenderer =
  40194. customBlockRendererFn(block, superProps) || null;
  40195. }
  40196. if (blockRenderer) {
  40197. return blockRenderer;
  40198. }
  40199. var extensionBlockRendererFns = getExtensionBlockRendererFns(
  40200. superProps.editorId
  40201. );
  40202. extensionBlockRendererFns.find(function(item) {
  40203. if (
  40204. item.blockType === blockType ||
  40205. (item.blockType instanceof RegExp &&
  40206. item.blockType.test(blockType))
  40207. ) {
  40208. blockRenderer = item.rendererFn
  40209. ? item.rendererFn(superProps)
  40210. : null;
  40211. return true;
  40212. }
  40213. });
  40214. if (blockRenderer) {
  40215. return blockRenderer;
  40216. }
  40217. if (blockType === "atomic") {
  40218. blockRenderer = {
  40219. component: _this.renderAtomicBlock,
  40220. editable: false
  40221. };
  40222. }
  40223. return blockRenderer;
  40224. });
  40225. };
  40226. var blockRenderFnContext = new blockRendererFn_BlockRenderFnContext();
  40227. /* harmony default export */ var block_blockRendererFn =
  40228. blockRenderFnContext.getRenderFn;
  40229. // CONCATENATED MODULE: ./renderers/block/blockStyleFn.js
  40230. /* harmony default export */ var block_blockStyleFn = function(
  40231. customBlockStyleFn
  40232. ) {
  40233. return function(block) {
  40234. var blockAlignment =
  40235. block.getData() && block.getData().get("textAlign");
  40236. var blockIndent =
  40237. block.getData() && block.getData().get("textIndent");
  40238. var blockFloat = block.getData() && block.getData().get("float");
  40239. var result = "";
  40240. if (blockAlignment) {
  40241. result = "bfa-".concat(blockAlignment);
  40242. }
  40243. if (blockIndent && blockIndent !== 0) {
  40244. result += " bftd-".concat(blockIndent);
  40245. }
  40246. if (blockFloat) {
  40247. result += " bff-".concat(blockFloat);
  40248. }
  40249. if (customBlockStyleFn) {
  40250. result += customBlockStyleFn(block) || "";
  40251. }
  40252. return result;
  40253. };
  40254. };
  40255. // CONCATENATED MODULE: ./renderers/inline/inlineStyleMap.js
  40256. /* harmony default export */ var inlineStyleMap = function(props) {
  40257. var customStyleMap =
  40258. arguments.length > 1 && arguments[1] !== undefined
  40259. ? arguments[1]
  40260. : {};
  40261. var extensionInlineStyleMap = getExtensionInlineStyleMap(
  40262. props.editorId
  40263. );
  40264. return objectSpread_default()(
  40265. {
  40266. SUPERSCRIPT: {
  40267. position: "relative",
  40268. top: "-8px",
  40269. fontSize: "11px"
  40270. },
  40271. SUBSCRIPT: {
  40272. position: "relative",
  40273. bottom: "-8px",
  40274. fontSize: "11px"
  40275. }
  40276. },
  40277. extensionInlineStyleMap,
  40278. customStyleMap
  40279. );
  40280. };
  40281. // CONCATENATED MODULE: ./renderers/inline/inlineStyleFn.js
  40282. var getStyleValue = function getStyleValue(style) {
  40283. return style.split("-")[1];
  40284. };
  40285. /* harmony default export */ var inlineStyleFn = function(
  40286. props,
  40287. options
  40288. ) {
  40289. return function(styles, block) {
  40290. var output = {};
  40291. var fontFamilies = options.fontFamilies,
  40292. unitExportFn = options.unitExportFn,
  40293. customStyleFn = options.customStyleFn;
  40294. var extensionInlineStyleFns = getExtensionInlineStyleFns(
  40295. props.editorId
  40296. );
  40297. extensionInlineStyleFns.forEach(function(item) {
  40298. output = item.styleFn
  40299. ? item.styleFn(styles, block, output)
  40300. : output;
  40301. });
  40302. output = customStyleFn
  40303. ? customStyleFn(styles, block, output)
  40304. : {};
  40305. styles.forEach(function(style) {
  40306. if (style.indexOf("COLOR-") === 0) {
  40307. output.color = "#" + getStyleValue(style);
  40308. } else if (style.indexOf("BGCOLOR-") === 0) {
  40309. output.backgroundColor = "#" + getStyleValue(style);
  40310. } else if (style.indexOf("FONTSIZE-") === 0) {
  40311. output.fontSize = unitExportFn(
  40312. getStyleValue(style),
  40313. "font-size",
  40314. "editor"
  40315. );
  40316. } else if (style.indexOf("LINEHEIGHT-") === 0) {
  40317. output.lineHeight = unitExportFn(
  40318. getStyleValue(style),
  40319. "line-height",
  40320. "editor"
  40321. );
  40322. } else if (style.indexOf("LETTERSPACING-") === 0) {
  40323. output.letterSpacing = unitExportFn(
  40324. getStyleValue(style),
  40325. "letter-spacing",
  40326. "editor"
  40327. );
  40328. } else if (style.indexOf("TEXTINDENT-") === 0) {
  40329. output.textIndent = unitExportFn(
  40330. getStyleValue(style),
  40331. "text-indent",
  40332. "editor"
  40333. );
  40334. } else if (style.indexOf("FONTFAMILY-") === 0) {
  40335. output.fontFamily =
  40336. (
  40337. fontFamilies.find(function(item) {
  40338. return item.name.toUpperCase() === getStyleValue(style);
  40339. }) || {}
  40340. ).family || "";
  40341. }
  40342. });
  40343. return output;
  40344. };
  40345. };
  40346. // EXTERNAL MODULE: ../node_modules/draft-js-multidecorators/index.js
  40347. var draft_js_multidecorators = __webpack_require__(18);
  40348. var draft_js_multidecorators_default = /*#__PURE__*/ __webpack_require__.n(
  40349. draft_js_multidecorators
  40350. );
  40351. // CONCATENATED MODULE: ./renderers/decorators/Link/index.jsx
  40352. /* harmony default export */ var Link = function(props) {
  40353. var children = props.children,
  40354. entityKey = props.entityKey,
  40355. contentState = props.contentState;
  40356. var _contentState$getEnti = contentState
  40357. .getEntity(entityKey)
  40358. .getData(),
  40359. href = _contentState$getEnti.href,
  40360. target = _contentState$getEnti.target;
  40361. return external_react_default.a.createElement(
  40362. "span",
  40363. {
  40364. className: "bf-link-wrap"
  40365. },
  40366. external_react_default.a.createElement(
  40367. "a",
  40368. {
  40369. onClick: function onClick(event) {
  40370. return viewLink(event, href);
  40371. },
  40372. className: "bf-link",
  40373. href: href,
  40374. target: target
  40375. },
  40376. children
  40377. )
  40378. );
  40379. };
  40380. var viewLink = function viewLink(event, link) {
  40381. // 当按下Ctrl/command键时,点击打开链接文字中的url
  40382. if (
  40383. event.getModifierState("Control") ||
  40384. event.getModifierState("Meta")
  40385. ) {
  40386. var tempLink = document.createElement("a");
  40387. tempLink.href = link;
  40388. tempLink.target = event.currentTarget.target;
  40389. tempLink.click();
  40390. }
  40391. };
  40392. // CONCATENATED MODULE: ./renderers/decorators/index.js
  40393. var KEY_SEPARATOR = "-";
  40394. draft_js_multidecorators_default.a.prototype.getDecorations = function(
  40395. block,
  40396. contentState
  40397. ) {
  40398. var decorations = Array(block.getText().length).fill(null);
  40399. this.decorators.forEach(function(decorator, i) {
  40400. decorator
  40401. .getDecorations(block, contentState)
  40402. .forEach(function(key, offset) {
  40403. if (!key) {
  40404. return;
  40405. }
  40406. key = i + KEY_SEPARATOR + key;
  40407. decorations[offset] = key;
  40408. });
  40409. });
  40410. return external_immutable_default.a.List(decorations);
  40411. };
  40412. var builtinDecorators = [
  40413. {
  40414. type: "entity",
  40415. decorator: {
  40416. key: "LINK",
  40417. component: Link
  40418. }
  40419. }
  40420. ];
  40421. var createStrategy = function createStrategy(type) {
  40422. return function(block, callback, contentState) {
  40423. block.findEntityRanges(function(character) {
  40424. var entityKey = character.getEntity();
  40425. return (
  40426. entityKey !== null &&
  40427. contentState.getEntity(entityKey).getType() === type
  40428. );
  40429. }, callback);
  40430. };
  40431. };
  40432. /* harmony default export */ var decorators = function(editorId) {
  40433. var extensionDecorators = getExtensionDecorators(editorId);
  40434. var entityDecorators = builtinDecorators.concat(
  40435. toConsumableArray_default()(
  40436. extensionDecorators.filter(function(item) {
  40437. return item.type === "entity";
  40438. })
  40439. )
  40440. );
  40441. var strategyDecorators = extensionDecorators.filter(function(item) {
  40442. return item.type === "strategy";
  40443. });
  40444. var classDecorators = extensionDecorators.filter(function(item) {
  40445. return item.type === "class";
  40446. });
  40447. return new draft_js_multidecorators_default.a(
  40448. toConsumableArray_default()(
  40449. classDecorators.map(function(item) {
  40450. return item.decorator;
  40451. })
  40452. ).concat([
  40453. // combine decorators created with strategy
  40454. new external_draft_js_["CompositeDecorator"](
  40455. strategyDecorators.map(function(item) {
  40456. return item.decorator;
  40457. })
  40458. ), // combine decorators for entities
  40459. new external_draft_js_["CompositeDecorator"](
  40460. entityDecorators.map(function(item) {
  40461. return {
  40462. strategy: createStrategy(item.decorator.key),
  40463. component: item.decorator.component
  40464. };
  40465. })
  40466. )
  40467. ])
  40468. );
  40469. };
  40470. // CONCATENATED MODULE: ./renderers/index.js
  40471. var getBlockRenderMap = block_blockRenderMap;
  40472. var getBlockRendererFn = block_blockRendererFn;
  40473. var getBlockStyleFn = block_blockStyleFn;
  40474. var getCustomStyleMap = inlineStyleMap;
  40475. var getCustomStyleFn = inlineStyleFn;
  40476. var getDecorators = decorators;
  40477. // EXTERNAL MODULE: ./components/business/ControlBar/style.scss
  40478. var ControlBar_style = __webpack_require__(53);
  40479. // EXTERNAL MODULE: ./components/business/LinkEditor/style.scss
  40480. var LinkEditor_style = __webpack_require__(54);
  40481. // EXTERNAL MODULE: ./components/common/DropDown/style.scss
  40482. var DropDown_style = __webpack_require__(55);
  40483. // CONCATENATED MODULE: ./helpers/responsive.js
  40484. var resizeEventHandlers = [];
  40485. var responsiveHelperInited = false;
  40486. var debouce = false;
  40487. /* harmony default export */ var responsive = {
  40488. resolve: function resolve(eventHandler) {
  40489. var id = external_braft_utils_["BaseUtils"].UniqueIndex();
  40490. resizeEventHandlers.push({
  40491. id: id,
  40492. eventHandler: eventHandler
  40493. });
  40494. return id;
  40495. },
  40496. unresolve: function unresolve(id) {
  40497. resizeEventHandlers = resizeEventHandlers.filter(function(item) {
  40498. return item.id !== id;
  40499. });
  40500. }
  40501. };
  40502. if (
  40503. !responsiveHelperInited &&
  40504. (typeof window === "undefined"
  40505. ? "undefined"
  40506. : typeof_default()(window)) === "object"
  40507. ) {
  40508. window.addEventListener("resize", function(event) {
  40509. clearTimeout(debouce);
  40510. debouce = setTimeout(function() {
  40511. resizeEventHandlers.map(function(item) {
  40512. typeof item.eventHandler === "function" &&
  40513. item.eventHandler(event);
  40514. });
  40515. debouce = false;
  40516. }, 100);
  40517. });
  40518. responsiveHelperInited = true;
  40519. }
  40520. // CONCATENATED MODULE: ./components/common/DropDown/index.jsx
  40521. var DropDown_DropDown =
  40522. /*#__PURE__*/
  40523. (function(_React$Component) {
  40524. inherits_default()(DropDown, _React$Component);
  40525. function DropDown() {
  40526. var _getPrototypeOf2;
  40527. var _this;
  40528. classCallCheck_default()(this, DropDown);
  40529. for (
  40530. var _len = arguments.length, args = new Array(_len), _key = 0;
  40531. _key < _len;
  40532. _key++
  40533. ) {
  40534. args[_key] = arguments[_key];
  40535. }
  40536. _this = possibleConstructorReturn_default()(
  40537. this,
  40538. (_getPrototypeOf2 = getPrototypeOf_default()(
  40539. DropDown
  40540. )).call.apply(_getPrototypeOf2, [this].concat(args))
  40541. );
  40542. defineProperty_default()(
  40543. assertThisInitialized_default()(
  40544. assertThisInitialized_default()(_this)
  40545. ),
  40546. "responsiveResolveId",
  40547. null
  40548. );
  40549. defineProperty_default()(
  40550. assertThisInitialized_default()(
  40551. assertThisInitialized_default()(_this)
  40552. ),
  40553. "dropDownHandlerElement",
  40554. null
  40555. );
  40556. defineProperty_default()(
  40557. assertThisInitialized_default()(
  40558. assertThisInitialized_default()(_this)
  40559. ),
  40560. "dropDownContentElement",
  40561. null
  40562. );
  40563. defineProperty_default()(
  40564. assertThisInitialized_default()(
  40565. assertThisInitialized_default()(_this)
  40566. ),
  40567. "state",
  40568. {
  40569. active: false,
  40570. offset: 0
  40571. }
  40572. );
  40573. defineProperty_default()(
  40574. assertThisInitialized_default()(
  40575. assertThisInitialized_default()(_this)
  40576. ),
  40577. "fixDropDownPosition",
  40578. function() {
  40579. var viewRect = _this.props
  40580. .getContainerNode()
  40581. .getBoundingClientRect();
  40582. var handlerRect = _this.dropDownHandlerElement.getBoundingClientRect();
  40583. var contentRect = _this.dropDownContentElement.getBoundingClientRect();
  40584. var offset = 0;
  40585. var right =
  40586. handlerRect.right -
  40587. handlerRect.width / 2 +
  40588. contentRect.width / 2;
  40589. var left =
  40590. handlerRect.left +
  40591. handlerRect.width / 2 -
  40592. contentRect.width / 2;
  40593. right = viewRect.right - right;
  40594. left = left - viewRect.left;
  40595. if (right < 10) {
  40596. offset = right - 10;
  40597. } else if (left < 10) {
  40598. offset = left * -1 + 10;
  40599. }
  40600. if (offset !== _this.state.offset) {
  40601. _this.setState({
  40602. offset: offset
  40603. });
  40604. }
  40605. }
  40606. );
  40607. defineProperty_default()(
  40608. assertThisInitialized_default()(
  40609. assertThisInitialized_default()(_this)
  40610. ),
  40611. "registerClickEvent",
  40612. function(event) {
  40613. var autoHide = _this.props.autoHide;
  40614. var active = _this.state.active;
  40615. if (
  40616. _this.dropDownContentElement.contains(event.target) ||
  40617. _this.dropDownHandlerElement.contains(event.target)
  40618. ) {
  40619. return false;
  40620. }
  40621. autoHide && active && _this.hide();
  40622. }
  40623. );
  40624. defineProperty_default()(
  40625. assertThisInitialized_default()(
  40626. assertThisInitialized_default()(_this)
  40627. ),
  40628. "toggle",
  40629. function() {
  40630. _this.setState({
  40631. active: !_this.state.active
  40632. });
  40633. }
  40634. );
  40635. defineProperty_default()(
  40636. assertThisInitialized_default()(
  40637. assertThisInitialized_default()(_this)
  40638. ),
  40639. "show",
  40640. function() {
  40641. _this.setState({
  40642. active: true
  40643. });
  40644. }
  40645. );
  40646. defineProperty_default()(
  40647. assertThisInitialized_default()(
  40648. assertThisInitialized_default()(_this)
  40649. ),
  40650. "hide",
  40651. function() {
  40652. _this.setState({
  40653. active: false
  40654. });
  40655. }
  40656. );
  40657. return _this;
  40658. }
  40659. createClass_default()(DropDown, [
  40660. {
  40661. key: "componentDidMount",
  40662. value: function componentDidMount() {
  40663. if (document) {
  40664. document.body.addEventListener(
  40665. "click",
  40666. this.registerClickEvent
  40667. );
  40668. this.responsiveResolveId = responsive.resolve(
  40669. this.fixDropDownPosition
  40670. );
  40671. }
  40672. }
  40673. },
  40674. {
  40675. key: "componentWillReceiveProps",
  40676. value: function componentWillReceiveProps(next) {
  40677. if (!this.props.disabled && next.disabled) {
  40678. this.hide();
  40679. }
  40680. }
  40681. },
  40682. {
  40683. key: "componentDidUpdate",
  40684. value: function componentDidUpdate(prevState) {
  40685. if (!prevState.active && this.state.active) {
  40686. this.fixDropDownPosition();
  40687. }
  40688. }
  40689. },
  40690. {
  40691. key: "componentWillUnmount",
  40692. value: function componentWillUnmount() {
  40693. if (document) {
  40694. document.body.removeEventListener(
  40695. "click",
  40696. this.registerClickEvent
  40697. );
  40698. responsive.unresolve(this.responsiveResolveId);
  40699. }
  40700. }
  40701. },
  40702. {
  40703. key: "render",
  40704. value: function render() {
  40705. var _this2 = this;
  40706. var _this$state = this.state,
  40707. active = _this$state.active,
  40708. offset = _this$state.offset;
  40709. var _this$props = this.props,
  40710. caption = _this$props.caption,
  40711. htmlCaption = _this$props.htmlCaption,
  40712. title = _this$props.title,
  40713. disabled = _this$props.disabled,
  40714. showArrow = _this$props.showArrow,
  40715. arrowActive = _this$props.arrowActive,
  40716. className = _this$props.className,
  40717. children = _this$props.children,
  40718. theme = _this$props.theme;
  40719. disabled && (active = false);
  40720. theme === "light" &&
  40721. (className = " light-theme " + className);
  40722. return external_react_default.a.createElement(
  40723. "div",
  40724. {
  40725. className:
  40726. "bf-dropdown " +
  40727. (active ? "active " : "") +
  40728. (disabled ? "disabled " : "") +
  40729. className
  40730. },
  40731. htmlCaption
  40732. ? external_react_default.a.createElement("button", {
  40733. type: "button",
  40734. className: "dropdown-handler",
  40735. "data-title": title,
  40736. onClick: this.toggle,
  40737. dangerouslySetInnerHTML: htmlCaption
  40738. ? {
  40739. __html: htmlCaption
  40740. }
  40741. : null,
  40742. ref: function ref(instance) {
  40743. return (_this2.dropDownHandlerElement = instance);
  40744. }
  40745. })
  40746. : external_react_default.a.createElement(
  40747. "button",
  40748. {
  40749. type: "button",
  40750. className: "dropdown-handler",
  40751. "data-title": title,
  40752. onClick: this.toggle,
  40753. ref: function ref(instance) {
  40754. return (_this2.dropDownHandlerElement = instance);
  40755. }
  40756. },
  40757. external_react_default.a.createElement(
  40758. "span",
  40759. null,
  40760. caption
  40761. ),
  40762. showArrow !== false
  40763. ? external_react_default.a.createElement("i", {
  40764. className: "bfi-drop-down"
  40765. })
  40766. : null
  40767. ),
  40768. external_react_default.a.createElement(
  40769. "div",
  40770. {
  40771. className: "dropdown-content",
  40772. style: {
  40773. marginLeft: offset
  40774. },
  40775. ref: function ref(instance) {
  40776. return (_this2.dropDownContentElement = instance);
  40777. }
  40778. },
  40779. external_react_default.a.createElement("i", {
  40780. style: {
  40781. marginLeft: offset * -1
  40782. },
  40783. className:
  40784. "dropdown-arrow" + (arrowActive ? " active" : "")
  40785. }),
  40786. external_react_default.a.createElement(
  40787. "div",
  40788. {
  40789. className: "dropdown-content-inner"
  40790. },
  40791. children
  40792. )
  40793. )
  40794. );
  40795. }
  40796. }
  40797. ]);
  40798. return DropDown;
  40799. })(external_react_default.a.Component);
  40800. // CONCATENATED MODULE: ./components/business/ControlGroup/index.jsx
  40801. /* harmony default export */ var ControlGroup = function(props) {
  40802. if (external_react_default.a.Fragment) {
  40803. return external_react_default.a.createElement(
  40804. external_react_default.a.Fragment,
  40805. null,
  40806. props.children
  40807. );
  40808. } else {
  40809. return external_react_default.a.createElement(
  40810. "div",
  40811. {
  40812. className: "control-item-group"
  40813. },
  40814. props.children
  40815. );
  40816. }
  40817. };
  40818. // CONCATENATED MODULE: ./components/business/LinkEditor/index.jsx
  40819. var LinkEditor_LinkEditor =
  40820. /*#__PURE__*/
  40821. (function(_React$Component) {
  40822. inherits_default()(LinkEditor, _React$Component);
  40823. function LinkEditor(props) {
  40824. var _this;
  40825. classCallCheck_default()(this, LinkEditor);
  40826. _this = possibleConstructorReturn_default()(
  40827. this,
  40828. getPrototypeOf_default()(LinkEditor).call(this, props)
  40829. );
  40830. defineProperty_default()(
  40831. assertThisInitialized_default()(
  40832. assertThisInitialized_default()(_this)
  40833. ),
  40834. "dropDownInstance",
  40835. null
  40836. );
  40837. defineProperty_default()(
  40838. assertThisInitialized_default()(
  40839. assertThisInitialized_default()(_this)
  40840. ),
  40841. "handeKeyDown",
  40842. function(e) {
  40843. if (e.keyCode === 13) {
  40844. _this.handleConfirm();
  40845. e.preventDefault();
  40846. return false;
  40847. }
  40848. }
  40849. );
  40850. defineProperty_default()(
  40851. assertThisInitialized_default()(
  40852. assertThisInitialized_default()(_this)
  40853. ),
  40854. "handleTnputText",
  40855. function(e) {
  40856. _this.setState({
  40857. text: e.currentTarget.value
  40858. });
  40859. }
  40860. );
  40861. defineProperty_default()(
  40862. assertThisInitialized_default()(
  40863. assertThisInitialized_default()(_this)
  40864. ),
  40865. "handleInputLink",
  40866. function(e) {
  40867. _this.setState({
  40868. href: e.currentTarget.value
  40869. });
  40870. }
  40871. );
  40872. defineProperty_default()(
  40873. assertThisInitialized_default()(
  40874. assertThisInitialized_default()(_this)
  40875. ),
  40876. "setTarget",
  40877. function() {
  40878. _this.setState({
  40879. target: _this.state.target === "_blank" ? "" : "_blank"
  40880. });
  40881. }
  40882. );
  40883. defineProperty_default()(
  40884. assertThisInitialized_default()(
  40885. assertThisInitialized_default()(_this)
  40886. ),
  40887. "handleCancel",
  40888. function() {
  40889. _this.dropDownInstance.hide();
  40890. }
  40891. );
  40892. defineProperty_default()(
  40893. assertThisInitialized_default()(
  40894. assertThisInitialized_default()(_this)
  40895. ),
  40896. "handleUnlink",
  40897. function() {
  40898. _this.dropDownInstance.hide();
  40899. _this.props.editor.setValue(
  40900. external_braft_utils_["ContentUtils"].toggleSelectionLink(
  40901. _this.props.editorState,
  40902. false
  40903. )
  40904. );
  40905. }
  40906. );
  40907. defineProperty_default()(
  40908. assertThisInitialized_default()(
  40909. assertThisInitialized_default()(_this)
  40910. ),
  40911. "handleConfirm",
  40912. function() {
  40913. var _this$state = _this.state,
  40914. text = _this$state.text,
  40915. href = _this$state.href,
  40916. target = _this$state.target,
  40917. textSelected = _this$state.textSelected;
  40918. var hookReturns = _this.props.hooks("toggle-link", {
  40919. href: href,
  40920. target: target
  40921. })({
  40922. href: href,
  40923. target: target
  40924. });
  40925. _this.dropDownInstance.hide();
  40926. _this.props.editor.requestFocus();
  40927. if (hookReturns === false) {
  40928. return false;
  40929. }
  40930. if (hookReturns) {
  40931. typeof hookReturns.href === "string" &&
  40932. (href = hookReturns.href);
  40933. typeof hookReturns.target === "string" &&
  40934. (target = hookReturns.target);
  40935. }
  40936. if (textSelected) {
  40937. if (href) {
  40938. _this.props.editor.setValue(
  40939. external_braft_utils_[
  40940. "ContentUtils"
  40941. ].toggleSelectionLink(
  40942. _this.props.editorState,
  40943. href,
  40944. target
  40945. )
  40946. );
  40947. } else {
  40948. _this.props.editor.setValue(
  40949. external_braft_utils_[
  40950. "ContentUtils"
  40951. ].toggleSelectionLink(_this.props.editorState, false)
  40952. );
  40953. }
  40954. } else {
  40955. _this.props.editor.setValue(
  40956. external_braft_utils_["ContentUtils"].insertText(
  40957. _this.props.editorState,
  40958. text || href,
  40959. null,
  40960. {
  40961. type: "LINK",
  40962. data: {
  40963. href: href,
  40964. target: target
  40965. }
  40966. }
  40967. )
  40968. );
  40969. }
  40970. }
  40971. );
  40972. _this.state = {
  40973. text: "",
  40974. href: "",
  40975. target: props.defaultLinkTarget || "",
  40976. textSelected: false
  40977. };
  40978. return _this;
  40979. }
  40980. createClass_default()(LinkEditor, [
  40981. {
  40982. key: "componentWillReceiveProps",
  40983. value: function componentWillReceiveProps(nextProps) {
  40984. var _ContentUtils$getSele = external_braft_utils_[
  40985. "ContentUtils"
  40986. ].getSelectionEntityData(nextProps.editorState, "LINK"),
  40987. href = _ContentUtils$getSele.href,
  40988. target = _ContentUtils$getSele.target;
  40989. var textSelected =
  40990. !external_braft_utils_[
  40991. "ContentUtils"
  40992. ].isSelectionCollapsed(this.props.editorState) &&
  40993. external_braft_utils_[
  40994. "ContentUtils"
  40995. ].getSelectionBlockType(this.props.editorState) !==
  40996. "atomic";
  40997. var selectedText = "";
  40998. if (textSelected) {
  40999. selectedText = external_braft_utils_[
  41000. "ContentUtils"
  41001. ].getSelectionText(this.props.editorState);
  41002. }
  41003. this.setState({
  41004. textSelected: textSelected,
  41005. text: selectedText,
  41006. href: href || "",
  41007. target:
  41008. typeof target === "undefined"
  41009. ? nextProps.defaultLinkTarget || ""
  41010. : target || ""
  41011. });
  41012. }
  41013. },
  41014. {
  41015. key: "render",
  41016. value: function render() {
  41017. var _this2 = this;
  41018. var allowInsertLinkText = this.props.allowInsertLinkText;
  41019. var _this$state2 = this.state,
  41020. text = _this$state2.text,
  41021. href = _this$state2.href,
  41022. target = _this$state2.target,
  41023. textSelected = _this$state2.textSelected;
  41024. var caption = external_react_default.a.createElement("i", {
  41025. className: "bfi-link"
  41026. });
  41027. return external_react_default.a.createElement(
  41028. ControlGroup,
  41029. null,
  41030. external_react_default.a.createElement(
  41031. DropDown_DropDown,
  41032. {
  41033. key: 0,
  41034. caption: caption,
  41035. title: this.props.language.controls.link,
  41036. autoHide: true,
  41037. getContainerNode: this.props.getContainerNode,
  41038. showArrow: false,
  41039. ref: function ref(instance) {
  41040. return (_this2.dropDownInstance = instance);
  41041. },
  41042. className:
  41043. "control-item dropdown link-editor-dropdown"
  41044. },
  41045. external_react_default.a.createElement(
  41046. "div",
  41047. {
  41048. className: "bf-link-editor"
  41049. },
  41050. allowInsertLinkText
  41051. ? external_react_default.a.createElement(
  41052. "div",
  41053. {
  41054. className: "input-group"
  41055. },
  41056. external_react_default.a.createElement(
  41057. "input",
  41058. {
  41059. type: "text",
  41060. value: text,
  41061. spellCheck: false,
  41062. disabled: textSelected,
  41063. placeholder: this.props.language.linkEditor
  41064. .textInputPlaceHolder,
  41065. onKeyDown: this.handeKeyDown,
  41066. onChange: this.handleTnputText
  41067. }
  41068. )
  41069. )
  41070. : null,
  41071. external_react_default.a.createElement(
  41072. "div",
  41073. {
  41074. className: "input-group"
  41075. },
  41076. external_react_default.a.createElement("input", {
  41077. type: "text",
  41078. value: href,
  41079. spellCheck: false,
  41080. placeholder: this.props.language.linkEditor
  41081. .linkInputPlaceHolder,
  41082. onKeyDown: this.handeKeyDown,
  41083. onChange: this.handleInputLink
  41084. })
  41085. ),
  41086. external_react_default.a.createElement(
  41087. "div",
  41088. {
  41089. className: "switch-group"
  41090. },
  41091. external_react_default.a.createElement(Switch, {
  41092. active: target === "_blank",
  41093. onClick: this.setTarget
  41094. }),
  41095. external_react_default.a.createElement(
  41096. "label",
  41097. null,
  41098. this.props.language.linkEditor.openInNewWindow
  41099. )
  41100. ),
  41101. external_react_default.a.createElement(
  41102. "div",
  41103. {
  41104. className: "buttons"
  41105. },
  41106. external_react_default.a.createElement(
  41107. "a",
  41108. {
  41109. onClick: this.handleUnlink,
  41110. className:
  41111. "primary button-remove-link pull-left"
  41112. },
  41113. external_react_default.a.createElement("i", {
  41114. className: "bfi-close"
  41115. }),
  41116. external_react_default.a.createElement(
  41117. "span",
  41118. null,
  41119. this.props.language.linkEditor.removeLink
  41120. )
  41121. ),
  41122. external_react_default.a.createElement(
  41123. "button",
  41124. {
  41125. type: "button",
  41126. onClick: this.handleConfirm,
  41127. className: "primary pull-right"
  41128. },
  41129. this.props.language.base.confirm
  41130. ),
  41131. external_react_default.a.createElement(
  41132. "button",
  41133. {
  41134. type: "button",
  41135. onClick: this.handleCancel,
  41136. className: "default pull-right"
  41137. },
  41138. this.props.language.base.cancel
  41139. )
  41140. )
  41141. )
  41142. ),
  41143. external_react_default.a.createElement(
  41144. "button",
  41145. {
  41146. key: 1,
  41147. type: "button",
  41148. "data-title": this.props.language.controls.unlink,
  41149. className: "control-item button",
  41150. onClick: this.handleUnlink,
  41151. disabled: !textSelected || !href
  41152. },
  41153. external_react_default.a.createElement("i", {
  41154. className: "bfi-link-off"
  41155. })
  41156. )
  41157. );
  41158. }
  41159. }
  41160. ]);
  41161. return LinkEditor;
  41162. })(external_react_default.a.Component);
  41163. // EXTERNAL MODULE: ./components/business/Headings/style.scss
  41164. var Headings_style = __webpack_require__(56);
  41165. // CONCATENATED MODULE: ./configs/maps.js
  41166. var maps_getHeadings = function getHeadings(lang) {
  41167. return [
  41168. {
  41169. key: "header-one",
  41170. title: lang.controls.header + " 1",
  41171. text: external_react_default.a.createElement(
  41172. "h1",
  41173. null,
  41174. lang.controls.header,
  41175. " 1"
  41176. ),
  41177. type: "block-type",
  41178. command: "header-one"
  41179. },
  41180. {
  41181. key: "header-two",
  41182. title: lang.controls.header + " 2",
  41183. text: external_react_default.a.createElement(
  41184. "h2",
  41185. null,
  41186. lang.controls.header,
  41187. " 2"
  41188. ),
  41189. type: "block-type",
  41190. command: "header-two"
  41191. },
  41192. {
  41193. key: "header-three",
  41194. title: lang.controls.header + " 3",
  41195. text: external_react_default.a.createElement(
  41196. "h3",
  41197. null,
  41198. lang.controls.header,
  41199. " 3"
  41200. ),
  41201. type: "block-type",
  41202. command: "header-three"
  41203. },
  41204. {
  41205. key: "header-four",
  41206. title: lang.controls.header + " 4",
  41207. text: external_react_default.a.createElement(
  41208. "h4",
  41209. null,
  41210. lang.controls.header,
  41211. " 4"
  41212. ),
  41213. type: "block-type",
  41214. command: "header-four"
  41215. },
  41216. {
  41217. key: "header-five",
  41218. title: lang.controls.header + " 5",
  41219. text: external_react_default.a.createElement(
  41220. "h5",
  41221. null,
  41222. lang.controls.header,
  41223. " 5"
  41224. ),
  41225. type: "block-type",
  41226. command: "header-five"
  41227. },
  41228. {
  41229. key: "header-six",
  41230. title: lang.controls.header + " 6",
  41231. text: external_react_default.a.createElement(
  41232. "h6",
  41233. null,
  41234. lang.controls.header,
  41235. " 6"
  41236. ),
  41237. type: "block-type",
  41238. command: "header-six"
  41239. },
  41240. {
  41241. key: "unstyled",
  41242. title: lang.controls.normal,
  41243. text: lang.controls.normal,
  41244. type: "block-type",
  41245. command: "unstyled"
  41246. }
  41247. ];
  41248. };
  41249. // CONCATENATED MODULE: ./components/business/Headings/index.jsx
  41250. /* harmony default export */ var Headings = function(props) {
  41251. var dropDownInstance = null;
  41252. var headings = maps_getHeadings(props.language).filter(function(
  41253. item
  41254. ) {
  41255. return props.headings.indexOf(item.key) !== -1;
  41256. });
  41257. var currentHeadingIndex = headings.findIndex(function(item) {
  41258. return item.command === props.current;
  41259. });
  41260. var caption = headings[currentHeadingIndex]
  41261. ? headings[currentHeadingIndex].title
  41262. : props.language.controls.normal;
  41263. return external_react_default.a.createElement(
  41264. DropDown_DropDown,
  41265. {
  41266. caption: caption,
  41267. autoHide: true,
  41268. getContainerNode: props.getContainerNode,
  41269. title: props.language.controls.headings,
  41270. arrowActive: currentHeadingIndex === 0,
  41271. ref: function ref(instance) {
  41272. return (dropDownInstance = instance);
  41273. },
  41274. className: "control-item dropdown headings-dropdown"
  41275. },
  41276. external_react_default.a.createElement(
  41277. "ul",
  41278. {
  41279. className: "menu"
  41280. },
  41281. headings.map(function(item, index) {
  41282. var isActive = props.current === item.command;
  41283. return external_react_default.a.createElement(
  41284. "li",
  41285. {
  41286. key: index,
  41287. className: "menu-item" + (isActive ? " active" : ""),
  41288. onClick: function onClick() {
  41289. props.onChange(item.command, item.type),
  41290. dropDownInstance.hide();
  41291. }
  41292. },
  41293. item.text
  41294. );
  41295. })
  41296. )
  41297. );
  41298. };
  41299. // EXTERNAL MODULE: ./components/business/TextColor/style.scss
  41300. var TextColor_style = __webpack_require__(57);
  41301. // EXTERNAL MODULE: ./components/common/ColorPicker/style.scss
  41302. var ColorPicker_style = __webpack_require__(58);
  41303. // CONCATENATED MODULE: ./components/common/ColorPicker/index.jsx
  41304. /* harmony default export */ var common_ColorPicker = function(
  41305. props
  41306. ) {
  41307. return external_react_default.a.createElement(
  41308. "div",
  41309. {
  41310. className: "bf-colors-wrap"
  41311. },
  41312. external_react_default.a.createElement(
  41313. "ul",
  41314. {
  41315. className: "bf-colors"
  41316. },
  41317. props.presetColors.map(function(item, index) {
  41318. var className =
  41319. props.color &&
  41320. item.toLowerCase() === props.color.toLowerCase()
  41321. ? "color-item active"
  41322. : "color-item";
  41323. return external_react_default.a.createElement("li", {
  41324. key: index,
  41325. title: item,
  41326. className: className,
  41327. style: {
  41328. color: item
  41329. },
  41330. "data-color": item.replace("#", ""),
  41331. onClick: function onClick(e) {
  41332. props.onChange(e.currentTarget.dataset.color, true);
  41333. }
  41334. });
  41335. })
  41336. )
  41337. );
  41338. };
  41339. // CONCATENATED MODULE: ./components/business/TextColor/index.jsx
  41340. var TextColor_TextColor =
  41341. /*#__PURE__*/
  41342. (function(_React$Component) {
  41343. inherits_default()(TextColor, _React$Component);
  41344. function TextColor() {
  41345. var _getPrototypeOf2;
  41346. var _this;
  41347. classCallCheck_default()(this, TextColor);
  41348. for (
  41349. var _len = arguments.length, args = new Array(_len), _key = 0;
  41350. _key < _len;
  41351. _key++
  41352. ) {
  41353. args[_key] = arguments[_key];
  41354. }
  41355. _this = possibleConstructorReturn_default()(
  41356. this,
  41357. (_getPrototypeOf2 = getPrototypeOf_default()(
  41358. TextColor
  41359. )).call.apply(_getPrototypeOf2, [this].concat(args))
  41360. );
  41361. defineProperty_default()(
  41362. assertThisInitialized_default()(
  41363. assertThisInitialized_default()(_this)
  41364. ),
  41365. "state",
  41366. {
  41367. colorType: "color"
  41368. }
  41369. );
  41370. defineProperty_default()(
  41371. assertThisInitialized_default()(
  41372. assertThisInitialized_default()(_this)
  41373. ),
  41374. "switchColorType",
  41375. function(_ref) {
  41376. var currentTarget = _ref.currentTarget;
  41377. _this.setState({
  41378. colorType: currentTarget.dataset.type
  41379. });
  41380. }
  41381. );
  41382. defineProperty_default()(
  41383. assertThisInitialized_default()(
  41384. assertThisInitialized_default()(_this)
  41385. ),
  41386. "toggleColor",
  41387. function(color, closePicker) {
  41388. if (color) {
  41389. var hookReturns = _this.props.hooks(
  41390. "toggle-text-".concat(_this.state.colorType),
  41391. color
  41392. )(color);
  41393. if (hookReturns === false) {
  41394. return false;
  41395. }
  41396. if (typeof hookReturns === "string") {
  41397. color = hookReturns;
  41398. }
  41399. if (_this.state.colorType === "color") {
  41400. _this.props.editor.setValue(
  41401. external_braft_utils_[
  41402. "ContentUtils"
  41403. ].toggleSelectionColor(_this.props.editorState, color)
  41404. );
  41405. } else {
  41406. _this.props.editor.setValue(
  41407. external_braft_utils_[
  41408. "ContentUtils"
  41409. ].toggleSelectionBackgroundColor(
  41410. _this.props.editorState,
  41411. color
  41412. )
  41413. );
  41414. }
  41415. }
  41416. if (closePicker) {
  41417. _this.dropDownInstance.hide();
  41418. _this.props.editor.requestFocus();
  41419. }
  41420. }
  41421. );
  41422. return _this;
  41423. }
  41424. createClass_default()(TextColor, [
  41425. {
  41426. key: "render",
  41427. value: function render() {
  41428. var _this2 = this;
  41429. var captionStyle = {};
  41430. var currentColor = null;
  41431. var colorType = this.state.colorType;
  41432. var selectionStyles = this.props.editorState
  41433. .getCurrentInlineStyle()
  41434. .toJS();
  41435. selectionStyles.forEach(function(style) {
  41436. if (style.indexOf("COLOR-") === 0) {
  41437. captionStyle.color = "#" + style.split("-")[1];
  41438. colorType === "color" &&
  41439. (currentColor = captionStyle.color);
  41440. }
  41441. if (style.indexOf("BGCOLOR-") === 0) {
  41442. captionStyle.backgroundColor =
  41443. "#" + style.split("-")[1];
  41444. colorType === "background-color" &&
  41445. (currentColor = captionStyle.backgroundColor);
  41446. }
  41447. });
  41448. var caption = external_react_default.a.createElement(
  41449. "i",
  41450. {
  41451. style: captionStyle,
  41452. className: "bfi-text-color"
  41453. },
  41454. external_react_default.a.createElement("span", {
  41455. className: "path1"
  41456. }),
  41457. external_react_default.a.createElement("span", {
  41458. className: "path2"
  41459. })
  41460. );
  41461. var ColorPicker =
  41462. this.props.colorPicker || common_ColorPicker;
  41463. return external_react_default.a.createElement(
  41464. DropDown_DropDown,
  41465. {
  41466. caption: caption,
  41467. title: this.props.language.controls.color,
  41468. showArrow: false,
  41469. autoHide: this.props.autoHide,
  41470. theme: this.props.theme,
  41471. getContainerNode: this.props.getContainerNode,
  41472. ref: function ref(instance) {
  41473. return (_this2.dropDownInstance = instance);
  41474. },
  41475. className: "control-item dropdown text-color-dropdown"
  41476. },
  41477. external_react_default.a.createElement(
  41478. "div",
  41479. {
  41480. className: "bf-text-color-picker-wrap"
  41481. },
  41482. external_react_default.a.createElement(
  41483. "div",
  41484. {
  41485. className: "bf-color-switch-buttons",
  41486. style: this.props.enableBackgroundColor
  41487. ? {}
  41488. : {
  41489. display: "none"
  41490. }
  41491. },
  41492. external_react_default.a.createElement(
  41493. "button",
  41494. {
  41495. type: "button",
  41496. "data-type": "color",
  41497. className: colorType === "color" ? "active" : "",
  41498. onClick: this.switchColorType
  41499. },
  41500. this.props.language.controls.textColor
  41501. ),
  41502. external_react_default.a.createElement(
  41503. "button",
  41504. {
  41505. type: "button",
  41506. "data-type": "background-color",
  41507. className:
  41508. colorType === "background-color"
  41509. ? "active"
  41510. : "",
  41511. onClick: this.switchColorType
  41512. },
  41513. this.props.language.controls.backgroundColor
  41514. )
  41515. ),
  41516. external_react_default.a.createElement(ColorPicker, {
  41517. width: 200,
  41518. color: currentColor,
  41519. disableAlpha: true,
  41520. presetColors: this.props.colors,
  41521. onChange: this.toggleColor
  41522. })
  41523. )
  41524. );
  41525. }
  41526. }
  41527. ]);
  41528. return TextColor;
  41529. })(external_react_default.a.Component);
  41530. // EXTERNAL MODULE: ./components/business/FontSize/style.scss
  41531. var FontSize_style = __webpack_require__(59);
  41532. // CONCATENATED MODULE: ./components/business/FontSize/index.jsx
  41533. var FontSize_toggleFontSize = function toggleFontSize(event, props) {
  41534. var fontSize = event.currentTarget.dataset.size;
  41535. var hookReturns = props.hooks(
  41536. "toggle-font-size",
  41537. fontSize
  41538. )(fontSize);
  41539. if (hookReturns === false) {
  41540. return false;
  41541. }
  41542. if (!isNaN(fontSize)) {
  41543. fontSize = hookReturns;
  41544. }
  41545. props.editor.setValue(
  41546. external_braft_utils_["ContentUtils"].toggleSelectionFontSize(
  41547. props.editorState,
  41548. fontSize
  41549. )
  41550. );
  41551. props.editor.requestFocus();
  41552. };
  41553. /* harmony default export */ var FontSize = function(props) {
  41554. var caption = null;
  41555. var currentFontSize = null;
  41556. var dropDownInstance = null;
  41557. props.fontSizes.find(function(item) {
  41558. if (
  41559. external_braft_utils_["ContentUtils"].selectionHasInlineStyle(
  41560. props.editorState,
  41561. "FONTSIZE-" + item
  41562. )
  41563. ) {
  41564. caption = item;
  41565. currentFontSize = item;
  41566. return true;
  41567. }
  41568. return false;
  41569. });
  41570. return external_react_default.a.createElement(
  41571. DropDown_DropDown,
  41572. {
  41573. autoHide: true,
  41574. caption: caption || props.defaultCaption,
  41575. getContainerNode: props.getContainerNode,
  41576. title: props.language.controls.fontSize,
  41577. ref: function ref(instance) {
  41578. return (dropDownInstance = instance);
  41579. },
  41580. className: "control-item dropdown bf-font-size-dropdown"
  41581. },
  41582. external_react_default.a.createElement(
  41583. "ul",
  41584. {
  41585. className: "bf-font-sizes"
  41586. },
  41587. props.fontSizes.map(function(item, index) {
  41588. return external_react_default.a.createElement(
  41589. "li",
  41590. {
  41591. key: index,
  41592. className: item === currentFontSize ? "active" : null,
  41593. "data-size": item,
  41594. onClick: function onClick(event) {
  41595. FontSize_toggleFontSize(event, props),
  41596. dropDownInstance.hide();
  41597. }
  41598. },
  41599. item
  41600. );
  41601. })
  41602. )
  41603. );
  41604. };
  41605. // EXTERNAL MODULE: ./components/business/LineHeight/style.scss
  41606. var LineHeight_style = __webpack_require__(60);
  41607. // CONCATENATED MODULE: ./components/business/LineHeight/index.jsx
  41608. var LineHeight_toggleLineHeight = function toggleLineHeight(
  41609. event,
  41610. props
  41611. ) {
  41612. var lineHeight = event.currentTarget.dataset.size;
  41613. var hookReturns = props.hooks(
  41614. "toggle-line-height",
  41615. lineHeight
  41616. )(lineHeight);
  41617. if (hookReturns === false) {
  41618. return false;
  41619. }
  41620. if (!isNaN(hookReturns)) {
  41621. lineHeight = hookReturns;
  41622. }
  41623. props.editor.setValue(
  41624. external_braft_utils_["ContentUtils"].toggleSelectionLineHeight(
  41625. props.editorState,
  41626. lineHeight
  41627. )
  41628. );
  41629. props.editor.requestFocus();
  41630. };
  41631. /* harmony default export */ var LineHeight = function(props) {
  41632. var caption = null;
  41633. var currentLineHeight = null;
  41634. var dropDownInstance = null;
  41635. props.lineHeights.find(function(item) {
  41636. if (
  41637. external_braft_utils_["ContentUtils"].selectionHasInlineStyle(
  41638. props.editorState,
  41639. "LINEHEIGHT-" + item
  41640. )
  41641. ) {
  41642. caption = item;
  41643. currentLineHeight = item;
  41644. return true;
  41645. }
  41646. return false;
  41647. });
  41648. return external_react_default.a.createElement(
  41649. DropDown_DropDown,
  41650. {
  41651. autoHide: true,
  41652. caption: caption || props.defaultCaption,
  41653. getContainerNode: props.getContainerNode,
  41654. title: props.language.controls.lineHeight,
  41655. ref: function ref(instance) {
  41656. return (dropDownInstance = instance);
  41657. },
  41658. className: "control-item dropdown bf-line-height-dropdown"
  41659. },
  41660. external_react_default.a.createElement(
  41661. "ul",
  41662. {
  41663. className: "bf-line-heights"
  41664. },
  41665. props.lineHeights.map(function(item, index) {
  41666. return external_react_default.a.createElement(
  41667. "li",
  41668. {
  41669. key: index,
  41670. className: item === currentLineHeight ? "active" : null,
  41671. "data-size": item,
  41672. onClick: function onClick(event) {
  41673. LineHeight_toggleLineHeight(event, props),
  41674. dropDownInstance.hide();
  41675. }
  41676. },
  41677. item
  41678. );
  41679. })
  41680. )
  41681. );
  41682. };
  41683. // EXTERNAL MODULE: ./components/business/FontFamily/style.scss
  41684. var FontFamily_style = __webpack_require__(61);
  41685. // CONCATENATED MODULE: ./components/business/FontFamily/index.jsx
  41686. var FontFamily_toggleFontFamily = function toggleFontFamily(
  41687. event,
  41688. props
  41689. ) {
  41690. var fontFamilyName = event.currentTarget.dataset.name;
  41691. var hookReturns = props.hooks("toggle-font-family", fontFamilyName)(
  41692. fontFamilyName,
  41693. props.fontFamilies
  41694. );
  41695. if (hookReturns === false) {
  41696. return false;
  41697. }
  41698. if (typeof hookReturns === "string") {
  41699. fontFamilyName = hookReturns;
  41700. }
  41701. props.editor.setValue(
  41702. external_braft_utils_["ContentUtils"].toggleSelectionFontFamily(
  41703. props.editorState,
  41704. fontFamilyName
  41705. )
  41706. );
  41707. props.editor.requestFocus();
  41708. };
  41709. /* harmony default export */ var FontFamily = function(props) {
  41710. var caption = null;
  41711. var currentIndex = null;
  41712. var dropDownInstance = null;
  41713. props.fontFamilies.find(function(item, index) {
  41714. if (
  41715. external_braft_utils_["ContentUtils"].selectionHasInlineStyle(
  41716. props.editorState,
  41717. "FONTFAMILY-" + item.name
  41718. )
  41719. ) {
  41720. caption = item.name;
  41721. currentIndex = index;
  41722. return true;
  41723. }
  41724. return false;
  41725. });
  41726. return external_react_default.a.createElement(
  41727. DropDown_DropDown,
  41728. {
  41729. caption: caption || props.defaultCaption,
  41730. getContainerNode: props.getContainerNode,
  41731. title: props.language.controls.fontFamily,
  41732. autoHide: true,
  41733. arrowActive: currentIndex === 0,
  41734. ref: function ref(instance) {
  41735. return (dropDownInstance = instance);
  41736. },
  41737. className: "control-item dropdown font-family-dropdown"
  41738. },
  41739. external_react_default.a.createElement(
  41740. "ul",
  41741. {
  41742. className: "menu"
  41743. },
  41744. props.fontFamilies.map(function(item, index) {
  41745. return external_react_default.a.createElement(
  41746. "li",
  41747. {
  41748. key: index,
  41749. className:
  41750. "menu-item " + (index === currentIndex ? "active" : ""),
  41751. "data-name": item.name,
  41752. onClick: function onClick(event) {
  41753. FontFamily_toggleFontFamily(event, props),
  41754. dropDownInstance.hide();
  41755. }
  41756. },
  41757. external_react_default.a.createElement(
  41758. "span",
  41759. {
  41760. style: {
  41761. fontFamily: item.family
  41762. }
  41763. },
  41764. item.name
  41765. )
  41766. );
  41767. })
  41768. )
  41769. );
  41770. };
  41771. // CONCATENATED MODULE: ./components/business/TextAlign/index.jsx
  41772. var TextAlign_TextAlign =
  41773. /*#__PURE__*/
  41774. (function(_React$Component) {
  41775. inherits_default()(TextAlign, _React$Component);
  41776. function TextAlign() {
  41777. var _getPrototypeOf2;
  41778. var _this;
  41779. classCallCheck_default()(this, TextAlign);
  41780. for (
  41781. var _len = arguments.length, args = new Array(_len), _key = 0;
  41782. _key < _len;
  41783. _key++
  41784. ) {
  41785. args[_key] = arguments[_key];
  41786. }
  41787. _this = possibleConstructorReturn_default()(
  41788. this,
  41789. (_getPrototypeOf2 = getPrototypeOf_default()(
  41790. TextAlign
  41791. )).call.apply(_getPrototypeOf2, [this].concat(args))
  41792. );
  41793. defineProperty_default()(
  41794. assertThisInitialized_default()(
  41795. assertThisInitialized_default()(_this)
  41796. ),
  41797. "state",
  41798. {
  41799. currentAlignment: undefined
  41800. }
  41801. );
  41802. defineProperty_default()(
  41803. assertThisInitialized_default()(
  41804. assertThisInitialized_default()(_this)
  41805. ),
  41806. "setAlignment",
  41807. function(event) {
  41808. var alignment = event.currentTarget.dataset.alignment;
  41809. var hookReturns = _this.props.hooks(
  41810. "toggle-text-alignment",
  41811. alignment
  41812. )(alignment);
  41813. if (_this.props.textAligns.indexOf(hookReturns) > -1) {
  41814. alignment = hookReturns;
  41815. }
  41816. _this.props.editor.setValue(
  41817. external_braft_utils_[
  41818. "ContentUtils"
  41819. ].toggleSelectionAlignment(
  41820. _this.props.editorState,
  41821. alignment
  41822. )
  41823. );
  41824. _this.props.editor.requestFocus();
  41825. }
  41826. );
  41827. return _this;
  41828. }
  41829. createClass_default()(TextAlign, [
  41830. {
  41831. key: "componentWillReceiveProps",
  41832. value: function componentWillReceiveProps(next) {
  41833. this.setState({
  41834. currentAlignment: external_braft_utils_[
  41835. "ContentUtils"
  41836. ].getSelectionBlockData(next.editorState, "textAlign")
  41837. });
  41838. }
  41839. },
  41840. {
  41841. key: "render",
  41842. value: function render() {
  41843. var _this2 = this;
  41844. var textAlignmentTitles = [
  41845. this.props.language.controls.alignLeft,
  41846. this.props.language.controls.alignCenter,
  41847. this.props.language.controls.alignRight,
  41848. this.props.language.controls.alignJustify
  41849. ];
  41850. return external_react_default.a.createElement(
  41851. ControlGroup,
  41852. null,
  41853. this.props.textAligns.map(function(item, index) {
  41854. return external_react_default.a.createElement(
  41855. "button",
  41856. {
  41857. type: "button",
  41858. key: index,
  41859. "data-title": textAlignmentTitles[index],
  41860. "data-alignment": item,
  41861. className:
  41862. "control-item button " +
  41863. (item === _this2.state.currentAlignment
  41864. ? "active"
  41865. : null),
  41866. onClick: _this2.setAlignment
  41867. },
  41868. external_react_default.a.createElement("i", {
  41869. className: "bfi-align-" + item
  41870. })
  41871. );
  41872. })
  41873. );
  41874. }
  41875. }
  41876. ]);
  41877. return TextAlign;
  41878. })(external_react_default.a.Component);
  41879. // EXTERNAL MODULE: ./components/business/EmojiPicker/style.scss
  41880. var EmojiPicker_style = __webpack_require__(62);
  41881. // CONCATENATED MODULE: ./components/business/EmojiPicker/index.jsx
  41882. var EmojiPicker_insertEmoji = function insertEmoji(event, props) {
  41883. var emoji = event.currentTarget.dataset.emoji;
  41884. var hookReturns = props.hooks("insert-emoji", emoji)(emoji);
  41885. if (hookReturns === false) {
  41886. return false;
  41887. }
  41888. if (typeof hookReturns === "string") {
  41889. emoji = hookReturns;
  41890. }
  41891. props.editor.setValue(
  41892. external_braft_utils_["ContentUtils"].insertText(
  41893. props.editorState,
  41894. emoji
  41895. )
  41896. );
  41897. props.editor.requestFocus();
  41898. };
  41899. /* harmony default export */ var EmojiPicker = function(props) {
  41900. return external_react_default.a.createElement(
  41901. DropDown_DropDown,
  41902. {
  41903. caption: props.defaultCaption,
  41904. autoHide: true,
  41905. showArrow: false,
  41906. getContainerNode: props.getContainerNode,
  41907. title: props.language.controls.emoji,
  41908. className: "control-item dropdown bf-emoji-dropdown"
  41909. },
  41910. external_react_default.a.createElement(
  41911. "div",
  41912. {
  41913. className: "bf-emojis-wrap"
  41914. },
  41915. external_react_default.a.createElement(
  41916. "ul",
  41917. {
  41918. className: "bf-emojis"
  41919. },
  41920. props.emojis.map(function(item, index) {
  41921. return external_react_default.a.createElement(
  41922. "li",
  41923. {
  41924. key: index,
  41925. "data-emoji": item,
  41926. onClick: function onClick(event) {
  41927. return EmojiPicker_insertEmoji(event, props);
  41928. }
  41929. },
  41930. item
  41931. );
  41932. })
  41933. )
  41934. )
  41935. );
  41936. };
  41937. // EXTERNAL MODULE: ./components/business/LetterSpacing/style.scss
  41938. var LetterSpacing_style = __webpack_require__(63);
  41939. // CONCATENATED MODULE: ./components/business/LetterSpacing/index.jsx
  41940. var LetterSpacing_toggleLetterSpacing = function toggleLetterSpacing(
  41941. event,
  41942. props
  41943. ) {
  41944. var letterSpacing = event.currentTarget.dataset.size;
  41945. var hookReturns = props.hooks(
  41946. "toggle-letter-spacing",
  41947. letterSpacing
  41948. )(letterSpacing);
  41949. if (hookReturns === false) {
  41950. return false;
  41951. }
  41952. if (!isNaN(hookReturns)) {
  41953. letterSpacing = hookReturns;
  41954. }
  41955. props.editor.setValue(
  41956. external_braft_utils_[
  41957. "ContentUtils"
  41958. ].toggleSelectionLetterSpacing(props.editorState, letterSpacing)
  41959. );
  41960. props.editor.requestFocus();
  41961. };
  41962. /* harmony default export */ var LetterSpacing = function(props) {
  41963. var caption = null;
  41964. var currentLetterSpacing = null;
  41965. var dropDownInstance = null;
  41966. props.letterSpacings.find(function(item) {
  41967. if (
  41968. external_braft_utils_["ContentUtils"].selectionHasInlineStyle(
  41969. props.editorState,
  41970. "LETTERSPACING-" + item
  41971. )
  41972. ) {
  41973. caption = item;
  41974. currentLetterSpacing = item;
  41975. return true;
  41976. }
  41977. return false;
  41978. });
  41979. return external_react_default.a.createElement(
  41980. DropDown_DropDown,
  41981. {
  41982. autoHide: true,
  41983. caption: caption || props.defaultCaption,
  41984. getContainerNode: props.getContainerNode,
  41985. title: props.language.controls.letterSpacing,
  41986. ref: function ref(instance) {
  41987. return (dropDownInstance = instance);
  41988. },
  41989. className: "control-item dropdown bf-letter-spacing-dropdown"
  41990. },
  41991. external_react_default.a.createElement(
  41992. "ul",
  41993. {
  41994. className: "bf-letter-spacings"
  41995. },
  41996. props.letterSpacings.map(function(item, index) {
  41997. return external_react_default.a.createElement(
  41998. "li",
  41999. {
  42000. key: index,
  42001. className:
  42002. item === currentLetterSpacing ? "active" : null,
  42003. "data-size": item,
  42004. onClick: function onClick(event) {
  42005. LetterSpacing_toggleLetterSpacing(event, props),
  42006. dropDownInstance.hide();
  42007. }
  42008. },
  42009. item
  42010. );
  42011. })
  42012. )
  42013. );
  42014. };
  42015. // CONCATENATED MODULE: ./components/business/TextIndent/index.jsx
  42016. var TextIndent_TextAlign =
  42017. /*#__PURE__*/
  42018. (function(_React$Component) {
  42019. inherits_default()(TextAlign, _React$Component);
  42020. function TextAlign() {
  42021. var _getPrototypeOf2;
  42022. var _this;
  42023. classCallCheck_default()(this, TextAlign);
  42024. for (
  42025. var _len = arguments.length, args = new Array(_len), _key = 0;
  42026. _key < _len;
  42027. _key++
  42028. ) {
  42029. args[_key] = arguments[_key];
  42030. }
  42031. _this = possibleConstructorReturn_default()(
  42032. this,
  42033. (_getPrototypeOf2 = getPrototypeOf_default()(
  42034. TextAlign
  42035. )).call.apply(_getPrototypeOf2, [this].concat(args))
  42036. );
  42037. defineProperty_default()(
  42038. assertThisInitialized_default()(
  42039. assertThisInitialized_default()(_this)
  42040. ),
  42041. "state",
  42042. {
  42043. currentIndent: 0
  42044. }
  42045. );
  42046. defineProperty_default()(
  42047. assertThisInitialized_default()(
  42048. assertThisInitialized_default()(_this)
  42049. ),
  42050. "increaseIndent",
  42051. function() {
  42052. _this.props.editor.setValue(
  42053. external_braft_utils_[
  42054. "ContentUtils"
  42055. ].increaseSelectionIndent(_this.props.editorState)
  42056. );
  42057. _this.props.editor.requestFocus();
  42058. }
  42059. );
  42060. defineProperty_default()(
  42061. assertThisInitialized_default()(
  42062. assertThisInitialized_default()(_this)
  42063. ),
  42064. "decreaseIndent",
  42065. function() {
  42066. _this.props.editor.setValue(
  42067. external_braft_utils_[
  42068. "ContentUtils"
  42069. ].decreaseSelectionIndent(_this.props.editorState)
  42070. );
  42071. _this.props.editor.requestFocus();
  42072. }
  42073. );
  42074. return _this;
  42075. }
  42076. createClass_default()(TextAlign, [
  42077. {
  42078. key: "componentWillReceiveProps",
  42079. value: function componentWillReceiveProps(nextProps) {
  42080. this.setState({
  42081. currentIndent:
  42082. external_braft_utils_[
  42083. "ContentUtils"
  42084. ].getSelectionBlockData(
  42085. nextProps.editorState,
  42086. "textIndent"
  42087. ) || 0
  42088. });
  42089. }
  42090. },
  42091. {
  42092. key: "render",
  42093. value: function render() {
  42094. var currentIndent = this.state.currentIndent;
  42095. var language = this.props.language;
  42096. return external_react_default.a.createElement(
  42097. ControlGroup,
  42098. null,
  42099. external_react_default.a.createElement(
  42100. "button",
  42101. {
  42102. key: 0,
  42103. type: "button",
  42104. "data-title": language.controls.increaseIndent,
  42105. disabled: currentIndent >= 6,
  42106. className: "control-item button button-indent-increase".concat(
  42107. currentIndent > 0 && currentIndent < 6
  42108. ? " active"
  42109. : ""
  42110. ),
  42111. onClick: this.increaseIndent
  42112. },
  42113. external_react_default.a.createElement("i", {
  42114. className: "bfi-indent-increase"
  42115. })
  42116. ),
  42117. external_react_default.a.createElement(
  42118. "button",
  42119. {
  42120. key: 1,
  42121. type: "button",
  42122. "data-title": language.controls.decreaseIndent,
  42123. disabled: currentIndent <= 0,
  42124. className:
  42125. "control-item button button-indent-decrease",
  42126. onClick: this.decreaseIndent
  42127. },
  42128. external_react_default.a.createElement("i", {
  42129. className: "bfi-indent-decrease"
  42130. })
  42131. )
  42132. );
  42133. }
  42134. }
  42135. ]);
  42136. return TextAlign;
  42137. })(external_react_default.a.Component);
  42138. // CONCATENATED MODULE: ./components/business/ControlBar/index.jsx
  42139. var commandHookMap = {
  42140. "inline-style": "toggle-inline-style",
  42141. "block-type": "change-block-type",
  42142. "editor-method": "exec-editor-command"
  42143. };
  42144. var exclusiveInlineStyles = {
  42145. superscript: "subscript",
  42146. subscript: "superscript"
  42147. };
  42148. var mergeControls = function mergeControls(
  42149. commonProps,
  42150. builtControls,
  42151. extensionControls,
  42152. extendControls
  42153. ) {
  42154. extensionControls = extensionControls.map(function(item) {
  42155. return typeof item === "function" ? item(commonProps) : item;
  42156. });
  42157. extendControls = extendControls.map(function(item) {
  42158. return typeof item === "function" ? item(commonProps) : item;
  42159. });
  42160. if (extensionControls.length === 0 && extendControls.length === 0) {
  42161. return builtControls;
  42162. }
  42163. return builtControls
  42164. .map(function(item) {
  42165. return (
  42166. extendControls.find(function(subItem) {
  42167. return subItem.replace === (item.key || item);
  42168. }) ||
  42169. extensionControls.find(function(subItem) {
  42170. return subItem.replace === (item.key || item);
  42171. }) ||
  42172. item
  42173. );
  42174. })
  42175. .concat(extensionControls.length ? "separator" : "")
  42176. .concat(
  42177. extensionControls.filter(function(item) {
  42178. return !item.replace;
  42179. })
  42180. )
  42181. .concat(
  42182. extendControls.filter(function(item) {
  42183. return typeof item === "string" || !item.replace;
  42184. })
  42185. );
  42186. };
  42187. var ControlBar_ControlBar =
  42188. /*#__PURE__*/
  42189. (function(_React$Component) {
  42190. inherits_default()(ControlBar, _React$Component);
  42191. function ControlBar() {
  42192. var _getPrototypeOf2;
  42193. var _this;
  42194. classCallCheck_default()(this, ControlBar);
  42195. for (
  42196. var _len = arguments.length, args = new Array(_len), _key = 0;
  42197. _key < _len;
  42198. _key++
  42199. ) {
  42200. args[_key] = arguments[_key];
  42201. }
  42202. _this = possibleConstructorReturn_default()(
  42203. this,
  42204. (_getPrototypeOf2 = getPrototypeOf_default()(
  42205. ControlBar
  42206. )).call.apply(_getPrototypeOf2, [this].concat(args))
  42207. );
  42208. defineProperty_default()(
  42209. assertThisInitialized_default()(
  42210. assertThisInitialized_default()(_this)
  42211. ),
  42212. "allControls",
  42213. []
  42214. );
  42215. defineProperty_default()(
  42216. assertThisInitialized_default()(
  42217. assertThisInitialized_default()(_this)
  42218. ),
  42219. "mediaLibiraryModal",
  42220. null
  42221. );
  42222. defineProperty_default()(
  42223. assertThisInitialized_default()(
  42224. assertThisInitialized_default()(_this)
  42225. ),
  42226. "extendedModals",
  42227. {}
  42228. );
  42229. defineProperty_default()(
  42230. assertThisInitialized_default()(
  42231. assertThisInitialized_default()(_this)
  42232. ),
  42233. "openBraftFinder",
  42234. function() {
  42235. if (
  42236. !_this.props.braftFinder ||
  42237. !_this.props.braftFinder.ReactComponent
  42238. ) {
  42239. return false;
  42240. }
  42241. if (_this.props.hooks("open-braft-finder")() === false) {
  42242. return false;
  42243. }
  42244. var mediaProps = _this.props.media;
  42245. var MediaLibrary = _this.props.braftFinder.ReactComponent;
  42246. _this.mediaLibiraryModal = Modal_showModal({
  42247. title: _this.props.language.controls.mediaLibirary,
  42248. language: _this.props.language,
  42249. width: 640,
  42250. showFooter: false,
  42251. component: external_react_default.a.createElement(
  42252. MediaLibrary,
  42253. {
  42254. accepts: mediaProps.accepts,
  42255. onCancel: _this.closeBraftFinder,
  42256. onInsert: _this.insertMedias,
  42257. onChange: mediaProps.onChange,
  42258. externals: mediaProps.externals,
  42259. onBeforeSelect: _this.bindBraftFinderHook(
  42260. "select-medias"
  42261. ),
  42262. onBeforeDeselect: _this.bindBraftFinderHook(
  42263. "deselect-medias"
  42264. ),
  42265. onBeforeRemove: _this.bindBraftFinderHook(
  42266. "remove-medias"
  42267. ),
  42268. onBeforeInsert: _this.bindBraftFinderHook(
  42269. "insert-medias"
  42270. ),
  42271. onFileSelect: _this.bindBraftFinderHook(
  42272. "select-files"
  42273. )
  42274. }
  42275. )
  42276. });
  42277. }
  42278. );
  42279. defineProperty_default()(
  42280. assertThisInitialized_default()(
  42281. assertThisInitialized_default()(_this)
  42282. ),
  42283. "bindBraftFinderHook",
  42284. function(hookName) {
  42285. return function() {
  42286. return _this.props
  42287. .hooks(
  42288. hookName,
  42289. arguments.length <= 0 ? undefined : arguments[0]
  42290. )
  42291. .apply(void 0, arguments);
  42292. };
  42293. }
  42294. );
  42295. defineProperty_default()(
  42296. assertThisInitialized_default()(
  42297. assertThisInitialized_default()(_this)
  42298. ),
  42299. "insertMedias",
  42300. function(medias) {
  42301. _this.props.editor.setValue(
  42302. external_braft_utils_["ContentUtils"].insertMedias(
  42303. _this.props.editorState,
  42304. medias
  42305. )
  42306. );
  42307. _this.props.editor.requestFocus();
  42308. _this.props.media.onInsert &&
  42309. _this.props.media.onInsert(medias);
  42310. _this.closeBraftFinder();
  42311. }
  42312. );
  42313. defineProperty_default()(
  42314. assertThisInitialized_default()(
  42315. assertThisInitialized_default()(_this)
  42316. ),
  42317. "closeBraftFinder",
  42318. function() {
  42319. _this.props.media.onCancel && _this.props.media.onCancel();
  42320. _this.mediaLibiraryModal &&
  42321. _this.mediaLibiraryModal.close();
  42322. }
  42323. );
  42324. return _this;
  42325. }
  42326. createClass_default()(ControlBar, [
  42327. {
  42328. key: "componentDidUpdate",
  42329. value: function componentDidUpdate() {
  42330. var _this2 = this;
  42331. var language = this.props.language;
  42332. this.allControls.forEach(function(item) {
  42333. if (item.type === "modal") {
  42334. if (
  42335. item.modal &&
  42336. item.modal.id &&
  42337. _this2.extendedModals[item.modal.id]
  42338. ) {
  42339. _this2.extendedModals[item.modal.id].update(
  42340. objectSpread_default()({}, item.modal, {
  42341. language: language
  42342. })
  42343. );
  42344. }
  42345. }
  42346. });
  42347. }
  42348. },
  42349. {
  42350. key: "getControlItemClassName",
  42351. value: function getControlItemClassName(data) {
  42352. var className = "control-item button";
  42353. var type = data.type,
  42354. command = data.command;
  42355. if (
  42356. type === "inline-style" &&
  42357. external_braft_utils_[
  42358. "ContentUtils"
  42359. ].selectionHasInlineStyle(this.props.editorState, command)
  42360. ) {
  42361. className += " active";
  42362. } else if (
  42363. type === "block-type" &&
  42364. external_braft_utils_[
  42365. "ContentUtils"
  42366. ].getSelectionBlockType(this.props.editorState) ===
  42367. command
  42368. ) {
  42369. className += " active";
  42370. } else if (
  42371. type === "entity" &&
  42372. external_braft_utils_[
  42373. "ContentUtils"
  42374. ].getSelectionEntityType(this.props.editorState) ===
  42375. command
  42376. ) {
  42377. className += " active";
  42378. }
  42379. return className;
  42380. }
  42381. },
  42382. {
  42383. key: "applyControl",
  42384. value: function applyControl(command, type) {
  42385. var data =
  42386. arguments.length > 2 && arguments[2] !== undefined
  42387. ? arguments[2]
  42388. : {};
  42389. var hookReturns = this.props.hooks(
  42390. commandHookMap[type] || type,
  42391. command
  42392. )(command);
  42393. var editorState = this.props.editorState;
  42394. if (hookReturns === false) {
  42395. return false;
  42396. }
  42397. if (typeof hookReturns === "string") {
  42398. command = hookReturns;
  42399. }
  42400. if (type === "inline-style") {
  42401. var exclusiveInlineStyle = exclusiveInlineStyles[command];
  42402. if (
  42403. exclusiveInlineStyle &&
  42404. external_braft_utils_[
  42405. "ContentUtils"
  42406. ].selectionHasInlineStyle(
  42407. editorState,
  42408. exclusiveInlineStyle
  42409. )
  42410. ) {
  42411. editorState = external_braft_utils_[
  42412. "ContentUtils"
  42413. ].toggleSelectionInlineStyle(
  42414. editorState,
  42415. exclusiveInlineStyle
  42416. );
  42417. }
  42418. this.props.editor.setValue(
  42419. external_braft_utils_[
  42420. "ContentUtils"
  42421. ].toggleSelectionInlineStyle(editorState, command)
  42422. );
  42423. } else if (type === "block-type") {
  42424. this.props.editor.setValue(
  42425. external_braft_utils_[
  42426. "ContentUtils"
  42427. ].toggleSelectionBlockType(editorState, command)
  42428. );
  42429. } else if (type === "entity") {
  42430. this.props.editor.setValue(
  42431. external_braft_utils_[
  42432. "ContentUtils"
  42433. ].toggleSelectionEntity(editorState, {
  42434. type: command,
  42435. mutability: data.mutability || "MUTABLE",
  42436. data: data.data || {}
  42437. })
  42438. );
  42439. } else if (type === "editor-method") {
  42440. this.props.editor[command] &&
  42441. this.props.editor[command]();
  42442. }
  42443. }
  42444. },
  42445. {
  42446. key: "render",
  42447. value: function render() {
  42448. var _this3 = this;
  42449. var _this$props = this.props,
  42450. editor = _this$props.editor,
  42451. editorId = _this$props.editorId,
  42452. editorState = _this$props.editorState,
  42453. className = _this$props.className,
  42454. style = _this$props.style,
  42455. controls = _this$props.controls,
  42456. media = _this$props.media,
  42457. extendControls = _this$props.extendControls,
  42458. language = _this$props.language,
  42459. hooks = _this$props.hooks,
  42460. colors = _this$props.colors,
  42461. colorPicker = _this$props.colorPicker,
  42462. colorPickerTheme = _this$props.colorPickerTheme,
  42463. colorPickerAutoHide = _this$props.colorPickerAutoHide,
  42464. headings = _this$props.headings,
  42465. fontSizes = _this$props.fontSizes,
  42466. fontFamilies = _this$props.fontFamilies,
  42467. emojis = _this$props.emojis,
  42468. getContainerNode = _this$props.getContainerNode,
  42469. lineHeights = _this$props.lineHeights,
  42470. letterSpacings = _this$props.letterSpacings,
  42471. textAligns = _this$props.textAligns,
  42472. textBackgroundColor = _this$props.textBackgroundColor,
  42473. allowInsertLinkText = _this$props.allowInsertLinkText,
  42474. defaultLinkTarget = _this$props.defaultLinkTarget;
  42475. var currentBlockType = external_braft_utils_[
  42476. "ContentUtils"
  42477. ].getSelectionBlockType(editorState);
  42478. var commonProps = {
  42479. editor: editor,
  42480. editorId: editorId,
  42481. editorState: editorState,
  42482. language: language,
  42483. getContainerNode: getContainerNode,
  42484. hooks: hooks
  42485. };
  42486. var renderedControls = [];
  42487. var editorControls = configs_controls(language, editor);
  42488. var extensionControls = getExtensionControls(editorId);
  42489. var allControls = mergeControls(
  42490. commonProps,
  42491. controls,
  42492. extensionControls,
  42493. extendControls
  42494. );
  42495. this.allControls = allControls;
  42496. return external_react_default.a.createElement(
  42497. "div",
  42498. {
  42499. className: "bf-controlbar ".concat(className || ""),
  42500. style: style,
  42501. onMouseDown: this.preventDefault
  42502. },
  42503. allControls.map(function(item, index) {
  42504. var itemKey =
  42505. typeof item === "string" ? item : item.key;
  42506. if (typeof itemKey !== "string") {
  42507. return null;
  42508. }
  42509. if (renderedControls.indexOf(itemKey) > -1) {
  42510. return null;
  42511. }
  42512. if (itemKey.toLowerCase() === "separator") {
  42513. return external_react_default.a.createElement(
  42514. "span",
  42515. {
  42516. key: index,
  42517. className: "separator-line"
  42518. }
  42519. );
  42520. }
  42521. var controlItem = editorControls.find(function(
  42522. subItem
  42523. ) {
  42524. return (
  42525. subItem.key.toLowerCase() === itemKey.toLowerCase()
  42526. );
  42527. });
  42528. if (typeof item !== "string") {
  42529. controlItem = objectSpread_default()(
  42530. {},
  42531. controlItem,
  42532. item
  42533. );
  42534. }
  42535. if (!controlItem) {
  42536. return null;
  42537. }
  42538. renderedControls.push(itemKey);
  42539. if (controlItem.type === "headings") {
  42540. return external_react_default.a.createElement(
  42541. Headings,
  42542. extends_default()(
  42543. {
  42544. key: index,
  42545. headings: headings,
  42546. current: currentBlockType,
  42547. onChange: function onChange(command) {
  42548. return _this3.applyControl(
  42549. command,
  42550. "block-type"
  42551. );
  42552. }
  42553. },
  42554. commonProps
  42555. )
  42556. );
  42557. } else if (controlItem.type === "text-color") {
  42558. return external_react_default.a.createElement(
  42559. TextColor_TextColor,
  42560. extends_default()(
  42561. {
  42562. key: index,
  42563. colors: colors,
  42564. colorPicker: colorPicker,
  42565. theme: colorPickerTheme,
  42566. autoHide: colorPickerAutoHide,
  42567. enableBackgroundColor: textBackgroundColor
  42568. },
  42569. commonProps
  42570. )
  42571. );
  42572. } else if (controlItem.type === "font-size") {
  42573. return external_react_default.a.createElement(
  42574. FontSize,
  42575. extends_default()(
  42576. {
  42577. key: index,
  42578. fontSizes: fontSizes,
  42579. defaultCaption: controlItem.title
  42580. },
  42581. commonProps
  42582. )
  42583. );
  42584. } else if (controlItem.type === "line-height") {
  42585. return external_react_default.a.createElement(
  42586. LineHeight,
  42587. extends_default()(
  42588. {
  42589. key: index,
  42590. lineHeights: lineHeights,
  42591. defaultCaption: controlItem.title
  42592. },
  42593. commonProps
  42594. )
  42595. );
  42596. } else if (controlItem.type === "letter-spacing") {
  42597. return external_react_default.a.createElement(
  42598. LetterSpacing,
  42599. extends_default()(
  42600. {
  42601. key: index,
  42602. letterSpacings: letterSpacings,
  42603. defaultCaption: controlItem.title
  42604. },
  42605. commonProps
  42606. )
  42607. );
  42608. } else if (controlItem.type === "text-indent") {
  42609. return external_react_default.a.createElement(
  42610. TextIndent_TextAlign,
  42611. extends_default()(
  42612. {
  42613. key: index,
  42614. defaultCaption: controlItem.title
  42615. },
  42616. commonProps
  42617. )
  42618. );
  42619. } else if (controlItem.type === "font-family") {
  42620. return external_react_default.a.createElement(
  42621. FontFamily,
  42622. extends_default()(
  42623. {
  42624. key: index,
  42625. fontFamilies: fontFamilies,
  42626. defaultCaption: controlItem.title
  42627. },
  42628. commonProps
  42629. )
  42630. );
  42631. } else if (controlItem.type === "emoji") {
  42632. return external_react_default.a.createElement(
  42633. EmojiPicker,
  42634. extends_default()(
  42635. {
  42636. key: index,
  42637. emojis: emojis,
  42638. defaultCaption: controlItem.text
  42639. },
  42640. commonProps
  42641. )
  42642. );
  42643. } else if (controlItem.type === "link") {
  42644. return external_react_default.a.createElement(
  42645. LinkEditor_LinkEditor,
  42646. extends_default()(
  42647. {
  42648. key: index,
  42649. defaultLinkTarget: defaultLinkTarget,
  42650. allowInsertLinkText: allowInsertLinkText
  42651. },
  42652. commonProps
  42653. )
  42654. );
  42655. } else if (controlItem.type === "text-align") {
  42656. return external_react_default.a.createElement(
  42657. TextAlign_TextAlign,
  42658. extends_default()(
  42659. {
  42660. key: index,
  42661. textAligns: textAligns
  42662. },
  42663. commonProps
  42664. )
  42665. );
  42666. } else if (controlItem.type === "media") {
  42667. if (!media.image && !media.video && !media.audio) {
  42668. return null;
  42669. }
  42670. return external_react_default.a.createElement(
  42671. "button",
  42672. {
  42673. type: "button",
  42674. key: index,
  42675. "data-title": controlItem.title,
  42676. disabled: controlItem.disabled,
  42677. className: "control-item media button",
  42678. onClick: _this3.openBraftFinder
  42679. },
  42680. controlItem.text
  42681. );
  42682. } else if (controlItem.type === "dropdown") {
  42683. return external_react_default.a.createElement(
  42684. DropDown_DropDown,
  42685. extends_default()(
  42686. {
  42687. key: index,
  42688. className: "control-item extend-control-item dropdown ".concat(
  42689. controlItem.className || ""
  42690. ),
  42691. caption: controlItem.text,
  42692. htmlCaption: controlItem.html,
  42693. showArrow: controlItem.showArrow,
  42694. title: controlItem.title,
  42695. arrowActive: controlItem.arrowActive,
  42696. theme: controlItem.theme,
  42697. autoHide: controlItem.autoHide,
  42698. disabled: controlItem.disabled,
  42699. ref: controlItem.ref
  42700. },
  42701. commonProps
  42702. ),
  42703. controlItem.component
  42704. );
  42705. } else if (controlItem.type === "modal") {
  42706. return external_react_default.a.createElement(
  42707. "button",
  42708. {
  42709. type: "button",
  42710. key: index,
  42711. "data-title": controlItem.title,
  42712. disabled: controlItem.disabled,
  42713. className: "control-item extend-control-item button ".concat(
  42714. controlItem.className || ""
  42715. ),
  42716. dangerouslySetInnerHTML: controlItem.html
  42717. ? {
  42718. __html: controlItem.html
  42719. }
  42720. : null,
  42721. onClick: function onClick(event) {
  42722. if (controlItem.modal && controlItem.modal.id) {
  42723. if (
  42724. _this3.extendedModals[controlItem.modal.id]
  42725. ) {
  42726. _this3.extendedModals[
  42727. controlItem.modal.id
  42728. ].active = true;
  42729. _this3.extendedModals[
  42730. controlItem.modal.id
  42731. ].update(
  42732. objectSpread_default()(
  42733. {},
  42734. controlItem.modal,
  42735. {
  42736. language: language
  42737. }
  42738. )
  42739. );
  42740. } else {
  42741. _this3.extendedModals[
  42742. controlItem.modal.id
  42743. ] = Modal_showModal(
  42744. objectSpread_default()(
  42745. {},
  42746. controlItem.modal,
  42747. {
  42748. language: language
  42749. }
  42750. )
  42751. );
  42752. controlItem.modal.onCreate &&
  42753. controlItem.modal.onCreate(
  42754. _this3.extendedModals[
  42755. controlItem.modal.id
  42756. ]
  42757. );
  42758. }
  42759. }
  42760. controlItem.onClick &&
  42761. controlItem.onClick(event);
  42762. }
  42763. },
  42764. !controlItem.html ? controlItem.text : null
  42765. );
  42766. } else if (controlItem.type === "component") {
  42767. return external_react_default.a.createElement(
  42768. "div",
  42769. {
  42770. key: index,
  42771. className: "component-wrapper ".concat(
  42772. controlItem.className || ""
  42773. )
  42774. },
  42775. controlItem.component
  42776. );
  42777. } else if (controlItem.type === "button") {
  42778. return external_react_default.a.createElement(
  42779. "button",
  42780. {
  42781. type: "button",
  42782. key: index,
  42783. "data-title": controlItem.title,
  42784. disabled: controlItem.disabled,
  42785. className: "control-item button ".concat(
  42786. controlItem.className || ""
  42787. ),
  42788. dangerouslySetInnerHTML: controlItem.html
  42789. ? {
  42790. __html: controlItem.html
  42791. }
  42792. : null,
  42793. onClick: function onClick(event) {
  42794. return (
  42795. controlItem.onClick &&
  42796. controlItem.onClick(event)
  42797. );
  42798. }
  42799. },
  42800. !controlItem.html ? controlItem.text : null
  42801. );
  42802. } else if (controlItem) {
  42803. var disabled = false;
  42804. if (controlItem.command === "undo") {
  42805. disabled = editorState.getUndoStack().size === 0;
  42806. } else if (controlItem.command === "redo") {
  42807. disabled = editorState.getRedoStack().size === 0;
  42808. }
  42809. return external_react_default.a.createElement(
  42810. "button",
  42811. {
  42812. type: "button",
  42813. key: index,
  42814. disabled: disabled,
  42815. "data-title": controlItem.title,
  42816. className: _this3.getControlItemClassName({
  42817. type: controlItem.type,
  42818. command: controlItem.command
  42819. }),
  42820. onClick: function onClick() {
  42821. return _this3.applyControl(
  42822. controlItem.command,
  42823. controlItem.type,
  42824. controlItem.data
  42825. );
  42826. }
  42827. },
  42828. controlItem.text
  42829. );
  42830. }
  42831. })
  42832. );
  42833. }
  42834. },
  42835. {
  42836. key: "preventDefault",
  42837. value: function preventDefault(event) {
  42838. var tagName = event.target.tagName.toLowerCase();
  42839. if (tagName === "input" || tagName === "label");
  42840. else {
  42841. event.preventDefault();
  42842. }
  42843. }
  42844. }
  42845. ]);
  42846. return ControlBar;
  42847. })(external_react_default.a.Component);
  42848. // CONCATENATED MODULE: ./editor/index.jsx
  42849. var buildHooks = function buildHooks(hooks) {
  42850. return function(hookName) {
  42851. var defaultReturns =
  42852. arguments.length > 1 && arguments[1] !== undefined
  42853. ? arguments[1]
  42854. : {};
  42855. return (
  42856. hooks[hookName] ||
  42857. function() {
  42858. return defaultReturns;
  42859. }
  42860. );
  42861. };
  42862. };
  42863. var filterColors = function filterColors(colors, colors2) {
  42864. return colors
  42865. .filter(function(item) {
  42866. return !colors2.find(function(color) {
  42867. return color.toLowerCase() === item.toLowerCase();
  42868. });
  42869. })
  42870. .filter(function(item, index, array) {
  42871. return array.indexOf(item) === index;
  42872. });
  42873. };
  42874. var editor_isControlEnabled = function isControlEnabled(
  42875. props,
  42876. controlName
  42877. ) {
  42878. return (
  42879. toConsumableArray_default()(props.controls)
  42880. .concat(toConsumableArray_default()(props.extendControls))
  42881. .find(function(item) {
  42882. return item === controlName || item.key === controlName;
  42883. }) && props.excludeControls.indexOf(controlName) === -1
  42884. );
  42885. };
  42886. var editor_getConvertOptions = function getConvertOptions(props) {
  42887. var editorId = props.editorId || props.id;
  42888. var convertOptions = objectSpread_default()(
  42889. {},
  42890. configs_props.converts,
  42891. props.converts,
  42892. {
  42893. fontFamilies: props.fontFamilies
  42894. }
  42895. );
  42896. convertOptions.styleImportFn = compositeStyleImportFn(
  42897. convertOptions.styleImportFn,
  42898. editorId
  42899. );
  42900. convertOptions.styleExportFn = compositeStyleExportFn(
  42901. convertOptions.styleExportFn,
  42902. editorId
  42903. );
  42904. convertOptions.entityImportFn = compositeEntityImportFn(
  42905. convertOptions.entityImportFn,
  42906. editorId
  42907. );
  42908. convertOptions.entityExportFn = compositeEntityExportFn(
  42909. convertOptions.entityExportFn,
  42910. editorId
  42911. );
  42912. convertOptions.blockImportFn = compositeBlockImportFn(
  42913. convertOptions.blockImportFn,
  42914. editorId
  42915. );
  42916. convertOptions.blockExportFn = compositeBlockExportFn(
  42917. convertOptions.blockExportFn,
  42918. editorId
  42919. );
  42920. return convertOptions;
  42921. };
  42922. var editor_BraftEditor =
  42923. /*#__PURE__*/
  42924. (function(_React$Component) {
  42925. inherits_default()(BraftEditor, _React$Component);
  42926. function BraftEditor(props) {
  42927. var _this;
  42928. classCallCheck_default()(this, BraftEditor);
  42929. _this = possibleConstructorReturn_default()(
  42930. this,
  42931. getPrototypeOf_default()(BraftEditor).call(this, props)
  42932. );
  42933. defineProperty_default()(
  42934. assertThisInitialized_default()(
  42935. assertThisInitialized_default()(_this)
  42936. ),
  42937. "onChange",
  42938. function(editorState, callback) {
  42939. if (
  42940. !(
  42941. editorState instanceof external_draft_js_["EditorState"]
  42942. )
  42943. ) {
  42944. editorState = external_draft_js_["EditorState"].set(
  42945. editorState,
  42946. {
  42947. decorator: _this.editorDecorators
  42948. }
  42949. );
  42950. }
  42951. if (!editorState.convertOptions) {
  42952. editorState.setConvertOptions(
  42953. editor_getConvertOptions(_this.editorProps)
  42954. );
  42955. }
  42956. _this.setState(
  42957. {
  42958. editorState: editorState
  42959. },
  42960. function() {
  42961. _this.props.onChange &&
  42962. _this.props.onChange(editorState);
  42963. callback && callback(editorState);
  42964. }
  42965. );
  42966. }
  42967. );
  42968. defineProperty_default()(
  42969. assertThisInitialized_default()(
  42970. assertThisInitialized_default()(_this)
  42971. ),
  42972. "getDraftInstance",
  42973. function() {
  42974. return _this.draftInstance;
  42975. }
  42976. );
  42977. defineProperty_default()(
  42978. assertThisInitialized_default()(
  42979. assertThisInitialized_default()(_this)
  42980. ),
  42981. "getFinderInstance",
  42982. function() {
  42983. return _this.braftFinder;
  42984. }
  42985. );
  42986. defineProperty_default()(
  42987. assertThisInitialized_default()(
  42988. assertThisInitialized_default()(_this)
  42989. ),
  42990. "getValue",
  42991. function() {
  42992. return _this.state.editorState;
  42993. }
  42994. );
  42995. defineProperty_default()(
  42996. assertThisInitialized_default()(
  42997. assertThisInitialized_default()(_this)
  42998. ),
  42999. "setValue",
  43000. function(editorState, callback) {
  43001. return _this.onChange(editorState, callback);
  43002. }
  43003. );
  43004. defineProperty_default()(
  43005. assertThisInitialized_default()(
  43006. assertThisInitialized_default()(_this)
  43007. ),
  43008. "forceRender",
  43009. function() {
  43010. var selectionState = _this.state.editorState.getSelection();
  43011. _this.setValue(
  43012. external_draft_js_["EditorState"].set(
  43013. _this.state.editorState,
  43014. {
  43015. decorator: _this.editorDecorators
  43016. }
  43017. ),
  43018. function() {
  43019. _this.setValue(
  43020. external_draft_js_["EditorState"].forceSelection(
  43021. _this.state.editorState,
  43022. selectionState
  43023. )
  43024. );
  43025. }
  43026. );
  43027. }
  43028. );
  43029. defineProperty_default()(
  43030. assertThisInitialized_default()(
  43031. assertThisInitialized_default()(_this)
  43032. ),
  43033. "onTab",
  43034. function(event) {
  43035. if (
  43036. handlers_keyCommandHandlers(
  43037. "tab",
  43038. _this.state.editorState,
  43039. assertThisInitialized_default()(
  43040. assertThisInitialized_default()(_this)
  43041. )
  43042. ) === "handled"
  43043. ) {
  43044. event.preventDefault();
  43045. }
  43046. _this.editorProps.onTab && _this.editorProps.onTab(event);
  43047. }
  43048. );
  43049. defineProperty_default()(
  43050. assertThisInitialized_default()(
  43051. assertThisInitialized_default()(_this)
  43052. ),
  43053. "onFocus",
  43054. function() {
  43055. _this.isFocused = true;
  43056. _this.editorProps.onFocus &&
  43057. _this.editorProps.onFocus(_this.state.editorState);
  43058. }
  43059. );
  43060. defineProperty_default()(
  43061. assertThisInitialized_default()(
  43062. assertThisInitialized_default()(_this)
  43063. ),
  43064. "onBlur",
  43065. function() {
  43066. _this.isFocused = false;
  43067. _this.editorProps.onBlur &&
  43068. _this.editorProps.onBlur(_this.state.editorState);
  43069. }
  43070. );
  43071. defineProperty_default()(
  43072. assertThisInitialized_default()(
  43073. assertThisInitialized_default()(_this)
  43074. ),
  43075. "requestFocus",
  43076. function() {
  43077. setTimeout(function() {
  43078. return _this.draftInstance.focus();
  43079. }, 0);
  43080. }
  43081. );
  43082. defineProperty_default()(
  43083. assertThisInitialized_default()(
  43084. assertThisInitialized_default()(_this)
  43085. ),
  43086. "handleKeyCommand",
  43087. function(command, editorState) {
  43088. return handlers_keyCommandHandlers(
  43089. command,
  43090. editorState,
  43091. assertThisInitialized_default()(
  43092. assertThisInitialized_default()(_this)
  43093. )
  43094. );
  43095. }
  43096. );
  43097. defineProperty_default()(
  43098. assertThisInitialized_default()(
  43099. assertThisInitialized_default()(_this)
  43100. ),
  43101. "handleReturn",
  43102. function(event, editorState) {
  43103. return handlers_returnHandlers(
  43104. event,
  43105. editorState,
  43106. assertThisInitialized_default()(
  43107. assertThisInitialized_default()(_this)
  43108. )
  43109. );
  43110. }
  43111. );
  43112. defineProperty_default()(
  43113. assertThisInitialized_default()(
  43114. assertThisInitialized_default()(_this)
  43115. ),
  43116. "handleBeforeInput",
  43117. function(chars, editorState) {
  43118. return beforeInputHandlers(
  43119. chars,
  43120. editorState,
  43121. assertThisInitialized_default()(
  43122. assertThisInitialized_default()(_this)
  43123. )
  43124. );
  43125. }
  43126. );
  43127. defineProperty_default()(
  43128. assertThisInitialized_default()(
  43129. assertThisInitialized_default()(_this)
  43130. ),
  43131. "handleDrop",
  43132. function(selectionState, dataTransfer) {
  43133. return handlers_dropHandlers(
  43134. selectionState,
  43135. dataTransfer,
  43136. assertThisInitialized_default()(
  43137. assertThisInitialized_default()(_this)
  43138. )
  43139. );
  43140. }
  43141. );
  43142. defineProperty_default()(
  43143. assertThisInitialized_default()(
  43144. assertThisInitialized_default()(_this)
  43145. ),
  43146. "handleDroppedFiles",
  43147. function(selectionState, files) {
  43148. return droppedFilesHandlers(
  43149. selectionState,
  43150. files,
  43151. assertThisInitialized_default()(
  43152. assertThisInitialized_default()(_this)
  43153. )
  43154. );
  43155. }
  43156. );
  43157. defineProperty_default()(
  43158. assertThisInitialized_default()(
  43159. assertThisInitialized_default()(_this)
  43160. ),
  43161. "handlePastedFiles",
  43162. function(files) {
  43163. return pastedFilesHandlers(
  43164. files,
  43165. assertThisInitialized_default()(
  43166. assertThisInitialized_default()(_this)
  43167. )
  43168. );
  43169. }
  43170. );
  43171. defineProperty_default()(
  43172. assertThisInitialized_default()(
  43173. assertThisInitialized_default()(_this)
  43174. ),
  43175. "handleCopyContent",
  43176. function(event) {
  43177. return handlers_copyHandlers(
  43178. event,
  43179. assertThisInitialized_default()(
  43180. assertThisInitialized_default()(_this)
  43181. )
  43182. );
  43183. }
  43184. );
  43185. defineProperty_default()(
  43186. assertThisInitialized_default()(
  43187. assertThisInitialized_default()(_this)
  43188. ),
  43189. "handlePastedText",
  43190. function(text, html, editorState) {
  43191. return handlers_pastedTextHandlers(
  43192. text,
  43193. html,
  43194. editorState,
  43195. assertThisInitialized_default()(
  43196. assertThisInitialized_default()(_this)
  43197. )
  43198. );
  43199. }
  43200. );
  43201. defineProperty_default()(
  43202. assertThisInitialized_default()(
  43203. assertThisInitialized_default()(_this)
  43204. ),
  43205. "handleCompositionStart",
  43206. function(event) {
  43207. return handlers_compositionStartHandler(
  43208. event,
  43209. assertThisInitialized_default()(
  43210. assertThisInitialized_default()(_this)
  43211. )
  43212. );
  43213. }
  43214. );
  43215. defineProperty_default()(
  43216. assertThisInitialized_default()(
  43217. assertThisInitialized_default()(_this)
  43218. ),
  43219. "undo",
  43220. function() {
  43221. _this.setValue(
  43222. external_braft_utils_["ContentUtils"].undo(
  43223. _this.state.editorState
  43224. )
  43225. );
  43226. }
  43227. );
  43228. defineProperty_default()(
  43229. assertThisInitialized_default()(
  43230. assertThisInitialized_default()(_this)
  43231. ),
  43232. "redo",
  43233. function() {
  43234. _this.setValue(
  43235. external_braft_utils_["ContentUtils"].redo(
  43236. _this.state.editorState
  43237. )
  43238. );
  43239. }
  43240. );
  43241. defineProperty_default()(
  43242. assertThisInitialized_default()(
  43243. assertThisInitialized_default()(_this)
  43244. ),
  43245. "removeSelectionInlineStyles",
  43246. function() {
  43247. _this.setValue(
  43248. external_braft_utils_[
  43249. "ContentUtils"
  43250. ].removeSelectionInlineStyles(_this.state.editorState)
  43251. );
  43252. }
  43253. );
  43254. defineProperty_default()(
  43255. assertThisInitialized_default()(
  43256. assertThisInitialized_default()(_this)
  43257. ),
  43258. "insertHorizontalLine",
  43259. function() {
  43260. _this.setValue(
  43261. external_braft_utils_[
  43262. "ContentUtils"
  43263. ].insertHorizontalLine(_this.state.editorState)
  43264. );
  43265. }
  43266. );
  43267. defineProperty_default()(
  43268. assertThisInitialized_default()(
  43269. assertThisInitialized_default()(_this)
  43270. ),
  43271. "clearEditorContent",
  43272. function() {
  43273. _this.setValue(
  43274. external_braft_utils_["ContentUtils"].clear(
  43275. _this.state.editorState
  43276. ),
  43277. function(editorState) {
  43278. _this.setValue(
  43279. external_braft_utils_[
  43280. "ContentUtils"
  43281. ].toggleSelectionIndent(editorState, 0)
  43282. );
  43283. }
  43284. );
  43285. }
  43286. );
  43287. defineProperty_default()(
  43288. assertThisInitialized_default()(
  43289. assertThisInitialized_default()(_this)
  43290. ),
  43291. "toggleFullscreen",
  43292. function(fullscreen) {
  43293. _this.setState(
  43294. {
  43295. isFullscreen:
  43296. typeof fullscreen !== "undefined"
  43297. ? fullscreen
  43298. : !_this.state.isFullscreen
  43299. },
  43300. function() {
  43301. _this.editorProps.onFullscreen &&
  43302. _this.editorProps.onFullscreen(
  43303. _this.state.isFullscreen
  43304. );
  43305. }
  43306. );
  43307. }
  43308. );
  43309. defineProperty_default()(
  43310. assertThisInitialized_default()(
  43311. assertThisInitialized_default()(_this)
  43312. ),
  43313. "setEditorContainerNode",
  43314. function(containerNode) {
  43315. _this.containerNode = containerNode;
  43316. }
  43317. );
  43318. _this.editorProps = _this.getEditorProps(props);
  43319. _this.editorDecorators = getDecorators(
  43320. _this.editorProps.editorId || _this.editorProps.id
  43321. );
  43322. _this.isFocused = false;
  43323. _this.isLiving = false;
  43324. _this.braftFinder = null;
  43325. _this.valueInitialized = !!(
  43326. _this.props.defaultValue || _this.props.value
  43327. );
  43328. var defaultEditorState =
  43329. (_this.props.defaultValue || _this.props.value) instanceof
  43330. external_draft_js_["EditorState"]
  43331. ? _this.props.defaultValue || _this.props.value
  43332. : external_draft_js_["EditorState"].createEmpty(
  43333. _this.editorDecorators
  43334. );
  43335. defaultEditorState.setConvertOptions(
  43336. editor_getConvertOptions(_this.editorProps)
  43337. );
  43338. var tempColors = [];
  43339. if (
  43340. external_braft_utils_["ContentUtils"].isEditorState(
  43341. defaultEditorState
  43342. )
  43343. ) {
  43344. var colors = external_braft_utils_[
  43345. "ColorUtils"
  43346. ].detectColorsFromDraftState(defaultEditorState.toRAW(true));
  43347. defaultEditorState.setConvertOptions(
  43348. editor_getConvertOptions(_this.editorProps)
  43349. );
  43350. tempColors = filterColors(colors, _this.editorProps.colors);
  43351. }
  43352. _this.state = {
  43353. tempColors: tempColors,
  43354. editorState: defaultEditorState,
  43355. isFullscreen: false,
  43356. draftProps: {}
  43357. };
  43358. _this.containerNode = null;
  43359. return _this;
  43360. }
  43361. createClass_default()(BraftEditor, [
  43362. {
  43363. key: "getEditorProps",
  43364. value: function getEditorProps(props) {
  43365. var _this2 = this;
  43366. props = props || this.props;
  43367. var _props = props,
  43368. value = _props.value,
  43369. defaultValue = _props.defaultValue,
  43370. onChange = _props.onChange,
  43371. restProps = objectWithoutProperties_default()(_props, [
  43372. "value",
  43373. "defaultValue",
  43374. "onChange"
  43375. ]); // eslint-disable-line no-unused-vars
  43376. var propInterceptors = getPropInterceptors(
  43377. restProps.editorId || restProps.id
  43378. );
  43379. if (propInterceptors.length === 0) {
  43380. return restProps;
  43381. }
  43382. var porpsMap = Object(external_immutable_["Map"])(
  43383. restProps
  43384. );
  43385. propInterceptors.forEach(function(interceptor) {
  43386. porpsMap = porpsMap.merge(
  43387. Object(external_immutable_["Map"])(
  43388. interceptor(porpsMap.toJS(), _this2) || {}
  43389. )
  43390. );
  43391. });
  43392. return porpsMap.toJS();
  43393. }
  43394. },
  43395. {
  43396. key: "componentWillMount",
  43397. value: function componentWillMount() {
  43398. if (editor_isControlEnabled(this.editorProps, "media")) {
  43399. var _this$editorProps = this.editorProps,
  43400. language = _this$editorProps.language,
  43401. media = _this$editorProps.media;
  43402. var _defaultProps$media$m = objectSpread_default()(
  43403. {},
  43404. configs_props.media,
  43405. media
  43406. ),
  43407. uploadFn = _defaultProps$media$m.uploadFn,
  43408. validateFn = _defaultProps$media$m.validateFn,
  43409. items = _defaultProps$media$m.items;
  43410. this.braftFinder = new external_braft_finder_default.a({
  43411. items: items,
  43412. language: language,
  43413. uploader: uploadFn,
  43414. validator: validateFn
  43415. });
  43416. this.forceUpdate();
  43417. }
  43418. }
  43419. },
  43420. {
  43421. key: "componentDidMount",
  43422. value: function componentDidMount() {
  43423. this.isLiving = true;
  43424. }
  43425. },
  43426. {
  43427. key: "componentDidUpdate",
  43428. value: function componentDidUpdate(_, prevState) {
  43429. if (prevState.editorState !== this.state.editorState) {
  43430. this.state.editorState.setConvertOptions(
  43431. editor_getConvertOptions(this.editorProps)
  43432. );
  43433. }
  43434. }
  43435. },
  43436. {
  43437. key: "componentWillReceiveProps",
  43438. value: function componentWillReceiveProps(props) {
  43439. var _this3 = this;
  43440. this.editorProps = this.getEditorProps(props);
  43441. var editorState = props.value;
  43442. var _this$editorProps2 = this.editorProps,
  43443. media = _this$editorProps2.media,
  43444. language = _this$editorProps2.language;
  43445. var currentProps = this.getEditorProps();
  43446. if (
  43447. !editor_isControlEnabled(currentProps, "media") &&
  43448. editor_isControlEnabled(this.editorProps, "media") &&
  43449. !this.braftFinder
  43450. ) {
  43451. var _defaultProps$media$m2 = objectSpread_default()(
  43452. {},
  43453. configs_props.media,
  43454. media
  43455. ),
  43456. uploadFn = _defaultProps$media$m2.uploadFn,
  43457. validateFn = _defaultProps$media$m2.validateFn,
  43458. items = _defaultProps$media$m2.items;
  43459. this.braftFinder = new external_braft_finder_default.a({
  43460. items: items,
  43461. language: language,
  43462. uploader: uploadFn,
  43463. validator: validateFn
  43464. });
  43465. this.forceUpdate();
  43466. }
  43467. if (media && media.items && this.braftFinder) {
  43468. this.braftFinder.setItems(media.items);
  43469. }
  43470. var nextEditorState;
  43471. if (
  43472. !this.valueInitialized &&
  43473. typeof this.props.defaultValue === "undefined" &&
  43474. external_braft_utils_["ContentUtils"].isEditorState(
  43475. props.defaultValue
  43476. )
  43477. ) {
  43478. nextEditorState = props.defaultValue;
  43479. } else if (
  43480. external_braft_utils_["ContentUtils"].isEditorState(
  43481. editorState
  43482. )
  43483. ) {
  43484. nextEditorState = editorState;
  43485. }
  43486. if (nextEditorState) {
  43487. if (
  43488. nextEditorState &&
  43489. nextEditorState !== this.state.editorState
  43490. ) {
  43491. var tempColors = external_braft_utils_[
  43492. "ColorUtils"
  43493. ].detectColorsFromDraftState(
  43494. nextEditorState.toRAW(true)
  43495. );
  43496. nextEditorState.setConvertOptions(
  43497. editor_getConvertOptions(this.editorProps)
  43498. );
  43499. this.setState(
  43500. {
  43501. tempColors: filterColors(
  43502. toConsumableArray_default()(
  43503. this.state.tempColors
  43504. ).concat(toConsumableArray_default()(tempColors)),
  43505. currentProps.colors
  43506. ),
  43507. editorState: nextEditorState
  43508. },
  43509. function() {
  43510. _this3.props.onChange &&
  43511. _this3.props.onChange(nextEditorState);
  43512. }
  43513. );
  43514. } else {
  43515. this.setState({
  43516. editorState: nextEditorState
  43517. });
  43518. }
  43519. }
  43520. }
  43521. },
  43522. {
  43523. key: "componentWillUnmount",
  43524. value: function componentWillUnmount() {
  43525. this.isLiving = false;
  43526. this.controlBarInstance &&
  43527. this.controlBarInstance.closeBraftFinder();
  43528. }
  43529. },
  43530. {
  43531. key: "lockOrUnlockEditor",
  43532. value: function lockOrUnlockEditor(editorLocked) {
  43533. this.setState({
  43534. editorLocked: editorLocked
  43535. });
  43536. }
  43537. },
  43538. {
  43539. key: "render",
  43540. value: function render() {
  43541. var _this4 = this;
  43542. var _this$editorProps3 = this.editorProps,
  43543. id = _this$editorProps3.id,
  43544. editorId = _this$editorProps3.editorId,
  43545. controls = _this$editorProps3.controls,
  43546. excludeControls = _this$editorProps3.excludeControls,
  43547. extendControls = _this$editorProps3.extendControls,
  43548. readOnly = _this$editorProps3.readOnly,
  43549. disabled = _this$editorProps3.disabled,
  43550. media = _this$editorProps3.media,
  43551. language = _this$editorProps3.language,
  43552. colors = _this$editorProps3.colors,
  43553. colorPicker = _this$editorProps3.colorPicker,
  43554. colorPickerTheme = _this$editorProps3.colorPickerTheme,
  43555. colorPickerAutoHide =
  43556. _this$editorProps3.colorPickerAutoHide,
  43557. hooks = _this$editorProps3.hooks,
  43558. fontSizes = _this$editorProps3.fontSizes,
  43559. fontFamilies = _this$editorProps3.fontFamilies,
  43560. emojis = _this$editorProps3.emojis,
  43561. placeholder = _this$editorProps3.placeholder,
  43562. fixPlaceholder = _this$editorProps3.fixPlaceholder,
  43563. headings = _this$editorProps3.headings,
  43564. imageControls = _this$editorProps3.imageControls,
  43565. imageResizable = _this$editorProps3.imageResizable,
  43566. lineHeights = _this$editorProps3.lineHeights,
  43567. letterSpacings = _this$editorProps3.letterSpacings,
  43568. textAligns = _this$editorProps3.textAligns,
  43569. textBackgroundColor =
  43570. _this$editorProps3.textBackgroundColor,
  43571. allowInsertLinkText =
  43572. _this$editorProps3.allowInsertLinkText,
  43573. defaultLinkTarget = _this$editorProps3.defaultLinkTarget,
  43574. extendAtomics = _this$editorProps3.extendAtomics,
  43575. className = _this$editorProps3.className,
  43576. style = _this$editorProps3.style,
  43577. controlBarClassName =
  43578. _this$editorProps3.controlBarClassName,
  43579. controlBarStyle = _this$editorProps3.controlBarStyle,
  43580. contentClassName = _this$editorProps3.contentClassName,
  43581. contentStyle = _this$editorProps3.contentStyle,
  43582. stripPastedStyles = _this$editorProps3.stripPastedStyles,
  43583. componentBelowControlBar =
  43584. _this$editorProps3.componentBelowControlBar;
  43585. var _this$state = this.state,
  43586. isFullscreen = _this$state.isFullscreen,
  43587. editorState = _this$state.editorState;
  43588. editorId = editorId || id;
  43589. hooks = buildHooks(hooks);
  43590. controls = controls.filter(function(item) {
  43591. return excludeControls.indexOf(item) === -1;
  43592. });
  43593. language =
  43594. (typeof language === "function"
  43595. ? language(languages, "braft-editor")
  43596. : languages[language]) ||
  43597. languages[configs_props.language];
  43598. var externalMedias =
  43599. media && media.externals
  43600. ? objectSpread_default()(
  43601. {},
  43602. configs_props.media.externals,
  43603. media.externals
  43604. )
  43605. : configs_props.media.externals;
  43606. var accepts =
  43607. media && media.accepts
  43608. ? objectSpread_default()(
  43609. {},
  43610. configs_props.media.accepts,
  43611. media.accepts
  43612. )
  43613. : configs_props.media.accepts;
  43614. media = objectSpread_default()(
  43615. {},
  43616. configs_props.media,
  43617. media,
  43618. {
  43619. externalMedias: externalMedias,
  43620. accepts: accepts
  43621. }
  43622. );
  43623. if (!media.uploadFn) {
  43624. media.video = false;
  43625. media.audio = false;
  43626. }
  43627. var controlBarProps = {
  43628. editor: this,
  43629. editorState: editorState,
  43630. braftFinder: this.braftFinder,
  43631. ref: function ref(instance) {
  43632. return (_this4.controlBarInstance = instance);
  43633. },
  43634. getContainerNode: function getContainerNode() {
  43635. return _this4.containerNode;
  43636. },
  43637. className: controlBarClassName,
  43638. style: controlBarStyle,
  43639. colors: toConsumableArray_default()(colors).concat(
  43640. toConsumableArray_default()(this.state.tempColors)
  43641. ),
  43642. colorPicker: colorPicker,
  43643. colorPickerTheme: colorPickerTheme,
  43644. colorPickerAutoHide: colorPickerAutoHide,
  43645. hooks: hooks,
  43646. editorId: editorId,
  43647. media: media,
  43648. controls: controls,
  43649. language: language,
  43650. extendControls: extendControls,
  43651. headings: headings,
  43652. fontSizes: fontSizes,
  43653. fontFamilies: fontFamilies,
  43654. emojis: emojis,
  43655. lineHeights: lineHeights,
  43656. letterSpacings: letterSpacings,
  43657. textAligns: textAligns,
  43658. textBackgroundColor: textBackgroundColor,
  43659. allowInsertLinkText: allowInsertLinkText,
  43660. defaultLinkTarget: defaultLinkTarget
  43661. };
  43662. var unitExportFn = editorState.convertOptions.unitExportFn;
  43663. var commonProps = {
  43664. editor: this,
  43665. editorId: editorId,
  43666. hooks: hooks,
  43667. editorState: editorState,
  43668. containerNode: this.containerNode,
  43669. imageControls: imageControls,
  43670. imageResizable: imageResizable,
  43671. language: language,
  43672. extendAtomics: extendAtomics
  43673. };
  43674. var blockRendererFn = getBlockRendererFn(
  43675. commonProps,
  43676. this.editorProps.blockRendererFn
  43677. );
  43678. var blockRenderMap = getBlockRenderMap(
  43679. commonProps,
  43680. this.editorProps.blockRenderMap
  43681. );
  43682. var blockStyleFn = getBlockStyleFn(
  43683. this.editorProps.blockStyleFn
  43684. );
  43685. var customStyleMap = getCustomStyleMap(
  43686. commonProps,
  43687. this.editorProps.customStyleMap
  43688. );
  43689. var customStyleFn = getCustomStyleFn(commonProps, {
  43690. fontFamilies: fontFamilies,
  43691. unitExportFn: unitExportFn,
  43692. customStyleFn: this.editorProps.customStyleFn
  43693. });
  43694. var keyBindingFn = keybindings(
  43695. this.editorProps.keyBindingFn
  43696. );
  43697. var mixedProps = {};
  43698. if (
  43699. this.state.editorLocked ||
  43700. this.editorProps.disabled ||
  43701. this.editorProps.readOnly ||
  43702. this.editorProps.draftProps.readOnly
  43703. ) {
  43704. mixedProps.readOnly = true;
  43705. }
  43706. if (
  43707. placeholder &&
  43708. fixPlaceholder &&
  43709. editorState.isEmpty() &&
  43710. editorState
  43711. .getCurrentContent()
  43712. .getFirstBlock()
  43713. .getType() !== "unstyled"
  43714. ) {
  43715. placeholder = "";
  43716. }
  43717. var draftProps = objectSpread_default()(
  43718. {
  43719. ref: function ref(instance) {
  43720. _this4.draftInstance = instance;
  43721. },
  43722. editorState: editorState,
  43723. handleKeyCommand: this.handleKeyCommand,
  43724. handleReturn: this.handleReturn,
  43725. handleBeforeInput: this.handleBeforeInput,
  43726. handleDrop: this.handleDrop,
  43727. handleDroppedFiles: this.handleDroppedFiles,
  43728. handlePastedText: this.handlePastedText,
  43729. handlePastedFiles: this.handlePastedFiles,
  43730. onChange: this.onChange,
  43731. onTab: this.onTab,
  43732. onFocus: this.onFocus,
  43733. onBlur: this.onBlur,
  43734. blockRenderMap: blockRenderMap,
  43735. blockRendererFn: blockRendererFn,
  43736. blockStyleFn: blockStyleFn,
  43737. customStyleMap: customStyleMap,
  43738. customStyleFn: customStyleFn,
  43739. keyBindingFn: keyBindingFn,
  43740. placeholder: placeholder,
  43741. stripPastedStyles: stripPastedStyles
  43742. },
  43743. this.editorProps.draftProps,
  43744. mixedProps
  43745. );
  43746. return external_react_default.a.createElement(
  43747. "div",
  43748. {
  43749. style: style,
  43750. ref: this.setEditorContainerNode,
  43751. className: "bf-container "
  43752. .concat(className)
  43753. .concat(disabled ? " disabled" : "")
  43754. .concat(readOnly ? " read-only" : "")
  43755. .concat(isFullscreen ? " fullscreen" : "")
  43756. },
  43757. external_react_default.a.createElement(
  43758. ControlBar_ControlBar,
  43759. controlBarProps
  43760. ),
  43761. componentBelowControlBar,
  43762. external_react_default.a.createElement(
  43763. "div",
  43764. {
  43765. onCompositionStart: this.handleCompositionStart,
  43766. className: "bf-content ".concat(contentClassName),
  43767. onCopy: this.handleCopyContent,
  43768. style: contentStyle
  43769. },
  43770. external_react_default.a.createElement(
  43771. external_draft_js_["Editor"],
  43772. draftProps
  43773. )
  43774. )
  43775. );
  43776. }
  43777. }
  43778. ]);
  43779. return BraftEditor;
  43780. })(external_react_default.a.Component);
  43781. defineProperty_default()(
  43782. editor_BraftEditor,
  43783. "defaultProps",
  43784. configs_props
  43785. );
  43786. // EXTERNAL MODULE: external "braft-convert"
  43787. var external_braft_convert_ = __webpack_require__(14);
  43788. // CONCATENATED MODULE: ./index.jsx
  43789. /* concated harmony reexport EditorState */ __webpack_require__.d(
  43790. __webpack_exports__,
  43791. "EditorState",
  43792. function() {
  43793. return external_draft_js_["EditorState"];
  43794. }
  43795. );
  43796. /* concated harmony reexport getDecorators */ __webpack_require__.d(
  43797. __webpack_exports__,
  43798. "getDecorators",
  43799. function() {
  43800. return getDecorators;
  43801. }
  43802. );
  43803. external_draft_js_[
  43804. "EditorState"
  43805. ].prototype.setConvertOptions = function() {
  43806. var options =
  43807. arguments.length > 0 && arguments[0] !== undefined
  43808. ? arguments[0]
  43809. : {};
  43810. this.convertOptions = options;
  43811. };
  43812. external_draft_js_["EditorState"].prototype.toHTML = function() {
  43813. var options =
  43814. arguments.length > 0 && arguments[0] !== undefined
  43815. ? arguments[0]
  43816. : {};
  43817. var convertOptions = this.convertOptions || {};
  43818. return Object(external_braft_convert_["convertEditorStateToHTML"])(
  43819. this,
  43820. objectSpread_default()({}, convertOptions, options)
  43821. );
  43822. };
  43823. external_draft_js_["EditorState"].prototype.toRAW = function(
  43824. noStringify
  43825. ) {
  43826. return noStringify
  43827. ? Object(external_braft_convert_["convertEditorStateToRaw"])(this)
  43828. : JSON.stringify(
  43829. Object(external_braft_convert_["convertEditorStateToRaw"])(
  43830. this
  43831. )
  43832. );
  43833. };
  43834. external_draft_js_["EditorState"].prototype.toText = function() {
  43835. return this.getCurrentContent().getPlainText();
  43836. };
  43837. external_draft_js_["EditorState"].prototype.isEmpty = function() {
  43838. return !this.getCurrentContent().hasText();
  43839. };
  43840. editor_BraftEditor.createEditorState = external_draft_js_[
  43841. "EditorState"
  43842. ].createFrom = function(content) {
  43843. var options =
  43844. arguments.length > 1 && arguments[1] !== undefined
  43845. ? arguments[1]
  43846. : {};
  43847. options.unitExportFn =
  43848. options.unitExportFn ||
  43849. editor_BraftEditor.defaultProps.converts.unitExportFn;
  43850. options.styleImportFn = compositeStyleImportFn(
  43851. options.styleImportFn,
  43852. options.editorId
  43853. );
  43854. options.entityImportFn = compositeEntityImportFn(
  43855. options.entityImportFn,
  43856. options.editorId
  43857. );
  43858. options.blockImportFn = compositeBlockImportFn(
  43859. options.blockImportFn,
  43860. options.editorId
  43861. );
  43862. var editorState = null;
  43863. if (content instanceof external_draft_js_["EditorState"]) {
  43864. editorState = content;
  43865. } else if (
  43866. typeof_default()(content) === "object" &&
  43867. content &&
  43868. content.blocks &&
  43869. content.entityMap
  43870. ) {
  43871. editorState = Object(
  43872. external_braft_convert_["convertRawToEditorState"]
  43873. )(content, getDecorators(options.editorId));
  43874. } else if (typeof content === "string") {
  43875. try {
  43876. if (/^(-)?\d+$/.test(content)) {
  43877. editorState = Object(
  43878. external_braft_convert_["convertHTMLToEditorState"]
  43879. )(
  43880. content,
  43881. getDecorators(options.editorId),
  43882. options,
  43883. "create"
  43884. );
  43885. } else {
  43886. editorState = external_draft_js_["EditorState"].createFrom(
  43887. JSON.parse(content),
  43888. options
  43889. );
  43890. }
  43891. } catch (error) {
  43892. editorState = Object(
  43893. external_braft_convert_["convertHTMLToEditorState"]
  43894. )(content, getDecorators(options.editorId), options, "create");
  43895. }
  43896. } else if (typeof content === "number") {
  43897. editorState = Object(
  43898. external_braft_convert_["convertHTMLToEditorState"]
  43899. )(
  43900. content.toLocaleString().replace(/,/g, ""),
  43901. getDecorators(options.editorId),
  43902. options,
  43903. "create"
  43904. );
  43905. } else {
  43906. editorState = external_draft_js_["EditorState"].createEmpty(
  43907. getDecorators(options.editorId)
  43908. );
  43909. }
  43910. options.styleExportFn = compositeStyleExportFn(
  43911. options.styleExportFn,
  43912. options.editorId
  43913. );
  43914. options.entityExportFn = compositeEntityExportFn(
  43915. options.entityExportFn,
  43916. options.editorId
  43917. );
  43918. options.blockExportFn = compositeBlockExportFn(
  43919. options.blockExportFn,
  43920. options.editorId
  43921. );
  43922. editorState.setConvertOptions(options);
  43923. return editorState;
  43924. };
  43925. /* harmony default export */ var index_0 = (__webpack_exports__[
  43926. "default"
  43927. ] = createExtensibleEditor(editor_BraftEditor));
  43928. // 2.1版本开发计划
  43929. // [ ]优化选中多行文字是插入链接报错的问题
  43930. // [ ]新增编辑器内图片删除hook
  43931. // 2.2版本开发计划
  43932. // [ ]表格功能
  43933. // [ ]美化UI,包括图标和界面风格
  43934. // 2.3版本开发计划
  43935. // [ ]初级md快捷输入支持
  43936. // [ ]图片裁切等简单的编辑功能
  43937. // [ ]允许自定义快捷键
  43938. /***/
  43939. },
  43940. /* 40 */
  43941. /***/ function(module, exports) {
  43942. // removed by extract-text-webpack-plugin
  43943. /***/
  43944. },
  43945. ,
  43946. /* 41 */ /* 42 */
  43947. /***/ function(module, exports) {
  43948. // removed by extract-text-webpack-plugin
  43949. /***/
  43950. },
  43951. ,
  43952. ,
  43953. /* 43 */ /* 44 */ /* 45 */
  43954. /***/ function(module, exports) {
  43955. // removed by extract-text-webpack-plugin
  43956. /***/
  43957. },
  43958. /* 46 */
  43959. /***/ function(module, exports) {
  43960. // removed by extract-text-webpack-plugin
  43961. /***/
  43962. },
  43963. /* 47 */
  43964. /***/ function(module, exports) {
  43965. // removed by extract-text-webpack-plugin
  43966. /***/
  43967. },
  43968. /* 48 */
  43969. /***/ function(module, exports) {
  43970. // removed by extract-text-webpack-plugin
  43971. /***/
  43972. },
  43973. /* 49 */
  43974. /***/ function(module, exports) {
  43975. // removed by extract-text-webpack-plugin
  43976. /***/
  43977. },
  43978. /* 50 */
  43979. /***/ function(module, exports) {
  43980. // removed by extract-text-webpack-plugin
  43981. /***/
  43982. },
  43983. /* 51 */
  43984. /***/ function(module, exports) {
  43985. // removed by extract-text-webpack-plugin
  43986. /***/
  43987. },
  43988. /* 52 */
  43989. /***/ function(module, exports) {
  43990. // removed by extract-text-webpack-plugin
  43991. /***/
  43992. },
  43993. /* 53 */
  43994. /***/ function(module, exports) {
  43995. // removed by extract-text-webpack-plugin
  43996. /***/
  43997. },
  43998. /* 54 */
  43999. /***/ function(module, exports) {
  44000. // removed by extract-text-webpack-plugin
  44001. /***/
  44002. },
  44003. /* 55 */
  44004. /***/ function(module, exports) {
  44005. // removed by extract-text-webpack-plugin
  44006. /***/
  44007. },
  44008. /* 56 */
  44009. /***/ function(module, exports) {
  44010. // removed by extract-text-webpack-plugin
  44011. /***/
  44012. },
  44013. /* 57 */
  44014. /***/ function(module, exports) {
  44015. // removed by extract-text-webpack-plugin
  44016. /***/
  44017. },
  44018. /* 58 */
  44019. /***/ function(module, exports) {
  44020. // removed by extract-text-webpack-plugin
  44021. /***/
  44022. },
  44023. /* 59 */
  44024. /***/ function(module, exports) {
  44025. // removed by extract-text-webpack-plugin
  44026. /***/
  44027. },
  44028. /* 60 */
  44029. /***/ function(module, exports) {
  44030. // removed by extract-text-webpack-plugin
  44031. /***/
  44032. },
  44033. /* 61 */
  44034. /***/ function(module, exports) {
  44035. // removed by extract-text-webpack-plugin
  44036. /***/
  44037. },
  44038. /* 62 */
  44039. /***/ function(module, exports) {
  44040. // removed by extract-text-webpack-plugin
  44041. /***/
  44042. },
  44043. /* 63 */
  44044. /***/ function(module, exports) {
  44045. // removed by extract-text-webpack-plugin
  44046. /***/
  44047. }
  44048. /******/
  44049. ]
  44050. );
  44051. });
  44052. });
  44053. var BraftEditor = _commonjsHelpers.unwrapExports(dist$3);
  44054. var css =
  44055. '.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)}';
  44056. styleInject_es.styleInject(css);
  44057. var css$1 =
  44058. '.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}';
  44059. styleInject_es.styleInject(css$1);
  44060. var immutable$3 = _commonjsHelpers.createCommonjsModule(function(
  44061. module,
  44062. exports
  44063. ) {
  44064. /**
  44065. * Copyright (c) 2014-present, Facebook, Inc.
  44066. *
  44067. * This source code is licensed under the MIT license found in the
  44068. * LICENSE file in the root directory of this source tree.
  44069. */
  44070. (function(global, factory) {
  44071. factory(exports);
  44072. })(_commonjsHelpers.commonjsGlobal, function(exports) {
  44073. // Used for setting prototype methods that IE8 chokes on.
  44074. var DELETE = "delete";
  44075. // Constants describing the size of trie nodes.
  44076. var SHIFT = 5; // Resulted in best performance after ______?
  44077. var SIZE = 1 << SHIFT;
  44078. var MASK = SIZE - 1;
  44079. // A consistent shared value representing "not set" which equals nothing other
  44080. // than itself, and nothing that could be provided externally.
  44081. var NOT_SET = {};
  44082. // Boolean references, Rough equivalent of `bool &`.
  44083. function MakeRef() {
  44084. return { value: false };
  44085. }
  44086. function SetRef(ref) {
  44087. if (ref) {
  44088. ref.value = true;
  44089. }
  44090. }
  44091. // A function which returns a value representing an "owner" for transient writes
  44092. // to tries. The return value will only ever equal itself, and will not equal
  44093. // the return of any subsequent call of this function.
  44094. function OwnerID() {}
  44095. function ensureSize(iter) {
  44096. if (iter.size === undefined) {
  44097. iter.size = iter.__iterate(returnTrue);
  44098. }
  44099. return iter.size;
  44100. }
  44101. function wrapIndex(iter, index) {
  44102. // This implements "is array index" which the ECMAString spec defines as:
  44103. //
  44104. // A String property name P is an array index if and only if
  44105. // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
  44106. // to 2^32−1.
  44107. //
  44108. // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
  44109. if (typeof index !== "number") {
  44110. var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
  44111. if ("" + uint32Index !== index || uint32Index === 4294967295) {
  44112. return NaN;
  44113. }
  44114. index = uint32Index;
  44115. }
  44116. return index < 0 ? ensureSize(iter) + index : index;
  44117. }
  44118. function returnTrue() {
  44119. return true;
  44120. }
  44121. function wholeSlice(begin, end, size) {
  44122. return (
  44123. ((begin === 0 && !isNeg(begin)) ||
  44124. (size !== undefined && begin <= -size)) &&
  44125. (end === undefined || (size !== undefined && end >= size))
  44126. );
  44127. }
  44128. function resolveBegin(begin, size) {
  44129. return resolveIndex(begin, size, 0);
  44130. }
  44131. function resolveEnd(end, size) {
  44132. return resolveIndex(end, size, size);
  44133. }
  44134. function resolveIndex(index, size, defaultIndex) {
  44135. // Sanitize indices using this shorthand for ToInt32(argument)
  44136. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  44137. return index === undefined
  44138. ? defaultIndex
  44139. : isNeg(index)
  44140. ? size === Infinity
  44141. ? size
  44142. : Math.max(0, size + index) | 0
  44143. : size === undefined || size === index
  44144. ? index
  44145. : Math.min(size, index) | 0;
  44146. }
  44147. function isNeg(value) {
  44148. // Account for -0 which is negative, but not less than 0.
  44149. return value < 0 || (value === 0 && 1 / value === -Infinity);
  44150. }
  44151. // Note: value is unchanged to not break immutable-devtools.
  44152. var IS_COLLECTION_SYMBOL = "@@__IMMUTABLE_ITERABLE__@@";
  44153. function isCollection(maybeCollection) {
  44154. return Boolean(maybeCollection && maybeCollection[IS_COLLECTION_SYMBOL]);
  44155. }
  44156. var IS_KEYED_SYMBOL = "@@__IMMUTABLE_KEYED__@@";
  44157. function isKeyed(maybeKeyed) {
  44158. return Boolean(maybeKeyed && maybeKeyed[IS_KEYED_SYMBOL]);
  44159. }
  44160. var IS_INDEXED_SYMBOL = "@@__IMMUTABLE_INDEXED__@@";
  44161. function isIndexed(maybeIndexed) {
  44162. return Boolean(maybeIndexed && maybeIndexed[IS_INDEXED_SYMBOL]);
  44163. }
  44164. function isAssociative(maybeAssociative) {
  44165. return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
  44166. }
  44167. var Collection = function Collection(value) {
  44168. return isCollection(value) ? value : Seq(value);
  44169. };
  44170. var KeyedCollection = /*@__PURE__*/ (function(Collection) {
  44171. function KeyedCollection(value) {
  44172. return isKeyed(value) ? value : KeyedSeq(value);
  44173. }
  44174. if (Collection) KeyedCollection.__proto__ = Collection;
  44175. KeyedCollection.prototype = Object.create(
  44176. Collection && Collection.prototype
  44177. );
  44178. KeyedCollection.prototype.constructor = KeyedCollection;
  44179. return KeyedCollection;
  44180. })(Collection);
  44181. var IndexedCollection = /*@__PURE__*/ (function(Collection) {
  44182. function IndexedCollection(value) {
  44183. return isIndexed(value) ? value : IndexedSeq(value);
  44184. }
  44185. if (Collection) IndexedCollection.__proto__ = Collection;
  44186. IndexedCollection.prototype = Object.create(
  44187. Collection && Collection.prototype
  44188. );
  44189. IndexedCollection.prototype.constructor = IndexedCollection;
  44190. return IndexedCollection;
  44191. })(Collection);
  44192. var SetCollection = /*@__PURE__*/ (function(Collection) {
  44193. function SetCollection(value) {
  44194. return isCollection(value) && !isAssociative(value)
  44195. ? value
  44196. : SetSeq(value);
  44197. }
  44198. if (Collection) SetCollection.__proto__ = Collection;
  44199. SetCollection.prototype = Object.create(
  44200. Collection && Collection.prototype
  44201. );
  44202. SetCollection.prototype.constructor = SetCollection;
  44203. return SetCollection;
  44204. })(Collection);
  44205. Collection.Keyed = KeyedCollection;
  44206. Collection.Indexed = IndexedCollection;
  44207. Collection.Set = SetCollection;
  44208. var IS_SEQ_SYMBOL = "@@__IMMUTABLE_SEQ__@@";
  44209. function isSeq(maybeSeq) {
  44210. return Boolean(maybeSeq && maybeSeq[IS_SEQ_SYMBOL]);
  44211. }
  44212. var IS_RECORD_SYMBOL = "@@__IMMUTABLE_RECORD__@@";
  44213. function isRecord(maybeRecord) {
  44214. return Boolean(maybeRecord && maybeRecord[IS_RECORD_SYMBOL]);
  44215. }
  44216. function isImmutable(maybeImmutable) {
  44217. return isCollection(maybeImmutable) || isRecord(maybeImmutable);
  44218. }
  44219. var IS_ORDERED_SYMBOL = "@@__IMMUTABLE_ORDERED__@@";
  44220. function isOrdered(maybeOrdered) {
  44221. return Boolean(maybeOrdered && maybeOrdered[IS_ORDERED_SYMBOL]);
  44222. }
  44223. var ITERATE_KEYS = 0;
  44224. var ITERATE_VALUES = 1;
  44225. var ITERATE_ENTRIES = 2;
  44226. var REAL_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
  44227. var FAUX_ITERATOR_SYMBOL = "@@iterator";
  44228. var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
  44229. var Iterator = function Iterator(next) {
  44230. this.next = next;
  44231. };
  44232. Iterator.prototype.toString = function toString() {
  44233. return "[Iterator]";
  44234. };
  44235. Iterator.KEYS = ITERATE_KEYS;
  44236. Iterator.VALUES = ITERATE_VALUES;
  44237. Iterator.ENTRIES = ITERATE_ENTRIES;
  44238. Iterator.prototype.inspect = Iterator.prototype.toSource = function() {
  44239. return this.toString();
  44240. };
  44241. Iterator.prototype[ITERATOR_SYMBOL] = function() {
  44242. return this;
  44243. };
  44244. function iteratorValue(type, k, v, iteratorResult) {
  44245. var value = type === 0 ? k : type === 1 ? v : [k, v];
  44246. iteratorResult
  44247. ? (iteratorResult.value = value)
  44248. : (iteratorResult = {
  44249. value: value,
  44250. done: false
  44251. });
  44252. return iteratorResult;
  44253. }
  44254. function iteratorDone() {
  44255. return { value: undefined, done: true };
  44256. }
  44257. function hasIterator(maybeIterable) {
  44258. return !!getIteratorFn(maybeIterable);
  44259. }
  44260. function isIterator(maybeIterator) {
  44261. return maybeIterator && typeof maybeIterator.next === "function";
  44262. }
  44263. function getIterator(iterable) {
  44264. var iteratorFn = getIteratorFn(iterable);
  44265. return iteratorFn && iteratorFn.call(iterable);
  44266. }
  44267. function getIteratorFn(iterable) {
  44268. var iteratorFn =
  44269. iterable &&
  44270. ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
  44271. iterable[FAUX_ITERATOR_SYMBOL]);
  44272. if (typeof iteratorFn === "function") {
  44273. return iteratorFn;
  44274. }
  44275. }
  44276. var hasOwnProperty = Object.prototype.hasOwnProperty;
  44277. function isArrayLike(value) {
  44278. if (Array.isArray(value) || typeof value === "string") {
  44279. return true;
  44280. }
  44281. return (
  44282. value &&
  44283. typeof value === "object" &&
  44284. Number.isInteger(value.length) &&
  44285. value.length >= 0 &&
  44286. (value.length === 0
  44287. ? // Only {length: 0} is considered Array-like.
  44288. Object.keys(value).length === 1
  44289. : // An object is only Array-like if it has a property where the last value
  44290. // in the array-like may be found (which could be undefined).
  44291. value.hasOwnProperty(value.length - 1))
  44292. );
  44293. }
  44294. var Seq = /*@__PURE__*/ (function(Collection$$1) {
  44295. function Seq(value) {
  44296. return value === null || value === undefined
  44297. ? emptySequence()
  44298. : isImmutable(value)
  44299. ? value.toSeq()
  44300. : seqFromValue(value);
  44301. }
  44302. if (Collection$$1) Seq.__proto__ = Collection$$1;
  44303. Seq.prototype = Object.create(Collection$$1 && Collection$$1.prototype);
  44304. Seq.prototype.constructor = Seq;
  44305. Seq.prototype.toSeq = function toSeq() {
  44306. return this;
  44307. };
  44308. Seq.prototype.toString = function toString() {
  44309. return this.__toString("Seq {", "}");
  44310. };
  44311. Seq.prototype.cacheResult = function cacheResult() {
  44312. if (!this._cache && this.__iterateUncached) {
  44313. this._cache = this.entrySeq().toArray();
  44314. this.size = this._cache.length;
  44315. }
  44316. return this;
  44317. };
  44318. // abstract __iterateUncached(fn, reverse)
  44319. Seq.prototype.__iterate = function __iterate(fn, reverse) {
  44320. var cache = this._cache;
  44321. if (cache) {
  44322. var size = cache.length;
  44323. var i = 0;
  44324. while (i !== size) {
  44325. var entry = cache[reverse ? size - ++i : i++];
  44326. if (fn(entry[1], entry[0], this) === false) {
  44327. break;
  44328. }
  44329. }
  44330. return i;
  44331. }
  44332. return this.__iterateUncached(fn, reverse);
  44333. };
  44334. // abstract __iteratorUncached(type, reverse)
  44335. Seq.prototype.__iterator = function __iterator(type, reverse) {
  44336. var cache = this._cache;
  44337. if (cache) {
  44338. var size = cache.length;
  44339. var i = 0;
  44340. return new Iterator(function() {
  44341. if (i === size) {
  44342. return iteratorDone();
  44343. }
  44344. var entry = cache[reverse ? size - ++i : i++];
  44345. return iteratorValue(type, entry[0], entry[1]);
  44346. });
  44347. }
  44348. return this.__iteratorUncached(type, reverse);
  44349. };
  44350. return Seq;
  44351. })(Collection);
  44352. var KeyedSeq = /*@__PURE__*/ (function(Seq) {
  44353. function KeyedSeq(value) {
  44354. return value === null || value === undefined
  44355. ? emptySequence().toKeyedSeq()
  44356. : isCollection(value)
  44357. ? isKeyed(value)
  44358. ? value.toSeq()
  44359. : value.fromEntrySeq()
  44360. : isRecord(value)
  44361. ? value.toSeq()
  44362. : keyedSeqFromValue(value);
  44363. }
  44364. if (Seq) KeyedSeq.__proto__ = Seq;
  44365. KeyedSeq.prototype = Object.create(Seq && Seq.prototype);
  44366. KeyedSeq.prototype.constructor = KeyedSeq;
  44367. KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq() {
  44368. return this;
  44369. };
  44370. return KeyedSeq;
  44371. })(Seq);
  44372. var IndexedSeq = /*@__PURE__*/ (function(Seq) {
  44373. function IndexedSeq(value) {
  44374. return value === null || value === undefined
  44375. ? emptySequence()
  44376. : isCollection(value)
  44377. ? isKeyed(value)
  44378. ? value.entrySeq()
  44379. : value.toIndexedSeq()
  44380. : isRecord(value)
  44381. ? value.toSeq().entrySeq()
  44382. : indexedSeqFromValue(value);
  44383. }
  44384. if (Seq) IndexedSeq.__proto__ = Seq;
  44385. IndexedSeq.prototype = Object.create(Seq && Seq.prototype);
  44386. IndexedSeq.prototype.constructor = IndexedSeq;
  44387. IndexedSeq.of = function of(/*...values*/) {
  44388. return IndexedSeq(arguments);
  44389. };
  44390. IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq() {
  44391. return this;
  44392. };
  44393. IndexedSeq.prototype.toString = function toString() {
  44394. return this.__toString("Seq [", "]");
  44395. };
  44396. return IndexedSeq;
  44397. })(Seq);
  44398. var SetSeq = /*@__PURE__*/ (function(Seq) {
  44399. function SetSeq(value) {
  44400. return (isCollection(value) && !isAssociative(value)
  44401. ? value
  44402. : IndexedSeq(value)
  44403. ).toSetSeq();
  44404. }
  44405. if (Seq) SetSeq.__proto__ = Seq;
  44406. SetSeq.prototype = Object.create(Seq && Seq.prototype);
  44407. SetSeq.prototype.constructor = SetSeq;
  44408. SetSeq.of = function of(/*...values*/) {
  44409. return SetSeq(arguments);
  44410. };
  44411. SetSeq.prototype.toSetSeq = function toSetSeq() {
  44412. return this;
  44413. };
  44414. return SetSeq;
  44415. })(Seq);
  44416. Seq.isSeq = isSeq;
  44417. Seq.Keyed = KeyedSeq;
  44418. Seq.Set = SetSeq;
  44419. Seq.Indexed = IndexedSeq;
  44420. Seq.prototype[IS_SEQ_SYMBOL] = true;
  44421. // #pragma Root Sequences
  44422. var ArraySeq = /*@__PURE__*/ (function(IndexedSeq) {
  44423. function ArraySeq(array) {
  44424. this._array = array;
  44425. this.size = array.length;
  44426. }
  44427. if (IndexedSeq) ArraySeq.__proto__ = IndexedSeq;
  44428. ArraySeq.prototype = Object.create(IndexedSeq && IndexedSeq.prototype);
  44429. ArraySeq.prototype.constructor = ArraySeq;
  44430. ArraySeq.prototype.get = function get(index, notSetValue) {
  44431. return this.has(index)
  44432. ? this._array[wrapIndex(this, index)]
  44433. : notSetValue;
  44434. };
  44435. ArraySeq.prototype.__iterate = function __iterate(fn, reverse) {
  44436. var array = this._array;
  44437. var size = array.length;
  44438. var i = 0;
  44439. while (i !== size) {
  44440. var ii = reverse ? size - ++i : i++;
  44441. if (fn(array[ii], ii, this) === false) {
  44442. break;
  44443. }
  44444. }
  44445. return i;
  44446. };
  44447. ArraySeq.prototype.__iterator = function __iterator(type, reverse) {
  44448. var array = this._array;
  44449. var size = array.length;
  44450. var i = 0;
  44451. return new Iterator(function() {
  44452. if (i === size) {
  44453. return iteratorDone();
  44454. }
  44455. var ii = reverse ? size - ++i : i++;
  44456. return iteratorValue(type, ii, array[ii]);
  44457. });
  44458. };
  44459. return ArraySeq;
  44460. })(IndexedSeq);
  44461. var ObjectSeq = /*@__PURE__*/ (function(KeyedSeq) {
  44462. function ObjectSeq(object) {
  44463. var keys = Object.keys(object);
  44464. this._object = object;
  44465. this._keys = keys;
  44466. this.size = keys.length;
  44467. }
  44468. if (KeyedSeq) ObjectSeq.__proto__ = KeyedSeq;
  44469. ObjectSeq.prototype = Object.create(KeyedSeq && KeyedSeq.prototype);
  44470. ObjectSeq.prototype.constructor = ObjectSeq;
  44471. ObjectSeq.prototype.get = function get(key, notSetValue) {
  44472. if (notSetValue !== undefined && !this.has(key)) {
  44473. return notSetValue;
  44474. }
  44475. return this._object[key];
  44476. };
  44477. ObjectSeq.prototype.has = function has(key) {
  44478. return hasOwnProperty.call(this._object, key);
  44479. };
  44480. ObjectSeq.prototype.__iterate = function __iterate(fn, reverse) {
  44481. var object = this._object;
  44482. var keys = this._keys;
  44483. var size = keys.length;
  44484. var i = 0;
  44485. while (i !== size) {
  44486. var key = keys[reverse ? size - ++i : i++];
  44487. if (fn(object[key], key, this) === false) {
  44488. break;
  44489. }
  44490. }
  44491. return i;
  44492. };
  44493. ObjectSeq.prototype.__iterator = function __iterator(type, reverse) {
  44494. var object = this._object;
  44495. var keys = this._keys;
  44496. var size = keys.length;
  44497. var i = 0;
  44498. return new Iterator(function() {
  44499. if (i === size) {
  44500. return iteratorDone();
  44501. }
  44502. var key = keys[reverse ? size - ++i : i++];
  44503. return iteratorValue(type, key, object[key]);
  44504. });
  44505. };
  44506. return ObjectSeq;
  44507. })(KeyedSeq);
  44508. ObjectSeq.prototype[IS_ORDERED_SYMBOL] = true;
  44509. var CollectionSeq = /*@__PURE__*/ (function(IndexedSeq) {
  44510. function CollectionSeq(collection) {
  44511. this._collection = collection;
  44512. this.size = collection.length || collection.size;
  44513. }
  44514. if (IndexedSeq) CollectionSeq.__proto__ = IndexedSeq;
  44515. CollectionSeq.prototype = Object.create(
  44516. IndexedSeq && IndexedSeq.prototype
  44517. );
  44518. CollectionSeq.prototype.constructor = CollectionSeq;
  44519. CollectionSeq.prototype.__iterateUncached = function __iterateUncached(
  44520. fn,
  44521. reverse
  44522. ) {
  44523. if (reverse) {
  44524. return this.cacheResult().__iterate(fn, reverse);
  44525. }
  44526. var collection = this._collection;
  44527. var iterator = getIterator(collection);
  44528. var iterations = 0;
  44529. if (isIterator(iterator)) {
  44530. var step;
  44531. while (!(step = iterator.next()).done) {
  44532. if (fn(step.value, iterations++, this) === false) {
  44533. break;
  44534. }
  44535. }
  44536. }
  44537. return iterations;
  44538. };
  44539. CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached(
  44540. type,
  44541. reverse
  44542. ) {
  44543. if (reverse) {
  44544. return this.cacheResult().__iterator(type, reverse);
  44545. }
  44546. var collection = this._collection;
  44547. var iterator = getIterator(collection);
  44548. if (!isIterator(iterator)) {
  44549. return new Iterator(iteratorDone);
  44550. }
  44551. var iterations = 0;
  44552. return new Iterator(function() {
  44553. var step = iterator.next();
  44554. return step.done
  44555. ? step
  44556. : iteratorValue(type, iterations++, step.value);
  44557. });
  44558. };
  44559. return CollectionSeq;
  44560. })(IndexedSeq);
  44561. // # pragma Helper functions
  44562. var EMPTY_SEQ;
  44563. function emptySequence() {
  44564. return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
  44565. }
  44566. function keyedSeqFromValue(value) {
  44567. var seq = Array.isArray(value)
  44568. ? new ArraySeq(value)
  44569. : hasIterator(value)
  44570. ? new CollectionSeq(value)
  44571. : undefined;
  44572. if (seq) {
  44573. return seq.fromEntrySeq();
  44574. }
  44575. if (typeof value === "object") {
  44576. return new ObjectSeq(value);
  44577. }
  44578. throw new TypeError(
  44579. "Expected Array or collection object of [k, v] entries, or keyed object: " +
  44580. value
  44581. );
  44582. }
  44583. function indexedSeqFromValue(value) {
  44584. var seq = maybeIndexedSeqFromValue(value);
  44585. if (seq) {
  44586. return seq;
  44587. }
  44588. throw new TypeError(
  44589. "Expected Array or collection object of values: " + value
  44590. );
  44591. }
  44592. function seqFromValue(value) {
  44593. var seq = maybeIndexedSeqFromValue(value);
  44594. if (seq) {
  44595. return seq;
  44596. }
  44597. if (typeof value === "object") {
  44598. return new ObjectSeq(value);
  44599. }
  44600. throw new TypeError(
  44601. "Expected Array or collection object of values, or keyed object: " +
  44602. value
  44603. );
  44604. }
  44605. function maybeIndexedSeqFromValue(value) {
  44606. return isArrayLike(value)
  44607. ? new ArraySeq(value)
  44608. : hasIterator(value)
  44609. ? new CollectionSeq(value)
  44610. : undefined;
  44611. }
  44612. var IS_MAP_SYMBOL = "@@__IMMUTABLE_MAP__@@";
  44613. function isMap(maybeMap) {
  44614. return Boolean(maybeMap && maybeMap[IS_MAP_SYMBOL]);
  44615. }
  44616. function isOrderedMap(maybeOrderedMap) {
  44617. return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
  44618. }
  44619. function isValueObject(maybeValue) {
  44620. return Boolean(
  44621. maybeValue &&
  44622. typeof maybeValue.equals === "function" &&
  44623. typeof maybeValue.hashCode === "function"
  44624. );
  44625. }
  44626. /**
  44627. * An extension of the "same-value" algorithm as [described for use by ES6 Map
  44628. * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
  44629. *
  44630. * NaN is considered the same as NaN, however -0 and 0 are considered the same
  44631. * value, which is different from the algorithm described by
  44632. * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
  44633. *
  44634. * This is extended further to allow Objects to describe the values they
  44635. * represent, by way of `valueOf` or `equals` (and `hashCode`).
  44636. *
  44637. * Note: because of this extension, the key equality of Immutable.Map and the
  44638. * value equality of Immutable.Set will differ from ES6 Map and Set.
  44639. *
  44640. * ### Defining custom values
  44641. *
  44642. * The easiest way to describe the value an object represents is by implementing
  44643. * `valueOf`. For example, `Date` represents a value by returning a unix
  44644. * timestamp for `valueOf`:
  44645. *
  44646. * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
  44647. * var date2 = new Date(1234567890000);
  44648. * date1.valueOf(); // 1234567890000
  44649. * assert( date1 !== date2 );
  44650. * assert( Immutable.is( date1, date2 ) );
  44651. *
  44652. * Note: overriding `valueOf` may have other implications if you use this object
  44653. * where JavaScript expects a primitive, such as implicit string coercion.
  44654. *
  44655. * For more complex types, especially collections, implementing `valueOf` may
  44656. * not be performant. An alternative is to implement `equals` and `hashCode`.
  44657. *
  44658. * `equals` takes another object, presumably of similar type, and returns true
  44659. * if it is equal. Equality is symmetrical, so the same result should be
  44660. * returned if this and the argument are flipped.
  44661. *
  44662. * assert( a.equals(b) === b.equals(a) );
  44663. *
  44664. * `hashCode` returns a 32bit integer number representing the object which will
  44665. * be used to determine how to store the value object in a Map or Set. You must
  44666. * provide both or neither methods, one must not exist without the other.
  44667. *
  44668. * Also, an important relationship between these methods must be upheld: if two
  44669. * values are equal, they *must* return the same hashCode. If the values are not
  44670. * equal, they might have the same hashCode; this is called a hash collision,
  44671. * and while undesirable for performance reasons, it is acceptable.
  44672. *
  44673. * if (a.equals(b)) {
  44674. * assert( a.hashCode() === b.hashCode() );
  44675. * }
  44676. *
  44677. * All Immutable collections are Value Objects: they implement `equals()`
  44678. * and `hashCode()`.
  44679. */
  44680. function is(valueA, valueB) {
  44681. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  44682. return true;
  44683. }
  44684. if (!valueA || !valueB) {
  44685. return false;
  44686. }
  44687. if (
  44688. typeof valueA.valueOf === "function" &&
  44689. typeof valueB.valueOf === "function"
  44690. ) {
  44691. valueA = valueA.valueOf();
  44692. valueB = valueB.valueOf();
  44693. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  44694. return true;
  44695. }
  44696. if (!valueA || !valueB) {
  44697. return false;
  44698. }
  44699. }
  44700. return !!(
  44701. isValueObject(valueA) &&
  44702. isValueObject(valueB) &&
  44703. valueA.equals(valueB)
  44704. );
  44705. }
  44706. var imul =
  44707. typeof Math.imul === "function" && Math.imul(0xffffffff, 2) === -2
  44708. ? Math.imul
  44709. : function imul(a, b) {
  44710. a |= 0; // int
  44711. b |= 0; // int
  44712. var c = a & 0xffff;
  44713. var d = b & 0xffff;
  44714. // Shift by 0 fixes the sign on the high part.
  44715. return (
  44716. (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0
  44717. ); // int
  44718. };
  44719. // v8 has an optimization for storing 31-bit signed numbers.
  44720. // Values which have either 00 or 11 as the high order bits qualify.
  44721. // This function drops the highest order bit in a signed number, maintaining
  44722. // the sign bit.
  44723. function smi(i32) {
  44724. return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff);
  44725. }
  44726. var defaultValueOf = Object.prototype.valueOf;
  44727. function hash(o) {
  44728. switch (typeof o) {
  44729. case "boolean":
  44730. // The hash values for built-in constants are a 1 value for each 5-byte
  44731. // shift region expect for the first, which encodes the value. This
  44732. // reduces the odds of a hash collision for these common values.
  44733. return o ? 0x42108421 : 0x42108420;
  44734. case "number":
  44735. return hashNumber(o);
  44736. case "string":
  44737. return o.length > STRING_HASH_CACHE_MIN_STRLEN
  44738. ? cachedHashString(o)
  44739. : hashString(o);
  44740. case "object":
  44741. case "function":
  44742. if (o === null) {
  44743. return 0x42108422;
  44744. }
  44745. if (typeof o.hashCode === "function") {
  44746. // Drop any high bits from accidentally long hash codes.
  44747. return smi(o.hashCode(o));
  44748. }
  44749. if (o.valueOf !== defaultValueOf && typeof o.valueOf === "function") {
  44750. o = o.valueOf(o);
  44751. }
  44752. return hashJSObj(o);
  44753. case "undefined":
  44754. return 0x42108423;
  44755. default:
  44756. if (typeof o.toString === "function") {
  44757. return hashString(o.toString());
  44758. }
  44759. throw new Error("Value type " + typeof o + " cannot be hashed.");
  44760. }
  44761. }
  44762. // Compress arbitrarily large numbers into smi hashes.
  44763. function hashNumber(n) {
  44764. if (n !== n || n === Infinity) {
  44765. return 0;
  44766. }
  44767. var hash = n | 0;
  44768. if (hash !== n) {
  44769. hash ^= n * 0xffffffff;
  44770. }
  44771. while (n > 0xffffffff) {
  44772. n /= 0xffffffff;
  44773. hash ^= n;
  44774. }
  44775. return smi(hash);
  44776. }
  44777. function cachedHashString(string) {
  44778. var hashed = stringHashCache[string];
  44779. if (hashed === undefined) {
  44780. hashed = hashString(string);
  44781. if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
  44782. STRING_HASH_CACHE_SIZE = 0;
  44783. stringHashCache = {};
  44784. }
  44785. STRING_HASH_CACHE_SIZE++;
  44786. stringHashCache[string] = hashed;
  44787. }
  44788. return hashed;
  44789. }
  44790. // http://jsperf.com/hashing-strings
  44791. function hashString(string) {
  44792. // This is the hash from JVM
  44793. // The hash code for a string is computed as
  44794. // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  44795. // where s[i] is the ith character of the string and n is the length of
  44796. // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  44797. // (exclusive) by dropping high bits.
  44798. var hashed = 0;
  44799. for (var ii = 0; ii < string.length; ii++) {
  44800. hashed = (31 * hashed + string.charCodeAt(ii)) | 0;
  44801. }
  44802. return smi(hashed);
  44803. }
  44804. function hashJSObj(obj) {
  44805. var hashed;
  44806. if (usingWeakMap) {
  44807. hashed = weakMap.get(obj);
  44808. if (hashed !== undefined) {
  44809. return hashed;
  44810. }
  44811. }
  44812. hashed = obj[UID_HASH_KEY];
  44813. if (hashed !== undefined) {
  44814. return hashed;
  44815. }
  44816. if (!canDefineProperty) {
  44817. hashed =
  44818. obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
  44819. if (hashed !== undefined) {
  44820. return hashed;
  44821. }
  44822. hashed = getIENodeHash(obj);
  44823. if (hashed !== undefined) {
  44824. return hashed;
  44825. }
  44826. }
  44827. hashed = ++objHashUID;
  44828. if (objHashUID & 0x40000000) {
  44829. objHashUID = 0;
  44830. }
  44831. if (usingWeakMap) {
  44832. weakMap.set(obj, hashed);
  44833. } else if (isExtensible !== undefined && isExtensible(obj) === false) {
  44834. throw new Error("Non-extensible objects are not allowed as keys.");
  44835. } else if (canDefineProperty) {
  44836. Object.defineProperty(obj, UID_HASH_KEY, {
  44837. enumerable: false,
  44838. configurable: false,
  44839. writable: false,
  44840. value: hashed
  44841. });
  44842. } else if (
  44843. obj.propertyIsEnumerable !== undefined &&
  44844. obj.propertyIsEnumerable ===
  44845. obj.constructor.prototype.propertyIsEnumerable
  44846. ) {
  44847. // Since we can't define a non-enumerable property on the object
  44848. // we'll hijack one of the less-used non-enumerable properties to
  44849. // save our hash on it. Since this is a function it will not show up in
  44850. // `JSON.stringify` which is what we want.
  44851. obj.propertyIsEnumerable = function() {
  44852. return this.constructor.prototype.propertyIsEnumerable.apply(
  44853. this,
  44854. arguments
  44855. );
  44856. };
  44857. obj.propertyIsEnumerable[UID_HASH_KEY] = hashed;
  44858. } else if (obj.nodeType !== undefined) {
  44859. // At this point we couldn't get the IE `uniqueID` to use as a hash
  44860. // and we couldn't use a non-enumerable property to exploit the
  44861. // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
  44862. // itself.
  44863. obj[UID_HASH_KEY] = hashed;
  44864. } else {
  44865. throw new Error("Unable to set a non-enumerable property on object.");
  44866. }
  44867. return hashed;
  44868. }
  44869. // Get references to ES5 object methods.
  44870. var isExtensible = Object.isExtensible;
  44871. // True if Object.defineProperty works as expected. IE8 fails this test.
  44872. var canDefineProperty = (function() {
  44873. try {
  44874. Object.defineProperty({}, "@", {});
  44875. return true;
  44876. } catch (e) {
  44877. return false;
  44878. }
  44879. })();
  44880. // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
  44881. // and avoid memory leaks from the IE cloneNode bug.
  44882. function getIENodeHash(node) {
  44883. if (node && node.nodeType > 0) {
  44884. switch (node.nodeType) {
  44885. case 1: // Element
  44886. return node.uniqueID;
  44887. case 9: // Document
  44888. return node.documentElement && node.documentElement.uniqueID;
  44889. }
  44890. }
  44891. }
  44892. // If possible, use a WeakMap.
  44893. var usingWeakMap = typeof WeakMap === "function";
  44894. var weakMap;
  44895. if (usingWeakMap) {
  44896. weakMap = new WeakMap();
  44897. }
  44898. var objHashUID = 0;
  44899. var UID_HASH_KEY = "__immutablehash__";
  44900. if (typeof Symbol === "function") {
  44901. UID_HASH_KEY = Symbol(UID_HASH_KEY);
  44902. }
  44903. var STRING_HASH_CACHE_MIN_STRLEN = 16;
  44904. var STRING_HASH_CACHE_MAX_SIZE = 255;
  44905. var STRING_HASH_CACHE_SIZE = 0;
  44906. var stringHashCache = {};
  44907. var ToKeyedSequence = /*@__PURE__*/ (function(KeyedSeq$$1) {
  44908. function ToKeyedSequence(indexed, useKeys) {
  44909. this._iter = indexed;
  44910. this._useKeys = useKeys;
  44911. this.size = indexed.size;
  44912. }
  44913. if (KeyedSeq$$1) ToKeyedSequence.__proto__ = KeyedSeq$$1;
  44914. ToKeyedSequence.prototype = Object.create(
  44915. KeyedSeq$$1 && KeyedSeq$$1.prototype
  44916. );
  44917. ToKeyedSequence.prototype.constructor = ToKeyedSequence;
  44918. ToKeyedSequence.prototype.get = function get(key, notSetValue) {
  44919. return this._iter.get(key, notSetValue);
  44920. };
  44921. ToKeyedSequence.prototype.has = function has(key) {
  44922. return this._iter.has(key);
  44923. };
  44924. ToKeyedSequence.prototype.valueSeq = function valueSeq() {
  44925. return this._iter.valueSeq();
  44926. };
  44927. ToKeyedSequence.prototype.reverse = function reverse() {
  44928. var this$1 = this;
  44929. var reversedSequence = reverseFactory(this, true);
  44930. if (!this._useKeys) {
  44931. reversedSequence.valueSeq = function() {
  44932. return this$1._iter.toSeq().reverse();
  44933. };
  44934. }
  44935. return reversedSequence;
  44936. };
  44937. ToKeyedSequence.prototype.map = function map(mapper, context) {
  44938. var this$1 = this;
  44939. var mappedSequence = mapFactory(this, mapper, context);
  44940. if (!this._useKeys) {
  44941. mappedSequence.valueSeq = function() {
  44942. return this$1._iter.toSeq().map(mapper, context);
  44943. };
  44944. }
  44945. return mappedSequence;
  44946. };
  44947. ToKeyedSequence.prototype.__iterate = function __iterate(fn, reverse) {
  44948. var this$1 = this;
  44949. return this._iter.__iterate(function(v, k) {
  44950. return fn(v, k, this$1);
  44951. }, reverse);
  44952. };
  44953. ToKeyedSequence.prototype.__iterator = function __iterator(
  44954. type,
  44955. reverse
  44956. ) {
  44957. return this._iter.__iterator(type, reverse);
  44958. };
  44959. return ToKeyedSequence;
  44960. })(KeyedSeq);
  44961. ToKeyedSequence.prototype[IS_ORDERED_SYMBOL] = true;
  44962. var ToIndexedSequence = /*@__PURE__*/ (function(IndexedSeq$$1) {
  44963. function ToIndexedSequence(iter) {
  44964. this._iter = iter;
  44965. this.size = iter.size;
  44966. }
  44967. if (IndexedSeq$$1) ToIndexedSequence.__proto__ = IndexedSeq$$1;
  44968. ToIndexedSequence.prototype = Object.create(
  44969. IndexedSeq$$1 && IndexedSeq$$1.prototype
  44970. );
  44971. ToIndexedSequence.prototype.constructor = ToIndexedSequence;
  44972. ToIndexedSequence.prototype.includes = function includes(value) {
  44973. return this._iter.includes(value);
  44974. };
  44975. ToIndexedSequence.prototype.__iterate = function __iterate(fn, reverse) {
  44976. var this$1 = this;
  44977. var i = 0;
  44978. reverse && ensureSize(this);
  44979. return this._iter.__iterate(function(v) {
  44980. return fn(v, reverse ? this$1.size - ++i : i++, this$1);
  44981. }, reverse);
  44982. };
  44983. ToIndexedSequence.prototype.__iterator = function __iterator(
  44984. type,
  44985. reverse
  44986. ) {
  44987. var this$1 = this;
  44988. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  44989. var i = 0;
  44990. reverse && ensureSize(this);
  44991. return new Iterator(function() {
  44992. var step = iterator.next();
  44993. return step.done
  44994. ? step
  44995. : iteratorValue(
  44996. type,
  44997. reverse ? this$1.size - ++i : i++,
  44998. step.value,
  44999. step
  45000. );
  45001. });
  45002. };
  45003. return ToIndexedSequence;
  45004. })(IndexedSeq);
  45005. var ToSetSequence = /*@__PURE__*/ (function(SetSeq$$1) {
  45006. function ToSetSequence(iter) {
  45007. this._iter = iter;
  45008. this.size = iter.size;
  45009. }
  45010. if (SetSeq$$1) ToSetSequence.__proto__ = SetSeq$$1;
  45011. ToSetSequence.prototype = Object.create(SetSeq$$1 && SetSeq$$1.prototype);
  45012. ToSetSequence.prototype.constructor = ToSetSequence;
  45013. ToSetSequence.prototype.has = function has(key) {
  45014. return this._iter.includes(key);
  45015. };
  45016. ToSetSequence.prototype.__iterate = function __iterate(fn, reverse) {
  45017. var this$1 = this;
  45018. return this._iter.__iterate(function(v) {
  45019. return fn(v, v, this$1);
  45020. }, reverse);
  45021. };
  45022. ToSetSequence.prototype.__iterator = function __iterator(type, reverse) {
  45023. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  45024. return new Iterator(function() {
  45025. var step = iterator.next();
  45026. return step.done
  45027. ? step
  45028. : iteratorValue(type, step.value, step.value, step);
  45029. });
  45030. };
  45031. return ToSetSequence;
  45032. })(SetSeq);
  45033. var FromEntriesSequence = /*@__PURE__*/ (function(KeyedSeq$$1) {
  45034. function FromEntriesSequence(entries) {
  45035. this._iter = entries;
  45036. this.size = entries.size;
  45037. }
  45038. if (KeyedSeq$$1) FromEntriesSequence.__proto__ = KeyedSeq$$1;
  45039. FromEntriesSequence.prototype = Object.create(
  45040. KeyedSeq$$1 && KeyedSeq$$1.prototype
  45041. );
  45042. FromEntriesSequence.prototype.constructor = FromEntriesSequence;
  45043. FromEntriesSequence.prototype.entrySeq = function entrySeq() {
  45044. return this._iter.toSeq();
  45045. };
  45046. FromEntriesSequence.prototype.__iterate = function __iterate(
  45047. fn,
  45048. reverse
  45049. ) {
  45050. var this$1 = this;
  45051. return this._iter.__iterate(function(entry) {
  45052. // Check if entry exists first so array access doesn't throw for holes
  45053. // in the parent iteration.
  45054. if (entry) {
  45055. validateEntry(entry);
  45056. var indexedCollection = isCollection(entry);
  45057. return fn(
  45058. indexedCollection ? entry.get(1) : entry[1],
  45059. indexedCollection ? entry.get(0) : entry[0],
  45060. this$1
  45061. );
  45062. }
  45063. }, reverse);
  45064. };
  45065. FromEntriesSequence.prototype.__iterator = function __iterator(
  45066. type,
  45067. reverse
  45068. ) {
  45069. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  45070. return new Iterator(function() {
  45071. while (true) {
  45072. var step = iterator.next();
  45073. if (step.done) {
  45074. return step;
  45075. }
  45076. var entry = step.value;
  45077. // Check if entry exists first so array access doesn't throw for holes
  45078. // in the parent iteration.
  45079. if (entry) {
  45080. validateEntry(entry);
  45081. var indexedCollection = isCollection(entry);
  45082. return iteratorValue(
  45083. type,
  45084. indexedCollection ? entry.get(0) : entry[0],
  45085. indexedCollection ? entry.get(1) : entry[1],
  45086. step
  45087. );
  45088. }
  45089. }
  45090. });
  45091. };
  45092. return FromEntriesSequence;
  45093. })(KeyedSeq);
  45094. ToIndexedSequence.prototype.cacheResult = ToKeyedSequence.prototype.cacheResult = ToSetSequence.prototype.cacheResult = FromEntriesSequence.prototype.cacheResult = cacheResultThrough;
  45095. function flipFactory(collection) {
  45096. var flipSequence = makeSequence(collection);
  45097. flipSequence._iter = collection;
  45098. flipSequence.size = collection.size;
  45099. flipSequence.flip = function() {
  45100. return collection;
  45101. };
  45102. flipSequence.reverse = function() {
  45103. var reversedSequence = collection.reverse.apply(this); // super.reverse()
  45104. reversedSequence.flip = function() {
  45105. return collection.reverse();
  45106. };
  45107. return reversedSequence;
  45108. };
  45109. flipSequence.has = function(key) {
  45110. return collection.includes(key);
  45111. };
  45112. flipSequence.includes = function(key) {
  45113. return collection.has(key);
  45114. };
  45115. flipSequence.cacheResult = cacheResultThrough;
  45116. flipSequence.__iterateUncached = function(fn, reverse) {
  45117. var this$1 = this;
  45118. return collection.__iterate(function(v, k) {
  45119. return fn(k, v, this$1) !== false;
  45120. }, reverse);
  45121. };
  45122. flipSequence.__iteratorUncached = function(type, reverse) {
  45123. if (type === ITERATE_ENTRIES) {
  45124. var iterator = collection.__iterator(type, reverse);
  45125. return new Iterator(function() {
  45126. var step = iterator.next();
  45127. if (!step.done) {
  45128. var k = step.value[0];
  45129. step.value[0] = step.value[1];
  45130. step.value[1] = k;
  45131. }
  45132. return step;
  45133. });
  45134. }
  45135. return collection.__iterator(
  45136. type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
  45137. reverse
  45138. );
  45139. };
  45140. return flipSequence;
  45141. }
  45142. function mapFactory(collection, mapper, context) {
  45143. var mappedSequence = makeSequence(collection);
  45144. mappedSequence.size = collection.size;
  45145. mappedSequence.has = function(key) {
  45146. return collection.has(key);
  45147. };
  45148. mappedSequence.get = function(key, notSetValue) {
  45149. var v = collection.get(key, NOT_SET);
  45150. return v === NOT_SET
  45151. ? notSetValue
  45152. : mapper.call(context, v, key, collection);
  45153. };
  45154. mappedSequence.__iterateUncached = function(fn, reverse) {
  45155. var this$1 = this;
  45156. return collection.__iterate(function(v, k, c) {
  45157. return fn(mapper.call(context, v, k, c), k, this$1) !== false;
  45158. }, reverse);
  45159. };
  45160. mappedSequence.__iteratorUncached = function(type, reverse) {
  45161. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  45162. return new Iterator(function() {
  45163. var step = iterator.next();
  45164. if (step.done) {
  45165. return step;
  45166. }
  45167. var entry = step.value;
  45168. var key = entry[0];
  45169. return iteratorValue(
  45170. type,
  45171. key,
  45172. mapper.call(context, entry[1], key, collection),
  45173. step
  45174. );
  45175. });
  45176. };
  45177. return mappedSequence;
  45178. }
  45179. function reverseFactory(collection, useKeys) {
  45180. var this$1 = this;
  45181. var reversedSequence = makeSequence(collection);
  45182. reversedSequence._iter = collection;
  45183. reversedSequence.size = collection.size;
  45184. reversedSequence.reverse = function() {
  45185. return collection;
  45186. };
  45187. if (collection.flip) {
  45188. reversedSequence.flip = function() {
  45189. var flipSequence = flipFactory(collection);
  45190. flipSequence.reverse = function() {
  45191. return collection.flip();
  45192. };
  45193. return flipSequence;
  45194. };
  45195. }
  45196. reversedSequence.get = function(key, notSetValue) {
  45197. return collection.get(useKeys ? key : -1 - key, notSetValue);
  45198. };
  45199. reversedSequence.has = function(key) {
  45200. return collection.has(useKeys ? key : -1 - key);
  45201. };
  45202. reversedSequence.includes = function(value) {
  45203. return collection.includes(value);
  45204. };
  45205. reversedSequence.cacheResult = cacheResultThrough;
  45206. reversedSequence.__iterate = function(fn, reverse) {
  45207. var this$1 = this;
  45208. var i = 0;
  45209. reverse && ensureSize(collection);
  45210. return collection.__iterate(function(v, k) {
  45211. return fn(v, useKeys ? k : reverse ? this$1.size - ++i : i++, this$1);
  45212. }, !reverse);
  45213. };
  45214. reversedSequence.__iterator = function(type, reverse) {
  45215. var i = 0;
  45216. reverse && ensureSize(collection);
  45217. var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse);
  45218. return new Iterator(function() {
  45219. var step = iterator.next();
  45220. if (step.done) {
  45221. return step;
  45222. }
  45223. var entry = step.value;
  45224. return iteratorValue(
  45225. type,
  45226. useKeys ? entry[0] : reverse ? this$1.size - ++i : i++,
  45227. entry[1],
  45228. step
  45229. );
  45230. });
  45231. };
  45232. return reversedSequence;
  45233. }
  45234. function filterFactory(collection, predicate, context, useKeys) {
  45235. var filterSequence = makeSequence(collection);
  45236. if (useKeys) {
  45237. filterSequence.has = function(key) {
  45238. var v = collection.get(key, NOT_SET);
  45239. return v !== NOT_SET && !!predicate.call(context, v, key, collection);
  45240. };
  45241. filterSequence.get = function(key, notSetValue) {
  45242. var v = collection.get(key, NOT_SET);
  45243. return v !== NOT_SET && predicate.call(context, v, key, collection)
  45244. ? v
  45245. : notSetValue;
  45246. };
  45247. }
  45248. filterSequence.__iterateUncached = function(fn, reverse) {
  45249. var this$1 = this;
  45250. var iterations = 0;
  45251. collection.__iterate(function(v, k, c) {
  45252. if (predicate.call(context, v, k, c)) {
  45253. iterations++;
  45254. return fn(v, useKeys ? k : iterations - 1, this$1);
  45255. }
  45256. }, reverse);
  45257. return iterations;
  45258. };
  45259. filterSequence.__iteratorUncached = function(type, reverse) {
  45260. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  45261. var iterations = 0;
  45262. return new Iterator(function() {
  45263. while (true) {
  45264. var step = iterator.next();
  45265. if (step.done) {
  45266. return step;
  45267. }
  45268. var entry = step.value;
  45269. var key = entry[0];
  45270. var value = entry[1];
  45271. if (predicate.call(context, value, key, collection)) {
  45272. return iteratorValue(
  45273. type,
  45274. useKeys ? key : iterations++,
  45275. value,
  45276. step
  45277. );
  45278. }
  45279. }
  45280. });
  45281. };
  45282. return filterSequence;
  45283. }
  45284. function countByFactory(collection, grouper, context) {
  45285. var groups = Map().asMutable();
  45286. collection.__iterate(function(v, k) {
  45287. groups.update(grouper.call(context, v, k, collection), 0, function(a) {
  45288. return a + 1;
  45289. });
  45290. });
  45291. return groups.asImmutable();
  45292. }
  45293. function groupByFactory(collection, grouper, context) {
  45294. var isKeyedIter = isKeyed(collection);
  45295. var groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable();
  45296. collection.__iterate(function(v, k) {
  45297. groups.update(grouper.call(context, v, k, collection), function(a) {
  45298. return (a = a || []), a.push(isKeyedIter ? [k, v] : v), a;
  45299. });
  45300. });
  45301. var coerce = collectionClass(collection);
  45302. return groups
  45303. .map(function(arr) {
  45304. return reify(collection, coerce(arr));
  45305. })
  45306. .asImmutable();
  45307. }
  45308. function sliceFactory(collection, begin, end, useKeys) {
  45309. var originalSize = collection.size;
  45310. if (wholeSlice(begin, end, originalSize)) {
  45311. return collection;
  45312. }
  45313. var resolvedBegin = resolveBegin(begin, originalSize);
  45314. var resolvedEnd = resolveEnd(end, originalSize);
  45315. // begin or end will be NaN if they were provided as negative numbers and
  45316. // this collection's size is unknown. In that case, cache first so there is
  45317. // a known size and these do not resolve to NaN.
  45318. if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
  45319. return sliceFactory(
  45320. collection.toSeq().cacheResult(),
  45321. begin,
  45322. end,
  45323. useKeys
  45324. );
  45325. }
  45326. // Note: resolvedEnd is undefined when the original sequence's length is
  45327. // unknown and this slice did not supply an end and should contain all
  45328. // elements after resolvedBegin.
  45329. // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
  45330. var resolvedSize = resolvedEnd - resolvedBegin;
  45331. var sliceSize;
  45332. if (resolvedSize === resolvedSize) {
  45333. sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
  45334. }
  45335. var sliceSeq = makeSequence(collection);
  45336. // If collection.size is undefined, the size of the realized sliceSeq is
  45337. // unknown at this point unless the number of items to slice is 0
  45338. sliceSeq.size =
  45339. sliceSize === 0
  45340. ? sliceSize
  45341. : (collection.size && sliceSize) || undefined;
  45342. if (!useKeys && isSeq(collection) && sliceSize >= 0) {
  45343. sliceSeq.get = function(index, notSetValue) {
  45344. index = wrapIndex(this, index);
  45345. return index >= 0 && index < sliceSize
  45346. ? collection.get(index + resolvedBegin, notSetValue)
  45347. : notSetValue;
  45348. };
  45349. }
  45350. sliceSeq.__iterateUncached = function(fn, reverse) {
  45351. var this$1 = this;
  45352. if (sliceSize === 0) {
  45353. return 0;
  45354. }
  45355. if (reverse) {
  45356. return this.cacheResult().__iterate(fn, reverse);
  45357. }
  45358. var skipped = 0;
  45359. var isSkipping = true;
  45360. var iterations = 0;
  45361. collection.__iterate(function(v, k) {
  45362. if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
  45363. iterations++;
  45364. return (
  45365. fn(v, useKeys ? k : iterations - 1, this$1) !== false &&
  45366. iterations !== sliceSize
  45367. );
  45368. }
  45369. });
  45370. return iterations;
  45371. };
  45372. sliceSeq.__iteratorUncached = function(type, reverse) {
  45373. if (sliceSize !== 0 && reverse) {
  45374. return this.cacheResult().__iterator(type, reverse);
  45375. }
  45376. // Don't bother instantiating parent iterator if taking 0.
  45377. if (sliceSize === 0) {
  45378. return new Iterator(iteratorDone);
  45379. }
  45380. var iterator = collection.__iterator(type, reverse);
  45381. var skipped = 0;
  45382. var iterations = 0;
  45383. return new Iterator(function() {
  45384. while (skipped++ < resolvedBegin) {
  45385. iterator.next();
  45386. }
  45387. if (++iterations > sliceSize) {
  45388. return iteratorDone();
  45389. }
  45390. var step = iterator.next();
  45391. if (useKeys || type === ITERATE_VALUES || step.done) {
  45392. return step;
  45393. }
  45394. if (type === ITERATE_KEYS) {
  45395. return iteratorValue(type, iterations - 1, undefined, step);
  45396. }
  45397. return iteratorValue(type, iterations - 1, step.value[1], step);
  45398. });
  45399. };
  45400. return sliceSeq;
  45401. }
  45402. function takeWhileFactory(collection, predicate, context) {
  45403. var takeSequence = makeSequence(collection);
  45404. takeSequence.__iterateUncached = function(fn, reverse) {
  45405. var this$1 = this;
  45406. if (reverse) {
  45407. return this.cacheResult().__iterate(fn, reverse);
  45408. }
  45409. var iterations = 0;
  45410. collection.__iterate(function(v, k, c) {
  45411. return (
  45412. predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1)
  45413. );
  45414. });
  45415. return iterations;
  45416. };
  45417. takeSequence.__iteratorUncached = function(type, reverse) {
  45418. var this$1 = this;
  45419. if (reverse) {
  45420. return this.cacheResult().__iterator(type, reverse);
  45421. }
  45422. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  45423. var iterating = true;
  45424. return new Iterator(function() {
  45425. if (!iterating) {
  45426. return iteratorDone();
  45427. }
  45428. var step = iterator.next();
  45429. if (step.done) {
  45430. return step;
  45431. }
  45432. var entry = step.value;
  45433. var k = entry[0];
  45434. var v = entry[1];
  45435. if (!predicate.call(context, v, k, this$1)) {
  45436. iterating = false;
  45437. return iteratorDone();
  45438. }
  45439. return type === ITERATE_ENTRIES
  45440. ? step
  45441. : iteratorValue(type, k, v, step);
  45442. });
  45443. };
  45444. return takeSequence;
  45445. }
  45446. function skipWhileFactory(collection, predicate, context, useKeys) {
  45447. var skipSequence = makeSequence(collection);
  45448. skipSequence.__iterateUncached = function(fn, reverse) {
  45449. var this$1 = this;
  45450. if (reverse) {
  45451. return this.cacheResult().__iterate(fn, reverse);
  45452. }
  45453. var isSkipping = true;
  45454. var iterations = 0;
  45455. collection.__iterate(function(v, k, c) {
  45456. if (
  45457. !(isSkipping && (isSkipping = predicate.call(context, v, k, c)))
  45458. ) {
  45459. iterations++;
  45460. return fn(v, useKeys ? k : iterations - 1, this$1);
  45461. }
  45462. });
  45463. return iterations;
  45464. };
  45465. skipSequence.__iteratorUncached = function(type, reverse) {
  45466. var this$1 = this;
  45467. if (reverse) {
  45468. return this.cacheResult().__iterator(type, reverse);
  45469. }
  45470. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  45471. var skipping = true;
  45472. var iterations = 0;
  45473. return new Iterator(function() {
  45474. var step;
  45475. var k;
  45476. var v;
  45477. do {
  45478. step = iterator.next();
  45479. if (step.done) {
  45480. if (useKeys || type === ITERATE_VALUES) {
  45481. return step;
  45482. }
  45483. if (type === ITERATE_KEYS) {
  45484. return iteratorValue(type, iterations++, undefined, step);
  45485. }
  45486. return iteratorValue(type, iterations++, step.value[1], step);
  45487. }
  45488. var entry = step.value;
  45489. k = entry[0];
  45490. v = entry[1];
  45491. skipping && (skipping = predicate.call(context, v, k, this$1));
  45492. } while (skipping);
  45493. return type === ITERATE_ENTRIES
  45494. ? step
  45495. : iteratorValue(type, k, v, step);
  45496. });
  45497. };
  45498. return skipSequence;
  45499. }
  45500. function concatFactory(collection, values) {
  45501. var isKeyedCollection = isKeyed(collection);
  45502. var iters = [collection]
  45503. .concat(values)
  45504. .map(function(v) {
  45505. if (!isCollection(v)) {
  45506. v = isKeyedCollection
  45507. ? keyedSeqFromValue(v)
  45508. : indexedSeqFromValue(Array.isArray(v) ? v : [v]);
  45509. } else if (isKeyedCollection) {
  45510. v = KeyedCollection(v);
  45511. }
  45512. return v;
  45513. })
  45514. .filter(function(v) {
  45515. return v.size !== 0;
  45516. });
  45517. if (iters.length === 0) {
  45518. return collection;
  45519. }
  45520. if (iters.length === 1) {
  45521. var singleton = iters[0];
  45522. if (
  45523. singleton === collection ||
  45524. (isKeyedCollection && isKeyed(singleton)) ||
  45525. (isIndexed(collection) && isIndexed(singleton))
  45526. ) {
  45527. return singleton;
  45528. }
  45529. }
  45530. var concatSeq = new ArraySeq(iters);
  45531. if (isKeyedCollection) {
  45532. concatSeq = concatSeq.toKeyedSeq();
  45533. } else if (!isIndexed(collection)) {
  45534. concatSeq = concatSeq.toSetSeq();
  45535. }
  45536. concatSeq = concatSeq.flatten(true);
  45537. concatSeq.size = iters.reduce(function(sum, seq) {
  45538. if (sum !== undefined) {
  45539. var size = seq.size;
  45540. if (size !== undefined) {
  45541. return sum + size;
  45542. }
  45543. }
  45544. }, 0);
  45545. return concatSeq;
  45546. }
  45547. function flattenFactory(collection, depth, useKeys) {
  45548. var flatSequence = makeSequence(collection);
  45549. flatSequence.__iterateUncached = function(fn, reverse) {
  45550. if (reverse) {
  45551. return this.cacheResult().__iterate(fn, reverse);
  45552. }
  45553. var iterations = 0;
  45554. var stopped = false;
  45555. function flatDeep(iter, currentDepth) {
  45556. iter.__iterate(function(v, k) {
  45557. if ((!depth || currentDepth < depth) && isCollection(v)) {
  45558. flatDeep(v, currentDepth + 1);
  45559. } else {
  45560. iterations++;
  45561. if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) {
  45562. stopped = true;
  45563. }
  45564. }
  45565. return !stopped;
  45566. }, reverse);
  45567. }
  45568. flatDeep(collection, 0);
  45569. return iterations;
  45570. };
  45571. flatSequence.__iteratorUncached = function(type, reverse) {
  45572. if (reverse) {
  45573. return this.cacheResult().__iterator(type, reverse);
  45574. }
  45575. var iterator = collection.__iterator(type, reverse);
  45576. var stack = [];
  45577. var iterations = 0;
  45578. return new Iterator(function() {
  45579. while (iterator) {
  45580. var step = iterator.next();
  45581. if (step.done !== false) {
  45582. iterator = stack.pop();
  45583. continue;
  45584. }
  45585. var v = step.value;
  45586. if (type === ITERATE_ENTRIES) {
  45587. v = v[1];
  45588. }
  45589. if ((!depth || stack.length < depth) && isCollection(v)) {
  45590. stack.push(iterator);
  45591. iterator = v.__iterator(type, reverse);
  45592. } else {
  45593. return useKeys
  45594. ? step
  45595. : iteratorValue(type, iterations++, v, step);
  45596. }
  45597. }
  45598. return iteratorDone();
  45599. });
  45600. };
  45601. return flatSequence;
  45602. }
  45603. function flatMapFactory(collection, mapper, context) {
  45604. var coerce = collectionClass(collection);
  45605. return collection
  45606. .toSeq()
  45607. .map(function(v, k) {
  45608. return coerce(mapper.call(context, v, k, collection));
  45609. })
  45610. .flatten(true);
  45611. }
  45612. function interposeFactory(collection, separator) {
  45613. var interposedSequence = makeSequence(collection);
  45614. interposedSequence.size = collection.size && collection.size * 2 - 1;
  45615. interposedSequence.__iterateUncached = function(fn, reverse) {
  45616. var this$1 = this;
  45617. var iterations = 0;
  45618. collection.__iterate(function(v) {
  45619. return (
  45620. (!iterations || fn(separator, iterations++, this$1) !== false) &&
  45621. fn(v, iterations++, this$1) !== false
  45622. );
  45623. }, reverse);
  45624. return iterations;
  45625. };
  45626. interposedSequence.__iteratorUncached = function(type, reverse) {
  45627. var iterator = collection.__iterator(ITERATE_VALUES, reverse);
  45628. var iterations = 0;
  45629. var step;
  45630. return new Iterator(function() {
  45631. if (!step || iterations % 2) {
  45632. step = iterator.next();
  45633. if (step.done) {
  45634. return step;
  45635. }
  45636. }
  45637. return iterations % 2
  45638. ? iteratorValue(type, iterations++, separator)
  45639. : iteratorValue(type, iterations++, step.value, step);
  45640. });
  45641. };
  45642. return interposedSequence;
  45643. }
  45644. function sortFactory(collection, comparator, mapper) {
  45645. if (!comparator) {
  45646. comparator = defaultComparator;
  45647. }
  45648. var isKeyedCollection = isKeyed(collection);
  45649. var index = 0;
  45650. var entries = collection
  45651. .toSeq()
  45652. .map(function(v, k) {
  45653. return [k, v, index++, mapper ? mapper(v, k, collection) : v];
  45654. })
  45655. .valueSeq()
  45656. .toArray();
  45657. entries
  45658. .sort(function(a, b) {
  45659. return comparator(a[3], b[3]) || a[2] - b[2];
  45660. })
  45661. .forEach(
  45662. isKeyedCollection
  45663. ? function(v, i) {
  45664. entries[i].length = 2;
  45665. }
  45666. : function(v, i) {
  45667. entries[i] = v[1];
  45668. }
  45669. );
  45670. return isKeyedCollection
  45671. ? KeyedSeq(entries)
  45672. : isIndexed(collection)
  45673. ? IndexedSeq(entries)
  45674. : SetSeq(entries);
  45675. }
  45676. function maxFactory(collection, comparator, mapper) {
  45677. if (!comparator) {
  45678. comparator = defaultComparator;
  45679. }
  45680. if (mapper) {
  45681. var entry = collection
  45682. .toSeq()
  45683. .map(function(v, k) {
  45684. return [v, mapper(v, k, collection)];
  45685. })
  45686. .reduce(function(a, b) {
  45687. return maxCompare(comparator, a[1], b[1]) ? b : a;
  45688. });
  45689. return entry && entry[0];
  45690. }
  45691. return collection.reduce(function(a, b) {
  45692. return maxCompare(comparator, a, b) ? b : a;
  45693. });
  45694. }
  45695. function maxCompare(comparator, a, b) {
  45696. var comp = comparator(b, a);
  45697. // b is considered the new max if the comparator declares them equal, but
  45698. // they are not equal and b is in fact a nullish value.
  45699. return (
  45700. (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) ||
  45701. comp > 0
  45702. );
  45703. }
  45704. function zipWithFactory(keyIter, zipper, iters, zipAll) {
  45705. var zipSequence = makeSequence(keyIter);
  45706. var sizes = new ArraySeq(iters).map(function(i) {
  45707. return i.size;
  45708. });
  45709. zipSequence.size = zipAll ? sizes.max() : sizes.min();
  45710. // Note: this a generic base implementation of __iterate in terms of
  45711. // __iterator which may be more generically useful in the future.
  45712. zipSequence.__iterate = function(fn, reverse) {
  45713. /* generic:
  45714. var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
  45715. var step;
  45716. var iterations = 0;
  45717. while (!(step = iterator.next()).done) {
  45718. iterations++;
  45719. if (fn(step.value[1], step.value[0], this) === false) {
  45720. break;
  45721. }
  45722. }
  45723. return iterations;
  45724. */
  45725. // indexed:
  45726. var iterator = this.__iterator(ITERATE_VALUES, reverse);
  45727. var step;
  45728. var iterations = 0;
  45729. while (!(step = iterator.next()).done) {
  45730. if (fn(step.value, iterations++, this) === false) {
  45731. break;
  45732. }
  45733. }
  45734. return iterations;
  45735. };
  45736. zipSequence.__iteratorUncached = function(type, reverse) {
  45737. var iterators = iters.map(function(i) {
  45738. return (i = Collection(i)), getIterator(reverse ? i.reverse() : i);
  45739. });
  45740. var iterations = 0;
  45741. var isDone = false;
  45742. return new Iterator(function() {
  45743. var steps;
  45744. if (!isDone) {
  45745. steps = iterators.map(function(i) {
  45746. return i.next();
  45747. });
  45748. isDone = zipAll
  45749. ? steps.every(function(s) {
  45750. return s.done;
  45751. })
  45752. : steps.some(function(s) {
  45753. return s.done;
  45754. });
  45755. }
  45756. if (isDone) {
  45757. return iteratorDone();
  45758. }
  45759. return iteratorValue(
  45760. type,
  45761. iterations++,
  45762. zipper.apply(
  45763. null,
  45764. steps.map(function(s) {
  45765. return s.value;
  45766. })
  45767. )
  45768. );
  45769. });
  45770. };
  45771. return zipSequence;
  45772. }
  45773. // #pragma Helper Functions
  45774. function reify(iter, seq) {
  45775. return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq);
  45776. }
  45777. function validateEntry(entry) {
  45778. if (entry !== Object(entry)) {
  45779. throw new TypeError("Expected [K, V] tuple: " + entry);
  45780. }
  45781. }
  45782. function collectionClass(collection) {
  45783. return isKeyed(collection)
  45784. ? KeyedCollection
  45785. : isIndexed(collection)
  45786. ? IndexedCollection
  45787. : SetCollection;
  45788. }
  45789. function makeSequence(collection) {
  45790. return Object.create(
  45791. (isKeyed(collection)
  45792. ? KeyedSeq
  45793. : isIndexed(collection)
  45794. ? IndexedSeq
  45795. : SetSeq
  45796. ).prototype
  45797. );
  45798. }
  45799. function cacheResultThrough() {
  45800. if (this._iter.cacheResult) {
  45801. this._iter.cacheResult();
  45802. this.size = this._iter.size;
  45803. return this;
  45804. }
  45805. return Seq.prototype.cacheResult.call(this);
  45806. }
  45807. function defaultComparator(a, b) {
  45808. if (a === undefined && b === undefined) {
  45809. return 0;
  45810. }
  45811. if (a === undefined) {
  45812. return 1;
  45813. }
  45814. if (b === undefined) {
  45815. return -1;
  45816. }
  45817. return a > b ? 1 : a < b ? -1 : 0;
  45818. }
  45819. // http://jsperf.com/copy-array-inline
  45820. function arrCopy(arr, offset) {
  45821. offset = offset || 0;
  45822. var len = Math.max(0, arr.length - offset);
  45823. var newArr = new Array(len);
  45824. for (var ii = 0; ii < len; ii++) {
  45825. newArr[ii] = arr[ii + offset];
  45826. }
  45827. return newArr;
  45828. }
  45829. function invariant(condition, error) {
  45830. if (!condition) {
  45831. throw new Error(error);
  45832. }
  45833. }
  45834. function assertNotInfinite(size) {
  45835. invariant(
  45836. size !== Infinity,
  45837. "Cannot perform this action with an infinite size."
  45838. );
  45839. }
  45840. function coerceKeyPath(keyPath) {
  45841. if (isArrayLike(keyPath) && typeof keyPath !== "string") {
  45842. return keyPath;
  45843. }
  45844. if (isOrdered(keyPath)) {
  45845. return keyPath.toArray();
  45846. }
  45847. throw new TypeError(
  45848. "Invalid keyPath: expected Ordered Collection or Array: " + keyPath
  45849. );
  45850. }
  45851. function isPlainObj(value) {
  45852. return (
  45853. value &&
  45854. (typeof value.constructor !== "function" ||
  45855. value.constructor.name === "Object")
  45856. );
  45857. }
  45858. /**
  45859. * Returns true if the value is a potentially-persistent data structure, either
  45860. * provided by Immutable.js or a plain Array or Object.
  45861. */
  45862. function isDataStructure(value) {
  45863. return (
  45864. typeof value === "object" &&
  45865. (isImmutable(value) || Array.isArray(value) || isPlainObj(value))
  45866. );
  45867. }
  45868. /**
  45869. * Converts a value to a string, adding quotes if a string was provided.
  45870. */
  45871. function quoteString(value) {
  45872. try {
  45873. return typeof value === "string"
  45874. ? JSON.stringify(value)
  45875. : String(value);
  45876. } catch (_ignoreError) {
  45877. return JSON.stringify(value);
  45878. }
  45879. }
  45880. function has(collection, key) {
  45881. return isImmutable(collection)
  45882. ? collection.has(key)
  45883. : isDataStructure(collection) && hasOwnProperty.call(collection, key);
  45884. }
  45885. function get(collection, key, notSetValue) {
  45886. return isImmutable(collection)
  45887. ? collection.get(key, notSetValue)
  45888. : !has(collection, key)
  45889. ? notSetValue
  45890. : typeof collection.get === "function"
  45891. ? collection.get(key)
  45892. : collection[key];
  45893. }
  45894. function shallowCopy(from) {
  45895. if (Array.isArray(from)) {
  45896. return arrCopy(from);
  45897. }
  45898. var to = {};
  45899. for (var key in from) {
  45900. if (hasOwnProperty.call(from, key)) {
  45901. to[key] = from[key];
  45902. }
  45903. }
  45904. return to;
  45905. }
  45906. function remove(collection, key) {
  45907. if (!isDataStructure(collection)) {
  45908. throw new TypeError(
  45909. "Cannot update non-data-structure value: " + collection
  45910. );
  45911. }
  45912. if (isImmutable(collection)) {
  45913. if (!collection.remove) {
  45914. throw new TypeError(
  45915. "Cannot update immutable value without .remove() method: " +
  45916. collection
  45917. );
  45918. }
  45919. return collection.remove(key);
  45920. }
  45921. if (!hasOwnProperty.call(collection, key)) {
  45922. return collection;
  45923. }
  45924. var collectionCopy = shallowCopy(collection);
  45925. if (Array.isArray(collectionCopy)) {
  45926. collectionCopy.splice(key, 1);
  45927. } else {
  45928. delete collectionCopy[key];
  45929. }
  45930. return collectionCopy;
  45931. }
  45932. function set(collection, key, value) {
  45933. if (!isDataStructure(collection)) {
  45934. throw new TypeError(
  45935. "Cannot update non-data-structure value: " + collection
  45936. );
  45937. }
  45938. if (isImmutable(collection)) {
  45939. if (!collection.set) {
  45940. throw new TypeError(
  45941. "Cannot update immutable value without .set() method: " + collection
  45942. );
  45943. }
  45944. return collection.set(key, value);
  45945. }
  45946. if (hasOwnProperty.call(collection, key) && value === collection[key]) {
  45947. return collection;
  45948. }
  45949. var collectionCopy = shallowCopy(collection);
  45950. collectionCopy[key] = value;
  45951. return collectionCopy;
  45952. }
  45953. function updateIn(collection, keyPath, notSetValue, updater) {
  45954. if (!updater) {
  45955. updater = notSetValue;
  45956. notSetValue = undefined;
  45957. }
  45958. var updatedValue = updateInDeeply(
  45959. isImmutable(collection),
  45960. collection,
  45961. coerceKeyPath(keyPath),
  45962. 0,
  45963. notSetValue,
  45964. updater
  45965. );
  45966. return updatedValue === NOT_SET ? notSetValue : updatedValue;
  45967. }
  45968. function updateInDeeply(
  45969. inImmutable,
  45970. existing,
  45971. keyPath,
  45972. i,
  45973. notSetValue,
  45974. updater
  45975. ) {
  45976. var wasNotSet = existing === NOT_SET;
  45977. if (i === keyPath.length) {
  45978. var existingValue = wasNotSet ? notSetValue : existing;
  45979. var newValue = updater(existingValue);
  45980. return newValue === existingValue ? existing : newValue;
  45981. }
  45982. if (!wasNotSet && !isDataStructure(existing)) {
  45983. throw new TypeError(
  45984. "Cannot update within non-data-structure value in path [" +
  45985. keyPath.slice(0, i).map(quoteString) +
  45986. "]: " +
  45987. existing
  45988. );
  45989. }
  45990. var key = keyPath[i];
  45991. var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET);
  45992. var nextUpdated = updateInDeeply(
  45993. nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting),
  45994. nextExisting,
  45995. keyPath,
  45996. i + 1,
  45997. notSetValue,
  45998. updater
  45999. );
  46000. return nextUpdated === nextExisting
  46001. ? existing
  46002. : nextUpdated === NOT_SET
  46003. ? remove(existing, key)
  46004. : set(
  46005. wasNotSet ? (inImmutable ? emptyMap() : {}) : existing,
  46006. key,
  46007. nextUpdated
  46008. );
  46009. }
  46010. function setIn(collection, keyPath, value) {
  46011. return updateIn(collection, keyPath, NOT_SET, function() {
  46012. return value;
  46013. });
  46014. }
  46015. function setIn$1(keyPath, v) {
  46016. return setIn(this, keyPath, v);
  46017. }
  46018. function removeIn(collection, keyPath) {
  46019. return updateIn(collection, keyPath, function() {
  46020. return NOT_SET;
  46021. });
  46022. }
  46023. function deleteIn(keyPath) {
  46024. return removeIn(this, keyPath);
  46025. }
  46026. function update(collection, key, notSetValue, updater) {
  46027. return updateIn(collection, [key], notSetValue, updater);
  46028. }
  46029. function update$1(key, notSetValue, updater) {
  46030. return arguments.length === 1
  46031. ? key(this)
  46032. : update(this, key, notSetValue, updater);
  46033. }
  46034. function updateIn$1(keyPath, notSetValue, updater) {
  46035. return updateIn(this, keyPath, notSetValue, updater);
  46036. }
  46037. function merge() {
  46038. var iters = [],
  46039. len = arguments.length;
  46040. while (len--) iters[len] = arguments[len];
  46041. return mergeIntoKeyedWith(this, iters);
  46042. }
  46043. function mergeWith(merger) {
  46044. var iters = [],
  46045. len = arguments.length - 1;
  46046. while (len-- > 0) iters[len] = arguments[len + 1];
  46047. if (typeof merger !== "function") {
  46048. throw new TypeError("Invalid merger function: " + merger);
  46049. }
  46050. return mergeIntoKeyedWith(this, iters, merger);
  46051. }
  46052. function mergeIntoKeyedWith(collection, collections, merger) {
  46053. var iters = [];
  46054. for (var ii = 0; ii < collections.length; ii++) {
  46055. var collection$1 = KeyedCollection(collections[ii]);
  46056. if (collection$1.size !== 0) {
  46057. iters.push(collection$1);
  46058. }
  46059. }
  46060. if (iters.length === 0) {
  46061. return collection;
  46062. }
  46063. if (
  46064. collection.toSeq().size === 0 &&
  46065. !collection.__ownerID &&
  46066. iters.length === 1
  46067. ) {
  46068. return collection.constructor(iters[0]);
  46069. }
  46070. return collection.withMutations(function(collection) {
  46071. var mergeIntoCollection = merger
  46072. ? function(value, key) {
  46073. update(collection, key, NOT_SET, function(oldVal) {
  46074. return oldVal === NOT_SET ? value : merger(oldVal, value, key);
  46075. });
  46076. }
  46077. : function(value, key) {
  46078. collection.set(key, value);
  46079. };
  46080. for (var ii = 0; ii < iters.length; ii++) {
  46081. iters[ii].forEach(mergeIntoCollection);
  46082. }
  46083. });
  46084. }
  46085. function merge$1(collection) {
  46086. var sources = [],
  46087. len = arguments.length - 1;
  46088. while (len-- > 0) sources[len] = arguments[len + 1];
  46089. return mergeWithSources(collection, sources);
  46090. }
  46091. function mergeWith$1(merger, collection) {
  46092. var sources = [],
  46093. len = arguments.length - 2;
  46094. while (len-- > 0) sources[len] = arguments[len + 2];
  46095. return mergeWithSources(collection, sources, merger);
  46096. }
  46097. function mergeDeep(collection) {
  46098. var sources = [],
  46099. len = arguments.length - 1;
  46100. while (len-- > 0) sources[len] = arguments[len + 1];
  46101. return mergeDeepWithSources(collection, sources);
  46102. }
  46103. function mergeDeepWith(merger, collection) {
  46104. var sources = [],
  46105. len = arguments.length - 2;
  46106. while (len-- > 0) sources[len] = arguments[len + 2];
  46107. return mergeDeepWithSources(collection, sources, merger);
  46108. }
  46109. function mergeDeepWithSources(collection, sources, merger) {
  46110. return mergeWithSources(collection, sources, deepMergerWith(merger));
  46111. }
  46112. function mergeWithSources(collection, sources, merger) {
  46113. if (!isDataStructure(collection)) {
  46114. throw new TypeError(
  46115. "Cannot merge into non-data-structure value: " + collection
  46116. );
  46117. }
  46118. if (isImmutable(collection)) {
  46119. return typeof merger === "function" && collection.mergeWith
  46120. ? collection.mergeWith.apply(collection, [merger].concat(sources))
  46121. : collection.merge
  46122. ? collection.merge.apply(collection, sources)
  46123. : collection.concat.apply(collection, sources);
  46124. }
  46125. var isArray = Array.isArray(collection);
  46126. var merged = collection;
  46127. var Collection$$1 = isArray ? IndexedCollection : KeyedCollection;
  46128. var mergeItem = isArray
  46129. ? function(value) {
  46130. // Copy on write
  46131. if (merged === collection) {
  46132. merged = shallowCopy(merged);
  46133. }
  46134. merged.push(value);
  46135. }
  46136. : function(value, key) {
  46137. var hasVal = hasOwnProperty.call(merged, key);
  46138. var nextVal =
  46139. hasVal && merger ? merger(merged[key], value, key) : value;
  46140. if (!hasVal || nextVal !== merged[key]) {
  46141. // Copy on write
  46142. if (merged === collection) {
  46143. merged = shallowCopy(merged);
  46144. }
  46145. merged[key] = nextVal;
  46146. }
  46147. };
  46148. for (var i = 0; i < sources.length; i++) {
  46149. Collection$$1(sources[i]).forEach(mergeItem);
  46150. }
  46151. return merged;
  46152. }
  46153. function deepMergerWith(merger) {
  46154. function deepMerger(oldValue, newValue, key) {
  46155. return isDataStructure(oldValue) && isDataStructure(newValue)
  46156. ? mergeWithSources(oldValue, [newValue], deepMerger)
  46157. : merger
  46158. ? merger(oldValue, newValue, key)
  46159. : newValue;
  46160. }
  46161. return deepMerger;
  46162. }
  46163. function mergeDeep$1() {
  46164. var iters = [],
  46165. len = arguments.length;
  46166. while (len--) iters[len] = arguments[len];
  46167. return mergeDeepWithSources(this, iters);
  46168. }
  46169. function mergeDeepWith$1(merger) {
  46170. var iters = [],
  46171. len = arguments.length - 1;
  46172. while (len-- > 0) iters[len] = arguments[len + 1];
  46173. return mergeDeepWithSources(this, iters, merger);
  46174. }
  46175. function mergeIn(keyPath) {
  46176. var iters = [],
  46177. len = arguments.length - 1;
  46178. while (len-- > 0) iters[len] = arguments[len + 1];
  46179. return updateIn(this, keyPath, emptyMap(), function(m) {
  46180. return mergeWithSources(m, iters);
  46181. });
  46182. }
  46183. function mergeDeepIn(keyPath) {
  46184. var iters = [],
  46185. len = arguments.length - 1;
  46186. while (len-- > 0) iters[len] = arguments[len + 1];
  46187. return updateIn(this, keyPath, emptyMap(), function(m) {
  46188. return mergeDeepWithSources(m, iters);
  46189. });
  46190. }
  46191. function withMutations(fn) {
  46192. var mutable = this.asMutable();
  46193. fn(mutable);
  46194. return mutable.wasAltered()
  46195. ? mutable.__ensureOwner(this.__ownerID)
  46196. : this;
  46197. }
  46198. function asMutable() {
  46199. return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
  46200. }
  46201. function asImmutable() {
  46202. return this.__ensureOwner();
  46203. }
  46204. function wasAltered() {
  46205. return this.__altered;
  46206. }
  46207. var Map = /*@__PURE__*/ (function(KeyedCollection$$1) {
  46208. function Map(value) {
  46209. return value === null || value === undefined
  46210. ? emptyMap()
  46211. : isMap(value) && !isOrdered(value)
  46212. ? value
  46213. : emptyMap().withMutations(function(map) {
  46214. var iter = KeyedCollection$$1(value);
  46215. assertNotInfinite(iter.size);
  46216. iter.forEach(function(v, k) {
  46217. return map.set(k, v);
  46218. });
  46219. });
  46220. }
  46221. if (KeyedCollection$$1) Map.__proto__ = KeyedCollection$$1;
  46222. Map.prototype = Object.create(
  46223. KeyedCollection$$1 && KeyedCollection$$1.prototype
  46224. );
  46225. Map.prototype.constructor = Map;
  46226. Map.of = function of() {
  46227. var keyValues = [],
  46228. len = arguments.length;
  46229. while (len--) keyValues[len] = arguments[len];
  46230. return emptyMap().withMutations(function(map) {
  46231. for (var i = 0; i < keyValues.length; i += 2) {
  46232. if (i + 1 >= keyValues.length) {
  46233. throw new Error("Missing value for key: " + keyValues[i]);
  46234. }
  46235. map.set(keyValues[i], keyValues[i + 1]);
  46236. }
  46237. });
  46238. };
  46239. Map.prototype.toString = function toString() {
  46240. return this.__toString("Map {", "}");
  46241. };
  46242. // @pragma Access
  46243. Map.prototype.get = function get(k, notSetValue) {
  46244. return this._root
  46245. ? this._root.get(0, undefined, k, notSetValue)
  46246. : notSetValue;
  46247. };
  46248. // @pragma Modification
  46249. Map.prototype.set = function set(k, v) {
  46250. return updateMap(this, k, v);
  46251. };
  46252. Map.prototype.remove = function remove(k) {
  46253. return updateMap(this, k, NOT_SET);
  46254. };
  46255. Map.prototype.deleteAll = function deleteAll(keys) {
  46256. var collection = Collection(keys);
  46257. if (collection.size === 0) {
  46258. return this;
  46259. }
  46260. return this.withMutations(function(map) {
  46261. collection.forEach(function(key) {
  46262. return map.remove(key);
  46263. });
  46264. });
  46265. };
  46266. Map.prototype.clear = function clear() {
  46267. if (this.size === 0) {
  46268. return this;
  46269. }
  46270. if (this.__ownerID) {
  46271. this.size = 0;
  46272. this._root = null;
  46273. this.__hash = undefined;
  46274. this.__altered = true;
  46275. return this;
  46276. }
  46277. return emptyMap();
  46278. };
  46279. // @pragma Composition
  46280. Map.prototype.sort = function sort(comparator) {
  46281. // Late binding
  46282. return OrderedMap(sortFactory(this, comparator));
  46283. };
  46284. Map.prototype.sortBy = function sortBy(mapper, comparator) {
  46285. // Late binding
  46286. return OrderedMap(sortFactory(this, comparator, mapper));
  46287. };
  46288. Map.prototype.map = function map(mapper, context) {
  46289. return this.withMutations(function(map) {
  46290. map.forEach(function(value, key) {
  46291. map.set(key, mapper.call(context, value, key, map));
  46292. });
  46293. });
  46294. };
  46295. // @pragma Mutability
  46296. Map.prototype.__iterator = function __iterator(type, reverse) {
  46297. return new MapIterator(this, type, reverse);
  46298. };
  46299. Map.prototype.__iterate = function __iterate(fn, reverse) {
  46300. var this$1 = this;
  46301. var iterations = 0;
  46302. this._root &&
  46303. this._root.iterate(function(entry) {
  46304. iterations++;
  46305. return fn(entry[1], entry[0], this$1);
  46306. }, reverse);
  46307. return iterations;
  46308. };
  46309. Map.prototype.__ensureOwner = function __ensureOwner(ownerID) {
  46310. if (ownerID === this.__ownerID) {
  46311. return this;
  46312. }
  46313. if (!ownerID) {
  46314. if (this.size === 0) {
  46315. return emptyMap();
  46316. }
  46317. this.__ownerID = ownerID;
  46318. this.__altered = false;
  46319. return this;
  46320. }
  46321. return makeMap(this.size, this._root, ownerID, this.__hash);
  46322. };
  46323. return Map;
  46324. })(KeyedCollection);
  46325. Map.isMap = isMap;
  46326. var MapPrototype = Map.prototype;
  46327. MapPrototype[IS_MAP_SYMBOL] = true;
  46328. MapPrototype[DELETE] = MapPrototype.remove;
  46329. MapPrototype.removeAll = MapPrototype.deleteAll;
  46330. MapPrototype.setIn = setIn$1;
  46331. MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn;
  46332. MapPrototype.update = update$1;
  46333. MapPrototype.updateIn = updateIn$1;
  46334. MapPrototype.merge = MapPrototype.concat = merge;
  46335. MapPrototype.mergeWith = mergeWith;
  46336. MapPrototype.mergeDeep = mergeDeep$1;
  46337. MapPrototype.mergeDeepWith = mergeDeepWith$1;
  46338. MapPrototype.mergeIn = mergeIn;
  46339. MapPrototype.mergeDeepIn = mergeDeepIn;
  46340. MapPrototype.withMutations = withMutations;
  46341. MapPrototype.wasAltered = wasAltered;
  46342. MapPrototype.asImmutable = asImmutable;
  46343. MapPrototype["@@transducer/init"] = MapPrototype.asMutable = asMutable;
  46344. MapPrototype["@@transducer/step"] = function(result, arr) {
  46345. return result.set(arr[0], arr[1]);
  46346. };
  46347. MapPrototype["@@transducer/result"] = function(obj) {
  46348. return obj.asImmutable();
  46349. };
  46350. // #pragma Trie Nodes
  46351. var ArrayMapNode = function ArrayMapNode(ownerID, entries) {
  46352. this.ownerID = ownerID;
  46353. this.entries = entries;
  46354. };
  46355. ArrayMapNode.prototype.get = function get(
  46356. shift,
  46357. keyHash,
  46358. key,
  46359. notSetValue
  46360. ) {
  46361. var entries = this.entries;
  46362. for (var ii = 0, len = entries.length; ii < len; ii++) {
  46363. if (is(key, entries[ii][0])) {
  46364. return entries[ii][1];
  46365. }
  46366. }
  46367. return notSetValue;
  46368. };
  46369. ArrayMapNode.prototype.update = function update(
  46370. ownerID,
  46371. shift,
  46372. keyHash,
  46373. key,
  46374. value,
  46375. didChangeSize,
  46376. didAlter
  46377. ) {
  46378. var removed = value === NOT_SET;
  46379. var entries = this.entries;
  46380. var idx = 0;
  46381. var len = entries.length;
  46382. for (; idx < len; idx++) {
  46383. if (is(key, entries[idx][0])) {
  46384. break;
  46385. }
  46386. }
  46387. var exists = idx < len;
  46388. if (exists ? entries[idx][1] === value : removed) {
  46389. return this;
  46390. }
  46391. SetRef(didAlter);
  46392. (removed || !exists) && SetRef(didChangeSize);
  46393. if (removed && entries.length === 1) {
  46394. return; // undefined
  46395. }
  46396. if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
  46397. return createNodes(ownerID, entries, key, value);
  46398. }
  46399. var isEditable = ownerID && ownerID === this.ownerID;
  46400. var newEntries = isEditable ? entries : arrCopy(entries);
  46401. if (exists) {
  46402. if (removed) {
  46403. idx === len - 1
  46404. ? newEntries.pop()
  46405. : (newEntries[idx] = newEntries.pop());
  46406. } else {
  46407. newEntries[idx] = [key, value];
  46408. }
  46409. } else {
  46410. newEntries.push([key, value]);
  46411. }
  46412. if (isEditable) {
  46413. this.entries = newEntries;
  46414. return this;
  46415. }
  46416. return new ArrayMapNode(ownerID, newEntries);
  46417. };
  46418. var BitmapIndexedNode = function BitmapIndexedNode(ownerID, bitmap, nodes) {
  46419. this.ownerID = ownerID;
  46420. this.bitmap = bitmap;
  46421. this.nodes = nodes;
  46422. };
  46423. BitmapIndexedNode.prototype.get = function get(
  46424. shift,
  46425. keyHash,
  46426. key,
  46427. notSetValue
  46428. ) {
  46429. if (keyHash === undefined) {
  46430. keyHash = hash(key);
  46431. }
  46432. var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK);
  46433. var bitmap = this.bitmap;
  46434. return (bitmap & bit) === 0
  46435. ? notSetValue
  46436. : this.nodes[popCount(bitmap & (bit - 1))].get(
  46437. shift + SHIFT,
  46438. keyHash,
  46439. key,
  46440. notSetValue
  46441. );
  46442. };
  46443. BitmapIndexedNode.prototype.update = function update(
  46444. ownerID,
  46445. shift,
  46446. keyHash,
  46447. key,
  46448. value,
  46449. didChangeSize,
  46450. didAlter
  46451. ) {
  46452. if (keyHash === undefined) {
  46453. keyHash = hash(key);
  46454. }
  46455. var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  46456. var bit = 1 << keyHashFrag;
  46457. var bitmap = this.bitmap;
  46458. var exists = (bitmap & bit) !== 0;
  46459. if (!exists && value === NOT_SET) {
  46460. return this;
  46461. }
  46462. var idx = popCount(bitmap & (bit - 1));
  46463. var nodes = this.nodes;
  46464. var node = exists ? nodes[idx] : undefined;
  46465. var newNode = updateNode(
  46466. node,
  46467. ownerID,
  46468. shift + SHIFT,
  46469. keyHash,
  46470. key,
  46471. value,
  46472. didChangeSize,
  46473. didAlter
  46474. );
  46475. if (newNode === node) {
  46476. return this;
  46477. }
  46478. if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
  46479. return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
  46480. }
  46481. if (
  46482. exists &&
  46483. !newNode &&
  46484. nodes.length === 2 &&
  46485. isLeafNode(nodes[idx ^ 1])
  46486. ) {
  46487. return nodes[idx ^ 1];
  46488. }
  46489. if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
  46490. return newNode;
  46491. }
  46492. var isEditable = ownerID && ownerID === this.ownerID;
  46493. var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit;
  46494. var newNodes = exists
  46495. ? newNode
  46496. ? setAt(nodes, idx, newNode, isEditable)
  46497. : spliceOut(nodes, idx, isEditable)
  46498. : spliceIn(nodes, idx, newNode, isEditable);
  46499. if (isEditable) {
  46500. this.bitmap = newBitmap;
  46501. this.nodes = newNodes;
  46502. return this;
  46503. }
  46504. return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
  46505. };
  46506. var HashArrayMapNode = function HashArrayMapNode(ownerID, count, nodes) {
  46507. this.ownerID = ownerID;
  46508. this.count = count;
  46509. this.nodes = nodes;
  46510. };
  46511. HashArrayMapNode.prototype.get = function get(
  46512. shift,
  46513. keyHash,
  46514. key,
  46515. notSetValue
  46516. ) {
  46517. if (keyHash === undefined) {
  46518. keyHash = hash(key);
  46519. }
  46520. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  46521. var node = this.nodes[idx];
  46522. return node
  46523. ? node.get(shift + SHIFT, keyHash, key, notSetValue)
  46524. : notSetValue;
  46525. };
  46526. HashArrayMapNode.prototype.update = function update(
  46527. ownerID,
  46528. shift,
  46529. keyHash,
  46530. key,
  46531. value,
  46532. didChangeSize,
  46533. didAlter
  46534. ) {
  46535. if (keyHash === undefined) {
  46536. keyHash = hash(key);
  46537. }
  46538. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  46539. var removed = value === NOT_SET;
  46540. var nodes = this.nodes;
  46541. var node = nodes[idx];
  46542. if (removed && !node) {
  46543. return this;
  46544. }
  46545. var newNode = updateNode(
  46546. node,
  46547. ownerID,
  46548. shift + SHIFT,
  46549. keyHash,
  46550. key,
  46551. value,
  46552. didChangeSize,
  46553. didAlter
  46554. );
  46555. if (newNode === node) {
  46556. return this;
  46557. }
  46558. var newCount = this.count;
  46559. if (!node) {
  46560. newCount++;
  46561. } else if (!newNode) {
  46562. newCount--;
  46563. if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
  46564. return packNodes(ownerID, nodes, newCount, idx);
  46565. }
  46566. }
  46567. var isEditable = ownerID && ownerID === this.ownerID;
  46568. var newNodes = setAt(nodes, idx, newNode, isEditable);
  46569. if (isEditable) {
  46570. this.count = newCount;
  46571. this.nodes = newNodes;
  46572. return this;
  46573. }
  46574. return new HashArrayMapNode(ownerID, newCount, newNodes);
  46575. };
  46576. var HashCollisionNode = function HashCollisionNode(
  46577. ownerID,
  46578. keyHash,
  46579. entries
  46580. ) {
  46581. this.ownerID = ownerID;
  46582. this.keyHash = keyHash;
  46583. this.entries = entries;
  46584. };
  46585. HashCollisionNode.prototype.get = function get(
  46586. shift,
  46587. keyHash,
  46588. key,
  46589. notSetValue
  46590. ) {
  46591. var entries = this.entries;
  46592. for (var ii = 0, len = entries.length; ii < len; ii++) {
  46593. if (is(key, entries[ii][0])) {
  46594. return entries[ii][1];
  46595. }
  46596. }
  46597. return notSetValue;
  46598. };
  46599. HashCollisionNode.prototype.update = function update(
  46600. ownerID,
  46601. shift,
  46602. keyHash,
  46603. key,
  46604. value,
  46605. didChangeSize,
  46606. didAlter
  46607. ) {
  46608. if (keyHash === undefined) {
  46609. keyHash = hash(key);
  46610. }
  46611. var removed = value === NOT_SET;
  46612. if (keyHash !== this.keyHash) {
  46613. if (removed) {
  46614. return this;
  46615. }
  46616. SetRef(didAlter);
  46617. SetRef(didChangeSize);
  46618. return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
  46619. }
  46620. var entries = this.entries;
  46621. var idx = 0;
  46622. var len = entries.length;
  46623. for (; idx < len; idx++) {
  46624. if (is(key, entries[idx][0])) {
  46625. break;
  46626. }
  46627. }
  46628. var exists = idx < len;
  46629. if (exists ? entries[idx][1] === value : removed) {
  46630. return this;
  46631. }
  46632. SetRef(didAlter);
  46633. (removed || !exists) && SetRef(didChangeSize);
  46634. if (removed && len === 2) {
  46635. return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
  46636. }
  46637. var isEditable = ownerID && ownerID === this.ownerID;
  46638. var newEntries = isEditable ? entries : arrCopy(entries);
  46639. if (exists) {
  46640. if (removed) {
  46641. idx === len - 1
  46642. ? newEntries.pop()
  46643. : (newEntries[idx] = newEntries.pop());
  46644. } else {
  46645. newEntries[idx] = [key, value];
  46646. }
  46647. } else {
  46648. newEntries.push([key, value]);
  46649. }
  46650. if (isEditable) {
  46651. this.entries = newEntries;
  46652. return this;
  46653. }
  46654. return new HashCollisionNode(ownerID, this.keyHash, newEntries);
  46655. };
  46656. var ValueNode = function ValueNode(ownerID, keyHash, entry) {
  46657. this.ownerID = ownerID;
  46658. this.keyHash = keyHash;
  46659. this.entry = entry;
  46660. };
  46661. ValueNode.prototype.get = function get(shift, keyHash, key, notSetValue) {
  46662. return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
  46663. };
  46664. ValueNode.prototype.update = function update(
  46665. ownerID,
  46666. shift,
  46667. keyHash,
  46668. key,
  46669. value,
  46670. didChangeSize,
  46671. didAlter
  46672. ) {
  46673. var removed = value === NOT_SET;
  46674. var keyMatch = is(key, this.entry[0]);
  46675. if (keyMatch ? value === this.entry[1] : removed) {
  46676. return this;
  46677. }
  46678. SetRef(didAlter);
  46679. if (removed) {
  46680. SetRef(didChangeSize);
  46681. return; // undefined
  46682. }
  46683. if (keyMatch) {
  46684. if (ownerID && ownerID === this.ownerID) {
  46685. this.entry[1] = value;
  46686. return this;
  46687. }
  46688. return new ValueNode(ownerID, this.keyHash, [key, value]);
  46689. }
  46690. SetRef(didChangeSize);
  46691. return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
  46692. };
  46693. // #pragma Iterators
  46694. ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = function(
  46695. fn,
  46696. reverse
  46697. ) {
  46698. var entries = this.entries;
  46699. for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
  46700. if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
  46701. return false;
  46702. }
  46703. }
  46704. };
  46705. BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = function(
  46706. fn,
  46707. reverse
  46708. ) {
  46709. var nodes = this.nodes;
  46710. for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
  46711. var node = nodes[reverse ? maxIndex - ii : ii];
  46712. if (node && node.iterate(fn, reverse) === false) {
  46713. return false;
  46714. }
  46715. }
  46716. };
  46717. // eslint-disable-next-line no-unused-vars
  46718. ValueNode.prototype.iterate = function(fn, reverse) {
  46719. return fn(this.entry);
  46720. };
  46721. var MapIterator = /*@__PURE__*/ (function(Iterator$$1) {
  46722. function MapIterator(map, type, reverse) {
  46723. this._type = type;
  46724. this._reverse = reverse;
  46725. this._stack = map._root && mapIteratorFrame(map._root);
  46726. }
  46727. if (Iterator$$1) MapIterator.__proto__ = Iterator$$1;
  46728. MapIterator.prototype = Object.create(
  46729. Iterator$$1 && Iterator$$1.prototype
  46730. );
  46731. MapIterator.prototype.constructor = MapIterator;
  46732. MapIterator.prototype.next = function next() {
  46733. var type = this._type;
  46734. var stack = this._stack;
  46735. while (stack) {
  46736. var node = stack.node;
  46737. var index = stack.index++;
  46738. var maxIndex = void 0;
  46739. if (node.entry) {
  46740. if (index === 0) {
  46741. return mapIteratorValue(type, node.entry);
  46742. }
  46743. } else if (node.entries) {
  46744. maxIndex = node.entries.length - 1;
  46745. if (index <= maxIndex) {
  46746. return mapIteratorValue(
  46747. type,
  46748. node.entries[this._reverse ? maxIndex - index : index]
  46749. );
  46750. }
  46751. } else {
  46752. maxIndex = node.nodes.length - 1;
  46753. if (index <= maxIndex) {
  46754. var subNode =
  46755. node.nodes[this._reverse ? maxIndex - index : index];
  46756. if (subNode) {
  46757. if (subNode.entry) {
  46758. return mapIteratorValue(type, subNode.entry);
  46759. }
  46760. stack = this._stack = mapIteratorFrame(subNode, stack);
  46761. }
  46762. continue;
  46763. }
  46764. }
  46765. stack = this._stack = this._stack.__prev;
  46766. }
  46767. return iteratorDone();
  46768. };
  46769. return MapIterator;
  46770. })(Iterator);
  46771. function mapIteratorValue(type, entry) {
  46772. return iteratorValue(type, entry[0], entry[1]);
  46773. }
  46774. function mapIteratorFrame(node, prev) {
  46775. return {
  46776. node: node,
  46777. index: 0,
  46778. __prev: prev
  46779. };
  46780. }
  46781. function makeMap(size, root, ownerID, hash$$1) {
  46782. var map = Object.create(MapPrototype);
  46783. map.size = size;
  46784. map._root = root;
  46785. map.__ownerID = ownerID;
  46786. map.__hash = hash$$1;
  46787. map.__altered = false;
  46788. return map;
  46789. }
  46790. var EMPTY_MAP;
  46791. function emptyMap() {
  46792. return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
  46793. }
  46794. function updateMap(map, k, v) {
  46795. var newRoot;
  46796. var newSize;
  46797. if (!map._root) {
  46798. if (v === NOT_SET) {
  46799. return map;
  46800. }
  46801. newSize = 1;
  46802. newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
  46803. } else {
  46804. var didChangeSize = MakeRef();
  46805. var didAlter = MakeRef();
  46806. newRoot = updateNode(
  46807. map._root,
  46808. map.__ownerID,
  46809. 0,
  46810. undefined,
  46811. k,
  46812. v,
  46813. didChangeSize,
  46814. didAlter
  46815. );
  46816. if (!didAlter.value) {
  46817. return map;
  46818. }
  46819. newSize =
  46820. map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0);
  46821. }
  46822. if (map.__ownerID) {
  46823. map.size = newSize;
  46824. map._root = newRoot;
  46825. map.__hash = undefined;
  46826. map.__altered = true;
  46827. return map;
  46828. }
  46829. return newRoot ? makeMap(newSize, newRoot) : emptyMap();
  46830. }
  46831. function updateNode(
  46832. node,
  46833. ownerID,
  46834. shift,
  46835. keyHash,
  46836. key,
  46837. value,
  46838. didChangeSize,
  46839. didAlter
  46840. ) {
  46841. if (!node) {
  46842. if (value === NOT_SET) {
  46843. return node;
  46844. }
  46845. SetRef(didAlter);
  46846. SetRef(didChangeSize);
  46847. return new ValueNode(ownerID, keyHash, [key, value]);
  46848. }
  46849. return node.update(
  46850. ownerID,
  46851. shift,
  46852. keyHash,
  46853. key,
  46854. value,
  46855. didChangeSize,
  46856. didAlter
  46857. );
  46858. }
  46859. function isLeafNode(node) {
  46860. return (
  46861. node.constructor === ValueNode || node.constructor === HashCollisionNode
  46862. );
  46863. }
  46864. function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
  46865. if (node.keyHash === keyHash) {
  46866. return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
  46867. }
  46868. var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
  46869. var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  46870. var newNode;
  46871. var nodes =
  46872. idx1 === idx2
  46873. ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)]
  46874. : ((newNode = new ValueNode(ownerID, keyHash, entry)),
  46875. idx1 < idx2 ? [node, newNode] : [newNode, node]);
  46876. return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
  46877. }
  46878. function createNodes(ownerID, entries, key, value) {
  46879. if (!ownerID) {
  46880. ownerID = new OwnerID();
  46881. }
  46882. var node = new ValueNode(ownerID, hash(key), [key, value]);
  46883. for (var ii = 0; ii < entries.length; ii++) {
  46884. var entry = entries[ii];
  46885. node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
  46886. }
  46887. return node;
  46888. }
  46889. function packNodes(ownerID, nodes, count, excluding) {
  46890. var bitmap = 0;
  46891. var packedII = 0;
  46892. var packedNodes = new Array(count);
  46893. for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
  46894. var node = nodes[ii];
  46895. if (node !== undefined && ii !== excluding) {
  46896. bitmap |= bit;
  46897. packedNodes[packedII++] = node;
  46898. }
  46899. }
  46900. return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
  46901. }
  46902. function expandNodes(ownerID, nodes, bitmap, including, node) {
  46903. var count = 0;
  46904. var expandedNodes = new Array(SIZE);
  46905. for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
  46906. expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
  46907. }
  46908. expandedNodes[including] = node;
  46909. return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
  46910. }
  46911. function popCount(x) {
  46912. x -= (x >> 1) & 0x55555555;
  46913. x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  46914. x = (x + (x >> 4)) & 0x0f0f0f0f;
  46915. x += x >> 8;
  46916. x += x >> 16;
  46917. return x & 0x7f;
  46918. }
  46919. function setAt(array, idx, val, canEdit) {
  46920. var newArray = canEdit ? array : arrCopy(array);
  46921. newArray[idx] = val;
  46922. return newArray;
  46923. }
  46924. function spliceIn(array, idx, val, canEdit) {
  46925. var newLen = array.length + 1;
  46926. if (canEdit && idx + 1 === newLen) {
  46927. array[idx] = val;
  46928. return array;
  46929. }
  46930. var newArray = new Array(newLen);
  46931. var after = 0;
  46932. for (var ii = 0; ii < newLen; ii++) {
  46933. if (ii === idx) {
  46934. newArray[ii] = val;
  46935. after = -1;
  46936. } else {
  46937. newArray[ii] = array[ii + after];
  46938. }
  46939. }
  46940. return newArray;
  46941. }
  46942. function spliceOut(array, idx, canEdit) {
  46943. var newLen = array.length - 1;
  46944. if (canEdit && idx === newLen) {
  46945. array.pop();
  46946. return array;
  46947. }
  46948. var newArray = new Array(newLen);
  46949. var after = 0;
  46950. for (var ii = 0; ii < newLen; ii++) {
  46951. if (ii === idx) {
  46952. after = 1;
  46953. }
  46954. newArray[ii] = array[ii + after];
  46955. }
  46956. return newArray;
  46957. }
  46958. var MAX_ARRAY_MAP_SIZE = SIZE / 4;
  46959. var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
  46960. var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
  46961. var IS_LIST_SYMBOL = "@@__IMMUTABLE_LIST__@@";
  46962. function isList(maybeList) {
  46963. return Boolean(maybeList && maybeList[IS_LIST_SYMBOL]);
  46964. }
  46965. var List = /*@__PURE__*/ (function(IndexedCollection$$1) {
  46966. function List(value) {
  46967. var empty = emptyList();
  46968. if (value === null || value === undefined) {
  46969. return empty;
  46970. }
  46971. if (isList(value)) {
  46972. return value;
  46973. }
  46974. var iter = IndexedCollection$$1(value);
  46975. var size = iter.size;
  46976. if (size === 0) {
  46977. return empty;
  46978. }
  46979. assertNotInfinite(size);
  46980. if (size > 0 && size < SIZE) {
  46981. return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
  46982. }
  46983. return empty.withMutations(function(list) {
  46984. list.setSize(size);
  46985. iter.forEach(function(v, i) {
  46986. return list.set(i, v);
  46987. });
  46988. });
  46989. }
  46990. if (IndexedCollection$$1) List.__proto__ = IndexedCollection$$1;
  46991. List.prototype = Object.create(
  46992. IndexedCollection$$1 && IndexedCollection$$1.prototype
  46993. );
  46994. List.prototype.constructor = List;
  46995. List.of = function of(/*...values*/) {
  46996. return this(arguments);
  46997. };
  46998. List.prototype.toString = function toString() {
  46999. return this.__toString("List [", "]");
  47000. };
  47001. // @pragma Access
  47002. List.prototype.get = function get(index, notSetValue) {
  47003. index = wrapIndex(this, index);
  47004. if (index >= 0 && index < this.size) {
  47005. index += this._origin;
  47006. var node = listNodeFor(this, index);
  47007. return node && node.array[index & MASK];
  47008. }
  47009. return notSetValue;
  47010. };
  47011. // @pragma Modification
  47012. List.prototype.set = function set(index, value) {
  47013. return updateList(this, index, value);
  47014. };
  47015. List.prototype.remove = function remove(index) {
  47016. return !this.has(index)
  47017. ? this
  47018. : index === 0
  47019. ? this.shift()
  47020. : index === this.size - 1
  47021. ? this.pop()
  47022. : this.splice(index, 1);
  47023. };
  47024. List.prototype.insert = function insert(index, value) {
  47025. return this.splice(index, 0, value);
  47026. };
  47027. List.prototype.clear = function clear() {
  47028. if (this.size === 0) {
  47029. return this;
  47030. }
  47031. if (this.__ownerID) {
  47032. this.size = this._origin = this._capacity = 0;
  47033. this._level = SHIFT;
  47034. this._root = this._tail = null;
  47035. this.__hash = undefined;
  47036. this.__altered = true;
  47037. return this;
  47038. }
  47039. return emptyList();
  47040. };
  47041. List.prototype.push = function push(/*...values*/) {
  47042. var values = arguments;
  47043. var oldSize = this.size;
  47044. return this.withMutations(function(list) {
  47045. setListBounds(list, 0, oldSize + values.length);
  47046. for (var ii = 0; ii < values.length; ii++) {
  47047. list.set(oldSize + ii, values[ii]);
  47048. }
  47049. });
  47050. };
  47051. List.prototype.pop = function pop() {
  47052. return setListBounds(this, 0, -1);
  47053. };
  47054. List.prototype.unshift = function unshift(/*...values*/) {
  47055. var values = arguments;
  47056. return this.withMutations(function(list) {
  47057. setListBounds(list, -values.length);
  47058. for (var ii = 0; ii < values.length; ii++) {
  47059. list.set(ii, values[ii]);
  47060. }
  47061. });
  47062. };
  47063. List.prototype.shift = function shift() {
  47064. return setListBounds(this, 1);
  47065. };
  47066. // @pragma Composition
  47067. List.prototype.concat = function concat(/*...collections*/) {
  47068. var arguments$1 = arguments;
  47069. var seqs = [];
  47070. for (var i = 0; i < arguments.length; i++) {
  47071. var argument = arguments$1[i];
  47072. var seq = IndexedCollection$$1(
  47073. typeof argument !== "string" && hasIterator(argument)
  47074. ? argument
  47075. : [argument]
  47076. );
  47077. if (seq.size !== 0) {
  47078. seqs.push(seq);
  47079. }
  47080. }
  47081. if (seqs.length === 0) {
  47082. return this;
  47083. }
  47084. if (this.size === 0 && !this.__ownerID && seqs.length === 1) {
  47085. return this.constructor(seqs[0]);
  47086. }
  47087. return this.withMutations(function(list) {
  47088. seqs.forEach(function(seq) {
  47089. return seq.forEach(function(value) {
  47090. return list.push(value);
  47091. });
  47092. });
  47093. });
  47094. };
  47095. List.prototype.setSize = function setSize(size) {
  47096. return setListBounds(this, 0, size);
  47097. };
  47098. List.prototype.map = function map(mapper, context) {
  47099. var this$1 = this;
  47100. return this.withMutations(function(list) {
  47101. for (var i = 0; i < this$1.size; i++) {
  47102. list.set(i, mapper.call(context, list.get(i), i, list));
  47103. }
  47104. });
  47105. };
  47106. // @pragma Iteration
  47107. List.prototype.slice = function slice(begin, end) {
  47108. var size = this.size;
  47109. if (wholeSlice(begin, end, size)) {
  47110. return this;
  47111. }
  47112. return setListBounds(
  47113. this,
  47114. resolveBegin(begin, size),
  47115. resolveEnd(end, size)
  47116. );
  47117. };
  47118. List.prototype.__iterator = function __iterator(type, reverse) {
  47119. var index = reverse ? this.size : 0;
  47120. var values = iterateList(this, reverse);
  47121. return new Iterator(function() {
  47122. var value = values();
  47123. return value === DONE
  47124. ? iteratorDone()
  47125. : iteratorValue(type, reverse ? --index : index++, value);
  47126. });
  47127. };
  47128. List.prototype.__iterate = function __iterate(fn, reverse) {
  47129. var index = reverse ? this.size : 0;
  47130. var values = iterateList(this, reverse);
  47131. var value;
  47132. while ((value = values()) !== DONE) {
  47133. if (fn(value, reverse ? --index : index++, this) === false) {
  47134. break;
  47135. }
  47136. }
  47137. return index;
  47138. };
  47139. List.prototype.__ensureOwner = function __ensureOwner(ownerID) {
  47140. if (ownerID === this.__ownerID) {
  47141. return this;
  47142. }
  47143. if (!ownerID) {
  47144. if (this.size === 0) {
  47145. return emptyList();
  47146. }
  47147. this.__ownerID = ownerID;
  47148. this.__altered = false;
  47149. return this;
  47150. }
  47151. return makeList(
  47152. this._origin,
  47153. this._capacity,
  47154. this._level,
  47155. this._root,
  47156. this._tail,
  47157. ownerID,
  47158. this.__hash
  47159. );
  47160. };
  47161. return List;
  47162. })(IndexedCollection);
  47163. List.isList = isList;
  47164. var ListPrototype = List.prototype;
  47165. ListPrototype[IS_LIST_SYMBOL] = true;
  47166. ListPrototype[DELETE] = ListPrototype.remove;
  47167. ListPrototype.merge = ListPrototype.concat;
  47168. ListPrototype.setIn = setIn$1;
  47169. ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn;
  47170. ListPrototype.update = update$1;
  47171. ListPrototype.updateIn = updateIn$1;
  47172. ListPrototype.mergeIn = mergeIn;
  47173. ListPrototype.mergeDeepIn = mergeDeepIn;
  47174. ListPrototype.withMutations = withMutations;
  47175. ListPrototype.wasAltered = wasAltered;
  47176. ListPrototype.asImmutable = asImmutable;
  47177. ListPrototype["@@transducer/init"] = ListPrototype.asMutable = asMutable;
  47178. ListPrototype["@@transducer/step"] = function(result, arr) {
  47179. return result.push(arr);
  47180. };
  47181. ListPrototype["@@transducer/result"] = function(obj) {
  47182. return obj.asImmutable();
  47183. };
  47184. var VNode = function VNode(array, ownerID) {
  47185. this.array = array;
  47186. this.ownerID = ownerID;
  47187. };
  47188. // TODO: seems like these methods are very similar
  47189. VNode.prototype.removeBefore = function removeBefore(
  47190. ownerID,
  47191. level,
  47192. index
  47193. ) {
  47194. if (index === level ? 1 << level : this.array.length === 0) {
  47195. return this;
  47196. }
  47197. var originIndex = (index >>> level) & MASK;
  47198. if (originIndex >= this.array.length) {
  47199. return new VNode([], ownerID);
  47200. }
  47201. var removingFirst = originIndex === 0;
  47202. var newChild;
  47203. if (level > 0) {
  47204. var oldChild = this.array[originIndex];
  47205. newChild =
  47206. oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
  47207. if (newChild === oldChild && removingFirst) {
  47208. return this;
  47209. }
  47210. }
  47211. if (removingFirst && !newChild) {
  47212. return this;
  47213. }
  47214. var editable = editableVNode(this, ownerID);
  47215. if (!removingFirst) {
  47216. for (var ii = 0; ii < originIndex; ii++) {
  47217. editable.array[ii] = undefined;
  47218. }
  47219. }
  47220. if (newChild) {
  47221. editable.array[originIndex] = newChild;
  47222. }
  47223. return editable;
  47224. };
  47225. VNode.prototype.removeAfter = function removeAfter(ownerID, level, index) {
  47226. if (index === (level ? 1 << level : 0) || this.array.length === 0) {
  47227. return this;
  47228. }
  47229. var sizeIndex = ((index - 1) >>> level) & MASK;
  47230. if (sizeIndex >= this.array.length) {
  47231. return this;
  47232. }
  47233. var newChild;
  47234. if (level > 0) {
  47235. var oldChild = this.array[sizeIndex];
  47236. newChild =
  47237. oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
  47238. if (newChild === oldChild && sizeIndex === this.array.length - 1) {
  47239. return this;
  47240. }
  47241. }
  47242. var editable = editableVNode(this, ownerID);
  47243. editable.array.splice(sizeIndex + 1);
  47244. if (newChild) {
  47245. editable.array[sizeIndex] = newChild;
  47246. }
  47247. return editable;
  47248. };
  47249. var DONE = {};
  47250. function iterateList(list, reverse) {
  47251. var left = list._origin;
  47252. var right = list._capacity;
  47253. var tailPos = getTailOffset(right);
  47254. var tail = list._tail;
  47255. return iterateNodeOrLeaf(list._root, list._level, 0);
  47256. function iterateNodeOrLeaf(node, level, offset) {
  47257. return level === 0
  47258. ? iterateLeaf(node, offset)
  47259. : iterateNode(node, level, offset);
  47260. }
  47261. function iterateLeaf(node, offset) {
  47262. var array =
  47263. offset === tailPos ? tail && tail.array : node && node.array;
  47264. var from = offset > left ? 0 : left - offset;
  47265. var to = right - offset;
  47266. if (to > SIZE) {
  47267. to = SIZE;
  47268. }
  47269. return function() {
  47270. if (from === to) {
  47271. return DONE;
  47272. }
  47273. var idx = reverse ? --to : from++;
  47274. return array && array[idx];
  47275. };
  47276. }
  47277. function iterateNode(node, level, offset) {
  47278. var values;
  47279. var array = node && node.array;
  47280. var from = offset > left ? 0 : (left - offset) >> level;
  47281. var to = ((right - offset) >> level) + 1;
  47282. if (to > SIZE) {
  47283. to = SIZE;
  47284. }
  47285. return function() {
  47286. while (true) {
  47287. if (values) {
  47288. var value = values();
  47289. if (value !== DONE) {
  47290. return value;
  47291. }
  47292. values = null;
  47293. }
  47294. if (from === to) {
  47295. return DONE;
  47296. }
  47297. var idx = reverse ? --to : from++;
  47298. values = iterateNodeOrLeaf(
  47299. array && array[idx],
  47300. level - SHIFT,
  47301. offset + (idx << level)
  47302. );
  47303. }
  47304. };
  47305. }
  47306. }
  47307. function makeList(origin, capacity, level, root, tail, ownerID, hash) {
  47308. var list = Object.create(ListPrototype);
  47309. list.size = capacity - origin;
  47310. list._origin = origin;
  47311. list._capacity = capacity;
  47312. list._level = level;
  47313. list._root = root;
  47314. list._tail = tail;
  47315. list.__ownerID = ownerID;
  47316. list.__hash = hash;
  47317. list.__altered = false;
  47318. return list;
  47319. }
  47320. var EMPTY_LIST;
  47321. function emptyList() {
  47322. return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
  47323. }
  47324. function updateList(list, index, value) {
  47325. index = wrapIndex(list, index);
  47326. if (index !== index) {
  47327. return list;
  47328. }
  47329. if (index >= list.size || index < 0) {
  47330. return list.withMutations(function(list) {
  47331. index < 0
  47332. ? setListBounds(list, index).set(0, value)
  47333. : setListBounds(list, 0, index + 1).set(index, value);
  47334. });
  47335. }
  47336. index += list._origin;
  47337. var newTail = list._tail;
  47338. var newRoot = list._root;
  47339. var didAlter = MakeRef();
  47340. if (index >= getTailOffset(list._capacity)) {
  47341. newTail = updateVNode(
  47342. newTail,
  47343. list.__ownerID,
  47344. 0,
  47345. index,
  47346. value,
  47347. didAlter
  47348. );
  47349. } else {
  47350. newRoot = updateVNode(
  47351. newRoot,
  47352. list.__ownerID,
  47353. list._level,
  47354. index,
  47355. value,
  47356. didAlter
  47357. );
  47358. }
  47359. if (!didAlter.value) {
  47360. return list;
  47361. }
  47362. if (list.__ownerID) {
  47363. list._root = newRoot;
  47364. list._tail = newTail;
  47365. list.__hash = undefined;
  47366. list.__altered = true;
  47367. return list;
  47368. }
  47369. return makeList(
  47370. list._origin,
  47371. list._capacity,
  47372. list._level,
  47373. newRoot,
  47374. newTail
  47375. );
  47376. }
  47377. function updateVNode(node, ownerID, level, index, value, didAlter) {
  47378. var idx = (index >>> level) & MASK;
  47379. var nodeHas = node && idx < node.array.length;
  47380. if (!nodeHas && value === undefined) {
  47381. return node;
  47382. }
  47383. var newNode;
  47384. if (level > 0) {
  47385. var lowerNode = node && node.array[idx];
  47386. var newLowerNode = updateVNode(
  47387. lowerNode,
  47388. ownerID,
  47389. level - SHIFT,
  47390. index,
  47391. value,
  47392. didAlter
  47393. );
  47394. if (newLowerNode === lowerNode) {
  47395. return node;
  47396. }
  47397. newNode = editableVNode(node, ownerID);
  47398. newNode.array[idx] = newLowerNode;
  47399. return newNode;
  47400. }
  47401. if (nodeHas && node.array[idx] === value) {
  47402. return node;
  47403. }
  47404. if (didAlter) {
  47405. SetRef(didAlter);
  47406. }
  47407. newNode = editableVNode(node, ownerID);
  47408. if (value === undefined && idx === newNode.array.length - 1) {
  47409. newNode.array.pop();
  47410. } else {
  47411. newNode.array[idx] = value;
  47412. }
  47413. return newNode;
  47414. }
  47415. function editableVNode(node, ownerID) {
  47416. if (ownerID && node && ownerID === node.ownerID) {
  47417. return node;
  47418. }
  47419. return new VNode(node ? node.array.slice() : [], ownerID);
  47420. }
  47421. function listNodeFor(list, rawIndex) {
  47422. if (rawIndex >= getTailOffset(list._capacity)) {
  47423. return list._tail;
  47424. }
  47425. if (rawIndex < 1 << (list._level + SHIFT)) {
  47426. var node = list._root;
  47427. var level = list._level;
  47428. while (node && level > 0) {
  47429. node = node.array[(rawIndex >>> level) & MASK];
  47430. level -= SHIFT;
  47431. }
  47432. return node;
  47433. }
  47434. }
  47435. function setListBounds(list, begin, end) {
  47436. // Sanitize begin & end using this shorthand for ToInt32(argument)
  47437. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  47438. if (begin !== undefined) {
  47439. begin |= 0;
  47440. }
  47441. if (end !== undefined) {
  47442. end |= 0;
  47443. }
  47444. var owner = list.__ownerID || new OwnerID();
  47445. var oldOrigin = list._origin;
  47446. var oldCapacity = list._capacity;
  47447. var newOrigin = oldOrigin + begin;
  47448. var newCapacity =
  47449. end === undefined
  47450. ? oldCapacity
  47451. : end < 0
  47452. ? oldCapacity + end
  47453. : oldOrigin + end;
  47454. if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
  47455. return list;
  47456. }
  47457. // If it's going to end after it starts, it's empty.
  47458. if (newOrigin >= newCapacity) {
  47459. return list.clear();
  47460. }
  47461. var newLevel = list._level;
  47462. var newRoot = list._root;
  47463. // New origin might need creating a higher root.
  47464. var offsetShift = 0;
  47465. while (newOrigin + offsetShift < 0) {
  47466. newRoot = new VNode(
  47467. newRoot && newRoot.array.length ? [undefined, newRoot] : [],
  47468. owner
  47469. );
  47470. newLevel += SHIFT;
  47471. offsetShift += 1 << newLevel;
  47472. }
  47473. if (offsetShift) {
  47474. newOrigin += offsetShift;
  47475. oldOrigin += offsetShift;
  47476. newCapacity += offsetShift;
  47477. oldCapacity += offsetShift;
  47478. }
  47479. var oldTailOffset = getTailOffset(oldCapacity);
  47480. var newTailOffset = getTailOffset(newCapacity);
  47481. // New size might need creating a higher root.
  47482. while (newTailOffset >= 1 << (newLevel + SHIFT)) {
  47483. newRoot = new VNode(
  47484. newRoot && newRoot.array.length ? [newRoot] : [],
  47485. owner
  47486. );
  47487. newLevel += SHIFT;
  47488. }
  47489. // Locate or create the new tail.
  47490. var oldTail = list._tail;
  47491. var newTail =
  47492. newTailOffset < oldTailOffset
  47493. ? listNodeFor(list, newCapacity - 1)
  47494. : newTailOffset > oldTailOffset
  47495. ? new VNode([], owner)
  47496. : oldTail;
  47497. // Merge Tail into tree.
  47498. if (
  47499. oldTail &&
  47500. newTailOffset > oldTailOffset &&
  47501. newOrigin < oldCapacity &&
  47502. oldTail.array.length
  47503. ) {
  47504. newRoot = editableVNode(newRoot, owner);
  47505. var node = newRoot;
  47506. for (var level = newLevel; level > SHIFT; level -= SHIFT) {
  47507. var idx = (oldTailOffset >>> level) & MASK;
  47508. node = node.array[idx] = editableVNode(node.array[idx], owner);
  47509. }
  47510. node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
  47511. }
  47512. // If the size has been reduced, there's a chance the tail needs to be trimmed.
  47513. if (newCapacity < oldCapacity) {
  47514. newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
  47515. }
  47516. // If the new origin is within the tail, then we do not need a root.
  47517. if (newOrigin >= newTailOffset) {
  47518. newOrigin -= newTailOffset;
  47519. newCapacity -= newTailOffset;
  47520. newLevel = SHIFT;
  47521. newRoot = null;
  47522. newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
  47523. // Otherwise, if the root has been trimmed, garbage collect.
  47524. } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
  47525. offsetShift = 0;
  47526. // Identify the new top root node of the subtree of the old root.
  47527. while (newRoot) {
  47528. var beginIndex = (newOrigin >>> newLevel) & MASK;
  47529. if ((beginIndex !== newTailOffset >>> newLevel) & MASK) {
  47530. break;
  47531. }
  47532. if (beginIndex) {
  47533. offsetShift += (1 << newLevel) * beginIndex;
  47534. }
  47535. newLevel -= SHIFT;
  47536. newRoot = newRoot.array[beginIndex];
  47537. }
  47538. // Trim the new sides of the new root.
  47539. if (newRoot && newOrigin > oldOrigin) {
  47540. newRoot = newRoot.removeBefore(
  47541. owner,
  47542. newLevel,
  47543. newOrigin - offsetShift
  47544. );
  47545. }
  47546. if (newRoot && newTailOffset < oldTailOffset) {
  47547. newRoot = newRoot.removeAfter(
  47548. owner,
  47549. newLevel,
  47550. newTailOffset - offsetShift
  47551. );
  47552. }
  47553. if (offsetShift) {
  47554. newOrigin -= offsetShift;
  47555. newCapacity -= offsetShift;
  47556. }
  47557. }
  47558. if (list.__ownerID) {
  47559. list.size = newCapacity - newOrigin;
  47560. list._origin = newOrigin;
  47561. list._capacity = newCapacity;
  47562. list._level = newLevel;
  47563. list._root = newRoot;
  47564. list._tail = newTail;
  47565. list.__hash = undefined;
  47566. list.__altered = true;
  47567. return list;
  47568. }
  47569. return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
  47570. }
  47571. function getTailOffset(size) {
  47572. return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT;
  47573. }
  47574. var OrderedMap = /*@__PURE__*/ (function(Map$$1) {
  47575. function OrderedMap(value) {
  47576. return value === null || value === undefined
  47577. ? emptyOrderedMap()
  47578. : isOrderedMap(value)
  47579. ? value
  47580. : emptyOrderedMap().withMutations(function(map) {
  47581. var iter = KeyedCollection(value);
  47582. assertNotInfinite(iter.size);
  47583. iter.forEach(function(v, k) {
  47584. return map.set(k, v);
  47585. });
  47586. });
  47587. }
  47588. if (Map$$1) OrderedMap.__proto__ = Map$$1;
  47589. OrderedMap.prototype = Object.create(Map$$1 && Map$$1.prototype);
  47590. OrderedMap.prototype.constructor = OrderedMap;
  47591. OrderedMap.of = function of(/*...values*/) {
  47592. return this(arguments);
  47593. };
  47594. OrderedMap.prototype.toString = function toString() {
  47595. return this.__toString("OrderedMap {", "}");
  47596. };
  47597. // @pragma Access
  47598. OrderedMap.prototype.get = function get(k, notSetValue) {
  47599. var index = this._map.get(k);
  47600. return index !== undefined ? this._list.get(index)[1] : notSetValue;
  47601. };
  47602. // @pragma Modification
  47603. OrderedMap.prototype.clear = function clear() {
  47604. if (this.size === 0) {
  47605. return this;
  47606. }
  47607. if (this.__ownerID) {
  47608. this.size = 0;
  47609. this._map.clear();
  47610. this._list.clear();
  47611. return this;
  47612. }
  47613. return emptyOrderedMap();
  47614. };
  47615. OrderedMap.prototype.set = function set(k, v) {
  47616. return updateOrderedMap(this, k, v);
  47617. };
  47618. OrderedMap.prototype.remove = function remove(k) {
  47619. return updateOrderedMap(this, k, NOT_SET);
  47620. };
  47621. OrderedMap.prototype.wasAltered = function wasAltered() {
  47622. return this._map.wasAltered() || this._list.wasAltered();
  47623. };
  47624. OrderedMap.prototype.__iterate = function __iterate(fn, reverse) {
  47625. var this$1 = this;
  47626. return this._list.__iterate(function(entry) {
  47627. return entry && fn(entry[1], entry[0], this$1);
  47628. }, reverse);
  47629. };
  47630. OrderedMap.prototype.__iterator = function __iterator(type, reverse) {
  47631. return this._list.fromEntrySeq().__iterator(type, reverse);
  47632. };
  47633. OrderedMap.prototype.__ensureOwner = function __ensureOwner(ownerID) {
  47634. if (ownerID === this.__ownerID) {
  47635. return this;
  47636. }
  47637. var newMap = this._map.__ensureOwner(ownerID);
  47638. var newList = this._list.__ensureOwner(ownerID);
  47639. if (!ownerID) {
  47640. if (this.size === 0) {
  47641. return emptyOrderedMap();
  47642. }
  47643. this.__ownerID = ownerID;
  47644. this._map = newMap;
  47645. this._list = newList;
  47646. return this;
  47647. }
  47648. return makeOrderedMap(newMap, newList, ownerID, this.__hash);
  47649. };
  47650. return OrderedMap;
  47651. })(Map);
  47652. OrderedMap.isOrderedMap = isOrderedMap;
  47653. OrderedMap.prototype[IS_ORDERED_SYMBOL] = true;
  47654. OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
  47655. function makeOrderedMap(map, list, ownerID, hash) {
  47656. var omap = Object.create(OrderedMap.prototype);
  47657. omap.size = map ? map.size : 0;
  47658. omap._map = map;
  47659. omap._list = list;
  47660. omap.__ownerID = ownerID;
  47661. omap.__hash = hash;
  47662. return omap;
  47663. }
  47664. var EMPTY_ORDERED_MAP;
  47665. function emptyOrderedMap() {
  47666. return (
  47667. EMPTY_ORDERED_MAP ||
  47668. (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()))
  47669. );
  47670. }
  47671. function updateOrderedMap(omap, k, v) {
  47672. var map = omap._map;
  47673. var list = omap._list;
  47674. var i = map.get(k);
  47675. var has = i !== undefined;
  47676. var newMap;
  47677. var newList;
  47678. if (v === NOT_SET) {
  47679. // removed
  47680. if (!has) {
  47681. return omap;
  47682. }
  47683. if (list.size >= SIZE && list.size >= map.size * 2) {
  47684. newList = list.filter(function(entry, idx) {
  47685. return entry !== undefined && i !== idx;
  47686. });
  47687. newMap = newList
  47688. .toKeyedSeq()
  47689. .map(function(entry) {
  47690. return entry[0];
  47691. })
  47692. .flip()
  47693. .toMap();
  47694. if (omap.__ownerID) {
  47695. newMap.__ownerID = newList.__ownerID = omap.__ownerID;
  47696. }
  47697. } else {
  47698. newMap = map.remove(k);
  47699. newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
  47700. }
  47701. } else if (has) {
  47702. if (v === list.get(i)[1]) {
  47703. return omap;
  47704. }
  47705. newMap = map;
  47706. newList = list.set(i, [k, v]);
  47707. } else {
  47708. newMap = map.set(k, list.size);
  47709. newList = list.set(list.size, [k, v]);
  47710. }
  47711. if (omap.__ownerID) {
  47712. omap.size = newMap.size;
  47713. omap._map = newMap;
  47714. omap._list = newList;
  47715. omap.__hash = undefined;
  47716. return omap;
  47717. }
  47718. return makeOrderedMap(newMap, newList);
  47719. }
  47720. var IS_STACK_SYMBOL = "@@__IMMUTABLE_STACK__@@";
  47721. function isStack(maybeStack) {
  47722. return Boolean(maybeStack && maybeStack[IS_STACK_SYMBOL]);
  47723. }
  47724. var Stack = /*@__PURE__*/ (function(IndexedCollection$$1) {
  47725. function Stack(value) {
  47726. return value === null || value === undefined
  47727. ? emptyStack()
  47728. : isStack(value)
  47729. ? value
  47730. : emptyStack().pushAll(value);
  47731. }
  47732. if (IndexedCollection$$1) Stack.__proto__ = IndexedCollection$$1;
  47733. Stack.prototype = Object.create(
  47734. IndexedCollection$$1 && IndexedCollection$$1.prototype
  47735. );
  47736. Stack.prototype.constructor = Stack;
  47737. Stack.of = function of(/*...values*/) {
  47738. return this(arguments);
  47739. };
  47740. Stack.prototype.toString = function toString() {
  47741. return this.__toString("Stack [", "]");
  47742. };
  47743. // @pragma Access
  47744. Stack.prototype.get = function get(index, notSetValue) {
  47745. var head = this._head;
  47746. index = wrapIndex(this, index);
  47747. while (head && index--) {
  47748. head = head.next;
  47749. }
  47750. return head ? head.value : notSetValue;
  47751. };
  47752. Stack.prototype.peek = function peek() {
  47753. return this._head && this._head.value;
  47754. };
  47755. // @pragma Modification
  47756. Stack.prototype.push = function push(/*...values*/) {
  47757. var arguments$1 = arguments;
  47758. if (arguments.length === 0) {
  47759. return this;
  47760. }
  47761. var newSize = this.size + arguments.length;
  47762. var head = this._head;
  47763. for (var ii = arguments.length - 1; ii >= 0; ii--) {
  47764. head = {
  47765. value: arguments$1[ii],
  47766. next: head
  47767. };
  47768. }
  47769. if (this.__ownerID) {
  47770. this.size = newSize;
  47771. this._head = head;
  47772. this.__hash = undefined;
  47773. this.__altered = true;
  47774. return this;
  47775. }
  47776. return makeStack(newSize, head);
  47777. };
  47778. Stack.prototype.pushAll = function pushAll(iter) {
  47779. iter = IndexedCollection$$1(iter);
  47780. if (iter.size === 0) {
  47781. return this;
  47782. }
  47783. if (this.size === 0 && isStack(iter)) {
  47784. return iter;
  47785. }
  47786. assertNotInfinite(iter.size);
  47787. var newSize = this.size;
  47788. var head = this._head;
  47789. iter.__iterate(function(value) {
  47790. newSize++;
  47791. head = {
  47792. value: value,
  47793. next: head
  47794. };
  47795. }, /* reverse */ true);
  47796. if (this.__ownerID) {
  47797. this.size = newSize;
  47798. this._head = head;
  47799. this.__hash = undefined;
  47800. this.__altered = true;
  47801. return this;
  47802. }
  47803. return makeStack(newSize, head);
  47804. };
  47805. Stack.prototype.pop = function pop() {
  47806. return this.slice(1);
  47807. };
  47808. Stack.prototype.clear = function clear() {
  47809. if (this.size === 0) {
  47810. return this;
  47811. }
  47812. if (this.__ownerID) {
  47813. this.size = 0;
  47814. this._head = undefined;
  47815. this.__hash = undefined;
  47816. this.__altered = true;
  47817. return this;
  47818. }
  47819. return emptyStack();
  47820. };
  47821. Stack.prototype.slice = function slice(begin, end) {
  47822. if (wholeSlice(begin, end, this.size)) {
  47823. return this;
  47824. }
  47825. var resolvedBegin = resolveBegin(begin, this.size);
  47826. var resolvedEnd = resolveEnd(end, this.size);
  47827. if (resolvedEnd !== this.size) {
  47828. // super.slice(begin, end);
  47829. return IndexedCollection$$1.prototype.slice.call(this, begin, end);
  47830. }
  47831. var newSize = this.size - resolvedBegin;
  47832. var head = this._head;
  47833. while (resolvedBegin--) {
  47834. head = head.next;
  47835. }
  47836. if (this.__ownerID) {
  47837. this.size = newSize;
  47838. this._head = head;
  47839. this.__hash = undefined;
  47840. this.__altered = true;
  47841. return this;
  47842. }
  47843. return makeStack(newSize, head);
  47844. };
  47845. // @pragma Mutability
  47846. Stack.prototype.__ensureOwner = function __ensureOwner(ownerID) {
  47847. if (ownerID === this.__ownerID) {
  47848. return this;
  47849. }
  47850. if (!ownerID) {
  47851. if (this.size === 0) {
  47852. return emptyStack();
  47853. }
  47854. this.__ownerID = ownerID;
  47855. this.__altered = false;
  47856. return this;
  47857. }
  47858. return makeStack(this.size, this._head, ownerID, this.__hash);
  47859. };
  47860. // @pragma Iteration
  47861. Stack.prototype.__iterate = function __iterate(fn, reverse) {
  47862. var this$1 = this;
  47863. if (reverse) {
  47864. return new ArraySeq(this.toArray()).__iterate(function(v, k) {
  47865. return fn(v, k, this$1);
  47866. }, reverse);
  47867. }
  47868. var iterations = 0;
  47869. var node = this._head;
  47870. while (node) {
  47871. if (fn(node.value, iterations++, this) === false) {
  47872. break;
  47873. }
  47874. node = node.next;
  47875. }
  47876. return iterations;
  47877. };
  47878. Stack.prototype.__iterator = function __iterator(type, reverse) {
  47879. if (reverse) {
  47880. return new ArraySeq(this.toArray()).__iterator(type, reverse);
  47881. }
  47882. var iterations = 0;
  47883. var node = this._head;
  47884. return new Iterator(function() {
  47885. if (node) {
  47886. var value = node.value;
  47887. node = node.next;
  47888. return iteratorValue(type, iterations++, value);
  47889. }
  47890. return iteratorDone();
  47891. });
  47892. };
  47893. return Stack;
  47894. })(IndexedCollection);
  47895. Stack.isStack = isStack;
  47896. var StackPrototype = Stack.prototype;
  47897. StackPrototype[IS_STACK_SYMBOL] = true;
  47898. StackPrototype.shift = StackPrototype.pop;
  47899. StackPrototype.unshift = StackPrototype.push;
  47900. StackPrototype.unshiftAll = StackPrototype.pushAll;
  47901. StackPrototype.withMutations = withMutations;
  47902. StackPrototype.wasAltered = wasAltered;
  47903. StackPrototype.asImmutable = asImmutable;
  47904. StackPrototype["@@transducer/init"] = StackPrototype.asMutable = asMutable;
  47905. StackPrototype["@@transducer/step"] = function(result, arr) {
  47906. return result.unshift(arr);
  47907. };
  47908. StackPrototype["@@transducer/result"] = function(obj) {
  47909. return obj.asImmutable();
  47910. };
  47911. function makeStack(size, head, ownerID, hash) {
  47912. var map = Object.create(StackPrototype);
  47913. map.size = size;
  47914. map._head = head;
  47915. map.__ownerID = ownerID;
  47916. map.__hash = hash;
  47917. map.__altered = false;
  47918. return map;
  47919. }
  47920. var EMPTY_STACK;
  47921. function emptyStack() {
  47922. return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
  47923. }
  47924. var IS_SET_SYMBOL = "@@__IMMUTABLE_SET__@@";
  47925. function isSet(maybeSet) {
  47926. return Boolean(maybeSet && maybeSet[IS_SET_SYMBOL]);
  47927. }
  47928. function isOrderedSet(maybeOrderedSet) {
  47929. return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
  47930. }
  47931. function deepEqual(a, b) {
  47932. if (a === b) {
  47933. return true;
  47934. }
  47935. if (
  47936. !isCollection(b) ||
  47937. (a.size !== undefined && b.size !== undefined && a.size !== b.size) ||
  47938. (a.__hash !== undefined &&
  47939. b.__hash !== undefined &&
  47940. a.__hash !== b.__hash) ||
  47941. isKeyed(a) !== isKeyed(b) ||
  47942. isIndexed(a) !== isIndexed(b) ||
  47943. isOrdered(a) !== isOrdered(b)
  47944. ) {
  47945. return false;
  47946. }
  47947. if (a.size === 0 && b.size === 0) {
  47948. return true;
  47949. }
  47950. var notAssociative = !isAssociative(a);
  47951. if (isOrdered(a)) {
  47952. var entries = a.entries();
  47953. return (
  47954. b.every(function(v, k) {
  47955. var entry = entries.next().value;
  47956. return (
  47957. entry && is(entry[1], v) && (notAssociative || is(entry[0], k))
  47958. );
  47959. }) && entries.next().done
  47960. );
  47961. }
  47962. var flipped = false;
  47963. if (a.size === undefined) {
  47964. if (b.size === undefined) {
  47965. if (typeof a.cacheResult === "function") {
  47966. a.cacheResult();
  47967. }
  47968. } else {
  47969. flipped = true;
  47970. var _ = a;
  47971. a = b;
  47972. b = _;
  47973. }
  47974. }
  47975. var allEqual = true;
  47976. var bSize = b.__iterate(function(v, k) {
  47977. if (
  47978. notAssociative
  47979. ? !a.has(v)
  47980. : flipped
  47981. ? !is(v, a.get(k, NOT_SET))
  47982. : !is(a.get(k, NOT_SET), v)
  47983. ) {
  47984. allEqual = false;
  47985. return false;
  47986. }
  47987. });
  47988. return allEqual && a.size === bSize;
  47989. }
  47990. /**
  47991. * Contributes additional methods to a constructor
  47992. */
  47993. function mixin(ctor, methods) {
  47994. var keyCopier = function(key) {
  47995. ctor.prototype[key] = methods[key];
  47996. };
  47997. Object.keys(methods).forEach(keyCopier);
  47998. Object.getOwnPropertySymbols &&
  47999. Object.getOwnPropertySymbols(methods).forEach(keyCopier);
  48000. return ctor;
  48001. }
  48002. function toJS(value) {
  48003. if (!value || typeof value !== "object") {
  48004. return value;
  48005. }
  48006. if (!isCollection(value)) {
  48007. if (!isDataStructure(value)) {
  48008. return value;
  48009. }
  48010. value = Seq(value);
  48011. }
  48012. if (isKeyed(value)) {
  48013. var result$1 = {};
  48014. value.__iterate(function(v, k) {
  48015. result$1[k] = toJS(v);
  48016. });
  48017. return result$1;
  48018. }
  48019. var result = [];
  48020. value.__iterate(function(v) {
  48021. result.push(toJS(v));
  48022. });
  48023. return result;
  48024. }
  48025. var Set = /*@__PURE__*/ (function(SetCollection$$1) {
  48026. function Set(value) {
  48027. return value === null || value === undefined
  48028. ? emptySet()
  48029. : isSet(value) && !isOrdered(value)
  48030. ? value
  48031. : emptySet().withMutations(function(set) {
  48032. var iter = SetCollection$$1(value);
  48033. assertNotInfinite(iter.size);
  48034. iter.forEach(function(v) {
  48035. return set.add(v);
  48036. });
  48037. });
  48038. }
  48039. if (SetCollection$$1) Set.__proto__ = SetCollection$$1;
  48040. Set.prototype = Object.create(
  48041. SetCollection$$1 && SetCollection$$1.prototype
  48042. );
  48043. Set.prototype.constructor = Set;
  48044. Set.of = function of(/*...values*/) {
  48045. return this(arguments);
  48046. };
  48047. Set.fromKeys = function fromKeys(value) {
  48048. return this(KeyedCollection(value).keySeq());
  48049. };
  48050. Set.intersect = function intersect(sets) {
  48051. sets = Collection(sets).toArray();
  48052. return sets.length
  48053. ? SetPrototype.intersect.apply(Set(sets.pop()), sets)
  48054. : emptySet();
  48055. };
  48056. Set.union = function union(sets) {
  48057. sets = Collection(sets).toArray();
  48058. return sets.length
  48059. ? SetPrototype.union.apply(Set(sets.pop()), sets)
  48060. : emptySet();
  48061. };
  48062. Set.prototype.toString = function toString() {
  48063. return this.__toString("Set {", "}");
  48064. };
  48065. // @pragma Access
  48066. Set.prototype.has = function has(value) {
  48067. return this._map.has(value);
  48068. };
  48069. // @pragma Modification
  48070. Set.prototype.add = function add(value) {
  48071. return updateSet(this, this._map.set(value, value));
  48072. };
  48073. Set.prototype.remove = function remove(value) {
  48074. return updateSet(this, this._map.remove(value));
  48075. };
  48076. Set.prototype.clear = function clear() {
  48077. return updateSet(this, this._map.clear());
  48078. };
  48079. // @pragma Composition
  48080. Set.prototype.map = function map(mapper, context) {
  48081. var this$1 = this;
  48082. var removes = [];
  48083. var adds = [];
  48084. this.forEach(function(value) {
  48085. var mapped = mapper.call(context, value, value, this$1);
  48086. if (mapped !== value) {
  48087. removes.push(value);
  48088. adds.push(mapped);
  48089. }
  48090. });
  48091. return this.withMutations(function(set) {
  48092. removes.forEach(function(value) {
  48093. return set.remove(value);
  48094. });
  48095. adds.forEach(function(value) {
  48096. return set.add(value);
  48097. });
  48098. });
  48099. };
  48100. Set.prototype.union = function union() {
  48101. var iters = [],
  48102. len = arguments.length;
  48103. while (len--) iters[len] = arguments[len];
  48104. iters = iters.filter(function(x) {
  48105. return x.size !== 0;
  48106. });
  48107. if (iters.length === 0) {
  48108. return this;
  48109. }
  48110. if (this.size === 0 && !this.__ownerID && iters.length === 1) {
  48111. return this.constructor(iters[0]);
  48112. }
  48113. return this.withMutations(function(set) {
  48114. for (var ii = 0; ii < iters.length; ii++) {
  48115. SetCollection$$1(iters[ii]).forEach(function(value) {
  48116. return set.add(value);
  48117. });
  48118. }
  48119. });
  48120. };
  48121. Set.prototype.intersect = function intersect() {
  48122. var iters = [],
  48123. len = arguments.length;
  48124. while (len--) iters[len] = arguments[len];
  48125. if (iters.length === 0) {
  48126. return this;
  48127. }
  48128. iters = iters.map(function(iter) {
  48129. return SetCollection$$1(iter);
  48130. });
  48131. var toRemove = [];
  48132. this.forEach(function(value) {
  48133. if (
  48134. !iters.every(function(iter) {
  48135. return iter.includes(value);
  48136. })
  48137. ) {
  48138. toRemove.push(value);
  48139. }
  48140. });
  48141. return this.withMutations(function(set) {
  48142. toRemove.forEach(function(value) {
  48143. set.remove(value);
  48144. });
  48145. });
  48146. };
  48147. Set.prototype.subtract = function subtract() {
  48148. var iters = [],
  48149. len = arguments.length;
  48150. while (len--) iters[len] = arguments[len];
  48151. if (iters.length === 0) {
  48152. return this;
  48153. }
  48154. iters = iters.map(function(iter) {
  48155. return SetCollection$$1(iter);
  48156. });
  48157. var toRemove = [];
  48158. this.forEach(function(value) {
  48159. if (
  48160. iters.some(function(iter) {
  48161. return iter.includes(value);
  48162. })
  48163. ) {
  48164. toRemove.push(value);
  48165. }
  48166. });
  48167. return this.withMutations(function(set) {
  48168. toRemove.forEach(function(value) {
  48169. set.remove(value);
  48170. });
  48171. });
  48172. };
  48173. Set.prototype.sort = function sort(comparator) {
  48174. // Late binding
  48175. return OrderedSet(sortFactory(this, comparator));
  48176. };
  48177. Set.prototype.sortBy = function sortBy(mapper, comparator) {
  48178. // Late binding
  48179. return OrderedSet(sortFactory(this, comparator, mapper));
  48180. };
  48181. Set.prototype.wasAltered = function wasAltered() {
  48182. return this._map.wasAltered();
  48183. };
  48184. Set.prototype.__iterate = function __iterate(fn, reverse) {
  48185. var this$1 = this;
  48186. return this._map.__iterate(function(k) {
  48187. return fn(k, k, this$1);
  48188. }, reverse);
  48189. };
  48190. Set.prototype.__iterator = function __iterator(type, reverse) {
  48191. return this._map.__iterator(type, reverse);
  48192. };
  48193. Set.prototype.__ensureOwner = function __ensureOwner(ownerID) {
  48194. if (ownerID === this.__ownerID) {
  48195. return this;
  48196. }
  48197. var newMap = this._map.__ensureOwner(ownerID);
  48198. if (!ownerID) {
  48199. if (this.size === 0) {
  48200. return this.__empty();
  48201. }
  48202. this.__ownerID = ownerID;
  48203. this._map = newMap;
  48204. return this;
  48205. }
  48206. return this.__make(newMap, ownerID);
  48207. };
  48208. return Set;
  48209. })(SetCollection);
  48210. Set.isSet = isSet;
  48211. var SetPrototype = Set.prototype;
  48212. SetPrototype[IS_SET_SYMBOL] = true;
  48213. SetPrototype[DELETE] = SetPrototype.remove;
  48214. SetPrototype.merge = SetPrototype.concat = SetPrototype.union;
  48215. SetPrototype.withMutations = withMutations;
  48216. SetPrototype.asImmutable = asImmutable;
  48217. SetPrototype["@@transducer/init"] = SetPrototype.asMutable = asMutable;
  48218. SetPrototype["@@transducer/step"] = function(result, arr) {
  48219. return result.add(arr);
  48220. };
  48221. SetPrototype["@@transducer/result"] = function(obj) {
  48222. return obj.asImmutable();
  48223. };
  48224. SetPrototype.__empty = emptySet;
  48225. SetPrototype.__make = makeSet;
  48226. function updateSet(set, newMap) {
  48227. if (set.__ownerID) {
  48228. set.size = newMap.size;
  48229. set._map = newMap;
  48230. return set;
  48231. }
  48232. return newMap === set._map
  48233. ? set
  48234. : newMap.size === 0
  48235. ? set.__empty()
  48236. : set.__make(newMap);
  48237. }
  48238. function makeSet(map, ownerID) {
  48239. var set = Object.create(SetPrototype);
  48240. set.size = map ? map.size : 0;
  48241. set._map = map;
  48242. set.__ownerID = ownerID;
  48243. return set;
  48244. }
  48245. var EMPTY_SET;
  48246. function emptySet() {
  48247. return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
  48248. }
  48249. /**
  48250. * Returns a lazy seq of nums from start (inclusive) to end
  48251. * (exclusive), by step, where start defaults to 0, step to 1, and end to
  48252. * infinity. When start is equal to end, returns empty list.
  48253. */
  48254. var Range = /*@__PURE__*/ (function(IndexedSeq$$1) {
  48255. function Range(start, end, step) {
  48256. if (!(this instanceof Range)) {
  48257. return new Range(start, end, step);
  48258. }
  48259. invariant(step !== 0, "Cannot step a Range by 0");
  48260. start = start || 0;
  48261. if (end === undefined) {
  48262. end = Infinity;
  48263. }
  48264. step = step === undefined ? 1 : Math.abs(step);
  48265. if (end < start) {
  48266. step = -step;
  48267. }
  48268. this._start = start;
  48269. this._end = end;
  48270. this._step = step;
  48271. this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
  48272. if (this.size === 0) {
  48273. if (EMPTY_RANGE) {
  48274. return EMPTY_RANGE;
  48275. }
  48276. EMPTY_RANGE = this;
  48277. }
  48278. }
  48279. if (IndexedSeq$$1) Range.__proto__ = IndexedSeq$$1;
  48280. Range.prototype = Object.create(IndexedSeq$$1 && IndexedSeq$$1.prototype);
  48281. Range.prototype.constructor = Range;
  48282. Range.prototype.toString = function toString() {
  48283. if (this.size === 0) {
  48284. return "Range []";
  48285. }
  48286. return (
  48287. "Range [ " +
  48288. this._start +
  48289. "..." +
  48290. this._end +
  48291. (this._step !== 1 ? " by " + this._step : "") +
  48292. " ]"
  48293. );
  48294. };
  48295. Range.prototype.get = function get(index, notSetValue) {
  48296. return this.has(index)
  48297. ? this._start + wrapIndex(this, index) * this._step
  48298. : notSetValue;
  48299. };
  48300. Range.prototype.includes = function includes(searchValue) {
  48301. var possibleIndex = (searchValue - this._start) / this._step;
  48302. return (
  48303. possibleIndex >= 0 &&
  48304. possibleIndex < this.size &&
  48305. possibleIndex === Math.floor(possibleIndex)
  48306. );
  48307. };
  48308. Range.prototype.slice = function slice(begin, end) {
  48309. if (wholeSlice(begin, end, this.size)) {
  48310. return this;
  48311. }
  48312. begin = resolveBegin(begin, this.size);
  48313. end = resolveEnd(end, this.size);
  48314. if (end <= begin) {
  48315. return new Range(0, 0);
  48316. }
  48317. return new Range(
  48318. this.get(begin, this._end),
  48319. this.get(end, this._end),
  48320. this._step
  48321. );
  48322. };
  48323. Range.prototype.indexOf = function indexOf(searchValue) {
  48324. var offsetValue = searchValue - this._start;
  48325. if (offsetValue % this._step === 0) {
  48326. var index = offsetValue / this._step;
  48327. if (index >= 0 && index < this.size) {
  48328. return index;
  48329. }
  48330. }
  48331. return -1;
  48332. };
  48333. Range.prototype.lastIndexOf = function lastIndexOf(searchValue) {
  48334. return this.indexOf(searchValue);
  48335. };
  48336. Range.prototype.__iterate = function __iterate(fn, reverse) {
  48337. var size = this.size;
  48338. var step = this._step;
  48339. var value = reverse ? this._start + (size - 1) * step : this._start;
  48340. var i = 0;
  48341. while (i !== size) {
  48342. if (fn(value, reverse ? size - ++i : i++, this) === false) {
  48343. break;
  48344. }
  48345. value += reverse ? -step : step;
  48346. }
  48347. return i;
  48348. };
  48349. Range.prototype.__iterator = function __iterator(type, reverse) {
  48350. var size = this.size;
  48351. var step = this._step;
  48352. var value = reverse ? this._start + (size - 1) * step : this._start;
  48353. var i = 0;
  48354. return new Iterator(function() {
  48355. if (i === size) {
  48356. return iteratorDone();
  48357. }
  48358. var v = value;
  48359. value += reverse ? -step : step;
  48360. return iteratorValue(type, reverse ? size - ++i : i++, v);
  48361. });
  48362. };
  48363. Range.prototype.equals = function equals(other) {
  48364. return other instanceof Range
  48365. ? this._start === other._start &&
  48366. this._end === other._end &&
  48367. this._step === other._step
  48368. : deepEqual(this, other);
  48369. };
  48370. return Range;
  48371. })(IndexedSeq);
  48372. var EMPTY_RANGE;
  48373. function getIn(collection, searchKeyPath, notSetValue) {
  48374. var keyPath = coerceKeyPath(searchKeyPath);
  48375. var i = 0;
  48376. while (i !== keyPath.length) {
  48377. collection = get(collection, keyPath[i++], NOT_SET);
  48378. if (collection === NOT_SET) {
  48379. return notSetValue;
  48380. }
  48381. }
  48382. return collection;
  48383. }
  48384. function getIn$1(searchKeyPath, notSetValue) {
  48385. return getIn(this, searchKeyPath, notSetValue);
  48386. }
  48387. function hasIn(collection, keyPath) {
  48388. return getIn(collection, keyPath, NOT_SET) !== NOT_SET;
  48389. }
  48390. function hasIn$1(searchKeyPath) {
  48391. return hasIn(this, searchKeyPath);
  48392. }
  48393. function toObject() {
  48394. assertNotInfinite(this.size);
  48395. var object = {};
  48396. this.__iterate(function(v, k) {
  48397. object[k] = v;
  48398. });
  48399. return object;
  48400. }
  48401. // Note: all of these methods are deprecated.
  48402. Collection.isIterable = isCollection;
  48403. Collection.isKeyed = isKeyed;
  48404. Collection.isIndexed = isIndexed;
  48405. Collection.isAssociative = isAssociative;
  48406. Collection.isOrdered = isOrdered;
  48407. Collection.Iterator = Iterator;
  48408. mixin(Collection, {
  48409. // ### Conversion to other types
  48410. toArray: function toArray() {
  48411. assertNotInfinite(this.size);
  48412. var array = new Array(this.size || 0);
  48413. var useTuples = isKeyed(this);
  48414. var i = 0;
  48415. this.__iterate(function(v, k) {
  48416. // Keyed collections produce an array of tuples.
  48417. array[i++] = useTuples ? [k, v] : v;
  48418. });
  48419. return array;
  48420. },
  48421. toIndexedSeq: function toIndexedSeq() {
  48422. return new ToIndexedSequence(this);
  48423. },
  48424. toJS: function toJS$1() {
  48425. return toJS(this);
  48426. },
  48427. toKeyedSeq: function toKeyedSeq() {
  48428. return new ToKeyedSequence(this, true);
  48429. },
  48430. toMap: function toMap() {
  48431. // Use Late Binding here to solve the circular dependency.
  48432. return Map(this.toKeyedSeq());
  48433. },
  48434. toObject: toObject,
  48435. toOrderedMap: function toOrderedMap() {
  48436. // Use Late Binding here to solve the circular dependency.
  48437. return OrderedMap(this.toKeyedSeq());
  48438. },
  48439. toOrderedSet: function toOrderedSet() {
  48440. // Use Late Binding here to solve the circular dependency.
  48441. return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
  48442. },
  48443. toSet: function toSet() {
  48444. // Use Late Binding here to solve the circular dependency.
  48445. return Set(isKeyed(this) ? this.valueSeq() : this);
  48446. },
  48447. toSetSeq: function toSetSeq() {
  48448. return new ToSetSequence(this);
  48449. },
  48450. toSeq: function toSeq() {
  48451. return isIndexed(this)
  48452. ? this.toIndexedSeq()
  48453. : isKeyed(this)
  48454. ? this.toKeyedSeq()
  48455. : this.toSetSeq();
  48456. },
  48457. toStack: function toStack() {
  48458. // Use Late Binding here to solve the circular dependency.
  48459. return Stack(isKeyed(this) ? this.valueSeq() : this);
  48460. },
  48461. toList: function toList() {
  48462. // Use Late Binding here to solve the circular dependency.
  48463. return List(isKeyed(this) ? this.valueSeq() : this);
  48464. },
  48465. // ### Common JavaScript methods and properties
  48466. toString: function toString() {
  48467. return "[Collection]";
  48468. },
  48469. __toString: function __toString(head, tail) {
  48470. if (this.size === 0) {
  48471. return head + tail;
  48472. }
  48473. return (
  48474. head +
  48475. " " +
  48476. this.toSeq()
  48477. .map(this.__toStringMapper)
  48478. .join(", ") +
  48479. " " +
  48480. tail
  48481. );
  48482. },
  48483. // ### ES6 Collection methods (ES6 Array and Map)
  48484. concat: function concat() {
  48485. var values = [],
  48486. len = arguments.length;
  48487. while (len--) values[len] = arguments[len];
  48488. return reify(this, concatFactory(this, values));
  48489. },
  48490. includes: function includes(searchValue) {
  48491. return this.some(function(value) {
  48492. return is(value, searchValue);
  48493. });
  48494. },
  48495. entries: function entries() {
  48496. return this.__iterator(ITERATE_ENTRIES);
  48497. },
  48498. every: function every(predicate, context) {
  48499. assertNotInfinite(this.size);
  48500. var returnValue = true;
  48501. this.__iterate(function(v, k, c) {
  48502. if (!predicate.call(context, v, k, c)) {
  48503. returnValue = false;
  48504. return false;
  48505. }
  48506. });
  48507. return returnValue;
  48508. },
  48509. filter: function filter(predicate, context) {
  48510. return reify(this, filterFactory(this, predicate, context, true));
  48511. },
  48512. find: function find(predicate, context, notSetValue) {
  48513. var entry = this.findEntry(predicate, context);
  48514. return entry ? entry[1] : notSetValue;
  48515. },
  48516. forEach: function forEach(sideEffect, context) {
  48517. assertNotInfinite(this.size);
  48518. return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
  48519. },
  48520. join: function join(separator) {
  48521. assertNotInfinite(this.size);
  48522. separator = separator !== undefined ? "" + separator : ",";
  48523. var joined = "";
  48524. var isFirst = true;
  48525. this.__iterate(function(v) {
  48526. isFirst ? (isFirst = false) : (joined += separator);
  48527. joined += v !== null && v !== undefined ? v.toString() : "";
  48528. });
  48529. return joined;
  48530. },
  48531. keys: function keys() {
  48532. return this.__iterator(ITERATE_KEYS);
  48533. },
  48534. map: function map(mapper, context) {
  48535. return reify(this, mapFactory(this, mapper, context));
  48536. },
  48537. reduce: function reduce$1(reducer, initialReduction, context) {
  48538. return reduce(
  48539. this,
  48540. reducer,
  48541. initialReduction,
  48542. context,
  48543. arguments.length < 2,
  48544. false
  48545. );
  48546. },
  48547. reduceRight: function reduceRight(reducer, initialReduction, context) {
  48548. return reduce(
  48549. this,
  48550. reducer,
  48551. initialReduction,
  48552. context,
  48553. arguments.length < 2,
  48554. true
  48555. );
  48556. },
  48557. reverse: function reverse() {
  48558. return reify(this, reverseFactory(this, true));
  48559. },
  48560. slice: function slice(begin, end) {
  48561. return reify(this, sliceFactory(this, begin, end, true));
  48562. },
  48563. some: function some(predicate, context) {
  48564. return !this.every(not(predicate), context);
  48565. },
  48566. sort: function sort(comparator) {
  48567. return reify(this, sortFactory(this, comparator));
  48568. },
  48569. values: function values() {
  48570. return this.__iterator(ITERATE_VALUES);
  48571. },
  48572. // ### More sequential methods
  48573. butLast: function butLast() {
  48574. return this.slice(0, -1);
  48575. },
  48576. isEmpty: function isEmpty() {
  48577. return this.size !== undefined
  48578. ? this.size === 0
  48579. : !this.some(function() {
  48580. return true;
  48581. });
  48582. },
  48583. count: function count(predicate, context) {
  48584. return ensureSize(
  48585. predicate ? this.toSeq().filter(predicate, context) : this
  48586. );
  48587. },
  48588. countBy: function countBy(grouper, context) {
  48589. return countByFactory(this, grouper, context);
  48590. },
  48591. equals: function equals(other) {
  48592. return deepEqual(this, other);
  48593. },
  48594. entrySeq: function entrySeq() {
  48595. var collection = this;
  48596. if (collection._cache) {
  48597. // We cache as an entries array, so we can just return the cache!
  48598. return new ArraySeq(collection._cache);
  48599. }
  48600. var entriesSequence = collection
  48601. .toSeq()
  48602. .map(entryMapper)
  48603. .toIndexedSeq();
  48604. entriesSequence.fromEntrySeq = function() {
  48605. return collection.toSeq();
  48606. };
  48607. return entriesSequence;
  48608. },
  48609. filterNot: function filterNot(predicate, context) {
  48610. return this.filter(not(predicate), context);
  48611. },
  48612. findEntry: function findEntry(predicate, context, notSetValue) {
  48613. var found = notSetValue;
  48614. this.__iterate(function(v, k, c) {
  48615. if (predicate.call(context, v, k, c)) {
  48616. found = [k, v];
  48617. return false;
  48618. }
  48619. });
  48620. return found;
  48621. },
  48622. findKey: function findKey(predicate, context) {
  48623. var entry = this.findEntry(predicate, context);
  48624. return entry && entry[0];
  48625. },
  48626. findLast: function findLast(predicate, context, notSetValue) {
  48627. return this.toKeyedSeq()
  48628. .reverse()
  48629. .find(predicate, context, notSetValue);
  48630. },
  48631. findLastEntry: function findLastEntry(predicate, context, notSetValue) {
  48632. return this.toKeyedSeq()
  48633. .reverse()
  48634. .findEntry(predicate, context, notSetValue);
  48635. },
  48636. findLastKey: function findLastKey(predicate, context) {
  48637. return this.toKeyedSeq()
  48638. .reverse()
  48639. .findKey(predicate, context);
  48640. },
  48641. first: function first(notSetValue) {
  48642. return this.find(returnTrue, null, notSetValue);
  48643. },
  48644. flatMap: function flatMap(mapper, context) {
  48645. return reify(this, flatMapFactory(this, mapper, context));
  48646. },
  48647. flatten: function flatten(depth) {
  48648. return reify(this, flattenFactory(this, depth, true));
  48649. },
  48650. fromEntrySeq: function fromEntrySeq() {
  48651. return new FromEntriesSequence(this);
  48652. },
  48653. get: function get(searchKey, notSetValue) {
  48654. return this.find(
  48655. function(_, key) {
  48656. return is(key, searchKey);
  48657. },
  48658. undefined,
  48659. notSetValue
  48660. );
  48661. },
  48662. getIn: getIn$1,
  48663. groupBy: function groupBy(grouper, context) {
  48664. return groupByFactory(this, grouper, context);
  48665. },
  48666. has: function has(searchKey) {
  48667. return this.get(searchKey, NOT_SET) !== NOT_SET;
  48668. },
  48669. hasIn: hasIn$1,
  48670. isSubset: function isSubset(iter) {
  48671. iter = typeof iter.includes === "function" ? iter : Collection(iter);
  48672. return this.every(function(value) {
  48673. return iter.includes(value);
  48674. });
  48675. },
  48676. isSuperset: function isSuperset(iter) {
  48677. iter = typeof iter.isSubset === "function" ? iter : Collection(iter);
  48678. return iter.isSubset(this);
  48679. },
  48680. keyOf: function keyOf(searchValue) {
  48681. return this.findKey(function(value) {
  48682. return is(value, searchValue);
  48683. });
  48684. },
  48685. keySeq: function keySeq() {
  48686. return this.toSeq()
  48687. .map(keyMapper)
  48688. .toIndexedSeq();
  48689. },
  48690. last: function last(notSetValue) {
  48691. return this.toSeq()
  48692. .reverse()
  48693. .first(notSetValue);
  48694. },
  48695. lastKeyOf: function lastKeyOf(searchValue) {
  48696. return this.toKeyedSeq()
  48697. .reverse()
  48698. .keyOf(searchValue);
  48699. },
  48700. max: function max(comparator) {
  48701. return maxFactory(this, comparator);
  48702. },
  48703. maxBy: function maxBy(mapper, comparator) {
  48704. return maxFactory(this, comparator, mapper);
  48705. },
  48706. min: function min(comparator) {
  48707. return maxFactory(
  48708. this,
  48709. comparator ? neg(comparator) : defaultNegComparator
  48710. );
  48711. },
  48712. minBy: function minBy(mapper, comparator) {
  48713. return maxFactory(
  48714. this,
  48715. comparator ? neg(comparator) : defaultNegComparator,
  48716. mapper
  48717. );
  48718. },
  48719. rest: function rest() {
  48720. return this.slice(1);
  48721. },
  48722. skip: function skip(amount) {
  48723. return amount === 0 ? this : this.slice(Math.max(0, amount));
  48724. },
  48725. skipLast: function skipLast(amount) {
  48726. return amount === 0 ? this : this.slice(0, -Math.max(0, amount));
  48727. },
  48728. skipWhile: function skipWhile(predicate, context) {
  48729. return reify(this, skipWhileFactory(this, predicate, context, true));
  48730. },
  48731. skipUntil: function skipUntil(predicate, context) {
  48732. return this.skipWhile(not(predicate), context);
  48733. },
  48734. sortBy: function sortBy(mapper, comparator) {
  48735. return reify(this, sortFactory(this, comparator, mapper));
  48736. },
  48737. take: function take(amount) {
  48738. return this.slice(0, Math.max(0, amount));
  48739. },
  48740. takeLast: function takeLast(amount) {
  48741. return this.slice(-Math.max(0, amount));
  48742. },
  48743. takeWhile: function takeWhile(predicate, context) {
  48744. return reify(this, takeWhileFactory(this, predicate, context));
  48745. },
  48746. takeUntil: function takeUntil(predicate, context) {
  48747. return this.takeWhile(not(predicate), context);
  48748. },
  48749. update: function update(fn) {
  48750. return fn(this);
  48751. },
  48752. valueSeq: function valueSeq() {
  48753. return this.toIndexedSeq();
  48754. },
  48755. // ### Hashable Object
  48756. hashCode: function hashCode() {
  48757. return this.__hash || (this.__hash = hashCollection(this));
  48758. }
  48759. // ### Internal
  48760. // abstract __iterate(fn, reverse)
  48761. // abstract __iterator(type, reverse)
  48762. });
  48763. var CollectionPrototype = Collection.prototype;
  48764. CollectionPrototype[IS_COLLECTION_SYMBOL] = true;
  48765. CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values;
  48766. CollectionPrototype.toJSON = CollectionPrototype.toArray;
  48767. CollectionPrototype.__toStringMapper = quoteString;
  48768. CollectionPrototype.inspect = CollectionPrototype.toSource = function() {
  48769. return this.toString();
  48770. };
  48771. CollectionPrototype.chain = CollectionPrototype.flatMap;
  48772. CollectionPrototype.contains = CollectionPrototype.includes;
  48773. mixin(KeyedCollection, {
  48774. // ### More sequential methods
  48775. flip: function flip() {
  48776. return reify(this, flipFactory(this));
  48777. },
  48778. mapEntries: function mapEntries(mapper, context) {
  48779. var this$1 = this;
  48780. var iterations = 0;
  48781. return reify(
  48782. this,
  48783. this.toSeq()
  48784. .map(function(v, k) {
  48785. return mapper.call(context, [k, v], iterations++, this$1);
  48786. })
  48787. .fromEntrySeq()
  48788. );
  48789. },
  48790. mapKeys: function mapKeys(mapper, context) {
  48791. var this$1 = this;
  48792. return reify(
  48793. this,
  48794. this.toSeq()
  48795. .flip()
  48796. .map(function(k, v) {
  48797. return mapper.call(context, k, v, this$1);
  48798. })
  48799. .flip()
  48800. );
  48801. }
  48802. });
  48803. var KeyedCollectionPrototype = KeyedCollection.prototype;
  48804. KeyedCollectionPrototype[IS_KEYED_SYMBOL] = true;
  48805. KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries;
  48806. KeyedCollectionPrototype.toJSON = toObject;
  48807. KeyedCollectionPrototype.__toStringMapper = function(v, k) {
  48808. return quoteString(k) + ": " + quoteString(v);
  48809. };
  48810. mixin(IndexedCollection, {
  48811. // ### Conversion to other types
  48812. toKeyedSeq: function toKeyedSeq() {
  48813. return new ToKeyedSequence(this, false);
  48814. },
  48815. // ### ES6 Collection methods (ES6 Array and Map)
  48816. filter: function filter(predicate, context) {
  48817. return reify(this, filterFactory(this, predicate, context, false));
  48818. },
  48819. findIndex: function findIndex(predicate, context) {
  48820. var entry = this.findEntry(predicate, context);
  48821. return entry ? entry[0] : -1;
  48822. },
  48823. indexOf: function indexOf(searchValue) {
  48824. var key = this.keyOf(searchValue);
  48825. return key === undefined ? -1 : key;
  48826. },
  48827. lastIndexOf: function lastIndexOf(searchValue) {
  48828. var key = this.lastKeyOf(searchValue);
  48829. return key === undefined ? -1 : key;
  48830. },
  48831. reverse: function reverse() {
  48832. return reify(this, reverseFactory(this, false));
  48833. },
  48834. slice: function slice(begin, end) {
  48835. return reify(this, sliceFactory(this, begin, end, false));
  48836. },
  48837. splice: function splice(index, removeNum /*, ...values*/) {
  48838. var numArgs = arguments.length;
  48839. removeNum = Math.max(removeNum || 0, 0);
  48840. if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
  48841. return this;
  48842. }
  48843. // If index is negative, it should resolve relative to the size of the
  48844. // collection. However size may be expensive to compute if not cached, so
  48845. // only call count() if the number is in fact negative.
  48846. index = resolveBegin(index, index < 0 ? this.count() : this.size);
  48847. var spliced = this.slice(0, index);
  48848. return reify(
  48849. this,
  48850. numArgs === 1
  48851. ? spliced
  48852. : spliced.concat(
  48853. arrCopy(arguments, 2),
  48854. this.slice(index + removeNum)
  48855. )
  48856. );
  48857. },
  48858. // ### More collection methods
  48859. findLastIndex: function findLastIndex(predicate, context) {
  48860. var entry = this.findLastEntry(predicate, context);
  48861. return entry ? entry[0] : -1;
  48862. },
  48863. first: function first(notSetValue) {
  48864. return this.get(0, notSetValue);
  48865. },
  48866. flatten: function flatten(depth) {
  48867. return reify(this, flattenFactory(this, depth, false));
  48868. },
  48869. get: function get(index, notSetValue) {
  48870. index = wrapIndex(this, index);
  48871. return index < 0 ||
  48872. this.size === Infinity ||
  48873. (this.size !== undefined && index > this.size)
  48874. ? notSetValue
  48875. : this.find(
  48876. function(_, key) {
  48877. return key === index;
  48878. },
  48879. undefined,
  48880. notSetValue
  48881. );
  48882. },
  48883. has: function has(index) {
  48884. index = wrapIndex(this, index);
  48885. return (
  48886. index >= 0 &&
  48887. (this.size !== undefined
  48888. ? this.size === Infinity || index < this.size
  48889. : this.indexOf(index) !== -1)
  48890. );
  48891. },
  48892. interpose: function interpose(separator) {
  48893. return reify(this, interposeFactory(this, separator));
  48894. },
  48895. interleave: function interleave(/*...collections*/) {
  48896. var collections = [this].concat(arrCopy(arguments));
  48897. var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, collections);
  48898. var interleaved = zipped.flatten(true);
  48899. if (zipped.size) {
  48900. interleaved.size = zipped.size * collections.length;
  48901. }
  48902. return reify(this, interleaved);
  48903. },
  48904. keySeq: function keySeq() {
  48905. return Range(0, this.size);
  48906. },
  48907. last: function last(notSetValue) {
  48908. return this.get(-1, notSetValue);
  48909. },
  48910. skipWhile: function skipWhile(predicate, context) {
  48911. return reify(this, skipWhileFactory(this, predicate, context, false));
  48912. },
  48913. zip: function zip(/*, ...collections */) {
  48914. var collections = [this].concat(arrCopy(arguments));
  48915. return reify(this, zipWithFactory(this, defaultZipper, collections));
  48916. },
  48917. zipAll: function zipAll(/*, ...collections */) {
  48918. var collections = [this].concat(arrCopy(arguments));
  48919. return reify(
  48920. this,
  48921. zipWithFactory(this, defaultZipper, collections, true)
  48922. );
  48923. },
  48924. zipWith: function zipWith(zipper /*, ...collections */) {
  48925. var collections = arrCopy(arguments);
  48926. collections[0] = this;
  48927. return reify(this, zipWithFactory(this, zipper, collections));
  48928. }
  48929. });
  48930. var IndexedCollectionPrototype = IndexedCollection.prototype;
  48931. IndexedCollectionPrototype[IS_INDEXED_SYMBOL] = true;
  48932. IndexedCollectionPrototype[IS_ORDERED_SYMBOL] = true;
  48933. mixin(SetCollection, {
  48934. // ### ES6 Collection methods (ES6 Array and Map)
  48935. get: function get(value, notSetValue) {
  48936. return this.has(value) ? value : notSetValue;
  48937. },
  48938. includes: function includes(value) {
  48939. return this.has(value);
  48940. },
  48941. // ### More sequential methods
  48942. keySeq: function keySeq() {
  48943. return this.valueSeq();
  48944. }
  48945. });
  48946. SetCollection.prototype.has = CollectionPrototype.includes;
  48947. SetCollection.prototype.contains = SetCollection.prototype.includes;
  48948. // Mixin subclasses
  48949. mixin(KeyedSeq, KeyedCollection.prototype);
  48950. mixin(IndexedSeq, IndexedCollection.prototype);
  48951. mixin(SetSeq, SetCollection.prototype);
  48952. // #pragma Helper functions
  48953. function reduce(
  48954. collection,
  48955. reducer,
  48956. reduction,
  48957. context,
  48958. useFirst,
  48959. reverse
  48960. ) {
  48961. assertNotInfinite(collection.size);
  48962. collection.__iterate(function(v, k, c) {
  48963. if (useFirst) {
  48964. useFirst = false;
  48965. reduction = v;
  48966. } else {
  48967. reduction = reducer.call(context, reduction, v, k, c);
  48968. }
  48969. }, reverse);
  48970. return reduction;
  48971. }
  48972. function keyMapper(v, k) {
  48973. return k;
  48974. }
  48975. function entryMapper(v, k) {
  48976. return [k, v];
  48977. }
  48978. function not(predicate) {
  48979. return function() {
  48980. return !predicate.apply(this, arguments);
  48981. };
  48982. }
  48983. function neg(predicate) {
  48984. return function() {
  48985. return -predicate.apply(this, arguments);
  48986. };
  48987. }
  48988. function defaultZipper() {
  48989. return arrCopy(arguments);
  48990. }
  48991. function defaultNegComparator(a, b) {
  48992. return a < b ? 1 : a > b ? -1 : 0;
  48993. }
  48994. function hashCollection(collection) {
  48995. if (collection.size === Infinity) {
  48996. return 0;
  48997. }
  48998. var ordered = isOrdered(collection);
  48999. var keyed = isKeyed(collection);
  49000. var h = ordered ? 1 : 0;
  49001. var size = collection.__iterate(
  49002. keyed
  49003. ? ordered
  49004. ? function(v, k) {
  49005. h = (31 * h + hashMerge(hash(v), hash(k))) | 0;
  49006. }
  49007. : function(v, k) {
  49008. h = (h + hashMerge(hash(v), hash(k))) | 0;
  49009. }
  49010. : ordered
  49011. ? function(v) {
  49012. h = (31 * h + hash(v)) | 0;
  49013. }
  49014. : function(v) {
  49015. h = (h + hash(v)) | 0;
  49016. }
  49017. );
  49018. return murmurHashOfSize(size, h);
  49019. }
  49020. function murmurHashOfSize(size, h) {
  49021. h = imul(h, 0xcc9e2d51);
  49022. h = imul((h << 15) | (h >>> -15), 0x1b873593);
  49023. h = imul((h << 13) | (h >>> -13), 5);
  49024. h = ((h + 0xe6546b64) | 0) ^ size;
  49025. h = imul(h ^ (h >>> 16), 0x85ebca6b);
  49026. h = imul(h ^ (h >>> 13), 0xc2b2ae35);
  49027. h = smi(h ^ (h >>> 16));
  49028. return h;
  49029. }
  49030. function hashMerge(a, b) {
  49031. return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int
  49032. }
  49033. var OrderedSet = /*@__PURE__*/ (function(Set$$1) {
  49034. function OrderedSet(value) {
  49035. return value === null || value === undefined
  49036. ? emptyOrderedSet()
  49037. : isOrderedSet(value)
  49038. ? value
  49039. : emptyOrderedSet().withMutations(function(set) {
  49040. var iter = SetCollection(value);
  49041. assertNotInfinite(iter.size);
  49042. iter.forEach(function(v) {
  49043. return set.add(v);
  49044. });
  49045. });
  49046. }
  49047. if (Set$$1) OrderedSet.__proto__ = Set$$1;
  49048. OrderedSet.prototype = Object.create(Set$$1 && Set$$1.prototype);
  49049. OrderedSet.prototype.constructor = OrderedSet;
  49050. OrderedSet.of = function of(/*...values*/) {
  49051. return this(arguments);
  49052. };
  49053. OrderedSet.fromKeys = function fromKeys(value) {
  49054. return this(KeyedCollection(value).keySeq());
  49055. };
  49056. OrderedSet.prototype.toString = function toString() {
  49057. return this.__toString("OrderedSet {", "}");
  49058. };
  49059. return OrderedSet;
  49060. })(Set);
  49061. OrderedSet.isOrderedSet = isOrderedSet;
  49062. var OrderedSetPrototype = OrderedSet.prototype;
  49063. OrderedSetPrototype[IS_ORDERED_SYMBOL] = true;
  49064. OrderedSetPrototype.zip = IndexedCollectionPrototype.zip;
  49065. OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith;
  49066. OrderedSetPrototype.__empty = emptyOrderedSet;
  49067. OrderedSetPrototype.__make = makeOrderedSet;
  49068. function makeOrderedSet(map, ownerID) {
  49069. var set = Object.create(OrderedSetPrototype);
  49070. set.size = map ? map.size : 0;
  49071. set._map = map;
  49072. set.__ownerID = ownerID;
  49073. return set;
  49074. }
  49075. var EMPTY_ORDERED_SET;
  49076. function emptyOrderedSet() {
  49077. return (
  49078. EMPTY_ORDERED_SET ||
  49079. (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()))
  49080. );
  49081. }
  49082. var Record = function Record(defaultValues, name) {
  49083. var hasInitialized;
  49084. var RecordType = function Record(values) {
  49085. var this$1 = this;
  49086. if (values instanceof RecordType) {
  49087. return values;
  49088. }
  49089. if (!(this instanceof RecordType)) {
  49090. return new RecordType(values);
  49091. }
  49092. if (!hasInitialized) {
  49093. hasInitialized = true;
  49094. var keys = Object.keys(defaultValues);
  49095. var indices = (RecordTypePrototype._indices = {});
  49096. // Deprecated: left to attempt not to break any external code which
  49097. // relies on a ._name property existing on record instances.
  49098. // Use Record.getDescriptiveName() instead
  49099. RecordTypePrototype._name = name;
  49100. RecordTypePrototype._keys = keys;
  49101. RecordTypePrototype._defaultValues = defaultValues;
  49102. for (var i = 0; i < keys.length; i++) {
  49103. var propName = keys[i];
  49104. indices[propName] = i;
  49105. if (RecordTypePrototype[propName]) {
  49106. /* eslint-disable no-console */
  49107. typeof console === "object" &&
  49108. console.warn &&
  49109. console.warn(
  49110. "Cannot define " +
  49111. recordName(this) +
  49112. ' with property "' +
  49113. propName +
  49114. '" since that property name is part of the Record API.'
  49115. );
  49116. /* eslint-enable no-console */
  49117. } else {
  49118. setProp(RecordTypePrototype, propName);
  49119. }
  49120. }
  49121. }
  49122. this.__ownerID = undefined;
  49123. this._values = List().withMutations(function(l) {
  49124. l.setSize(this$1._keys.length);
  49125. KeyedCollection(values).forEach(function(v, k) {
  49126. l.set(
  49127. this$1._indices[k],
  49128. v === this$1._defaultValues[k] ? undefined : v
  49129. );
  49130. });
  49131. });
  49132. };
  49133. var RecordTypePrototype = (RecordType.prototype = Object.create(
  49134. RecordPrototype
  49135. ));
  49136. RecordTypePrototype.constructor = RecordType;
  49137. if (name) {
  49138. RecordType.displayName = name;
  49139. }
  49140. return RecordType;
  49141. };
  49142. Record.prototype.toString = function toString() {
  49143. var str = recordName(this) + " { ";
  49144. var keys = this._keys;
  49145. var k;
  49146. for (var i = 0, l = keys.length; i !== l; i++) {
  49147. k = keys[i];
  49148. str += (i ? ", " : "") + k + ": " + quoteString(this.get(k));
  49149. }
  49150. return str + " }";
  49151. };
  49152. Record.prototype.equals = function equals(other) {
  49153. return (
  49154. this === other ||
  49155. (other &&
  49156. this._keys === other._keys &&
  49157. recordSeq(this).equals(recordSeq(other)))
  49158. );
  49159. };
  49160. Record.prototype.hashCode = function hashCode() {
  49161. return recordSeq(this).hashCode();
  49162. };
  49163. // @pragma Access
  49164. Record.prototype.has = function has(k) {
  49165. return this._indices.hasOwnProperty(k);
  49166. };
  49167. Record.prototype.get = function get(k, notSetValue) {
  49168. if (!this.has(k)) {
  49169. return notSetValue;
  49170. }
  49171. var index = this._indices[k];
  49172. var value = this._values.get(index);
  49173. return value === undefined ? this._defaultValues[k] : value;
  49174. };
  49175. // @pragma Modification
  49176. Record.prototype.set = function set(k, v) {
  49177. if (this.has(k)) {
  49178. var newValues = this._values.set(
  49179. this._indices[k],
  49180. v === this._defaultValues[k] ? undefined : v
  49181. );
  49182. if (newValues !== this._values && !this.__ownerID) {
  49183. return makeRecord(this, newValues);
  49184. }
  49185. }
  49186. return this;
  49187. };
  49188. Record.prototype.remove = function remove(k) {
  49189. return this.set(k);
  49190. };
  49191. Record.prototype.clear = function clear() {
  49192. var newValues = this._values.clear().setSize(this._keys.length);
  49193. return this.__ownerID ? this : makeRecord(this, newValues);
  49194. };
  49195. Record.prototype.wasAltered = function wasAltered() {
  49196. return this._values.wasAltered();
  49197. };
  49198. Record.prototype.toSeq = function toSeq() {
  49199. return recordSeq(this);
  49200. };
  49201. Record.prototype.toJS = function toJS$1() {
  49202. return toJS(this);
  49203. };
  49204. Record.prototype.entries = function entries() {
  49205. return this.__iterator(ITERATE_ENTRIES);
  49206. };
  49207. Record.prototype.__iterator = function __iterator(type, reverse) {
  49208. return recordSeq(this).__iterator(type, reverse);
  49209. };
  49210. Record.prototype.__iterate = function __iterate(fn, reverse) {
  49211. return recordSeq(this).__iterate(fn, reverse);
  49212. };
  49213. Record.prototype.__ensureOwner = function __ensureOwner(ownerID) {
  49214. if (ownerID === this.__ownerID) {
  49215. return this;
  49216. }
  49217. var newValues = this._values.__ensureOwner(ownerID);
  49218. if (!ownerID) {
  49219. this.__ownerID = ownerID;
  49220. this._values = newValues;
  49221. return this;
  49222. }
  49223. return makeRecord(this, newValues, ownerID);
  49224. };
  49225. Record.isRecord = isRecord;
  49226. Record.getDescriptiveName = recordName;
  49227. var RecordPrototype = Record.prototype;
  49228. RecordPrototype[IS_RECORD_SYMBOL] = true;
  49229. RecordPrototype[DELETE] = RecordPrototype.remove;
  49230. RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn;
  49231. RecordPrototype.getIn = getIn$1;
  49232. RecordPrototype.hasIn = CollectionPrototype.hasIn;
  49233. RecordPrototype.merge = merge;
  49234. RecordPrototype.mergeWith = mergeWith;
  49235. RecordPrototype.mergeIn = mergeIn;
  49236. RecordPrototype.mergeDeep = mergeDeep$1;
  49237. RecordPrototype.mergeDeepWith = mergeDeepWith$1;
  49238. RecordPrototype.mergeDeepIn = mergeDeepIn;
  49239. RecordPrototype.setIn = setIn$1;
  49240. RecordPrototype.update = update$1;
  49241. RecordPrototype.updateIn = updateIn$1;
  49242. RecordPrototype.withMutations = withMutations;
  49243. RecordPrototype.asMutable = asMutable;
  49244. RecordPrototype.asImmutable = asImmutable;
  49245. RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries;
  49246. RecordPrototype.toJSON = RecordPrototype.toObject =
  49247. CollectionPrototype.toObject;
  49248. RecordPrototype.inspect = RecordPrototype.toSource = function() {
  49249. return this.toString();
  49250. };
  49251. function makeRecord(likeRecord, values, ownerID) {
  49252. var record = Object.create(Object.getPrototypeOf(likeRecord));
  49253. record._values = values;
  49254. record.__ownerID = ownerID;
  49255. return record;
  49256. }
  49257. function recordName(record) {
  49258. return (
  49259. record.constructor.displayName || record.constructor.name || "Record"
  49260. );
  49261. }
  49262. function recordSeq(record) {
  49263. return keyedSeqFromValue(
  49264. record._keys.map(function(k) {
  49265. return [k, record.get(k)];
  49266. })
  49267. );
  49268. }
  49269. function setProp(prototype, name) {
  49270. try {
  49271. Object.defineProperty(prototype, name, {
  49272. get: function() {
  49273. return this.get(name);
  49274. },
  49275. set: function(value) {
  49276. invariant(this.__ownerID, "Cannot set on an immutable record.");
  49277. this.set(name, value);
  49278. }
  49279. });
  49280. } catch (error) {
  49281. // Object.defineProperty failed. Probably IE8.
  49282. }
  49283. }
  49284. /**
  49285. * Returns a lazy Seq of `value` repeated `times` times. When `times` is
  49286. * undefined, returns an infinite sequence of `value`.
  49287. */
  49288. var Repeat = /*@__PURE__*/ (function(IndexedSeq$$1) {
  49289. function Repeat(value, times) {
  49290. if (!(this instanceof Repeat)) {
  49291. return new Repeat(value, times);
  49292. }
  49293. this._value = value;
  49294. this.size = times === undefined ? Infinity : Math.max(0, times);
  49295. if (this.size === 0) {
  49296. if (EMPTY_REPEAT) {
  49297. return EMPTY_REPEAT;
  49298. }
  49299. EMPTY_REPEAT = this;
  49300. }
  49301. }
  49302. if (IndexedSeq$$1) Repeat.__proto__ = IndexedSeq$$1;
  49303. Repeat.prototype = Object.create(
  49304. IndexedSeq$$1 && IndexedSeq$$1.prototype
  49305. );
  49306. Repeat.prototype.constructor = Repeat;
  49307. Repeat.prototype.toString = function toString() {
  49308. if (this.size === 0) {
  49309. return "Repeat []";
  49310. }
  49311. return "Repeat [ " + this._value + " " + this.size + " times ]";
  49312. };
  49313. Repeat.prototype.get = function get(index, notSetValue) {
  49314. return this.has(index) ? this._value : notSetValue;
  49315. };
  49316. Repeat.prototype.includes = function includes(searchValue) {
  49317. return is(this._value, searchValue);
  49318. };
  49319. Repeat.prototype.slice = function slice(begin, end) {
  49320. var size = this.size;
  49321. return wholeSlice(begin, end, size)
  49322. ? this
  49323. : new Repeat(
  49324. this._value,
  49325. resolveEnd(end, size) - resolveBegin(begin, size)
  49326. );
  49327. };
  49328. Repeat.prototype.reverse = function reverse() {
  49329. return this;
  49330. };
  49331. Repeat.prototype.indexOf = function indexOf(searchValue) {
  49332. if (is(this._value, searchValue)) {
  49333. return 0;
  49334. }
  49335. return -1;
  49336. };
  49337. Repeat.prototype.lastIndexOf = function lastIndexOf(searchValue) {
  49338. if (is(this._value, searchValue)) {
  49339. return this.size;
  49340. }
  49341. return -1;
  49342. };
  49343. Repeat.prototype.__iterate = function __iterate(fn, reverse) {
  49344. var size = this.size;
  49345. var i = 0;
  49346. while (i !== size) {
  49347. if (fn(this._value, reverse ? size - ++i : i++, this) === false) {
  49348. break;
  49349. }
  49350. }
  49351. return i;
  49352. };
  49353. Repeat.prototype.__iterator = function __iterator(type, reverse) {
  49354. var this$1 = this;
  49355. var size = this.size;
  49356. var i = 0;
  49357. return new Iterator(function() {
  49358. return i === size
  49359. ? iteratorDone()
  49360. : iteratorValue(type, reverse ? size - ++i : i++, this$1._value);
  49361. });
  49362. };
  49363. Repeat.prototype.equals = function equals(other) {
  49364. return other instanceof Repeat
  49365. ? is(this._value, other._value)
  49366. : deepEqual(other);
  49367. };
  49368. return Repeat;
  49369. })(IndexedSeq);
  49370. var EMPTY_REPEAT;
  49371. function fromJS(value, converter) {
  49372. return fromJSWith(
  49373. [],
  49374. converter || defaultConverter,
  49375. value,
  49376. "",
  49377. converter && converter.length > 2 ? [] : undefined,
  49378. { "": value }
  49379. );
  49380. }
  49381. function fromJSWith(stack, converter, value, key, keyPath, parentValue) {
  49382. var toSeq = Array.isArray(value)
  49383. ? IndexedSeq
  49384. : isPlainObj(value)
  49385. ? KeyedSeq
  49386. : null;
  49387. if (toSeq) {
  49388. if (~stack.indexOf(value)) {
  49389. throw new TypeError("Cannot convert circular structure to Immutable");
  49390. }
  49391. stack.push(value);
  49392. keyPath && key !== "" && keyPath.push(key);
  49393. var converted = converter.call(
  49394. parentValue,
  49395. key,
  49396. toSeq(value).map(function(v, k) {
  49397. return fromJSWith(stack, converter, v, k, keyPath, value);
  49398. }),
  49399. keyPath && keyPath.slice()
  49400. );
  49401. stack.pop();
  49402. keyPath && keyPath.pop();
  49403. return converted;
  49404. }
  49405. return value;
  49406. }
  49407. function defaultConverter(k, v) {
  49408. return isKeyed(v) ? v.toMap() : v.toList();
  49409. }
  49410. var version = "4.0.0-rc.11";
  49411. var Immutable = {
  49412. version: version,
  49413. Collection: Collection,
  49414. // Note: Iterable is deprecated
  49415. Iterable: Collection,
  49416. Seq: Seq,
  49417. Map: Map,
  49418. OrderedMap: OrderedMap,
  49419. List: List,
  49420. Stack: Stack,
  49421. Set: Set,
  49422. OrderedSet: OrderedSet,
  49423. Record: Record,
  49424. Range: Range,
  49425. Repeat: Repeat,
  49426. is: is,
  49427. fromJS: fromJS,
  49428. hash: hash,
  49429. isImmutable: isImmutable,
  49430. isCollection: isCollection,
  49431. isKeyed: isKeyed,
  49432. isIndexed: isIndexed,
  49433. isAssociative: isAssociative,
  49434. isOrdered: isOrdered,
  49435. isValueObject: isValueObject,
  49436. isSeq: isSeq,
  49437. isList: isList,
  49438. isMap: isMap,
  49439. isOrderedMap: isOrderedMap,
  49440. isStack: isStack,
  49441. isSet: isSet,
  49442. isOrderedSet: isOrderedSet,
  49443. isRecord: isRecord,
  49444. get: get,
  49445. getIn: getIn,
  49446. has: has,
  49447. hasIn: hasIn,
  49448. merge: merge$1,
  49449. mergeDeep: mergeDeep,
  49450. mergeWith: mergeWith$1,
  49451. mergeDeepWith: mergeDeepWith,
  49452. remove: remove,
  49453. removeIn: removeIn,
  49454. set: set,
  49455. setIn: setIn,
  49456. update: update,
  49457. updateIn: updateIn
  49458. };
  49459. // Note: Iterable is deprecated
  49460. var Iterable = Collection;
  49461. exports.default = Immutable;
  49462. exports.version = version;
  49463. exports.Collection = Collection;
  49464. exports.Iterable = Iterable;
  49465. exports.Seq = Seq;
  49466. exports.Map = Map;
  49467. exports.OrderedMap = OrderedMap;
  49468. exports.List = List;
  49469. exports.Stack = Stack;
  49470. exports.Set = Set;
  49471. exports.OrderedSet = OrderedSet;
  49472. exports.Record = Record;
  49473. exports.Range = Range;
  49474. exports.Repeat = Repeat;
  49475. exports.is = is;
  49476. exports.fromJS = fromJS;
  49477. exports.hash = hash;
  49478. exports.isImmutable = isImmutable;
  49479. exports.isCollection = isCollection;
  49480. exports.isKeyed = isKeyed;
  49481. exports.isIndexed = isIndexed;
  49482. exports.isAssociative = isAssociative;
  49483. exports.isOrdered = isOrdered;
  49484. exports.isValueObject = isValueObject;
  49485. exports.get = get;
  49486. exports.getIn = getIn;
  49487. exports.has = has;
  49488. exports.hasIn = hasIn;
  49489. exports.merge = merge$1;
  49490. exports.mergeDeep = mergeDeep;
  49491. exports.mergeWith = mergeWith$1;
  49492. exports.mergeDeepWith = mergeDeepWith;
  49493. exports.remove = remove;
  49494. exports.removeIn = removeIn;
  49495. exports.set = set;
  49496. exports.setIn = setIn;
  49497. exports.update = update;
  49498. exports.updateIn = updateIn;
  49499. Object.defineProperty(exports, "__esModule", { value: true });
  49500. });
  49501. });
  49502. _commonjsHelpers.unwrapExports(immutable$3);
  49503. var draftjsUtils$1 = _commonjsHelpers.createCommonjsModule(function(
  49504. module,
  49505. exports
  49506. ) {
  49507. !(function(t, e) {
  49508. module.exports = e(Draft, immutable$3);
  49509. })(window, function(n, r) {
  49510. return (
  49511. (u = {}),
  49512. (o.m = i = [
  49513. function(t, e) {
  49514. t.exports = n;
  49515. },
  49516. function(t, e) {
  49517. t.exports = r;
  49518. },
  49519. function(t, e, n) {
  49520. t.exports = n(3);
  49521. },
  49522. function(t, e, n) {
  49523. n.r(e);
  49524. var C = n(0),
  49525. i = n(1);
  49526. function m(t) {
  49527. var e = t.getSelection(),
  49528. n = t.getCurrentContent(),
  49529. r = e.getStartKey(),
  49530. o = e.getEndKey(),
  49531. i = n.getBlockMap();
  49532. return i
  49533. .toSeq()
  49534. .skipUntil(function(t, e) {
  49535. return e === r;
  49536. })
  49537. .takeUntil(function(t, e) {
  49538. return e === o;
  49539. })
  49540. .concat([[o, i.get(o)]]);
  49541. }
  49542. function a(t) {
  49543. return m(t).toList();
  49544. }
  49545. function f(t) {
  49546. if (t) return a(t).get(0);
  49547. }
  49548. function r(t) {
  49549. if (t) {
  49550. var n = f(t),
  49551. e = t
  49552. .getCurrentContent()
  49553. .getBlockMap()
  49554. .toSeq()
  49555. .toList(),
  49556. r = 0;
  49557. if (
  49558. (e.forEach(function(t, e) {
  49559. t.get("key") === n.get("key") && (r = e - 1);
  49560. }),
  49561. -1 < r)
  49562. )
  49563. return e.get(r);
  49564. }
  49565. }
  49566. function o(t) {
  49567. return t
  49568. ? t
  49569. .getCurrentContent()
  49570. .getBlockMap()
  49571. .toList()
  49572. : new i.List();
  49573. }
  49574. function u(t) {
  49575. var e = a(t);
  49576. if (
  49577. !e.some(function(t) {
  49578. return t.type !== e.get(0).type;
  49579. })
  49580. )
  49581. return e.get(0).type;
  49582. }
  49583. function c(t) {
  49584. var e = C.RichUtils.tryToRemoveBlockStyle(t);
  49585. return e ? C.EditorState.push(t, e, "change-block-type") : t;
  49586. }
  49587. function l(t) {
  49588. var e = "",
  49589. n = t.getSelection(),
  49590. r = n.getAnchorOffset(),
  49591. o = n.getFocusOffset(),
  49592. i = a(t);
  49593. if (0 < i.size) {
  49594. if (n.getIsBackward()) {
  49595. var u = r;
  49596. (r = o), (o = u);
  49597. }
  49598. for (var c = 0; c < i.size; c += 1) {
  49599. var f = 0 === c ? r : 0,
  49600. l = c === i.size - 1 ? o : i.get(c).getText().length;
  49601. e += i
  49602. .get(c)
  49603. .getText()
  49604. .slice(f, l);
  49605. }
  49606. }
  49607. return e;
  49608. }
  49609. function s(t) {
  49610. var e = t.getCurrentContent(),
  49611. n = t.getSelection(),
  49612. r = C.Modifier.removeRange(e, n, "forward"),
  49613. o = r.getSelectionAfter(),
  49614. i = r.getBlockForKey(o.getStartKey());
  49615. return (
  49616. (r = C.Modifier.insertText(
  49617. r,
  49618. o,
  49619. "\n",
  49620. i.getInlineStyleAt(o.getStartOffset()),
  49621. null
  49622. )),
  49623. C.EditorState.push(t, r, "insert-fragment")
  49624. );
  49625. }
  49626. function g(t) {
  49627. var e = C.Modifier.splitBlock(
  49628. t.getCurrentContent(),
  49629. t.getSelection()
  49630. );
  49631. return c(C.EditorState.push(t, e, "split-block"));
  49632. }
  49633. function d(t) {
  49634. var e = t
  49635. .getCurrentContent()
  49636. .getBlockMap()
  49637. .toList(),
  49638. n = t
  49639. .getSelection()
  49640. .merge({
  49641. anchorKey: e.first().get("key"),
  49642. anchorOffset: 0,
  49643. focusKey: e.last().get("key"),
  49644. focusOffset: e.last().getLength()
  49645. }),
  49646. r = C.Modifier.removeRange(t.getCurrentContent(), n, "forward");
  49647. return C.EditorState.push(t, r, "remove-range");
  49648. }
  49649. function S(t, e) {
  49650. var n = C.Modifier.setBlockData(
  49651. t.getCurrentContent(),
  49652. t.getSelection(),
  49653. e
  49654. );
  49655. return C.EditorState.push(t, n, "change-block-data");
  49656. }
  49657. function p(t) {
  49658. var r = new i.Map({}),
  49659. e = a(t);
  49660. if (e && 0 < e.size)
  49661. for (
  49662. var n = function(t) {
  49663. var n = e.get(t).getData();
  49664. if (!n || 0 === n.size) return (r = r.clear()), "break";
  49665. if (0 === t) r = n;
  49666. else if (
  49667. (r.forEach(function(t, e) {
  49668. (n.get(e) && n.get(e) === t) || (r = r.delete(e));
  49669. }),
  49670. 0 === r.size)
  49671. )
  49672. return (r = r.clear()), "break";
  49673. },
  49674. o = 0;
  49675. o < e.size;
  49676. o += 1
  49677. ) {
  49678. if ("break" === n(o)) break;
  49679. }
  49680. return r;
  49681. }
  49682. var y = Object(i.Map)({ code: { element: "pre" } }),
  49683. v = C.DefaultDraftBlockRenderMap.merge(y);
  49684. function b(t) {
  49685. if (t) {
  49686. var e = t.getType();
  49687. return "unordered-list-item" === e || "ordered-list-item" === e;
  49688. }
  49689. return !1;
  49690. }
  49691. function h(t, e, n) {
  49692. var r,
  49693. o = t.getSelection();
  49694. r = o.getIsBackward() ? o.getFocusKey() : o.getAnchorKey();
  49695. var i = t.getCurrentContent(),
  49696. u = i.getBlockForKey(r),
  49697. c = u.getType();
  49698. if ("unordered-list-item" !== c && "ordered-list-item" !== c)
  49699. return t;
  49700. var f = i.getBlockBefore(r);
  49701. if (!f) return t;
  49702. if (f.getType() !== c) return t;
  49703. var l = u.getDepth();
  49704. if (1 === e && l === n) return t;
  49705. var a,
  49706. s,
  49707. g,
  49708. d,
  49709. S,
  49710. p,
  49711. y,
  49712. v = Math.min(f.getDepth() + 1, n),
  49713. b =
  49714. ((s = e),
  49715. (g = v),
  49716. (d = (a = t).getSelection()),
  49717. (S = a.getCurrentContent()),
  49718. (p = S.getBlockMap()),
  49719. (y = m(a).map(function(t) {
  49720. var e = t.getDepth() + s;
  49721. return (e = Math.max(0, Math.min(e, g))), t.set("depth", e);
  49722. })),
  49723. (p = p.merge(y)),
  49724. S.merge({
  49725. blockMap: p,
  49726. selectionBefore: d,
  49727. selectionAfter: d
  49728. }));
  49729. return C.EditorState.push(t, b, "adjust-depth");
  49730. }
  49731. function O(t, e) {
  49732. var n;
  49733. return 13 === (n = e).which &&
  49734. (n.getModifierState("Shift") ||
  49735. n.getModifierState("Alt") ||
  49736. n.getModifierState("Control"))
  49737. ? t.getSelection().isCollapsed()
  49738. ? C.RichUtils.insertSoftNewline(t)
  49739. : s(t)
  49740. : (function(t) {
  49741. var e = t.getSelection();
  49742. if (e.isCollapsed()) {
  49743. var n = t.getCurrentContent(),
  49744. r = e.getStartKey(),
  49745. o = n.getBlockForKey(r);
  49746. if (
  49747. !b(o) &&
  49748. "unstyled" !== o.getType() &&
  49749. o.getLength() === e.getStartOffset()
  49750. )
  49751. return g(t);
  49752. if (b(o) && 0 === o.getLength()) {
  49753. var i = o.getDepth();
  49754. if (0 === i) return c(t);
  49755. if (0 < i) return h(t, -1, i);
  49756. }
  49757. }
  49758. })(t);
  49759. }
  49760. function k(e, t) {
  49761. var n = Object.keys(e);
  49762. if (Object.getOwnPropertySymbols) {
  49763. var r = Object.getOwnPropertySymbols(e);
  49764. t &&
  49765. (r = r.filter(function(t) {
  49766. return Object.getOwnPropertyDescriptor(e, t).enumerable;
  49767. })),
  49768. n.push.apply(n, r);
  49769. }
  49770. return n;
  49771. }
  49772. function E(t, e, n) {
  49773. return (
  49774. e in t
  49775. ? Object.defineProperty(t, e, {
  49776. value: n,
  49777. enumerable: !0,
  49778. configurable: !0,
  49779. writable: !0
  49780. })
  49781. : (t[e] = n),
  49782. t
  49783. );
  49784. }
  49785. function I(t) {
  49786. return (I =
  49787. "function" == typeof Symbol && "symbol" == typeof Symbol.iterator
  49788. ? function(t) {
  49789. return typeof t;
  49790. }
  49791. : function(t) {
  49792. return t &&
  49793. "function" == typeof Symbol &&
  49794. t.constructor === Symbol &&
  49795. t !== Symbol.prototype
  49796. ? "symbol"
  49797. : typeof t;
  49798. })(t);
  49799. }
  49800. function R(t) {
  49801. var e = t.getSelection();
  49802. if (e.isCollapsed()) {
  49803. var n = {},
  49804. r = t
  49805. .getCurrentInlineStyle()
  49806. .toList()
  49807. .toJS();
  49808. if (r)
  49809. return (
  49810. [
  49811. "BOLD",
  49812. "ITALIC",
  49813. "UNDERLINE",
  49814. "STRIKETHROUGH",
  49815. "CODE",
  49816. "SUPERSCRIPT",
  49817. "SUBSCRIPT"
  49818. ].forEach(function(t) {
  49819. n[t] = 0 <= r.indexOf(t);
  49820. }),
  49821. n
  49822. );
  49823. }
  49824. var u = e.getStartOffset(),
  49825. c = e.getEndOffset(),
  49826. f = a(t);
  49827. if (0 < f.size) {
  49828. var o = (function() {
  49829. for (
  49830. var n = {
  49831. BOLD: !0,
  49832. ITALIC: !0,
  49833. UNDERLINE: !0,
  49834. STRIKETHROUGH: !0,
  49835. CODE: !0,
  49836. SUPERSCRIPT: !0,
  49837. SUBSCRIPT: !0
  49838. },
  49839. r = 0;
  49840. r < f.size;
  49841. r += 1
  49842. ) {
  49843. var t = 0 === r ? u : 0,
  49844. e = r === f.size - 1 ? c : f.get(r).getText().length;
  49845. t === e && 0 === t ? ((t = 1), (e = 2)) : t === e && --t;
  49846. for (
  49847. var o = function(t) {
  49848. var e = f.get(r).getInlineStyleAt(t);
  49849. [
  49850. "BOLD",
  49851. "ITALIC",
  49852. "UNDERLINE",
  49853. "STRIKETHROUGH",
  49854. "CODE",
  49855. "SUPERSCRIPT",
  49856. "SUBSCRIPT"
  49857. ].forEach(function(t) {
  49858. n[t] = n[t] && e.get(t) === t;
  49859. });
  49860. },
  49861. i = t;
  49862. i < e;
  49863. i += 1
  49864. )
  49865. o(i);
  49866. }
  49867. return { v: n };
  49868. })();
  49869. if ("object" === I(o)) return o.v;
  49870. }
  49871. return {};
  49872. }
  49873. function B(t) {
  49874. var e,
  49875. n = t.getSelection(),
  49876. r = n.getStartOffset(),
  49877. o = n.getEndOffset();
  49878. r === o && 0 === r ? (o = 1) : r === o && --r;
  49879. for (var i = f(t), u = r; u < o; u += 1) {
  49880. var c = i.getEntityAt(u);
  49881. if (!c) {
  49882. e = void 0;
  49883. break;
  49884. }
  49885. if (u === r) e = c;
  49886. else if (e !== c) {
  49887. e = void 0;
  49888. break;
  49889. }
  49890. }
  49891. return e;
  49892. }
  49893. function T(t, e) {
  49894. var n,
  49895. r = f(t);
  49896. return (
  49897. r.findEntityRanges(
  49898. function(t) {
  49899. return t.get("entity") === e;
  49900. },
  49901. function(t, e) {
  49902. n = { start: t, end: e, text: r.get("text").slice(t, e) };
  49903. }
  49904. ),
  49905. n
  49906. );
  49907. }
  49908. function P(t, e, n) {
  49909. x[t]["".concat(t.toLowerCase(), "-").concat(n)] = E(
  49910. {},
  49911. "".concat(e),
  49912. n
  49913. );
  49914. }
  49915. function j() {
  49916. return (function(e) {
  49917. for (var t = 1; t < arguments.length; t++) {
  49918. var n = null != arguments[t] ? arguments[t] : {};
  49919. t % 2
  49920. ? k(Object(n), !0).forEach(function(t) {
  49921. E(e, t, n[t]);
  49922. })
  49923. : Object.getOwnPropertyDescriptors
  49924. ? Object.defineProperties(
  49925. e,
  49926. Object.getOwnPropertyDescriptors(n)
  49927. )
  49928. : k(Object(n)).forEach(function(t) {
  49929. Object.defineProperty(
  49930. e,
  49931. t,
  49932. Object.getOwnPropertyDescriptor(n, t)
  49933. );
  49934. });
  49935. }
  49936. return e;
  49937. })({}, x.color, {}, x.bgcolor, {}, x.fontSize, {}, x.fontFamily, {
  49938. CODE: x.CODE,
  49939. SUPERSCRIPT: x.SUPERSCRIPT,
  49940. SUBSCRIPT: x.SUBSCRIPT
  49941. });
  49942. }
  49943. var x = {
  49944. color: {},
  49945. bgcolor: {},
  49946. fontSize: {},
  49947. fontFamily: {},
  49948. CODE: {
  49949. fontFamily: "monospace",
  49950. wordWrap: "break-word",
  49951. background: "#f1f1f1",
  49952. borderRadius: 3,
  49953. padding: "1px 3px"
  49954. },
  49955. SUPERSCRIPT: {
  49956. fontSize: 11,
  49957. position: "relative",
  49958. top: -8,
  49959. display: "inline-flex"
  49960. },
  49961. SUBSCRIPT: {
  49962. fontSize: 11,
  49963. position: "relative",
  49964. bottom: -8,
  49965. display: "inline-flex"
  49966. }
  49967. };
  49968. function M(t, e, n) {
  49969. var r = t.getSelection(),
  49970. o = Object.keys(x[e]).reduce(function(t, e) {
  49971. return C.Modifier.removeInlineStyle(t, r, e);
  49972. }, t.getCurrentContent()),
  49973. i = C.EditorState.push(t, o, "changeinline-style"),
  49974. u = t.getCurrentInlineStyle();
  49975. if (
  49976. (r.isCollapsed() &&
  49977. (i = u.reduce(function(t, e) {
  49978. return C.RichUtils.toggleInlineStyle(t, e);
  49979. }, i)),
  49980. "SUPERSCRIPT" === e || "SUBSCRIPT" == e)
  49981. )
  49982. u.has(n) || (i = C.RichUtils.toggleInlineStyle(i, n));
  49983. else {
  49984. var c = "bgcolor" === e ? "backgroundColor" : e;
  49985. u.has("".concat(c, "-").concat(n)) ||
  49986. ((i = C.RichUtils.toggleInlineStyle(
  49987. i,
  49988. "".concat(e.toLowerCase(), "-").concat(n)
  49989. )),
  49990. P(e, c, n));
  49991. }
  49992. return i;
  49993. }
  49994. function L(t) {
  49995. t &&
  49996. t
  49997. .getCurrentContent()
  49998. .getBlockMap()
  49999. .map(function(t) {
  50000. return t.get("characterList");
  50001. })
  50002. .toList()
  50003. .flatten()
  50004. .forEach(function(t) {
  50005. t && 0 === t.indexOf("color-")
  50006. ? P("color", "color", t.substr(6))
  50007. : t && 0 === t.indexOf("bgcolor-")
  50008. ? P("bgcolor", "backgroundColor", t.substr(8))
  50009. : t && 0 === t.indexOf("fontsize-")
  50010. ? P("fontSize", "fontSize", +t.substr(9))
  50011. : t &&
  50012. 0 === t.indexOf("fontfamily-") &&
  50013. P("fontFamily", "fontFamily", t.substr(11));
  50014. });
  50015. }
  50016. function U(t, e, n) {
  50017. var r = t
  50018. .getInlineStyleAt(n)
  50019. .toList()
  50020. .filter(function(t) {
  50021. return t.startsWith(e.toLowerCase());
  50022. });
  50023. if (r && 0 < r.size) return r.get(0);
  50024. }
  50025. function w(r, l) {
  50026. if (r && l && 0 < l.length) {
  50027. var t = (function() {
  50028. var t = r.getSelection(),
  50029. i = {};
  50030. if (t.isCollapsed())
  50031. return (
  50032. l.forEach(function(t) {
  50033. i[t] = (function(t, e) {
  50034. var n = t
  50035. .getCurrentInlineStyle()
  50036. .toList()
  50037. .filter(function(t) {
  50038. return t.startsWith(e.toLowerCase());
  50039. });
  50040. if (n && 0 < n.size) return n.get(0);
  50041. })(r, t);
  50042. }),
  50043. { v: i }
  50044. );
  50045. var u = t.getStartOffset(),
  50046. c = t.getEndOffset(),
  50047. f = a(r);
  50048. if (0 < f.size) {
  50049. for (
  50050. var e = function(n) {
  50051. var t = 0 === n ? u : 0,
  50052. e = n === f.size - 1 ? c : f.get(n).getText().length;
  50053. t === e && 0 === t
  50054. ? ((t = 1), (e = 2))
  50055. : t === e && --t;
  50056. for (
  50057. var r = function(e) {
  50058. e === t
  50059. ? l.forEach(function(t) {
  50060. i[t] = U(f.get(n), t, e);
  50061. })
  50062. : l.forEach(function(t) {
  50063. i[t] &&
  50064. i[t] !== U(f.get(n), t, e) &&
  50065. (i[t] = void 0);
  50066. });
  50067. },
  50068. o = t;
  50069. o < e;
  50070. o += 1
  50071. )
  50072. r(o);
  50073. },
  50074. n = 0;
  50075. n < f.size;
  50076. n += 1
  50077. )
  50078. e(n);
  50079. return { v: i };
  50080. }
  50081. })();
  50082. if ("object" === I(t)) return t.v;
  50083. }
  50084. return {};
  50085. }
  50086. function D(e) {
  50087. var t = e.getCurrentInlineStyle(),
  50088. n = e.getCurrentContent();
  50089. return (
  50090. t.forEach(function(t) {
  50091. n = C.Modifier.removeInlineStyle(n, e.getSelection(), t);
  50092. }),
  50093. C.EditorState.push(e, n, "change-inline-style")
  50094. );
  50095. }
  50096. n.d(e, "isListBlock", function() {
  50097. return b;
  50098. }),
  50099. n.d(e, "changeDepth", function() {
  50100. return h;
  50101. }),
  50102. n.d(e, "handleNewLine", function() {
  50103. return O;
  50104. }),
  50105. n.d(e, "getEntityRange", function() {
  50106. return T;
  50107. }),
  50108. n.d(e, "getCustomStyleMap", function() {
  50109. return j;
  50110. }),
  50111. n.d(e, "toggleCustomInlineStyle", function() {
  50112. return M;
  50113. }),
  50114. n.d(e, "getSelectionEntity", function() {
  50115. return B;
  50116. }),
  50117. n.d(e, "extractInlineStyle", function() {
  50118. return L;
  50119. }),
  50120. n.d(e, "removeAllInlineStyles", function() {
  50121. return D;
  50122. }),
  50123. n.d(e, "getSelectionInlineStyle", function() {
  50124. return R;
  50125. }),
  50126. n.d(e, "getSelectionCustomInlineStyle", function() {
  50127. return w;
  50128. }),
  50129. n.d(e, "getSelectedBlocksMap", function() {
  50130. return m;
  50131. }),
  50132. n.d(e, "getSelectedBlocksList", function() {
  50133. return a;
  50134. }),
  50135. n.d(e, "getSelectedBlock", function() {
  50136. return f;
  50137. }),
  50138. n.d(e, "getBlockBeforeSelectedBlock", function() {
  50139. return r;
  50140. }),
  50141. n.d(e, "getAllBlocks", function() {
  50142. return o;
  50143. }),
  50144. n.d(e, "getSelectedBlocksType", function() {
  50145. return u;
  50146. }),
  50147. n.d(e, "removeSelectedBlocksStyle", function() {
  50148. return c;
  50149. }),
  50150. n.d(e, "getSelectionText", function() {
  50151. return l;
  50152. }),
  50153. n.d(e, "addLineBreakRemovingSelection", function() {
  50154. return s;
  50155. }),
  50156. n.d(e, "insertNewUnstyledBlock", function() {
  50157. return g;
  50158. }),
  50159. n.d(e, "clearEditorContent", function() {
  50160. return d;
  50161. }),
  50162. n.d(e, "setBlockData", function() {
  50163. return S;
  50164. }),
  50165. n.d(e, "getSelectedBlocksMetadata", function() {
  50166. return p;
  50167. }),
  50168. n.d(e, "blockRenderMap", function() {
  50169. return v;
  50170. });
  50171. }
  50172. ]),
  50173. (o.c = u),
  50174. (o.d = function(t, e, n) {
  50175. o.o(t, e) || Object.defineProperty(t, e, { enumerable: !0, get: n });
  50176. }),
  50177. (o.r = function(t) {
  50178. "undefined" != typeof Symbol &&
  50179. Symbol.toStringTag &&
  50180. Object.defineProperty(t, Symbol.toStringTag, { value: "Module" }),
  50181. Object.defineProperty(t, "__esModule", { value: !0 });
  50182. }),
  50183. (o.t = function(e, t) {
  50184. if ((1 & t && (e = o(e)), 8 & t)) return e;
  50185. if (4 & t && "object" == typeof e && e && e.__esModule) return e;
  50186. var n = Object.create(null);
  50187. if (
  50188. (o.r(n),
  50189. Object.defineProperty(n, "default", { enumerable: !0, value: e }),
  50190. 2 & t && "string" != typeof e)
  50191. )
  50192. for (var r in e)
  50193. o.d(
  50194. n,
  50195. r,
  50196. function(t) {
  50197. return e[t];
  50198. }.bind(null, r)
  50199. );
  50200. return n;
  50201. }),
  50202. (o.n = function(t) {
  50203. var e =
  50204. t && t.__esModule
  50205. ? function() {
  50206. return t.default;
  50207. }
  50208. : function() {
  50209. return t;
  50210. };
  50211. return o.d(e, "a", e), e;
  50212. }),
  50213. (o.o = function(t, e) {
  50214. return Object.prototype.hasOwnProperty.call(t, e);
  50215. }),
  50216. (o.p = ""),
  50217. o((o.s = 2))
  50218. );
  50219. function o(t) {
  50220. if (u[t]) return u[t].exports;
  50221. var e = (u[t] = { i: t, l: !1, exports: {} });
  50222. return i[t].call(e.exports, e, e.exports, o), (e.l = !0), e.exports;
  50223. }
  50224. var i, u;
  50225. });
  50226. });
  50227. _commonjsHelpers.unwrapExports(draftjsUtils$1);
  50228. var draftjsUtils_1$1 = draftjsUtils$1.draftjsUtils;
  50229. var content$1 = _commonjsHelpers.createCommonjsModule(function(
  50230. module,
  50231. exports
  50232. ) {
  50233. Object.defineProperty(exports, "__esModule", {
  50234. value: true
  50235. });
  50236. 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;
  50237. var _immutable2 = _interopRequireDefault(immutable$3);
  50238. function _interopRequireDefault(obj) {
  50239. return obj && obj.__esModule ? obj : { default: obj };
  50240. }
  50241. var strictBlockTypes = ["atomic"];
  50242. var registerStrictBlockType = (exports.registerStrictBlockType = function registerStrictBlockType(
  50243. blockType
  50244. ) {
  50245. strictBlockTypes.indexOf(blockType) === -1 &&
  50246. strictBlockTypes.push(blockType);
  50247. });
  50248. var isEditorState = (exports.isEditorState = function isEditorState(
  50249. editorState
  50250. ) {
  50251. return editorState instanceof Draft.EditorState;
  50252. });
  50253. var createEmptyEditorState = (exports.createEmptyEditorState = function createEmptyEditorState(
  50254. editorDecorators
  50255. ) {
  50256. return Draft.EditorState.createEmpty(editorDecorators);
  50257. });
  50258. var createEditorState = (exports.createEditorState = function createEditorState(
  50259. contentState,
  50260. editorDecorators
  50261. ) {
  50262. return Draft.EditorState.createWithContent(contentState, editorDecorators);
  50263. });
  50264. var isSelectionCollapsed = (exports.isSelectionCollapsed = function isSelectionCollapsed(
  50265. editorState
  50266. ) {
  50267. return editorState.getSelection().isCollapsed();
  50268. });
  50269. var selectionContainsBlockType = (exports.selectionContainsBlockType = function selectionContainsBlockType(
  50270. editorState,
  50271. blockType
  50272. ) {
  50273. return getSelectedBlocks(editorState).find(function(block) {
  50274. return block.getType() === blockType;
  50275. });
  50276. });
  50277. var selectionContainsStrictBlock = (exports.selectionContainsStrictBlock = function selectionContainsStrictBlock(
  50278. editorState
  50279. ) {
  50280. return getSelectedBlocks(editorState).find(function(block) {
  50281. return ~strictBlockTypes.indexOf(block.getType());
  50282. });
  50283. });
  50284. var selectBlock = (exports.selectBlock = function selectBlock(
  50285. editorState,
  50286. block
  50287. ) {
  50288. var blockKey = block.getKey();
  50289. return Draft.EditorState.forceSelection(
  50290. editorState,
  50291. new Draft.SelectionState({
  50292. anchorKey: blockKey,
  50293. anchorOffset: 0,
  50294. focusKey: blockKey,
  50295. focusOffset: block.getLength()
  50296. })
  50297. );
  50298. });
  50299. var selectNextBlock = (exports.selectNextBlock = function selectNextBlock(
  50300. editorState,
  50301. block
  50302. ) {
  50303. var nextBlock = editorState
  50304. .getCurrentContent()
  50305. .getBlockAfter(block.getKey());
  50306. return nextBlock ? selectBlock(editorState, nextBlock) : editorState;
  50307. });
  50308. var removeBlock = (exports.removeBlock = function removeBlock(
  50309. editorState,
  50310. block
  50311. ) {
  50312. var lastSelection =
  50313. arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  50314. var nextContentState = void 0,
  50315. nextEditorState = void 0;
  50316. var blockKey = block.getKey();
  50317. nextContentState = Draft.Modifier.removeRange(
  50318. editorState.getCurrentContent(),
  50319. new Draft.SelectionState({
  50320. anchorKey: blockKey,
  50321. anchorOffset: 0,
  50322. focusKey: blockKey,
  50323. focusOffset: block.getLength()
  50324. }),
  50325. "backward"
  50326. );
  50327. nextContentState = Draft.Modifier.setBlockType(
  50328. nextContentState,
  50329. nextContentState.getSelectionAfter(),
  50330. "unstyled"
  50331. );
  50332. nextEditorState = Draft.EditorState.push(
  50333. editorState,
  50334. nextContentState,
  50335. "remove-range"
  50336. );
  50337. return Draft.EditorState.forceSelection(
  50338. nextEditorState,
  50339. lastSelection || nextContentState.getSelectionAfter()
  50340. );
  50341. });
  50342. var getSelectionBlock = (exports.getSelectionBlock = function getSelectionBlock(
  50343. editorState
  50344. ) {
  50345. return editorState
  50346. .getCurrentContent()
  50347. .getBlockForKey(editorState.getSelection().getAnchorKey());
  50348. });
  50349. var updateEachCharacterOfSelection = (exports.updateEachCharacterOfSelection = function updateEachCharacterOfSelection(
  50350. editorState,
  50351. callback
  50352. ) {
  50353. var selectionState = editorState.getSelection();
  50354. var contentState = editorState.getCurrentContent();
  50355. var contentBlocks = contentState.getBlockMap();
  50356. var selectedBlocks = getSelectedBlocks(editorState);
  50357. if (selectedBlocks.length === 0) {
  50358. return editorState;
  50359. }
  50360. var startKey = selectionState.getStartKey();
  50361. var startOffset = selectionState.getStartOffset();
  50362. var endKey = selectionState.getEndKey();
  50363. var endOffset = selectionState.getEndOffset();
  50364. var nextContentBlocks = contentBlocks.map(function(block) {
  50365. if (selectedBlocks.indexOf(block) === -1) {
  50366. return block;
  50367. }
  50368. var blockKey = block.getKey();
  50369. var charactersList = block.getCharacterList();
  50370. var nextCharactersList = null;
  50371. if (blockKey === startKey && blockKey === endKey) {
  50372. nextCharactersList = charactersList.map(function(character, index) {
  50373. if (index >= startOffset && index < endOffset) {
  50374. return callback(character);
  50375. }
  50376. return character;
  50377. });
  50378. } else if (blockKey === startKey) {
  50379. nextCharactersList = charactersList.map(function(character, index) {
  50380. if (index >= startOffset) {
  50381. return callback(character);
  50382. }
  50383. return character;
  50384. });
  50385. } else if (blockKey === endKey) {
  50386. nextCharactersList = charactersList.map(function(character, index) {
  50387. if (index < endOffset) {
  50388. return callback(character);
  50389. }
  50390. return character;
  50391. });
  50392. } else {
  50393. nextCharactersList = charactersList.map(function(character) {
  50394. return callback(character);
  50395. });
  50396. }
  50397. return block.merge({
  50398. characterList: nextCharactersList
  50399. });
  50400. });
  50401. return Draft.EditorState.push(
  50402. editorState,
  50403. contentState.merge({
  50404. blockMap: nextContentBlocks,
  50405. selectionBefore: selectionState,
  50406. selectionAfter: selectionState
  50407. }),
  50408. "update-selection-character-list"
  50409. );
  50410. });
  50411. var getSelectedBlocks = (exports.getSelectedBlocks = function getSelectedBlocks(
  50412. editorState
  50413. ) {
  50414. var selectionState = editorState.getSelection();
  50415. var contentState = editorState.getCurrentContent();
  50416. var startKey = selectionState.getStartKey();
  50417. var endKey = selectionState.getEndKey();
  50418. var isSameBlock = startKey === endKey;
  50419. var startingBlock = contentState.getBlockForKey(startKey);
  50420. var selectedBlocks = [startingBlock];
  50421. if (!isSameBlock) {
  50422. var blockKey = startKey;
  50423. while (blockKey !== endKey) {
  50424. var nextBlock = contentState.getBlockAfter(blockKey);
  50425. selectedBlocks.push(nextBlock);
  50426. blockKey = nextBlock.getKey();
  50427. }
  50428. }
  50429. return selectedBlocks;
  50430. });
  50431. var setSelectionBlockData = (exports.setSelectionBlockData = function setSelectionBlockData(
  50432. editorState,
  50433. blockData,
  50434. override
  50435. ) {
  50436. var newBlockData = override
  50437. ? blockData
  50438. : Object.assign({}, getSelectionBlockData(editorState).toJS(), blockData);
  50439. Object.keys(newBlockData).forEach(function(key) {
  50440. if (newBlockData.hasOwnProperty(key) && newBlockData[key] === undefined) {
  50441. delete newBlockData[key];
  50442. }
  50443. });
  50444. return (0, draftjsUtils$1.setBlockData)(editorState, newBlockData);
  50445. });
  50446. var getSelectionBlockData = (exports.getSelectionBlockData = function getSelectionBlockData(
  50447. editorState,
  50448. name
  50449. ) {
  50450. var blockData = getSelectionBlock(editorState).getData();
  50451. return name ? blockData.get(name) : blockData;
  50452. });
  50453. var getSelectionBlockType = (exports.getSelectionBlockType = function getSelectionBlockType(
  50454. editorState
  50455. ) {
  50456. return getSelectionBlock(editorState).getType();
  50457. });
  50458. var getSelectionText = (exports.getSelectionText = function getSelectionText(
  50459. editorState
  50460. ) {
  50461. var selectionState = editorState.getSelection();
  50462. var contentState = editorState.getCurrentContent();
  50463. if (
  50464. selectionState.isCollapsed() ||
  50465. getSelectionBlockType(editorState) === "atomic"
  50466. ) {
  50467. return "";
  50468. }
  50469. var anchorKey = selectionState.getAnchorKey();
  50470. var currentContentBlock = contentState.getBlockForKey(anchorKey);
  50471. var start = selectionState.getStartOffset();
  50472. var end = selectionState.getEndOffset();
  50473. return currentContentBlock.getText().slice(start, end);
  50474. });
  50475. var toggleSelectionBlockType = (exports.toggleSelectionBlockType = function toggleSelectionBlockType(
  50476. editorState,
  50477. blockType
  50478. ) {
  50479. if (selectionContainsStrictBlock(editorState)) {
  50480. return editorState;
  50481. }
  50482. return Draft.RichUtils.toggleBlockType(editorState, blockType);
  50483. });
  50484. var getSelectionEntityType = (exports.getSelectionEntityType = function getSelectionEntityType(
  50485. editorState
  50486. ) {
  50487. var entityKey = (0, draftjsUtils$1.getSelectionEntity)(editorState);
  50488. if (entityKey) {
  50489. var entity = editorState.getCurrentContent().getEntity(entityKey);
  50490. return entity ? entity.get("type") : null;
  50491. }
  50492. return null;
  50493. });
  50494. var getSelectionEntityData = (exports.getSelectionEntityData = function getSelectionEntityData(
  50495. editorState,
  50496. type
  50497. ) {
  50498. var entityKey = (0, draftjsUtils$1.getSelectionEntity)(editorState);
  50499. if (entityKey) {
  50500. var entity = editorState.getCurrentContent().getEntity(entityKey);
  50501. if (entity && entity.get("type") === type) {
  50502. return entity.getData();
  50503. } else {
  50504. return {};
  50505. }
  50506. } else {
  50507. return {};
  50508. }
  50509. });
  50510. var toggleSelectionEntity = (exports.toggleSelectionEntity = function toggleSelectionEntity(
  50511. editorState,
  50512. entity
  50513. ) {
  50514. var contentState = editorState.getCurrentContent();
  50515. var selectionState = editorState.getSelection();
  50516. if (
  50517. selectionState.isCollapsed() ||
  50518. getSelectionBlockType(editorState) === "atomic"
  50519. ) {
  50520. return editorState;
  50521. }
  50522. if (
  50523. !entity ||
  50524. !entity.type ||
  50525. getSelectionEntityType(editorState) === entity.type
  50526. ) {
  50527. return Draft.EditorState.push(
  50528. editorState,
  50529. Draft.Modifier.applyEntity(contentState, selectionState, null),
  50530. "apply-entity"
  50531. );
  50532. }
  50533. try {
  50534. var nextContentState = contentState.createEntity(
  50535. entity.type,
  50536. entity.mutability,
  50537. entity.data
  50538. );
  50539. var entityKey = nextContentState.getLastCreatedEntityKey();
  50540. var nextEditorState = Draft.EditorState.set(editorState, {
  50541. currentContent: nextContentState
  50542. });
  50543. return Draft.EditorState.push(
  50544. nextEditorState,
  50545. Draft.Modifier.applyEntity(nextContentState, selectionState, entityKey),
  50546. "apply-entity"
  50547. );
  50548. } catch (error) {
  50549. console.warn(error);
  50550. return editorState;
  50551. }
  50552. });
  50553. var toggleSelectionLink = (exports.toggleSelectionLink = function toggleSelectionLink(
  50554. editorState,
  50555. href,
  50556. target
  50557. ) {
  50558. var contentState = editorState.getCurrentContent();
  50559. var selectionState = editorState.getSelection();
  50560. var entityData = { href: href, target: target };
  50561. if (
  50562. selectionState.isCollapsed() ||
  50563. getSelectionBlockType(editorState) === "atomic"
  50564. ) {
  50565. return editorState;
  50566. }
  50567. if (href === false) {
  50568. return Draft.RichUtils.toggleLink(editorState, selectionState, null);
  50569. }
  50570. if (href === null) {
  50571. delete entityData.href;
  50572. }
  50573. try {
  50574. var nextContentState = contentState.createEntity(
  50575. "LINK",
  50576. "MUTABLE",
  50577. entityData
  50578. );
  50579. var entityKey = nextContentState.getLastCreatedEntityKey();
  50580. var nextEditorState = Draft.EditorState.set(editorState, {
  50581. currentContent: nextContentState
  50582. });
  50583. nextEditorState = Draft.RichUtils.toggleLink(
  50584. nextEditorState,
  50585. selectionState,
  50586. entityKey
  50587. );
  50588. nextEditorState = Draft.EditorState.forceSelection(
  50589. nextEditorState,
  50590. selectionState.merge({
  50591. anchorOffset: selectionState.getEndOffset(),
  50592. focusOffset: selectionState.getEndOffset()
  50593. })
  50594. );
  50595. nextEditorState = Draft.EditorState.push(
  50596. nextEditorState,
  50597. Draft.Modifier.insertText(
  50598. nextEditorState.getCurrentContent(),
  50599. nextEditorState.getSelection(),
  50600. ""
  50601. ),
  50602. "insert-text"
  50603. );
  50604. return nextEditorState;
  50605. } catch (error) {
  50606. console.warn(error);
  50607. return editorState;
  50608. }
  50609. });
  50610. var getSelectionInlineStyle = (exports.getSelectionInlineStyle = function getSelectionInlineStyle(
  50611. editorState
  50612. ) {
  50613. return editorState.getCurrentInlineStyle();
  50614. });
  50615. var selectionHasInlineStyle = (exports.selectionHasInlineStyle = function selectionHasInlineStyle(
  50616. editorState,
  50617. style
  50618. ) {
  50619. return getSelectionInlineStyle(editorState).has(style.toUpperCase());
  50620. });
  50621. var toggleSelectionInlineStyle = (exports.toggleSelectionInlineStyle = function toggleSelectionInlineStyle(
  50622. editorState,
  50623. style
  50624. ) {
  50625. var prefix =
  50626. arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
  50627. var nextEditorState = editorState;
  50628. style = prefix + style.toUpperCase();
  50629. if (prefix) {
  50630. nextEditorState = updateEachCharacterOfSelection(
  50631. nextEditorState,
  50632. function(characterMetadata) {
  50633. return characterMetadata
  50634. .toJS()
  50635. .style.reduce(function(characterMetadata, characterStyle) {
  50636. if (
  50637. characterStyle.indexOf(prefix) === 0 &&
  50638. style !== characterStyle
  50639. ) {
  50640. return Draft.CharacterMetadata.removeStyle(
  50641. characterMetadata,
  50642. characterStyle
  50643. );
  50644. } else {
  50645. return characterMetadata;
  50646. }
  50647. }, characterMetadata);
  50648. }
  50649. );
  50650. }
  50651. return Draft.RichUtils.toggleInlineStyle(nextEditorState, style);
  50652. });
  50653. var removeSelectionInlineStyles = (exports.removeSelectionInlineStyles = function removeSelectionInlineStyles(
  50654. editorState
  50655. ) {
  50656. return updateEachCharacterOfSelection(editorState, function(
  50657. characterMetadata
  50658. ) {
  50659. return characterMetadata.merge({
  50660. style: _immutable2.default.OrderedSet([])
  50661. });
  50662. });
  50663. });
  50664. var toggleSelectionAlignment = (exports.toggleSelectionAlignment = function toggleSelectionAlignment(
  50665. editorState,
  50666. alignment
  50667. ) {
  50668. return setSelectionBlockData(editorState, {
  50669. textAlign:
  50670. getSelectionBlockData(editorState, "textAlign") !== alignment
  50671. ? alignment
  50672. : undefined
  50673. });
  50674. });
  50675. var toggleSelectionIndent = (exports.toggleSelectionIndent = function toggleSelectionIndent(
  50676. editorState,
  50677. textIndent
  50678. ) {
  50679. var maxIndent =
  50680. arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 6;
  50681. return textIndent < 0 || textIndent > maxIndent || isNaN(textIndent)
  50682. ? editorState
  50683. : setSelectionBlockData(editorState, {
  50684. textIndent: textIndent || undefined
  50685. });
  50686. });
  50687. var increaseSelectionIndent = (exports.increaseSelectionIndent = function increaseSelectionIndent(
  50688. editorState
  50689. ) {
  50690. var maxIndent =
  50691. arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
  50692. var currentIndent = getSelectionBlockData(editorState, "textIndent") || 0;
  50693. return toggleSelectionIndent(editorState, currentIndent + 1, maxIndent);
  50694. });
  50695. var decreaseSelectionIndent = (exports.decreaseSelectionIndent = function decreaseSelectionIndent(
  50696. editorState
  50697. ) {
  50698. var currentIndent = getSelectionBlockData(editorState, "textIndent") || 0;
  50699. return toggleSelectionIndent(editorState, currentIndent - 1);
  50700. });
  50701. var toggleSelectionColor = (exports.toggleSelectionColor = function toggleSelectionColor(
  50702. editorState,
  50703. color
  50704. ) {
  50705. return toggleSelectionInlineStyle(
  50706. editorState,
  50707. color.replace("#", ""),
  50708. "COLOR-"
  50709. );
  50710. });
  50711. var toggleSelectionBackgroundColor = (exports.toggleSelectionBackgroundColor = function toggleSelectionBackgroundColor(
  50712. editorState,
  50713. color
  50714. ) {
  50715. return toggleSelectionInlineStyle(
  50716. editorState,
  50717. color.replace("#", ""),
  50718. "BGCOLOR-"
  50719. );
  50720. });
  50721. var toggleSelectionFontSize = (exports.toggleSelectionFontSize = function toggleSelectionFontSize(
  50722. editorState,
  50723. fontSize
  50724. ) {
  50725. return toggleSelectionInlineStyle(editorState, fontSize, "FONTSIZE-");
  50726. });
  50727. var toggleSelectionLineHeight = (exports.toggleSelectionLineHeight = function toggleSelectionLineHeight(
  50728. editorState,
  50729. lineHeight
  50730. ) {
  50731. return toggleSelectionInlineStyle(editorState, lineHeight, "LINEHEIGHT-");
  50732. });
  50733. var toggleSelectionFontFamily = (exports.toggleSelectionFontFamily = function toggleSelectionFontFamily(
  50734. editorState,
  50735. fontFamily
  50736. ) {
  50737. return toggleSelectionInlineStyle(editorState, fontFamily, "FONTFAMILY-");
  50738. });
  50739. var toggleSelectionLetterSpacing = (exports.toggleSelectionLetterSpacing = function toggleSelectionLetterSpacing(
  50740. editorState,
  50741. letterSpacing
  50742. ) {
  50743. return toggleSelectionInlineStyle(
  50744. editorState,
  50745. letterSpacing,
  50746. "LETTERSPACING-"
  50747. );
  50748. });
  50749. var insertText = (exports.insertText = function insertText(
  50750. editorState,
  50751. text,
  50752. inlineStyle,
  50753. entity
  50754. ) {
  50755. var selectionState = editorState.getSelection();
  50756. var currentSelectedBlockType = getSelectionBlockType(editorState);
  50757. if (currentSelectedBlockType === "atomic") {
  50758. return editorState;
  50759. }
  50760. var entityKey = void 0;
  50761. var contentState = editorState.getCurrentContent();
  50762. if (entity && entity.type) {
  50763. contentState = contentState.createEntity(
  50764. entity.type,
  50765. entity.mutability || "MUTABLE",
  50766. entity.data || entityData
  50767. );
  50768. entityKey = contentState.getLastCreatedEntityKey();
  50769. }
  50770. if (!selectionState.isCollapsed()) {
  50771. return Draft.EditorState.push(
  50772. editorState,
  50773. Draft.Modifier.replaceText(
  50774. contentState,
  50775. selectionState,
  50776. text,
  50777. inlineStyle,
  50778. entityKey
  50779. ),
  50780. "replace-text"
  50781. );
  50782. } else {
  50783. return Draft.EditorState.push(
  50784. editorState,
  50785. Draft.Modifier.insertText(
  50786. contentState,
  50787. selectionState,
  50788. text,
  50789. inlineStyle,
  50790. entityKey
  50791. ),
  50792. "insert-text"
  50793. );
  50794. }
  50795. });
  50796. var insertHTML = (exports.insertHTML = function insertHTML(
  50797. editorState,
  50798. htmlString,
  50799. source
  50800. ) {
  50801. if (!htmlString) {
  50802. return editorState;
  50803. }
  50804. var selectionState = editorState.getSelection();
  50805. var contentState = editorState.getCurrentContent();
  50806. var options = editorState.convertOptions || {};
  50807. try {
  50808. var _convertFromRaw = (0, Draft.convertFromRaw)(
  50809. (0, dist.convertHTMLToRaw)(htmlString, options, source)
  50810. ),
  50811. blockMap = _convertFromRaw.blockMap;
  50812. return Draft.EditorState.push(
  50813. editorState,
  50814. Draft.Modifier.replaceWithFragment(
  50815. contentState,
  50816. selectionState,
  50817. blockMap
  50818. ),
  50819. "insert-fragment"
  50820. );
  50821. } catch (error) {
  50822. console.warn(error);
  50823. return editorState;
  50824. }
  50825. });
  50826. var insertAtomicBlock = (exports.insertAtomicBlock = function insertAtomicBlock(
  50827. editorState,
  50828. type
  50829. ) {
  50830. var immutable =
  50831. arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  50832. var data =
  50833. arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  50834. if (selectionContainsStrictBlock(editorState)) {
  50835. return insertAtomicBlock(
  50836. selectNextBlock(editorState, getSelectionBlock(editorState)),
  50837. type,
  50838. immutable,
  50839. data
  50840. );
  50841. }
  50842. var selectionState = editorState.getSelection();
  50843. var contentState = editorState.getCurrentContent();
  50844. if (
  50845. !selectionState.isCollapsed() ||
  50846. getSelectionBlockType(editorState) === "atomic"
  50847. ) {
  50848. return editorState;
  50849. }
  50850. var contentStateWithEntity = contentState.createEntity(
  50851. type,
  50852. immutable ? "IMMUTABLE" : "MUTABLE",
  50853. data
  50854. );
  50855. var entityKey = contentStateWithEntity.getLastCreatedEntityKey();
  50856. var newEditorState = Draft.AtomicBlockUtils.insertAtomicBlock(
  50857. editorState,
  50858. entityKey,
  50859. " "
  50860. );
  50861. return newEditorState;
  50862. });
  50863. var insertHorizontalLine = (exports.insertHorizontalLine = function insertHorizontalLine(
  50864. editorState
  50865. ) {
  50866. return insertAtomicBlock(editorState, "HR");
  50867. });
  50868. var insertMedias = (exports.insertMedias = function insertMedias(
  50869. editorState
  50870. ) {
  50871. var medias =
  50872. arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  50873. if (!medias.length) {
  50874. return editorState;
  50875. }
  50876. return medias.reduce(function(editorState, media) {
  50877. var url = media.url,
  50878. link = media.link,
  50879. link_target = media.link_target,
  50880. name = media.name,
  50881. type = media.type,
  50882. width = media.width,
  50883. height = media.height,
  50884. meta = media.meta;
  50885. return insertAtomicBlock(editorState, type, true, {
  50886. url: url,
  50887. link: link,
  50888. link_target: link_target,
  50889. name: name,
  50890. type: type,
  50891. width: width,
  50892. height: height,
  50893. meta: meta
  50894. });
  50895. }, editorState);
  50896. });
  50897. var setMediaData = (exports.setMediaData = function setMediaData(
  50898. editorState,
  50899. entityKey,
  50900. data
  50901. ) {
  50902. return Draft.EditorState.push(
  50903. editorState,
  50904. editorState.getCurrentContent().mergeEntityData(entityKey, data),
  50905. "change-block-data"
  50906. );
  50907. });
  50908. var removeMedia = (exports.removeMedia = function removeMedia(
  50909. editorState,
  50910. mediaBlock
  50911. ) {
  50912. return removeBlock(editorState, mediaBlock);
  50913. });
  50914. var setMediaPosition = (exports.setMediaPosition = function setMediaPosition(
  50915. editorState,
  50916. mediaBlock,
  50917. position
  50918. ) {
  50919. var newPosition = {};
  50920. var float = position.float,
  50921. alignment = position.alignment;
  50922. if (typeof float !== "undefined") {
  50923. newPosition.float =
  50924. mediaBlock.getData().get("float") === float ? null : float;
  50925. }
  50926. if (typeof alignment !== "undefined") {
  50927. newPosition.alignment =
  50928. mediaBlock.getData().get("alignment") === alignment ? null : alignment;
  50929. }
  50930. return setSelectionBlockData(
  50931. selectBlock(editorState, mediaBlock),
  50932. newPosition
  50933. );
  50934. });
  50935. var clear = (exports.clear = function clear(editorState) {
  50936. var contentState = editorState.getCurrentContent();
  50937. var firstBlock = contentState.getFirstBlock();
  50938. var lastBlock = contentState.getLastBlock();
  50939. var allSelected = new Draft.SelectionState({
  50940. anchorKey: firstBlock.getKey(),
  50941. anchorOffset: 0,
  50942. focusKey: lastBlock.getKey(),
  50943. focusOffset: lastBlock.getLength(),
  50944. hasFocus: true
  50945. });
  50946. return Draft.RichUtils.toggleBlockType(
  50947. Draft.EditorState.push(
  50948. editorState,
  50949. Draft.Modifier.removeRange(contentState, allSelected, "backward"),
  50950. "remove-range"
  50951. ),
  50952. "unstyled"
  50953. );
  50954. });
  50955. var handleKeyCommand = (exports.handleKeyCommand = function handleKeyCommand(
  50956. editorState,
  50957. command
  50958. ) {
  50959. return Draft.RichUtils.handleKeyCommand(editorState, command);
  50960. });
  50961. var undo = (exports.undo = function undo(editorState) {
  50962. return Draft.EditorState.undo(editorState);
  50963. });
  50964. var redo = (exports.redo = function redo(editorState) {
  50965. return Draft.EditorState.redo(editorState);
  50966. });
  50967. });
  50968. _commonjsHelpers.unwrapExports(content$1);
  50969. var content_1$1 = content$1.redo;
  50970. var content_2$1 = content$1.undo;
  50971. var content_3$1 = content$1.handleKeyCommand;
  50972. var content_4$1 = content$1.clear;
  50973. var content_5$1 = content$1.setMediaPosition;
  50974. var content_6$1 = content$1.removeMedia;
  50975. var content_7$1 = content$1.setMediaData;
  50976. var content_8$1 = content$1.insertMedias;
  50977. var content_9$1 = content$1.insertHorizontalLine;
  50978. var content_10$1 = content$1.insertAtomicBlock;
  50979. var content_11$1 = content$1.insertHTML;
  50980. var content_12$1 = content$1.insertText;
  50981. var content_13$1 = content$1.toggleSelectionLetterSpacing;
  50982. var content_14$1 = content$1.toggleSelectionFontFamily;
  50983. var content_15$1 = content$1.toggleSelectionLineHeight;
  50984. var content_16$1 = content$1.toggleSelectionFontSize;
  50985. var content_17$1 = content$1.toggleSelectionBackgroundColor;
  50986. var content_18$1 = content$1.toggleSelectionColor;
  50987. var content_19$1 = content$1.decreaseSelectionIndent;
  50988. var content_20$1 = content$1.increaseSelectionIndent;
  50989. var content_21$1 = content$1.toggleSelectionIndent;
  50990. var content_22$1 = content$1.toggleSelectionAlignment;
  50991. var content_23$1 = content$1.removeSelectionInlineStyles;
  50992. var content_24$1 = content$1.toggleSelectionInlineStyle;
  50993. var content_25$1 = content$1.selectionHasInlineStyle;
  50994. var content_26$1 = content$1.getSelectionInlineStyle;
  50995. var content_27$1 = content$1.toggleSelectionLink;
  50996. var content_28$1 = content$1.toggleSelectionEntity;
  50997. var content_29$1 = content$1.getSelectionEntityData;
  50998. var content_30$1 = content$1.getSelectionEntityType;
  50999. var content_31$1 = content$1.toggleSelectionBlockType;
  51000. var content_32$1 = content$1.getSelectionText;
  51001. var content_33$1 = content$1.getSelectionBlockType;
  51002. var content_34$1 = content$1.getSelectionBlockData;
  51003. var content_35$1 = content$1.setSelectionBlockData;
  51004. var content_36$1 = content$1.getSelectedBlocks;
  51005. var content_37$1 = content$1.updateEachCharacterOfSelection;
  51006. var content_38$1 = content$1.getSelectionBlock;
  51007. var content_39$1 = content$1.removeBlock;
  51008. var content_40$1 = content$1.selectNextBlock;
  51009. var content_41$1 = content$1.selectBlock;
  51010. var content_42$1 = content$1.selectionContainsStrictBlock;
  51011. var content_43$1 = content$1.selectionContainsBlockType;
  51012. var content_44$1 = content$1.isSelectionCollapsed;
  51013. var content_45$1 = content$1.createEditorState;
  51014. var content_46$1 = content$1.createEmptyEditorState;
  51015. var content_47$1 = content$1.isEditorState;
  51016. var content_48$1 = content$1.registerStrictBlockType;
  51017. var base$1 = _commonjsHelpers.createCommonjsModule(function(module, exports) {
  51018. Object.defineProperty(exports, "__esModule", {
  51019. value: true
  51020. });
  51021. var braftUniqueIndex = 0;
  51022. var UniqueIndex = (exports.UniqueIndex = function UniqueIndex() {
  51023. return (braftUniqueIndex += 1);
  51024. });
  51025. });
  51026. _commonjsHelpers.unwrapExports(base$1);
  51027. var base_1$1 = base$1.UniqueIndex;
  51028. var color$1 = _commonjsHelpers.createCommonjsModule(function(module, exports) {
  51029. Object.defineProperty(exports, "__esModule", {
  51030. value: true
  51031. });
  51032. var _namedColors = {
  51033. aliceblue: "#f0f8ff",
  51034. antiquewhite: "#faebd7",
  51035. aqua: "#00ffff",
  51036. aquamarine: "#7fffd4",
  51037. azure: "#f0ffff",
  51038. beige: "#f5f5dc",
  51039. bisque: "#ffe4c4",
  51040. black: "#000000",
  51041. blanchedalmond: "#ffebcd",
  51042. blue: "#0000ff",
  51043. blueviolet: "#8a2be2",
  51044. brown: "#a52a2a",
  51045. burlywood: "#deb887",
  51046. cadetblue: "#5f9ea0",
  51047. chartreuse: "#7fff00",
  51048. chocolate: "#d2691e",
  51049. coral: "#ff7f50",
  51050. cornflowerblue: "#6495ed",
  51051. cornsilk: "#fff8dc",
  51052. crimson: "#dc143c",
  51053. cyan: "#00ffff",
  51054. darkblue: "#00008b",
  51055. darkcyan: "#008b8b",
  51056. darkgoldenrod: "#b8860b",
  51057. darkgray: "#a9a9a9",
  51058. darkgreen: "#006400",
  51059. darkkhaki: "#bdb76b",
  51060. darkmagenta: "#8b008b",
  51061. darkolivegreen: "#556b2f",
  51062. darkorange: "#ff8c00",
  51063. darkorchid: "#9932cc",
  51064. darkred: "#8b0000",
  51065. darksalmon: "#e9967a",
  51066. darkseagreen: "#8fbc8f",
  51067. darkslateblue: "#483d8b",
  51068. darkslategray: "#2f4f4f",
  51069. darkturquoise: "#00ced1",
  51070. darkviolet: "#9400d3",
  51071. deeppink: "#ff1493",
  51072. deepskyblue: "#00bfff",
  51073. dimgray: "#696969",
  51074. dodgerblue: "#1e90ff",
  51075. firebrick: "#b22222",
  51076. floralwhite: "#fffaf0",
  51077. forestgreen: "#228b22",
  51078. fuchsia: "#ff00ff",
  51079. gainsboro: "#dcdcdc",
  51080. ghostwhite: "#f8f8ff",
  51081. gold: "#ffd700",
  51082. goldenrod: "#daa520",
  51083. gray: "#808080",
  51084. green: "#008000",
  51085. greenyellow: "#adff2f",
  51086. honeydew: "#f0fff0",
  51087. hotpink: "#ff69b4",
  51088. "indianred ": "#cd5c5c",
  51089. indigo: "#4b0082",
  51090. ivory: "#fffff0",
  51091. khaki: "#f0e68c",
  51092. lavender: "#e6e6fa",
  51093. lavenderblush: "#fff0f5",
  51094. lawngreen: "#7cfc00",
  51095. lemonchiffon: "#fffacd",
  51096. lightblue: "#add8e6",
  51097. lightcoral: "#f08080",
  51098. lightcyan: "#e0ffff",
  51099. lightgoldenrodyellow: "#fafad2",
  51100. lightgrey: "#d3d3d3",
  51101. lightgreen: "#90ee90",
  51102. lightpink: "#ffb6c1",
  51103. lightsalmon: "#ffa07a",
  51104. lightseagreen: "#20b2aa",
  51105. lightskyblue: "#87cefa",
  51106. lightslategray: "#778899",
  51107. lightsteelblue: "#b0c4de",
  51108. lightyellow: "#ffffe0",
  51109. lime: "#00ff00",
  51110. limegreen: "#32cd32",
  51111. linen: "#faf0e6",
  51112. magenta: "#ff00ff",
  51113. maroon: "#800000",
  51114. mediumaquamarine: "#66cdaa",
  51115. mediumblue: "#0000cd",
  51116. mediumorchid: "#ba55d3",
  51117. mediumpurple: "#9370d8",
  51118. mediumseagreen: "#3cb371",
  51119. mediumslateblue: "#7b68ee",
  51120. mediumspringgreen: "#00fa9a",
  51121. mediumturquoise: "#48d1cc",
  51122. mediumvioletred: "#c71585",
  51123. midnightblue: "#191970",
  51124. mintcream: "#f5fffa",
  51125. mistyrose: "#ffe4e1",
  51126. moccasin: "#ffe4b5",
  51127. navajowhite: "#ffdead",
  51128. navy: "#000080",
  51129. oldlace: "#fdf5e6",
  51130. olive: "#808000",
  51131. olivedrab: "#6b8e23",
  51132. orange: "#ffa500",
  51133. orangered: "#ff4500",
  51134. orchid: "#da70d6",
  51135. palegoldenrod: "#eee8aa",
  51136. palegreen: "#98fb98",
  51137. paleturquoise: "#afeeee",
  51138. palevioletred: "#d87093",
  51139. papayawhip: "#ffefd5",
  51140. peachpuff: "#ffdab9",
  51141. peru: "#cd853f",
  51142. pink: "#ffc0cb",
  51143. plum: "#dda0dd",
  51144. powderblue: "#b0e0e6",
  51145. purple: "#800080",
  51146. rebeccapurple: "#663399",
  51147. red: "#ff0000",
  51148. rosybrown: "#bc8f8f",
  51149. royalblue: "#4169e1",
  51150. saddlebrown: "#8b4513",
  51151. salmon: "#fa8072",
  51152. sandybrown: "#f4a460",
  51153. seagreen: "#2e8b57",
  51154. seashell: "#fff5ee",
  51155. sienna: "#a0522d",
  51156. silver: "#c0c0c0",
  51157. skyblue: "#87ceeb",
  51158. slateblue: "#6a5acd",
  51159. slategray: "#708090",
  51160. snow: "#fffafa",
  51161. springgreen: "#00ff7f",
  51162. steelblue: "#4682b4",
  51163. tan: "#d2b48c",
  51164. teal: "#008080",
  51165. thistle: "#d8bfd8",
  51166. tomato: "#ff6347",
  51167. turquoise: "#40e0d0",
  51168. violet: "#ee82ee",
  51169. wheat: "#f5deb3",
  51170. white: "#ffffff",
  51171. whitesmoke: "#f5f5f5",
  51172. yellow: "#ffff00",
  51173. yellowgreen: "#9acd32"
  51174. };
  51175. var _getHexColor = function _getHexColor(color) {
  51176. color = color
  51177. .replace("color:", "")
  51178. .replace(";", "")
  51179. .replace(" ", "");
  51180. if (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(color)) {
  51181. return color;
  51182. } else if (namedColors[color]) {
  51183. return namedColors[color];
  51184. } else if (color.indexOf("rgb") === 0) {
  51185. var rgbArray = color.split(",");
  51186. var convertedColor =
  51187. rgbArray.length < 3
  51188. ? null
  51189. : "#" +
  51190. [rgbArray[0], rgbArray[1], rgbArray[2]]
  51191. .map(function(x) {
  51192. var hex = parseInt(x.replace(/\D/g, ""), 10).toString(16);
  51193. return hex.length === 1 ? "0" + hex : hex;
  51194. })
  51195. .join("");
  51196. return /^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(convertedColor)
  51197. ? convertedColor
  51198. : null;
  51199. } else {
  51200. return null;
  51201. }
  51202. };
  51203. var namedColors = (exports.namedColors = _namedColors);
  51204. var getHexColor = (exports.getHexColor = _getHexColor);
  51205. var detectColorsFromHTMLString = (exports.detectColorsFromHTMLString = function detectColorsFromHTMLString(
  51206. html
  51207. ) {
  51208. return typeof html !== "string"
  51209. ? []
  51210. : (html.match(/color:[^;]{3,24};/g) || [])
  51211. .map(getHexColor)
  51212. .filter(function(color) {
  51213. return color;
  51214. });
  51215. });
  51216. var detectColorsFromDraftState = (exports.detectColorsFromDraftState = function detectColorsFromDraftState(
  51217. draftState
  51218. ) {
  51219. var result = [];
  51220. if (!draftState || !draftState.blocks || !draftState.blocks.length) {
  51221. return result;
  51222. }
  51223. draftState.blocks.forEach(function(block) {
  51224. if (block && block.inlineStyleRanges && block.inlineStyleRanges.length) {
  51225. block.inlineStyleRanges.forEach(function(inlineStyle) {
  51226. if (inlineStyle.style && inlineStyle.style.indexOf("COLOR-") >= 0) {
  51227. result.push("#" + inlineStyle.style.split("COLOR-")[1]);
  51228. }
  51229. });
  51230. }
  51231. });
  51232. return result.filter(function(color) {
  51233. return color;
  51234. });
  51235. });
  51236. });
  51237. _commonjsHelpers.unwrapExports(color$1);
  51238. var color_1$1 = color$1.namedColors;
  51239. var color_2$1 = color$1.getHexColor;
  51240. var color_3$1 = color$1.detectColorsFromHTMLString;
  51241. var color_4$1 = color$1.detectColorsFromDraftState;
  51242. var dist$4 = _commonjsHelpers.createCommonjsModule(function(module, exports) {
  51243. Object.defineProperty(exports, "__esModule", {
  51244. value: true
  51245. });
  51246. exports.ColorUtils = exports.BaseUtils = exports.ContentUtils = undefined;
  51247. var _ContentUtils = _interopRequireWildcard(content$1);
  51248. var _BaseUtils = _interopRequireWildcard(base$1);
  51249. var _ColorUtils = _interopRequireWildcard(color$1);
  51250. function _interopRequireWildcard(obj) {
  51251. if (obj && obj.__esModule) {
  51252. return obj;
  51253. } else {
  51254. var newObj = {};
  51255. if (obj != null) {
  51256. for (var key in obj) {
  51257. if (Object.prototype.hasOwnProperty.call(obj, key))
  51258. newObj[key] = obj[key];
  51259. }
  51260. }
  51261. newObj.default = obj;
  51262. return newObj;
  51263. }
  51264. }
  51265. var ContentUtils = (exports.ContentUtils = _ContentUtils);
  51266. var BaseUtils = (exports.BaseUtils = _BaseUtils);
  51267. var ColorUtils = (exports.ColorUtils = _ColorUtils);
  51268. });
  51269. _commonjsHelpers.unwrapExports(dist$4);
  51270. var dist_1$2 = dist$4.ColorUtils;
  51271. var dist_2$2 = dist$4.BaseUtils;
  51272. var dist_3$2 = dist$4.ContentUtils;
  51273. var emoticon = _commonjsHelpers.createCommonjsModule(function(module, exports) {
  51274. (function webpackUniversalModuleDefinition(root, factory) {
  51275. module.exports = factory(React__default, dist$4);
  51276. })(window, function(
  51277. __WEBPACK_EXTERNAL_MODULE__1__,
  51278. __WEBPACK_EXTERNAL_MODULE__6__
  51279. ) {
  51280. return /******/ (function(modules) {
  51281. // webpackBootstrap
  51282. /******/ // The module cache
  51283. /******/ var installedModules = {}; // The require function
  51284. /******/
  51285. /******/ /******/ function __webpack_require__(moduleId) {
  51286. /******/
  51287. /******/ // Check if module is in cache
  51288. /******/ if (installedModules[moduleId]) {
  51289. /******/ return installedModules[moduleId].exports;
  51290. /******/
  51291. } // Create a new module (and put it into the cache)
  51292. /******/ /******/ var module = (installedModules[moduleId] = {
  51293. /******/ i: moduleId,
  51294. /******/ l: false,
  51295. /******/ exports: {}
  51296. /******/
  51297. }); // Execute the module function
  51298. /******/
  51299. /******/ /******/ modules[moduleId].call(
  51300. module.exports,
  51301. module,
  51302. module.exports,
  51303. __webpack_require__
  51304. ); // Flag the module as loaded
  51305. /******/
  51306. /******/ /******/ module.l = true; // Return the exports of the module
  51307. /******/
  51308. /******/ /******/ return module.exports;
  51309. /******/
  51310. } // expose the modules object (__webpack_modules__)
  51311. /******/
  51312. /******/
  51313. /******/ /******/ __webpack_require__.m = modules; // expose the module cache
  51314. /******/
  51315. /******/ /******/ __webpack_require__.c = installedModules; // define getter function for harmony exports
  51316. /******/
  51317. /******/ /******/ __webpack_require__.d = function(
  51318. exports,
  51319. name,
  51320. getter
  51321. ) {
  51322. /******/ if (!__webpack_require__.o(exports, name)) {
  51323. /******/ Object.defineProperty(exports, name, {
  51324. enumerable: true,
  51325. get: getter
  51326. });
  51327. /******/
  51328. }
  51329. /******/
  51330. }; // define __esModule on exports
  51331. /******/
  51332. /******/ /******/ __webpack_require__.r = function(exports) {
  51333. /******/ if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
  51334. /******/ Object.defineProperty(exports, Symbol.toStringTag, {
  51335. value: "Module"
  51336. });
  51337. /******/
  51338. }
  51339. /******/ Object.defineProperty(exports, "__esModule", { value: true });
  51340. /******/
  51341. }; // create a fake namespace object // mode & 1: value is a module id, require it // mode & 2: merge all properties of value into the ns // mode & 4: return value when already ns object // mode & 8|1: behave like require
  51342. /******/
  51343. /******/ /******/ /******/ /******/ /******/ /******/ __webpack_require__.t = function(
  51344. value,
  51345. mode
  51346. ) {
  51347. /******/ if (mode & 1) value = __webpack_require__(value);
  51348. /******/ if (mode & 8) return value;
  51349. /******/ if (
  51350. mode & 4 &&
  51351. typeof value === "object" &&
  51352. value &&
  51353. value.__esModule
  51354. )
  51355. return value;
  51356. /******/ var ns = Object.create(null);
  51357. /******/ __webpack_require__.r(ns);
  51358. /******/ Object.defineProperty(ns, "default", {
  51359. enumerable: true,
  51360. value: value
  51361. });
  51362. /******/ if (mode & 2 && typeof value != "string")
  51363. for (var key in value)
  51364. __webpack_require__.d(
  51365. ns,
  51366. key,
  51367. function(key) {
  51368. return value[key];
  51369. }.bind(null, key)
  51370. );
  51371. /******/ return ns;
  51372. /******/
  51373. }; // getDefaultExport function for compatibility with non-harmony modules
  51374. /******/
  51375. /******/ /******/ __webpack_require__.n = function(module) {
  51376. /******/ var getter =
  51377. module && module.__esModule
  51378. ? /******/ function getDefault() {
  51379. return module["default"];
  51380. }
  51381. : /******/ function getModuleExports() {
  51382. return module;
  51383. };
  51384. /******/ __webpack_require__.d(getter, "a", getter);
  51385. /******/ return getter;
  51386. /******/
  51387. }; // Object.prototype.hasOwnProperty.call
  51388. /******/
  51389. /******/ /******/ __webpack_require__.o = function(object, property) {
  51390. return Object.prototype.hasOwnProperty.call(object, property);
  51391. }; // __webpack_public_path__
  51392. /******/
  51393. /******/ /******/ __webpack_require__.p = "/"; // Load entry module and return exports
  51394. /******/
  51395. /******/
  51396. /******/ /******/ return __webpack_require__(
  51397. (__webpack_require__.s = 33)
  51398. );
  51399. /******/
  51400. })(
  51401. /************************************************************************/
  51402. /******/ {
  51403. /***/ 1: /***/ function(module, exports) {
  51404. module.exports = __WEBPACK_EXTERNAL_MODULE__1__;
  51405. /***/
  51406. },
  51407. /***/ 2: /***/ function(module, exports) {
  51408. function _defineProperty(obj, key, value) {
  51409. if (key in obj) {
  51410. Object.defineProperty(obj, key, {
  51411. value: value,
  51412. enumerable: true,
  51413. configurable: true,
  51414. writable: true
  51415. });
  51416. } else {
  51417. obj[key] = value;
  51418. }
  51419. return obj;
  51420. }
  51421. module.exports = _defineProperty;
  51422. /***/
  51423. },
  51424. /***/ 33: /***/ function(
  51425. module,
  51426. __webpack_exports__,
  51427. __webpack_require__
  51428. ) {
  51429. __webpack_require__.r(__webpack_exports__);
  51430. /* harmony export (binding) */ __webpack_require__.d(
  51431. __webpack_exports__,
  51432. "defaultEmoticons",
  51433. function() {
  51434. return defaultEmoticons;
  51435. }
  51436. );
  51437. /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
  51438. 5
  51439. );
  51440. /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n(
  51441. _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__
  51442. );
  51443. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
  51444. 1
  51445. );
  51446. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/ __webpack_require__.n(
  51447. react__WEBPACK_IMPORTED_MODULE_1__
  51448. );
  51449. /* harmony import */ var braft_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
  51450. 6
  51451. );
  51452. /* harmony import */ var _styles_scss__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
  51453. 48
  51454. );
  51455. // https://www.iconfinder.com/iconsets/emoji-18
  51456. var defaultEmoticons = [
  51457. 1,
  51458. 2,
  51459. 3,
  51460. 4,
  51461. 5,
  51462. 6,
  51463. 7,
  51464. 8,
  51465. 9,
  51466. 10,
  51467. 11,
  51468. 12,
  51469. 13,
  51470. 14,
  51471. 15,
  51472. 16,
  51473. 17,
  51474. 18,
  51475. 19,
  51476. 20,
  51477. 21,
  51478. 22,
  51479. 23,
  51480. 24,
  51481. 25
  51482. ].map(function(item) {
  51483. return "".concat(item, ".png");
  51484. });
  51485. var insertEmoticon = function insertEmoticon(
  51486. editor,
  51487. editorState,
  51488. src
  51489. ) {
  51490. editor.setValue(
  51491. braft_utils__WEBPACK_IMPORTED_MODULE_2__[
  51492. "ContentUtils"
  51493. ].insertText(editorState, " ", null, {
  51494. type: "EMOTICON",
  51495. mutability: "IMMUTABLE",
  51496. data: {
  51497. src: src
  51498. }
  51499. })
  51500. );
  51501. };
  51502. var controlRef = null;
  51503. var bindControlRef = function bindControlRef(ref) {
  51504. return (controlRef = ref);
  51505. };
  51506. /* harmony default export */ __webpack_exports__[
  51507. "default"
  51508. ] = function(options) {
  51509. options = _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default()(
  51510. {
  51511. emoticons: [],
  51512. closeOnSelect: false,
  51513. closeOnBlur: false
  51514. },
  51515. options
  51516. );
  51517. var _options = options,
  51518. emoticons = _options.emoticons,
  51519. closeOnSelect = _options.closeOnSelect,
  51520. closeOnBlur = _options.closeOnBlur,
  51521. includeEditors = _options.includeEditors,
  51522. excludeEditors = _options.excludeEditors;
  51523. return {
  51524. type: "entity",
  51525. includeEditors: includeEditors,
  51526. excludeEditors: excludeEditors,
  51527. name: "EMOTICON",
  51528. control: function control(props) {
  51529. return {
  51530. key: "EMOTICON",
  51531. replace: "emoji",
  51532. type: "dropdown",
  51533. text: react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(
  51534. "i",
  51535. {
  51536. className: "bfi-emoji"
  51537. }
  51538. ),
  51539. showArrow: false,
  51540. ref: bindControlRef,
  51541. autoHide: closeOnBlur,
  51542. component: react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(
  51543. "div",
  51544. {
  51545. className: "braft-emoticon-picker"
  51546. },
  51547. react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(
  51548. "div",
  51549. {
  51550. className: "braft-emoticons-list"
  51551. },
  51552. emoticons.map(function(item, index) {
  51553. return react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(
  51554. "img",
  51555. {
  51556. onClick: function onClick() {
  51557. insertEmoticon(
  51558. props.editor,
  51559. props.editorState,
  51560. item
  51561. );
  51562. closeOnSelect && controlRef && controlRef.hide();
  51563. },
  51564. key: index,
  51565. src: item
  51566. }
  51567. );
  51568. })
  51569. )
  51570. )
  51571. };
  51572. },
  51573. mutability: "IMMUTABLE",
  51574. component: function component(props) {
  51575. var entity = props.contentState.getEntity(props.entityKey);
  51576. var _entity$getData = entity.getData(),
  51577. src = _entity$getData.src;
  51578. return react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(
  51579. "span",
  51580. {
  51581. className: "braft-emoticon-in-editor"
  51582. },
  51583. react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(
  51584. "img",
  51585. {
  51586. src: src
  51587. }
  51588. ),
  51589. props.children
  51590. );
  51591. },
  51592. importer: function importer(nodeName, node) {
  51593. if (
  51594. nodeName.toLowerCase() === "span" &&
  51595. node.classList &&
  51596. node.classList.contains("braft-emoticon-wrap")
  51597. ) {
  51598. var imgNode = node.querySelector("img");
  51599. var src = imgNode.getAttribute("src"); // 移除img节点以避免生成atomic block
  51600. node.removeChild(imgNode);
  51601. return {
  51602. mutability: "IMMUTABLE",
  51603. data: {
  51604. src: src
  51605. }
  51606. };
  51607. }
  51608. },
  51609. exporter: function exporter(entityObject, initialText) {
  51610. var src = entityObject.data.src;
  51611. return react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(
  51612. "span",
  51613. {
  51614. className: "braft-emoticon-wrap"
  51615. },
  51616. react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(
  51617. "img",
  51618. {
  51619. src: src
  51620. }
  51621. ),
  51622. initialText
  51623. );
  51624. }
  51625. };
  51626. };
  51627. /***/
  51628. },
  51629. /***/ 48: /***/ function(module, exports) {
  51630. // removed by extract-text-webpack-plugin
  51631. /***/
  51632. },
  51633. /***/ 5: /***/ function(module, exports, __webpack_require__) {
  51634. var defineProperty = __webpack_require__(2);
  51635. function _objectSpread(target) {
  51636. for (var i = 1; i < arguments.length; i++) {
  51637. var source = arguments[i] != null ? arguments[i] : {};
  51638. var ownKeys = Object.keys(source);
  51639. if (typeof Object.getOwnPropertySymbols === "function") {
  51640. ownKeys = ownKeys.concat(
  51641. Object.getOwnPropertySymbols(source).filter(function(sym) {
  51642. return Object.getOwnPropertyDescriptor(
  51643. source,
  51644. sym
  51645. ).enumerable;
  51646. })
  51647. );
  51648. }
  51649. ownKeys.forEach(function(key) {
  51650. defineProperty(target, key, source[key]);
  51651. });
  51652. }
  51653. return target;
  51654. }
  51655. module.exports = _objectSpread;
  51656. /***/
  51657. },
  51658. /***/ 6: /***/ function(module, exports) {
  51659. module.exports = __WEBPACK_EXTERNAL_MODULE__6__;
  51660. /***/
  51661. }
  51662. /******/
  51663. }
  51664. );
  51665. });
  51666. });
  51667. var Emoticon = _commonjsHelpers.unwrapExports(emoticon);
  51668. var emoticon_1 = emoticon.defaultEmoticons;
  51669. var maxLength = _commonjsHelpers.createCommonjsModule(function(
  51670. module,
  51671. exports
  51672. ) {
  51673. (function webpackUniversalModuleDefinition(root, factory) {
  51674. module.exports = factory();
  51675. })(window, function() {
  51676. return /******/ (function(modules) {
  51677. // webpackBootstrap
  51678. /******/ // The module cache
  51679. /******/ var installedModules = {}; // The require function
  51680. /******/
  51681. /******/ /******/ function __webpack_require__(moduleId) {
  51682. /******/
  51683. /******/ // Check if module is in cache
  51684. /******/ if (installedModules[moduleId]) {
  51685. /******/ return installedModules[moduleId].exports;
  51686. /******/
  51687. } // Create a new module (and put it into the cache)
  51688. /******/ /******/ var module = (installedModules[moduleId] = {
  51689. /******/ i: moduleId,
  51690. /******/ l: false,
  51691. /******/ exports: {}
  51692. /******/
  51693. }); // Execute the module function
  51694. /******/
  51695. /******/ /******/ modules[moduleId].call(
  51696. module.exports,
  51697. module,
  51698. module.exports,
  51699. __webpack_require__
  51700. ); // Flag the module as loaded
  51701. /******/
  51702. /******/ /******/ module.l = true; // Return the exports of the module
  51703. /******/
  51704. /******/ /******/ return module.exports;
  51705. /******/
  51706. } // expose the modules object (__webpack_modules__)
  51707. /******/
  51708. /******/
  51709. /******/ /******/ __webpack_require__.m = modules; // expose the module cache
  51710. /******/
  51711. /******/ /******/ __webpack_require__.c = installedModules; // define getter function for harmony exports
  51712. /******/
  51713. /******/ /******/ __webpack_require__.d = function(
  51714. exports,
  51715. name,
  51716. getter
  51717. ) {
  51718. /******/ if (!__webpack_require__.o(exports, name)) {
  51719. /******/ Object.defineProperty(exports, name, {
  51720. enumerable: true,
  51721. get: getter
  51722. });
  51723. /******/
  51724. }
  51725. /******/
  51726. }; // define __esModule on exports
  51727. /******/
  51728. /******/ /******/ __webpack_require__.r = function(exports) {
  51729. /******/ if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
  51730. /******/ Object.defineProperty(exports, Symbol.toStringTag, {
  51731. value: "Module"
  51732. });
  51733. /******/
  51734. }
  51735. /******/ Object.defineProperty(exports, "__esModule", { value: true });
  51736. /******/
  51737. }; // create a fake namespace object // mode & 1: value is a module id, require it // mode & 2: merge all properties of value into the ns // mode & 4: return value when already ns object // mode & 8|1: behave like require
  51738. /******/
  51739. /******/ /******/ /******/ /******/ /******/ /******/ __webpack_require__.t = function(
  51740. value,
  51741. mode
  51742. ) {
  51743. /******/ if (mode & 1) value = __webpack_require__(value);
  51744. /******/ if (mode & 8) return value;
  51745. /******/ if (
  51746. mode & 4 &&
  51747. typeof value === "object" &&
  51748. value &&
  51749. value.__esModule
  51750. )
  51751. return value;
  51752. /******/ var ns = Object.create(null);
  51753. /******/ __webpack_require__.r(ns);
  51754. /******/ Object.defineProperty(ns, "default", {
  51755. enumerable: true,
  51756. value: value
  51757. });
  51758. /******/ if (mode & 2 && typeof value != "string")
  51759. for (var key in value)
  51760. __webpack_require__.d(
  51761. ns,
  51762. key,
  51763. function(key) {
  51764. return value[key];
  51765. }.bind(null, key)
  51766. );
  51767. /******/ return ns;
  51768. /******/
  51769. }; // getDefaultExport function for compatibility with non-harmony modules
  51770. /******/
  51771. /******/ /******/ __webpack_require__.n = function(module) {
  51772. /******/ var getter =
  51773. module && module.__esModule
  51774. ? /******/ function getDefault() {
  51775. return module["default"];
  51776. }
  51777. : /******/ function getModuleExports() {
  51778. return module;
  51779. };
  51780. /******/ __webpack_require__.d(getter, "a", getter);
  51781. /******/ return getter;
  51782. /******/
  51783. }; // Object.prototype.hasOwnProperty.call
  51784. /******/
  51785. /******/ /******/ __webpack_require__.o = function(object, property) {
  51786. return Object.prototype.hasOwnProperty.call(object, property);
  51787. }; // __webpack_public_path__
  51788. /******/
  51789. /******/ /******/ __webpack_require__.p = "/"; // Load entry module and return exports
  51790. /******/
  51791. /******/
  51792. /******/ /******/ return __webpack_require__(
  51793. (__webpack_require__.s = 34)
  51794. );
  51795. /******/
  51796. })(
  51797. /************************************************************************/
  51798. /******/ {
  51799. /***/ 2: /***/ function(module, exports) {
  51800. function _defineProperty(obj, key, value) {
  51801. if (key in obj) {
  51802. Object.defineProperty(obj, key, {
  51803. value: value,
  51804. enumerable: true,
  51805. configurable: true,
  51806. writable: true
  51807. });
  51808. } else {
  51809. obj[key] = value;
  51810. }
  51811. return obj;
  51812. }
  51813. module.exports = _defineProperty;
  51814. /***/
  51815. },
  51816. /***/ 34: /***/ function(
  51817. module,
  51818. __webpack_exports__,
  51819. __webpack_require__
  51820. ) {
  51821. __webpack_require__.r(__webpack_exports__);
  51822. /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
  51823. 5
  51824. );
  51825. /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n(
  51826. _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__
  51827. );
  51828. var getSelectedTextLength = function getSelectedTextLength(
  51829. editorState
  51830. ) {
  51831. var currentSelection = editorState.getSelection();
  51832. var isCollapsed = currentSelection.isCollapsed();
  51833. var length = 0;
  51834. if (!isCollapsed) {
  51835. var currentContent = editorState.getCurrentContent();
  51836. var startKey = currentSelection.getStartKey();
  51837. var endKey = currentSelection.getEndKey();
  51838. var startBlock = currentContent.getBlockForKey(startKey);
  51839. var isStartAndEndBlockAreTheSame = startKey === endKey;
  51840. var startBlockTextLength = startBlock.getLength();
  51841. var startSelectedTextLength =
  51842. startBlockTextLength - currentSelection.getStartOffset();
  51843. var endSelectedTextLength = currentSelection.getEndOffset();
  51844. var keyAfterEnd = currentContent.getKeyAfter(endKey);
  51845. if (isStartAndEndBlockAreTheSame) {
  51846. length +=
  51847. currentSelection.getEndOffset() -
  51848. currentSelection.getStartOffset();
  51849. } else {
  51850. var currentKey = startKey;
  51851. while (currentKey && currentKey !== keyAfterEnd) {
  51852. if (currentKey === startKey) {
  51853. length += startSelectedTextLength + 1;
  51854. } else if (currentKey === endKey) {
  51855. length += endSelectedTextLength;
  51856. } else {
  51857. length +=
  51858. currentContent.getBlockForKey(currentKey).getLength() + 1;
  51859. }
  51860. currentKey = currentContent.getKeyAfter(currentKey);
  51861. }
  51862. }
  51863. }
  51864. return length;
  51865. };
  51866. /* harmony default export */ __webpack_exports__[
  51867. "default"
  51868. ] = function(options) {
  51869. options = _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default()(
  51870. {
  51871. defaultValue: Infinity
  51872. },
  51873. options
  51874. );
  51875. var _options = options,
  51876. includeEditors = _options.includeEditors,
  51877. excludeEditors = _options.excludeEditors,
  51878. defaultValue = _options.defaultValue;
  51879. return {
  51880. type: "prop-interception",
  51881. includeEditors: includeEditors,
  51882. excludeEditors: excludeEditors,
  51883. interceptor: function interceptor(editorProps) {
  51884. var maxLength = editorProps.maxLength || defaultValue;
  51885. editorProps.handleBeforeInput = function(_, editorState) {
  51886. if (maxLength === Infinity) {
  51887. return "not-handled";
  51888. }
  51889. var currentContentLength = editorState.toText().length;
  51890. var selectedTextLength = getSelectedTextLength(editorState);
  51891. if (
  51892. currentContentLength - selectedTextLength >
  51893. maxLength - 1
  51894. ) {
  51895. editorProps.onReachMaxLength &&
  51896. editorProps.onReachMaxLength(maxLength);
  51897. return "handled";
  51898. }
  51899. };
  51900. editorProps.handlePastedText = function(
  51901. pastedText,
  51902. _,
  51903. editorState
  51904. ) {
  51905. if (maxLength === Infinity) {
  51906. return "not-handled";
  51907. }
  51908. var currentContentLength = editorState.toText().length;
  51909. var selectedTextLength = getSelectedTextLength(editorState);
  51910. if (
  51911. currentContentLength +
  51912. pastedText.length -
  51913. selectedTextLength >
  51914. maxLength
  51915. ) {
  51916. editorProps.onReachMaxLength &&
  51917. editorProps.onReachMaxLength(maxLength);
  51918. return "handled";
  51919. }
  51920. };
  51921. return editorProps;
  51922. }
  51923. };
  51924. };
  51925. /***/
  51926. },
  51927. /***/ 5: /***/ function(module, exports, __webpack_require__) {
  51928. var defineProperty = __webpack_require__(2);
  51929. function _objectSpread(target) {
  51930. for (var i = 1; i < arguments.length; i++) {
  51931. var source = arguments[i] != null ? arguments[i] : {};
  51932. var ownKeys = Object.keys(source);
  51933. if (typeof Object.getOwnPropertySymbols === "function") {
  51934. ownKeys = ownKeys.concat(
  51935. Object.getOwnPropertySymbols(source).filter(function(sym) {
  51936. return Object.getOwnPropertyDescriptor(
  51937. source,
  51938. sym
  51939. ).enumerable;
  51940. })
  51941. );
  51942. }
  51943. ownKeys.forEach(function(key) {
  51944. defineProperty(target, key, source[key]);
  51945. });
  51946. }
  51947. return target;
  51948. }
  51949. module.exports = _objectSpread;
  51950. /***/
  51951. }
  51952. /******/
  51953. }
  51954. );
  51955. });
  51956. });
  51957. var MaxLength = _commonjsHelpers.unwrapExports(maxLength);
  51958. var lengthOptions = {
  51959. defaultValue: 100
  51960. };
  51961. BraftEditor.use(MaxLength(lengthOptions));
  51962. var emoticons = emoticon_1.map(function(item) {
  51963. return require("braft-extensions/dist/assets/".concat(item));
  51964. });
  51965. var emotionOptions = {
  51966. emoticons: emoticons,
  51967. closeOnBlur: true,
  51968. closeOnSelect: false
  51969. };
  51970. BraftEditor.use(Emoticon(emotionOptions));
  51971. var BarftEditorPage = function BarftEditorPage(_ref) {
  51972. var value = _ref.value;
  51973. var controls = [
  51974. "bold",
  51975. "italic",
  51976. "underline",
  51977. "separator",
  51978. "link",
  51979. "emoji",
  51980. "separator",
  51981. "media"
  51982. ];
  51983. var _useState = React.useState(
  51984. BraftEditor.createEditorState(value || "<p>Hello <b>World!</b></p>")
  51985. ),
  51986. _useState2 = slicedToArray._slicedToArray(_useState, 2),
  51987. editorState = _useState2[0],
  51988. setEditorState = _useState2[1];
  51989. return React__default.createElement(
  51990. "div",
  51991. {
  51992. className: "editor-wrapper"
  51993. },
  51994. React__default.createElement(BraftEditor, {
  51995. value: editorState,
  51996. onChange: setEditorState,
  51997. controls: controls,
  51998. contentStyle: {
  51999. boxShadow: "inset 0 1px 3px rgba(0,0,0,.1)"
  52000. }
  52001. })
  52002. );
  52003. };
  52004. exports.BarftEditorPage = BarftEditorPage;
  52005. exports.default = BarftEditorPage;
  52006. //# sourceMappingURL=index.js.map