123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571 |
- import React, { useState } from 'react';
- import ReactDOM from 'react-dom';
- import { s as styleInject } from '../style-inject.es-1f59c1d0.js';
- import { c as createCommonjsModule, a as commonjsGlobal, u as unwrapExports } from '../_commonjsHelpers-97e6d7b1.js';
- import { _ as _slicedToArray } from '../slicedToArray-4cd9e6d3.js';
- import server from 'react-dom/server';
-
- /*
- object-assign
- (c) Sindre Sorhus
- @license MIT
- */
- /* eslint-disable no-unused-vars */
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- var propIsEnumerable = Object.prototype.propertyIsEnumerable;
-
- function toObject(val) {
- if (val === null || val === undefined) {
- throw new TypeError('Object.assign cannot be called with null or undefined');
- }
-
- return Object(val);
- }
-
- function shouldUseNative() {
- try {
- if (!Object.assign) {
- return false;
- }
-
- // Detect buggy property enumeration order in older V8 versions.
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
- var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
- test1[5] = 'de';
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
- return false;
- }
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test2 = {};
- for (var i = 0; i < 10; i++) {
- test2['_' + String.fromCharCode(i)] = i;
- }
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
- return test2[n];
- });
- if (order2.join('') !== '0123456789') {
- return false;
- }
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test3 = {};
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
- test3[letter] = letter;
- });
- if (Object.keys(Object.assign({}, test3)).join('') !==
- 'abcdefghijklmnopqrst') {
- return false;
- }
-
- return true;
- } catch (err) {
- // We don't expect any of the above to throw, but better to be safe.
- return false;
- }
- }
-
- var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
- var from;
- var to = toObject(target);
- var symbols;
-
- for (var s = 1; s < arguments.length; s++) {
- from = Object(arguments[s]);
-
- for (var key in from) {
- if (hasOwnProperty.call(from, key)) {
- to[key] = from[key];
- }
- }
-
- if (getOwnPropertySymbols) {
- symbols = getOwnPropertySymbols(from);
- for (var i = 0; i < symbols.length; i++) {
- if (propIsEnumerable.call(from, symbols[i])) {
- to[symbols[i]] = from[symbols[i]];
- }
- }
- }
- }
-
- return to;
- };
-
- var immutable = createCommonjsModule(function (module, exports) {
- /**
- * Copyright (c) 2014-2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
-
- (function (global, factory) {
- module.exports = factory() ;
- }(commonjsGlobal, function () {var SLICE$0 = Array.prototype.slice;
-
- function createClass(ctor, superClass) {
- if (superClass) {
- ctor.prototype = Object.create(superClass.prototype);
- }
- ctor.prototype.constructor = ctor;
- }
-
- function Iterable(value) {
- return isIterable(value) ? value : Seq(value);
- }
-
-
- createClass(KeyedIterable, Iterable);
- function KeyedIterable(value) {
- return isKeyed(value) ? value : KeyedSeq(value);
- }
-
-
- createClass(IndexedIterable, Iterable);
- function IndexedIterable(value) {
- return isIndexed(value) ? value : IndexedSeq(value);
- }
-
-
- createClass(SetIterable, Iterable);
- function SetIterable(value) {
- return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
- }
-
-
-
- function isIterable(maybeIterable) {
- return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
- }
-
- function isKeyed(maybeKeyed) {
- return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
- }
-
- function isIndexed(maybeIndexed) {
- return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
- }
-
- function isAssociative(maybeAssociative) {
- return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
- }
-
- function isOrdered(maybeOrdered) {
- return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
- }
-
- Iterable.isIterable = isIterable;
- Iterable.isKeyed = isKeyed;
- Iterable.isIndexed = isIndexed;
- Iterable.isAssociative = isAssociative;
- Iterable.isOrdered = isOrdered;
-
- Iterable.Keyed = KeyedIterable;
- Iterable.Indexed = IndexedIterable;
- Iterable.Set = SetIterable;
-
-
- var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
- var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
- var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
- var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
-
- // Used for setting prototype methods that IE8 chokes on.
- var DELETE = 'delete';
-
- // Constants describing the size of trie nodes.
- var SHIFT = 5; // Resulted in best performance after ______?
- var SIZE = 1 << SHIFT;
- var MASK = SIZE - 1;
-
- // A consistent shared value representing "not set" which equals nothing other
- // than itself, and nothing that could be provided externally.
- var NOT_SET = {};
-
- // Boolean references, Rough equivalent of `bool &`.
- var CHANGE_LENGTH = { value: false };
- var DID_ALTER = { value: false };
-
- function MakeRef(ref) {
- ref.value = false;
- return ref;
- }
-
- function SetRef(ref) {
- ref && (ref.value = true);
- }
-
- // A function which returns a value representing an "owner" for transient writes
- // to tries. The return value will only ever equal itself, and will not equal
- // the return of any subsequent call of this function.
- function OwnerID() {}
-
- // http://jsperf.com/copy-array-inline
- function arrCopy(arr, offset) {
- offset = offset || 0;
- var len = Math.max(0, arr.length - offset);
- var newArr = new Array(len);
- for (var ii = 0; ii < len; ii++) {
- newArr[ii] = arr[ii + offset];
- }
- return newArr;
- }
-
- function ensureSize(iter) {
- if (iter.size === undefined) {
- iter.size = iter.__iterate(returnTrue);
- }
- return iter.size;
- }
-
- function wrapIndex(iter, index) {
- // This implements "is array index" which the ECMAString spec defines as:
- //
- // A String property name P is an array index if and only if
- // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
- // to 2^32−1.
- //
- // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
- if (typeof index !== 'number') {
- var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
- if ('' + uint32Index !== index || uint32Index === 4294967295) {
- return NaN;
- }
- index = uint32Index;
- }
- return index < 0 ? ensureSize(iter) + index : index;
- }
-
- function returnTrue() {
- return true;
- }
-
- function wholeSlice(begin, end, size) {
- return (begin === 0 || (size !== undefined && begin <= -size)) &&
- (end === undefined || (size !== undefined && end >= size));
- }
-
- function resolveBegin(begin, size) {
- return resolveIndex(begin, size, 0);
- }
-
- function resolveEnd(end, size) {
- return resolveIndex(end, size, size);
- }
-
- function resolveIndex(index, size, defaultIndex) {
- return index === undefined ?
- defaultIndex :
- index < 0 ?
- Math.max(0, size + index) :
- size === undefined ?
- index :
- Math.min(size, index);
- }
-
- /* global Symbol */
-
- var ITERATE_KEYS = 0;
- var ITERATE_VALUES = 1;
- var ITERATE_ENTRIES = 2;
-
- var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
- var FAUX_ITERATOR_SYMBOL = '@@iterator';
-
- var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
-
-
- function Iterator(next) {
- this.next = next;
- }
-
- Iterator.prototype.toString = function() {
- return '[Iterator]';
- };
-
-
- Iterator.KEYS = ITERATE_KEYS;
- Iterator.VALUES = ITERATE_VALUES;
- Iterator.ENTRIES = ITERATE_ENTRIES;
-
- Iterator.prototype.inspect =
- Iterator.prototype.toSource = function () { return this.toString(); };
- Iterator.prototype[ITERATOR_SYMBOL] = function () {
- return this;
- };
-
-
- function iteratorValue(type, k, v, iteratorResult) {
- var value = type === 0 ? k : type === 1 ? v : [k, v];
- iteratorResult ? (iteratorResult.value = value) : (iteratorResult = {
- value: value, done: false
- });
- return iteratorResult;
- }
-
- function iteratorDone() {
- return { value: undefined, done: true };
- }
-
- function hasIterator(maybeIterable) {
- return !!getIteratorFn(maybeIterable);
- }
-
- function isIterator(maybeIterator) {
- return maybeIterator && typeof maybeIterator.next === 'function';
- }
-
- function getIterator(iterable) {
- var iteratorFn = getIteratorFn(iterable);
- return iteratorFn && iteratorFn.call(iterable);
- }
-
- function getIteratorFn(iterable) {
- var iteratorFn = iterable && (
- (REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
- iterable[FAUX_ITERATOR_SYMBOL]
- );
- if (typeof iteratorFn === 'function') {
- return iteratorFn;
- }
- }
-
- function isArrayLike(value) {
- return value && typeof value.length === 'number';
- }
-
- createClass(Seq, Iterable);
- function Seq(value) {
- return value === null || value === undefined ? emptySequence() :
- isIterable(value) ? value.toSeq() : seqFromValue(value);
- }
-
- Seq.of = function(/*...values*/) {
- return Seq(arguments);
- };
-
- Seq.prototype.toSeq = function() {
- return this;
- };
-
- Seq.prototype.toString = function() {
- return this.__toString('Seq {', '}');
- };
-
- Seq.prototype.cacheResult = function() {
- if (!this._cache && this.__iterateUncached) {
- this._cache = this.entrySeq().toArray();
- this.size = this._cache.length;
- }
- return this;
- };
-
- // abstract __iterateUncached(fn, reverse)
-
- Seq.prototype.__iterate = function(fn, reverse) {
- return seqIterate(this, fn, reverse, true);
- };
-
- // abstract __iteratorUncached(type, reverse)
-
- Seq.prototype.__iterator = function(type, reverse) {
- return seqIterator(this, type, reverse, true);
- };
-
-
-
- createClass(KeyedSeq, Seq);
- function KeyedSeq(value) {
- return value === null || value === undefined ?
- emptySequence().toKeyedSeq() :
- isIterable(value) ?
- (isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) :
- keyedSeqFromValue(value);
- }
-
- KeyedSeq.prototype.toKeyedSeq = function() {
- return this;
- };
-
-
-
- createClass(IndexedSeq, Seq);
- function IndexedSeq(value) {
- return value === null || value === undefined ? emptySequence() :
- !isIterable(value) ? indexedSeqFromValue(value) :
- isKeyed(value) ? value.entrySeq() : value.toIndexedSeq();
- }
-
- IndexedSeq.of = function(/*...values*/) {
- return IndexedSeq(arguments);
- };
-
- IndexedSeq.prototype.toIndexedSeq = function() {
- return this;
- };
-
- IndexedSeq.prototype.toString = function() {
- return this.__toString('Seq [', ']');
- };
-
- IndexedSeq.prototype.__iterate = function(fn, reverse) {
- return seqIterate(this, fn, reverse, false);
- };
-
- IndexedSeq.prototype.__iterator = function(type, reverse) {
- return seqIterator(this, type, reverse, false);
- };
-
-
-
- createClass(SetSeq, Seq);
- function SetSeq(value) {
- return (
- value === null || value === undefined ? emptySequence() :
- !isIterable(value) ? indexedSeqFromValue(value) :
- isKeyed(value) ? value.entrySeq() : value
- ).toSetSeq();
- }
-
- SetSeq.of = function(/*...values*/) {
- return SetSeq(arguments);
- };
-
- SetSeq.prototype.toSetSeq = function() {
- return this;
- };
-
-
-
- Seq.isSeq = isSeq;
- Seq.Keyed = KeyedSeq;
- Seq.Set = SetSeq;
- Seq.Indexed = IndexedSeq;
-
- var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
-
- Seq.prototype[IS_SEQ_SENTINEL] = true;
-
-
-
- createClass(ArraySeq, IndexedSeq);
- function ArraySeq(array) {
- this._array = array;
- this.size = array.length;
- }
-
- ArraySeq.prototype.get = function(index, notSetValue) {
- return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
- };
-
- ArraySeq.prototype.__iterate = function(fn, reverse) {
- var array = this._array;
- var maxIndex = array.length - 1;
- for (var ii = 0; ii <= maxIndex; ii++) {
- if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
- return ii + 1;
- }
- }
- return ii;
- };
-
- ArraySeq.prototype.__iterator = function(type, reverse) {
- var array = this._array;
- var maxIndex = array.length - 1;
- var ii = 0;
- return new Iterator(function()
- {return ii > maxIndex ?
- iteratorDone() :
- iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])}
- );
- };
-
-
-
- createClass(ObjectSeq, KeyedSeq);
- function ObjectSeq(object) {
- var keys = Object.keys(object);
- this._object = object;
- this._keys = keys;
- this.size = keys.length;
- }
-
- ObjectSeq.prototype.get = function(key, notSetValue) {
- if (notSetValue !== undefined && !this.has(key)) {
- return notSetValue;
- }
- return this._object[key];
- };
-
- ObjectSeq.prototype.has = function(key) {
- return this._object.hasOwnProperty(key);
- };
-
- ObjectSeq.prototype.__iterate = function(fn, reverse) {
- var object = this._object;
- var keys = this._keys;
- var maxIndex = keys.length - 1;
- for (var ii = 0; ii <= maxIndex; ii++) {
- var key = keys[reverse ? maxIndex - ii : ii];
- if (fn(object[key], key, this) === false) {
- return ii + 1;
- }
- }
- return ii;
- };
-
- ObjectSeq.prototype.__iterator = function(type, reverse) {
- var object = this._object;
- var keys = this._keys;
- var maxIndex = keys.length - 1;
- var ii = 0;
- return new Iterator(function() {
- var key = keys[reverse ? maxIndex - ii : ii];
- return ii++ > maxIndex ?
- iteratorDone() :
- iteratorValue(type, key, object[key]);
- });
- };
-
- ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
-
-
- createClass(IterableSeq, IndexedSeq);
- function IterableSeq(iterable) {
- this._iterable = iterable;
- this.size = iterable.length || iterable.size;
- }
-
- IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
- if (reverse) {
- return this.cacheResult().__iterate(fn, reverse);
- }
- var iterable = this._iterable;
- var iterator = getIterator(iterable);
- var iterations = 0;
- if (isIterator(iterator)) {
- var step;
- while (!(step = iterator.next()).done) {
- if (fn(step.value, iterations++, this) === false) {
- break;
- }
- }
- }
- return iterations;
- };
-
- IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
- if (reverse) {
- return this.cacheResult().__iterator(type, reverse);
- }
- var iterable = this._iterable;
- var iterator = getIterator(iterable);
- if (!isIterator(iterator)) {
- return new Iterator(iteratorDone);
- }
- var iterations = 0;
- return new Iterator(function() {
- var step = iterator.next();
- return step.done ? step : iteratorValue(type, iterations++, step.value);
- });
- };
-
-
-
- createClass(IteratorSeq, IndexedSeq);
- function IteratorSeq(iterator) {
- this._iterator = iterator;
- this._iteratorCache = [];
- }
-
- IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
- if (reverse) {
- return this.cacheResult().__iterate(fn, reverse);
- }
- var iterator = this._iterator;
- var cache = this._iteratorCache;
- var iterations = 0;
- while (iterations < cache.length) {
- if (fn(cache[iterations], iterations++, this) === false) {
- return iterations;
- }
- }
- var step;
- while (!(step = iterator.next()).done) {
- var val = step.value;
- cache[iterations] = val;
- if (fn(val, iterations++, this) === false) {
- break;
- }
- }
- return iterations;
- };
-
- IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
- if (reverse) {
- return this.cacheResult().__iterator(type, reverse);
- }
- var iterator = this._iterator;
- var cache = this._iteratorCache;
- var iterations = 0;
- return new Iterator(function() {
- if (iterations >= cache.length) {
- var step = iterator.next();
- if (step.done) {
- return step;
- }
- cache[iterations] = step.value;
- }
- return iteratorValue(type, iterations, cache[iterations++]);
- });
- };
-
-
-
-
- // # pragma Helper functions
-
- function isSeq(maybeSeq) {
- return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
- }
-
- var EMPTY_SEQ;
-
- function emptySequence() {
- return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
- }
-
- function keyedSeqFromValue(value) {
- var seq =
- Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() :
- isIterator(value) ? new IteratorSeq(value).fromEntrySeq() :
- hasIterator(value) ? new IterableSeq(value).fromEntrySeq() :
- typeof value === 'object' ? new ObjectSeq(value) :
- undefined;
- if (!seq) {
- throw new TypeError(
- 'Expected Array or iterable object of [k, v] entries, '+
- 'or keyed object: ' + value
- );
- }
- return seq;
- }
-
- function indexedSeqFromValue(value) {
- var seq = maybeIndexedSeqFromValue(value);
- if (!seq) {
- throw new TypeError(
- 'Expected Array or iterable object of values: ' + value
- );
- }
- return seq;
- }
-
- function seqFromValue(value) {
- var seq = maybeIndexedSeqFromValue(value) ||
- (typeof value === 'object' && new ObjectSeq(value));
- if (!seq) {
- throw new TypeError(
- 'Expected Array or iterable object of values, or keyed object: ' + value
- );
- }
- return seq;
- }
-
- function maybeIndexedSeqFromValue(value) {
- return (
- isArrayLike(value) ? new ArraySeq(value) :
- isIterator(value) ? new IteratorSeq(value) :
- hasIterator(value) ? new IterableSeq(value) :
- undefined
- );
- }
-
- function seqIterate(seq, fn, reverse, useKeys) {
- var cache = seq._cache;
- if (cache) {
- var maxIndex = cache.length - 1;
- for (var ii = 0; ii <= maxIndex; ii++) {
- var entry = cache[reverse ? maxIndex - ii : ii];
- if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
- return ii + 1;
- }
- }
- return ii;
- }
- return seq.__iterateUncached(fn, reverse);
- }
-
- function seqIterator(seq, type, reverse, useKeys) {
- var cache = seq._cache;
- if (cache) {
- var maxIndex = cache.length - 1;
- var ii = 0;
- return new Iterator(function() {
- var entry = cache[reverse ? maxIndex - ii : ii];
- return ii++ > maxIndex ?
- iteratorDone() :
- iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
- });
- }
- return seq.__iteratorUncached(type, reverse);
- }
-
- function fromJS(json, converter) {
- return converter ?
- fromJSWith(converter, json, '', {'': json}) :
- fromJSDefault(json);
- }
-
- function fromJSWith(converter, json, key, parentJSON) {
- if (Array.isArray(json)) {
- return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
- }
- if (isPlainObj(json)) {
- return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
- }
- return json;
- }
-
- function fromJSDefault(json) {
- if (Array.isArray(json)) {
- return IndexedSeq(json).map(fromJSDefault).toList();
- }
- if (isPlainObj(json)) {
- return KeyedSeq(json).map(fromJSDefault).toMap();
- }
- return json;
- }
-
- function isPlainObj(value) {
- return value && (value.constructor === Object || value.constructor === undefined);
- }
-
- /**
- * An extension of the "same-value" algorithm as [described for use by ES6 Map
- * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
- *
- * NaN is considered the same as NaN, however -0 and 0 are considered the same
- * value, which is different from the algorithm described by
- * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
- *
- * This is extended further to allow Objects to describe the values they
- * represent, by way of `valueOf` or `equals` (and `hashCode`).
- *
- * Note: because of this extension, the key equality of Immutable.Map and the
- * value equality of Immutable.Set will differ from ES6 Map and Set.
- *
- * ### Defining custom values
- *
- * The easiest way to describe the value an object represents is by implementing
- * `valueOf`. For example, `Date` represents a value by returning a unix
- * timestamp for `valueOf`:
- *
- * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
- * var date2 = new Date(1234567890000);
- * date1.valueOf(); // 1234567890000
- * assert( date1 !== date2 );
- * assert( Immutable.is( date1, date2 ) );
- *
- * Note: overriding `valueOf` may have other implications if you use this object
- * where JavaScript expects a primitive, such as implicit string coercion.
- *
- * For more complex types, especially collections, implementing `valueOf` may
- * not be performant. An alternative is to implement `equals` and `hashCode`.
- *
- * `equals` takes another object, presumably of similar type, and returns true
- * if the it is equal. Equality is symmetrical, so the same result should be
- * returned if this and the argument are flipped.
- *
- * assert( a.equals(b) === b.equals(a) );
- *
- * `hashCode` returns a 32bit integer number representing the object which will
- * be used to determine how to store the value object in a Map or Set. You must
- * provide both or neither methods, one must not exist without the other.
- *
- * Also, an important relationship between these methods must be upheld: if two
- * values are equal, they *must* return the same hashCode. If the values are not
- * equal, they might have the same hashCode; this is called a hash collision,
- * and while undesirable for performance reasons, it is acceptable.
- *
- * if (a.equals(b)) {
- * assert( a.hashCode() === b.hashCode() );
- * }
- *
- * All Immutable collections implement `equals` and `hashCode`.
- *
- */
- function is(valueA, valueB) {
- if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
- return true;
- }
- if (!valueA || !valueB) {
- return false;
- }
- if (typeof valueA.valueOf === 'function' &&
- typeof valueB.valueOf === 'function') {
- valueA = valueA.valueOf();
- valueB = valueB.valueOf();
- if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
- return true;
- }
- if (!valueA || !valueB) {
- return false;
- }
- }
- if (typeof valueA.equals === 'function' &&
- typeof valueB.equals === 'function' &&
- valueA.equals(valueB)) {
- return true;
- }
- return false;
- }
-
- function deepEqual(a, b) {
- if (a === b) {
- return true;
- }
-
- if (
- !isIterable(b) ||
- a.size !== undefined && b.size !== undefined && a.size !== b.size ||
- a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash ||
- isKeyed(a) !== isKeyed(b) ||
- isIndexed(a) !== isIndexed(b) ||
- isOrdered(a) !== isOrdered(b)
- ) {
- return false;
- }
-
- if (a.size === 0 && b.size === 0) {
- return true;
- }
-
- var notAssociative = !isAssociative(a);
-
- if (isOrdered(a)) {
- var entries = a.entries();
- return b.every(function(v, k) {
- var entry = entries.next().value;
- return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
- }) && entries.next().done;
- }
-
- var flipped = false;
-
- if (a.size === undefined) {
- if (b.size === undefined) {
- if (typeof a.cacheResult === 'function') {
- a.cacheResult();
- }
- } else {
- flipped = true;
- var _ = a;
- a = b;
- b = _;
- }
- }
-
- var allEqual = true;
- var bSize = b.__iterate(function(v, k) {
- if (notAssociative ? !a.has(v) :
- flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) {
- allEqual = false;
- return false;
- }
- });
-
- return allEqual && a.size === bSize;
- }
-
- createClass(Repeat, IndexedSeq);
-
- function Repeat(value, times) {
- if (!(this instanceof Repeat)) {
- return new Repeat(value, times);
- }
- this._value = value;
- this.size = times === undefined ? Infinity : Math.max(0, times);
- if (this.size === 0) {
- if (EMPTY_REPEAT) {
- return EMPTY_REPEAT;
- }
- EMPTY_REPEAT = this;
- }
- }
-
- Repeat.prototype.toString = function() {
- if (this.size === 0) {
- return 'Repeat []';
- }
- return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
- };
-
- Repeat.prototype.get = function(index, notSetValue) {
- return this.has(index) ? this._value : notSetValue;
- };
-
- Repeat.prototype.includes = function(searchValue) {
- return is(this._value, searchValue);
- };
-
- Repeat.prototype.slice = function(begin, end) {
- var size = this.size;
- return wholeSlice(begin, end, size) ? this :
- new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size));
- };
-
- Repeat.prototype.reverse = function() {
- return this;
- };
-
- Repeat.prototype.indexOf = function(searchValue) {
- if (is(this._value, searchValue)) {
- return 0;
- }
- return -1;
- };
-
- Repeat.prototype.lastIndexOf = function(searchValue) {
- if (is(this._value, searchValue)) {
- return this.size;
- }
- return -1;
- };
-
- Repeat.prototype.__iterate = function(fn, reverse) {
- for (var ii = 0; ii < this.size; ii++) {
- if (fn(this._value, ii, this) === false) {
- return ii + 1;
- }
- }
- return ii;
- };
-
- Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this;
- var ii = 0;
- return new Iterator(function()
- {return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()}
- );
- };
-
- Repeat.prototype.equals = function(other) {
- return other instanceof Repeat ?
- is(this._value, other._value) :
- deepEqual(other);
- };
-
-
- var EMPTY_REPEAT;
-
- function invariant(condition, error) {
- if (!condition) throw new Error(error);
- }
-
- createClass(Range, IndexedSeq);
-
- function Range(start, end, step) {
- if (!(this instanceof Range)) {
- return new Range(start, end, step);
- }
- invariant(step !== 0, 'Cannot step a Range by 0');
- start = start || 0;
- if (end === undefined) {
- end = Infinity;
- }
- step = step === undefined ? 1 : Math.abs(step);
- if (end < start) {
- step = -step;
- }
- this._start = start;
- this._end = end;
- this._step = step;
- this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
- if (this.size === 0) {
- if (EMPTY_RANGE) {
- return EMPTY_RANGE;
- }
- EMPTY_RANGE = this;
- }
- }
-
- Range.prototype.toString = function() {
- if (this.size === 0) {
- return 'Range []';
- }
- return 'Range [ ' +
- this._start + '...' + this._end +
- (this._step > 1 ? ' by ' + this._step : '') +
- ' ]';
- };
-
- Range.prototype.get = function(index, notSetValue) {
- return this.has(index) ?
- this._start + wrapIndex(this, index) * this._step :
- notSetValue;
- };
-
- Range.prototype.includes = function(searchValue) {
- var possibleIndex = (searchValue - this._start) / this._step;
- return possibleIndex >= 0 &&
- possibleIndex < this.size &&
- possibleIndex === Math.floor(possibleIndex);
- };
-
- Range.prototype.slice = function(begin, end) {
- if (wholeSlice(begin, end, this.size)) {
- return this;
- }
- begin = resolveBegin(begin, this.size);
- end = resolveEnd(end, this.size);
- if (end <= begin) {
- return new Range(0, 0);
- }
- return new Range(this.get(begin, this._end), this.get(end, this._end), this._step);
- };
-
- Range.prototype.indexOf = function(searchValue) {
- var offsetValue = searchValue - this._start;
- if (offsetValue % this._step === 0) {
- var index = offsetValue / this._step;
- if (index >= 0 && index < this.size) {
- return index
- }
- }
- return -1;
- };
-
- Range.prototype.lastIndexOf = function(searchValue) {
- return this.indexOf(searchValue);
- };
-
- Range.prototype.__iterate = function(fn, reverse) {
- var maxIndex = this.size - 1;
- var step = this._step;
- var value = reverse ? this._start + maxIndex * step : this._start;
- for (var ii = 0; ii <= maxIndex; ii++) {
- if (fn(value, ii, this) === false) {
- return ii + 1;
- }
- value += reverse ? -step : step;
- }
- return ii;
- };
-
- Range.prototype.__iterator = function(type, reverse) {
- var maxIndex = this.size - 1;
- var step = this._step;
- var value = reverse ? this._start + maxIndex * step : this._start;
- var ii = 0;
- return new Iterator(function() {
- var v = value;
- value += reverse ? -step : step;
- return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
- });
- };
-
- Range.prototype.equals = function(other) {
- return other instanceof Range ?
- this._start === other._start &&
- this._end === other._end &&
- this._step === other._step :
- deepEqual(this, other);
- };
-
-
- var EMPTY_RANGE;
-
- createClass(Collection, Iterable);
- function Collection() {
- throw TypeError('Abstract');
- }
-
-
- createClass(KeyedCollection, Collection);function KeyedCollection() {}
-
- createClass(IndexedCollection, Collection);function IndexedCollection() {}
-
- createClass(SetCollection, Collection);function SetCollection() {}
-
-
- Collection.Keyed = KeyedCollection;
- Collection.Indexed = IndexedCollection;
- Collection.Set = SetCollection;
-
- var imul =
- typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ?
- Math.imul :
- function imul(a, b) {
- a = a | 0; // int
- b = b | 0; // int
- var c = a & 0xffff;
- var d = b & 0xffff;
- // Shift by 0 fixes the sign on the high part.
- return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int
- };
-
- // v8 has an optimization for storing 31-bit signed numbers.
- // Values which have either 00 or 11 as the high order bits qualify.
- // This function drops the highest order bit in a signed number, maintaining
- // the sign bit.
- function smi(i32) {
- return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF);
- }
-
- function hash(o) {
- if (o === false || o === null || o === undefined) {
- return 0;
- }
- if (typeof o.valueOf === 'function') {
- o = o.valueOf();
- if (o === false || o === null || o === undefined) {
- return 0;
- }
- }
- if (o === true) {
- return 1;
- }
- var type = typeof o;
- if (type === 'number') {
- var h = o | 0;
- if (h !== o) {
- h ^= o * 0xFFFFFFFF;
- }
- while (o > 0xFFFFFFFF) {
- o /= 0xFFFFFFFF;
- h ^= o;
- }
- return smi(h);
- }
- if (type === 'string') {
- return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o);
- }
- if (typeof o.hashCode === 'function') {
- return o.hashCode();
- }
- if (type === 'object') {
- return hashJSObj(o);
- }
- if (typeof o.toString === 'function') {
- return hashString(o.toString());
- }
- throw new Error('Value type ' + type + ' cannot be hashed.');
- }
-
- function cachedHashString(string) {
- var hash = stringHashCache[string];
- if (hash === undefined) {
- hash = hashString(string);
- if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
- STRING_HASH_CACHE_SIZE = 0;
- stringHashCache = {};
- }
- STRING_HASH_CACHE_SIZE++;
- stringHashCache[string] = hash;
- }
- return hash;
- }
-
- // http://jsperf.com/hashing-strings
- function hashString(string) {
- // This is the hash from JVM
- // The hash code for a string is computed as
- // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
- // where s[i] is the ith character of the string and n is the length of
- // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
- // (exclusive) by dropping high bits.
- var hash = 0;
- for (var ii = 0; ii < string.length; ii++) {
- hash = 31 * hash + string.charCodeAt(ii) | 0;
- }
- return smi(hash);
- }
-
- function hashJSObj(obj) {
- var hash;
- if (usingWeakMap) {
- hash = weakMap.get(obj);
- if (hash !== undefined) {
- return hash;
- }
- }
-
- hash = obj[UID_HASH_KEY];
- if (hash !== undefined) {
- return hash;
- }
-
- if (!canDefineProperty) {
- hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
- if (hash !== undefined) {
- return hash;
- }
-
- hash = getIENodeHash(obj);
- if (hash !== undefined) {
- return hash;
- }
- }
-
- hash = ++objHashUID;
- if (objHashUID & 0x40000000) {
- objHashUID = 0;
- }
-
- if (usingWeakMap) {
- weakMap.set(obj, hash);
- } else if (isExtensible !== undefined && isExtensible(obj) === false) {
- throw new Error('Non-extensible objects are not allowed as keys.');
- } else if (canDefineProperty) {
- Object.defineProperty(obj, UID_HASH_KEY, {
- 'enumerable': false,
- 'configurable': false,
- 'writable': false,
- 'value': hash
- });
- } else if (obj.propertyIsEnumerable !== undefined &&
- obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {
- // Since we can't define a non-enumerable property on the object
- // we'll hijack one of the less-used non-enumerable properties to
- // save our hash on it. Since this is a function it will not show up in
- // `JSON.stringify` which is what we want.
- obj.propertyIsEnumerable = function() {
- return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
- };
- obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
- } else if (obj.nodeType !== undefined) {
- // At this point we couldn't get the IE `uniqueID` to use as a hash
- // and we couldn't use a non-enumerable property to exploit the
- // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
- // itself.
- obj[UID_HASH_KEY] = hash;
- } else {
- throw new Error('Unable to set a non-enumerable property on object.');
- }
-
- return hash;
- }
-
- // Get references to ES5 object methods.
- var isExtensible = Object.isExtensible;
-
- // True if Object.defineProperty works as expected. IE8 fails this test.
- var canDefineProperty = (function() {
- try {
- Object.defineProperty({}, '@', {});
- return true;
- } catch (e) {
- return false;
- }
- }());
-
- // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
- // and avoid memory leaks from the IE cloneNode bug.
- function getIENodeHash(node) {
- if (node && node.nodeType > 0) {
- switch (node.nodeType) {
- case 1: // Element
- return node.uniqueID;
- case 9: // Document
- return node.documentElement && node.documentElement.uniqueID;
- }
- }
- }
-
- // If possible, use a WeakMap.
- var usingWeakMap = typeof WeakMap === 'function';
- var weakMap;
- if (usingWeakMap) {
- weakMap = new WeakMap();
- }
-
- var objHashUID = 0;
-
- var UID_HASH_KEY = '__immutablehash__';
- if (typeof Symbol === 'function') {
- UID_HASH_KEY = Symbol(UID_HASH_KEY);
- }
-
- var STRING_HASH_CACHE_MIN_STRLEN = 16;
- var STRING_HASH_CACHE_MAX_SIZE = 255;
- var STRING_HASH_CACHE_SIZE = 0;
- var stringHashCache = {};
-
- function assertNotInfinite(size) {
- invariant(
- size !== Infinity,
- 'Cannot perform this action with an infinite size.'
- );
- }
-
- createClass(Map, KeyedCollection);
-
- // @pragma Construction
-
- function Map(value) {
- return value === null || value === undefined ? emptyMap() :
- isMap(value) && !isOrdered(value) ? value :
- emptyMap().withMutations(function(map ) {
- var iter = KeyedIterable(value);
- assertNotInfinite(iter.size);
- iter.forEach(function(v, k) {return map.set(k, v)});
- });
- }
-
- Map.prototype.toString = function() {
- return this.__toString('Map {', '}');
- };
-
- // @pragma Access
-
- Map.prototype.get = function(k, notSetValue) {
- return this._root ?
- this._root.get(0, undefined, k, notSetValue) :
- notSetValue;
- };
-
- // @pragma Modification
-
- Map.prototype.set = function(k, v) {
- return updateMap(this, k, v);
- };
-
- Map.prototype.setIn = function(keyPath, v) {
- return this.updateIn(keyPath, NOT_SET, function() {return v});
- };
-
- Map.prototype.remove = function(k) {
- return updateMap(this, k, NOT_SET);
- };
-
- Map.prototype.deleteIn = function(keyPath) {
- return this.updateIn(keyPath, function() {return NOT_SET});
- };
-
- Map.prototype.update = function(k, notSetValue, updater) {
- return arguments.length === 1 ?
- k(this) :
- this.updateIn([k], notSetValue, updater);
- };
-
- Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
- if (!updater) {
- updater = notSetValue;
- notSetValue = undefined;
- }
- var updatedValue = updateInDeepMap(
- this,
- forceIterator(keyPath),
- notSetValue,
- updater
- );
- return updatedValue === NOT_SET ? undefined : updatedValue;
- };
-
- Map.prototype.clear = function() {
- if (this.size === 0) {
- return this;
- }
- if (this.__ownerID) {
- this.size = 0;
- this._root = null;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return emptyMap();
- };
-
- // @pragma Composition
-
- Map.prototype.merge = function(/*...iters*/) {
- return mergeIntoMapWith(this, undefined, arguments);
- };
-
- Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
- return mergeIntoMapWith(this, merger, iters);
- };
-
- Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
- return this.updateIn(
- keyPath,
- emptyMap(),
- function(m ) {return typeof m.merge === 'function' ?
- m.merge.apply(m, iters) :
- iters[iters.length - 1]}
- );
- };
-
- Map.prototype.mergeDeep = function(/*...iters*/) {
- return mergeIntoMapWith(this, deepMerger, arguments);
- };
-
- Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
- return mergeIntoMapWith(this, deepMergerWith(merger), iters);
- };
-
- Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
- return this.updateIn(
- keyPath,
- emptyMap(),
- function(m ) {return typeof m.mergeDeep === 'function' ?
- m.mergeDeep.apply(m, iters) :
- iters[iters.length - 1]}
- );
- };
-
- Map.prototype.sort = function(comparator) {
- // Late binding
- return OrderedMap(sortFactory(this, comparator));
- };
-
- Map.prototype.sortBy = function(mapper, comparator) {
- // Late binding
- return OrderedMap(sortFactory(this, comparator, mapper));
- };
-
- // @pragma Mutability
-
- Map.prototype.withMutations = function(fn) {
- var mutable = this.asMutable();
- fn(mutable);
- return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
- };
-
- Map.prototype.asMutable = function() {
- return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
- };
-
- Map.prototype.asImmutable = function() {
- return this.__ensureOwner();
- };
-
- Map.prototype.wasAltered = function() {
- return this.__altered;
- };
-
- Map.prototype.__iterator = function(type, reverse) {
- return new MapIterator(this, type, reverse);
- };
-
- Map.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- var iterations = 0;
- this._root && this._root.iterate(function(entry ) {
- iterations++;
- return fn(entry[1], entry[0], this$0);
- }, reverse);
- return iterations;
- };
-
- Map.prototype.__ensureOwner = function(ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- if (!ownerID) {
- this.__ownerID = ownerID;
- this.__altered = false;
- return this;
- }
- return makeMap(this.size, this._root, ownerID, this.__hash);
- };
-
-
- function isMap(maybeMap) {
- return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
- }
-
- Map.isMap = isMap;
-
- var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
-
- var MapPrototype = Map.prototype;
- MapPrototype[IS_MAP_SENTINEL] = true;
- MapPrototype[DELETE] = MapPrototype.remove;
- MapPrototype.removeIn = MapPrototype.deleteIn;
-
-
- // #pragma Trie Nodes
-
-
-
- function ArrayMapNode(ownerID, entries) {
- this.ownerID = ownerID;
- this.entries = entries;
- }
-
- ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
- var entries = this.entries;
- for (var ii = 0, len = entries.length; ii < len; ii++) {
- if (is(key, entries[ii][0])) {
- return entries[ii][1];
- }
- }
- return notSetValue;
- };
-
- ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- var removed = value === NOT_SET;
-
- var entries = this.entries;
- var idx = 0;
- for (var len = entries.length; idx < len; idx++) {
- if (is(key, entries[idx][0])) {
- break;
- }
- }
- var exists = idx < len;
-
- if (exists ? entries[idx][1] === value : removed) {
- return this;
- }
-
- SetRef(didAlter);
- (removed || !exists) && SetRef(didChangeSize);
-
- if (removed && entries.length === 1) {
- return; // undefined
- }
-
- if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
- return createNodes(ownerID, entries, key, value);
- }
-
- var isEditable = ownerID && ownerID === this.ownerID;
- var newEntries = isEditable ? entries : arrCopy(entries);
-
- if (exists) {
- if (removed) {
- idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
- } else {
- newEntries[idx] = [key, value];
- }
- } else {
- newEntries.push([key, value]);
- }
-
- if (isEditable) {
- this.entries = newEntries;
- return this;
- }
-
- return new ArrayMapNode(ownerID, newEntries);
- };
-
-
-
-
- function BitmapIndexedNode(ownerID, bitmap, nodes) {
- this.ownerID = ownerID;
- this.bitmap = bitmap;
- this.nodes = nodes;
- }
-
- BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) {
- if (keyHash === undefined) {
- keyHash = hash(key);
- }
- var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK));
- var bitmap = this.bitmap;
- return (bitmap & bit) === 0 ? notSetValue :
- this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue);
- };
-
- BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- if (keyHash === undefined) {
- keyHash = hash(key);
- }
- var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
- var bit = 1 << keyHashFrag;
- var bitmap = this.bitmap;
- var exists = (bitmap & bit) !== 0;
-
- if (!exists && value === NOT_SET) {
- return this;
- }
-
- var idx = popCount(bitmap & (bit - 1));
- var nodes = this.nodes;
- var node = exists ? nodes[idx] : undefined;
- var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
-
- if (newNode === node) {
- return this;
- }
-
- if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
- return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
- }
-
- if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) {
- return nodes[idx ^ 1];
- }
-
- if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
- return newNode;
- }
-
- var isEditable = ownerID && ownerID === this.ownerID;
- var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit;
- var newNodes = exists ? newNode ?
- setIn(nodes, idx, newNode, isEditable) :
- spliceOut(nodes, idx, isEditable) :
- spliceIn(nodes, idx, newNode, isEditable);
-
- if (isEditable) {
- this.bitmap = newBitmap;
- this.nodes = newNodes;
- return this;
- }
-
- return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
- };
-
-
-
-
- function HashArrayMapNode(ownerID, count, nodes) {
- this.ownerID = ownerID;
- this.count = count;
- this.nodes = nodes;
- }
-
- HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
- if (keyHash === undefined) {
- keyHash = hash(key);
- }
- var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
- var node = this.nodes[idx];
- return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue;
- };
-
- HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- if (keyHash === undefined) {
- keyHash = hash(key);
- }
- var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
- var removed = value === NOT_SET;
- var nodes = this.nodes;
- var node = nodes[idx];
-
- if (removed && !node) {
- return this;
- }
-
- var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
- if (newNode === node) {
- return this;
- }
-
- var newCount = this.count;
- if (!node) {
- newCount++;
- } else if (!newNode) {
- newCount--;
- if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
- return packNodes(ownerID, nodes, newCount, idx);
- }
- }
-
- var isEditable = ownerID && ownerID === this.ownerID;
- var newNodes = setIn(nodes, idx, newNode, isEditable);
-
- if (isEditable) {
- this.count = newCount;
- this.nodes = newNodes;
- return this;
- }
-
- return new HashArrayMapNode(ownerID, newCount, newNodes);
- };
-
-
-
-
- function HashCollisionNode(ownerID, keyHash, entries) {
- this.ownerID = ownerID;
- this.keyHash = keyHash;
- this.entries = entries;
- }
-
- HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) {
- var entries = this.entries;
- for (var ii = 0, len = entries.length; ii < len; ii++) {
- if (is(key, entries[ii][0])) {
- return entries[ii][1];
- }
- }
- return notSetValue;
- };
-
- HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- if (keyHash === undefined) {
- keyHash = hash(key);
- }
-
- var removed = value === NOT_SET;
-
- if (keyHash !== this.keyHash) {
- if (removed) {
- return this;
- }
- SetRef(didAlter);
- SetRef(didChangeSize);
- return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
- }
-
- var entries = this.entries;
- var idx = 0;
- for (var len = entries.length; idx < len; idx++) {
- if (is(key, entries[idx][0])) {
- break;
- }
- }
- var exists = idx < len;
-
- if (exists ? entries[idx][1] === value : removed) {
- return this;
- }
-
- SetRef(didAlter);
- (removed || !exists) && SetRef(didChangeSize);
-
- if (removed && len === 2) {
- return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
- }
-
- var isEditable = ownerID && ownerID === this.ownerID;
- var newEntries = isEditable ? entries : arrCopy(entries);
-
- if (exists) {
- if (removed) {
- idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
- } else {
- newEntries[idx] = [key, value];
- }
- } else {
- newEntries.push([key, value]);
- }
-
- if (isEditable) {
- this.entries = newEntries;
- return this;
- }
-
- return new HashCollisionNode(ownerID, this.keyHash, newEntries);
- };
-
-
-
-
- function ValueNode(ownerID, keyHash, entry) {
- this.ownerID = ownerID;
- this.keyHash = keyHash;
- this.entry = entry;
- }
-
- ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
- return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
- };
-
- ValueNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- var removed = value === NOT_SET;
- var keyMatch = is(key, this.entry[0]);
- if (keyMatch ? value === this.entry[1] : removed) {
- return this;
- }
-
- SetRef(didAlter);
-
- if (removed) {
- SetRef(didChangeSize);
- return; // undefined
- }
-
- if (keyMatch) {
- if (ownerID && ownerID === this.ownerID) {
- this.entry[1] = value;
- return this;
- }
- return new ValueNode(ownerID, this.keyHash, [key, value]);
- }
-
- SetRef(didChangeSize);
- return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
- };
-
-
-
- // #pragma Iterators
-
- ArrayMapNode.prototype.iterate =
- HashCollisionNode.prototype.iterate = function (fn, reverse) {
- var entries = this.entries;
- for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
- if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
- return false;
- }
- }
- };
-
- BitmapIndexedNode.prototype.iterate =
- HashArrayMapNode.prototype.iterate = function (fn, reverse) {
- var nodes = this.nodes;
- for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
- var node = nodes[reverse ? maxIndex - ii : ii];
- if (node && node.iterate(fn, reverse) === false) {
- return false;
- }
- }
- };
-
- ValueNode.prototype.iterate = function (fn, reverse) {
- return fn(this.entry);
- };
-
- createClass(MapIterator, Iterator);
-
- function MapIterator(map, type, reverse) {
- this._type = type;
- this._reverse = reverse;
- this._stack = map._root && mapIteratorFrame(map._root);
- }
-
- MapIterator.prototype.next = function() {
- var type = this._type;
- var stack = this._stack;
- while (stack) {
- var node = stack.node;
- var index = stack.index++;
- var maxIndex;
- if (node.entry) {
- if (index === 0) {
- return mapIteratorValue(type, node.entry);
- }
- } else if (node.entries) {
- maxIndex = node.entries.length - 1;
- if (index <= maxIndex) {
- return mapIteratorValue(type, node.entries[this._reverse ? maxIndex - index : index]);
- }
- } else {
- maxIndex = node.nodes.length - 1;
- if (index <= maxIndex) {
- var subNode = node.nodes[this._reverse ? maxIndex - index : index];
- if (subNode) {
- if (subNode.entry) {
- return mapIteratorValue(type, subNode.entry);
- }
- stack = this._stack = mapIteratorFrame(subNode, stack);
- }
- continue;
- }
- }
- stack = this._stack = this._stack.__prev;
- }
- return iteratorDone();
- };
-
-
- function mapIteratorValue(type, entry) {
- return iteratorValue(type, entry[0], entry[1]);
- }
-
- function mapIteratorFrame(node, prev) {
- return {
- node: node,
- index: 0,
- __prev: prev
- };
- }
-
- function makeMap(size, root, ownerID, hash) {
- var map = Object.create(MapPrototype);
- map.size = size;
- map._root = root;
- map.__ownerID = ownerID;
- map.__hash = hash;
- map.__altered = false;
- return map;
- }
-
- var EMPTY_MAP;
- function emptyMap() {
- return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
- }
-
- function updateMap(map, k, v) {
- var newRoot;
- var newSize;
- if (!map._root) {
- if (v === NOT_SET) {
- return map;
- }
- newSize = 1;
- newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
- } else {
- var didChangeSize = MakeRef(CHANGE_LENGTH);
- var didAlter = MakeRef(DID_ALTER);
- newRoot = updateNode(map._root, map.__ownerID, 0, undefined, k, v, didChangeSize, didAlter);
- if (!didAlter.value) {
- return map;
- }
- newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0);
- }
- if (map.__ownerID) {
- map.size = newSize;
- map._root = newRoot;
- map.__hash = undefined;
- map.__altered = true;
- return map;
- }
- return newRoot ? makeMap(newSize, newRoot) : emptyMap();
- }
-
- function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- if (!node) {
- if (value === NOT_SET) {
- return node;
- }
- SetRef(didAlter);
- SetRef(didChangeSize);
- return new ValueNode(ownerID, keyHash, [key, value]);
- }
- return node.update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter);
- }
-
- function isLeafNode(node) {
- return node.constructor === ValueNode || node.constructor === HashCollisionNode;
- }
-
- function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
- if (node.keyHash === keyHash) {
- return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
- }
-
- var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
- var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
-
- var newNode;
- var nodes = idx1 === idx2 ?
- [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] :
- ((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 ? [node, newNode] : [newNode, node]);
-
- return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
- }
-
- function createNodes(ownerID, entries, key, value) {
- if (!ownerID) {
- ownerID = new OwnerID();
- }
- var node = new ValueNode(ownerID, hash(key), [key, value]);
- for (var ii = 0; ii < entries.length; ii++) {
- var entry = entries[ii];
- node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
- }
- return node;
- }
-
- function packNodes(ownerID, nodes, count, excluding) {
- var bitmap = 0;
- var packedII = 0;
- var packedNodes = new Array(count);
- for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
- var node = nodes[ii];
- if (node !== undefined && ii !== excluding) {
- bitmap |= bit;
- packedNodes[packedII++] = node;
- }
- }
- return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
- }
-
- function expandNodes(ownerID, nodes, bitmap, including, node) {
- var count = 0;
- var expandedNodes = new Array(SIZE);
- for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
- expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
- }
- expandedNodes[including] = node;
- return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
- }
-
- function mergeIntoMapWith(map, merger, iterables) {
- var iters = [];
- for (var ii = 0; ii < iterables.length; ii++) {
- var value = iterables[ii];
- var iter = KeyedIterable(value);
- if (!isIterable(value)) {
- iter = iter.map(function(v ) {return fromJS(v)});
- }
- iters.push(iter);
- }
- return mergeIntoCollectionWith(map, merger, iters);
- }
-
- function deepMerger(existing, value, key) {
- return existing && existing.mergeDeep && isIterable(value) ?
- existing.mergeDeep(value) :
- is(existing, value) ? existing : value;
- }
-
- function deepMergerWith(merger) {
- return function(existing, value, key) {
- if (existing && existing.mergeDeepWith && isIterable(value)) {
- return existing.mergeDeepWith(merger, value);
- }
- var nextValue = merger(existing, value, key);
- return is(existing, nextValue) ? existing : nextValue;
- };
- }
-
- function mergeIntoCollectionWith(collection, merger, iters) {
- iters = iters.filter(function(x ) {return x.size !== 0});
- if (iters.length === 0) {
- return collection;
- }
- if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
- return collection.constructor(iters[0]);
- }
- return collection.withMutations(function(collection ) {
- var mergeIntoMap = merger ?
- function(value, key) {
- collection.update(key, NOT_SET, function(existing )
- {return existing === NOT_SET ? value : merger(existing, value, key)}
- );
- } :
- function(value, key) {
- collection.set(key, value);
- };
- for (var ii = 0; ii < iters.length; ii++) {
- iters[ii].forEach(mergeIntoMap);
- }
- });
- }
-
- function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
- var isNotSet = existing === NOT_SET;
- var step = keyPathIter.next();
- if (step.done) {
- var existingValue = isNotSet ? notSetValue : existing;
- var newValue = updater(existingValue);
- return newValue === existingValue ? existing : newValue;
- }
- invariant(
- isNotSet || (existing && existing.set),
- 'invalid keyPath'
- );
- var key = step.value;
- var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
- var nextUpdated = updateInDeepMap(
- nextExisting,
- keyPathIter,
- notSetValue,
- updater
- );
- return nextUpdated === nextExisting ? existing :
- nextUpdated === NOT_SET ? existing.remove(key) :
- (isNotSet ? emptyMap() : existing).set(key, nextUpdated);
- }
-
- function popCount(x) {
- x = x - ((x >> 1) & 0x55555555);
- x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
- x = (x + (x >> 4)) & 0x0f0f0f0f;
- x = x + (x >> 8);
- x = x + (x >> 16);
- return x & 0x7f;
- }
-
- function setIn(array, idx, val, canEdit) {
- var newArray = canEdit ? array : arrCopy(array);
- newArray[idx] = val;
- return newArray;
- }
-
- function spliceIn(array, idx, val, canEdit) {
- var newLen = array.length + 1;
- if (canEdit && idx + 1 === newLen) {
- array[idx] = val;
- return array;
- }
- var newArray = new Array(newLen);
- var after = 0;
- for (var ii = 0; ii < newLen; ii++) {
- if (ii === idx) {
- newArray[ii] = val;
- after = -1;
- } else {
- newArray[ii] = array[ii + after];
- }
- }
- return newArray;
- }
-
- function spliceOut(array, idx, canEdit) {
- var newLen = array.length - 1;
- if (canEdit && idx === newLen) {
- array.pop();
- return array;
- }
- var newArray = new Array(newLen);
- var after = 0;
- for (var ii = 0; ii < newLen; ii++) {
- if (ii === idx) {
- after = 1;
- }
- newArray[ii] = array[ii + after];
- }
- return newArray;
- }
-
- var MAX_ARRAY_MAP_SIZE = SIZE / 4;
- var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
- var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
-
- createClass(List, IndexedCollection);
-
- // @pragma Construction
-
- function List(value) {
- var empty = emptyList();
- if (value === null || value === undefined) {
- return empty;
- }
- if (isList(value)) {
- return value;
- }
- var iter = IndexedIterable(value);
- var size = iter.size;
- if (size === 0) {
- return empty;
- }
- assertNotInfinite(size);
- if (size > 0 && size < SIZE) {
- return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
- }
- return empty.withMutations(function(list ) {
- list.setSize(size);
- iter.forEach(function(v, i) {return list.set(i, v)});
- });
- }
-
- List.of = function(/*...values*/) {
- return this(arguments);
- };
-
- List.prototype.toString = function() {
- return this.__toString('List [', ']');
- };
-
- // @pragma Access
-
- List.prototype.get = function(index, notSetValue) {
- index = wrapIndex(this, index);
- if (index >= 0 && index < this.size) {
- index += this._origin;
- var node = listNodeFor(this, index);
- return node && node.array[index & MASK];
- }
- return notSetValue;
- };
-
- // @pragma Modification
-
- List.prototype.set = function(index, value) {
- return updateList(this, index, value);
- };
-
- List.prototype.remove = function(index) {
- return !this.has(index) ? this :
- index === 0 ? this.shift() :
- index === this.size - 1 ? this.pop() :
- this.splice(index, 1);
- };
-
- List.prototype.insert = function(index, value) {
- return this.splice(index, 0, value);
- };
-
- List.prototype.clear = function() {
- if (this.size === 0) {
- return this;
- }
- if (this.__ownerID) {
- this.size = this._origin = this._capacity = 0;
- this._level = SHIFT;
- this._root = this._tail = null;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return emptyList();
- };
-
- List.prototype.push = function(/*...values*/) {
- var values = arguments;
- var oldSize = this.size;
- return this.withMutations(function(list ) {
- setListBounds(list, 0, oldSize + values.length);
- for (var ii = 0; ii < values.length; ii++) {
- list.set(oldSize + ii, values[ii]);
- }
- });
- };
-
- List.prototype.pop = function() {
- return setListBounds(this, 0, -1);
- };
-
- List.prototype.unshift = function(/*...values*/) {
- var values = arguments;
- return this.withMutations(function(list ) {
- setListBounds(list, -values.length);
- for (var ii = 0; ii < values.length; ii++) {
- list.set(ii, values[ii]);
- }
- });
- };
-
- List.prototype.shift = function() {
- return setListBounds(this, 1);
- };
-
- // @pragma Composition
-
- List.prototype.merge = function(/*...iters*/) {
- return mergeIntoListWith(this, undefined, arguments);
- };
-
- List.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
- return mergeIntoListWith(this, merger, iters);
- };
-
- List.prototype.mergeDeep = function(/*...iters*/) {
- return mergeIntoListWith(this, deepMerger, arguments);
- };
-
- List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
- return mergeIntoListWith(this, deepMergerWith(merger), iters);
- };
-
- List.prototype.setSize = function(size) {
- return setListBounds(this, 0, size);
- };
-
- // @pragma Iteration
-
- List.prototype.slice = function(begin, end) {
- var size = this.size;
- if (wholeSlice(begin, end, size)) {
- return this;
- }
- return setListBounds(
- this,
- resolveBegin(begin, size),
- resolveEnd(end, size)
- );
- };
-
- List.prototype.__iterator = function(type, reverse) {
- var index = 0;
- var values = iterateList(this, reverse);
- return new Iterator(function() {
- var value = values();
- return value === DONE ?
- iteratorDone() :
- iteratorValue(type, index++, value);
- });
- };
-
- List.prototype.__iterate = function(fn, reverse) {
- var index = 0;
- var values = iterateList(this, reverse);
- var value;
- while ((value = values()) !== DONE) {
- if (fn(value, index++, this) === false) {
- break;
- }
- }
- return index;
- };
-
- List.prototype.__ensureOwner = function(ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- if (!ownerID) {
- this.__ownerID = ownerID;
- return this;
- }
- return makeList(this._origin, this._capacity, this._level, this._root, this._tail, ownerID, this.__hash);
- };
-
-
- function isList(maybeList) {
- return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
- }
-
- List.isList = isList;
-
- var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
-
- var ListPrototype = List.prototype;
- ListPrototype[IS_LIST_SENTINEL] = true;
- ListPrototype[DELETE] = ListPrototype.remove;
- ListPrototype.setIn = MapPrototype.setIn;
- ListPrototype.deleteIn =
- ListPrototype.removeIn = MapPrototype.removeIn;
- ListPrototype.update = MapPrototype.update;
- ListPrototype.updateIn = MapPrototype.updateIn;
- ListPrototype.mergeIn = MapPrototype.mergeIn;
- ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
- ListPrototype.withMutations = MapPrototype.withMutations;
- ListPrototype.asMutable = MapPrototype.asMutable;
- ListPrototype.asImmutable = MapPrototype.asImmutable;
- ListPrototype.wasAltered = MapPrototype.wasAltered;
-
-
-
- function VNode(array, ownerID) {
- this.array = array;
- this.ownerID = ownerID;
- }
-
- // TODO: seems like these methods are very similar
-
- VNode.prototype.removeBefore = function(ownerID, level, index) {
- if (index === level ? 1 << level : this.array.length === 0) {
- return this;
- }
- var originIndex = (index >>> level) & MASK;
- if (originIndex >= this.array.length) {
- return new VNode([], ownerID);
- }
- var removingFirst = originIndex === 0;
- var newChild;
- if (level > 0) {
- var oldChild = this.array[originIndex];
- newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
- if (newChild === oldChild && removingFirst) {
- return this;
- }
- }
- if (removingFirst && !newChild) {
- return this;
- }
- var editable = editableVNode(this, ownerID);
- if (!removingFirst) {
- for (var ii = 0; ii < originIndex; ii++) {
- editable.array[ii] = undefined;
- }
- }
- if (newChild) {
- editable.array[originIndex] = newChild;
- }
- return editable;
- };
-
- VNode.prototype.removeAfter = function(ownerID, level, index) {
- if (index === (level ? 1 << level : 0) || this.array.length === 0) {
- return this;
- }
- var sizeIndex = ((index - 1) >>> level) & MASK;
- if (sizeIndex >= this.array.length) {
- return this;
- }
-
- var newChild;
- if (level > 0) {
- var oldChild = this.array[sizeIndex];
- newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
- if (newChild === oldChild && sizeIndex === this.array.length - 1) {
- return this;
- }
- }
-
- var editable = editableVNode(this, ownerID);
- editable.array.splice(sizeIndex + 1);
- if (newChild) {
- editable.array[sizeIndex] = newChild;
- }
- return editable;
- };
-
-
-
- var DONE = {};
-
- function iterateList(list, reverse) {
- var left = list._origin;
- var right = list._capacity;
- var tailPos = getTailOffset(right);
- var tail = list._tail;
-
- return iterateNodeOrLeaf(list._root, list._level, 0);
-
- function iterateNodeOrLeaf(node, level, offset) {
- return level === 0 ?
- iterateLeaf(node, offset) :
- iterateNode(node, level, offset);
- }
-
- function iterateLeaf(node, offset) {
- var array = offset === tailPos ? tail && tail.array : node && node.array;
- var from = offset > left ? 0 : left - offset;
- var to = right - offset;
- if (to > SIZE) {
- to = SIZE;
- }
- return function() {
- if (from === to) {
- return DONE;
- }
- var idx = reverse ? --to : from++;
- return array && array[idx];
- };
- }
-
- function iterateNode(node, level, offset) {
- var values;
- var array = node && node.array;
- var from = offset > left ? 0 : (left - offset) >> level;
- var to = ((right - offset) >> level) + 1;
- if (to > SIZE) {
- to = SIZE;
- }
- return function() {
- do {
- if (values) {
- var value = values();
- if (value !== DONE) {
- return value;
- }
- values = null;
- }
- if (from === to) {
- return DONE;
- }
- var idx = reverse ? --to : from++;
- values = iterateNodeOrLeaf(
- array && array[idx], level - SHIFT, offset + (idx << level)
- );
- } while (true);
- };
- }
- }
-
- function makeList(origin, capacity, level, root, tail, ownerID, hash) {
- var list = Object.create(ListPrototype);
- list.size = capacity - origin;
- list._origin = origin;
- list._capacity = capacity;
- list._level = level;
- list._root = root;
- list._tail = tail;
- list.__ownerID = ownerID;
- list.__hash = hash;
- list.__altered = false;
- return list;
- }
-
- var EMPTY_LIST;
- function emptyList() {
- return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
- }
-
- function updateList(list, index, value) {
- index = wrapIndex(list, index);
-
- if (index !== index) {
- return list;
- }
-
- if (index >= list.size || index < 0) {
- return list.withMutations(function(list ) {
- index < 0 ?
- setListBounds(list, index).set(0, value) :
- setListBounds(list, 0, index + 1).set(index, value);
- });
- }
-
- index += list._origin;
-
- var newTail = list._tail;
- var newRoot = list._root;
- var didAlter = MakeRef(DID_ALTER);
- if (index >= getTailOffset(list._capacity)) {
- newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
- } else {
- newRoot = updateVNode(newRoot, list.__ownerID, list._level, index, value, didAlter);
- }
-
- if (!didAlter.value) {
- return list;
- }
-
- if (list.__ownerID) {
- list._root = newRoot;
- list._tail = newTail;
- list.__hash = undefined;
- list.__altered = true;
- return list;
- }
- return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
- }
-
- function updateVNode(node, ownerID, level, index, value, didAlter) {
- var idx = (index >>> level) & MASK;
- var nodeHas = node && idx < node.array.length;
- if (!nodeHas && value === undefined) {
- return node;
- }
-
- var newNode;
-
- if (level > 0) {
- var lowerNode = node && node.array[idx];
- var newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter);
- if (newLowerNode === lowerNode) {
- return node;
- }
- newNode = editableVNode(node, ownerID);
- newNode.array[idx] = newLowerNode;
- return newNode;
- }
-
- if (nodeHas && node.array[idx] === value) {
- return node;
- }
-
- SetRef(didAlter);
-
- newNode = editableVNode(node, ownerID);
- if (value === undefined && idx === newNode.array.length - 1) {
- newNode.array.pop();
- } else {
- newNode.array[idx] = value;
- }
- return newNode;
- }
-
- function editableVNode(node, ownerID) {
- if (ownerID && node && ownerID === node.ownerID) {
- return node;
- }
- return new VNode(node ? node.array.slice() : [], ownerID);
- }
-
- function listNodeFor(list, rawIndex) {
- if (rawIndex >= getTailOffset(list._capacity)) {
- return list._tail;
- }
- if (rawIndex < 1 << (list._level + SHIFT)) {
- var node = list._root;
- var level = list._level;
- while (node && level > 0) {
- node = node.array[(rawIndex >>> level) & MASK];
- level -= SHIFT;
- }
- return node;
- }
- }
-
- function setListBounds(list, begin, end) {
- // Sanitize begin & end using this shorthand for ToInt32(argument)
- // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
- if (begin !== undefined) {
- begin = begin | 0;
- }
- if (end !== undefined) {
- end = end | 0;
- }
- var owner = list.__ownerID || new OwnerID();
- var oldOrigin = list._origin;
- var oldCapacity = list._capacity;
- var newOrigin = oldOrigin + begin;
- var newCapacity = end === undefined ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end;
- if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
- return list;
- }
-
- // If it's going to end after it starts, it's empty.
- if (newOrigin >= newCapacity) {
- return list.clear();
- }
-
- var newLevel = list._level;
- var newRoot = list._root;
-
- // New origin might need creating a higher root.
- var offsetShift = 0;
- while (newOrigin + offsetShift < 0) {
- newRoot = new VNode(newRoot && newRoot.array.length ? [undefined, newRoot] : [], owner);
- newLevel += SHIFT;
- offsetShift += 1 << newLevel;
- }
- if (offsetShift) {
- newOrigin += offsetShift;
- oldOrigin += offsetShift;
- newCapacity += offsetShift;
- oldCapacity += offsetShift;
- }
-
- var oldTailOffset = getTailOffset(oldCapacity);
- var newTailOffset = getTailOffset(newCapacity);
-
- // New size might need creating a higher root.
- while (newTailOffset >= 1 << (newLevel + SHIFT)) {
- newRoot = new VNode(newRoot && newRoot.array.length ? [newRoot] : [], owner);
- newLevel += SHIFT;
- }
-
- // Locate or create the new tail.
- var oldTail = list._tail;
- var newTail = newTailOffset < oldTailOffset ?
- listNodeFor(list, newCapacity - 1) :
- newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
-
- // Merge Tail into tree.
- if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) {
- newRoot = editableVNode(newRoot, owner);
- var node = newRoot;
- for (var level = newLevel; level > SHIFT; level -= SHIFT) {
- var idx = (oldTailOffset >>> level) & MASK;
- node = node.array[idx] = editableVNode(node.array[idx], owner);
- }
- node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
- }
-
- // If the size has been reduced, there's a chance the tail needs to be trimmed.
- if (newCapacity < oldCapacity) {
- newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
- }
-
- // If the new origin is within the tail, then we do not need a root.
- if (newOrigin >= newTailOffset) {
- newOrigin -= newTailOffset;
- newCapacity -= newTailOffset;
- newLevel = SHIFT;
- newRoot = null;
- newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
-
- // Otherwise, if the root has been trimmed, garbage collect.
- } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
- offsetShift = 0;
-
- // Identify the new top root node of the subtree of the old root.
- while (newRoot) {
- var beginIndex = (newOrigin >>> newLevel) & MASK;
- if (beginIndex !== (newTailOffset >>> newLevel) & MASK) {
- break;
- }
- if (beginIndex) {
- offsetShift += (1 << newLevel) * beginIndex;
- }
- newLevel -= SHIFT;
- newRoot = newRoot.array[beginIndex];
- }
-
- // Trim the new sides of the new root.
- if (newRoot && newOrigin > oldOrigin) {
- newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
- }
- if (newRoot && newTailOffset < oldTailOffset) {
- newRoot = newRoot.removeAfter(owner, newLevel, newTailOffset - offsetShift);
- }
- if (offsetShift) {
- newOrigin -= offsetShift;
- newCapacity -= offsetShift;
- }
- }
-
- if (list.__ownerID) {
- list.size = newCapacity - newOrigin;
- list._origin = newOrigin;
- list._capacity = newCapacity;
- list._level = newLevel;
- list._root = newRoot;
- list._tail = newTail;
- list.__hash = undefined;
- list.__altered = true;
- return list;
- }
- return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
- }
-
- function mergeIntoListWith(list, merger, iterables) {
- var iters = [];
- var maxSize = 0;
- for (var ii = 0; ii < iterables.length; ii++) {
- var value = iterables[ii];
- var iter = IndexedIterable(value);
- if (iter.size > maxSize) {
- maxSize = iter.size;
- }
- if (!isIterable(value)) {
- iter = iter.map(function(v ) {return fromJS(v)});
- }
- iters.push(iter);
- }
- if (maxSize > list.size) {
- list = list.setSize(maxSize);
- }
- return mergeIntoCollectionWith(list, merger, iters);
- }
-
- function getTailOffset(size) {
- return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT);
- }
-
- createClass(OrderedMap, Map);
-
- // @pragma Construction
-
- function OrderedMap(value) {
- return value === null || value === undefined ? emptyOrderedMap() :
- isOrderedMap(value) ? value :
- emptyOrderedMap().withMutations(function(map ) {
- var iter = KeyedIterable(value);
- assertNotInfinite(iter.size);
- iter.forEach(function(v, k) {return map.set(k, v)});
- });
- }
-
- OrderedMap.of = function(/*...values*/) {
- return this(arguments);
- };
-
- OrderedMap.prototype.toString = function() {
- return this.__toString('OrderedMap {', '}');
- };
-
- // @pragma Access
-
- OrderedMap.prototype.get = function(k, notSetValue) {
- var index = this._map.get(k);
- return index !== undefined ? this._list.get(index)[1] : notSetValue;
- };
-
- // @pragma Modification
-
- OrderedMap.prototype.clear = function() {
- if (this.size === 0) {
- return this;
- }
- if (this.__ownerID) {
- this.size = 0;
- this._map.clear();
- this._list.clear();
- return this;
- }
- return emptyOrderedMap();
- };
-
- OrderedMap.prototype.set = function(k, v) {
- return updateOrderedMap(this, k, v);
- };
-
- OrderedMap.prototype.remove = function(k) {
- return updateOrderedMap(this, k, NOT_SET);
- };
-
- OrderedMap.prototype.wasAltered = function() {
- return this._map.wasAltered() || this._list.wasAltered();
- };
-
- OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- return this._list.__iterate(
- function(entry ) {return entry && fn(entry[1], entry[0], this$0)},
- reverse
- );
- };
-
- OrderedMap.prototype.__iterator = function(type, reverse) {
- return this._list.fromEntrySeq().__iterator(type, reverse);
- };
-
- OrderedMap.prototype.__ensureOwner = function(ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- var newMap = this._map.__ensureOwner(ownerID);
- var newList = this._list.__ensureOwner(ownerID);
- if (!ownerID) {
- this.__ownerID = ownerID;
- this._map = newMap;
- this._list = newList;
- return this;
- }
- return makeOrderedMap(newMap, newList, ownerID, this.__hash);
- };
-
-
- function isOrderedMap(maybeOrderedMap) {
- return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
- }
-
- OrderedMap.isOrderedMap = isOrderedMap;
-
- OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
- OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
-
-
-
- function makeOrderedMap(map, list, ownerID, hash) {
- var omap = Object.create(OrderedMap.prototype);
- omap.size = map ? map.size : 0;
- omap._map = map;
- omap._list = list;
- omap.__ownerID = ownerID;
- omap.__hash = hash;
- return omap;
- }
-
- var EMPTY_ORDERED_MAP;
- function emptyOrderedMap() {
- return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()));
- }
-
- function updateOrderedMap(omap, k, v) {
- var map = omap._map;
- var list = omap._list;
- var i = map.get(k);
- var has = i !== undefined;
- var newMap;
- var newList;
- if (v === NOT_SET) { // removed
- if (!has) {
- return omap;
- }
- if (list.size >= SIZE && list.size >= map.size * 2) {
- newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx});
- newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap();
- if (omap.__ownerID) {
- newMap.__ownerID = newList.__ownerID = omap.__ownerID;
- }
- } else {
- newMap = map.remove(k);
- newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
- }
- } else {
- if (has) {
- if (v === list.get(i)[1]) {
- return omap;
- }
- newMap = map;
- newList = list.set(i, [k, v]);
- } else {
- newMap = map.set(k, list.size);
- newList = list.set(list.size, [k, v]);
- }
- }
- if (omap.__ownerID) {
- omap.size = newMap.size;
- omap._map = newMap;
- omap._list = newList;
- omap.__hash = undefined;
- return omap;
- }
- return makeOrderedMap(newMap, newList);
- }
-
- createClass(ToKeyedSequence, KeyedSeq);
- function ToKeyedSequence(indexed, useKeys) {
- this._iter = indexed;
- this._useKeys = useKeys;
- this.size = indexed.size;
- }
-
- ToKeyedSequence.prototype.get = function(key, notSetValue) {
- return this._iter.get(key, notSetValue);
- };
-
- ToKeyedSequence.prototype.has = function(key) {
- return this._iter.has(key);
- };
-
- ToKeyedSequence.prototype.valueSeq = function() {
- return this._iter.valueSeq();
- };
-
- ToKeyedSequence.prototype.reverse = function() {var this$0 = this;
- var reversedSequence = reverseFactory(this, true);
- if (!this._useKeys) {
- reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()};
- }
- return reversedSequence;
- };
-
- ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this;
- var mappedSequence = mapFactory(this, mapper, context);
- if (!this._useKeys) {
- mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)};
- }
- return mappedSequence;
- };
-
- ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- var ii;
- return this._iter.__iterate(
- this._useKeys ?
- function(v, k) {return fn(v, k, this$0)} :
- ((ii = reverse ? resolveSize(this) : 0),
- function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}),
- reverse
- );
- };
-
- ToKeyedSequence.prototype.__iterator = function(type, reverse) {
- if (this._useKeys) {
- return this._iter.__iterator(type, reverse);
- }
- var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
- var ii = reverse ? resolveSize(this) : 0;
- return new Iterator(function() {
- var step = iterator.next();
- return step.done ? step :
- iteratorValue(type, reverse ? --ii : ii++, step.value, step);
- });
- };
-
- ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
-
-
- createClass(ToIndexedSequence, IndexedSeq);
- function ToIndexedSequence(iter) {
- this._iter = iter;
- this.size = iter.size;
- }
-
- ToIndexedSequence.prototype.includes = function(value) {
- return this._iter.includes(value);
- };
-
- ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- var iterations = 0;
- return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse);
- };
-
- ToIndexedSequence.prototype.__iterator = function(type, reverse) {
- var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
- var iterations = 0;
- return new Iterator(function() {
- var step = iterator.next();
- return step.done ? step :
- iteratorValue(type, iterations++, step.value, step)
- });
- };
-
-
-
- createClass(ToSetSequence, SetSeq);
- function ToSetSequence(iter) {
- this._iter = iter;
- this.size = iter.size;
- }
-
- ToSetSequence.prototype.has = function(key) {
- return this._iter.includes(key);
- };
-
- ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse);
- };
-
- ToSetSequence.prototype.__iterator = function(type, reverse) {
- var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
- return new Iterator(function() {
- var step = iterator.next();
- return step.done ? step :
- iteratorValue(type, step.value, step.value, step);
- });
- };
-
-
-
- createClass(FromEntriesSequence, KeyedSeq);
- function FromEntriesSequence(entries) {
- this._iter = entries;
- this.size = entries.size;
- }
-
- FromEntriesSequence.prototype.entrySeq = function() {
- return this._iter.toSeq();
- };
-
- FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- return this._iter.__iterate(function(entry ) {
- // Check if entry exists first so array access doesn't throw for holes
- // in the parent iteration.
- if (entry) {
- validateEntry(entry);
- var indexedIterable = isIterable(entry);
- return fn(
- indexedIterable ? entry.get(1) : entry[1],
- indexedIterable ? entry.get(0) : entry[0],
- this$0
- );
- }
- }, reverse);
- };
-
- FromEntriesSequence.prototype.__iterator = function(type, reverse) {
- var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
- return new Iterator(function() {
- while (true) {
- var step = iterator.next();
- if (step.done) {
- return step;
- }
- var entry = step.value;
- // Check if entry exists first so array access doesn't throw for holes
- // in the parent iteration.
- if (entry) {
- validateEntry(entry);
- var indexedIterable = isIterable(entry);
- return iteratorValue(
- type,
- indexedIterable ? entry.get(0) : entry[0],
- indexedIterable ? entry.get(1) : entry[1],
- step
- );
- }
- }
- });
- };
-
-
- ToIndexedSequence.prototype.cacheResult =
- ToKeyedSequence.prototype.cacheResult =
- ToSetSequence.prototype.cacheResult =
- FromEntriesSequence.prototype.cacheResult =
- cacheResultThrough;
-
-
- function flipFactory(iterable) {
- var flipSequence = makeSequence(iterable);
- flipSequence._iter = iterable;
- flipSequence.size = iterable.size;
- flipSequence.flip = function() {return iterable};
- flipSequence.reverse = function () {
- var reversedSequence = iterable.reverse.apply(this); // super.reverse()
- reversedSequence.flip = function() {return iterable.reverse()};
- return reversedSequence;
- };
- flipSequence.has = function(key ) {return iterable.includes(key)};
- flipSequence.includes = function(key ) {return iterable.has(key)};
- flipSequence.cacheResult = cacheResultThrough;
- flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
- return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse);
- };
- flipSequence.__iteratorUncached = function(type, reverse) {
- if (type === ITERATE_ENTRIES) {
- var iterator = iterable.__iterator(type, reverse);
- return new Iterator(function() {
- var step = iterator.next();
- if (!step.done) {
- var k = step.value[0];
- step.value[0] = step.value[1];
- step.value[1] = k;
- }
- return step;
- });
- }
- return iterable.__iterator(
- type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
- reverse
- );
- };
- return flipSequence;
- }
-
-
- function mapFactory(iterable, mapper, context) {
- var mappedSequence = makeSequence(iterable);
- mappedSequence.size = iterable.size;
- mappedSequence.has = function(key ) {return iterable.has(key)};
- mappedSequence.get = function(key, notSetValue) {
- var v = iterable.get(key, NOT_SET);
- return v === NOT_SET ?
- notSetValue :
- mapper.call(context, v, key, iterable);
- };
- mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
- return iterable.__iterate(
- function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false},
- reverse
- );
- };
- mappedSequence.__iteratorUncached = function (type, reverse) {
- var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
- return new Iterator(function() {
- var step = iterator.next();
- if (step.done) {
- return step;
- }
- var entry = step.value;
- var key = entry[0];
- return iteratorValue(
- type,
- key,
- mapper.call(context, entry[1], key, iterable),
- step
- );
- });
- };
- return mappedSequence;
- }
-
-
- function reverseFactory(iterable, useKeys) {
- var reversedSequence = makeSequence(iterable);
- reversedSequence._iter = iterable;
- reversedSequence.size = iterable.size;
- reversedSequence.reverse = function() {return iterable};
- if (iterable.flip) {
- reversedSequence.flip = function () {
- var flipSequence = flipFactory(iterable);
- flipSequence.reverse = function() {return iterable.flip()};
- return flipSequence;
- };
- }
- reversedSequence.get = function(key, notSetValue)
- {return iterable.get(useKeys ? key : -1 - key, notSetValue)};
- reversedSequence.has = function(key )
- {return iterable.has(useKeys ? key : -1 - key)};
- reversedSequence.includes = function(value ) {return iterable.includes(value)};
- reversedSequence.cacheResult = cacheResultThrough;
- reversedSequence.__iterate = function (fn, reverse) {var this$0 = this;
- return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse);
- };
- reversedSequence.__iterator =
- function(type, reverse) {return iterable.__iterator(type, !reverse)};
- return reversedSequence;
- }
-
-
- function filterFactory(iterable, predicate, context, useKeys) {
- var filterSequence = makeSequence(iterable);
- if (useKeys) {
- filterSequence.has = function(key ) {
- var v = iterable.get(key, NOT_SET);
- return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
- };
- filterSequence.get = function(key, notSetValue) {
- var v = iterable.get(key, NOT_SET);
- return v !== NOT_SET && predicate.call(context, v, key, iterable) ?
- v : notSetValue;
- };
- }
- filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
- var iterations = 0;
- iterable.__iterate(function(v, k, c) {
- if (predicate.call(context, v, k, c)) {
- iterations++;
- return fn(v, useKeys ? k : iterations - 1, this$0);
- }
- }, reverse);
- return iterations;
- };
- filterSequence.__iteratorUncached = function (type, reverse) {
- var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
- var iterations = 0;
- return new Iterator(function() {
- while (true) {
- var step = iterator.next();
- if (step.done) {
- return step;
- }
- var entry = step.value;
- var key = entry[0];
- var value = entry[1];
- if (predicate.call(context, value, key, iterable)) {
- return iteratorValue(type, useKeys ? key : iterations++, value, step);
- }
- }
- });
- };
- return filterSequence;
- }
-
-
- function countByFactory(iterable, grouper, context) {
- var groups = Map().asMutable();
- iterable.__iterate(function(v, k) {
- groups.update(
- grouper.call(context, v, k, iterable),
- 0,
- function(a ) {return a + 1}
- );
- });
- return groups.asImmutable();
- }
-
-
- function groupByFactory(iterable, grouper, context) {
- var isKeyedIter = isKeyed(iterable);
- var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
- iterable.__iterate(function(v, k) {
- groups.update(
- grouper.call(context, v, k, iterable),
- function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)}
- );
- });
- var coerce = iterableClass(iterable);
- return groups.map(function(arr ) {return reify(iterable, coerce(arr))});
- }
-
-
- function sliceFactory(iterable, begin, end, useKeys) {
- var originalSize = iterable.size;
-
- // Sanitize begin & end using this shorthand for ToInt32(argument)
- // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
- if (begin !== undefined) {
- begin = begin | 0;
- }
- if (end !== undefined) {
- end = end | 0;
- }
-
- if (wholeSlice(begin, end, originalSize)) {
- return iterable;
- }
-
- var resolvedBegin = resolveBegin(begin, originalSize);
- var resolvedEnd = resolveEnd(end, originalSize);
-
- // begin or end will be NaN if they were provided as negative numbers and
- // this iterable's size is unknown. In that case, cache first so there is
- // a known size and these do not resolve to NaN.
- if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
- return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys);
- }
-
- // Note: resolvedEnd is undefined when the original sequence's length is
- // unknown and this slice did not supply an end and should contain all
- // elements after resolvedBegin.
- // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
- var resolvedSize = resolvedEnd - resolvedBegin;
- var sliceSize;
- if (resolvedSize === resolvedSize) {
- sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
- }
-
- var sliceSeq = makeSequence(iterable);
-
- // If iterable.size is undefined, the size of the realized sliceSeq is
- // unknown at this point unless the number of items to slice is 0
- sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined;
-
- if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
- sliceSeq.get = function (index, notSetValue) {
- index = wrapIndex(this, index);
- return index >= 0 && index < sliceSize ?
- iterable.get(index + resolvedBegin, notSetValue) :
- notSetValue;
- };
- }
-
- sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this;
- if (sliceSize === 0) {
- return 0;
- }
- if (reverse) {
- return this.cacheResult().__iterate(fn, reverse);
- }
- var skipped = 0;
- var isSkipping = true;
- var iterations = 0;
- iterable.__iterate(function(v, k) {
- if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
- iterations++;
- return fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
- iterations !== sliceSize;
- }
- });
- return iterations;
- };
-
- sliceSeq.__iteratorUncached = function(type, reverse) {
- if (sliceSize !== 0 && reverse) {
- return this.cacheResult().__iterator(type, reverse);
- }
- // Don't bother instantiating parent iterator if taking 0.
- var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
- var skipped = 0;
- var iterations = 0;
- return new Iterator(function() {
- while (skipped++ < resolvedBegin) {
- iterator.next();
- }
- if (++iterations > sliceSize) {
- return iteratorDone();
- }
- var step = iterator.next();
- if (useKeys || type === ITERATE_VALUES) {
- return step;
- } else if (type === ITERATE_KEYS) {
- return iteratorValue(type, iterations - 1, undefined, step);
- } else {
- return iteratorValue(type, iterations - 1, step.value[1], step);
- }
- });
- };
-
- return sliceSeq;
- }
-
-
- function takeWhileFactory(iterable, predicate, context) {
- var takeSequence = makeSequence(iterable);
- takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
- if (reverse) {
- return this.cacheResult().__iterate(fn, reverse);
- }
- var iterations = 0;
- iterable.__iterate(function(v, k, c)
- {return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)}
- );
- return iterations;
- };
- takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
- if (reverse) {
- return this.cacheResult().__iterator(type, reverse);
- }
- var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
- var iterating = true;
- return new Iterator(function() {
- if (!iterating) {
- return iteratorDone();
- }
- var step = iterator.next();
- if (step.done) {
- return step;
- }
- var entry = step.value;
- var k = entry[0];
- var v = entry[1];
- if (!predicate.call(context, v, k, this$0)) {
- iterating = false;
- return iteratorDone();
- }
- return type === ITERATE_ENTRIES ? step :
- iteratorValue(type, k, v, step);
- });
- };
- return takeSequence;
- }
-
-
- function skipWhileFactory(iterable, predicate, context, useKeys) {
- var skipSequence = makeSequence(iterable);
- skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
- if (reverse) {
- return this.cacheResult().__iterate(fn, reverse);
- }
- var isSkipping = true;
- var iterations = 0;
- iterable.__iterate(function(v, k, c) {
- if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
- iterations++;
- return fn(v, useKeys ? k : iterations - 1, this$0);
- }
- });
- return iterations;
- };
- skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
- if (reverse) {
- return this.cacheResult().__iterator(type, reverse);
- }
- var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
- var skipping = true;
- var iterations = 0;
- return new Iterator(function() {
- var step, k, v;
- do {
- step = iterator.next();
- if (step.done) {
- if (useKeys || type === ITERATE_VALUES) {
- return step;
- } else if (type === ITERATE_KEYS) {
- return iteratorValue(type, iterations++, undefined, step);
- } else {
- return iteratorValue(type, iterations++, step.value[1], step);
- }
- }
- var entry = step.value;
- k = entry[0];
- v = entry[1];
- skipping && (skipping = predicate.call(context, v, k, this$0));
- } while (skipping);
- return type === ITERATE_ENTRIES ? step :
- iteratorValue(type, k, v, step);
- });
- };
- return skipSequence;
- }
-
-
- function concatFactory(iterable, values) {
- var isKeyedIterable = isKeyed(iterable);
- var iters = [iterable].concat(values).map(function(v ) {
- if (!isIterable(v)) {
- v = isKeyedIterable ?
- keyedSeqFromValue(v) :
- indexedSeqFromValue(Array.isArray(v) ? v : [v]);
- } else if (isKeyedIterable) {
- v = KeyedIterable(v);
- }
- return v;
- }).filter(function(v ) {return v.size !== 0});
-
- if (iters.length === 0) {
- return iterable;
- }
-
- if (iters.length === 1) {
- var singleton = iters[0];
- if (singleton === iterable ||
- isKeyedIterable && isKeyed(singleton) ||
- isIndexed(iterable) && isIndexed(singleton)) {
- return singleton;
- }
- }
-
- var concatSeq = new ArraySeq(iters);
- if (isKeyedIterable) {
- concatSeq = concatSeq.toKeyedSeq();
- } else if (!isIndexed(iterable)) {
- concatSeq = concatSeq.toSetSeq();
- }
- concatSeq = concatSeq.flatten(true);
- concatSeq.size = iters.reduce(
- function(sum, seq) {
- if (sum !== undefined) {
- var size = seq.size;
- if (size !== undefined) {
- return sum + size;
- }
- }
- },
- 0
- );
- return concatSeq;
- }
-
-
- function flattenFactory(iterable, depth, useKeys) {
- var flatSequence = makeSequence(iterable);
- flatSequence.__iterateUncached = function(fn, reverse) {
- var iterations = 0;
- var stopped = false;
- function flatDeep(iter, currentDepth) {var this$0 = this;
- iter.__iterate(function(v, k) {
- if ((!depth || currentDepth < depth) && isIterable(v)) {
- flatDeep(v, currentDepth + 1);
- } else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
- stopped = true;
- }
- return !stopped;
- }, reverse);
- }
- flatDeep(iterable, 0);
- return iterations;
- };
- flatSequence.__iteratorUncached = function(type, reverse) {
- var iterator = iterable.__iterator(type, reverse);
- var stack = [];
- var iterations = 0;
- return new Iterator(function() {
- while (iterator) {
- var step = iterator.next();
- if (step.done !== false) {
- iterator = stack.pop();
- continue;
- }
- var v = step.value;
- if (type === ITERATE_ENTRIES) {
- v = v[1];
- }
- if ((!depth || stack.length < depth) && isIterable(v)) {
- stack.push(iterator);
- iterator = v.__iterator(type, reverse);
- } else {
- return useKeys ? step : iteratorValue(type, iterations++, v, step);
- }
- }
- return iteratorDone();
- });
- };
- return flatSequence;
- }
-
-
- function flatMapFactory(iterable, mapper, context) {
- var coerce = iterableClass(iterable);
- return iterable.toSeq().map(
- function(v, k) {return coerce(mapper.call(context, v, k, iterable))}
- ).flatten(true);
- }
-
-
- function interposeFactory(iterable, separator) {
- var interposedSequence = makeSequence(iterable);
- interposedSequence.size = iterable.size && iterable.size * 2 -1;
- interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
- var iterations = 0;
- iterable.__iterate(function(v, k)
- {return (!iterations || fn(separator, iterations++, this$0) !== false) &&
- fn(v, iterations++, this$0) !== false},
- reverse
- );
- return iterations;
- };
- interposedSequence.__iteratorUncached = function(type, reverse) {
- var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
- var iterations = 0;
- var step;
- return new Iterator(function() {
- if (!step || iterations % 2) {
- step = iterator.next();
- if (step.done) {
- return step;
- }
- }
- return iterations % 2 ?
- iteratorValue(type, iterations++, separator) :
- iteratorValue(type, iterations++, step.value, step);
- });
- };
- return interposedSequence;
- }
-
-
- function sortFactory(iterable, comparator, mapper) {
- if (!comparator) {
- comparator = defaultComparator;
- }
- var isKeyedIterable = isKeyed(iterable);
- var index = 0;
- var entries = iterable.toSeq().map(
- function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]}
- ).toArray();
- entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach(
- isKeyedIterable ?
- function(v, i) { entries[i].length = 2; } :
- function(v, i) { entries[i] = v[1]; }
- );
- return isKeyedIterable ? KeyedSeq(entries) :
- isIndexed(iterable) ? IndexedSeq(entries) :
- SetSeq(entries);
- }
-
-
- function maxFactory(iterable, comparator, mapper) {
- if (!comparator) {
- comparator = defaultComparator;
- }
- if (mapper) {
- var entry = iterable.toSeq()
- .map(function(v, k) {return [v, mapper(v, k, iterable)]})
- .reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a});
- return entry && entry[0];
- } else {
- return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a});
- }
- }
-
- function maxCompare(comparator, a, b) {
- var comp = comparator(b, a);
- // b is considered the new max if the comparator declares them equal, but
- // they are not equal and b is in fact a nullish value.
- return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0;
- }
-
-
- function zipWithFactory(keyIter, zipper, iters) {
- var zipSequence = makeSequence(keyIter);
- zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min();
- // Note: this a generic base implementation of __iterate in terms of
- // __iterator which may be more generically useful in the future.
- zipSequence.__iterate = function(fn, reverse) {
- /* generic:
- var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
- var step;
- var iterations = 0;
- while (!(step = iterator.next()).done) {
- iterations++;
- if (fn(step.value[1], step.value[0], this) === false) {
- break;
- }
- }
- return iterations;
- */
- // indexed:
- var iterator = this.__iterator(ITERATE_VALUES, reverse);
- var step;
- var iterations = 0;
- while (!(step = iterator.next()).done) {
- if (fn(step.value, iterations++, this) === false) {
- break;
- }
- }
- return iterations;
- };
- zipSequence.__iteratorUncached = function(type, reverse) {
- var iterators = iters.map(function(i )
- {return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))}
- );
- var iterations = 0;
- var isDone = false;
- return new Iterator(function() {
- var steps;
- if (!isDone) {
- steps = iterators.map(function(i ) {return i.next()});
- isDone = steps.some(function(s ) {return s.done});
- }
- if (isDone) {
- return iteratorDone();
- }
- return iteratorValue(
- type,
- iterations++,
- zipper.apply(null, steps.map(function(s ) {return s.value}))
- );
- });
- };
- return zipSequence
- }
-
-
- // #pragma Helper Functions
-
- function reify(iter, seq) {
- return isSeq(iter) ? seq : iter.constructor(seq);
- }
-
- function validateEntry(entry) {
- if (entry !== Object(entry)) {
- throw new TypeError('Expected [K, V] tuple: ' + entry);
- }
- }
-
- function resolveSize(iter) {
- assertNotInfinite(iter.size);
- return ensureSize(iter);
- }
-
- function iterableClass(iterable) {
- return isKeyed(iterable) ? KeyedIterable :
- isIndexed(iterable) ? IndexedIterable :
- SetIterable;
- }
-
- function makeSequence(iterable) {
- return Object.create(
- (
- isKeyed(iterable) ? KeyedSeq :
- isIndexed(iterable) ? IndexedSeq :
- SetSeq
- ).prototype
- );
- }
-
- function cacheResultThrough() {
- if (this._iter.cacheResult) {
- this._iter.cacheResult();
- this.size = this._iter.size;
- return this;
- } else {
- return Seq.prototype.cacheResult.call(this);
- }
- }
-
- function defaultComparator(a, b) {
- return a > b ? 1 : a < b ? -1 : 0;
- }
-
- function forceIterator(keyPath) {
- var iter = getIterator(keyPath);
- if (!iter) {
- // Array might not be iterable in this environment, so we need a fallback
- // to our wrapped type.
- if (!isArrayLike(keyPath)) {
- throw new TypeError('Expected iterable or array-like: ' + keyPath);
- }
- iter = getIterator(Iterable(keyPath));
- }
- return iter;
- }
-
- createClass(Record, KeyedCollection);
-
- function Record(defaultValues, name) {
- var hasInitialized;
-
- var RecordType = function Record(values) {
- if (values instanceof RecordType) {
- return values;
- }
- if (!(this instanceof RecordType)) {
- return new RecordType(values);
- }
- if (!hasInitialized) {
- hasInitialized = true;
- var keys = Object.keys(defaultValues);
- setProps(RecordTypePrototype, keys);
- RecordTypePrototype.size = keys.length;
- RecordTypePrototype._name = name;
- RecordTypePrototype._keys = keys;
- RecordTypePrototype._defaultValues = defaultValues;
- }
- this._map = Map(values);
- };
-
- var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype);
- RecordTypePrototype.constructor = RecordType;
-
- return RecordType;
- }
-
- Record.prototype.toString = function() {
- return this.__toString(recordName(this) + ' {', '}');
- };
-
- // @pragma Access
-
- Record.prototype.has = function(k) {
- return this._defaultValues.hasOwnProperty(k);
- };
-
- Record.prototype.get = function(k, notSetValue) {
- if (!this.has(k)) {
- return notSetValue;
- }
- var defaultVal = this._defaultValues[k];
- return this._map ? this._map.get(k, defaultVal) : defaultVal;
- };
-
- // @pragma Modification
-
- Record.prototype.clear = function() {
- if (this.__ownerID) {
- this._map && this._map.clear();
- return this;
- }
- var RecordType = this.constructor;
- return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()));
- };
-
- Record.prototype.set = function(k, v) {
- if (!this.has(k)) {
- throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this));
- }
- var newMap = this._map && this._map.set(k, v);
- if (this.__ownerID || newMap === this._map) {
- return this;
- }
- return makeRecord(this, newMap);
- };
-
- Record.prototype.remove = function(k) {
- if (!this.has(k)) {
- return this;
- }
- var newMap = this._map && this._map.remove(k);
- if (this.__ownerID || newMap === this._map) {
- return this;
- }
- return makeRecord(this, newMap);
- };
-
- Record.prototype.wasAltered = function() {
- return this._map.wasAltered();
- };
-
- Record.prototype.__iterator = function(type, reverse) {var this$0 = this;
- return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse);
- };
-
- Record.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse);
- };
-
- Record.prototype.__ensureOwner = function(ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- var newMap = this._map && this._map.__ensureOwner(ownerID);
- if (!ownerID) {
- this.__ownerID = ownerID;
- this._map = newMap;
- return this;
- }
- return makeRecord(this, newMap, ownerID);
- };
-
-
- var RecordPrototype = Record.prototype;
- RecordPrototype[DELETE] = RecordPrototype.remove;
- RecordPrototype.deleteIn =
- RecordPrototype.removeIn = MapPrototype.removeIn;
- RecordPrototype.merge = MapPrototype.merge;
- RecordPrototype.mergeWith = MapPrototype.mergeWith;
- RecordPrototype.mergeIn = MapPrototype.mergeIn;
- RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
- RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
- RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
- RecordPrototype.setIn = MapPrototype.setIn;
- RecordPrototype.update = MapPrototype.update;
- RecordPrototype.updateIn = MapPrototype.updateIn;
- RecordPrototype.withMutations = MapPrototype.withMutations;
- RecordPrototype.asMutable = MapPrototype.asMutable;
- RecordPrototype.asImmutable = MapPrototype.asImmutable;
-
-
- function makeRecord(likeRecord, map, ownerID) {
- var record = Object.create(Object.getPrototypeOf(likeRecord));
- record._map = map;
- record.__ownerID = ownerID;
- return record;
- }
-
- function recordName(record) {
- return record._name || record.constructor.name || 'Record';
- }
-
- function setProps(prototype, names) {
- try {
- names.forEach(setProp.bind(undefined, prototype));
- } catch (error) {
- // Object.defineProperty failed. Probably IE8.
- }
- }
-
- function setProp(prototype, name) {
- Object.defineProperty(prototype, name, {
- get: function() {
- return this.get(name);
- },
- set: function(value) {
- invariant(this.__ownerID, 'Cannot set on an immutable record.');
- this.set(name, value);
- }
- });
- }
-
- createClass(Set, SetCollection);
-
- // @pragma Construction
-
- function Set(value) {
- return value === null || value === undefined ? emptySet() :
- isSet(value) && !isOrdered(value) ? value :
- emptySet().withMutations(function(set ) {
- var iter = SetIterable(value);
- assertNotInfinite(iter.size);
- iter.forEach(function(v ) {return set.add(v)});
- });
- }
-
- Set.of = function(/*...values*/) {
- return this(arguments);
- };
-
- Set.fromKeys = function(value) {
- return this(KeyedIterable(value).keySeq());
- };
-
- Set.prototype.toString = function() {
- return this.__toString('Set {', '}');
- };
-
- // @pragma Access
-
- Set.prototype.has = function(value) {
- return this._map.has(value);
- };
-
- // @pragma Modification
-
- Set.prototype.add = function(value) {
- return updateSet(this, this._map.set(value, true));
- };
-
- Set.prototype.remove = function(value) {
- return updateSet(this, this._map.remove(value));
- };
-
- Set.prototype.clear = function() {
- return updateSet(this, this._map.clear());
- };
-
- // @pragma Composition
-
- Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0);
- iters = iters.filter(function(x ) {return x.size !== 0});
- if (iters.length === 0) {
- return this;
- }
- if (this.size === 0 && !this.__ownerID && iters.length === 1) {
- return this.constructor(iters[0]);
- }
- return this.withMutations(function(set ) {
- for (var ii = 0; ii < iters.length; ii++) {
- SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)});
- }
- });
- };
-
- Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0);
- if (iters.length === 0) {
- return this;
- }
- iters = iters.map(function(iter ) {return SetIterable(iter)});
- var originalSet = this;
- return this.withMutations(function(set ) {
- originalSet.forEach(function(value ) {
- if (!iters.every(function(iter ) {return iter.includes(value)})) {
- set.remove(value);
- }
- });
- });
- };
-
- Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0);
- if (iters.length === 0) {
- return this;
- }
- iters = iters.map(function(iter ) {return SetIterable(iter)});
- var originalSet = this;
- return this.withMutations(function(set ) {
- originalSet.forEach(function(value ) {
- if (iters.some(function(iter ) {return iter.includes(value)})) {
- set.remove(value);
- }
- });
- });
- };
-
- Set.prototype.merge = function() {
- return this.union.apply(this, arguments);
- };
-
- Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
- return this.union.apply(this, iters);
- };
-
- Set.prototype.sort = function(comparator) {
- // Late binding
- return OrderedSet(sortFactory(this, comparator));
- };
-
- Set.prototype.sortBy = function(mapper, comparator) {
- // Late binding
- return OrderedSet(sortFactory(this, comparator, mapper));
- };
-
- Set.prototype.wasAltered = function() {
- return this._map.wasAltered();
- };
-
- Set.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse);
- };
-
- Set.prototype.__iterator = function(type, reverse) {
- return this._map.map(function(_, k) {return k}).__iterator(type, reverse);
- };
-
- Set.prototype.__ensureOwner = function(ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- var newMap = this._map.__ensureOwner(ownerID);
- if (!ownerID) {
- this.__ownerID = ownerID;
- this._map = newMap;
- return this;
- }
- return this.__make(newMap, ownerID);
- };
-
-
- function isSet(maybeSet) {
- return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
- }
-
- Set.isSet = isSet;
-
- var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
-
- var SetPrototype = Set.prototype;
- SetPrototype[IS_SET_SENTINEL] = true;
- SetPrototype[DELETE] = SetPrototype.remove;
- SetPrototype.mergeDeep = SetPrototype.merge;
- SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
- SetPrototype.withMutations = MapPrototype.withMutations;
- SetPrototype.asMutable = MapPrototype.asMutable;
- SetPrototype.asImmutable = MapPrototype.asImmutable;
-
- SetPrototype.__empty = emptySet;
- SetPrototype.__make = makeSet;
-
- function updateSet(set, newMap) {
- if (set.__ownerID) {
- set.size = newMap.size;
- set._map = newMap;
- return set;
- }
- return newMap === set._map ? set :
- newMap.size === 0 ? set.__empty() :
- set.__make(newMap);
- }
-
- function makeSet(map, ownerID) {
- var set = Object.create(SetPrototype);
- set.size = map ? map.size : 0;
- set._map = map;
- set.__ownerID = ownerID;
- return set;
- }
-
- var EMPTY_SET;
- function emptySet() {
- return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
- }
-
- createClass(OrderedSet, Set);
-
- // @pragma Construction
-
- function OrderedSet(value) {
- return value === null || value === undefined ? emptyOrderedSet() :
- isOrderedSet(value) ? value :
- emptyOrderedSet().withMutations(function(set ) {
- var iter = SetIterable(value);
- assertNotInfinite(iter.size);
- iter.forEach(function(v ) {return set.add(v)});
- });
- }
-
- OrderedSet.of = function(/*...values*/) {
- return this(arguments);
- };
-
- OrderedSet.fromKeys = function(value) {
- return this(KeyedIterable(value).keySeq());
- };
-
- OrderedSet.prototype.toString = function() {
- return this.__toString('OrderedSet {', '}');
- };
-
-
- function isOrderedSet(maybeOrderedSet) {
- return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
- }
-
- OrderedSet.isOrderedSet = isOrderedSet;
-
- var OrderedSetPrototype = OrderedSet.prototype;
- OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
-
- OrderedSetPrototype.__empty = emptyOrderedSet;
- OrderedSetPrototype.__make = makeOrderedSet;
-
- function makeOrderedSet(map, ownerID) {
- var set = Object.create(OrderedSetPrototype);
- set.size = map ? map.size : 0;
- set._map = map;
- set.__ownerID = ownerID;
- return set;
- }
-
- var EMPTY_ORDERED_SET;
- function emptyOrderedSet() {
- return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()));
- }
-
- createClass(Stack, IndexedCollection);
-
- // @pragma Construction
-
- function Stack(value) {
- return value === null || value === undefined ? emptyStack() :
- isStack(value) ? value :
- emptyStack().unshiftAll(value);
- }
-
- Stack.of = function(/*...values*/) {
- return this(arguments);
- };
-
- Stack.prototype.toString = function() {
- return this.__toString('Stack [', ']');
- };
-
- // @pragma Access
-
- Stack.prototype.get = function(index, notSetValue) {
- var head = this._head;
- index = wrapIndex(this, index);
- while (head && index--) {
- head = head.next;
- }
- return head ? head.value : notSetValue;
- };
-
- Stack.prototype.peek = function() {
- return this._head && this._head.value;
- };
-
- // @pragma Modification
-
- Stack.prototype.push = function(/*...values*/) {
- if (arguments.length === 0) {
- return this;
- }
- var newSize = this.size + arguments.length;
- var head = this._head;
- for (var ii = arguments.length - 1; ii >= 0; ii--) {
- head = {
- value: arguments[ii],
- next: head
- };
- }
- if (this.__ownerID) {
- this.size = newSize;
- this._head = head;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return makeStack(newSize, head);
- };
-
- Stack.prototype.pushAll = function(iter) {
- iter = IndexedIterable(iter);
- if (iter.size === 0) {
- return this;
- }
- assertNotInfinite(iter.size);
- var newSize = this.size;
- var head = this._head;
- iter.reverse().forEach(function(value ) {
- newSize++;
- head = {
- value: value,
- next: head
- };
- });
- if (this.__ownerID) {
- this.size = newSize;
- this._head = head;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return makeStack(newSize, head);
- };
-
- Stack.prototype.pop = function() {
- return this.slice(1);
- };
-
- Stack.prototype.unshift = function(/*...values*/) {
- return this.push.apply(this, arguments);
- };
-
- Stack.prototype.unshiftAll = function(iter) {
- return this.pushAll(iter);
- };
-
- Stack.prototype.shift = function() {
- return this.pop.apply(this, arguments);
- };
-
- Stack.prototype.clear = function() {
- if (this.size === 0) {
- return this;
- }
- if (this.__ownerID) {
- this.size = 0;
- this._head = undefined;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return emptyStack();
- };
-
- Stack.prototype.slice = function(begin, end) {
- if (wholeSlice(begin, end, this.size)) {
- return this;
- }
- var resolvedBegin = resolveBegin(begin, this.size);
- var resolvedEnd = resolveEnd(end, this.size);
- if (resolvedEnd !== this.size) {
- // super.slice(begin, end);
- return IndexedCollection.prototype.slice.call(this, begin, end);
- }
- var newSize = this.size - resolvedBegin;
- var head = this._head;
- while (resolvedBegin--) {
- head = head.next;
- }
- if (this.__ownerID) {
- this.size = newSize;
- this._head = head;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return makeStack(newSize, head);
- };
-
- // @pragma Mutability
-
- Stack.prototype.__ensureOwner = function(ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- if (!ownerID) {
- this.__ownerID = ownerID;
- this.__altered = false;
- return this;
- }
- return makeStack(this.size, this._head, ownerID, this.__hash);
- };
-
- // @pragma Iteration
-
- Stack.prototype.__iterate = function(fn, reverse) {
- if (reverse) {
- return this.reverse().__iterate(fn);
- }
- var iterations = 0;
- var node = this._head;
- while (node) {
- if (fn(node.value, iterations++, this) === false) {
- break;
- }
- node = node.next;
- }
- return iterations;
- };
-
- Stack.prototype.__iterator = function(type, reverse) {
- if (reverse) {
- return this.reverse().__iterator(type);
- }
- var iterations = 0;
- var node = this._head;
- return new Iterator(function() {
- if (node) {
- var value = node.value;
- node = node.next;
- return iteratorValue(type, iterations++, value);
- }
- return iteratorDone();
- });
- };
-
-
- function isStack(maybeStack) {
- return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
- }
-
- Stack.isStack = isStack;
-
- var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
-
- var StackPrototype = Stack.prototype;
- StackPrototype[IS_STACK_SENTINEL] = true;
- StackPrototype.withMutations = MapPrototype.withMutations;
- StackPrototype.asMutable = MapPrototype.asMutable;
- StackPrototype.asImmutable = MapPrototype.asImmutable;
- StackPrototype.wasAltered = MapPrototype.wasAltered;
-
-
- function makeStack(size, head, ownerID, hash) {
- var map = Object.create(StackPrototype);
- map.size = size;
- map._head = head;
- map.__ownerID = ownerID;
- map.__hash = hash;
- map.__altered = false;
- return map;
- }
-
- var EMPTY_STACK;
- function emptyStack() {
- return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
- }
-
- /**
- * Contributes additional methods to a constructor
- */
- function mixin(ctor, methods) {
- var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; };
- Object.keys(methods).forEach(keyCopier);
- Object.getOwnPropertySymbols &&
- Object.getOwnPropertySymbols(methods).forEach(keyCopier);
- return ctor;
- }
-
- Iterable.Iterator = Iterator;
-
- mixin(Iterable, {
-
- // ### Conversion to other types
-
- toArray: function() {
- assertNotInfinite(this.size);
- var array = new Array(this.size || 0);
- this.valueSeq().__iterate(function(v, i) { array[i] = v; });
- return array;
- },
-
- toIndexedSeq: function() {
- return new ToIndexedSequence(this);
- },
-
- toJS: function() {
- return this.toSeq().map(
- function(value ) {return value && typeof value.toJS === 'function' ? value.toJS() : value}
- ).__toJS();
- },
-
- toJSON: function() {
- return this.toSeq().map(
- function(value ) {return value && typeof value.toJSON === 'function' ? value.toJSON() : value}
- ).__toJS();
- },
-
- toKeyedSeq: function() {
- return new ToKeyedSequence(this, true);
- },
-
- toMap: function() {
- // Use Late Binding here to solve the circular dependency.
- return Map(this.toKeyedSeq());
- },
-
- toObject: function() {
- assertNotInfinite(this.size);
- var object = {};
- this.__iterate(function(v, k) { object[k] = v; });
- return object;
- },
-
- toOrderedMap: function() {
- // Use Late Binding here to solve the circular dependency.
- return OrderedMap(this.toKeyedSeq());
- },
-
- toOrderedSet: function() {
- // Use Late Binding here to solve the circular dependency.
- return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
- },
-
- toSet: function() {
- // Use Late Binding here to solve the circular dependency.
- return Set(isKeyed(this) ? this.valueSeq() : this);
- },
-
- toSetSeq: function() {
- return new ToSetSequence(this);
- },
-
- toSeq: function() {
- return isIndexed(this) ? this.toIndexedSeq() :
- isKeyed(this) ? this.toKeyedSeq() :
- this.toSetSeq();
- },
-
- toStack: function() {
- // Use Late Binding here to solve the circular dependency.
- return Stack(isKeyed(this) ? this.valueSeq() : this);
- },
-
- toList: function() {
- // Use Late Binding here to solve the circular dependency.
- return List(isKeyed(this) ? this.valueSeq() : this);
- },
-
-
- // ### Common JavaScript methods and properties
-
- toString: function() {
- return '[Iterable]';
- },
-
- __toString: function(head, tail) {
- if (this.size === 0) {
- return head + tail;
- }
- return head + ' ' + this.toSeq().map(this.__toStringMapper).join(', ') + ' ' + tail;
- },
-
-
- // ### ES6 Collection methods (ES6 Array and Map)
-
- concat: function() {var values = SLICE$0.call(arguments, 0);
- return reify(this, concatFactory(this, values));
- },
-
- includes: function(searchValue) {
- return this.some(function(value ) {return is(value, searchValue)});
- },
-
- entries: function() {
- return this.__iterator(ITERATE_ENTRIES);
- },
-
- every: function(predicate, context) {
- assertNotInfinite(this.size);
- var returnValue = true;
- this.__iterate(function(v, k, c) {
- if (!predicate.call(context, v, k, c)) {
- returnValue = false;
- return false;
- }
- });
- return returnValue;
- },
-
- filter: function(predicate, context) {
- return reify(this, filterFactory(this, predicate, context, true));
- },
-
- find: function(predicate, context, notSetValue) {
- var entry = this.findEntry(predicate, context);
- return entry ? entry[1] : notSetValue;
- },
-
- findEntry: function(predicate, context) {
- var found;
- this.__iterate(function(v, k, c) {
- if (predicate.call(context, v, k, c)) {
- found = [k, v];
- return false;
- }
- });
- return found;
- },
-
- findLastEntry: function(predicate, context) {
- return this.toSeq().reverse().findEntry(predicate, context);
- },
-
- forEach: function(sideEffect, context) {
- assertNotInfinite(this.size);
- return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
- },
-
- join: function(separator) {
- assertNotInfinite(this.size);
- separator = separator !== undefined ? '' + separator : ',';
- var joined = '';
- var isFirst = true;
- this.__iterate(function(v ) {
- isFirst ? (isFirst = false) : (joined += separator);
- joined += v !== null && v !== undefined ? v.toString() : '';
- });
- return joined;
- },
-
- keys: function() {
- return this.__iterator(ITERATE_KEYS);
- },
-
- map: function(mapper, context) {
- return reify(this, mapFactory(this, mapper, context));
- },
-
- reduce: function(reducer, initialReduction, context) {
- assertNotInfinite(this.size);
- var reduction;
- var useFirst;
- if (arguments.length < 2) {
- useFirst = true;
- } else {
- reduction = initialReduction;
- }
- this.__iterate(function(v, k, c) {
- if (useFirst) {
- useFirst = false;
- reduction = v;
- } else {
- reduction = reducer.call(context, reduction, v, k, c);
- }
- });
- return reduction;
- },
-
- reduceRight: function(reducer, initialReduction, context) {
- var reversed = this.toKeyedSeq().reverse();
- return reversed.reduce.apply(reversed, arguments);
- },
-
- reverse: function() {
- return reify(this, reverseFactory(this, true));
- },
-
- slice: function(begin, end) {
- return reify(this, sliceFactory(this, begin, end, true));
- },
-
- some: function(predicate, context) {
- return !this.every(not(predicate), context);
- },
-
- sort: function(comparator) {
- return reify(this, sortFactory(this, comparator));
- },
-
- values: function() {
- return this.__iterator(ITERATE_VALUES);
- },
-
-
- // ### More sequential methods
-
- butLast: function() {
- return this.slice(0, -1);
- },
-
- isEmpty: function() {
- return this.size !== undefined ? this.size === 0 : !this.some(function() {return true});
- },
-
- count: function(predicate, context) {
- return ensureSize(
- predicate ? this.toSeq().filter(predicate, context) : this
- );
- },
-
- countBy: function(grouper, context) {
- return countByFactory(this, grouper, context);
- },
-
- equals: function(other) {
- return deepEqual(this, other);
- },
-
- entrySeq: function() {
- var iterable = this;
- if (iterable._cache) {
- // We cache as an entries array, so we can just return the cache!
- return new ArraySeq(iterable._cache);
- }
- var entriesSequence = iterable.toSeq().map(entryMapper).toIndexedSeq();
- entriesSequence.fromEntrySeq = function() {return iterable.toSeq()};
- return entriesSequence;
- },
-
- filterNot: function(predicate, context) {
- return this.filter(not(predicate), context);
- },
-
- findLast: function(predicate, context, notSetValue) {
- return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
- },
-
- first: function() {
- return this.find(returnTrue);
- },
-
- flatMap: function(mapper, context) {
- return reify(this, flatMapFactory(this, mapper, context));
- },
-
- flatten: function(depth) {
- return reify(this, flattenFactory(this, depth, true));
- },
-
- fromEntrySeq: function() {
- return new FromEntriesSequence(this);
- },
-
- get: function(searchKey, notSetValue) {
- return this.find(function(_, key) {return is(key, searchKey)}, undefined, notSetValue);
- },
-
- getIn: function(searchKeyPath, notSetValue) {
- var nested = this;
- // Note: in an ES6 environment, we would prefer:
- // for (var key of searchKeyPath) {
- var iter = forceIterator(searchKeyPath);
- var step;
- while (!(step = iter.next()).done) {
- var key = step.value;
- nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
- if (nested === NOT_SET) {
- return notSetValue;
- }
- }
- return nested;
- },
-
- groupBy: function(grouper, context) {
- return groupByFactory(this, grouper, context);
- },
-
- has: function(searchKey) {
- return this.get(searchKey, NOT_SET) !== NOT_SET;
- },
-
- hasIn: function(searchKeyPath) {
- return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
- },
-
- isSubset: function(iter) {
- iter = typeof iter.includes === 'function' ? iter : Iterable(iter);
- return this.every(function(value ) {return iter.includes(value)});
- },
-
- isSuperset: function(iter) {
- iter = typeof iter.isSubset === 'function' ? iter : Iterable(iter);
- return iter.isSubset(this);
- },
-
- keySeq: function() {
- return this.toSeq().map(keyMapper).toIndexedSeq();
- },
-
- last: function() {
- return this.toSeq().reverse().first();
- },
-
- max: function(comparator) {
- return maxFactory(this, comparator);
- },
-
- maxBy: function(mapper, comparator) {
- return maxFactory(this, comparator, mapper);
- },
-
- min: function(comparator) {
- return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator);
- },
-
- minBy: function(mapper, comparator) {
- return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator, mapper);
- },
-
- rest: function() {
- return this.slice(1);
- },
-
- skip: function(amount) {
- return this.slice(Math.max(0, amount));
- },
-
- skipLast: function(amount) {
- return reify(this, this.toSeq().reverse().skip(amount).reverse());
- },
-
- skipWhile: function(predicate, context) {
- return reify(this, skipWhileFactory(this, predicate, context, true));
- },
-
- skipUntil: function(predicate, context) {
- return this.skipWhile(not(predicate), context);
- },
-
- sortBy: function(mapper, comparator) {
- return reify(this, sortFactory(this, comparator, mapper));
- },
-
- take: function(amount) {
- return this.slice(0, Math.max(0, amount));
- },
-
- takeLast: function(amount) {
- return reify(this, this.toSeq().reverse().take(amount).reverse());
- },
-
- takeWhile: function(predicate, context) {
- return reify(this, takeWhileFactory(this, predicate, context));
- },
-
- takeUntil: function(predicate, context) {
- return this.takeWhile(not(predicate), context);
- },
-
- valueSeq: function() {
- return this.toIndexedSeq();
- },
-
-
- // ### Hashable Object
-
- hashCode: function() {
- return this.__hash || (this.__hash = hashIterable(this));
- }
-
-
- // ### Internal
-
- // abstract __iterate(fn, reverse)
-
- // abstract __iterator(type, reverse)
- });
-
- // var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
- // var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
- // var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
- // var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
-
- var IterablePrototype = Iterable.prototype;
- IterablePrototype[IS_ITERABLE_SENTINEL] = true;
- IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
- IterablePrototype.__toJS = IterablePrototype.toArray;
- IterablePrototype.__toStringMapper = quoteString;
- IterablePrototype.inspect =
- IterablePrototype.toSource = function() { return this.toString(); };
- IterablePrototype.chain = IterablePrototype.flatMap;
- IterablePrototype.contains = IterablePrototype.includes;
-
- // Temporary warning about using length
- (function () {
- try {
- Object.defineProperty(IterablePrototype, 'length', {
- get: function () {
- if (!Iterable.noLengthWarning) {
- var stack;
- try {
- throw new Error();
- } catch (error) {
- stack = error.stack;
- }
- if (stack.indexOf('_wrapObject') === -1) {
- console && console.warn && console.warn(
- 'iterable.length has been deprecated, '+
- 'use iterable.size or iterable.count(). '+
- 'This warning will become a silent error in a future version. ' +
- stack
- );
- return this.size;
- }
- }
- }
- });
- } catch (e) {}
- })();
-
-
-
- mixin(KeyedIterable, {
-
- // ### More sequential methods
-
- flip: function() {
- return reify(this, flipFactory(this));
- },
-
- findKey: function(predicate, context) {
- var entry = this.findEntry(predicate, context);
- return entry && entry[0];
- },
-
- findLastKey: function(predicate, context) {
- return this.toSeq().reverse().findKey(predicate, context);
- },
-
- keyOf: function(searchValue) {
- return this.findKey(function(value ) {return is(value, searchValue)});
- },
-
- lastKeyOf: function(searchValue) {
- return this.findLastKey(function(value ) {return is(value, searchValue)});
- },
-
- mapEntries: function(mapper, context) {var this$0 = this;
- var iterations = 0;
- return reify(this,
- this.toSeq().map(
- function(v, k) {return mapper.call(context, [k, v], iterations++, this$0)}
- ).fromEntrySeq()
- );
- },
-
- mapKeys: function(mapper, context) {var this$0 = this;
- return reify(this,
- this.toSeq().flip().map(
- function(k, v) {return mapper.call(context, k, v, this$0)}
- ).flip()
- );
- }
-
- });
-
- var KeyedIterablePrototype = KeyedIterable.prototype;
- KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
- KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
- KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
- KeyedIterablePrototype.__toStringMapper = function(v, k) {return JSON.stringify(k) + ': ' + quoteString(v)};
-
-
-
- mixin(IndexedIterable, {
-
- // ### Conversion to other types
-
- toKeyedSeq: function() {
- return new ToKeyedSequence(this, false);
- },
-
-
- // ### ES6 Collection methods (ES6 Array and Map)
-
- filter: function(predicate, context) {
- return reify(this, filterFactory(this, predicate, context, false));
- },
-
- findIndex: function(predicate, context) {
- var entry = this.findEntry(predicate, context);
- return entry ? entry[0] : -1;
- },
-
- indexOf: function(searchValue) {
- var key = this.toKeyedSeq().keyOf(searchValue);
- return key === undefined ? -1 : key;
- },
-
- lastIndexOf: function(searchValue) {
- var key = this.toKeyedSeq().reverse().keyOf(searchValue);
- return key === undefined ? -1 : key;
-
- // var index =
- // return this.toSeq().reverse().indexOf(searchValue);
- },
-
- reverse: function() {
- return reify(this, reverseFactory(this, false));
- },
-
- slice: function(begin, end) {
- return reify(this, sliceFactory(this, begin, end, false));
- },
-
- splice: function(index, removeNum /*, ...values*/) {
- var numArgs = arguments.length;
- removeNum = Math.max(removeNum | 0, 0);
- if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
- return this;
- }
- // If index is negative, it should resolve relative to the size of the
- // collection. However size may be expensive to compute if not cached, so
- // only call count() if the number is in fact negative.
- index = resolveBegin(index, index < 0 ? this.count() : this.size);
- var spliced = this.slice(0, index);
- return reify(
- this,
- numArgs === 1 ?
- spliced :
- spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
- );
- },
-
-
- // ### More collection methods
-
- findLastIndex: function(predicate, context) {
- var key = this.toKeyedSeq().findLastKey(predicate, context);
- return key === undefined ? -1 : key;
- },
-
- first: function() {
- return this.get(0);
- },
-
- flatten: function(depth) {
- return reify(this, flattenFactory(this, depth, false));
- },
-
- get: function(index, notSetValue) {
- index = wrapIndex(this, index);
- return (index < 0 || (this.size === Infinity ||
- (this.size !== undefined && index > this.size))) ?
- notSetValue :
- this.find(function(_, key) {return key === index}, undefined, notSetValue);
- },
-
- has: function(index) {
- index = wrapIndex(this, index);
- return index >= 0 && (this.size !== undefined ?
- this.size === Infinity || index < this.size :
- this.indexOf(index) !== -1
- );
- },
-
- interpose: function(separator) {
- return reify(this, interposeFactory(this, separator));
- },
-
- interleave: function(/*...iterables*/) {
- var iterables = [this].concat(arrCopy(arguments));
- var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
- var interleaved = zipped.flatten(true);
- if (zipped.size) {
- interleaved.size = zipped.size * iterables.length;
- }
- return reify(this, interleaved);
- },
-
- last: function() {
- return this.get(-1);
- },
-
- skipWhile: function(predicate, context) {
- return reify(this, skipWhileFactory(this, predicate, context, false));
- },
-
- zip: function(/*, ...iterables */) {
- var iterables = [this].concat(arrCopy(arguments));
- return reify(this, zipWithFactory(this, defaultZipper, iterables));
- },
-
- zipWith: function(zipper/*, ...iterables */) {
- var iterables = arrCopy(arguments);
- iterables[0] = this;
- return reify(this, zipWithFactory(this, zipper, iterables));
- }
-
- });
-
- IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
- IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
-
-
-
- mixin(SetIterable, {
-
- // ### ES6 Collection methods (ES6 Array and Map)
-
- get: function(value, notSetValue) {
- return this.has(value) ? value : notSetValue;
- },
-
- includes: function(value) {
- return this.has(value);
- },
-
-
- // ### More sequential methods
-
- keySeq: function() {
- return this.valueSeq();
- }
-
- });
-
- SetIterable.prototype.has = IterablePrototype.includes;
-
-
- // Mixin subclasses
-
- mixin(KeyedSeq, KeyedIterable.prototype);
- mixin(IndexedSeq, IndexedIterable.prototype);
- mixin(SetSeq, SetIterable.prototype);
-
- mixin(KeyedCollection, KeyedIterable.prototype);
- mixin(IndexedCollection, IndexedIterable.prototype);
- mixin(SetCollection, SetIterable.prototype);
-
-
- // #pragma Helper functions
-
- function keyMapper(v, k) {
- return k;
- }
-
- function entryMapper(v, k) {
- return [k, v];
- }
-
- function not(predicate) {
- return function() {
- return !predicate.apply(this, arguments);
- }
- }
-
- function neg(predicate) {
- return function() {
- return -predicate.apply(this, arguments);
- }
- }
-
- function quoteString(value) {
- return typeof value === 'string' ? JSON.stringify(value) : value;
- }
-
- function defaultZipper() {
- return arrCopy(arguments);
- }
-
- function defaultNegComparator(a, b) {
- return a < b ? 1 : a > b ? -1 : 0;
- }
-
- function hashIterable(iterable) {
- if (iterable.size === Infinity) {
- return 0;
- }
- var ordered = isOrdered(iterable);
- var keyed = isKeyed(iterable);
- var h = ordered ? 1 : 0;
- var size = iterable.__iterate(
- keyed ?
- ordered ?
- function(v, k) { h = 31 * h + hashMerge(hash(v), hash(k)) | 0; } :
- function(v, k) { h = h + hashMerge(hash(v), hash(k)) | 0; } :
- ordered ?
- function(v ) { h = 31 * h + hash(v) | 0; } :
- function(v ) { h = h + hash(v) | 0; }
- );
- return murmurHashOfSize(size, h);
- }
-
- function murmurHashOfSize(size, h) {
- h = imul(h, 0xCC9E2D51);
- h = imul(h << 15 | h >>> -15, 0x1B873593);
- h = imul(h << 13 | h >>> -13, 5);
- h = (h + 0xE6546B64 | 0) ^ size;
- h = imul(h ^ h >>> 16, 0x85EBCA6B);
- h = imul(h ^ h >>> 13, 0xC2B2AE35);
- h = smi(h ^ h >>> 16);
- return h;
- }
-
- function hashMerge(a, b) {
- return a ^ b + 0x9E3779B9 + (a << 6) + (a >> 2) | 0; // int
- }
-
- var Immutable = {
-
- Iterable: Iterable,
-
- Seq: Seq,
- Collection: Collection,
- Map: Map,
- OrderedMap: OrderedMap,
- List: List,
- Stack: Stack,
- Set: Set,
- OrderedSet: OrderedSet,
-
- Record: Record,
- Range: Range,
- Repeat: Repeat,
-
- is: is,
- fromJS: fromJS
-
- };
-
- return Immutable;
-
- }));
- });
-
- var OrderedMap = immutable.OrderedMap;
-
-
- var BlockMapBuilder = {
- createFromArray: function createFromArray(blocks) {
- return OrderedMap(blocks.map(function (block) {
- return [block.getKey(), block];
- }));
- }
- };
-
- var BlockMapBuilder_1 = BlockMapBuilder;
-
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
- var Map = immutable.Map,
- OrderedSet = immutable.OrderedSet,
- Record = immutable.Record;
-
- // Immutable.map is typed such that the value for every key in the map
- // must be the same type
-
-
- var EMPTY_SET = OrderedSet();
-
- var defaultRecord = {
- style: EMPTY_SET,
- entity: null
- };
-
- var CharacterMetadataRecord = Record(defaultRecord);
-
- var CharacterMetadata = function (_CharacterMetadataRec) {
- _inherits(CharacterMetadata, _CharacterMetadataRec);
-
- function CharacterMetadata() {
- _classCallCheck(this, CharacterMetadata);
-
- return _possibleConstructorReturn(this, _CharacterMetadataRec.apply(this, arguments));
- }
-
- CharacterMetadata.prototype.getStyle = function getStyle() {
- return this.get('style');
- };
-
- CharacterMetadata.prototype.getEntity = function getEntity() {
- return this.get('entity');
- };
-
- CharacterMetadata.prototype.hasStyle = function hasStyle(style) {
- return this.getStyle().includes(style);
- };
-
- CharacterMetadata.applyStyle = function applyStyle(record, style) {
- var withStyle = record.set('style', record.getStyle().add(style));
- return CharacterMetadata.create(withStyle);
- };
-
- CharacterMetadata.removeStyle = function removeStyle(record, style) {
- var withoutStyle = record.set('style', record.getStyle().remove(style));
- return CharacterMetadata.create(withoutStyle);
- };
-
- CharacterMetadata.applyEntity = function applyEntity(record, entityKey) {
- var withEntity = record.getEntity() === entityKey ? record : record.set('entity', entityKey);
- return CharacterMetadata.create(withEntity);
- };
-
- /**
- * Use this function instead of the `CharacterMetadata` constructor.
- * Since most content generally uses only a very small number of
- * style/entity permutations, we can reuse these objects as often as
- * possible.
- */
-
-
- CharacterMetadata.create = function create(config) {
- if (!config) {
- return EMPTY;
- }
-
- var defaultConfig = {
- style: EMPTY_SET,
- entity: null
- };
-
- // Fill in unspecified properties, if necessary.
- var configMap = Map(defaultConfig).merge(config);
-
- var existing = pool.get(configMap);
- if (existing) {
- return existing;
- }
-
- var newCharacter = new CharacterMetadata(configMap);
- pool = pool.set(configMap, newCharacter);
- return newCharacter;
- };
-
- return CharacterMetadata;
- }(CharacterMetadataRecord);
-
- var EMPTY = new CharacterMetadata();
- var pool = Map([[Map(defaultRecord), EMPTY]]);
-
- CharacterMetadata.EMPTY = EMPTY;
-
- var CharacterMetadata_1 = CharacterMetadata;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule findRangesImmutable
- * @format
- *
- */
-
- /**
- * Search through an array to find contiguous stretches of elements that
- * match a specified filter function.
- *
- * When ranges are found, execute a specified `found` function to supply
- * the values to the caller.
- */
- function findRangesImmutable(haystack, areEqualFn, filterFn, foundFn) {
- if (!haystack.size) {
- return;
- }
-
- var cursor = 0;
-
- haystack.reduce(function (value, nextValue, nextIndex) {
- if (!areEqualFn(value, nextValue)) {
- if (filterFn(value)) {
- foundFn(cursor, nextIndex);
- }
- cursor = nextIndex;
- }
- return nextValue;
- });
-
- filterFn(haystack.last()) && foundFn(cursor, haystack.count());
- }
-
- var findRangesImmutable_1 = findRangesImmutable;
-
- function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- function _possibleConstructorReturn$1(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
- function _inherits$1(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-
-
-
-
-
- var List = immutable.List,
- Map$1 = immutable.Map,
- OrderedSet$1 = immutable.OrderedSet,
- Record$1 = immutable.Record,
- Repeat = immutable.Repeat;
-
-
- var EMPTY_SET$1 = OrderedSet$1();
-
- var defaultRecord$1 = {
- key: '',
- type: 'unstyled',
- text: '',
- characterList: List(),
- depth: 0,
- data: Map$1()
- };
-
- var ContentBlockRecord = Record$1(defaultRecord$1);
-
- var decorateCharacterList = function decorateCharacterList(config) {
- if (!config) {
- return config;
- }
-
- var characterList = config.characterList,
- text = config.text;
-
-
- if (text && !characterList) {
- config.characterList = List(Repeat(CharacterMetadata_1.EMPTY, text.length));
- }
-
- return config;
- };
-
- var ContentBlock = function (_ContentBlockRecord) {
- _inherits$1(ContentBlock, _ContentBlockRecord);
-
- function ContentBlock(config) {
- _classCallCheck$1(this, ContentBlock);
-
- return _possibleConstructorReturn$1(this, _ContentBlockRecord.call(this, decorateCharacterList(config)));
- }
-
- ContentBlock.prototype.getKey = function getKey() {
- return this.get('key');
- };
-
- ContentBlock.prototype.getType = function getType() {
- return this.get('type');
- };
-
- ContentBlock.prototype.getText = function getText() {
- return this.get('text');
- };
-
- ContentBlock.prototype.getCharacterList = function getCharacterList() {
- return this.get('characterList');
- };
-
- ContentBlock.prototype.getLength = function getLength() {
- return this.getText().length;
- };
-
- ContentBlock.prototype.getDepth = function getDepth() {
- return this.get('depth');
- };
-
- ContentBlock.prototype.getData = function getData() {
- return this.get('data');
- };
-
- ContentBlock.prototype.getInlineStyleAt = function getInlineStyleAt(offset) {
- var character = this.getCharacterList().get(offset);
- return character ? character.getStyle() : EMPTY_SET$1;
- };
-
- ContentBlock.prototype.getEntityAt = function getEntityAt(offset) {
- var character = this.getCharacterList().get(offset);
- return character ? character.getEntity() : null;
- };
-
- /**
- * Execute a callback for every contiguous range of styles within the block.
- */
-
-
- ContentBlock.prototype.findStyleRanges = function findStyleRanges(filterFn, callback) {
- findRangesImmutable_1(this.getCharacterList(), haveEqualStyle, filterFn, callback);
- };
-
- /**
- * Execute a callback for every contiguous range of entities within the block.
- */
-
-
- ContentBlock.prototype.findEntityRanges = function findEntityRanges(filterFn, callback) {
- findRangesImmutable_1(this.getCharacterList(), haveEqualEntity, filterFn, callback);
- };
-
- return ContentBlock;
- }(ContentBlockRecord);
-
- function haveEqualStyle(charA, charB) {
- return charA.getStyle() === charB.getStyle();
- }
-
- function haveEqualEntity(charA, charB) {
- return charA.getEntity() === charB.getEntity();
- }
-
- var ContentBlock_1 = ContentBlock;
-
- function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- function _possibleConstructorReturn$2(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
- function _inherits$2(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-
-
-
-
-
- var List$1 = immutable.List,
- Map$2 = immutable.Map,
- OrderedSet$2 = immutable.OrderedSet,
- Record$2 = immutable.Record,
- Repeat$1 = immutable.Repeat;
-
-
- var EMPTY_SET$2 = OrderedSet$2();
-
- var defaultRecord$2 = {
- parent: null,
- characterList: List$1(),
- data: Map$2(),
- depth: 0,
- key: '',
- text: '',
- type: 'unstyled',
- children: List$1(),
- prevSibling: null,
- nextSibling: null
- };
-
- var haveEqualStyle$1 = function haveEqualStyle(charA, charB) {
- return charA.getStyle() === charB.getStyle();
- };
-
- var haveEqualEntity$1 = function haveEqualEntity(charA, charB) {
- return charA.getEntity() === charB.getEntity();
- };
-
- var decorateCharacterList$1 = function decorateCharacterList(config) {
- if (!config) {
- return config;
- }
-
- var characterList = config.characterList,
- text = config.text;
-
-
- if (text && !characterList) {
- config.characterList = List$1(Repeat$1(CharacterMetadata_1.EMPTY, text.length));
- }
-
- return config;
- };
-
- var ContentBlockNode = function (_Record) {
- _inherits$2(ContentBlockNode, _Record);
-
- function ContentBlockNode() {
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultRecord$2;
-
- _classCallCheck$2(this, ContentBlockNode);
-
- return _possibleConstructorReturn$2(this, _Record.call(this, decorateCharacterList$1(props)));
- }
-
- ContentBlockNode.prototype.getKey = function getKey() {
- return this.get('key');
- };
-
- ContentBlockNode.prototype.getType = function getType() {
- return this.get('type');
- };
-
- ContentBlockNode.prototype.getText = function getText() {
- return this.get('text');
- };
-
- ContentBlockNode.prototype.getCharacterList = function getCharacterList() {
- return this.get('characterList');
- };
-
- ContentBlockNode.prototype.getLength = function getLength() {
- return this.getText().length;
- };
-
- ContentBlockNode.prototype.getDepth = function getDepth() {
- return this.get('depth');
- };
-
- ContentBlockNode.prototype.getData = function getData() {
- return this.get('data');
- };
-
- ContentBlockNode.prototype.getInlineStyleAt = function getInlineStyleAt(offset) {
- var character = this.getCharacterList().get(offset);
- return character ? character.getStyle() : EMPTY_SET$2;
- };
-
- ContentBlockNode.prototype.getEntityAt = function getEntityAt(offset) {
- var character = this.getCharacterList().get(offset);
- return character ? character.getEntity() : null;
- };
-
- ContentBlockNode.prototype.getChildKeys = function getChildKeys() {
- return this.get('children');
- };
-
- ContentBlockNode.prototype.getParentKey = function getParentKey() {
- return this.get('parent');
- };
-
- ContentBlockNode.prototype.getPrevSiblingKey = function getPrevSiblingKey() {
- return this.get('prevSibling');
- };
-
- ContentBlockNode.prototype.getNextSiblingKey = function getNextSiblingKey() {
- return this.get('nextSibling');
- };
-
- ContentBlockNode.prototype.findStyleRanges = function findStyleRanges(filterFn, callback) {
- findRangesImmutable_1(this.getCharacterList(), haveEqualStyle$1, filterFn, callback);
- };
-
- ContentBlockNode.prototype.findEntityRanges = function findEntityRanges(filterFn, callback) {
- findRangesImmutable_1(this.getCharacterList(), haveEqualEntity$1, filterFn, callback);
- };
-
- return ContentBlockNode;
- }(Record$2(defaultRecord$2));
-
- var ContentBlockNode_1 = ContentBlockNode;
-
- /**
- * Copyright 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule DraftFeatureFlags-core
- * @format
- *
- */
-
- var DraftFeatureFlags = {
- draft_killswitch_allow_nontextnodes: false,
- draft_segmented_entities_behavior: false,
- draft_handlebeforeinput_composed_text: false,
- draft_tree_data_support: false
- };
-
- var DraftFeatureFlagsCore = DraftFeatureFlags;
-
- var DraftFeatureFlags_1 = DraftFeatureFlagsCore;
-
- var Map$3 = immutable.Map;
-
- var ContentStateInlineStyle = {
- add: function add(contentState, selectionState, inlineStyle) {
- return modifyInlineStyle(contentState, selectionState, inlineStyle, true);
- },
-
- remove: function remove(contentState, selectionState, inlineStyle) {
- return modifyInlineStyle(contentState, selectionState, inlineStyle, false);
- }
- };
-
- function modifyInlineStyle(contentState, selectionState, inlineStyle, addOrRemove) {
- var blockMap = contentState.getBlockMap();
- var startKey = selectionState.getStartKey();
- var startOffset = selectionState.getStartOffset();
- var endKey = selectionState.getEndKey();
- var endOffset = selectionState.getEndOffset();
-
- var newBlocks = blockMap.skipUntil(function (_, k) {
- return k === startKey;
- }).takeUntil(function (_, k) {
- return k === endKey;
- }).concat(Map$3([[endKey, blockMap.get(endKey)]])).map(function (block, blockKey) {
- var sliceStart;
- var sliceEnd;
-
- if (startKey === endKey) {
- sliceStart = startOffset;
- sliceEnd = endOffset;
- } else {
- sliceStart = blockKey === startKey ? startOffset : 0;
- sliceEnd = blockKey === endKey ? endOffset : block.getLength();
- }
-
- var chars = block.getCharacterList();
- var current;
- while (sliceStart < sliceEnd) {
- current = chars.get(sliceStart);
- chars = chars.set(sliceStart, addOrRemove ? CharacterMetadata_1.applyStyle(current, inlineStyle) : CharacterMetadata_1.removeStyle(current, inlineStyle));
- sliceStart++;
- }
-
- return block.set('characterList', chars);
- });
-
- return contentState.merge({
- blockMap: blockMap.merge(newBlocks),
- selectionBefore: selectionState,
- selectionAfter: selectionState
- });
- }
-
- var ContentStateInlineStyle_1 = ContentStateInlineStyle;
-
- function applyEntityToContentBlock(contentBlock, start, end, entityKey) {
- var characterList = contentBlock.getCharacterList();
- while (start < end) {
- characterList = characterList.set(start, CharacterMetadata_1.applyEntity(characterList.get(start), entityKey));
- start++;
- }
- return contentBlock.set('characterList', characterList);
- }
-
- var applyEntityToContentBlock_1 = applyEntityToContentBlock;
-
- function applyEntityToContentState(contentState, selectionState, entityKey) {
- var blockMap = contentState.getBlockMap();
- var startKey = selectionState.getStartKey();
- var startOffset = selectionState.getStartOffset();
- var endKey = selectionState.getEndKey();
- var endOffset = selectionState.getEndOffset();
-
- var newBlocks = blockMap.skipUntil(function (_, k) {
- return k === startKey;
- }).takeUntil(function (_, k) {
- return k === endKey;
- }).toOrderedMap().merge(immutable.OrderedMap([[endKey, blockMap.get(endKey)]])).map(function (block, blockKey) {
- var sliceStart = blockKey === startKey ? startOffset : 0;
- var sliceEnd = blockKey === endKey ? endOffset : block.getLength();
- return applyEntityToContentBlock_1(block, sliceStart, sliceEnd, entityKey);
- });
-
- return contentState.merge({
- blockMap: blockMap.merge(newBlocks),
- selectionBefore: selectionState,
- selectionAfter: selectionState
- });
- }
-
- var applyEntityToContentState_1 = applyEntityToContentState;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule DraftEntitySegments
- * @format
- *
- */
-
- /**
- * Identify the range to delete from a segmented entity.
- *
- * Rules:
- *
- * Example: 'John F. Kennedy'
- *
- * - Deletion from within any non-whitespace (i.e. ['John', 'F.', 'Kennedy'])
- * will return the range of that text.
- *
- * 'John F. Kennedy' -> 'John F.'
- * ^
- *
- * - Forward deletion of whitespace will remove the following section:
- *
- * 'John F. Kennedy' -> 'John Kennedy'
- * ^
- *
- * - Backward deletion of whitespace will remove the previous section:
- *
- * 'John F. Kennedy' -> 'F. Kennedy'
- * ^
- */
- var DraftEntitySegments = {
- getRemovalRange: function getRemovalRange(selectionStart, selectionEnd, text, entityStart, direction) {
- var segments = text.split(' ');
- segments = segments.map(function ( /*string*/segment, /*number*/ii) {
- if (direction === 'forward') {
- if (ii > 0) {
- return ' ' + segment;
- }
- } else if (ii < segments.length - 1) {
- return segment + ' ';
- }
- return segment;
- });
-
- var segmentStart = entityStart;
- var segmentEnd;
- var segment;
- var removalStart = null;
- var removalEnd = null;
-
- for (var jj = 0; jj < segments.length; jj++) {
- segment = segments[jj];
- segmentEnd = segmentStart + segment.length;
-
- // Our selection overlaps this segment.
- if (selectionStart < segmentEnd && segmentStart < selectionEnd) {
- if (removalStart !== null) {
- removalEnd = segmentEnd;
- } else {
- removalStart = segmentStart;
- removalEnd = segmentEnd;
- }
- } else if (removalStart !== null) {
- break;
- }
-
- segmentStart = segmentEnd;
- }
-
- var entityEnd = entityStart + text.length;
- var atStart = removalStart === entityStart;
- var atEnd = removalEnd === entityEnd;
-
- if (!atStart && atEnd || atStart && !atEnd) {
- if (direction === 'forward') {
- if (removalEnd !== entityEnd) {
- removalEnd++;
- }
- } else if (removalStart !== entityStart) {
- removalStart--;
- }
- }
-
- return {
- start: removalStart,
- end: removalEnd
- };
- }
- };
-
- var DraftEntitySegments_1 = DraftEntitySegments;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- */
-
- /**
- * Use invariant() to assert state which your program assumes to be true.
- *
- * Provide sprintf-style format (only %s is supported) and arguments
- * to provide information about what broke and what you were
- * expecting.
- *
- * The invariant message will be stripped in production, but the invariant
- * will remain to ensure logic does not differ in production.
- */
-
- var validateFormat = function validateFormat(format) {};
-
- if (process.env.NODE_ENV !== 'production') {
- validateFormat = function validateFormat(format) {
- if (format === undefined) {
- throw new Error('invariant requires an error message argument');
- }
- };
- }
-
- function invariant(condition, format, a, b, c, d, e, f) {
- validateFormat(format);
-
- if (!condition) {
- var error;
- if (format === undefined) {
- error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
- } else {
- var args = [a, b, c, d, e, f];
- var argIndex = 0;
- error = new Error(format.replace(/%s/g, function () {
- return args[argIndex++];
- }));
- error.name = 'Invariant Violation';
- }
-
- error.framesToPop = 1; // we don't care about invariant's own frame
- throw error;
- }
- }
-
- var invariant_1 = invariant;
-
- /**
- * Obtain the start and end positions of the range that has the
- * specified entity applied to it.
- *
- * Entity keys are applied only to contiguous stretches of text, so this
- * method searches for the first instance of the entity key and returns
- * the subsequent range.
- */
- function getRangesForDraftEntity(block, key) {
- var ranges = [];
- block.findEntityRanges(function (c) {
- return c.getEntity() === key;
- }, function (start, end) {
- ranges.push({ start: start, end: end });
- });
-
- !!!ranges.length ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Entity key not found in this range.') : invariant_1(false) : void 0;
-
- return ranges;
- }
-
- var getRangesForDraftEntity_1 = getRangesForDraftEntity;
-
- /**
- * Given a SelectionState and a removal direction, determine the entire range
- * that should be removed from a ContentState. This is based on any entities
- * within the target, with their `mutability` values taken into account.
- *
- * For instance, if we are attempting to remove part of an "immutable" entity
- * range, the entire entity must be removed. The returned `SelectionState`
- * will be adjusted accordingly.
- */
- function getCharacterRemovalRange(entityMap, startBlock, endBlock, selectionState, direction) {
- var start = selectionState.getStartOffset();
- var end = selectionState.getEndOffset();
- var startEntityKey = startBlock.getEntityAt(start);
- var endEntityKey = endBlock.getEntityAt(end - 1);
- if (!startEntityKey && !endEntityKey) {
- return selectionState;
- }
- var newSelectionState = selectionState;
- if (startEntityKey && startEntityKey === endEntityKey) {
- newSelectionState = getEntityRemovalRange(entityMap, startBlock, newSelectionState, direction, startEntityKey, true, true);
- } else if (startEntityKey && endEntityKey) {
- var startSelectionState = getEntityRemovalRange(entityMap, startBlock, newSelectionState, direction, startEntityKey, false, true);
- var endSelectionState = getEntityRemovalRange(entityMap, endBlock, newSelectionState, direction, endEntityKey, false, false);
- newSelectionState = newSelectionState.merge({
- anchorOffset: startSelectionState.getAnchorOffset(),
- focusOffset: endSelectionState.getFocusOffset(),
- isBackward: false
- });
- } else if (startEntityKey) {
- var _startSelectionState = getEntityRemovalRange(entityMap, startBlock, newSelectionState, direction, startEntityKey, false, true);
- newSelectionState = newSelectionState.merge({
- anchorOffset: _startSelectionState.getStartOffset(),
- isBackward: false
- });
- } else if (endEntityKey) {
- var _endSelectionState = getEntityRemovalRange(entityMap, endBlock, newSelectionState, direction, endEntityKey, false, false);
- newSelectionState = newSelectionState.merge({
- focusOffset: _endSelectionState.getEndOffset(),
- isBackward: false
- });
- }
- return newSelectionState;
- }
-
- function getEntityRemovalRange(entityMap, block, selectionState, direction, entityKey, isEntireSelectionWithinEntity, isEntityAtStart) {
- var start = selectionState.getStartOffset();
- var end = selectionState.getEndOffset();
- var entity = entityMap.__get(entityKey);
- var mutability = entity.getMutability();
- var sideToConsider = isEntityAtStart ? start : end;
-
- // `MUTABLE` entities can just have the specified range of text removed
- // directly. No adjustments are needed.
- if (mutability === 'MUTABLE') {
- return selectionState;
- }
-
- // Find the entity range that overlaps with our removal range.
- var entityRanges = getRangesForDraftEntity_1(block, entityKey).filter(function (range) {
- return sideToConsider <= range.end && sideToConsider >= range.start;
- });
-
- !(entityRanges.length == 1) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'There should only be one entity range within this removal range.') : invariant_1(false) : void 0;
-
- var entityRange = entityRanges[0];
-
- // For `IMMUTABLE` entity types, we will remove the entire entity range.
- if (mutability === 'IMMUTABLE') {
- return selectionState.merge({
- anchorOffset: entityRange.start,
- focusOffset: entityRange.end,
- isBackward: false
- });
- }
-
- // For `SEGMENTED` entity types, determine the appropriate segment to
- // remove.
- if (!isEntireSelectionWithinEntity) {
- if (isEntityAtStart) {
- end = entityRange.end;
- } else {
- start = entityRange.start;
- }
- }
-
- var removalRange = DraftEntitySegments_1.getRemovalRange(start, end, block.getText().slice(entityRange.start, entityRange.end), entityRange.start, direction);
-
- return selectionState.merge({
- anchorOffset: removalRange.start,
- focusOffset: removalRange.end,
- isBackward: false
- });
- }
-
- var getCharacterRemovalRange_1 = getCharacterRemovalRange;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule generateRandomKey
- * @format
- *
- */
-
- var seenKeys = {};
- var MULTIPLIER = Math.pow(2, 24);
-
- function generateRandomKey() {
- var key = void 0;
- while (key === undefined || seenKeys.hasOwnProperty(key) || !isNaN(+key)) {
- key = Math.floor(Math.random() * MULTIPLIER).toString(32);
- }
- seenKeys[key] = true;
- return key;
- }
-
- var generateRandomKey_1 = generateRandomKey;
-
- var OrderedMap$1 = immutable.OrderedMap;
-
-
- var randomizeContentBlockNodeKeys = function randomizeContentBlockNodeKeys(blockMap) {
- var newKeysRef = {};
-
- // we keep track of root blocks in order to update subsequent sibling links
- var lastRootBlock = void 0;
-
- return OrderedMap$1(blockMap.withMutations(function (blockMapState) {
- blockMapState.forEach(function (block, index) {
- var oldKey = block.getKey();
- var nextKey = block.getNextSiblingKey();
- var prevKey = block.getPrevSiblingKey();
- var childrenKeys = block.getChildKeys();
- var parentKey = block.getParentKey();
-
- // new key that we will use to build linking
- var key = generateRandomKey_1();
-
- // we will add it here to re-use it later
- newKeysRef[oldKey] = key;
-
- if (nextKey) {
- var nextBlock = blockMapState.get(nextKey);
- if (nextBlock) {
- blockMapState.setIn([nextKey, 'prevSibling'], key);
- } else {
- // this can happen when generating random keys for fragments
- blockMapState.setIn([oldKey, 'nextSibling'], null);
- }
- }
-
- if (prevKey) {
- var prevBlock = blockMapState.get(prevKey);
- if (prevBlock) {
- blockMapState.setIn([prevKey, 'nextSibling'], key);
- } else {
- // this can happen when generating random keys for fragments
- blockMapState.setIn([oldKey, 'prevSibling'], null);
- }
- }
-
- if (parentKey && blockMapState.get(parentKey)) {
- var parentBlock = blockMapState.get(parentKey);
- var parentChildrenList = parentBlock.getChildKeys();
- blockMapState.setIn([parentKey, 'children'], parentChildrenList.set(parentChildrenList.indexOf(block.getKey()), key));
- } else {
- // blocks will then be treated as root block nodes
- blockMapState.setIn([oldKey, 'parent'], null);
-
- if (lastRootBlock) {
- blockMapState.setIn([lastRootBlock.getKey(), 'nextSibling'], key);
- blockMapState.setIn([oldKey, 'prevSibling'], newKeysRef[lastRootBlock.getKey()]);
- }
-
- lastRootBlock = blockMapState.get(oldKey);
- }
-
- childrenKeys.forEach(function (childKey) {
- var childBlock = blockMapState.get(childKey);
- if (childBlock) {
- blockMapState.setIn([childKey, 'parent'], key);
- } else {
- blockMapState.setIn([oldKey, 'children'], block.getChildKeys().filter(function (child) {
- return child !== childKey;
- }));
- }
- });
- });
- }).toArray().map(function (block) {
- return [newKeysRef[block.getKey()], block.set('key', newKeysRef[block.getKey()])];
- }));
- };
-
- var randomizeContentBlockKeys = function randomizeContentBlockKeys(blockMap) {
- return OrderedMap$1(blockMap.toArray().map(function (block) {
- var key = generateRandomKey_1();
- return [key, block.set('key', key)];
- }));
- };
-
- var randomizeBlockMapKeys = function randomizeBlockMapKeys(blockMap) {
- var isTreeBasedBlockMap = blockMap.first() instanceof ContentBlockNode_1;
-
- if (!isTreeBasedBlockMap) {
- return randomizeContentBlockKeys(blockMap);
- }
-
- return randomizeContentBlockNodeKeys(blockMap);
- };
-
- var randomizeBlockMapKeys_1 = randomizeBlockMapKeys;
-
- function removeEntitiesAtEdges(contentState, selectionState) {
- var blockMap = contentState.getBlockMap();
- var entityMap = contentState.getEntityMap();
-
- var updatedBlocks = {};
-
- var startKey = selectionState.getStartKey();
- var startOffset = selectionState.getStartOffset();
- var startBlock = blockMap.get(startKey);
- var updatedStart = removeForBlock(entityMap, startBlock, startOffset);
-
- if (updatedStart !== startBlock) {
- updatedBlocks[startKey] = updatedStart;
- }
-
- var endKey = selectionState.getEndKey();
- var endOffset = selectionState.getEndOffset();
- var endBlock = blockMap.get(endKey);
- if (startKey === endKey) {
- endBlock = updatedStart;
- }
-
- var updatedEnd = removeForBlock(entityMap, endBlock, endOffset);
-
- if (updatedEnd !== endBlock) {
- updatedBlocks[endKey] = updatedEnd;
- }
-
- if (!Object.keys(updatedBlocks).length) {
- return contentState.set('selectionAfter', selectionState);
- }
-
- return contentState.merge({
- blockMap: blockMap.merge(updatedBlocks),
- selectionAfter: selectionState
- });
- }
-
- function getRemovalRange(characters, key, offset) {
- var removalRange;
- findRangesImmutable_1(characters, function (a, b) {
- return a.getEntity() === b.getEntity();
- }, function (element) {
- return element.getEntity() === key;
- }, function (start, end) {
- if (start <= offset && end >= offset) {
- removalRange = { start: start, end: end };
- }
- });
- !(typeof removalRange === 'object') ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Removal range must exist within character list.') : invariant_1(false) : void 0;
- return removalRange;
- }
-
- function removeForBlock(entityMap, block, offset) {
- var chars = block.getCharacterList();
- var charBefore = offset > 0 ? chars.get(offset - 1) : undefined;
- var charAfter = offset < chars.count() ? chars.get(offset) : undefined;
- var entityBeforeCursor = charBefore ? charBefore.getEntity() : undefined;
- var entityAfterCursor = charAfter ? charAfter.getEntity() : undefined;
-
- if (entityAfterCursor && entityAfterCursor === entityBeforeCursor) {
- var entity = entityMap.__get(entityAfterCursor);
- if (entity.getMutability() !== 'MUTABLE') {
- var _getRemovalRange = getRemovalRange(chars, entityAfterCursor, offset),
- start = _getRemovalRange.start,
- end = _getRemovalRange.end;
-
- var current;
- while (start < end) {
- current = chars.get(start);
- chars = chars.set(start, CharacterMetadata_1.applyEntity(current, null));
- start++;
- }
- return block.set('characterList', chars);
- }
- }
-
- return block;
- }
-
- var removeEntitiesAtEdges_1 = removeEntitiesAtEdges;
-
- var getContentStateFragment = function getContentStateFragment(contentState, selectionState) {
- var startKey = selectionState.getStartKey();
- var startOffset = selectionState.getStartOffset();
- var endKey = selectionState.getEndKey();
- var endOffset = selectionState.getEndOffset();
-
- // Edge entities should be stripped to ensure that we don't preserve
- // invalid partial entities when the fragment is reused. We do, however,
- // preserve entities that are entirely within the selection range.
- var contentWithoutEdgeEntities = removeEntitiesAtEdges_1(contentState, selectionState);
-
- var blockMap = contentWithoutEdgeEntities.getBlockMap();
- var blockKeys = blockMap.keySeq();
- var startIndex = blockKeys.indexOf(startKey);
- var endIndex = blockKeys.indexOf(endKey) + 1;
-
- return randomizeBlockMapKeys_1(blockMap.slice(startIndex, endIndex).map(function (block, blockKey) {
- var text = block.getText();
- var chars = block.getCharacterList();
-
- if (startKey === endKey) {
- return block.merge({
- text: text.slice(startOffset, endOffset),
- characterList: chars.slice(startOffset, endOffset)
- });
- }
-
- if (blockKey === startKey) {
- return block.merge({
- text: text.slice(startOffset),
- characterList: chars.slice(startOffset)
- });
- }
-
- if (blockKey === endKey) {
- return block.merge({
- text: text.slice(0, endOffset),
- characterList: chars.slice(0, endOffset)
- });
- }
-
- return block;
- }));
- };
-
- var getContentStateFragment_1 = getContentStateFragment;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule insertIntoList
- * @format
- *
- */
-
- /**
- * Maintain persistence for target list when appending and prepending.
- */
- function insertIntoList(targetList, toInsert, offset) {
- if (offset === targetList.count()) {
- toInsert.forEach(function (c) {
- targetList = targetList.push(c);
- });
- } else if (offset === 0) {
- toInsert.reverse().forEach(function (c) {
- targetList = targetList.unshift(c);
- });
- } else {
- var head = targetList.slice(0, offset);
- var tail = targetList.slice(offset);
- targetList = head.concat(toInsert, tail).toList();
- }
- return targetList;
- }
-
- var insertIntoList_1 = insertIntoList;
-
- var List$2 = immutable.List;
-
-
- var updateExistingBlock = function updateExistingBlock(contentState, selectionState, blockMap, fragmentBlock, targetKey, targetOffset) {
- var targetBlock = blockMap.get(targetKey);
- var text = targetBlock.getText();
- var chars = targetBlock.getCharacterList();
- var finalKey = targetKey;
- var finalOffset = targetOffset + fragmentBlock.getText().length;
-
- var newBlock = targetBlock.merge({
- text: text.slice(0, targetOffset) + fragmentBlock.getText() + text.slice(targetOffset),
- characterList: insertIntoList_1(chars, fragmentBlock.getCharacterList(), targetOffset),
- data: fragmentBlock.getData()
- });
-
- return contentState.merge({
- blockMap: blockMap.set(targetKey, newBlock),
- selectionBefore: selectionState,
- selectionAfter: selectionState.merge({
- anchorKey: finalKey,
- anchorOffset: finalOffset,
- focusKey: finalKey,
- focusOffset: finalOffset,
- isBackward: false
- })
- });
- };
-
- /**
- * Appends text/characterList from the fragment first block to
- * target block.
- */
- var updateHead = function updateHead(block, targetOffset, fragment) {
- var text = block.getText();
- var chars = block.getCharacterList();
-
- // Modify head portion of block.
- var headText = text.slice(0, targetOffset);
- var headCharacters = chars.slice(0, targetOffset);
- var appendToHead = fragment.first();
-
- return block.merge({
- text: headText + appendToHead.getText(),
- characterList: headCharacters.concat(appendToHead.getCharacterList()),
- type: headText ? block.getType() : appendToHead.getType(),
- data: appendToHead.getData()
- });
- };
-
- /**
- * Appends offset text/characterList from the target block to the last
- * fragment block.
- */
- var updateTail = function updateTail(block, targetOffset, fragment) {
- // Modify tail portion of block.
- var text = block.getText();
- var chars = block.getCharacterList();
-
- // Modify head portion of block.
- var blockSize = text.length;
- var tailText = text.slice(targetOffset, blockSize);
- var tailCharacters = chars.slice(targetOffset, blockSize);
- var prependToTail = fragment.last();
-
- return prependToTail.merge({
- text: prependToTail.getText() + tailText,
- characterList: prependToTail.getCharacterList().concat(tailCharacters),
- data: prependToTail.getData()
- });
- };
-
- var getRootBlocks = function getRootBlocks(block, blockMap) {
- var headKey = block.getKey();
- var rootBlock = block;
- var rootBlocks = [];
-
- // sometimes the fragment head block will not be part of the blockMap itself this can happen when
- // the fragment head is used to update the target block, however when this does not happen we need
- // to make sure that we include it on the rootBlocks since the first block of a fragment is always a
- // fragment root block
- if (blockMap.get(headKey)) {
- rootBlocks.push(headKey);
- }
-
- while (rootBlock && rootBlock.getNextSiblingKey()) {
- var lastSiblingKey = rootBlock.getNextSiblingKey();
-
- if (!lastSiblingKey) {
- break;
- }
-
- rootBlocks.push(lastSiblingKey);
- rootBlock = blockMap.get(lastSiblingKey);
- }
-
- return rootBlocks;
- };
-
- var updateBlockMapLinks = function updateBlockMapLinks(blockMap, originalBlockMap, targetBlock, fragmentHeadBlock) {
- return blockMap.withMutations(function (blockMapState) {
- var targetKey = targetBlock.getKey();
- var headKey = fragmentHeadBlock.getKey();
- var targetNextKey = targetBlock.getNextSiblingKey();
- var targetParentKey = targetBlock.getParentKey();
- var fragmentRootBlocks = getRootBlocks(fragmentHeadBlock, blockMap);
- var lastRootFragmentBlockKey = fragmentRootBlocks[fragmentRootBlocks.length - 1];
-
- if (blockMapState.get(headKey)) {
- // update the fragment head when it is part of the blockMap otherwise
- blockMapState.setIn([targetKey, 'nextSibling'], headKey);
- blockMapState.setIn([headKey, 'prevSibling'], targetKey);
- } else {
- // update the target block that had the fragment head contents merged into it
- blockMapState.setIn([targetKey, 'nextSibling'], fragmentHeadBlock.getNextSiblingKey());
- blockMapState.setIn([fragmentHeadBlock.getNextSiblingKey(), 'prevSibling'], targetKey);
- }
-
- // update the last root block fragment
- blockMapState.setIn([lastRootFragmentBlockKey, 'nextSibling'], targetNextKey);
-
- // update the original target next block
- if (targetNextKey) {
- blockMapState.setIn([targetNextKey, 'prevSibling'], lastRootFragmentBlockKey);
- }
-
- // update fragment parent links
- fragmentRootBlocks.forEach(function (blockKey) {
- return blockMapState.setIn([blockKey, 'parent'], targetParentKey);
- });
-
- // update targetBlock parent child links
- if (targetParentKey) {
- var targetParent = blockMap.get(targetParentKey);
- var originalTargetParentChildKeys = targetParent.getChildKeys();
-
- var targetBlockIndex = originalTargetParentChildKeys.indexOf(targetKey);
- var insertionIndex = targetBlockIndex + 1;
-
- var newChildrenKeysArray = originalTargetParentChildKeys.toArray();
-
- // insert fragment children
- newChildrenKeysArray.splice.apply(newChildrenKeysArray, [insertionIndex, 0].concat(fragmentRootBlocks));
-
- blockMapState.setIn([targetParentKey, 'children'], List$2(newChildrenKeysArray));
- }
- });
- };
-
- var insertFragment = function insertFragment(contentState, selectionState, blockMap, fragment, targetKey, targetOffset) {
- var isTreeBasedBlockMap = blockMap.first() instanceof ContentBlockNode_1;
- var newBlockArr = [];
- var fragmentSize = fragment.size;
- var target = blockMap.get(targetKey);
- var head = fragment.first();
- var tail = fragment.last();
- var finalOffset = tail.getLength();
- var finalKey = tail.getKey();
- var shouldNotUpdateFromFragmentBlock = isTreeBasedBlockMap && (!target.getChildKeys().isEmpty() || !head.getChildKeys().isEmpty());
-
- blockMap.forEach(function (block, blockKey) {
- if (blockKey !== targetKey) {
- newBlockArr.push(block);
- return;
- }
-
- if (shouldNotUpdateFromFragmentBlock) {
- newBlockArr.push(block);
- } else {
- newBlockArr.push(updateHead(block, targetOffset, fragment));
- }
-
- // Insert fragment blocks after the head and before the tail.
- fragment
- // when we are updating the target block with the head fragment block we skip the first fragment
- // head since its contents have already been merged with the target block otherwise we include
- // the whole fragment
- .slice(shouldNotUpdateFromFragmentBlock ? 0 : 1, fragmentSize - 1).forEach(function (fragmentBlock) {
- return newBlockArr.push(fragmentBlock);
- });
-
- // update tail
- newBlockArr.push(updateTail(block, targetOffset, fragment));
- });
-
- var updatedBlockMap = BlockMapBuilder_1.createFromArray(newBlockArr);
-
- if (isTreeBasedBlockMap) {
- updatedBlockMap = updateBlockMapLinks(updatedBlockMap, blockMap, target, head);
- }
-
- return contentState.merge({
- blockMap: updatedBlockMap,
- selectionBefore: selectionState,
- selectionAfter: selectionState.merge({
- anchorKey: finalKey,
- anchorOffset: finalOffset,
- focusKey: finalKey,
- focusOffset: finalOffset,
- isBackward: false
- })
- });
- };
-
- var insertFragmentIntoContentState = function insertFragmentIntoContentState(contentState, selectionState, fragmentBlockMap) {
- !selectionState.isCollapsed() ? process.env.NODE_ENV !== 'production' ? invariant_1(false, '`insertFragment` should only be called with a collapsed selection state.') : invariant_1(false) : void 0;
-
- var blockMap = contentState.getBlockMap();
- var fragment = randomizeBlockMapKeys_1(fragmentBlockMap);
- var targetKey = selectionState.getStartKey();
- var targetOffset = selectionState.getStartOffset();
-
- var targetBlock = blockMap.get(targetKey);
-
- if (targetBlock instanceof ContentBlockNode_1) {
- !targetBlock.getChildKeys().isEmpty() ? process.env.NODE_ENV !== 'production' ? invariant_1(false, '`insertFragment` should not be called when a container node is selected.') : invariant_1(false) : void 0;
- }
-
- // When we insert a fragment with a single block we simply update the target block
- // with the contents of the inserted fragment block
- if (fragment.size === 1) {
- return updateExistingBlock(contentState, selectionState, blockMap, fragment.first(), targetKey, targetOffset);
- }
-
- return insertFragment(contentState, selectionState, blockMap, fragment, targetKey, targetOffset);
- };
-
- var insertFragmentIntoContentState_1 = insertFragmentIntoContentState;
-
- var Repeat$2 = immutable.Repeat;
-
-
- function insertTextIntoContentState(contentState, selectionState, text, characterMetadata) {
- !selectionState.isCollapsed() ? process.env.NODE_ENV !== 'production' ? invariant_1(false, '`insertText` should only be called with a collapsed range.') : invariant_1(false) : void 0;
-
- var len = text.length;
- if (!len) {
- return contentState;
- }
-
- var blockMap = contentState.getBlockMap();
- var key = selectionState.getStartKey();
- var offset = selectionState.getStartOffset();
- var block = blockMap.get(key);
- var blockText = block.getText();
-
- var newBlock = block.merge({
- text: blockText.slice(0, offset) + text + blockText.slice(offset, block.getLength()),
- characterList: insertIntoList_1(block.getCharacterList(), Repeat$2(characterMetadata, len).toList(), offset)
- });
-
- var newOffset = offset + len;
-
- return contentState.merge({
- blockMap: blockMap.set(key, newBlock),
- selectionAfter: selectionState.merge({
- anchorOffset: newOffset,
- focusOffset: newOffset
- })
- });
- }
-
- var insertTextIntoContentState_1 = insertTextIntoContentState;
-
- var Map$4 = immutable.Map;
-
-
- function modifyBlockForContentState(contentState, selectionState, operation) {
- var startKey = selectionState.getStartKey();
- var endKey = selectionState.getEndKey();
- var blockMap = contentState.getBlockMap();
- var newBlocks = blockMap.toSeq().skipUntil(function (_, k) {
- return k === startKey;
- }).takeUntil(function (_, k) {
- return k === endKey;
- }).concat(Map$4([[endKey, blockMap.get(endKey)]])).map(operation);
-
- return contentState.merge({
- blockMap: blockMap.merge(newBlocks),
- selectionBefore: selectionState,
- selectionAfter: selectionState
- });
- }
-
- var modifyBlockForContentState_1 = modifyBlockForContentState;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule getNextDelimiterBlockKey
- * @format
- *
- *
- * This is unstable and not part of the public API and should not be used by
- * production systems. This file may be update/removed without notice.
- */
-
-
-
- var getNextDelimiterBlockKey = function getNextDelimiterBlockKey(block, blockMap) {
- var isExperimentalTreeBlock = block instanceof ContentBlockNode_1;
-
- if (!isExperimentalTreeBlock) {
- return null;
- }
-
- var nextSiblingKey = block.getNextSiblingKey();
-
- if (nextSiblingKey) {
- return nextSiblingKey;
- }
-
- var parent = block.getParentKey();
-
- if (!parent) {
- return null;
- }
-
- var nextNonDescendantBlock = blockMap.get(parent);
- while (nextNonDescendantBlock && !nextNonDescendantBlock.getNextSiblingKey()) {
- var parentKey = nextNonDescendantBlock.getParentKey();
- nextNonDescendantBlock = parentKey ? blockMap.get(parentKey) : null;
- }
-
- if (!nextNonDescendantBlock) {
- return null;
- }
-
- return nextNonDescendantBlock.getNextSiblingKey();
- };
-
- var getNextDelimiterBlockKey_1 = getNextDelimiterBlockKey;
-
- var List$3 = immutable.List,
- Map$5 = immutable.Map;
-
-
- var transformBlock = function transformBlock(key, blockMap, func) {
- if (!key) {
- return;
- }
-
- var block = blockMap.get(key);
-
- if (!block) {
- return;
- }
-
- blockMap.set(key, func(block));
- };
-
- /**
- * Ancestors needs to be preserved when there are non selected
- * children to make sure we do not leave any orphans behind
- */
- var getAncestorsKeys = function getAncestorsKeys(blockKey, blockMap) {
- var parents = [];
-
- if (!blockKey) {
- return parents;
- }
-
- var blockNode = blockMap.get(blockKey);
- while (blockNode && blockNode.getParentKey()) {
- var parentKey = blockNode.getParentKey();
- if (parentKey) {
- parents.push(parentKey);
- }
- blockNode = parentKey ? blockMap.get(parentKey) : null;
- }
-
- return parents;
- };
-
- /**
- * Get all next delimiter keys until we hit a root delimiter and return
- * an array of key references
- */
- var getNextDelimitersBlockKeys = function getNextDelimitersBlockKeys(block, blockMap) {
- var nextDelimiters = [];
-
- if (!block) {
- return nextDelimiters;
- }
-
- var nextDelimiter = getNextDelimiterBlockKey_1(block, blockMap);
- while (nextDelimiter && blockMap.get(nextDelimiter)) {
- var _block = blockMap.get(nextDelimiter);
- nextDelimiters.push(nextDelimiter);
-
- // we do not need to keep checking all root node siblings, just the first occurance
- nextDelimiter = _block.getParentKey() ? getNextDelimiterBlockKey_1(_block, blockMap) : null;
- }
-
- return nextDelimiters;
- };
-
- var getNextValidSibling = function getNextValidSibling(block, blockMap, originalBlockMap) {
- if (!block) {
- return null;
- }
-
- // note that we need to make sure we refer to the original block since this
- // function is called within a withMutations
- var nextValidSiblingKey = originalBlockMap.get(block.getKey()).getNextSiblingKey();
-
- while (nextValidSiblingKey && !blockMap.get(nextValidSiblingKey)) {
- nextValidSiblingKey = originalBlockMap.get(nextValidSiblingKey).getNextSiblingKey() || null;
- }
-
- return nextValidSiblingKey;
- };
-
- var getPrevValidSibling = function getPrevValidSibling(block, blockMap, originalBlockMap) {
- if (!block) {
- return null;
- }
-
- // note that we need to make sure we refer to the original block since this
- // function is called within a withMutations
- var prevValidSiblingKey = originalBlockMap.get(block.getKey()).getPrevSiblingKey();
-
- while (prevValidSiblingKey && !blockMap.get(prevValidSiblingKey)) {
- prevValidSiblingKey = originalBlockMap.get(prevValidSiblingKey).getPrevSiblingKey() || null;
- }
-
- return prevValidSiblingKey;
- };
-
- var updateBlockMapLinks$1 = function updateBlockMapLinks(blockMap, startBlock, endBlock, originalBlockMap) {
- return blockMap.withMutations(function (blocks) {
- // update start block if its retained
- transformBlock(startBlock.getKey(), blocks, function (block) {
- return block.merge({
- nextSibling: getNextValidSibling(startBlock, blocks, originalBlockMap),
- prevSibling: getPrevValidSibling(startBlock, blocks, originalBlockMap)
- });
- });
-
- // update endblock if its retained
- transformBlock(endBlock.getKey(), blocks, function (block) {
- return block.merge({
- nextSibling: getNextValidSibling(endBlock, blocks, originalBlockMap),
- prevSibling: getPrevValidSibling(endBlock, blocks, originalBlockMap)
- });
- });
-
- // update start block parent ancestors
- getAncestorsKeys(startBlock.getKey(), originalBlockMap).forEach(function (parentKey) {
- return transformBlock(parentKey, blocks, function (block) {
- return block.merge({
- children: block.getChildKeys().filter(function (key) {
- return blocks.get(key);
- }),
- nextSibling: getNextValidSibling(block, blocks, originalBlockMap),
- prevSibling: getPrevValidSibling(block, blocks, originalBlockMap)
- });
- });
- });
-
- // update start block next - can only happen if startBlock == endBlock
- transformBlock(startBlock.getNextSiblingKey(), blocks, function (block) {
- return block.merge({
- prevSibling: startBlock.getPrevSiblingKey()
- });
- });
-
- // update start block prev
- transformBlock(startBlock.getPrevSiblingKey(), blocks, function (block) {
- return block.merge({
- nextSibling: getNextValidSibling(startBlock, blocks, originalBlockMap)
- });
- });
-
- // update end block next
- transformBlock(endBlock.getNextSiblingKey(), blocks, function (block) {
- return block.merge({
- prevSibling: getPrevValidSibling(endBlock, blocks, originalBlockMap)
- });
- });
-
- // update end block prev
- transformBlock(endBlock.getPrevSiblingKey(), blocks, function (block) {
- return block.merge({
- nextSibling: endBlock.getNextSiblingKey()
- });
- });
-
- // update end block parent ancestors
- getAncestorsKeys(endBlock.getKey(), originalBlockMap).forEach(function (parentKey) {
- transformBlock(parentKey, blocks, function (block) {
- return block.merge({
- children: block.getChildKeys().filter(function (key) {
- return blocks.get(key);
- }),
- nextSibling: getNextValidSibling(block, blocks, originalBlockMap),
- prevSibling: getPrevValidSibling(block, blocks, originalBlockMap)
- });
- });
- });
-
- // update next delimiters all the way to a root delimiter
- getNextDelimitersBlockKeys(endBlock, originalBlockMap).forEach(function (delimiterKey) {
- return transformBlock(delimiterKey, blocks, function (block) {
- return block.merge({
- nextSibling: getNextValidSibling(block, blocks, originalBlockMap),
- prevSibling: getPrevValidSibling(block, blocks, originalBlockMap)
- });
- });
- });
- });
- };
-
- var removeRangeFromContentState = function removeRangeFromContentState(contentState, selectionState) {
- if (selectionState.isCollapsed()) {
- return contentState;
- }
-
- var blockMap = contentState.getBlockMap();
- var startKey = selectionState.getStartKey();
- var startOffset = selectionState.getStartOffset();
- var endKey = selectionState.getEndKey();
- var endOffset = selectionState.getEndOffset();
-
- var startBlock = blockMap.get(startKey);
- var endBlock = blockMap.get(endKey);
-
- // we assume that ContentBlockNode and ContentBlocks are not mixed together
- var isExperimentalTreeBlock = startBlock instanceof ContentBlockNode_1;
-
- // used to retain blocks that should not be deleted to avoid orphan children
- var parentAncestors = [];
-
- if (isExperimentalTreeBlock) {
- var endBlockchildrenKeys = endBlock.getChildKeys();
- var endBlockAncestors = getAncestorsKeys(endKey, blockMap);
-
- // endBlock has unselected sibblings so we can not remove its ancestors parents
- if (endBlock.getNextSiblingKey()) {
- parentAncestors = parentAncestors.concat(endBlockAncestors);
- }
-
- // endBlock has children so can not remove this block or any of its ancestors
- if (!endBlockchildrenKeys.isEmpty()) {
- parentAncestors = parentAncestors.concat(endBlockAncestors.concat([endKey]));
- }
-
- // we need to retain all ancestors of the next delimiter block
- parentAncestors = parentAncestors.concat(getAncestorsKeys(getNextDelimiterBlockKey_1(endBlock, blockMap), blockMap));
- }
-
- var characterList = void 0;
-
- if (startBlock === endBlock) {
- characterList = removeFromList(startBlock.getCharacterList(), startOffset, endOffset);
- } else {
- characterList = startBlock.getCharacterList().slice(0, startOffset).concat(endBlock.getCharacterList().slice(endOffset));
- }
-
- var modifiedStart = startBlock.merge({
- text: startBlock.getText().slice(0, startOffset) + endBlock.getText().slice(endOffset),
- characterList: characterList
- });
-
- var newBlocks = blockMap.toSeq().skipUntil(function (_, k) {
- return k === startKey;
- }).takeUntil(function (_, k) {
- return k === endKey;
- }).filter(function (_, k) {
- return parentAncestors.indexOf(k) === -1;
- }).concat(Map$5([[endKey, null]])).map(function (_, k) {
- return k === startKey ? modifiedStart : null;
- });
-
- var updatedBlockMap = blockMap.merge(newBlocks).filter(function (block) {
- return !!block;
- });
-
- if (isExperimentalTreeBlock) {
- updatedBlockMap = updateBlockMapLinks$1(updatedBlockMap, startBlock, endBlock, blockMap);
- }
-
- return contentState.merge({
- blockMap: updatedBlockMap,
- selectionBefore: selectionState,
- selectionAfter: selectionState.merge({
- anchorKey: startKey,
- anchorOffset: startOffset,
- focusKey: startKey,
- focusOffset: startOffset,
- isBackward: false
- })
- });
- };
-
- /**
- * Maintain persistence for target list when removing characters on the
- * head and tail of the character list.
- */
- var removeFromList = function removeFromList(targetList, startOffset, endOffset) {
- if (startOffset === 0) {
- while (startOffset < endOffset) {
- targetList = targetList.shift();
- startOffset++;
- }
- } else if (endOffset === targetList.count()) {
- while (endOffset > startOffset) {
- targetList = targetList.pop();
- endOffset--;
- }
- } else {
- var head = targetList.slice(0, startOffset);
- var tail = targetList.slice(endOffset);
- targetList = head.concat(tail).toList();
- }
- return targetList;
- };
-
- var removeRangeFromContentState_1 = removeRangeFromContentState;
-
- var List$4 = immutable.List,
- Map$6 = immutable.Map;
-
-
- var transformBlock$1 = function transformBlock(key, blockMap, func) {
- if (!key) {
- return;
- }
-
- var block = blockMap.get(key);
-
- if (!block) {
- return;
- }
-
- blockMap.set(key, func(block));
- };
-
- var updateBlockMapLinks$2 = function updateBlockMapLinks(blockMap, originalBlock, belowBlock) {
- return blockMap.withMutations(function (blocks) {
- var originalBlockKey = originalBlock.getKey();
- var belowBlockKey = belowBlock.getKey();
-
- // update block parent
- transformBlock$1(originalBlock.getParentKey(), blocks, function (block) {
- var parentChildrenList = block.getChildKeys();
- var insertionIndex = parentChildrenList.indexOf(originalBlockKey) + 1;
- var newChildrenArray = parentChildrenList.toArray();
-
- newChildrenArray.splice(insertionIndex, 0, belowBlockKey);
-
- return block.merge({
- children: List$4(newChildrenArray)
- });
- });
-
- // update original next block
- transformBlock$1(originalBlock.getNextSiblingKey(), blocks, function (block) {
- return block.merge({
- prevSibling: belowBlockKey
- });
- });
-
- // update original block
- transformBlock$1(originalBlockKey, blocks, function (block) {
- return block.merge({
- nextSibling: belowBlockKey
- });
- });
-
- // update below block
- transformBlock$1(belowBlockKey, blocks, function (block) {
- return block.merge({
- prevSibling: originalBlockKey
- });
- });
- });
- };
-
- var splitBlockInContentState = function splitBlockInContentState(contentState, selectionState) {
- !selectionState.isCollapsed() ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Selection range must be collapsed.') : invariant_1(false) : void 0;
-
- var key = selectionState.getAnchorKey();
- var offset = selectionState.getAnchorOffset();
- var blockMap = contentState.getBlockMap();
- var blockToSplit = blockMap.get(key);
- var text = blockToSplit.getText();
- var chars = blockToSplit.getCharacterList();
- var keyBelow = generateRandomKey_1();
- var isExperimentalTreeBlock = blockToSplit instanceof ContentBlockNode_1;
-
- var blockAbove = blockToSplit.merge({
- text: text.slice(0, offset),
- characterList: chars.slice(0, offset)
- });
- var blockBelow = blockAbove.merge({
- key: keyBelow,
- text: text.slice(offset),
- characterList: chars.slice(offset),
- data: Map$6()
- });
-
- var blocksBefore = blockMap.toSeq().takeUntil(function (v) {
- return v === blockToSplit;
- });
- var blocksAfter = blockMap.toSeq().skipUntil(function (v) {
- return v === blockToSplit;
- }).rest();
- var newBlocks = blocksBefore.concat([[key, blockAbove], [keyBelow, blockBelow]], blocksAfter).toOrderedMap();
-
- if (isExperimentalTreeBlock) {
- !blockToSplit.getChildKeys().isEmpty() ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'ContentBlockNode must not have children') : invariant_1(false) : void 0;
-
- newBlocks = updateBlockMapLinks$2(newBlocks, blockAbove, blockBelow);
- }
-
- return contentState.merge({
- blockMap: newBlocks,
- selectionBefore: selectionState,
- selectionAfter: selectionState.merge({
- anchorKey: keyBelow,
- anchorOffset: 0,
- focusKey: keyBelow,
- focusOffset: 0,
- isBackward: false
- })
- });
- };
-
- var splitBlockInContentState_1 = splitBlockInContentState;
-
- var OrderedSet$3 = immutable.OrderedSet;
-
- /**
- * `DraftModifier` provides a set of convenience methods that apply
- * modifications to a `ContentState` object based on a target `SelectionState`.
- *
- * Any change to a `ContentState` should be decomposable into a series of
- * transaction functions that apply the required changes and return output
- * `ContentState` objects.
- *
- * These functions encapsulate some of the most common transaction sequences.
- */
-
- var DraftModifier = {
- replaceText: function replaceText(contentState, rangeToReplace, text, inlineStyle, entityKey) {
- var withoutEntities = removeEntitiesAtEdges_1(contentState, rangeToReplace);
- var withoutText = removeRangeFromContentState_1(withoutEntities, rangeToReplace);
-
- var character = CharacterMetadata_1.create({
- style: inlineStyle || OrderedSet$3(),
- entity: entityKey || null
- });
-
- return insertTextIntoContentState_1(withoutText, withoutText.getSelectionAfter(), text, character);
- },
-
- insertText: function insertText(contentState, targetRange, text, inlineStyle, entityKey) {
- !targetRange.isCollapsed() ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Target range must be collapsed for `insertText`.') : invariant_1(false) : void 0;
- return DraftModifier.replaceText(contentState, targetRange, text, inlineStyle, entityKey);
- },
-
- moveText: function moveText(contentState, removalRange, targetRange) {
- var movedFragment = getContentStateFragment_1(contentState, removalRange);
-
- var afterRemoval = DraftModifier.removeRange(contentState, removalRange, 'backward');
-
- return DraftModifier.replaceWithFragment(afterRemoval, targetRange, movedFragment);
- },
-
- replaceWithFragment: function replaceWithFragment(contentState, targetRange, fragment) {
- var withoutEntities = removeEntitiesAtEdges_1(contentState, targetRange);
- var withoutText = removeRangeFromContentState_1(withoutEntities, targetRange);
-
- return insertFragmentIntoContentState_1(withoutText, withoutText.getSelectionAfter(), fragment);
- },
-
- removeRange: function removeRange(contentState, rangeToRemove, removalDirection) {
- var startKey = void 0,
- endKey = void 0,
- startBlock = void 0,
- endBlock = void 0;
- if (rangeToRemove.getIsBackward()) {
- rangeToRemove = rangeToRemove.merge({
- anchorKey: rangeToRemove.getFocusKey(),
- anchorOffset: rangeToRemove.getFocusOffset(),
- focusKey: rangeToRemove.getAnchorKey(),
- focusOffset: rangeToRemove.getAnchorOffset(),
- isBackward: false
- });
- }
- startKey = rangeToRemove.getAnchorKey();
- endKey = rangeToRemove.getFocusKey();
- startBlock = contentState.getBlockForKey(startKey);
- endBlock = contentState.getBlockForKey(endKey);
- var startOffset = rangeToRemove.getStartOffset();
- var endOffset = rangeToRemove.getEndOffset();
-
- var startEntityKey = startBlock.getEntityAt(startOffset);
- var endEntityKey = endBlock.getEntityAt(endOffset - 1);
-
- // Check whether the selection state overlaps with a single entity.
- // If so, try to remove the appropriate substring of the entity text.
- if (startKey === endKey) {
- if (startEntityKey && startEntityKey === endEntityKey) {
- var _adjustedRemovalRange = getCharacterRemovalRange_1(contentState.getEntityMap(), startBlock, endBlock, rangeToRemove, removalDirection);
- return removeRangeFromContentState_1(contentState, _adjustedRemovalRange);
- }
- }
- var adjustedRemovalRange = rangeToRemove;
-
- var withoutEntities = removeEntitiesAtEdges_1(contentState, adjustedRemovalRange);
- return removeRangeFromContentState_1(withoutEntities, adjustedRemovalRange);
- },
-
- splitBlock: function splitBlock(contentState, selectionState) {
- var withoutEntities = removeEntitiesAtEdges_1(contentState, selectionState);
- var withoutText = removeRangeFromContentState_1(withoutEntities, selectionState);
-
- return splitBlockInContentState_1(withoutText, withoutText.getSelectionAfter());
- },
-
- applyInlineStyle: function applyInlineStyle(contentState, selectionState, inlineStyle) {
- return ContentStateInlineStyle_1.add(contentState, selectionState, inlineStyle);
- },
-
- removeInlineStyle: function removeInlineStyle(contentState, selectionState, inlineStyle) {
- return ContentStateInlineStyle_1.remove(contentState, selectionState, inlineStyle);
- },
-
- setBlockType: function setBlockType(contentState, selectionState, blockType) {
- return modifyBlockForContentState_1(contentState, selectionState, function (block) {
- return block.merge({ type: blockType, depth: 0 });
- });
- },
-
- setBlockData: function setBlockData(contentState, selectionState, blockData) {
- return modifyBlockForContentState_1(contentState, selectionState, function (block) {
- return block.merge({ data: blockData });
- });
- },
-
- mergeBlockData: function mergeBlockData(contentState, selectionState, blockData) {
- return modifyBlockForContentState_1(contentState, selectionState, function (block) {
- return block.merge({ data: block.getData().merge(blockData) });
- });
- },
-
- applyEntity: function applyEntity(contentState, selectionState, entityKey) {
- var withoutEntities = removeEntitiesAtEdges_1(contentState, selectionState);
- return applyEntityToContentState_1(withoutEntities, selectionState, entityKey);
- }
- };
-
- var DraftModifier_1 = DraftModifier;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- *
- */
-
- function makeEmptyFunction(arg) {
- return function () {
- return arg;
- };
- }
-
- /**
- * This function accepts and discards inputs; it has no side effects. This is
- * primarily useful idiomatically for overridable function endpoints which
- * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
- */
- var emptyFunction = function emptyFunction() {};
-
- emptyFunction.thatReturns = makeEmptyFunction;
- emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
- emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
- emptyFunction.thatReturnsNull = makeEmptyFunction(null);
- emptyFunction.thatReturnsThis = function () {
- return this;
- };
- emptyFunction.thatReturnsArgument = function (arg) {
- return arg;
- };
-
- var emptyFunction_1 = emptyFunction;
-
- var List$5 = immutable.List,
- Repeat$3 = immutable.Repeat,
- Record$3 = immutable.Record;
-
-
- var returnTrue = emptyFunction_1.thatReturnsTrue;
-
- var FINGERPRINT_DELIMITER = '-';
-
- var defaultLeafRange = {
- start: null,
- end: null
- };
-
- var LeafRange = Record$3(defaultLeafRange);
-
- var defaultDecoratorRange = {
- start: null,
- end: null,
- decoratorKey: null,
- leaves: null
- };
-
- var DecoratorRange = Record$3(defaultDecoratorRange);
-
- var BlockTree = {
- /**
- * Generate a block tree for a given ContentBlock/decorator pair.
- */
- generate: function generate(contentState, block, decorator) {
- var textLength = block.getLength();
- if (!textLength) {
- return List$5.of(new DecoratorRange({
- start: 0,
- end: 0,
- decoratorKey: null,
- leaves: List$5.of(new LeafRange({ start: 0, end: 0 }))
- }));
- }
-
- var leafSets = [];
- var decorations = decorator ? decorator.getDecorations(block, contentState) : List$5(Repeat$3(null, textLength));
-
- var chars = block.getCharacterList();
-
- findRangesImmutable_1(decorations, areEqual, returnTrue, function (start, end) {
- leafSets.push(new DecoratorRange({
- start: start,
- end: end,
- decoratorKey: decorations.get(start),
- leaves: generateLeaves(chars.slice(start, end).toList(), start)
- }));
- });
-
- return List$5(leafSets);
- },
-
- /**
- * Create a string representation of the given tree map. This allows us
- * to rapidly determine whether a tree has undergone a significant
- * structural change.
- */
- getFingerprint: function getFingerprint(tree) {
- return tree.map(function (leafSet) {
- var decoratorKey = leafSet.get('decoratorKey');
- var fingerprintString = decoratorKey !== null ? decoratorKey + '.' + (leafSet.get('end') - leafSet.get('start')) : '';
- return '' + fingerprintString + '.' + leafSet.get('leaves').size;
- }).join(FINGERPRINT_DELIMITER);
- }
- };
-
- /**
- * Generate LeafRange records for a given character list.
- */
- function generateLeaves(characters, offset) {
- var leaves = [];
- var inlineStyles = characters.map(function (c) {
- return c.getStyle();
- }).toList();
- findRangesImmutable_1(inlineStyles, areEqual, returnTrue, function (start, end) {
- leaves.push(new LeafRange({
- start: start + offset,
- end: end + offset
- }));
- });
- return List$5(leaves);
- }
-
- function areEqual(a, b) {
- return a === b;
- }
-
- var BlockTree_1 = BlockTree;
-
- function _classCallCheck$3(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- function _possibleConstructorReturn$3(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
- function _inherits$3(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-
-
- var Record$4 = immutable.Record;
-
-
- var DraftEntityInstanceRecord = Record$4({
- type: 'TOKEN',
- mutability: 'IMMUTABLE',
- data: Object
- });
-
- /**
- * An instance of a document entity, consisting of a `type` and relevant
- * `data`, metadata about the entity.
- *
- * For instance, a "link" entity might provide a URI, and a "mention"
- * entity might provide the mentioned user's ID. These pieces of data
- * may be used when rendering the entity as part of a ContentBlock DOM
- * representation. For a link, the data would be used as an href for
- * the rendered anchor. For a mention, the ID could be used to retrieve
- * a hovercard.
- */
-
- var DraftEntityInstance = function (_DraftEntityInstanceR) {
- _inherits$3(DraftEntityInstance, _DraftEntityInstanceR);
-
- function DraftEntityInstance() {
- _classCallCheck$3(this, DraftEntityInstance);
-
- return _possibleConstructorReturn$3(this, _DraftEntityInstanceR.apply(this, arguments));
- }
-
- DraftEntityInstance.prototype.getType = function getType() {
- return this.get('type');
- };
-
- DraftEntityInstance.prototype.getMutability = function getMutability() {
- return this.get('mutability');
- };
-
- DraftEntityInstance.prototype.getData = function getData() {
- return this.get('data');
- };
-
- return DraftEntityInstance;
- }(DraftEntityInstanceRecord);
-
- var DraftEntityInstance_1 = DraftEntityInstance;
-
- var _extends = objectAssign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule DraftEntity
- * @format
- *
- */
-
-
-
-
-
-
- var Map$7 = immutable.Map;
-
-
- var instances = Map$7();
- var instanceKey = 0;
-
- /**
- * Temporary utility for generating the warnings
- */
- function logWarning(oldMethodCall, newMethodCall) {
- console.warn('WARNING: ' + oldMethodCall + ' will be deprecated soon!\nPlease use "' + newMethodCall + '" instead.');
- }
-
- /**
- * A "document entity" is an object containing metadata associated with a
- * piece of text in a ContentBlock.
- *
- * For example, a `link` entity might include a `uri` property. When a
- * ContentBlock is rendered in the browser, text that refers to that link
- * entity may be rendered as an anchor, with the `uri` as the href value.
- *
- * In a ContentBlock, every position in the text may correspond to zero
- * or one entities. This correspondence is tracked using a key string,
- * generated via DraftEntity.create() and used to obtain entity metadata
- * via DraftEntity.get().
- */
- var DraftEntity = {
- /**
- * WARNING: This method will be deprecated soon!
- * Please use 'contentState.getLastCreatedEntityKey' instead.
- * ---
- * Get the random key string from whatever entity was last created.
- * We need this to support the new API, as part of transitioning to put Entity
- * storage in contentState.
- */
- getLastCreatedEntityKey: function getLastCreatedEntityKey() {
- logWarning('DraftEntity.getLastCreatedEntityKey', 'contentState.getLastCreatedEntityKey');
- return DraftEntity.__getLastCreatedEntityKey();
- },
-
- /**
- * WARNING: This method will be deprecated soon!
- * Please use 'contentState.createEntity' instead.
- * ---
- * Create a DraftEntityInstance and store it for later retrieval.
- *
- * A random key string will be generated and returned. This key may
- * be used to track the entity's usage in a ContentBlock, and for
- * retrieving data about the entity at render time.
- */
- create: function create(type, mutability, data) {
- logWarning('DraftEntity.create', 'contentState.createEntity');
- return DraftEntity.__create(type, mutability, data);
- },
-
- /**
- * WARNING: This method will be deprecated soon!
- * Please use 'contentState.addEntity' instead.
- * ---
- * Add an existing DraftEntityInstance to the DraftEntity map. This is
- * useful when restoring instances from the server.
- */
- add: function add(instance) {
- logWarning('DraftEntity.add', 'contentState.addEntity');
- return DraftEntity.__add(instance);
- },
-
- /**
- * WARNING: This method will be deprecated soon!
- * Please use 'contentState.getEntity' instead.
- * ---
- * Retrieve the entity corresponding to the supplied key string.
- */
- get: function get(key) {
- logWarning('DraftEntity.get', 'contentState.getEntity');
- return DraftEntity.__get(key);
- },
-
- /**
- * WARNING: This method will be deprecated soon!
- * Please use 'contentState.mergeEntityData' instead.
- * ---
- * Entity instances are immutable. If you need to update the data for an
- * instance, this method will merge your data updates and return a new
- * instance.
- */
- mergeData: function mergeData(key, toMerge) {
- logWarning('DraftEntity.mergeData', 'contentState.mergeEntityData');
- return DraftEntity.__mergeData(key, toMerge);
- },
-
- /**
- * WARNING: This method will be deprecated soon!
- * Please use 'contentState.replaceEntityData' instead.
- * ---
- * Completely replace the data for a given instance.
- */
- replaceData: function replaceData(key, newData) {
- logWarning('DraftEntity.replaceData', 'contentState.replaceEntityData');
- return DraftEntity.__replaceData(key, newData);
- },
-
- // ***********************************WARNING******************************
- // --- the above public API will be deprecated in the next version of Draft!
- // The methods below this line are private - don't call them directly.
-
- /**
- * Get the random key string from whatever entity was last created.
- * We need this to support the new API, as part of transitioning to put Entity
- * storage in contentState.
- */
- __getLastCreatedEntityKey: function __getLastCreatedEntityKey() {
- return '' + instanceKey;
- },
-
- /**
- * Create a DraftEntityInstance and store it for later retrieval.
- *
- * A random key string will be generated and returned. This key may
- * be used to track the entity's usage in a ContentBlock, and for
- * retrieving data about the entity at render time.
- */
- __create: function __create(type, mutability, data) {
- return DraftEntity.__add(new DraftEntityInstance_1({ type: type, mutability: mutability, data: data || {} }));
- },
-
- /**
- * Add an existing DraftEntityInstance to the DraftEntity map. This is
- * useful when restoring instances from the server.
- */
- __add: function __add(instance) {
- var key = '' + ++instanceKey;
- instances = instances.set(key, instance);
- return key;
- },
-
- /**
- * Retrieve the entity corresponding to the supplied key string.
- */
- __get: function __get(key) {
- var instance = instances.get(key);
- !!!instance ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Unknown DraftEntity key: %s.', key) : invariant_1(false) : void 0;
- return instance;
- },
-
- /**
- * Entity instances are immutable. If you need to update the data for an
- * instance, this method will merge your data updates and return a new
- * instance.
- */
- __mergeData: function __mergeData(key, toMerge) {
- var instance = DraftEntity.__get(key);
- var newData = _extends({}, instance.getData(), toMerge);
- var newInstance = instance.set('data', newData);
- instances = instances.set(key, newInstance);
- return newInstance;
- },
-
- /**
- * Completely replace the data for a given instance.
- */
- __replaceData: function __replaceData(key, newData) {
- var instance = DraftEntity.__get(key);
- var newInstance = instance.set('data', newData);
- instances = instances.set(key, newInstance);
- return newInstance;
- }
- };
-
- var DraftEntity_1 = DraftEntity;
-
- function _classCallCheck$4(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- function _possibleConstructorReturn$4(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
- function _inherits$4(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-
-
- var Record$5 = immutable.Record;
-
-
- var defaultRecord$3 = {
- anchorKey: '',
- anchorOffset: 0,
- focusKey: '',
- focusOffset: 0,
- isBackward: false,
- hasFocus: false
- };
-
- var SelectionStateRecord = Record$5(defaultRecord$3);
-
- var SelectionState = function (_SelectionStateRecord) {
- _inherits$4(SelectionState, _SelectionStateRecord);
-
- function SelectionState() {
- _classCallCheck$4(this, SelectionState);
-
- return _possibleConstructorReturn$4(this, _SelectionStateRecord.apply(this, arguments));
- }
-
- SelectionState.prototype.serialize = function serialize() {
- return 'Anchor: ' + this.getAnchorKey() + ':' + this.getAnchorOffset() + ', ' + 'Focus: ' + this.getFocusKey() + ':' + this.getFocusOffset() + ', ' + 'Is Backward: ' + String(this.getIsBackward()) + ', ' + 'Has Focus: ' + String(this.getHasFocus());
- };
-
- SelectionState.prototype.getAnchorKey = function getAnchorKey() {
- return this.get('anchorKey');
- };
-
- SelectionState.prototype.getAnchorOffset = function getAnchorOffset() {
- return this.get('anchorOffset');
- };
-
- SelectionState.prototype.getFocusKey = function getFocusKey() {
- return this.get('focusKey');
- };
-
- SelectionState.prototype.getFocusOffset = function getFocusOffset() {
- return this.get('focusOffset');
- };
-
- SelectionState.prototype.getIsBackward = function getIsBackward() {
- return this.get('isBackward');
- };
-
- SelectionState.prototype.getHasFocus = function getHasFocus() {
- return this.get('hasFocus');
- };
-
- /**
- * Return whether the specified range overlaps with an edge of the
- * SelectionState.
- */
-
-
- SelectionState.prototype.hasEdgeWithin = function hasEdgeWithin(blockKey, start, end) {
- var anchorKey = this.getAnchorKey();
- var focusKey = this.getFocusKey();
-
- if (anchorKey === focusKey && anchorKey === blockKey) {
- var selectionStart = this.getStartOffset();
- var selectionEnd = this.getEndOffset();
- return start <= selectionEnd && selectionStart <= end;
- }
-
- if (blockKey !== anchorKey && blockKey !== focusKey) {
- return false;
- }
-
- var offsetToCheck = blockKey === anchorKey ? this.getAnchorOffset() : this.getFocusOffset();
-
- return start <= offsetToCheck && end >= offsetToCheck;
- };
-
- SelectionState.prototype.isCollapsed = function isCollapsed() {
- return this.getAnchorKey() === this.getFocusKey() && this.getAnchorOffset() === this.getFocusOffset();
- };
-
- SelectionState.prototype.getStartKey = function getStartKey() {
- return this.getIsBackward() ? this.getFocusKey() : this.getAnchorKey();
- };
-
- SelectionState.prototype.getStartOffset = function getStartOffset() {
- return this.getIsBackward() ? this.getFocusOffset() : this.getAnchorOffset();
- };
-
- SelectionState.prototype.getEndKey = function getEndKey() {
- return this.getIsBackward() ? this.getAnchorKey() : this.getFocusKey();
- };
-
- SelectionState.prototype.getEndOffset = function getEndOffset() {
- return this.getIsBackward() ? this.getAnchorOffset() : this.getFocusOffset();
- };
-
- SelectionState.createEmpty = function createEmpty(key) {
- return new SelectionState({
- anchorKey: key,
- anchorOffset: 0,
- focusKey: key,
- focusOffset: 0,
- isBackward: false,
- hasFocus: false
- });
- };
-
- return SelectionState;
- }(SelectionStateRecord);
-
- var SelectionState_1 = SelectionState;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule sanitizeDraftText
- * @format
- *
- */
-
- var REGEX_BLOCK_DELIMITER = new RegExp('\r', 'g');
-
- function sanitizeDraftText(input) {
- return input.replace(REGEX_BLOCK_DELIMITER, '');
- }
-
- var sanitizeDraftText_1 = sanitizeDraftText;
-
- function _classCallCheck$5(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- function _possibleConstructorReturn$5(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
- function _inherits$5(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-
-
-
-
-
-
-
-
-
-
-
-
- var List$6 = immutable.List,
- Record$6 = immutable.Record,
- Repeat$4 = immutable.Repeat;
-
- var defaultRecord$4 = {
- entityMap: null,
- blockMap: null,
- selectionBefore: null,
- selectionAfter: null
- };
-
- var ContentBlockNodeRecord = ContentBlock_1;
-
- var ContentStateRecord = Record$6(defaultRecord$4);
-
- var ContentState = function (_ContentStateRecord) {
- _inherits$5(ContentState, _ContentStateRecord);
-
- function ContentState() {
- _classCallCheck$5(this, ContentState);
-
- return _possibleConstructorReturn$5(this, _ContentStateRecord.apply(this, arguments));
- }
-
- ContentState.prototype.getEntityMap = function getEntityMap() {
- // TODO: update this when we fully remove DraftEntity
- return DraftEntity_1;
- };
-
- ContentState.prototype.getBlockMap = function getBlockMap() {
- return this.get('blockMap');
- };
-
- ContentState.prototype.getSelectionBefore = function getSelectionBefore() {
- return this.get('selectionBefore');
- };
-
- ContentState.prototype.getSelectionAfter = function getSelectionAfter() {
- return this.get('selectionAfter');
- };
-
- ContentState.prototype.getBlockForKey = function getBlockForKey(key) {
- var block = this.getBlockMap().get(key);
- return block;
- };
-
- ContentState.prototype.getKeyBefore = function getKeyBefore(key) {
- return this.getBlockMap().reverse().keySeq().skipUntil(function (v) {
- return v === key;
- }).skip(1).first();
- };
-
- ContentState.prototype.getKeyAfter = function getKeyAfter(key) {
- return this.getBlockMap().keySeq().skipUntil(function (v) {
- return v === key;
- }).skip(1).first();
- };
-
- ContentState.prototype.getBlockAfter = function getBlockAfter(key) {
- return this.getBlockMap().skipUntil(function (_, k) {
- return k === key;
- }).skip(1).first();
- };
-
- ContentState.prototype.getBlockBefore = function getBlockBefore(key) {
- return this.getBlockMap().reverse().skipUntil(function (_, k) {
- return k === key;
- }).skip(1).first();
- };
-
- ContentState.prototype.getBlocksAsArray = function getBlocksAsArray() {
- return this.getBlockMap().toArray();
- };
-
- ContentState.prototype.getFirstBlock = function getFirstBlock() {
- return this.getBlockMap().first();
- };
-
- ContentState.prototype.getLastBlock = function getLastBlock() {
- return this.getBlockMap().last();
- };
-
- ContentState.prototype.getPlainText = function getPlainText(delimiter) {
- return this.getBlockMap().map(function (block) {
- return block ? block.getText() : '';
- }).join(delimiter || '\n');
- };
-
- ContentState.prototype.getLastCreatedEntityKey = function getLastCreatedEntityKey() {
- // TODO: update this when we fully remove DraftEntity
- return DraftEntity_1.__getLastCreatedEntityKey();
- };
-
- ContentState.prototype.hasText = function hasText() {
- var blockMap = this.getBlockMap();
- return blockMap.size > 1 || blockMap.first().getLength() > 0;
- };
-
- ContentState.prototype.createEntity = function createEntity(type, mutability, data) {
- // TODO: update this when we fully remove DraftEntity
- DraftEntity_1.__create(type, mutability, data);
- return this;
- };
-
- ContentState.prototype.mergeEntityData = function mergeEntityData(key, toMerge) {
- // TODO: update this when we fully remove DraftEntity
- DraftEntity_1.__mergeData(key, toMerge);
- return this;
- };
-
- ContentState.prototype.replaceEntityData = function replaceEntityData(key, newData) {
- // TODO: update this when we fully remove DraftEntity
- DraftEntity_1.__replaceData(key, newData);
- return this;
- };
-
- ContentState.prototype.addEntity = function addEntity(instance) {
- // TODO: update this when we fully remove DraftEntity
- DraftEntity_1.__add(instance);
- return this;
- };
-
- ContentState.prototype.getEntity = function getEntity(key) {
- // TODO: update this when we fully remove DraftEntity
- return DraftEntity_1.__get(key);
- };
-
- ContentState.createFromBlockArray = function createFromBlockArray(
- // TODO: update flow type when we completely deprecate the old entity API
- blocks, entityMap) {
- // TODO: remove this when we completely deprecate the old entity API
- var theBlocks = Array.isArray(blocks) ? blocks : blocks.contentBlocks;
- var blockMap = BlockMapBuilder_1.createFromArray(theBlocks);
- var selectionState = blockMap.isEmpty() ? new SelectionState_1() : SelectionState_1.createEmpty(blockMap.first().getKey());
- return new ContentState({
- blockMap: blockMap,
- entityMap: entityMap || DraftEntity_1,
- selectionBefore: selectionState,
- selectionAfter: selectionState
- });
- };
-
- ContentState.createFromText = function createFromText(text) {
- var delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : /\r\n?|\n/g;
-
- var strings = text.split(delimiter);
- var blocks = strings.map(function (block) {
- block = sanitizeDraftText_1(block);
- return new ContentBlockNodeRecord({
- key: generateRandomKey_1(),
- text: block,
- type: 'unstyled',
- characterList: List$6(Repeat$4(CharacterMetadata_1.EMPTY, block.length))
- });
- });
- return ContentState.createFromBlockArray(blocks);
- };
-
- return ContentState;
- }(ContentStateRecord);
-
- var ContentState_1 = ContentState;
-
- var NEUTRAL = 'NEUTRAL'; // No strong direction
- var LTR = 'LTR'; // Left-to-Right direction
- var RTL = 'RTL'; // Right-to-Left direction
-
- var globalDir = null;
-
- // == Helpers ==
-
- /**
- * Check if a directionality value is a Strong one
- */
- function isStrong(dir) {
- return dir === LTR || dir === RTL;
- }
-
- /**
- * Get string value to be used for `dir` HTML attribute or `direction` CSS
- * property.
- */
- function getHTMLDir(dir) {
- !isStrong(dir) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, '`dir` must be a strong direction to be converted to HTML Direction') : invariant_1(false) : void 0;
- return dir === LTR ? 'ltr' : 'rtl';
- }
-
- /**
- * Get string value to be used for `dir` HTML attribute or `direction` CSS
- * property, but returns null if `dir` has same value as `otherDir`.
- * `null`.
- */
- function getHTMLDirIfDifferent(dir, otherDir) {
- !isStrong(dir) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, '`dir` must be a strong direction to be converted to HTML Direction') : invariant_1(false) : void 0;
- !isStrong(otherDir) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, '`otherDir` must be a strong direction to be converted to HTML Direction') : invariant_1(false) : void 0;
- return dir === otherDir ? null : getHTMLDir(dir);
- }
-
- // == Global Direction ==
-
- /**
- * Set the global direction.
- */
- function setGlobalDir(dir) {
- globalDir = dir;
- }
-
- /**
- * Initialize the global direction
- */
- function initGlobalDir() {
- setGlobalDir(LTR);
- }
-
- /**
- * Get the global direction
- */
- function getGlobalDir() {
- if (!globalDir) {
- this.initGlobalDir();
- }
- !globalDir ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Global direction not set.') : invariant_1(false) : void 0;
- return globalDir;
- }
-
- var UnicodeBidiDirection = {
- // Values
- NEUTRAL: NEUTRAL,
- LTR: LTR,
- RTL: RTL,
- // Helpers
- isStrong: isStrong,
- getHTMLDir: getHTMLDir,
- getHTMLDirIfDifferent: getHTMLDirIfDifferent,
- // Global Direction
- setGlobalDir: setGlobalDir,
- initGlobalDir: initGlobalDir,
- getGlobalDir: getGlobalDir
- };
-
- var UnicodeBidiDirection_1 = UnicodeBidiDirection;
-
- /**
- * RegExp ranges of characters with a *Strong* Bidi_Class value.
- *
- * Data is based on DerivedBidiClass.txt in UCD version 7.0.0.
- *
- * NOTE: For performance reasons, we only support Unicode's
- * Basic Multilingual Plane (BMP) for now.
- */
- var RANGE_BY_BIDI_TYPE = {
-
- L: 'A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u01BA\u01BB' + '\u01BC-\u01BF\u01C0-\u01C3\u01C4-\u0293\u0294\u0295-\u02AF\u02B0-\u02B8' + '\u02BB-\u02C1\u02D0-\u02D1\u02E0-\u02E4\u02EE\u0370-\u0373\u0376-\u0377' + '\u037A\u037B-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1' + '\u03A3-\u03F5\u03F7-\u0481\u0482\u048A-\u052F\u0531-\u0556\u0559' + '\u055A-\u055F\u0561-\u0587\u0589\u0903\u0904-\u0939\u093B\u093D' + '\u093E-\u0940\u0949-\u094C\u094E-\u094F\u0950\u0958-\u0961\u0964-\u0965' + '\u0966-\u096F\u0970\u0971\u0972-\u0980\u0982-\u0983\u0985-\u098C' + '\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD' + '\u09BE-\u09C0\u09C7-\u09C8\u09CB-\u09CC\u09CE\u09D7\u09DC-\u09DD' + '\u09DF-\u09E1\u09E6-\u09EF\u09F0-\u09F1\u09F4-\u09F9\u09FA\u0A03' + '\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33' + '\u0A35-\u0A36\u0A38-\u0A39\u0A3E-\u0A40\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F' + '\u0A72-\u0A74\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0' + '\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0ABE-\u0AC0\u0AC9\u0ACB-\u0ACC\u0AD0' + '\u0AE0-\u0AE1\u0AE6-\u0AEF\u0AF0\u0B02-\u0B03\u0B05-\u0B0C\u0B0F-\u0B10' + '\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B35-\u0B39\u0B3D\u0B3E\u0B40' + '\u0B47-\u0B48\u0B4B-\u0B4C\u0B57\u0B5C-\u0B5D\u0B5F-\u0B61\u0B66-\u0B6F' + '\u0B70\u0B71\u0B72-\u0B77\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95' + '\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9' + '\u0BBE-\u0BBF\u0BC1-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0BD0\u0BD7' + '\u0BE6-\u0BEF\u0BF0-\u0BF2\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10' + '\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C41-\u0C44\u0C58-\u0C59\u0C60-\u0C61' + '\u0C66-\u0C6F\u0C7F\u0C82-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8' + '\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CBE\u0CBF\u0CC0-\u0CC4\u0CC6' + '\u0CC7-\u0CC8\u0CCA-\u0CCB\u0CD5-\u0CD6\u0CDE\u0CE0-\u0CE1\u0CE6-\u0CEF' + '\u0CF1-\u0CF2\u0D02-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D' + '\u0D3E-\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D4E\u0D57\u0D60-\u0D61' + '\u0D66-\u0D6F\u0D70-\u0D75\u0D79\u0D7A-\u0D7F\u0D82-\u0D83\u0D85-\u0D96' + '\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCF-\u0DD1\u0DD8-\u0DDF' + '\u0DE6-\u0DEF\u0DF2-\u0DF3\u0DF4\u0E01-\u0E30\u0E32-\u0E33\u0E40-\u0E45' + '\u0E46\u0E4F\u0E50-\u0E59\u0E5A-\u0E5B\u0E81-\u0E82\u0E84\u0E87-\u0E88' + '\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7' + '\u0EAA-\u0EAB\u0EAD-\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6' + '\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F01-\u0F03\u0F04-\u0F12\u0F13\u0F14' + '\u0F15-\u0F17\u0F1A-\u0F1F\u0F20-\u0F29\u0F2A-\u0F33\u0F34\u0F36\u0F38' + '\u0F3E-\u0F3F\u0F40-\u0F47\u0F49-\u0F6C\u0F7F\u0F85\u0F88-\u0F8C' + '\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE-\u0FCF\u0FD0-\u0FD4\u0FD5-\u0FD8' + '\u0FD9-\u0FDA\u1000-\u102A\u102B-\u102C\u1031\u1038\u103B-\u103C\u103F' + '\u1040-\u1049\u104A-\u104F\u1050-\u1055\u1056-\u1057\u105A-\u105D\u1061' + '\u1062-\u1064\u1065-\u1066\u1067-\u106D\u106E-\u1070\u1075-\u1081' + '\u1083-\u1084\u1087-\u108C\u108E\u108F\u1090-\u1099\u109A-\u109C' + '\u109E-\u109F\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FB\u10FC' + '\u10FD-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288' + '\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5' + '\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1360-\u1368' + '\u1369-\u137C\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166D-\u166E' + '\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EB-\u16ED\u16EE-\u16F0' + '\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1735-\u1736' + '\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17B6\u17BE-\u17C5' + '\u17C7-\u17C8\u17D4-\u17D6\u17D7\u17D8-\u17DA\u17DC\u17E0-\u17E9' + '\u1810-\u1819\u1820-\u1842\u1843\u1844-\u1877\u1880-\u18A8\u18AA' + '\u18B0-\u18F5\u1900-\u191E\u1923-\u1926\u1929-\u192B\u1930-\u1931' + '\u1933-\u1938\u1946-\u194F\u1950-\u196D\u1970-\u1974\u1980-\u19AB' + '\u19B0-\u19C0\u19C1-\u19C7\u19C8-\u19C9\u19D0-\u19D9\u19DA\u1A00-\u1A16' + '\u1A19-\u1A1A\u1A1E-\u1A1F\u1A20-\u1A54\u1A55\u1A57\u1A61\u1A63-\u1A64' + '\u1A6D-\u1A72\u1A80-\u1A89\u1A90-\u1A99\u1AA0-\u1AA6\u1AA7\u1AA8-\u1AAD' + '\u1B04\u1B05-\u1B33\u1B35\u1B3B\u1B3D-\u1B41\u1B43-\u1B44\u1B45-\u1B4B' + '\u1B50-\u1B59\u1B5A-\u1B60\u1B61-\u1B6A\u1B74-\u1B7C\u1B82\u1B83-\u1BA0' + '\u1BA1\u1BA6-\u1BA7\u1BAA\u1BAE-\u1BAF\u1BB0-\u1BB9\u1BBA-\u1BE5\u1BE7' + '\u1BEA-\u1BEC\u1BEE\u1BF2-\u1BF3\u1BFC-\u1BFF\u1C00-\u1C23\u1C24-\u1C2B' + '\u1C34-\u1C35\u1C3B-\u1C3F\u1C40-\u1C49\u1C4D-\u1C4F\u1C50-\u1C59' + '\u1C5A-\u1C77\u1C78-\u1C7D\u1C7E-\u1C7F\u1CC0-\u1CC7\u1CD3\u1CE1' + '\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF2-\u1CF3\u1CF5-\u1CF6\u1D00-\u1D2B' + '\u1D2C-\u1D6A\u1D6B-\u1D77\u1D78\u1D79-\u1D9A\u1D9B-\u1DBF\u1E00-\u1F15' + '\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D' + '\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC' + '\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200E' + '\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D' + '\u2124\u2126\u2128\u212A-\u212D\u212F-\u2134\u2135-\u2138\u2139' + '\u213C-\u213F\u2145-\u2149\u214E\u214F\u2160-\u2182\u2183-\u2184' + '\u2185-\u2188\u2336-\u237A\u2395\u249C-\u24E9\u26AC\u2800-\u28FF' + '\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2C7B\u2C7C-\u2C7D\u2C7E-\u2CE4' + '\u2CEB-\u2CEE\u2CF2-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F' + '\u2D70\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE' + '\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005\u3006\u3007' + '\u3021-\u3029\u302E-\u302F\u3031-\u3035\u3038-\u303A\u303B\u303C' + '\u3041-\u3096\u309D-\u309E\u309F\u30A1-\u30FA\u30FC-\u30FE\u30FF' + '\u3105-\u312D\u3131-\u318E\u3190-\u3191\u3192-\u3195\u3196-\u319F' + '\u31A0-\u31BA\u31F0-\u31FF\u3200-\u321C\u3220-\u3229\u322A-\u3247' + '\u3248-\u324F\u3260-\u327B\u327F\u3280-\u3289\u328A-\u32B0\u32C0-\u32CB' + '\u32D0-\u32FE\u3300-\u3376\u337B-\u33DD\u33E0-\u33FE\u3400-\u4DB5' + '\u4E00-\u9FCC\uA000-\uA014\uA015\uA016-\uA48C\uA4D0-\uA4F7\uA4F8-\uA4FD' + '\uA4FE-\uA4FF\uA500-\uA60B\uA60C\uA610-\uA61F\uA620-\uA629\uA62A-\uA62B' + '\uA640-\uA66D\uA66E\uA680-\uA69B\uA69C-\uA69D\uA6A0-\uA6E5\uA6E6-\uA6EF' + '\uA6F2-\uA6F7\uA722-\uA76F\uA770\uA771-\uA787\uA789-\uA78A\uA78B-\uA78E' + '\uA790-\uA7AD\uA7B0-\uA7B1\uA7F7\uA7F8-\uA7F9\uA7FA\uA7FB-\uA801' + '\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA823-\uA824\uA827\uA830-\uA835' + '\uA836-\uA837\uA840-\uA873\uA880-\uA881\uA882-\uA8B3\uA8B4-\uA8C3' + '\uA8CE-\uA8CF\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8F8-\uA8FA\uA8FB\uA900-\uA909' + '\uA90A-\uA925\uA92E-\uA92F\uA930-\uA946\uA952-\uA953\uA95F\uA960-\uA97C' + '\uA983\uA984-\uA9B2\uA9B4-\uA9B5\uA9BA-\uA9BB\uA9BD-\uA9C0\uA9C1-\uA9CD' + '\uA9CF\uA9D0-\uA9D9\uA9DE-\uA9DF\uA9E0-\uA9E4\uA9E6\uA9E7-\uA9EF' + '\uA9F0-\uA9F9\uA9FA-\uA9FE\uAA00-\uAA28\uAA2F-\uAA30\uAA33-\uAA34' + '\uAA40-\uAA42\uAA44-\uAA4B\uAA4D\uAA50-\uAA59\uAA5C-\uAA5F\uAA60-\uAA6F' + '\uAA70\uAA71-\uAA76\uAA77-\uAA79\uAA7A\uAA7B\uAA7D\uAA7E-\uAAAF\uAAB1' + '\uAAB5-\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADC\uAADD\uAADE-\uAADF' + '\uAAE0-\uAAEA\uAAEB\uAAEE-\uAAEF\uAAF0-\uAAF1\uAAF2\uAAF3-\uAAF4\uAAF5' + '\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E' + '\uAB30-\uAB5A\uAB5B\uAB5C-\uAB5F\uAB64-\uAB65\uABC0-\uABE2\uABE3-\uABE4' + '\uABE6-\uABE7\uABE9-\uABEA\uABEB\uABEC\uABF0-\uABF9\uAC00-\uD7A3' + '\uD7B0-\uD7C6\uD7CB-\uD7FB\uE000-\uF8FF\uF900-\uFA6D\uFA70-\uFAD9' + '\uFB00-\uFB06\uFB13-\uFB17\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFF6F\uFF70' + '\uFF71-\uFF9D\uFF9E-\uFF9F\uFFA0-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF' + '\uFFD2-\uFFD7\uFFDA-\uFFDC',
-
- R: '\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05D0-\u05EA\u05EB-\u05EF' + '\u05F0-\u05F2\u05F3-\u05F4\u05F5-\u05FF\u07C0-\u07C9\u07CA-\u07EA' + '\u07F4-\u07F5\u07FA\u07FB-\u07FF\u0800-\u0815\u081A\u0824\u0828' + '\u082E-\u082F\u0830-\u083E\u083F\u0840-\u0858\u085C-\u085D\u085E' + '\u085F-\u089F\u200F\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB37\uFB38-\uFB3C' + '\uFB3D\uFB3E\uFB3F\uFB40-\uFB41\uFB42\uFB43-\uFB44\uFB45\uFB46-\uFB4F',
-
- AL: '\u0608\u060B\u060D\u061B\u061C\u061D\u061E-\u061F\u0620-\u063F\u0640' + '\u0641-\u064A\u066D\u066E-\u066F\u0671-\u06D3\u06D4\u06D5\u06E5-\u06E6' + '\u06EE-\u06EF\u06FA-\u06FC\u06FD-\u06FE\u06FF\u0700-\u070D\u070E\u070F' + '\u0710\u0712-\u072F\u074B-\u074C\u074D-\u07A5\u07B1\u07B2-\u07BF' + '\u08A0-\u08B2\u08B3-\u08E3\uFB50-\uFBB1\uFBB2-\uFBC1\uFBC2-\uFBD2' + '\uFBD3-\uFD3D\uFD40-\uFD4F\uFD50-\uFD8F\uFD90-\uFD91\uFD92-\uFDC7' + '\uFDC8-\uFDCF\uFDF0-\uFDFB\uFDFC\uFDFE-\uFDFF\uFE70-\uFE74\uFE75' + '\uFE76-\uFEFC\uFEFD-\uFEFE'
-
- };
-
- var REGEX_STRONG = new RegExp('[' + RANGE_BY_BIDI_TYPE.L + RANGE_BY_BIDI_TYPE.R + RANGE_BY_BIDI_TYPE.AL + ']');
-
- var REGEX_RTL = new RegExp('[' + RANGE_BY_BIDI_TYPE.R + RANGE_BY_BIDI_TYPE.AL + ']');
-
- /**
- * Returns the first strong character (has Bidi_Class value of L, R, or AL).
- *
- * @param str A text block; e.g. paragraph, table cell, tag
- * @return A character with strong bidi direction, or null if not found
- */
- function firstStrongChar(str) {
- var match = REGEX_STRONG.exec(str);
- return match == null ? null : match[0];
- }
-
- /**
- * Returns the direction of a block of text, based on the direction of its
- * first strong character (has Bidi_Class value of L, R, or AL).
- *
- * @param str A text block; e.g. paragraph, table cell, tag
- * @return The resolved direction
- */
- function firstStrongCharDir(str) {
- var strongChar = firstStrongChar(str);
- if (strongChar == null) {
- return UnicodeBidiDirection_1.NEUTRAL;
- }
- return REGEX_RTL.exec(strongChar) ? UnicodeBidiDirection_1.RTL : UnicodeBidiDirection_1.LTR;
- }
-
- /**
- * Returns the direction of a block of text, based on the direction of its
- * first strong character (has Bidi_Class value of L, R, or AL), or a fallback
- * direction, if no strong character is found.
- *
- * This function is supposed to be used in respect to Higher-Level Protocol
- * rule HL1. (http://www.unicode.org/reports/tr9/#HL1)
- *
- * @param str A text block; e.g. paragraph, table cell, tag
- * @param fallback Fallback direction, used if no strong direction detected
- * for the block (default = NEUTRAL)
- * @return The resolved direction
- */
- function resolveBlockDir(str, fallback) {
- fallback = fallback || UnicodeBidiDirection_1.NEUTRAL;
- if (!str.length) {
- return fallback;
- }
- var blockDir = firstStrongCharDir(str);
- return blockDir === UnicodeBidiDirection_1.NEUTRAL ? fallback : blockDir;
- }
-
- /**
- * Returns the direction of a block of text, based on the direction of its
- * first strong character (has Bidi_Class value of L, R, or AL), or a fallback
- * direction, if no strong character is found.
- *
- * NOTE: This function is similar to resolveBlockDir(), but uses the global
- * direction as the fallback, so it *always* returns a Strong direction,
- * making it useful for integration in places that you need to make the final
- * decision, like setting some CSS class.
- *
- * This function is supposed to be used in respect to Higher-Level Protocol
- * rule HL1. (http://www.unicode.org/reports/tr9/#HL1)
- *
- * @param str A text block; e.g. paragraph, table cell
- * @param strongFallback Fallback direction, used if no strong direction
- * detected for the block (default = global direction)
- * @return The resolved Strong direction
- */
- function getDirection(str, strongFallback) {
- if (!strongFallback) {
- strongFallback = UnicodeBidiDirection_1.getGlobalDir();
- }
- !UnicodeBidiDirection_1.isStrong(strongFallback) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Fallback direction must be a strong direction') : invariant_1(false) : void 0;
- return resolveBlockDir(str, strongFallback);
- }
-
- /**
- * Returns true if getDirection(arguments...) returns LTR.
- *
- * @param str A text block; e.g. paragraph, table cell
- * @param strongFallback Fallback direction, used if no strong direction
- * detected for the block (default = global direction)
- * @return True if the resolved direction is LTR
- */
- function isDirectionLTR(str, strongFallback) {
- return getDirection(str, strongFallback) === UnicodeBidiDirection_1.LTR;
- }
-
- /**
- * Returns true if getDirection(arguments...) returns RTL.
- *
- * @param str A text block; e.g. paragraph, table cell
- * @param strongFallback Fallback direction, used if no strong direction
- * detected for the block (default = global direction)
- * @return True if the resolved direction is RTL
- */
- function isDirectionRTL(str, strongFallback) {
- return getDirection(str, strongFallback) === UnicodeBidiDirection_1.RTL;
- }
-
- var UnicodeBidi = {
- firstStrongChar: firstStrongChar,
- firstStrongCharDir: firstStrongCharDir,
- resolveBlockDir: resolveBlockDir,
- getDirection: getDirection,
- isDirectionLTR: isDirectionLTR,
- isDirectionRTL: isDirectionRTL
- };
-
- var UnicodeBidi_1 = UnicodeBidi;
-
- function _classCallCheck$6(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-
-
-
-
-
- var UnicodeBidiService = function () {
-
- /**
- * Stateful class for paragraph direction detection
- *
- * @param defaultDir Default direction of the service
- */
- function UnicodeBidiService(defaultDir) {
- _classCallCheck$6(this, UnicodeBidiService);
-
- if (!defaultDir) {
- defaultDir = UnicodeBidiDirection_1.getGlobalDir();
- } else {
- !UnicodeBidiDirection_1.isStrong(defaultDir) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Default direction must be a strong direction (LTR or RTL)') : invariant_1(false) : void 0;
- }
- this._defaultDir = defaultDir;
- this.reset();
- }
-
- /**
- * Reset the internal state
- *
- * Instead of creating a new instance, you can just reset() your instance
- * everytime you start a new loop.
- */
-
-
- UnicodeBidiService.prototype.reset = function reset() {
- this._lastDir = this._defaultDir;
- };
-
- /**
- * Returns the direction of a block of text, and remembers it as the
- * fall-back direction for the next paragraph.
- *
- * @param str A text block, e.g. paragraph, table cell, tag
- * @return The resolved direction
- */
-
-
- UnicodeBidiService.prototype.getDirection = function getDirection(str) {
- this._lastDir = UnicodeBidi_1.getDirection(str, this._lastDir);
- return this._lastDir;
- };
-
- return UnicodeBidiService;
- }();
-
- var UnicodeBidiService_1 = UnicodeBidiService;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- *
- */
-
- var nullthrows = function nullthrows(x) {
- if (x != null) {
- return x;
- }
- throw new Error("Got unexpected null or undefined");
- };
-
- var nullthrows_1 = nullthrows;
-
- var OrderedMap$2 = immutable.OrderedMap;
-
-
- var bidiService;
-
- var EditorBidiService = {
- getDirectionMap: function getDirectionMap(content, prevBidiMap) {
- if (!bidiService) {
- bidiService = new UnicodeBidiService_1();
- } else {
- bidiService.reset();
- }
-
- var blockMap = content.getBlockMap();
- var nextBidi = blockMap.valueSeq().map(function (block) {
- return nullthrows_1(bidiService).getDirection(block.getText());
- });
- var bidiMap = OrderedMap$2(blockMap.keySeq().zip(nextBidi));
-
- if (prevBidiMap != null && immutable.is(prevBidiMap, bidiMap)) {
- return prevBidiMap;
- }
-
- return bidiMap;
- }
- };
-
- var EditorBidiService_1 = EditorBidiService;
-
- var _extends$1 = objectAssign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
-
- function _classCallCheck$7(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-
-
-
-
-
-
- var OrderedSet$4 = immutable.OrderedSet,
- Record$7 = immutable.Record,
- Stack = immutable.Stack;
-
-
- var defaultRecord$5 = {
- allowUndo: true,
- currentContent: null,
- decorator: null,
- directionMap: null,
- forceSelection: false,
- inCompositionMode: false,
- inlineStyleOverride: null,
- lastChangeType: null,
- nativelyRenderedContent: null,
- redoStack: Stack(),
- selection: null,
- treeMap: null,
- undoStack: Stack()
- };
-
- var EditorStateRecord = Record$7(defaultRecord$5);
-
- var EditorState = function () {
- EditorState.createEmpty = function createEmpty(decorator) {
- return EditorState.createWithContent(ContentState_1.createFromText(''), decorator);
- };
-
- EditorState.createWithContent = function createWithContent(contentState, decorator) {
- var firstKey = contentState.getBlockMap().first().getKey();
- return EditorState.create({
- currentContent: contentState,
- undoStack: Stack(),
- redoStack: Stack(),
- decorator: decorator || null,
- selection: SelectionState_1.createEmpty(firstKey)
- });
- };
-
- EditorState.create = function create(config) {
- var currentContent = config.currentContent,
- decorator = config.decorator;
-
- var recordConfig = _extends$1({}, config, {
- treeMap: generateNewTreeMap(currentContent, decorator),
- directionMap: EditorBidiService_1.getDirectionMap(currentContent)
- });
- return new EditorState(new EditorStateRecord(recordConfig));
- };
-
- EditorState.set = function set(editorState, put) {
- var map = editorState.getImmutable().withMutations(function (state) {
- var existingDecorator = state.get('decorator');
- var decorator = existingDecorator;
- if (put.decorator === null) {
- decorator = null;
- } else if (put.decorator) {
- decorator = put.decorator;
- }
-
- var newContent = put.currentContent || editorState.getCurrentContent();
-
- if (decorator !== existingDecorator) {
- var treeMap = state.get('treeMap');
- var newTreeMap;
- if (decorator && existingDecorator) {
- newTreeMap = regenerateTreeForNewDecorator(newContent, newContent.getBlockMap(), treeMap, decorator, existingDecorator);
- } else {
- newTreeMap = generateNewTreeMap(newContent, decorator);
- }
-
- state.merge({
- decorator: decorator,
- treeMap: newTreeMap,
- nativelyRenderedContent: null
- });
- return;
- }
-
- var existingContent = editorState.getCurrentContent();
- if (newContent !== existingContent) {
- state.set('treeMap', regenerateTreeForNewBlocks(editorState, newContent.getBlockMap(), newContent.getEntityMap(), decorator));
- }
-
- state.merge(put);
- });
-
- return new EditorState(map);
- };
-
- EditorState.prototype.toJS = function toJS() {
- return this.getImmutable().toJS();
- };
-
- EditorState.prototype.getAllowUndo = function getAllowUndo() {
- return this.getImmutable().get('allowUndo');
- };
-
- EditorState.prototype.getCurrentContent = function getCurrentContent() {
- return this.getImmutable().get('currentContent');
- };
-
- EditorState.prototype.getUndoStack = function getUndoStack() {
- return this.getImmutable().get('undoStack');
- };
-
- EditorState.prototype.getRedoStack = function getRedoStack() {
- return this.getImmutable().get('redoStack');
- };
-
- EditorState.prototype.getSelection = function getSelection() {
- return this.getImmutable().get('selection');
- };
-
- EditorState.prototype.getDecorator = function getDecorator() {
- return this.getImmutable().get('decorator');
- };
-
- EditorState.prototype.isInCompositionMode = function isInCompositionMode() {
- return this.getImmutable().get('inCompositionMode');
- };
-
- EditorState.prototype.mustForceSelection = function mustForceSelection() {
- return this.getImmutable().get('forceSelection');
- };
-
- EditorState.prototype.getNativelyRenderedContent = function getNativelyRenderedContent() {
- return this.getImmutable().get('nativelyRenderedContent');
- };
-
- EditorState.prototype.getLastChangeType = function getLastChangeType() {
- return this.getImmutable().get('lastChangeType');
- };
-
- /**
- * While editing, the user may apply inline style commands with a collapsed
- * cursor, intending to type text that adopts the specified style. In this
- * case, we track the specified style as an "override" that takes precedence
- * over the inline style of the text adjacent to the cursor.
- *
- * If null, there is no override in place.
- */
-
-
- EditorState.prototype.getInlineStyleOverride = function getInlineStyleOverride() {
- return this.getImmutable().get('inlineStyleOverride');
- };
-
- EditorState.setInlineStyleOverride = function setInlineStyleOverride(editorState, inlineStyleOverride) {
- return EditorState.set(editorState, { inlineStyleOverride: inlineStyleOverride });
- };
-
- /**
- * Get the appropriate inline style for the editor state. If an
- * override is in place, use it. Otherwise, the current style is
- * based on the location of the selection state.
- */
-
-
- EditorState.prototype.getCurrentInlineStyle = function getCurrentInlineStyle() {
- var override = this.getInlineStyleOverride();
- if (override != null) {
- return override;
- }
-
- var content = this.getCurrentContent();
- var selection = this.getSelection();
-
- if (selection.isCollapsed()) {
- return getInlineStyleForCollapsedSelection(content, selection);
- }
-
- return getInlineStyleForNonCollapsedSelection(content, selection);
- };
-
- EditorState.prototype.getBlockTree = function getBlockTree(blockKey) {
- return this.getImmutable().getIn(['treeMap', blockKey]);
- };
-
- EditorState.prototype.isSelectionAtStartOfContent = function isSelectionAtStartOfContent() {
- var firstKey = this.getCurrentContent().getBlockMap().first().getKey();
- return this.getSelection().hasEdgeWithin(firstKey, 0, 0);
- };
-
- EditorState.prototype.isSelectionAtEndOfContent = function isSelectionAtEndOfContent() {
- var content = this.getCurrentContent();
- var blockMap = content.getBlockMap();
- var last = blockMap.last();
- var end = last.getLength();
- return this.getSelection().hasEdgeWithin(last.getKey(), end, end);
- };
-
- EditorState.prototype.getDirectionMap = function getDirectionMap() {
- return this.getImmutable().get('directionMap');
- };
-
- /**
- * Incorporate native DOM selection changes into the EditorState. This
- * method can be used when we simply want to accept whatever the DOM
- * has given us to represent selection, and we do not need to re-render
- * the editor.
- *
- * To forcibly move the DOM selection, see `EditorState.forceSelection`.
- */
-
-
- EditorState.acceptSelection = function acceptSelection(editorState, selection) {
- return updateSelection(editorState, selection, false);
- };
-
- /**
- * At times, we need to force the DOM selection to be where we
- * need it to be. This can occur when the anchor or focus nodes
- * are non-text nodes, for instance. In this case, we want to trigger
- * a re-render of the editor, which in turn forces selection into
- * the correct place in the DOM. The `forceSelection` method
- * accomplishes this.
- *
- * This method should be used in cases where you need to explicitly
- * move the DOM selection from one place to another without a change
- * in ContentState.
- */
-
-
- EditorState.forceSelection = function forceSelection(editorState, selection) {
- if (!selection.getHasFocus()) {
- selection = selection.set('hasFocus', true);
- }
- return updateSelection(editorState, selection, true);
- };
-
- /**
- * Move selection to the end of the editor without forcing focus.
- */
-
-
- EditorState.moveSelectionToEnd = function moveSelectionToEnd(editorState) {
- var content = editorState.getCurrentContent();
- var lastBlock = content.getLastBlock();
- var lastKey = lastBlock.getKey();
- var length = lastBlock.getLength();
-
- return EditorState.acceptSelection(editorState, new SelectionState_1({
- anchorKey: lastKey,
- anchorOffset: length,
- focusKey: lastKey,
- focusOffset: length,
- isBackward: false
- }));
- };
-
- /**
- * Force focus to the end of the editor. This is useful in scenarios
- * where we want to programmatically focus the input and it makes sense
- * to allow the user to continue working seamlessly.
- */
-
-
- EditorState.moveFocusToEnd = function moveFocusToEnd(editorState) {
- var afterSelectionMove = EditorState.moveSelectionToEnd(editorState);
- return EditorState.forceSelection(afterSelectionMove, afterSelectionMove.getSelection());
- };
-
- /**
- * Push the current ContentState onto the undo stack if it should be
- * considered a boundary state, and set the provided ContentState as the
- * new current content.
- */
-
-
- EditorState.push = function push(editorState, contentState, changeType) {
- if (editorState.getCurrentContent() === contentState) {
- return editorState;
- }
-
- var forceSelection = changeType !== 'insert-characters';
- var directionMap = EditorBidiService_1.getDirectionMap(contentState, editorState.getDirectionMap());
-
- if (!editorState.getAllowUndo()) {
- return EditorState.set(editorState, {
- currentContent: contentState,
- directionMap: directionMap,
- lastChangeType: changeType,
- selection: contentState.getSelectionAfter(),
- forceSelection: forceSelection,
- inlineStyleOverride: null
- });
- }
-
- var selection = editorState.getSelection();
- var currentContent = editorState.getCurrentContent();
- var undoStack = editorState.getUndoStack();
- var newContent = contentState;
-
- if (selection !== currentContent.getSelectionAfter() || mustBecomeBoundary(editorState, changeType)) {
- undoStack = undoStack.push(currentContent);
- newContent = newContent.set('selectionBefore', selection);
- } else if (changeType === 'insert-characters' || changeType === 'backspace-character' || changeType === 'delete-character') {
- // Preserve the previous selection.
- newContent = newContent.set('selectionBefore', currentContent.getSelectionBefore());
- }
-
- var inlineStyleOverride = editorState.getInlineStyleOverride();
-
- // Don't discard inline style overrides for the following change types:
- var overrideChangeTypes = ['adjust-depth', 'change-block-type', 'split-block'];
-
- if (overrideChangeTypes.indexOf(changeType) === -1) {
- inlineStyleOverride = null;
- }
-
- var editorStateChanges = {
- currentContent: newContent,
- directionMap: directionMap,
- undoStack: undoStack,
- redoStack: Stack(),
- lastChangeType: changeType,
- selection: contentState.getSelectionAfter(),
- forceSelection: forceSelection,
- inlineStyleOverride: inlineStyleOverride
- };
-
- return EditorState.set(editorState, editorStateChanges);
- };
-
- /**
- * Make the top ContentState in the undo stack the new current content and
- * push the current content onto the redo stack.
- */
-
-
- EditorState.undo = function undo(editorState) {
- if (!editorState.getAllowUndo()) {
- return editorState;
- }
-
- var undoStack = editorState.getUndoStack();
- var newCurrentContent = undoStack.peek();
- if (!newCurrentContent) {
- return editorState;
- }
-
- var currentContent = editorState.getCurrentContent();
- var directionMap = EditorBidiService_1.getDirectionMap(newCurrentContent, editorState.getDirectionMap());
-
- return EditorState.set(editorState, {
- currentContent: newCurrentContent,
- directionMap: directionMap,
- undoStack: undoStack.shift(),
- redoStack: editorState.getRedoStack().push(currentContent),
- forceSelection: true,
- inlineStyleOverride: null,
- lastChangeType: 'undo',
- nativelyRenderedContent: null,
- selection: currentContent.getSelectionBefore()
- });
- };
-
- /**
- * Make the top ContentState in the redo stack the new current content and
- * push the current content onto the undo stack.
- */
-
-
- EditorState.redo = function redo(editorState) {
- if (!editorState.getAllowUndo()) {
- return editorState;
- }
-
- var redoStack = editorState.getRedoStack();
- var newCurrentContent = redoStack.peek();
- if (!newCurrentContent) {
- return editorState;
- }
-
- var currentContent = editorState.getCurrentContent();
- var directionMap = EditorBidiService_1.getDirectionMap(newCurrentContent, editorState.getDirectionMap());
-
- return EditorState.set(editorState, {
- currentContent: newCurrentContent,
- directionMap: directionMap,
- undoStack: editorState.getUndoStack().push(currentContent),
- redoStack: redoStack.shift(),
- forceSelection: true,
- inlineStyleOverride: null,
- lastChangeType: 'redo',
- nativelyRenderedContent: null,
- selection: newCurrentContent.getSelectionAfter()
- });
- };
-
- /**
- * Not for public consumption.
- */
-
-
- function EditorState(immutable) {
- _classCallCheck$7(this, EditorState);
-
- this._immutable = immutable;
- }
-
- /**
- * Not for public consumption.
- */
-
-
- EditorState.prototype.getImmutable = function getImmutable() {
- return this._immutable;
- };
-
- return EditorState;
- }();
-
- /**
- * Set the supplied SelectionState as the new current selection, and set
- * the `force` flag to trigger manual selection placement by the view.
- */
-
-
- function updateSelection(editorState, selection, forceSelection) {
- return EditorState.set(editorState, {
- selection: selection,
- forceSelection: forceSelection,
- nativelyRenderedContent: null,
- inlineStyleOverride: null
- });
- }
-
- /**
- * Regenerate the entire tree map for a given ContentState and decorator.
- * Returns an OrderedMap that maps all available ContentBlock objects.
- */
- function generateNewTreeMap(contentState, decorator) {
- return contentState.getBlockMap().map(function (block) {
- return BlockTree_1.generate(contentState, block, decorator);
- }).toOrderedMap();
- }
-
- /**
- * Regenerate tree map objects for all ContentBlocks that have changed
- * between the current editorState and newContent. Returns an OrderedMap
- * with only changed regenerated tree map objects.
- */
- function regenerateTreeForNewBlocks(editorState, newBlockMap, newEntityMap, decorator) {
- var contentState = editorState.getCurrentContent().set('entityMap', newEntityMap);
- var prevBlockMap = contentState.getBlockMap();
- var prevTreeMap = editorState.getImmutable().get('treeMap');
- return prevTreeMap.merge(newBlockMap.toSeq().filter(function (block, key) {
- return block !== prevBlockMap.get(key);
- }).map(function (block) {
- return BlockTree_1.generate(contentState, block, decorator);
- }));
- }
-
- /**
- * Generate tree map objects for a new decorator object, preserving any
- * decorations that are unchanged from the previous decorator.
- *
- * Note that in order for this to perform optimally, decoration Lists for
- * decorators should be preserved when possible to allow for direct immutable
- * List comparison.
- */
- function regenerateTreeForNewDecorator(content, blockMap, previousTreeMap, decorator, existingDecorator) {
- return previousTreeMap.merge(blockMap.toSeq().filter(function (block) {
- return decorator.getDecorations(block, content) !== existingDecorator.getDecorations(block, content);
- }).map(function (block) {
- return BlockTree_1.generate(content, block, decorator);
- }));
- }
-
- /**
- * Return whether a change should be considered a boundary state, given
- * the previous change type. Allows us to discard potential boundary states
- * during standard typing or deletion behavior.
- */
- function mustBecomeBoundary(editorState, changeType) {
- var lastChangeType = editorState.getLastChangeType();
- return changeType !== lastChangeType || changeType !== 'insert-characters' && changeType !== 'backspace-character' && changeType !== 'delete-character';
- }
-
- function getInlineStyleForCollapsedSelection(content, selection) {
- var startKey = selection.getStartKey();
- var startOffset = selection.getStartOffset();
- var startBlock = content.getBlockForKey(startKey);
-
- // If the cursor is not at the start of the block, look backward to
- // preserve the style of the preceding character.
- if (startOffset > 0) {
- return startBlock.getInlineStyleAt(startOffset - 1);
- }
-
- // The caret is at position zero in this block. If the block has any
- // text at all, use the style of the first character.
- if (startBlock.getLength()) {
- return startBlock.getInlineStyleAt(0);
- }
-
- // Otherwise, look upward in the document to find the closest character.
- return lookUpwardForInlineStyle(content, startKey);
- }
-
- function getInlineStyleForNonCollapsedSelection(content, selection) {
- var startKey = selection.getStartKey();
- var startOffset = selection.getStartOffset();
- var startBlock = content.getBlockForKey(startKey);
-
- // If there is a character just inside the selection, use its style.
- if (startOffset < startBlock.getLength()) {
- return startBlock.getInlineStyleAt(startOffset);
- }
-
- // Check if the selection at the end of a non-empty block. Use the last
- // style in the block.
- if (startOffset > 0) {
- return startBlock.getInlineStyleAt(startOffset - 1);
- }
-
- // Otherwise, look upward in the document to find the closest character.
- return lookUpwardForInlineStyle(content, startKey);
- }
-
- function lookUpwardForInlineStyle(content, fromKey) {
- var lastNonEmpty = content.getBlockMap().reverse().skipUntil(function (_, k) {
- return k === fromKey;
- }).skip(1).skipUntil(function (block, _) {
- return block.getLength();
- }).first();
-
- if (lastNonEmpty) return lastNonEmpty.getInlineStyleAt(lastNonEmpty.getLength() - 1);
- return OrderedSet$4();
- }
-
- var EditorState_1 = EditorState;
-
- var OrderedMap$3 = immutable.OrderedMap,
- List$7 = immutable.List;
-
-
- var transformBlock$2 = function transformBlock(key, blockMap, func) {
- if (!key) {
- return;
- }
-
- var block = blockMap.get(key);
-
- if (!block) {
- return;
- }
-
- blockMap.set(key, func(block));
- };
-
- var updateBlockMapLinks$3 = function updateBlockMapLinks(blockMap, originalBlockToBeMoved, originalTargetBlock, insertionMode, isExperimentalTreeBlock) {
- if (!isExperimentalTreeBlock) {
- return blockMap;
- }
- // possible values of 'insertionMode' are: 'after', 'before'
- var isInsertedAfterTarget = insertionMode === 'after';
-
- var originalBlockKey = originalBlockToBeMoved.getKey();
- var originalTargetKey = originalTargetBlock.getKey();
- var originalParentKey = originalBlockToBeMoved.getParentKey();
- var originalNextSiblingKey = originalBlockToBeMoved.getNextSiblingKey();
- var originalPrevSiblingKey = originalBlockToBeMoved.getPrevSiblingKey();
- var newParentKey = originalTargetBlock.getParentKey();
- var newNextSiblingKey = isInsertedAfterTarget ? originalTargetBlock.getNextSiblingKey() : originalTargetKey;
- var newPrevSiblingKey = isInsertedAfterTarget ? originalTargetKey : originalTargetBlock.getPrevSiblingKey();
-
- return blockMap.withMutations(function (blocks) {
- // update old parent
- transformBlock$2(originalParentKey, blocks, function (block) {
- var parentChildrenList = block.getChildKeys();
- return block.merge({
- children: parentChildrenList['delete'](parentChildrenList.indexOf(originalBlockKey))
- });
- });
-
- // update old prev
- transformBlock$2(originalPrevSiblingKey, blocks, function (block) {
- return block.merge({
- nextSibling: originalNextSiblingKey
- });
- });
-
- // update old next
- transformBlock$2(originalNextSiblingKey, blocks, function (block) {
- return block.merge({
- prevSibling: originalPrevSiblingKey
- });
- });
-
- // update new next
- transformBlock$2(newNextSiblingKey, blocks, function (block) {
- return block.merge({
- prevSibling: originalBlockKey
- });
- });
-
- // update new prev
- transformBlock$2(newPrevSiblingKey, blocks, function (block) {
- return block.merge({
- nextSibling: originalBlockKey
- });
- });
-
- // update new parent
- transformBlock$2(newParentKey, blocks, function (block) {
- var newParentChildrenList = block.getChildKeys();
- var targetBlockIndex = newParentChildrenList.indexOf(originalTargetKey);
-
- var insertionIndex = isInsertedAfterTarget ? targetBlockIndex + 1 : targetBlockIndex !== 0 ? targetBlockIndex - 1 : 0;
-
- var newChildrenArray = newParentChildrenList.toArray();
- newChildrenArray.splice(insertionIndex, 0, originalBlockKey);
-
- return block.merge({
- children: List$7(newChildrenArray)
- });
- });
-
- // update block
- transformBlock$2(originalBlockKey, blocks, function (block) {
- return block.merge({
- nextSibling: newNextSiblingKey,
- prevSibling: newPrevSiblingKey,
- parent: newParentKey
- });
- });
- });
- };
-
- var moveBlockInContentState = function moveBlockInContentState(contentState, blockToBeMoved, targetBlock, insertionMode) {
- !(insertionMode !== 'replace') ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Replacing blocks is not supported.') : invariant_1(false) : void 0;
-
- var targetKey = targetBlock.getKey();
- var blockKey = blockToBeMoved.getKey();
-
- !(blockKey !== targetKey) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Block cannot be moved next to itself.') : invariant_1(false) : void 0;
-
- var blockMap = contentState.getBlockMap();
- var isExperimentalTreeBlock = blockToBeMoved instanceof ContentBlockNode_1;
-
- var blocksToBeMoved = [blockToBeMoved];
- var blockMapWithoutBlocksToBeMoved = blockMap['delete'](blockKey);
-
- if (isExperimentalTreeBlock) {
- blocksToBeMoved = [];
- blockMapWithoutBlocksToBeMoved = blockMap.withMutations(function (blocks) {
- var nextSiblingKey = blockToBeMoved.getNextSiblingKey();
- var nextDelimiterBlockKey = getNextDelimiterBlockKey_1(blockToBeMoved, blocks);
-
- blocks.toSeq().skipUntil(function (block) {
- return block.getKey() === blockKey;
- }).takeWhile(function (block) {
- var key = block.getKey();
- var isBlockToBeMoved = key === blockKey;
- var hasNextSiblingAndIsNotNextSibling = nextSiblingKey && key !== nextSiblingKey;
- var doesNotHaveNextSiblingAndIsNotDelimiter = !nextSiblingKey && block.getParentKey() && (!nextDelimiterBlockKey || key !== nextDelimiterBlockKey);
-
- return !!(isBlockToBeMoved || hasNextSiblingAndIsNotNextSibling || doesNotHaveNextSiblingAndIsNotDelimiter);
- }).forEach(function (block) {
- blocksToBeMoved.push(block);
- blocks['delete'](block.getKey());
- });
- });
- }
-
- var blocksBefore = blockMapWithoutBlocksToBeMoved.toSeq().takeUntil(function (v) {
- return v === targetBlock;
- });
-
- var blocksAfter = blockMapWithoutBlocksToBeMoved.toSeq().skipUntil(function (v) {
- return v === targetBlock;
- }).skip(1);
-
- var slicedBlocks = blocksToBeMoved.map(function (block) {
- return [block.getKey(), block];
- });
-
- var newBlocks = OrderedMap$3();
-
- if (insertionMode === 'before') {
- var blockBefore = contentState.getBlockBefore(targetKey);
-
- !(!blockBefore || blockBefore.getKey() !== blockToBeMoved.getKey()) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Block cannot be moved next to itself.') : invariant_1(false) : void 0;
-
- newBlocks = blocksBefore.concat([].concat(slicedBlocks, [[targetKey, targetBlock]]), blocksAfter).toOrderedMap();
- } else if (insertionMode === 'after') {
- var blockAfter = contentState.getBlockAfter(targetKey);
-
- !(!blockAfter || blockAfter.getKey() !== blockKey) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Block cannot be moved next to itself.') : invariant_1(false) : void 0;
-
- newBlocks = blocksBefore.concat([[targetKey, targetBlock]].concat(slicedBlocks), blocksAfter).toOrderedMap();
- }
-
- return contentState.merge({
- blockMap: updateBlockMapLinks$3(newBlocks, blockToBeMoved, targetBlock, insertionMode, isExperimentalTreeBlock),
- selectionBefore: contentState.getSelectionAfter(),
- selectionAfter: contentState.getSelectionAfter().merge({
- anchorKey: blockKey,
- focusKey: blockKey
- })
- });
- };
-
- var moveBlockInContentState_1 = moveBlockInContentState;
-
- var ContentBlockRecord$1 = ContentBlock_1;
-
- var List$8 = immutable.List,
- Repeat$5 = immutable.Repeat;
-
-
- var AtomicBlockUtils = {
- insertAtomicBlock: function insertAtomicBlock(editorState, entityKey, character) {
- var contentState = editorState.getCurrentContent();
- var selectionState = editorState.getSelection();
-
- var afterRemoval = DraftModifier_1.removeRange(contentState, selectionState, 'backward');
-
- var targetSelection = afterRemoval.getSelectionAfter();
- var afterSplit = DraftModifier_1.splitBlock(afterRemoval, targetSelection);
- var insertionTarget = afterSplit.getSelectionAfter();
-
- var asAtomicBlock = DraftModifier_1.setBlockType(afterSplit, insertionTarget, 'atomic');
-
- var charData = CharacterMetadata_1.create({ entity: entityKey });
-
- var atomicBlockConfig = {
- key: generateRandomKey_1(),
- type: 'atomic',
- text: character,
- characterList: List$8(Repeat$5(charData, character.length))
- };
-
- var atomicDividerBlockConfig = {
- key: generateRandomKey_1(),
- type: 'unstyled'
- };
-
- var fragmentArray = [new ContentBlockRecord$1(atomicBlockConfig), new ContentBlockRecord$1(atomicDividerBlockConfig)];
-
- var fragment = BlockMapBuilder_1.createFromArray(fragmentArray);
-
- var withAtomicBlock = DraftModifier_1.replaceWithFragment(asAtomicBlock, insertionTarget, fragment);
-
- var newContent = withAtomicBlock.merge({
- selectionBefore: selectionState,
- selectionAfter: withAtomicBlock.getSelectionAfter().set('hasFocus', true)
- });
-
- return EditorState_1.push(editorState, newContent, 'insert-fragment');
- },
-
- moveAtomicBlock: function moveAtomicBlock(editorState, atomicBlock, targetRange, insertionMode) {
- var contentState = editorState.getCurrentContent();
- var selectionState = editorState.getSelection();
-
- var withMovedAtomicBlock = void 0;
-
- if (insertionMode === 'before' || insertionMode === 'after') {
- var targetBlock = contentState.getBlockForKey(insertionMode === 'before' ? targetRange.getStartKey() : targetRange.getEndKey());
-
- withMovedAtomicBlock = moveBlockInContentState_1(contentState, atomicBlock, targetBlock, insertionMode);
- } else {
- var afterRemoval = DraftModifier_1.removeRange(contentState, targetRange, 'backward');
-
- var selectionAfterRemoval = afterRemoval.getSelectionAfter();
- var _targetBlock = afterRemoval.getBlockForKey(selectionAfterRemoval.getFocusKey());
-
- if (selectionAfterRemoval.getStartOffset() === 0) {
- withMovedAtomicBlock = moveBlockInContentState_1(afterRemoval, atomicBlock, _targetBlock, 'before');
- } else if (selectionAfterRemoval.getEndOffset() === _targetBlock.getLength()) {
- withMovedAtomicBlock = moveBlockInContentState_1(afterRemoval, atomicBlock, _targetBlock, 'after');
- } else {
- var afterSplit = DraftModifier_1.splitBlock(afterRemoval, selectionAfterRemoval);
-
- var selectionAfterSplit = afterSplit.getSelectionAfter();
- var _targetBlock2 = afterSplit.getBlockForKey(selectionAfterSplit.getFocusKey());
-
- withMovedAtomicBlock = moveBlockInContentState_1(afterSplit, atomicBlock, _targetBlock2, 'before');
- }
- }
-
- var newContent = withMovedAtomicBlock.merge({
- selectionBefore: selectionState,
- selectionAfter: withMovedAtomicBlock.getSelectionAfter().set('hasFocus', true)
- });
-
- return EditorState_1.push(editorState, newContent, 'move-block');
- }
- };
-
- var AtomicBlockUtils_1 = AtomicBlockUtils;
-
- function _classCallCheck$8(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-
-
- var List$9 = immutable.List;
-
-
- var DELIMITER = '.';
-
- /**
- * A CompositeDraftDecorator traverses through a list of DraftDecorator
- * instances to identify sections of a ContentBlock that should be rendered
- * in a "decorated" manner. For example, hashtags, mentions, and links may
- * be intended to stand out visually, be rendered as anchors, etc.
- *
- * The list of decorators supplied to the constructor will be used in the
- * order they are provided. This allows the caller to specify a priority for
- * string matching, in case of match collisions among decorators.
- *
- * For instance, I may have a link with a `#` in its text. Though this section
- * of text may match our hashtag decorator, it should not be treated as a
- * hashtag. I should therefore list my link DraftDecorator
- * before my hashtag DraftDecorator when constructing this composite
- * decorator instance.
- *
- * Thus, when a collision like this is encountered, the earlier match is
- * preserved and the new match is discarded.
- */
-
- var CompositeDraftDecorator = function () {
- function CompositeDraftDecorator(decorators) {
- _classCallCheck$8(this, CompositeDraftDecorator);
-
- // Copy the decorator array, since we use this array order to determine
- // precedence of decoration matching. If the array is mutated externally,
- // we don't want to be affected here.
- this._decorators = decorators.slice();
- }
-
- CompositeDraftDecorator.prototype.getDecorations = function getDecorations(block, contentState) {
- var decorations = Array(block.getText().length).fill(null);
-
- this._decorators.forEach(function ( /*object*/decorator, /*number*/ii) {
- var counter = 0;
- var strategy = decorator.strategy;
- var callback = function callback( /*number*/start, /*number*/end) {
- // Find out if any of our matching range is already occupied
- // by another decorator. If so, discard the match. Otherwise, store
- // the component key for rendering.
- if (canOccupySlice(decorations, start, end)) {
- occupySlice(decorations, start, end, ii + DELIMITER + counter);
- counter++;
- }
- };
- strategy(block, callback, contentState);
- });
-
- return List$9(decorations);
- };
-
- CompositeDraftDecorator.prototype.getComponentForKey = function getComponentForKey(key) {
- var componentKey = parseInt(key.split(DELIMITER)[0], 10);
- return this._decorators[componentKey].component;
- };
-
- CompositeDraftDecorator.prototype.getPropsForKey = function getPropsForKey(key) {
- var componentKey = parseInt(key.split(DELIMITER)[0], 10);
- return this._decorators[componentKey].props;
- };
-
- return CompositeDraftDecorator;
- }();
-
- /**
- * Determine whether we can occupy the specified slice of the decorations
- * array.
- */
-
-
- function canOccupySlice(decorations, start, end) {
- for (var ii = start; ii < end; ii++) {
- if (decorations[ii] != null) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Splice the specified component into our decoration array at the desired
- * range.
- */
- function occupySlice(targetArr, start, end, componentKey) {
- for (var ii = start; ii < end; ii++) {
- targetArr[ii] = componentKey;
- }
- }
-
- var CompositeDraftDecorator_1 = CompositeDraftDecorator;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- */
-
- /**
- * This function is used to mark string literals representing CSS class names
- * so that they can be transformed statically. This allows for modularization
- * and minification of CSS class names.
- *
- * In static_upstream, this function is actually implemented, but it should
- * eventually be replaced with something more descriptive, and the transform
- * that is used in the main stack should be ported for use elsewhere.
- *
- * @param string|object className to modularize, or an object of key/values.
- * In the object case, the values are conditions that
- * determine if the className keys should be included.
- * @param [string ...] Variable list of classNames in the string case.
- * @return string Renderable space-separated CSS className.
- */
- function cx(classNames) {
- if (typeof classNames == 'object') {
- return Object.keys(classNames).filter(function (className) {
- return classNames[className];
- }).map(replace).join(' ');
- }
- return Array.prototype.map.call(arguments, replace).join(' ');
- }
-
- function replace(str) {
- return str.replace(/\//g, '-');
- }
-
- var cx_1 = cx;
-
- var Map$8 = immutable.Map;
-
-
-
-
-
- var UL_WRAP = React.createElement('ul', { className: cx_1('public/DraftStyleDefault/ul') });
- var OL_WRAP = React.createElement('ol', { className: cx_1('public/DraftStyleDefault/ol') });
- var PRE_WRAP = React.createElement('pre', { className: cx_1('public/DraftStyleDefault/pre') });
-
- var DefaultDraftBlockRenderMap = Map$8({
- 'header-one': {
- element: 'h1'
- },
- 'header-two': {
- element: 'h2'
- },
- 'header-three': {
- element: 'h3'
- },
- 'header-four': {
- element: 'h4'
- },
- 'header-five': {
- element: 'h5'
- },
- 'header-six': {
- element: 'h6'
- },
- 'unordered-list-item': {
- element: 'li',
- wrapper: UL_WRAP
- },
- 'ordered-list-item': {
- element: 'li',
- wrapper: OL_WRAP
- },
- blockquote: {
- element: 'blockquote'
- },
- atomic: {
- element: 'figure'
- },
- 'code-block': {
- element: 'pre',
- wrapper: PRE_WRAP
- },
- unstyled: {
- element: 'div',
- aliasedElements: ['p']
- }
- });
-
- var DefaultDraftBlockRenderMap_1 = DefaultDraftBlockRenderMap;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule DefaultDraftInlineStyle
- * @format
- *
- */
-
- var DefaultDraftInlineStyle = {
- BOLD: {
- fontWeight: 'bold'
- },
-
- CODE: {
- fontFamily: 'monospace',
- wordWrap: 'break-word'
- },
-
- ITALIC: {
- fontStyle: 'italic'
- },
-
- STRIKETHROUGH: {
- textDecoration: 'line-through'
- },
-
- UNDERLINE: {
- textDecoration: 'underline'
- }
- };
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- */
-
- var Keys = {
- BACKSPACE: 8,
- TAB: 9,
- RETURN: 13,
- ALT: 18,
- ESC: 27,
- SPACE: 32,
- PAGE_UP: 33,
- PAGE_DOWN: 34,
- END: 35,
- HOME: 36,
- LEFT: 37,
- UP: 38,
- RIGHT: 39,
- DOWN: 40,
- DELETE: 46,
- COMMA: 188,
- PERIOD: 190,
- A: 65,
- Z: 90,
- ZERO: 48,
- NUMPAD_0: 96,
- NUMPAD_9: 105
- };
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule getEntityKeyForSelection
- * @format
- *
- */
-
- /**
- * Return the entity key that should be used when inserting text for the
- * specified target selection, only if the entity is `MUTABLE`. `IMMUTABLE`
- * and `SEGMENTED` entities should not be used for insertion behavior.
- */
- function getEntityKeyForSelection(contentState, targetSelection) {
- var entityKey;
-
- if (targetSelection.isCollapsed()) {
- var key = targetSelection.getAnchorKey();
- var offset = targetSelection.getAnchorOffset();
- if (offset > 0) {
- entityKey = contentState.getBlockForKey(key).getEntityAt(offset - 1);
- if (entityKey !== contentState.getBlockForKey(key).getEntityAt(offset)) {
- return null;
- }
- return filterKey(contentState.getEntityMap(), entityKey);
- }
- return null;
- }
-
- var startKey = targetSelection.getStartKey();
- var startOffset = targetSelection.getStartOffset();
- var startBlock = contentState.getBlockForKey(startKey);
-
- entityKey = startOffset === startBlock.getLength() ? null : startBlock.getEntityAt(startOffset);
-
- return filterKey(contentState.getEntityMap(), entityKey);
- }
-
- /**
- * Determine whether an entity key corresponds to a `MUTABLE` entity. If so,
- * return it. If not, return null.
- */
- function filterKey(entityMap, entityKey) {
- if (entityKey) {
- var entity = entityMap.__get(entityKey);
- return entity.getMutability() === 'MUTABLE' ? entityKey : null;
- }
- return null;
- }
-
- var getEntityKeyForSelection_1 = getEntityKeyForSelection;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule isEventHandled
- * @format
- *
- */
-
- /**
- * Utility method for determining whether or not the value returned
- * from a handler indicates that it was handled.
- */
- function isEventHandled(value) {
- return value === 'handled' || value === true;
- }
-
- var isEventHandled_1 = isEventHandled;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule isSelectionAtLeafStart
- * @format
- *
- */
-
- function isSelectionAtLeafStart(editorState) {
- var selection = editorState.getSelection();
- var anchorKey = selection.getAnchorKey();
- var blockTree = editorState.getBlockTree(anchorKey);
- var offset = selection.getStartOffset();
-
- var isAtStart = false;
-
- blockTree.some(function (leafSet) {
- if (offset === leafSet.get('start')) {
- isAtStart = true;
- return true;
- }
-
- if (offset < leafSet.get('end')) {
- return leafSet.get('leaves').some(function (leaf) {
- var leafStart = leaf.get('start');
- if (offset === leafStart) {
- isAtStart = true;
- return true;
- }
-
- return false;
- });
- }
-
- return false;
- });
-
- return isAtStart;
- }
-
- var isSelectionAtLeafStart_1 = isSelectionAtLeafStart;
-
- /**
- * Millisecond delay to allow `compositionstart` to fire again upon
- * `compositionend`.
- *
- * This is used for Korean input to ensure that typing can continue without
- * the editor trying to render too quickly. More specifically, Safari 7.1+
- * triggers `compositionstart` a little slower than Chrome/FF, which
- * leads to composed characters being resolved and re-render occurring
- * sooner than we want.
- */
- var RESOLVE_DELAY = 20;
-
- /**
- * A handful of variables used to track the current composition and its
- * resolution status. These exist at the module level because it is not
- * possible to have compositions occurring in multiple editors simultaneously,
- * and it simplifies state management with respect to the DraftEditor component.
- */
- var resolved = false;
- var stillComposing = false;
- var textInputData = '';
-
- var DraftEditorCompositionHandler = {
- onBeforeInput: function onBeforeInput(editor, e) {
- textInputData = (textInputData || '') + e.data;
- },
-
- /**
- * A `compositionstart` event has fired while we're still in composition
- * mode. Continue the current composition session to prevent a re-render.
- */
- onCompositionStart: function onCompositionStart(editor) {
- stillComposing = true;
- },
-
- /**
- * Attempt to end the current composition session.
- *
- * Defer handling because browser will still insert the chars into active
- * element after `compositionend`. If a `compositionstart` event fires
- * before `resolveComposition` executes, our composition session will
- * continue.
- *
- * The `resolved` flag is useful because certain IME interfaces fire the
- * `compositionend` event multiple times, thus queueing up multiple attempts
- * at handling the composition. Since handling the same composition event
- * twice could break the DOM, we only use the first event. Example: Arabic
- * Google Input Tools on Windows 8.1 fires `compositionend` three times.
- */
- onCompositionEnd: function onCompositionEnd(editor) {
- resolved = false;
- stillComposing = false;
- setTimeout(function () {
- if (!resolved) {
- DraftEditorCompositionHandler.resolveComposition(editor);
- }
- }, RESOLVE_DELAY);
- },
-
- /**
- * In Safari, keydown events may fire when committing compositions. If
- * the arrow keys are used to commit, prevent default so that the cursor
- * doesn't move, otherwise it will jump back noticeably on re-render.
- */
- onKeyDown: function onKeyDown(editor, e) {
- if (!stillComposing) {
- // If a keydown event is received after compositionend but before the
- // 20ms timer expires (ex: type option-E then backspace, or type A then
- // backspace in 2-Set Korean), we should immediately resolve the
- // composition and reinterpret the key press in edit mode.
- DraftEditorCompositionHandler.resolveComposition(editor);
- editor._onKeyDown(e);
- return;
- }
- if (e.which === Keys.RIGHT || e.which === Keys.LEFT) {
- e.preventDefault();
- }
- },
-
- /**
- * Keypress events may fire when committing compositions. In Firefox,
- * pressing RETURN commits the composition and inserts extra newline
- * characters that we do not want. `preventDefault` allows the composition
- * to be committed while preventing the extra characters.
- */
- onKeyPress: function onKeyPress(editor, e) {
- if (e.which === Keys.RETURN) {
- e.preventDefault();
- }
- },
-
- /**
- * Attempt to insert composed characters into the document.
- *
- * If we are still in a composition session, do nothing. Otherwise, insert
- * the characters into the document and terminate the composition session.
- *
- * If no characters were composed -- for instance, the user
- * deleted all composed characters and committed nothing new --
- * force a re-render. We also re-render when the composition occurs
- * at the beginning of a leaf, to ensure that if the browser has
- * created a new text node for the composition, we will discard it.
- *
- * Resetting innerHTML will move focus to the beginning of the editor,
- * so we update to force it back to the correct place.
- */
- resolveComposition: function resolveComposition(editor) {
- if (stillComposing) {
- return;
- }
-
- resolved = true;
- var composedChars = textInputData;
- textInputData = '';
-
- var editorState = EditorState_1.set(editor._latestEditorState, {
- inCompositionMode: false
- });
-
- var currentStyle = editorState.getCurrentInlineStyle();
- var entityKey = getEntityKeyForSelection_1(editorState.getCurrentContent(), editorState.getSelection());
-
- var mustReset = !composedChars || isSelectionAtLeafStart_1(editorState) || currentStyle.size > 0 || entityKey !== null;
-
- if (mustReset) {
- editor.restoreEditorDOM();
- }
-
- editor.exitCurrentMode();
-
- if (composedChars) {
- // If characters have been composed, re-rendering with the update
- // is sufficient to reset the editor.
- var contentState = DraftModifier_1.replaceText(editorState.getCurrentContent(), editorState.getSelection(), composedChars, currentStyle, entityKey);
- editor.update(EditorState_1.push(editorState, contentState, 'insert-characters'));
- return;
- }
-
- if (mustReset) {
- editor.update(EditorState_1.set(editorState, {
- nativelyRenderedContent: null,
- forceSelection: true
- }));
- }
- }
- };
-
- var DraftEditorCompositionHandler_1 = DraftEditorCompositionHandler;
-
- var uaParser = createCommonjsModule(function (module, exports) {
- /*!
- * UAParser.js v0.7.21
- * Lightweight JavaScript-based User-Agent string parser
- * https://github.com/faisalman/ua-parser-js
- *
- * Copyright © 2012-2019 Faisal Salman <f@faisalman.com>
- * Licensed under MIT License
- */
-
- (function (window, undefined$1) {
-
- //////////////
- // Constants
- /////////////
-
-
- var LIBVERSION = '0.7.21',
- EMPTY = '',
- UNKNOWN = '?',
- FUNC_TYPE = 'function',
- OBJ_TYPE = 'object',
- STR_TYPE = 'string',
- MAJOR = 'major', // deprecated
- MODEL = 'model',
- NAME = 'name',
- TYPE = 'type',
- VENDOR = 'vendor',
- VERSION = 'version',
- ARCHITECTURE= 'architecture',
- CONSOLE = 'console',
- MOBILE = 'mobile',
- TABLET = 'tablet',
- SMARTTV = 'smarttv',
- WEARABLE = 'wearable',
- EMBEDDED = 'embedded';
-
-
- ///////////
- // Helper
- //////////
-
-
- var util = {
- extend : function (regexes, extensions) {
- var mergedRegexes = {};
- for (var i in regexes) {
- if (extensions[i] && extensions[i].length % 2 === 0) {
- mergedRegexes[i] = extensions[i].concat(regexes[i]);
- } else {
- mergedRegexes[i] = regexes[i];
- }
- }
- return mergedRegexes;
- },
- has : function (str1, str2) {
- if (typeof str1 === "string") {
- return str2.toLowerCase().indexOf(str1.toLowerCase()) !== -1;
- } else {
- return false;
- }
- },
- lowerize : function (str) {
- return str.toLowerCase();
- },
- major : function (version) {
- return typeof(version) === STR_TYPE ? version.replace(/[^\d\.]/g,'').split(".")[0] : undefined$1;
- },
- trim : function (str) {
- return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
- }
- };
-
-
- ///////////////
- // Map helper
- //////////////
-
-
- var mapper = {
-
- rgx : function (ua, arrays) {
-
- var i = 0, j, k, p, q, matches, match;
-
- // loop through all regexes maps
- while (i < arrays.length && !matches) {
-
- var regex = arrays[i], // even sequence (0,2,4,..)
- props = arrays[i + 1]; // odd sequence (1,3,5,..)
- j = k = 0;
-
- // try matching uastring with regexes
- while (j < regex.length && !matches) {
-
- matches = regex[j++].exec(ua);
-
- if (!!matches) {
- for (p = 0; p < props.length; p++) {
- match = matches[++k];
- q = props[p];
- // check if given property is actually array
- if (typeof q === OBJ_TYPE && q.length > 0) {
- if (q.length == 2) {
- if (typeof q[1] == FUNC_TYPE) {
- // assign modified match
- this[q[0]] = q[1].call(this, match);
- } else {
- // assign given value, ignore regex match
- this[q[0]] = q[1];
- }
- } else if (q.length == 3) {
- // check whether function or regex
- if (typeof q[1] === FUNC_TYPE && !(q[1].exec && q[1].test)) {
- // call function (usually string mapper)
- this[q[0]] = match ? q[1].call(this, match, q[2]) : undefined$1;
- } else {
- // sanitize match using given regex
- this[q[0]] = match ? match.replace(q[1], q[2]) : undefined$1;
- }
- } else if (q.length == 4) {
- this[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined$1;
- }
- } else {
- this[q] = match ? match : undefined$1;
- }
- }
- }
- }
- i += 2;
- }
- },
-
- str : function (str, map) {
-
- for (var i in map) {
- // check if array
- if (typeof map[i] === OBJ_TYPE && map[i].length > 0) {
- for (var j = 0; j < map[i].length; j++) {
- if (util.has(map[i][j], str)) {
- return (i === UNKNOWN) ? undefined$1 : i;
- }
- }
- } else if (util.has(map[i], str)) {
- return (i === UNKNOWN) ? undefined$1 : i;
- }
- }
- return str;
- }
- };
-
-
- ///////////////
- // String map
- //////////////
-
-
- var maps = {
-
- browser : {
- oldsafari : {
- version : {
- '1.0' : '/8',
- '1.2' : '/1',
- '1.3' : '/3',
- '2.0' : '/412',
- '2.0.2' : '/416',
- '2.0.3' : '/417',
- '2.0.4' : '/419',
- '?' : '/'
- }
- }
- },
-
- device : {
- amazon : {
- model : {
- 'Fire Phone' : ['SD', 'KF']
- }
- },
- sprint : {
- model : {
- 'Evo Shift 4G' : '7373KT'
- },
- vendor : {
- 'HTC' : 'APA',
- 'Sprint' : 'Sprint'
- }
- }
- },
-
- os : {
- windows : {
- version : {
- 'ME' : '4.90',
- 'NT 3.11' : 'NT3.51',
- 'NT 4.0' : 'NT4.0',
- '2000' : 'NT 5.0',
- 'XP' : ['NT 5.1', 'NT 5.2'],
- 'Vista' : 'NT 6.0',
- '7' : 'NT 6.1',
- '8' : 'NT 6.2',
- '8.1' : 'NT 6.3',
- '10' : ['NT 6.4', 'NT 10.0'],
- 'RT' : 'ARM'
- }
- }
- }
- };
-
-
- //////////////
- // Regex map
- /////////////
-
-
- var regexes = {
-
- browser : [[
-
- // Presto based
- /(opera\smini)\/([\w\.-]+)/i, // Opera Mini
- /(opera\s[mobiletab]+).+version\/([\w\.-]+)/i, // Opera Mobi/Tablet
- /(opera).+version\/([\w\.]+)/i, // Opera > 9.80
- /(opera)[\/\s]+([\w\.]+)/i // Opera < 9.80
- ], [NAME, VERSION], [
-
- /(opios)[\/\s]+([\w\.]+)/i // Opera mini on iphone >= 8.0
- ], [[NAME, 'Opera Mini'], VERSION], [
-
- /\s(opr)\/([\w\.]+)/i // Opera Webkit
- ], [[NAME, 'Opera'], VERSION], [
-
- // Mixed
- /(kindle)\/([\w\.]+)/i, // Kindle
- /(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?([\w\.]*)/i,
- // Lunascape/Maxthon/Netfront/Jasmine/Blazer
- // Trident based
- /(avant\s|iemobile|slim)(?:browser)?[\/\s]?([\w\.]*)/i,
- // Avant/IEMobile/SlimBrowser
- /(bidubrowser|baidubrowser)[\/\s]?([\w\.]+)/i, // Baidu Browser
- /(?:ms|\()(ie)\s([\w\.]+)/i, // Internet Explorer
-
- // Webkit/KHTML based
- /(rekonq)\/([\w\.]*)/i, // Rekonq
- /(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon)\/([\w\.-]+)/i
- // Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium/PhantomJS/Bowser/QupZilla/Falkon
- ], [NAME, VERSION], [
-
- /(konqueror)\/([\w\.]+)/i // Konqueror
- ], [[NAME, 'Konqueror'], VERSION], [
-
- /(trident).+rv[:\s]([\w\.]+).+like\sgecko/i // IE11
- ], [[NAME, 'IE'], VERSION], [
-
- /(edge|edgios|edga|edg)\/((\d+)?[\w\.]+)/i // Microsoft Edge
- ], [[NAME, 'Edge'], VERSION], [
-
- /(yabrowser)\/([\w\.]+)/i // Yandex
- ], [[NAME, 'Yandex'], VERSION], [
-
- /(Avast)\/([\w\.]+)/i // Avast Secure Browser
- ], [[NAME, 'Avast Secure Browser'], VERSION], [
-
- /(AVG)\/([\w\.]+)/i // AVG Secure Browser
- ], [[NAME, 'AVG Secure Browser'], VERSION], [
-
- /(puffin)\/([\w\.]+)/i // Puffin
- ], [[NAME, 'Puffin'], VERSION], [
-
- /(focus)\/([\w\.]+)/i // Firefox Focus
- ], [[NAME, 'Firefox Focus'], VERSION], [
-
- /(opt)\/([\w\.]+)/i // Opera Touch
- ], [[NAME, 'Opera Touch'], VERSION], [
-
- /((?:[\s\/])uc?\s?browser|(?:juc.+)ucweb)[\/\s]?([\w\.]+)/i // UCBrowser
- ], [[NAME, 'UCBrowser'], VERSION], [
-
- /(comodo_dragon)\/([\w\.]+)/i // Comodo Dragon
- ], [[NAME, /_/g, ' '], VERSION], [
-
- /(windowswechat qbcore)\/([\w\.]+)/i // WeChat Desktop for Windows Built-in Browser
- ], [[NAME, 'WeChat(Win) Desktop'], VERSION], [
-
- /(micromessenger)\/([\w\.]+)/i // WeChat
- ], [[NAME, 'WeChat'], VERSION], [
-
- /(brave)\/([\w\.]+)/i // Brave browser
- ], [[NAME, 'Brave'], VERSION], [
-
- /(qqbrowserlite)\/([\w\.]+)/i // QQBrowserLite
- ], [NAME, VERSION], [
-
- /(QQ)\/([\d\.]+)/i // QQ, aka ShouQ
- ], [NAME, VERSION], [
-
- /m?(qqbrowser)[\/\s]?([\w\.]+)/i // QQBrowser
- ], [NAME, VERSION], [
-
- /(baiduboxapp)[\/\s]?([\w\.]+)/i // Baidu App
- ], [NAME, VERSION], [
-
- /(2345Explorer)[\/\s]?([\w\.]+)/i // 2345 Browser
- ], [NAME, VERSION], [
-
- /(MetaSr)[\/\s]?([\w\.]+)/i // SouGouBrowser
- ], [NAME], [
-
- /(LBBROWSER)/i // LieBao Browser
- ], [NAME], [
-
- /xiaomi\/miuibrowser\/([\w\.]+)/i // MIUI Browser
- ], [VERSION, [NAME, 'MIUI Browser']], [
-
- /;fbav\/([\w\.]+);/i // Facebook App for iOS & Android
- ], [VERSION, [NAME, 'Facebook']], [
-
- /safari\s(line)\/([\w\.]+)/i, // Line App for iOS
- /android.+(line)\/([\w\.]+)\/iab/i // Line App for Android
- ], [NAME, VERSION], [
-
- /headlesschrome(?:\/([\w\.]+)|\s)/i // Chrome Headless
- ], [VERSION, [NAME, 'Chrome Headless']], [
-
- /\swv\).+(chrome)\/([\w\.]+)/i // Chrome WebView
- ], [[NAME, /(.+)/, '$1 WebView'], VERSION], [
-
- /((?:oculus|samsung)browser)\/([\w\.]+)/i
- ], [[NAME, /(.+(?:g|us))(.+)/, '$1 $2'], VERSION], [ // Oculus / Samsung Browser
-
- /android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)*/i // Android Browser
- ], [VERSION, [NAME, 'Android Browser']], [
-
- /(sailfishbrowser)\/([\w\.]+)/i // Sailfish Browser
- ], [[NAME, 'Sailfish Browser'], VERSION], [
-
- /(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?([\w\.]+)/i
- // Chrome/OmniWeb/Arora/Tizen/Nokia
- ], [NAME, VERSION], [
-
- /(dolfin)\/([\w\.]+)/i // Dolphin
- ], [[NAME, 'Dolphin'], VERSION], [
-
- /(qihu|qhbrowser|qihoobrowser|360browser)/i // 360
- ], [[NAME, '360 Browser']], [
-
- /((?:android.+)crmo|crios)\/([\w\.]+)/i // Chrome for Android/iOS
- ], [[NAME, 'Chrome'], VERSION], [
-
- /(coast)\/([\w\.]+)/i // Opera Coast
- ], [[NAME, 'Opera Coast'], VERSION], [
-
- /fxios\/([\w\.-]+)/i // Firefox for iOS
- ], [VERSION, [NAME, 'Firefox']], [
-
- /version\/([\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari
- ], [VERSION, [NAME, 'Mobile Safari']], [
-
- /version\/([\w\.]+).+?(mobile\s?safari|safari)/i // Safari & Safari Mobile
- ], [VERSION, NAME], [
-
- /webkit.+?(gsa)\/([\w\.]+).+?(mobile\s?safari|safari)(\/[\w\.]+)/i // Google Search Appliance on iOS
- ], [[NAME, 'GSA'], VERSION], [
-
- /webkit.+?(mobile\s?safari|safari)(\/[\w\.]+)/i // Safari < 3.0
- ], [NAME, [VERSION, mapper.str, maps.browser.oldsafari.version]], [
-
- /(webkit|khtml)\/([\w\.]+)/i
- ], [NAME, VERSION], [
-
- // Gecko based
- /(navigator|netscape)\/([\w\.-]+)/i // Netscape
- ], [[NAME, 'Netscape'], VERSION], [
- /(swiftfox)/i, // Swiftfox
- /(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?([\w\.\+]+)/i,
- // IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror
- /(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([\w\.-]+)$/i,
-
- // Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix
- /(mozilla)\/([\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla
-
- // Other
- /(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir)[\/\s]?([\w\.]+)/i,
- // Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/Sleipnir
- /(links)\s\(([\w\.]+)/i, // Links
- /(gobrowser)\/?([\w\.]*)/i, // GoBrowser
- /(ice\s?browser)\/v?([\w\._]+)/i, // ICE Browser
- /(mosaic)[\/\s]([\w\.]+)/i // Mosaic
- ], [NAME, VERSION]
- ],
-
- cpu : [[
-
- /(?:(amd|x(?:(?:86|64)[_-])?|wow|win)64)[;\)]/i // AMD64
- ], [[ARCHITECTURE, 'amd64']], [
-
- /(ia32(?=;))/i // IA32 (quicktime)
- ], [[ARCHITECTURE, util.lowerize]], [
-
- /((?:i[346]|x)86)[;\)]/i // IA32
- ], [[ARCHITECTURE, 'ia32']], [
-
- // PocketPC mistakenly identified as PowerPC
- /windows\s(ce|mobile);\sppc;/i
- ], [[ARCHITECTURE, 'arm']], [
-
- /((?:ppc|powerpc)(?:64)?)(?:\smac|;|\))/i // PowerPC
- ], [[ARCHITECTURE, /ower/, '', util.lowerize]], [
-
- /(sun4\w)[;\)]/i // SPARC
- ], [[ARCHITECTURE, 'sparc']], [
-
- /((?:avr32|ia64(?=;))|68k(?=\))|arm(?:64|(?=v\d+[;l]))|(?=atmel\s)avr|(?:irix|mips|sparc)(?:64)?(?=;)|pa-risc)/i
- // IA64, 68K, ARM/64, AVR/32, IRIX/64, MIPS/64, SPARC/64, PA-RISC
- ], [[ARCHITECTURE, util.lowerize]]
- ],
-
- device : [[
-
- /\((ipad|playbook);[\w\s\),;-]+(rim|apple)/i // iPad/PlayBook
- ], [MODEL, VENDOR, [TYPE, TABLET]], [
-
- /applecoremedia\/[\w\.]+ \((ipad)/ // iPad
- ], [MODEL, [VENDOR, 'Apple'], [TYPE, TABLET]], [
-
- /(apple\s{0,1}tv)/i // Apple TV
- ], [[MODEL, 'Apple TV'], [VENDOR, 'Apple'], [TYPE, SMARTTV]], [
-
- /(archos)\s(gamepad2?)/i, // Archos
- /(hp).+(touchpad)/i, // HP TouchPad
- /(hp).+(tablet)/i, // HP Tablet
- /(kindle)\/([\w\.]+)/i, // Kindle
- /\s(nook)[\w\s]+build\/(\w+)/i, // Nook
- /(dell)\s(strea[kpr\s\d]*[\dko])/i // Dell Streak
- ], [VENDOR, MODEL, [TYPE, TABLET]], [
-
- /(kf[A-z]+)\sbuild\/.+silk\//i // Kindle Fire HD
- ], [MODEL, [VENDOR, 'Amazon'], [TYPE, TABLET]], [
- /(sd|kf)[0349hijorstuw]+\sbuild\/.+silk\//i // Fire Phone
- ], [[MODEL, mapper.str, maps.device.amazon.model], [VENDOR, 'Amazon'], [TYPE, MOBILE]], [
- /android.+aft([bms])\sbuild/i // Fire TV
- ], [MODEL, [VENDOR, 'Amazon'], [TYPE, SMARTTV]], [
-
- /\((ip[honed|\s\w*]+);.+(apple)/i // iPod/iPhone
- ], [MODEL, VENDOR, [TYPE, MOBILE]], [
- /\((ip[honed|\s\w*]+);/i // iPod/iPhone
- ], [MODEL, [VENDOR, 'Apple'], [TYPE, MOBILE]], [
-
- /(blackberry)[\s-]?(\w+)/i, // BlackBerry
- /(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[\s_-]?([\w-]*)/i,
- // BenQ/Palm/Sony-Ericsson/Acer/Asus/Dell/Meizu/Motorola/Polytron
- /(hp)\s([\w\s]+\w)/i, // HP iPAQ
- /(asus)-?(\w+)/i // Asus
- ], [VENDOR, MODEL, [TYPE, MOBILE]], [
- /\(bb10;\s(\w+)/i // BlackBerry 10
- ], [MODEL, [VENDOR, 'BlackBerry'], [TYPE, MOBILE]], [
- // Asus Tablets
- /android.+(transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+|nexus 7|padfone|p00c)/i
- ], [MODEL, [VENDOR, 'Asus'], [TYPE, TABLET]], [
-
- /(sony)\s(tablet\s[ps])\sbuild\//i, // Sony
- /(sony)?(?:sgp.+)\sbuild\//i
- ], [[VENDOR, 'Sony'], [MODEL, 'Xperia Tablet'], [TYPE, TABLET]], [
- /android.+\s([c-g]\d{4}|so[-l]\w+)(?=\sbuild\/|\).+chrome\/(?![1-6]{0,1}\d\.))/i
- ], [MODEL, [VENDOR, 'Sony'], [TYPE, MOBILE]], [
-
- /\s(ouya)\s/i, // Ouya
- /(nintendo)\s([wids3u]+)/i // Nintendo
- ], [VENDOR, MODEL, [TYPE, CONSOLE]], [
-
- /android.+;\s(shield)\sbuild/i // Nvidia
- ], [MODEL, [VENDOR, 'Nvidia'], [TYPE, CONSOLE]], [
-
- /(playstation\s[34portablevi]+)/i // Playstation
- ], [MODEL, [VENDOR, 'Sony'], [TYPE, CONSOLE]], [
-
- /(sprint\s(\w+))/i // Sprint Phones
- ], [[VENDOR, mapper.str, maps.device.sprint.vendor], [MODEL, mapper.str, maps.device.sprint.model], [TYPE, MOBILE]], [
-
- /(htc)[;_\s-]+([\w\s]+(?=\)|\sbuild)|\w+)/i, // HTC
- /(zte)-(\w*)/i, // ZTE
- /(alcatel|geeksphone|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]*)/i
- // Alcatel/GeeksPhone/Nexian/Panasonic/Sony
- ], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [
-
- /(nexus\s9)/i // HTC Nexus 9
- ], [MODEL, [VENDOR, 'HTC'], [TYPE, TABLET]], [
-
- /d\/huawei([\w\s-]+)[;\)]/i,
- /(nexus\s6p|vog-l29|ane-lx1|eml-l29)/i // Huawei
- ], [MODEL, [VENDOR, 'Huawei'], [TYPE, MOBILE]], [
-
- /android.+(bah2?-a?[lw]\d{2})/i // Huawei MediaPad
- ], [MODEL, [VENDOR, 'Huawei'], [TYPE, TABLET]], [
-
- /(microsoft);\s(lumia[\s\w]+)/i // Microsoft Lumia
- ], [VENDOR, MODEL, [TYPE, MOBILE]], [
-
- /[\s\(;](xbox(?:\sone)?)[\s\);]/i // Microsoft Xbox
- ], [MODEL, [VENDOR, 'Microsoft'], [TYPE, CONSOLE]], [
- /(kin\.[onetw]{3})/i // Microsoft Kin
- ], [[MODEL, /\./g, ' '], [VENDOR, 'Microsoft'], [TYPE, MOBILE]], [
-
- // Motorola
- /\s(milestone|droid(?:[2-4x]|\s(?:bionic|x2|pro|razr))?:?(\s4g)?)[\w\s]+build\//i,
- /mot[\s-]?(\w*)/i,
- /(XT\d{3,4}) build\//i,
- /(nexus\s6)/i
- ], [MODEL, [VENDOR, 'Motorola'], [TYPE, MOBILE]], [
- /android.+\s(mz60\d|xoom[\s2]{0,2})\sbuild\//i
- ], [MODEL, [VENDOR, 'Motorola'], [TYPE, TABLET]], [
-
- /hbbtv\/\d+\.\d+\.\d+\s+\([\w\s]*;\s*(\w[^;]*);([^;]*)/i // HbbTV devices
- ], [[VENDOR, util.trim], [MODEL, util.trim], [TYPE, SMARTTV]], [
-
- /hbbtv.+maple;(\d+)/i
- ], [[MODEL, /^/, 'SmartTV'], [VENDOR, 'Samsung'], [TYPE, SMARTTV]], [
-
- /\(dtv[\);].+(aquos)/i // Sharp
- ], [MODEL, [VENDOR, 'Sharp'], [TYPE, SMARTTV]], [
-
- /android.+((sch-i[89]0\d|shw-m380s|gt-p\d{4}|gt-n\d+|sgh-t8[56]9|nexus 10))/i,
- /((SM-T\w+))/i
- ], [[VENDOR, 'Samsung'], MODEL, [TYPE, TABLET]], [ // Samsung
- /smart-tv.+(samsung)/i
- ], [VENDOR, [TYPE, SMARTTV], MODEL], [
- /((s[cgp]h-\w+|gt-\w+|galaxy\snexus|sm-\w[\w\d]+))/i,
- /(sam[sung]*)[\s-]*(\w+-?[\w-]*)/i,
- /sec-((sgh\w+))/i
- ], [[VENDOR, 'Samsung'], MODEL, [TYPE, MOBILE]], [
-
- /sie-(\w*)/i // Siemens
- ], [MODEL, [VENDOR, 'Siemens'], [TYPE, MOBILE]], [
-
- /(maemo|nokia).*(n900|lumia\s\d+)/i, // Nokia
- /(nokia)[\s_-]?([\w-]*)/i
- ], [[VENDOR, 'Nokia'], MODEL, [TYPE, MOBILE]], [
-
- /android[x\d\.\s;]+\s([ab][1-7]\-?[0178a]\d\d?)/i // Acer
- ], [MODEL, [VENDOR, 'Acer'], [TYPE, TABLET]], [
-
- /android.+([vl]k\-?\d{3})\s+build/i // LG Tablet
- ], [MODEL, [VENDOR, 'LG'], [TYPE, TABLET]], [
- /android\s3\.[\s\w;-]{10}(lg?)-([06cv9]{3,4})/i // LG Tablet
- ], [[VENDOR, 'LG'], MODEL, [TYPE, TABLET]], [
- /(lg) netcast\.tv/i // LG SmartTV
- ], [VENDOR, MODEL, [TYPE, SMARTTV]], [
- /(nexus\s[45])/i, // LG
- /lg[e;\s\/-]+(\w*)/i,
- /android.+lg(\-?[\d\w]+)\s+build/i
- ], [MODEL, [VENDOR, 'LG'], [TYPE, MOBILE]], [
-
- /(lenovo)\s?(s(?:5000|6000)(?:[\w-]+)|tab(?:[\s\w]+))/i // Lenovo tablets
- ], [VENDOR, MODEL, [TYPE, TABLET]], [
- /android.+(ideatab[a-z0-9\-\s]+)/i // Lenovo
- ], [MODEL, [VENDOR, 'Lenovo'], [TYPE, TABLET]], [
- /(lenovo)[_\s-]?([\w-]+)/i
- ], [VENDOR, MODEL, [TYPE, MOBILE]], [
-
- /linux;.+((jolla));/i // Jolla
- ], [VENDOR, MODEL, [TYPE, MOBILE]], [
-
- /((pebble))app\/[\d\.]+\s/i // Pebble
- ], [VENDOR, MODEL, [TYPE, WEARABLE]], [
-
- /android.+;\s(oppo)\s?([\w\s]+)\sbuild/i // OPPO
- ], [VENDOR, MODEL, [TYPE, MOBILE]], [
-
- /crkey/i // Google Chromecast
- ], [[MODEL, 'Chromecast'], [VENDOR, 'Google'], [TYPE, SMARTTV]], [
-
- /android.+;\s(glass)\s\d/i // Google Glass
- ], [MODEL, [VENDOR, 'Google'], [TYPE, WEARABLE]], [
-
- /android.+;\s(pixel c)[\s)]/i // Google Pixel C
- ], [MODEL, [VENDOR, 'Google'], [TYPE, TABLET]], [
-
- /android.+;\s(pixel( [23])?( xl)?)[\s)]/i // Google Pixel
- ], [MODEL, [VENDOR, 'Google'], [TYPE, MOBILE]], [
-
- /android.+;\s(\w+)\s+build\/hm\1/i, // Xiaomi Hongmi 'numeric' models
- /android.+(hm[\s\-_]*note?[\s_]*(?:\d\w)?)\s+build/i, // Xiaomi Hongmi
- /android.+(mi[\s\-_]*(?:a\d|one|one[\s_]plus|note lte)?[\s_]*(?:\d?\w?)[\s_]*(?:plus)?)\s+build/i,
- // Xiaomi Mi
- /android.+(redmi[\s\-_]*(?:note)?(?:[\s_]*[\w\s]+))\s+build/i // Redmi Phones
- ], [[MODEL, /_/g, ' '], [VENDOR, 'Xiaomi'], [TYPE, MOBILE]], [
- /android.+(mi[\s\-_]*(?:pad)(?:[\s_]*[\w\s]+))\s+build/i // Mi Pad tablets
- ],[[MODEL, /_/g, ' '], [VENDOR, 'Xiaomi'], [TYPE, TABLET]], [
- /android.+;\s(m[1-5]\snote)\sbuild/i // Meizu
- ], [MODEL, [VENDOR, 'Meizu'], [TYPE, MOBILE]], [
- /(mz)-([\w-]{2,})/i
- ], [[VENDOR, 'Meizu'], MODEL, [TYPE, MOBILE]], [
-
- /android.+a000(1)\s+build/i, // OnePlus
- /android.+oneplus\s(a\d{4})[\s)]/i
- ], [MODEL, [VENDOR, 'OnePlus'], [TYPE, MOBILE]], [
-
- /android.+[;\/]\s*(RCT[\d\w]+)\s+build/i // RCA Tablets
- ], [MODEL, [VENDOR, 'RCA'], [TYPE, TABLET]], [
-
- /android.+[;\/\s]+(Venue[\d\s]{2,7})\s+build/i // Dell Venue Tablets
- ], [MODEL, [VENDOR, 'Dell'], [TYPE, TABLET]], [
-
- /android.+[;\/]\s*(Q[T|M][\d\w]+)\s+build/i // Verizon Tablet
- ], [MODEL, [VENDOR, 'Verizon'], [TYPE, TABLET]], [
-
- /android.+[;\/]\s+(Barnes[&\s]+Noble\s+|BN[RT])(V?.*)\s+build/i // Barnes & Noble Tablet
- ], [[VENDOR, 'Barnes & Noble'], MODEL, [TYPE, TABLET]], [
-
- /android.+[;\/]\s+(TM\d{3}.*\b)\s+build/i // Barnes & Noble Tablet
- ], [MODEL, [VENDOR, 'NuVision'], [TYPE, TABLET]], [
-
- /android.+;\s(k88)\sbuild/i // ZTE K Series Tablet
- ], [MODEL, [VENDOR, 'ZTE'], [TYPE, TABLET]], [
-
- /android.+[;\/]\s*(gen\d{3})\s+build.*49h/i // Swiss GEN Mobile
- ], [MODEL, [VENDOR, 'Swiss'], [TYPE, MOBILE]], [
-
- /android.+[;\/]\s*(zur\d{3})\s+build/i // Swiss ZUR Tablet
- ], [MODEL, [VENDOR, 'Swiss'], [TYPE, TABLET]], [
-
- /android.+[;\/]\s*((Zeki)?TB.*\b)\s+build/i // Zeki Tablets
- ], [MODEL, [VENDOR, 'Zeki'], [TYPE, TABLET]], [
-
- /(android).+[;\/]\s+([YR]\d{2})\s+build/i,
- /android.+[;\/]\s+(Dragon[\-\s]+Touch\s+|DT)(\w{5})\sbuild/i // Dragon Touch Tablet
- ], [[VENDOR, 'Dragon Touch'], MODEL, [TYPE, TABLET]], [
-
- /android.+[;\/]\s*(NS-?\w{0,9})\sbuild/i // Insignia Tablets
- ], [MODEL, [VENDOR, 'Insignia'], [TYPE, TABLET]], [
-
- /android.+[;\/]\s*((NX|Next)-?\w{0,9})\s+build/i // NextBook Tablets
- ], [MODEL, [VENDOR, 'NextBook'], [TYPE, TABLET]], [
-
- /android.+[;\/]\s*(Xtreme\_)?(V(1[045]|2[015]|30|40|60|7[05]|90))\s+build/i
- ], [[VENDOR, 'Voice'], MODEL, [TYPE, MOBILE]], [ // Voice Xtreme Phones
-
- /android.+[;\/]\s*(LVTEL\-)?(V1[12])\s+build/i // LvTel Phones
- ], [[VENDOR, 'LvTel'], MODEL, [TYPE, MOBILE]], [
-
- /android.+;\s(PH-1)\s/i
- ], [MODEL, [VENDOR, 'Essential'], [TYPE, MOBILE]], [ // Essential PH-1
-
- /android.+[;\/]\s*(V(100MD|700NA|7011|917G).*\b)\s+build/i // Envizen Tablets
- ], [MODEL, [VENDOR, 'Envizen'], [TYPE, TABLET]], [
-
- /android.+[;\/]\s*(Le[\s\-]+Pan)[\s\-]+(\w{1,9})\s+build/i // Le Pan Tablets
- ], [VENDOR, MODEL, [TYPE, TABLET]], [
-
- /android.+[;\/]\s*(Trio[\s\-]*.*)\s+build/i // MachSpeed Tablets
- ], [MODEL, [VENDOR, 'MachSpeed'], [TYPE, TABLET]], [
-
- /android.+[;\/]\s*(Trinity)[\-\s]*(T\d{3})\s+build/i // Trinity Tablets
- ], [VENDOR, MODEL, [TYPE, TABLET]], [
-
- /android.+[;\/]\s*TU_(1491)\s+build/i // Rotor Tablets
- ], [MODEL, [VENDOR, 'Rotor'], [TYPE, TABLET]], [
-
- /android.+(KS(.+))\s+build/i // Amazon Kindle Tablets
- ], [MODEL, [VENDOR, 'Amazon'], [TYPE, TABLET]], [
-
- /android.+(Gigaset)[\s\-]+(Q\w{1,9})\s+build/i // Gigaset Tablets
- ], [VENDOR, MODEL, [TYPE, TABLET]], [
-
- /\s(tablet|tab)[;\/]/i, // Unidentifiable Tablet
- /\s(mobile)(?:[;\/]|\ssafari)/i // Unidentifiable Mobile
- ], [[TYPE, util.lowerize], VENDOR, MODEL], [
-
- /[\s\/\(](smart-?tv)[;\)]/i // SmartTV
- ], [[TYPE, SMARTTV]], [
-
- /(android[\w\.\s\-]{0,9});.+build/i // Generic Android Device
- ], [MODEL, [VENDOR, 'Generic']]
- ],
-
- engine : [[
-
- /windows.+\sedge\/([\w\.]+)/i // EdgeHTML
- ], [VERSION, [NAME, 'EdgeHTML']], [
-
- /webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i // Blink
- ], [VERSION, [NAME, 'Blink']], [
-
- /(presto)\/([\w\.]+)/i, // Presto
- /(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,
- // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m/Goanna
- /(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i, // KHTML/Tasman/Links
- /(icab)[\/\s]([23]\.[\d\.]+)/i // iCab
- ], [NAME, VERSION], [
-
- /rv\:([\w\.]{1,9}).+(gecko)/i // Gecko
- ], [VERSION, NAME]
- ],
-
- os : [[
-
- // Windows based
- /microsoft\s(windows)\s(vista|xp)/i // Windows (iTunes)
- ], [NAME, VERSION], [
- /(windows)\snt\s6\.2;\s(arm)/i, // Windows RT
- /(windows\sphone(?:\sos)*)[\s\/]?([\d\.\s\w]*)/i, // Windows Phone
- /(windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i
- ], [NAME, [VERSION, mapper.str, maps.os.windows.version]], [
- /(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i
- ], [[NAME, 'Windows'], [VERSION, mapper.str, maps.os.windows.version]], [
-
- // Mobile/Embedded OS
- /\((bb)(10);/i // BlackBerry 10
- ], [[NAME, 'BlackBerry'], VERSION], [
- /(blackberry)\w*\/?([\w\.]*)/i, // Blackberry
- /(tizen|kaios)[\/\s]([\w\.]+)/i, // Tizen/KaiOS
- /(android|webos|palm\sos|qnx|bada|rim\stablet\sos|meego|sailfish|contiki)[\/\s-]?([\w\.]*)/i
- // Android/WebOS/Palm/QNX/Bada/RIM/MeeGo/Contiki/Sailfish OS
- ], [NAME, VERSION], [
- /(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]*)/i // Symbian
- ], [[NAME, 'Symbian'], VERSION], [
- /\((series40);/i // Series 40
- ], [NAME], [
- /mozilla.+\(mobile;.+gecko.+firefox/i // Firefox OS
- ], [[NAME, 'Firefox OS'], VERSION], [
-
- // Console
- /(nintendo|playstation)\s([wids34portablevu]+)/i, // Nintendo/Playstation
-
- // GNU/Linux based
- /(mint)[\/\s\(]?(\w*)/i, // Mint
- /(mageia|vectorlinux)[;\s]/i, // Mageia/VectorLinux
- /(joli|[kxln]?ubuntu|debian|suse|opensuse|gentoo|(?=\s)arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus)[\/\s-]?(?!chrom)([\w\.-]*)/i,
- // Joli/Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware
- // Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk/Linpus
- /(hurd|linux)\s?([\w\.]*)/i, // Hurd/Linux
- /(gnu)\s?([\w\.]*)/i // GNU
- ], [NAME, VERSION], [
-
- /(cros)\s[\w]+\s([\w\.]+\w)/i // Chromium OS
- ], [[NAME, 'Chromium OS'], VERSION],[
-
- // Solaris
- /(sunos)\s?([\w\.\d]*)/i // Solaris
- ], [[NAME, 'Solaris'], VERSION], [
-
- // BSD based
- /\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]*)/i // FreeBSD/NetBSD/OpenBSD/PC-BSD/DragonFly
- ], [NAME, VERSION],[
-
- /(haiku)\s(\w+)/i // Haiku
- ], [NAME, VERSION],[
-
- /cfnetwork\/.+darwin/i,
- /ip[honead]{2,4}(?:.*os\s([\w]+)\slike\smac|;\sopera)/i // iOS
- ], [[VERSION, /_/g, '.'], [NAME, 'iOS']], [
-
- /(mac\sos\sx)\s?([\w\s\.]*)/i,
- /(macintosh|mac(?=_powerpc)\s)/i // Mac OS
- ], [[NAME, 'Mac OS'], [VERSION, /_/g, '.']], [
-
- // Other
- /((?:open)?solaris)[\/\s-]?([\w\.]*)/i, // Solaris
- /(aix)\s((\d)(?=\.|\)|\s)[\w\.])*/i, // AIX
- /(plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos|openvms|fuchsia)/i,
- // Plan9/Minix/BeOS/OS2/AmigaOS/MorphOS/RISCOS/OpenVMS/Fuchsia
- /(unix)\s?([\w\.]*)/i // UNIX
- ], [NAME, VERSION]
- ]
- };
-
-
- /////////////////
- // Constructor
- ////////////////
- var UAParser = function (uastring, extensions) {
-
- if (typeof uastring === 'object') {
- extensions = uastring;
- uastring = undefined$1;
- }
-
- if (!(this instanceof UAParser)) {
- return new UAParser(uastring, extensions).getResult();
- }
-
- var ua = uastring || ((window && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY);
- var rgxmap = extensions ? util.extend(regexes, extensions) : regexes;
-
- this.getBrowser = function () {
- var browser = { name: undefined$1, version: undefined$1 };
- mapper.rgx.call(browser, ua, rgxmap.browser);
- browser.major = util.major(browser.version); // deprecated
- return browser;
- };
- this.getCPU = function () {
- var cpu = { architecture: undefined$1 };
- mapper.rgx.call(cpu, ua, rgxmap.cpu);
- return cpu;
- };
- this.getDevice = function () {
- var device = { vendor: undefined$1, model: undefined$1, type: undefined$1 };
- mapper.rgx.call(device, ua, rgxmap.device);
- return device;
- };
- this.getEngine = function () {
- var engine = { name: undefined$1, version: undefined$1 };
- mapper.rgx.call(engine, ua, rgxmap.engine);
- return engine;
- };
- this.getOS = function () {
- var os = { name: undefined$1, version: undefined$1 };
- mapper.rgx.call(os, ua, rgxmap.os);
- return os;
- };
- this.getResult = function () {
- return {
- ua : this.getUA(),
- browser : this.getBrowser(),
- engine : this.getEngine(),
- os : this.getOS(),
- device : this.getDevice(),
- cpu : this.getCPU()
- };
- };
- this.getUA = function () {
- return ua;
- };
- this.setUA = function (uastring) {
- ua = uastring;
- return this;
- };
- return this;
- };
-
- UAParser.VERSION = LIBVERSION;
- UAParser.BROWSER = {
- NAME : NAME,
- MAJOR : MAJOR, // deprecated
- VERSION : VERSION
- };
- UAParser.CPU = {
- ARCHITECTURE : ARCHITECTURE
- };
- UAParser.DEVICE = {
- MODEL : MODEL,
- VENDOR : VENDOR,
- TYPE : TYPE,
- CONSOLE : CONSOLE,
- MOBILE : MOBILE,
- SMARTTV : SMARTTV,
- TABLET : TABLET,
- WEARABLE: WEARABLE,
- EMBEDDED: EMBEDDED
- };
- UAParser.ENGINE = {
- NAME : NAME,
- VERSION : VERSION
- };
- UAParser.OS = {
- NAME : NAME,
- VERSION : VERSION
- };
-
- ///////////
- // Export
- //////////
-
-
- // check js environment
- {
- // nodejs env
- if ( module.exports) {
- exports = module.exports = UAParser;
- }
- exports.UAParser = UAParser;
- }
-
- // jQuery/Zepto specific (optional)
- // Note:
- // In AMD env the global scope should be kept clean, but jQuery is an exception.
- // jQuery always exports to global scope, unless jQuery.noConflict(true) is used,
- // and we should catch that.
- var $ = window && (window.jQuery || window.Zepto);
- if ($ && !$.ua) {
- var parser = new UAParser();
- $.ua = parser.getResult();
- $.ua.get = function () {
- return parser.getUA();
- };
- $.ua.set = function (uastring) {
- parser.setUA(uastring);
- var result = parser.getResult();
- for (var prop in result) {
- $.ua[prop] = result[prop];
- }
- };
- }
-
- })(typeof window === 'object' ? window : commonjsGlobal);
- });
- var uaParser_1 = uaParser.UAParser;
-
- var UNKNOWN = 'Unknown';
-
- var PLATFORM_MAP = {
- 'Mac OS': 'Mac OS X'
- };
-
- /**
- * Convert from UAParser platform name to what we expect.
- */
- function convertPlatformName(name) {
- return PLATFORM_MAP[name] || name;
- }
-
- /**
- * Get the version number in parts. This is very naive. We actually get major
- * version as a part of UAParser already, which is generally good enough, but
- * let's get the minor just in case.
- */
- function getBrowserVersion(version) {
- if (!version) {
- return {
- major: '',
- minor: ''
- };
- }
- var parts = version.split('.');
- return {
- major: parts[0],
- minor: parts[1]
- };
- }
-
- /**
- * Get the UA data fom UAParser and then convert it to the format we're
- * expecting for our APIS.
- */
- var parser = new uaParser();
- var results = parser.getResult();
-
- // Do some conversion first.
- var browserVersionData = getBrowserVersion(results.browser.version);
- var uaData = {
- browserArchitecture: results.cpu.architecture || UNKNOWN,
- browserFullVersion: results.browser.version || UNKNOWN,
- browserMinorVersion: browserVersionData.minor || UNKNOWN,
- browserName: results.browser.name || UNKNOWN,
- browserVersion: results.browser.major || UNKNOWN,
- deviceName: results.device.model || UNKNOWN,
- engineName: results.engine.name || UNKNOWN,
- engineVersion: results.engine.version || UNKNOWN,
- platformArchitecture: results.cpu.architecture || UNKNOWN,
- platformName: convertPlatformName(results.os.name) || UNKNOWN,
- platformVersion: results.os.version || UNKNOWN,
- platformFullVersion: results.os.version || UNKNOWN
- };
-
- var UserAgentData = uaData;
-
- var componentRegex = /\./;
- var orRegex = /\|\|/;
- var rangeRegex = /\s+\-\s+/;
- var modifierRegex = /^(<=|<|=|>=|~>|~|>|)?\s*(.+)/;
- var numericRegex = /^(\d*)(.*)/;
-
- /**
- * Splits input `range` on "||" and returns true if any subrange matches
- * `version`.
- *
- * @param {string} range
- * @param {string} version
- * @returns {boolean}
- */
- function checkOrExpression(range, version) {
- var expressions = range.split(orRegex);
-
- if (expressions.length > 1) {
- return expressions.some(function (range) {
- return VersionRange.contains(range, version);
- });
- } else {
- range = expressions[0].trim();
- return checkRangeExpression(range, version);
- }
- }
-
- /**
- * Splits input `range` on " - " (the surrounding whitespace is required) and
- * returns true if version falls between the two operands.
- *
- * @param {string} range
- * @param {string} version
- * @returns {boolean}
- */
- function checkRangeExpression(range, version) {
- var expressions = range.split(rangeRegex);
-
- !(expressions.length > 0 && expressions.length <= 2) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'the "-" operator expects exactly 2 operands') : invariant_1(false) : void 0;
-
- if (expressions.length === 1) {
- return checkSimpleExpression(expressions[0], version);
- } else {
- var startVersion = expressions[0],
- endVersion = expressions[1];
-
- !(isSimpleVersion(startVersion) && isSimpleVersion(endVersion)) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'operands to the "-" operator must be simple (no modifiers)') : invariant_1(false) : void 0;
-
- return checkSimpleExpression('>=' + startVersion, version) && checkSimpleExpression('<=' + endVersion, version);
- }
- }
-
- /**
- * Checks if `range` matches `version`. `range` should be a "simple" range (ie.
- * not a compound range using the " - " or "||" operators).
- *
- * @param {string} range
- * @param {string} version
- * @returns {boolean}
- */
- function checkSimpleExpression(range, version) {
- range = range.trim();
- if (range === '') {
- return true;
- }
-
- var versionComponents = version.split(componentRegex);
-
- var _getModifierAndCompon = getModifierAndComponents(range),
- modifier = _getModifierAndCompon.modifier,
- rangeComponents = _getModifierAndCompon.rangeComponents;
-
- switch (modifier) {
- case '<':
- return checkLessThan(versionComponents, rangeComponents);
- case '<=':
- return checkLessThanOrEqual(versionComponents, rangeComponents);
- case '>=':
- return checkGreaterThanOrEqual(versionComponents, rangeComponents);
- case '>':
- return checkGreaterThan(versionComponents, rangeComponents);
- case '~':
- case '~>':
- return checkApproximateVersion(versionComponents, rangeComponents);
- default:
- return checkEqual(versionComponents, rangeComponents);
- }
- }
-
- /**
- * Checks whether `a` is less than `b`.
- *
- * @param {array<string>} a
- * @param {array<string>} b
- * @returns {boolean}
- */
- function checkLessThan(a, b) {
- return compareComponents(a, b) === -1;
- }
-
- /**
- * Checks whether `a` is less than or equal to `b`.
- *
- * @param {array<string>} a
- * @param {array<string>} b
- * @returns {boolean}
- */
- function checkLessThanOrEqual(a, b) {
- var result = compareComponents(a, b);
- return result === -1 || result === 0;
- }
-
- /**
- * Checks whether `a` is equal to `b`.
- *
- * @param {array<string>} a
- * @param {array<string>} b
- * @returns {boolean}
- */
- function checkEqual(a, b) {
- return compareComponents(a, b) === 0;
- }
-
- /**
- * Checks whether `a` is greater than or equal to `b`.
- *
- * @param {array<string>} a
- * @param {array<string>} b
- * @returns {boolean}
- */
- function checkGreaterThanOrEqual(a, b) {
- var result = compareComponents(a, b);
- return result === 1 || result === 0;
- }
-
- /**
- * Checks whether `a` is greater than `b`.
- *
- * @param {array<string>} a
- * @param {array<string>} b
- * @returns {boolean}
- */
- function checkGreaterThan(a, b) {
- return compareComponents(a, b) === 1;
- }
-
- /**
- * Checks whether `a` is "reasonably close" to `b` (as described in
- * https://www.npmjs.org/doc/misc/semver.html). For example, if `b` is "1.3.1"
- * then "reasonably close" is defined as ">= 1.3.1 and < 1.4".
- *
- * @param {array<string>} a
- * @param {array<string>} b
- * @returns {boolean}
- */
- function checkApproximateVersion(a, b) {
- var lowerBound = b.slice();
- var upperBound = b.slice();
-
- if (upperBound.length > 1) {
- upperBound.pop();
- }
- var lastIndex = upperBound.length - 1;
- var numeric = parseInt(upperBound[lastIndex], 10);
- if (isNumber(numeric)) {
- upperBound[lastIndex] = numeric + 1 + '';
- }
-
- return checkGreaterThanOrEqual(a, lowerBound) && checkLessThan(a, upperBound);
- }
-
- /**
- * Extracts the optional modifier (<, <=, =, >=, >, ~, ~>) and version
- * components from `range`.
- *
- * For example, given `range` ">= 1.2.3" returns an object with a `modifier` of
- * `">="` and `components` of `[1, 2, 3]`.
- *
- * @param {string} range
- * @returns {object}
- */
- function getModifierAndComponents(range) {
- var rangeComponents = range.split(componentRegex);
- var matches = rangeComponents[0].match(modifierRegex);
- !matches ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'expected regex to match but it did not') : invariant_1(false) : void 0;
-
- return {
- modifier: matches[1],
- rangeComponents: [matches[2]].concat(rangeComponents.slice(1))
- };
- }
-
- /**
- * Determines if `number` is a number.
- *
- * @param {mixed} number
- * @returns {boolean}
- */
- function isNumber(number) {
- return !isNaN(number) && isFinite(number);
- }
-
- /**
- * Tests whether `range` is a "simple" version number without any modifiers
- * (">", "~" etc).
- *
- * @param {string} range
- * @returns {boolean}
- */
- function isSimpleVersion(range) {
- return !getModifierAndComponents(range).modifier;
- }
-
- /**
- * Zero-pads array `array` until it is at least `length` long.
- *
- * @param {array} array
- * @param {number} length
- */
- function zeroPad(array, length) {
- for (var i = array.length; i < length; i++) {
- array[i] = '0';
- }
- }
-
- /**
- * Normalizes `a` and `b` in preparation for comparison by doing the following:
- *
- * - zero-pads `a` and `b`
- * - marks any "x", "X" or "*" component in `b` as equivalent by zero-ing it out
- * in both `a` and `b`
- * - marks any final "*" component in `b` as a greedy wildcard by zero-ing it
- * and all of its successors in `a`
- *
- * @param {array<string>} a
- * @param {array<string>} b
- * @returns {array<array<string>>}
- */
- function normalizeVersions(a, b) {
- a = a.slice();
- b = b.slice();
-
- zeroPad(a, b.length);
-
- // mark "x" and "*" components as equal
- for (var i = 0; i < b.length; i++) {
- var matches = b[i].match(/^[x*]$/i);
- if (matches) {
- b[i] = a[i] = '0';
-
- // final "*" greedily zeros all remaining components
- if (matches[0] === '*' && i === b.length - 1) {
- for (var j = i; j < a.length; j++) {
- a[j] = '0';
- }
- }
- }
- }
-
- zeroPad(b, a.length);
-
- return [a, b];
- }
-
- /**
- * Returns the numerical -- not the lexicographical -- ordering of `a` and `b`.
- *
- * For example, `10-alpha` is greater than `2-beta`.
- *
- * @param {string} a
- * @param {string} b
- * @returns {number} -1, 0 or 1 to indicate whether `a` is less than, equal to,
- * or greater than `b`, respectively
- */
- function compareNumeric(a, b) {
- var aPrefix = a.match(numericRegex)[1];
- var bPrefix = b.match(numericRegex)[1];
- var aNumeric = parseInt(aPrefix, 10);
- var bNumeric = parseInt(bPrefix, 10);
-
- if (isNumber(aNumeric) && isNumber(bNumeric) && aNumeric !== bNumeric) {
- return compare(aNumeric, bNumeric);
- } else {
- return compare(a, b);
- }
- }
-
- /**
- * Returns the ordering of `a` and `b`.
- *
- * @param {string|number} a
- * @param {string|number} b
- * @returns {number} -1, 0 or 1 to indicate whether `a` is less than, equal to,
- * or greater than `b`, respectively
- */
- function compare(a, b) {
- !(typeof a === typeof b) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, '"a" and "b" must be of the same type') : invariant_1(false) : void 0;
-
- if (a > b) {
- return 1;
- } else if (a < b) {
- return -1;
- } else {
- return 0;
- }
- }
-
- /**
- * Compares arrays of version components.
- *
- * @param {array<string>} a
- * @param {array<string>} b
- * @returns {number} -1, 0 or 1 to indicate whether `a` is less than, equal to,
- * or greater than `b`, respectively
- */
- function compareComponents(a, b) {
- var _normalizeVersions = normalizeVersions(a, b),
- aNormalized = _normalizeVersions[0],
- bNormalized = _normalizeVersions[1];
-
- for (var i = 0; i < bNormalized.length; i++) {
- var result = compareNumeric(aNormalized[i], bNormalized[i]);
- if (result) {
- return result;
- }
- }
-
- return 0;
- }
-
- var VersionRange = {
- /**
- * Checks whether `version` satisfies the `range` specification.
- *
- * We support a subset of the expressions defined in
- * https://www.npmjs.org/doc/misc/semver.html:
- *
- * version Must match version exactly
- * =version Same as just version
- * >version Must be greater than version
- * >=version Must be greater than or equal to version
- * <version Must be less than version
- * <=version Must be less than or equal to version
- * ~version Must be at least version, but less than the next significant
- * revision above version:
- * "~1.2.3" is equivalent to ">= 1.2.3 and < 1.3"
- * ~>version Equivalent to ~version
- * 1.2.x Must match "1.2.x", where "x" is a wildcard that matches
- * anything
- * 1.2.* Similar to "1.2.x", but "*" in the trailing position is a
- * "greedy" wildcard, so will match any number of additional
- * components:
- * "1.2.*" will match "1.2.1", "1.2.1.1", "1.2.1.1.1" etc
- * * Any version
- * "" (Empty string) Same as *
- * v1 - v2 Equivalent to ">= v1 and <= v2"
- * r1 || r2 Passes if either r1 or r2 are satisfied
- *
- * @param {string} range
- * @param {string} version
- * @returns {boolean}
- */
- contains: function contains(range, version) {
- return checkOrExpression(range.trim(), version.trim());
- }
- };
-
- var VersionRange_1 = VersionRange;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- */
-
- var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
-
- /**
- * Executes the provided `callback` once for each enumerable own property in the
- * object and constructs a new object from the results. The `callback` is
- * invoked with three arguments:
- *
- * - the property value
- * - the property name
- * - the object being traversed
- *
- * Properties that are added after the call to `mapObject` will not be visited
- * by `callback`. If the values of existing properties are changed, the value
- * passed to `callback` will be the value at the time `mapObject` visits them.
- * Properties that are deleted before being visited are not visited.
- *
- * @grep function objectMap()
- * @grep function objMap()
- *
- * @param {?object} object
- * @param {function} callback
- * @param {*} context
- * @return {?object}
- */
- function mapObject(object, callback, context) {
- if (!object) {
- return null;
- }
- var result = {};
- for (var name in object) {
- if (hasOwnProperty$1.call(object, name)) {
- result[name] = callback.call(context, object[name], name, object);
- }
- }
- return result;
- }
-
- var mapObject_1 = mapObject;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- *
- * @typechecks static-only
- */
-
- /**
- * Memoizes the return value of a function that accepts one string argument.
- */
-
- function memoizeStringOnly(callback) {
- var cache = {};
- return function (string) {
- if (!cache.hasOwnProperty(string)) {
- cache[string] = callback.call(this, string);
- }
- return cache[string];
- };
- }
-
- var memoizeStringOnly_1 = memoizeStringOnly;
-
- /**
- * Checks to see whether `name` and `version` satisfy `query`.
- *
- * @param {string} name Name of the browser, device, engine or platform
- * @param {?string} version Version of the browser, engine or platform
- * @param {string} query Query of form "Name [range expression]"
- * @param {?function} normalizer Optional pre-processor for range expression
- * @return {boolean}
- */
- function compare$1(name, version, query, normalizer) {
- // check for exact match with no version
- if (name === query) {
- return true;
- }
-
- // check for non-matching names
- if (!query.startsWith(name)) {
- return false;
- }
-
- // full comparison with version
- var range = query.slice(name.length);
- if (version) {
- range = normalizer ? normalizer(range) : range;
- return VersionRange_1.contains(range, version);
- }
-
- return false;
- }
-
- /**
- * Normalizes `version` by stripping any "NT" prefix, but only on the Windows
- * platform.
- *
- * Mimics the stripping performed by the `UserAgentWindowsPlatform` PHP class.
- *
- * @param {string} version
- * @return {string}
- */
- function normalizePlatformVersion(version) {
- if (UserAgentData.platformName === 'Windows') {
- return version.replace(/^\s*NT/, '');
- }
-
- return version;
- }
-
- /**
- * Provides client-side access to the authoritative PHP-generated User Agent
- * information supplied by the server.
- */
- var UserAgent = {
- /**
- * Check if the User Agent browser matches `query`.
- *
- * `query` should be a string like "Chrome" or "Chrome > 33".
- *
- * Valid browser names include:
- *
- * - ACCESS NetFront
- * - AOL
- * - Amazon Silk
- * - Android
- * - BlackBerry
- * - BlackBerry PlayBook
- * - Chrome
- * - Chrome for iOS
- * - Chrome frame
- * - Facebook PHP SDK
- * - Facebook for iOS
- * - Firefox
- * - IE
- * - IE Mobile
- * - Mobile Safari
- * - Motorola Internet Browser
- * - Nokia
- * - Openwave Mobile Browser
- * - Opera
- * - Opera Mini
- * - Opera Mobile
- * - Safari
- * - UIWebView
- * - Unknown
- * - webOS
- * - etc...
- *
- * An authoritative list can be found in the PHP `BrowserDetector` class and
- * related classes in the same file (see calls to `new UserAgentBrowser` here:
- * https://fburl.com/50728104).
- *
- * @note Function results are memoized
- *
- * @param {string} query Query of the form "Name [range expression]"
- * @return {boolean}
- */
- isBrowser: function isBrowser(query) {
- return compare$1(UserAgentData.browserName, UserAgentData.browserFullVersion, query);
- },
-
-
- /**
- * Check if the User Agent browser uses a 32 or 64 bit architecture.
- *
- * @note Function results are memoized
- *
- * @param {string} query Query of the form "32" or "64".
- * @return {boolean}
- */
- isBrowserArchitecture: function isBrowserArchitecture(query) {
- return compare$1(UserAgentData.browserArchitecture, null, query);
- },
-
-
- /**
- * Check if the User Agent device matches `query`.
- *
- * `query` should be a string like "iPhone" or "iPad".
- *
- * Valid device names include:
- *
- * - Kindle
- * - Kindle Fire
- * - Unknown
- * - iPad
- * - iPhone
- * - iPod
- * - etc...
- *
- * An authoritative list can be found in the PHP `DeviceDetector` class and
- * related classes in the same file (see calls to `new UserAgentDevice` here:
- * https://fburl.com/50728332).
- *
- * @note Function results are memoized
- *
- * @param {string} query Query of the form "Name"
- * @return {boolean}
- */
- isDevice: function isDevice(query) {
- return compare$1(UserAgentData.deviceName, null, query);
- },
-
-
- /**
- * Check if the User Agent rendering engine matches `query`.
- *
- * `query` should be a string like "WebKit" or "WebKit >= 537".
- *
- * Valid engine names include:
- *
- * - Gecko
- * - Presto
- * - Trident
- * - WebKit
- * - etc...
- *
- * An authoritative list can be found in the PHP `RenderingEngineDetector`
- * class related classes in the same file (see calls to `new
- * UserAgentRenderingEngine` here: https://fburl.com/50728617).
- *
- * @note Function results are memoized
- *
- * @param {string} query Query of the form "Name [range expression]"
- * @return {boolean}
- */
- isEngine: function isEngine(query) {
- return compare$1(UserAgentData.engineName, UserAgentData.engineVersion, query);
- },
-
-
- /**
- * Check if the User Agent platform matches `query`.
- *
- * `query` should be a string like "Windows" or "iOS 5 - 6".
- *
- * Valid platform names include:
- *
- * - Android
- * - BlackBerry OS
- * - Java ME
- * - Linux
- * - Mac OS X
- * - Mac OS X Calendar
- * - Mac OS X Internet Account
- * - Symbian
- * - SymbianOS
- * - Windows
- * - Windows Mobile
- * - Windows Phone
- * - iOS
- * - iOS Facebook Integration Account
- * - iOS Facebook Social Sharing UI
- * - webOS
- * - Chrome OS
- * - etc...
- *
- * An authoritative list can be found in the PHP `PlatformDetector` class and
- * related classes in the same file (see calls to `new UserAgentPlatform`
- * here: https://fburl.com/50729226).
- *
- * @note Function results are memoized
- *
- * @param {string} query Query of the form "Name [range expression]"
- * @return {boolean}
- */
- isPlatform: function isPlatform(query) {
- return compare$1(UserAgentData.platformName, UserAgentData.platformFullVersion, query, normalizePlatformVersion);
- },
-
-
- /**
- * Check if the User Agent platform is a 32 or 64 bit architecture.
- *
- * @note Function results are memoized
- *
- * @param {string} query Query of the form "32" or "64".
- * @return {boolean}
- */
- isPlatformArchitecture: function isPlatformArchitecture(query) {
- return compare$1(UserAgentData.platformArchitecture, null, query);
- }
- };
-
- var UserAgent_1 = mapObject_1(UserAgent, memoizeStringOnly_1);
-
- function _classCallCheck$9(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- function _possibleConstructorReturn$6(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
- function _inherits$6(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-
-
-
-
-
-
- // In IE, spans with <br> tags render as two newlines. By rendering a span
- // with only a newline character, we can be sure to render a single line.
- var useNewlineChar = UserAgent_1.isBrowser('IE <= 11');
-
- /**
- * Check whether the node should be considered a newline.
- */
- function isNewline(node) {
- return useNewlineChar ? node.textContent === '\n' : node.tagName === 'BR';
- }
-
- /**
- * Placeholder elements for empty text content.
- *
- * What is this `data-text` attribute, anyway? It turns out that we need to
- * put an attribute on the lowest-level text node in order to preserve correct
- * spellcheck handling. If the <span> is naked, Chrome and Safari may do
- * bizarre things to do the DOM -- split text nodes, create extra spans, etc.
- * If the <span> has an attribute, this appears not to happen.
- * See http://jsfiddle.net/9khdavod/ for the failure case, and
- * http://jsfiddle.net/7pg143f7/ for the fixed case.
- */
- var NEWLINE_A = useNewlineChar ? React.createElement(
- 'span',
- { key: 'A', 'data-text': 'true' },
- '\n'
- ) : React.createElement('br', { key: 'A', 'data-text': 'true' });
-
- var NEWLINE_B = useNewlineChar ? React.createElement(
- 'span',
- { key: 'B', 'data-text': 'true' },
- '\n'
- ) : React.createElement('br', { key: 'B', 'data-text': 'true' });
-
- /**
- * The lowest-level component in a `DraftEditor`, the text node component
- * replaces the default React text node implementation. This allows us to
- * perform custom handling of newline behavior and avoid re-rendering text
- * nodes with DOM state that already matches the expectations of our immutable
- * editor state.
- */
- var DraftEditorTextNode = function (_React$Component) {
- _inherits$6(DraftEditorTextNode, _React$Component);
-
- function DraftEditorTextNode(props) {
- _classCallCheck$9(this, DraftEditorTextNode);
-
- // By flipping this flag, we also keep flipping keys which forces
- // React to remount this node every time it rerenders.
- var _this = _possibleConstructorReturn$6(this, _React$Component.call(this, props));
-
- _this._forceFlag = false;
- return _this;
- }
-
- DraftEditorTextNode.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
- var node = ReactDOM.findDOMNode(this);
- var shouldBeNewline = nextProps.children === '';
- !(node instanceof Element) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'node is not an Element') : invariant_1(false) : void 0;
- if (shouldBeNewline) {
- return !isNewline(node);
- }
- return node.textContent !== nextProps.children;
- };
-
- DraftEditorTextNode.prototype.componentDidMount = function componentDidMount() {
- this._forceFlag = !this._forceFlag;
- };
-
- DraftEditorTextNode.prototype.componentDidUpdate = function componentDidUpdate() {
- this._forceFlag = !this._forceFlag;
- };
-
- DraftEditorTextNode.prototype.render = function render() {
- if (this.props.children === '') {
- return this._forceFlag ? NEWLINE_A : NEWLINE_B;
- }
- return React.createElement(
- 'span',
- { key: this._forceFlag ? 'A' : 'B', 'data-text': 'true' },
- this.props.children
- );
- };
-
- return DraftEditorTextNode;
- }(React.Component);
-
- var DraftEditorTextNode_react = DraftEditorTextNode;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule DraftJsDebugLogging
- */
-
- var DraftJsDebugLogging = {
- logSelectionStateFailure: function logSelectionStateFailure() {
- return null;
- }
- };
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
-
- /**
- * @param {*} object The object to check.
- * @return {boolean} Whether or not the object is a DOM node.
- */
- function isNode(object) {
- var doc = object ? object.ownerDocument || object : document;
- var defaultView = doc.defaultView || window;
- return !!(object && (typeof defaultView.Node === 'function' ? object instanceof defaultView.Node : typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string'));
- }
-
- var isNode_1 = isNode;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
-
-
-
- /**
- * @param {*} object The object to check.
- * @return {boolean} Whether or not the object is a DOM text node.
- */
- function isTextNode(object) {
- return isNode_1(object) && object.nodeType == 3;
- }
-
- var isTextNode_1 = isTextNode;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- *
- */
-
-
-
- /*eslint-disable no-bitwise */
-
- /**
- * Checks if a given DOM node contains or is another DOM node.
- */
- function containsNode(outerNode, innerNode) {
- if (!outerNode || !innerNode) {
- return false;
- } else if (outerNode === innerNode) {
- return true;
- } else if (isTextNode_1(outerNode)) {
- return false;
- } else if (isTextNode_1(innerNode)) {
- return containsNode(outerNode, innerNode.parentNode);
- } else if ('contains' in outerNode) {
- return outerNode.contains(innerNode);
- } else if (outerNode.compareDocumentPosition) {
- return !!(outerNode.compareDocumentPosition(innerNode) & 16);
- } else {
- return false;
- }
- }
-
- var containsNode_1 = containsNode;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
-
- /* eslint-disable fb-www/typeof-undefined */
-
- /**
- * Same as document.activeElement but wraps in a try-catch block. In IE it is
- * not safe to call document.activeElement if there is nothing focused.
- *
- * The activeElement will be null only if the document or document body is not
- * yet defined.
- *
- * @param {?DOMDocument} doc Defaults to current document.
- * @return {?DOMElement}
- */
- function getActiveElement(doc) /*?DOMElement*/{
- doc = doc || (typeof document !== 'undefined' ? document : undefined);
- if (typeof doc === 'undefined') {
- return null;
- }
- try {
- return doc.activeElement || doc.body;
- } catch (e) {
- return doc.body;
- }
- }
-
- var getActiveElement_1 = getActiveElement;
-
- function getAnonymizedDOM(node, getNodeLabels) {
- if (!node) {
- return '[empty]';
- }
-
- var anonymized = anonymizeTextWithin(node, getNodeLabels);
- if (anonymized.nodeType === Node.TEXT_NODE) {
- return anonymized.textContent;
- }
-
- !(anonymized instanceof Element) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Node must be an Element if it is not a text node.') : invariant_1(false) : void 0;
- return anonymized.outerHTML;
- }
-
- function anonymizeTextWithin(node, getNodeLabels) {
- var labels = getNodeLabels !== undefined ? getNodeLabels(node) : [];
-
- if (node.nodeType === Node.TEXT_NODE) {
- var length = node.textContent.length;
- return document.createTextNode('[text ' + length + (labels.length ? ' | ' + labels.join(', ') : '') + ']');
- }
-
- var clone = node.cloneNode();
- if (clone.nodeType === 1 && labels.length) {
- clone.setAttribute('data-labels', labels.join(', '));
- }
- var childNodes = node.childNodes;
- for (var ii = 0; ii < childNodes.length; ii++) {
- clone.appendChild(anonymizeTextWithin(childNodes[ii], getNodeLabels));
- }
-
- return clone;
- }
-
- function getAnonymizedEditorDOM(node, getNodeLabels) {
- // grabbing the DOM content of the Draft editor
- var currentNode = node;
- while (currentNode) {
- if (currentNode instanceof Element && currentNode.hasAttribute('contenteditable')) {
- // found the Draft editor container
- return getAnonymizedDOM(currentNode, getNodeLabels);
- } else {
- currentNode = currentNode.parentNode;
- }
- }
- return 'Could not find contentEditable parent of node';
- }
-
- function getNodeLength(node) {
- return node.nodeValue === null ? node.childNodes.length : node.nodeValue.length;
- }
-
- /**
- * In modern non-IE browsers, we can support both forward and backward
- * selections.
- *
- * Note: IE10+ supports the Selection object, but it does not support
- * the `extend` method, which means that even in modern IE, it's not possible
- * to programatically create a backward selection. Thus, for all IE
- * versions, we use the old IE API to create our selections.
- */
- function setDraftEditorSelection(selectionState, node, blockKey, nodeStart, nodeEnd) {
- // It's possible that the editor has been removed from the DOM but
- // our selection code doesn't know it yet. Forcing selection in
- // this case may lead to errors, so just bail now.
- if (!containsNode_1(document.documentElement, node)) {
- return;
- }
-
- var selection = commonjsGlobal.getSelection();
- var anchorKey = selectionState.getAnchorKey();
- var anchorOffset = selectionState.getAnchorOffset();
- var focusKey = selectionState.getFocusKey();
- var focusOffset = selectionState.getFocusOffset();
- var isBackward = selectionState.getIsBackward();
-
- // IE doesn't support backward selection. Swap key/offset pairs.
- if (!selection.extend && isBackward) {
- var tempKey = anchorKey;
- var tempOffset = anchorOffset;
- anchorKey = focusKey;
- anchorOffset = focusOffset;
- focusKey = tempKey;
- focusOffset = tempOffset;
- isBackward = false;
- }
-
- var hasAnchor = anchorKey === blockKey && nodeStart <= anchorOffset && nodeEnd >= anchorOffset;
-
- var hasFocus = focusKey === blockKey && nodeStart <= focusOffset && nodeEnd >= focusOffset;
-
- // If the selection is entirely bound within this node, set the selection
- // and be done.
- if (hasAnchor && hasFocus) {
- selection.removeAllRanges();
- addPointToSelection(selection, node, anchorOffset - nodeStart, selectionState);
- addFocusToSelection(selection, node, focusOffset - nodeStart, selectionState);
- return;
- }
-
- if (!isBackward) {
- // If the anchor is within this node, set the range start.
- if (hasAnchor) {
- selection.removeAllRanges();
- addPointToSelection(selection, node, anchorOffset - nodeStart, selectionState);
- }
-
- // If the focus is within this node, we can assume that we have
- // already set the appropriate start range on the selection, and
- // can simply extend the selection.
- if (hasFocus) {
- addFocusToSelection(selection, node, focusOffset - nodeStart, selectionState);
- }
- } else {
- // If this node has the focus, set the selection range to be a
- // collapsed range beginning here. Later, when we encounter the anchor,
- // we'll use this information to extend the selection.
- if (hasFocus) {
- selection.removeAllRanges();
- addPointToSelection(selection, node, focusOffset - nodeStart, selectionState);
- }
-
- // If this node has the anchor, we may assume that the correct
- // focus information is already stored on the selection object.
- // We keep track of it, reset the selection range, and extend it
- // back to the focus point.
- if (hasAnchor) {
- var storedFocusNode = selection.focusNode;
- var storedFocusOffset = selection.focusOffset;
-
- selection.removeAllRanges();
- addPointToSelection(selection, node, anchorOffset - nodeStart, selectionState);
- addFocusToSelection(selection, storedFocusNode, storedFocusOffset, selectionState);
- }
- }
- }
-
- /**
- * Extend selection towards focus point.
- */
- function addFocusToSelection(selection, node, offset, selectionState) {
- var activeElement = getActiveElement_1();
- if (selection.extend && containsNode_1(activeElement, node)) {
- // If `extend` is called while another element has focus, an error is
- // thrown. We therefore disable `extend` if the active element is somewhere
- // other than the node we are selecting. This should only occur in Firefox,
- // since it is the only browser to support multiple selections.
- // See https://bugzilla.mozilla.org/show_bug.cgi?id=921444.
-
- // logging to catch bug that is being reported in t16250795
- if (offset > getNodeLength(node)) {
- // the call to 'selection.extend' is about to throw
- DraftJsDebugLogging.logSelectionStateFailure({
- anonymizedDom: getAnonymizedEditorDOM(node),
- extraParams: JSON.stringify({ offset: offset }),
- selectionState: JSON.stringify(selectionState.toJS())
- });
- }
-
- // logging to catch bug that is being reported in t18110632
- var nodeWasFocus = node === selection.focusNode;
- try {
- selection.extend(node, offset);
- } catch (e) {
- DraftJsDebugLogging.logSelectionStateFailure({
- anonymizedDom: getAnonymizedEditorDOM(node, function (n) {
- var labels = [];
- if (n === activeElement) {
- labels.push('active element');
- }
- if (n === selection.anchorNode) {
- labels.push('selection anchor node');
- }
- if (n === selection.focusNode) {
- labels.push('selection focus node');
- }
- return labels;
- }),
- extraParams: JSON.stringify({
- activeElementName: activeElement ? activeElement.nodeName : null,
- nodeIsFocus: node === selection.focusNode,
- nodeWasFocus: nodeWasFocus,
- selectionRangeCount: selection.rangeCount,
- selectionAnchorNodeName: selection.anchorNode ? selection.anchorNode.nodeName : null,
- selectionAnchorOffset: selection.anchorOffset,
- selectionFocusNodeName: selection.focusNode ? selection.focusNode.nodeName : null,
- selectionFocusOffset: selection.focusOffset,
- message: e ? '' + e : null,
- offset: offset
- }, null, 2),
- selectionState: JSON.stringify(selectionState.toJS(), null, 2)
- });
- // allow the error to be thrown -
- // better than continuing in a broken state
- throw e;
- }
- } else {
- // IE doesn't support extend. This will mean no backward selection.
- // Extract the existing selection range and add focus to it.
- // Additionally, clone the selection range. IE11 throws an
- // InvalidStateError when attempting to access selection properties
- // after the range is detached.
- var range = selection.getRangeAt(0);
- range.setEnd(node, offset);
- selection.addRange(range.cloneRange());
- }
- }
-
- function addPointToSelection(selection, node, offset, selectionState) {
- var range = document.createRange();
- // logging to catch bug that is being reported in t16250795
- if (offset > getNodeLength(node)) {
- // in this case we know that the call to 'range.setStart' is about to throw
- DraftJsDebugLogging.logSelectionStateFailure({
- anonymizedDom: getAnonymizedEditorDOM(node),
- extraParams: JSON.stringify({ offset: offset }),
- selectionState: JSON.stringify(selectionState.toJS())
- });
- }
- range.setStart(node, offset);
- selection.addRange(range);
- }
-
- var setDraftEditorSelection_1 = setDraftEditorSelection;
-
- function _classCallCheck$a(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- function _possibleConstructorReturn$7(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
- function _inherits$7(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-
-
-
-
-
-
-
- /**
- * All leaf nodes in the editor are spans with single text nodes. Leaf
- * elements are styled based on the merging of an optional custom style map
- * and a default style map.
- *
- * `DraftEditorLeaf` also provides a wrapper for calling into the imperative
- * DOM Selection API. In this way, top-level components can declaratively
- * maintain the selection state.
- */
- var DraftEditorLeaf = function (_React$Component) {
- _inherits$7(DraftEditorLeaf, _React$Component);
-
- function DraftEditorLeaf() {
- _classCallCheck$a(this, DraftEditorLeaf);
-
- return _possibleConstructorReturn$7(this, _React$Component.apply(this, arguments));
- }
-
- DraftEditorLeaf.prototype._setSelection = function _setSelection() {
- var selection = this.props.selection;
-
- // If selection state is irrelevant to the parent block, no-op.
-
- if (selection == null || !selection.getHasFocus()) {
- return;
- }
-
- var _props = this.props,
- block = _props.block,
- start = _props.start,
- text = _props.text;
-
- var blockKey = block.getKey();
- var end = start + text.length;
- if (!selection.hasEdgeWithin(blockKey, start, end)) {
- return;
- }
-
- // Determine the appropriate target node for selection. If the child
- // is not a text node, it is a <br /> spacer. In this case, use the
- // <span> itself as the selection target.
- var node = ReactDOM.findDOMNode(this);
- !node ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Missing node') : invariant_1(false) : void 0;
- var child = node.firstChild;
- !child ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Missing child') : invariant_1(false) : void 0;
- var targetNode = void 0;
-
- if (child.nodeType === Node.TEXT_NODE) {
- targetNode = child;
- } else if (child.tagName === 'BR') {
- targetNode = node;
- } else {
- targetNode = child.firstChild;
- !targetNode ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Missing targetNode') : invariant_1(false) : void 0;
- }
-
- setDraftEditorSelection_1(selection, targetNode, blockKey, start, end);
- };
- /**
- * By making individual leaf instances aware of their context within
- * the text of the editor, we can set our selection range more
- * easily than we could in the non-React world.
- *
- * Note that this depends on our maintaining tight control over the
- * DOM structure of the DraftEditor component. If leaves had multiple
- * text nodes, this would be harder.
- */
-
- DraftEditorLeaf.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
- var leafNode = ReactDOM.findDOMNode(this.leaf);
- !leafNode ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Missing leafNode') : invariant_1(false) : void 0;
- return leafNode.textContent !== nextProps.text || nextProps.styleSet !== this.props.styleSet || nextProps.forceSelection;
- };
-
- DraftEditorLeaf.prototype.componentDidUpdate = function componentDidUpdate() {
- this._setSelection();
- };
-
- DraftEditorLeaf.prototype.componentDidMount = function componentDidMount() {
- this._setSelection();
- };
-
- DraftEditorLeaf.prototype.render = function render() {
- var _this2 = this;
-
- var block = this.props.block;
- var text = this.props.text;
-
- // If the leaf is at the end of its block and ends in a soft newline, append
- // an extra line feed character. Browsers collapse trailing newline
- // characters, which leaves the cursor in the wrong place after a
- // shift+enter. The extra character repairs this.
-
- if (text.endsWith('\n') && this.props.isLast) {
- text += '\n';
- }
-
- var _props2 = this.props,
- customStyleMap = _props2.customStyleMap,
- customStyleFn = _props2.customStyleFn,
- offsetKey = _props2.offsetKey,
- styleSet = _props2.styleSet;
-
- var styleObj = styleSet.reduce(function (map, styleName) {
- var mergedStyles = {};
- var style = customStyleMap[styleName];
-
- if (style !== undefined && map.textDecoration !== style.textDecoration) {
- // .trim() is necessary for IE9/10/11 and Edge
- mergedStyles.textDecoration = [map.textDecoration, style.textDecoration].join(' ').trim();
- }
-
- return objectAssign(map, style, mergedStyles);
- }, {});
-
- if (customStyleFn) {
- var newStyles = customStyleFn(styleSet, block);
- styleObj = objectAssign(styleObj, newStyles);
- }
-
- return React.createElement(
- 'span',
- {
- 'data-offset-key': offsetKey,
- ref: function ref(_ref) {
- return _this2.leaf = _ref;
- },
- style: styleObj },
- React.createElement(
- DraftEditorTextNode_react,
- null,
- text
- )
- );
- };
-
- return DraftEditorLeaf;
- }(React.Component);
-
- var DraftEditorLeaf_react = DraftEditorLeaf;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule DraftOffsetKey
- * @format
- *
- */
-
- var KEY_DELIMITER = '-';
-
- var DraftOffsetKey = {
- encode: function encode(blockKey, decoratorKey, leafKey) {
- return blockKey + KEY_DELIMITER + decoratorKey + KEY_DELIMITER + leafKey;
- },
-
- decode: function decode(offsetKey) {
- var _offsetKey$split = offsetKey.split(KEY_DELIMITER),
- blockKey = _offsetKey$split[0],
- decoratorKey = _offsetKey$split[1],
- leafKey = _offsetKey$split[2];
-
- return {
- blockKey: blockKey,
- decoratorKey: parseInt(decoratorKey, 10),
- leafKey: parseInt(leafKey, 10)
- };
- }
- };
-
- var DraftOffsetKey_1 = DraftOffsetKey;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- */
-
- /**
- * @param {DOMElement} element
- * @param {DOMDocument} doc
- * @return {boolean}
- */
- function _isViewportScrollElement(element, doc) {
- return !!doc && (element === doc.documentElement || element === doc.body);
- }
-
- /**
- * Scroll Module. This class contains 4 simple static functions
- * to be used to access Element.scrollTop/scrollLeft properties.
- * To solve the inconsistencies between browsers when either
- * document.body or document.documentElement is supplied,
- * below logic will be used to alleviate the issue:
- *
- * 1. If 'element' is either 'document.body' or 'document.documentElement,
- * get whichever element's 'scroll{Top,Left}' is larger.
- * 2. If 'element' is either 'document.body' or 'document.documentElement',
- * set the 'scroll{Top,Left}' on both elements.
- */
-
- var Scroll = {
- /**
- * @param {DOMElement} element
- * @return {number}
- */
- getTop: function getTop(element) {
- var doc = element.ownerDocument;
- return _isViewportScrollElement(element, doc) ?
- // In practice, they will either both have the same value,
- // or one will be zero and the other will be the scroll position
- // of the viewport. So we can use `X || Y` instead of `Math.max(X, Y)`
- doc.body.scrollTop || doc.documentElement.scrollTop : element.scrollTop;
- },
-
- /**
- * @param {DOMElement} element
- * @param {number} newTop
- */
- setTop: function setTop(element, newTop) {
- var doc = element.ownerDocument;
- if (_isViewportScrollElement(element, doc)) {
- doc.body.scrollTop = doc.documentElement.scrollTop = newTop;
- } else {
- element.scrollTop = newTop;
- }
- },
-
- /**
- * @param {DOMElement} element
- * @return {number}
- */
- getLeft: function getLeft(element) {
- var doc = element.ownerDocument;
- return _isViewportScrollElement(element, doc) ? doc.body.scrollLeft || doc.documentElement.scrollLeft : element.scrollLeft;
- },
-
- /**
- * @param {DOMElement} element
- * @param {number} newLeft
- */
- setLeft: function setLeft(element, newLeft) {
- var doc = element.ownerDocument;
- if (_isViewportScrollElement(element, doc)) {
- doc.body.scrollLeft = doc.documentElement.scrollLeft = newLeft;
- } else {
- element.scrollLeft = newLeft;
- }
- }
- };
-
- var Scroll_1 = Scroll;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
-
- var _hyphenPattern = /-(.)/g;
-
- /**
- * Camelcases a hyphenated string, for example:
- *
- * > camelize('background-color')
- * < "backgroundColor"
- *
- * @param {string} string
- * @return {string}
- */
- function camelize(string) {
- return string.replace(_hyphenPattern, function (_, character) {
- return character.toUpperCase();
- });
- }
-
- var camelize_1 = camelize;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
-
- var _uppercasePattern = /([A-Z])/g;
-
- /**
- * Hyphenates a camelcased string, for example:
- *
- * > hyphenate('backgroundColor')
- * < "background-color"
- *
- * For CSS style names, use `hyphenateStyleName` instead which works properly
- * with all vendor prefixes, including `ms`.
- *
- * @param {string} string
- * @return {string}
- */
- function hyphenate(string) {
- return string.replace(_uppercasePattern, '-$1').toLowerCase();
- }
-
- var hyphenate_1 = hyphenate;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
-
-
-
-
- function asString(value) /*?string*/{
- return value == null ? value : String(value);
- }
-
- function getStyleProperty( /*DOMNode*/node, /*string*/name) /*?string*/{
- var computedStyle = void 0;
-
- // W3C Standard
- if (window.getComputedStyle) {
- // In certain cases such as within an iframe in FF3, this returns null.
- computedStyle = window.getComputedStyle(node, null);
- if (computedStyle) {
- return asString(computedStyle.getPropertyValue(hyphenate_1(name)));
- }
- }
- // Safari
- if (document.defaultView && document.defaultView.getComputedStyle) {
- computedStyle = document.defaultView.getComputedStyle(node, null);
- // A Safari bug causes this to return null for `display: none` elements.
- if (computedStyle) {
- return asString(computedStyle.getPropertyValue(hyphenate_1(name)));
- }
- if (name === 'display') {
- return 'none';
- }
- }
- // Internet Explorer
- if (node.currentStyle) {
- if (name === 'float') {
- return asString(node.currentStyle.cssFloat || node.currentStyle.styleFloat);
- }
- return asString(node.currentStyle[camelize_1(name)]);
- }
- return asString(node.style && node.style[camelize_1(name)]);
- }
-
- var getStyleProperty_1 = getStyleProperty;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
-
-
-
- /**
- * @param {DOMNode} element [description]
- * @param {string} name Overflow style property name.
- * @return {boolean} True if the supplied ndoe is scrollable.
- */
- function _isNodeScrollable(element, name) {
- var overflow = Style.get(element, name);
- return overflow === 'auto' || overflow === 'scroll';
- }
-
- /**
- * Utilities for querying and mutating style properties.
- */
- var Style = {
- /**
- * Gets the style property for the supplied node. This will return either the
- * computed style, if available, or the declared style.
- *
- * @param {DOMNode} node
- * @param {string} name Style property name.
- * @return {?string} Style property value.
- */
- get: getStyleProperty_1,
-
- /**
- * Determines the nearest ancestor of a node that is scrollable.
- *
- * NOTE: This can be expensive if used repeatedly or on a node nested deeply.
- *
- * @param {?DOMNode} node Node from which to start searching.
- * @return {?DOMWindow|DOMElement} Scroll parent of the supplied node.
- */
- getScrollParent: function getScrollParent(node) {
- if (!node) {
- return null;
- }
- var ownerDocument = node.ownerDocument;
- while (node && node !== ownerDocument.body) {
- if (_isNodeScrollable(node, 'overflow') || _isNodeScrollable(node, 'overflowY') || _isNodeScrollable(node, 'overflowX')) {
- return node;
- }
- node = node.parentNode;
- }
- return ownerDocument.defaultView || ownerDocument.parentWindow;
- }
-
- };
-
- var Style_1 = Style;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
-
-
-
- /**
- * Gets an element's bounding rect in pixels relative to the viewport.
- *
- * @param {DOMElement} elem
- * @return {object}
- */
- function getElementRect(elem) {
- var docElem = elem.ownerDocument.documentElement;
-
- // FF 2, Safari 3 and Opera 9.5- do not support getBoundingClientRect().
- // IE9- will throw if the element is not in the document.
- if (!('getBoundingClientRect' in elem) || !containsNode_1(docElem, elem)) {
- return {
- left: 0,
- right: 0,
- top: 0,
- bottom: 0
- };
- }
-
- // Subtracts clientTop/Left because IE8- added a 2px border to the
- // <html> element (see http://fburl.com/1493213). IE 7 in
- // Quicksmode does not report clientLeft/clientTop so there
- // will be an unaccounted offset of 2px when in quirksmode
- var rect = elem.getBoundingClientRect();
-
- return {
- left: Math.round(rect.left) - docElem.clientLeft,
- right: Math.round(rect.right) - docElem.clientLeft,
- top: Math.round(rect.top) - docElem.clientTop,
- bottom: Math.round(rect.bottom) - docElem.clientTop
- };
- }
-
- var getElementRect_1 = getElementRect;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
-
-
-
- /**
- * Gets an element's position in pixels relative to the viewport. The returned
- * object represents the position of the element's top left corner.
- *
- * @param {DOMElement} element
- * @return {object}
- */
- function getElementPosition(element) {
- var rect = getElementRect_1(element);
- return {
- x: rect.left,
- y: rect.top,
- width: rect.right - rect.left,
- height: rect.bottom - rect.top
- };
- }
-
- var getElementPosition_1 = getElementPosition;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
-
- var isWebkit = typeof navigator !== 'undefined' && navigator.userAgent.indexOf('AppleWebKit') > -1;
-
- /**
- * Gets the element with the document scroll properties such as `scrollLeft` and
- * `scrollHeight`. This may differ across different browsers.
- *
- * NOTE: The return value can be null if the DOM is not yet ready.
- *
- * @param {?DOMDocument} doc Defaults to current document.
- * @return {?DOMElement}
- */
- function getDocumentScrollElement(doc) {
- doc = doc || document;
- if (doc.scrollingElement) {
- return doc.scrollingElement;
- }
- return !isWebkit && doc.compatMode === 'CSS1Compat' ? doc.documentElement : doc.body;
- }
-
- var getDocumentScrollElement_1 = getDocumentScrollElement;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
-
- /**
- * Gets the scroll position of the supplied element or window.
- *
- * The return values are unbounded, unlike `getScrollPosition`. This means they
- * may be negative or exceed the element boundaries (which is possible using
- * inertial scrolling).
- *
- * @param {DOMWindow|DOMElement} scrollable
- * @return {object} Map with `x` and `y` keys.
- */
-
- function getUnboundedScrollPosition(scrollable) {
- if (scrollable.Window && scrollable instanceof scrollable.Window) {
- return {
- x: scrollable.pageXOffset || scrollable.document.documentElement.scrollLeft,
- y: scrollable.pageYOffset || scrollable.document.documentElement.scrollTop
- };
- }
- return {
- x: scrollable.scrollLeft,
- y: scrollable.scrollTop
- };
- }
-
- var getUnboundedScrollPosition_1 = getUnboundedScrollPosition;
-
- /**
- * Gets the scroll position of the supplied element or window.
- *
- * The return values are bounded. This means that if the scroll position is
- * negative or exceeds the element boundaries (which is possible using inertial
- * scrolling), you will get zero or the maximum scroll position, respectively.
- *
- * If you need the unbound scroll position, use `getUnboundedScrollPosition`.
- *
- * @param {DOMWindow|DOMElement} scrollable
- * @return {object} Map with `x` and `y` keys.
- */
- function getScrollPosition(scrollable) {
- var documentScrollElement = getDocumentScrollElement_1(scrollable.ownerDocument || scrollable.document);
- if (scrollable.Window && scrollable instanceof scrollable.Window) {
- scrollable = documentScrollElement;
- }
- var scrollPosition = getUnboundedScrollPosition_1(scrollable);
-
- var viewport = scrollable === documentScrollElement ? scrollable.ownerDocument.documentElement : scrollable;
-
- var xMax = scrollable.scrollWidth - viewport.clientWidth;
- var yMax = scrollable.scrollHeight - viewport.clientHeight;
-
- scrollPosition.x = Math.max(0, Math.min(scrollPosition.x, xMax));
- scrollPosition.y = Math.max(0, Math.min(scrollPosition.y, yMax));
-
- return scrollPosition;
- }
-
- var getScrollPosition_1 = getScrollPosition;
-
- function getViewportWidth() {
- var width = void 0;
- if (document.documentElement) {
- width = document.documentElement.clientWidth;
- }
-
- if (!width && document.body) {
- width = document.body.clientWidth;
- }
-
- return width || 0;
- } /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- *
- * @typechecks
- */
-
- function getViewportHeight() {
- var height = void 0;
- if (document.documentElement) {
- height = document.documentElement.clientHeight;
- }
-
- if (!height && document.body) {
- height = document.body.clientHeight;
- }
-
- return height || 0;
- }
-
- /**
- * Gets the viewport dimensions including any scrollbars.
- */
- function getViewportDimensions() {
- return {
- width: window.innerWidth || getViewportWidth(),
- height: window.innerHeight || getViewportHeight()
- };
- }
-
- /**
- * Gets the viewport dimensions excluding any scrollbars.
- */
- getViewportDimensions.withoutScrollbars = function () {
- return {
- width: getViewportWidth(),
- height: getViewportHeight()
- };
- };
-
- var getViewportDimensions_1 = getViewportDimensions;
-
- var _extends$2 = objectAssign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
-
- function _classCallCheck$b(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- function _possibleConstructorReturn$8(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
- function _inherits$8(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var SCROLL_BUFFER = 10;
-
- /**
- * Return whether a block overlaps with either edge of the `SelectionState`.
- */
- var isBlockOnSelectionEdge = function isBlockOnSelectionEdge(selection, key) {
- return selection.getAnchorKey() === key || selection.getFocusKey() === key;
- };
-
- /**
- * The default block renderer for a `DraftEditor` component.
- *
- * A `DraftEditorBlock` is able to render a given `ContentBlock` to its
- * appropriate decorator and inline style components.
- */
-
- var DraftEditorBlock = function (_React$Component) {
- _inherits$8(DraftEditorBlock, _React$Component);
-
- function DraftEditorBlock() {
- _classCallCheck$b(this, DraftEditorBlock);
-
- return _possibleConstructorReturn$8(this, _React$Component.apply(this, arguments));
- }
-
- DraftEditorBlock.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
- return this.props.block !== nextProps.block || this.props.tree !== nextProps.tree || this.props.direction !== nextProps.direction || isBlockOnSelectionEdge(nextProps.selection, nextProps.block.getKey()) && nextProps.forceSelection;
- };
-
- /**
- * When a block is mounted and overlaps the selection state, we need to make
- * sure that the cursor is visible to match native behavior. This may not
- * be the case if the user has pressed `RETURN` or pasted some content, since
- * programatically creating these new blocks and setting the DOM selection
- * will miss out on the browser natively scrolling to that position.
- *
- * To replicate native behavior, if the block overlaps the selection state
- * on mount, force the scroll position. Check the scroll state of the scroll
- * parent, and adjust it to align the entire block to the bottom of the
- * scroll parent.
- */
-
-
- DraftEditorBlock.prototype.componentDidMount = function componentDidMount() {
- var selection = this.props.selection;
- var endKey = selection.getEndKey();
- if (!selection.getHasFocus() || endKey !== this.props.block.getKey()) {
- return;
- }
-
- var blockNode = ReactDOM.findDOMNode(this);
- var scrollParent = Style_1.getScrollParent(blockNode);
- var scrollPosition = getScrollPosition_1(scrollParent);
- var scrollDelta = void 0;
-
- if (scrollParent === window) {
- var nodePosition = getElementPosition_1(blockNode);
- var nodeBottom = nodePosition.y + nodePosition.height;
- var viewportHeight = getViewportDimensions_1().height;
- scrollDelta = nodeBottom - viewportHeight;
- if (scrollDelta > 0) {
- window.scrollTo(scrollPosition.x, scrollPosition.y + scrollDelta + SCROLL_BUFFER);
- }
- } else {
- !(blockNode instanceof HTMLElement) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'blockNode is not an HTMLElement') : invariant_1(false) : void 0;
- var blockBottom = blockNode.offsetHeight + blockNode.offsetTop;
- var scrollBottom = scrollParent.offsetHeight + scrollPosition.y;
- scrollDelta = blockBottom - scrollBottom;
- if (scrollDelta > 0) {
- Scroll_1.setTop(scrollParent, Scroll_1.getTop(scrollParent) + scrollDelta + SCROLL_BUFFER);
- }
- }
- };
-
- DraftEditorBlock.prototype._renderChildren = function _renderChildren() {
- var _this2 = this;
-
- var block = this.props.block;
- var blockKey = block.getKey();
- var text = block.getText();
- var lastLeafSet = this.props.tree.size - 1;
- var hasSelection = isBlockOnSelectionEdge(this.props.selection, blockKey);
-
- return this.props.tree.map(function (leafSet, ii) {
- var leavesForLeafSet = leafSet.get('leaves');
- var lastLeaf = leavesForLeafSet.size - 1;
- var leaves = leavesForLeafSet.map(function (leaf, jj) {
- var offsetKey = DraftOffsetKey_1.encode(blockKey, ii, jj);
- var start = leaf.get('start');
- var end = leaf.get('end');
- return React.createElement(DraftEditorLeaf_react, {
- key: offsetKey,
- offsetKey: offsetKey,
- block: block,
- start: start,
- selection: hasSelection ? _this2.props.selection : null,
- forceSelection: _this2.props.forceSelection,
- text: text.slice(start, end),
- styleSet: block.getInlineStyleAt(start),
- customStyleMap: _this2.props.customStyleMap,
- customStyleFn: _this2.props.customStyleFn,
- isLast: ii === lastLeafSet && jj === lastLeaf
- });
- }).toArray();
-
- var decoratorKey = leafSet.get('decoratorKey');
- if (decoratorKey == null) {
- return leaves;
- }
-
- if (!_this2.props.decorator) {
- return leaves;
- }
-
- var decorator = nullthrows_1(_this2.props.decorator);
-
- var DecoratorComponent = decorator.getComponentForKey(decoratorKey);
- if (!DecoratorComponent) {
- return leaves;
- }
-
- var decoratorProps = decorator.getPropsForKey(decoratorKey);
- var decoratorOffsetKey = DraftOffsetKey_1.encode(blockKey, ii, 0);
- var decoratedText = text.slice(leavesForLeafSet.first().get('start'), leavesForLeafSet.last().get('end'));
-
- // Resetting dir to the same value on a child node makes Chrome/Firefox
- // confused on cursor movement. See http://jsfiddle.net/d157kLck/3/
- var dir = UnicodeBidiDirection_1.getHTMLDirIfDifferent(UnicodeBidi_1.getDirection(decoratedText), _this2.props.direction);
-
- return React.createElement(
- DecoratorComponent,
- _extends$2({}, decoratorProps, {
- contentState: _this2.props.contentState,
- decoratedText: decoratedText,
- dir: dir,
- key: decoratorOffsetKey,
- entityKey: block.getEntityAt(leafSet.get('start')),
- offsetKey: decoratorOffsetKey }),
- leaves
- );
- }).toArray();
- };
-
- DraftEditorBlock.prototype.render = function render() {
- var _props = this.props,
- direction = _props.direction,
- offsetKey = _props.offsetKey;
-
- var className = cx_1({
- 'public/DraftStyleDefault/block': true,
- 'public/DraftStyleDefault/ltr': direction === 'LTR',
- 'public/DraftStyleDefault/rtl': direction === 'RTL'
- });
-
- return React.createElement(
- 'div',
- { 'data-offset-key': offsetKey, className: className },
- this._renderChildren()
- );
- };
-
- return DraftEditorBlock;
- }(React.Component);
-
- var DraftEditorBlock_react = DraftEditorBlock;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks static-only
- */
-
- /**
- * Combines multiple className strings into one.
- * http://jsperf.com/joinclasses-args-vs-array
- *
- * @param {...?string} className
- * @return {string}
- */
-
- function joinClasses(className /*, ... */) {
- if (!className) {
- className = '';
- }
- var nextClass = void 0;
- var argLength = arguments.length;
- if (argLength > 1) {
- for (var ii = 1; ii < argLength; ii++) {
- nextClass = arguments[ii];
- if (nextClass) {
- className = (className ? className + ' ' : '') + nextClass;
- }
- }
- }
- return className;
- }
-
- var joinClasses_1 = joinClasses;
-
- var _extends$3 = objectAssign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
-
- function _classCallCheck$c(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- function _possibleConstructorReturn$9(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
- function _inherits$9(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-
-
-
-
-
-
-
-
-
- /**
- * Provide default styling for list items. This way, lists will be styled with
- * proper counters and indentation even if the caller does not specify
- * their own styling at all. If more than five levels of nesting are needed,
- * the necessary CSS classes can be provided via `blockStyleFn` configuration.
- */
- var getListItemClasses = function getListItemClasses(type, depth, shouldResetCount, direction) {
- return cx_1({
- 'public/DraftStyleDefault/unorderedListItem': type === 'unordered-list-item',
- 'public/DraftStyleDefault/orderedListItem': type === 'ordered-list-item',
- 'public/DraftStyleDefault/reset': shouldResetCount,
- 'public/DraftStyleDefault/depth0': depth === 0,
- 'public/DraftStyleDefault/depth1': depth === 1,
- 'public/DraftStyleDefault/depth2': depth === 2,
- 'public/DraftStyleDefault/depth3': depth === 3,
- 'public/DraftStyleDefault/depth4': depth === 4,
- 'public/DraftStyleDefault/listLTR': direction === 'LTR',
- 'public/DraftStyleDefault/listRTL': direction === 'RTL'
- });
- };
-
- /**
- * `DraftEditorContents` is the container component for all block components
- * rendered for a `DraftEditor`. It is optimized to aggressively avoid
- * re-rendering blocks whenever possible.
- *
- * This component is separate from `DraftEditor` because certain props
- * (for instance, ARIA props) must be allowed to update without affecting
- * the contents of the editor.
- */
-
- var DraftEditorContents = function (_React$Component) {
- _inherits$9(DraftEditorContents, _React$Component);
-
- function DraftEditorContents() {
- _classCallCheck$c(this, DraftEditorContents);
-
- return _possibleConstructorReturn$9(this, _React$Component.apply(this, arguments));
- }
-
- DraftEditorContents.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
- var prevEditorState = this.props.editorState;
- var nextEditorState = nextProps.editorState;
-
- var prevDirectionMap = prevEditorState.getDirectionMap();
- var nextDirectionMap = nextEditorState.getDirectionMap();
-
- // Text direction has changed for one or more blocks. We must re-render.
- if (prevDirectionMap !== nextDirectionMap) {
- return true;
- }
-
- var didHaveFocus = prevEditorState.getSelection().getHasFocus();
- var nowHasFocus = nextEditorState.getSelection().getHasFocus();
-
- if (didHaveFocus !== nowHasFocus) {
- return true;
- }
-
- var nextNativeContent = nextEditorState.getNativelyRenderedContent();
-
- var wasComposing = prevEditorState.isInCompositionMode();
- var nowComposing = nextEditorState.isInCompositionMode();
-
- // If the state is unchanged or we're currently rendering a natively
- // rendered state, there's nothing new to be done.
- if (prevEditorState === nextEditorState || nextNativeContent !== null && nextEditorState.getCurrentContent() === nextNativeContent || wasComposing && nowComposing) {
- return false;
- }
-
- var prevContent = prevEditorState.getCurrentContent();
- var nextContent = nextEditorState.getCurrentContent();
- var prevDecorator = prevEditorState.getDecorator();
- var nextDecorator = nextEditorState.getDecorator();
- return wasComposing !== nowComposing || prevContent !== nextContent || prevDecorator !== nextDecorator || nextEditorState.mustForceSelection();
- };
-
- DraftEditorContents.prototype.render = function render() {
- var _props = this.props,
- blockRenderMap = _props.blockRenderMap,
- blockRendererFn = _props.blockRendererFn,
- blockStyleFn = _props.blockStyleFn,
- customStyleMap = _props.customStyleMap,
- customStyleFn = _props.customStyleFn,
- editorState = _props.editorState,
- editorKey = _props.editorKey,
- textDirectionality = _props.textDirectionality;
-
-
- var content = editorState.getCurrentContent();
- var selection = editorState.getSelection();
- var forceSelection = editorState.mustForceSelection();
- var decorator = editorState.getDecorator();
- var directionMap = nullthrows_1(editorState.getDirectionMap());
-
- var blocksAsArray = content.getBlocksAsArray();
- var processedBlocks = [];
-
- var currentDepth = null;
- var lastWrapperTemplate = null;
-
- for (var ii = 0; ii < blocksAsArray.length; ii++) {
- var _block = blocksAsArray[ii];
- var key = _block.getKey();
- var blockType = _block.getType();
-
- var customRenderer = blockRendererFn(_block);
- var CustomComponent = void 0,
- customProps = void 0,
- customEditable = void 0;
- if (customRenderer) {
- CustomComponent = customRenderer.component;
- customProps = customRenderer.props;
- customEditable = customRenderer.editable;
- }
-
- var direction = textDirectionality ? textDirectionality : directionMap.get(key);
- var offsetKey = DraftOffsetKey_1.encode(key, 0, 0);
- var componentProps = {
- contentState: content,
- block: _block,
- blockProps: customProps,
- blockStyleFn: blockStyleFn,
- customStyleMap: customStyleMap,
- customStyleFn: customStyleFn,
- decorator: decorator,
- direction: direction,
- forceSelection: forceSelection,
- key: key,
- offsetKey: offsetKey,
- selection: selection,
- tree: editorState.getBlockTree(key)
- };
-
- var configForType = blockRenderMap.get(blockType) || blockRenderMap.get('unstyled');
- var wrapperTemplate = configForType.wrapper;
-
- var Element = configForType.element || blockRenderMap.get('unstyled').element;
-
- var depth = _block.getDepth();
- var className = '';
- if (blockStyleFn) {
- className = blockStyleFn(_block);
- }
-
- // List items are special snowflakes, since we handle nesting and
- // counters manually.
- if (Element === 'li') {
- var shouldResetCount = lastWrapperTemplate !== wrapperTemplate || currentDepth === null || depth > currentDepth;
- className = joinClasses_1(className, getListItemClasses(blockType, depth, shouldResetCount, direction));
- }
-
- var Component = CustomComponent || DraftEditorBlock_react;
- var childProps = {
- className: className,
- 'data-block': true,
- 'data-editor': editorKey,
- 'data-offset-key': offsetKey,
- key: key
- };
- if (customEditable !== undefined) {
- childProps = _extends$3({}, childProps, {
- contentEditable: customEditable,
- suppressContentEditableWarning: true
- });
- }
-
- var child = React.createElement(Element, childProps, React.createElement(Component, componentProps));
-
- processedBlocks.push({
- block: child,
- wrapperTemplate: wrapperTemplate,
- key: key,
- offsetKey: offsetKey
- });
-
- if (wrapperTemplate) {
- currentDepth = _block.getDepth();
- } else {
- currentDepth = null;
- }
- lastWrapperTemplate = wrapperTemplate;
- }
-
- // Group contiguous runs of blocks that have the same wrapperTemplate
- var outputBlocks = [];
- for (var _ii = 0; _ii < processedBlocks.length;) {
- var info = processedBlocks[_ii];
- if (info.wrapperTemplate) {
- var blocks = [];
- do {
- blocks.push(processedBlocks[_ii].block);
- _ii++;
- } while (_ii < processedBlocks.length && processedBlocks[_ii].wrapperTemplate === info.wrapperTemplate);
- var wrapperElement = React.cloneElement(info.wrapperTemplate, {
- key: info.key + '-wrap',
- 'data-offset-key': info.offsetKey
- }, blocks);
- outputBlocks.push(wrapperElement);
- } else {
- outputBlocks.push(info.block);
- _ii++;
- }
- }
-
- return React.createElement(
- 'div',
- { 'data-contents': 'true' },
- outputBlocks
- );
- };
-
- return DraftEditorContents;
- }(React.Component);
-
- var DraftEditorContentsCore_react = DraftEditorContents;
-
- var DraftEditorContents_react = DraftEditorContentsCore_react;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- */
- var PhotosMimeType = {
- isImage: function isImage(mimeString) {
- return getParts(mimeString)[0] === 'image';
- },
- isJpeg: function isJpeg(mimeString) {
- var parts = getParts(mimeString);
- return PhotosMimeType.isImage(mimeString) && (
- // see http://fburl.com/10972194
- parts[1] === 'jpeg' || parts[1] === 'pjpeg');
- }
- };
-
- function getParts(mimeString) {
- return mimeString.split('/');
- }
-
- var PhotosMimeType_1 = PhotosMimeType;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
-
-
-
- /**
- * Convert array-like objects to arrays.
- *
- * This API assumes the caller knows the contents of the data type. For less
- * well defined inputs use createArrayFromMixed.
- *
- * @param {object|function|filelist} obj
- * @return {array}
- */
- function toArray(obj) {
- var length = obj.length;
-
- // Some browsers builtin objects can report typeof 'function' (e.g. NodeList
- // in old versions of Safari).
- !(!Array.isArray(obj) && (typeof obj === 'object' || typeof obj === 'function')) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'toArray: Array-like object expected') : invariant_1(false) : void 0;
-
- !(typeof length === 'number') ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'toArray: Object needs a length property') : invariant_1(false) : void 0;
-
- !(length === 0 || length - 1 in obj) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'toArray: Object should have keys for indices') : invariant_1(false) : void 0;
-
- !(typeof obj.callee !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'toArray: Object can\'t be `arguments`. Use rest params ' + '(function(...args) {}) or Array.from() instead.') : invariant_1(false) : void 0;
-
- // Old IE doesn't give collections access to hasOwnProperty. Assume inputs
- // without method will throw during the slice call and skip straight to the
- // fallback.
- if (obj.hasOwnProperty) {
- try {
- return Array.prototype.slice.call(obj);
- } catch (e) {
- // IE < 9 does not support Array#slice on collections objects
- }
- }
-
- // Fall back to copying key by key. This assumes all keys have a value,
- // so will not preserve sparsely populated inputs.
- var ret = Array(length);
- for (var ii = 0; ii < length; ii++) {
- ret[ii] = obj[ii];
- }
- return ret;
- }
-
- /**
- * Perform a heuristic test to determine if an object is "array-like".
- *
- * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?"
- * Joshu replied: "Mu."
- *
- * This function determines if its argument has "array nature": it returns
- * true if the argument is an actual array, an `arguments' object, or an
- * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()).
- *
- * It will return false for other array-like objects like Filelist.
- *
- * @param {*} obj
- * @return {boolean}
- */
- function hasArrayNature(obj) {
- return (
- // not null/false
- !!obj && (
- // arrays are objects, NodeLists are functions in Safari
- typeof obj == 'object' || typeof obj == 'function') &&
- // quacks like an array
- 'length' in obj &&
- // not window
- !('setInterval' in obj) &&
- // no DOM node should be considered an array-like
- // a 'select' element has 'length' and 'item' properties on IE8
- typeof obj.nodeType != 'number' && (
- // a real array
- Array.isArray(obj) ||
- // arguments
- 'callee' in obj ||
- // HTMLCollection/NodeList
- 'item' in obj)
- );
- }
-
- /**
- * Ensure that the argument is an array by wrapping it in an array if it is not.
- * Creates a copy of the argument if it is already an array.
- *
- * This is mostly useful idiomatically:
- *
- * var createArrayFromMixed = require('createArrayFromMixed');
- *
- * function takesOneOrMoreThings(things) {
- * things = createArrayFromMixed(things);
- * ...
- * }
- *
- * This allows you to treat `things' as an array, but accept scalars in the API.
- *
- * If you need to convert an array-like object, like `arguments`, into an array
- * use toArray instead.
- *
- * @param {*} obj
- * @return {array}
- */
- function createArrayFromMixed(obj) {
- if (!hasArrayNature(obj)) {
- return [obj];
- } else if (Array.isArray(obj)) {
- return obj.slice();
- } else {
- return toArray(obj);
- }
- }
-
- var createArrayFromMixed_1 = createArrayFromMixed;
-
- function _classCallCheck$d(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- */
-
-
-
-
-
-
- var CR_LF_REGEX = new RegExp('\r\n', 'g');
- var LF_ONLY = '\n';
-
- var RICH_TEXT_TYPES = {
- 'text/rtf': 1,
- 'text/html': 1
- };
-
- /**
- * If DataTransferItem is a file then return the Blob of data.
- *
- * @param {object} item
- * @return {?blob}
- */
- function getFileFromDataTransfer(item) {
- if (item.kind == 'file') {
- return item.getAsFile();
- }
- }
-
- var DataTransfer = function () {
- /**
- * @param {object} data
- */
- function DataTransfer(data) {
- _classCallCheck$d(this, DataTransfer);
-
- this.data = data;
-
- // Types could be DOMStringList or array
- this.types = data.types ? createArrayFromMixed_1(data.types) : [];
- }
-
- /**
- * Is this likely to be a rich text data transfer?
- *
- * @return {boolean}
- */
-
-
- DataTransfer.prototype.isRichText = function isRichText() {
- // If HTML is available, treat this data as rich text. This way, we avoid
- // using a pasted image if it is packaged with HTML -- this may occur with
- // pastes from MS Word, for example. However this is only rich text if
- // there's accompanying text.
- if (this.getHTML() && this.getText()) {
- return true;
- }
-
- // When an image is copied from a preview window, you end up with two
- // DataTransferItems one of which is a file's metadata as text. Skip those.
- if (this.isImage()) {
- return false;
- }
-
- return this.types.some(function (type) {
- return RICH_TEXT_TYPES[type];
- });
- };
-
- /**
- * Get raw text.
- *
- * @return {?string}
- */
-
-
- DataTransfer.prototype.getText = function getText() {
- var text;
- if (this.data.getData) {
- if (!this.types.length) {
- text = this.data.getData('Text');
- } else if (this.types.indexOf('text/plain') != -1) {
- text = this.data.getData('text/plain');
- }
- }
- return text ? text.replace(CR_LF_REGEX, LF_ONLY) : null;
- };
-
- /**
- * Get HTML paste data
- *
- * @return {?string}
- */
-
-
- DataTransfer.prototype.getHTML = function getHTML() {
- if (this.data.getData) {
- if (!this.types.length) {
- return this.data.getData('Text');
- } else if (this.types.indexOf('text/html') != -1) {
- return this.data.getData('text/html');
- }
- }
- };
-
- /**
- * Is this a link data transfer?
- *
- * @return {boolean}
- */
-
-
- DataTransfer.prototype.isLink = function isLink() {
- return this.types.some(function (type) {
- return type.indexOf('Url') != -1 || type.indexOf('text/uri-list') != -1 || type.indexOf('text/x-moz-url');
- });
- };
-
- /**
- * Get a link url.
- *
- * @return {?string}
- */
-
-
- DataTransfer.prototype.getLink = function getLink() {
- if (this.data.getData) {
- if (this.types.indexOf('text/x-moz-url') != -1) {
- var url = this.data.getData('text/x-moz-url').split('\n');
- return url[0];
- }
- return this.types.indexOf('text/uri-list') != -1 ? this.data.getData('text/uri-list') : this.data.getData('url');
- }
-
- return null;
- };
-
- /**
- * Is this an image data transfer?
- *
- * @return {boolean}
- */
-
-
- DataTransfer.prototype.isImage = function isImage() {
- var isImage = this.types.some(function (type) {
- // Firefox will have a type of application/x-moz-file for images during
- // dragging
- return type.indexOf('application/x-moz-file') != -1;
- });
-
- if (isImage) {
- return true;
- }
-
- var items = this.getFiles();
- for (var i = 0; i < items.length; i++) {
- var type = items[i].type;
- if (!PhotosMimeType_1.isImage(type)) {
- return false;
- }
- }
-
- return true;
- };
-
- DataTransfer.prototype.getCount = function getCount() {
- if (this.data.hasOwnProperty('items')) {
- return this.data.items.length;
- } else if (this.data.hasOwnProperty('mozItemCount')) {
- return this.data.mozItemCount;
- } else if (this.data.files) {
- return this.data.files.length;
- }
- return null;
- };
-
- /**
- * Get files.
- *
- * @return {array}
- */
-
-
- DataTransfer.prototype.getFiles = function getFiles() {
- if (this.data.items) {
- // createArrayFromMixed doesn't properly handle DataTransferItemLists.
- return Array.prototype.slice.call(this.data.items).map(getFileFromDataTransfer).filter(emptyFunction_1.thatReturnsArgument);
- } else if (this.data.files) {
- return Array.prototype.slice.call(this.data.files);
- } else {
- return [];
- }
- };
-
- /**
- * Are there any files to fetch?
- *
- * @return {boolean}
- */
-
-
- DataTransfer.prototype.hasFiles = function hasFiles() {
- return this.getFiles().length > 0;
- };
-
- return DataTransfer;
- }();
-
- var DataTransfer_1 = DataTransfer;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule getSelectionOffsetKeyForNode
- * @format
- *
- */
-
- /**
- * Get offset key from a node or it's child nodes. Return the first offset key
- * found on the DOM tree of given node.
- */
-
- function getSelectionOffsetKeyForNode(node) {
- if (node instanceof Element) {
- var offsetKey = node.getAttribute('data-offset-key');
- if (offsetKey) {
- return offsetKey;
- }
- for (var ii = 0; ii < node.childNodes.length; ii++) {
- var childOffsetKey = getSelectionOffsetKeyForNode(node.childNodes[ii]);
- if (childOffsetKey) {
- return childOffsetKey;
- }
- }
- }
- return null;
- }
-
- var getSelectionOffsetKeyForNode_1 = getSelectionOffsetKeyForNode;
-
- /**
- * Get the key from the node's nearest offset-aware ancestor.
- */
- function findAncestorOffsetKey(node) {
- var searchNode = node;
- while (searchNode && searchNode !== document.documentElement) {
- var key = getSelectionOffsetKeyForNode_1(searchNode);
- if (key != null) {
- return key;
- }
- searchNode = searchNode.parentNode;
- }
- return null;
- }
-
- var findAncestorOffsetKey_1 = findAncestorOffsetKey;
-
- var TEXT_CLIPPING_REGEX = /\.textClipping$/;
-
- var TEXT_TYPES = {
- 'text/plain': true,
- 'text/html': true,
- 'text/rtf': true
- };
-
- // Somewhat arbitrary upper bound on text size. Let's not lock up the browser.
- var TEXT_SIZE_UPPER_BOUND = 5000;
-
- /**
- * Extract the text content from a file list.
- */
- function getTextContentFromFiles(files, callback) {
- var readCount = 0;
- var results = [];
- files.forEach(function ( /*blob*/file) {
- readFile(file, function ( /*string*/text) {
- readCount++;
- text && results.push(text.slice(0, TEXT_SIZE_UPPER_BOUND));
- if (readCount == files.length) {
- callback(results.join('\r'));
- }
- });
- });
- }
-
- /**
- * todo isaac: Do work to turn html/rtf into a content fragment.
- */
- function readFile(file, callback) {
- if (!commonjsGlobal.FileReader || file.type && !(file.type in TEXT_TYPES)) {
- callback('');
- return;
- }
-
- if (file.type === '') {
- var contents = '';
- // Special-case text clippings, which have an empty type but include
- // `.textClipping` in the file name. `readAsText` results in an empty
- // string for text clippings, so we force the file name to serve
- // as the text value for the file.
- if (TEXT_CLIPPING_REGEX.test(file.name)) {
- contents = file.name.replace(TEXT_CLIPPING_REGEX, '');
- }
- callback(contents);
- return;
- }
-
- var reader = new FileReader();
- reader.onload = function () {
- var result = reader.result;
- !(typeof result === 'string') ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'We should be calling "FileReader.readAsText" which returns a string') : invariant_1(false) : void 0;
- callback(result);
- };
- reader.onerror = function () {
- callback('');
- };
- reader.readAsText(file);
- }
-
- var getTextContentFromFiles_1 = getTextContentFromFiles;
-
- function getUpdatedSelectionState(editorState, anchorKey, anchorOffset, focusKey, focusOffset) {
- var selection = nullthrows_1(editorState.getSelection());
- if (process.env.NODE_ENV !== 'production') {
- if (!anchorKey || !focusKey) {
- /*eslint-disable no-console */
- console.warn('Invalid selection state.', arguments, editorState.toJS());
- /*eslint-enable no-console */
- return selection;
- }
- }
-
- var anchorPath = DraftOffsetKey_1.decode(anchorKey);
- var anchorBlockKey = anchorPath.blockKey;
- var anchorLeaf = editorState.getBlockTree(anchorBlockKey).getIn([anchorPath.decoratorKey, 'leaves', anchorPath.leafKey]);
-
- var focusPath = DraftOffsetKey_1.decode(focusKey);
- var focusBlockKey = focusPath.blockKey;
- var focusLeaf = editorState.getBlockTree(focusBlockKey).getIn([focusPath.decoratorKey, 'leaves', focusPath.leafKey]);
-
- var anchorLeafStart = anchorLeaf.get('start');
- var focusLeafStart = focusLeaf.get('start');
-
- var anchorBlockOffset = anchorLeaf ? anchorLeafStart + anchorOffset : null;
- var focusBlockOffset = focusLeaf ? focusLeafStart + focusOffset : null;
-
- var areEqual = selection.getAnchorKey() === anchorBlockKey && selection.getAnchorOffset() === anchorBlockOffset && selection.getFocusKey() === focusBlockKey && selection.getFocusOffset() === focusBlockOffset;
-
- if (areEqual) {
- return selection;
- }
-
- var isBackward = false;
- if (anchorBlockKey === focusBlockKey) {
- var anchorLeafEnd = anchorLeaf.get('end');
- var focusLeafEnd = focusLeaf.get('end');
- if (focusLeafStart === anchorLeafStart && focusLeafEnd === anchorLeafEnd) {
- isBackward = focusOffset < anchorOffset;
- } else {
- isBackward = focusLeafStart < anchorLeafStart;
- }
- } else {
- var startKey = editorState.getCurrentContent().getBlockMap().keySeq().skipUntil(function (v) {
- return v === anchorBlockKey || v === focusBlockKey;
- }).first();
- isBackward = startKey === focusBlockKey;
- }
-
- return selection.merge({
- anchorKey: anchorBlockKey,
- anchorOffset: anchorBlockOffset,
- focusKey: focusBlockKey,
- focusOffset: focusBlockOffset,
- isBackward: isBackward
- });
- }
-
- var getUpdatedSelectionState_1 = getUpdatedSelectionState;
-
- /**
- * Get a SelectionState for the supplied mouse event.
- */
- function getSelectionForEvent(event, editorState) {
- var node = null;
- var offset = null;
-
- if (typeof document.caretRangeFromPoint === 'function') {
- var dropRange = document.caretRangeFromPoint(event.x, event.y);
- node = dropRange.startContainer;
- offset = dropRange.startOffset;
- } else if (event.rangeParent) {
- node = event.rangeParent;
- offset = event.rangeOffset;
- } else {
- return null;
- }
-
- node = nullthrows_1(node);
- offset = nullthrows_1(offset);
- var offsetKey = nullthrows_1(findAncestorOffsetKey_1(node));
-
- return getUpdatedSelectionState_1(editorState, offsetKey, offset, offsetKey, offset);
- }
-
- var DraftEditorDragHandler = {
- /**
- * Drag originating from input terminated.
- */
- onDragEnd: function onDragEnd(editor) {
- editor.exitCurrentMode();
- },
-
- /**
- * Handle data being dropped.
- */
- onDrop: function onDrop(editor, e) {
- var data = new DataTransfer_1(e.nativeEvent.dataTransfer);
-
- var editorState = editor._latestEditorState;
- var dropSelection = getSelectionForEvent(e.nativeEvent, editorState);
-
- e.preventDefault();
- editor.exitCurrentMode();
-
- if (dropSelection == null) {
- return;
- }
-
- var files = data.getFiles();
- if (files.length > 0) {
- if (editor.props.handleDroppedFiles && isEventHandled_1(editor.props.handleDroppedFiles(dropSelection, files))) {
- return;
- }
-
- getTextContentFromFiles_1(files, function (fileText) {
- fileText && editor.update(insertTextAtSelection(editorState, dropSelection, fileText));
- });
- return;
- }
-
- var dragType = editor._internalDrag ? 'internal' : 'external';
- if (editor.props.handleDrop && isEventHandled_1(editor.props.handleDrop(dropSelection, data, dragType))) {
- return;
- }
-
- if (editor._internalDrag) {
- editor.update(moveText(editorState, dropSelection));
- return;
- }
-
- editor.update(insertTextAtSelection(editorState, dropSelection, data.getText()));
- }
- };
-
- function moveText(editorState, targetSelection) {
- var newContentState = DraftModifier_1.moveText(editorState.getCurrentContent(), editorState.getSelection(), targetSelection);
- return EditorState_1.push(editorState, newContentState, 'insert-fragment');
- }
-
- /**
- * Insert text at a specified selection.
- */
- function insertTextAtSelection(editorState, selection, text) {
- var newContentState = DraftModifier_1.insertText(editorState.getCurrentContent(), selection, text, editorState.getCurrentInlineStyle());
- return EditorState_1.push(editorState, newContentState, 'insert-fragment');
- }
-
- var DraftEditorDragHandler_1 = DraftEditorDragHandler;
-
- (function (global, undefined$1) {
-
- if (global.setImmediate) {
- return;
- }
-
- var nextHandle = 1; // Spec says greater than zero
- var tasksByHandle = {};
- var currentlyRunningATask = false;
- var doc = global.document;
- var registerImmediate;
-
- function setImmediate(callback) {
- // Callback can either be a function or a string
- if (typeof callback !== "function") {
- callback = new Function("" + callback);
- }
- // Copy function arguments
- var args = new Array(arguments.length - 1);
- for (var i = 0; i < args.length; i++) {
- args[i] = arguments[i + 1];
- }
- // Store and register the task
- var task = { callback: callback, args: args };
- tasksByHandle[nextHandle] = task;
- registerImmediate(nextHandle);
- return nextHandle++;
- }
-
- function clearImmediate(handle) {
- delete tasksByHandle[handle];
- }
-
- function run(task) {
- var callback = task.callback;
- var args = task.args;
- switch (args.length) {
- case 0:
- callback();
- break;
- case 1:
- callback(args[0]);
- break;
- case 2:
- callback(args[0], args[1]);
- break;
- case 3:
- callback(args[0], args[1], args[2]);
- break;
- default:
- callback.apply(undefined$1, args);
- break;
- }
- }
-
- function runIfPresent(handle) {
- // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
- // So if we're currently running a task, we'll need to delay this invocation.
- if (currentlyRunningATask) {
- // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
- // "too much recursion" error.
- setTimeout(runIfPresent, 0, handle);
- } else {
- var task = tasksByHandle[handle];
- if (task) {
- currentlyRunningATask = true;
- try {
- run(task);
- } finally {
- clearImmediate(handle);
- currentlyRunningATask = false;
- }
- }
- }
- }
-
- function installNextTickImplementation() {
- registerImmediate = function(handle) {
- process.nextTick(function () { runIfPresent(handle); });
- };
- }
-
- function canUsePostMessage() {
- // The test against `importScripts` prevents this implementation from being installed inside a web worker,
- // where `global.postMessage` means something completely different and can't be used for this purpose.
- if (global.postMessage && !global.importScripts) {
- var postMessageIsAsynchronous = true;
- var oldOnMessage = global.onmessage;
- global.onmessage = function() {
- postMessageIsAsynchronous = false;
- };
- global.postMessage("", "*");
- global.onmessage = oldOnMessage;
- return postMessageIsAsynchronous;
- }
- }
-
- function installPostMessageImplementation() {
- // Installs an event handler on `global` for the `message` event: see
- // * https://developer.mozilla.org/en/DOM/window.postMessage
- // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
-
- var messagePrefix = "setImmediate$" + Math.random() + "$";
- var onGlobalMessage = function(event) {
- if (event.source === global &&
- typeof event.data === "string" &&
- event.data.indexOf(messagePrefix) === 0) {
- runIfPresent(+event.data.slice(messagePrefix.length));
- }
- };
-
- if (global.addEventListener) {
- global.addEventListener("message", onGlobalMessage, false);
- } else {
- global.attachEvent("onmessage", onGlobalMessage);
- }
-
- registerImmediate = function(handle) {
- global.postMessage(messagePrefix + handle, "*");
- };
- }
-
- function installMessageChannelImplementation() {
- var channel = new MessageChannel();
- channel.port1.onmessage = function(event) {
- var handle = event.data;
- runIfPresent(handle);
- };
-
- registerImmediate = function(handle) {
- channel.port2.postMessage(handle);
- };
- }
-
- function installReadyStateChangeImplementation() {
- var html = doc.documentElement;
- registerImmediate = function(handle) {
- // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
- // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
- var script = doc.createElement("script");
- script.onreadystatechange = function () {
- runIfPresent(handle);
- script.onreadystatechange = null;
- html.removeChild(script);
- script = null;
- };
- html.appendChild(script);
- };
- }
-
- function installSetTimeoutImplementation() {
- registerImmediate = function(handle) {
- setTimeout(runIfPresent, 0, handle);
- };
- }
-
- // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
- var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
- attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
-
- // Don't get fooled by e.g. browserify environments.
- if ({}.toString.call(global.process) === "[object process]") {
- // For Node.js before 0.9
- installNextTickImplementation();
-
- } else if (canUsePostMessage()) {
- // For non-IE10 modern browsers
- installPostMessageImplementation();
-
- } else if (global.MessageChannel) {
- // For web workers, where supported
- installMessageChannelImplementation();
-
- } else if (doc && "onreadystatechange" in doc.createElement("script")) {
- // For IE 6–8
- installReadyStateChangeImplementation();
-
- } else {
- // For older browsers
- installSetTimeoutImplementation();
- }
-
- attachTo.setImmediate = setImmediate;
- attachTo.clearImmediate = clearImmediate;
- }(typeof self === "undefined" ? typeof commonjsGlobal === "undefined" ? commonjsGlobal : commonjsGlobal : self));
-
- // setimmediate adds setImmediate to the global. We want to make sure we export
- // the actual function.
-
-
- var setImmediate = commonjsGlobal.setImmediate;
-
- // When nothing is focused, Firefox regards two characters, `'` and `/`, as
- // commands that should open and focus the "quickfind" search bar. This should
- // *never* happen while a contenteditable is focused, but as of v28, it
- // sometimes does, even when the keypress event target is the contenteditable.
- // This breaks the input. Special case these characters to ensure that when
- // they are typed, we prevent default on the event to make sure not to
- // trigger quickfind.
- var FF_QUICKFIND_CHAR = "'";
- var FF_QUICKFIND_LINK_CHAR = '/';
- var isFirefox = UserAgent_1.isBrowser('Firefox');
-
- function mustPreventDefaultForCharacter(character) {
- return isFirefox && (character == FF_QUICKFIND_CHAR || character == FF_QUICKFIND_LINK_CHAR);
- }
-
- /**
- * Replace the current selection with the specified text string, with the
- * inline style and entity key applied to the newly inserted text.
- */
- function replaceText(editorState, text, inlineStyle, entityKey) {
- var contentState = DraftModifier_1.replaceText(editorState.getCurrentContent(), editorState.getSelection(), text, inlineStyle, entityKey);
- return EditorState_1.push(editorState, contentState, 'insert-characters');
- }
-
- /**
- * When `onBeforeInput` executes, the browser is attempting to insert a
- * character into the editor. Apply this character data to the document,
- * allowing native insertion if possible.
- *
- * Native insertion is encouraged in order to limit re-rendering and to
- * preserve spellcheck highlighting, which disappears or flashes if re-render
- * occurs on the relevant text nodes.
- */
- function editOnBeforeInput(editor, e) {
- if (editor._pendingStateFromBeforeInput !== undefined) {
- editor.update(editor._pendingStateFromBeforeInput);
- editor._pendingStateFromBeforeInput = undefined;
- }
-
- var editorState = editor._latestEditorState;
-
- var chars = e.data;
-
- // In some cases (ex: IE ideographic space insertion) no character data
- // is provided. There's nothing to do when this happens.
- if (!chars) {
- return;
- }
-
- // Allow the top-level component to handle the insertion manually. This is
- // useful when triggering interesting behaviors for a character insertion,
- // Simple examples: replacing a raw text ':)' with a smile emoji or image
- // decorator, or setting a block to be a list item after typing '- ' at the
- // start of the block.
- if (editor.props.handleBeforeInput && isEventHandled_1(editor.props.handleBeforeInput(chars, editorState))) {
- e.preventDefault();
- return;
- }
-
- // If selection is collapsed, conditionally allow native behavior. This
- // reduces re-renders and preserves spellcheck highlighting. If the selection
- // is not collapsed, we will re-render.
- var selection = editorState.getSelection();
- var selectionStart = selection.getStartOffset();
- var selectionEnd = selection.getEndOffset();
- var anchorKey = selection.getAnchorKey();
-
- if (!selection.isCollapsed()) {
- e.preventDefault();
-
- // If the currently selected text matches what the user is trying to
- // replace it with, let's just update the `SelectionState`. If not, update
- // the `ContentState` with the new text.
- var currentlySelectedChars = editorState.getCurrentContent().getPlainText().slice(selectionStart, selectionEnd);
- if (chars === currentlySelectedChars) {
- editor.update(EditorState_1.forceSelection(editorState, selection.merge({
- focusOffset: selectionEnd
- })));
- } else {
- editor.update(replaceText(editorState, chars, editorState.getCurrentInlineStyle(), getEntityKeyForSelection_1(editorState.getCurrentContent(), editorState.getSelection())));
- }
- return;
- }
-
- var newEditorState = replaceText(editorState, chars, editorState.getCurrentInlineStyle(), getEntityKeyForSelection_1(editorState.getCurrentContent(), editorState.getSelection()));
-
- // Bunch of different cases follow where we need to prevent native insertion.
- var mustPreventNative = false;
- if (!mustPreventNative) {
- // Browsers tend to insert text in weird places in the DOM when typing at
- // the start of a leaf, so we'll handle it ourselves.
- mustPreventNative = isSelectionAtLeafStart_1(editor._latestCommittedEditorState);
- }
- if (!mustPreventNative) {
- // Chrome will also split up a node into two pieces if it contains a Tab
- // char, for no explicable reason. Seemingly caused by this commit:
- // https://chromium.googlesource.com/chromium/src/+/013ac5eaf3%5E%21/
- var nativeSelection = commonjsGlobal.getSelection();
- // Selection is necessarily collapsed at this point due to earlier check.
- if (nativeSelection.anchorNode && nativeSelection.anchorNode.nodeType === Node.TEXT_NODE) {
- // See isTabHTMLSpanElement in chromium EditingUtilities.cpp.
- var parentNode = nativeSelection.anchorNode.parentNode;
- mustPreventNative = parentNode.nodeName === 'SPAN' && parentNode.firstChild.nodeType === Node.TEXT_NODE && parentNode.firstChild.nodeValue.indexOf('\t') !== -1;
- }
- }
- if (!mustPreventNative) {
- // Check the old and new "fingerprints" of the current block to determine
- // whether this insertion requires any addition or removal of text nodes,
- // in which case we would prevent the native character insertion.
- var originalFingerprint = BlockTree_1.getFingerprint(editorState.getBlockTree(anchorKey));
- var newFingerprint = BlockTree_1.getFingerprint(newEditorState.getBlockTree(anchorKey));
- mustPreventNative = originalFingerprint !== newFingerprint;
- }
- if (!mustPreventNative) {
- mustPreventNative = mustPreventDefaultForCharacter(chars);
- }
- if (!mustPreventNative) {
- mustPreventNative = nullthrows_1(newEditorState.getDirectionMap()).get(anchorKey) !== nullthrows_1(editorState.getDirectionMap()).get(anchorKey);
- }
-
- if (mustPreventNative) {
- e.preventDefault();
- editor.update(newEditorState);
- return;
- }
-
- // We made it all the way! Let the browser do its thing and insert the char.
- newEditorState = EditorState_1.set(newEditorState, {
- nativelyRenderedContent: newEditorState.getCurrentContent()
- });
- // The native event is allowed to occur. To allow user onChange handlers to
- // change the inserted text, we wait until the text is actually inserted
- // before we actually update our state. That way when we rerender, the text
- // we see in the DOM will already have been inserted properly.
- editor._pendingStateFromBeforeInput = newEditorState;
- setImmediate(function () {
- if (editor._pendingStateFromBeforeInput !== undefined) {
- editor.update(editor._pendingStateFromBeforeInput);
- editor._pendingStateFromBeforeInput = undefined;
- }
- });
- }
-
- var editOnBeforeInput_1 = editOnBeforeInput;
-
- function editOnBlur(editor, e) {
- // In a contentEditable element, when you select a range and then click
- // another active element, this does trigger a `blur` event but will not
- // remove the DOM selection from the contenteditable.
- // This is consistent across all browsers, but we prefer that the editor
- // behave like a textarea, where a `blur` event clears the DOM selection.
- // We therefore force the issue to be certain, checking whether the active
- // element is `body` to force it when blurring occurs within the window (as
- // opposed to clicking to another tab or window).
- if (getActiveElement_1() === document.body) {
- var _selection = commonjsGlobal.getSelection();
- var editorNode = editor.editor;
- if (_selection.rangeCount === 1 && containsNode_1(editorNode, _selection.anchorNode) && containsNode_1(editorNode, _selection.focusNode)) {
- _selection.removeAllRanges();
- }
- }
-
- var editorState = editor._latestEditorState;
- var currentSelection = editorState.getSelection();
- if (!currentSelection.getHasFocus()) {
- return;
- }
-
- var selection = currentSelection.set('hasFocus', false);
- editor.props.onBlur && editor.props.onBlur(e);
- editor.update(EditorState_1.acceptSelection(editorState, selection));
- }
-
- var editOnBlur_1 = editOnBlur;
-
- /**
- * The user has begun using an IME input system. Switching to `composite` mode
- * allows handling composition input and disables other edit behavior.
- */
- function editOnCompositionStart(editor, e) {
- editor.setMode('composite');
- editor.update(EditorState_1.set(editor._latestEditorState, { inCompositionMode: true }));
- // Allow composition handler to interpret the compositionstart event
- editor._onCompositionStart(e);
- }
-
- var editOnCompositionStart_1 = editOnCompositionStart;
-
- function getFragmentFromSelection(editorState) {
- var selectionState = editorState.getSelection();
-
- if (selectionState.isCollapsed()) {
- return null;
- }
-
- return getContentStateFragment_1(editorState.getCurrentContent(), selectionState);
- }
-
- var getFragmentFromSelection_1 = getFragmentFromSelection;
-
- /**
- * If we have a selection, create a ContentState fragment and store
- * it in our internal clipboard. Subsequent paste events will use this
- * fragment if no external clipboard data is supplied.
- */
- function editOnCopy(editor, e) {
- var editorState = editor._latestEditorState;
- var selection = editorState.getSelection();
-
- // No selection, so there's nothing to copy.
- if (selection.isCollapsed()) {
- e.preventDefault();
- return;
- }
-
- editor.setClipboard(getFragmentFromSelection_1(editor._latestEditorState));
- }
-
- var editOnCopy_1 = editOnCopy;
-
- /**
- * On `cut` events, native behavior is allowed to occur so that the system
- * clipboard is set properly. This means that we need to take steps to recover
- * the editor DOM state after the `cut` has occurred in order to maintain
- * control of the component.
- *
- * In addition, we can keep a copy of the removed fragment, including all
- * styles and entities, for use as an internal paste.
- */
- function editOnCut(editor, e) {
- var editorState = editor._latestEditorState;
- var selection = editorState.getSelection();
- var element = e.target;
- var scrollPosition = void 0;
-
- // No selection, so there's nothing to cut.
- if (selection.isCollapsed()) {
- e.preventDefault();
- return;
- }
-
- // Track the current scroll position so that it can be forced back in place
- // after the editor regains control of the DOM.
- if (element instanceof Node) {
- scrollPosition = getScrollPosition_1(Style_1.getScrollParent(element));
- }
-
- var fragment = getFragmentFromSelection_1(editorState);
- editor.setClipboard(fragment);
-
- // Set `cut` mode to disable all event handling temporarily.
- editor.setMode('cut');
-
- // Let native `cut` behavior occur, then recover control.
- setTimeout(function () {
- editor.restoreEditorDOM(scrollPosition);
- editor.exitCurrentMode();
- editor.update(removeFragment(editorState));
- }, 0);
- }
-
- function removeFragment(editorState) {
- var newContent = DraftModifier_1.removeRange(editorState.getCurrentContent(), editorState.getSelection(), 'forward');
- return EditorState_1.push(editorState, newContent, 'remove-range');
- }
-
- var editOnCut_1 = editOnCut;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule editOnDragOver
- * @format
- *
- */
-
- /**
- * Drag behavior has begun from outside the editor element.
- */
- function editOnDragOver(editor, e) {
- editor._internalDrag = false;
- editor.setMode('drag');
- e.preventDefault();
- }
-
- var editOnDragOver_1 = editOnDragOver;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule editOnDragStart
- * @format
- *
- */
-
- /**
- * A `dragstart` event has begun within the text editor component.
- */
- function editOnDragStart(editor) {
- editor._internalDrag = true;
- editor.setMode('drag');
- }
-
- var editOnDragStart_1 = editOnDragStart;
-
- function editOnFocus(editor, e) {
- var editorState = editor._latestEditorState;
- var currentSelection = editorState.getSelection();
- if (currentSelection.getHasFocus()) {
- return;
- }
-
- var selection = currentSelection.set('hasFocus', true);
- editor.props.onFocus && editor.props.onFocus(e);
-
- // When the tab containing this text editor is hidden and the user does a
- // find-in-page in a _different_ tab, Chrome on Mac likes to forget what the
- // selection was right after sending this focus event and (if you let it)
- // moves the cursor back to the beginning of the editor, so we force the
- // selection here instead of simply accepting it in order to preserve the
- // old cursor position. See https://crbug.com/540004.
- // But it looks like this is fixed in Chrome 60.0.3081.0.
- // Other browsers also don't have this bug, so we prefer to acceptSelection
- // when possible, to ensure that unfocusing and refocusing a Draft editor
- // doesn't preserve the selection, matching how textareas work.
- if (UserAgent_1.isBrowser('Chrome < 60.0.3081.0')) {
- editor.update(EditorState_1.forceSelection(editorState, selection));
- } else {
- editor.update(EditorState_1.acceptSelection(editorState, selection));
- }
- }
-
- var editOnFocus_1 = editOnFocus;
-
- var isGecko = UserAgent_1.isEngine('Gecko');
-
- var DOUBLE_NEWLINE = '\n\n';
-
- /**
- * This function is intended to handle spellcheck and autocorrect changes,
- * which occur in the DOM natively without any opportunity to observe or
- * interpret the changes before they occur.
- *
- * The `input` event fires in contentEditable elements reliably for non-IE
- * browsers, immediately after changes occur to the editor DOM. Since our other
- * handlers override or otherwise handle cover other varieties of text input,
- * the DOM state should match the model in all controlled input cases. Thus,
- * when an `input` change leads to a DOM/model mismatch, the change should be
- * due to a spellcheck change, and we can incorporate it into our model.
- */
- function editOnInput(editor) {
- if (editor._pendingStateFromBeforeInput !== undefined) {
- editor.update(editor._pendingStateFromBeforeInput);
- editor._pendingStateFromBeforeInput = undefined;
- }
-
- var domSelection = commonjsGlobal.getSelection();
-
- var anchorNode = domSelection.anchorNode,
- isCollapsed = domSelection.isCollapsed;
-
- var isNotTextNode = anchorNode.nodeType !== Node.TEXT_NODE;
- var isNotTextOrElementNode = anchorNode.nodeType !== Node.TEXT_NODE && anchorNode.nodeType !== Node.ELEMENT_NODE;
-
- {
- if (isNotTextOrElementNode) {
- // TODO: (t16149272) figure out context for this change
- return;
- }
- }
-
- if (anchorNode.nodeType === Node.TEXT_NODE && (anchorNode.previousSibling !== null || anchorNode.nextSibling !== null)) {
- // When typing at the beginning of a visual line, Chrome splits the text
- // nodes into two. Why? No one knows. This commit is suspicious:
- // https://chromium.googlesource.com/chromium/src/+/a3b600981286b135632371477f902214c55a1724
- // To work around, we'll merge the sibling text nodes back into this one.
- var span = anchorNode.parentNode;
- anchorNode.nodeValue = span.textContent;
- for (var child = span.firstChild; child !== null; child = child.nextSibling) {
- if (child !== anchorNode) {
- span.removeChild(child);
- }
- }
- }
-
- var domText = anchorNode.textContent;
- var editorState = editor._latestEditorState;
- var offsetKey = nullthrows_1(findAncestorOffsetKey_1(anchorNode));
-
- var _DraftOffsetKey$decod = DraftOffsetKey_1.decode(offsetKey),
- blockKey = _DraftOffsetKey$decod.blockKey,
- decoratorKey = _DraftOffsetKey$decod.decoratorKey,
- leafKey = _DraftOffsetKey$decod.leafKey;
-
- var _editorState$getBlock = editorState.getBlockTree(blockKey).getIn([decoratorKey, 'leaves', leafKey]),
- start = _editorState$getBlock.start,
- end = _editorState$getBlock.end;
-
- var content = editorState.getCurrentContent();
- var block = content.getBlockForKey(blockKey);
- var modelText = block.getText().slice(start, end);
-
- // Special-case soft newlines here. If the DOM text ends in a soft newline,
- // we will have manually inserted an extra soft newline in DraftEditorLeaf.
- // We want to remove this extra newline for the purpose of our comparison
- // of DOM and model text.
- if (domText.endsWith(DOUBLE_NEWLINE)) {
- domText = domText.slice(0, -1);
- }
-
- // No change -- the DOM is up to date. Nothing to do here.
- if (domText === modelText) {
- // This can be buggy for some Android keyboards because they don't fire
- // standard onkeydown/pressed events and only fired editOnInput
- // so domText is already changed by the browser and ends up being equal
- // to modelText unexpectedly
- return;
- }
-
- var selection = editorState.getSelection();
-
- // We'll replace the entire leaf with the text content of the target.
- var targetRange = selection.merge({
- anchorOffset: start,
- focusOffset: end,
- isBackward: false
- });
-
- var entityKey = block.getEntityAt(start);
- var entity = entityKey && content.getEntity(entityKey);
- var entityType = entity && entity.getMutability();
- var preserveEntity = entityType === 'MUTABLE';
-
- // Immutable or segmented entities cannot properly be handled by the
- // default browser undo, so we have to use a different change type to
- // force using our internal undo method instead of falling through to the
- // native browser undo.
- var changeType = preserveEntity ? 'spellcheck-change' : 'apply-entity';
-
- var newContent = DraftModifier_1.replaceText(content, targetRange, domText, block.getInlineStyleAt(start), preserveEntity ? block.getEntityAt(start) : null);
-
- var anchorOffset, focusOffset, startOffset, endOffset;
-
- if (isGecko) {
- // Firefox selection does not change while the context menu is open, so
- // we preserve the anchor and focus values of the DOM selection.
- anchorOffset = domSelection.anchorOffset;
- focusOffset = domSelection.focusOffset;
- startOffset = start + Math.min(anchorOffset, focusOffset);
- endOffset = startOffset + Math.abs(anchorOffset - focusOffset);
- anchorOffset = startOffset;
- focusOffset = endOffset;
- } else {
- // Browsers other than Firefox may adjust DOM selection while the context
- // menu is open, and Safari autocorrect is prone to providing an inaccurate
- // DOM selection. Don't trust it. Instead, use our existing SelectionState
- // and adjust it based on the number of characters changed during the
- // mutation.
- var charDelta = domText.length - modelText.length;
- startOffset = selection.getStartOffset();
- endOffset = selection.getEndOffset();
-
- anchorOffset = isCollapsed ? endOffset + charDelta : startOffset;
- focusOffset = endOffset + charDelta;
- }
-
- // Segmented entities are completely or partially removed when their
- // text content changes. For this case we do not want any text to be selected
- // after the change, so we are not merging the selection.
- var contentWithAdjustedDOMSelection = newContent.merge({
- selectionBefore: content.getSelectionAfter(),
- selectionAfter: selection.merge({ anchorOffset: anchorOffset, focusOffset: focusOffset })
- });
-
- editor.update(EditorState_1.push(editorState, contentWithAdjustedDOMSelection, changeType));
- }
-
- var editOnInput_1 = editOnInput;
-
- var isOSX = UserAgent_1.isPlatform('Mac OS X');
-
- var KeyBindingUtil = {
- /**
- * Check whether the ctrlKey modifier is *not* being used in conjunction with
- * the altKey modifier. If they are combined, the result is an `altGraph`
- * key modifier, which should not be handled by this set of key bindings.
- */
- isCtrlKeyCommand: function isCtrlKeyCommand(e) {
- return !!e.ctrlKey && !e.altKey;
- },
-
- isOptionKeyCommand: function isOptionKeyCommand(e) {
- return isOSX && e.altKey;
- },
-
- hasCommandModifier: function hasCommandModifier(e) {
- return isOSX ? !!e.metaKey && !e.altKey : KeyBindingUtil.isCtrlKeyCommand(e);
- }
- };
-
- var KeyBindingUtil_1 = KeyBindingUtil;
-
- var clipboard = null;
-
- /**
- * Some systems offer a "secondary" clipboard to allow quick internal cut
- * and paste behavior. For instance, Ctrl+K (cut) and Ctrl+Y (paste).
- */
- var SecondaryClipboard = {
- cut: function cut(editorState) {
- var content = editorState.getCurrentContent();
- var selection = editorState.getSelection();
- var targetRange = null;
-
- if (selection.isCollapsed()) {
- var anchorKey = selection.getAnchorKey();
- var blockEnd = content.getBlockForKey(anchorKey).getLength();
-
- if (blockEnd === selection.getAnchorOffset()) {
- return editorState;
- }
-
- targetRange = selection.set('focusOffset', blockEnd);
- } else {
- targetRange = selection;
- }
-
- targetRange = nullthrows_1(targetRange);
- clipboard = getContentStateFragment_1(content, targetRange);
-
- var afterRemoval = DraftModifier_1.removeRange(content, targetRange, 'forward');
-
- if (afterRemoval === content) {
- return editorState;
- }
-
- return EditorState_1.push(editorState, afterRemoval, 'remove-range');
- },
-
- paste: function paste(editorState) {
- if (!clipboard) {
- return editorState;
- }
-
- var newContent = DraftModifier_1.replaceWithFragment(editorState.getCurrentContent(), editorState.getSelection(), clipboard);
-
- return EditorState_1.push(editorState, newContent, 'insert-fragment');
- }
- };
-
- var SecondaryClipboard_1 = SecondaryClipboard;
-
- // These two ranges are consecutive so anything in [HIGH_START, LOW_END] is a
- // surrogate code unit.
- var SURROGATE_HIGH_START = 0xD800;
- var SURROGATE_HIGH_END = 0xDBFF;
- var SURROGATE_LOW_START = 0xDC00;
- var SURROGATE_LOW_END = 0xDFFF;
- var SURROGATE_UNITS_REGEX = /[\uD800-\uDFFF]/;
-
- /**
- * @param {number} codeUnit A Unicode code-unit, in range [0, 0x10FFFF]
- * @return {boolean} Whether code-unit is in a surrogate (hi/low) range
- */
- function isCodeUnitInSurrogateRange(codeUnit) {
- return SURROGATE_HIGH_START <= codeUnit && codeUnit <= SURROGATE_LOW_END;
- }
-
- /**
- * Returns whether the two characters starting at `index` form a surrogate pair.
- * For example, given the string s = "\uD83D\uDE0A", (s, 0) returns true and
- * (s, 1) returns false.
- *
- * @param {string} str
- * @param {number} index
- * @return {boolean}
- */
- function isSurrogatePair(str, index) {
- !(0 <= index && index < str.length) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'isSurrogatePair: Invalid index %s for string length %s.', index, str.length) : invariant_1(false) : void 0;
- if (index + 1 === str.length) {
- return false;
- }
- var first = str.charCodeAt(index);
- var second = str.charCodeAt(index + 1);
- return SURROGATE_HIGH_START <= first && first <= SURROGATE_HIGH_END && SURROGATE_LOW_START <= second && second <= SURROGATE_LOW_END;
- }
-
- /**
- * @param {string} str Non-empty string
- * @return {boolean} True if the input includes any surrogate code units
- */
- function hasSurrogateUnit(str) {
- return SURROGATE_UNITS_REGEX.test(str);
- }
-
- /**
- * Return the length of the original Unicode character at given position in the
- * String by looking into the UTF-16 code unit; that is equal to 1 for any
- * non-surrogate characters in BMP ([U+0000..U+D7FF] and [U+E000, U+FFFF]); and
- * returns 2 for the hi/low surrogates ([U+D800..U+DFFF]), which are in fact
- * representing non-BMP characters ([U+10000..U+10FFFF]).
- *
- * Examples:
- * - '\u0020' => 1
- * - '\u3020' => 1
- * - '\uD835' => 2
- * - '\uD835\uDDEF' => 2
- * - '\uDDEF' => 2
- *
- * @param {string} str Non-empty string
- * @param {number} pos Position in the string to look for one code unit
- * @return {number} Number 1 or 2
- */
- function getUTF16Length(str, pos) {
- return 1 + isCodeUnitInSurrogateRange(str.charCodeAt(pos));
- }
-
- /**
- * Fully Unicode-enabled replacement for String#length
- *
- * @param {string} str Valid Unicode string
- * @return {number} The number of Unicode characters in the string
- */
- function strlen(str) {
- // Call the native functions if there's no surrogate char
- if (!hasSurrogateUnit(str)) {
- return str.length;
- }
-
- var len = 0;
- for (var pos = 0; pos < str.length; pos += getUTF16Length(str, pos)) {
- len++;
- }
- return len;
- }
-
- /**
- * Fully Unicode-enabled replacement for String#substr()
- *
- * @param {string} str Valid Unicode string
- * @param {number} start Location in Unicode sequence to begin extracting
- * @param {?number} length The number of Unicode characters to extract
- * (default: to the end of the string)
- * @return {string} Extracted sub-string
- */
- function substr(str, start, length) {
- start = start || 0;
- length = length === undefined ? Infinity : length || 0;
-
- // Call the native functions if there's no surrogate char
- if (!hasSurrogateUnit(str)) {
- return str.substr(start, length);
- }
-
- // Obvious cases
- var size = str.length;
- if (size <= 0 || start > size || length <= 0) {
- return '';
- }
-
- // Find the actual starting position
- var posA = 0;
- if (start > 0) {
- for (; start > 0 && posA < size; start--) {
- posA += getUTF16Length(str, posA);
- }
- if (posA >= size) {
- return '';
- }
- } else if (start < 0) {
- for (posA = size; start < 0 && 0 < posA; start++) {
- posA -= getUTF16Length(str, posA - 1);
- }
- if (posA < 0) {
- posA = 0;
- }
- }
-
- // Find the actual ending position
- var posB = size;
- if (length < size) {
- for (posB = posA; length > 0 && posB < size; length--) {
- posB += getUTF16Length(str, posB);
- }
- }
-
- return str.substring(posA, posB);
- }
-
- /**
- * Fully Unicode-enabled replacement for String#substring()
- *
- * @param {string} str Valid Unicode string
- * @param {number} start Location in Unicode sequence to begin extracting
- * @param {?number} end Location in Unicode sequence to end extracting
- * (default: end of the string)
- * @return {string} Extracted sub-string
- */
- function substring(str, start, end) {
- start = start || 0;
- end = end === undefined ? Infinity : end || 0;
-
- if (start < 0) {
- start = 0;
- }
- if (end < 0) {
- end = 0;
- }
-
- var length = Math.abs(end - start);
- start = start < end ? start : end;
- return substr(str, start, length);
- }
-
- /**
- * Get a list of Unicode code-points from a String
- *
- * @param {string} str Valid Unicode string
- * @return {array<number>} A list of code-points in [0..0x10FFFF]
- */
- function getCodePoints(str) {
- var codePoints = [];
- for (var pos = 0; pos < str.length; pos += getUTF16Length(str, pos)) {
- codePoints.push(str.codePointAt(pos));
- }
- return codePoints;
- }
-
- var UnicodeUtils = {
- getCodePoints: getCodePoints,
- getUTF16Length: getUTF16Length,
- hasSurrogateUnit: hasSurrogateUnit,
- isCodeUnitInSurrogateRange: isCodeUnitInSurrogateRange,
- isSurrogatePair: isSurrogatePair,
- strlen: strlen,
- substring: substring,
- substr: substr
- };
-
- var UnicodeUtils_1 = UnicodeUtils;
-
- var isChrome = UserAgent_1.isBrowser('Chrome');
-
- // In Chrome, the client rects will include the entire bounds of all nodes that
- // begin (have a start tag) within the selection, even if the selection does
- // not overlap the entire node. To resolve this, we split the range at each
- // start tag and join the client rects together.
- // https://code.google.com/p/chromium/issues/detail?id=324437
- /* eslint-disable consistent-return */
- function getRangeClientRectsChrome(range) {
- var tempRange = range.cloneRange();
- var clientRects = [];
-
- for (var ancestor = range.endContainer; ancestor != null; ancestor = ancestor.parentNode) {
- // If we've climbed up to the common ancestor, we can now use the
- // original start point and stop climbing the tree.
- var atCommonAncestor = ancestor === range.commonAncestorContainer;
- if (atCommonAncestor) {
- tempRange.setStart(range.startContainer, range.startOffset);
- } else {
- tempRange.setStart(tempRange.endContainer, 0);
- }
- var rects = Array.from(tempRange.getClientRects());
- clientRects.push(rects);
- if (atCommonAncestor) {
- var _ref;
-
- clientRects.reverse();
- return (_ref = []).concat.apply(_ref, clientRects);
- }
- tempRange.setEndBefore(ancestor);
- }
-
- process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Found an unexpected detached subtree when getting range client rects.') : invariant_1(false) ;
- }
- /* eslint-enable consistent-return */
-
- /**
- * Like range.getClientRects() but normalizes for browser bugs.
- */
- var getRangeClientRects = isChrome ? getRangeClientRectsChrome : function (range) {
- return Array.from(range.getClientRects());
- };
-
- var getRangeClientRects_1 = getRangeClientRects;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule expandRangeToStartOfLine
- * @format
- *
- */
-
-
-
-
-
-
- /**
- * Return the computed line height, in pixels, for the provided element.
- */
- function getLineHeightPx(element) {
- var computed = getComputedStyle(element);
- var div = document.createElement('div');
- div.style.fontFamily = computed.fontFamily;
- div.style.fontSize = computed.fontSize;
- div.style.fontStyle = computed.fontStyle;
- div.style.fontWeight = computed.fontWeight;
- div.style.lineHeight = computed.lineHeight;
- div.style.position = 'absolute';
- div.textContent = 'M';
-
- var documentBody = document.body;
- !documentBody ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Missing document.body') : invariant_1(false) : void 0;
-
- // forced layout here
- documentBody.appendChild(div);
- var rect = div.getBoundingClientRect();
- documentBody.removeChild(div);
-
- return rect.height;
- }
-
- /**
- * Return whether every ClientRect in the provided list lies on the same line.
- *
- * We assume that the rects on the same line all contain the baseline, so the
- * lowest top line needs to be above the highest bottom line (i.e., if you were
- * to project the rects onto the y-axis, their intersection would be nonempty).
- *
- * In addition, we require that no two boxes are lineHeight (or more) apart at
- * either top or bottom, which helps protect against false positives for fonts
- * with extremely large glyph heights (e.g., with a font size of 17px, Zapfino
- * produces rects of height 58px!).
- */
- function areRectsOnOneLine(rects, lineHeight) {
- var minTop = Infinity;
- var minBottom = Infinity;
- var maxTop = -Infinity;
- var maxBottom = -Infinity;
-
- for (var ii = 0; ii < rects.length; ii++) {
- var rect = rects[ii];
- if (rect.width === 0 || rect.width === 1) {
- // When a range starts or ends a soft wrap, many browsers (Chrome, IE,
- // Safari) include an empty rect on the previous or next line. When the
- // text lies in a container whose position is not integral (e.g., from
- // margin: auto), Safari makes these empty rects have width 1 (instead of
- // 0). Having one-pixel-wide characters seems unlikely (and most browsers
- // report widths in subpixel precision anyway) so it's relatively safe to
- // skip over them.
- continue;
- }
- minTop = Math.min(minTop, rect.top);
- minBottom = Math.min(minBottom, rect.bottom);
- maxTop = Math.max(maxTop, rect.top);
- maxBottom = Math.max(maxBottom, rect.bottom);
- }
-
- return maxTop <= minBottom && maxTop - minTop < lineHeight && maxBottom - minBottom < lineHeight;
- }
-
- /**
- * Return the length of a node, as used by Range offsets.
- */
- function getNodeLength$1(node) {
- // http://www.w3.org/TR/dom/#concept-node-length
- switch (node.nodeType) {
- case Node.DOCUMENT_TYPE_NODE:
- return 0;
- case Node.TEXT_NODE:
- case Node.PROCESSING_INSTRUCTION_NODE:
- case Node.COMMENT_NODE:
- return node.length;
- default:
- return node.childNodes.length;
- }
- }
-
- /**
- * Given a collapsed range, move the start position backwards as far as
- * possible while the range still spans only a single line.
- */
- function expandRangeToStartOfLine(range) {
- !range.collapsed ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'expandRangeToStartOfLine: Provided range is not collapsed.') : invariant_1(false) : void 0;
- range = range.cloneRange();
-
- var containingElement = range.startContainer;
- if (containingElement.nodeType !== 1) {
- containingElement = containingElement.parentNode;
- }
- var lineHeight = getLineHeightPx(containingElement);
-
- // Imagine our text looks like:
- // <div><span>once upon a time, there was a <em>boy
- // who lived</em> </span><q><strong>under^ the
- // stairs</strong> in a small closet.</q></div>
- // where the caret represents the cursor. First, we crawl up the tree until
- // the range spans multiple lines (setting the start point to before
- // "<strong>", then before "<div>"), then at each level we do a search to
- // find the latest point which is still on a previous line. We'll find that
- // the break point is inside the span, then inside the <em>, then in its text
- // node child, the actual break point before "who".
-
- var bestContainer = range.endContainer;
- var bestOffset = range.endOffset;
- range.setStart(range.startContainer, 0);
-
- while (areRectsOnOneLine(getRangeClientRects_1(range), lineHeight)) {
- bestContainer = range.startContainer;
- bestOffset = range.startOffset;
- !bestContainer.parentNode ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Found unexpected detached subtree when traversing.') : invariant_1(false) : void 0;
- range.setStartBefore(bestContainer);
- if (bestContainer.nodeType === 1 && getComputedStyle(bestContainer).display !== 'inline') {
- // The start of the line is never in a different block-level container.
- break;
- }
- }
-
- // In the above example, range now spans from "<div>" to "under",
- // bestContainer is <div>, and bestOffset is 1 (index of <q> inside <div>)].
- // Picking out which child to recurse into here is a special case since we
- // don't want to check past <q> -- once we find that the final range starts
- // in <span>, we can look at all of its children (and all of their children)
- // to find the break point.
-
- // At all times, (bestContainer, bestOffset) is the latest single-line start
- // point that we know of.
- var currentContainer = bestContainer;
- var maxIndexToConsider = bestOffset - 1;
-
- do {
- var nodeValue = currentContainer.nodeValue;
-
- for (var ii = maxIndexToConsider; ii >= 0; ii--) {
- if (nodeValue != null && ii > 0 && UnicodeUtils_1.isSurrogatePair(nodeValue, ii - 1)) {
- // We're in the middle of a surrogate pair -- skip over so we never
- // return a range with an endpoint in the middle of a code point.
- continue;
- }
-
- range.setStart(currentContainer, ii);
- if (areRectsOnOneLine(getRangeClientRects_1(range), lineHeight)) {
- bestContainer = currentContainer;
- bestOffset = ii;
- } else {
- break;
- }
- }
-
- if (ii === -1 || currentContainer.childNodes.length === 0) {
- // If ii === -1, then (bestContainer, bestOffset), which is equal to
- // (currentContainer, 0), was a single-line start point but a start
- // point before currentContainer wasn't, so the line break seems to
- // have occurred immediately after currentContainer's start tag
- //
- // If currentContainer.childNodes.length === 0, we're already at a
- // terminal node (e.g., text node) and should return our current best.
- break;
- }
-
- currentContainer = currentContainer.childNodes[ii];
- maxIndexToConsider = getNodeLength$1(currentContainer);
- } while (true);
-
- range.setStart(bestContainer, bestOffset);
- return range;
- }
-
- var expandRangeToStartOfLine_1 = expandRangeToStartOfLine;
-
- /**
- * Convert the current selection range to an anchor/focus pair of offset keys
- * and values that can be interpreted by components.
- */
- function getDraftEditorSelectionWithNodes(editorState, root, anchorNode, anchorOffset, focusNode, focusOffset) {
- var anchorIsTextNode = anchorNode.nodeType === Node.TEXT_NODE;
- var focusIsTextNode = focusNode.nodeType === Node.TEXT_NODE;
-
- // If the selection range lies only on text nodes, the task is simple.
- // Find the nearest offset-aware elements and use the
- // offset values supplied by the selection range.
- if (anchorIsTextNode && focusIsTextNode) {
- return {
- selectionState: getUpdatedSelectionState_1(editorState, nullthrows_1(findAncestorOffsetKey_1(anchorNode)), anchorOffset, nullthrows_1(findAncestorOffsetKey_1(focusNode)), focusOffset),
- needsRecovery: false
- };
- }
-
- var anchorPoint = null;
- var focusPoint = null;
- var needsRecovery = true;
-
- // An element is selected. Convert this selection range into leaf offset
- // keys and offset values for consumption at the component level. This
- // is common in Firefox, where select-all and triple click behavior leads
- // to entire elements being selected.
- //
- // Note that we use the `needsRecovery` parameter in the callback here. This
- // is because when certain elements are selected, the behavior for subsequent
- // cursor movement (e.g. via arrow keys) is uncertain and may not match
- // expectations at the component level. For example, if an entire <div> is
- // selected and the user presses the right arrow, Firefox keeps the selection
- // on the <div>. If we allow subsequent keypresses to insert characters
- // natively, they will be inserted into a browser-created text node to the
- // right of that <div>. This is obviously undesirable.
- //
- // With the `needsRecovery` flag, we inform the caller that it is responsible
- // for manually setting the selection state on the rendered document to
- // ensure proper selection state maintenance.
-
- if (anchorIsTextNode) {
- anchorPoint = {
- key: nullthrows_1(findAncestorOffsetKey_1(anchorNode)),
- offset: anchorOffset
- };
- focusPoint = getPointForNonTextNode(root, focusNode, focusOffset);
- } else if (focusIsTextNode) {
- focusPoint = {
- key: nullthrows_1(findAncestorOffsetKey_1(focusNode)),
- offset: focusOffset
- };
- anchorPoint = getPointForNonTextNode(root, anchorNode, anchorOffset);
- } else {
- anchorPoint = getPointForNonTextNode(root, anchorNode, anchorOffset);
- focusPoint = getPointForNonTextNode(root, focusNode, focusOffset);
-
- // If the selection is collapsed on an empty block, don't force recovery.
- // This way, on arrow key selection changes, the browser can move the
- // cursor from a non-zero offset on one block, through empty blocks,
- // to a matching non-zero offset on other text blocks.
- if (anchorNode === focusNode && anchorOffset === focusOffset) {
- needsRecovery = !!anchorNode.firstChild && anchorNode.firstChild.nodeName !== 'BR';
- }
- }
-
- return {
- selectionState: getUpdatedSelectionState_1(editorState, anchorPoint.key, anchorPoint.offset, focusPoint.key, focusPoint.offset),
- needsRecovery: needsRecovery
- };
- }
-
- /**
- * Identify the first leaf descendant for the given node.
- */
- function getFirstLeaf(node) {
- while (node.firstChild && (
- // data-blocks has no offset
- node.firstChild instanceof Element && node.firstChild.getAttribute('data-blocks') === 'true' || getSelectionOffsetKeyForNode_1(node.firstChild))) {
- node = node.firstChild;
- }
- return node;
- }
-
- /**
- * Identify the last leaf descendant for the given node.
- */
- function getLastLeaf(node) {
- while (node.lastChild && (
- // data-blocks has no offset
- node.lastChild instanceof Element && node.lastChild.getAttribute('data-blocks') === 'true' || getSelectionOffsetKeyForNode_1(node.lastChild))) {
- node = node.lastChild;
- }
- return node;
- }
-
- function getPointForNonTextNode(editorRoot, startNode, childOffset) {
- var node = startNode;
- var offsetKey = findAncestorOffsetKey_1(node);
-
- !(offsetKey != null || editorRoot && (editorRoot === node || editorRoot.firstChild === node)) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Unknown node in selection range.') : invariant_1(false) : void 0;
-
- // If the editorRoot is the selection, step downward into the content
- // wrapper.
- if (editorRoot === node) {
- node = node.firstChild;
- !(node instanceof Element && node.getAttribute('data-contents') === 'true') ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Invalid DraftEditorContents structure.') : invariant_1(false) : void 0;
- if (childOffset > 0) {
- childOffset = node.childNodes.length;
- }
- }
-
- // If the child offset is zero and we have an offset key, we're done.
- // If there's no offset key because the entire editor is selected,
- // find the leftmost ("first") leaf in the tree and use that as the offset
- // key.
- if (childOffset === 0) {
- var key = null;
- if (offsetKey != null) {
- key = offsetKey;
- } else {
- var firstLeaf = getFirstLeaf(node);
- key = nullthrows_1(getSelectionOffsetKeyForNode_1(firstLeaf));
- }
- return { key: key, offset: 0 };
- }
-
- var nodeBeforeCursor = node.childNodes[childOffset - 1];
- var leafKey = null;
- var textLength = null;
-
- if (!getSelectionOffsetKeyForNode_1(nodeBeforeCursor)) {
- // Our target node may be a leaf or a text node, in which case we're
- // already where we want to be and can just use the child's length as
- // our offset.
- leafKey = nullthrows_1(offsetKey);
- textLength = getTextContentLength(nodeBeforeCursor);
- } else {
- // Otherwise, we'll look at the child to the left of the cursor and find
- // the last leaf node in its subtree.
- var lastLeaf = getLastLeaf(nodeBeforeCursor);
- leafKey = nullthrows_1(getSelectionOffsetKeyForNode_1(lastLeaf));
- textLength = getTextContentLength(lastLeaf);
- }
-
- return {
- key: leafKey,
- offset: textLength
- };
- }
-
- /**
- * Return the length of a node's textContent, regarding single newline
- * characters as zero-length. This allows us to avoid problems with identifying
- * the correct selection offset for empty blocks in IE, in which we
- * render newlines instead of break tags.
- */
- function getTextContentLength(node) {
- var textContent = node.textContent;
- return textContent === '\n' ? 0 : textContent.length;
- }
-
- var getDraftEditorSelectionWithNodes_1 = getDraftEditorSelectionWithNodes;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule moveSelectionBackward
- * @format
- *
- */
-
- /**
- * Given a collapsed selection, move the focus `maxDistance` backward within
- * the selected block. If the selection will go beyond the start of the block,
- * move focus to the end of the previous block, but no further.
- *
- * This function is not Unicode-aware, so surrogate pairs will be treated
- * as having length 2.
- */
- function moveSelectionBackward(editorState, maxDistance) {
- var selection = editorState.getSelection();
- var content = editorState.getCurrentContent();
- var key = selection.getStartKey();
- var offset = selection.getStartOffset();
-
- var focusKey = key;
- var focusOffset = 0;
-
- if (maxDistance > offset) {
- var keyBefore = content.getKeyBefore(key);
- if (keyBefore == null) {
- focusKey = key;
- } else {
- focusKey = keyBefore;
- var blockBefore = content.getBlockForKey(keyBefore);
- focusOffset = blockBefore.getText().length;
- }
- } else {
- focusOffset = offset - maxDistance;
- }
-
- return selection.merge({
- focusKey: focusKey,
- focusOffset: focusOffset,
- isBackward: true
- });
- }
-
- var moveSelectionBackward_1 = moveSelectionBackward;
-
- /**
- * For a collapsed selection state, remove text based on the specified strategy.
- * If the selection state is not collapsed, remove the entire selected range.
- */
- function removeTextWithStrategy(editorState, strategy, direction) {
- var selection = editorState.getSelection();
- var content = editorState.getCurrentContent();
- var target = selection;
- if (selection.isCollapsed()) {
- if (direction === 'forward') {
- if (editorState.isSelectionAtEndOfContent()) {
- return content;
- }
- } else if (editorState.isSelectionAtStartOfContent()) {
- return content;
- }
-
- target = strategy(editorState);
- if (target === selection) {
- return content;
- }
- }
- return DraftModifier_1.removeRange(content, target, direction);
- }
-
- var removeTextWithStrategy_1 = removeTextWithStrategy;
-
- function keyCommandBackspaceToStartOfLine(editorState) {
- var afterRemoval = removeTextWithStrategy_1(editorState, function (strategyState) {
- var selection = strategyState.getSelection();
- if (selection.isCollapsed() && selection.getAnchorOffset() === 0) {
- return moveSelectionBackward_1(strategyState, 1);
- }
-
- var domSelection = commonjsGlobal.getSelection();
- var range = domSelection.getRangeAt(0);
- range = expandRangeToStartOfLine_1(range);
-
- return getDraftEditorSelectionWithNodes_1(strategyState, null, range.endContainer, range.endOffset, range.startContainer, range.startOffset).selectionState;
- }, 'backward');
-
- if (afterRemoval === editorState.getCurrentContent()) {
- return editorState;
- }
-
- return EditorState_1.push(editorState, afterRemoval, 'remove-range');
- }
-
- var keyCommandBackspaceToStartOfLine_1 = keyCommandBackspaceToStartOfLine;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @typechecks
- * @stub
- *
- */
-
- // \u00a1-\u00b1\u00b4-\u00b8\u00ba\u00bb\u00bf
- // is latin supplement punctuation except fractions and superscript
- // numbers
- // \u2010-\u2027\u2030-\u205e
- // is punctuation from the general punctuation block:
- // weird quotes, commas, bullets, dashes, etc.
- // \u30fb\u3001\u3002\u3008-\u3011\u3014-\u301f
- // is CJK punctuation
- // \uff1a-\uff1f\uff01-\uff0f\uff3b-\uff40\uff5b-\uff65
- // is some full-width/half-width punctuation
- // \u2E2E\u061f\u066a-\u066c\u061b\u060c\u060d\uFD3e\uFD3F
- // is some Arabic punctuation marks
- // \u1801\u0964\u104a\u104b
- // is misc. other language punctuation marks
-
- var PUNCTUATION = '[.,+*?$|#{}()\'\\^\\-\\[\\]\\\\\\/!@%"~=<>_:;' + '\u30FB\u3001\u3002\u3008-\u3011\u3014-\u301F\uFF1A-\uFF1F\uFF01-\uFF0F' + '\uFF3B-\uFF40\uFF5B-\uFF65\u2E2E\u061F\u066A-\u066C\u061B\u060C\u060D' + '\uFD3E\uFD3F\u1801\u0964\u104A\u104B\u2010-\u2027\u2030-\u205E' + '\xA1-\xB1\xB4-\xB8\xBA\xBB\xBF]';
-
- var TokenizeUtil = {
- getPunctuation: function getPunctuation() {
- return PUNCTUATION;
- }
- };
-
- var punctuation = TokenizeUtil.getPunctuation();
-
- // The apostrophe and curly single quotes behave in a curious way: when
- // surrounded on both sides by word characters, they behave as word chars; when
- // either neighbor is punctuation or an end of the string, they behave as
- // punctuation.
- var CHAMELEON_CHARS = '[\'\u2018\u2019]';
-
- // Remove the underscore, which should count as part of the removable word. The
- // "chameleon chars" also count as punctuation in this regex.
- var WHITESPACE_AND_PUNCTUATION = '\\s|(?![_])' + punctuation;
-
- var DELETE_STRING = '^' + '(?:' + WHITESPACE_AND_PUNCTUATION + ')*' + '(?:' + CHAMELEON_CHARS + '|(?!' + WHITESPACE_AND_PUNCTUATION + ').)*' + '(?:(?!' + WHITESPACE_AND_PUNCTUATION + ').)';
- var DELETE_REGEX = new RegExp(DELETE_STRING);
-
- var BACKSPACE_STRING = '(?:(?!' + WHITESPACE_AND_PUNCTUATION + ').)' + '(?:' + CHAMELEON_CHARS + '|(?!' + WHITESPACE_AND_PUNCTUATION + ').)*' + '(?:' + WHITESPACE_AND_PUNCTUATION + ')*' + '$';
- var BACKSPACE_REGEX = new RegExp(BACKSPACE_STRING);
-
- function getRemovableWord(text, isBackward) {
- var matches = isBackward ? BACKSPACE_REGEX.exec(text) : DELETE_REGEX.exec(text);
- return matches ? matches[0] : text;
- }
-
- var DraftRemovableWord = {
- getBackward: function getBackward(text) {
- return getRemovableWord(text, true);
- },
-
- getForward: function getForward(text) {
- return getRemovableWord(text, false);
- }
- };
-
- var DraftRemovableWord_1 = DraftRemovableWord;
-
- /**
- * Delete the word that is left of the cursor, as well as any spaces or
- * punctuation after the word.
- */
- function keyCommandBackspaceWord(editorState) {
- var afterRemoval = removeTextWithStrategy_1(editorState, function (strategyState) {
- var selection = strategyState.getSelection();
- var offset = selection.getStartOffset();
- // If there are no words before the cursor, remove the preceding newline.
- if (offset === 0) {
- return moveSelectionBackward_1(strategyState, 1);
- }
- var key = selection.getStartKey();
- var content = strategyState.getCurrentContent();
- var text = content.getBlockForKey(key).getText().slice(0, offset);
- var toRemove = DraftRemovableWord_1.getBackward(text);
- return moveSelectionBackward_1(strategyState, toRemove.length || 1);
- }, 'backward');
-
- if (afterRemoval === editorState.getCurrentContent()) {
- return editorState;
- }
-
- return EditorState_1.push(editorState, afterRemoval, 'remove-range');
- }
-
- var keyCommandBackspaceWord_1 = keyCommandBackspaceWord;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule moveSelectionForward
- * @format
- *
- */
-
- /**
- * Given a collapsed selection, move the focus `maxDistance` forward within
- * the selected block. If the selection will go beyond the end of the block,
- * move focus to the start of the next block, but no further.
- *
- * This function is not Unicode-aware, so surrogate pairs will be treated
- * as having length 2.
- */
- function moveSelectionForward(editorState, maxDistance) {
- var selection = editorState.getSelection();
- var key = selection.getStartKey();
- var offset = selection.getStartOffset();
- var content = editorState.getCurrentContent();
-
- var focusKey = key;
- var focusOffset;
-
- var block = content.getBlockForKey(key);
-
- if (maxDistance > block.getText().length - offset) {
- focusKey = content.getKeyAfter(key);
- focusOffset = 0;
- } else {
- focusOffset = offset + maxDistance;
- }
-
- return selection.merge({ focusKey: focusKey, focusOffset: focusOffset });
- }
-
- var moveSelectionForward_1 = moveSelectionForward;
-
- /**
- * Delete the word that is right of the cursor, as well as any spaces or
- * punctuation before the word.
- */
- function keyCommandDeleteWord(editorState) {
- var afterRemoval = removeTextWithStrategy_1(editorState, function (strategyState) {
- var selection = strategyState.getSelection();
- var offset = selection.getStartOffset();
- var key = selection.getStartKey();
- var content = strategyState.getCurrentContent();
- var text = content.getBlockForKey(key).getText().slice(offset);
- var toRemove = DraftRemovableWord_1.getForward(text);
-
- // If there are no words in front of the cursor, remove the newline.
- return moveSelectionForward_1(strategyState, toRemove.length || 1);
- }, 'forward');
-
- if (afterRemoval === editorState.getCurrentContent()) {
- return editorState;
- }
-
- return EditorState_1.push(editorState, afterRemoval, 'remove-range');
- }
-
- var keyCommandDeleteWord_1 = keyCommandDeleteWord;
-
- function keyCommandInsertNewline(editorState) {
- var contentState = DraftModifier_1.splitBlock(editorState.getCurrentContent(), editorState.getSelection());
- return EditorState_1.push(editorState, contentState, 'split-block');
- }
-
- var keyCommandInsertNewline_1 = keyCommandInsertNewline;
-
- /**
- * See comment for `moveSelectionToStartOfBlock`.
- */
- function keyCommandMoveSelectionToEndOfBlock(editorState) {
- var selection = editorState.getSelection();
- var endKey = selection.getEndKey();
- var content = editorState.getCurrentContent();
- var textLength = content.getBlockForKey(endKey).getLength();
- return EditorState_1.set(editorState, {
- selection: selection.merge({
- anchorKey: endKey,
- anchorOffset: textLength,
- focusKey: endKey,
- focusOffset: textLength,
- isBackward: false
- }),
- forceSelection: true
- });
- }
-
- var keyCommandMoveSelectionToEndOfBlock_1 = keyCommandMoveSelectionToEndOfBlock;
-
- /**
- * Collapse selection at the start of the first selected block. This is used
- * for Firefox versions that attempt to navigate forward/backward instead of
- * moving the cursor. Other browsers are able to move the cursor natively.
- */
- function keyCommandMoveSelectionToStartOfBlock(editorState) {
- var selection = editorState.getSelection();
- var startKey = selection.getStartKey();
- return EditorState_1.set(editorState, {
- selection: selection.merge({
- anchorKey: startKey,
- anchorOffset: 0,
- focusKey: startKey,
- focusOffset: 0,
- isBackward: false
- }),
- forceSelection: true
- });
- }
-
- var keyCommandMoveSelectionToStartOfBlock_1 = keyCommandMoveSelectionToStartOfBlock;
-
- /**
- * Remove the selected range. If the cursor is collapsed, remove the preceding
- * character. This operation is Unicode-aware, so removing a single character
- * will remove a surrogate pair properly as well.
- */
- function keyCommandPlainBackspace(editorState) {
- var afterRemoval = removeTextWithStrategy_1(editorState, function (strategyState) {
- var selection = strategyState.getSelection();
- var content = strategyState.getCurrentContent();
- var key = selection.getAnchorKey();
- var offset = selection.getAnchorOffset();
- var charBehind = content.getBlockForKey(key).getText()[offset - 1];
- return moveSelectionBackward_1(strategyState, charBehind ? UnicodeUtils_1.getUTF16Length(charBehind, 0) : 1);
- }, 'backward');
-
- if (afterRemoval === editorState.getCurrentContent()) {
- return editorState;
- }
-
- var selection = editorState.getSelection();
- return EditorState_1.push(editorState, afterRemoval.set('selectionBefore', selection), selection.isCollapsed() ? 'backspace-character' : 'remove-range');
- }
-
- var keyCommandPlainBackspace_1 = keyCommandPlainBackspace;
-
- /**
- * Remove the selected range. If the cursor is collapsed, remove the following
- * character. This operation is Unicode-aware, so removing a single character
- * will remove a surrogate pair properly as well.
- */
- function keyCommandPlainDelete(editorState) {
- var afterRemoval = removeTextWithStrategy_1(editorState, function (strategyState) {
- var selection = strategyState.getSelection();
- var content = strategyState.getCurrentContent();
- var key = selection.getAnchorKey();
- var offset = selection.getAnchorOffset();
- var charAhead = content.getBlockForKey(key).getText()[offset];
- return moveSelectionForward_1(strategyState, charAhead ? UnicodeUtils_1.getUTF16Length(charAhead, 0) : 1);
- }, 'forward');
-
- if (afterRemoval === editorState.getCurrentContent()) {
- return editorState;
- }
-
- var selection = editorState.getSelection();
-
- return EditorState_1.push(editorState, afterRemoval.set('selectionBefore', selection), selection.isCollapsed() ? 'delete-character' : 'remove-range');
- }
-
- var keyCommandPlainDelete_1 = keyCommandPlainDelete;
-
- /**
- * Transpose the characters on either side of a collapsed cursor, or
- * if the cursor is at the end of the block, transpose the last two
- * characters.
- */
- function keyCommandTransposeCharacters(editorState) {
- var selection = editorState.getSelection();
- if (!selection.isCollapsed()) {
- return editorState;
- }
-
- var offset = selection.getAnchorOffset();
- if (offset === 0) {
- return editorState;
- }
-
- var blockKey = selection.getAnchorKey();
- var content = editorState.getCurrentContent();
- var block = content.getBlockForKey(blockKey);
- var length = block.getLength();
-
- // Nothing to transpose if there aren't two characters.
- if (length <= 1) {
- return editorState;
- }
-
- var removalRange;
- var finalSelection;
-
- if (offset === length) {
- // The cursor is at the end of the block. Swap the last two characters.
- removalRange = selection.set('anchorOffset', offset - 1);
- finalSelection = selection;
- } else {
- removalRange = selection.set('focusOffset', offset + 1);
- finalSelection = removalRange.set('anchorOffset', offset + 1);
- }
-
- // Extract the character to move as a fragment. This preserves its
- // styling and entity, if any.
- var movedFragment = getContentStateFragment_1(content, removalRange);
- var afterRemoval = DraftModifier_1.removeRange(content, removalRange, 'backward');
-
- // After the removal, the insertion target is one character back.
- var selectionAfter = afterRemoval.getSelectionAfter();
- var targetOffset = selectionAfter.getAnchorOffset() - 1;
- var targetRange = selectionAfter.merge({
- anchorOffset: targetOffset,
- focusOffset: targetOffset
- });
-
- var afterInsert = DraftModifier_1.replaceWithFragment(afterRemoval, targetRange, movedFragment);
-
- var newEditorState = EditorState_1.push(editorState, afterInsert, 'insert-fragment');
-
- return EditorState_1.acceptSelection(newEditorState, finalSelection);
- }
-
- var keyCommandTransposeCharacters_1 = keyCommandTransposeCharacters;
-
- function keyCommandUndo(e, editorState, updateFn) {
- var undoneState = EditorState_1.undo(editorState);
-
- // If the last change to occur was a spellcheck change, allow the undo
- // event to fall through to the browser. This allows the browser to record
- // the unwanted change, which should soon lead it to learn not to suggest
- // the correction again.
- if (editorState.getLastChangeType() === 'spellcheck-change') {
- var nativelyRenderedContent = undoneState.getCurrentContent();
- updateFn(EditorState_1.set(undoneState, { nativelyRenderedContent: nativelyRenderedContent }));
- return;
- }
-
- // Otheriwse, manage the undo behavior manually.
- e.preventDefault();
- if (!editorState.getNativelyRenderedContent()) {
- updateFn(undoneState);
- return;
- }
-
- // Trigger a re-render with the current content state to ensure that the
- // component tree has up-to-date props for comparison.
- updateFn(EditorState_1.set(editorState, { nativelyRenderedContent: null }));
-
- // Wait to ensure that the re-render has occurred before performing
- // the undo action.
- setTimeout(function () {
- updateFn(undoneState);
- }, 0);
- }
-
- var keyCommandUndo_1 = keyCommandUndo;
-
- var isOptionKeyCommand = KeyBindingUtil_1.isOptionKeyCommand;
-
- var isChrome$1 = UserAgent_1.isBrowser('Chrome');
-
- /**
- * Map a `DraftEditorCommand` command value to a corresponding function.
- */
- function onKeyCommand(command, editorState) {
- switch (command) {
- case 'redo':
- return EditorState_1.redo(editorState);
- case 'delete':
- return keyCommandPlainDelete_1(editorState);
- case 'delete-word':
- return keyCommandDeleteWord_1(editorState);
- case 'backspace':
- return keyCommandPlainBackspace_1(editorState);
- case 'backspace-word':
- return keyCommandBackspaceWord_1(editorState);
- case 'backspace-to-start-of-line':
- return keyCommandBackspaceToStartOfLine_1(editorState);
- case 'split-block':
- return keyCommandInsertNewline_1(editorState);
- case 'transpose-characters':
- return keyCommandTransposeCharacters_1(editorState);
- case 'move-selection-to-start-of-block':
- return keyCommandMoveSelectionToStartOfBlock_1(editorState);
- case 'move-selection-to-end-of-block':
- return keyCommandMoveSelectionToEndOfBlock_1(editorState);
- case 'secondary-cut':
- return SecondaryClipboard_1.cut(editorState);
- case 'secondary-paste':
- return SecondaryClipboard_1.paste(editorState);
- default:
- return editorState;
- }
- }
-
- /**
- * Intercept keydown behavior to handle keys and commands manually, if desired.
- *
- * Keydown combinations may be mapped to `DraftCommand` values, which may
- * correspond to command functions that modify the editor or its contents.
- *
- * See `getDefaultKeyBinding` for defaults. Alternatively, the top-level
- * component may provide a custom mapping via the `keyBindingFn` prop.
- */
- function editOnKeyDown(editor, e) {
- var keyCode = e.which;
- var editorState = editor._latestEditorState;
-
- switch (keyCode) {
- case Keys.RETURN:
- e.preventDefault();
- // The top-level component may manually handle newline insertion. If
- // no special handling is performed, fall through to command handling.
- if (editor.props.handleReturn && isEventHandled_1(editor.props.handleReturn(e, editorState))) {
- return;
- }
- break;
- case Keys.ESC:
- e.preventDefault();
- editor.props.onEscape && editor.props.onEscape(e);
- return;
- case Keys.TAB:
- editor.props.onTab && editor.props.onTab(e);
- return;
- case Keys.UP:
- editor.props.onUpArrow && editor.props.onUpArrow(e);
- return;
- case Keys.RIGHT:
- editor.props.onRightArrow && editor.props.onRightArrow(e);
- return;
- case Keys.DOWN:
- editor.props.onDownArrow && editor.props.onDownArrow(e);
- return;
- case Keys.LEFT:
- editor.props.onLeftArrow && editor.props.onLeftArrow(e);
- return;
- case Keys.SPACE:
- // Handling for OSX where option + space scrolls.
- if (isChrome$1 && isOptionKeyCommand(e)) {
- e.preventDefault();
- // Insert a nbsp into the editor.
- var contentState = DraftModifier_1.replaceText(editorState.getCurrentContent(), editorState.getSelection(), '\xA0');
- editor.update(EditorState_1.push(editorState, contentState, 'insert-characters'));
- return;
- }
- }
-
- var command = editor.props.keyBindingFn(e);
-
- // If no command is specified, allow keydown event to continue.
- if (!command) {
- return;
- }
-
- if (command === 'undo') {
- // Since undo requires some special updating behavior to keep the editor
- // in sync, handle it separately.
- keyCommandUndo_1(e, editorState, editor.update);
- return;
- }
-
- // At this point, we know that we're handling a command of some kind, so
- // we don't want to insert a character following the keydown.
- e.preventDefault();
-
- // Allow components higher up the tree to handle the command first.
- if (editor.props.handleKeyCommand && isEventHandled_1(editor.props.handleKeyCommand(command, editorState))) {
- return;
- }
-
- var newState = onKeyCommand(command, editorState);
- if (newState !== editorState) {
- editor.update(newState);
- }
- }
-
- var editOnKeyDown_1 = editOnKeyDown;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- *
- */
-
- function _classCallCheck$e(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- var URI = function () {
- function URI(uri) {
- _classCallCheck$e(this, URI);
-
- this._uri = uri;
- }
-
- URI.prototype.toString = function toString() {
- return this._uri;
- };
-
- return URI;
- }();
-
- var URI_1 = URI;
-
- var isOldIE = UserAgent_1.isBrowser('IE <= 9');
-
- // Provides a dom node that will not execute scripts
- // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation.createHTMLDocument
- // https://developer.mozilla.org/en-US/Add-ons/Code_snippets/HTML_to_DOM
-
- function getSafeBodyFromHTML(html) {
- var doc;
- var root = null;
- // Provides a safe context
- if (!isOldIE && document.implementation && document.implementation.createHTMLDocument) {
- doc = document.implementation.createHTMLDocument('foo');
- !doc.documentElement ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Missing doc.documentElement') : invariant_1(false) : void 0;
- doc.documentElement.innerHTML = html;
- root = doc.getElementsByTagName('body')[0];
- }
- return root;
- }
-
- var getSafeBodyFromHTML_1 = getSafeBodyFromHTML;
-
- var _extends$4 = objectAssign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
-
- var _knownListItemDepthCl;
-
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-
-
-
-
-
-
-
-
-
- var _require = immutable,
- Set = _require.Set;
-
-
-
-
-
-
-
-
-
- var experimentalTreeDataSupport = DraftFeatureFlags_1.draft_tree_data_support;
-
- var List$a = immutable.List,
- OrderedSet$5 = immutable.OrderedSet;
-
-
- var NBSP = ' ';
- var SPACE = ' ';
-
- // Arbitrary max indent
- var MAX_DEPTH = 4;
-
- // used for replacing characters in HTML
- var REGEX_CR = new RegExp('\r', 'g');
- var REGEX_LF = new RegExp('\n', 'g');
- var REGEX_NBSP = new RegExp(NBSP, 'g');
- var REGEX_CARRIAGE = new RegExp(' ?', 'g');
- var REGEX_ZWS = new RegExp('​?', 'g');
-
- // https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
- var boldValues = ['bold', 'bolder', '500', '600', '700', '800', '900'];
- var notBoldValues = ['light', 'lighter', '100', '200', '300', '400'];
-
- // Block tag flow is different because LIs do not have
- // a deterministic style ;_;
- var inlineTags = {
- b: 'BOLD',
- code: 'CODE',
- del: 'STRIKETHROUGH',
- em: 'ITALIC',
- i: 'ITALIC',
- s: 'STRIKETHROUGH',
- strike: 'STRIKETHROUGH',
- strong: 'BOLD',
- u: 'UNDERLINE'
- };
-
- var knownListItemDepthClasses = (_knownListItemDepthCl = {}, _defineProperty(_knownListItemDepthCl, cx_1('public/DraftStyleDefault/depth0'), 0), _defineProperty(_knownListItemDepthCl, cx_1('public/DraftStyleDefault/depth1'), 1), _defineProperty(_knownListItemDepthCl, cx_1('public/DraftStyleDefault/depth2'), 2), _defineProperty(_knownListItemDepthCl, cx_1('public/DraftStyleDefault/depth3'), 3), _defineProperty(_knownListItemDepthCl, cx_1('public/DraftStyleDefault/depth4'), 4), _knownListItemDepthCl);
-
- var anchorAttr = ['className', 'href', 'rel', 'target', 'title'];
-
- var imgAttr = ['alt', 'className', 'height', 'src', 'width'];
-
- var lastBlock = void 0;
-
- var EMPTY_CHUNK = {
- text: '',
- inlines: [],
- entities: [],
- blocks: []
- };
-
- var EMPTY_BLOCK = {
- children: List$a(),
- depth: 0,
- key: '',
- type: ''
- };
-
- var getListBlockType = function getListBlockType(tag, lastList) {
- if (tag === 'li') {
- return lastList === 'ol' ? 'ordered-list-item' : 'unordered-list-item';
- }
- return null;
- };
-
- var getBlockMapSupportedTags = function getBlockMapSupportedTags(blockRenderMap) {
- var unstyledElement = blockRenderMap.get('unstyled').element;
- var tags = Set([]);
-
- blockRenderMap.forEach(function (draftBlock) {
- if (draftBlock.aliasedElements) {
- draftBlock.aliasedElements.forEach(function (tag) {
- tags = tags.add(tag);
- });
- }
-
- tags = tags.add(draftBlock.element);
- });
-
- return tags.filter(function (tag) {
- return tag && tag !== unstyledElement;
- }).toArray().sort();
- };
-
- // custom element conversions
- var getMultiMatchedType = function getMultiMatchedType(tag, lastList, multiMatchExtractor) {
- for (var ii = 0; ii < multiMatchExtractor.length; ii++) {
- var matchType = multiMatchExtractor[ii](tag, lastList);
- if (matchType) {
- return matchType;
- }
- }
- return null;
- };
-
- var getBlockTypeForTag = function getBlockTypeForTag(tag, lastList, blockRenderMap) {
- var matchedTypes = blockRenderMap.filter(function (draftBlock) {
- return draftBlock.element === tag || draftBlock.wrapper === tag || draftBlock.aliasedElements && draftBlock.aliasedElements.some(function (alias) {
- return alias === tag;
- });
- }).keySeq().toSet().toArray().sort();
-
- // if we dont have any matched type, return unstyled
- // if we have one matched type return it
- // if we have multi matched types use the multi-match function to gather type
- switch (matchedTypes.length) {
- case 0:
- return 'unstyled';
- case 1:
- return matchedTypes[0];
- default:
- return getMultiMatchedType(tag, lastList, [getListBlockType]) || 'unstyled';
- }
- };
-
- var processInlineTag = function processInlineTag(tag, node, currentStyle) {
- var styleToCheck = inlineTags[tag];
- if (styleToCheck) {
- currentStyle = currentStyle.add(styleToCheck).toOrderedSet();
- } else if (node instanceof HTMLElement) {
- var htmlElement = node;
- currentStyle = currentStyle.withMutations(function (style) {
- var fontWeight = htmlElement.style.fontWeight;
- var fontStyle = htmlElement.style.fontStyle;
- var textDecoration = htmlElement.style.textDecoration;
-
- if (boldValues.indexOf(fontWeight) >= 0) {
- style.add('BOLD');
- } else if (notBoldValues.indexOf(fontWeight) >= 0) {
- style.remove('BOLD');
- }
-
- if (fontStyle === 'italic') {
- style.add('ITALIC');
- } else if (fontStyle === 'normal') {
- style.remove('ITALIC');
- }
-
- if (textDecoration === 'underline') {
- style.add('UNDERLINE');
- }
- if (textDecoration === 'line-through') {
- style.add('STRIKETHROUGH');
- }
- if (textDecoration === 'none') {
- style.remove('UNDERLINE');
- style.remove('STRIKETHROUGH');
- }
- }).toOrderedSet();
- }
- return currentStyle;
- };
-
- var joinChunks = function joinChunks(A, B, experimentalHasNestedBlocks) {
- // Sometimes two blocks will touch in the DOM and we need to strip the
- // extra delimiter to preserve niceness.
- var lastInA = A.text.slice(-1);
- var firstInB = B.text.slice(0, 1);
-
- if (lastInA === '\r' && firstInB === '\r' && !experimentalHasNestedBlocks) {
- A.text = A.text.slice(0, -1);
- A.inlines.pop();
- A.entities.pop();
- A.blocks.pop();
- }
-
- // Kill whitespace after blocks
- if (lastInA === '\r') {
- if (B.text === SPACE || B.text === '\n') {
- return A;
- } else if (firstInB === SPACE || firstInB === '\n') {
- B.text = B.text.slice(1);
- B.inlines.shift();
- B.entities.shift();
- }
- }
-
- return {
- text: A.text + B.text,
- inlines: A.inlines.concat(B.inlines),
- entities: A.entities.concat(B.entities),
- blocks: A.blocks.concat(B.blocks)
- };
- };
-
- /**
- * Check to see if we have anything like <p> <blockquote> <h1>... to create
- * block tags from. If we do, we can use those and ignore <div> tags. If we
- * don't, we can treat <div> tags as meaningful (unstyled) blocks.
- */
- var containsSemanticBlockMarkup = function containsSemanticBlockMarkup(html, blockTags) {
- return blockTags.some(function (tag) {
- return html.indexOf('<' + tag) !== -1;
- });
- };
-
- var hasValidLinkText = function hasValidLinkText(link) {
- !(link instanceof HTMLAnchorElement) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Link must be an HTMLAnchorElement.') : invariant_1(false) : void 0;
- var protocol = link.protocol;
- return protocol === 'http:' || protocol === 'https:' || protocol === 'mailto:';
- };
-
- var getWhitespaceChunk = function getWhitespaceChunk(inEntity) {
- var entities = new Array(1);
- if (inEntity) {
- entities[0] = inEntity;
- }
- return _extends$4({}, EMPTY_CHUNK, {
- text: SPACE,
- inlines: [OrderedSet$5()],
- entities: entities
- });
- };
-
- var getSoftNewlineChunk = function getSoftNewlineChunk() {
- return _extends$4({}, EMPTY_CHUNK, {
- text: '\n',
- inlines: [OrderedSet$5()],
- entities: new Array(1)
- });
- };
-
- var getChunkedBlock = function getChunkedBlock() {
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
-
- return _extends$4({}, EMPTY_BLOCK, props);
- };
-
- var getBlockDividerChunk = function getBlockDividerChunk(block, depth) {
- var parentKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
-
- return {
- text: '\r',
- inlines: [OrderedSet$5()],
- entities: new Array(1),
- blocks: [getChunkedBlock({
- parent: parentKey,
- key: generateRandomKey_1(),
- type: block,
- depth: Math.max(0, Math.min(MAX_DEPTH, depth))
- })]
- };
- };
-
- /**
- * If we're pasting from one DraftEditor to another we can check to see if
- * existing list item depth classes are being used and preserve this style
- */
- var getListItemDepth = function getListItemDepth(node) {
- var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
-
- Object.keys(knownListItemDepthClasses).some(function (depthClass) {
- if (node.classList.contains(depthClass)) {
- depth = knownListItemDepthClasses[depthClass];
- }
- });
- return depth;
- };
-
- var genFragment = function genFragment(entityMap, node, inlineStyle, lastList, inBlock, blockTags, depth, blockRenderMap, inEntity, parentKey) {
- var lastLastBlock = lastBlock;
- var nodeName = node.nodeName.toLowerCase();
- var newEntityMap = entityMap;
- var nextBlockType = 'unstyled';
- var newBlock = false;
- var inBlockType = inBlock && getBlockTypeForTag(inBlock, lastList, blockRenderMap);
- var chunk = _extends$4({}, EMPTY_CHUNK);
- var newChunk = null;
- var blockKey = void 0;
-
- // Base Case
- if (nodeName === '#text') {
- var _text = node.textContent;
- var nodeTextContent = _text.trim();
-
- // We should not create blocks for leading spaces that are
- // existing around ol/ul and their children list items
- if (lastList && nodeTextContent === '' && node.parentElement) {
- var parentNodeName = node.parentElement.nodeName.toLowerCase();
- if (parentNodeName === 'ol' || parentNodeName === 'ul') {
- return { chunk: _extends$4({}, EMPTY_CHUNK), entityMap: entityMap };
- }
- }
-
- if (nodeTextContent === '' && inBlock !== 'pre') {
- return { chunk: getWhitespaceChunk(inEntity), entityMap: entityMap };
- }
- if (inBlock !== 'pre') {
- // Can't use empty string because MSWord
- _text = _text.replace(REGEX_LF, SPACE);
- }
-
- // save the last block so we can use it later
- lastBlock = nodeName;
-
- return {
- chunk: {
- text: _text,
- inlines: Array(_text.length).fill(inlineStyle),
- entities: Array(_text.length).fill(inEntity),
- blocks: []
- },
- entityMap: entityMap
- };
- }
-
- // save the last block so we can use it later
- lastBlock = nodeName;
-
- // BR tags
- if (nodeName === 'br') {
- if (lastLastBlock === 'br' && (!inBlock || inBlockType === 'unstyled')) {
- return {
- chunk: getBlockDividerChunk('unstyled', depth, parentKey),
- entityMap: entityMap
- };
- }
- return { chunk: getSoftNewlineChunk(), entityMap: entityMap };
- }
-
- // IMG tags
- if (nodeName === 'img' && node instanceof HTMLImageElement && node.attributes.getNamedItem('src') && node.attributes.getNamedItem('src').value) {
- var image = node;
- var entityConfig = {};
-
- imgAttr.forEach(function (attr) {
- var imageAttribute = image.getAttribute(attr);
- if (imageAttribute) {
- entityConfig[attr] = imageAttribute;
- }
- });
- // Forcing this node to have children because otherwise no entity will be
- // created for this node.
- // The child text node cannot just have a space or return as content -
- // we strip those out.
- // See https://github.com/facebook/draft-js/issues/231 for some context.
- node.textContent = '\uD83D\uDCF7';
-
- // TODO: update this when we remove DraftEntity entirely
- inEntity = DraftEntity_1.__create('IMAGE', 'MUTABLE', entityConfig || {});
- }
-
- // Inline tags
- inlineStyle = processInlineTag(nodeName, node, inlineStyle);
-
- // Handle lists
- if (nodeName === 'ul' || nodeName === 'ol') {
- if (lastList) {
- depth += 1;
- }
- lastList = nodeName;
- }
-
- if ( nodeName === 'li' && node instanceof HTMLElement) {
- depth = getListItemDepth(node, depth);
- }
-
- var blockType = getBlockTypeForTag(nodeName, lastList, blockRenderMap);
- var inListBlock = lastList && inBlock === 'li' && nodeName === 'li';
- var inBlockOrHasNestedBlocks = (!inBlock || experimentalTreeDataSupport) && blockTags.indexOf(nodeName) !== -1;
-
- // Block Tags
- if (inListBlock || inBlockOrHasNestedBlocks) {
- chunk = getBlockDividerChunk(blockType, depth, parentKey);
- blockKey = chunk.blocks[0].key;
- inBlock = nodeName;
- newBlock = !experimentalTreeDataSupport;
- }
-
- // this is required so that we can handle 'ul' and 'ol'
- if (inListBlock) {
- nextBlockType = lastList === 'ul' ? 'unordered-list-item' : 'ordered-list-item';
- }
-
- // Recurse through children
- var child = node.firstChild;
- if (child != null) {
- nodeName = child.nodeName.toLowerCase();
- }
-
- var entityId = null;
-
- while (child) {
- if (child instanceof HTMLAnchorElement && child.href && hasValidLinkText(child)) {
- (function () {
- var anchor = child;
- var entityConfig = {};
-
- anchorAttr.forEach(function (attr) {
- var anchorAttribute = anchor.getAttribute(attr);
- if (anchorAttribute) {
- entityConfig[attr] = anchorAttribute;
- }
- });
-
- entityConfig.url = new URI_1(anchor.href).toString();
- // TODO: update this when we remove DraftEntity completely
- entityId = DraftEntity_1.__create('LINK', 'MUTABLE', entityConfig || {});
- })();
- } else {
- entityId = undefined;
- }
-
- var _genFragment = genFragment(newEntityMap, child, inlineStyle, lastList, inBlock, blockTags, depth, blockRenderMap, entityId || inEntity, null),
- generatedChunk = _genFragment.chunk,
- maybeUpdatedEntityMap = _genFragment.entityMap;
-
- newChunk = generatedChunk;
- newEntityMap = maybeUpdatedEntityMap;
-
- chunk = joinChunks(chunk, newChunk, experimentalTreeDataSupport);
- var sibling = child.nextSibling;
-
- // Put in a newline to break up blocks inside blocks
- if (!parentKey && sibling && blockTags.indexOf(nodeName) >= 0 && inBlock) {
- chunk = joinChunks(chunk, getSoftNewlineChunk());
- }
- if (sibling) {
- nodeName = sibling.nodeName.toLowerCase();
- }
- child = sibling;
- }
-
- if (newBlock) {
- chunk = joinChunks(chunk, getBlockDividerChunk(nextBlockType, depth, parentKey));
- }
-
- return { chunk: chunk, entityMap: newEntityMap };
- };
-
- var getChunkForHTML = function getChunkForHTML(html, DOMBuilder, blockRenderMap, entityMap) {
- html = html.trim().replace(REGEX_CR, '').replace(REGEX_NBSP, SPACE).replace(REGEX_CARRIAGE, '').replace(REGEX_ZWS, '');
-
- var supportedBlockTags = getBlockMapSupportedTags(blockRenderMap);
-
- var safeBody = DOMBuilder(html);
- if (!safeBody) {
- return null;
- }
- lastBlock = null;
-
- // Sometimes we aren't dealing with content that contains nice semantic
- // tags. In this case, use divs to separate everything out into paragraphs
- // and hope for the best.
- var workingBlocks = containsSemanticBlockMarkup(html, supportedBlockTags) ? supportedBlockTags : ['div'];
-
- // Start with -1 block depth to offset the fact that we are passing in a fake
- // UL block to start with.
- var fragment = genFragment(entityMap, safeBody, OrderedSet$5(), 'ul', null, workingBlocks, -1, blockRenderMap);
-
- var chunk = fragment.chunk;
- var newEntityMap = fragment.entityMap;
-
- // join with previous block to prevent weirdness on paste
- if (chunk.text.indexOf('\r') === 0) {
- chunk = {
- text: chunk.text.slice(1),
- inlines: chunk.inlines.slice(1),
- entities: chunk.entities.slice(1),
- blocks: chunk.blocks
- };
- }
-
- // Kill block delimiter at the end
- if (chunk.text.slice(-1) === '\r') {
- chunk.text = chunk.text.slice(0, -1);
- chunk.inlines = chunk.inlines.slice(0, -1);
- chunk.entities = chunk.entities.slice(0, -1);
- chunk.blocks.pop();
- }
-
- // If we saw no block tags, put an unstyled one in
- if (chunk.blocks.length === 0) {
- chunk.blocks.push(_extends$4({}, EMPTY_CHUNK, {
- type: 'unstyled',
- depth: 0
- }));
- }
-
- // Sometimes we start with text that isn't in a block, which is then
- // followed by blocks. Need to fix up the blocks to add in
- // an unstyled block for this content
- if (chunk.text.split('\r').length === chunk.blocks.length + 1) {
- chunk.blocks.unshift({ type: 'unstyled', depth: 0 });
- }
-
- return { chunk: chunk, entityMap: newEntityMap };
- };
-
- var convertChunkToContentBlocks = function convertChunkToContentBlocks(chunk) {
- if (!chunk || !chunk.text || !Array.isArray(chunk.blocks)) {
- return null;
- }
-
- var initialState = {
- cacheRef: {},
- contentBlocks: []
- };
-
- var start = 0;
-
- var rawBlocks = chunk.blocks,
- rawInlines = chunk.inlines,
- rawEntities = chunk.entities;
-
-
- var BlockNodeRecord = ContentBlock_1;
-
- return chunk.text.split('\r').reduce(function (acc, textBlock, index) {
- // Make absolutely certain that our text is acceptable.
- textBlock = sanitizeDraftText_1(textBlock);
-
- var block = rawBlocks[index];
- var end = start + textBlock.length;
- var inlines = rawInlines.slice(start, end);
- var entities = rawEntities.slice(start, end);
- var characterList = List$a(inlines.map(function (style, index) {
- var data = { style: style, entity: null };
- if (entities[index]) {
- data.entity = entities[index];
- }
- return CharacterMetadata_1.create(data);
- }));
- start = end + 1;
-
- var depth = block.depth,
- type = block.type,
- parent = block.parent;
-
-
- var key = block.key || generateRandomKey_1();
- var parentTextNodeKey = null; // will be used to store container text nodes
-
- // childrens add themselves to their parents since we are iterating in order
- if (parent) {
- var parentIndex = acc.cacheRef[parent];
- var parentRecord = acc.contentBlocks[parentIndex];
-
- // if parent has text we need to split it into a separate unstyled element
- if (parentRecord.getChildKeys().isEmpty() && parentRecord.getText()) {
- var parentCharacterList = parentRecord.getCharacterList();
- var parentText = parentRecord.getText();
- parentTextNodeKey = generateRandomKey_1();
-
- var textNode = new ContentBlockNode_1({
- key: parentTextNodeKey,
- text: parentText,
- characterList: parentCharacterList,
- parent: parent,
- nextSibling: key
- });
-
- acc.contentBlocks.push(textNode);
-
- parentRecord = parentRecord.withMutations(function (block) {
- block.set('characterList', List$a()).set('text', '').set('children', parentRecord.children.push(textNode.getKey()));
- });
- }
-
- acc.contentBlocks[parentIndex] = parentRecord.set('children', parentRecord.children.push(key));
- }
-
- var blockNode = new BlockNodeRecord({
- key: key,
- parent: parent,
- type: type,
- depth: depth,
- text: textBlock,
- characterList: characterList,
- prevSibling: parentTextNodeKey || (index === 0 || rawBlocks[index - 1].parent !== parent ? null : rawBlocks[index - 1].key),
- nextSibling: index === rawBlocks.length - 1 || rawBlocks[index + 1].parent !== parent ? null : rawBlocks[index + 1].key
- });
-
- // insert node
- acc.contentBlocks.push(blockNode);
-
- // cache ref for building links
- acc.cacheRef[blockNode.key] = index;
-
- return acc;
- }, initialState).contentBlocks;
- };
-
- var convertFromHTMLtoContentBlocks = function convertFromHTMLtoContentBlocks(html) {
- var DOMBuilder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getSafeBodyFromHTML_1;
- var blockRenderMap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DefaultDraftBlockRenderMap_1;
-
- // Be ABSOLUTELY SURE that the dom builder you pass here won't execute
- // arbitrary code in whatever environment you're running this in. For an
- // example of how we try to do this in-browser, see getSafeBodyFromHTML.
-
- // TODO: replace DraftEntity with an OrderedMap here
- var chunkData = getChunkForHTML(html, DOMBuilder, blockRenderMap, DraftEntity_1);
-
- if (chunkData == null) {
- return null;
- }
-
- var chunk = chunkData.chunk,
- entityMap = chunkData.entityMap;
-
- var contentBlocks = convertChunkToContentBlocks(chunk);
-
- return {
- contentBlocks: contentBlocks,
- entityMap: entityMap
- };
- };
-
- var convertFromHTMLToContentBlocks = convertFromHTMLtoContentBlocks;
-
- var List$b = immutable.List,
- Repeat$6 = immutable.Repeat;
- var ContentBlockRecord$2 = ContentBlock_1;
-
- var DraftPasteProcessor = {
- processHTML: function processHTML(html, blockRenderMap) {
- return convertFromHTMLToContentBlocks(html, getSafeBodyFromHTML_1, blockRenderMap);
- },
- processText: function processText(textBlocks, character, type) {
- return textBlocks.reduce(function (acc, textLine, index) {
- textLine = sanitizeDraftText_1(textLine);
- var key = generateRandomKey_1();
-
- var blockNodeConfig = {
- key: key,
- type: type,
- text: textLine,
- characterList: List$b(Repeat$6(character, textLine.length))
- };
-
- acc.push(new ContentBlockRecord$2(blockNodeConfig));
-
- return acc;
- }, []);
- }
- };
-
- var DraftPasteProcessor_1 = DraftPasteProcessor;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule adjustBlockDepthForContentState
- * @format
- *
- */
-
- function adjustBlockDepthForContentState(contentState, selectionState, adjustment, maxDepth) {
- var startKey = selectionState.getStartKey();
- var endKey = selectionState.getEndKey();
- var blockMap = contentState.getBlockMap();
- var blocks = blockMap.toSeq().skipUntil(function (_, k) {
- return k === startKey;
- }).takeUntil(function (_, k) {
- return k === endKey;
- }).concat([[endKey, blockMap.get(endKey)]]).map(function (block) {
- var depth = block.getDepth() + adjustment;
- depth = Math.max(0, Math.min(depth, maxDepth));
- return block.set('depth', depth);
- });
-
- blockMap = blockMap.merge(blocks);
-
- return contentState.merge({
- blockMap: blockMap,
- selectionBefore: selectionState,
- selectionAfter: selectionState
- });
- }
-
- var adjustBlockDepthForContentState_1 = adjustBlockDepthForContentState;
-
- var RichTextEditorUtil = {
- currentBlockContainsLink: function currentBlockContainsLink(editorState) {
- var selection = editorState.getSelection();
- var contentState = editorState.getCurrentContent();
- var entityMap = contentState.getEntityMap();
- return contentState.getBlockForKey(selection.getAnchorKey()).getCharacterList().slice(selection.getStartOffset(), selection.getEndOffset()).some(function (v) {
- var entity = v.getEntity();
- return !!entity && entityMap.__get(entity).getType() === 'LINK';
- });
- },
-
- getCurrentBlockType: function getCurrentBlockType(editorState) {
- var selection = editorState.getSelection();
- return editorState.getCurrentContent().getBlockForKey(selection.getStartKey()).getType();
- },
-
- getDataObjectForLinkURL: function getDataObjectForLinkURL(uri) {
- return { url: uri.toString() };
- },
-
- handleKeyCommand: function handleKeyCommand(editorState, command) {
- switch (command) {
- case 'bold':
- return RichTextEditorUtil.toggleInlineStyle(editorState, 'BOLD');
- case 'italic':
- return RichTextEditorUtil.toggleInlineStyle(editorState, 'ITALIC');
- case 'underline':
- return RichTextEditorUtil.toggleInlineStyle(editorState, 'UNDERLINE');
- case 'code':
- return RichTextEditorUtil.toggleCode(editorState);
- case 'backspace':
- case 'backspace-word':
- case 'backspace-to-start-of-line':
- return RichTextEditorUtil.onBackspace(editorState);
- case 'delete':
- case 'delete-word':
- case 'delete-to-end-of-block':
- return RichTextEditorUtil.onDelete(editorState);
- default:
- // they may have custom editor commands; ignore those
- return null;
- }
- },
-
- insertSoftNewline: function insertSoftNewline(editorState) {
- var contentState = DraftModifier_1.insertText(editorState.getCurrentContent(), editorState.getSelection(), '\n', editorState.getCurrentInlineStyle(), null);
-
- var newEditorState = EditorState_1.push(editorState, contentState, 'insert-characters');
-
- return EditorState_1.forceSelection(newEditorState, contentState.getSelectionAfter());
- },
-
- /**
- * For collapsed selections at the start of styled blocks, backspace should
- * just remove the existing style.
- */
- onBackspace: function onBackspace(editorState) {
- var selection = editorState.getSelection();
- if (!selection.isCollapsed() || selection.getAnchorOffset() || selection.getFocusOffset()) {
- return null;
- }
-
- // First, try to remove a preceding atomic block.
- var content = editorState.getCurrentContent();
- var startKey = selection.getStartKey();
- var blockBefore = content.getBlockBefore(startKey);
-
- if (blockBefore && blockBefore.getType() === 'atomic') {
- var blockMap = content.getBlockMap()['delete'](blockBefore.getKey());
- var withoutAtomicBlock = content.merge({
- blockMap: blockMap,
- selectionAfter: selection
- });
- if (withoutAtomicBlock !== content) {
- return EditorState_1.push(editorState, withoutAtomicBlock, 'remove-range');
- }
- }
-
- // If that doesn't succeed, try to remove the current block style.
- var withoutBlockStyle = RichTextEditorUtil.tryToRemoveBlockStyle(editorState);
-
- if (withoutBlockStyle) {
- return EditorState_1.push(editorState, withoutBlockStyle, 'change-block-type');
- }
-
- return null;
- },
-
- onDelete: function onDelete(editorState) {
- var selection = editorState.getSelection();
- if (!selection.isCollapsed()) {
- return null;
- }
-
- var content = editorState.getCurrentContent();
- var startKey = selection.getStartKey();
- var block = content.getBlockForKey(startKey);
- var length = block.getLength();
-
- // The cursor is somewhere within the text. Behave normally.
- if (selection.getStartOffset() < length) {
- return null;
- }
-
- var blockAfter = content.getBlockAfter(startKey);
-
- if (!blockAfter || blockAfter.getType() !== 'atomic') {
- return null;
- }
-
- var atomicBlockTarget = selection.merge({
- focusKey: blockAfter.getKey(),
- focusOffset: blockAfter.getLength()
- });
-
- var withoutAtomicBlock = DraftModifier_1.removeRange(content, atomicBlockTarget, 'forward');
-
- if (withoutAtomicBlock !== content) {
- return EditorState_1.push(editorState, withoutAtomicBlock, 'remove-range');
- }
-
- return null;
- },
-
- onTab: function onTab(event, editorState, maxDepth) {
- var selection = editorState.getSelection();
- var key = selection.getAnchorKey();
- if (key !== selection.getFocusKey()) {
- return editorState;
- }
-
- var content = editorState.getCurrentContent();
- var block = content.getBlockForKey(key);
- var type = block.getType();
- if (type !== 'unordered-list-item' && type !== 'ordered-list-item') {
- return editorState;
- }
-
- event.preventDefault();
-
- // Only allow indenting one level beyond the block above, and only if
- // the block above is a list item as well.
- var blockAbove = content.getBlockBefore(key);
- if (!blockAbove) {
- return editorState;
- }
-
- var typeAbove = blockAbove.getType();
- if (typeAbove !== 'unordered-list-item' && typeAbove !== 'ordered-list-item') {
- return editorState;
- }
-
- var depth = block.getDepth();
- if (!event.shiftKey && depth === maxDepth) {
- return editorState;
- }
-
- maxDepth = Math.min(blockAbove.getDepth() + 1, maxDepth);
-
- var withAdjustment = adjustBlockDepthForContentState_1(content, selection, event.shiftKey ? -1 : 1, maxDepth);
-
- return EditorState_1.push(editorState, withAdjustment, 'adjust-depth');
- },
-
- toggleBlockType: function toggleBlockType(editorState, blockType) {
- var selection = editorState.getSelection();
- var startKey = selection.getStartKey();
- var endKey = selection.getEndKey();
- var content = editorState.getCurrentContent();
- var target = selection;
-
- // Triple-click can lead to a selection that includes offset 0 of the
- // following block. The `SelectionState` for this case is accurate, but
- // we should avoid toggling block type for the trailing block because it
- // is a confusing interaction.
- if (startKey !== endKey && selection.getEndOffset() === 0) {
- var blockBefore = nullthrows_1(content.getBlockBefore(endKey));
- endKey = blockBefore.getKey();
- target = target.merge({
- anchorKey: startKey,
- anchorOffset: selection.getStartOffset(),
- focusKey: endKey,
- focusOffset: blockBefore.getLength(),
- isBackward: false
- });
- }
-
- var hasAtomicBlock = content.getBlockMap().skipWhile(function (_, k) {
- return k !== startKey;
- }).reverse().skipWhile(function (_, k) {
- return k !== endKey;
- }).some(function (v) {
- return v.getType() === 'atomic';
- });
-
- if (hasAtomicBlock) {
- return editorState;
- }
-
- var typeToSet = content.getBlockForKey(startKey).getType() === blockType ? 'unstyled' : blockType;
-
- return EditorState_1.push(editorState, DraftModifier_1.setBlockType(content, target, typeToSet), 'change-block-type');
- },
-
- toggleCode: function toggleCode(editorState) {
- var selection = editorState.getSelection();
- var anchorKey = selection.getAnchorKey();
- var focusKey = selection.getFocusKey();
-
- if (selection.isCollapsed() || anchorKey !== focusKey) {
- return RichTextEditorUtil.toggleBlockType(editorState, 'code-block');
- }
-
- return RichTextEditorUtil.toggleInlineStyle(editorState, 'CODE');
- },
-
- /**
- * Toggle the specified inline style for the selection. If the
- * user's selection is collapsed, apply or remove the style for the
- * internal state. If it is not collapsed, apply the change directly
- * to the document state.
- */
- toggleInlineStyle: function toggleInlineStyle(editorState, inlineStyle) {
- var selection = editorState.getSelection();
- var currentStyle = editorState.getCurrentInlineStyle();
-
- // If the selection is collapsed, toggle the specified style on or off and
- // set the result as the new inline style override. This will then be
- // used as the inline style for the next character to be inserted.
- if (selection.isCollapsed()) {
- return EditorState_1.setInlineStyleOverride(editorState, currentStyle.has(inlineStyle) ? currentStyle.remove(inlineStyle) : currentStyle.add(inlineStyle));
- }
-
- // If characters are selected, immediately apply or remove the
- // inline style on the document state itself.
- var content = editorState.getCurrentContent();
- var newContent;
-
- // If the style is already present for the selection range, remove it.
- // Otherwise, apply it.
- if (currentStyle.has(inlineStyle)) {
- newContent = DraftModifier_1.removeInlineStyle(content, selection, inlineStyle);
- } else {
- newContent = DraftModifier_1.applyInlineStyle(content, selection, inlineStyle);
- }
-
- return EditorState_1.push(editorState, newContent, 'change-inline-style');
- },
-
- toggleLink: function toggleLink(editorState, targetSelection, entityKey) {
- var withoutLink = DraftModifier_1.applyEntity(editorState.getCurrentContent(), targetSelection, entityKey);
-
- return EditorState_1.push(editorState, withoutLink, 'apply-entity');
- },
-
- /**
- * When a collapsed cursor is at the start of the first styled block, or
- * an empty styled block, changes block to 'unstyled'. Returns null if
- * block or selection does not meet that criteria.
- */
- tryToRemoveBlockStyle: function tryToRemoveBlockStyle(editorState) {
- var selection = editorState.getSelection();
- var offset = selection.getAnchorOffset();
- if (selection.isCollapsed() && offset === 0) {
- var key = selection.getAnchorKey();
- var content = editorState.getCurrentContent();
- var block = content.getBlockForKey(key);
-
- var firstBlock = content.getFirstBlock();
- if (block.getLength() > 0 && block !== firstBlock) {
- return null;
- }
-
- var type = block.getType();
- var blockBefore = content.getBlockBefore(key);
- if (type === 'code-block' && blockBefore && blockBefore.getType() === 'code-block' && blockBefore.getLength() !== 0) {
- return null;
- }
-
- if (type !== 'unstyled') {
- return DraftModifier_1.setBlockType(content, selection, 'unstyled');
- }
- }
- return null;
- }
- };
-
- var RichTextEditorUtil_1 = RichTextEditorUtil;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule splitTextIntoTextBlocks
- * @format
- *
- */
-
- var NEWLINE_REGEX = /\r\n?|\n/g;
-
- function splitTextIntoTextBlocks(text) {
- return text.split(NEWLINE_REGEX);
- }
-
- var splitTextIntoTextBlocks_1 = splitTextIntoTextBlocks;
-
- /**
- * Paste content.
- */
- function editOnPaste(editor, e) {
- e.preventDefault();
- var data = new DataTransfer_1(e.clipboardData);
-
- // Get files, unless this is likely to be a string the user wants inline.
- if (!data.isRichText()) {
- var files = data.getFiles();
- var defaultFileText = data.getText();
- if (files.length > 0) {
- // Allow customized paste handling for images, etc. Otherwise, fall
- // through to insert text contents into the editor.
- if (editor.props.handlePastedFiles && isEventHandled_1(editor.props.handlePastedFiles(files))) {
- return;
- }
-
- getTextContentFromFiles_1(files, function ( /*string*/fileText) {
- fileText = fileText || defaultFileText;
- if (!fileText) {
- return;
- }
-
- var editorState = editor._latestEditorState;
- var blocks = splitTextIntoTextBlocks_1(fileText);
- var character = CharacterMetadata_1.create({
- style: editorState.getCurrentInlineStyle(),
- entity: getEntityKeyForSelection_1(editorState.getCurrentContent(), editorState.getSelection())
- });
- var currentBlockType = RichTextEditorUtil_1.getCurrentBlockType(editorState);
-
- var text = DraftPasteProcessor_1.processText(blocks, character, currentBlockType);
- var fragment = BlockMapBuilder_1.createFromArray(text);
-
- var withInsertedText = DraftModifier_1.replaceWithFragment(editorState.getCurrentContent(), editorState.getSelection(), fragment);
-
- editor.update(EditorState_1.push(editorState, withInsertedText, 'insert-fragment'));
- });
-
- return;
- }
- }
-
- var textBlocks = [];
- var text = data.getText();
- var html = data.getHTML();
- var editorState = editor._latestEditorState;
-
- if (editor.props.handlePastedText && isEventHandled_1(editor.props.handlePastedText(text, html, editorState))) {
- return;
- }
-
- if (text) {
- textBlocks = splitTextIntoTextBlocks_1(text);
- }
-
- if (!editor.props.stripPastedStyles) {
- // If the text from the paste event is rich content that matches what we
- // already have on the internal clipboard, assume that we should just use
- // the clipboard fragment for the paste. This will allow us to preserve
- // styling and entities, if any are present. Note that newlines are
- // stripped during comparison -- this is because copy/paste within the
- // editor in Firefox and IE will not include empty lines. The resulting
- // paste will preserve the newlines correctly.
- var internalClipboard = editor.getClipboard();
- if (data.isRichText() && internalClipboard) {
- if (
- // If the editorKey is present in the pasted HTML, it should be safe to
- // assume this is an internal paste.
- html.indexOf(editor.getEditorKey()) !== -1 ||
- // The copy may have been made within a single block, in which case the
- // editor key won't be part of the paste. In this case, just check
- // whether the pasted text matches the internal clipboard.
- textBlocks.length === 1 && internalClipboard.size === 1 && internalClipboard.first().getText() === text) {
- editor.update(insertFragment$1(editor._latestEditorState, internalClipboard));
- return;
- }
- } else if (internalClipboard && data.types.includes('com.apple.webarchive') && !data.types.includes('text/html') && areTextBlocksAndClipboardEqual(textBlocks, internalClipboard)) {
- // Safari does not properly store text/html in some cases.
- // Use the internalClipboard if present and equal to what is on
- // the clipboard. See https://bugs.webkit.org/show_bug.cgi?id=19893.
- editor.update(insertFragment$1(editor._latestEditorState, internalClipboard));
- return;
- }
-
- // If there is html paste data, try to parse that.
- if (html) {
- var htmlFragment = DraftPasteProcessor_1.processHTML(html, editor.props.blockRenderMap);
- if (htmlFragment) {
- var contentBlocks = htmlFragment.contentBlocks,
- entityMap = htmlFragment.entityMap;
-
- if (contentBlocks) {
- var htmlMap = BlockMapBuilder_1.createFromArray(contentBlocks);
- editor.update(insertFragment$1(editor._latestEditorState, htmlMap, entityMap));
- return;
- }
- }
- }
-
- // Otherwise, create a new fragment from our pasted text. Also
- // empty the internal clipboard, since it's no longer valid.
- editor.setClipboard(null);
- }
-
- if (textBlocks.length) {
- var character = CharacterMetadata_1.create({
- style: editorState.getCurrentInlineStyle(),
- entity: getEntityKeyForSelection_1(editorState.getCurrentContent(), editorState.getSelection())
- });
-
- var currentBlockType = RichTextEditorUtil_1.getCurrentBlockType(editorState);
-
- var textFragment = DraftPasteProcessor_1.processText(textBlocks, character, currentBlockType);
-
- var textMap = BlockMapBuilder_1.createFromArray(textFragment);
- editor.update(insertFragment$1(editor._latestEditorState, textMap));
- }
- }
-
- function insertFragment$1(editorState, fragment, entityMap) {
- var newContent = DraftModifier_1.replaceWithFragment(editorState.getCurrentContent(), editorState.getSelection(), fragment);
- // TODO: merge the entity map once we stop using DraftEntity
- // like this:
- // const mergedEntityMap = newContent.getEntityMap().merge(entityMap);
-
- return EditorState_1.push(editorState, newContent.set('entityMap', entityMap), 'insert-fragment');
- }
-
- function areTextBlocksAndClipboardEqual(textBlocks, blockMap) {
- return textBlocks.length === blockMap.size && blockMap.valueSeq().every(function (block, ii) {
- return block.getText() === textBlocks[ii];
- });
- }
-
- var editOnPaste_1 = editOnPaste;
-
- /**
- * Convert the current selection range to an anchor/focus pair of offset keys
- * and values that can be interpreted by components.
- */
- function getDraftEditorSelection(editorState, root) {
- var selection = commonjsGlobal.getSelection();
-
- // No active selection.
- if (selection.rangeCount === 0) {
- return {
- selectionState: editorState.getSelection().set('hasFocus', false),
- needsRecovery: false
- };
- }
-
- return getDraftEditorSelectionWithNodes_1(editorState, root, selection.anchorNode, selection.anchorOffset, selection.focusNode, selection.focusOffset);
- }
-
- var getDraftEditorSelection_1 = getDraftEditorSelection;
-
- function editOnSelect(editor) {
- if (editor._blockSelectEvents || editor._latestEditorState !== editor.props.editorState) {
- return;
- }
-
- var editorState = editor.props.editorState;
- var editorNode = ReactDOM.findDOMNode(editor.editorContainer);
- !editorNode ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Missing editorNode') : invariant_1(false) : void 0;
- !(editorNode.firstChild instanceof HTMLElement) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'editorNode.firstChild is not an HTMLElement') : invariant_1(false) : void 0;
- var documentSelection = getDraftEditorSelection_1(editorState, editorNode.firstChild);
- var updatedSelectionState = documentSelection.selectionState;
-
- if (updatedSelectionState !== editorState.getSelection()) {
- if (documentSelection.needsRecovery) {
- editorState = EditorState_1.forceSelection(editorState, updatedSelectionState);
- } else {
- editorState = EditorState_1.acceptSelection(editorState, updatedSelectionState);
- }
- editor.update(editorState);
- }
- }
-
- var editOnSelect_1 = editOnSelect;
-
- var DraftEditorEditHandler = {
- onBeforeInput: editOnBeforeInput_1,
- onBlur: editOnBlur_1,
- onCompositionStart: editOnCompositionStart_1,
- onCopy: editOnCopy_1,
- onCut: editOnCut_1,
- onDragOver: editOnDragOver_1,
- onDragStart: editOnDragStart_1,
- onFocus: editOnFocus_1,
- onInput: editOnInput_1,
- onKeyDown: editOnKeyDown_1,
- onPaste: editOnPaste_1,
- onSelect: editOnSelect_1
- };
-
- var DraftEditorEditHandler_1 = DraftEditorEditHandler;
-
- function _classCallCheck$f(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- function _possibleConstructorReturn$a(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
- function _inherits$a(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-
-
-
-
- /**
- * This component is responsible for rendering placeholder text for the
- * `DraftEditor` component.
- *
- * Override placeholder style via CSS.
- */
- var DraftEditorPlaceholder = function (_React$Component) {
- _inherits$a(DraftEditorPlaceholder, _React$Component);
-
- function DraftEditorPlaceholder() {
- _classCallCheck$f(this, DraftEditorPlaceholder);
-
- return _possibleConstructorReturn$a(this, _React$Component.apply(this, arguments));
- }
-
- DraftEditorPlaceholder.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
- return this.props.text !== nextProps.text || this.props.editorState.getSelection().getHasFocus() !== nextProps.editorState.getSelection().getHasFocus();
- };
-
- DraftEditorPlaceholder.prototype.render = function render() {
- var hasFocus = this.props.editorState.getSelection().getHasFocus();
-
- var className = cx_1({
- 'public/DraftEditorPlaceholder/root': true,
- 'public/DraftEditorPlaceholder/hasFocus': hasFocus
- });
-
- var contentStyle = {
- whiteSpace: 'pre-wrap'
- };
-
- return React.createElement(
- 'div',
- { className: className },
- React.createElement(
- 'div',
- {
- className: cx_1('public/DraftEditorPlaceholder/inner'),
- id: this.props.accessibilityID,
- style: contentStyle },
- this.props.text
- )
- );
- };
-
- return DraftEditorPlaceholder;
- }(React.Component);
-
- var DraftEditorPlaceholder_react = DraftEditorPlaceholder;
-
- var isOSX$1 = UserAgent_1.isPlatform('Mac OS X');
- var isWindows = UserAgent_1.isPlatform('Windows');
-
- // Firefox on OSX had a bug resulting in navigation instead of cursor movement.
- // This bug was fixed in Firefox 29. Feature detection is virtually impossible
- // so we just check the version number. See #342765.
- var shouldFixFirefoxMovement = isOSX$1 && UserAgent_1.isBrowser('Firefox < 29');
-
- var hasCommandModifier = KeyBindingUtil_1.hasCommandModifier,
- isCtrlKeyCommand = KeyBindingUtil_1.isCtrlKeyCommand;
-
-
- function shouldRemoveWord(e) {
- return isOSX$1 && e.altKey || isCtrlKeyCommand(e);
- }
-
- /**
- * Get the appropriate undo/redo command for a Z key command.
- */
- function getZCommand(e) {
- if (!hasCommandModifier(e)) {
- return null;
- }
- return e.shiftKey ? 'redo' : 'undo';
- }
-
- function getDeleteCommand(e) {
- // Allow default "cut" behavior for Windows on Shift + Delete.
- if (isWindows && e.shiftKey) {
- return null;
- }
- return shouldRemoveWord(e) ? 'delete-word' : 'delete';
- }
-
- function getBackspaceCommand(e) {
- if (hasCommandModifier(e) && isOSX$1) {
- return 'backspace-to-start-of-line';
- }
- return shouldRemoveWord(e) ? 'backspace-word' : 'backspace';
- }
-
- /**
- * Retrieve a bound key command for the given event.
- */
- function getDefaultKeyBinding(e) {
- switch (e.keyCode) {
- case 66:
- // B
- return hasCommandModifier(e) ? 'bold' : null;
- case 68:
- // D
- return isCtrlKeyCommand(e) ? 'delete' : null;
- case 72:
- // H
- return isCtrlKeyCommand(e) ? 'backspace' : null;
- case 73:
- // I
- return hasCommandModifier(e) ? 'italic' : null;
- case 74:
- // J
- return hasCommandModifier(e) ? 'code' : null;
- case 75:
- // K
- return !isWindows && isCtrlKeyCommand(e) ? 'secondary-cut' : null;
- case 77:
- // M
- return isCtrlKeyCommand(e) ? 'split-block' : null;
- case 79:
- // O
- return isCtrlKeyCommand(e) ? 'split-block' : null;
- case 84:
- // T
- return isOSX$1 && isCtrlKeyCommand(e) ? 'transpose-characters' : null;
- case 85:
- // U
- return hasCommandModifier(e) ? 'underline' : null;
- case 87:
- // W
- return isOSX$1 && isCtrlKeyCommand(e) ? 'backspace-word' : null;
- case 89:
- // Y
- if (isCtrlKeyCommand(e)) {
- return isWindows ? 'redo' : 'secondary-paste';
- }
- return null;
- case 90:
- // Z
- return getZCommand(e) || null;
- case Keys.RETURN:
- return 'split-block';
- case Keys.DELETE:
- return getDeleteCommand(e);
- case Keys.BACKSPACE:
- return getBackspaceCommand(e);
- // LEFT/RIGHT handlers serve as a workaround for a Firefox bug.
- case Keys.LEFT:
- return shouldFixFirefoxMovement && hasCommandModifier(e) ? 'move-selection-to-start-of-block' : null;
- case Keys.RIGHT:
- return shouldFixFirefoxMovement && hasCommandModifier(e) ? 'move-selection-to-end-of-block' : null;
- default:
- return null;
- }
- }
-
- var getDefaultKeyBinding_1 = getDefaultKeyBinding;
-
- var _extends$5 = objectAssign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
-
- function _classCallCheck$g(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- function _possibleConstructorReturn$b(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
- function _inherits$b(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var isIE = UserAgent_1.isBrowser('IE');
-
- // IE does not support the `input` event on contentEditable, so we can't
- // observe spellcheck behavior.
- var allowSpellCheck = !isIE;
-
- // Define a set of handler objects to correspond to each possible `mode`
- // of editor behavior.
- var handlerMap = {
- edit: DraftEditorEditHandler_1,
- composite: DraftEditorCompositionHandler_1,
- drag: DraftEditorDragHandler_1,
- cut: null,
- render: null
- };
-
- /**
- * `DraftEditor` is the root editor component. It composes a `contentEditable`
- * div, and provides a wide variety of useful function props for managing the
- * state of the editor. See `DraftEditorProps` for details.
- */
- var DraftEditor = function (_React$Component) {
- _inherits$b(DraftEditor, _React$Component);
-
- function DraftEditor(props) {
- _classCallCheck$g(this, DraftEditor);
-
- var _this = _possibleConstructorReturn$b(this, _React$Component.call(this, props));
-
- _this.focus = function (scrollPosition) {
- var editorState = _this.props.editorState;
-
- var alreadyHasFocus = editorState.getSelection().getHasFocus();
- var editorNode = ReactDOM.findDOMNode(_this.editor);
-
- if (!editorNode) {
- // once in a while people call 'focus' in a setTimeout, and the node has
- // been deleted, so it can be null in that case.
- return;
- }
-
- var scrollParent = Style_1.getScrollParent(editorNode);
-
- var _ref = scrollPosition || getScrollPosition_1(scrollParent),
- x = _ref.x,
- y = _ref.y;
-
- !(editorNode instanceof HTMLElement) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'editorNode is not an HTMLElement') : invariant_1(false) : void 0;
- editorNode.focus();
-
- // Restore scroll position
- if (scrollParent === window) {
- window.scrollTo(x, y);
- } else {
- Scroll_1.setTop(scrollParent, y);
- }
-
- // On Chrome and Safari, calling focus on contenteditable focuses the
- // cursor at the first character. This is something you don't expect when
- // you're clicking on an input element but not directly on a character.
- // Put the cursor back where it was before the blur.
- if (!alreadyHasFocus) {
- _this.update(EditorState_1.forceSelection(editorState, editorState.getSelection()));
- }
- };
-
- _this.blur = function () {
- var editorNode = ReactDOM.findDOMNode(_this.editor);
- !(editorNode instanceof HTMLElement) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'editorNode is not an HTMLElement') : invariant_1(false) : void 0;
- editorNode.blur();
- };
-
- _this.setMode = function (mode) {
- _this._handler = handlerMap[mode];
- };
-
- _this.exitCurrentMode = function () {
- _this.setMode('edit');
- };
-
- _this.restoreEditorDOM = function (scrollPosition) {
- _this.setState({ contentsKey: _this.state.contentsKey + 1 }, function () {
- _this.focus(scrollPosition);
- });
- };
-
- _this.setClipboard = function (clipboard) {
- _this._clipboard = clipboard;
- };
-
- _this.getClipboard = function () {
- return _this._clipboard;
- };
-
- _this.update = function (editorState) {
- _this._latestEditorState = editorState;
- _this.props.onChange(editorState);
- };
-
- _this.onDragEnter = function () {
- _this._dragCount++;
- };
-
- _this.onDragLeave = function () {
- _this._dragCount--;
- if (_this._dragCount === 0) {
- _this.exitCurrentMode();
- }
- };
-
- _this._blockSelectEvents = false;
- _this._clipboard = null;
- _this._handler = null;
- _this._dragCount = 0;
- _this._editorKey = props.editorKey || generateRandomKey_1();
- _this._placeholderAccessibilityID = 'placeholder-' + _this._editorKey;
- _this._latestEditorState = props.editorState;
- _this._latestCommittedEditorState = props.editorState;
-
- _this._onBeforeInput = _this._buildHandler('onBeforeInput');
- _this._onBlur = _this._buildHandler('onBlur');
- _this._onCharacterData = _this._buildHandler('onCharacterData');
- _this._onCompositionEnd = _this._buildHandler('onCompositionEnd');
- _this._onCompositionStart = _this._buildHandler('onCompositionStart');
- _this._onCopy = _this._buildHandler('onCopy');
- _this._onCut = _this._buildHandler('onCut');
- _this._onDragEnd = _this._buildHandler('onDragEnd');
- _this._onDragOver = _this._buildHandler('onDragOver');
- _this._onDragStart = _this._buildHandler('onDragStart');
- _this._onDrop = _this._buildHandler('onDrop');
- _this._onInput = _this._buildHandler('onInput');
- _this._onFocus = _this._buildHandler('onFocus');
- _this._onKeyDown = _this._buildHandler('onKeyDown');
- _this._onKeyPress = _this._buildHandler('onKeyPress');
- _this._onKeyUp = _this._buildHandler('onKeyUp');
- _this._onMouseDown = _this._buildHandler('onMouseDown');
- _this._onMouseUp = _this._buildHandler('onMouseUp');
- _this._onPaste = _this._buildHandler('onPaste');
- _this._onSelect = _this._buildHandler('onSelect');
-
- _this.getEditorKey = function () {
- return _this._editorKey;
- };
-
- // See `restoreEditorDOM()`.
- _this.state = { contentsKey: 0 };
- return _this;
- }
-
- /**
- * Build a method that will pass the event to the specified handler method.
- * This allows us to look up the correct handler function for the current
- * editor mode, if any has been specified.
- */
-
-
- /**
- * Define proxies that can route events to the current handler.
- */
-
-
- DraftEditor.prototype._buildHandler = function _buildHandler(eventName) {
- var _this2 = this;
-
- return function (e) {
- if (!_this2.props.readOnly) {
- var method = _this2._handler && _this2._handler[eventName];
- method && method(_this2, e);
- }
- };
- };
-
- DraftEditor.prototype._showPlaceholder = function _showPlaceholder() {
- return !!this.props.placeholder && !this.props.editorState.isInCompositionMode() && !this.props.editorState.getCurrentContent().hasText();
- };
-
- DraftEditor.prototype._renderPlaceholder = function _renderPlaceholder() {
- if (this._showPlaceholder()) {
- var placeHolderProps = {
- text: nullthrows_1(this.props.placeholder),
- editorState: this.props.editorState,
- textAlignment: this.props.textAlignment,
- accessibilityID: this._placeholderAccessibilityID
- };
-
- return React.createElement(DraftEditorPlaceholder_react, placeHolderProps);
- }
- return null;
- };
-
- DraftEditor.prototype.render = function render() {
- var _this3 = this;
-
- var _props = this.props,
- blockRenderMap = _props.blockRenderMap,
- blockRendererFn = _props.blockRendererFn,
- blockStyleFn = _props.blockStyleFn,
- customStyleFn = _props.customStyleFn,
- customStyleMap = _props.customStyleMap,
- editorState = _props.editorState,
- readOnly = _props.readOnly,
- textAlignment = _props.textAlignment,
- textDirectionality = _props.textDirectionality;
-
-
- var rootClass = cx_1({
- 'DraftEditor/root': true,
- 'DraftEditor/alignLeft': textAlignment === 'left',
- 'DraftEditor/alignRight': textAlignment === 'right',
- 'DraftEditor/alignCenter': textAlignment === 'center'
- });
-
- var contentStyle = {
- outline: 'none',
- // fix parent-draggable Safari bug. #1326
- userSelect: 'text',
- WebkitUserSelect: 'text',
- whiteSpace: 'pre-wrap',
- wordWrap: 'break-word'
- };
-
- // The aria-expanded and aria-haspopup properties should only be rendered
- // for a combobox.
- var ariaRole = this.props.role || 'textbox';
- var ariaExpanded = ariaRole === 'combobox' ? !!this.props.ariaExpanded : null;
-
- var editorContentsProps = {
- blockRenderMap: blockRenderMap,
- blockRendererFn: blockRendererFn,
- blockStyleFn: blockStyleFn,
- customStyleMap: _extends$5({}, DefaultDraftInlineStyle, customStyleMap),
- customStyleFn: customStyleFn,
- editorKey: this._editorKey,
- editorState: editorState,
- key: 'contents' + this.state.contentsKey,
- textDirectionality: textDirectionality
- };
-
- return React.createElement(
- 'div',
- { className: rootClass },
- this._renderPlaceholder(),
- React.createElement(
- 'div',
- {
- className: cx_1('DraftEditor/editorContainer'),
- ref: function ref(_ref3) {
- return _this3.editorContainer = _ref3;
- } },
- React.createElement(
- 'div',
- {
- 'aria-activedescendant': readOnly ? null : this.props.ariaActiveDescendantID,
- 'aria-autocomplete': readOnly ? null : this.props.ariaAutoComplete,
- 'aria-controls': readOnly ? null : this.props.ariaControls,
- 'aria-describedby': this.props.ariaDescribedBy || this._placeholderAccessibilityID,
- 'aria-expanded': readOnly ? null : ariaExpanded,
- 'aria-label': this.props.ariaLabel,
- 'aria-labelledby': this.props.ariaLabelledBy,
- 'aria-multiline': this.props.ariaMultiline,
- autoCapitalize: this.props.autoCapitalize,
- autoComplete: this.props.autoComplete,
- autoCorrect: this.props.autoCorrect,
- className: cx_1({
- // Chrome's built-in translation feature mutates the DOM in ways
- // that Draft doesn't expect (ex: adding <font> tags inside
- // DraftEditorLeaf spans) and causes problems. We add notranslate
- // here which makes its autotranslation skip over this subtree.
- notranslate: !readOnly,
- 'public/DraftEditor/content': true
- }),
- contentEditable: !readOnly,
- 'data-testid': this.props.webDriverTestID,
- onBeforeInput: this._onBeforeInput,
- onBlur: this._onBlur,
- onCompositionEnd: this._onCompositionEnd,
- onCompositionStart: this._onCompositionStart,
- onCopy: this._onCopy,
- onCut: this._onCut,
- onDragEnd: this._onDragEnd,
- onDragEnter: this.onDragEnter,
- onDragLeave: this.onDragLeave,
- onDragOver: this._onDragOver,
- onDragStart: this._onDragStart,
- onDrop: this._onDrop,
- onFocus: this._onFocus,
- onInput: this._onInput,
- onKeyDown: this._onKeyDown,
- onKeyPress: this._onKeyPress,
- onKeyUp: this._onKeyUp,
- onMouseUp: this._onMouseUp,
- onPaste: this._onPaste,
- onSelect: this._onSelect,
- ref: function ref(_ref2) {
- return _this3.editor = _ref2;
- },
- role: readOnly ? null : ariaRole,
- spellCheck: allowSpellCheck && this.props.spellCheck,
- style: contentStyle,
- suppressContentEditableWarning: true,
- tabIndex: this.props.tabIndex },
- React.createElement(DraftEditorContents_react, editorContentsProps)
- )
- )
- );
- };
-
- DraftEditor.prototype.componentDidMount = function componentDidMount() {
- this.setMode('edit');
-
- /**
- * IE has a hardcoded "feature" that attempts to convert link text into
- * anchors in contentEditable DOM. This breaks the editor's expectations of
- * the DOM, and control is lost. Disable it to make IE behave.
- * See: http://blogs.msdn.com/b/ieinternals/archive/2010/09/15/
- * ie9-beta-minor-change-list.aspx
- */
- if (isIE) {
- document.execCommand('AutoUrlDetect', false, false);
- }
- };
-
- /**
- * Prevent selection events from affecting the current editor state. This
- * is mostly intended to defend against IE, which fires off `selectionchange`
- * events regardless of whether the selection is set via the browser or
- * programmatically. We only care about selection events that occur because
- * of browser interaction, not re-renders and forced selections.
- */
-
-
- DraftEditor.prototype.componentWillUpdate = function componentWillUpdate(nextProps) {
- this._blockSelectEvents = true;
- this._latestEditorState = nextProps.editorState;
- };
-
- DraftEditor.prototype.componentDidUpdate = function componentDidUpdate() {
- this._blockSelectEvents = false;
- this._latestCommittedEditorState = this.props.editorState;
- };
-
- /**
- * Used via `this.focus()`.
- *
- * Force focus back onto the editor node.
- *
- * We attempt to preserve scroll position when focusing. You can also pass
- * a specified scroll position (for cases like `cut` behavior where it should
- * be restored to a known position).
- */
-
-
- /**
- * Used via `this.setMode(...)`.
- *
- * Set the behavior mode for the editor component. This switches the current
- * handler module to ensure that DOM events are managed appropriately for
- * the active mode.
- */
-
-
- /**
- * Used via `this.restoreEditorDOM()`.
- *
- * Force a complete re-render of the DraftEditorContents based on the current
- * EditorState. This is useful when we know we are going to lose control of
- * the DOM state (cut command, IME) and we want to make sure that
- * reconciliation occurs on a version of the DOM that is synchronized with
- * our EditorState.
- */
-
-
- /**
- * Used via `this.setClipboard(...)`.
- *
- * Set the clipboard state for a cut/copy event.
- */
-
-
- /**
- * Used via `this.getClipboard()`.
- *
- * Retrieve the clipboard state for a cut/copy event.
- */
-
-
- /**
- * Used via `this.update(...)`.
- *
- * Propagate a new `EditorState` object to higher-level components. This is
- * the method by which event handlers inform the `DraftEditor` component of
- * state changes. A component that composes a `DraftEditor` **must** provide
- * an `onChange` prop to receive state updates passed along from this
- * function.
- */
-
-
- /**
- * Used in conjunction with `onDragLeave()`, by counting the number of times
- * a dragged element enters and leaves the editor (or any of its children),
- * to determine when the dragged element absolutely leaves the editor.
- */
-
-
- /**
- * See `onDragEnter()`.
- */
-
-
- return DraftEditor;
- }(React.Component);
-
- DraftEditor.defaultProps = {
- blockRenderMap: DefaultDraftBlockRenderMap_1,
- blockRendererFn: emptyFunction_1.thatReturnsNull,
- blockStyleFn: emptyFunction_1.thatReturns(''),
- keyBindingFn: getDefaultKeyBinding_1,
- readOnly: false,
- spellCheck: false,
- stripPastedStyles: false
- };
-
-
- var DraftEditor_react = DraftEditor;
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule DraftStringKey
- * @format
- *
- */
-
- var DraftStringKey = {
- stringify: function stringify(key) {
- return '_' + String(key);
- },
-
- unstringify: function unstringify(key) {
- return key.slice(1);
- }
- };
-
- var DraftStringKey_1 = DraftStringKey;
-
- var strlen$1 = UnicodeUtils_1.strlen;
-
- /**
- * Convert to UTF-8 character counts for storage.
- */
-
- function encodeEntityRanges(block, storageMap) {
- var encoded = [];
- block.findEntityRanges(function (character) {
- return !!character.getEntity();
- }, function ( /*number*/start, /*number*/end) {
- var text = block.getText();
- var key = block.getEntityAt(start);
- encoded.push({
- offset: strlen$1(text.slice(0, start)),
- length: strlen$1(text.slice(start, end)),
- // Encode the key as a number for range storage.
- key: Number(storageMap[DraftStringKey_1.stringify(key)])
- });
- });
- return encoded;
- }
-
- var encodeEntityRanges_1 = encodeEntityRanges;
-
- var areEqual$1 = function areEqual(a, b) {
- return a === b;
- };
- var isTruthy = function isTruthy(a) {
- return !!a;
- };
- var EMPTY_ARRAY = [];
-
- /**
- * Helper function for getting encoded styles for each inline style. Convert
- * to UTF-8 character counts for storage.
- */
- function getEncodedInlinesForType(block, styleList, styleToEncode) {
- var ranges = [];
-
- // Obtain an array with ranges for only the specified style.
- var filteredInlines = styleList.map(function (style) {
- return style.has(styleToEncode);
- }).toList();
-
- findRangesImmutable_1(filteredInlines, areEqual$1,
- // We only want to keep ranges with nonzero style values.
- isTruthy, function (start, end) {
- var text = block.getText();
- ranges.push({
- offset: UnicodeUtils_1.strlen(text.slice(0, start)),
- length: UnicodeUtils_1.strlen(text.slice(start, end)),
- style: styleToEncode
- });
- });
-
- return ranges;
- }
-
- /*
- * Retrieve the encoded arrays of inline styles, with each individual style
- * treated separately.
- */
- function encodeInlineStyleRanges(block) {
- var styleList = block.getCharacterList().map(function (c) {
- return c.getStyle();
- }).toList();
- var ranges = styleList.flatten().toSet().map(function (style) {
- return getEncodedInlinesForType(block, styleList, style);
- });
-
- return Array.prototype.concat.apply(EMPTY_ARRAY, ranges.toJS());
- }
-
- var encodeInlineStyleRanges_1 = encodeInlineStyleRanges;
-
- var _extends$6 = objectAssign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
-
-
-
-
-
-
-
-
-
- var createRawBlock = function createRawBlock(block, entityStorageMap) {
- return {
- key: block.getKey(),
- text: block.getText(),
- type: block.getType(),
- depth: block.getDepth(),
- inlineStyleRanges: encodeInlineStyleRanges_1(block),
- entityRanges: encodeEntityRanges_1(block, entityStorageMap),
- data: block.getData().toObject()
- };
- };
-
- var insertRawBlock = function insertRawBlock(block, entityMap, rawBlocks, blockCacheRef) {
- if (block instanceof ContentBlock_1) {
- rawBlocks.push(createRawBlock(block, entityMap));
- return;
- }
-
- !(block instanceof ContentBlockNode_1) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'block is not a BlockNode') : invariant_1(false) : void 0;
-
- var parentKey = block.getParentKey();
- var rawBlock = blockCacheRef[block.getKey()] = _extends$6({}, createRawBlock(block, entityMap), {
- children: []
- });
-
- if (parentKey) {
- blockCacheRef[parentKey].children.push(rawBlock);
- return;
- }
-
- rawBlocks.push(rawBlock);
- };
-
- var encodeRawBlocks = function encodeRawBlocks(contentState, rawState) {
- var entityMap = rawState.entityMap;
-
-
- var rawBlocks = [];
-
- var blockCacheRef = {};
- var entityCacheRef = {};
- var entityStorageKey = 0;
-
- contentState.getBlockMap().forEach(function (block) {
- block.findEntityRanges(function (character) {
- return character.getEntity() !== null;
- }, function (start) {
- var entityKey = block.getEntityAt(start);
- // Stringify to maintain order of otherwise numeric keys.
- var stringifiedEntityKey = DraftStringKey_1.stringify(entityKey);
- // This makes this function resilient to two entities
- // erroneously having the same key
- if (entityCacheRef[stringifiedEntityKey]) {
- return;
- }
- entityCacheRef[stringifiedEntityKey] = entityKey;
- // we need the `any` casting here since this is a temporary state
- // where we will later on flip the entity map and populate it with
- // real entity, at this stage we just need to map back the entity
- // key used by the BlockNode
- entityMap[stringifiedEntityKey] = '' + entityStorageKey;
- entityStorageKey++;
- });
-
- insertRawBlock(block, entityMap, rawBlocks, blockCacheRef);
- });
-
- return {
- blocks: rawBlocks,
- entityMap: entityMap
- };
- };
-
- // Flip storage map so that our storage keys map to global
- // DraftEntity keys.
- var encodeRawEntityMap = function encodeRawEntityMap(contentState, rawState) {
- var blocks = rawState.blocks,
- entityMap = rawState.entityMap;
-
-
- var rawEntityMap = {};
-
- Object.keys(entityMap).forEach(function (key, index) {
- var entity = contentState.getEntity(DraftStringKey_1.unstringify(key));
- rawEntityMap[index] = {
- type: entity.getType(),
- mutability: entity.getMutability(),
- data: entity.getData()
- };
- });
-
- return {
- blocks: blocks,
- entityMap: rawEntityMap
- };
- };
-
- var convertFromDraftStateToRaw = function convertFromDraftStateToRaw(contentState) {
- var rawDraftContentState = {
- entityMap: {},
- blocks: []
- };
-
- // add blocks
- rawDraftContentState = encodeRawBlocks(contentState, rawDraftContentState);
-
- // add entities
- rawDraftContentState = encodeRawEntityMap(contentState, rawDraftContentState);
-
- return rawDraftContentState;
- };
-
- var convertFromDraftStateToRaw_1 = convertFromDraftStateToRaw;
-
- var _extends$7 = objectAssign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule DraftTreeAdapter
- * @format
- *
- *
- * This is unstable and not part of the public API and should not be used by
- * production systems. This file may be update/removed without notice.
- */
-
-
-
- var traverseInDepthOrder = function traverseInDepthOrder(blocks, fn) {
- var stack = [].concat(blocks).reverse();
- while (stack.length) {
- var _block = stack.pop();
-
- fn(_block);
-
- var children = _block.children;
-
- !Array.isArray(children) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Invalid tree raw block') : invariant_1(false) : void 0;
-
- stack = stack.concat([].concat(children.reverse()));
- }
- };
-
- var isListBlock = function isListBlock(block) {
- if (!(block && block.type)) {
- return false;
- }
- var type = block.type;
-
- return type === 'unordered-list-item' || type === 'ordered-list-item';
- };
-
- var addDepthToChildren = function addDepthToChildren(block) {
- if (Array.isArray(block.children)) {
- block.children = block.children.map(function (child) {
- return child.type === block.type ? _extends$7({}, child, { depth: (block.depth || 0) + 1 }) : child;
- });
- }
- };
-
- /**
- * This adapter is intended to be be used as an adapter to draft tree data
- *
- * draft state <=====> draft tree state
- */
- var DraftTreeAdapter = {
- /**
- * Converts from a tree raw state back to draft raw state
- */
- fromRawTreeStateToRawState: function fromRawTreeStateToRawState(draftTreeState) {
- var blocks = draftTreeState.blocks;
-
- var transformedBlocks = [];
-
- !Array.isArray(blocks) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Invalid raw state') : invariant_1(false) : void 0;
-
- if (!Array.isArray(blocks) || !blocks.length) {
- return draftTreeState;
- }
-
- traverseInDepthOrder(blocks, function (block) {
- var newBlock = _extends$7({}, block);
-
- if (isListBlock(block)) {
- newBlock.depth = newBlock.depth || 0;
- addDepthToChildren(block);
- }
-
- delete newBlock.children;
-
- transformedBlocks.push(newBlock);
- });
-
- draftTreeState.blocks = transformedBlocks;
-
- return _extends$7({}, draftTreeState, {
- blocks: transformedBlocks
- });
- },
-
-
- /**
- * Converts from draft raw state to tree draft state
- */
- fromRawStateToRawTreeState: function fromRawStateToRawTreeState(draftState) {
- var lastListDepthCacheRef = {};
- var transformedBlocks = [];
-
- draftState.blocks.forEach(function (block) {
- var isList = isListBlock(block);
- var depth = block.depth || 0;
- var treeBlock = _extends$7({}, block, {
- children: []
- });
-
- if (!isList) {
- // reset the cache path
- lastListDepthCacheRef = {};
- transformedBlocks.push(treeBlock);
- return;
- }
-
- // update our depth cache reference path
- lastListDepthCacheRef[depth] = treeBlock;
-
- // if we are greater than zero we must have seen a parent already
- if (depth > 0) {
- var parent = lastListDepthCacheRef[depth - 1];
-
- !parent ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Invalid depth for RawDraftContentBlock') : invariant_1(false) : void 0;
-
- // push nested list blocks
- parent.children.push(treeBlock);
- return;
- }
-
- // push root list blocks
- transformedBlocks.push(treeBlock);
- });
-
- return _extends$7({}, draftState, {
- blocks: transformedBlocks
- });
- }
- };
-
- var DraftTreeAdapter_1 = DraftTreeAdapter;
-
- var List$c = immutable.List;
-
-
- function createCharacterList(inlineStyles, entities) {
- var characterArray = inlineStyles.map(function (style, ii) {
- var entity = entities[ii];
- return CharacterMetadata_1.create({ style: style, entity: entity });
- });
- return List$c(characterArray);
- }
-
- var createCharacterList_1 = createCharacterList;
-
- var substr$1 = UnicodeUtils_1.substr;
-
- /**
- * Convert to native JavaScript string lengths to determine ranges.
- */
-
- function decodeEntityRanges(text, ranges) {
- var entities = Array(text.length).fill(null);
- if (ranges) {
- ranges.forEach(function (range) {
- // Using Unicode-enabled substrings converted to JavaScript lengths,
- // fill the output array with entity keys.
- var start = substr$1(text, 0, range.offset).length;
- var end = start + substr$1(text, range.offset, range.length).length;
- for (var ii = start; ii < end; ii++) {
- entities[ii] = range.key;
- }
- });
- }
- return entities;
- }
-
- var decodeEntityRanges_1 = decodeEntityRanges;
-
- var OrderedSet$6 = immutable.OrderedSet;
-
-
-
- var substr$2 = UnicodeUtils_1.substr;
-
-
- var EMPTY_SET$3 = OrderedSet$6();
-
- /**
- * Convert to native JavaScript string lengths to determine ranges.
- */
- function decodeInlineStyleRanges(text, ranges) {
- var styles = Array(text.length).fill(EMPTY_SET$3);
- if (ranges) {
- ranges.forEach(function ( /*object*/range) {
- var cursor = substr$2(text, 0, range.offset).length;
- var end = cursor + substr$2(text, range.offset, range.length).length;
- while (cursor < end) {
- styles[cursor] = styles[cursor].add(range.style);
- cursor++;
- }
- });
- }
- return styles;
- }
-
- var decodeInlineStyleRanges_1 = decodeInlineStyleRanges;
-
- var _extends$8 = objectAssign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
-
- var List$d = immutable.List,
- Map$9 = immutable.Map,
- OrderedMap$4 = immutable.OrderedMap;
-
-
- var decodeBlockNodeConfig = function decodeBlockNodeConfig(block, entityMap) {
- var key = block.key,
- type = block.type,
- data = block.data,
- text = block.text,
- depth = block.depth;
-
-
- var blockNodeConfig = {
- text: text,
- depth: depth || 0,
- type: type || 'unstyled',
- key: key || generateRandomKey_1(),
- data: Map$9(data),
- characterList: decodeCharacterList(block, entityMap)
- };
-
- return blockNodeConfig;
- };
-
- var decodeCharacterList = function decodeCharacterList(block, entityMap) {
- var text = block.text,
- rawEntityRanges = block.entityRanges,
- rawInlineStyleRanges = block.inlineStyleRanges;
-
-
- var entityRanges = rawEntityRanges || [];
- var inlineStyleRanges = rawInlineStyleRanges || [];
-
- // Translate entity range keys to the DraftEntity map.
- return createCharacterList_1(decodeInlineStyleRanges_1(text, inlineStyleRanges), decodeEntityRanges_1(text, entityRanges.filter(function (range) {
- return entityMap.hasOwnProperty(range.key);
- }).map(function (range) {
- return _extends$8({}, range, { key: entityMap[range.key] });
- })));
- };
-
- var decodeContentBlocks = function decodeContentBlocks(blocks, entityMap) {
- return OrderedMap$4(blocks.map(function (block) {
- var contentBlock = new ContentBlock_1(decodeBlockNodeConfig(block, entityMap));
- return [contentBlock.getKey(), contentBlock];
- }));
- };
-
- var decodeRawBlocks = function decodeRawBlocks(rawState, entityMap) {
- var isTreeRawBlock = Array.isArray(rawState.blocks[0].children);
- var rawBlocks = rawState.blocks;
-
- {
- return decodeContentBlocks(isTreeRawBlock ? DraftTreeAdapter_1.fromRawTreeStateToRawState(rawState).blocks : rawBlocks, entityMap);
- }
- };
-
- var decodeRawEntityMap = function decodeRawEntityMap(rawState) {
- var rawEntityMap = rawState.entityMap;
-
- var entityMap = {};
-
- // TODO: Update this once we completely remove DraftEntity
- Object.keys(rawEntityMap).forEach(function (rawEntityKey) {
- var _rawEntityMap$rawEnti = rawEntityMap[rawEntityKey],
- type = _rawEntityMap$rawEnti.type,
- mutability = _rawEntityMap$rawEnti.mutability,
- data = _rawEntityMap$rawEnti.data;
-
- // get the key reference to created entity
-
- entityMap[rawEntityKey] = DraftEntity_1.__create(type, mutability, data || {});
- });
-
- return entityMap;
- };
-
- var convertFromRawToDraftState = function convertFromRawToDraftState(rawState) {
- !Array.isArray(rawState.blocks) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'invalid RawDraftContentState') : invariant_1(false) : void 0;
-
- // decode entities
- var entityMap = decodeRawEntityMap(rawState);
-
- // decode blockMap
- var blockMap = decodeRawBlocks(rawState, entityMap);
-
- // create initial selection
- var selectionState = blockMap.isEmpty() ? new SelectionState_1() : SelectionState_1.createEmpty(blockMap.first().getKey());
-
- return new ContentState_1({
- blockMap: blockMap,
- entityMap: entityMap,
- selectionBefore: selectionState,
- selectionAfter: selectionState
- });
- };
-
- var convertFromRawToDraftState_1 = convertFromRawToDraftState;
-
- /**
- * Like range.getBoundingClientRect() but normalizes for browser bugs.
- */
- function getRangeBoundingClientRect(range) {
- // "Return a DOMRect object describing the smallest rectangle that includes
- // the first rectangle in list and all of the remaining rectangles of which
- // the height or width is not zero."
- // http://www.w3.org/TR/cssom-view/#dom-range-getboundingclientrect
- var rects = getRangeClientRects_1(range);
- var top = 0;
- var right = 0;
- var bottom = 0;
- var left = 0;
-
- if (rects.length) {
- // If the first rectangle has 0 width, we use the second, this is needed
- // because Chrome renders a 0 width rectangle when the selection contains
- // a line break.
- if (rects.length > 1 && rects[0].width === 0) {
- var _rects$ = rects[1];
- top = _rects$.top;
- right = _rects$.right;
- bottom = _rects$.bottom;
- left = _rects$.left;
- } else {
- var _rects$2 = rects[0];
- top = _rects$2.top;
- right = _rects$2.right;
- bottom = _rects$2.bottom;
- left = _rects$2.left;
- }
-
- for (var ii = 1; ii < rects.length; ii++) {
- var rect = rects[ii];
- if (rect.height !== 0 && rect.width !== 0) {
- top = Math.min(top, rect.top);
- right = Math.max(right, rect.right);
- bottom = Math.max(bottom, rect.bottom);
- left = Math.min(left, rect.left);
- }
- }
- }
-
- return {
- top: top,
- right: right,
- bottom: bottom,
- left: left,
- width: right - left,
- height: bottom - top
- };
- }
-
- var getRangeBoundingClientRect_1 = getRangeBoundingClientRect;
-
- /**
- * Return the bounding ClientRect for the visible DOM selection, if any.
- * In cases where there are no selected ranges or the bounding rect is
- * temporarily invalid, return null.
- */
- function getVisibleSelectionRect(global) {
- var selection = global.getSelection();
- if (!selection.rangeCount) {
- return null;
- }
-
- var range = selection.getRangeAt(0);
- var boundingRect = getRangeBoundingClientRect_1(range);
- var top = boundingRect.top,
- right = boundingRect.right,
- bottom = boundingRect.bottom,
- left = boundingRect.left;
-
- // When a re-render leads to a node being removed, the DOM selection will
- // temporarily be placed on an ancestor node, which leads to an invalid
- // bounding rect. Discard this state.
-
- if (top === 0 && right === 0 && bottom === 0 && left === 0) {
- return null;
- }
-
- return boundingRect;
- }
-
- var getVisibleSelectionRect_1 = getVisibleSelectionRect;
-
- var DraftPublic = {
- Editor: DraftEditor_react,
- EditorBlock: DraftEditorBlock_react,
- EditorState: EditorState_1,
-
- CompositeDecorator: CompositeDraftDecorator_1,
- Entity: DraftEntity_1,
- EntityInstance: DraftEntityInstance_1,
-
- BlockMapBuilder: BlockMapBuilder_1,
- CharacterMetadata: CharacterMetadata_1,
- ContentBlock: ContentBlock_1,
- ContentState: ContentState_1,
- SelectionState: SelectionState_1,
-
- AtomicBlockUtils: AtomicBlockUtils_1,
- KeyBindingUtil: KeyBindingUtil_1,
- Modifier: DraftModifier_1,
- RichUtils: RichTextEditorUtil_1,
-
- DefaultDraftBlockRenderMap: DefaultDraftBlockRenderMap_1,
- DefaultDraftInlineStyle: DefaultDraftInlineStyle,
-
- convertFromHTML: convertFromHTMLToContentBlocks,
- convertFromRaw: convertFromRawToDraftState_1,
- convertToRaw: convertFromDraftStateToRaw_1,
- genKey: generateRandomKey_1,
- getDefaultKeyBinding: getDefaultKeyBinding_1,
- getVisibleSelectionRect: getVisibleSelectionRect_1
- };
-
- var Draft = DraftPublic;
-
- var immutable$1 = createCommonjsModule(function (module, exports) {
- /**
- * Copyright (c) 2014-2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
-
- (function (global, factory) {
- module.exports = factory() ;
- }(commonjsGlobal, function () {var SLICE$0 = Array.prototype.slice;
-
- function createClass(ctor, superClass) {
- if (superClass) {
- ctor.prototype = Object.create(superClass.prototype);
- }
- ctor.prototype.constructor = ctor;
- }
-
- function Iterable(value) {
- return isIterable(value) ? value : Seq(value);
- }
-
-
- createClass(KeyedIterable, Iterable);
- function KeyedIterable(value) {
- return isKeyed(value) ? value : KeyedSeq(value);
- }
-
-
- createClass(IndexedIterable, Iterable);
- function IndexedIterable(value) {
- return isIndexed(value) ? value : IndexedSeq(value);
- }
-
-
- createClass(SetIterable, Iterable);
- function SetIterable(value) {
- return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
- }
-
-
-
- function isIterable(maybeIterable) {
- return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
- }
-
- function isKeyed(maybeKeyed) {
- return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
- }
-
- function isIndexed(maybeIndexed) {
- return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
- }
-
- function isAssociative(maybeAssociative) {
- return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
- }
-
- function isOrdered(maybeOrdered) {
- return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
- }
-
- Iterable.isIterable = isIterable;
- Iterable.isKeyed = isKeyed;
- Iterable.isIndexed = isIndexed;
- Iterable.isAssociative = isAssociative;
- Iterable.isOrdered = isOrdered;
-
- Iterable.Keyed = KeyedIterable;
- Iterable.Indexed = IndexedIterable;
- Iterable.Set = SetIterable;
-
-
- var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
- var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
- var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
- var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
-
- // Used for setting prototype methods that IE8 chokes on.
- var DELETE = 'delete';
-
- // Constants describing the size of trie nodes.
- var SHIFT = 5; // Resulted in best performance after ______?
- var SIZE = 1 << SHIFT;
- var MASK = SIZE - 1;
-
- // A consistent shared value representing "not set" which equals nothing other
- // than itself, and nothing that could be provided externally.
- var NOT_SET = {};
-
- // Boolean references, Rough equivalent of `bool &`.
- var CHANGE_LENGTH = { value: false };
- var DID_ALTER = { value: false };
-
- function MakeRef(ref) {
- ref.value = false;
- return ref;
- }
-
- function SetRef(ref) {
- ref && (ref.value = true);
- }
-
- // A function which returns a value representing an "owner" for transient writes
- // to tries. The return value will only ever equal itself, and will not equal
- // the return of any subsequent call of this function.
- function OwnerID() {}
-
- // http://jsperf.com/copy-array-inline
- function arrCopy(arr, offset) {
- offset = offset || 0;
- var len = Math.max(0, arr.length - offset);
- var newArr = new Array(len);
- for (var ii = 0; ii < len; ii++) {
- newArr[ii] = arr[ii + offset];
- }
- return newArr;
- }
-
- function ensureSize(iter) {
- if (iter.size === undefined) {
- iter.size = iter.__iterate(returnTrue);
- }
- return iter.size;
- }
-
- function wrapIndex(iter, index) {
- // This implements "is array index" which the ECMAString spec defines as:
- //
- // A String property name P is an array index if and only if
- // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
- // to 2^32−1.
- //
- // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
- if (typeof index !== 'number') {
- var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
- if ('' + uint32Index !== index || uint32Index === 4294967295) {
- return NaN;
- }
- index = uint32Index;
- }
- return index < 0 ? ensureSize(iter) + index : index;
- }
-
- function returnTrue() {
- return true;
- }
-
- function wholeSlice(begin, end, size) {
- return (begin === 0 || (size !== undefined && begin <= -size)) &&
- (end === undefined || (size !== undefined && end >= size));
- }
-
- function resolveBegin(begin, size) {
- return resolveIndex(begin, size, 0);
- }
-
- function resolveEnd(end, size) {
- return resolveIndex(end, size, size);
- }
-
- function resolveIndex(index, size, defaultIndex) {
- return index === undefined ?
- defaultIndex :
- index < 0 ?
- Math.max(0, size + index) :
- size === undefined ?
- index :
- Math.min(size, index);
- }
-
- /* global Symbol */
-
- var ITERATE_KEYS = 0;
- var ITERATE_VALUES = 1;
- var ITERATE_ENTRIES = 2;
-
- var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
- var FAUX_ITERATOR_SYMBOL = '@@iterator';
-
- var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
-
-
- function Iterator(next) {
- this.next = next;
- }
-
- Iterator.prototype.toString = function() {
- return '[Iterator]';
- };
-
-
- Iterator.KEYS = ITERATE_KEYS;
- Iterator.VALUES = ITERATE_VALUES;
- Iterator.ENTRIES = ITERATE_ENTRIES;
-
- Iterator.prototype.inspect =
- Iterator.prototype.toSource = function () { return this.toString(); };
- Iterator.prototype[ITERATOR_SYMBOL] = function () {
- return this;
- };
-
-
- function iteratorValue(type, k, v, iteratorResult) {
- var value = type === 0 ? k : type === 1 ? v : [k, v];
- iteratorResult ? (iteratorResult.value = value) : (iteratorResult = {
- value: value, done: false
- });
- return iteratorResult;
- }
-
- function iteratorDone() {
- return { value: undefined, done: true };
- }
-
- function hasIterator(maybeIterable) {
- return !!getIteratorFn(maybeIterable);
- }
-
- function isIterator(maybeIterator) {
- return maybeIterator && typeof maybeIterator.next === 'function';
- }
-
- function getIterator(iterable) {
- var iteratorFn = getIteratorFn(iterable);
- return iteratorFn && iteratorFn.call(iterable);
- }
-
- function getIteratorFn(iterable) {
- var iteratorFn = iterable && (
- (REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
- iterable[FAUX_ITERATOR_SYMBOL]
- );
- if (typeof iteratorFn === 'function') {
- return iteratorFn;
- }
- }
-
- function isArrayLike(value) {
- return value && typeof value.length === 'number';
- }
-
- createClass(Seq, Iterable);
- function Seq(value) {
- return value === null || value === undefined ? emptySequence() :
- isIterable(value) ? value.toSeq() : seqFromValue(value);
- }
-
- Seq.of = function(/*...values*/) {
- return Seq(arguments);
- };
-
- Seq.prototype.toSeq = function() {
- return this;
- };
-
- Seq.prototype.toString = function() {
- return this.__toString('Seq {', '}');
- };
-
- Seq.prototype.cacheResult = function() {
- if (!this._cache && this.__iterateUncached) {
- this._cache = this.entrySeq().toArray();
- this.size = this._cache.length;
- }
- return this;
- };
-
- // abstract __iterateUncached(fn, reverse)
-
- Seq.prototype.__iterate = function(fn, reverse) {
- return seqIterate(this, fn, reverse, true);
- };
-
- // abstract __iteratorUncached(type, reverse)
-
- Seq.prototype.__iterator = function(type, reverse) {
- return seqIterator(this, type, reverse, true);
- };
-
-
-
- createClass(KeyedSeq, Seq);
- function KeyedSeq(value) {
- return value === null || value === undefined ?
- emptySequence().toKeyedSeq() :
- isIterable(value) ?
- (isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) :
- keyedSeqFromValue(value);
- }
-
- KeyedSeq.prototype.toKeyedSeq = function() {
- return this;
- };
-
-
-
- createClass(IndexedSeq, Seq);
- function IndexedSeq(value) {
- return value === null || value === undefined ? emptySequence() :
- !isIterable(value) ? indexedSeqFromValue(value) :
- isKeyed(value) ? value.entrySeq() : value.toIndexedSeq();
- }
-
- IndexedSeq.of = function(/*...values*/) {
- return IndexedSeq(arguments);
- };
-
- IndexedSeq.prototype.toIndexedSeq = function() {
- return this;
- };
-
- IndexedSeq.prototype.toString = function() {
- return this.__toString('Seq [', ']');
- };
-
- IndexedSeq.prototype.__iterate = function(fn, reverse) {
- return seqIterate(this, fn, reverse, false);
- };
-
- IndexedSeq.prototype.__iterator = function(type, reverse) {
- return seqIterator(this, type, reverse, false);
- };
-
-
-
- createClass(SetSeq, Seq);
- function SetSeq(value) {
- return (
- value === null || value === undefined ? emptySequence() :
- !isIterable(value) ? indexedSeqFromValue(value) :
- isKeyed(value) ? value.entrySeq() : value
- ).toSetSeq();
- }
-
- SetSeq.of = function(/*...values*/) {
- return SetSeq(arguments);
- };
-
- SetSeq.prototype.toSetSeq = function() {
- return this;
- };
-
-
-
- Seq.isSeq = isSeq;
- Seq.Keyed = KeyedSeq;
- Seq.Set = SetSeq;
- Seq.Indexed = IndexedSeq;
-
- var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
-
- Seq.prototype[IS_SEQ_SENTINEL] = true;
-
-
-
- createClass(ArraySeq, IndexedSeq);
- function ArraySeq(array) {
- this._array = array;
- this.size = array.length;
- }
-
- ArraySeq.prototype.get = function(index, notSetValue) {
- return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
- };
-
- ArraySeq.prototype.__iterate = function(fn, reverse) {
- var array = this._array;
- var maxIndex = array.length - 1;
- for (var ii = 0; ii <= maxIndex; ii++) {
- if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
- return ii + 1;
- }
- }
- return ii;
- };
-
- ArraySeq.prototype.__iterator = function(type, reverse) {
- var array = this._array;
- var maxIndex = array.length - 1;
- var ii = 0;
- return new Iterator(function()
- {return ii > maxIndex ?
- iteratorDone() :
- iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])}
- );
- };
-
-
-
- createClass(ObjectSeq, KeyedSeq);
- function ObjectSeq(object) {
- var keys = Object.keys(object);
- this._object = object;
- this._keys = keys;
- this.size = keys.length;
- }
-
- ObjectSeq.prototype.get = function(key, notSetValue) {
- if (notSetValue !== undefined && !this.has(key)) {
- return notSetValue;
- }
- return this._object[key];
- };
-
- ObjectSeq.prototype.has = function(key) {
- return this._object.hasOwnProperty(key);
- };
-
- ObjectSeq.prototype.__iterate = function(fn, reverse) {
- var object = this._object;
- var keys = this._keys;
- var maxIndex = keys.length - 1;
- for (var ii = 0; ii <= maxIndex; ii++) {
- var key = keys[reverse ? maxIndex - ii : ii];
- if (fn(object[key], key, this) === false) {
- return ii + 1;
- }
- }
- return ii;
- };
-
- ObjectSeq.prototype.__iterator = function(type, reverse) {
- var object = this._object;
- var keys = this._keys;
- var maxIndex = keys.length - 1;
- var ii = 0;
- return new Iterator(function() {
- var key = keys[reverse ? maxIndex - ii : ii];
- return ii++ > maxIndex ?
- iteratorDone() :
- iteratorValue(type, key, object[key]);
- });
- };
-
- ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
-
-
- createClass(IterableSeq, IndexedSeq);
- function IterableSeq(iterable) {
- this._iterable = iterable;
- this.size = iterable.length || iterable.size;
- }
-
- IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
- if (reverse) {
- return this.cacheResult().__iterate(fn, reverse);
- }
- var iterable = this._iterable;
- var iterator = getIterator(iterable);
- var iterations = 0;
- if (isIterator(iterator)) {
- var step;
- while (!(step = iterator.next()).done) {
- if (fn(step.value, iterations++, this) === false) {
- break;
- }
- }
- }
- return iterations;
- };
-
- IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
- if (reverse) {
- return this.cacheResult().__iterator(type, reverse);
- }
- var iterable = this._iterable;
- var iterator = getIterator(iterable);
- if (!isIterator(iterator)) {
- return new Iterator(iteratorDone);
- }
- var iterations = 0;
- return new Iterator(function() {
- var step = iterator.next();
- return step.done ? step : iteratorValue(type, iterations++, step.value);
- });
- };
-
-
-
- createClass(IteratorSeq, IndexedSeq);
- function IteratorSeq(iterator) {
- this._iterator = iterator;
- this._iteratorCache = [];
- }
-
- IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
- if (reverse) {
- return this.cacheResult().__iterate(fn, reverse);
- }
- var iterator = this._iterator;
- var cache = this._iteratorCache;
- var iterations = 0;
- while (iterations < cache.length) {
- if (fn(cache[iterations], iterations++, this) === false) {
- return iterations;
- }
- }
- var step;
- while (!(step = iterator.next()).done) {
- var val = step.value;
- cache[iterations] = val;
- if (fn(val, iterations++, this) === false) {
- break;
- }
- }
- return iterations;
- };
-
- IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
- if (reverse) {
- return this.cacheResult().__iterator(type, reverse);
- }
- var iterator = this._iterator;
- var cache = this._iteratorCache;
- var iterations = 0;
- return new Iterator(function() {
- if (iterations >= cache.length) {
- var step = iterator.next();
- if (step.done) {
- return step;
- }
- cache[iterations] = step.value;
- }
- return iteratorValue(type, iterations, cache[iterations++]);
- });
- };
-
-
-
-
- // # pragma Helper functions
-
- function isSeq(maybeSeq) {
- return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
- }
-
- var EMPTY_SEQ;
-
- function emptySequence() {
- return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
- }
-
- function keyedSeqFromValue(value) {
- var seq =
- Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() :
- isIterator(value) ? new IteratorSeq(value).fromEntrySeq() :
- hasIterator(value) ? new IterableSeq(value).fromEntrySeq() :
- typeof value === 'object' ? new ObjectSeq(value) :
- undefined;
- if (!seq) {
- throw new TypeError(
- 'Expected Array or iterable object of [k, v] entries, '+
- 'or keyed object: ' + value
- );
- }
- return seq;
- }
-
- function indexedSeqFromValue(value) {
- var seq = maybeIndexedSeqFromValue(value);
- if (!seq) {
- throw new TypeError(
- 'Expected Array or iterable object of values: ' + value
- );
- }
- return seq;
- }
-
- function seqFromValue(value) {
- var seq = maybeIndexedSeqFromValue(value) ||
- (typeof value === 'object' && new ObjectSeq(value));
- if (!seq) {
- throw new TypeError(
- 'Expected Array or iterable object of values, or keyed object: ' + value
- );
- }
- return seq;
- }
-
- function maybeIndexedSeqFromValue(value) {
- return (
- isArrayLike(value) ? new ArraySeq(value) :
- isIterator(value) ? new IteratorSeq(value) :
- hasIterator(value) ? new IterableSeq(value) :
- undefined
- );
- }
-
- function seqIterate(seq, fn, reverse, useKeys) {
- var cache = seq._cache;
- if (cache) {
- var maxIndex = cache.length - 1;
- for (var ii = 0; ii <= maxIndex; ii++) {
- var entry = cache[reverse ? maxIndex - ii : ii];
- if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
- return ii + 1;
- }
- }
- return ii;
- }
- return seq.__iterateUncached(fn, reverse);
- }
-
- function seqIterator(seq, type, reverse, useKeys) {
- var cache = seq._cache;
- if (cache) {
- var maxIndex = cache.length - 1;
- var ii = 0;
- return new Iterator(function() {
- var entry = cache[reverse ? maxIndex - ii : ii];
- return ii++ > maxIndex ?
- iteratorDone() :
- iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
- });
- }
- return seq.__iteratorUncached(type, reverse);
- }
-
- function fromJS(json, converter) {
- return converter ?
- fromJSWith(converter, json, '', {'': json}) :
- fromJSDefault(json);
- }
-
- function fromJSWith(converter, json, key, parentJSON) {
- if (Array.isArray(json)) {
- return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
- }
- if (isPlainObj(json)) {
- return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
- }
- return json;
- }
-
- function fromJSDefault(json) {
- if (Array.isArray(json)) {
- return IndexedSeq(json).map(fromJSDefault).toList();
- }
- if (isPlainObj(json)) {
- return KeyedSeq(json).map(fromJSDefault).toMap();
- }
- return json;
- }
-
- function isPlainObj(value) {
- return value && (value.constructor === Object || value.constructor === undefined);
- }
-
- /**
- * An extension of the "same-value" algorithm as [described for use by ES6 Map
- * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
- *
- * NaN is considered the same as NaN, however -0 and 0 are considered the same
- * value, which is different from the algorithm described by
- * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
- *
- * This is extended further to allow Objects to describe the values they
- * represent, by way of `valueOf` or `equals` (and `hashCode`).
- *
- * Note: because of this extension, the key equality of Immutable.Map and the
- * value equality of Immutable.Set will differ from ES6 Map and Set.
- *
- * ### Defining custom values
- *
- * The easiest way to describe the value an object represents is by implementing
- * `valueOf`. For example, `Date` represents a value by returning a unix
- * timestamp for `valueOf`:
- *
- * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
- * var date2 = new Date(1234567890000);
- * date1.valueOf(); // 1234567890000
- * assert( date1 !== date2 );
- * assert( Immutable.is( date1, date2 ) );
- *
- * Note: overriding `valueOf` may have other implications if you use this object
- * where JavaScript expects a primitive, such as implicit string coercion.
- *
- * For more complex types, especially collections, implementing `valueOf` may
- * not be performant. An alternative is to implement `equals` and `hashCode`.
- *
- * `equals` takes another object, presumably of similar type, and returns true
- * if the it is equal. Equality is symmetrical, so the same result should be
- * returned if this and the argument are flipped.
- *
- * assert( a.equals(b) === b.equals(a) );
- *
- * `hashCode` returns a 32bit integer number representing the object which will
- * be used to determine how to store the value object in a Map or Set. You must
- * provide both or neither methods, one must not exist without the other.
- *
- * Also, an important relationship between these methods must be upheld: if two
- * values are equal, they *must* return the same hashCode. If the values are not
- * equal, they might have the same hashCode; this is called a hash collision,
- * and while undesirable for performance reasons, it is acceptable.
- *
- * if (a.equals(b)) {
- * assert( a.hashCode() === b.hashCode() );
- * }
- *
- * All Immutable collections implement `equals` and `hashCode`.
- *
- */
- function is(valueA, valueB) {
- if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
- return true;
- }
- if (!valueA || !valueB) {
- return false;
- }
- if (typeof valueA.valueOf === 'function' &&
- typeof valueB.valueOf === 'function') {
- valueA = valueA.valueOf();
- valueB = valueB.valueOf();
- if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
- return true;
- }
- if (!valueA || !valueB) {
- return false;
- }
- }
- if (typeof valueA.equals === 'function' &&
- typeof valueB.equals === 'function' &&
- valueA.equals(valueB)) {
- return true;
- }
- return false;
- }
-
- function deepEqual(a, b) {
- if (a === b) {
- return true;
- }
-
- if (
- !isIterable(b) ||
- a.size !== undefined && b.size !== undefined && a.size !== b.size ||
- a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash ||
- isKeyed(a) !== isKeyed(b) ||
- isIndexed(a) !== isIndexed(b) ||
- isOrdered(a) !== isOrdered(b)
- ) {
- return false;
- }
-
- if (a.size === 0 && b.size === 0) {
- return true;
- }
-
- var notAssociative = !isAssociative(a);
-
- if (isOrdered(a)) {
- var entries = a.entries();
- return b.every(function(v, k) {
- var entry = entries.next().value;
- return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
- }) && entries.next().done;
- }
-
- var flipped = false;
-
- if (a.size === undefined) {
- if (b.size === undefined) {
- if (typeof a.cacheResult === 'function') {
- a.cacheResult();
- }
- } else {
- flipped = true;
- var _ = a;
- a = b;
- b = _;
- }
- }
-
- var allEqual = true;
- var bSize = b.__iterate(function(v, k) {
- if (notAssociative ? !a.has(v) :
- flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) {
- allEqual = false;
- return false;
- }
- });
-
- return allEqual && a.size === bSize;
- }
-
- createClass(Repeat, IndexedSeq);
-
- function Repeat(value, times) {
- if (!(this instanceof Repeat)) {
- return new Repeat(value, times);
- }
- this._value = value;
- this.size = times === undefined ? Infinity : Math.max(0, times);
- if (this.size === 0) {
- if (EMPTY_REPEAT) {
- return EMPTY_REPEAT;
- }
- EMPTY_REPEAT = this;
- }
- }
-
- Repeat.prototype.toString = function() {
- if (this.size === 0) {
- return 'Repeat []';
- }
- return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
- };
-
- Repeat.prototype.get = function(index, notSetValue) {
- return this.has(index) ? this._value : notSetValue;
- };
-
- Repeat.prototype.includes = function(searchValue) {
- return is(this._value, searchValue);
- };
-
- Repeat.prototype.slice = function(begin, end) {
- var size = this.size;
- return wholeSlice(begin, end, size) ? this :
- new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size));
- };
-
- Repeat.prototype.reverse = function() {
- return this;
- };
-
- Repeat.prototype.indexOf = function(searchValue) {
- if (is(this._value, searchValue)) {
- return 0;
- }
- return -1;
- };
-
- Repeat.prototype.lastIndexOf = function(searchValue) {
- if (is(this._value, searchValue)) {
- return this.size;
- }
- return -1;
- };
-
- Repeat.prototype.__iterate = function(fn, reverse) {
- for (var ii = 0; ii < this.size; ii++) {
- if (fn(this._value, ii, this) === false) {
- return ii + 1;
- }
- }
- return ii;
- };
-
- Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this;
- var ii = 0;
- return new Iterator(function()
- {return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()}
- );
- };
-
- Repeat.prototype.equals = function(other) {
- return other instanceof Repeat ?
- is(this._value, other._value) :
- deepEqual(other);
- };
-
-
- var EMPTY_REPEAT;
-
- function invariant(condition, error) {
- if (!condition) throw new Error(error);
- }
-
- createClass(Range, IndexedSeq);
-
- function Range(start, end, step) {
- if (!(this instanceof Range)) {
- return new Range(start, end, step);
- }
- invariant(step !== 0, 'Cannot step a Range by 0');
- start = start || 0;
- if (end === undefined) {
- end = Infinity;
- }
- step = step === undefined ? 1 : Math.abs(step);
- if (end < start) {
- step = -step;
- }
- this._start = start;
- this._end = end;
- this._step = step;
- this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
- if (this.size === 0) {
- if (EMPTY_RANGE) {
- return EMPTY_RANGE;
- }
- EMPTY_RANGE = this;
- }
- }
-
- Range.prototype.toString = function() {
- if (this.size === 0) {
- return 'Range []';
- }
- return 'Range [ ' +
- this._start + '...' + this._end +
- (this._step > 1 ? ' by ' + this._step : '') +
- ' ]';
- };
-
- Range.prototype.get = function(index, notSetValue) {
- return this.has(index) ?
- this._start + wrapIndex(this, index) * this._step :
- notSetValue;
- };
-
- Range.prototype.includes = function(searchValue) {
- var possibleIndex = (searchValue - this._start) / this._step;
- return possibleIndex >= 0 &&
- possibleIndex < this.size &&
- possibleIndex === Math.floor(possibleIndex);
- };
-
- Range.prototype.slice = function(begin, end) {
- if (wholeSlice(begin, end, this.size)) {
- return this;
- }
- begin = resolveBegin(begin, this.size);
- end = resolveEnd(end, this.size);
- if (end <= begin) {
- return new Range(0, 0);
- }
- return new Range(this.get(begin, this._end), this.get(end, this._end), this._step);
- };
-
- Range.prototype.indexOf = function(searchValue) {
- var offsetValue = searchValue - this._start;
- if (offsetValue % this._step === 0) {
- var index = offsetValue / this._step;
- if (index >= 0 && index < this.size) {
- return index
- }
- }
- return -1;
- };
-
- Range.prototype.lastIndexOf = function(searchValue) {
- return this.indexOf(searchValue);
- };
-
- Range.prototype.__iterate = function(fn, reverse) {
- var maxIndex = this.size - 1;
- var step = this._step;
- var value = reverse ? this._start + maxIndex * step : this._start;
- for (var ii = 0; ii <= maxIndex; ii++) {
- if (fn(value, ii, this) === false) {
- return ii + 1;
- }
- value += reverse ? -step : step;
- }
- return ii;
- };
-
- Range.prototype.__iterator = function(type, reverse) {
- var maxIndex = this.size - 1;
- var step = this._step;
- var value = reverse ? this._start + maxIndex * step : this._start;
- var ii = 0;
- return new Iterator(function() {
- var v = value;
- value += reverse ? -step : step;
- return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
- });
- };
-
- Range.prototype.equals = function(other) {
- return other instanceof Range ?
- this._start === other._start &&
- this._end === other._end &&
- this._step === other._step :
- deepEqual(this, other);
- };
-
-
- var EMPTY_RANGE;
-
- createClass(Collection, Iterable);
- function Collection() {
- throw TypeError('Abstract');
- }
-
-
- createClass(KeyedCollection, Collection);function KeyedCollection() {}
-
- createClass(IndexedCollection, Collection);function IndexedCollection() {}
-
- createClass(SetCollection, Collection);function SetCollection() {}
-
-
- Collection.Keyed = KeyedCollection;
- Collection.Indexed = IndexedCollection;
- Collection.Set = SetCollection;
-
- var imul =
- typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ?
- Math.imul :
- function imul(a, b) {
- a = a | 0; // int
- b = b | 0; // int
- var c = a & 0xffff;
- var d = b & 0xffff;
- // Shift by 0 fixes the sign on the high part.
- return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int
- };
-
- // v8 has an optimization for storing 31-bit signed numbers.
- // Values which have either 00 or 11 as the high order bits qualify.
- // This function drops the highest order bit in a signed number, maintaining
- // the sign bit.
- function smi(i32) {
- return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF);
- }
-
- function hash(o) {
- if (o === false || o === null || o === undefined) {
- return 0;
- }
- if (typeof o.valueOf === 'function') {
- o = o.valueOf();
- if (o === false || o === null || o === undefined) {
- return 0;
- }
- }
- if (o === true) {
- return 1;
- }
- var type = typeof o;
- if (type === 'number') {
- var h = o | 0;
- if (h !== o) {
- h ^= o * 0xFFFFFFFF;
- }
- while (o > 0xFFFFFFFF) {
- o /= 0xFFFFFFFF;
- h ^= o;
- }
- return smi(h);
- }
- if (type === 'string') {
- return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o);
- }
- if (typeof o.hashCode === 'function') {
- return o.hashCode();
- }
- if (type === 'object') {
- return hashJSObj(o);
- }
- if (typeof o.toString === 'function') {
- return hashString(o.toString());
- }
- throw new Error('Value type ' + type + ' cannot be hashed.');
- }
-
- function cachedHashString(string) {
- var hash = stringHashCache[string];
- if (hash === undefined) {
- hash = hashString(string);
- if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
- STRING_HASH_CACHE_SIZE = 0;
- stringHashCache = {};
- }
- STRING_HASH_CACHE_SIZE++;
- stringHashCache[string] = hash;
- }
- return hash;
- }
-
- // http://jsperf.com/hashing-strings
- function hashString(string) {
- // This is the hash from JVM
- // The hash code for a string is computed as
- // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
- // where s[i] is the ith character of the string and n is the length of
- // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
- // (exclusive) by dropping high bits.
- var hash = 0;
- for (var ii = 0; ii < string.length; ii++) {
- hash = 31 * hash + string.charCodeAt(ii) | 0;
- }
- return smi(hash);
- }
-
- function hashJSObj(obj) {
- var hash;
- if (usingWeakMap) {
- hash = weakMap.get(obj);
- if (hash !== undefined) {
- return hash;
- }
- }
-
- hash = obj[UID_HASH_KEY];
- if (hash !== undefined) {
- return hash;
- }
-
- if (!canDefineProperty) {
- hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
- if (hash !== undefined) {
- return hash;
- }
-
- hash = getIENodeHash(obj);
- if (hash !== undefined) {
- return hash;
- }
- }
-
- hash = ++objHashUID;
- if (objHashUID & 0x40000000) {
- objHashUID = 0;
- }
-
- if (usingWeakMap) {
- weakMap.set(obj, hash);
- } else if (isExtensible !== undefined && isExtensible(obj) === false) {
- throw new Error('Non-extensible objects are not allowed as keys.');
- } else if (canDefineProperty) {
- Object.defineProperty(obj, UID_HASH_KEY, {
- 'enumerable': false,
- 'configurable': false,
- 'writable': false,
- 'value': hash
- });
- } else if (obj.propertyIsEnumerable !== undefined &&
- obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {
- // Since we can't define a non-enumerable property on the object
- // we'll hijack one of the less-used non-enumerable properties to
- // save our hash on it. Since this is a function it will not show up in
- // `JSON.stringify` which is what we want.
- obj.propertyIsEnumerable = function() {
- return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
- };
- obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
- } else if (obj.nodeType !== undefined) {
- // At this point we couldn't get the IE `uniqueID` to use as a hash
- // and we couldn't use a non-enumerable property to exploit the
- // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
- // itself.
- obj[UID_HASH_KEY] = hash;
- } else {
- throw new Error('Unable to set a non-enumerable property on object.');
- }
-
- return hash;
- }
-
- // Get references to ES5 object methods.
- var isExtensible = Object.isExtensible;
-
- // True if Object.defineProperty works as expected. IE8 fails this test.
- var canDefineProperty = (function() {
- try {
- Object.defineProperty({}, '@', {});
- return true;
- } catch (e) {
- return false;
- }
- }());
-
- // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
- // and avoid memory leaks from the IE cloneNode bug.
- function getIENodeHash(node) {
- if (node && node.nodeType > 0) {
- switch (node.nodeType) {
- case 1: // Element
- return node.uniqueID;
- case 9: // Document
- return node.documentElement && node.documentElement.uniqueID;
- }
- }
- }
-
- // If possible, use a WeakMap.
- var usingWeakMap = typeof WeakMap === 'function';
- var weakMap;
- if (usingWeakMap) {
- weakMap = new WeakMap();
- }
-
- var objHashUID = 0;
-
- var UID_HASH_KEY = '__immutablehash__';
- if (typeof Symbol === 'function') {
- UID_HASH_KEY = Symbol(UID_HASH_KEY);
- }
-
- var STRING_HASH_CACHE_MIN_STRLEN = 16;
- var STRING_HASH_CACHE_MAX_SIZE = 255;
- var STRING_HASH_CACHE_SIZE = 0;
- var stringHashCache = {};
-
- function assertNotInfinite(size) {
- invariant(
- size !== Infinity,
- 'Cannot perform this action with an infinite size.'
- );
- }
-
- createClass(Map, KeyedCollection);
-
- // @pragma Construction
-
- function Map(value) {
- return value === null || value === undefined ? emptyMap() :
- isMap(value) && !isOrdered(value) ? value :
- emptyMap().withMutations(function(map ) {
- var iter = KeyedIterable(value);
- assertNotInfinite(iter.size);
- iter.forEach(function(v, k) {return map.set(k, v)});
- });
- }
-
- Map.prototype.toString = function() {
- return this.__toString('Map {', '}');
- };
-
- // @pragma Access
-
- Map.prototype.get = function(k, notSetValue) {
- return this._root ?
- this._root.get(0, undefined, k, notSetValue) :
- notSetValue;
- };
-
- // @pragma Modification
-
- Map.prototype.set = function(k, v) {
- return updateMap(this, k, v);
- };
-
- Map.prototype.setIn = function(keyPath, v) {
- return this.updateIn(keyPath, NOT_SET, function() {return v});
- };
-
- Map.prototype.remove = function(k) {
- return updateMap(this, k, NOT_SET);
- };
-
- Map.prototype.deleteIn = function(keyPath) {
- return this.updateIn(keyPath, function() {return NOT_SET});
- };
-
- Map.prototype.update = function(k, notSetValue, updater) {
- return arguments.length === 1 ?
- k(this) :
- this.updateIn([k], notSetValue, updater);
- };
-
- Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
- if (!updater) {
- updater = notSetValue;
- notSetValue = undefined;
- }
- var updatedValue = updateInDeepMap(
- this,
- forceIterator(keyPath),
- notSetValue,
- updater
- );
- return updatedValue === NOT_SET ? undefined : updatedValue;
- };
-
- Map.prototype.clear = function() {
- if (this.size === 0) {
- return this;
- }
- if (this.__ownerID) {
- this.size = 0;
- this._root = null;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return emptyMap();
- };
-
- // @pragma Composition
-
- Map.prototype.merge = function(/*...iters*/) {
- return mergeIntoMapWith(this, undefined, arguments);
- };
-
- Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
- return mergeIntoMapWith(this, merger, iters);
- };
-
- Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
- return this.updateIn(
- keyPath,
- emptyMap(),
- function(m ) {return typeof m.merge === 'function' ?
- m.merge.apply(m, iters) :
- iters[iters.length - 1]}
- );
- };
-
- Map.prototype.mergeDeep = function(/*...iters*/) {
- return mergeIntoMapWith(this, deepMerger, arguments);
- };
-
- Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
- return mergeIntoMapWith(this, deepMergerWith(merger), iters);
- };
-
- Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
- return this.updateIn(
- keyPath,
- emptyMap(),
- function(m ) {return typeof m.mergeDeep === 'function' ?
- m.mergeDeep.apply(m, iters) :
- iters[iters.length - 1]}
- );
- };
-
- Map.prototype.sort = function(comparator) {
- // Late binding
- return OrderedMap(sortFactory(this, comparator));
- };
-
- Map.prototype.sortBy = function(mapper, comparator) {
- // Late binding
- return OrderedMap(sortFactory(this, comparator, mapper));
- };
-
- // @pragma Mutability
-
- Map.prototype.withMutations = function(fn) {
- var mutable = this.asMutable();
- fn(mutable);
- return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
- };
-
- Map.prototype.asMutable = function() {
- return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
- };
-
- Map.prototype.asImmutable = function() {
- return this.__ensureOwner();
- };
-
- Map.prototype.wasAltered = function() {
- return this.__altered;
- };
-
- Map.prototype.__iterator = function(type, reverse) {
- return new MapIterator(this, type, reverse);
- };
-
- Map.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- var iterations = 0;
- this._root && this._root.iterate(function(entry ) {
- iterations++;
- return fn(entry[1], entry[0], this$0);
- }, reverse);
- return iterations;
- };
-
- Map.prototype.__ensureOwner = function(ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- if (!ownerID) {
- this.__ownerID = ownerID;
- this.__altered = false;
- return this;
- }
- return makeMap(this.size, this._root, ownerID, this.__hash);
- };
-
-
- function isMap(maybeMap) {
- return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
- }
-
- Map.isMap = isMap;
-
- var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
-
- var MapPrototype = Map.prototype;
- MapPrototype[IS_MAP_SENTINEL] = true;
- MapPrototype[DELETE] = MapPrototype.remove;
- MapPrototype.removeIn = MapPrototype.deleteIn;
-
-
- // #pragma Trie Nodes
-
-
-
- function ArrayMapNode(ownerID, entries) {
- this.ownerID = ownerID;
- this.entries = entries;
- }
-
- ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
- var entries = this.entries;
- for (var ii = 0, len = entries.length; ii < len; ii++) {
- if (is(key, entries[ii][0])) {
- return entries[ii][1];
- }
- }
- return notSetValue;
- };
-
- ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- var removed = value === NOT_SET;
-
- var entries = this.entries;
- var idx = 0;
- for (var len = entries.length; idx < len; idx++) {
- if (is(key, entries[idx][0])) {
- break;
- }
- }
- var exists = idx < len;
-
- if (exists ? entries[idx][1] === value : removed) {
- return this;
- }
-
- SetRef(didAlter);
- (removed || !exists) && SetRef(didChangeSize);
-
- if (removed && entries.length === 1) {
- return; // undefined
- }
-
- if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
- return createNodes(ownerID, entries, key, value);
- }
-
- var isEditable = ownerID && ownerID === this.ownerID;
- var newEntries = isEditable ? entries : arrCopy(entries);
-
- if (exists) {
- if (removed) {
- idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
- } else {
- newEntries[idx] = [key, value];
- }
- } else {
- newEntries.push([key, value]);
- }
-
- if (isEditable) {
- this.entries = newEntries;
- return this;
- }
-
- return new ArrayMapNode(ownerID, newEntries);
- };
-
-
-
-
- function BitmapIndexedNode(ownerID, bitmap, nodes) {
- this.ownerID = ownerID;
- this.bitmap = bitmap;
- this.nodes = nodes;
- }
-
- BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) {
- if (keyHash === undefined) {
- keyHash = hash(key);
- }
- var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK));
- var bitmap = this.bitmap;
- return (bitmap & bit) === 0 ? notSetValue :
- this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue);
- };
-
- BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- if (keyHash === undefined) {
- keyHash = hash(key);
- }
- var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
- var bit = 1 << keyHashFrag;
- var bitmap = this.bitmap;
- var exists = (bitmap & bit) !== 0;
-
- if (!exists && value === NOT_SET) {
- return this;
- }
-
- var idx = popCount(bitmap & (bit - 1));
- var nodes = this.nodes;
- var node = exists ? nodes[idx] : undefined;
- var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
-
- if (newNode === node) {
- return this;
- }
-
- if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
- return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
- }
-
- if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) {
- return nodes[idx ^ 1];
- }
-
- if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
- return newNode;
- }
-
- var isEditable = ownerID && ownerID === this.ownerID;
- var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit;
- var newNodes = exists ? newNode ?
- setIn(nodes, idx, newNode, isEditable) :
- spliceOut(nodes, idx, isEditable) :
- spliceIn(nodes, idx, newNode, isEditable);
-
- if (isEditable) {
- this.bitmap = newBitmap;
- this.nodes = newNodes;
- return this;
- }
-
- return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
- };
-
-
-
-
- function HashArrayMapNode(ownerID, count, nodes) {
- this.ownerID = ownerID;
- this.count = count;
- this.nodes = nodes;
- }
-
- HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
- if (keyHash === undefined) {
- keyHash = hash(key);
- }
- var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
- var node = this.nodes[idx];
- return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue;
- };
-
- HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- if (keyHash === undefined) {
- keyHash = hash(key);
- }
- var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
- var removed = value === NOT_SET;
- var nodes = this.nodes;
- var node = nodes[idx];
-
- if (removed && !node) {
- return this;
- }
-
- var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
- if (newNode === node) {
- return this;
- }
-
- var newCount = this.count;
- if (!node) {
- newCount++;
- } else if (!newNode) {
- newCount--;
- if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
- return packNodes(ownerID, nodes, newCount, idx);
- }
- }
-
- var isEditable = ownerID && ownerID === this.ownerID;
- var newNodes = setIn(nodes, idx, newNode, isEditable);
-
- if (isEditable) {
- this.count = newCount;
- this.nodes = newNodes;
- return this;
- }
-
- return new HashArrayMapNode(ownerID, newCount, newNodes);
- };
-
-
-
-
- function HashCollisionNode(ownerID, keyHash, entries) {
- this.ownerID = ownerID;
- this.keyHash = keyHash;
- this.entries = entries;
- }
-
- HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) {
- var entries = this.entries;
- for (var ii = 0, len = entries.length; ii < len; ii++) {
- if (is(key, entries[ii][0])) {
- return entries[ii][1];
- }
- }
- return notSetValue;
- };
-
- HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- if (keyHash === undefined) {
- keyHash = hash(key);
- }
-
- var removed = value === NOT_SET;
-
- if (keyHash !== this.keyHash) {
- if (removed) {
- return this;
- }
- SetRef(didAlter);
- SetRef(didChangeSize);
- return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
- }
-
- var entries = this.entries;
- var idx = 0;
- for (var len = entries.length; idx < len; idx++) {
- if (is(key, entries[idx][0])) {
- break;
- }
- }
- var exists = idx < len;
-
- if (exists ? entries[idx][1] === value : removed) {
- return this;
- }
-
- SetRef(didAlter);
- (removed || !exists) && SetRef(didChangeSize);
-
- if (removed && len === 2) {
- return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
- }
-
- var isEditable = ownerID && ownerID === this.ownerID;
- var newEntries = isEditable ? entries : arrCopy(entries);
-
- if (exists) {
- if (removed) {
- idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
- } else {
- newEntries[idx] = [key, value];
- }
- } else {
- newEntries.push([key, value]);
- }
-
- if (isEditable) {
- this.entries = newEntries;
- return this;
- }
-
- return new HashCollisionNode(ownerID, this.keyHash, newEntries);
- };
-
-
-
-
- function ValueNode(ownerID, keyHash, entry) {
- this.ownerID = ownerID;
- this.keyHash = keyHash;
- this.entry = entry;
- }
-
- ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
- return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
- };
-
- ValueNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- var removed = value === NOT_SET;
- var keyMatch = is(key, this.entry[0]);
- if (keyMatch ? value === this.entry[1] : removed) {
- return this;
- }
-
- SetRef(didAlter);
-
- if (removed) {
- SetRef(didChangeSize);
- return; // undefined
- }
-
- if (keyMatch) {
- if (ownerID && ownerID === this.ownerID) {
- this.entry[1] = value;
- return this;
- }
- return new ValueNode(ownerID, this.keyHash, [key, value]);
- }
-
- SetRef(didChangeSize);
- return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
- };
-
-
-
- // #pragma Iterators
-
- ArrayMapNode.prototype.iterate =
- HashCollisionNode.prototype.iterate = function (fn, reverse) {
- var entries = this.entries;
- for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
- if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
- return false;
- }
- }
- };
-
- BitmapIndexedNode.prototype.iterate =
- HashArrayMapNode.prototype.iterate = function (fn, reverse) {
- var nodes = this.nodes;
- for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
- var node = nodes[reverse ? maxIndex - ii : ii];
- if (node && node.iterate(fn, reverse) === false) {
- return false;
- }
- }
- };
-
- ValueNode.prototype.iterate = function (fn, reverse) {
- return fn(this.entry);
- };
-
- createClass(MapIterator, Iterator);
-
- function MapIterator(map, type, reverse) {
- this._type = type;
- this._reverse = reverse;
- this._stack = map._root && mapIteratorFrame(map._root);
- }
-
- MapIterator.prototype.next = function() {
- var type = this._type;
- var stack = this._stack;
- while (stack) {
- var node = stack.node;
- var index = stack.index++;
- var maxIndex;
- if (node.entry) {
- if (index === 0) {
- return mapIteratorValue(type, node.entry);
- }
- } else if (node.entries) {
- maxIndex = node.entries.length - 1;
- if (index <= maxIndex) {
- return mapIteratorValue(type, node.entries[this._reverse ? maxIndex - index : index]);
- }
- } else {
- maxIndex = node.nodes.length - 1;
- if (index <= maxIndex) {
- var subNode = node.nodes[this._reverse ? maxIndex - index : index];
- if (subNode) {
- if (subNode.entry) {
- return mapIteratorValue(type, subNode.entry);
- }
- stack = this._stack = mapIteratorFrame(subNode, stack);
- }
- continue;
- }
- }
- stack = this._stack = this._stack.__prev;
- }
- return iteratorDone();
- };
-
-
- function mapIteratorValue(type, entry) {
- return iteratorValue(type, entry[0], entry[1]);
- }
-
- function mapIteratorFrame(node, prev) {
- return {
- node: node,
- index: 0,
- __prev: prev
- };
- }
-
- function makeMap(size, root, ownerID, hash) {
- var map = Object.create(MapPrototype);
- map.size = size;
- map._root = root;
- map.__ownerID = ownerID;
- map.__hash = hash;
- map.__altered = false;
- return map;
- }
-
- var EMPTY_MAP;
- function emptyMap() {
- return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
- }
-
- function updateMap(map, k, v) {
- var newRoot;
- var newSize;
- if (!map._root) {
- if (v === NOT_SET) {
- return map;
- }
- newSize = 1;
- newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
- } else {
- var didChangeSize = MakeRef(CHANGE_LENGTH);
- var didAlter = MakeRef(DID_ALTER);
- newRoot = updateNode(map._root, map.__ownerID, 0, undefined, k, v, didChangeSize, didAlter);
- if (!didAlter.value) {
- return map;
- }
- newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0);
- }
- if (map.__ownerID) {
- map.size = newSize;
- map._root = newRoot;
- map.__hash = undefined;
- map.__altered = true;
- return map;
- }
- return newRoot ? makeMap(newSize, newRoot) : emptyMap();
- }
-
- function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- if (!node) {
- if (value === NOT_SET) {
- return node;
- }
- SetRef(didAlter);
- SetRef(didChangeSize);
- return new ValueNode(ownerID, keyHash, [key, value]);
- }
- return node.update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter);
- }
-
- function isLeafNode(node) {
- return node.constructor === ValueNode || node.constructor === HashCollisionNode;
- }
-
- function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
- if (node.keyHash === keyHash) {
- return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
- }
-
- var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
- var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
-
- var newNode;
- var nodes = idx1 === idx2 ?
- [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] :
- ((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 ? [node, newNode] : [newNode, node]);
-
- return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
- }
-
- function createNodes(ownerID, entries, key, value) {
- if (!ownerID) {
- ownerID = new OwnerID();
- }
- var node = new ValueNode(ownerID, hash(key), [key, value]);
- for (var ii = 0; ii < entries.length; ii++) {
- var entry = entries[ii];
- node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
- }
- return node;
- }
-
- function packNodes(ownerID, nodes, count, excluding) {
- var bitmap = 0;
- var packedII = 0;
- var packedNodes = new Array(count);
- for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
- var node = nodes[ii];
- if (node !== undefined && ii !== excluding) {
- bitmap |= bit;
- packedNodes[packedII++] = node;
- }
- }
- return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
- }
-
- function expandNodes(ownerID, nodes, bitmap, including, node) {
- var count = 0;
- var expandedNodes = new Array(SIZE);
- for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
- expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
- }
- expandedNodes[including] = node;
- return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
- }
-
- function mergeIntoMapWith(map, merger, iterables) {
- var iters = [];
- for (var ii = 0; ii < iterables.length; ii++) {
- var value = iterables[ii];
- var iter = KeyedIterable(value);
- if (!isIterable(value)) {
- iter = iter.map(function(v ) {return fromJS(v)});
- }
- iters.push(iter);
- }
- return mergeIntoCollectionWith(map, merger, iters);
- }
-
- function deepMerger(existing, value, key) {
- return existing && existing.mergeDeep && isIterable(value) ?
- existing.mergeDeep(value) :
- is(existing, value) ? existing : value;
- }
-
- function deepMergerWith(merger) {
- return function(existing, value, key) {
- if (existing && existing.mergeDeepWith && isIterable(value)) {
- return existing.mergeDeepWith(merger, value);
- }
- var nextValue = merger(existing, value, key);
- return is(existing, nextValue) ? existing : nextValue;
- };
- }
-
- function mergeIntoCollectionWith(collection, merger, iters) {
- iters = iters.filter(function(x ) {return x.size !== 0});
- if (iters.length === 0) {
- return collection;
- }
- if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
- return collection.constructor(iters[0]);
- }
- return collection.withMutations(function(collection ) {
- var mergeIntoMap = merger ?
- function(value, key) {
- collection.update(key, NOT_SET, function(existing )
- {return existing === NOT_SET ? value : merger(existing, value, key)}
- );
- } :
- function(value, key) {
- collection.set(key, value);
- };
- for (var ii = 0; ii < iters.length; ii++) {
- iters[ii].forEach(mergeIntoMap);
- }
- });
- }
-
- function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
- var isNotSet = existing === NOT_SET;
- var step = keyPathIter.next();
- if (step.done) {
- var existingValue = isNotSet ? notSetValue : existing;
- var newValue = updater(existingValue);
- return newValue === existingValue ? existing : newValue;
- }
- invariant(
- isNotSet || (existing && existing.set),
- 'invalid keyPath'
- );
- var key = step.value;
- var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
- var nextUpdated = updateInDeepMap(
- nextExisting,
- keyPathIter,
- notSetValue,
- updater
- );
- return nextUpdated === nextExisting ? existing :
- nextUpdated === NOT_SET ? existing.remove(key) :
- (isNotSet ? emptyMap() : existing).set(key, nextUpdated);
- }
-
- function popCount(x) {
- x = x - ((x >> 1) & 0x55555555);
- x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
- x = (x + (x >> 4)) & 0x0f0f0f0f;
- x = x + (x >> 8);
- x = x + (x >> 16);
- return x & 0x7f;
- }
-
- function setIn(array, idx, val, canEdit) {
- var newArray = canEdit ? array : arrCopy(array);
- newArray[idx] = val;
- return newArray;
- }
-
- function spliceIn(array, idx, val, canEdit) {
- var newLen = array.length + 1;
- if (canEdit && idx + 1 === newLen) {
- array[idx] = val;
- return array;
- }
- var newArray = new Array(newLen);
- var after = 0;
- for (var ii = 0; ii < newLen; ii++) {
- if (ii === idx) {
- newArray[ii] = val;
- after = -1;
- } else {
- newArray[ii] = array[ii + after];
- }
- }
- return newArray;
- }
-
- function spliceOut(array, idx, canEdit) {
- var newLen = array.length - 1;
- if (canEdit && idx === newLen) {
- array.pop();
- return array;
- }
- var newArray = new Array(newLen);
- var after = 0;
- for (var ii = 0; ii < newLen; ii++) {
- if (ii === idx) {
- after = 1;
- }
- newArray[ii] = array[ii + after];
- }
- return newArray;
- }
-
- var MAX_ARRAY_MAP_SIZE = SIZE / 4;
- var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
- var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
-
- createClass(List, IndexedCollection);
-
- // @pragma Construction
-
- function List(value) {
- var empty = emptyList();
- if (value === null || value === undefined) {
- return empty;
- }
- if (isList(value)) {
- return value;
- }
- var iter = IndexedIterable(value);
- var size = iter.size;
- if (size === 0) {
- return empty;
- }
- assertNotInfinite(size);
- if (size > 0 && size < SIZE) {
- return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
- }
- return empty.withMutations(function(list ) {
- list.setSize(size);
- iter.forEach(function(v, i) {return list.set(i, v)});
- });
- }
-
- List.of = function(/*...values*/) {
- return this(arguments);
- };
-
- List.prototype.toString = function() {
- return this.__toString('List [', ']');
- };
-
- // @pragma Access
-
- List.prototype.get = function(index, notSetValue) {
- index = wrapIndex(this, index);
- if (index >= 0 && index < this.size) {
- index += this._origin;
- var node = listNodeFor(this, index);
- return node && node.array[index & MASK];
- }
- return notSetValue;
- };
-
- // @pragma Modification
-
- List.prototype.set = function(index, value) {
- return updateList(this, index, value);
- };
-
- List.prototype.remove = function(index) {
- return !this.has(index) ? this :
- index === 0 ? this.shift() :
- index === this.size - 1 ? this.pop() :
- this.splice(index, 1);
- };
-
- List.prototype.insert = function(index, value) {
- return this.splice(index, 0, value);
- };
-
- List.prototype.clear = function() {
- if (this.size === 0) {
- return this;
- }
- if (this.__ownerID) {
- this.size = this._origin = this._capacity = 0;
- this._level = SHIFT;
- this._root = this._tail = null;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return emptyList();
- };
-
- List.prototype.push = function(/*...values*/) {
- var values = arguments;
- var oldSize = this.size;
- return this.withMutations(function(list ) {
- setListBounds(list, 0, oldSize + values.length);
- for (var ii = 0; ii < values.length; ii++) {
- list.set(oldSize + ii, values[ii]);
- }
- });
- };
-
- List.prototype.pop = function() {
- return setListBounds(this, 0, -1);
- };
-
- List.prototype.unshift = function(/*...values*/) {
- var values = arguments;
- return this.withMutations(function(list ) {
- setListBounds(list, -values.length);
- for (var ii = 0; ii < values.length; ii++) {
- list.set(ii, values[ii]);
- }
- });
- };
-
- List.prototype.shift = function() {
- return setListBounds(this, 1);
- };
-
- // @pragma Composition
-
- List.prototype.merge = function(/*...iters*/) {
- return mergeIntoListWith(this, undefined, arguments);
- };
-
- List.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
- return mergeIntoListWith(this, merger, iters);
- };
-
- List.prototype.mergeDeep = function(/*...iters*/) {
- return mergeIntoListWith(this, deepMerger, arguments);
- };
-
- List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
- return mergeIntoListWith(this, deepMergerWith(merger), iters);
- };
-
- List.prototype.setSize = function(size) {
- return setListBounds(this, 0, size);
- };
-
- // @pragma Iteration
-
- List.prototype.slice = function(begin, end) {
- var size = this.size;
- if (wholeSlice(begin, end, size)) {
- return this;
- }
- return setListBounds(
- this,
- resolveBegin(begin, size),
- resolveEnd(end, size)
- );
- };
-
- List.prototype.__iterator = function(type, reverse) {
- var index = 0;
- var values = iterateList(this, reverse);
- return new Iterator(function() {
- var value = values();
- return value === DONE ?
- iteratorDone() :
- iteratorValue(type, index++, value);
- });
- };
-
- List.prototype.__iterate = function(fn, reverse) {
- var index = 0;
- var values = iterateList(this, reverse);
- var value;
- while ((value = values()) !== DONE) {
- if (fn(value, index++, this) === false) {
- break;
- }
- }
- return index;
- };
-
- List.prototype.__ensureOwner = function(ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- if (!ownerID) {
- this.__ownerID = ownerID;
- return this;
- }
- return makeList(this._origin, this._capacity, this._level, this._root, this._tail, ownerID, this.__hash);
- };
-
-
- function isList(maybeList) {
- return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
- }
-
- List.isList = isList;
-
- var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
-
- var ListPrototype = List.prototype;
- ListPrototype[IS_LIST_SENTINEL] = true;
- ListPrototype[DELETE] = ListPrototype.remove;
- ListPrototype.setIn = MapPrototype.setIn;
- ListPrototype.deleteIn =
- ListPrototype.removeIn = MapPrototype.removeIn;
- ListPrototype.update = MapPrototype.update;
- ListPrototype.updateIn = MapPrototype.updateIn;
- ListPrototype.mergeIn = MapPrototype.mergeIn;
- ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
- ListPrototype.withMutations = MapPrototype.withMutations;
- ListPrototype.asMutable = MapPrototype.asMutable;
- ListPrototype.asImmutable = MapPrototype.asImmutable;
- ListPrototype.wasAltered = MapPrototype.wasAltered;
-
-
-
- function VNode(array, ownerID) {
- this.array = array;
- this.ownerID = ownerID;
- }
-
- // TODO: seems like these methods are very similar
-
- VNode.prototype.removeBefore = function(ownerID, level, index) {
- if (index === level ? 1 << level : this.array.length === 0) {
- return this;
- }
- var originIndex = (index >>> level) & MASK;
- if (originIndex >= this.array.length) {
- return new VNode([], ownerID);
- }
- var removingFirst = originIndex === 0;
- var newChild;
- if (level > 0) {
- var oldChild = this.array[originIndex];
- newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
- if (newChild === oldChild && removingFirst) {
- return this;
- }
- }
- if (removingFirst && !newChild) {
- return this;
- }
- var editable = editableVNode(this, ownerID);
- if (!removingFirst) {
- for (var ii = 0; ii < originIndex; ii++) {
- editable.array[ii] = undefined;
- }
- }
- if (newChild) {
- editable.array[originIndex] = newChild;
- }
- return editable;
- };
-
- VNode.prototype.removeAfter = function(ownerID, level, index) {
- if (index === (level ? 1 << level : 0) || this.array.length === 0) {
- return this;
- }
- var sizeIndex = ((index - 1) >>> level) & MASK;
- if (sizeIndex >= this.array.length) {
- return this;
- }
-
- var newChild;
- if (level > 0) {
- var oldChild = this.array[sizeIndex];
- newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
- if (newChild === oldChild && sizeIndex === this.array.length - 1) {
- return this;
- }
- }
-
- var editable = editableVNode(this, ownerID);
- editable.array.splice(sizeIndex + 1);
- if (newChild) {
- editable.array[sizeIndex] = newChild;
- }
- return editable;
- };
-
-
-
- var DONE = {};
-
- function iterateList(list, reverse) {
- var left = list._origin;
- var right = list._capacity;
- var tailPos = getTailOffset(right);
- var tail = list._tail;
-
- return iterateNodeOrLeaf(list._root, list._level, 0);
-
- function iterateNodeOrLeaf(node, level, offset) {
- return level === 0 ?
- iterateLeaf(node, offset) :
- iterateNode(node, level, offset);
- }
-
- function iterateLeaf(node, offset) {
- var array = offset === tailPos ? tail && tail.array : node && node.array;
- var from = offset > left ? 0 : left - offset;
- var to = right - offset;
- if (to > SIZE) {
- to = SIZE;
- }
- return function() {
- if (from === to) {
- return DONE;
- }
- var idx = reverse ? --to : from++;
- return array && array[idx];
- };
- }
-
- function iterateNode(node, level, offset) {
- var values;
- var array = node && node.array;
- var from = offset > left ? 0 : (left - offset) >> level;
- var to = ((right - offset) >> level) + 1;
- if (to > SIZE) {
- to = SIZE;
- }
- return function() {
- do {
- if (values) {
- var value = values();
- if (value !== DONE) {
- return value;
- }
- values = null;
- }
- if (from === to) {
- return DONE;
- }
- var idx = reverse ? --to : from++;
- values = iterateNodeOrLeaf(
- array && array[idx], level - SHIFT, offset + (idx << level)
- );
- } while (true);
- };
- }
- }
-
- function makeList(origin, capacity, level, root, tail, ownerID, hash) {
- var list = Object.create(ListPrototype);
- list.size = capacity - origin;
- list._origin = origin;
- list._capacity = capacity;
- list._level = level;
- list._root = root;
- list._tail = tail;
- list.__ownerID = ownerID;
- list.__hash = hash;
- list.__altered = false;
- return list;
- }
-
- var EMPTY_LIST;
- function emptyList() {
- return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
- }
-
- function updateList(list, index, value) {
- index = wrapIndex(list, index);
-
- if (index !== index) {
- return list;
- }
-
- if (index >= list.size || index < 0) {
- return list.withMutations(function(list ) {
- index < 0 ?
- setListBounds(list, index).set(0, value) :
- setListBounds(list, 0, index + 1).set(index, value);
- });
- }
-
- index += list._origin;
-
- var newTail = list._tail;
- var newRoot = list._root;
- var didAlter = MakeRef(DID_ALTER);
- if (index >= getTailOffset(list._capacity)) {
- newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
- } else {
- newRoot = updateVNode(newRoot, list.__ownerID, list._level, index, value, didAlter);
- }
-
- if (!didAlter.value) {
- return list;
- }
-
- if (list.__ownerID) {
- list._root = newRoot;
- list._tail = newTail;
- list.__hash = undefined;
- list.__altered = true;
- return list;
- }
- return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
- }
-
- function updateVNode(node, ownerID, level, index, value, didAlter) {
- var idx = (index >>> level) & MASK;
- var nodeHas = node && idx < node.array.length;
- if (!nodeHas && value === undefined) {
- return node;
- }
-
- var newNode;
-
- if (level > 0) {
- var lowerNode = node && node.array[idx];
- var newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter);
- if (newLowerNode === lowerNode) {
- return node;
- }
- newNode = editableVNode(node, ownerID);
- newNode.array[idx] = newLowerNode;
- return newNode;
- }
-
- if (nodeHas && node.array[idx] === value) {
- return node;
- }
-
- SetRef(didAlter);
-
- newNode = editableVNode(node, ownerID);
- if (value === undefined && idx === newNode.array.length - 1) {
- newNode.array.pop();
- } else {
- newNode.array[idx] = value;
- }
- return newNode;
- }
-
- function editableVNode(node, ownerID) {
- if (ownerID && node && ownerID === node.ownerID) {
- return node;
- }
- return new VNode(node ? node.array.slice() : [], ownerID);
- }
-
- function listNodeFor(list, rawIndex) {
- if (rawIndex >= getTailOffset(list._capacity)) {
- return list._tail;
- }
- if (rawIndex < 1 << (list._level + SHIFT)) {
- var node = list._root;
- var level = list._level;
- while (node && level > 0) {
- node = node.array[(rawIndex >>> level) & MASK];
- level -= SHIFT;
- }
- return node;
- }
- }
-
- function setListBounds(list, begin, end) {
- // Sanitize begin & end using this shorthand for ToInt32(argument)
- // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
- if (begin !== undefined) {
- begin = begin | 0;
- }
- if (end !== undefined) {
- end = end | 0;
- }
- var owner = list.__ownerID || new OwnerID();
- var oldOrigin = list._origin;
- var oldCapacity = list._capacity;
- var newOrigin = oldOrigin + begin;
- var newCapacity = end === undefined ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end;
- if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
- return list;
- }
-
- // If it's going to end after it starts, it's empty.
- if (newOrigin >= newCapacity) {
- return list.clear();
- }
-
- var newLevel = list._level;
- var newRoot = list._root;
-
- // New origin might need creating a higher root.
- var offsetShift = 0;
- while (newOrigin + offsetShift < 0) {
- newRoot = new VNode(newRoot && newRoot.array.length ? [undefined, newRoot] : [], owner);
- newLevel += SHIFT;
- offsetShift += 1 << newLevel;
- }
- if (offsetShift) {
- newOrigin += offsetShift;
- oldOrigin += offsetShift;
- newCapacity += offsetShift;
- oldCapacity += offsetShift;
- }
-
- var oldTailOffset = getTailOffset(oldCapacity);
- var newTailOffset = getTailOffset(newCapacity);
-
- // New size might need creating a higher root.
- while (newTailOffset >= 1 << (newLevel + SHIFT)) {
- newRoot = new VNode(newRoot && newRoot.array.length ? [newRoot] : [], owner);
- newLevel += SHIFT;
- }
-
- // Locate or create the new tail.
- var oldTail = list._tail;
- var newTail = newTailOffset < oldTailOffset ?
- listNodeFor(list, newCapacity - 1) :
- newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
-
- // Merge Tail into tree.
- if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) {
- newRoot = editableVNode(newRoot, owner);
- var node = newRoot;
- for (var level = newLevel; level > SHIFT; level -= SHIFT) {
- var idx = (oldTailOffset >>> level) & MASK;
- node = node.array[idx] = editableVNode(node.array[idx], owner);
- }
- node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
- }
-
- // If the size has been reduced, there's a chance the tail needs to be trimmed.
- if (newCapacity < oldCapacity) {
- newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
- }
-
- // If the new origin is within the tail, then we do not need a root.
- if (newOrigin >= newTailOffset) {
- newOrigin -= newTailOffset;
- newCapacity -= newTailOffset;
- newLevel = SHIFT;
- newRoot = null;
- newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
-
- // Otherwise, if the root has been trimmed, garbage collect.
- } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
- offsetShift = 0;
-
- // Identify the new top root node of the subtree of the old root.
- while (newRoot) {
- var beginIndex = (newOrigin >>> newLevel) & MASK;
- if (beginIndex !== (newTailOffset >>> newLevel) & MASK) {
- break;
- }
- if (beginIndex) {
- offsetShift += (1 << newLevel) * beginIndex;
- }
- newLevel -= SHIFT;
- newRoot = newRoot.array[beginIndex];
- }
-
- // Trim the new sides of the new root.
- if (newRoot && newOrigin > oldOrigin) {
- newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
- }
- if (newRoot && newTailOffset < oldTailOffset) {
- newRoot = newRoot.removeAfter(owner, newLevel, newTailOffset - offsetShift);
- }
- if (offsetShift) {
- newOrigin -= offsetShift;
- newCapacity -= offsetShift;
- }
- }
-
- if (list.__ownerID) {
- list.size = newCapacity - newOrigin;
- list._origin = newOrigin;
- list._capacity = newCapacity;
- list._level = newLevel;
- list._root = newRoot;
- list._tail = newTail;
- list.__hash = undefined;
- list.__altered = true;
- return list;
- }
- return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
- }
-
- function mergeIntoListWith(list, merger, iterables) {
- var iters = [];
- var maxSize = 0;
- for (var ii = 0; ii < iterables.length; ii++) {
- var value = iterables[ii];
- var iter = IndexedIterable(value);
- if (iter.size > maxSize) {
- maxSize = iter.size;
- }
- if (!isIterable(value)) {
- iter = iter.map(function(v ) {return fromJS(v)});
- }
- iters.push(iter);
- }
- if (maxSize > list.size) {
- list = list.setSize(maxSize);
- }
- return mergeIntoCollectionWith(list, merger, iters);
- }
-
- function getTailOffset(size) {
- return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT);
- }
-
- createClass(OrderedMap, Map);
-
- // @pragma Construction
-
- function OrderedMap(value) {
- return value === null || value === undefined ? emptyOrderedMap() :
- isOrderedMap(value) ? value :
- emptyOrderedMap().withMutations(function(map ) {
- var iter = KeyedIterable(value);
- assertNotInfinite(iter.size);
- iter.forEach(function(v, k) {return map.set(k, v)});
- });
- }
-
- OrderedMap.of = function(/*...values*/) {
- return this(arguments);
- };
-
- OrderedMap.prototype.toString = function() {
- return this.__toString('OrderedMap {', '}');
- };
-
- // @pragma Access
-
- OrderedMap.prototype.get = function(k, notSetValue) {
- var index = this._map.get(k);
- return index !== undefined ? this._list.get(index)[1] : notSetValue;
- };
-
- // @pragma Modification
-
- OrderedMap.prototype.clear = function() {
- if (this.size === 0) {
- return this;
- }
- if (this.__ownerID) {
- this.size = 0;
- this._map.clear();
- this._list.clear();
- return this;
- }
- return emptyOrderedMap();
- };
-
- OrderedMap.prototype.set = function(k, v) {
- return updateOrderedMap(this, k, v);
- };
-
- OrderedMap.prototype.remove = function(k) {
- return updateOrderedMap(this, k, NOT_SET);
- };
-
- OrderedMap.prototype.wasAltered = function() {
- return this._map.wasAltered() || this._list.wasAltered();
- };
-
- OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- return this._list.__iterate(
- function(entry ) {return entry && fn(entry[1], entry[0], this$0)},
- reverse
- );
- };
-
- OrderedMap.prototype.__iterator = function(type, reverse) {
- return this._list.fromEntrySeq().__iterator(type, reverse);
- };
-
- OrderedMap.prototype.__ensureOwner = function(ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- var newMap = this._map.__ensureOwner(ownerID);
- var newList = this._list.__ensureOwner(ownerID);
- if (!ownerID) {
- this.__ownerID = ownerID;
- this._map = newMap;
- this._list = newList;
- return this;
- }
- return makeOrderedMap(newMap, newList, ownerID, this.__hash);
- };
-
-
- function isOrderedMap(maybeOrderedMap) {
- return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
- }
-
- OrderedMap.isOrderedMap = isOrderedMap;
-
- OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
- OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
-
-
-
- function makeOrderedMap(map, list, ownerID, hash) {
- var omap = Object.create(OrderedMap.prototype);
- omap.size = map ? map.size : 0;
- omap._map = map;
- omap._list = list;
- omap.__ownerID = ownerID;
- omap.__hash = hash;
- return omap;
- }
-
- var EMPTY_ORDERED_MAP;
- function emptyOrderedMap() {
- return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()));
- }
-
- function updateOrderedMap(omap, k, v) {
- var map = omap._map;
- var list = omap._list;
- var i = map.get(k);
- var has = i !== undefined;
- var newMap;
- var newList;
- if (v === NOT_SET) { // removed
- if (!has) {
- return omap;
- }
- if (list.size >= SIZE && list.size >= map.size * 2) {
- newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx});
- newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap();
- if (omap.__ownerID) {
- newMap.__ownerID = newList.__ownerID = omap.__ownerID;
- }
- } else {
- newMap = map.remove(k);
- newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
- }
- } else {
- if (has) {
- if (v === list.get(i)[1]) {
- return omap;
- }
- newMap = map;
- newList = list.set(i, [k, v]);
- } else {
- newMap = map.set(k, list.size);
- newList = list.set(list.size, [k, v]);
- }
- }
- if (omap.__ownerID) {
- omap.size = newMap.size;
- omap._map = newMap;
- omap._list = newList;
- omap.__hash = undefined;
- return omap;
- }
- return makeOrderedMap(newMap, newList);
- }
-
- createClass(ToKeyedSequence, KeyedSeq);
- function ToKeyedSequence(indexed, useKeys) {
- this._iter = indexed;
- this._useKeys = useKeys;
- this.size = indexed.size;
- }
-
- ToKeyedSequence.prototype.get = function(key, notSetValue) {
- return this._iter.get(key, notSetValue);
- };
-
- ToKeyedSequence.prototype.has = function(key) {
- return this._iter.has(key);
- };
-
- ToKeyedSequence.prototype.valueSeq = function() {
- return this._iter.valueSeq();
- };
-
- ToKeyedSequence.prototype.reverse = function() {var this$0 = this;
- var reversedSequence = reverseFactory(this, true);
- if (!this._useKeys) {
- reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()};
- }
- return reversedSequence;
- };
-
- ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this;
- var mappedSequence = mapFactory(this, mapper, context);
- if (!this._useKeys) {
- mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)};
- }
- return mappedSequence;
- };
-
- ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- var ii;
- return this._iter.__iterate(
- this._useKeys ?
- function(v, k) {return fn(v, k, this$0)} :
- ((ii = reverse ? resolveSize(this) : 0),
- function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}),
- reverse
- );
- };
-
- ToKeyedSequence.prototype.__iterator = function(type, reverse) {
- if (this._useKeys) {
- return this._iter.__iterator(type, reverse);
- }
- var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
- var ii = reverse ? resolveSize(this) : 0;
- return new Iterator(function() {
- var step = iterator.next();
- return step.done ? step :
- iteratorValue(type, reverse ? --ii : ii++, step.value, step);
- });
- };
-
- ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
-
-
- createClass(ToIndexedSequence, IndexedSeq);
- function ToIndexedSequence(iter) {
- this._iter = iter;
- this.size = iter.size;
- }
-
- ToIndexedSequence.prototype.includes = function(value) {
- return this._iter.includes(value);
- };
-
- ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- var iterations = 0;
- return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse);
- };
-
- ToIndexedSequence.prototype.__iterator = function(type, reverse) {
- var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
- var iterations = 0;
- return new Iterator(function() {
- var step = iterator.next();
- return step.done ? step :
- iteratorValue(type, iterations++, step.value, step)
- });
- };
-
-
-
- createClass(ToSetSequence, SetSeq);
- function ToSetSequence(iter) {
- this._iter = iter;
- this.size = iter.size;
- }
-
- ToSetSequence.prototype.has = function(key) {
- return this._iter.includes(key);
- };
-
- ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse);
- };
-
- ToSetSequence.prototype.__iterator = function(type, reverse) {
- var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
- return new Iterator(function() {
- var step = iterator.next();
- return step.done ? step :
- iteratorValue(type, step.value, step.value, step);
- });
- };
-
-
-
- createClass(FromEntriesSequence, KeyedSeq);
- function FromEntriesSequence(entries) {
- this._iter = entries;
- this.size = entries.size;
- }
-
- FromEntriesSequence.prototype.entrySeq = function() {
- return this._iter.toSeq();
- };
-
- FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- return this._iter.__iterate(function(entry ) {
- // Check if entry exists first so array access doesn't throw for holes
- // in the parent iteration.
- if (entry) {
- validateEntry(entry);
- var indexedIterable = isIterable(entry);
- return fn(
- indexedIterable ? entry.get(1) : entry[1],
- indexedIterable ? entry.get(0) : entry[0],
- this$0
- );
- }
- }, reverse);
- };
-
- FromEntriesSequence.prototype.__iterator = function(type, reverse) {
- var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
- return new Iterator(function() {
- while (true) {
- var step = iterator.next();
- if (step.done) {
- return step;
- }
- var entry = step.value;
- // Check if entry exists first so array access doesn't throw for holes
- // in the parent iteration.
- if (entry) {
- validateEntry(entry);
- var indexedIterable = isIterable(entry);
- return iteratorValue(
- type,
- indexedIterable ? entry.get(0) : entry[0],
- indexedIterable ? entry.get(1) : entry[1],
- step
- );
- }
- }
- });
- };
-
-
- ToIndexedSequence.prototype.cacheResult =
- ToKeyedSequence.prototype.cacheResult =
- ToSetSequence.prototype.cacheResult =
- FromEntriesSequence.prototype.cacheResult =
- cacheResultThrough;
-
-
- function flipFactory(iterable) {
- var flipSequence = makeSequence(iterable);
- flipSequence._iter = iterable;
- flipSequence.size = iterable.size;
- flipSequence.flip = function() {return iterable};
- flipSequence.reverse = function () {
- var reversedSequence = iterable.reverse.apply(this); // super.reverse()
- reversedSequence.flip = function() {return iterable.reverse()};
- return reversedSequence;
- };
- flipSequence.has = function(key ) {return iterable.includes(key)};
- flipSequence.includes = function(key ) {return iterable.has(key)};
- flipSequence.cacheResult = cacheResultThrough;
- flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
- return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse);
- };
- flipSequence.__iteratorUncached = function(type, reverse) {
- if (type === ITERATE_ENTRIES) {
- var iterator = iterable.__iterator(type, reverse);
- return new Iterator(function() {
- var step = iterator.next();
- if (!step.done) {
- var k = step.value[0];
- step.value[0] = step.value[1];
- step.value[1] = k;
- }
- return step;
- });
- }
- return iterable.__iterator(
- type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
- reverse
- );
- };
- return flipSequence;
- }
-
-
- function mapFactory(iterable, mapper, context) {
- var mappedSequence = makeSequence(iterable);
- mappedSequence.size = iterable.size;
- mappedSequence.has = function(key ) {return iterable.has(key)};
- mappedSequence.get = function(key, notSetValue) {
- var v = iterable.get(key, NOT_SET);
- return v === NOT_SET ?
- notSetValue :
- mapper.call(context, v, key, iterable);
- };
- mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
- return iterable.__iterate(
- function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false},
- reverse
- );
- };
- mappedSequence.__iteratorUncached = function (type, reverse) {
- var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
- return new Iterator(function() {
- var step = iterator.next();
- if (step.done) {
- return step;
- }
- var entry = step.value;
- var key = entry[0];
- return iteratorValue(
- type,
- key,
- mapper.call(context, entry[1], key, iterable),
- step
- );
- });
- };
- return mappedSequence;
- }
-
-
- function reverseFactory(iterable, useKeys) {
- var reversedSequence = makeSequence(iterable);
- reversedSequence._iter = iterable;
- reversedSequence.size = iterable.size;
- reversedSequence.reverse = function() {return iterable};
- if (iterable.flip) {
- reversedSequence.flip = function () {
- var flipSequence = flipFactory(iterable);
- flipSequence.reverse = function() {return iterable.flip()};
- return flipSequence;
- };
- }
- reversedSequence.get = function(key, notSetValue)
- {return iterable.get(useKeys ? key : -1 - key, notSetValue)};
- reversedSequence.has = function(key )
- {return iterable.has(useKeys ? key : -1 - key)};
- reversedSequence.includes = function(value ) {return iterable.includes(value)};
- reversedSequence.cacheResult = cacheResultThrough;
- reversedSequence.__iterate = function (fn, reverse) {var this$0 = this;
- return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse);
- };
- reversedSequence.__iterator =
- function(type, reverse) {return iterable.__iterator(type, !reverse)};
- return reversedSequence;
- }
-
-
- function filterFactory(iterable, predicate, context, useKeys) {
- var filterSequence = makeSequence(iterable);
- if (useKeys) {
- filterSequence.has = function(key ) {
- var v = iterable.get(key, NOT_SET);
- return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
- };
- filterSequence.get = function(key, notSetValue) {
- var v = iterable.get(key, NOT_SET);
- return v !== NOT_SET && predicate.call(context, v, key, iterable) ?
- v : notSetValue;
- };
- }
- filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
- var iterations = 0;
- iterable.__iterate(function(v, k, c) {
- if (predicate.call(context, v, k, c)) {
- iterations++;
- return fn(v, useKeys ? k : iterations - 1, this$0);
- }
- }, reverse);
- return iterations;
- };
- filterSequence.__iteratorUncached = function (type, reverse) {
- var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
- var iterations = 0;
- return new Iterator(function() {
- while (true) {
- var step = iterator.next();
- if (step.done) {
- return step;
- }
- var entry = step.value;
- var key = entry[0];
- var value = entry[1];
- if (predicate.call(context, value, key, iterable)) {
- return iteratorValue(type, useKeys ? key : iterations++, value, step);
- }
- }
- });
- };
- return filterSequence;
- }
-
-
- function countByFactory(iterable, grouper, context) {
- var groups = Map().asMutable();
- iterable.__iterate(function(v, k) {
- groups.update(
- grouper.call(context, v, k, iterable),
- 0,
- function(a ) {return a + 1}
- );
- });
- return groups.asImmutable();
- }
-
-
- function groupByFactory(iterable, grouper, context) {
- var isKeyedIter = isKeyed(iterable);
- var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
- iterable.__iterate(function(v, k) {
- groups.update(
- grouper.call(context, v, k, iterable),
- function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)}
- );
- });
- var coerce = iterableClass(iterable);
- return groups.map(function(arr ) {return reify(iterable, coerce(arr))});
- }
-
-
- function sliceFactory(iterable, begin, end, useKeys) {
- var originalSize = iterable.size;
-
- // Sanitize begin & end using this shorthand for ToInt32(argument)
- // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
- if (begin !== undefined) {
- begin = begin | 0;
- }
- if (end !== undefined) {
- end = end | 0;
- }
-
- if (wholeSlice(begin, end, originalSize)) {
- return iterable;
- }
-
- var resolvedBegin = resolveBegin(begin, originalSize);
- var resolvedEnd = resolveEnd(end, originalSize);
-
- // begin or end will be NaN if they were provided as negative numbers and
- // this iterable's size is unknown. In that case, cache first so there is
- // a known size and these do not resolve to NaN.
- if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
- return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys);
- }
-
- // Note: resolvedEnd is undefined when the original sequence's length is
- // unknown and this slice did not supply an end and should contain all
- // elements after resolvedBegin.
- // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
- var resolvedSize = resolvedEnd - resolvedBegin;
- var sliceSize;
- if (resolvedSize === resolvedSize) {
- sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
- }
-
- var sliceSeq = makeSequence(iterable);
-
- // If iterable.size is undefined, the size of the realized sliceSeq is
- // unknown at this point unless the number of items to slice is 0
- sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined;
-
- if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
- sliceSeq.get = function (index, notSetValue) {
- index = wrapIndex(this, index);
- return index >= 0 && index < sliceSize ?
- iterable.get(index + resolvedBegin, notSetValue) :
- notSetValue;
- };
- }
-
- sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this;
- if (sliceSize === 0) {
- return 0;
- }
- if (reverse) {
- return this.cacheResult().__iterate(fn, reverse);
- }
- var skipped = 0;
- var isSkipping = true;
- var iterations = 0;
- iterable.__iterate(function(v, k) {
- if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
- iterations++;
- return fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
- iterations !== sliceSize;
- }
- });
- return iterations;
- };
-
- sliceSeq.__iteratorUncached = function(type, reverse) {
- if (sliceSize !== 0 && reverse) {
- return this.cacheResult().__iterator(type, reverse);
- }
- // Don't bother instantiating parent iterator if taking 0.
- var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
- var skipped = 0;
- var iterations = 0;
- return new Iterator(function() {
- while (skipped++ < resolvedBegin) {
- iterator.next();
- }
- if (++iterations > sliceSize) {
- return iteratorDone();
- }
- var step = iterator.next();
- if (useKeys || type === ITERATE_VALUES) {
- return step;
- } else if (type === ITERATE_KEYS) {
- return iteratorValue(type, iterations - 1, undefined, step);
- } else {
- return iteratorValue(type, iterations - 1, step.value[1], step);
- }
- });
- };
-
- return sliceSeq;
- }
-
-
- function takeWhileFactory(iterable, predicate, context) {
- var takeSequence = makeSequence(iterable);
- takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
- if (reverse) {
- return this.cacheResult().__iterate(fn, reverse);
- }
- var iterations = 0;
- iterable.__iterate(function(v, k, c)
- {return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)}
- );
- return iterations;
- };
- takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
- if (reverse) {
- return this.cacheResult().__iterator(type, reverse);
- }
- var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
- var iterating = true;
- return new Iterator(function() {
- if (!iterating) {
- return iteratorDone();
- }
- var step = iterator.next();
- if (step.done) {
- return step;
- }
- var entry = step.value;
- var k = entry[0];
- var v = entry[1];
- if (!predicate.call(context, v, k, this$0)) {
- iterating = false;
- return iteratorDone();
- }
- return type === ITERATE_ENTRIES ? step :
- iteratorValue(type, k, v, step);
- });
- };
- return takeSequence;
- }
-
-
- function skipWhileFactory(iterable, predicate, context, useKeys) {
- var skipSequence = makeSequence(iterable);
- skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
- if (reverse) {
- return this.cacheResult().__iterate(fn, reverse);
- }
- var isSkipping = true;
- var iterations = 0;
- iterable.__iterate(function(v, k, c) {
- if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
- iterations++;
- return fn(v, useKeys ? k : iterations - 1, this$0);
- }
- });
- return iterations;
- };
- skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
- if (reverse) {
- return this.cacheResult().__iterator(type, reverse);
- }
- var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
- var skipping = true;
- var iterations = 0;
- return new Iterator(function() {
- var step, k, v;
- do {
- step = iterator.next();
- if (step.done) {
- if (useKeys || type === ITERATE_VALUES) {
- return step;
- } else if (type === ITERATE_KEYS) {
- return iteratorValue(type, iterations++, undefined, step);
- } else {
- return iteratorValue(type, iterations++, step.value[1], step);
- }
- }
- var entry = step.value;
- k = entry[0];
- v = entry[1];
- skipping && (skipping = predicate.call(context, v, k, this$0));
- } while (skipping);
- return type === ITERATE_ENTRIES ? step :
- iteratorValue(type, k, v, step);
- });
- };
- return skipSequence;
- }
-
-
- function concatFactory(iterable, values) {
- var isKeyedIterable = isKeyed(iterable);
- var iters = [iterable].concat(values).map(function(v ) {
- if (!isIterable(v)) {
- v = isKeyedIterable ?
- keyedSeqFromValue(v) :
- indexedSeqFromValue(Array.isArray(v) ? v : [v]);
- } else if (isKeyedIterable) {
- v = KeyedIterable(v);
- }
- return v;
- }).filter(function(v ) {return v.size !== 0});
-
- if (iters.length === 0) {
- return iterable;
- }
-
- if (iters.length === 1) {
- var singleton = iters[0];
- if (singleton === iterable ||
- isKeyedIterable && isKeyed(singleton) ||
- isIndexed(iterable) && isIndexed(singleton)) {
- return singleton;
- }
- }
-
- var concatSeq = new ArraySeq(iters);
- if (isKeyedIterable) {
- concatSeq = concatSeq.toKeyedSeq();
- } else if (!isIndexed(iterable)) {
- concatSeq = concatSeq.toSetSeq();
- }
- concatSeq = concatSeq.flatten(true);
- concatSeq.size = iters.reduce(
- function(sum, seq) {
- if (sum !== undefined) {
- var size = seq.size;
- if (size !== undefined) {
- return sum + size;
- }
- }
- },
- 0
- );
- return concatSeq;
- }
-
-
- function flattenFactory(iterable, depth, useKeys) {
- var flatSequence = makeSequence(iterable);
- flatSequence.__iterateUncached = function(fn, reverse) {
- var iterations = 0;
- var stopped = false;
- function flatDeep(iter, currentDepth) {var this$0 = this;
- iter.__iterate(function(v, k) {
- if ((!depth || currentDepth < depth) && isIterable(v)) {
- flatDeep(v, currentDepth + 1);
- } else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
- stopped = true;
- }
- return !stopped;
- }, reverse);
- }
- flatDeep(iterable, 0);
- return iterations;
- };
- flatSequence.__iteratorUncached = function(type, reverse) {
- var iterator = iterable.__iterator(type, reverse);
- var stack = [];
- var iterations = 0;
- return new Iterator(function() {
- while (iterator) {
- var step = iterator.next();
- if (step.done !== false) {
- iterator = stack.pop();
- continue;
- }
- var v = step.value;
- if (type === ITERATE_ENTRIES) {
- v = v[1];
- }
- if ((!depth || stack.length < depth) && isIterable(v)) {
- stack.push(iterator);
- iterator = v.__iterator(type, reverse);
- } else {
- return useKeys ? step : iteratorValue(type, iterations++, v, step);
- }
- }
- return iteratorDone();
- });
- };
- return flatSequence;
- }
-
-
- function flatMapFactory(iterable, mapper, context) {
- var coerce = iterableClass(iterable);
- return iterable.toSeq().map(
- function(v, k) {return coerce(mapper.call(context, v, k, iterable))}
- ).flatten(true);
- }
-
-
- function interposeFactory(iterable, separator) {
- var interposedSequence = makeSequence(iterable);
- interposedSequence.size = iterable.size && iterable.size * 2 -1;
- interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
- var iterations = 0;
- iterable.__iterate(function(v, k)
- {return (!iterations || fn(separator, iterations++, this$0) !== false) &&
- fn(v, iterations++, this$0) !== false},
- reverse
- );
- return iterations;
- };
- interposedSequence.__iteratorUncached = function(type, reverse) {
- var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
- var iterations = 0;
- var step;
- return new Iterator(function() {
- if (!step || iterations % 2) {
- step = iterator.next();
- if (step.done) {
- return step;
- }
- }
- return iterations % 2 ?
- iteratorValue(type, iterations++, separator) :
- iteratorValue(type, iterations++, step.value, step);
- });
- };
- return interposedSequence;
- }
-
-
- function sortFactory(iterable, comparator, mapper) {
- if (!comparator) {
- comparator = defaultComparator;
- }
- var isKeyedIterable = isKeyed(iterable);
- var index = 0;
- var entries = iterable.toSeq().map(
- function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]}
- ).toArray();
- entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach(
- isKeyedIterable ?
- function(v, i) { entries[i].length = 2; } :
- function(v, i) { entries[i] = v[1]; }
- );
- return isKeyedIterable ? KeyedSeq(entries) :
- isIndexed(iterable) ? IndexedSeq(entries) :
- SetSeq(entries);
- }
-
-
- function maxFactory(iterable, comparator, mapper) {
- if (!comparator) {
- comparator = defaultComparator;
- }
- if (mapper) {
- var entry = iterable.toSeq()
- .map(function(v, k) {return [v, mapper(v, k, iterable)]})
- .reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a});
- return entry && entry[0];
- } else {
- return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a});
- }
- }
-
- function maxCompare(comparator, a, b) {
- var comp = comparator(b, a);
- // b is considered the new max if the comparator declares them equal, but
- // they are not equal and b is in fact a nullish value.
- return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0;
- }
-
-
- function zipWithFactory(keyIter, zipper, iters) {
- var zipSequence = makeSequence(keyIter);
- zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min();
- // Note: this a generic base implementation of __iterate in terms of
- // __iterator which may be more generically useful in the future.
- zipSequence.__iterate = function(fn, reverse) {
- /* generic:
- var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
- var step;
- var iterations = 0;
- while (!(step = iterator.next()).done) {
- iterations++;
- if (fn(step.value[1], step.value[0], this) === false) {
- break;
- }
- }
- return iterations;
- */
- // indexed:
- var iterator = this.__iterator(ITERATE_VALUES, reverse);
- var step;
- var iterations = 0;
- while (!(step = iterator.next()).done) {
- if (fn(step.value, iterations++, this) === false) {
- break;
- }
- }
- return iterations;
- };
- zipSequence.__iteratorUncached = function(type, reverse) {
- var iterators = iters.map(function(i )
- {return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))}
- );
- var iterations = 0;
- var isDone = false;
- return new Iterator(function() {
- var steps;
- if (!isDone) {
- steps = iterators.map(function(i ) {return i.next()});
- isDone = steps.some(function(s ) {return s.done});
- }
- if (isDone) {
- return iteratorDone();
- }
- return iteratorValue(
- type,
- iterations++,
- zipper.apply(null, steps.map(function(s ) {return s.value}))
- );
- });
- };
- return zipSequence
- }
-
-
- // #pragma Helper Functions
-
- function reify(iter, seq) {
- return isSeq(iter) ? seq : iter.constructor(seq);
- }
-
- function validateEntry(entry) {
- if (entry !== Object(entry)) {
- throw new TypeError('Expected [K, V] tuple: ' + entry);
- }
- }
-
- function resolveSize(iter) {
- assertNotInfinite(iter.size);
- return ensureSize(iter);
- }
-
- function iterableClass(iterable) {
- return isKeyed(iterable) ? KeyedIterable :
- isIndexed(iterable) ? IndexedIterable :
- SetIterable;
- }
-
- function makeSequence(iterable) {
- return Object.create(
- (
- isKeyed(iterable) ? KeyedSeq :
- isIndexed(iterable) ? IndexedSeq :
- SetSeq
- ).prototype
- );
- }
-
- function cacheResultThrough() {
- if (this._iter.cacheResult) {
- this._iter.cacheResult();
- this.size = this._iter.size;
- return this;
- } else {
- return Seq.prototype.cacheResult.call(this);
- }
- }
-
- function defaultComparator(a, b) {
- return a > b ? 1 : a < b ? -1 : 0;
- }
-
- function forceIterator(keyPath) {
- var iter = getIterator(keyPath);
- if (!iter) {
- // Array might not be iterable in this environment, so we need a fallback
- // to our wrapped type.
- if (!isArrayLike(keyPath)) {
- throw new TypeError('Expected iterable or array-like: ' + keyPath);
- }
- iter = getIterator(Iterable(keyPath));
- }
- return iter;
- }
-
- createClass(Record, KeyedCollection);
-
- function Record(defaultValues, name) {
- var hasInitialized;
-
- var RecordType = function Record(values) {
- if (values instanceof RecordType) {
- return values;
- }
- if (!(this instanceof RecordType)) {
- return new RecordType(values);
- }
- if (!hasInitialized) {
- hasInitialized = true;
- var keys = Object.keys(defaultValues);
- setProps(RecordTypePrototype, keys);
- RecordTypePrototype.size = keys.length;
- RecordTypePrototype._name = name;
- RecordTypePrototype._keys = keys;
- RecordTypePrototype._defaultValues = defaultValues;
- }
- this._map = Map(values);
- };
-
- var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype);
- RecordTypePrototype.constructor = RecordType;
-
- return RecordType;
- }
-
- Record.prototype.toString = function() {
- return this.__toString(recordName(this) + ' {', '}');
- };
-
- // @pragma Access
-
- Record.prototype.has = function(k) {
- return this._defaultValues.hasOwnProperty(k);
- };
-
- Record.prototype.get = function(k, notSetValue) {
- if (!this.has(k)) {
- return notSetValue;
- }
- var defaultVal = this._defaultValues[k];
- return this._map ? this._map.get(k, defaultVal) : defaultVal;
- };
-
- // @pragma Modification
-
- Record.prototype.clear = function() {
- if (this.__ownerID) {
- this._map && this._map.clear();
- return this;
- }
- var RecordType = this.constructor;
- return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()));
- };
-
- Record.prototype.set = function(k, v) {
- if (!this.has(k)) {
- throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this));
- }
- var newMap = this._map && this._map.set(k, v);
- if (this.__ownerID || newMap === this._map) {
- return this;
- }
- return makeRecord(this, newMap);
- };
-
- Record.prototype.remove = function(k) {
- if (!this.has(k)) {
- return this;
- }
- var newMap = this._map && this._map.remove(k);
- if (this.__ownerID || newMap === this._map) {
- return this;
- }
- return makeRecord(this, newMap);
- };
-
- Record.prototype.wasAltered = function() {
- return this._map.wasAltered();
- };
-
- Record.prototype.__iterator = function(type, reverse) {var this$0 = this;
- return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse);
- };
-
- Record.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse);
- };
-
- Record.prototype.__ensureOwner = function(ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- var newMap = this._map && this._map.__ensureOwner(ownerID);
- if (!ownerID) {
- this.__ownerID = ownerID;
- this._map = newMap;
- return this;
- }
- return makeRecord(this, newMap, ownerID);
- };
-
-
- var RecordPrototype = Record.prototype;
- RecordPrototype[DELETE] = RecordPrototype.remove;
- RecordPrototype.deleteIn =
- RecordPrototype.removeIn = MapPrototype.removeIn;
- RecordPrototype.merge = MapPrototype.merge;
- RecordPrototype.mergeWith = MapPrototype.mergeWith;
- RecordPrototype.mergeIn = MapPrototype.mergeIn;
- RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
- RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
- RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
- RecordPrototype.setIn = MapPrototype.setIn;
- RecordPrototype.update = MapPrototype.update;
- RecordPrototype.updateIn = MapPrototype.updateIn;
- RecordPrototype.withMutations = MapPrototype.withMutations;
- RecordPrototype.asMutable = MapPrototype.asMutable;
- RecordPrototype.asImmutable = MapPrototype.asImmutable;
-
-
- function makeRecord(likeRecord, map, ownerID) {
- var record = Object.create(Object.getPrototypeOf(likeRecord));
- record._map = map;
- record.__ownerID = ownerID;
- return record;
- }
-
- function recordName(record) {
- return record._name || record.constructor.name || 'Record';
- }
-
- function setProps(prototype, names) {
- try {
- names.forEach(setProp.bind(undefined, prototype));
- } catch (error) {
- // Object.defineProperty failed. Probably IE8.
- }
- }
-
- function setProp(prototype, name) {
- Object.defineProperty(prototype, name, {
- get: function() {
- return this.get(name);
- },
- set: function(value) {
- invariant(this.__ownerID, 'Cannot set on an immutable record.');
- this.set(name, value);
- }
- });
- }
-
- createClass(Set, SetCollection);
-
- // @pragma Construction
-
- function Set(value) {
- return value === null || value === undefined ? emptySet() :
- isSet(value) && !isOrdered(value) ? value :
- emptySet().withMutations(function(set ) {
- var iter = SetIterable(value);
- assertNotInfinite(iter.size);
- iter.forEach(function(v ) {return set.add(v)});
- });
- }
-
- Set.of = function(/*...values*/) {
- return this(arguments);
- };
-
- Set.fromKeys = function(value) {
- return this(KeyedIterable(value).keySeq());
- };
-
- Set.prototype.toString = function() {
- return this.__toString('Set {', '}');
- };
-
- // @pragma Access
-
- Set.prototype.has = function(value) {
- return this._map.has(value);
- };
-
- // @pragma Modification
-
- Set.prototype.add = function(value) {
- return updateSet(this, this._map.set(value, true));
- };
-
- Set.prototype.remove = function(value) {
- return updateSet(this, this._map.remove(value));
- };
-
- Set.prototype.clear = function() {
- return updateSet(this, this._map.clear());
- };
-
- // @pragma Composition
-
- Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0);
- iters = iters.filter(function(x ) {return x.size !== 0});
- if (iters.length === 0) {
- return this;
- }
- if (this.size === 0 && !this.__ownerID && iters.length === 1) {
- return this.constructor(iters[0]);
- }
- return this.withMutations(function(set ) {
- for (var ii = 0; ii < iters.length; ii++) {
- SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)});
- }
- });
- };
-
- Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0);
- if (iters.length === 0) {
- return this;
- }
- iters = iters.map(function(iter ) {return SetIterable(iter)});
- var originalSet = this;
- return this.withMutations(function(set ) {
- originalSet.forEach(function(value ) {
- if (!iters.every(function(iter ) {return iter.includes(value)})) {
- set.remove(value);
- }
- });
- });
- };
-
- Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0);
- if (iters.length === 0) {
- return this;
- }
- iters = iters.map(function(iter ) {return SetIterable(iter)});
- var originalSet = this;
- return this.withMutations(function(set ) {
- originalSet.forEach(function(value ) {
- if (iters.some(function(iter ) {return iter.includes(value)})) {
- set.remove(value);
- }
- });
- });
- };
-
- Set.prototype.merge = function() {
- return this.union.apply(this, arguments);
- };
-
- Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
- return this.union.apply(this, iters);
- };
-
- Set.prototype.sort = function(comparator) {
- // Late binding
- return OrderedSet(sortFactory(this, comparator));
- };
-
- Set.prototype.sortBy = function(mapper, comparator) {
- // Late binding
- return OrderedSet(sortFactory(this, comparator, mapper));
- };
-
- Set.prototype.wasAltered = function() {
- return this._map.wasAltered();
- };
-
- Set.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse);
- };
-
- Set.prototype.__iterator = function(type, reverse) {
- return this._map.map(function(_, k) {return k}).__iterator(type, reverse);
- };
-
- Set.prototype.__ensureOwner = function(ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- var newMap = this._map.__ensureOwner(ownerID);
- if (!ownerID) {
- this.__ownerID = ownerID;
- this._map = newMap;
- return this;
- }
- return this.__make(newMap, ownerID);
- };
-
-
- function isSet(maybeSet) {
- return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
- }
-
- Set.isSet = isSet;
-
- var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
-
- var SetPrototype = Set.prototype;
- SetPrototype[IS_SET_SENTINEL] = true;
- SetPrototype[DELETE] = SetPrototype.remove;
- SetPrototype.mergeDeep = SetPrototype.merge;
- SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
- SetPrototype.withMutations = MapPrototype.withMutations;
- SetPrototype.asMutable = MapPrototype.asMutable;
- SetPrototype.asImmutable = MapPrototype.asImmutable;
-
- SetPrototype.__empty = emptySet;
- SetPrototype.__make = makeSet;
-
- function updateSet(set, newMap) {
- if (set.__ownerID) {
- set.size = newMap.size;
- set._map = newMap;
- return set;
- }
- return newMap === set._map ? set :
- newMap.size === 0 ? set.__empty() :
- set.__make(newMap);
- }
-
- function makeSet(map, ownerID) {
- var set = Object.create(SetPrototype);
- set.size = map ? map.size : 0;
- set._map = map;
- set.__ownerID = ownerID;
- return set;
- }
-
- var EMPTY_SET;
- function emptySet() {
- return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
- }
-
- createClass(OrderedSet, Set);
-
- // @pragma Construction
-
- function OrderedSet(value) {
- return value === null || value === undefined ? emptyOrderedSet() :
- isOrderedSet(value) ? value :
- emptyOrderedSet().withMutations(function(set ) {
- var iter = SetIterable(value);
- assertNotInfinite(iter.size);
- iter.forEach(function(v ) {return set.add(v)});
- });
- }
-
- OrderedSet.of = function(/*...values*/) {
- return this(arguments);
- };
-
- OrderedSet.fromKeys = function(value) {
- return this(KeyedIterable(value).keySeq());
- };
-
- OrderedSet.prototype.toString = function() {
- return this.__toString('OrderedSet {', '}');
- };
-
-
- function isOrderedSet(maybeOrderedSet) {
- return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
- }
-
- OrderedSet.isOrderedSet = isOrderedSet;
-
- var OrderedSetPrototype = OrderedSet.prototype;
- OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
-
- OrderedSetPrototype.__empty = emptyOrderedSet;
- OrderedSetPrototype.__make = makeOrderedSet;
-
- function makeOrderedSet(map, ownerID) {
- var set = Object.create(OrderedSetPrototype);
- set.size = map ? map.size : 0;
- set._map = map;
- set.__ownerID = ownerID;
- return set;
- }
-
- var EMPTY_ORDERED_SET;
- function emptyOrderedSet() {
- return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()));
- }
-
- createClass(Stack, IndexedCollection);
-
- // @pragma Construction
-
- function Stack(value) {
- return value === null || value === undefined ? emptyStack() :
- isStack(value) ? value :
- emptyStack().unshiftAll(value);
- }
-
- Stack.of = function(/*...values*/) {
- return this(arguments);
- };
-
- Stack.prototype.toString = function() {
- return this.__toString('Stack [', ']');
- };
-
- // @pragma Access
-
- Stack.prototype.get = function(index, notSetValue) {
- var head = this._head;
- index = wrapIndex(this, index);
- while (head && index--) {
- head = head.next;
- }
- return head ? head.value : notSetValue;
- };
-
- Stack.prototype.peek = function() {
- return this._head && this._head.value;
- };
-
- // @pragma Modification
-
- Stack.prototype.push = function(/*...values*/) {
- if (arguments.length === 0) {
- return this;
- }
- var newSize = this.size + arguments.length;
- var head = this._head;
- for (var ii = arguments.length - 1; ii >= 0; ii--) {
- head = {
- value: arguments[ii],
- next: head
- };
- }
- if (this.__ownerID) {
- this.size = newSize;
- this._head = head;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return makeStack(newSize, head);
- };
-
- Stack.prototype.pushAll = function(iter) {
- iter = IndexedIterable(iter);
- if (iter.size === 0) {
- return this;
- }
- assertNotInfinite(iter.size);
- var newSize = this.size;
- var head = this._head;
- iter.reverse().forEach(function(value ) {
- newSize++;
- head = {
- value: value,
- next: head
- };
- });
- if (this.__ownerID) {
- this.size = newSize;
- this._head = head;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return makeStack(newSize, head);
- };
-
- Stack.prototype.pop = function() {
- return this.slice(1);
- };
-
- Stack.prototype.unshift = function(/*...values*/) {
- return this.push.apply(this, arguments);
- };
-
- Stack.prototype.unshiftAll = function(iter) {
- return this.pushAll(iter);
- };
-
- Stack.prototype.shift = function() {
- return this.pop.apply(this, arguments);
- };
-
- Stack.prototype.clear = function() {
- if (this.size === 0) {
- return this;
- }
- if (this.__ownerID) {
- this.size = 0;
- this._head = undefined;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return emptyStack();
- };
-
- Stack.prototype.slice = function(begin, end) {
- if (wholeSlice(begin, end, this.size)) {
- return this;
- }
- var resolvedBegin = resolveBegin(begin, this.size);
- var resolvedEnd = resolveEnd(end, this.size);
- if (resolvedEnd !== this.size) {
- // super.slice(begin, end);
- return IndexedCollection.prototype.slice.call(this, begin, end);
- }
- var newSize = this.size - resolvedBegin;
- var head = this._head;
- while (resolvedBegin--) {
- head = head.next;
- }
- if (this.__ownerID) {
- this.size = newSize;
- this._head = head;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return makeStack(newSize, head);
- };
-
- // @pragma Mutability
-
- Stack.prototype.__ensureOwner = function(ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- if (!ownerID) {
- this.__ownerID = ownerID;
- this.__altered = false;
- return this;
- }
- return makeStack(this.size, this._head, ownerID, this.__hash);
- };
-
- // @pragma Iteration
-
- Stack.prototype.__iterate = function(fn, reverse) {
- if (reverse) {
- return this.reverse().__iterate(fn);
- }
- var iterations = 0;
- var node = this._head;
- while (node) {
- if (fn(node.value, iterations++, this) === false) {
- break;
- }
- node = node.next;
- }
- return iterations;
- };
-
- Stack.prototype.__iterator = function(type, reverse) {
- if (reverse) {
- return this.reverse().__iterator(type);
- }
- var iterations = 0;
- var node = this._head;
- return new Iterator(function() {
- if (node) {
- var value = node.value;
- node = node.next;
- return iteratorValue(type, iterations++, value);
- }
- return iteratorDone();
- });
- };
-
-
- function isStack(maybeStack) {
- return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
- }
-
- Stack.isStack = isStack;
-
- var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
-
- var StackPrototype = Stack.prototype;
- StackPrototype[IS_STACK_SENTINEL] = true;
- StackPrototype.withMutations = MapPrototype.withMutations;
- StackPrototype.asMutable = MapPrototype.asMutable;
- StackPrototype.asImmutable = MapPrototype.asImmutable;
- StackPrototype.wasAltered = MapPrototype.wasAltered;
-
-
- function makeStack(size, head, ownerID, hash) {
- var map = Object.create(StackPrototype);
- map.size = size;
- map._head = head;
- map.__ownerID = ownerID;
- map.__hash = hash;
- map.__altered = false;
- return map;
- }
-
- var EMPTY_STACK;
- function emptyStack() {
- return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
- }
-
- /**
- * Contributes additional methods to a constructor
- */
- function mixin(ctor, methods) {
- var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; };
- Object.keys(methods).forEach(keyCopier);
- Object.getOwnPropertySymbols &&
- Object.getOwnPropertySymbols(methods).forEach(keyCopier);
- return ctor;
- }
-
- Iterable.Iterator = Iterator;
-
- mixin(Iterable, {
-
- // ### Conversion to other types
-
- toArray: function() {
- assertNotInfinite(this.size);
- var array = new Array(this.size || 0);
- this.valueSeq().__iterate(function(v, i) { array[i] = v; });
- return array;
- },
-
- toIndexedSeq: function() {
- return new ToIndexedSequence(this);
- },
-
- toJS: function() {
- return this.toSeq().map(
- function(value ) {return value && typeof value.toJS === 'function' ? value.toJS() : value}
- ).__toJS();
- },
-
- toJSON: function() {
- return this.toSeq().map(
- function(value ) {return value && typeof value.toJSON === 'function' ? value.toJSON() : value}
- ).__toJS();
- },
-
- toKeyedSeq: function() {
- return new ToKeyedSequence(this, true);
- },
-
- toMap: function() {
- // Use Late Binding here to solve the circular dependency.
- return Map(this.toKeyedSeq());
- },
-
- toObject: function() {
- assertNotInfinite(this.size);
- var object = {};
- this.__iterate(function(v, k) { object[k] = v; });
- return object;
- },
-
- toOrderedMap: function() {
- // Use Late Binding here to solve the circular dependency.
- return OrderedMap(this.toKeyedSeq());
- },
-
- toOrderedSet: function() {
- // Use Late Binding here to solve the circular dependency.
- return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
- },
-
- toSet: function() {
- // Use Late Binding here to solve the circular dependency.
- return Set(isKeyed(this) ? this.valueSeq() : this);
- },
-
- toSetSeq: function() {
- return new ToSetSequence(this);
- },
-
- toSeq: function() {
- return isIndexed(this) ? this.toIndexedSeq() :
- isKeyed(this) ? this.toKeyedSeq() :
- this.toSetSeq();
- },
-
- toStack: function() {
- // Use Late Binding here to solve the circular dependency.
- return Stack(isKeyed(this) ? this.valueSeq() : this);
- },
-
- toList: function() {
- // Use Late Binding here to solve the circular dependency.
- return List(isKeyed(this) ? this.valueSeq() : this);
- },
-
-
- // ### Common JavaScript methods and properties
-
- toString: function() {
- return '[Iterable]';
- },
-
- __toString: function(head, tail) {
- if (this.size === 0) {
- return head + tail;
- }
- return head + ' ' + this.toSeq().map(this.__toStringMapper).join(', ') + ' ' + tail;
- },
-
-
- // ### ES6 Collection methods (ES6 Array and Map)
-
- concat: function() {var values = SLICE$0.call(arguments, 0);
- return reify(this, concatFactory(this, values));
- },
-
- includes: function(searchValue) {
- return this.some(function(value ) {return is(value, searchValue)});
- },
-
- entries: function() {
- return this.__iterator(ITERATE_ENTRIES);
- },
-
- every: function(predicate, context) {
- assertNotInfinite(this.size);
- var returnValue = true;
- this.__iterate(function(v, k, c) {
- if (!predicate.call(context, v, k, c)) {
- returnValue = false;
- return false;
- }
- });
- return returnValue;
- },
-
- filter: function(predicate, context) {
- return reify(this, filterFactory(this, predicate, context, true));
- },
-
- find: function(predicate, context, notSetValue) {
- var entry = this.findEntry(predicate, context);
- return entry ? entry[1] : notSetValue;
- },
-
- findEntry: function(predicate, context) {
- var found;
- this.__iterate(function(v, k, c) {
- if (predicate.call(context, v, k, c)) {
- found = [k, v];
- return false;
- }
- });
- return found;
- },
-
- findLastEntry: function(predicate, context) {
- return this.toSeq().reverse().findEntry(predicate, context);
- },
-
- forEach: function(sideEffect, context) {
- assertNotInfinite(this.size);
- return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
- },
-
- join: function(separator) {
- assertNotInfinite(this.size);
- separator = separator !== undefined ? '' + separator : ',';
- var joined = '';
- var isFirst = true;
- this.__iterate(function(v ) {
- isFirst ? (isFirst = false) : (joined += separator);
- joined += v !== null && v !== undefined ? v.toString() : '';
- });
- return joined;
- },
-
- keys: function() {
- return this.__iterator(ITERATE_KEYS);
- },
-
- map: function(mapper, context) {
- return reify(this, mapFactory(this, mapper, context));
- },
-
- reduce: function(reducer, initialReduction, context) {
- assertNotInfinite(this.size);
- var reduction;
- var useFirst;
- if (arguments.length < 2) {
- useFirst = true;
- } else {
- reduction = initialReduction;
- }
- this.__iterate(function(v, k, c) {
- if (useFirst) {
- useFirst = false;
- reduction = v;
- } else {
- reduction = reducer.call(context, reduction, v, k, c);
- }
- });
- return reduction;
- },
-
- reduceRight: function(reducer, initialReduction, context) {
- var reversed = this.toKeyedSeq().reverse();
- return reversed.reduce.apply(reversed, arguments);
- },
-
- reverse: function() {
- return reify(this, reverseFactory(this, true));
- },
-
- slice: function(begin, end) {
- return reify(this, sliceFactory(this, begin, end, true));
- },
-
- some: function(predicate, context) {
- return !this.every(not(predicate), context);
- },
-
- sort: function(comparator) {
- return reify(this, sortFactory(this, comparator));
- },
-
- values: function() {
- return this.__iterator(ITERATE_VALUES);
- },
-
-
- // ### More sequential methods
-
- butLast: function() {
- return this.slice(0, -1);
- },
-
- isEmpty: function() {
- return this.size !== undefined ? this.size === 0 : !this.some(function() {return true});
- },
-
- count: function(predicate, context) {
- return ensureSize(
- predicate ? this.toSeq().filter(predicate, context) : this
- );
- },
-
- countBy: function(grouper, context) {
- return countByFactory(this, grouper, context);
- },
-
- equals: function(other) {
- return deepEqual(this, other);
- },
-
- entrySeq: function() {
- var iterable = this;
- if (iterable._cache) {
- // We cache as an entries array, so we can just return the cache!
- return new ArraySeq(iterable._cache);
- }
- var entriesSequence = iterable.toSeq().map(entryMapper).toIndexedSeq();
- entriesSequence.fromEntrySeq = function() {return iterable.toSeq()};
- return entriesSequence;
- },
-
- filterNot: function(predicate, context) {
- return this.filter(not(predicate), context);
- },
-
- findLast: function(predicate, context, notSetValue) {
- return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
- },
-
- first: function() {
- return this.find(returnTrue);
- },
-
- flatMap: function(mapper, context) {
- return reify(this, flatMapFactory(this, mapper, context));
- },
-
- flatten: function(depth) {
- return reify(this, flattenFactory(this, depth, true));
- },
-
- fromEntrySeq: function() {
- return new FromEntriesSequence(this);
- },
-
- get: function(searchKey, notSetValue) {
- return this.find(function(_, key) {return is(key, searchKey)}, undefined, notSetValue);
- },
-
- getIn: function(searchKeyPath, notSetValue) {
- var nested = this;
- // Note: in an ES6 environment, we would prefer:
- // for (var key of searchKeyPath) {
- var iter = forceIterator(searchKeyPath);
- var step;
- while (!(step = iter.next()).done) {
- var key = step.value;
- nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
- if (nested === NOT_SET) {
- return notSetValue;
- }
- }
- return nested;
- },
-
- groupBy: function(grouper, context) {
- return groupByFactory(this, grouper, context);
- },
-
- has: function(searchKey) {
- return this.get(searchKey, NOT_SET) !== NOT_SET;
- },
-
- hasIn: function(searchKeyPath) {
- return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
- },
-
- isSubset: function(iter) {
- iter = typeof iter.includes === 'function' ? iter : Iterable(iter);
- return this.every(function(value ) {return iter.includes(value)});
- },
-
- isSuperset: function(iter) {
- iter = typeof iter.isSubset === 'function' ? iter : Iterable(iter);
- return iter.isSubset(this);
- },
-
- keySeq: function() {
- return this.toSeq().map(keyMapper).toIndexedSeq();
- },
-
- last: function() {
- return this.toSeq().reverse().first();
- },
-
- max: function(comparator) {
- return maxFactory(this, comparator);
- },
-
- maxBy: function(mapper, comparator) {
- return maxFactory(this, comparator, mapper);
- },
-
- min: function(comparator) {
- return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator);
- },
-
- minBy: function(mapper, comparator) {
- return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator, mapper);
- },
-
- rest: function() {
- return this.slice(1);
- },
-
- skip: function(amount) {
- return this.slice(Math.max(0, amount));
- },
-
- skipLast: function(amount) {
- return reify(this, this.toSeq().reverse().skip(amount).reverse());
- },
-
- skipWhile: function(predicate, context) {
- return reify(this, skipWhileFactory(this, predicate, context, true));
- },
-
- skipUntil: function(predicate, context) {
- return this.skipWhile(not(predicate), context);
- },
-
- sortBy: function(mapper, comparator) {
- return reify(this, sortFactory(this, comparator, mapper));
- },
-
- take: function(amount) {
- return this.slice(0, Math.max(0, amount));
- },
-
- takeLast: function(amount) {
- return reify(this, this.toSeq().reverse().take(amount).reverse());
- },
-
- takeWhile: function(predicate, context) {
- return reify(this, takeWhileFactory(this, predicate, context));
- },
-
- takeUntil: function(predicate, context) {
- return this.takeWhile(not(predicate), context);
- },
-
- valueSeq: function() {
- return this.toIndexedSeq();
- },
-
-
- // ### Hashable Object
-
- hashCode: function() {
- return this.__hash || (this.__hash = hashIterable(this));
- }
-
-
- // ### Internal
-
- // abstract __iterate(fn, reverse)
-
- // abstract __iterator(type, reverse)
- });
-
- // var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
- // var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
- // var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
- // var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
-
- var IterablePrototype = Iterable.prototype;
- IterablePrototype[IS_ITERABLE_SENTINEL] = true;
- IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
- IterablePrototype.__toJS = IterablePrototype.toArray;
- IterablePrototype.__toStringMapper = quoteString;
- IterablePrototype.inspect =
- IterablePrototype.toSource = function() { return this.toString(); };
- IterablePrototype.chain = IterablePrototype.flatMap;
- IterablePrototype.contains = IterablePrototype.includes;
-
- // Temporary warning about using length
- (function () {
- try {
- Object.defineProperty(IterablePrototype, 'length', {
- get: function () {
- if (!Iterable.noLengthWarning) {
- var stack;
- try {
- throw new Error();
- } catch (error) {
- stack = error.stack;
- }
- if (stack.indexOf('_wrapObject') === -1) {
- console && console.warn && console.warn(
- 'iterable.length has been deprecated, '+
- 'use iterable.size or iterable.count(). '+
- 'This warning will become a silent error in a future version. ' +
- stack
- );
- return this.size;
- }
- }
- }
- });
- } catch (e) {}
- })();
-
-
-
- mixin(KeyedIterable, {
-
- // ### More sequential methods
-
- flip: function() {
- return reify(this, flipFactory(this));
- },
-
- findKey: function(predicate, context) {
- var entry = this.findEntry(predicate, context);
- return entry && entry[0];
- },
-
- findLastKey: function(predicate, context) {
- return this.toSeq().reverse().findKey(predicate, context);
- },
-
- keyOf: function(searchValue) {
- return this.findKey(function(value ) {return is(value, searchValue)});
- },
-
- lastKeyOf: function(searchValue) {
- return this.findLastKey(function(value ) {return is(value, searchValue)});
- },
-
- mapEntries: function(mapper, context) {var this$0 = this;
- var iterations = 0;
- return reify(this,
- this.toSeq().map(
- function(v, k) {return mapper.call(context, [k, v], iterations++, this$0)}
- ).fromEntrySeq()
- );
- },
-
- mapKeys: function(mapper, context) {var this$0 = this;
- return reify(this,
- this.toSeq().flip().map(
- function(k, v) {return mapper.call(context, k, v, this$0)}
- ).flip()
- );
- }
-
- });
-
- var KeyedIterablePrototype = KeyedIterable.prototype;
- KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
- KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
- KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
- KeyedIterablePrototype.__toStringMapper = function(v, k) {return JSON.stringify(k) + ': ' + quoteString(v)};
-
-
-
- mixin(IndexedIterable, {
-
- // ### Conversion to other types
-
- toKeyedSeq: function() {
- return new ToKeyedSequence(this, false);
- },
-
-
- // ### ES6 Collection methods (ES6 Array and Map)
-
- filter: function(predicate, context) {
- return reify(this, filterFactory(this, predicate, context, false));
- },
-
- findIndex: function(predicate, context) {
- var entry = this.findEntry(predicate, context);
- return entry ? entry[0] : -1;
- },
-
- indexOf: function(searchValue) {
- var key = this.toKeyedSeq().keyOf(searchValue);
- return key === undefined ? -1 : key;
- },
-
- lastIndexOf: function(searchValue) {
- var key = this.toKeyedSeq().reverse().keyOf(searchValue);
- return key === undefined ? -1 : key;
-
- // var index =
- // return this.toSeq().reverse().indexOf(searchValue);
- },
-
- reverse: function() {
- return reify(this, reverseFactory(this, false));
- },
-
- slice: function(begin, end) {
- return reify(this, sliceFactory(this, begin, end, false));
- },
-
- splice: function(index, removeNum /*, ...values*/) {
- var numArgs = arguments.length;
- removeNum = Math.max(removeNum | 0, 0);
- if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
- return this;
- }
- // If index is negative, it should resolve relative to the size of the
- // collection. However size may be expensive to compute if not cached, so
- // only call count() if the number is in fact negative.
- index = resolveBegin(index, index < 0 ? this.count() : this.size);
- var spliced = this.slice(0, index);
- return reify(
- this,
- numArgs === 1 ?
- spliced :
- spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
- );
- },
-
-
- // ### More collection methods
-
- findLastIndex: function(predicate, context) {
- var key = this.toKeyedSeq().findLastKey(predicate, context);
- return key === undefined ? -1 : key;
- },
-
- first: function() {
- return this.get(0);
- },
-
- flatten: function(depth) {
- return reify(this, flattenFactory(this, depth, false));
- },
-
- get: function(index, notSetValue) {
- index = wrapIndex(this, index);
- return (index < 0 || (this.size === Infinity ||
- (this.size !== undefined && index > this.size))) ?
- notSetValue :
- this.find(function(_, key) {return key === index}, undefined, notSetValue);
- },
-
- has: function(index) {
- index = wrapIndex(this, index);
- return index >= 0 && (this.size !== undefined ?
- this.size === Infinity || index < this.size :
- this.indexOf(index) !== -1
- );
- },
-
- interpose: function(separator) {
- return reify(this, interposeFactory(this, separator));
- },
-
- interleave: function(/*...iterables*/) {
- var iterables = [this].concat(arrCopy(arguments));
- var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
- var interleaved = zipped.flatten(true);
- if (zipped.size) {
- interleaved.size = zipped.size * iterables.length;
- }
- return reify(this, interleaved);
- },
-
- last: function() {
- return this.get(-1);
- },
-
- skipWhile: function(predicate, context) {
- return reify(this, skipWhileFactory(this, predicate, context, false));
- },
-
- zip: function(/*, ...iterables */) {
- var iterables = [this].concat(arrCopy(arguments));
- return reify(this, zipWithFactory(this, defaultZipper, iterables));
- },
-
- zipWith: function(zipper/*, ...iterables */) {
- var iterables = arrCopy(arguments);
- iterables[0] = this;
- return reify(this, zipWithFactory(this, zipper, iterables));
- }
-
- });
-
- IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
- IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
-
-
-
- mixin(SetIterable, {
-
- // ### ES6 Collection methods (ES6 Array and Map)
-
- get: function(value, notSetValue) {
- return this.has(value) ? value : notSetValue;
- },
-
- includes: function(value) {
- return this.has(value);
- },
-
-
- // ### More sequential methods
-
- keySeq: function() {
- return this.valueSeq();
- }
-
- });
-
- SetIterable.prototype.has = IterablePrototype.includes;
-
-
- // Mixin subclasses
-
- mixin(KeyedSeq, KeyedIterable.prototype);
- mixin(IndexedSeq, IndexedIterable.prototype);
- mixin(SetSeq, SetIterable.prototype);
-
- mixin(KeyedCollection, KeyedIterable.prototype);
- mixin(IndexedCollection, IndexedIterable.prototype);
- mixin(SetCollection, SetIterable.prototype);
-
-
- // #pragma Helper functions
-
- function keyMapper(v, k) {
- return k;
- }
-
- function entryMapper(v, k) {
- return [k, v];
- }
-
- function not(predicate) {
- return function() {
- return !predicate.apply(this, arguments);
- }
- }
-
- function neg(predicate) {
- return function() {
- return -predicate.apply(this, arguments);
- }
- }
-
- function quoteString(value) {
- return typeof value === 'string' ? JSON.stringify(value) : value;
- }
-
- function defaultZipper() {
- return arrCopy(arguments);
- }
-
- function defaultNegComparator(a, b) {
- return a < b ? 1 : a > b ? -1 : 0;
- }
-
- function hashIterable(iterable) {
- if (iterable.size === Infinity) {
- return 0;
- }
- var ordered = isOrdered(iterable);
- var keyed = isKeyed(iterable);
- var h = ordered ? 1 : 0;
- var size = iterable.__iterate(
- keyed ?
- ordered ?
- function(v, k) { h = 31 * h + hashMerge(hash(v), hash(k)) | 0; } :
- function(v, k) { h = h + hashMerge(hash(v), hash(k)) | 0; } :
- ordered ?
- function(v ) { h = 31 * h + hash(v) | 0; } :
- function(v ) { h = h + hash(v) | 0; }
- );
- return murmurHashOfSize(size, h);
- }
-
- function murmurHashOfSize(size, h) {
- h = imul(h, 0xCC9E2D51);
- h = imul(h << 15 | h >>> -15, 0x1B873593);
- h = imul(h << 13 | h >>> -13, 5);
- h = (h + 0xE6546B64 | 0) ^ size;
- h = imul(h ^ h >>> 16, 0x85EBCA6B);
- h = imul(h ^ h >>> 13, 0xC2B2AE35);
- h = smi(h ^ h >>> 16);
- return h;
- }
-
- function hashMerge(a, b) {
- return a ^ b + 0x9E3779B9 + (a << 6) + (a >> 2) | 0; // int
- }
-
- var Immutable = {
-
- Iterable: Iterable,
-
- Seq: Seq,
- Collection: Collection,
- Map: Map,
- OrderedMap: OrderedMap,
- List: List,
- Stack: Stack,
- Set: Set,
- OrderedSet: OrderedSet,
-
- Record: Record,
- Range: Range,
- Repeat: Repeat,
-
- is: is,
- fromJS: fromJS
-
- };
-
- return Immutable;
-
- }));
- });
-
- var draftjsUtils = createCommonjsModule(function (module, exports) {
- !function(e,t){module.exports=t(Draft,immutable$1);}("undefined"!=typeof self?self:commonjsGlobal,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r});},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=3)}([function(t,n){t.exports=e;},function(e,t,n){function r(e){var t=e.getSelection(),n=e.getCurrentContent(),r=t.getStartKey(),o=t.getEndKey(),i=n.getBlockMap();return i.toSeq().skipUntil(function(e,t){return t===r}).takeUntil(function(e,t){return t===o}).concat([[o,i.get(o)]])}function o(e){return r(e).toList()}function i(e){if(e)return o(e).get(0)}function l(e){if(e){var t=i(e),n=e.getCurrentContent(),r=n.getBlockMap().toSeq().toList(),o=0;if(r.forEach(function(e,n){e.get("key")===t.get("key")&&(o=n-1);}),o>-1)return r.get(o)}}function c(e){return e?e.getCurrentContent().getBlockMap().toList():new v.List}function a(e){var t=o(e);if(!t.some(function(e){return e.type!==t.get(0).type}))return t.get(0).type}function f(e){var t=p.RichUtils.tryToRemoveBlockStyle(e);return t?p.EditorState.push(e,t,"change-block-type"):e}function u(e){var t="",n=e.getSelection(),r=n.getAnchorOffset(),i=n.getFocusOffset(),l=o(e);if(l.size>0){if(n.getIsBackward()){var c=r;r=i,i=c;}for(var a=0;a<l.size;a+=1){var f=0===a?r:0,u=a===l.size-1?i:l.get(a).getText().length;t+=l.get(a).getText().slice(f,u);}}return t}function s(e){var t=e.getCurrentContent(),n=e.getSelection(),r=p.Modifier.removeRange(t,n,"forward"),o=r.getSelectionAfter(),i=r.getBlockForKey(o.getStartKey());return r=p.Modifier.insertText(r,o,"\n",i.getInlineStyleAt(o.getStartOffset()),null),p.EditorState.push(e,r,"insert-fragment")}function g(e){var t=p.Modifier.splitBlock(e.getCurrentContent(),e.getSelection());return f(p.EditorState.push(e,t,"split-block"))}function d(e){var t=e.getCurrentContent().getBlockMap().toList(),n=e.getSelection().merge({anchorKey:t.first().get("key"),anchorOffset:0,focusKey:t.last().get("key"),focusOffset:t.last().getLength()}),r=p.Modifier.removeRange(e.getCurrentContent(),n,"forward");return p.EditorState.push(e,r,"remove-range")}function S(e,t){var n=p.Modifier.setBlockData(e.getCurrentContent(),e.getSelection(),t);return p.EditorState.push(e,n,"change-block-data")}function y(e){var t=new v.Map({}),n=o(e);if(n&&n.size>0)for(var r=0;r<n.size;r+=1){var i=function(e){var r=n.get(e).getData();if(!r||0===r.size)return t=t.clear(),"break";if(0===e)t=r;else if(t.forEach(function(e,n){r.get(n)&&r.get(n)===e||(t=t.delete(n));}),0===t.size)return t=t.clear(),"break"}(r);if("break"===i)break}return t}Object.defineProperty(t,"__esModule",{value:!0}),t.blockRenderMap=void 0,t.getSelectedBlocksMap=r,t.getSelectedBlocksList=o,t.getSelectedBlock=i,t.getBlockBeforeSelectedBlock=l,t.getAllBlocks=c,t.getSelectedBlocksType=a,t.removeSelectedBlocksStyle=f,t.getSelectionText=u,t.addLineBreakRemovingSelection=s,t.insertNewUnstyledBlock=g,t.clearEditorContent=d,t.setBlockData=S,t.getSelectedBlocksMetadata=y;var p=n(0),v=n(6),k=(0, v.Map)({code:{element:"pre"}});t.blockRenderMap=p.DefaultDraftBlockRenderMap.merge(k);},function(e,t,n){function r(e){if(e){var t=e.getType();return "unordered-list-item"===t||"ordered-list-item"===t}return !1}function o(e,t,n){var r=e.getSelection(),o=e.getCurrentContent(),i=o.getBlockMap(),l=(0, c.getSelectedBlocksMap)(e).map(function(e){var r=e.getDepth()+t;return r=Math.max(0,Math.min(r,n)),e.set("depth",r)});return i=i.merge(l),o.merge({blockMap:i,selectionBefore:r,selectionAfter:r})}function i(e,t,n){var r=e.getSelection(),i=void 0;i=r.getIsBackward()?r.getFocusKey():r.getAnchorKey();var c=e.getCurrentContent(),a=c.getBlockForKey(i),f=a.getType();if("unordered-list-item"!==f&&"ordered-list-item"!==f)return e;var u=c.getBlockBefore(i);if(!u)return e;if(u.getType()!==f)return e;var s=a.getDepth();if(1===t&&s===n)return e;var g=Math.min(u.getDepth()+1,n),d=o(e,t,g);return l.EditorState.push(e,d,"adjust-depth")}Object.defineProperty(t,"__esModule",{value:!0}),t.isListBlock=r,t.changeDepth=i;var l=n(0),c=n(1);},function(e,t,n){e.exports=n(4);},function(e,t,n){var r=n(5),o=n(1),i=n(7),l=function(e){return e&&e.__esModule?e:{default:e}}(i),c=n(2);e.exports={getSelectedBlocksMap:o.getSelectedBlocksMap,getSelectedBlocksList:o.getSelectedBlocksList,getSelectedBlock:o.getSelectedBlock,getBlockBeforeSelectedBlock:o.getBlockBeforeSelectedBlock,getAllBlocks:o.getAllBlocks,getSelectedBlocksType:o.getSelectedBlocksType,removeSelectedBlocksStyle:o.removeSelectedBlocksStyle,getSelectionText:o.getSelectionText,addLineBreakRemovingSelection:o.addLineBreakRemovingSelection,insertNewUnstyledBlock:o.insertNewUnstyledBlock,clearEditorContent:o.clearEditorContent,setBlockData:o.setBlockData,getSelectedBlocksMetadata:o.getSelectedBlocksMetadata,blockRenderMap:o.blockRenderMap,getEntityRange:r.getEntityRange,getCustomStyleMap:r.getCustomStyleMap,toggleCustomInlineStyle:r.toggleCustomInlineStyle,getSelectionEntity:r.getSelectionEntity,extractInlineStyle:r.extractInlineStyle,removeAllInlineStyles:r.removeAllInlineStyles,getSelectionInlineStyle:r.getSelectionInlineStyle,getSelectionCustomInlineStyle:r.getSelectionCustomInlineStyle,handleNewLine:l.default,isListBlock:c.isListBlock,changeDepth:c.changeDepth};},function(e,t,n){function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e){var t=e.getSelection();if(t.isCollapsed()){var n={},r=e.getCurrentInlineStyle().toList().toJS();if(r)return ["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"].forEach(function(e){n[e]=r.indexOf(e)>=0;}),n}var o=t.getStartOffset(),i=t.getEndOffset(),l=(0, p.getSelectedBlocksList)(e);if(l.size>0){var c=function(){for(var e={BOLD:!0,ITALIC:!0,UNDERLINE:!0,STRIKETHROUGH:!0,CODE:!0,SUPERSCRIPT:!0,SUBSCRIPT:!0},t=0;t<l.size;t+=1){var n=0===t?o:0,r=t===l.size-1?i:l.get(t).getText().length;n===r&&0===n?(n=1,r=2):n===r&&(n-=1);for(var c=n;c<r;c+=1)!function(n){var r=l.get(t).getInlineStyleAt(n);["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"].forEach(function(t){e[t]=e[t]&&r.get(t)===t;});}(c);}return {v:e}}();if("object"===(void 0===c?"undefined":S(c)))return c.v}return {}}function i(e){var t=void 0,n=e.getSelection(),r=n.getStartOffset(),o=n.getEndOffset();r===o&&0===r?o=1:r===o&&(r-=1);for(var i=(0, p.getSelectedBlock)(e),l=r;l<o;l+=1){var c=i.getEntityAt(l);if(!c){t=void 0;break}if(l===r)t=c;else if(t!==c){t=void 0;break}}return t}function l(e,t){var n=(0, p.getSelectedBlock)(e),r=void 0;return n.findEntityRanges(function(e){return e.get("entity")===t},function(e,t){r={start:e,end:t,text:n.get("text").slice(e,t)};}),r}function c(e,t,n){var r=e.getSelection(),o=Object.keys(v[t]).reduce(function(e,t){return y.Modifier.removeInlineStyle(e,r,t)},e.getCurrentContent()),i=y.EditorState.push(e,o,"changeinline-style"),l=e.getCurrentInlineStyle();if(r.isCollapsed()&&(i=l.reduce(function(e,t){return y.RichUtils.toggleInlineStyle(e,t)},i)),"SUPERSCRIPT"===t||"SUBSCRIPT"==t)l.has(n)||(i=y.RichUtils.toggleInlineStyle(i,n));else{var c="bgcolor"===t?"backgroundColor":t;l.has(c+"-"+n)||(i=y.RichUtils.toggleInlineStyle(i,t.toLowerCase()+"-"+n),k(t,c,n));}return i}function a(e){if(e){e.getCurrentContent().getBlockMap().map(function(e){return e.get("characterList")}).toList().flatten().forEach(function(e){e&&0===e.indexOf("color-")?k("color","color",e.substr(6)):e&&0===e.indexOf("bgcolor-")?k("bgcolor","backgroundColor",e.substr(8)):e&&0===e.indexOf("fontsize-")?k("fontSize","fontSize",+e.substr(9)):e&&0===e.indexOf("fontfamily-")&&k("fontFamily","fontFamily",e.substr(11));});}}function f(e,t,n){var r=e.getInlineStyleAt(n).toList(),o=r.filter(function(e){return e.startsWith(t.toLowerCase())});if(o&&o.size>0)return o.get(0)}function u(e,t){var n=e.getCurrentInlineStyle().toList(),r=n.filter(function(e){return e.startsWith(t.toLowerCase())});if(r&&r.size>0)return r.get(0)}function s(e,t){if(e&&t&&t.length>0){var n=function(){var n=e.getSelection(),r={};if(n.isCollapsed())return t.forEach(function(t){r[t]=u(e,t);}),{v:r};var o=n.getStartOffset(),i=n.getEndOffset(),l=(0, p.getSelectedBlocksList)(e);if(l.size>0){for(var c=0;c<l.size;c+=1)!function(e){var n=0===e?o:0,c=e===l.size-1?i:l.get(e).getText().length;n===c&&0===n?(n=1,c=2):n===c&&(n-=1);for(var a=n;a<c;a+=1)!function(o){o===n?t.forEach(function(t){r[t]=f(l.get(e),t,o);}):t.forEach(function(t){r[t]&&r[t]!==f(l.get(e),t,o)&&(r[t]=void 0);});}(a);}(c);return {v:r}}}();if("object"===(void 0===n?"undefined":S(n)))return n.v}return {}}function g(e){var t=e.getCurrentInlineStyle(),n=e.getCurrentContent();return t.forEach(function(t){n=y.Modifier.removeInlineStyle(n,e.getSelection(),t);}),y.EditorState.push(e,n,"change-inline-style")}Object.defineProperty(t,"__esModule",{value:!0}),t.getCustomStyleMap=void 0;var d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);}return e},S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.getSelectionInlineStyle=o,t.getSelectionEntity=i,t.getEntityRange=l,t.toggleCustomInlineStyle=c,t.extractInlineStyle=a,t.getSelectionCustomInlineStyle=s,t.removeAllInlineStyles=g;var y=n(0),p=n(1),v={color:{},bgcolor:{},fontSize:{},fontFamily:{},CODE:{fontFamily:"monospace",wordWrap:"break-word",background:"#f1f1f1",borderRadius:3,padding:"1px 3px"},SUPERSCRIPT:{fontSize:11,position:"relative",top:-8,display:"inline-flex"},SUBSCRIPT:{fontSize:11,position:"relative",bottom:-8,display:"inline-flex"}},k=function(e,t,n){v[e][e.toLowerCase()+"-"+n]=r({},""+t,n);};t.getCustomStyleMap=function(){return d({},v.color,v.bgcolor,v.fontSize,v.fontFamily,{CODE:v.CODE,SUPERSCRIPT:v.SUPERSCRIPT,SUBSCRIPT:v.SUBSCRIPT})};},function(e,n){e.exports=t;},function(e,t,n){function r(e){var t=e.getSelection();if(t.isCollapsed()){var n=e.getCurrentContent(),r=t.getStartKey(),o=n.getBlockForKey(r);if(!(0, a.isListBlock)(o)&&"unstyled"!==o.getType()&&o.getLength()===t.getStartOffset())return (0, c.insertNewUnstyledBlock)(e);if((0, a.isListBlock)(o)&&0===o.getLength()){var i=o.getDepth();if(0===i)return (0, c.removeSelectedBlocksStyle)(e);if(i>0)return (0, a.changeDepth)(e,-1,i)}}}function o(e){return 13===e.which&&(e.getModifierState("Shift")||e.getModifierState("Alt")||e.getModifierState("Control"))}function i(e,t){if(o(t)){return e.getSelection().isCollapsed()?l.RichUtils.insertSoftNewline(e):(0, c.addLineBreakRemovingSelection)(e)}return r(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var l=n(0),c=n(1),a=n(2);}])});
- });
-
- unwrapExports(draftjsUtils);
- var draftjsUtils_1 = draftjsUtils.draftjsUtils;
-
- var interopRequireDefault = createCommonjsModule(function (module) {
- function _interopRequireDefault(obj) {
- return obj && obj.__esModule ? obj : {
- "default": obj
- };
- }
-
- module.exports = _interopRequireDefault;
- });
-
- unwrapExports(interopRequireDefault);
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
-
- /**
- * Use invariant() to assert state which your program assumes to be true.
- *
- * Provide sprintf-style format (only %s is supported) and arguments
- * to provide information about what broke and what you were
- * expecting.
- *
- * The invariant message will be stripped in production, but the invariant
- * will remain to ensure logic does not differ in production.
- */
-
- var invariant$1 = function(condition, format, a, b, c, d, e, f) {
- if (process.env.NODE_ENV !== 'production') {
- if (format === undefined) {
- throw new Error('invariant requires an error message argument');
- }
- }
-
- if (!condition) {
- var error;
- if (format === undefined) {
- error = new Error(
- 'Minified exception occurred; use the non-minified dev environment ' +
- 'for the full error message and additional helpful warnings.'
- );
- } else {
- var args = [a, b, c, d, e, f];
- var argIndex = 0;
- error = new Error(
- format.replace(/%s/g, function() { return args[argIndex++]; })
- );
- error.name = 'Invariant Violation';
- }
-
- error.framesToPop = 1; // we don't care about invariant's own frame
- throw error;
- }
- };
-
- var browser = invariant$1;
-
- function _arrayWithoutHoles(arr) {
- if (Array.isArray(arr)) {
- for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
- arr2[i] = arr[i];
- }
-
- return arr2;
- }
- }
-
- var arrayWithoutHoles = _arrayWithoutHoles;
-
- function _iterableToArray(iter) {
- if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
- }
-
- var iterableToArray = _iterableToArray;
-
- function _nonIterableSpread() {
- throw new TypeError("Invalid attempt to spread non-iterable instance");
- }
-
- var nonIterableSpread = _nonIterableSpread;
-
- function _toConsumableArray(arr) {
- return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();
- }
-
- var toConsumableArray = _toConsumableArray;
-
- var updateMutation_1 = createCommonjsModule(function (module, exports) {
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports["default"] = updateMutation;
-
- function updateMutation(mutation, originalOffset, originalLength, newLength, prefixLength, suffixLength) {
- // three cases we can reasonably adjust - disjoint mutations that
- // happen later on where the offset will need to be changed,
- // mutations that completely contain the new one where we can adjust
- // the length, and mutations that occur partially within the new one.
- var lengthDiff = newLength - originalLength;
- var mutationAfterChange = originalOffset + originalLength <= mutation.offset;
-
- if (mutationAfterChange) {
- return Object.assign({}, mutation, {
- offset: mutation.offset + lengthDiff
- });
- }
-
- var mutationContainsChange = originalOffset >= mutation.offset && originalOffset + originalLength <= mutation.offset + mutation.length;
-
- if (mutationContainsChange) {
- return Object.assign({}, mutation, {
- length: mutation.length + lengthDiff
- });
- }
-
- var mutationWithinPrefixChange = mutation.offset >= originalOffset && mutation.offset + mutation.length <= originalOffset + originalLength && prefixLength > 0;
-
- if (mutationWithinPrefixChange) {
- return Object.assign({}, mutation, {
- offset: mutation.offset + prefixLength
- });
- }
-
- var mutationContainsPrefix = mutation.offset < originalOffset && mutation.offset + mutation.length <= originalOffset + originalLength && mutation.offset + mutation.length > originalOffset && prefixLength > 0;
-
- if (mutationContainsPrefix) {
- return [Object.assign({}, mutation, {
- length: originalOffset - mutation.offset
- }), Object.assign({}, mutation, {
- offset: originalOffset + prefixLength,
- length: mutation.offset - originalOffset + mutation.length
- })];
- }
-
- var mutationContainsSuffix = mutation.offset >= originalOffset && mutation.offset + mutation.length > originalOffset + originalLength && originalOffset + originalLength > mutation.offset && suffixLength > 0;
-
- if (mutationContainsSuffix) {
- return [Object.assign({}, mutation, {
- offset: mutation.offset + prefixLength,
- length: originalOffset + originalLength - mutation.offset
- }), Object.assign({}, mutation, {
- offset: originalOffset + originalLength + prefixLength + suffixLength,
- length: mutation.offset + mutation.length - (originalOffset + originalLength)
- })];
- }
-
- return mutation;
- }
- });
-
- unwrapExports(updateMutation_1);
-
- var rangeSort = createCommonjsModule(function (module, exports) {
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports["default"] = void 0;
-
- var _default = function _default(r1, r2) {
- if (r1.offset === r2.offset) {
- return r2.length - r1.length;
- }
-
- return r1.offset - r2.offset;
- };
-
- exports["default"] = _default;
- });
-
- unwrapExports(rangeSort);
-
- var encodeBlock = createCommonjsModule(function (module, exports) {
-
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports["default"] = void 0;
-
- var _toConsumableArray2 = interopRequireDefault(toConsumableArray);
-
- var _updateMutation = interopRequireDefault(updateMutation_1);
-
- var _rangeSort = interopRequireDefault(rangeSort);
-
- var ENTITY_MAP = {
- '&': '&',
- '<': '<',
- '>': '>',
- '"': '"',
- "'": ''',
- '`': '`',
- '\n': '<br/>'
- };
-
- var _default = function _default(block) {
- var blockText = (0, _toConsumableArray2["default"])(block.text);
- var entities = block.entityRanges.sort(_rangeSort["default"]);
- var styles = block.inlineStyleRanges.sort(_rangeSort["default"]);
- var resultText = '';
-
- var _loop = function _loop(index) {
- var _char = blockText[index];
-
- if (ENTITY_MAP[_char] !== undefined) {
- var encoded = ENTITY_MAP[_char];
- var resultIndex = (0, _toConsumableArray2["default"])(resultText).length;
- resultText += encoded;
-
- var updateForChar = function updateForChar(mutation) {
- return (0, _updateMutation["default"])(mutation, resultIndex, _char.length, encoded.length, 0, 0);
- };
-
- entities = entities.map(updateForChar);
- styles = styles.map(updateForChar);
- } else {
- resultText += _char;
- }
- };
-
- for (var index = 0; index < blockText.length; index++) {
- _loop(index);
- }
-
- return Object.assign({}, block, {
- text: resultText,
- inlineStyleRanges: styles,
- entityRanges: entities
- });
- };
-
- exports["default"] = _default;
- });
-
- unwrapExports(encodeBlock);
-
- var _typeof_1 = createCommonjsModule(function (module) {
- function _typeof(obj) {
- "@babel/helpers - typeof";
-
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
- module.exports = _typeof = function _typeof(obj) {
- return typeof obj;
- };
- } else {
- module.exports = _typeof = function _typeof(obj) {
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
- };
- }
-
- return _typeof(obj);
- }
-
- module.exports = _typeof;
- });
-
- var splitReactElement_1 = createCommonjsModule(function (module, exports) {
-
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports["default"] = splitReactElement;
-
- var _invariant = interopRequireDefault(browser);
-
- var _react = interopRequireDefault(React);
-
- var _server = interopRequireDefault(server);
-
- // see http://w3c.github.io/html/syntax.html#writing-html-documents-elements
- var VOID_TAGS = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
-
- function splitReactElement(element) {
- if (VOID_TAGS.indexOf(element.type) !== -1) {
- return _server["default"].renderToStaticMarkup(element);
- }
-
- var tags = _server["default"].renderToStaticMarkup(_react["default"].cloneElement(element, {}, '\r')).split('\r');
-
- (0, _invariant["default"])(tags.length > 1, "convertToHTML: Element of type ".concat(element.type, " must render children"));
- (0, _invariant["default"])(tags.length < 3, "convertToHTML: Element of type ".concat(element.type, " cannot use carriage return character"));
- return {
- start: tags[0],
- end: tags[1]
- };
- }
- });
-
- unwrapExports(splitReactElement_1);
-
- var getElementHTML_1 = createCommonjsModule(function (module, exports) {
-
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports["default"] = getElementHTML;
-
- var _typeof2 = interopRequireDefault(_typeof_1);
-
- var _invariant = interopRequireDefault(browser);
-
- var _react = interopRequireDefault(React);
-
- var _server = interopRequireDefault(server);
-
- var _splitReactElement = interopRequireDefault(splitReactElement_1);
-
- function hasChildren(element) {
- return _react["default"].isValidElement(element) && _react["default"].Children.count(element.props.children) > 0;
- }
-
- function getElementHTML(element) {
- var text = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
-
- if (element === undefined || element === null) {
- return element;
- }
-
- if (typeof element === 'string') {
- return element;
- }
-
- if (_react["default"].isValidElement(element)) {
- if (hasChildren(element)) {
- return _server["default"].renderToStaticMarkup(element);
- }
-
- var tags = (0, _splitReactElement["default"])(element);
-
- if (text !== null && (0, _typeof2["default"])(tags) === 'object') {
- var start = tags.start,
- end = tags.end;
- return start + text + end;
- }
-
- return tags;
- }
-
- (0, _invariant["default"])(Object.prototype.hasOwnProperty.call(element, 'start') && Object.prototype.hasOwnProperty.call(element, 'end'), 'convertToHTML: received conversion data without either an HTML string, ReactElement or an object with start/end tags');
-
- if (text !== null) {
- var _start = element.start,
- _end = element.end;
- return _start + text + _end;
- }
-
- return element;
- }
- });
-
- unwrapExports(getElementHTML_1);
-
- var getElementTagLength_1 = createCommonjsModule(function (module, exports) {
-
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports["default"] = void 0;
-
- var _typeof2 = interopRequireDefault(_typeof_1);
-
- var _react = interopRequireDefault(React);
-
- var _splitReactElement = interopRequireDefault(splitReactElement_1);
-
- var getElementTagLength = function getElementTagLength(element) {
- var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'start';
-
- if (_react["default"].isValidElement(element)) {
- var splitElement = (0, _splitReactElement["default"])(element);
-
- if (typeof splitElement === 'string') {
- return 0;
- }
-
- var length = splitElement[type].length;
-
- var child = _react["default"].Children.toArray(element.props.children)[0];
-
- return length + (child && _react["default"].isValidElement(child) ? getElementTagLength(child, type) : 0);
- }
-
- if ((0, _typeof2["default"])(element) === 'object') {
- return element[type] ? element[type].length : 0;
- }
-
- return 0;
- };
-
- var _default = getElementTagLength;
- exports["default"] = _default;
- });
-
- unwrapExports(getElementTagLength_1);
-
- var blockEntities = createCommonjsModule(function (module, exports) {
-
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports["default"] = void 0;
-
- var _toConsumableArray2 = interopRequireDefault(toConsumableArray);
-
- var _updateMutation = interopRequireDefault(updateMutation_1);
-
- var _rangeSort = interopRequireDefault(rangeSort);
-
- var _getElementHTML = interopRequireDefault(getElementHTML_1);
-
- var _getElementTagLength = interopRequireDefault(getElementTagLength_1);
-
- var converter = function converter() {
- var originalText = arguments.length > 1 ? arguments[1] : undefined;
- return originalText;
- };
-
- var _default = function _default(block, entityMap) {
- var entityConverter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : converter;
- var resultText = (0, _toConsumableArray2["default"])(block.text);
- var getEntityHTML = entityConverter;
-
- if (entityConverter.__isMiddleware) {
- getEntityHTML = entityConverter(converter);
- }
-
- if (Object.prototype.hasOwnProperty.call(block, 'entityRanges') && block.entityRanges.length > 0) {
- var entities = block.entityRanges.sort(_rangeSort["default"]);
- var styles = block.inlineStyleRanges;
-
- var _loop = function _loop(index) {
- var entityRange = entities[index];
- var entity = entityMap[entityRange.key];
- var originalText = resultText.slice(entityRange.offset, entityRange.offset + entityRange.length).join('');
- var entityHTML = getEntityHTML(entity, originalText);
- var converted = (0, _toConsumableArray2["default"])((0, _getElementHTML["default"])(entityHTML, originalText) || originalText);
- var prefixLength = (0, _getElementTagLength["default"])(entityHTML, 'start');
- var suffixLength = (0, _getElementTagLength["default"])(entityHTML, 'end');
-
- var updateLaterMutation = function updateLaterMutation(mutation, mutationIndex) {
- if (mutationIndex > index || Object.prototype.hasOwnProperty.call(mutation, 'style')) {
- return (0, _updateMutation["default"])(mutation, entityRange.offset, entityRange.length, converted.length, prefixLength, suffixLength);
- }
-
- return mutation;
- };
-
- var updateLaterMutations = function updateLaterMutations(mutationList) {
- return mutationList.reduce(function (acc, mutation, mutationIndex) {
- var updatedMutation = updateLaterMutation(mutation, mutationIndex);
-
- if (Array.isArray(updatedMutation)) {
- return acc.concat(updatedMutation);
- }
-
- return acc.concat([updatedMutation]);
- }, []);
- };
-
- entities = updateLaterMutations(entities);
- styles = updateLaterMutations(styles);
- resultText = [].concat((0, _toConsumableArray2["default"])(resultText.slice(0, entityRange.offset)), (0, _toConsumableArray2["default"])(converted), (0, _toConsumableArray2["default"])(resultText.slice(entityRange.offset + entityRange.length)));
- };
-
- for (var index = 0; index < entities.length; index++) {
- _loop(index);
- }
-
- return Object.assign({}, block, {
- text: resultText.join(''),
- inlineStyleRanges: styles,
- entityRanges: entities
- });
- }
-
- return block;
- };
-
- exports["default"] = _default;
- });
-
- unwrapExports(blockEntities);
-
- var styleObjectFunction = createCommonjsModule(function (module, exports) {
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports["default"] = void 0;
-
- var _default = function _default(object) {
- return function (style) {
- if (typeof object === 'function') {
- return object(style);
- }
-
- return object[style];
- };
- };
-
- exports["default"] = _default;
- });
-
- unwrapExports(styleObjectFunction);
-
- var accumulateFunction = createCommonjsModule(function (module, exports) {
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports["default"] = void 0;
-
- var _default = function _default(newFn, rest) {
- return function () {
- var newResult = newFn.apply(void 0, arguments);
-
- if (newResult !== undefined && newResult !== null) {
- return newResult;
- }
-
- return rest.apply(void 0, arguments);
- };
- };
-
- exports["default"] = _default;
- });
-
- unwrapExports(accumulateFunction);
-
- var defaultInlineHTML_1 = createCommonjsModule(function (module, exports) {
-
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports["default"] = defaultInlineHTML;
-
- var _react = interopRequireDefault(React);
-
- function defaultInlineHTML(style) {
- switch (style) {
- case 'BOLD':
- return _react["default"].createElement("strong", null);
-
- case 'ITALIC':
- return _react["default"].createElement("em", null);
-
- case 'UNDERLINE':
- return _react["default"].createElement("u", null);
-
- case 'CODE':
- return _react["default"].createElement("code", null);
-
- default:
- return {
- start: '',
- end: ''
- };
- }
- }
- });
-
- unwrapExports(defaultInlineHTML_1);
-
- var blockInlineStyles = createCommonjsModule(function (module, exports) {
-
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports["default"] = void 0;
-
- var _toConsumableArray2 = interopRequireDefault(toConsumableArray);
-
- var _invariant = interopRequireDefault(browser);
-
- var _styleObjectFunction = interopRequireDefault(styleObjectFunction);
-
- var _accumulateFunction = interopRequireDefault(accumulateFunction);
-
- var _getElementHTML = interopRequireDefault(getElementHTML_1);
-
- var _rangeSort = interopRequireDefault(rangeSort);
-
- var _defaultInlineHTML = interopRequireDefault(defaultInlineHTML_1);
-
- var subtractStyles = function subtractStyles(original, toRemove) {
- return original.filter(function (el) {
- return !toRemove.some(function (elToRemove) {
- return elToRemove.style === el.style;
- });
- });
- };
-
- var popEndingStyles = function popEndingStyles(styleStack, endingStyles) {
- return endingStyles.reduceRight(function (stack, style) {
- var styleToRemove = stack[stack.length - 1];
- (0, _invariant["default"])(styleToRemove.style === style.style, "Style ".concat(styleToRemove.style, " to be removed doesn't match expected ").concat(style.style));
- return stack.slice(0, -1);
- }, styleStack);
- };
-
- var characterStyles = function characterStyles(offset, ranges) {
- return ranges.filter(function (range) {
- return offset >= range.offset && offset < range.offset + range.length;
- });
- };
-
- var rangeIsSubset = function rangeIsSubset(firstRange, secondRange) {
- // returns true if the second range is a subset of the first
- var secondStartWithinFirst = firstRange.offset <= secondRange.offset;
- var secondEndWithinFirst = firstRange.offset + firstRange.length >= secondRange.offset + secondRange.length;
- return secondStartWithinFirst && secondEndWithinFirst;
- };
-
- var latestStyleLast = function latestStyleLast(s1, s2) {
- // make sure longer-lasting styles are added first
- var s2endIndex = s2.offset + s2.length;
- var s1endIndex = s1.offset + s1.length;
- return s2endIndex - s1endIndex;
- };
-
- var getStylesToReset = function getStylesToReset(remainingStyles, newStyles) {
- var i = 0;
-
- while (i < remainingStyles.length) {
- if (newStyles.every(rangeIsSubset.bind(null, remainingStyles[i]))) {
- i++;
- } else {
- return remainingStyles.slice(i);
- }
- }
-
- return [];
- };
-
- var appendStartMarkup = function appendStartMarkup(inlineHTML, string, styleRange) {
- return string + (0, _getElementHTML["default"])(inlineHTML(styleRange.style)).start;
- };
-
- var prependEndMarkup = function prependEndMarkup(inlineHTML, string, styleRange) {
- return (0, _getElementHTML["default"])(inlineHTML(styleRange.style)).end + string;
- };
-
- var defaultCustomInlineHTML = function defaultCustomInlineHTML(next) {
- return function (style) {
- return next(style);
- };
- };
-
- defaultCustomInlineHTML.__isMiddleware = true;
-
- var _default = function _default(rawBlock) {
- var customInlineHTML = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultCustomInlineHTML;
- (0, _invariant["default"])(rawBlock !== null && rawBlock !== undefined, 'Expected raw block to be non-null');
- var inlineHTML;
-
- if (customInlineHTML.__isMiddleware === true) {
- inlineHTML = customInlineHTML(_defaultInlineHTML["default"]);
- } else {
- inlineHTML = (0, _accumulateFunction["default"])((0, _styleObjectFunction["default"])(customInlineHTML), (0, _styleObjectFunction["default"])(_defaultInlineHTML["default"]));
- }
-
- var result = '';
- var styleStack = [];
- var sortedRanges = rawBlock.inlineStyleRanges.sort(_rangeSort["default"]);
- var originalTextArray = (0, _toConsumableArray2["default"])(rawBlock.text);
-
- for (var i = 0; i < originalTextArray.length; i++) {
- var styles = characterStyles(i, sortedRanges);
- var endingStyles = subtractStyles(styleStack, styles);
- var newStyles = subtractStyles(styles, styleStack);
- var remainingStyles = subtractStyles(styleStack, endingStyles); // reset styles: look for any already existing styles that will need to
- // end before styles that are being added on this character. to solve this
- // close out those current tags and all nested children,
- // then open new ones nested within the new styles.
-
- var resetStyles = getStylesToReset(remainingStyles, newStyles);
- var openingStyles = resetStyles.concat(newStyles).sort(latestStyleLast);
- var openingStyleTags = openingStyles.reduce(appendStartMarkup.bind(null, inlineHTML), '');
- var endingStyleTags = endingStyles.concat(resetStyles).reduce(prependEndMarkup.bind(null, inlineHTML), '');
- result += endingStyleTags + openingStyleTags + originalTextArray[i];
- styleStack = popEndingStyles(styleStack, resetStyles.concat(endingStyles));
- styleStack = styleStack.concat(openingStyles);
- (0, _invariant["default"])(styleStack.length === styles.length, "Character ".concat(i, ": ").concat(styleStack.length - styles.length, " styles left on stack that should no longer be there"));
- }
-
- result = styleStack.reduceRight(function (res, openStyle) {
- return res + (0, _getElementHTML["default"])(inlineHTML(openStyle.style)).end;
- }, result);
- return result;
- };
-
- exports["default"] = _default;
- });
-
- unwrapExports(blockInlineStyles);
-
- var blockTypeObjectFunction = createCommonjsModule(function (module, exports) {
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports["default"] = void 0;
-
- var _default = function _default(typeObject) {
- return function (block) {
- if (typeof typeObject === 'function') {
- // handle case where typeObject is already a function
- return typeObject(block);
- }
-
- return typeObject[block.type];
- };
- };
-
- exports["default"] = _default;
- });
-
- unwrapExports(blockTypeObjectFunction);
-
- var getBlockTags_1 = createCommonjsModule(function (module, exports) {
-
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports["default"] = getBlockTags;
-
- var _invariant = interopRequireDefault(browser);
-
- var _react = interopRequireDefault(React);
-
- var _server = interopRequireDefault(server);
-
- var _splitReactElement = interopRequireDefault(splitReactElement_1);
-
- function hasChildren(element) {
- return _react["default"].isValidElement(element) && _react["default"].Children.count(element.props.children) > 0;
- }
-
- function getBlockTags(blockHTML) {
- (0, _invariant["default"])(blockHTML !== null && blockHTML !== undefined, 'Expected block HTML value to be non-null');
-
- if (typeof blockHTML === 'string') {
- return blockHTML;
- }
-
- if (_react["default"].isValidElement(blockHTML)) {
- if (hasChildren(blockHTML)) {
- return _server["default"].renderToStaticMarkup(blockHTML);
- }
-
- return (0, _splitReactElement["default"])(blockHTML);
- }
-
- if (Object.prototype.hasOwnProperty.call(blockHTML, 'element') && _react["default"].isValidElement(blockHTML.element)) {
- return Object.assign({}, blockHTML, (0, _splitReactElement["default"])(blockHTML.element));
- }
-
- (0, _invariant["default"])(Object.prototype.hasOwnProperty.call(blockHTML, 'start') && Object.prototype.hasOwnProperty.call(blockHTML, 'end'), 'convertToHTML: received block information without either a ReactElement or an object with start/end tags');
- return blockHTML;
- }
- });
-
- unwrapExports(getBlockTags_1);
-
- var getNestedBlockTags_1 = createCommonjsModule(function (module, exports) {
-
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports["default"] = getNestedBlockTags;
-
- var _invariant = interopRequireDefault(browser);
-
- var _react = interopRequireDefault(React);
-
- var _splitReactElement2 = interopRequireDefault(splitReactElement_1);
-
- function getNestedBlockTags(blockHTML) {
- (0, _invariant["default"])(blockHTML !== null && blockHTML !== undefined, 'Expected block HTML value to be non-null');
-
- if (_react["default"].isValidElement(blockHTML.nest)) {
- var _splitReactElement = (0, _splitReactElement2["default"])(blockHTML.nest),
- start = _splitReactElement.start,
- end = _splitReactElement.end;
-
- return Object.assign({}, blockHTML, {
- nestStart: start,
- nestEnd: end
- });
- }
-
- (0, _invariant["default"])(Object.prototype.hasOwnProperty.call(blockHTML, 'nestStart') && Object.prototype.hasOwnProperty.call(blockHTML, 'nestEnd'), 'convertToHTML: received block information without either a ReactElement or an object with start/end tags');
- return blockHTML;
- }
- });
-
- unwrapExports(getNestedBlockTags_1);
-
- var defaultBlockHTML = createCommonjsModule(function (module, exports) {
-
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports["default"] = void 0;
-
- var _react = interopRequireDefault(React);
-
- var _default = {
- unstyled: _react["default"].createElement("p", null),
- paragraph: _react["default"].createElement("p", null),
- 'header-one': _react["default"].createElement("h1", null),
- 'header-two': _react["default"].createElement("h2", null),
- 'header-three': _react["default"].createElement("h3", null),
- 'header-four': _react["default"].createElement("h4", null),
- 'header-five': _react["default"].createElement("h5", null),
- 'header-six': _react["default"].createElement("h6", null),
- blockquote: _react["default"].createElement("blockquote", null),
- 'unordered-list-item': {
- element: _react["default"].createElement("li", null),
- nest: _react["default"].createElement("ul", null)
- },
- 'ordered-list-item': {
- element: _react["default"].createElement("li", null),
- nest: _react["default"].createElement("ol", null)
- },
- media: _react["default"].createElement("figure", null),
- atomic: _react["default"].createElement("figure", null)
- };
- exports["default"] = _default;
- });
-
- unwrapExports(defaultBlockHTML);
-
- var convertToHTML_1 = createCommonjsModule(function (module, exports) {
-
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports["default"] = void 0;
-
- var _invariant = interopRequireDefault(browser);
-
- var _react = interopRequireDefault(React);
-
- var _server = interopRequireDefault(server);
-
-
-
- var _encodeBlock = interopRequireDefault(encodeBlock);
-
- var _blockEntities = interopRequireDefault(blockEntities);
-
- var _blockInlineStyles = interopRequireDefault(blockInlineStyles);
-
- var _accumulateFunction = interopRequireDefault(accumulateFunction);
-
- var _blockTypeObjectFunction = interopRequireDefault(blockTypeObjectFunction);
-
- var _getBlockTags = interopRequireDefault(getBlockTags_1);
-
- var _getNestedBlockTags = interopRequireDefault(getNestedBlockTags_1);
-
- var _defaultBlockHTML = interopRequireDefault(defaultBlockHTML);
-
- // import Immutable from 'immutable'; // eslint-disable-line no-unused-vars
- var defaultEntityToHTML = function defaultEntityToHTML(entity, originalText) {
- return originalText;
- };
-
- var convertToHTML = function convertToHTML(_ref) {
- var _ref$styleToHTML = _ref.styleToHTML,
- styleToHTML = _ref$styleToHTML === void 0 ? {} : _ref$styleToHTML,
- _ref$blockToHTML = _ref.blockToHTML,
- blockToHTML = _ref$blockToHTML === void 0 ? {} : _ref$blockToHTML,
- _ref$entityToHTML = _ref.entityToHTML,
- entityToHTML = _ref$entityToHTML === void 0 ? defaultEntityToHTML : _ref$entityToHTML;
- return function (contentState) {
- (0, _invariant["default"])(contentState !== null && contentState !== undefined, 'Expected contentState to be non-null');
- var getBlockHTML;
-
- if (blockToHTML.__isMiddleware === true) {
- getBlockHTML = blockToHTML((0, _blockTypeObjectFunction["default"])(_defaultBlockHTML["default"]));
- } else {
- getBlockHTML = (0, _accumulateFunction["default"])((0, _blockTypeObjectFunction["default"])(blockToHTML), (0, _blockTypeObjectFunction["default"])(_defaultBlockHTML["default"]));
- }
-
- var rawState = (0, Draft.convertToRaw)(contentState);
- var listStack = [];
- var result = rawState.blocks.map(function (block) {
- var type = block.type,
- depth = block.depth;
- var closeNestTags = '';
- var openNestTags = '';
- var blockHTMLResult = getBlockHTML(block);
-
- if (!blockHTMLResult) {
- throw new Error("convertToHTML: missing HTML definition for block with type ".concat(block.type));
- }
-
- if (!blockHTMLResult.nest) {
- // this block can't be nested, so reset all nesting if necessary
- closeNestTags = listStack.reduceRight(function (string, nestedBlock) {
- return string + (0, _getNestedBlockTags["default"])(getBlockHTML(nestedBlock)).nestEnd;
- }, '');
- listStack = [];
- } else {
- while (depth + 1 !== listStack.length || type !== listStack[depth].type) {
- if (depth + 1 === listStack.length) {
- // depth is right but doesn't match type
- var blockToClose = listStack[depth];
- closeNestTags += (0, _getNestedBlockTags["default"])(getBlockHTML(blockToClose)).nestEnd;
- openNestTags += (0, _getNestedBlockTags["default"])(getBlockHTML(block)).nestStart;
- listStack[depth] = block;
- } else if (depth + 1 < listStack.length) {
- var _blockToClose = listStack[listStack.length - 1];
- closeNestTags += (0, _getNestedBlockTags["default"])(getBlockHTML(_blockToClose)).nestEnd;
- listStack = listStack.slice(0, -1);
- } else {
- openNestTags += (0, _getNestedBlockTags["default"])(getBlockHTML(block)).nestStart;
- listStack.push(block);
- }
- }
- }
-
- var innerHTML = (0, _blockInlineStyles["default"])((0, _blockEntities["default"])((0, _encodeBlock["default"])(block), rawState.entityMap, entityToHTML), styleToHTML);
- var blockHTML = (0, _getBlockTags["default"])(getBlockHTML(block));
- var html;
-
- if (typeof blockHTML === 'string') {
- html = blockHTML;
- } else {
- html = blockHTML.start + innerHTML + blockHTML.end;
- }
-
- if (innerHTML.length === 0 && Object.prototype.hasOwnProperty.call(blockHTML, 'empty')) {
- if (_react["default"].isValidElement(blockHTML.empty)) {
- html = _server["default"].renderToStaticMarkup(blockHTML.empty);
- } else {
- html = blockHTML.empty;
- }
- }
-
- return closeNestTags + openNestTags + html;
- }).join('');
- result = listStack.reduce(function (res, nestBlock) {
- return res + (0, _getNestedBlockTags["default"])(getBlockHTML(nestBlock)).nestEnd;
- }, result);
- return result;
- };
- };
-
- var _default = function _default() {
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- if (args.length === 1 && Object.prototype.hasOwnProperty.call(args[0], '_map') && args[0].getBlockMap != null) {
- // skip higher-order function and use defaults
- return convertToHTML({}).apply(void 0, args);
- }
-
- return convertToHTML.apply(void 0, args);
- };
-
- exports["default"] = _default;
- });
-
- unwrapExports(convertToHTML_1);
-
- var immutable$2 = createCommonjsModule(function (module, exports) {
- /**
- * Copyright (c) 2014-2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
-
- (function (global, factory) {
- module.exports = factory() ;
- }(commonjsGlobal, function () {var SLICE$0 = Array.prototype.slice;
-
- function createClass(ctor, superClass) {
- if (superClass) {
- ctor.prototype = Object.create(superClass.prototype);
- }
- ctor.prototype.constructor = ctor;
- }
-
- function Iterable(value) {
- return isIterable(value) ? value : Seq(value);
- }
-
-
- createClass(KeyedIterable, Iterable);
- function KeyedIterable(value) {
- return isKeyed(value) ? value : KeyedSeq(value);
- }
-
-
- createClass(IndexedIterable, Iterable);
- function IndexedIterable(value) {
- return isIndexed(value) ? value : IndexedSeq(value);
- }
-
-
- createClass(SetIterable, Iterable);
- function SetIterable(value) {
- return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
- }
-
-
-
- function isIterable(maybeIterable) {
- return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
- }
-
- function isKeyed(maybeKeyed) {
- return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
- }
-
- function isIndexed(maybeIndexed) {
- return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
- }
-
- function isAssociative(maybeAssociative) {
- return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
- }
-
- function isOrdered(maybeOrdered) {
- return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
- }
-
- Iterable.isIterable = isIterable;
- Iterable.isKeyed = isKeyed;
- Iterable.isIndexed = isIndexed;
- Iterable.isAssociative = isAssociative;
- Iterable.isOrdered = isOrdered;
-
- Iterable.Keyed = KeyedIterable;
- Iterable.Indexed = IndexedIterable;
- Iterable.Set = SetIterable;
-
-
- var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
- var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
- var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
- var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
-
- // Used for setting prototype methods that IE8 chokes on.
- var DELETE = 'delete';
-
- // Constants describing the size of trie nodes.
- var SHIFT = 5; // Resulted in best performance after ______?
- var SIZE = 1 << SHIFT;
- var MASK = SIZE - 1;
-
- // A consistent shared value representing "not set" which equals nothing other
- // than itself, and nothing that could be provided externally.
- var NOT_SET = {};
-
- // Boolean references, Rough equivalent of `bool &`.
- var CHANGE_LENGTH = { value: false };
- var DID_ALTER = { value: false };
-
- function MakeRef(ref) {
- ref.value = false;
- return ref;
- }
-
- function SetRef(ref) {
- ref && (ref.value = true);
- }
-
- // A function which returns a value representing an "owner" for transient writes
- // to tries. The return value will only ever equal itself, and will not equal
- // the return of any subsequent call of this function.
- function OwnerID() {}
-
- // http://jsperf.com/copy-array-inline
- function arrCopy(arr, offset) {
- offset = offset || 0;
- var len = Math.max(0, arr.length - offset);
- var newArr = new Array(len);
- for (var ii = 0; ii < len; ii++) {
- newArr[ii] = arr[ii + offset];
- }
- return newArr;
- }
-
- function ensureSize(iter) {
- if (iter.size === undefined) {
- iter.size = iter.__iterate(returnTrue);
- }
- return iter.size;
- }
-
- function wrapIndex(iter, index) {
- // This implements "is array index" which the ECMAString spec defines as:
- //
- // A String property name P is an array index if and only if
- // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
- // to 2^32−1.
- //
- // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
- if (typeof index !== 'number') {
- var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
- if ('' + uint32Index !== index || uint32Index === 4294967295) {
- return NaN;
- }
- index = uint32Index;
- }
- return index < 0 ? ensureSize(iter) + index : index;
- }
-
- function returnTrue() {
- return true;
- }
-
- function wholeSlice(begin, end, size) {
- return (begin === 0 || (size !== undefined && begin <= -size)) &&
- (end === undefined || (size !== undefined && end >= size));
- }
-
- function resolveBegin(begin, size) {
- return resolveIndex(begin, size, 0);
- }
-
- function resolveEnd(end, size) {
- return resolveIndex(end, size, size);
- }
-
- function resolveIndex(index, size, defaultIndex) {
- return index === undefined ?
- defaultIndex :
- index < 0 ?
- Math.max(0, size + index) :
- size === undefined ?
- index :
- Math.min(size, index);
- }
-
- /* global Symbol */
-
- var ITERATE_KEYS = 0;
- var ITERATE_VALUES = 1;
- var ITERATE_ENTRIES = 2;
-
- var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
- var FAUX_ITERATOR_SYMBOL = '@@iterator';
-
- var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
-
-
- function Iterator(next) {
- this.next = next;
- }
-
- Iterator.prototype.toString = function() {
- return '[Iterator]';
- };
-
-
- Iterator.KEYS = ITERATE_KEYS;
- Iterator.VALUES = ITERATE_VALUES;
- Iterator.ENTRIES = ITERATE_ENTRIES;
-
- Iterator.prototype.inspect =
- Iterator.prototype.toSource = function () { return this.toString(); };
- Iterator.prototype[ITERATOR_SYMBOL] = function () {
- return this;
- };
-
-
- function iteratorValue(type, k, v, iteratorResult) {
- var value = type === 0 ? k : type === 1 ? v : [k, v];
- iteratorResult ? (iteratorResult.value = value) : (iteratorResult = {
- value: value, done: false
- });
- return iteratorResult;
- }
-
- function iteratorDone() {
- return { value: undefined, done: true };
- }
-
- function hasIterator(maybeIterable) {
- return !!getIteratorFn(maybeIterable);
- }
-
- function isIterator(maybeIterator) {
- return maybeIterator && typeof maybeIterator.next === 'function';
- }
-
- function getIterator(iterable) {
- var iteratorFn = getIteratorFn(iterable);
- return iteratorFn && iteratorFn.call(iterable);
- }
-
- function getIteratorFn(iterable) {
- var iteratorFn = iterable && (
- (REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
- iterable[FAUX_ITERATOR_SYMBOL]
- );
- if (typeof iteratorFn === 'function') {
- return iteratorFn;
- }
- }
-
- function isArrayLike(value) {
- return value && typeof value.length === 'number';
- }
-
- createClass(Seq, Iterable);
- function Seq(value) {
- return value === null || value === undefined ? emptySequence() :
- isIterable(value) ? value.toSeq() : seqFromValue(value);
- }
-
- Seq.of = function(/*...values*/) {
- return Seq(arguments);
- };
-
- Seq.prototype.toSeq = function() {
- return this;
- };
-
- Seq.prototype.toString = function() {
- return this.__toString('Seq {', '}');
- };
-
- Seq.prototype.cacheResult = function() {
- if (!this._cache && this.__iterateUncached) {
- this._cache = this.entrySeq().toArray();
- this.size = this._cache.length;
- }
- return this;
- };
-
- // abstract __iterateUncached(fn, reverse)
-
- Seq.prototype.__iterate = function(fn, reverse) {
- return seqIterate(this, fn, reverse, true);
- };
-
- // abstract __iteratorUncached(type, reverse)
-
- Seq.prototype.__iterator = function(type, reverse) {
- return seqIterator(this, type, reverse, true);
- };
-
-
-
- createClass(KeyedSeq, Seq);
- function KeyedSeq(value) {
- return value === null || value === undefined ?
- emptySequence().toKeyedSeq() :
- isIterable(value) ?
- (isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) :
- keyedSeqFromValue(value);
- }
-
- KeyedSeq.prototype.toKeyedSeq = function() {
- return this;
- };
-
-
-
- createClass(IndexedSeq, Seq);
- function IndexedSeq(value) {
- return value === null || value === undefined ? emptySequence() :
- !isIterable(value) ? indexedSeqFromValue(value) :
- isKeyed(value) ? value.entrySeq() : value.toIndexedSeq();
- }
-
- IndexedSeq.of = function(/*...values*/) {
- return IndexedSeq(arguments);
- };
-
- IndexedSeq.prototype.toIndexedSeq = function() {
- return this;
- };
-
- IndexedSeq.prototype.toString = function() {
- return this.__toString('Seq [', ']');
- };
-
- IndexedSeq.prototype.__iterate = function(fn, reverse) {
- return seqIterate(this, fn, reverse, false);
- };
-
- IndexedSeq.prototype.__iterator = function(type, reverse) {
- return seqIterator(this, type, reverse, false);
- };
-
-
-
- createClass(SetSeq, Seq);
- function SetSeq(value) {
- return (
- value === null || value === undefined ? emptySequence() :
- !isIterable(value) ? indexedSeqFromValue(value) :
- isKeyed(value) ? value.entrySeq() : value
- ).toSetSeq();
- }
-
- SetSeq.of = function(/*...values*/) {
- return SetSeq(arguments);
- };
-
- SetSeq.prototype.toSetSeq = function() {
- return this;
- };
-
-
-
- Seq.isSeq = isSeq;
- Seq.Keyed = KeyedSeq;
- Seq.Set = SetSeq;
- Seq.Indexed = IndexedSeq;
-
- var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
-
- Seq.prototype[IS_SEQ_SENTINEL] = true;
-
-
-
- createClass(ArraySeq, IndexedSeq);
- function ArraySeq(array) {
- this._array = array;
- this.size = array.length;
- }
-
- ArraySeq.prototype.get = function(index, notSetValue) {
- return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
- };
-
- ArraySeq.prototype.__iterate = function(fn, reverse) {
- var array = this._array;
- var maxIndex = array.length - 1;
- for (var ii = 0; ii <= maxIndex; ii++) {
- if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
- return ii + 1;
- }
- }
- return ii;
- };
-
- ArraySeq.prototype.__iterator = function(type, reverse) {
- var array = this._array;
- var maxIndex = array.length - 1;
- var ii = 0;
- return new Iterator(function()
- {return ii > maxIndex ?
- iteratorDone() :
- iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])}
- );
- };
-
-
-
- createClass(ObjectSeq, KeyedSeq);
- function ObjectSeq(object) {
- var keys = Object.keys(object);
- this._object = object;
- this._keys = keys;
- this.size = keys.length;
- }
-
- ObjectSeq.prototype.get = function(key, notSetValue) {
- if (notSetValue !== undefined && !this.has(key)) {
- return notSetValue;
- }
- return this._object[key];
- };
-
- ObjectSeq.prototype.has = function(key) {
- return this._object.hasOwnProperty(key);
- };
-
- ObjectSeq.prototype.__iterate = function(fn, reverse) {
- var object = this._object;
- var keys = this._keys;
- var maxIndex = keys.length - 1;
- for (var ii = 0; ii <= maxIndex; ii++) {
- var key = keys[reverse ? maxIndex - ii : ii];
- if (fn(object[key], key, this) === false) {
- return ii + 1;
- }
- }
- return ii;
- };
-
- ObjectSeq.prototype.__iterator = function(type, reverse) {
- var object = this._object;
- var keys = this._keys;
- var maxIndex = keys.length - 1;
- var ii = 0;
- return new Iterator(function() {
- var key = keys[reverse ? maxIndex - ii : ii];
- return ii++ > maxIndex ?
- iteratorDone() :
- iteratorValue(type, key, object[key]);
- });
- };
-
- ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
-
-
- createClass(IterableSeq, IndexedSeq);
- function IterableSeq(iterable) {
- this._iterable = iterable;
- this.size = iterable.length || iterable.size;
- }
-
- IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
- if (reverse) {
- return this.cacheResult().__iterate(fn, reverse);
- }
- var iterable = this._iterable;
- var iterator = getIterator(iterable);
- var iterations = 0;
- if (isIterator(iterator)) {
- var step;
- while (!(step = iterator.next()).done) {
- if (fn(step.value, iterations++, this) === false) {
- break;
- }
- }
- }
- return iterations;
- };
-
- IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
- if (reverse) {
- return this.cacheResult().__iterator(type, reverse);
- }
- var iterable = this._iterable;
- var iterator = getIterator(iterable);
- if (!isIterator(iterator)) {
- return new Iterator(iteratorDone);
- }
- var iterations = 0;
- return new Iterator(function() {
- var step = iterator.next();
- return step.done ? step : iteratorValue(type, iterations++, step.value);
- });
- };
-
-
-
- createClass(IteratorSeq, IndexedSeq);
- function IteratorSeq(iterator) {
- this._iterator = iterator;
- this._iteratorCache = [];
- }
-
- IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
- if (reverse) {
- return this.cacheResult().__iterate(fn, reverse);
- }
- var iterator = this._iterator;
- var cache = this._iteratorCache;
- var iterations = 0;
- while (iterations < cache.length) {
- if (fn(cache[iterations], iterations++, this) === false) {
- return iterations;
- }
- }
- var step;
- while (!(step = iterator.next()).done) {
- var val = step.value;
- cache[iterations] = val;
- if (fn(val, iterations++, this) === false) {
- break;
- }
- }
- return iterations;
- };
-
- IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
- if (reverse) {
- return this.cacheResult().__iterator(type, reverse);
- }
- var iterator = this._iterator;
- var cache = this._iteratorCache;
- var iterations = 0;
- return new Iterator(function() {
- if (iterations >= cache.length) {
- var step = iterator.next();
- if (step.done) {
- return step;
- }
- cache[iterations] = step.value;
- }
- return iteratorValue(type, iterations, cache[iterations++]);
- });
- };
-
-
-
-
- // # pragma Helper functions
-
- function isSeq(maybeSeq) {
- return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
- }
-
- var EMPTY_SEQ;
-
- function emptySequence() {
- return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
- }
-
- function keyedSeqFromValue(value) {
- var seq =
- Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() :
- isIterator(value) ? new IteratorSeq(value).fromEntrySeq() :
- hasIterator(value) ? new IterableSeq(value).fromEntrySeq() :
- typeof value === 'object' ? new ObjectSeq(value) :
- undefined;
- if (!seq) {
- throw new TypeError(
- 'Expected Array or iterable object of [k, v] entries, '+
- 'or keyed object: ' + value
- );
- }
- return seq;
- }
-
- function indexedSeqFromValue(value) {
- var seq = maybeIndexedSeqFromValue(value);
- if (!seq) {
- throw new TypeError(
- 'Expected Array or iterable object of values: ' + value
- );
- }
- return seq;
- }
-
- function seqFromValue(value) {
- var seq = maybeIndexedSeqFromValue(value) ||
- (typeof value === 'object' && new ObjectSeq(value));
- if (!seq) {
- throw new TypeError(
- 'Expected Array or iterable object of values, or keyed object: ' + value
- );
- }
- return seq;
- }
-
- function maybeIndexedSeqFromValue(value) {
- return (
- isArrayLike(value) ? new ArraySeq(value) :
- isIterator(value) ? new IteratorSeq(value) :
- hasIterator(value) ? new IterableSeq(value) :
- undefined
- );
- }
-
- function seqIterate(seq, fn, reverse, useKeys) {
- var cache = seq._cache;
- if (cache) {
- var maxIndex = cache.length - 1;
- for (var ii = 0; ii <= maxIndex; ii++) {
- var entry = cache[reverse ? maxIndex - ii : ii];
- if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
- return ii + 1;
- }
- }
- return ii;
- }
- return seq.__iterateUncached(fn, reverse);
- }
-
- function seqIterator(seq, type, reverse, useKeys) {
- var cache = seq._cache;
- if (cache) {
- var maxIndex = cache.length - 1;
- var ii = 0;
- return new Iterator(function() {
- var entry = cache[reverse ? maxIndex - ii : ii];
- return ii++ > maxIndex ?
- iteratorDone() :
- iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
- });
- }
- return seq.__iteratorUncached(type, reverse);
- }
-
- function fromJS(json, converter) {
- return converter ?
- fromJSWith(converter, json, '', {'': json}) :
- fromJSDefault(json);
- }
-
- function fromJSWith(converter, json, key, parentJSON) {
- if (Array.isArray(json)) {
- return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
- }
- if (isPlainObj(json)) {
- return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
- }
- return json;
- }
-
- function fromJSDefault(json) {
- if (Array.isArray(json)) {
- return IndexedSeq(json).map(fromJSDefault).toList();
- }
- if (isPlainObj(json)) {
- return KeyedSeq(json).map(fromJSDefault).toMap();
- }
- return json;
- }
-
- function isPlainObj(value) {
- return value && (value.constructor === Object || value.constructor === undefined);
- }
-
- /**
- * An extension of the "same-value" algorithm as [described for use by ES6 Map
- * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
- *
- * NaN is considered the same as NaN, however -0 and 0 are considered the same
- * value, which is different from the algorithm described by
- * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
- *
- * This is extended further to allow Objects to describe the values they
- * represent, by way of `valueOf` or `equals` (and `hashCode`).
- *
- * Note: because of this extension, the key equality of Immutable.Map and the
- * value equality of Immutable.Set will differ from ES6 Map and Set.
- *
- * ### Defining custom values
- *
- * The easiest way to describe the value an object represents is by implementing
- * `valueOf`. For example, `Date` represents a value by returning a unix
- * timestamp for `valueOf`:
- *
- * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
- * var date2 = new Date(1234567890000);
- * date1.valueOf(); // 1234567890000
- * assert( date1 !== date2 );
- * assert( Immutable.is( date1, date2 ) );
- *
- * Note: overriding `valueOf` may have other implications if you use this object
- * where JavaScript expects a primitive, such as implicit string coercion.
- *
- * For more complex types, especially collections, implementing `valueOf` may
- * not be performant. An alternative is to implement `equals` and `hashCode`.
- *
- * `equals` takes another object, presumably of similar type, and returns true
- * if the it is equal. Equality is symmetrical, so the same result should be
- * returned if this and the argument are flipped.
- *
- * assert( a.equals(b) === b.equals(a) );
- *
- * `hashCode` returns a 32bit integer number representing the object which will
- * be used to determine how to store the value object in a Map or Set. You must
- * provide both or neither methods, one must not exist without the other.
- *
- * Also, an important relationship between these methods must be upheld: if two
- * values are equal, they *must* return the same hashCode. If the values are not
- * equal, they might have the same hashCode; this is called a hash collision,
- * and while undesirable for performance reasons, it is acceptable.
- *
- * if (a.equals(b)) {
- * assert( a.hashCode() === b.hashCode() );
- * }
- *
- * All Immutable collections implement `equals` and `hashCode`.
- *
- */
- function is(valueA, valueB) {
- if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
- return true;
- }
- if (!valueA || !valueB) {
- return false;
- }
- if (typeof valueA.valueOf === 'function' &&
- typeof valueB.valueOf === 'function') {
- valueA = valueA.valueOf();
- valueB = valueB.valueOf();
- if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
- return true;
- }
- if (!valueA || !valueB) {
- return false;
- }
- }
- if (typeof valueA.equals === 'function' &&
- typeof valueB.equals === 'function' &&
- valueA.equals(valueB)) {
- return true;
- }
- return false;
- }
-
- function deepEqual(a, b) {
- if (a === b) {
- return true;
- }
-
- if (
- !isIterable(b) ||
- a.size !== undefined && b.size !== undefined && a.size !== b.size ||
- a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash ||
- isKeyed(a) !== isKeyed(b) ||
- isIndexed(a) !== isIndexed(b) ||
- isOrdered(a) !== isOrdered(b)
- ) {
- return false;
- }
-
- if (a.size === 0 && b.size === 0) {
- return true;
- }
-
- var notAssociative = !isAssociative(a);
-
- if (isOrdered(a)) {
- var entries = a.entries();
- return b.every(function(v, k) {
- var entry = entries.next().value;
- return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
- }) && entries.next().done;
- }
-
- var flipped = false;
-
- if (a.size === undefined) {
- if (b.size === undefined) {
- if (typeof a.cacheResult === 'function') {
- a.cacheResult();
- }
- } else {
- flipped = true;
- var _ = a;
- a = b;
- b = _;
- }
- }
-
- var allEqual = true;
- var bSize = b.__iterate(function(v, k) {
- if (notAssociative ? !a.has(v) :
- flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) {
- allEqual = false;
- return false;
- }
- });
-
- return allEqual && a.size === bSize;
- }
-
- createClass(Repeat, IndexedSeq);
-
- function Repeat(value, times) {
- if (!(this instanceof Repeat)) {
- return new Repeat(value, times);
- }
- this._value = value;
- this.size = times === undefined ? Infinity : Math.max(0, times);
- if (this.size === 0) {
- if (EMPTY_REPEAT) {
- return EMPTY_REPEAT;
- }
- EMPTY_REPEAT = this;
- }
- }
-
- Repeat.prototype.toString = function() {
- if (this.size === 0) {
- return 'Repeat []';
- }
- return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
- };
-
- Repeat.prototype.get = function(index, notSetValue) {
- return this.has(index) ? this._value : notSetValue;
- };
-
- Repeat.prototype.includes = function(searchValue) {
- return is(this._value, searchValue);
- };
-
- Repeat.prototype.slice = function(begin, end) {
- var size = this.size;
- return wholeSlice(begin, end, size) ? this :
- new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size));
- };
-
- Repeat.prototype.reverse = function() {
- return this;
- };
-
- Repeat.prototype.indexOf = function(searchValue) {
- if (is(this._value, searchValue)) {
- return 0;
- }
- return -1;
- };
-
- Repeat.prototype.lastIndexOf = function(searchValue) {
- if (is(this._value, searchValue)) {
- return this.size;
- }
- return -1;
- };
-
- Repeat.prototype.__iterate = function(fn, reverse) {
- for (var ii = 0; ii < this.size; ii++) {
- if (fn(this._value, ii, this) === false) {
- return ii + 1;
- }
- }
- return ii;
- };
-
- Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this;
- var ii = 0;
- return new Iterator(function()
- {return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()}
- );
- };
-
- Repeat.prototype.equals = function(other) {
- return other instanceof Repeat ?
- is(this._value, other._value) :
- deepEqual(other);
- };
-
-
- var EMPTY_REPEAT;
-
- function invariant(condition, error) {
- if (!condition) throw new Error(error);
- }
-
- createClass(Range, IndexedSeq);
-
- function Range(start, end, step) {
- if (!(this instanceof Range)) {
- return new Range(start, end, step);
- }
- invariant(step !== 0, 'Cannot step a Range by 0');
- start = start || 0;
- if (end === undefined) {
- end = Infinity;
- }
- step = step === undefined ? 1 : Math.abs(step);
- if (end < start) {
- step = -step;
- }
- this._start = start;
- this._end = end;
- this._step = step;
- this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
- if (this.size === 0) {
- if (EMPTY_RANGE) {
- return EMPTY_RANGE;
- }
- EMPTY_RANGE = this;
- }
- }
-
- Range.prototype.toString = function() {
- if (this.size === 0) {
- return 'Range []';
- }
- return 'Range [ ' +
- this._start + '...' + this._end +
- (this._step > 1 ? ' by ' + this._step : '') +
- ' ]';
- };
-
- Range.prototype.get = function(index, notSetValue) {
- return this.has(index) ?
- this._start + wrapIndex(this, index) * this._step :
- notSetValue;
- };
-
- Range.prototype.includes = function(searchValue) {
- var possibleIndex = (searchValue - this._start) / this._step;
- return possibleIndex >= 0 &&
- possibleIndex < this.size &&
- possibleIndex === Math.floor(possibleIndex);
- };
-
- Range.prototype.slice = function(begin, end) {
- if (wholeSlice(begin, end, this.size)) {
- return this;
- }
- begin = resolveBegin(begin, this.size);
- end = resolveEnd(end, this.size);
- if (end <= begin) {
- return new Range(0, 0);
- }
- return new Range(this.get(begin, this._end), this.get(end, this._end), this._step);
- };
-
- Range.prototype.indexOf = function(searchValue) {
- var offsetValue = searchValue - this._start;
- if (offsetValue % this._step === 0) {
- var index = offsetValue / this._step;
- if (index >= 0 && index < this.size) {
- return index
- }
- }
- return -1;
- };
-
- Range.prototype.lastIndexOf = function(searchValue) {
- return this.indexOf(searchValue);
- };
-
- Range.prototype.__iterate = function(fn, reverse) {
- var maxIndex = this.size - 1;
- var step = this._step;
- var value = reverse ? this._start + maxIndex * step : this._start;
- for (var ii = 0; ii <= maxIndex; ii++) {
- if (fn(value, ii, this) === false) {
- return ii + 1;
- }
- value += reverse ? -step : step;
- }
- return ii;
- };
-
- Range.prototype.__iterator = function(type, reverse) {
- var maxIndex = this.size - 1;
- var step = this._step;
- var value = reverse ? this._start + maxIndex * step : this._start;
- var ii = 0;
- return new Iterator(function() {
- var v = value;
- value += reverse ? -step : step;
- return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
- });
- };
-
- Range.prototype.equals = function(other) {
- return other instanceof Range ?
- this._start === other._start &&
- this._end === other._end &&
- this._step === other._step :
- deepEqual(this, other);
- };
-
-
- var EMPTY_RANGE;
-
- createClass(Collection, Iterable);
- function Collection() {
- throw TypeError('Abstract');
- }
-
-
- createClass(KeyedCollection, Collection);function KeyedCollection() {}
-
- createClass(IndexedCollection, Collection);function IndexedCollection() {}
-
- createClass(SetCollection, Collection);function SetCollection() {}
-
-
- Collection.Keyed = KeyedCollection;
- Collection.Indexed = IndexedCollection;
- Collection.Set = SetCollection;
-
- var imul =
- typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ?
- Math.imul :
- function imul(a, b) {
- a = a | 0; // int
- b = b | 0; // int
- var c = a & 0xffff;
- var d = b & 0xffff;
- // Shift by 0 fixes the sign on the high part.
- return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int
- };
-
- // v8 has an optimization for storing 31-bit signed numbers.
- // Values which have either 00 or 11 as the high order bits qualify.
- // This function drops the highest order bit in a signed number, maintaining
- // the sign bit.
- function smi(i32) {
- return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF);
- }
-
- function hash(o) {
- if (o === false || o === null || o === undefined) {
- return 0;
- }
- if (typeof o.valueOf === 'function') {
- o = o.valueOf();
- if (o === false || o === null || o === undefined) {
- return 0;
- }
- }
- if (o === true) {
- return 1;
- }
- var type = typeof o;
- if (type === 'number') {
- var h = o | 0;
- if (h !== o) {
- h ^= o * 0xFFFFFFFF;
- }
- while (o > 0xFFFFFFFF) {
- o /= 0xFFFFFFFF;
- h ^= o;
- }
- return smi(h);
- }
- if (type === 'string') {
- return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o);
- }
- if (typeof o.hashCode === 'function') {
- return o.hashCode();
- }
- if (type === 'object') {
- return hashJSObj(o);
- }
- if (typeof o.toString === 'function') {
- return hashString(o.toString());
- }
- throw new Error('Value type ' + type + ' cannot be hashed.');
- }
-
- function cachedHashString(string) {
- var hash = stringHashCache[string];
- if (hash === undefined) {
- hash = hashString(string);
- if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
- STRING_HASH_CACHE_SIZE = 0;
- stringHashCache = {};
- }
- STRING_HASH_CACHE_SIZE++;
- stringHashCache[string] = hash;
- }
- return hash;
- }
-
- // http://jsperf.com/hashing-strings
- function hashString(string) {
- // This is the hash from JVM
- // The hash code for a string is computed as
- // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
- // where s[i] is the ith character of the string and n is the length of
- // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
- // (exclusive) by dropping high bits.
- var hash = 0;
- for (var ii = 0; ii < string.length; ii++) {
- hash = 31 * hash + string.charCodeAt(ii) | 0;
- }
- return smi(hash);
- }
-
- function hashJSObj(obj) {
- var hash;
- if (usingWeakMap) {
- hash = weakMap.get(obj);
- if (hash !== undefined) {
- return hash;
- }
- }
-
- hash = obj[UID_HASH_KEY];
- if (hash !== undefined) {
- return hash;
- }
-
- if (!canDefineProperty) {
- hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
- if (hash !== undefined) {
- return hash;
- }
-
- hash = getIENodeHash(obj);
- if (hash !== undefined) {
- return hash;
- }
- }
-
- hash = ++objHashUID;
- if (objHashUID & 0x40000000) {
- objHashUID = 0;
- }
-
- if (usingWeakMap) {
- weakMap.set(obj, hash);
- } else if (isExtensible !== undefined && isExtensible(obj) === false) {
- throw new Error('Non-extensible objects are not allowed as keys.');
- } else if (canDefineProperty) {
- Object.defineProperty(obj, UID_HASH_KEY, {
- 'enumerable': false,
- 'configurable': false,
- 'writable': false,
- 'value': hash
- });
- } else if (obj.propertyIsEnumerable !== undefined &&
- obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {
- // Since we can't define a non-enumerable property on the object
- // we'll hijack one of the less-used non-enumerable properties to
- // save our hash on it. Since this is a function it will not show up in
- // `JSON.stringify` which is what we want.
- obj.propertyIsEnumerable = function() {
- return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
- };
- obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
- } else if (obj.nodeType !== undefined) {
- // At this point we couldn't get the IE `uniqueID` to use as a hash
- // and we couldn't use a non-enumerable property to exploit the
- // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
- // itself.
- obj[UID_HASH_KEY] = hash;
- } else {
- throw new Error('Unable to set a non-enumerable property on object.');
- }
-
- return hash;
- }
-
- // Get references to ES5 object methods.
- var isExtensible = Object.isExtensible;
-
- // True if Object.defineProperty works as expected. IE8 fails this test.
- var canDefineProperty = (function() {
- try {
- Object.defineProperty({}, '@', {});
- return true;
- } catch (e) {
- return false;
- }
- }());
-
- // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
- // and avoid memory leaks from the IE cloneNode bug.
- function getIENodeHash(node) {
- if (node && node.nodeType > 0) {
- switch (node.nodeType) {
- case 1: // Element
- return node.uniqueID;
- case 9: // Document
- return node.documentElement && node.documentElement.uniqueID;
- }
- }
- }
-
- // If possible, use a WeakMap.
- var usingWeakMap = typeof WeakMap === 'function';
- var weakMap;
- if (usingWeakMap) {
- weakMap = new WeakMap();
- }
-
- var objHashUID = 0;
-
- var UID_HASH_KEY = '__immutablehash__';
- if (typeof Symbol === 'function') {
- UID_HASH_KEY = Symbol(UID_HASH_KEY);
- }
-
- var STRING_HASH_CACHE_MIN_STRLEN = 16;
- var STRING_HASH_CACHE_MAX_SIZE = 255;
- var STRING_HASH_CACHE_SIZE = 0;
- var stringHashCache = {};
-
- function assertNotInfinite(size) {
- invariant(
- size !== Infinity,
- 'Cannot perform this action with an infinite size.'
- );
- }
-
- createClass(Map, KeyedCollection);
-
- // @pragma Construction
-
- function Map(value) {
- return value === null || value === undefined ? emptyMap() :
- isMap(value) && !isOrdered(value) ? value :
- emptyMap().withMutations(function(map ) {
- var iter = KeyedIterable(value);
- assertNotInfinite(iter.size);
- iter.forEach(function(v, k) {return map.set(k, v)});
- });
- }
-
- Map.prototype.toString = function() {
- return this.__toString('Map {', '}');
- };
-
- // @pragma Access
-
- Map.prototype.get = function(k, notSetValue) {
- return this._root ?
- this._root.get(0, undefined, k, notSetValue) :
- notSetValue;
- };
-
- // @pragma Modification
-
- Map.prototype.set = function(k, v) {
- return updateMap(this, k, v);
- };
-
- Map.prototype.setIn = function(keyPath, v) {
- return this.updateIn(keyPath, NOT_SET, function() {return v});
- };
-
- Map.prototype.remove = function(k) {
- return updateMap(this, k, NOT_SET);
- };
-
- Map.prototype.deleteIn = function(keyPath) {
- return this.updateIn(keyPath, function() {return NOT_SET});
- };
-
- Map.prototype.update = function(k, notSetValue, updater) {
- return arguments.length === 1 ?
- k(this) :
- this.updateIn([k], notSetValue, updater);
- };
-
- Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
- if (!updater) {
- updater = notSetValue;
- notSetValue = undefined;
- }
- var updatedValue = updateInDeepMap(
- this,
- forceIterator(keyPath),
- notSetValue,
- updater
- );
- return updatedValue === NOT_SET ? undefined : updatedValue;
- };
-
- Map.prototype.clear = function() {
- if (this.size === 0) {
- return this;
- }
- if (this.__ownerID) {
- this.size = 0;
- this._root = null;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return emptyMap();
- };
-
- // @pragma Composition
-
- Map.prototype.merge = function(/*...iters*/) {
- return mergeIntoMapWith(this, undefined, arguments);
- };
-
- Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
- return mergeIntoMapWith(this, merger, iters);
- };
-
- Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
- return this.updateIn(
- keyPath,
- emptyMap(),
- function(m ) {return typeof m.merge === 'function' ?
- m.merge.apply(m, iters) :
- iters[iters.length - 1]}
- );
- };
-
- Map.prototype.mergeDeep = function(/*...iters*/) {
- return mergeIntoMapWith(this, deepMerger, arguments);
- };
-
- Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
- return mergeIntoMapWith(this, deepMergerWith(merger), iters);
- };
-
- Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
- return this.updateIn(
- keyPath,
- emptyMap(),
- function(m ) {return typeof m.mergeDeep === 'function' ?
- m.mergeDeep.apply(m, iters) :
- iters[iters.length - 1]}
- );
- };
-
- Map.prototype.sort = function(comparator) {
- // Late binding
- return OrderedMap(sortFactory(this, comparator));
- };
-
- Map.prototype.sortBy = function(mapper, comparator) {
- // Late binding
- return OrderedMap(sortFactory(this, comparator, mapper));
- };
-
- // @pragma Mutability
-
- Map.prototype.withMutations = function(fn) {
- var mutable = this.asMutable();
- fn(mutable);
- return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
- };
-
- Map.prototype.asMutable = function() {
- return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
- };
-
- Map.prototype.asImmutable = function() {
- return this.__ensureOwner();
- };
-
- Map.prototype.wasAltered = function() {
- return this.__altered;
- };
-
- Map.prototype.__iterator = function(type, reverse) {
- return new MapIterator(this, type, reverse);
- };
-
- Map.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- var iterations = 0;
- this._root && this._root.iterate(function(entry ) {
- iterations++;
- return fn(entry[1], entry[0], this$0);
- }, reverse);
- return iterations;
- };
-
- Map.prototype.__ensureOwner = function(ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- if (!ownerID) {
- this.__ownerID = ownerID;
- this.__altered = false;
- return this;
- }
- return makeMap(this.size, this._root, ownerID, this.__hash);
- };
-
-
- function isMap(maybeMap) {
- return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
- }
-
- Map.isMap = isMap;
-
- var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
-
- var MapPrototype = Map.prototype;
- MapPrototype[IS_MAP_SENTINEL] = true;
- MapPrototype[DELETE] = MapPrototype.remove;
- MapPrototype.removeIn = MapPrototype.deleteIn;
-
-
- // #pragma Trie Nodes
-
-
-
- function ArrayMapNode(ownerID, entries) {
- this.ownerID = ownerID;
- this.entries = entries;
- }
-
- ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
- var entries = this.entries;
- for (var ii = 0, len = entries.length; ii < len; ii++) {
- if (is(key, entries[ii][0])) {
- return entries[ii][1];
- }
- }
- return notSetValue;
- };
-
- ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- var removed = value === NOT_SET;
-
- var entries = this.entries;
- var idx = 0;
- for (var len = entries.length; idx < len; idx++) {
- if (is(key, entries[idx][0])) {
- break;
- }
- }
- var exists = idx < len;
-
- if (exists ? entries[idx][1] === value : removed) {
- return this;
- }
-
- SetRef(didAlter);
- (removed || !exists) && SetRef(didChangeSize);
-
- if (removed && entries.length === 1) {
- return; // undefined
- }
-
- if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
- return createNodes(ownerID, entries, key, value);
- }
-
- var isEditable = ownerID && ownerID === this.ownerID;
- var newEntries = isEditable ? entries : arrCopy(entries);
-
- if (exists) {
- if (removed) {
- idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
- } else {
- newEntries[idx] = [key, value];
- }
- } else {
- newEntries.push([key, value]);
- }
-
- if (isEditable) {
- this.entries = newEntries;
- return this;
- }
-
- return new ArrayMapNode(ownerID, newEntries);
- };
-
-
-
-
- function BitmapIndexedNode(ownerID, bitmap, nodes) {
- this.ownerID = ownerID;
- this.bitmap = bitmap;
- this.nodes = nodes;
- }
-
- BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) {
- if (keyHash === undefined) {
- keyHash = hash(key);
- }
- var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK));
- var bitmap = this.bitmap;
- return (bitmap & bit) === 0 ? notSetValue :
- this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue);
- };
-
- BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- if (keyHash === undefined) {
- keyHash = hash(key);
- }
- var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
- var bit = 1 << keyHashFrag;
- var bitmap = this.bitmap;
- var exists = (bitmap & bit) !== 0;
-
- if (!exists && value === NOT_SET) {
- return this;
- }
-
- var idx = popCount(bitmap & (bit - 1));
- var nodes = this.nodes;
- var node = exists ? nodes[idx] : undefined;
- var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
-
- if (newNode === node) {
- return this;
- }
-
- if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
- return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
- }
-
- if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) {
- return nodes[idx ^ 1];
- }
-
- if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
- return newNode;
- }
-
- var isEditable = ownerID && ownerID === this.ownerID;
- var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit;
- var newNodes = exists ? newNode ?
- setIn(nodes, idx, newNode, isEditable) :
- spliceOut(nodes, idx, isEditable) :
- spliceIn(nodes, idx, newNode, isEditable);
-
- if (isEditable) {
- this.bitmap = newBitmap;
- this.nodes = newNodes;
- return this;
- }
-
- return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
- };
-
-
-
-
- function HashArrayMapNode(ownerID, count, nodes) {
- this.ownerID = ownerID;
- this.count = count;
- this.nodes = nodes;
- }
-
- HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
- if (keyHash === undefined) {
- keyHash = hash(key);
- }
- var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
- var node = this.nodes[idx];
- return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue;
- };
-
- HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- if (keyHash === undefined) {
- keyHash = hash(key);
- }
- var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
- var removed = value === NOT_SET;
- var nodes = this.nodes;
- var node = nodes[idx];
-
- if (removed && !node) {
- return this;
- }
-
- var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
- if (newNode === node) {
- return this;
- }
-
- var newCount = this.count;
- if (!node) {
- newCount++;
- } else if (!newNode) {
- newCount--;
- if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
- return packNodes(ownerID, nodes, newCount, idx);
- }
- }
-
- var isEditable = ownerID && ownerID === this.ownerID;
- var newNodes = setIn(nodes, idx, newNode, isEditable);
-
- if (isEditable) {
- this.count = newCount;
- this.nodes = newNodes;
- return this;
- }
-
- return new HashArrayMapNode(ownerID, newCount, newNodes);
- };
-
-
-
-
- function HashCollisionNode(ownerID, keyHash, entries) {
- this.ownerID = ownerID;
- this.keyHash = keyHash;
- this.entries = entries;
- }
-
- HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) {
- var entries = this.entries;
- for (var ii = 0, len = entries.length; ii < len; ii++) {
- if (is(key, entries[ii][0])) {
- return entries[ii][1];
- }
- }
- return notSetValue;
- };
-
- HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- if (keyHash === undefined) {
- keyHash = hash(key);
- }
-
- var removed = value === NOT_SET;
-
- if (keyHash !== this.keyHash) {
- if (removed) {
- return this;
- }
- SetRef(didAlter);
- SetRef(didChangeSize);
- return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
- }
-
- var entries = this.entries;
- var idx = 0;
- for (var len = entries.length; idx < len; idx++) {
- if (is(key, entries[idx][0])) {
- break;
- }
- }
- var exists = idx < len;
-
- if (exists ? entries[idx][1] === value : removed) {
- return this;
- }
-
- SetRef(didAlter);
- (removed || !exists) && SetRef(didChangeSize);
-
- if (removed && len === 2) {
- return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
- }
-
- var isEditable = ownerID && ownerID === this.ownerID;
- var newEntries = isEditable ? entries : arrCopy(entries);
-
- if (exists) {
- if (removed) {
- idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
- } else {
- newEntries[idx] = [key, value];
- }
- } else {
- newEntries.push([key, value]);
- }
-
- if (isEditable) {
- this.entries = newEntries;
- return this;
- }
-
- return new HashCollisionNode(ownerID, this.keyHash, newEntries);
- };
-
-
-
-
- function ValueNode(ownerID, keyHash, entry) {
- this.ownerID = ownerID;
- this.keyHash = keyHash;
- this.entry = entry;
- }
-
- ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
- return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
- };
-
- ValueNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- var removed = value === NOT_SET;
- var keyMatch = is(key, this.entry[0]);
- if (keyMatch ? value === this.entry[1] : removed) {
- return this;
- }
-
- SetRef(didAlter);
-
- if (removed) {
- SetRef(didChangeSize);
- return; // undefined
- }
-
- if (keyMatch) {
- if (ownerID && ownerID === this.ownerID) {
- this.entry[1] = value;
- return this;
- }
- return new ValueNode(ownerID, this.keyHash, [key, value]);
- }
-
- SetRef(didChangeSize);
- return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
- };
-
-
-
- // #pragma Iterators
-
- ArrayMapNode.prototype.iterate =
- HashCollisionNode.prototype.iterate = function (fn, reverse) {
- var entries = this.entries;
- for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
- if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
- return false;
- }
- }
- };
-
- BitmapIndexedNode.prototype.iterate =
- HashArrayMapNode.prototype.iterate = function (fn, reverse) {
- var nodes = this.nodes;
- for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
- var node = nodes[reverse ? maxIndex - ii : ii];
- if (node && node.iterate(fn, reverse) === false) {
- return false;
- }
- }
- };
-
- ValueNode.prototype.iterate = function (fn, reverse) {
- return fn(this.entry);
- };
-
- createClass(MapIterator, Iterator);
-
- function MapIterator(map, type, reverse) {
- this._type = type;
- this._reverse = reverse;
- this._stack = map._root && mapIteratorFrame(map._root);
- }
-
- MapIterator.prototype.next = function() {
- var type = this._type;
- var stack = this._stack;
- while (stack) {
- var node = stack.node;
- var index = stack.index++;
- var maxIndex;
- if (node.entry) {
- if (index === 0) {
- return mapIteratorValue(type, node.entry);
- }
- } else if (node.entries) {
- maxIndex = node.entries.length - 1;
- if (index <= maxIndex) {
- return mapIteratorValue(type, node.entries[this._reverse ? maxIndex - index : index]);
- }
- } else {
- maxIndex = node.nodes.length - 1;
- if (index <= maxIndex) {
- var subNode = node.nodes[this._reverse ? maxIndex - index : index];
- if (subNode) {
- if (subNode.entry) {
- return mapIteratorValue(type, subNode.entry);
- }
- stack = this._stack = mapIteratorFrame(subNode, stack);
- }
- continue;
- }
- }
- stack = this._stack = this._stack.__prev;
- }
- return iteratorDone();
- };
-
-
- function mapIteratorValue(type, entry) {
- return iteratorValue(type, entry[0], entry[1]);
- }
-
- function mapIteratorFrame(node, prev) {
- return {
- node: node,
- index: 0,
- __prev: prev
- };
- }
-
- function makeMap(size, root, ownerID, hash) {
- var map = Object.create(MapPrototype);
- map.size = size;
- map._root = root;
- map.__ownerID = ownerID;
- map.__hash = hash;
- map.__altered = false;
- return map;
- }
-
- var EMPTY_MAP;
- function emptyMap() {
- return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
- }
-
- function updateMap(map, k, v) {
- var newRoot;
- var newSize;
- if (!map._root) {
- if (v === NOT_SET) {
- return map;
- }
- newSize = 1;
- newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
- } else {
- var didChangeSize = MakeRef(CHANGE_LENGTH);
- var didAlter = MakeRef(DID_ALTER);
- newRoot = updateNode(map._root, map.__ownerID, 0, undefined, k, v, didChangeSize, didAlter);
- if (!didAlter.value) {
- return map;
- }
- newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0);
- }
- if (map.__ownerID) {
- map.size = newSize;
- map._root = newRoot;
- map.__hash = undefined;
- map.__altered = true;
- return map;
- }
- return newRoot ? makeMap(newSize, newRoot) : emptyMap();
- }
-
- function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- if (!node) {
- if (value === NOT_SET) {
- return node;
- }
- SetRef(didAlter);
- SetRef(didChangeSize);
- return new ValueNode(ownerID, keyHash, [key, value]);
- }
- return node.update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter);
- }
-
- function isLeafNode(node) {
- return node.constructor === ValueNode || node.constructor === HashCollisionNode;
- }
-
- function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
- if (node.keyHash === keyHash) {
- return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
- }
-
- var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
- var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
-
- var newNode;
- var nodes = idx1 === idx2 ?
- [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] :
- ((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 ? [node, newNode] : [newNode, node]);
-
- return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
- }
-
- function createNodes(ownerID, entries, key, value) {
- if (!ownerID) {
- ownerID = new OwnerID();
- }
- var node = new ValueNode(ownerID, hash(key), [key, value]);
- for (var ii = 0; ii < entries.length; ii++) {
- var entry = entries[ii];
- node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
- }
- return node;
- }
-
- function packNodes(ownerID, nodes, count, excluding) {
- var bitmap = 0;
- var packedII = 0;
- var packedNodes = new Array(count);
- for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
- var node = nodes[ii];
- if (node !== undefined && ii !== excluding) {
- bitmap |= bit;
- packedNodes[packedII++] = node;
- }
- }
- return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
- }
-
- function expandNodes(ownerID, nodes, bitmap, including, node) {
- var count = 0;
- var expandedNodes = new Array(SIZE);
- for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
- expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
- }
- expandedNodes[including] = node;
- return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
- }
-
- function mergeIntoMapWith(map, merger, iterables) {
- var iters = [];
- for (var ii = 0; ii < iterables.length; ii++) {
- var value = iterables[ii];
- var iter = KeyedIterable(value);
- if (!isIterable(value)) {
- iter = iter.map(function(v ) {return fromJS(v)});
- }
- iters.push(iter);
- }
- return mergeIntoCollectionWith(map, merger, iters);
- }
-
- function deepMerger(existing, value, key) {
- return existing && existing.mergeDeep && isIterable(value) ?
- existing.mergeDeep(value) :
- is(existing, value) ? existing : value;
- }
-
- function deepMergerWith(merger) {
- return function(existing, value, key) {
- if (existing && existing.mergeDeepWith && isIterable(value)) {
- return existing.mergeDeepWith(merger, value);
- }
- var nextValue = merger(existing, value, key);
- return is(existing, nextValue) ? existing : nextValue;
- };
- }
-
- function mergeIntoCollectionWith(collection, merger, iters) {
- iters = iters.filter(function(x ) {return x.size !== 0});
- if (iters.length === 0) {
- return collection;
- }
- if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
- return collection.constructor(iters[0]);
- }
- return collection.withMutations(function(collection ) {
- var mergeIntoMap = merger ?
- function(value, key) {
- collection.update(key, NOT_SET, function(existing )
- {return existing === NOT_SET ? value : merger(existing, value, key)}
- );
- } :
- function(value, key) {
- collection.set(key, value);
- };
- for (var ii = 0; ii < iters.length; ii++) {
- iters[ii].forEach(mergeIntoMap);
- }
- });
- }
-
- function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
- var isNotSet = existing === NOT_SET;
- var step = keyPathIter.next();
- if (step.done) {
- var existingValue = isNotSet ? notSetValue : existing;
- var newValue = updater(existingValue);
- return newValue === existingValue ? existing : newValue;
- }
- invariant(
- isNotSet || (existing && existing.set),
- 'invalid keyPath'
- );
- var key = step.value;
- var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
- var nextUpdated = updateInDeepMap(
- nextExisting,
- keyPathIter,
- notSetValue,
- updater
- );
- return nextUpdated === nextExisting ? existing :
- nextUpdated === NOT_SET ? existing.remove(key) :
- (isNotSet ? emptyMap() : existing).set(key, nextUpdated);
- }
-
- function popCount(x) {
- x = x - ((x >> 1) & 0x55555555);
- x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
- x = (x + (x >> 4)) & 0x0f0f0f0f;
- x = x + (x >> 8);
- x = x + (x >> 16);
- return x & 0x7f;
- }
-
- function setIn(array, idx, val, canEdit) {
- var newArray = canEdit ? array : arrCopy(array);
- newArray[idx] = val;
- return newArray;
- }
-
- function spliceIn(array, idx, val, canEdit) {
- var newLen = array.length + 1;
- if (canEdit && idx + 1 === newLen) {
- array[idx] = val;
- return array;
- }
- var newArray = new Array(newLen);
- var after = 0;
- for (var ii = 0; ii < newLen; ii++) {
- if (ii === idx) {
- newArray[ii] = val;
- after = -1;
- } else {
- newArray[ii] = array[ii + after];
- }
- }
- return newArray;
- }
-
- function spliceOut(array, idx, canEdit) {
- var newLen = array.length - 1;
- if (canEdit && idx === newLen) {
- array.pop();
- return array;
- }
- var newArray = new Array(newLen);
- var after = 0;
- for (var ii = 0; ii < newLen; ii++) {
- if (ii === idx) {
- after = 1;
- }
- newArray[ii] = array[ii + after];
- }
- return newArray;
- }
-
- var MAX_ARRAY_MAP_SIZE = SIZE / 4;
- var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
- var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
-
- createClass(List, IndexedCollection);
-
- // @pragma Construction
-
- function List(value) {
- var empty = emptyList();
- if (value === null || value === undefined) {
- return empty;
- }
- if (isList(value)) {
- return value;
- }
- var iter = IndexedIterable(value);
- var size = iter.size;
- if (size === 0) {
- return empty;
- }
- assertNotInfinite(size);
- if (size > 0 && size < SIZE) {
- return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
- }
- return empty.withMutations(function(list ) {
- list.setSize(size);
- iter.forEach(function(v, i) {return list.set(i, v)});
- });
- }
-
- List.of = function(/*...values*/) {
- return this(arguments);
- };
-
- List.prototype.toString = function() {
- return this.__toString('List [', ']');
- };
-
- // @pragma Access
-
- List.prototype.get = function(index, notSetValue) {
- index = wrapIndex(this, index);
- if (index >= 0 && index < this.size) {
- index += this._origin;
- var node = listNodeFor(this, index);
- return node && node.array[index & MASK];
- }
- return notSetValue;
- };
-
- // @pragma Modification
-
- List.prototype.set = function(index, value) {
- return updateList(this, index, value);
- };
-
- List.prototype.remove = function(index) {
- return !this.has(index) ? this :
- index === 0 ? this.shift() :
- index === this.size - 1 ? this.pop() :
- this.splice(index, 1);
- };
-
- List.prototype.insert = function(index, value) {
- return this.splice(index, 0, value);
- };
-
- List.prototype.clear = function() {
- if (this.size === 0) {
- return this;
- }
- if (this.__ownerID) {
- this.size = this._origin = this._capacity = 0;
- this._level = SHIFT;
- this._root = this._tail = null;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return emptyList();
- };
-
- List.prototype.push = function(/*...values*/) {
- var values = arguments;
- var oldSize = this.size;
- return this.withMutations(function(list ) {
- setListBounds(list, 0, oldSize + values.length);
- for (var ii = 0; ii < values.length; ii++) {
- list.set(oldSize + ii, values[ii]);
- }
- });
- };
-
- List.prototype.pop = function() {
- return setListBounds(this, 0, -1);
- };
-
- List.prototype.unshift = function(/*...values*/) {
- var values = arguments;
- return this.withMutations(function(list ) {
- setListBounds(list, -values.length);
- for (var ii = 0; ii < values.length; ii++) {
- list.set(ii, values[ii]);
- }
- });
- };
-
- List.prototype.shift = function() {
- return setListBounds(this, 1);
- };
-
- // @pragma Composition
-
- List.prototype.merge = function(/*...iters*/) {
- return mergeIntoListWith(this, undefined, arguments);
- };
-
- List.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
- return mergeIntoListWith(this, merger, iters);
- };
-
- List.prototype.mergeDeep = function(/*...iters*/) {
- return mergeIntoListWith(this, deepMerger, arguments);
- };
-
- List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
- return mergeIntoListWith(this, deepMergerWith(merger), iters);
- };
-
- List.prototype.setSize = function(size) {
- return setListBounds(this, 0, size);
- };
-
- // @pragma Iteration
-
- List.prototype.slice = function(begin, end) {
- var size = this.size;
- if (wholeSlice(begin, end, size)) {
- return this;
- }
- return setListBounds(
- this,
- resolveBegin(begin, size),
- resolveEnd(end, size)
- );
- };
-
- List.prototype.__iterator = function(type, reverse) {
- var index = 0;
- var values = iterateList(this, reverse);
- return new Iterator(function() {
- var value = values();
- return value === DONE ?
- iteratorDone() :
- iteratorValue(type, index++, value);
- });
- };
-
- List.prototype.__iterate = function(fn, reverse) {
- var index = 0;
- var values = iterateList(this, reverse);
- var value;
- while ((value = values()) !== DONE) {
- if (fn(value, index++, this) === false) {
- break;
- }
- }
- return index;
- };
-
- List.prototype.__ensureOwner = function(ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- if (!ownerID) {
- this.__ownerID = ownerID;
- return this;
- }
- return makeList(this._origin, this._capacity, this._level, this._root, this._tail, ownerID, this.__hash);
- };
-
-
- function isList(maybeList) {
- return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
- }
-
- List.isList = isList;
-
- var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
-
- var ListPrototype = List.prototype;
- ListPrototype[IS_LIST_SENTINEL] = true;
- ListPrototype[DELETE] = ListPrototype.remove;
- ListPrototype.setIn = MapPrototype.setIn;
- ListPrototype.deleteIn =
- ListPrototype.removeIn = MapPrototype.removeIn;
- ListPrototype.update = MapPrototype.update;
- ListPrototype.updateIn = MapPrototype.updateIn;
- ListPrototype.mergeIn = MapPrototype.mergeIn;
- ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
- ListPrototype.withMutations = MapPrototype.withMutations;
- ListPrototype.asMutable = MapPrototype.asMutable;
- ListPrototype.asImmutable = MapPrototype.asImmutable;
- ListPrototype.wasAltered = MapPrototype.wasAltered;
-
-
-
- function VNode(array, ownerID) {
- this.array = array;
- this.ownerID = ownerID;
- }
-
- // TODO: seems like these methods are very similar
-
- VNode.prototype.removeBefore = function(ownerID, level, index) {
- if (index === level ? 1 << level : this.array.length === 0) {
- return this;
- }
- var originIndex = (index >>> level) & MASK;
- if (originIndex >= this.array.length) {
- return new VNode([], ownerID);
- }
- var removingFirst = originIndex === 0;
- var newChild;
- if (level > 0) {
- var oldChild = this.array[originIndex];
- newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
- if (newChild === oldChild && removingFirst) {
- return this;
- }
- }
- if (removingFirst && !newChild) {
- return this;
- }
- var editable = editableVNode(this, ownerID);
- if (!removingFirst) {
- for (var ii = 0; ii < originIndex; ii++) {
- editable.array[ii] = undefined;
- }
- }
- if (newChild) {
- editable.array[originIndex] = newChild;
- }
- return editable;
- };
-
- VNode.prototype.removeAfter = function(ownerID, level, index) {
- if (index === (level ? 1 << level : 0) || this.array.length === 0) {
- return this;
- }
- var sizeIndex = ((index - 1) >>> level) & MASK;
- if (sizeIndex >= this.array.length) {
- return this;
- }
-
- var newChild;
- if (level > 0) {
- var oldChild = this.array[sizeIndex];
- newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
- if (newChild === oldChild && sizeIndex === this.array.length - 1) {
- return this;
- }
- }
-
- var editable = editableVNode(this, ownerID);
- editable.array.splice(sizeIndex + 1);
- if (newChild) {
- editable.array[sizeIndex] = newChild;
- }
- return editable;
- };
-
-
-
- var DONE = {};
-
- function iterateList(list, reverse) {
- var left = list._origin;
- var right = list._capacity;
- var tailPos = getTailOffset(right);
- var tail = list._tail;
-
- return iterateNodeOrLeaf(list._root, list._level, 0);
-
- function iterateNodeOrLeaf(node, level, offset) {
- return level === 0 ?
- iterateLeaf(node, offset) :
- iterateNode(node, level, offset);
- }
-
- function iterateLeaf(node, offset) {
- var array = offset === tailPos ? tail && tail.array : node && node.array;
- var from = offset > left ? 0 : left - offset;
- var to = right - offset;
- if (to > SIZE) {
- to = SIZE;
- }
- return function() {
- if (from === to) {
- return DONE;
- }
- var idx = reverse ? --to : from++;
- return array && array[idx];
- };
- }
-
- function iterateNode(node, level, offset) {
- var values;
- var array = node && node.array;
- var from = offset > left ? 0 : (left - offset) >> level;
- var to = ((right - offset) >> level) + 1;
- if (to > SIZE) {
- to = SIZE;
- }
- return function() {
- do {
- if (values) {
- var value = values();
- if (value !== DONE) {
- return value;
- }
- values = null;
- }
- if (from === to) {
- return DONE;
- }
- var idx = reverse ? --to : from++;
- values = iterateNodeOrLeaf(
- array && array[idx], level - SHIFT, offset + (idx << level)
- );
- } while (true);
- };
- }
- }
-
- function makeList(origin, capacity, level, root, tail, ownerID, hash) {
- var list = Object.create(ListPrototype);
- list.size = capacity - origin;
- list._origin = origin;
- list._capacity = capacity;
- list._level = level;
- list._root = root;
- list._tail = tail;
- list.__ownerID = ownerID;
- list.__hash = hash;
- list.__altered = false;
- return list;
- }
-
- var EMPTY_LIST;
- function emptyList() {
- return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
- }
-
- function updateList(list, index, value) {
- index = wrapIndex(list, index);
-
- if (index !== index) {
- return list;
- }
-
- if (index >= list.size || index < 0) {
- return list.withMutations(function(list ) {
- index < 0 ?
- setListBounds(list, index).set(0, value) :
- setListBounds(list, 0, index + 1).set(index, value);
- });
- }
-
- index += list._origin;
-
- var newTail = list._tail;
- var newRoot = list._root;
- var didAlter = MakeRef(DID_ALTER);
- if (index >= getTailOffset(list._capacity)) {
- newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
- } else {
- newRoot = updateVNode(newRoot, list.__ownerID, list._level, index, value, didAlter);
- }
-
- if (!didAlter.value) {
- return list;
- }
-
- if (list.__ownerID) {
- list._root = newRoot;
- list._tail = newTail;
- list.__hash = undefined;
- list.__altered = true;
- return list;
- }
- return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
- }
-
- function updateVNode(node, ownerID, level, index, value, didAlter) {
- var idx = (index >>> level) & MASK;
- var nodeHas = node && idx < node.array.length;
- if (!nodeHas && value === undefined) {
- return node;
- }
-
- var newNode;
-
- if (level > 0) {
- var lowerNode = node && node.array[idx];
- var newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter);
- if (newLowerNode === lowerNode) {
- return node;
- }
- newNode = editableVNode(node, ownerID);
- newNode.array[idx] = newLowerNode;
- return newNode;
- }
-
- if (nodeHas && node.array[idx] === value) {
- return node;
- }
-
- SetRef(didAlter);
-
- newNode = editableVNode(node, ownerID);
- if (value === undefined && idx === newNode.array.length - 1) {
- newNode.array.pop();
- } else {
- newNode.array[idx] = value;
- }
- return newNode;
- }
-
- function editableVNode(node, ownerID) {
- if (ownerID && node && ownerID === node.ownerID) {
- return node;
- }
- return new VNode(node ? node.array.slice() : [], ownerID);
- }
-
- function listNodeFor(list, rawIndex) {
- if (rawIndex >= getTailOffset(list._capacity)) {
- return list._tail;
- }
- if (rawIndex < 1 << (list._level + SHIFT)) {
- var node = list._root;
- var level = list._level;
- while (node && level > 0) {
- node = node.array[(rawIndex >>> level) & MASK];
- level -= SHIFT;
- }
- return node;
- }
- }
-
- function setListBounds(list, begin, end) {
- // Sanitize begin & end using this shorthand for ToInt32(argument)
- // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
- if (begin !== undefined) {
- begin = begin | 0;
- }
- if (end !== undefined) {
- end = end | 0;
- }
- var owner = list.__ownerID || new OwnerID();
- var oldOrigin = list._origin;
- var oldCapacity = list._capacity;
- var newOrigin = oldOrigin + begin;
- var newCapacity = end === undefined ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end;
- if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
- return list;
- }
-
- // If it's going to end after it starts, it's empty.
- if (newOrigin >= newCapacity) {
- return list.clear();
- }
-
- var newLevel = list._level;
- var newRoot = list._root;
-
- // New origin might need creating a higher root.
- var offsetShift = 0;
- while (newOrigin + offsetShift < 0) {
- newRoot = new VNode(newRoot && newRoot.array.length ? [undefined, newRoot] : [], owner);
- newLevel += SHIFT;
- offsetShift += 1 << newLevel;
- }
- if (offsetShift) {
- newOrigin += offsetShift;
- oldOrigin += offsetShift;
- newCapacity += offsetShift;
- oldCapacity += offsetShift;
- }
-
- var oldTailOffset = getTailOffset(oldCapacity);
- var newTailOffset = getTailOffset(newCapacity);
-
- // New size might need creating a higher root.
- while (newTailOffset >= 1 << (newLevel + SHIFT)) {
- newRoot = new VNode(newRoot && newRoot.array.length ? [newRoot] : [], owner);
- newLevel += SHIFT;
- }
-
- // Locate or create the new tail.
- var oldTail = list._tail;
- var newTail = newTailOffset < oldTailOffset ?
- listNodeFor(list, newCapacity - 1) :
- newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
-
- // Merge Tail into tree.
- if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) {
- newRoot = editableVNode(newRoot, owner);
- var node = newRoot;
- for (var level = newLevel; level > SHIFT; level -= SHIFT) {
- var idx = (oldTailOffset >>> level) & MASK;
- node = node.array[idx] = editableVNode(node.array[idx], owner);
- }
- node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
- }
-
- // If the size has been reduced, there's a chance the tail needs to be trimmed.
- if (newCapacity < oldCapacity) {
- newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
- }
-
- // If the new origin is within the tail, then we do not need a root.
- if (newOrigin >= newTailOffset) {
- newOrigin -= newTailOffset;
- newCapacity -= newTailOffset;
- newLevel = SHIFT;
- newRoot = null;
- newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
-
- // Otherwise, if the root has been trimmed, garbage collect.
- } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
- offsetShift = 0;
-
- // Identify the new top root node of the subtree of the old root.
- while (newRoot) {
- var beginIndex = (newOrigin >>> newLevel) & MASK;
- if (beginIndex !== (newTailOffset >>> newLevel) & MASK) {
- break;
- }
- if (beginIndex) {
- offsetShift += (1 << newLevel) * beginIndex;
- }
- newLevel -= SHIFT;
- newRoot = newRoot.array[beginIndex];
- }
-
- // Trim the new sides of the new root.
- if (newRoot && newOrigin > oldOrigin) {
- newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
- }
- if (newRoot && newTailOffset < oldTailOffset) {
- newRoot = newRoot.removeAfter(owner, newLevel, newTailOffset - offsetShift);
- }
- if (offsetShift) {
- newOrigin -= offsetShift;
- newCapacity -= offsetShift;
- }
- }
-
- if (list.__ownerID) {
- list.size = newCapacity - newOrigin;
- list._origin = newOrigin;
- list._capacity = newCapacity;
- list._level = newLevel;
- list._root = newRoot;
- list._tail = newTail;
- list.__hash = undefined;
- list.__altered = true;
- return list;
- }
- return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
- }
-
- function mergeIntoListWith(list, merger, iterables) {
- var iters = [];
- var maxSize = 0;
- for (var ii = 0; ii < iterables.length; ii++) {
- var value = iterables[ii];
- var iter = IndexedIterable(value);
- if (iter.size > maxSize) {
- maxSize = iter.size;
- }
- if (!isIterable(value)) {
- iter = iter.map(function(v ) {return fromJS(v)});
- }
- iters.push(iter);
- }
- if (maxSize > list.size) {
- list = list.setSize(maxSize);
- }
- return mergeIntoCollectionWith(list, merger, iters);
- }
-
- function getTailOffset(size) {
- return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT);
- }
-
- createClass(OrderedMap, Map);
-
- // @pragma Construction
-
- function OrderedMap(value) {
- return value === null || value === undefined ? emptyOrderedMap() :
- isOrderedMap(value) ? value :
- emptyOrderedMap().withMutations(function(map ) {
- var iter = KeyedIterable(value);
- assertNotInfinite(iter.size);
- iter.forEach(function(v, k) {return map.set(k, v)});
- });
- }
-
- OrderedMap.of = function(/*...values*/) {
- return this(arguments);
- };
-
- OrderedMap.prototype.toString = function() {
- return this.__toString('OrderedMap {', '}');
- };
-
- // @pragma Access
-
- OrderedMap.prototype.get = function(k, notSetValue) {
- var index = this._map.get(k);
- return index !== undefined ? this._list.get(index)[1] : notSetValue;
- };
-
- // @pragma Modification
-
- OrderedMap.prototype.clear = function() {
- if (this.size === 0) {
- return this;
- }
- if (this.__ownerID) {
- this.size = 0;
- this._map.clear();
- this._list.clear();
- return this;
- }
- return emptyOrderedMap();
- };
-
- OrderedMap.prototype.set = function(k, v) {
- return updateOrderedMap(this, k, v);
- };
-
- OrderedMap.prototype.remove = function(k) {
- return updateOrderedMap(this, k, NOT_SET);
- };
-
- OrderedMap.prototype.wasAltered = function() {
- return this._map.wasAltered() || this._list.wasAltered();
- };
-
- OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- return this._list.__iterate(
- function(entry ) {return entry && fn(entry[1], entry[0], this$0)},
- reverse
- );
- };
-
- OrderedMap.prototype.__iterator = function(type, reverse) {
- return this._list.fromEntrySeq().__iterator(type, reverse);
- };
-
- OrderedMap.prototype.__ensureOwner = function(ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- var newMap = this._map.__ensureOwner(ownerID);
- var newList = this._list.__ensureOwner(ownerID);
- if (!ownerID) {
- this.__ownerID = ownerID;
- this._map = newMap;
- this._list = newList;
- return this;
- }
- return makeOrderedMap(newMap, newList, ownerID, this.__hash);
- };
-
-
- function isOrderedMap(maybeOrderedMap) {
- return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
- }
-
- OrderedMap.isOrderedMap = isOrderedMap;
-
- OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
- OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
-
-
-
- function makeOrderedMap(map, list, ownerID, hash) {
- var omap = Object.create(OrderedMap.prototype);
- omap.size = map ? map.size : 0;
- omap._map = map;
- omap._list = list;
- omap.__ownerID = ownerID;
- omap.__hash = hash;
- return omap;
- }
-
- var EMPTY_ORDERED_MAP;
- function emptyOrderedMap() {
- return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()));
- }
-
- function updateOrderedMap(omap, k, v) {
- var map = omap._map;
- var list = omap._list;
- var i = map.get(k);
- var has = i !== undefined;
- var newMap;
- var newList;
- if (v === NOT_SET) { // removed
- if (!has) {
- return omap;
- }
- if (list.size >= SIZE && list.size >= map.size * 2) {
- newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx});
- newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap();
- if (omap.__ownerID) {
- newMap.__ownerID = newList.__ownerID = omap.__ownerID;
- }
- } else {
- newMap = map.remove(k);
- newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
- }
- } else {
- if (has) {
- if (v === list.get(i)[1]) {
- return omap;
- }
- newMap = map;
- newList = list.set(i, [k, v]);
- } else {
- newMap = map.set(k, list.size);
- newList = list.set(list.size, [k, v]);
- }
- }
- if (omap.__ownerID) {
- omap.size = newMap.size;
- omap._map = newMap;
- omap._list = newList;
- omap.__hash = undefined;
- return omap;
- }
- return makeOrderedMap(newMap, newList);
- }
-
- createClass(ToKeyedSequence, KeyedSeq);
- function ToKeyedSequence(indexed, useKeys) {
- this._iter = indexed;
- this._useKeys = useKeys;
- this.size = indexed.size;
- }
-
- ToKeyedSequence.prototype.get = function(key, notSetValue) {
- return this._iter.get(key, notSetValue);
- };
-
- ToKeyedSequence.prototype.has = function(key) {
- return this._iter.has(key);
- };
-
- ToKeyedSequence.prototype.valueSeq = function() {
- return this._iter.valueSeq();
- };
-
- ToKeyedSequence.prototype.reverse = function() {var this$0 = this;
- var reversedSequence = reverseFactory(this, true);
- if (!this._useKeys) {
- reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()};
- }
- return reversedSequence;
- };
-
- ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this;
- var mappedSequence = mapFactory(this, mapper, context);
- if (!this._useKeys) {
- mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)};
- }
- return mappedSequence;
- };
-
- ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- var ii;
- return this._iter.__iterate(
- this._useKeys ?
- function(v, k) {return fn(v, k, this$0)} :
- ((ii = reverse ? resolveSize(this) : 0),
- function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}),
- reverse
- );
- };
-
- ToKeyedSequence.prototype.__iterator = function(type, reverse) {
- if (this._useKeys) {
- return this._iter.__iterator(type, reverse);
- }
- var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
- var ii = reverse ? resolveSize(this) : 0;
- return new Iterator(function() {
- var step = iterator.next();
- return step.done ? step :
- iteratorValue(type, reverse ? --ii : ii++, step.value, step);
- });
- };
-
- ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
-
-
- createClass(ToIndexedSequence, IndexedSeq);
- function ToIndexedSequence(iter) {
- this._iter = iter;
- this.size = iter.size;
- }
-
- ToIndexedSequence.prototype.includes = function(value) {
- return this._iter.includes(value);
- };
-
- ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- var iterations = 0;
- return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse);
- };
-
- ToIndexedSequence.prototype.__iterator = function(type, reverse) {
- var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
- var iterations = 0;
- return new Iterator(function() {
- var step = iterator.next();
- return step.done ? step :
- iteratorValue(type, iterations++, step.value, step)
- });
- };
-
-
-
- createClass(ToSetSequence, SetSeq);
- function ToSetSequence(iter) {
- this._iter = iter;
- this.size = iter.size;
- }
-
- ToSetSequence.prototype.has = function(key) {
- return this._iter.includes(key);
- };
-
- ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse);
- };
-
- ToSetSequence.prototype.__iterator = function(type, reverse) {
- var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
- return new Iterator(function() {
- var step = iterator.next();
- return step.done ? step :
- iteratorValue(type, step.value, step.value, step);
- });
- };
-
-
-
- createClass(FromEntriesSequence, KeyedSeq);
- function FromEntriesSequence(entries) {
- this._iter = entries;
- this.size = entries.size;
- }
-
- FromEntriesSequence.prototype.entrySeq = function() {
- return this._iter.toSeq();
- };
-
- FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- return this._iter.__iterate(function(entry ) {
- // Check if entry exists first so array access doesn't throw for holes
- // in the parent iteration.
- if (entry) {
- validateEntry(entry);
- var indexedIterable = isIterable(entry);
- return fn(
- indexedIterable ? entry.get(1) : entry[1],
- indexedIterable ? entry.get(0) : entry[0],
- this$0
- );
- }
- }, reverse);
- };
-
- FromEntriesSequence.prototype.__iterator = function(type, reverse) {
- var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
- return new Iterator(function() {
- while (true) {
- var step = iterator.next();
- if (step.done) {
- return step;
- }
- var entry = step.value;
- // Check if entry exists first so array access doesn't throw for holes
- // in the parent iteration.
- if (entry) {
- validateEntry(entry);
- var indexedIterable = isIterable(entry);
- return iteratorValue(
- type,
- indexedIterable ? entry.get(0) : entry[0],
- indexedIterable ? entry.get(1) : entry[1],
- step
- );
- }
- }
- });
- };
-
-
- ToIndexedSequence.prototype.cacheResult =
- ToKeyedSequence.prototype.cacheResult =
- ToSetSequence.prototype.cacheResult =
- FromEntriesSequence.prototype.cacheResult =
- cacheResultThrough;
-
-
- function flipFactory(iterable) {
- var flipSequence = makeSequence(iterable);
- flipSequence._iter = iterable;
- flipSequence.size = iterable.size;
- flipSequence.flip = function() {return iterable};
- flipSequence.reverse = function () {
- var reversedSequence = iterable.reverse.apply(this); // super.reverse()
- reversedSequence.flip = function() {return iterable.reverse()};
- return reversedSequence;
- };
- flipSequence.has = function(key ) {return iterable.includes(key)};
- flipSequence.includes = function(key ) {return iterable.has(key)};
- flipSequence.cacheResult = cacheResultThrough;
- flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
- return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse);
- };
- flipSequence.__iteratorUncached = function(type, reverse) {
- if (type === ITERATE_ENTRIES) {
- var iterator = iterable.__iterator(type, reverse);
- return new Iterator(function() {
- var step = iterator.next();
- if (!step.done) {
- var k = step.value[0];
- step.value[0] = step.value[1];
- step.value[1] = k;
- }
- return step;
- });
- }
- return iterable.__iterator(
- type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
- reverse
- );
- };
- return flipSequence;
- }
-
-
- function mapFactory(iterable, mapper, context) {
- var mappedSequence = makeSequence(iterable);
- mappedSequence.size = iterable.size;
- mappedSequence.has = function(key ) {return iterable.has(key)};
- mappedSequence.get = function(key, notSetValue) {
- var v = iterable.get(key, NOT_SET);
- return v === NOT_SET ?
- notSetValue :
- mapper.call(context, v, key, iterable);
- };
- mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
- return iterable.__iterate(
- function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false},
- reverse
- );
- };
- mappedSequence.__iteratorUncached = function (type, reverse) {
- var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
- return new Iterator(function() {
- var step = iterator.next();
- if (step.done) {
- return step;
- }
- var entry = step.value;
- var key = entry[0];
- return iteratorValue(
- type,
- key,
- mapper.call(context, entry[1], key, iterable),
- step
- );
- });
- };
- return mappedSequence;
- }
-
-
- function reverseFactory(iterable, useKeys) {
- var reversedSequence = makeSequence(iterable);
- reversedSequence._iter = iterable;
- reversedSequence.size = iterable.size;
- reversedSequence.reverse = function() {return iterable};
- if (iterable.flip) {
- reversedSequence.flip = function () {
- var flipSequence = flipFactory(iterable);
- flipSequence.reverse = function() {return iterable.flip()};
- return flipSequence;
- };
- }
- reversedSequence.get = function(key, notSetValue)
- {return iterable.get(useKeys ? key : -1 - key, notSetValue)};
- reversedSequence.has = function(key )
- {return iterable.has(useKeys ? key : -1 - key)};
- reversedSequence.includes = function(value ) {return iterable.includes(value)};
- reversedSequence.cacheResult = cacheResultThrough;
- reversedSequence.__iterate = function (fn, reverse) {var this$0 = this;
- return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse);
- };
- reversedSequence.__iterator =
- function(type, reverse) {return iterable.__iterator(type, !reverse)};
- return reversedSequence;
- }
-
-
- function filterFactory(iterable, predicate, context, useKeys) {
- var filterSequence = makeSequence(iterable);
- if (useKeys) {
- filterSequence.has = function(key ) {
- var v = iterable.get(key, NOT_SET);
- return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
- };
- filterSequence.get = function(key, notSetValue) {
- var v = iterable.get(key, NOT_SET);
- return v !== NOT_SET && predicate.call(context, v, key, iterable) ?
- v : notSetValue;
- };
- }
- filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
- var iterations = 0;
- iterable.__iterate(function(v, k, c) {
- if (predicate.call(context, v, k, c)) {
- iterations++;
- return fn(v, useKeys ? k : iterations - 1, this$0);
- }
- }, reverse);
- return iterations;
- };
- filterSequence.__iteratorUncached = function (type, reverse) {
- var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
- var iterations = 0;
- return new Iterator(function() {
- while (true) {
- var step = iterator.next();
- if (step.done) {
- return step;
- }
- var entry = step.value;
- var key = entry[0];
- var value = entry[1];
- if (predicate.call(context, value, key, iterable)) {
- return iteratorValue(type, useKeys ? key : iterations++, value, step);
- }
- }
- });
- };
- return filterSequence;
- }
-
-
- function countByFactory(iterable, grouper, context) {
- var groups = Map().asMutable();
- iterable.__iterate(function(v, k) {
- groups.update(
- grouper.call(context, v, k, iterable),
- 0,
- function(a ) {return a + 1}
- );
- });
- return groups.asImmutable();
- }
-
-
- function groupByFactory(iterable, grouper, context) {
- var isKeyedIter = isKeyed(iterable);
- var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
- iterable.__iterate(function(v, k) {
- groups.update(
- grouper.call(context, v, k, iterable),
- function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)}
- );
- });
- var coerce = iterableClass(iterable);
- return groups.map(function(arr ) {return reify(iterable, coerce(arr))});
- }
-
-
- function sliceFactory(iterable, begin, end, useKeys) {
- var originalSize = iterable.size;
-
- // Sanitize begin & end using this shorthand for ToInt32(argument)
- // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
- if (begin !== undefined) {
- begin = begin | 0;
- }
- if (end !== undefined) {
- end = end | 0;
- }
-
- if (wholeSlice(begin, end, originalSize)) {
- return iterable;
- }
-
- var resolvedBegin = resolveBegin(begin, originalSize);
- var resolvedEnd = resolveEnd(end, originalSize);
-
- // begin or end will be NaN if they were provided as negative numbers and
- // this iterable's size is unknown. In that case, cache first so there is
- // a known size and these do not resolve to NaN.
- if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
- return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys);
- }
-
- // Note: resolvedEnd is undefined when the original sequence's length is
- // unknown and this slice did not supply an end and should contain all
- // elements after resolvedBegin.
- // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
- var resolvedSize = resolvedEnd - resolvedBegin;
- var sliceSize;
- if (resolvedSize === resolvedSize) {
- sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
- }
-
- var sliceSeq = makeSequence(iterable);
-
- // If iterable.size is undefined, the size of the realized sliceSeq is
- // unknown at this point unless the number of items to slice is 0
- sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined;
-
- if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
- sliceSeq.get = function (index, notSetValue) {
- index = wrapIndex(this, index);
- return index >= 0 && index < sliceSize ?
- iterable.get(index + resolvedBegin, notSetValue) :
- notSetValue;
- };
- }
-
- sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this;
- if (sliceSize === 0) {
- return 0;
- }
- if (reverse) {
- return this.cacheResult().__iterate(fn, reverse);
- }
- var skipped = 0;
- var isSkipping = true;
- var iterations = 0;
- iterable.__iterate(function(v, k) {
- if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
- iterations++;
- return fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
- iterations !== sliceSize;
- }
- });
- return iterations;
- };
-
- sliceSeq.__iteratorUncached = function(type, reverse) {
- if (sliceSize !== 0 && reverse) {
- return this.cacheResult().__iterator(type, reverse);
- }
- // Don't bother instantiating parent iterator if taking 0.
- var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
- var skipped = 0;
- var iterations = 0;
- return new Iterator(function() {
- while (skipped++ < resolvedBegin) {
- iterator.next();
- }
- if (++iterations > sliceSize) {
- return iteratorDone();
- }
- var step = iterator.next();
- if (useKeys || type === ITERATE_VALUES) {
- return step;
- } else if (type === ITERATE_KEYS) {
- return iteratorValue(type, iterations - 1, undefined, step);
- } else {
- return iteratorValue(type, iterations - 1, step.value[1], step);
- }
- });
- };
-
- return sliceSeq;
- }
-
-
- function takeWhileFactory(iterable, predicate, context) {
- var takeSequence = makeSequence(iterable);
- takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
- if (reverse) {
- return this.cacheResult().__iterate(fn, reverse);
- }
- var iterations = 0;
- iterable.__iterate(function(v, k, c)
- {return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)}
- );
- return iterations;
- };
- takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
- if (reverse) {
- return this.cacheResult().__iterator(type, reverse);
- }
- var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
- var iterating = true;
- return new Iterator(function() {
- if (!iterating) {
- return iteratorDone();
- }
- var step = iterator.next();
- if (step.done) {
- return step;
- }
- var entry = step.value;
- var k = entry[0];
- var v = entry[1];
- if (!predicate.call(context, v, k, this$0)) {
- iterating = false;
- return iteratorDone();
- }
- return type === ITERATE_ENTRIES ? step :
- iteratorValue(type, k, v, step);
- });
- };
- return takeSequence;
- }
-
-
- function skipWhileFactory(iterable, predicate, context, useKeys) {
- var skipSequence = makeSequence(iterable);
- skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
- if (reverse) {
- return this.cacheResult().__iterate(fn, reverse);
- }
- var isSkipping = true;
- var iterations = 0;
- iterable.__iterate(function(v, k, c) {
- if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
- iterations++;
- return fn(v, useKeys ? k : iterations - 1, this$0);
- }
- });
- return iterations;
- };
- skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
- if (reverse) {
- return this.cacheResult().__iterator(type, reverse);
- }
- var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
- var skipping = true;
- var iterations = 0;
- return new Iterator(function() {
- var step, k, v;
- do {
- step = iterator.next();
- if (step.done) {
- if (useKeys || type === ITERATE_VALUES) {
- return step;
- } else if (type === ITERATE_KEYS) {
- return iteratorValue(type, iterations++, undefined, step);
- } else {
- return iteratorValue(type, iterations++, step.value[1], step);
- }
- }
- var entry = step.value;
- k = entry[0];
- v = entry[1];
- skipping && (skipping = predicate.call(context, v, k, this$0));
- } while (skipping);
- return type === ITERATE_ENTRIES ? step :
- iteratorValue(type, k, v, step);
- });
- };
- return skipSequence;
- }
-
-
- function concatFactory(iterable, values) {
- var isKeyedIterable = isKeyed(iterable);
- var iters = [iterable].concat(values).map(function(v ) {
- if (!isIterable(v)) {
- v = isKeyedIterable ?
- keyedSeqFromValue(v) :
- indexedSeqFromValue(Array.isArray(v) ? v : [v]);
- } else if (isKeyedIterable) {
- v = KeyedIterable(v);
- }
- return v;
- }).filter(function(v ) {return v.size !== 0});
-
- if (iters.length === 0) {
- return iterable;
- }
-
- if (iters.length === 1) {
- var singleton = iters[0];
- if (singleton === iterable ||
- isKeyedIterable && isKeyed(singleton) ||
- isIndexed(iterable) && isIndexed(singleton)) {
- return singleton;
- }
- }
-
- var concatSeq = new ArraySeq(iters);
- if (isKeyedIterable) {
- concatSeq = concatSeq.toKeyedSeq();
- } else if (!isIndexed(iterable)) {
- concatSeq = concatSeq.toSetSeq();
- }
- concatSeq = concatSeq.flatten(true);
- concatSeq.size = iters.reduce(
- function(sum, seq) {
- if (sum !== undefined) {
- var size = seq.size;
- if (size !== undefined) {
- return sum + size;
- }
- }
- },
- 0
- );
- return concatSeq;
- }
-
-
- function flattenFactory(iterable, depth, useKeys) {
- var flatSequence = makeSequence(iterable);
- flatSequence.__iterateUncached = function(fn, reverse) {
- var iterations = 0;
- var stopped = false;
- function flatDeep(iter, currentDepth) {var this$0 = this;
- iter.__iterate(function(v, k) {
- if ((!depth || currentDepth < depth) && isIterable(v)) {
- flatDeep(v, currentDepth + 1);
- } else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
- stopped = true;
- }
- return !stopped;
- }, reverse);
- }
- flatDeep(iterable, 0);
- return iterations;
- };
- flatSequence.__iteratorUncached = function(type, reverse) {
- var iterator = iterable.__iterator(type, reverse);
- var stack = [];
- var iterations = 0;
- return new Iterator(function() {
- while (iterator) {
- var step = iterator.next();
- if (step.done !== false) {
- iterator = stack.pop();
- continue;
- }
- var v = step.value;
- if (type === ITERATE_ENTRIES) {
- v = v[1];
- }
- if ((!depth || stack.length < depth) && isIterable(v)) {
- stack.push(iterator);
- iterator = v.__iterator(type, reverse);
- } else {
- return useKeys ? step : iteratorValue(type, iterations++, v, step);
- }
- }
- return iteratorDone();
- });
- };
- return flatSequence;
- }
-
-
- function flatMapFactory(iterable, mapper, context) {
- var coerce = iterableClass(iterable);
- return iterable.toSeq().map(
- function(v, k) {return coerce(mapper.call(context, v, k, iterable))}
- ).flatten(true);
- }
-
-
- function interposeFactory(iterable, separator) {
- var interposedSequence = makeSequence(iterable);
- interposedSequence.size = iterable.size && iterable.size * 2 -1;
- interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
- var iterations = 0;
- iterable.__iterate(function(v, k)
- {return (!iterations || fn(separator, iterations++, this$0) !== false) &&
- fn(v, iterations++, this$0) !== false},
- reverse
- );
- return iterations;
- };
- interposedSequence.__iteratorUncached = function(type, reverse) {
- var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
- var iterations = 0;
- var step;
- return new Iterator(function() {
- if (!step || iterations % 2) {
- step = iterator.next();
- if (step.done) {
- return step;
- }
- }
- return iterations % 2 ?
- iteratorValue(type, iterations++, separator) :
- iteratorValue(type, iterations++, step.value, step);
- });
- };
- return interposedSequence;
- }
-
-
- function sortFactory(iterable, comparator, mapper) {
- if (!comparator) {
- comparator = defaultComparator;
- }
- var isKeyedIterable = isKeyed(iterable);
- var index = 0;
- var entries = iterable.toSeq().map(
- function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]}
- ).toArray();
- entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach(
- isKeyedIterable ?
- function(v, i) { entries[i].length = 2; } :
- function(v, i) { entries[i] = v[1]; }
- );
- return isKeyedIterable ? KeyedSeq(entries) :
- isIndexed(iterable) ? IndexedSeq(entries) :
- SetSeq(entries);
- }
-
-
- function maxFactory(iterable, comparator, mapper) {
- if (!comparator) {
- comparator = defaultComparator;
- }
- if (mapper) {
- var entry = iterable.toSeq()
- .map(function(v, k) {return [v, mapper(v, k, iterable)]})
- .reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a});
- return entry && entry[0];
- } else {
- return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a});
- }
- }
-
- function maxCompare(comparator, a, b) {
- var comp = comparator(b, a);
- // b is considered the new max if the comparator declares them equal, but
- // they are not equal and b is in fact a nullish value.
- return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0;
- }
-
-
- function zipWithFactory(keyIter, zipper, iters) {
- var zipSequence = makeSequence(keyIter);
- zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min();
- // Note: this a generic base implementation of __iterate in terms of
- // __iterator which may be more generically useful in the future.
- zipSequence.__iterate = function(fn, reverse) {
- /* generic:
- var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
- var step;
- var iterations = 0;
- while (!(step = iterator.next()).done) {
- iterations++;
- if (fn(step.value[1], step.value[0], this) === false) {
- break;
- }
- }
- return iterations;
- */
- // indexed:
- var iterator = this.__iterator(ITERATE_VALUES, reverse);
- var step;
- var iterations = 0;
- while (!(step = iterator.next()).done) {
- if (fn(step.value, iterations++, this) === false) {
- break;
- }
- }
- return iterations;
- };
- zipSequence.__iteratorUncached = function(type, reverse) {
- var iterators = iters.map(function(i )
- {return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))}
- );
- var iterations = 0;
- var isDone = false;
- return new Iterator(function() {
- var steps;
- if (!isDone) {
- steps = iterators.map(function(i ) {return i.next()});
- isDone = steps.some(function(s ) {return s.done});
- }
- if (isDone) {
- return iteratorDone();
- }
- return iteratorValue(
- type,
- iterations++,
- zipper.apply(null, steps.map(function(s ) {return s.value}))
- );
- });
- };
- return zipSequence
- }
-
-
- // #pragma Helper Functions
-
- function reify(iter, seq) {
- return isSeq(iter) ? seq : iter.constructor(seq);
- }
-
- function validateEntry(entry) {
- if (entry !== Object(entry)) {
- throw new TypeError('Expected [K, V] tuple: ' + entry);
- }
- }
-
- function resolveSize(iter) {
- assertNotInfinite(iter.size);
- return ensureSize(iter);
- }
-
- function iterableClass(iterable) {
- return isKeyed(iterable) ? KeyedIterable :
- isIndexed(iterable) ? IndexedIterable :
- SetIterable;
- }
-
- function makeSequence(iterable) {
- return Object.create(
- (
- isKeyed(iterable) ? KeyedSeq :
- isIndexed(iterable) ? IndexedSeq :
- SetSeq
- ).prototype
- );
- }
-
- function cacheResultThrough() {
- if (this._iter.cacheResult) {
- this._iter.cacheResult();
- this.size = this._iter.size;
- return this;
- } else {
- return Seq.prototype.cacheResult.call(this);
- }
- }
-
- function defaultComparator(a, b) {
- return a > b ? 1 : a < b ? -1 : 0;
- }
-
- function forceIterator(keyPath) {
- var iter = getIterator(keyPath);
- if (!iter) {
- // Array might not be iterable in this environment, so we need a fallback
- // to our wrapped type.
- if (!isArrayLike(keyPath)) {
- throw new TypeError('Expected iterable or array-like: ' + keyPath);
- }
- iter = getIterator(Iterable(keyPath));
- }
- return iter;
- }
-
- createClass(Record, KeyedCollection);
-
- function Record(defaultValues, name) {
- var hasInitialized;
-
- var RecordType = function Record(values) {
- if (values instanceof RecordType) {
- return values;
- }
- if (!(this instanceof RecordType)) {
- return new RecordType(values);
- }
- if (!hasInitialized) {
- hasInitialized = true;
- var keys = Object.keys(defaultValues);
- setProps(RecordTypePrototype, keys);
- RecordTypePrototype.size = keys.length;
- RecordTypePrototype._name = name;
- RecordTypePrototype._keys = keys;
- RecordTypePrototype._defaultValues = defaultValues;
- }
- this._map = Map(values);
- };
-
- var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype);
- RecordTypePrototype.constructor = RecordType;
-
- return RecordType;
- }
-
- Record.prototype.toString = function() {
- return this.__toString(recordName(this) + ' {', '}');
- };
-
- // @pragma Access
-
- Record.prototype.has = function(k) {
- return this._defaultValues.hasOwnProperty(k);
- };
-
- Record.prototype.get = function(k, notSetValue) {
- if (!this.has(k)) {
- return notSetValue;
- }
- var defaultVal = this._defaultValues[k];
- return this._map ? this._map.get(k, defaultVal) : defaultVal;
- };
-
- // @pragma Modification
-
- Record.prototype.clear = function() {
- if (this.__ownerID) {
- this._map && this._map.clear();
- return this;
- }
- var RecordType = this.constructor;
- return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()));
- };
-
- Record.prototype.set = function(k, v) {
- if (!this.has(k)) {
- throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this));
- }
- var newMap = this._map && this._map.set(k, v);
- if (this.__ownerID || newMap === this._map) {
- return this;
- }
- return makeRecord(this, newMap);
- };
-
- Record.prototype.remove = function(k) {
- if (!this.has(k)) {
- return this;
- }
- var newMap = this._map && this._map.remove(k);
- if (this.__ownerID || newMap === this._map) {
- return this;
- }
- return makeRecord(this, newMap);
- };
-
- Record.prototype.wasAltered = function() {
- return this._map.wasAltered();
- };
-
- Record.prototype.__iterator = function(type, reverse) {var this$0 = this;
- return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse);
- };
-
- Record.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse);
- };
-
- Record.prototype.__ensureOwner = function(ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- var newMap = this._map && this._map.__ensureOwner(ownerID);
- if (!ownerID) {
- this.__ownerID = ownerID;
- this._map = newMap;
- return this;
- }
- return makeRecord(this, newMap, ownerID);
- };
-
-
- var RecordPrototype = Record.prototype;
- RecordPrototype[DELETE] = RecordPrototype.remove;
- RecordPrototype.deleteIn =
- RecordPrototype.removeIn = MapPrototype.removeIn;
- RecordPrototype.merge = MapPrototype.merge;
- RecordPrototype.mergeWith = MapPrototype.mergeWith;
- RecordPrototype.mergeIn = MapPrototype.mergeIn;
- RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
- RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
- RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
- RecordPrototype.setIn = MapPrototype.setIn;
- RecordPrototype.update = MapPrototype.update;
- RecordPrototype.updateIn = MapPrototype.updateIn;
- RecordPrototype.withMutations = MapPrototype.withMutations;
- RecordPrototype.asMutable = MapPrototype.asMutable;
- RecordPrototype.asImmutable = MapPrototype.asImmutable;
-
-
- function makeRecord(likeRecord, map, ownerID) {
- var record = Object.create(Object.getPrototypeOf(likeRecord));
- record._map = map;
- record.__ownerID = ownerID;
- return record;
- }
-
- function recordName(record) {
- return record._name || record.constructor.name || 'Record';
- }
-
- function setProps(prototype, names) {
- try {
- names.forEach(setProp.bind(undefined, prototype));
- } catch (error) {
- // Object.defineProperty failed. Probably IE8.
- }
- }
-
- function setProp(prototype, name) {
- Object.defineProperty(prototype, name, {
- get: function() {
- return this.get(name);
- },
- set: function(value) {
- invariant(this.__ownerID, 'Cannot set on an immutable record.');
- this.set(name, value);
- }
- });
- }
-
- createClass(Set, SetCollection);
-
- // @pragma Construction
-
- function Set(value) {
- return value === null || value === undefined ? emptySet() :
- isSet(value) && !isOrdered(value) ? value :
- emptySet().withMutations(function(set ) {
- var iter = SetIterable(value);
- assertNotInfinite(iter.size);
- iter.forEach(function(v ) {return set.add(v)});
- });
- }
-
- Set.of = function(/*...values*/) {
- return this(arguments);
- };
-
- Set.fromKeys = function(value) {
- return this(KeyedIterable(value).keySeq());
- };
-
- Set.prototype.toString = function() {
- return this.__toString('Set {', '}');
- };
-
- // @pragma Access
-
- Set.prototype.has = function(value) {
- return this._map.has(value);
- };
-
- // @pragma Modification
-
- Set.prototype.add = function(value) {
- return updateSet(this, this._map.set(value, true));
- };
-
- Set.prototype.remove = function(value) {
- return updateSet(this, this._map.remove(value));
- };
-
- Set.prototype.clear = function() {
- return updateSet(this, this._map.clear());
- };
-
- // @pragma Composition
-
- Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0);
- iters = iters.filter(function(x ) {return x.size !== 0});
- if (iters.length === 0) {
- return this;
- }
- if (this.size === 0 && !this.__ownerID && iters.length === 1) {
- return this.constructor(iters[0]);
- }
- return this.withMutations(function(set ) {
- for (var ii = 0; ii < iters.length; ii++) {
- SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)});
- }
- });
- };
-
- Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0);
- if (iters.length === 0) {
- return this;
- }
- iters = iters.map(function(iter ) {return SetIterable(iter)});
- var originalSet = this;
- return this.withMutations(function(set ) {
- originalSet.forEach(function(value ) {
- if (!iters.every(function(iter ) {return iter.includes(value)})) {
- set.remove(value);
- }
- });
- });
- };
-
- Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0);
- if (iters.length === 0) {
- return this;
- }
- iters = iters.map(function(iter ) {return SetIterable(iter)});
- var originalSet = this;
- return this.withMutations(function(set ) {
- originalSet.forEach(function(value ) {
- if (iters.some(function(iter ) {return iter.includes(value)})) {
- set.remove(value);
- }
- });
- });
- };
-
- Set.prototype.merge = function() {
- return this.union.apply(this, arguments);
- };
-
- Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
- return this.union.apply(this, iters);
- };
-
- Set.prototype.sort = function(comparator) {
- // Late binding
- return OrderedSet(sortFactory(this, comparator));
- };
-
- Set.prototype.sortBy = function(mapper, comparator) {
- // Late binding
- return OrderedSet(sortFactory(this, comparator, mapper));
- };
-
- Set.prototype.wasAltered = function() {
- return this._map.wasAltered();
- };
-
- Set.prototype.__iterate = function(fn, reverse) {var this$0 = this;
- return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse);
- };
-
- Set.prototype.__iterator = function(type, reverse) {
- return this._map.map(function(_, k) {return k}).__iterator(type, reverse);
- };
-
- Set.prototype.__ensureOwner = function(ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- var newMap = this._map.__ensureOwner(ownerID);
- if (!ownerID) {
- this.__ownerID = ownerID;
- this._map = newMap;
- return this;
- }
- return this.__make(newMap, ownerID);
- };
-
-
- function isSet(maybeSet) {
- return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
- }
-
- Set.isSet = isSet;
-
- var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
-
- var SetPrototype = Set.prototype;
- SetPrototype[IS_SET_SENTINEL] = true;
- SetPrototype[DELETE] = SetPrototype.remove;
- SetPrototype.mergeDeep = SetPrototype.merge;
- SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
- SetPrototype.withMutations = MapPrototype.withMutations;
- SetPrototype.asMutable = MapPrototype.asMutable;
- SetPrototype.asImmutable = MapPrototype.asImmutable;
-
- SetPrototype.__empty = emptySet;
- SetPrototype.__make = makeSet;
-
- function updateSet(set, newMap) {
- if (set.__ownerID) {
- set.size = newMap.size;
- set._map = newMap;
- return set;
- }
- return newMap === set._map ? set :
- newMap.size === 0 ? set.__empty() :
- set.__make(newMap);
- }
-
- function makeSet(map, ownerID) {
- var set = Object.create(SetPrototype);
- set.size = map ? map.size : 0;
- set._map = map;
- set.__ownerID = ownerID;
- return set;
- }
-
- var EMPTY_SET;
- function emptySet() {
- return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
- }
-
- createClass(OrderedSet, Set);
-
- // @pragma Construction
-
- function OrderedSet(value) {
- return value === null || value === undefined ? emptyOrderedSet() :
- isOrderedSet(value) ? value :
- emptyOrderedSet().withMutations(function(set ) {
- var iter = SetIterable(value);
- assertNotInfinite(iter.size);
- iter.forEach(function(v ) {return set.add(v)});
- });
- }
-
- OrderedSet.of = function(/*...values*/) {
- return this(arguments);
- };
-
- OrderedSet.fromKeys = function(value) {
- return this(KeyedIterable(value).keySeq());
- };
-
- OrderedSet.prototype.toString = function() {
- return this.__toString('OrderedSet {', '}');
- };
-
-
- function isOrderedSet(maybeOrderedSet) {
- return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
- }
-
- OrderedSet.isOrderedSet = isOrderedSet;
-
- var OrderedSetPrototype = OrderedSet.prototype;
- OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
-
- OrderedSetPrototype.__empty = emptyOrderedSet;
- OrderedSetPrototype.__make = makeOrderedSet;
-
- function makeOrderedSet(map, ownerID) {
- var set = Object.create(OrderedSetPrototype);
- set.size = map ? map.size : 0;
- set._map = map;
- set.__ownerID = ownerID;
- return set;
- }
-
- var EMPTY_ORDERED_SET;
- function emptyOrderedSet() {
- return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()));
- }
-
- createClass(Stack, IndexedCollection);
-
- // @pragma Construction
-
- function Stack(value) {
- return value === null || value === undefined ? emptyStack() :
- isStack(value) ? value :
- emptyStack().unshiftAll(value);
- }
-
- Stack.of = function(/*...values*/) {
- return this(arguments);
- };
-
- Stack.prototype.toString = function() {
- return this.__toString('Stack [', ']');
- };
-
- // @pragma Access
-
- Stack.prototype.get = function(index, notSetValue) {
- var head = this._head;
- index = wrapIndex(this, index);
- while (head && index--) {
- head = head.next;
- }
- return head ? head.value : notSetValue;
- };
-
- Stack.prototype.peek = function() {
- return this._head && this._head.value;
- };
-
- // @pragma Modification
-
- Stack.prototype.push = function(/*...values*/) {
- if (arguments.length === 0) {
- return this;
- }
- var newSize = this.size + arguments.length;
- var head = this._head;
- for (var ii = arguments.length - 1; ii >= 0; ii--) {
- head = {
- value: arguments[ii],
- next: head
- };
- }
- if (this.__ownerID) {
- this.size = newSize;
- this._head = head;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return makeStack(newSize, head);
- };
-
- Stack.prototype.pushAll = function(iter) {
- iter = IndexedIterable(iter);
- if (iter.size === 0) {
- return this;
- }
- assertNotInfinite(iter.size);
- var newSize = this.size;
- var head = this._head;
- iter.reverse().forEach(function(value ) {
- newSize++;
- head = {
- value: value,
- next: head
- };
- });
- if (this.__ownerID) {
- this.size = newSize;
- this._head = head;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return makeStack(newSize, head);
- };
-
- Stack.prototype.pop = function() {
- return this.slice(1);
- };
-
- Stack.prototype.unshift = function(/*...values*/) {
- return this.push.apply(this, arguments);
- };
-
- Stack.prototype.unshiftAll = function(iter) {
- return this.pushAll(iter);
- };
-
- Stack.prototype.shift = function() {
- return this.pop.apply(this, arguments);
- };
-
- Stack.prototype.clear = function() {
- if (this.size === 0) {
- return this;
- }
- if (this.__ownerID) {
- this.size = 0;
- this._head = undefined;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return emptyStack();
- };
-
- Stack.prototype.slice = function(begin, end) {
- if (wholeSlice(begin, end, this.size)) {
- return this;
- }
- var resolvedBegin = resolveBegin(begin, this.size);
- var resolvedEnd = resolveEnd(end, this.size);
- if (resolvedEnd !== this.size) {
- // super.slice(begin, end);
- return IndexedCollection.prototype.slice.call(this, begin, end);
- }
- var newSize = this.size - resolvedBegin;
- var head = this._head;
- while (resolvedBegin--) {
- head = head.next;
- }
- if (this.__ownerID) {
- this.size = newSize;
- this._head = head;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return makeStack(newSize, head);
- };
-
- // @pragma Mutability
-
- Stack.prototype.__ensureOwner = function(ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- if (!ownerID) {
- this.__ownerID = ownerID;
- this.__altered = false;
- return this;
- }
- return makeStack(this.size, this._head, ownerID, this.__hash);
- };
-
- // @pragma Iteration
-
- Stack.prototype.__iterate = function(fn, reverse) {
- if (reverse) {
- return this.reverse().__iterate(fn);
- }
- var iterations = 0;
- var node = this._head;
- while (node) {
- if (fn(node.value, iterations++, this) === false) {
- break;
- }
- node = node.next;
- }
- return iterations;
- };
-
- Stack.prototype.__iterator = function(type, reverse) {
- if (reverse) {
- return this.reverse().__iterator(type);
- }
- var iterations = 0;
- var node = this._head;
- return new Iterator(function() {
- if (node) {
- var value = node.value;
- node = node.next;
- return iteratorValue(type, iterations++, value);
- }
- return iteratorDone();
- });
- };
-
-
- function isStack(maybeStack) {
- return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
- }
-
- Stack.isStack = isStack;
-
- var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
-
- var StackPrototype = Stack.prototype;
- StackPrototype[IS_STACK_SENTINEL] = true;
- StackPrototype.withMutations = MapPrototype.withMutations;
- StackPrototype.asMutable = MapPrototype.asMutable;
- StackPrototype.asImmutable = MapPrototype.asImmutable;
- StackPrototype.wasAltered = MapPrototype.wasAltered;
-
-
- function makeStack(size, head, ownerID, hash) {
- var map = Object.create(StackPrototype);
- map.size = size;
- map._head = head;
- map.__ownerID = ownerID;
- map.__hash = hash;
- map.__altered = false;
- return map;
- }
-
- var EMPTY_STACK;
- function emptyStack() {
- return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
- }
-
- /**
- * Contributes additional methods to a constructor
- */
- function mixin(ctor, methods) {
- var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; };
- Object.keys(methods).forEach(keyCopier);
- Object.getOwnPropertySymbols &&
- Object.getOwnPropertySymbols(methods).forEach(keyCopier);
- return ctor;
- }
-
- Iterable.Iterator = Iterator;
-
- mixin(Iterable, {
-
- // ### Conversion to other types
-
- toArray: function() {
- assertNotInfinite(this.size);
- var array = new Array(this.size || 0);
- this.valueSeq().__iterate(function(v, i) { array[i] = v; });
- return array;
- },
-
- toIndexedSeq: function() {
- return new ToIndexedSequence(this);
- },
-
- toJS: function() {
- return this.toSeq().map(
- function(value ) {return value && typeof value.toJS === 'function' ? value.toJS() : value}
- ).__toJS();
- },
-
- toJSON: function() {
- return this.toSeq().map(
- function(value ) {return value && typeof value.toJSON === 'function' ? value.toJSON() : value}
- ).__toJS();
- },
-
- toKeyedSeq: function() {
- return new ToKeyedSequence(this, true);
- },
-
- toMap: function() {
- // Use Late Binding here to solve the circular dependency.
- return Map(this.toKeyedSeq());
- },
-
- toObject: function() {
- assertNotInfinite(this.size);
- var object = {};
- this.__iterate(function(v, k) { object[k] = v; });
- return object;
- },
-
- toOrderedMap: function() {
- // Use Late Binding here to solve the circular dependency.
- return OrderedMap(this.toKeyedSeq());
- },
-
- toOrderedSet: function() {
- // Use Late Binding here to solve the circular dependency.
- return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
- },
-
- toSet: function() {
- // Use Late Binding here to solve the circular dependency.
- return Set(isKeyed(this) ? this.valueSeq() : this);
- },
-
- toSetSeq: function() {
- return new ToSetSequence(this);
- },
-
- toSeq: function() {
- return isIndexed(this) ? this.toIndexedSeq() :
- isKeyed(this) ? this.toKeyedSeq() :
- this.toSetSeq();
- },
-
- toStack: function() {
- // Use Late Binding here to solve the circular dependency.
- return Stack(isKeyed(this) ? this.valueSeq() : this);
- },
-
- toList: function() {
- // Use Late Binding here to solve the circular dependency.
- return List(isKeyed(this) ? this.valueSeq() : this);
- },
-
-
- // ### Common JavaScript methods and properties
-
- toString: function() {
- return '[Iterable]';
- },
-
- __toString: function(head, tail) {
- if (this.size === 0) {
- return head + tail;
- }
- return head + ' ' + this.toSeq().map(this.__toStringMapper).join(', ') + ' ' + tail;
- },
-
-
- // ### ES6 Collection methods (ES6 Array and Map)
-
- concat: function() {var values = SLICE$0.call(arguments, 0);
- return reify(this, concatFactory(this, values));
- },
-
- includes: function(searchValue) {
- return this.some(function(value ) {return is(value, searchValue)});
- },
-
- entries: function() {
- return this.__iterator(ITERATE_ENTRIES);
- },
-
- every: function(predicate, context) {
- assertNotInfinite(this.size);
- var returnValue = true;
- this.__iterate(function(v, k, c) {
- if (!predicate.call(context, v, k, c)) {
- returnValue = false;
- return false;
- }
- });
- return returnValue;
- },
-
- filter: function(predicate, context) {
- return reify(this, filterFactory(this, predicate, context, true));
- },
-
- find: function(predicate, context, notSetValue) {
- var entry = this.findEntry(predicate, context);
- return entry ? entry[1] : notSetValue;
- },
-
- findEntry: function(predicate, context) {
- var found;
- this.__iterate(function(v, k, c) {
- if (predicate.call(context, v, k, c)) {
- found = [k, v];
- return false;
- }
- });
- return found;
- },
-
- findLastEntry: function(predicate, context) {
- return this.toSeq().reverse().findEntry(predicate, context);
- },
-
- forEach: function(sideEffect, context) {
- assertNotInfinite(this.size);
- return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
- },
-
- join: function(separator) {
- assertNotInfinite(this.size);
- separator = separator !== undefined ? '' + separator : ',';
- var joined = '';
- var isFirst = true;
- this.__iterate(function(v ) {
- isFirst ? (isFirst = false) : (joined += separator);
- joined += v !== null && v !== undefined ? v.toString() : '';
- });
- return joined;
- },
-
- keys: function() {
- return this.__iterator(ITERATE_KEYS);
- },
-
- map: function(mapper, context) {
- return reify(this, mapFactory(this, mapper, context));
- },
-
- reduce: function(reducer, initialReduction, context) {
- assertNotInfinite(this.size);
- var reduction;
- var useFirst;
- if (arguments.length < 2) {
- useFirst = true;
- } else {
- reduction = initialReduction;
- }
- this.__iterate(function(v, k, c) {
- if (useFirst) {
- useFirst = false;
- reduction = v;
- } else {
- reduction = reducer.call(context, reduction, v, k, c);
- }
- });
- return reduction;
- },
-
- reduceRight: function(reducer, initialReduction, context) {
- var reversed = this.toKeyedSeq().reverse();
- return reversed.reduce.apply(reversed, arguments);
- },
-
- reverse: function() {
- return reify(this, reverseFactory(this, true));
- },
-
- slice: function(begin, end) {
- return reify(this, sliceFactory(this, begin, end, true));
- },
-
- some: function(predicate, context) {
- return !this.every(not(predicate), context);
- },
-
- sort: function(comparator) {
- return reify(this, sortFactory(this, comparator));
- },
-
- values: function() {
- return this.__iterator(ITERATE_VALUES);
- },
-
-
- // ### More sequential methods
-
- butLast: function() {
- return this.slice(0, -1);
- },
-
- isEmpty: function() {
- return this.size !== undefined ? this.size === 0 : !this.some(function() {return true});
- },
-
- count: function(predicate, context) {
- return ensureSize(
- predicate ? this.toSeq().filter(predicate, context) : this
- );
- },
-
- countBy: function(grouper, context) {
- return countByFactory(this, grouper, context);
- },
-
- equals: function(other) {
- return deepEqual(this, other);
- },
-
- entrySeq: function() {
- var iterable = this;
- if (iterable._cache) {
- // We cache as an entries array, so we can just return the cache!
- return new ArraySeq(iterable._cache);
- }
- var entriesSequence = iterable.toSeq().map(entryMapper).toIndexedSeq();
- entriesSequence.fromEntrySeq = function() {return iterable.toSeq()};
- return entriesSequence;
- },
-
- filterNot: function(predicate, context) {
- return this.filter(not(predicate), context);
- },
-
- findLast: function(predicate, context, notSetValue) {
- return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
- },
-
- first: function() {
- return this.find(returnTrue);
- },
-
- flatMap: function(mapper, context) {
- return reify(this, flatMapFactory(this, mapper, context));
- },
-
- flatten: function(depth) {
- return reify(this, flattenFactory(this, depth, true));
- },
-
- fromEntrySeq: function() {
- return new FromEntriesSequence(this);
- },
-
- get: function(searchKey, notSetValue) {
- return this.find(function(_, key) {return is(key, searchKey)}, undefined, notSetValue);
- },
-
- getIn: function(searchKeyPath, notSetValue) {
- var nested = this;
- // Note: in an ES6 environment, we would prefer:
- // for (var key of searchKeyPath) {
- var iter = forceIterator(searchKeyPath);
- var step;
- while (!(step = iter.next()).done) {
- var key = step.value;
- nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
- if (nested === NOT_SET) {
- return notSetValue;
- }
- }
- return nested;
- },
-
- groupBy: function(grouper, context) {
- return groupByFactory(this, grouper, context);
- },
-
- has: function(searchKey) {
- return this.get(searchKey, NOT_SET) !== NOT_SET;
- },
-
- hasIn: function(searchKeyPath) {
- return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
- },
-
- isSubset: function(iter) {
- iter = typeof iter.includes === 'function' ? iter : Iterable(iter);
- return this.every(function(value ) {return iter.includes(value)});
- },
-
- isSuperset: function(iter) {
- iter = typeof iter.isSubset === 'function' ? iter : Iterable(iter);
- return iter.isSubset(this);
- },
-
- keySeq: function() {
- return this.toSeq().map(keyMapper).toIndexedSeq();
- },
-
- last: function() {
- return this.toSeq().reverse().first();
- },
-
- max: function(comparator) {
- return maxFactory(this, comparator);
- },
-
- maxBy: function(mapper, comparator) {
- return maxFactory(this, comparator, mapper);
- },
-
- min: function(comparator) {
- return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator);
- },
-
- minBy: function(mapper, comparator) {
- return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator, mapper);
- },
-
- rest: function() {
- return this.slice(1);
- },
-
- skip: function(amount) {
- return this.slice(Math.max(0, amount));
- },
-
- skipLast: function(amount) {
- return reify(this, this.toSeq().reverse().skip(amount).reverse());
- },
-
- skipWhile: function(predicate, context) {
- return reify(this, skipWhileFactory(this, predicate, context, true));
- },
-
- skipUntil: function(predicate, context) {
- return this.skipWhile(not(predicate), context);
- },
-
- sortBy: function(mapper, comparator) {
- return reify(this, sortFactory(this, comparator, mapper));
- },
-
- take: function(amount) {
- return this.slice(0, Math.max(0, amount));
- },
-
- takeLast: function(amount) {
- return reify(this, this.toSeq().reverse().take(amount).reverse());
- },
-
- takeWhile: function(predicate, context) {
- return reify(this, takeWhileFactory(this, predicate, context));
- },
-
- takeUntil: function(predicate, context) {
- return this.takeWhile(not(predicate), context);
- },
-
- valueSeq: function() {
- return this.toIndexedSeq();
- },
-
-
- // ### Hashable Object
-
- hashCode: function() {
- return this.__hash || (this.__hash = hashIterable(this));
- }
-
-
- // ### Internal
-
- // abstract __iterate(fn, reverse)
-
- // abstract __iterator(type, reverse)
- });
-
- // var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
- // var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
- // var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
- // var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
-
- var IterablePrototype = Iterable.prototype;
- IterablePrototype[IS_ITERABLE_SENTINEL] = true;
- IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
- IterablePrototype.__toJS = IterablePrototype.toArray;
- IterablePrototype.__toStringMapper = quoteString;
- IterablePrototype.inspect =
- IterablePrototype.toSource = function() { return this.toString(); };
- IterablePrototype.chain = IterablePrototype.flatMap;
- IterablePrototype.contains = IterablePrototype.includes;
-
- // Temporary warning about using length
- (function () {
- try {
- Object.defineProperty(IterablePrototype, 'length', {
- get: function () {
- if (!Iterable.noLengthWarning) {
- var stack;
- try {
- throw new Error();
- } catch (error) {
- stack = error.stack;
- }
- if (stack.indexOf('_wrapObject') === -1) {
- console && console.warn && console.warn(
- 'iterable.length has been deprecated, '+
- 'use iterable.size or iterable.count(). '+
- 'This warning will become a silent error in a future version. ' +
- stack
- );
- return this.size;
- }
- }
- }
- });
- } catch (e) {}
- })();
-
-
-
- mixin(KeyedIterable, {
-
- // ### More sequential methods
-
- flip: function() {
- return reify(this, flipFactory(this));
- },
-
- findKey: function(predicate, context) {
- var entry = this.findEntry(predicate, context);
- return entry && entry[0];
- },
-
- findLastKey: function(predicate, context) {
- return this.toSeq().reverse().findKey(predicate, context);
- },
-
- keyOf: function(searchValue) {
- return this.findKey(function(value ) {return is(value, searchValue)});
- },
-
- lastKeyOf: function(searchValue) {
- return this.findLastKey(function(value ) {return is(value, searchValue)});
- },
-
- mapEntries: function(mapper, context) {var this$0 = this;
- var iterations = 0;
- return reify(this,
- this.toSeq().map(
- function(v, k) {return mapper.call(context, [k, v], iterations++, this$0)}
- ).fromEntrySeq()
- );
- },
-
- mapKeys: function(mapper, context) {var this$0 = this;
- return reify(this,
- this.toSeq().flip().map(
- function(k, v) {return mapper.call(context, k, v, this$0)}
- ).flip()
- );
- }
-
- });
-
- var KeyedIterablePrototype = KeyedIterable.prototype;
- KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
- KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
- KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
- KeyedIterablePrototype.__toStringMapper = function(v, k) {return JSON.stringify(k) + ': ' + quoteString(v)};
-
-
-
- mixin(IndexedIterable, {
-
- // ### Conversion to other types
-
- toKeyedSeq: function() {
- return new ToKeyedSequence(this, false);
- },
-
-
- // ### ES6 Collection methods (ES6 Array and Map)
-
- filter: function(predicate, context) {
- return reify(this, filterFactory(this, predicate, context, false));
- },
-
- findIndex: function(predicate, context) {
- var entry = this.findEntry(predicate, context);
- return entry ? entry[0] : -1;
- },
-
- indexOf: function(searchValue) {
- var key = this.toKeyedSeq().keyOf(searchValue);
- return key === undefined ? -1 : key;
- },
-
- lastIndexOf: function(searchValue) {
- var key = this.toKeyedSeq().reverse().keyOf(searchValue);
- return key === undefined ? -1 : key;
-
- // var index =
- // return this.toSeq().reverse().indexOf(searchValue);
- },
-
- reverse: function() {
- return reify(this, reverseFactory(this, false));
- },
-
- slice: function(begin, end) {
- return reify(this, sliceFactory(this, begin, end, false));
- },
-
- splice: function(index, removeNum /*, ...values*/) {
- var numArgs = arguments.length;
- removeNum = Math.max(removeNum | 0, 0);
- if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
- return this;
- }
- // If index is negative, it should resolve relative to the size of the
- // collection. However size may be expensive to compute if not cached, so
- // only call count() if the number is in fact negative.
- index = resolveBegin(index, index < 0 ? this.count() : this.size);
- var spliced = this.slice(0, index);
- return reify(
- this,
- numArgs === 1 ?
- spliced :
- spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
- );
- },
-
-
- // ### More collection methods
-
- findLastIndex: function(predicate, context) {
- var key = this.toKeyedSeq().findLastKey(predicate, context);
- return key === undefined ? -1 : key;
- },
-
- first: function() {
- return this.get(0);
- },
-
- flatten: function(depth) {
- return reify(this, flattenFactory(this, depth, false));
- },
-
- get: function(index, notSetValue) {
- index = wrapIndex(this, index);
- return (index < 0 || (this.size === Infinity ||
- (this.size !== undefined && index > this.size))) ?
- notSetValue :
- this.find(function(_, key) {return key === index}, undefined, notSetValue);
- },
-
- has: function(index) {
- index = wrapIndex(this, index);
- return index >= 0 && (this.size !== undefined ?
- this.size === Infinity || index < this.size :
- this.indexOf(index) !== -1
- );
- },
-
- interpose: function(separator) {
- return reify(this, interposeFactory(this, separator));
- },
-
- interleave: function(/*...iterables*/) {
- var iterables = [this].concat(arrCopy(arguments));
- var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
- var interleaved = zipped.flatten(true);
- if (zipped.size) {
- interleaved.size = zipped.size * iterables.length;
- }
- return reify(this, interleaved);
- },
-
- last: function() {
- return this.get(-1);
- },
-
- skipWhile: function(predicate, context) {
- return reify(this, skipWhileFactory(this, predicate, context, false));
- },
-
- zip: function(/*, ...iterables */) {
- var iterables = [this].concat(arrCopy(arguments));
- return reify(this, zipWithFactory(this, defaultZipper, iterables));
- },
-
- zipWith: function(zipper/*, ...iterables */) {
- var iterables = arrCopy(arguments);
- iterables[0] = this;
- return reify(this, zipWithFactory(this, zipper, iterables));
- }
-
- });
-
- IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
- IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
-
-
-
- mixin(SetIterable, {
-
- // ### ES6 Collection methods (ES6 Array and Map)
-
- get: function(value, notSetValue) {
- return this.has(value) ? value : notSetValue;
- },
-
- includes: function(value) {
- return this.has(value);
- },
-
-
- // ### More sequential methods
-
- keySeq: function() {
- return this.valueSeq();
- }
-
- });
-
- SetIterable.prototype.has = IterablePrototype.includes;
-
-
- // Mixin subclasses
-
- mixin(KeyedSeq, KeyedIterable.prototype);
- mixin(IndexedSeq, IndexedIterable.prototype);
- mixin(SetSeq, SetIterable.prototype);
-
- mixin(KeyedCollection, KeyedIterable.prototype);
- mixin(IndexedCollection, IndexedIterable.prototype);
- mixin(SetCollection, SetIterable.prototype);
-
-
- // #pragma Helper functions
-
- function keyMapper(v, k) {
- return k;
- }
-
- function entryMapper(v, k) {
- return [k, v];
- }
-
- function not(predicate) {
- return function() {
- return !predicate.apply(this, arguments);
- }
- }
-
- function neg(predicate) {
- return function() {
- return -predicate.apply(this, arguments);
- }
- }
-
- function quoteString(value) {
- return typeof value === 'string' ? JSON.stringify(value) : value;
- }
-
- function defaultZipper() {
- return arrCopy(arguments);
- }
-
- function defaultNegComparator(a, b) {
- return a < b ? 1 : a > b ? -1 : 0;
- }
-
- function hashIterable(iterable) {
- if (iterable.size === Infinity) {
- return 0;
- }
- var ordered = isOrdered(iterable);
- var keyed = isKeyed(iterable);
- var h = ordered ? 1 : 0;
- var size = iterable.__iterate(
- keyed ?
- ordered ?
- function(v, k) { h = 31 * h + hashMerge(hash(v), hash(k)) | 0; } :
- function(v, k) { h = h + hashMerge(hash(v), hash(k)) | 0; } :
- ordered ?
- function(v ) { h = 31 * h + hash(v) | 0; } :
- function(v ) { h = h + hash(v) | 0; }
- );
- return murmurHashOfSize(size, h);
- }
-
- function murmurHashOfSize(size, h) {
- h = imul(h, 0xCC9E2D51);
- h = imul(h << 15 | h >>> -15, 0x1B873593);
- h = imul(h << 13 | h >>> -13, 5);
- h = (h + 0xE6546B64 | 0) ^ size;
- h = imul(h ^ h >>> 16, 0x85EBCA6B);
- h = imul(h ^ h >>> 13, 0xC2B2AE35);
- h = smi(h ^ h >>> 16);
- return h;
- }
-
- function hashMerge(a, b) {
- return a ^ b + 0x9E3779B9 + (a << 6) + (a >> 2) | 0; // int
- }
-
- var Immutable = {
-
- Iterable: Iterable,
-
- Seq: Seq,
- Collection: Collection,
- Map: Map,
- OrderedMap: OrderedMap,
- List: List,
- Stack: Stack,
- Set: Set,
- OrderedSet: OrderedSet,
-
- Record: Record,
- Range: Range,
- Repeat: Repeat,
-
- is: is,
- fromJS: fromJS
-
- };
-
- return Immutable;
-
- }));
- });
-
- var parseHTML_1 = createCommonjsModule(function (module, exports) {
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports["default"] = parseHTML;
-
- var fallback = function fallback(html) {
- var doc = document.implementation.createHTMLDocument('');
- doc.documentElement.innerHTML = html;
- return doc;
- };
-
- function parseHTML(html) {
- var doc;
-
- if (typeof DOMParser !== 'undefined') {
- var parser = new DOMParser();
- doc = parser.parseFromString(html, 'text/html');
-
- if (doc === null || doc.body === null) {
- doc = fallback(html);
- }
- } else {
- doc = fallback(html);
- }
-
- return doc.body;
- }
- });
-
- unwrapExports(parseHTML_1);
-
- var convertFromHTML_1 = createCommonjsModule(function (module, exports) {
-
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports["default"] = void 0;
-
-
-
-
-
- var _parseHTML = interopRequireDefault(parseHTML_1);
-
- var _rangeSort = interopRequireDefault(rangeSort);
-
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the /src directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- var NBSP = ' ';
- var SPACE = ' '; // Arbitrary max indent
-
- var MAX_DEPTH = 4; // used for replacing characters in HTML
-
- /* eslint-disable no-control-regex */
-
- var REGEX_CR = new RegExp('\r', 'g');
- var REGEX_LF = new RegExp('\n', 'g');
- var REGEX_NBSP = new RegExp(NBSP, 'g');
- var REGEX_BLOCK_DELIMITER = new RegExp('\r', 'g');
- /* eslint-enable no-control-regex */
- // Block tag flow is different because LIs do not have
- // a deterministic style ;_;
-
- var blockTags = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li', 'blockquote', 'pre'];
- var inlineTags = {
- b: 'BOLD',
- code: 'CODE',
- del: 'STRIKETHROUGH',
- em: 'ITALIC',
- i: 'ITALIC',
- s: 'STRIKETHROUGH',
- strike: 'STRIKETHROUGH',
- strong: 'BOLD',
- u: 'UNDERLINE'
- };
-
- var handleMiddleware = function handleMiddleware(maybeMiddleware, base) {
- if (maybeMiddleware && maybeMiddleware.__isMiddleware === true) {
- return maybeMiddleware(base);
- }
-
- return maybeMiddleware;
- };
-
- var defaultHTMLToBlock = function defaultHTMLToBlock(nodeName, node, lastList) {
- return undefined;
- };
-
- var defaultHTMLToStyle = function defaultHTMLToStyle(nodeName, node, currentStyle) {
- return currentStyle;
- };
-
- var defaultHTMLToEntity = function defaultHTMLToEntity(nodeName, node) {
- return undefined;
- };
-
- var defaultTextToEntity = function defaultTextToEntity(text) {
- return [];
- };
-
- var nullthrows = function nullthrows(x) {
- if (x != null) {
- return x;
- }
-
- throw new Error('Got unexpected null or undefined');
- };
-
- var sanitizeDraftText = function sanitizeDraftText(input) {
- return input.replace(REGEX_BLOCK_DELIMITER, '');
- };
-
- function getEmptyChunk() {
- return {
- text: '',
- inlines: [],
- entities: [],
- blocks: []
- };
- }
-
- function getWhitespaceChunk(inEntity) {
- var entities = new Array(1);
-
- if (inEntity) {
- entities[0] = inEntity;
- }
-
- return {
- text: SPACE,
- inlines: [(0, immutable$2.OrderedSet)()],
- entities: entities,
- blocks: []
- };
- }
-
- function getSoftNewlineChunk(block, depth) {
- var flat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
- var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : (0, immutable$2.Map)();
-
- if (flat === true) {
- return {
- text: '\r',
- inlines: [(0, immutable$2.OrderedSet)()],
- entities: new Array(1),
- blocks: [{
- type: block,
- data: data,
- depth: Math.max(0, Math.min(MAX_DEPTH, depth))
- }],
- isNewline: true
- };
- }
-
- return {
- text: '\n',
- inlines: [(0, immutable$2.OrderedSet)()],
- entities: new Array(1),
- blocks: []
- };
- }
-
- function getBlockDividerChunk(block, depth) {
- var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (0, immutable$2.Map)();
- return {
- text: '\r',
- inlines: [(0, immutable$2.OrderedSet)()],
- entities: new Array(1),
- blocks: [{
- type: block,
- data: data,
- depth: Math.max(0, Math.min(MAX_DEPTH, depth))
- }]
- };
- }
-
- function getBlockTypeForTag(tag, lastList) {
- switch (tag) {
- case 'h1':
- return 'header-one';
-
- case 'h2':
- return 'header-two';
-
- case 'h3':
- return 'header-three';
-
- case 'h4':
- return 'header-four';
-
- case 'h5':
- return 'header-five';
-
- case 'h6':
- return 'header-six';
-
- case 'li':
- if (lastList === 'ol') {
- return 'ordered-list-item';
- }
-
- return 'unordered-list-item';
-
- case 'blockquote':
- return 'blockquote';
-
- case 'pre':
- return 'code-block';
-
- case 'div':
- case 'p':
- return 'unstyled';
-
- default:
- return null;
- }
- }
-
- function baseCheckBlockType(nodeName, node, lastList) {
- return getBlockTypeForTag(nodeName, lastList);
- }
-
- function processInlineTag(tag, node, currentStyle) {
- var styleToCheck = inlineTags[tag];
-
- if (styleToCheck) {
- currentStyle = currentStyle.add(styleToCheck).toOrderedSet();
- } else if (node instanceof HTMLElement) {
- var htmlElement = node;
- currentStyle = currentStyle.withMutations(function (style) {
- if (htmlElement.style.fontWeight === 'bold') {
- style.add('BOLD');
- }
-
- if (htmlElement.style.fontStyle === 'italic') {
- style.add('ITALIC');
- }
-
- if (htmlElement.style.textDecoration === 'underline') {
- style.add('UNDERLINE');
- }
-
- if (htmlElement.style.textDecoration === 'line-through') {
- style.add('STRIKETHROUGH');
- }
- }).toOrderedSet();
- }
-
- return currentStyle;
- }
-
- function baseProcessInlineTag(tag, node) {
- var inlineStyles = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (0, immutable$2.OrderedSet)();
- return processInlineTag(tag, node, inlineStyles);
- }
-
- function joinChunks(A, B) {
- var flat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
- // Sometimes two blocks will touch in the DOM and we need to strip the
- // extra delimiter to preserve niceness.
- var firstInB = B.text.slice(0, 1);
- var lastInA = A.text.slice(-1);
- var adjacentDividers = lastInA === '\r' && firstInB === '\r';
- var isJoiningBlocks = A.text !== '\r' && B.text !== '\r'; // when joining two full blocks like this we want to pop one divider
-
- var addingNewlineToEmptyBlock = A.text === '\r' && !A.isNewline && B.isNewline; // when joining a newline to an empty block we want to remove the newline
-
- if (adjacentDividers && (isJoiningBlocks || addingNewlineToEmptyBlock)) {
- A.text = A.text.slice(0, -1);
- A.inlines.pop();
- A.entities.pop();
- A.blocks.pop();
- } // Kill whitespace after blocks if flat mode is on
-
-
- if (A.text.slice(-1) === '\r' && flat === true) {
- if (B.text === SPACE || B.text === '\n') {
- return A;
- } else if (firstInB === SPACE || firstInB === '\n') {
- B.text = B.text.slice(1);
- B.inlines.shift();
- B.entities.shift();
- }
- }
-
- var isNewline = A.text.length === 0 && B.isNewline;
- return {
- text: A.text + B.text,
- inlines: A.inlines.concat(B.inlines),
- entities: A.entities.concat(B.entities),
- blocks: A.blocks.concat(B.blocks),
- isNewline: isNewline
- };
- }
- /*
- * Check to see if we have anything like <p> <blockquote> <h1>... to create
- * block tags from. If we do, we can use those and ignore <div> tags. If we
- * don't, we can treat <div> tags as meaningful (unstyled) blocks.
- */
-
-
- function containsSemanticBlockMarkup(html) {
- return blockTags.some(function (tag) {
- return html.indexOf("<".concat(tag)) !== -1;
- });
- }
-
- function genFragment(node, inlineStyle, lastList, inBlock, fragmentBlockTags, depth, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, inEntity) {
- var nodeName = node.nodeName.toLowerCase();
- var newBlock = false;
- var nextBlockType = 'unstyled'; // Base Case
-
- if (nodeName === '#text') {
- var text = node.textContent;
-
- if (text.trim() === '' && inBlock === null) {
- return getEmptyChunk();
- }
-
- if (text.trim() === '' && inBlock !== 'code-block') {
- return getWhitespaceChunk(inEntity);
- }
-
- if (inBlock !== 'code-block') {
- // Can't use empty string because MSWord
- text = text.replace(REGEX_LF, SPACE);
- }
-
- var entities = Array(text.length).fill(inEntity);
- var offsetChange = 0;
- var textEntities = checkEntityText(text, createEntity, getEntity, mergeEntityData, replaceEntityData).sort(_rangeSort["default"]);
- textEntities.forEach(function (_ref) {
- var entity = _ref.entity,
- offset = _ref.offset,
- length = _ref.length,
- result = _ref.result;
- var adjustedOffset = offset + offsetChange;
-
- if (result === null || result === undefined) {
- result = text.substr(adjustedOffset, length);
- }
-
- var textArray = text.split('');
- textArray.splice.bind(textArray, adjustedOffset, length).apply(textArray, result.split(''));
- text = textArray.join('');
- entities.splice.bind(entities, adjustedOffset, length).apply(entities, Array(result.length).fill(entity));
- offsetChange += result.length - length;
- });
- return {
- text: text,
- inlines: Array(text.length).fill(inlineStyle),
- entities: entities,
- blocks: []
- };
- } // BR tags
-
-
- if (nodeName === 'br') {
- var _blockType = inBlock;
-
- if (_blockType === null) {
- // BR tag is at top level, treat it as an unstyled block
- return getSoftNewlineChunk('unstyled', depth, true);
- }
-
- return getSoftNewlineChunk(_blockType || 'unstyled', depth, options.flat);
- }
-
- var chunk = getEmptyChunk();
- var newChunk = null; // Inline tags
-
- inlineStyle = processInlineTag(nodeName, node, inlineStyle);
- inlineStyle = processCustomInlineStyles(nodeName, node, inlineStyle); // Handle lists
-
- if (nodeName === 'ul' || nodeName === 'ol') {
- if (lastList) {
- depth += 1;
- }
-
- lastList = nodeName;
- inBlock = null;
- } // Block Tags
-
-
- var blockInfo = checkBlockType(nodeName, node, lastList, inBlock);
- var blockType;
- var blockDataMap;
-
- if (blockInfo === false) {
- return getEmptyChunk();
- }
-
- blockInfo = blockInfo || {};
-
- if (typeof blockInfo === 'string') {
- blockType = blockInfo;
- blockDataMap = (0, immutable$2.Map)();
- } else {
- blockType = typeof blockInfo === 'string' ? blockInfo : blockInfo.type;
- blockDataMap = blockInfo.data ? (0, immutable$2.Map)(blockInfo.data) : (0, immutable$2.Map)();
- }
-
- if (!inBlock && (fragmentBlockTags.indexOf(nodeName) !== -1 || blockType)) {
- chunk = getBlockDividerChunk(blockType || getBlockTypeForTag(nodeName, lastList), depth, blockDataMap);
- inBlock = blockType || getBlockTypeForTag(nodeName, lastList);
- newBlock = true;
- } else if (lastList && (inBlock === 'ordered-list-item' || inBlock === 'unordered-list-item') && nodeName === 'li') {
- var listItemBlockType = getBlockTypeForTag(nodeName, lastList);
- chunk = getBlockDividerChunk(listItemBlockType, depth);
- inBlock = listItemBlockType;
- newBlock = true;
- nextBlockType = lastList === 'ul' ? 'unordered-list-item' : 'ordered-list-item';
- } else if (inBlock && inBlock !== 'atomic' && blockType === 'atomic') {
- inBlock = blockType;
- newBlock = true;
- chunk = getSoftNewlineChunk(blockType, depth, true, // atomic blocks within non-atomic blocks must always be split out
- blockDataMap);
- } // Recurse through children
-
-
- var child = node.firstChild; // hack to allow conversion of atomic blocks from HTML (e.g. <figure><img
- // src="..." /></figure>). since metadata must be stored on an entity text
- // must exist for the entity to apply to. the way chunks are joined strips
- // whitespace at the end so it cannot be a space character.
-
- if (child == null && inEntity && (blockType === 'atomic' || inBlock === 'atomic')) {
- child = document.createTextNode('a');
- }
-
- if (child != null) {
- nodeName = child.nodeName.toLowerCase();
- }
-
- var entityId = null;
-
- while (child) {
- entityId = checkEntityNode(nodeName, child, createEntity, getEntity, mergeEntityData, replaceEntityData);
- newChunk = genFragment(child, inlineStyle, lastList, inBlock, fragmentBlockTags, depth, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, entityId || inEntity);
- chunk = joinChunks(chunk, newChunk, options.flat);
- var sibling = child.nextSibling; // Put in a newline to break up blocks inside blocks
-
- if (sibling && fragmentBlockTags.indexOf(nodeName) >= 0 && inBlock) {
- var newBlockInfo = checkBlockType(nodeName, child, lastList, inBlock);
- var newBlockType = void 0;
- var newBlockData = void 0;
-
- if (newBlockInfo !== false) {
- newBlockInfo = newBlockInfo || {};
-
- if (typeof newBlockInfo === 'string') {
- newBlockType = newBlockInfo;
- newBlockData = (0, immutable$2.Map)();
- } else {
- newBlockType = newBlockInfo.type || getBlockTypeForTag(nodeName, lastList);
- newBlockData = newBlockInfo.data ? (0, immutable$2.Map)(newBlockInfo.data) : (0, immutable$2.Map)();
- }
-
- chunk = joinChunks(chunk, getSoftNewlineChunk(newBlockType, depth, options.flat, newBlockData), options.flat);
- }
- }
-
- if (sibling) {
- nodeName = sibling.nodeName.toLowerCase();
- }
-
- child = sibling;
- }
-
- if (newBlock) {
- chunk = joinChunks(chunk, getBlockDividerChunk(nextBlockType, depth, (0, immutable$2.Map)()), options.flat);
- }
-
- return chunk;
- }
-
- function getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder) {
- html = html.trim().replace(REGEX_CR, '').replace(REGEX_NBSP, SPACE);
- var safeBody = DOMBuilder(html);
-
- if (!safeBody) {
- return null;
- } // Sometimes we aren't dealing with content that contains nice semantic
- // tags. In this case, use divs to separate everything out into paragraphs
- // and hope for the best.
-
-
- var workingBlocks = containsSemanticBlockMarkup(html) ? blockTags.concat(['div']) : ['div']; // Start with -1 block depth to offset the fact that we are passing in a fake
- // UL block to sta rt with.
-
- var chunk = genFragment(safeBody, (0, immutable$2.OrderedSet)(), 'ul', null, workingBlocks, -1, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options); // join with previous block to prevent weirdness on paste
-
- if (chunk.text.indexOf('\r') === 0) {
- chunk = {
- text: chunk.text.slice(1),
- inlines: chunk.inlines.slice(1),
- entities: chunk.entities.slice(1),
- blocks: chunk.blocks
- };
- } // Kill block delimiter at the end
-
-
- if (chunk.text.slice(-1) === '\r') {
- chunk.text = chunk.text.slice(0, -1);
- chunk.inlines = chunk.inlines.slice(0, -1);
- chunk.entities = chunk.entities.slice(0, -1);
- chunk.blocks.pop();
- } // If we saw no block tags, put an unstyled one in
-
-
- if (chunk.blocks.length === 0) {
- chunk.blocks.push({
- type: 'unstyled',
- data: (0, immutable$2.Map)(),
- depth: 0
- });
- } // Sometimes we start with text that isn't in a block, which is then
- // followed by blocks. Need to fix up the blocks to add in
- // an unstyled block for this content
-
-
- if (chunk.text.split('\r').length === chunk.blocks.length + 1) {
- chunk.blocks.unshift({
- type: 'unstyled',
- data: (0, immutable$2.Map)(),
- depth: 0
- });
- }
-
- return chunk;
- }
-
- function convertFromHTMLtoContentBlocks(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder, generateKey) {
- // Be ABSOLUTELY SURE that the dom builder you pass hare won't execute
- // arbitrary code in whatever environment you're running this in. For an
- // example of how we try to do this in-browser, see getSafeBodyFromHTML.
- var chunk = getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder);
-
- if (chunk == null) {
- return [];
- }
-
- var start = 0;
- return chunk.text.split('\r').map(function (textBlock, blockIndex) {
- // Make absolutely certain that our text is acceptable.
- textBlock = sanitizeDraftText(textBlock);
- var end = start + textBlock.length;
- var inlines = nullthrows(chunk).inlines.slice(start, end);
- var entities = nullthrows(chunk).entities.slice(start, end);
- var characterList = (0, immutable$2.List)(inlines.map(function (style, entityIndex) {
- var data = {
- style: style,
- entity: null
- };
-
- if (entities[entityIndex]) {
- data.entity = entities[entityIndex];
- }
-
- return Draft.CharacterMetadata.create(data);
- }));
- start = end + 1;
- return new Draft.ContentBlock({
- key: generateKey(),
- type: nullthrows(chunk).blocks[blockIndex].type,
- data: nullthrows(chunk).blocks[blockIndex].data,
- depth: nullthrows(chunk).blocks[blockIndex].depth,
- text: textBlock,
- characterList: characterList
- });
- });
- }
-
- var convertFromHTML = function convertFromHTML(_ref2) {
- var _ref2$htmlToStyle = _ref2.htmlToStyle,
- htmlToStyle = _ref2$htmlToStyle === void 0 ? defaultHTMLToStyle : _ref2$htmlToStyle,
- _ref2$htmlToEntity = _ref2.htmlToEntity,
- htmlToEntity = _ref2$htmlToEntity === void 0 ? defaultHTMLToEntity : _ref2$htmlToEntity,
- _ref2$textToEntity = _ref2.textToEntity,
- textToEntity = _ref2$textToEntity === void 0 ? defaultTextToEntity : _ref2$textToEntity,
- _ref2$htmlToBlock = _ref2.htmlToBlock,
- htmlToBlock = _ref2$htmlToBlock === void 0 ? defaultHTMLToBlock : _ref2$htmlToBlock;
- return function (html) {
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
- flat: false
- };
- var DOMBuilder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _parseHTML["default"];
- var generateKey = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Draft.genKey;
-
- var contentState = Draft.ContentState.createFromText('');
-
- var createEntityWithContentState = function createEntityWithContentState() {
- if (contentState.createEntity) {
- var _contentState;
-
- contentState = (_contentState = contentState).createEntity.apply(_contentState, arguments);
- return contentState.getLastCreatedEntityKey();
- }
-
- return Draft.Entity.create.apply(Draft.Entity, arguments);
- };
-
- var getEntityWithContentState = function getEntityWithContentState() {
- if (contentState.getEntity) {
- var _contentState2;
-
- return (_contentState2 = contentState).getEntity.apply(_contentState2, arguments);
- }
-
- return Draft.Entity.get.apply(Draft.Entity, arguments);
- };
-
- var mergeEntityDataWithContentState = function mergeEntityDataWithContentState() {
- if (contentState.mergeEntityData) {
- var _contentState3;
-
- contentState = (_contentState3 = contentState).mergeEntityData.apply(_contentState3, arguments);
- return;
- }
-
- Draft.Entity.mergeData.apply(Draft.Entity, arguments);
- };
-
- var replaceEntityDataWithContentState = function replaceEntityDataWithContentState() {
- if (contentState.replaceEntityData) {
- var _contentState4;
-
- contentState = (_contentState4 = contentState).replaceEntityData.apply(_contentState4, arguments);
- return;
- }
-
- Draft.Entity.replaceData.apply(Draft.Entity, arguments);
- };
-
- var contentBlocks = convertFromHTMLtoContentBlocks(html, handleMiddleware(htmlToStyle, baseProcessInlineTag), handleMiddleware(htmlToEntity, defaultHTMLToEntity), handleMiddleware(textToEntity, defaultTextToEntity), handleMiddleware(htmlToBlock, baseCheckBlockType), createEntityWithContentState, getEntityWithContentState, mergeEntityDataWithContentState, replaceEntityDataWithContentState, options, DOMBuilder, generateKey);
-
- var blockMap = Draft.BlockMapBuilder.createFromArray(contentBlocks);
-
- var firstBlockKey = contentBlocks[0].getKey();
- return contentState.merge({
- blockMap: blockMap,
- selectionBefore: Draft.SelectionState.createEmpty(firstBlockKey),
- selectionAfter: Draft.SelectionState.createEmpty(firstBlockKey)
- });
- };
- };
-
- var _default = function _default() {
- if (arguments.length >= 1 && typeof (arguments.length <= 0 ? undefined : arguments[0]) === 'string') {
- return convertFromHTML({}).apply(void 0, arguments);
- }
-
- return convertFromHTML.apply(void 0, arguments);
- };
-
- exports["default"] = _default;
- });
-
- unwrapExports(convertFromHTML_1);
-
- var lib = createCommonjsModule(function (module, exports) {
-
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- Object.defineProperty(exports, "convertToHTML", {
- enumerable: true,
- get: function get() {
- return _convertToHTML["default"];
- }
- });
- Object.defineProperty(exports, "convertFromHTML", {
- enumerable: true,
- get: function get() {
- return _convertFromHTML["default"];
- }
- });
- Object.defineProperty(exports, "parseHTML", {
- enumerable: true,
- get: function get() {
- return _parseHTML["default"];
- }
- });
-
- var _convertToHTML = interopRequireDefault(convertToHTML_1);
-
- var _convertFromHTML = interopRequireDefault(convertFromHTML_1);
-
- var _parseHTML = interopRequireDefault(parseHTML_1);
- });
-
- unwrapExports(lib);
-
- var configs = createCommonjsModule(function (module, exports) {
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.getFromHTMLConfig = exports.getToHTMLConfig = exports.blocks = exports.getHexColor = exports.defaultFontFamilies = exports.namedColors = undefined;
-
- var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
-
-
-
- var _react2 = _interopRequireDefault(React);
-
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
- function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
-
- var namedColors = exports.namedColors = {
- "aliceblue": "#f0f8ff",
- "antiquewhite": "#faebd7",
- "aqua": "#00ffff",
- "aquamarine": "#7fffd4",
- "azure": "#f0ffff",
- "beige": "#f5f5dc",
- "bisque": "#ffe4c4",
- "black": "#000000",
- "blanchedalmond": "#ffebcd",
- "blue": "#0000ff",
- "blueviolet": "#8a2be2",
- "brown": "#a52a2a",
- "burlywood": "#deb887",
- "cadetblue": "#5f9ea0",
- "chartreuse": "#7fff00",
- "chocolate": "#d2691e",
- "coral": "#ff7f50",
- "cornflowerblue": "#6495ed",
- "cornsilk": "#fff8dc",
- "crimson": "#dc143c",
- "cyan": "#00ffff",
- "darkblue": "#00008b",
- "darkcyan": "#008b8b",
- "darkgoldenrod": "#b8860b",
- "darkgray": "#a9a9a9",
- "darkgreen": "#006400",
- "darkkhaki": "#bdb76b",
- "darkmagenta": "#8b008b",
- "darkolivegreen": "#556b2f",
- "darkorange": "#ff8c00",
- "darkorchid": "#9932cc",
- "darkred": "#8b0000",
- "darksalmon": "#e9967a",
- "darkseagreen": "#8fbc8f",
- "darkslateblue": "#483d8b",
- "darkslategray": "#2f4f4f",
- "darkturquoise": "#00ced1",
- "darkviolet": "#9400d3",
- "deeppink": "#ff1493",
- "deepskyblue": "#00bfff",
- "dimgray": "#696969",
- "dodgerblue": "#1e90ff",
- "firebrick": "#b22222",
- "floralwhite": "#fffaf0",
- "forestgreen": "#228b22",
- "fuchsia": "#ff00ff",
- "gainsboro": "#dcdcdc",
- "ghostwhite": "#f8f8ff",
- "gold": "#ffd700",
- "goldenrod": "#daa520",
- "gray": "#808080",
- "green": "#008000",
- "greenyellow": "#adff2f",
- "honeydew": "#f0fff0",
- "hotpink": "#ff69b4",
- "indianred ": "#cd5c5c",
- "indigo": "#4b0082",
- "ivory": "#fffff0",
- "khaki": "#f0e68c",
- "lavender": "#e6e6fa",
- "lavenderblush": "#fff0f5",
- "lawngreen": "#7cfc00",
- "lemonchiffon": "#fffacd",
- "lightblue": "#add8e6",
- "lightcoral": "#f08080",
- "lightcyan": "#e0ffff",
- "lightgoldenrodyellow": "#fafad2",
- "lightgrey": "#d3d3d3",
- "lightgreen": "#90ee90",
- "lightpink": "#ffb6c1",
- "lightsalmon": "#ffa07a",
- "lightseagreen": "#20b2aa",
- "lightskyblue": "#87cefa",
- "lightslategray": "#778899",
- "lightsteelblue": "#b0c4de",
- "lightyellow": "#ffffe0",
- "lime": "#00ff00",
- "limegreen": "#32cd32",
- "linen": "#faf0e6",
- "magenta": "#ff00ff",
- "maroon": "#800000",
- "mediumaquamarine": "#66cdaa",
- "mediumblue": "#0000cd",
- "mediumorchid": "#ba55d3",
- "mediumpurple": "#9370d8",
- "mediumseagreen": "#3cb371",
- "mediumslateblue": "#7b68ee",
- "mediumspringgreen": "#00fa9a",
- "mediumturquoise": "#48d1cc",
- "mediumvioletred": "#c71585",
- "midnightblue": "#191970",
- "mintcream": "#f5fffa",
- "mistyrose": "#ffe4e1",
- "moccasin": "#ffe4b5",
- "navajowhite": "#ffdead",
- "navy": "#000080",
- "oldlace": "#fdf5e6",
- "olive": "#808000",
- "olivedrab": "#6b8e23",
- "orange": "#ffa500",
- "orangered": "#ff4500",
- "orchid": "#da70d6",
- "palegoldenrod": "#eee8aa",
- "palegreen": "#98fb98",
- "paleturquoise": "#afeeee",
- "palevioletred": "#d87093",
- "papayawhip": "#ffefd5",
- "peachpuff": "#ffdab9",
- "peru": "#cd853f",
- "pink": "#ffc0cb",
- "plum": "#dda0dd",
- "powderblue": "#b0e0e6",
- "purple": "#800080",
- "rebeccapurple": "#663399",
- "red": "#ff0000",
- "rosybrown": "#bc8f8f",
- "royalblue": "#4169e1",
- "saddlebrown": "#8b4513",
- "salmon": "#fa8072",
- "sandybrown": "#f4a460",
- "seagreen": "#2e8b57",
- "seashell": "#fff5ee",
- "sienna": "#a0522d",
- "silver": "#c0c0c0",
- "skyblue": "#87ceeb",
- "slateblue": "#6a5acd",
- "slategray": "#708090",
- "snow": "#fffafa",
- "springgreen": "#00ff7f",
- "steelblue": "#4682b4",
- "tan": "#d2b48c",
- "teal": "#008080",
- "thistle": "#d8bfd8",
- "tomato": "#ff6347",
- "turquoise": "#40e0d0",
- "violet": "#ee82ee",
- "wheat": "#f5deb3",
- "white": "#ffffff",
- "whitesmoke": "#f5f5f5",
- "yellow": "#ffff00",
- "yellowgreen": "#9acd32"
- };
-
- var getStyleValue = function getStyleValue(style) {
- return style.split('-')[1];
- };
- var defaultUnitExportFn = function defaultUnitExportFn(unit) {
- return unit + 'px';
- };
- var defaultUnitImportFn = function defaultUnitImportFn(unit) {
- return unit.replace('px', '');
- };
-
- var ignoredNodeAttributes = ['style'];
- var ignoredEntityNodeAttributes = ['style', 'href', 'target', 'alt', 'title', 'id', 'controls', 'autoplay', 'loop', 'poster'];
-
- var spreadNodeAttributes = function spreadNodeAttributes(attributesObject) {
- return Object.keys(attributesObject).reduce(function (attributeString, attributeName) {
- return attributeString + " " + attributeName + "=\"" + attributesObject[attributeName] + "\"";
- }, '').replace(/^\s$/, '');
- };
-
- var defaultFontFamilies = exports.defaultFontFamilies = [{
- name: 'Araial',
- family: 'Arial, Helvetica, sans-serif'
- }, {
- name: 'Georgia',
- family: 'Georgia, serif'
- }, {
- name: 'Impact',
- family: 'Impact, serif'
- }, {
- name: 'Monospace',
- family: '"Courier New", Courier, monospace'
- }, {
- name: 'Tahoma',
- family: "tahoma, arial, 'Hiragino Sans GB', 宋体, sans-serif"
- }];
-
- var getHexColor = exports.getHexColor = function getHexColor(color) {
-
- color = color.replace('color:', '').replace(';', '').replace(' ', '');
-
- if (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(color)) {
- return color;
- } else if (namedColors[color]) {
- return namedColors[color];
- } else if (color.indexOf('rgb') === 0) {
-
- var rgbArray = color.split(',');
- var convertedColor = rgbArray.length < 3 ? null : '#' + [rgbArray[0], rgbArray[1], rgbArray[2]].map(function (x) {
- var hex = parseInt(x.replace(/\D/g, ''), 10).toString(16);
- return hex.length === 1 ? '0' + hex : hex;
- }).join('');
-
- return (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(convertedColor) ? convertedColor : null
- );
- } else {
- return null;
- }
- };
-
- var blocks = exports.blocks = {
- 'header-one': 'h1',
- 'header-two': 'h2',
- 'header-three': 'h3',
- 'header-four': 'h4',
- 'header-five': 'h5',
- 'header-six': 'h6',
- 'unstyled': 'p',
- 'blockquote': 'blockquote'
- };
-
- var blockTypes = Object.keys(blocks);
- var blockNames = blockTypes.map(function (key) {
- return blocks[key];
- });
-
- var convertAtomicBlock = function convertAtomicBlock(block, contentState, blockNodeAttributes) {
-
- if (!block || !block.key) {
- return _react2.default.createElement("p", null);
- }
-
- var contentBlock = contentState.getBlockForKey(block.key);
-
- var className = blockNodeAttributes.class,
- nodeAttrAsProps = _objectWithoutProperties(blockNodeAttributes, ["class"]);
-
- nodeAttrAsProps.className = className;
-
- if (!contentBlock) {
- return _react2.default.createElement("p", null);
- }
-
- var entityKey = contentBlock.getEntityAt(0);
-
- if (!entityKey) {
- return _react2.default.createElement("p", null);
- }
-
- var entity = contentState.getEntity(entityKey);
- var mediaType = entity.getType().toLowerCase();
-
- var _block$data = block.data,
- float = _block$data.float,
- alignment = _block$data.alignment;
-
- var _entity$getData = entity.getData(),
- url = _entity$getData.url,
- link = _entity$getData.link,
- link_target = _entity$getData.link_target,
- width = _entity$getData.width,
- height = _entity$getData.height,
- meta = _entity$getData.meta;
-
- if (mediaType === 'image') {
-
- var imageWrapStyle = {};
- var styledClassName = '';
-
- if (float) {
- imageWrapStyle.float = float;
- styledClassName += ' float-' + float;
- } else if (alignment) {
- imageWrapStyle.textAlign = alignment;
- styledClassName += ' align-' + alignment;
- }
-
- if (link) {
- return _react2.default.createElement(
- "div",
- { className: "media-wrap image-wrap" + styledClassName, style: imageWrapStyle },
- _react2.default.createElement(
- "a",
- { style: { display: 'inline-block' }, href: link, target: link_target },
- _react2.default.createElement("img", _extends({}, nodeAttrAsProps, meta, { src: url, width: width, height: height, style: { width: width, height: height } }))
- )
- );
- } else {
- return _react2.default.createElement(
- "div",
- { className: "media-wrap image-wrap" + styledClassName, style: imageWrapStyle },
- _react2.default.createElement("img", _extends({}, nodeAttrAsProps, meta, { src: url, width: width, height: height, style: { width: width, height: height } }))
- );
- }
- } else if (mediaType === 'audio') {
- return _react2.default.createElement(
- "div",
- { className: "media-wrap audio-wrap" },
- _react2.default.createElement("audio", _extends({ controls: true }, nodeAttrAsProps, meta, { src: url }))
- );
- } else if (mediaType === 'video') {
- return _react2.default.createElement(
- "div",
- { className: "media-wrap video-wrap" },
- _react2.default.createElement("video", _extends({ controls: true }, nodeAttrAsProps, meta, { src: url, width: width, height: height }))
- );
- } else if (mediaType === 'embed') {
- return _react2.default.createElement(
- "div",
- { className: "media-wrap embed-wrap" },
- _react2.default.createElement("div", { dangerouslySetInnerHTML: { __html: url } })
- );
- } else if (mediaType === 'hr') {
- return _react2.default.createElement("hr", null);
- } else {
- return _react2.default.createElement("p", null);
- }
- };
-
- var entityToHTML = function entityToHTML(options) {
- return function (entity, originalText) {
- var entityExportFn = options.entityExportFn;
-
- var entityType = entity.type.toLowerCase();
-
- if (entityExportFn) {
- var customOutput = entityExportFn(entity, originalText);
- if (customOutput) {
- return customOutput;
- }
- }
-
- if (entityType === 'link') {
- var _ref = entity.data.nodeAttributes || {},
- className = _ref.class,
- nodeAttrAsProps = _objectWithoutProperties(_ref, ["class"]);
-
- nodeAttrAsProps.className = className;
- return _react2.default.createElement("a", _extends({ href: entity.data.href, target: entity.data.target }, nodeAttrAsProps));
- }
- };
- };
-
- var styleToHTML = function styleToHTML(options) {
- return function (style) {
-
- var unitExportFn = options.unitExportFn || defaultUnitExportFn;
-
- if (options.styleExportFn) {
- var customOutput = options.styleExportFn(style, options);
- if (customOutput) {
- return customOutput;
- }
- }
-
- style = style.toLowerCase();
-
- if (style === 'strikethrough') {
- return _react2.default.createElement("span", { style: { textDecoration: 'line-through' } });
- } else if (style === 'superscript') {
- return _react2.default.createElement("sup", null);
- } else if (style === 'subscript') {
- return _react2.default.createElement("sub", null);
- } else if (style.indexOf('color-') === 0) {
- return _react2.default.createElement("span", { style: { color: '#' + getStyleValue(style) } });
- } else if (style.indexOf('bgcolor-') === 0) {
- return _react2.default.createElement("span", { style: { backgroundColor: '#' + getStyleValue(style) } });
- } else if (style.indexOf('fontsize-') === 0) {
- return _react2.default.createElement("span", { style: { fontSize: unitExportFn(getStyleValue(style), 'font-size', 'html') } });
- } else if (style.indexOf('lineheight-') === 0) {
- return _react2.default.createElement("span", { style: { lineHeight: unitExportFn(getStyleValue(style), 'line-height', 'html') } });
- } else if (style.indexOf('letterspacing-') === 0) {
- return _react2.default.createElement("span", { style: { letterSpacing: unitExportFn(getStyleValue(style), 'letter-spacing', 'html') } });
- } else if (style.indexOf('fontfamily-') === 0) {
- var fontFamily = options.fontFamilies.find(function (item) {
- return item.name.toLowerCase() === getStyleValue(style);
- });
- if (!fontFamily) return;
- return _react2.default.createElement("span", { style: { fontFamily: fontFamily.family } });
- }
- };
- };
-
- var blockToHTML = function blockToHTML(options) {
- return function (block) {
- var blockExportFn = options.blockExportFn,
- contentState = options.contentState;
-
-
- if (blockExportFn) {
- var customOutput = blockExportFn(contentState, block);
- if (customOutput) {
- return customOutput;
- }
- }
-
- var blockStyle = '';
-
- var blockType = block.type.toLowerCase();
- var _block$data2 = block.data,
- textAlign = _block$data2.textAlign,
- textIndent = _block$data2.textIndent,
- _block$data2$nodeAttr = _block$data2.nodeAttributes,
- nodeAttributes = _block$data2$nodeAttr === undefined ? {} : _block$data2$nodeAttr;
-
- var attributeString = spreadNodeAttributes(nodeAttributes);
-
- if (textAlign || textIndent) {
-
- blockStyle = ' style="';
-
- if (textAlign) {
- blockStyle += "text-align:" + textAlign + ";";
- }
-
- if (textIndent && !isNaN(textIndent) && textIndent > 0) {
- blockStyle += "text-indent:" + textIndent * 2 + "em;";
- }
-
- blockStyle += '"';
- }
-
- if (blockType === 'atomic') {
- return convertAtomicBlock(block, contentState, nodeAttributes);
- } else if (blockType === 'code-block') {
-
- var previousBlock = contentState.getBlockBefore(block.key);
- var nextBlock = contentState.getBlockAfter(block.key);
- var previousBlockType = previousBlock && previousBlock.getType();
- var nextBlockType = nextBlock && nextBlock.getType();
-
- var start = '';
- var end = '';
-
- if (previousBlockType !== 'code-block') {
- start = "<pre" + attributeString + "><code>";
- } else {
- start = '';
- }
-
- if (nextBlockType !== 'code-block') {
- end = '</code></pre>';
- } else {
- end = '<br/>';
- }
-
- return { start: start, end: end };
- } else if (blocks[blockType]) {
- return {
- start: "<" + blocks[blockType] + blockStyle + attributeString + ">",
- end: "</" + blocks[blockType] + ">"
- };
- } else if (blockType === 'unordered-list-item') {
- return {
- start: "<li" + blockStyle + attributeString + ">",
- end: '</li>',
- nest: _react2.default.createElement("ul", null)
- };
- } else if (blockType === 'ordered-list-item') {
- return {
- start: "<li" + blockStyle + attributeString + ">",
- end: '</li>',
- nest: _react2.default.createElement("ol", null)
- };
- }
- };
- };
-
- var htmlToStyle = function htmlToStyle(options, source) {
- return function (nodeName, node, currentStyle) {
-
- if (!node || !node.style) {
- return currentStyle;
- }
-
- var unitImportFn = options.unitImportFn || defaultUnitImportFn;
- var newStyle = currentStyle;
-
- [].forEach.call(node.style, function (style) {
-
- if (nodeName === 'span' && style === 'color') {
- var color = getHexColor(node.style.color);
- newStyle = color ? newStyle.add('COLOR-' + color.replace('#', '').toUpperCase()) : newStyle;
- } else if (nodeName === 'span' && style === 'background-color') {
- var _color = getHexColor(node.style.backgroundColor);
- newStyle = _color ? newStyle.add('BGCOLOR-' + _color.replace('#', '').toUpperCase()) : newStyle;
- } else if (nodeName === 'span' && style === 'font-size') {
- newStyle = newStyle.add('FONTSIZE-' + unitImportFn(node.style.fontSize, 'font-size', source));
- } else if (nodeName === 'span' && style === 'line-height' && !isNaN(parseFloat(node.style.lineHeight, 10))) {
- newStyle = newStyle.add('LINEHEIGHT-' + unitImportFn(node.style.lineHeight, 'line-height', source));
- } else if (nodeName === 'span' && style === 'letter-spacing' && !isNaN(parseFloat(node.style.letterSpacing, 10))) {
- newStyle = newStyle.add('LETTERSPACING-' + unitImportFn(node.style.letterSpacing, 'letter-spacing', source));
- } else if (nodeName === 'span' && style === 'text-decoration') {
- if (node.style.textDecoration === 'line-through') {
- newStyle = newStyle.add('STRIKETHROUGH');
- } else if (node.style.textDecoration === 'underline') {
- newStyle = newStyle.add('UNDERLINE');
- }
- } else if (nodeName === 'span' && style === 'font-family') {
- var fontFamily = options.fontFamilies.find(function (item) {
- return item.family.toLowerCase() === node.style.fontFamily.toLowerCase();
- });
- if (!fontFamily) return;
- newStyle = newStyle.add('FONTFAMILY-' + fontFamily.name.toUpperCase());
- }
- });
-
- if (nodeName === 'sup') {
- newStyle = newStyle.add('SUPERSCRIPT');
- } else if (nodeName === 'sub') {
- newStyle = newStyle.add('SUBSCRIPT');
- }
-
- options.styleImportFn && (newStyle = options.styleImportFn(nodeName, node, newStyle, source) || newStyle);
- return newStyle;
- };
- };
-
- var htmlToEntity = function htmlToEntity(options, source) {
- return function (nodeName, node, createEntity) {
-
- if (options && options.entityImportFn) {
- var customInput = options.entityImportFn(nodeName, node, createEntity, source);
- if (customInput) {
- return customInput;
- }
- }
-
- nodeName = nodeName.toLowerCase();
-
- var alt = node.alt,
- title = node.title,
- id = node.id,
- controls = node.controls,
- autoplay = node.autoplay,
- loop = node.loop,
- poster = node.poster;
-
- var meta = {};
- var nodeAttributes = {};
-
- id && (meta.id = id);
- alt && (meta.alt = alt);
- title && (meta.title = title);
- controls && (meta.controls = controls);
- autoplay && (meta.autoPlay = autoplay);
- loop && (meta.loop = loop);
- poster && (meta.poster = poster);
-
- node.attributes && Object.keys(node.attributes).forEach(function (key) {
- var attr = node.attributes[key];
- ignoredEntityNodeAttributes.indexOf(attr.name) === -1 && (nodeAttributes[attr.name] = attr.value);
- });
-
- if (nodeName === 'a' && !node.querySelectorAll('img').length) {
- var href = node.getAttribute('href');
- var _target = node.getAttribute('target');
- return createEntity('LINK', 'MUTABLE', { href: href, target: _target, nodeAttributes: nodeAttributes });
- } else if (nodeName === 'audio') {
- return createEntity('AUDIO', 'IMMUTABLE', { url: node.getAttribute('src'), meta: meta, nodeAttributes: nodeAttributes });
- } else if (nodeName === 'video') {
- return createEntity('VIDEO', 'IMMUTABLE', { url: node.getAttribute('src'), meta: meta, nodeAttributes: nodeAttributes });
- } else if (nodeName === 'img') {
-
- var parentNode = node.parentNode;
- var entityData = { meta: meta };
- var _node$style = node.style,
- width = _node$style.width,
- height = _node$style.height;
-
-
- entityData.url = node.getAttribute('src');
- width && (entityData.width = width);
- height && (entityData.height = height);
-
- if (parentNode.nodeName.toLowerCase() === 'a') {
- entityData.link = parentNode.getAttribute('href');
- entityData.link_target = parentNode.getAttribute('target');
- }
-
- return createEntity('IMAGE', 'IMMUTABLE', entityData);
- } else if (nodeName === 'hr') {
- return createEntity('HR', 'IMMUTABLE', {});
- } else if (node.parentNode && node.parentNode.classList.contains('embed-wrap')) {
-
- var embedContent = node.innerHTML || node.outerHTML;
-
- if (embedContent) {
- return createEntity('EMBED', 'IMMUTABLE', {
- url: embedContent
- });
- }
- }
- };
- };
-
- var htmlToBlock = function htmlToBlock(options, source) {
- return function (nodeName, node) {
-
- if (options && options.blockImportFn) {
- var customInput = options.blockImportFn(nodeName, node, source);
- if (customInput) {
- return customInput;
- }
- }
-
- var nodeAttributes = {};
- var nodeStyle = node.style || {};
-
- node.attributes && Object.keys(node.attributes).forEach(function (key) {
- var attr = node.attributes[key];
- ignoredNodeAttributes.indexOf(attr.name) === -1 && (nodeAttributes[attr.name] = attr.value);
- });
-
- if (node.classList && node.classList.contains('media-wrap')) {
-
- return {
- type: 'atomic',
- data: {
- nodeAttributes: nodeAttributes,
- float: nodeStyle.float,
- alignment: nodeStyle.textAlign
- }
- };
- } else if (nodeName === 'img') {
-
- return {
- type: 'atomic',
- data: {
- nodeAttributes: nodeAttributes,
- float: nodeStyle.float,
- alignment: nodeStyle.textAlign
- }
- };
- } else if (nodeName === 'hr') {
-
- return {
- type: 'atomic',
- data: { nodeAttributes: nodeAttributes }
- };
- } else if (nodeName === 'pre') {
-
- node.innerHTML = node.innerHTML.replace(/<code(.*?)>/g, '').replace(/<\/code>/g, '');
-
- return {
- type: 'code-block',
- data: { nodeAttributes: nodeAttributes }
- };
- } else if (blockNames.indexOf(nodeName) !== -1) {
-
- var blockData = { nodeAttributes: nodeAttributes };
-
- if (nodeStyle.textAlign) {
- blockData.textAlign = nodeStyle.textAlign;
- }
-
- if (nodeStyle.textIndent) {
- blockData.textIndent = /^\d+em$/.test(nodeStyle.textIndent) ? Math.ceil(parseInt(nodeStyle.textIndent, 10) / 2) : 1;
- }
-
- return {
- type: blockTypes[blockNames.indexOf(nodeName)],
- data: blockData
- };
- }
- };
- };
-
- var getToHTMLConfig = exports.getToHTMLConfig = function getToHTMLConfig(options) {
-
- return {
- styleToHTML: styleToHTML(options),
- entityToHTML: entityToHTML(options),
- blockToHTML: blockToHTML(options)
- };
- };
-
- var getFromHTMLConfig = exports.getFromHTMLConfig = function getFromHTMLConfig(options) {
- var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'unknow';
-
-
- return {
- htmlToStyle: htmlToStyle(options, source),
- htmlToEntity: htmlToEntity(options, source),
- htmlToBlock: htmlToBlock(options, source)
- };
- };
-
- });
-
- unwrapExports(configs);
- var configs_1 = configs.getFromHTMLConfig;
- var configs_2 = configs.getToHTMLConfig;
- var configs_3 = configs.blocks;
- var configs_4 = configs.getHexColor;
- var configs_5 = configs.defaultFontFamilies;
- var configs_6 = configs.namedColors;
-
- var dist = createCommonjsModule(function (module, exports) {
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.convertRawToEditorState = exports.convertEditorStateToRaw = exports.convertHTMLToEditorState = exports.convertEditorStateToHTML = exports.convertHTMLToRaw = exports.convertRawToHTML = undefined;
-
- var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
-
-
-
-
-
-
-
- var defaultConvertOptions = {
- fontFamilies: configs.defaultFontFamilies
- };
-
- var convertRawToHTML = exports.convertRawToHTML = function convertRawToHTML(rawContent, options) {
-
- options = _extends({}, defaultConvertOptions, options);
-
- try {
- var contentState = (0, Draft.convertFromRaw)(rawContent);
- options.contentState = contentState;
- return (0, lib.convertToHTML)((0, configs.getToHTMLConfig)(options))(contentState);
- } catch (error) {
- console.warn(error);
- return '';
- }
- };
-
- var convertHTMLToRaw = exports.convertHTMLToRaw = function convertHTMLToRaw(HTMLString, options, source) {
-
- options = _extends({}, defaultConvertOptions, options);
-
- try {
- var contentState = (0, lib.convertFromHTML)((0, configs.getFromHTMLConfig)(options, source))(HTMLString);
- return (0, Draft.convertToRaw)(contentState);
- } catch (error) {
- console.warn(error);
- return {};
- }
- };
-
- var convertEditorStateToHTML = exports.convertEditorStateToHTML = function convertEditorStateToHTML(editorState, options) {
-
- options = _extends({}, defaultConvertOptions, options);
-
- try {
- var contentState = editorState.getCurrentContent();
- options.contentState = contentState;
- return (0, lib.convertToHTML)((0, configs.getToHTMLConfig)(options))(contentState);
- } catch (error) {
- console.warn(error);
- return '';
- }
- };
-
- var convertHTMLToEditorState = exports.convertHTMLToEditorState = function convertHTMLToEditorState(HTMLString, editorDecorators, options, source) {
-
- options = _extends({}, defaultConvertOptions, options);
-
- try {
- return Draft.EditorState.createWithContent((0, lib.convertFromHTML)((0, configs.getFromHTMLConfig)(options, source))(HTMLString), editorDecorators);
- } catch (error) {
- console.warn(error);
- return Draft.EditorState.createEmpty(editorDecorators);
- }
- };
-
- var convertEditorStateToRaw = exports.convertEditorStateToRaw = function convertEditorStateToRaw(editorState) {
- return (0, Draft.convertToRaw)(editorState.getCurrentContent());
- };
-
- var convertRawToEditorState = exports.convertRawToEditorState = function convertRawToEditorState(rawContent, editorDecorators) {
-
- try {
- return Draft.EditorState.createWithContent((0, Draft.convertFromRaw)(rawContent), editorDecorators);
- } catch (error) {
- console.warn(error);
- return Draft.EditorState.createEmpty(editorDecorators);
- }
- };
-
- });
-
- unwrapExports(dist);
- var dist_1 = dist.convertRawToEditorState;
- var dist_2 = dist.convertEditorStateToRaw;
- var dist_3 = dist.convertHTMLToEditorState;
- var dist_4 = dist.convertEditorStateToHTML;
- var dist_5 = dist.convertHTMLToRaw;
- var dist_6 = dist.convertRawToHTML;
-
- var content = createCommonjsModule(function (module, exports) {
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- 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;
-
-
-
-
-
-
-
-
-
- var _immutable2 = _interopRequireDefault(immutable$1);
-
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
- var strictBlockTypes = ['atomic'];
-
- var registerStrictBlockType = exports.registerStrictBlockType = function registerStrictBlockType(blockType) {
- strictBlockTypes.indexOf(blockType) === -1 && strictBlockTypes.push(blockType);
- };
-
- var isEditorState = exports.isEditorState = function isEditorState(editorState) {
- return editorState instanceof Draft.EditorState;
- };
-
- var createEmptyEditorState = exports.createEmptyEditorState = function createEmptyEditorState(editorDecorators) {
- return Draft.EditorState.createEmpty(editorDecorators);
- };
-
- var createEditorState = exports.createEditorState = function createEditorState(contentState, editorDecorators) {
- return Draft.EditorState.createWithContent(contentState, editorDecorators);
- };
-
- var isSelectionCollapsed = exports.isSelectionCollapsed = function isSelectionCollapsed(editorState) {
- return editorState.getSelection().isCollapsed();
- };
-
- var selectionContainsBlockType = exports.selectionContainsBlockType = function selectionContainsBlockType(editorState, blockType) {
- return getSelectedBlocks(editorState).find(function (block) {
- return block.getType() === blockType;
- });
- };
-
- var selectionContainsStrictBlock = exports.selectionContainsStrictBlock = function selectionContainsStrictBlock(editorState) {
- return getSelectedBlocks(editorState).find(function (block) {
- return ~strictBlockTypes.indexOf(block.getType());
- });
- };
-
- var selectBlock = exports.selectBlock = function selectBlock(editorState, block) {
-
- var blockKey = block.getKey();
-
- return Draft.EditorState.forceSelection(editorState, new Draft.SelectionState({
- anchorKey: blockKey,
- anchorOffset: 0,
- focusKey: blockKey,
- focusOffset: block.getLength()
- }));
- };
-
- var selectNextBlock = exports.selectNextBlock = function selectNextBlock(editorState, block) {
- var nextBlock = editorState.getCurrentContent().getBlockAfter(block.getKey());
- return nextBlock ? selectBlock(editorState, nextBlock) : editorState;
- };
-
- var removeBlock = exports.removeBlock = function removeBlock(editorState, block) {
- var lastSelection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
-
-
- var nextContentState = void 0,
- nextEditorState = void 0;
- var blockKey = block.getKey();
-
- nextContentState = Draft.Modifier.removeRange(editorState.getCurrentContent(), new Draft.SelectionState({
- anchorKey: blockKey,
- anchorOffset: 0,
- focusKey: blockKey,
- focusOffset: block.getLength()
- }), 'backward');
-
- nextContentState = Draft.Modifier.setBlockType(nextContentState, nextContentState.getSelectionAfter(), 'unstyled');
- nextEditorState = Draft.EditorState.push(editorState, nextContentState, 'remove-range');
- return Draft.EditorState.forceSelection(nextEditorState, lastSelection || nextContentState.getSelectionAfter());
- };
-
- var getSelectionBlock = exports.getSelectionBlock = function getSelectionBlock(editorState) {
- return editorState.getCurrentContent().getBlockForKey(editorState.getSelection().getAnchorKey());
- };
-
- var updateEachCharacterOfSelection = exports.updateEachCharacterOfSelection = function updateEachCharacterOfSelection(editorState, callback) {
-
- var selectionState = editorState.getSelection();
- var contentState = editorState.getCurrentContent();
- var contentBlocks = contentState.getBlockMap();
- var selectedBlocks = getSelectedBlocks(editorState);
-
- if (selectedBlocks.length === 0) {
- return editorState;
- }
-
- var startKey = selectionState.getStartKey();
- var startOffset = selectionState.getStartOffset();
- var endKey = selectionState.getEndKey();
- var endOffset = selectionState.getEndOffset();
-
- var nextContentBlocks = contentBlocks.map(function (block) {
-
- if (selectedBlocks.indexOf(block) === -1) {
- return block;
- }
-
- var blockKey = block.getKey();
- var charactersList = block.getCharacterList();
- var nextCharactersList = null;
-
- if (blockKey === startKey && blockKey === endKey) {
- nextCharactersList = charactersList.map(function (character, index) {
- if (index >= startOffset && index < endOffset) {
- return callback(character);
- }
- return character;
- });
- } else if (blockKey === startKey) {
- nextCharactersList = charactersList.map(function (character, index) {
- if (index >= startOffset) {
- return callback(character);
- }
- return character;
- });
- } else if (blockKey === endKey) {
- nextCharactersList = charactersList.map(function (character, index) {
- if (index < endOffset) {
- return callback(character);
- }
- return character;
- });
- } else {
- nextCharactersList = charactersList.map(function (character) {
- return callback(character);
- });
- }
-
- return block.merge({
- 'characterList': nextCharactersList
- });
- });
-
- return Draft.EditorState.push(editorState, contentState.merge({
- blockMap: nextContentBlocks,
- selectionBefore: selectionState,
- selectionAfter: selectionState
- }), 'update-selection-character-list');
- };
-
- var getSelectedBlocks = exports.getSelectedBlocks = function getSelectedBlocks(editorState) {
-
- var selectionState = editorState.getSelection();
- var contentState = editorState.getCurrentContent();
-
- var startKey = selectionState.getStartKey();
- var endKey = selectionState.getEndKey();
- var isSameBlock = startKey === endKey;
- var startingBlock = contentState.getBlockForKey(startKey);
- var selectedBlocks = [startingBlock];
-
- if (!isSameBlock) {
- var blockKey = startKey;
-
- while (blockKey !== endKey) {
- var nextBlock = contentState.getBlockAfter(blockKey);
- selectedBlocks.push(nextBlock);
- blockKey = nextBlock.getKey();
- }
- }
-
- return selectedBlocks;
- };
-
- var setSelectionBlockData = exports.setSelectionBlockData = function setSelectionBlockData(editorState, blockData, override) {
-
- var newBlockData = override ? blockData : Object.assign({}, getSelectionBlockData(editorState).toJS(), blockData);
-
- Object.keys(newBlockData).forEach(function (key) {
- if (newBlockData.hasOwnProperty(key) && newBlockData[key] === undefined) {
- delete newBlockData[key];
- }
- });
-
- return (0, draftjsUtils.setBlockData)(editorState, newBlockData);
- };
-
- var getSelectionBlockData = exports.getSelectionBlockData = function getSelectionBlockData(editorState, name) {
- var blockData = getSelectionBlock(editorState).getData();
- return name ? blockData.get(name) : blockData;
- };
-
- var getSelectionBlockType = exports.getSelectionBlockType = function getSelectionBlockType(editorState) {
- return getSelectionBlock(editorState).getType();
- };
-
- var getSelectionText = exports.getSelectionText = function getSelectionText(editorState) {
-
- var selectionState = editorState.getSelection();
- var contentState = editorState.getCurrentContent();
-
- if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
- return '';
- }
-
- var anchorKey = selectionState.getAnchorKey();
- var currentContentBlock = contentState.getBlockForKey(anchorKey);
- var start = selectionState.getStartOffset();
- var end = selectionState.getEndOffset();
-
- return currentContentBlock.getText().slice(start, end);
- };
-
- var toggleSelectionBlockType = exports.toggleSelectionBlockType = function toggleSelectionBlockType(editorState, blockType) {
-
- if (selectionContainsStrictBlock(editorState)) {
- return editorState;
- }
-
- return Draft.RichUtils.toggleBlockType(editorState, blockType);
- };
-
- var getSelectionEntityType = exports.getSelectionEntityType = function getSelectionEntityType(editorState) {
-
- var entityKey = (0, draftjsUtils.getSelectionEntity)(editorState);
-
- if (entityKey) {
- var entity = editorState.getCurrentContent().getEntity(entityKey);
- return entity ? entity.get('type') : null;
- }
-
- return null;
- };
-
- var getSelectionEntityData = exports.getSelectionEntityData = function getSelectionEntityData(editorState, type) {
-
- var entityKey = (0, draftjsUtils.getSelectionEntity)(editorState);
-
- if (entityKey) {
- var entity = editorState.getCurrentContent().getEntity(entityKey);
- if (entity && entity.get('type') === type) {
- return entity.getData();
- } else {
- return {};
- }
- } else {
- return {};
- }
- };
-
- var toggleSelectionEntity = exports.toggleSelectionEntity = function toggleSelectionEntity(editorState, entity) {
-
- var contentState = editorState.getCurrentContent();
- var selectionState = editorState.getSelection();
-
- if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
- return editorState;
- }
-
- if (!entity || !entity.type || getSelectionEntityType(editorState) === entity.type) {
- return Draft.EditorState.push(editorState, Draft.Modifier.applyEntity(contentState, selectionState, null), 'apply-entity');
- }
-
- try {
-
- var nextContentState = contentState.createEntity(entity.type, entity.mutability, entity.data);
- var entityKey = nextContentState.getLastCreatedEntityKey();
-
- var nextEditorState = Draft.EditorState.set(editorState, {
- currentContent: nextContentState
- });
-
- return Draft.EditorState.push(nextEditorState, Draft.Modifier.applyEntity(nextContentState, selectionState, entityKey), 'apply-entity');
- } catch (error) {
- console.warn(error);
- return editorState;
- }
- };
-
- var toggleSelectionLink = exports.toggleSelectionLink = function toggleSelectionLink(editorState, href, target) {
-
- var contentState = editorState.getCurrentContent();
- var selectionState = editorState.getSelection();
-
- var entityData = { href: href, target: target };
-
- if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
- return editorState;
- }
-
- if (href === false) {
- return Draft.RichUtils.toggleLink(editorState, selectionState, null);
- }
-
- if (href === null) {
- delete entityData.href;
- }
-
- try {
-
- var nextContentState = contentState.createEntity('LINK', 'MUTABLE', entityData);
- var entityKey = nextContentState.getLastCreatedEntityKey();
-
- var nextEditorState = Draft.EditorState.set(editorState, {
- currentContent: nextContentState
- });
-
- nextEditorState = Draft.RichUtils.toggleLink(nextEditorState, selectionState, entityKey);
- nextEditorState = Draft.EditorState.forceSelection(nextEditorState, selectionState.merge({
- anchorOffset: selectionState.getEndOffset(),
- focusOffset: selectionState.getEndOffset()
- }));
-
- nextEditorState = Draft.EditorState.push(nextEditorState, Draft.Modifier.insertText(nextEditorState.getCurrentContent(), nextEditorState.getSelection(), ''), 'insert-text');
-
- return nextEditorState;
- } catch (error) {
- console.warn(error);
- return editorState;
- }
- };
-
- var getSelectionInlineStyle = exports.getSelectionInlineStyle = function getSelectionInlineStyle(editorState) {
- return editorState.getCurrentInlineStyle();
- };
-
- var selectionHasInlineStyle = exports.selectionHasInlineStyle = function selectionHasInlineStyle(editorState, style) {
- return getSelectionInlineStyle(editorState).has(style.toUpperCase());
- };
-
- var toggleSelectionInlineStyle = exports.toggleSelectionInlineStyle = function toggleSelectionInlineStyle(editorState, style) {
- var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
-
-
- var nextEditorState = editorState;
- style = prefix + style.toUpperCase();
-
- if (prefix) {
-
- nextEditorState = updateEachCharacterOfSelection(nextEditorState, function (characterMetadata) {
-
- return characterMetadata.toJS().style.reduce(function (characterMetadata, characterStyle) {
- if (characterStyle.indexOf(prefix) === 0 && style !== characterStyle) {
- return Draft.CharacterMetadata.removeStyle(characterMetadata, characterStyle);
- } else {
- return characterMetadata;
- }
- }, characterMetadata);
- });
- }
-
- return Draft.RichUtils.toggleInlineStyle(nextEditorState, style);
- };
-
- var removeSelectionInlineStyles = exports.removeSelectionInlineStyles = function removeSelectionInlineStyles(editorState) {
-
- return updateEachCharacterOfSelection(editorState, function (characterMetadata) {
- return characterMetadata.merge({
- style: _immutable2.default.OrderedSet([])
- });
- });
- };
-
- var toggleSelectionAlignment = exports.toggleSelectionAlignment = function toggleSelectionAlignment(editorState, alignment) {
- return setSelectionBlockData(editorState, {
- textAlign: getSelectionBlockData(editorState, 'textAlign') !== alignment ? alignment : undefined
- });
- };
-
- var toggleSelectionIndent = exports.toggleSelectionIndent = function toggleSelectionIndent(editorState, textIndent) {
- var maxIndent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 6;
-
- return textIndent < 0 || textIndent > maxIndent || isNaN(textIndent) ? editorState : setSelectionBlockData(editorState, {
- textIndent: textIndent || undefined
- });
- };
-
- var increaseSelectionIndent = exports.increaseSelectionIndent = function increaseSelectionIndent(editorState) {
- var maxIndent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
-
- var currentIndent = getSelectionBlockData(editorState, 'textIndent') || 0;
- return toggleSelectionIndent(editorState, currentIndent + 1, maxIndent);
- };
-
- var decreaseSelectionIndent = exports.decreaseSelectionIndent = function decreaseSelectionIndent(editorState) {
- var currentIndent = getSelectionBlockData(editorState, 'textIndent') || 0;
- return toggleSelectionIndent(editorState, currentIndent - 1);
- };
-
- var toggleSelectionColor = exports.toggleSelectionColor = function toggleSelectionColor(editorState, color) {
- return toggleSelectionInlineStyle(editorState, color.replace('#', ''), 'COLOR-');
- };
-
- var toggleSelectionBackgroundColor = exports.toggleSelectionBackgroundColor = function toggleSelectionBackgroundColor(editorState, color) {
- return toggleSelectionInlineStyle(editorState, color.replace('#', ''), 'BGCOLOR-');
- };
-
- var toggleSelectionFontSize = exports.toggleSelectionFontSize = function toggleSelectionFontSize(editorState, fontSize) {
- return toggleSelectionInlineStyle(editorState, fontSize, 'FONTSIZE-');
- };
-
- var toggleSelectionLineHeight = exports.toggleSelectionLineHeight = function toggleSelectionLineHeight(editorState, lineHeight) {
- return toggleSelectionInlineStyle(editorState, lineHeight, 'LINEHEIGHT-');
- };
-
- var toggleSelectionFontFamily = exports.toggleSelectionFontFamily = function toggleSelectionFontFamily(editorState, fontFamily) {
- return toggleSelectionInlineStyle(editorState, fontFamily, 'FONTFAMILY-');
- };
-
- var toggleSelectionLetterSpacing = exports.toggleSelectionLetterSpacing = function toggleSelectionLetterSpacing(editorState, letterSpacing) {
- return toggleSelectionInlineStyle(editorState, letterSpacing, 'LETTERSPACING-');
- };
-
- var insertText = exports.insertText = function insertText(editorState, text, inlineStyle, entity) {
-
- var selectionState = editorState.getSelection();
- var currentSelectedBlockType = getSelectionBlockType(editorState);
-
- if (currentSelectedBlockType === 'atomic') {
- return editorState;
- }
-
- var entityKey = void 0;
- var contentState = editorState.getCurrentContent();
-
- if (entity && entity.type) {
- contentState = contentState.createEntity(entity.type, entity.mutability || 'MUTABLE', entity.data || entityData);
- entityKey = contentState.getLastCreatedEntityKey();
- }
-
- if (!selectionState.isCollapsed()) {
- return Draft.EditorState.push(editorState, Draft.Modifier.replaceText(contentState, selectionState, text, inlineStyle, entityKey), 'replace-text');
- } else {
- return Draft.EditorState.push(editorState, Draft.Modifier.insertText(contentState, selectionState, text, inlineStyle, entityKey), 'insert-text');
- }
- };
-
- var insertHTML = exports.insertHTML = function insertHTML(editorState, htmlString, source) {
-
- if (!htmlString) {
- return editorState;
- }
-
- var selectionState = editorState.getSelection();
- var contentState = editorState.getCurrentContent();
- var options = editorState.convertOptions || {};
-
- try {
- var _convertFromRaw = (0, Draft.convertFromRaw)((0, dist.convertHTMLToRaw)(htmlString, options, source)),
- blockMap = _convertFromRaw.blockMap;
-
- return Draft.EditorState.push(editorState, Draft.Modifier.replaceWithFragment(contentState, selectionState, blockMap), 'insert-fragment');
- } catch (error) {
- console.warn(error);
- return editorState;
- }
- };
-
- var insertAtomicBlock = exports.insertAtomicBlock = function insertAtomicBlock(editorState, type) {
- var immutable = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
- var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
-
-
- if (selectionContainsStrictBlock(editorState)) {
- return insertAtomicBlock(selectNextBlock(editorState, getSelectionBlock(editorState)), type, immutable, data);
- }
-
- var selectionState = editorState.getSelection();
- var contentState = editorState.getCurrentContent();
-
- if (!selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
- return editorState;
- }
-
- var contentStateWithEntity = contentState.createEntity(type, immutable ? 'IMMUTABLE' : 'MUTABLE', data);
- var entityKey = contentStateWithEntity.getLastCreatedEntityKey();
- var newEditorState = Draft.AtomicBlockUtils.insertAtomicBlock(editorState, entityKey, ' ');
-
- return newEditorState;
- };
-
- var insertHorizontalLine = exports.insertHorizontalLine = function insertHorizontalLine(editorState) {
- return insertAtomicBlock(editorState, 'HR');
- };
-
- var insertMedias = exports.insertMedias = function insertMedias(editorState) {
- var medias = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
-
-
- if (!medias.length) {
- return editorState;
- }
-
- return medias.reduce(function (editorState, media) {
- var url = media.url,
- link = media.link,
- link_target = media.link_target,
- name = media.name,
- type = media.type,
- width = media.width,
- height = media.height,
- meta = media.meta;
-
- return insertAtomicBlock(editorState, type, true, { url: url, link: link, link_target: link_target, name: name, type: type, width: width, height: height, meta: meta });
- }, editorState);
- };
-
- var setMediaData = exports.setMediaData = function setMediaData(editorState, entityKey, data) {
- return Draft.EditorState.push(editorState, editorState.getCurrentContent().mergeEntityData(entityKey, data), 'change-block-data');
- };
-
- var removeMedia = exports.removeMedia = function removeMedia(editorState, mediaBlock) {
- return removeBlock(editorState, mediaBlock);
- };
-
- var setMediaPosition = exports.setMediaPosition = function setMediaPosition(editorState, mediaBlock, position) {
-
- var newPosition = {};
- var float = position.float,
- alignment = position.alignment;
-
-
- if (typeof float !== 'undefined') {
- newPosition.float = mediaBlock.getData().get('float') === float ? null : float;
- }
-
- if (typeof alignment !== 'undefined') {
- newPosition.alignment = mediaBlock.getData().get('alignment') === alignment ? null : alignment;
- }
-
- return setSelectionBlockData(selectBlock(editorState, mediaBlock), newPosition);
- };
-
- var clear = exports.clear = function clear(editorState) {
-
- var contentState = editorState.getCurrentContent();
-
- var firstBlock = contentState.getFirstBlock();
- var lastBlock = contentState.getLastBlock();
-
- var allSelected = new Draft.SelectionState({
- anchorKey: firstBlock.getKey(),
- anchorOffset: 0,
- focusKey: lastBlock.getKey(),
- focusOffset: lastBlock.getLength(),
- hasFocus: true
- });
-
- return Draft.RichUtils.toggleBlockType(Draft.EditorState.push(editorState, Draft.Modifier.removeRange(contentState, allSelected, 'backward'), 'remove-range'), 'unstyled');
- };
-
- var handleKeyCommand = exports.handleKeyCommand = function handleKeyCommand(editorState, command) {
- return Draft.RichUtils.handleKeyCommand(editorState, command);
- };
-
- var undo = exports.undo = function undo(editorState) {
- return Draft.EditorState.undo(editorState);
- };
-
- var redo = exports.redo = function redo(editorState) {
- return Draft.EditorState.redo(editorState);
- };
- });
-
- unwrapExports(content);
- var content_1 = content.redo;
- var content_2 = content.undo;
- var content_3 = content.handleKeyCommand;
- var content_4 = content.clear;
- var content_5 = content.setMediaPosition;
- var content_6 = content.removeMedia;
- var content_7 = content.setMediaData;
- var content_8 = content.insertMedias;
- var content_9 = content.insertHorizontalLine;
- var content_10 = content.insertAtomicBlock;
- var content_11 = content.insertHTML;
- var content_12 = content.insertText;
- var content_13 = content.toggleSelectionLetterSpacing;
- var content_14 = content.toggleSelectionFontFamily;
- var content_15 = content.toggleSelectionLineHeight;
- var content_16 = content.toggleSelectionFontSize;
- var content_17 = content.toggleSelectionBackgroundColor;
- var content_18 = content.toggleSelectionColor;
- var content_19 = content.decreaseSelectionIndent;
- var content_20 = content.increaseSelectionIndent;
- var content_21 = content.toggleSelectionIndent;
- var content_22 = content.toggleSelectionAlignment;
- var content_23 = content.removeSelectionInlineStyles;
- var content_24 = content.toggleSelectionInlineStyle;
- var content_25 = content.selectionHasInlineStyle;
- var content_26 = content.getSelectionInlineStyle;
- var content_27 = content.toggleSelectionLink;
- var content_28 = content.toggleSelectionEntity;
- var content_29 = content.getSelectionEntityData;
- var content_30 = content.getSelectionEntityType;
- var content_31 = content.toggleSelectionBlockType;
- var content_32 = content.getSelectionText;
- var content_33 = content.getSelectionBlockType;
- var content_34 = content.getSelectionBlockData;
- var content_35 = content.setSelectionBlockData;
- var content_36 = content.getSelectedBlocks;
- var content_37 = content.updateEachCharacterOfSelection;
- var content_38 = content.getSelectionBlock;
- var content_39 = content.removeBlock;
- var content_40 = content.selectNextBlock;
- var content_41 = content.selectBlock;
- var content_42 = content.selectionContainsStrictBlock;
- var content_43 = content.selectionContainsBlockType;
- var content_44 = content.isSelectionCollapsed;
- var content_45 = content.createEditorState;
- var content_46 = content.createEmptyEditorState;
- var content_47 = content.isEditorState;
- var content_48 = content.registerStrictBlockType;
-
- var base = createCommonjsModule(function (module, exports) {
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var braftUniqueIndex = 0;
-
- var UniqueIndex = exports.UniqueIndex = function UniqueIndex() {
- return braftUniqueIndex += 1;
- };
- });
-
- unwrapExports(base);
- var base_1 = base.UniqueIndex;
-
- var color = createCommonjsModule(function (module, exports) {
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var _namedColors = {
- "aliceblue": "#f0f8ff",
- "antiquewhite": "#faebd7",
- "aqua": "#00ffff",
- "aquamarine": "#7fffd4",
- "azure": "#f0ffff",
- "beige": "#f5f5dc",
- "bisque": "#ffe4c4",
- "black": "#000000",
- "blanchedalmond": "#ffebcd",
- "blue": "#0000ff",
- "blueviolet": "#8a2be2",
- "brown": "#a52a2a",
- "burlywood": "#deb887",
- "cadetblue": "#5f9ea0",
- "chartreuse": "#7fff00",
- "chocolate": "#d2691e",
- "coral": "#ff7f50",
- "cornflowerblue": "#6495ed",
- "cornsilk": "#fff8dc",
- "crimson": "#dc143c",
- "cyan": "#00ffff",
- "darkblue": "#00008b",
- "darkcyan": "#008b8b",
- "darkgoldenrod": "#b8860b",
- "darkgray": "#a9a9a9",
- "darkgreen": "#006400",
- "darkkhaki": "#bdb76b",
- "darkmagenta": "#8b008b",
- "darkolivegreen": "#556b2f",
- "darkorange": "#ff8c00",
- "darkorchid": "#9932cc",
- "darkred": "#8b0000",
- "darksalmon": "#e9967a",
- "darkseagreen": "#8fbc8f",
- "darkslateblue": "#483d8b",
- "darkslategray": "#2f4f4f",
- "darkturquoise": "#00ced1",
- "darkviolet": "#9400d3",
- "deeppink": "#ff1493",
- "deepskyblue": "#00bfff",
- "dimgray": "#696969",
- "dodgerblue": "#1e90ff",
- "firebrick": "#b22222",
- "floralwhite": "#fffaf0",
- "forestgreen": "#228b22",
- "fuchsia": "#ff00ff",
- "gainsboro": "#dcdcdc",
- "ghostwhite": "#f8f8ff",
- "gold": "#ffd700",
- "goldenrod": "#daa520",
- "gray": "#808080",
- "green": "#008000",
- "greenyellow": "#adff2f",
- "honeydew": "#f0fff0",
- "hotpink": "#ff69b4",
- "indianred ": "#cd5c5c",
- "indigo": "#4b0082",
- "ivory": "#fffff0",
- "khaki": "#f0e68c",
- "lavender": "#e6e6fa",
- "lavenderblush": "#fff0f5",
- "lawngreen": "#7cfc00",
- "lemonchiffon": "#fffacd",
- "lightblue": "#add8e6",
- "lightcoral": "#f08080",
- "lightcyan": "#e0ffff",
- "lightgoldenrodyellow": "#fafad2",
- "lightgrey": "#d3d3d3",
- "lightgreen": "#90ee90",
- "lightpink": "#ffb6c1",
- "lightsalmon": "#ffa07a",
- "lightseagreen": "#20b2aa",
- "lightskyblue": "#87cefa",
- "lightslategray": "#778899",
- "lightsteelblue": "#b0c4de",
- "lightyellow": "#ffffe0",
- "lime": "#00ff00",
- "limegreen": "#32cd32",
- "linen": "#faf0e6",
- "magenta": "#ff00ff",
- "maroon": "#800000",
- "mediumaquamarine": "#66cdaa",
- "mediumblue": "#0000cd",
- "mediumorchid": "#ba55d3",
- "mediumpurple": "#9370d8",
- "mediumseagreen": "#3cb371",
- "mediumslateblue": "#7b68ee",
- "mediumspringgreen": "#00fa9a",
- "mediumturquoise": "#48d1cc",
- "mediumvioletred": "#c71585",
- "midnightblue": "#191970",
- "mintcream": "#f5fffa",
- "mistyrose": "#ffe4e1",
- "moccasin": "#ffe4b5",
- "navajowhite": "#ffdead",
- "navy": "#000080",
- "oldlace": "#fdf5e6",
- "olive": "#808000",
- "olivedrab": "#6b8e23",
- "orange": "#ffa500",
- "orangered": "#ff4500",
- "orchid": "#da70d6",
- "palegoldenrod": "#eee8aa",
- "palegreen": "#98fb98",
- "paleturquoise": "#afeeee",
- "palevioletred": "#d87093",
- "papayawhip": "#ffefd5",
- "peachpuff": "#ffdab9",
- "peru": "#cd853f",
- "pink": "#ffc0cb",
- "plum": "#dda0dd",
- "powderblue": "#b0e0e6",
- "purple": "#800080",
- "rebeccapurple": "#663399",
- "red": "#ff0000",
- "rosybrown": "#bc8f8f",
- "royalblue": "#4169e1",
- "saddlebrown": "#8b4513",
- "salmon": "#fa8072",
- "sandybrown": "#f4a460",
- "seagreen": "#2e8b57",
- "seashell": "#fff5ee",
- "sienna": "#a0522d",
- "silver": "#c0c0c0",
- "skyblue": "#87ceeb",
- "slateblue": "#6a5acd",
- "slategray": "#708090",
- "snow": "#fffafa",
- "springgreen": "#00ff7f",
- "steelblue": "#4682b4",
- "tan": "#d2b48c",
- "teal": "#008080",
- "thistle": "#d8bfd8",
- "tomato": "#ff6347",
- "turquoise": "#40e0d0",
- "violet": "#ee82ee",
- "wheat": "#f5deb3",
- "white": "#ffffff",
- "whitesmoke": "#f5f5f5",
- "yellow": "#ffff00",
- "yellowgreen": "#9acd32"
- };
-
- var _getHexColor = function _getHexColor(color) {
-
- color = color.replace('color:', '').replace(';', '').replace(' ', '');
-
- if (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(color)) {
- return color;
- } else if (namedColors[color]) {
- return namedColors[color];
- } else if (color.indexOf('rgb') === 0) {
-
- var rgbArray = color.split(',');
- var convertedColor = rgbArray.length < 3 ? null : '#' + [rgbArray[0], rgbArray[1], rgbArray[2]].map(function (x) {
- var hex = parseInt(x.replace(/\D/g, ''), 10).toString(16);
- return hex.length === 1 ? '0' + hex : hex;
- }).join('');
-
- return (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(convertedColor) ? convertedColor : null
- );
- } else {
- return null;
- }
- };
-
- var namedColors = exports.namedColors = _namedColors;
- var getHexColor = exports.getHexColor = _getHexColor;
-
- var detectColorsFromHTMLString = exports.detectColorsFromHTMLString = function detectColorsFromHTMLString(html) {
- return typeof html !== 'string' ? [] : (html.match(/color:[^;]{3,24};/g) || []).map(getHexColor).filter(function (color) {
- return color;
- });
- };
-
- var detectColorsFromDraftState = exports.detectColorsFromDraftState = function detectColorsFromDraftState(draftState) {
-
- var result = [];
-
- if (!draftState || !draftState.blocks || !draftState.blocks.length) {
- return result;
- }
-
- draftState.blocks.forEach(function (block) {
- if (block && block.inlineStyleRanges && block.inlineStyleRanges.length) {
- block.inlineStyleRanges.forEach(function (inlineStyle) {
- if (inlineStyle.style && inlineStyle.style.indexOf('COLOR-') >= 0) {
- result.push('#' + inlineStyle.style.split('COLOR-')[1]);
- }
- });
- }
- });
-
- return result.filter(function (color) {
- return color;
- });
- };
- });
-
- unwrapExports(color);
- var color_1 = color.namedColors;
- var color_2 = color.getHexColor;
- var color_3 = color.detectColorsFromHTMLString;
- var color_4 = color.detectColorsFromDraftState;
-
- var dist$1 = createCommonjsModule(function (module, exports) {
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.ColorUtils = exports.BaseUtils = exports.ContentUtils = undefined;
-
-
-
- var _ContentUtils = _interopRequireWildcard(content);
-
-
-
- var _BaseUtils = _interopRequireWildcard(base);
-
-
-
- var _ColorUtils = _interopRequireWildcard(color);
-
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
-
- var ContentUtils = exports.ContentUtils = _ContentUtils;
- var BaseUtils = exports.BaseUtils = _BaseUtils;
- var ColorUtils = exports.ColorUtils = _ColorUtils;
- });
-
- unwrapExports(dist$1);
- var dist_1$1 = dist$1.ColorUtils;
- var dist_2$1 = dist$1.BaseUtils;
- var dist_3$1 = dist$1.ContentUtils;
-
- var dist$2 = createCommonjsModule(function (module, exports) {
- (function webpackUniversalModuleDefinition(root, factory) {
- module.exports = factory(React);
- })(window, function(__WEBPACK_EXTERNAL_MODULE__2__) {
- return /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
- /******/ }
- /******/ };
- /******/
- /******/ // define __esModule on exports
- /******/ __webpack_require__.r = function(exports) {
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
- /******/ }
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
- /******/ };
- /******/
- /******/ // 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
- /******/ __webpack_require__.t = function(value, mode) {
- /******/ if(mode & 1) value = __webpack_require__(value);
- /******/ if(mode & 8) return value;
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
- /******/ var ns = Object.create(null);
- /******/ __webpack_require__.r(ns);
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
- /******/ return ns;
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "/";
- /******/
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 20);
- /******/ })
- /************************************************************************/
- /******/ ([
- /* 0 */
- /***/ (function(module, exports, __webpack_require__) {
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var compressImage = exports.compressImage = function compressImage(url) {
- var width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1280;
- var height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 800;
-
-
- return new Promise(function (resolve, reject) {
-
- var image = new Image();
-
- image.src = url;
-
- image.onerror = function (error) {
- reject(error);
- };
-
- image.onload = function () {
-
- try {
-
- var compressCanvas = document.createElement('canvas');
- var scale = this.width > width || this.height > height ? this.width > this.height ? width / this.width : height / this.height : 1;
-
- compressCanvas.width = this.width * scale;
- compressCanvas.height = this.height * scale;
-
- var canvasContext = compressCanvas.getContext('2d');
- canvasContext.drawImage(this, 0, 0, compressCanvas.width, compressCanvas.height);
-
- resolve({
- url: compressCanvas.toDataURL('image/png', 1),
- width: compressCanvas.width,
- height: compressCanvas.height
- });
- } catch (error) {
- reject(error);
- }
- };
- });
- };
-
- /***/ }),
- /* 1 */
- /***/ (function(module, exports, __webpack_require__) {
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var UniqueIndex = exports.UniqueIndex = function UniqueIndex() {
-
- if (isNaN(window.__BRAFT_MM_UNIQUE_INDEX__)) {
- window.__BRAFT_MM_UNIQUE_INDEX__ = 1;
- } else {
- window.__BRAFT_MM_UNIQUE_INDEX__ += 1;
- }
-
- return window.__BRAFT_MM_UNIQUE_INDEX__;
- };
-
- /***/ }),
- /* 2 */
- /***/ (function(module, exports) {
-
- module.exports = __WEBPACK_EXTERNAL_MODULE__2__;
-
- /***/ }),
- /* 3 */
- /***/ (function(module, exports, __webpack_require__) {
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = {
- remove: 'Kaldır',
- cancel: 'İptal',
- confirm: 'Onayla',
- insert: 'Seçilenleri ekle',
- width: 'Genişlik',
- height: 'Yükseklik',
- image: 'Resim',
- video: 'Görüntü',
- audio: 'Ses',
- embed: 'Nesne göm',
- caption: 'Kitaplık',
- dragTip: 'Tıkla ya da dosya sürükle',
- dropTip: 'Yüklemek için sürükleyin',
- selectAll: 'Tümünü seç',
- deselect: 'Seçimi kaldır',
- removeSelected: 'Seçilenleri kaldır',
- externalInputPlaceHolder: 'Kaynak adı|Kaynak bağlantısı',
- externalInputTip: 'Kaynak asını ve bağlantısını "|" ile ayırın ve Enter\' a basın.',
- addLocalFile: 'Yerel\' den ekle',
- addExternalSource: 'Harici kaynaktan ekle',
- unnamedItem: 'Adlandırılmamış giriş',
- confirmInsert: 'Seçilenleri ekle'
- };
-
- /***/ }),
- /* 4 */
- /***/ (function(module, exports, __webpack_require__) {
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = {
- remove: '削除する',
- cancel: 'キャンセル',
- confirm: '確認する',
- insert: '選択したアイテムを挿入',
- width: '幅',
- height: '身長',
- image: '絵',
- video: 'ビデオ',
- audio: '音声',
- embed: '埋め込みメディア',
- caption: 'メディアライブラリー',
- dragTip: 'ファイルをこの位置までクリックまたはドラッグします',
- dropTip: 'アップロードするマウスを放します',
- selectAll: 'すべて選択',
- deselect: '選択を解除',
- removeSelected: '選択したアイテムを削除',
- externalInputPlaceHolder: 'リソース名|リソースアドレス',
- externalInputTip: 'リソース名とリソースアドレスは "|"で区切ります。',
- addLocalFile: 'ローカルリソースを追加する',
- addExternalSource: 'ネットワークリソースを追加する',
- unnamedItem: '名前のないアイテム',
- confirmInsert: '選択したアイテムを挿入'
- };
-
- /***/ }),
- /* 5 */
- /***/ (function(module, exports, __webpack_require__) {
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = {
- remove: '삭제',
- cancel: '취소',
- confirm: '확인',
- insert: '선택한항목삽입',
- width: '너비',
- height: '높이',
- image: '그림',
- video: '비디오',
- audio: '오디오',
- embed: '임베디드미디어',
- caption: '미디어라이브러리',
- dragTip: '파일을 클릭하거나이 지점으로 드래그하십시오.',
- dropTip: '업로드하려면마우스를놓으십시오.',
- selectAll: '모두 선택',
- deselect: '선택 취소',
- removeSelected: '선택한 항목 삭제',
- externalInputPlaceHolder: '리소스 이름 | 리소스 주소',
- externalInputTip: '자원 이름과 자원 주소를 "|"',
- addLocalFile: '로컬 리소스 추가',
- addExternalSource: '네트워크 리소스 추가',
- unnamedItem: '이름없는 항목',
- confirmInsert: '선택한 항목 삽입'
- };
-
- /***/ }),
- /* 6 */
- /***/ (function(module, exports, __webpack_require__) {
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = {
- remove: 'Usuń',
- cancel: 'Anuluj',
- confirm: 'Potwierdź',
- insert: 'Wstaw wybrane elementy',
- width: 'Szerokość',
- height: 'Wysokość',
- image: 'Obraz',
- video: 'Wideo',
- audio: 'Dźwięk',
- embed: 'Obiekt',
- caption: 'Biblioteka mediów',
- dragTip: 'Kliknij lub przenieś tu pliki',
- dropTip: 'Upuść aby dodać plik',
- selectAll: 'Zaznacz wszystko',
- deselect: 'Odznacz',
- removeSelected: 'Usuń wybrane',
- externalInputPlaceHolder: 'Nazwa źródła|Adres URL',
- externalInputTip: 'Oddziel nazwę i adres URL źródła z pomocą "|", Potwierdź Enter-em',
- addLocalFile: 'Dodaj z komputera',
- addExternalSource: 'Dodaj z Internetu',
- unnamedItem: 'Bez nazwy',
- confirmInsert: 'Dodaj wybrane elementy'
- };
-
- /***/ }),
- /* 7 */
- /***/ (function(module, exports, __webpack_require__) {
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = {
- remove: '删除',
- cancel: '取消',
- confirm: '确认',
- insert: '插入所选项目',
- width: '宽度',
- height: '高度',
- image: '图片',
- video: '视频',
- audio: '音频',
- embed: '嵌入式媒体',
- caption: '媒体库',
- dragTip: '点击或拖动文件至此',
- dropTip: '放开鼠标以上传',
- selectAll: '选择全部',
- deselect: '取消选择',
- removeSelected: '删除选中项目',
- externalInputPlaceHolder: '资源名称|资源地址',
- externalInputTip: '使用“|”分隔资源名称和资源地址',
- addLocalFile: '添加本地资源',
- addExternalSource: '添加网络资源',
- unnamedItem: '未命名项目',
- confirmInsert: '插入选中项目'
- };
-
- /***/ }),
- /* 8 */
- /***/ (function(module, exports, __webpack_require__) {
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = {
- remove: '删除',
- cancel: '取消',
- confirm: '确认',
- insert: '插入所选项目',
- width: '宽度',
- height: '高度',
- image: '图片',
- video: '视频',
- audio: '音频',
- embed: '嵌入式媒体',
- caption: '媒体库',
- dragTip: '点击或拖动文件至此',
- dropTip: '放开鼠标以上传',
- selectAll: '选择全部',
- deselect: '取消选择',
- removeSelected: '删除选中项目',
- externalInputPlaceHolder: '资源名称|资源地址',
- externalInputTip: '使用“|”分隔资源名称和资源地址',
- addLocalFile: '添加本地资源',
- addExternalSource: '添加网络资源',
- unnamedItem: '未命名项目',
- confirmInsert: '插入选中项目'
- };
-
- /***/ }),
- /* 9 */
- /***/ (function(module, exports, __webpack_require__) {
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = {
- remove: 'Remove',
- cancel: 'Cancel',
- confirm: 'Confirm',
- insert: 'Insert Selected Items',
- width: 'Width',
- height: 'Height',
- image: 'Image',
- video: 'Video',
- audio: 'Audio',
- embed: 'Embed',
- caption: 'Media Library',
- dragTip: 'Click Or Drag Files Here',
- dropTip: 'Drop To Upload',
- selectAll: 'Select All',
- deselect: 'Deselect',
- removeSelected: 'Remove Selected Items',
- externalInputPlaceHolder: 'Source Name|Source URL',
- externalInputTip: 'Split source name and source URL with "|", confirm by hit Enter.',
- addLocalFile: 'Add from local',
- addExternalSource: 'Add from Internet',
- unnamedItem: 'Unnamed Item',
- confirmInsert: 'Insert selected items'
- };
-
- /***/ }),
- /* 10 */
- /***/ (function(module, exports, __webpack_require__) {
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
-
- var _en = __webpack_require__(9);
-
- var _en2 = _interopRequireDefault(_en);
-
- var _zh = __webpack_require__(8);
-
- var _zh2 = _interopRequireDefault(_zh);
-
- var _zhHant = __webpack_require__(7);
-
- var _zhHant2 = _interopRequireDefault(_zhHant);
-
- var _pl = __webpack_require__(6);
-
- var _pl2 = _interopRequireDefault(_pl);
-
- var _kr = __webpack_require__(5);
-
- var _kr2 = _interopRequireDefault(_kr);
-
- var _jpn = __webpack_require__(4);
-
- var _jpn2 = _interopRequireDefault(_jpn);
-
- var _tr = __webpack_require__(3);
-
- var _tr2 = _interopRequireDefault(_tr);
-
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
- exports.default = {
- "en": _en2.default,
- "zh": _zh2.default,
- "zh-hant": _zhHant2.default,
- "pl": _pl2.default,
- "kr": _kr2.default,
- "jpn": _jpn2.default,
- "tr": _tr2.default
- };
-
- /***/ }),
- /* 11 */
- /***/ (function(module, exports) {
-
-
- /**
- * When source maps are enabled, `style-loader` uses a link element with a data-uri to
- * embed the css on the page. This breaks all relative urls because now they are relative to a
- * bundle instead of the current page.
- *
- * One solution is to only use full urls, but that may be impossible.
- *
- * Instead, this function "fixes" the relative urls to be absolute according to the current page location.
- *
- * A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command.
- *
- */
-
- module.exports = function (css) {
- // get current location
- var location = typeof window !== "undefined" && window.location;
-
- if (!location) {
- throw new Error("fixUrls requires window.location");
- }
-
- // blank or null?
- if (!css || typeof css !== "string") {
- return css;
- }
-
- var baseUrl = location.protocol + "//" + location.host;
- var currentDir = baseUrl + location.pathname.replace(/\/[^\/]*$/, "/");
-
- // convert each url(...)
- /*
- This regular expression is just a way to recursively match brackets within
- a string.
-
- /url\s*\( = Match on the word "url" with any whitespace after it and then a parens
- ( = Start a capturing group
- (?: = Start a non-capturing group
- [^)(] = Match anything that isn't a parentheses
- | = OR
- \( = Match a start parentheses
- (?: = Start another non-capturing groups
- [^)(]+ = Match anything that isn't a parentheses
- | = OR
- \( = Match a start parentheses
- [^)(]* = Match anything that isn't a parentheses
- \) = Match a end parentheses
- ) = End Group
- *\) = Match anything and then a close parens
- ) = Close non-capturing group
- * = Match anything
- ) = Close capturing group
- \) = Match a close parens
-
- /gi = Get all matches, not the first. Be case insensitive.
- */
- var fixedCss = css.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi, function(fullMatch, origUrl) {
- // strip quotes (if they exist)
- var unquotedOrigUrl = origUrl
- .trim()
- .replace(/^"(.*)"$/, function(o, $1){ return $1; })
- .replace(/^'(.*)'$/, function(o, $1){ return $1; });
-
- // already a full url? no change
- if (/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(unquotedOrigUrl)) {
- return fullMatch;
- }
-
- // convert the url to a full url
- var newUrl;
-
- if (unquotedOrigUrl.indexOf("//") === 0) {
- //TODO: should we add protocol?
- newUrl = unquotedOrigUrl;
- } else if (unquotedOrigUrl.indexOf("/") === 0) {
- // path should be relative to the base url
- newUrl = baseUrl + unquotedOrigUrl; // already starts with '/'
- } else {
- // path should be relative to current directory
- newUrl = currentDir + unquotedOrigUrl.replace(/^\.\//, ""); // Strip leading './'
- }
-
- // send back the fixed url(...)
- return "url(" + JSON.stringify(newUrl) + ")";
- });
-
- // send back the fixed css
- return fixedCss;
- };
-
-
- /***/ }),
- /* 12 */
- /***/ (function(module, exports, __webpack_require__) {
-
- /*
- MIT License http://www.opensource.org/licenses/mit-license.php
- Author Tobias Koppers @sokra
- */
-
- var stylesInDom = {};
-
- var memoize = function (fn) {
- var memo;
-
- return function () {
- if (typeof memo === "undefined") memo = fn.apply(this, arguments);
- return memo;
- };
- };
-
- var isOldIE = memoize(function () {
- // Test for IE <= 9 as proposed by Browserhacks
- // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
- // Tests for existence of standard globals is to allow style-loader
- // to operate correctly into non-standard environments
- // @see https://github.com/webpack-contrib/style-loader/issues/177
- return window && document && document.all && !window.atob;
- });
-
- var getTarget = function (target) {
- return document.querySelector(target);
- };
-
- var getElement = (function (fn) {
- var memo = {};
-
- return function(target) {
- // If passing function in options, then use it for resolve "head" element.
- // Useful for Shadow Root style i.e
- // {
- // insertInto: function () { return document.querySelector("#foo").shadowRoot }
- // }
- if (typeof target === 'function') {
- return target();
- }
- if (typeof memo[target] === "undefined") {
- var styleTarget = getTarget.call(this, target);
- // Special case to return head of iframe instead of iframe itself
- if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
- try {
- // This will throw an exception if access to iframe is blocked
- // due to cross-origin restrictions
- styleTarget = styleTarget.contentDocument.head;
- } catch(e) {
- styleTarget = null;
- }
- }
- memo[target] = styleTarget;
- }
- return memo[target]
- };
- })();
-
- var singleton = null;
- var singletonCounter = 0;
- var stylesInsertedAtTop = [];
-
- var fixUrls = __webpack_require__(11);
-
- module.exports = function(list, options) {
- if (typeof DEBUG !== "undefined" && DEBUG) {
- if (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
- }
-
- options = options || {};
-
- options.attrs = typeof options.attrs === "object" ? options.attrs : {};
-
- // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
- // tags it will allow on a page
- if (!options.singleton && typeof options.singleton !== "boolean") options.singleton = isOldIE();
-
- // By default, add <style> tags to the <head> element
- if (!options.insertInto) options.insertInto = "head";
-
- // By default, add <style> tags to the bottom of the target
- if (!options.insertAt) options.insertAt = "bottom";
-
- var styles = listToStyles(list, options);
-
- addStylesToDom(styles, options);
-
- return function update (newList) {
- var mayRemove = [];
-
- for (var i = 0; i < styles.length; i++) {
- var item = styles[i];
- var domStyle = stylesInDom[item.id];
-
- domStyle.refs--;
- mayRemove.push(domStyle);
- }
-
- if(newList) {
- var newStyles = listToStyles(newList, options);
- addStylesToDom(newStyles, options);
- }
-
- for (var i = 0; i < mayRemove.length; i++) {
- var domStyle = mayRemove[i];
-
- if(domStyle.refs === 0) {
- for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j]();
-
- delete stylesInDom[domStyle.id];
- }
- }
- };
- };
-
- function addStylesToDom (styles, options) {
- for (var i = 0; i < styles.length; i++) {
- var item = styles[i];
- var domStyle = stylesInDom[item.id];
-
- if(domStyle) {
- domStyle.refs++;
-
- for(var j = 0; j < domStyle.parts.length; j++) {
- domStyle.parts[j](item.parts[j]);
- }
-
- for(; j < item.parts.length; j++) {
- domStyle.parts.push(addStyle(item.parts[j], options));
- }
- } else {
- var parts = [];
-
- for(var j = 0; j < item.parts.length; j++) {
- parts.push(addStyle(item.parts[j], options));
- }
-
- stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
- }
- }
- }
-
- function listToStyles (list, options) {
- var styles = [];
- var newStyles = {};
-
- for (var i = 0; i < list.length; i++) {
- var item = list[i];
- var id = options.base ? item[0] + options.base : item[0];
- var css = item[1];
- var media = item[2];
- var sourceMap = item[3];
- var part = {css: css, media: media, sourceMap: sourceMap};
-
- if(!newStyles[id]) styles.push(newStyles[id] = {id: id, parts: [part]});
- else newStyles[id].parts.push(part);
- }
-
- return styles;
- }
-
- function insertStyleElement (options, style) {
- var target = getElement(options.insertInto);
-
- if (!target) {
- throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");
- }
-
- var lastStyleElementInsertedAtTop = stylesInsertedAtTop[stylesInsertedAtTop.length - 1];
-
- if (options.insertAt === "top") {
- if (!lastStyleElementInsertedAtTop) {
- target.insertBefore(style, target.firstChild);
- } else if (lastStyleElementInsertedAtTop.nextSibling) {
- target.insertBefore(style, lastStyleElementInsertedAtTop.nextSibling);
- } else {
- target.appendChild(style);
- }
- stylesInsertedAtTop.push(style);
- } else if (options.insertAt === "bottom") {
- target.appendChild(style);
- } else if (typeof options.insertAt === "object" && options.insertAt.before) {
- var nextSibling = getElement(options.insertInto + " " + options.insertAt.before);
- target.insertBefore(style, nextSibling);
- } else {
- throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");
- }
- }
-
- function removeStyleElement (style) {
- if (style.parentNode === null) return false;
- style.parentNode.removeChild(style);
-
- var idx = stylesInsertedAtTop.indexOf(style);
- if(idx >= 0) {
- stylesInsertedAtTop.splice(idx, 1);
- }
- }
-
- function createStyleElement (options) {
- var style = document.createElement("style");
-
- if(options.attrs.type === undefined) {
- options.attrs.type = "text/css";
- }
-
- addAttrs(style, options.attrs);
- insertStyleElement(options, style);
-
- return style;
- }
-
- function createLinkElement (options) {
- var link = document.createElement("link");
-
- if(options.attrs.type === undefined) {
- options.attrs.type = "text/css";
- }
- options.attrs.rel = "stylesheet";
-
- addAttrs(link, options.attrs);
- insertStyleElement(options, link);
-
- return link;
- }
-
- function addAttrs (el, attrs) {
- Object.keys(attrs).forEach(function (key) {
- el.setAttribute(key, attrs[key]);
- });
- }
-
- function addStyle (obj, options) {
- var style, update, remove, result;
-
- // If a transform function was defined, run it on the css
- if (options.transform && obj.css) {
- result = options.transform(obj.css);
-
- if (result) {
- // If transform returns a value, use that instead of the original css.
- // This allows running runtime transformations on the css.
- obj.css = result;
- } else {
- // If the transform function returns a falsy value, don't add this css.
- // This allows conditional loading of css
- return function() {
- // noop
- };
- }
- }
-
- if (options.singleton) {
- var styleIndex = singletonCounter++;
-
- style = singleton || (singleton = createStyleElement(options));
-
- update = applyToSingletonTag.bind(null, style, styleIndex, false);
- remove = applyToSingletonTag.bind(null, style, styleIndex, true);
-
- } else if (
- obj.sourceMap &&
- typeof URL === "function" &&
- typeof URL.createObjectURL === "function" &&
- typeof URL.revokeObjectURL === "function" &&
- typeof Blob === "function" &&
- typeof btoa === "function"
- ) {
- style = createLinkElement(options);
- update = updateLink.bind(null, style, options);
- remove = function () {
- removeStyleElement(style);
-
- if(style.href) URL.revokeObjectURL(style.href);
- };
- } else {
- style = createStyleElement(options);
- update = applyToTag.bind(null, style);
- remove = function () {
- removeStyleElement(style);
- };
- }
-
- update(obj);
-
- return function updateStyle (newObj) {
- if (newObj) {
- if (
- newObj.css === obj.css &&
- newObj.media === obj.media &&
- newObj.sourceMap === obj.sourceMap
- ) {
- return;
- }
-
- update(obj = newObj);
- } else {
- remove();
- }
- };
- }
-
- var replaceText = (function () {
- var textStore = [];
-
- return function (index, replacement) {
- textStore[index] = replacement;
-
- return textStore.filter(Boolean).join('\n');
- };
- })();
-
- function applyToSingletonTag (style, index, remove, obj) {
- var css = remove ? "" : obj.css;
-
- if (style.styleSheet) {
- style.styleSheet.cssText = replaceText(index, css);
- } else {
- var cssNode = document.createTextNode(css);
- var childNodes = style.childNodes;
-
- if (childNodes[index]) style.removeChild(childNodes[index]);
-
- if (childNodes.length) {
- style.insertBefore(cssNode, childNodes[index]);
- } else {
- style.appendChild(cssNode);
- }
- }
- }
-
- function applyToTag (style, obj) {
- var css = obj.css;
- var media = obj.media;
-
- if(media) {
- style.setAttribute("media", media);
- }
-
- if(style.styleSheet) {
- style.styleSheet.cssText = css;
- } else {
- while(style.firstChild) {
- style.removeChild(style.firstChild);
- }
-
- style.appendChild(document.createTextNode(css));
- }
- }
-
- function updateLink (link, options, obj) {
- var css = obj.css;
- var sourceMap = obj.sourceMap;
-
- /*
- If convertToAbsoluteUrls isn't defined, but sourcemaps are enabled
- and there is no publicPath defined then lets turn convertToAbsoluteUrls
- on by default. Otherwise default to the convertToAbsoluteUrls option
- directly
- */
- var autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap;
-
- if (options.convertToAbsoluteUrls || autoFixUrls) {
- css = fixUrls(css);
- }
-
- if (sourceMap) {
- // http://stackoverflow.com/a/26603875
- css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
- }
-
- var blob = new Blob([css], { type: "text/css" });
-
- var oldSrc = link.href;
-
- link.href = URL.createObjectURL(blob);
-
- if(oldSrc) URL.revokeObjectURL(oldSrc);
- }
-
-
- /***/ }),
- /* 13 */
- /***/ (function(module, exports) {
-
- module.exports = "data:font/ttf;base64,AAEAAAALAIAAAwAwT1MvMg8SBsIAAAC8AAAAYGNtYXBWNv1DAAABHAAAANRnYXNwAAAAEAAAAfAAAAAIZ2x5ZtZLKCQAAAH4AAAPTGhlYWQT25ZrAAARRAAAADZoaGVhB8ID3gAAEXwAAAAkaG10eGoAC+sAABGgAAAAdGxvY2EqcC3wAAASFAAAADxtYXhwACcAewAAElAAAAAgbmFtZZlKCfsAABJwAAABhnBvc3QAAwAAAAAT+AAAACAAAwPsAZAABQAAApkCzAAAAI8CmQLMAAAB6wAzAQkAAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAAAAAAAAAAAABAAADprAPA/8AAQAPAAEAAAAABAAAAAAAAAAAAAAAgAAAAAAADAAAAAwAAABwAAQADAAAAHAADAAEAAAAcAAQAuAAAACoAIAAEAAoAAQAg4DTgN+BC4V3iQ+gN6Mno/ukD6QjpD+kT6RjpHOkm6YDprP/9//8AAAAAACDgNOA34ELhXeJD6A3oyej+6QHpB+kO6RHpFukc6SbpgOms//3//wAB/+Mf0B/OH8Qeqh3FF/wXQRcNFwsXCBcDFwIXABb9FvQWmxZwAAMAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAH//wAPAAEAAAAAAAAAAAACAAA3OQEAAAAAAQAAAAAAAAAAAAIAADc5AQAAAAABAAAAAAAAAAAAAgAANzkBAAAAAAIBAACBAwAC1QADAAcAAAEzESMhETMRAlaqqv6qqgLV/awCVP2sAAABAVYAgQMqAtUAAgAACQIBVgHU/iwC1f7W/tYAAQCqACsDVgOBAC4AAAEyFx4BFxYVFAcOAQcGIyInLgEnJjUzFBceARcWMzI3PgE3NjU0Jy4BJyYjFSc3AgBGPz5dGxsbG10+PkdGPz5dGxtWFBRFLy81NS8vRRQUFBRFLy811tYC1RsbXD4+Rkc+Pl0bGxsbXT4+RzYuL0UUFBQURS8uNjUvLkYUFKzW1gAAAwBWAAEDqgNVABsANwA7AAAlMjc+ATc2NTQnLgEnJiMiBw4BBwYVFBceARcWEzIXHgEXFhUUBw4BBwYjIicuAScmNTQ3PgE3NgMhFSECAEY/Pl0bGxsbXT4+R0Y/Pl0bGxsbXT4+R1hOTnMiISEic05NWVhOTnMiISEic05NfQGs/lRVGxtdPj5HRj4/XRsbGxtdPz5GRz4+XRsbAwAiIXRNTlhZTU50ISEhIXROTVlYTk10ISL+gFQAAAABAKoAAQOAA1UAHwAAATMRIREUBisBIiY1ESE1IxUUBiMhIiY9ATQ2MyEyFhUDAID+qhgSVhIYAaoqGBL+ABIaGhICABIYAwH+qv6AEhgYEgHWqioSGhoSqhIYGBIAAAABAIAAAwOAA1UAMwAAJTIWFRQGIyImNTwBNyUOASMiJjU0NjMyFhclLgE1NDYzMhYVFAYjIiYnBR4BFRQGBwU+AQMAM0lJMzNJAv7SEiwaNExLNRktEgEsAQNLNTRMSzUZLRL+1AEDAgIBMBAs/UkzM0tLMwcPBrAREUs1NEwSEK4HDwg0TEw0NUsTEbAIDwcIDwewDxEAAAMAVgArA6oDVQACAAYAGgAALQI3FTM1FyERFAYjISImNREhNTQ2OwEyFhUBgAFA/sAqrFQBADAk/VQkMAEAMCSsJDCr1qrWVlZW/dYkMjIkAipWJDAwJAAEAIAAgQOAAtUAAwAHAAsADwAAEyEVIRU1IRUBNSEVJTUhFYADAP0AAwD9AAMA/QADAALVVKxWVv6sVFSqVlYABABVACIDqwN3AAQAIQA9AEIAACUzESMREyIHDgEHBhUUFx4BFxYzMjc+ATc2NTQnLgEnJiMRIicuAScmNTQ3PgE3NjMyFx4BFxYVFAcOAQcGAzM1IxUB1VZWK1hOTnQhIiIhdE5OWFhOTnQhIiIhdE5OWEc+Pl0aGxsaXT4+R0c+Pl0aGxsaXT4+clZW9wEA/wACgCEic05OWFlNTnQhIiIhdE5NWVhOTnMiIf0AGxtdPj5HRj8+XBsbGxtcPj9GRz4+XRsbAdZVVQAABABVACIDqwN3AAQAIQA9AFIAACUzNSMVEyIHDgEHBhUUFx4BFxYzMjc+ATc2NTQnLgEnJiMRIicuAScmNTQ3PgE3NjMyFx4BFxYVFAcOAQcGAyIGFTM0NjMyFhUUBhUzNDY1NCYjAdVWVitYTk50ISIiIXROTlhYTk50ISIiIXROTlhHPj5dGhsbGl0+PkdHPj5dGhsbGl0+PkdHZFYyIyMygFaAZEfNVVUCqiEic05OWFlNTnQhIiIhdE5NWVhOTnMiIf0AGxtdPj5HRj8+XBsbGxtcPj9GRz4+XRsbAlZkRyMyMiNALWhIPVBHZAAAAgBVAM0DqwLNAAUACwAAASc3JwkBJTcnNwkBAZHExDz/AAEAARrExDwBAP8AAQnExDz/AP8APMTEPP8A/wAAAAMAVQAiA6sDdwAcACsAOgAAASIHDgEHBhUUFx4BFxYzMjc+ATc2NTQnLgEnJiMBNDc+ATc2MzIWFwEuATUBIiYnAR4BFRQHDgEHBiMCAFhOTXQiIiIidE1OWFhOTXQiIiIidE1OWP6rGxtcPj9GOmot/iIjJQFVOmotAd4jJRsbXD4/RgN3ISJ0Tk1YWE5OdCEiIiF0Tk5YWE1OdCIh/lZGPj5dGxslI/4iLWo6/qomIwHeLWs5Rz4+XRsbAAAAAAMAgADNA4ACzQADAAcACwAANyE1ITUhNSE1FSE1gAMA/QADAP0AAwDNVYBV1lZWAAEAZAAlA1wDXABEAAABERQHBgcGBwYjIicmJyYnJjU0NzY3Njc2MzIXEQURFAcGBwYHBiMiJyYnJicmNTQ3Njc2NzYzMhcRNDc2NyU2MzIXFhUDXBERGhkaGRYXGRoZGhEREREaGRoZFzMr/oURERoZGhkXFhkaGRoRERERGhkaGRY0KwoJDwGbBggUDg4DLP3WGBQTCgsFBQUFCwoTFBgZExQKCwUFEwEKdv6iGRMTCwsFBQUFCwsTExkZExMLCgYFEwHeDw0MBX8CDg4UAAAEAHUAQgOJA1YALwA8AGIAeAAAAS4BBw4BJy4BJy4BBwYiJyYGBw4BJyYGBxQVHAEVFBUeATM2MzoBMzIzMjY3PAE1BSImNTQ2MzIWFRQGJyUqASM8ATU6ATMUFhUUFxwBFQYHFAYHDgEnLgE3PgE3OgEzPAE1BT4BNzoBMxQWBw4BJy4BNz4BNzoBMwKBARkZChUJCxcEFEMvBw8HHikMDCgdFyILCxgWNDM0ZzQzNBsaAf77L0FBMDBAQDEBtx8/IDRoNgEBAQENCxVFICIlBgc3JAcNCf7OAQICEyQTAwUFSiMmOAIBOiYHEAkCzhcaAQEBAwIJCC0fCAEBBhgbGxYGBBMVKCgpUCgoKQ8VARcaSpRK7T8uMEA/LzBAARchPyAKEgkzMjNmMjMzFCwRIBAOD0IjJjQDN2053QwUCi5dLSUsBgVEJig+BAAAAAAEAAAAAAQAA0AAGwAzAE8AUwAAARQXHgEXFjMyNz4BNzY1NCcuAScmIyIHDgEHBgEjLgEjISIGByMiBhURFBYzITI2NRE0JgEiJy4BJyY1NDc+ATc2MzIXHgEXFhUUBw4BBwYBIzUzATAQETgmJisrJiY4ERAQETgmJisrJiY4ERACkOAMJDD/ADAkDOAaJiYaA4AaJib+Jjs0M00XFhYXTTM0Ozs0M00XFhYXTTM0AYWAgAFgKyYmOBEQEBE4JiYrKyYmOBEQEBE4JiYBNTBQUDAmGv3AGiYmGgJAGib9hBYXTTM0Ozs0M00XFhYXTTM0Ozs0M00XFgG8QAABAJEAogOAAt4ABgAAAScHFwEnAQGAszzvAgA8/jwBGrM87wIAPP48AAAAAAEA4gCAAx4CyQAmAAABNzY0JyYiDwEnJiIHBhQfAQcGFBceATMyNj8BFx4BMzI2NzY0LwECPOINDQwkDOLiDCQMDQ3i4g0NBhAICBAG4uIGEAgIEAYNDeIBq+IMIw0MDOLiDAwNIwzi4g0jDAcGBgfh4QcGBgcMIw3iAAACAIAAYwNqA00AIgAvAAABIyc+ATU0Jy4BJyYjIgcOAQcGFRQXHgEXFjMyNjcXFRc3JyEiJjU0NjMyFhUUBiMClSEMHyQWFkszMjo5MzJLFhYWFksyMzk0XCUL1j/V/wBPcXFPUHBwUAF3DCRdMzoyM0sWFhYWSzMyOjkyM0sWFiQfDCLUP9VxT1BwcFBPcQACAGQAIgOcA3cATQBZAAABPgE1NCYnNz4BLwEuAQ8BLgEvAS4BKwEiBg8BDgEHJyYGDwEGFh8BDgEVFBYXBw4BHwEeAT8BHgEfAR4BOwEyNj8BPgE3FxY2PwE2JicFIiY1NDYzMhYVFAYDPQECAgFaBgMEVQQPB2oRJBQQAQwIqggMARAUJBFqBw8EVQQDBloBAgIBWgYDBFUEDwdqESQUEAEMCKoIDAEQFCQRagcPBFUEAwb+aT5XVz4+V1cBowoVCwsUC0YFDweUBwUDKgwVCHIHCgoHcggVDCoDBQeUBw8FRgsVCgsVCkYFEAeTBwUCKw0VCHEICgoIcQgVDSsDBgeTBxAFJlg+PldXPj5YAAEA1QCiAysC9wALAAABIREjESE1IREzESEDK/8AVv8AAQBWAQABov8AAQBVAQD/AAAAAAAJAAAAQAQAA0AAAwAHAAsADwATABcAGwAfACIAABMRIREBIzUzNSM1MzUjNTMBIREhEyM1MzUjNTM1IzUzBRElAAQA/MCAgICAgIACQP4AAgDAgICAgICA/cABAANA/QADAP1AgICAgID9gAKA/YCAgICAgID+gMAAAAAABgBA/8ADwAPAABkAIQA5AEcAVQBjAAABLgEnLgEnLgEjISIGFREUFjMhMjY1ETQmJyceARcjNR4BExQGIyEiJjURNDYzMDM6ATMyMRUUFjsBAyEiJjU0NjMhMhYVFAYnISImNTQ2MyEyFhUUBichIiY1NDYzITIWFRQGA5YRLRkaMxcnKQv+ECEvLyEC4CEvDhyFFyUNmhEphgkH/SAHCQkHTU66TU4TDeCg/kANExMNAcANExMN/kANExMNAcANExMN/kANExMNAcANExMC2xczGhktERwOLyH8oCEvLyECcAspJzYXKRGaDSX86AcJCQcDYAcJ4A0T/gATDQ0TEw0NE4ATDQ0TEw0NE4ATDQ0TEw0NEwAAAAcAAP/ABAADRgALABcAIwAvADsARwBTAAAlNDYzMhYVFAYjIiYBNDYzMhYVFAYjIiYlNDYzMhYVFAYjIiYBNDYzMhYVFAYjIiYBNDYzMhYVFAYjIiYlNDYzMhYVFAYjIiYBNDYzMhYVFAYjIiYBoDgoKDg4KCg4/mA4KCg4OCgoOANAOCgoODgoKDj9OjgoKDg4KCg4Akw4KCg4OCgoOP20OCgoODgoKDgCTDgoKDg4KCg4ICg4OCgoODgByCg4OCgoODgoKDg4KCg4OAFOKDg4KCg4OP3cKDg4KCg4OCgoODgoKDg4AnQoODgoKDg4AAUAfAAAA4QDVQAiAC0AOABGAFQAAAEjNTQmKwEiBh0BIyIGFRQWOwERFBYzITI2NREzMjY1NCYjJTQ2OwEyFh0BIzUBFAYjISImNREhEQEiBh0BFBYzMjY9ATQmMyIGHQEUFjMyNj0BNCYDXZtEMJwwRJsQFxcQJ0QwAYQwRCcQFxcQ/i8WEJwQFugBXRcQ/nwQFwHS/skQFhYQEBcXjBAXFxAQFhYCuicwREQwJxcQEBb+BzBERDAB+RYQEBcnEBcXECcn/ZMQFhYQAfn+BwGEFxDoEBcXEOgQFxcQ6BAXFxDoEBcAAAABAAAAAQAANAmLwV8PPPUACwQAAAAAANheKPcAAAAA2F4o9wAA/8AEAAPAAAAACAACAAAAAAAAAAEAAAPA/8AAAAQAAAAAAAQAAAEAAAAAAAAAAAAAAAAAAAAdBAAAAAAAAAAAAAAAAgAAAAQAAQAEAAFWBAAAqgQAAFYEAACqBAAAgAQAAFYEAACABAAAVQQAAFUEAABVBAAAVQQAAIAEAABkBAAAdQQAAAAEAACRBAAA4gQAAIAEAABkBAAA1QQAAAAEAABABAAAAAQAAHwAAAAAAAoAFAAeADIAQACIAOYBFgFiAY4BrgIUAowCrAMMAyQDjAQ0BLIEyAUGBU4F1gXwBi4GugcyB6YAAQAAAB0AeQAJAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAA4ArgABAAAAAAABAAcAAAABAAAAAAACAAcAYAABAAAAAAADAAcANgABAAAAAAAEAAcAdQABAAAAAAAFAAsAFQABAAAAAAAGAAcASwABAAAAAAAKABoAigADAAEECQABAA4ABwADAAEECQACAA4AZwADAAEECQADAA4APQADAAEECQAEAA4AfAADAAEECQAFABYAIAADAAEECQAGAA4AUgADAAEECQAKADQApGljb21vb24AaQBjAG8AbQBvAG8AblZlcnNpb24gMS4wAFYAZQByAHMAaQBvAG4AIAAxAC4AMGljb21vb24AaQBjAG8AbQBvAG8Abmljb21vb24AaQBjAG8AbQBvAG8AblJlZ3VsYXIAUgBlAGcAdQBsAGEAcmljb21vb24AaQBjAG8AbQBvAG8AbkZvbnQgZ2VuZXJhdGVkIGJ5IEljb01vb24uAEYAbwBuAHQAIABnAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAEkAYwBvAE0AbwBvAG4ALgAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
-
- /***/ }),
- /* 14 */
- /***/ (function(module, exports) {
-
- /*
- MIT License http://www.opensource.org/licenses/mit-license.php
- Author Tobias Koppers @sokra
- */
- // css base code, injected by the css-loader
- module.exports = function(useSourceMap) {
- var list = [];
-
- // return the list of modules as css string
- list.toString = function toString() {
- return this.map(function (item) {
- var content = cssWithMappingToString(item, useSourceMap);
- if(item[2]) {
- return "@media " + item[2] + "{" + content + "}";
- } else {
- return content;
- }
- }).join("");
- };
-
- // import a list of modules into the list
- list.i = function(modules, mediaQuery) {
- if(typeof modules === "string")
- modules = [[null, modules, ""]];
- var alreadyImportedModules = {};
- for(var i = 0; i < this.length; i++) {
- var id = this[i][0];
- if(typeof id === "number")
- alreadyImportedModules[id] = true;
- }
- for(i = 0; i < modules.length; i++) {
- var item = modules[i];
- // skip already imported module
- // this implementation is not 100% perfect for weird media query combinations
- // when a module is imported multiple times with different media queries.
- // I hope this will never occur (Hey this way we have smaller bundles)
- if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
- if(mediaQuery && !item[2]) {
- item[2] = mediaQuery;
- } else if(mediaQuery) {
- item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
- }
- list.push(item);
- }
- }
- };
- return list;
- };
-
- function cssWithMappingToString(item, useSourceMap) {
- var content = item[1] || '';
- var cssMapping = item[3];
- if (!cssMapping) {
- return content;
- }
-
- if (useSourceMap && typeof btoa === 'function') {
- var sourceMapping = toComment(cssMapping);
- var sourceURLs = cssMapping.sources.map(function (source) {
- return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
- });
-
- return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
- }
-
- return [content].join('\n');
- }
-
- // Adapted from convert-source-map (MIT)
- function toComment(sourceMap) {
- // eslint-disable-next-line no-undef
- var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
- var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
-
- return '/*# ' + data + ' */';
- }
-
-
- /***/ }),
- /* 15 */
- /***/ (function(module, exports) {
-
- module.exports = function escape(url) {
- if (typeof url !== 'string') {
- return url
- }
- // If url is already wrapped in quotes, remove them
- if (/^['"].*['"]$/.test(url)) {
- url = url.slice(1, -1);
- }
- // Should url be wrapped?
- // See https://drafts.csswg.org/css-values-3/#urls
- if (/["'() \t\n]/.test(url)) {
- return '"' + url.replace(/"/g, '\\"').replace(/\n/g, '\\n') + '"'
- }
-
- return url
- };
-
-
- /***/ }),
- /* 16 */
- /***/ (function(module, exports, __webpack_require__) {
-
- var escape = __webpack_require__(15);
- exports = module.exports = __webpack_require__(14)(false);
- // imports
-
-
- // module
- exports.push([module.i, "@font-face {\n font-family: 'bf-icons';\n src: url(" + escape(__webpack_require__(13)) + ") format(\"truetype\");\n font-weight: normal;\n font-style: normal; }\n\n.braft-finder [class^=\"braft-icon-\"], .braft-finder [class*=\" braft-icon-\"] {\n /* use !important to prevent issues with browser extensions that change fonts */\n font-family: 'bf-icons' !important;\n font-style: normal;\n font-weight: normal;\n font-variant: normal;\n text-transform: none;\n /* Better Font Rendering =========== */\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale; }\n\n.braft-finder .braft-icon-code:before {\n content: \"\\E903\"; }\n\n.braft-finder .braft-icon-pause:before {\n content: \"\\E034\"; }\n\n.braft-finder .braft-icon-play_arrow:before {\n content: \"\\E037\"; }\n\n.braft-finder .braft-icon-bin:before {\n content: \"\\E9AC\"; }\n\n.braft-finder .braft-icon-replay:before {\n content: \"\\E042\"; }\n\n.braft-finder .braft-icon-close:before {\n content: \"\\E913\"; }\n\n.braft-finder .braft-icon-music:before {\n content: \"\\E90E\"; }\n\n.braft-finder .braft-icon-camera:before {\n content: \"\\E911\"; }\n\n.braft-finder .braft-icon-file-text:before {\n content: \"\\E926\"; }\n\n.braft-finder .braft-icon-film:before {\n content: \"\\E91C\"; }\n\n.braft-finder .braft-icon-paste:before {\n content: \"\\E92D\"; }\n\n.braft-finder .braft-icon-spinner:before {\n content: \"\\E980\"; }\n\n.braft-finder .braft-icon-media:before {\n content: \"\\E90F\"; }\n\n.braft-finder .braft-icon-add:before {\n content: \"\\E918\"; }\n\n.braft-finder .braft-icon-done:before {\n content: \"\\E912\"; }\n\n.braft-finder .braft-icon-drop-down:before {\n content: \"\\E906\"; }\n\n.braft-finder .braft-icon-drop-up:before {\n content: \"\\E909\"; }\n\n.braft-finder .braft-icon-help:before {\n content: \"\\E902\"; }\n\n.braft-finder .braft-icon-info:before {\n content: \"\\E901\"; }\n\n.braft-finder .braft-icon-menu:before {\n content: \"\\E908\"; }\n\n.pull-left {\n float: left; }\n\n.pull-right {\n float: right; }\n\n.braft-finder .bf-uploader {\n position: relative;\n height: 370px;\n margin: 0; }\n .braft-finder .bf-uploader.draging .bf-list-wrap,\n .braft-finder .bf-uploader.draging .bf-add-external {\n pointer-events: none; }\n .braft-finder .bf-uploader input::-webkit-input-placeholder {\n color: #ccc; }\n .braft-finder .bf-uploader input::-moz-placeholder {\n color: #ccc; }\n .braft-finder .bf-uploader input::-ms-input-placeholder {\n color: #ccc; }\n\n.braft-finder .bf-list-wrap {\n position: relative;\n height: 370px; }\n\n.braft-finder .bf-list-tools {\n z-index: 1;\n position: absolute;\n top: 0;\n right: 0;\n left: 0;\n height: 20px;\n padding: 0 15px;\n background-color: #fff; }\n .braft-finder .bf-list-tools span {\n height: 26px;\n font-size: 12px;\n line-height: 20px;\n cursor: pointer;\n user-select: none; }\n .braft-finder .bf-list-tools span[disabled] {\n opacity: .3;\n pointer-events: none; }\n .braft-finder .bf-list-tools .bf-select-all,\n .braft-finder .bf-list-tools .bf-deselect-all {\n float: left;\n margin-right: 5px;\n color: #bbb; }\n .braft-finder .bf-list-tools .bf-select-all:hover,\n .braft-finder .bf-list-tools .bf-deselect-all:hover {\n color: #3498db; }\n .braft-finder .bf-list-tools .bf-remove-selected {\n float: right;\n color: #e74c3c; }\n .braft-finder .bf-list-tools .bf-remove-selected:hover {\n color: #c92e1e; }\n\n.braft-finder .bf-list {\n position: absolute;\n z-index: 1;\n top: 30px;\n right: 0;\n left: 0;\n bottom: 0;\n margin: 0;\n padding: 0 10px;\n list-style: none;\n overflow: auto; }\n .braft-finder .bf-list::-webkit-scrollbar {\n width: 5px;\n height: 5px;\n background-color: #fff; }\n .braft-finder .bf-list::-webkit-scrollbar-track {\n background-color: #fff; }\n .braft-finder .bf-list::-webkit-scrollbar-thumb {\n background-color: rgba(0, 0, 0, 0.1); }\n\n.braft-finder .bf-item,\n.braft-finder .bf-add-item {\n position: relative;\n display: block;\n float: left;\n width: 113px;\n height: 113px;\n margin: 5px;\n overflow: hidden;\n border-radius: 3px; }\n\n.braft-finder .bf-item.uploading {\n pointer-events: none; }\n\n.braft-finder .bf-item.error::before {\n display: block;\n content: \"\\E901\"; }\n\n.braft-finder .bf-item.error::after {\n position: absolute;\n z-index: 1;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: rgba(231, 76, 60, 0.8);\n content: ''; }\n\n.braft-finder .bf-item.error:hover::after {\n background-color: rgba(231, 76, 60, 0.9); }\n\n.braft-finder .bf-item.error .bf-item-uploading {\n display: none; }\n\n.braft-finder .bf-add-item {\n background-color: #ecedef;\n color: #999; }\n .braft-finder .bf-add-item:hover {\n background-color: #e1e2e3; }\n .braft-finder .bf-add-item i {\n display: block;\n width: 113px;\n height: 113px;\n font-size: 48px;\n line-height: 113px;\n text-align: center; }\n .braft-finder .bf-add-item input {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n opacity: 0;\n cursor: pointer; }\n\n.braft-finder .bf-item::before {\n display: none;\n position: absolute;\n z-index: 2;\n top: 0;\n left: 0;\n width: 113px;\n height: 113px;\n color: #fff;\n font-size: 48px;\n font-family: 'bf-icons';\n line-height: 113px;\n text-align: center; }\n\n.braft-finder .bf-item::after {\n position: absolute;\n z-index: 1;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: rgba(52, 152, 219, 0);\n content: ''; }\n\n.braft-finder .bf-item:hover::after {\n background-color: rgba(52, 152, 219, 0.3); }\n\n.braft-finder .bf-item:hover .bf-item-remove {\n display: block; }\n\n.braft-finder .bf-item.active::before {\n display: block;\n content: \"\\E912\"; }\n\n.braft-finder .bf-item.active::after {\n background-color: rgba(52, 152, 219, 0.6); }\n\n.braft-finder .bf-item.active:hover::after {\n background-color: rgba(52, 152, 219, 0.8); }\n\n.braft-finder .bf-item.active:hover .bf-item-remove {\n display: none; }\n\n.braft-finder .bf-item-uploading {\n box-sizing: border-box;\n position: absolute;\n z-index: 3;\n top: 52px;\n left: 10px;\n width: 93px;\n height: 10px;\n overflow: hidden;\n background-color: rgba(255, 255, 255, 0.3);\n border-radius: 5px;\n box-shadow: 0 0 0 100px rgba(0, 0, 0, 0.5); }\n\n.braft-finder .bf-item-uploading-bar {\n height: 10px;\n background-color: #3498db;\n border-radius: 0; }\n\n.braft-finder .bf-item-remove {\n display: none;\n position: absolute;\n z-index: 2;\n top: 0;\n right: 0;\n width: 28px;\n height: 28px;\n color: #fff;\n font-size: 18px;\n line-height: 28px;\n text-align: center;\n cursor: pointer; }\n .braft-finder .bf-item-remove:hover {\n color: #e74c3c; }\n\n.braft-finder .bf-item-title {\n display: none;\n box-sizing: border-box;\n position: absolute;\n z-index: 2;\n bottom: 0;\n left: 0;\n width: 100%;\n height: 40px;\n padding: 0 5px;\n overflow: hidden;\n background-image: linear-gradient(rgba(0, 0, 0, 0), black);\n color: #fff;\n font-size: 12px;\n line-height: 55px;\n text-align: center;\n text-overflow: ellipsis;\n white-space: nowrap; }\n\n.braft-finder .bf-image {\n width: 100%;\n height: 100%;\n background-color: #eee;\n user-select: none; }\n .braft-finder .bf-image img {\n display: block;\n width: 100%;\n height: 100%;\n object-fit: cover; }\n\n.braft-finder .bf-video {\n background-color: #8e44ad; }\n\n.braft-finder .bf-audio {\n background-color: #f39c12; }\n\n.braft-finder .bf-embed {\n background-color: #f1c40f; }\n\n.braft-finder .bf-icon {\n display: block;\n width: 113px;\n height: 113px;\n overflow: hidden;\n color: #fff;\n text-align: center;\n text-decoration: none; }\n .braft-finder .bf-icon i, .braft-finder .bf-icon span {\n display: block; }\n .braft-finder .bf-icon i {\n margin-top: 35px;\n font-size: 24px; }\n .braft-finder .bf-icon span {\n width: 103px;\n margin: 10px auto;\n overflow: hidden;\n font-size: 12px;\n text-overflow: ellipsis;\n white-space: nowrap; }\n\n.braft-finder .bf-drag-uploader {\n box-sizing: border-box;\n position: absolute;\n z-index: 2;\n top: 0;\n right: 15px;\n left: 15px;\n height: 100%;\n background-color: #fff;\n border: dashed 1px #bbb;\n text-align: center;\n opacity: 0;\n pointer-events: none; }\n .braft-finder .bf-drag-uploader:hover, .braft-finder .bf-drag-uploader.draging {\n background-color: #f1f2f3; }\n .braft-finder .bf-drag-uploader.active {\n opacity: 1;\n pointer-events: auto; }\n\n.braft-finder .bf-uploader-buttons {\n height: 370px;\n margin: auto;\n text-align: center; }\n\n.braft-finder .bf-drag-tip {\n display: inline-block;\n margin-top: 150px;\n color: #ccc;\n text-align: center;\n font-size: 28px;\n font-weight: normal;\n line-height: 40px; }\n .braft-finder .bf-drag-tip input {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n width: 100%;\n height: 100%;\n opacity: 0;\n color: #fff;\n text-indent: -100px;\n cursor: pointer; }\n\n.braft-finder .bf-manager-footer {\n height: 36px;\n margin: 10px 0;\n padding: 0 15px; }\n .braft-finder .bf-manager-footer .button {\n float: right;\n height: 36px;\n margin-left: 5px;\n padding: 0 35px;\n font-size: 12px;\n font-weight: 700;\n border: none;\n border-radius: 3px;\n cursor: pointer; }\n .braft-finder .bf-manager-footer .button-insert {\n color: #fff;\n background-color: #3498db; }\n .braft-finder .bf-manager-footer .button-insert:hover {\n background-color: #2084c7; }\n .braft-finder .bf-manager-footer .button-insert[disabled] {\n opacity: .3;\n pointer-events: none;\n filter: grayscale(0.4); }\n .braft-finder .bf-manager-footer .button-cancel {\n color: #999;\n background-color: #e8e8e9; }\n .braft-finder .bf-manager-footer .button-cancel:hover {\n background-color: #d8d8d9; }\n\n.braft-finder .bf-toggle-external-form {\n color: #666;\n font-size: 12px;\n line-height: 36px; }\n .braft-finder .bf-toggle-external-form span {\n color: #bbb;\n line-height: 16px;\n cursor: pointer;\n user-select: none; }\n .braft-finder .bf-toggle-external-form span:hover {\n color: #3498db; }\n .braft-finder .bf-toggle-external-form span i {\n position: relative;\n top: 2px;\n font-size: 16px; }\n\n.braft-finder .bf-add-external {\n position: absolute;\n z-index: 3;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: #fff; }\n .braft-finder .bf-add-external input {\n border: solid 1px rgba(0, 0, 0, 0.3);\n border: solid 0.5px rgba(0, 0, 0, 0.3);\n box-shadow: none; }\n .braft-finder .bf-add-external input:focus {\n border-color: #3498db;\n box-shadow: none; }\n\n.braft-finder .bf-external-form {\n width: 500px;\n max-width: 90%;\n margin: 91px auto 0 auto; }\n\n.braft-finder .bf-external-input {\n position: relative;\n width: 100%;\n height: 40px;\n margin-bottom: 10px; }\n .braft-finder .bf-external-input div {\n position: absolute;\n top: 0;\n right: 85px;\n left: 0;\n height: 40px; }\n .braft-finder .bf-external-input input,\n .braft-finder .bf-external-input textarea {\n display: block;\n box-sizing: border-box;\n width: 100%;\n height: 40px;\n padding: 0 10px;\n border: none;\n border-radius: 3px;\n outline: none;\n box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3);\n color: #999;\n font-size: 18px; }\n .braft-finder .bf-external-input input:focus,\n .braft-finder .bf-external-input textarea:focus {\n box-shadow: inset 0 0 0 1px #3498db; }\n .braft-finder .bf-external-input textarea {\n height: 100px;\n font-size: 14px; }\n .braft-finder .bf-external-input button {\n position: absolute;\n top: 0;\n right: 0;\n width: 80px;\n height: 40px;\n background-color: #3498db;\n border: none;\n border-radius: 3px;\n color: #fff;\n font-size: 14px;\n font-weight: bold;\n cursor: pointer; }\n .braft-finder .bf-external-input button:disabled {\n opacity: .3;\n pointer-events: none;\n filter: grayscale(0.4); }\n .braft-finder .bf-external-input button:hover {\n background-color: #2084c7; }\n\n.braft-finder .bf-switch-external-type {\n overflow: hidden;\n text-align: center; }\n .braft-finder .bf-switch-external-type button {\n width: auto;\n height: 30px;\n margin: 10px 5px;\n padding: 0 10px;\n background-color: #e8e9ea;\n border: none;\n border-radius: 3px;\n color: #999;\n font-size: 12px;\n cursor: pointer; }\n .braft-finder .bf-switch-external-type button:hover {\n background-color: #d8d9da; }\n .braft-finder .bf-switch-external-type button:only-child {\n display: none; }\n .braft-finder .bf-switch-external-type[data-type=\"IMAGE\"] [data-type=\"IMAGE\"],\n .braft-finder .bf-switch-external-type[data-type=\"VIDEO\"] [data-type=\"VIDEO\"],\n .braft-finder .bf-switch-external-type[data-type=\"AUDIO\"] [data-type=\"AUDIO\"],\n .braft-finder .bf-switch-external-type[data-type=\"EMBED\"] [data-type=\"EMBED\"],\n .braft-finder .bf-switch-external-type[data-type=\"FILE\"] [data-type=\"FILE\"] {\n background-color: #3498db;\n color: #fff; }\n\n.braft-finder .bf-external-tip {\n display: block;\n margin-top: 15px;\n color: #ccc;\n font-size: 12px;\n text-align: center; }\n", ""]);
-
- // exports
-
-
- /***/ }),
- /* 17 */
- /***/ (function(module, exports, __webpack_require__) {
-
-
- var content = __webpack_require__(16);
-
- if(typeof content === 'string') content = [[module.i, content, '']];
-
- var transform;
-
-
-
- var options = {"hmr":true};
-
- options.transform = transform;
- options.insertInto = undefined;
-
- var update = __webpack_require__(12)(content, options);
-
- if(content.locals) module.exports = content.locals;
-
- /***/ }),
- /* 18 */
- /***/ (function(module, exports, __webpack_require__) {
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
-
- var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
-
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
-
- __webpack_require__(17);
-
- var _react = __webpack_require__(2);
-
- var _react2 = _interopRequireDefault(_react);
-
- var _base = __webpack_require__(1);
-
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
- var defaultAccepts = {
- image: 'image/png,image/jpeg,image/gif,image/webp,image/apng,image/svg',
- video: 'video/mp4',
- audio: 'audio/mp3'
- };
-
- var BraftFinderView = function (_React$Component) {
- _inherits(BraftFinderView, _React$Component);
-
- function BraftFinderView(props) {
- _classCallCheck(this, BraftFinderView);
-
- var _this = _possibleConstructorReturn(this, (BraftFinderView.__proto__ || Object.getPrototypeOf(BraftFinderView)).call(this, props));
-
- _this.toggleSelectItem = function (event) {
-
- var itemId = event.currentTarget.dataset.id;
- var item = _this.controller.getMediaItem(itemId);
-
- if (!item) {
- return false;
- }
-
- if (item.selected) {
-
- if (!_this.props.onBeforeDeselect || _this.props.onBeforeDeselect([item], _this.controller.getItems()) !== false) {
- _this.controller.deselectMediaItem(itemId);
- _this.props.onDeselect && _this.props.onDeselect([item], _this.controller.getItems());
- }
- } else {
-
- if (!_this.props.onBeforeSelect || _this.props.onBeforeSelect([item], _this.controller.getItems()) !== false) {
- _this.controller.selectMediaItem(itemId);
- _this.props.onSelect && _this.props.onSelect([item], _this.controller.getItems());
- }
- }
- };
-
- _this.removeItem = function (event) {
-
- var itemId = event.currentTarget.dataset.id;
- var item = _this.controller.getMediaItem(itemId);
-
- if (!item) {
- return false;
- }
-
- if (!_this.props.onBeforeRemove || _this.props.onBeforeRemove([item], _this.controller.getItems()) !== false) {
- _this.controller.removeMediaItem(itemId);
- _this.props.onRemove && _this.props.onRemove([item], _this.controller.getItems());
- }
-
- event.stopPropagation();
- };
-
- _this.selectAllItems = function () {
-
- var allItems = _this.controller.getItems();
-
- if (!_this.props.onBeforeSelect || _this.props.onBeforeSelect(allItems, allItems) !== false) {
- _this.controller.selectAllItems();
- _this.props.onSelect && _this.props.onSelect(allItems, allItems);
- }
- };
-
- _this.deselectAllItems = function () {
-
- var allItems = _this.controller.getItems();
-
- if (!_this.props.onBeforeDeselect || _this.props.onBeforeDeselect(allItems, allItems) !== false) {
- _this.controller.deselectAllItems();
- _this.props.onDeselect && _this.props.onDeselect(allItems, allItems);
- }
- };
-
- _this.removeSelectedItems = function () {
-
- var selectedItems = _this.controller.getSelectedItems();
-
- if (!_this.props.onBeforeRemove || _this.props.onBeforeRemove(selectedItems, _this.controller.getItems()) !== false) {
- _this.controller.removeSelectedItems();
- _this.props.onRemove && _this.props.onRemove(selectedItems, _this.controller.getItems());
- }
- };
-
- _this.handleDragLeave = function (event) {
- event.preventDefault();
- _this.dragCounter--;
- _this.dragCounter === 0 && _this.setState({
- draging: false
- });
- };
-
- _this.handleDragDrop = function (event) {
- event.preventDefault();
- _this.dragCounter = 0;
- _this.setState({ draging: false });
- _this.reslovePickedFiles(event);
- };
-
- _this.handleDragEnter = function (event) {
- event.preventDefault();
- _this.dragCounter++;
- _this.setState({ draging: true });
- };
-
- _this.reslovePickedFiles = function (event) {
-
- event.persist();
-
- var _ref = event.type === 'drop' ? event.dataTransfer : event.target,
- files = _ref.files;
-
- if (_this.props.onFileSelect) {
- var result = _this.props.onFileSelect(files);
- if (result === false) {
- return false;
- } else if (result instanceof FileList || result instanceof Array) {
- files = result;
- }
- }
-
- var accepts = _extends({}, defaultAccepts, _this.props.accepts);
-
- _this.controller.resolveFiles({
- files: files,
- onItemReady: function onItemReady(_ref2) {
- var id = _ref2.id;
- return _this.controller.selectMediaItem(id);
- },
- onAllReady: function onAllReady() {
- return event.target.value = null;
- }
- }, 0, accepts);
- };
-
- _this.inputExternal = function (event) {
- _this.setState({
- external: _extends({}, _this.state.external, {
- url: event.target.value
- })
- });
- };
-
- _this.switchExternalType = function (event) {
- _this.setState({
- external: _extends({}, _this.state.external, { type: event.target.dataset.type })
- });
- };
-
- _this.confirmAddExternal = function (event) {
-
- if (event.target.nodeName.toLowerCase() === 'button' || event.keyCode === 13) {
- var _this$state$external = _this.state.external,
- url = _this$state$external.url,
- type = _this$state$external.type;
-
- url = url.split('|');
- var name = url.length > 1 ? url[0] : _this.props.language.unnamedItem;
- url = url.length > 1 ? url[1] : url[0];
- var thumbnail = type === 'IMAGE' ? url : null;
-
- _this.controller.addItems([{
- thumbnail: thumbnail, url: url, name: name, type: type,
- id: new Date().getTime() + '_' + (0, _base.UniqueIndex)(),
- uploading: false,
- uploadProgress: 1,
- selected: true
- }]);
-
- _this.setState({
- showExternalForm: false,
- external: {
- url: '',
- type: 'IMAGE'
- }
- });
- }
- };
-
- _this.toggleExternalForm = function () {
- _this.setState({
- showExternalForm: !_this.state.showExternalForm
- });
- };
-
- _this.cancelInsert = function () {
- _this.props.onCancel && _this.props.onCancel();
- };
-
- _this.confirmInsert = function () {
-
- var selectedItems = _this.controller.getSelectedItems();
-
- if (_this.props.onBeforeInsert) {
-
- var filteredItems = _this.props.onBeforeInsert(selectedItems);
-
- if (filteredItems && filteredItems instanceof Array) {
- _this.controller.deselectAllItems();
- _this.props.onInsert && _this.props.onInsert(filteredItems);
- } else if (filteredItems !== false) {
- _this.controller.deselectAllItems();
- _this.props.onInsert && _this.props.onInsert(selectedItems);
- }
- } else {
- _this.controller.deselectAllItems();
- _this.props.onInsert && _this.props.onInsert(selectedItems);
- }
- };
-
- _this.dragCounter = 0;
- _this.controller = _this.props.controller;
- var initialItems = _this.controller.getItems();
-
- _this.state = {
- draging: false,
- error: false,
- confirmable: initialItems.find(function (_ref3) {
- var selected = _ref3.selected;
- return selected;
- }),
- external: {
- url: '',
- type: 'IMAGE'
- },
- fileAccept: '',
- showExternalForm: false,
- allowExternal: false,
- items: initialItems
- };
-
- _this.changeListenerId = _this.controller.onChange(function (items) {
- _this.setState({ items: items, confirmable: items.find(function (_ref4) {
- var selected = _ref4.selected;
- return selected;
- }) });
- _this.props.onChange && _this.props.onChange(items);
- });
-
- return _this;
- }
-
- _createClass(BraftFinderView, [{
- key: 'mapPropsToState',
- value: function mapPropsToState(props) {
- var accepts = props.accepts,
- externals = props.externals;
-
-
- accepts = _extends({}, defaultAccepts, accepts);
-
- var fileAccept = !accepts ? [defaultAccepts.image, defaultAccepts.video, defaultAccepts.audio].join(',') : [accepts.image, accepts.video, accepts.audio].filter(function (item) {
- return item;
- }).join(',');
-
- var external = {
- url: '',
- type: externals.image ? 'IMAGE' : externals.audio ? 'AUDIO' : externals.video ? 'VIDEO' : externals.embed ? 'EMBED' : ''
- };
-
- return {
- fileAccept: fileAccept,
- external: external,
- allowExternal: externals && (externals.image || externals.audio || externals.video || externals.embed)
- };
- }
- }, {
- key: 'componentDidMount',
- value: function componentDidMount() {
- this.setState(this.mapPropsToState(this.props));
- }
- }, {
- key: 'componentWillReceiveProps',
- value: function componentWillReceiveProps(nextProps) {
- this.setState(this.mapPropsToState(nextProps));
- }
- }, {
- key: 'componentWillUnmount',
- value: function componentWillUnmount() {
- this.controller.offChange(this.changeListenerId);
- }
- }, {
- key: 'render',
- value: function render() {
- var _props = this.props,
- language = _props.language,
- externals = _props.externals;
- var _state = this.state,
- items = _state.items,
- draging = _state.draging,
- confirmable = _state.confirmable,
- fileAccept = _state.fileAccept,
- external = _state.external,
- showExternalForm = _state.showExternalForm,
- allowExternal = _state.allowExternal;
-
-
- return _react2.default.createElement(
- 'div',
- { className: 'braft-finder' },
- _react2.default.createElement(
- 'div',
- {
- onDragEnter: this.handleDragEnter,
- onDragOver: this.handleDragEnter,
- onDragLeave: this.handleDragLeave,
- onDrop: this.handleDragDrop,
- className: 'bf-uploader'
- },
- _react2.default.createElement(
- 'div',
- { className: "bf-drag-uploader " + (draging || !items.length ? 'active ' : ' ') + (draging ? 'draging' : '') },
- _react2.default.createElement(
- 'span',
- { className: 'bf-drag-tip' },
- _react2.default.createElement('input', { accept: fileAccept, onChange: this.reslovePickedFiles, multiple: true, type: 'file' }),
- draging ? language.dropTip : language.dragTip
- )
- ),
- items.length ? _react2.default.createElement(
- 'div',
- { className: 'bf-list-wrap' },
- _react2.default.createElement(
- 'div',
- { className: 'bf-list-tools' },
- _react2.default.createElement(
- 'span',
- { onClick: this.selectAllItems, className: 'bf-select-all' },
- _react2.default.createElement('i', { className: 'braft-icon-done' }),
- ' ',
- language.selectAll
- ),
- _react2.default.createElement(
- 'span',
- { onClick: this.deselectAllItems, disabled: !confirmable, className: 'bf-deselect-all' },
- _react2.default.createElement('i', { className: 'braft-icon-close' }),
- ' ',
- language.deselect
- ),
- _react2.default.createElement(
- 'span',
- { onClick: this.removeSelectedItems, disabled: !confirmable, className: 'bf-remove-selected' },
- _react2.default.createElement('i', { className: 'braft-icon-bin' }),
- ' ',
- language.removeSelected
- )
- ),
- this.buildItemList()
- ) : null,
- showExternalForm && allowExternal ? _react2.default.createElement(
- 'div',
- { className: 'bf-add-external' },
- _react2.default.createElement(
- 'div',
- { className: 'bf-external-form' },
- _react2.default.createElement(
- 'div',
- { className: 'bf-external-input' },
- _react2.default.createElement(
- 'div',
- null,
- _react2.default.createElement('input', { onKeyDown: this.confirmAddExternal, value: external.url, onChange: this.inputExternal, placeholder: language.externalInputPlaceHolder })
- ),
- _react2.default.createElement(
- 'button',
- { type: 'button', onClick: this.confirmAddExternal, disabled: !external.url.trim().length },
- language.confirm
- )
- ),
- _react2.default.createElement(
- 'div',
- { 'data-type': external.type, className: 'bf-switch-external-type' },
- externals.image ? _react2.default.createElement(
- 'button',
- { type: 'button', onClick: this.switchExternalType, 'data-type': 'IMAGE' },
- language.image
- ) : null,
- externals.audio ? _react2.default.createElement(
- 'button',
- { type: 'button', onClick: this.switchExternalType, 'data-type': 'AUDIO' },
- language.audio
- ) : null,
- externals.video ? _react2.default.createElement(
- 'button',
- { type: 'button', onClick: this.switchExternalType, 'data-type': 'VIDEO' },
- language.video
- ) : null,
- externals.embed ? _react2.default.createElement(
- 'button',
- { type: 'button', onClick: this.switchExternalType, 'data-type': 'EMBED' },
- language.embed
- ) : null
- ),
- _react2.default.createElement(
- 'span',
- { className: 'bf-external-tip' },
- language.externalInputTip
- )
- )
- ) : null
- ),
- _react2.default.createElement(
- 'footer',
- { className: 'bf-manager-footer' },
- _react2.default.createElement(
- 'div',
- { className: 'pull-left' },
- allowExternal ? _react2.default.createElement(
- 'span',
- {
- onClick: this.toggleExternalForm,
- className: 'bf-toggle-external-form'
- },
- showExternalForm ? _react2.default.createElement(
- 'span',
- { className: 'bf-bottom-text' },
- _react2.default.createElement('i', { className: 'braft-icon-add' }),
- ' ',
- language.addLocalFile
- ) : _react2.default.createElement(
- 'span',
- { className: 'bf-bottom-text' },
- _react2.default.createElement('i', { className: 'braft-icon-add' }),
- ' ',
- language.addExternalSource
- )
- ) : null
- ),
- _react2.default.createElement(
- 'div',
- { className: 'pull-right' },
- _react2.default.createElement(
- 'button',
- { onClick: this.confirmInsert, className: 'button button-insert', disabled: !confirmable },
- language.insert
- ),
- _react2.default.createElement(
- 'button',
- { onClick: this.cancelInsert, className: 'button button-cancel' },
- language.cancel
- )
- )
- )
- );
- }
- }, {
- key: 'buildItemList',
- value: function buildItemList() {
- var _this2 = this;
-
- return _react2.default.createElement(
- 'ul',
- { className: 'bf-list' },
- _react2.default.createElement(
- 'li',
- { className: 'bf-add-item' },
- _react2.default.createElement('i', { className: 'braft-icon-add' }),
- _react2.default.createElement('input', { accept: this.state.fileAccept, onChange: this.reslovePickedFiles, multiple: true, type: 'file' })
- ),
- this.state.items.map(function (item, index) {
-
- var previewerComponents = null;
- var progressMarker = item.uploading && !_this2.props.hideProgress ? _react2.default.createElement(
- 'div',
- { className: 'bf-item-uploading' },
- _react2.default.createElement('div', { className: 'bf-item-uploading-bar', style: { width: item.uploadProgress / 1 + '%' } })
- ) : '';
-
- switch (item.type) {
- case 'IMAGE':
- previewerComponents = _react2.default.createElement(
- 'div',
- { className: 'bf-image' },
- progressMarker,
- _react2.default.createElement('img', { src: item.thumbnail || item.url })
- );
- break;
- case 'VIDEO':
- previewerComponents = _react2.default.createElement(
- 'div',
- { className: 'bf-icon bf-video', title: item.url },
- progressMarker,
- _react2.default.createElement('i', { className: 'braft-icon-film' }),
- _react2.default.createElement(
- 'span',
- null,
- item.name || item.url
- )
- );
- break;
- case 'AUDIO':
- previewerComponents = _react2.default.createElement(
- 'div',
- { className: 'bf-icon bf-audio', title: item.url },
- progressMarker,
- _react2.default.createElement('i', { className: 'braft-icon-music' }),
- _react2.default.createElement(
- 'span',
- null,
- item.name || item.url
- )
- );
- break;
- case 'EMBED':
- previewerComponents = _react2.default.createElement(
- 'div',
- { className: 'bf-icon bf-embed', title: item.url },
- progressMarker,
- _react2.default.createElement('i', { className: 'braft-icon-code' }),
- _react2.default.createElement(
- 'span',
- null,
- item.name || _this2.props.language.embed
- )
- );
- break;
- default:
- previewerComponents = _react2.default.createElement(
- 'a',
- { className: 'bf-icon bf-file', title: item.url, href: item.url },
- progressMarker,
- _react2.default.createElement('i', { className: 'braft-icon-file-text' }),
- _react2.default.createElement(
- 'span',
- null,
- item.name || item.url
- )
- );
- break;
- }
-
- var className = ['bf-item'];
- item.selected && className.push('active');
- item.uploading && className.push('uploading');
- item.error && className.push('error');
-
- return _react2.default.createElement(
- 'li',
- {
- key: index,
- title: item.name,
- 'data-id': item.id,
- className: className.join(' '),
- onClick: _this2.toggleSelectItem
- },
- previewerComponents,
- _react2.default.createElement('span', { 'data-id': item.id, onClick: _this2.removeItem, className: 'bf-item-remove braft-icon-close' }),
- _react2.default.createElement(
- 'span',
- { className: 'bf-item-title' },
- item.name
- )
- );
- })
- );
- }
- }]);
-
- return BraftFinderView;
- }(_react2.default.Component);
-
- BraftFinderView.defaultProps = {
- accepts: defaultAccepts,
- externals: {
- image: true,
- video: true,
- audio: true,
- embed: true
- }
- };
- exports.default = BraftFinderView;
-
- /***/ }),
- /* 19 */
- /***/ (function(module, exports, __webpack_require__) {
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
-
- var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
-
- var _base = __webpack_require__(1);
-
- var _image = __webpack_require__(0);
-
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
-
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- var defaultValidator = function defaultValidator() {
- return true;
- };
-
- var BraftFinderController = function BraftFinderController() {
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
-
- _classCallCheck(this, BraftFinderController);
-
- _initialiseProps.call(this);
-
- this.items = props.items || [];
- this.uploadFn = props.uploader;
- this.validateFn = props.validator || defaultValidator;
-
- this.changeListeners = [];
- }
-
- // resolvePastedFiles ({ clipboardData }, callback) {
-
- // if (clipboardData && clipboardData.items && clipboardData.items[0].type.indexOf('image') > -1) {
- // this.uploadImage(clipboardData.items[0].getAsFile(), callback)
- // }
-
- // }
-
- ;
-
- var _initialiseProps = function _initialiseProps() {
- var _this = this;
-
- this.setProps = function () {
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
-
-
- _this.items = props.items || _this.items || [];
- _this.uploadFn = props.uploader;
- _this.validateFn = props.validator || defaultValidator;
- };
-
- this.getMediaItem = function (id) {
- return _this.items.find(function (item) {
- return item.id === id;
- });
- };
-
- this.getSelectedItems = function () {
- return _this.items.filter(function (item) {
- return item.selected;
- });
- };
-
- this.getItems = function () {
- return _this.items;
- };
-
- this.setItems = function (items) {
- _this.items = items.map(function (item) {
- return _extends({}, item, { id: item.id.toString() });
- }) || [];
- _this.applyChange();
- _this.uploadItems();
- };
-
- this.addMediaItem = function (item) {
- _this.addItems([item]);
- };
-
- this.addItems = function (items) {
- _this.items = [].concat(_toConsumableArray(_this.items), _toConsumableArray(items.map(function (item) {
- return _extends({}, item, { id: item.id.toString() });
- })));
- _this.applyChange();
- _this.uploadItems();
- };
-
- this.selectMediaItem = function (id) {
- var item = _this.getMediaItem(id);
- if (item && (item.uploading || item.error)) {
- return false;
- }
- _this.setMediaItemState(id, {
- selected: true
- });
- };
-
- this.selectAllItems = function () {
- _this.items = _this.items.filter(function (item) {
- return !item.error && !item.uploading;
- }).map(function (item) {
- return _extends({}, item, { selected: true });
- });
- _this.applyChange();
- };
-
- this.deselectMediaItem = function (id) {
- _this.setMediaItemState(id, {
- selected: false
- });
- };
-
- this.deselectAllItems = function () {
- _this.items = _this.items.map(function (item) {
- return _extends({}, item, { selected: false });
- });
- _this.applyChange();
- };
-
- this.removeMediaItem = function (id) {
- _this.items = _this.items.filter(function (item) {
- return item.id !== id;
- });
- _this.applyChange();
- };
-
- this.removeItems = function () {
- var ids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
-
- _this.items = _this.items.filter(function (item) {
- return !ids.includes(item.id);
- });
- _this.applyChange();
- };
-
- this.removeSelectedItems = function () {
- _this.items = _this.items.filter(function (item) {
- return !item.selected;
- });
- _this.applyChange();
- };
-
- this.removeErrorItems = function () {
- _this.items = _this.items.filter(function (item) {
- return !item.error;
- });
- _this.applyChange();
- };
-
- this.removeAllItems = function () {
- _this.items = [];
- _this.applyChange();
- };
-
- this.setMediaItemState = function (id, state) {
- _this.items = _this.items.map(function (item) {
- return item.id === id ? _extends({}, item, state) : item;
- });
- _this.applyChange();
- };
-
- this.reuploadErrorItems = function () {
- _this.uploadItems(true);
- };
-
- this.uploadItems = function () {
- var ignoreError = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
-
-
- _this.items.forEach(function (item, index) {
-
- if (item.uploading || item.url) {
- return false;
- }
-
- if (!ignoreError && item.error) {
- return false;
- }
-
- if (item.type === 'IMAGE') {
- _this.createThumbnail(item);
- _this.uploadFn = _this.uploadFn || _this.createInlineImage;
- } else if (!_this.uploadFn) {
- _this.setMediaItemState(item.id, { error: 1 });
- return false;
- }
-
- _this.setMediaItemState(item.id, {
- uploading: true,
- uploadProgress: 0,
- error: 0
- });
-
- _this.uploadFn({
- id: item.id,
- file: item.file,
- success: function success(res) {
- _this.handleUploadSuccess(item.id, res);
- },
- progress: function progress(_progress) {
- _this.setMediaItemState(item.id, {
- uploading: true,
- uploadProgress: _progress
- });
- },
- error: function error(_error) {
- _this.setMediaItemState(item.id, {
- uploading: false,
- error: 2
- });
- }
- });
- });
- };
-
- this.createThumbnail = function (_ref) {
- var id = _ref.id,
- file = _ref.file;
-
-
- (0, _image.compressImage)(URL.createObjectURL(file), 226, 226).then(function (result) {
- _this.setMediaItemState(id, { thumbnail: result.url });
- });
- };
-
- this.createInlineImage = function (param) {
-
- (0, _image.compressImage)(URL.createObjectURL(param.file), 1280, 800).then(function (result) {
- param.success({ url: result.url });
- }).catch(function (error) {
- param.error(error);
- });
- };
-
- this.handleUploadSuccess = function (id, data) {
-
- _this.setMediaItemState(id, _extends({}, data, {
- file: null,
- uploadProgress: 1,
- uploading: false,
- selected: false
- }));
-
- var item = _this.getMediaItem(data.id || id);
- item.onReady && item.onReady(item);
- };
-
- this.applyChange = function () {
- _this.changeListeners.forEach(function (_ref2) {
- var callback = _ref2.callback;
- return callback(_this.items);
- });
- };
-
- this.uploadImage = function (file, callback) {
-
- var fileId = new Date().getTime() + '_' + (0, _base.UniqueIndex)();
-
- _this.addMediaItem({
- type: 'IMAGE',
- id: fileId,
- file: file,
- name: fileId,
- size: file.size,
- uploadProgress: 0,
- uploading: false,
- selected: false,
- error: 0,
- onReady: callback
- });
- };
-
- this.uploadImageRecursively = function (files, callback) {
- var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
-
-
- if (files[index] && files[index].type.indexOf('image') > -1) {
- _this.uploadImage(files[index], function (image) {
- callback && callback(image);
- index < files.length - 1 && _this.uploadImageRecursively(files, callback, index + 1);
- });
- } else {
- index < files.length - 1 && _this.uploadImageRecursively(files, callback, index + 1);
- }
- };
-
- this.addResolvedFiles = function (param, index, accepts) {
-
- var data = {
- id: new Date().getTime() + '_' + (0, _base.UniqueIndex)(),
- file: param.files[index],
- name: param.files[index].name,
- size: param.files[index].size,
- uploadProgress: 0,
- uploading: false,
- selected: false,
- error: 0,
- onReady: function onReady(item) {
- param.onItemReady && param.onItemReady(item);
- }
- };
-
- if (param.files[index].type.indexOf('image/') === 0 && accepts.image) {
- data.type = 'IMAGE';
- _this.addMediaItem(data);
- } else if (param.files[index].type.indexOf('video/') === 0 && accepts.video) {
- data.type = 'VIDEO';
- _this.addMediaItem(data);
- } else if (param.files[index].type.indexOf('audio/') === 0 && accepts.audio) {
- data.type = 'AUDIO';
- _this.addMediaItem(data);
- }
-
- setTimeout(function () {
- _this.resolveFiles(param, index + 1, accepts);
- }, 60);
- };
-
- this.resolveFiles = function (param, index, accepts) {
-
- if (index < param.files.length) {
-
- var validateResult = _this.validateFn(param.files[index]);
-
- if (validateResult instanceof Promise) {
- validateResult.then(function () {
- _this.addResolvedFiles(param, index, accepts);
- });
- } else if (validateResult) {
- _this.addResolvedFiles(param, index, accepts);
- }
- } else {
- param.onAllReady && param.onAllReady();
- }
- };
-
- this.onChange = function (callback) {
-
- var listenerId = (0, _base.UniqueIndex)();
-
- _this.changeListeners.push({
- id: listenerId,
- callback: callback
- });
-
- return listenerId;
- };
-
- this.offChange = function (listenerId) {
- _this.changeListeners = _this.changeListeners.filter(function (_ref3) {
- var id = _ref3.id;
- return id !== listenerId;
- });
- };
- };
-
- exports.default = BraftFinderController;
-
- /***/ }),
- /* 20 */
- /***/ (function(module, exports, __webpack_require__) {
-
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.ImageUtils = undefined;
-
- var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
-
- var _react = __webpack_require__(2);
-
- var _react2 = _interopRequireDefault(_react);
-
- var _controller = __webpack_require__(19);
-
- var _controller2 = _interopRequireDefault(_controller);
-
- var _view = __webpack_require__(18);
-
- var _view2 = _interopRequireDefault(_view);
-
- var _languages = __webpack_require__(10);
-
- var _languages2 = _interopRequireDefault(_languages);
-
- var _image = __webpack_require__(0);
-
- var ImageUtils = _interopRequireWildcard(_image);
-
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
-
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
- var BraftFinder = function (_FinderController) {
- _inherits(BraftFinder, _FinderController);
-
- function BraftFinder(props) {
- _classCallCheck(this, BraftFinder);
-
- var _this = _possibleConstructorReturn(this, (BraftFinder.__proto__ || Object.getPrototypeOf(BraftFinder)).call(this, props));
-
- _initialiseProps.call(_this);
-
- _this.superProps = props;
- return _this;
- }
-
- return BraftFinder;
- }(_controller2.default);
-
- var _initialiseProps = function _initialiseProps() {
- var _this2 = this;
-
- this.ReactComponent = function () {
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
-
-
- var componentProps = _extends({}, _this2.superProps, props);
-
- var language = (typeof componentProps.language === 'function' ? componentProps.language(_languages2.default, 'braft-finder') : _languages2.default[componentProps.language]) || _languages2.default['zh'];
-
- return _react2.default.createElement(_view2.default, _extends({}, componentProps, {
- language: language,
- controller: _this2
- }));
- };
- };
-
- exports.default = BraftFinder;
- exports.ImageUtils = ImageUtils;
-
- /***/ })
- /******/ ]);
- });
- });
-
- unwrapExports(dist$2);
-
- var dist$3 = createCommonjsModule(function (module, exports) {
- (function webpackUniversalModuleDefinition(root, factory) {
- module.exports = factory(React, dist$1, Draft, immutable$1, dist, ReactDOM, dist$2, draftjsUtils);
- })(window, function(__WEBPACK_EXTERNAL_MODULE__0__, __WEBPACK_EXTERNAL_MODULE__3__, __WEBPACK_EXTERNAL_MODULE__6__, __WEBPACK_EXTERNAL_MODULE__13__, __WEBPACK_EXTERNAL_MODULE__14__, __WEBPACK_EXTERNAL_MODULE__16__, __WEBPACK_EXTERNAL_MODULE__17__, __WEBPACK_EXTERNAL_MODULE__23__) {
- return /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
- /******/ }
- /******/ };
- /******/
- /******/ // define __esModule on exports
- /******/ __webpack_require__.r = function(exports) {
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
- /******/ }
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
- /******/ };
- /******/
- /******/ // 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
- /******/ __webpack_require__.t = function(value, mode) {
- /******/ if(mode & 1) value = __webpack_require__(value);
- /******/ if(mode & 8) return value;
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
- /******/ var ns = Object.create(null);
- /******/ __webpack_require__.r(ns);
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
- /******/ return ns;
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "/";
- /******/
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 39);
- /******/ })
- /************************************************************************/
- /******/ ([
- /* 0 */
- /***/ (function(module, exports) {
-
- module.exports = __WEBPACK_EXTERNAL_MODULE__0__;
-
- /***/ }),
- /* 1 */
- /***/ (function(module, exports) {
-
- function _assertThisInitialized(self) {
- if (self === void 0) {
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- }
-
- return self;
- }
-
- module.exports = _assertThisInitialized;
-
- /***/ }),
- /* 2 */
- /***/ (function(module, exports) {
-
- function _defineProperty(obj, key, value) {
- if (key in obj) {
- Object.defineProperty(obj, key, {
- value: value,
- enumerable: true,
- configurable: true,
- writable: true
- });
- } else {
- obj[key] = value;
- }
-
- return obj;
- }
-
- module.exports = _defineProperty;
-
- /***/ }),
- /* 3 */
- /***/ (function(module, exports) {
-
- module.exports = __WEBPACK_EXTERNAL_MODULE__3__;
-
- /***/ }),
- /* 4 */
- /***/ (function(module, exports) {
-
- function _classCallCheck(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError("Cannot call a class as a function");
- }
- }
-
- module.exports = _classCallCheck;
-
- /***/ }),
- /* 5 */
- /***/ (function(module, exports, __webpack_require__) {
-
- var defineProperty = __webpack_require__(2);
-
- function _objectSpread(target) {
- for (var i = 1; i < arguments.length; i++) {
- var source = arguments[i] != null ? arguments[i] : {};
- var ownKeys = Object.keys(source);
-
- if (typeof Object.getOwnPropertySymbols === 'function') {
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
- }));
- }
-
- ownKeys.forEach(function (key) {
- defineProperty(target, key, source[key]);
- });
- }
-
- return target;
- }
-
- module.exports = _objectSpread;
-
- /***/ }),
- /* 6 */
- /***/ (function(module, exports) {
-
- module.exports = __WEBPACK_EXTERNAL_MODULE__6__;
-
- /***/ }),
- /* 7 */
- /***/ (function(module, exports) {
-
- function _defineProperties(target, props) {
- for (var i = 0; i < props.length; i++) {
- var descriptor = props[i];
- descriptor.enumerable = descriptor.enumerable || false;
- descriptor.configurable = true;
- if ("value" in descriptor) descriptor.writable = true;
- Object.defineProperty(target, descriptor.key, descriptor);
- }
- }
-
- function _createClass(Constructor, protoProps, staticProps) {
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
- if (staticProps) _defineProperties(Constructor, staticProps);
- return Constructor;
- }
-
- module.exports = _createClass;
-
- /***/ }),
- /* 8 */
- /***/ (function(module, exports, __webpack_require__) {
-
- var _typeof = __webpack_require__(15);
-
- var assertThisInitialized = __webpack_require__(1);
-
- function _possibleConstructorReturn(self, call) {
- if (call && (_typeof(call) === "object" || typeof call === "function")) {
- return call;
- }
-
- return assertThisInitialized(self);
- }
-
- module.exports = _possibleConstructorReturn;
-
- /***/ }),
- /* 9 */
- /***/ (function(module, exports) {
-
- function _getPrototypeOf(o) {
- module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
- return o.__proto__ || Object.getPrototypeOf(o);
- };
- return _getPrototypeOf(o);
- }
-
- module.exports = _getPrototypeOf;
-
- /***/ }),
- /* 10 */
- /***/ (function(module, exports, __webpack_require__) {
-
- var setPrototypeOf = __webpack_require__(26);
-
- function _inherits(subClass, superClass) {
- if (typeof superClass !== "function" && superClass !== null) {
- throw new TypeError("Super expression must either be null or a function");
- }
-
- subClass.prototype = Object.create(superClass && superClass.prototype, {
- constructor: {
- value: subClass,
- writable: true,
- configurable: true
- }
- });
- if (superClass) setPrototypeOf(subClass, superClass);
- }
-
- module.exports = _inherits;
-
- /***/ }),
- /* 11 */
- /***/ (function(module, exports) {
-
- function _extends() {
- module.exports = _extends = Object.assign || function (target) {
- for (var i = 1; i < arguments.length; i++) {
- var source = arguments[i];
-
- for (var key in source) {
- if (Object.prototype.hasOwnProperty.call(source, key)) {
- target[key] = source[key];
- }
- }
- }
-
- return target;
- };
-
- return _extends.apply(this, arguments);
- }
-
- module.exports = _extends;
-
- /***/ }),
- /* 12 */
- /***/ (function(module, exports, __webpack_require__) {
-
- var arrayWithoutHoles = __webpack_require__(27);
-
- var iterableToArray = __webpack_require__(28);
-
- var nonIterableSpread = __webpack_require__(29);
-
- function _toConsumableArray(arr) {
- return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();
- }
-
- module.exports = _toConsumableArray;
-
- /***/ }),
- /* 13 */
- /***/ (function(module, exports) {
-
- module.exports = __WEBPACK_EXTERNAL_MODULE__13__;
-
- /***/ }),
- /* 14 */
- /***/ (function(module, exports) {
-
- module.exports = __WEBPACK_EXTERNAL_MODULE__14__;
-
- /***/ }),
- /* 15 */
- /***/ (function(module, exports) {
-
- function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); }
-
- function _typeof(obj) {
- if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") {
- module.exports = _typeof = function _typeof(obj) {
- return _typeof2(obj);
- };
- } else {
- module.exports = _typeof = function _typeof(obj) {
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj);
- };
- }
-
- return _typeof(obj);
- }
-
- module.exports = _typeof;
-
- /***/ }),
- /* 16 */
- /***/ (function(module, exports) {
-
- module.exports = __WEBPACK_EXTERNAL_MODULE__16__;
-
- /***/ }),
- /* 17 */
- /***/ (function(module, exports) {
-
- module.exports = __WEBPACK_EXTERNAL_MODULE__17__;
-
- /***/ }),
- /* 18 */
- /***/ (function(module, exports, __webpack_require__) {
-
- var Immutable = __webpack_require__(13);
-
- var KEY_SEPARATOR = '-';
-
- function MultiDecorator(decorators) {
- this.decorators = Immutable.List(decorators);
- }
-
- /**
- Return list of decoration IDs per character
-
- @param {ContentBlock}
- @return {List<String>}
- */
- MultiDecorator.prototype.getDecorations = function(block) {
- var decorations = Array(block.getText().length).fill(null);
-
- this.decorators.forEach(function(decorator, i) {
- var _decorations = decorator.getDecorations(block);
-
- _decorations.forEach(function(key, offset) {
- if (!key) {
- return;
- }
-
- key = i + KEY_SEPARATOR + key;
-
- decorations[offset] = key;
- });
- });
-
- return Immutable.List(decorations);
- };
-
- /**
- Return component to render a decoration
-
- @param {String}
- @return {Function}
- */
- MultiDecorator.prototype.getComponentForKey = function(key) {
- var decorator = this.getDecoratorForKey(key);
- return decorator.getComponentForKey(
- this.getInnerKey(key)
- );
- };
-
- /**
- Return props to render a decoration
-
- @param {String}
- @return {Object}
- */
- MultiDecorator.prototype.getPropsForKey = function(key) {
- var decorator = this.getDecoratorForKey(key);
- return decorator.getPropsForKey(
- this.getInnerKey(key)
- );
- };
-
- /**
- Return a decorator for a specific key
-
- @param {String}
- @return {Decorator}
- */
- MultiDecorator.prototype.getDecoratorForKey = function(key) {
- var parts = key.split(KEY_SEPARATOR);
- var index = Number(parts[0]);
-
- return this.decorators.get(index);
- };
-
- /**
- Return inner key for a decorator
-
- @param {String}
- @return {String}
- */
- MultiDecorator.prototype.getInnerKey = function(key) {
- var parts = key.split(KEY_SEPARATOR);
- return parts.slice(1).join(KEY_SEPARATOR);
- };
-
- module.exports = MultiDecorator;
-
-
- /***/ }),
- /* 19 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule CharacterMetadata
- * @format
- *
- */
-
-
-
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
- var _require = __webpack_require__(13),
- Map = _require.Map,
- OrderedSet = _require.OrderedSet,
- Record = _require.Record;
-
- // Immutable.map is typed such that the value for every key in the map
- // must be the same type
-
-
- var EMPTY_SET = OrderedSet();
-
- var defaultRecord = {
- style: EMPTY_SET,
- entity: null
- };
-
- var CharacterMetadataRecord = Record(defaultRecord);
-
- var CharacterMetadata = function (_CharacterMetadataRec) {
- _inherits(CharacterMetadata, _CharacterMetadataRec);
-
- function CharacterMetadata() {
- _classCallCheck(this, CharacterMetadata);
-
- return _possibleConstructorReturn(this, _CharacterMetadataRec.apply(this, arguments));
- }
-
- CharacterMetadata.prototype.getStyle = function getStyle() {
- return this.get('style');
- };
-
- CharacterMetadata.prototype.getEntity = function getEntity() {
- return this.get('entity');
- };
-
- CharacterMetadata.prototype.hasStyle = function hasStyle(style) {
- return this.getStyle().includes(style);
- };
-
- CharacterMetadata.applyStyle = function applyStyle(record, style) {
- var withStyle = record.set('style', record.getStyle().add(style));
- return CharacterMetadata.create(withStyle);
- };
-
- CharacterMetadata.removeStyle = function removeStyle(record, style) {
- var withoutStyle = record.set('style', record.getStyle().remove(style));
- return CharacterMetadata.create(withoutStyle);
- };
-
- CharacterMetadata.applyEntity = function applyEntity(record, entityKey) {
- var withEntity = record.getEntity() === entityKey ? record : record.set('entity', entityKey);
- return CharacterMetadata.create(withEntity);
- };
-
- /**
- * Use this function instead of the `CharacterMetadata` constructor.
- * Since most content generally uses only a very small number of
- * style/entity permutations, we can reuse these objects as often as
- * possible.
- */
-
-
- CharacterMetadata.create = function create(config) {
- if (!config) {
- return EMPTY;
- }
-
- var defaultConfig = {
- style: EMPTY_SET,
- entity: null
- };
-
- // Fill in unspecified properties, if necessary.
- var configMap = Map(defaultConfig).merge(config);
-
- var existing = pool.get(configMap);
- if (existing) {
- return existing;
- }
-
- var newCharacter = new CharacterMetadata(configMap);
- pool = pool.set(configMap, newCharacter);
- return newCharacter;
- };
-
- return CharacterMetadata;
- }(CharacterMetadataRecord);
-
- var EMPTY = new CharacterMetadata();
- var pool = Map([[Map(defaultRecord), EMPTY]]);
-
- CharacterMetadata.EMPTY = EMPTY;
-
- module.exports = CharacterMetadata;
-
- /***/ }),
- /* 20 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule findRangesImmutable
- * @format
- *
- */
-
-
-
- /**
- * Search through an array to find contiguous stretches of elements that
- * match a specified filter function.
- *
- * When ranges are found, execute a specified `found` function to supply
- * the values to the caller.
- */
- function findRangesImmutable(haystack, areEqualFn, filterFn, foundFn) {
- if (!haystack.size) {
- return;
- }
-
- var cursor = 0;
-
- haystack.reduce(function (value, nextValue, nextIndex) {
- if (!areEqualFn(value, nextValue)) {
- if (filterFn(value)) {
- foundFn(cursor, nextIndex);
- }
- cursor = nextIndex;
- }
- return nextValue;
- });
-
- filterFn(haystack.last()) && foundFn(cursor, haystack.count());
- }
-
- module.exports = findRangesImmutable;
-
- /***/ }),
- /* 21 */
- /***/ (function(module, exports, __webpack_require__) {
-
- var objectWithoutPropertiesLoose = __webpack_require__(25);
-
- function _objectWithoutProperties(source, excluded) {
- if (source == null) return {};
- var target = objectWithoutPropertiesLoose(source, excluded);
- var key, i;
-
- if (Object.getOwnPropertySymbols) {
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
-
- for (i = 0; i < sourceSymbolKeys.length; i++) {
- key = sourceSymbolKeys[i];
- if (excluded.indexOf(key) >= 0) continue;
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
- target[key] = source[key];
- }
- }
-
- return target;
- }
-
- module.exports = _objectWithoutProperties;
-
- /***/ }),
- /* 22 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule getFragmentFromSelection
- * @format
- *
- */
-
-
-
- var getContentStateFragment = __webpack_require__(30);
-
- function getFragmentFromSelection(editorState) {
- var selectionState = editorState.getSelection();
-
- if (selectionState.isCollapsed()) {
- return null;
- }
-
- return getContentStateFragment(editorState.getCurrentContent(), selectionState);
- }
-
- module.exports = getFragmentFromSelection;
-
- /***/ }),
- /* 23 */
- /***/ (function(module, exports) {
-
- module.exports = __WEBPACK_EXTERNAL_MODULE__23__;
-
- /***/ }),
- /* 24 */
- /***/ (function(module, exports, __webpack_require__) {
-
- var arrayWithHoles = __webpack_require__(36);
-
- var iterableToArrayLimit = __webpack_require__(37);
-
- var nonIterableRest = __webpack_require__(38);
-
- function _slicedToArray(arr, i) {
- return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || nonIterableRest();
- }
-
- module.exports = _slicedToArray;
-
- /***/ }),
- /* 25 */
- /***/ (function(module, exports) {
-
- function _objectWithoutPropertiesLoose(source, excluded) {
- if (source == null) return {};
- var target = {};
- var sourceKeys = Object.keys(source);
- var key, i;
-
- for (i = 0; i < sourceKeys.length; i++) {
- key = sourceKeys[i];
- if (excluded.indexOf(key) >= 0) continue;
- target[key] = source[key];
- }
-
- return target;
- }
-
- module.exports = _objectWithoutPropertiesLoose;
-
- /***/ }),
- /* 26 */
- /***/ (function(module, exports) {
-
- function _setPrototypeOf(o, p) {
- module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
- o.__proto__ = p;
- return o;
- };
-
- return _setPrototypeOf(o, p);
- }
-
- module.exports = _setPrototypeOf;
-
- /***/ }),
- /* 27 */
- /***/ (function(module, exports) {
-
- function _arrayWithoutHoles(arr) {
- if (Array.isArray(arr)) {
- for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
- arr2[i] = arr[i];
- }
-
- return arr2;
- }
- }
-
- module.exports = _arrayWithoutHoles;
-
- /***/ }),
- /* 28 */
- /***/ (function(module, exports) {
-
- function _iterableToArray(iter) {
- if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
- }
-
- module.exports = _iterableToArray;
-
- /***/ }),
- /* 29 */
- /***/ (function(module, exports) {
-
- function _nonIterableSpread() {
- throw new TypeError("Invalid attempt to spread non-iterable instance");
- }
-
- module.exports = _nonIterableSpread;
-
- /***/ }),
- /* 30 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule getContentStateFragment
- * @format
- *
- */
-
-
-
- var randomizeBlockMapKeys = __webpack_require__(31);
- var removeEntitiesAtEdges = __webpack_require__(34);
-
- var getContentStateFragment = function getContentStateFragment(contentState, selectionState) {
- var startKey = selectionState.getStartKey();
- var startOffset = selectionState.getStartOffset();
- var endKey = selectionState.getEndKey();
- var endOffset = selectionState.getEndOffset();
-
- // Edge entities should be stripped to ensure that we don't preserve
- // invalid partial entities when the fragment is reused. We do, however,
- // preserve entities that are entirely within the selection range.
- var contentWithoutEdgeEntities = removeEntitiesAtEdges(contentState, selectionState);
-
- var blockMap = contentWithoutEdgeEntities.getBlockMap();
- var blockKeys = blockMap.keySeq();
- var startIndex = blockKeys.indexOf(startKey);
- var endIndex = blockKeys.indexOf(endKey) + 1;
-
- return randomizeBlockMapKeys(blockMap.slice(startIndex, endIndex).map(function (block, blockKey) {
- var text = block.getText();
- var chars = block.getCharacterList();
-
- if (startKey === endKey) {
- return block.merge({
- text: text.slice(startOffset, endOffset),
- characterList: chars.slice(startOffset, endOffset)
- });
- }
-
- if (blockKey === startKey) {
- return block.merge({
- text: text.slice(startOffset),
- characterList: chars.slice(startOffset)
- });
- }
-
- if (blockKey === endKey) {
- return block.merge({
- text: text.slice(0, endOffset),
- characterList: chars.slice(0, endOffset)
- });
- }
-
- return block;
- }));
- };
-
- module.exports = getContentStateFragment;
-
- /***/ }),
- /* 31 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule randomizeBlockMapKeys
- * @format
- *
- */
-
-
-
- var ContentBlockNode = __webpack_require__(32);
- var Immutable = __webpack_require__(13);
-
- var generateRandomKey = __webpack_require__(33);
-
- var OrderedMap = Immutable.OrderedMap;
-
-
- var randomizeContentBlockNodeKeys = function randomizeContentBlockNodeKeys(blockMap) {
- var newKeysRef = {};
-
- // we keep track of root blocks in order to update subsequent sibling links
- var lastRootBlock = void 0;
-
- return OrderedMap(blockMap.withMutations(function (blockMapState) {
- blockMapState.forEach(function (block, index) {
- var oldKey = block.getKey();
- var nextKey = block.getNextSiblingKey();
- var prevKey = block.getPrevSiblingKey();
- var childrenKeys = block.getChildKeys();
- var parentKey = block.getParentKey();
-
- // new key that we will use to build linking
- var key = generateRandomKey();
-
- // we will add it here to re-use it later
- newKeysRef[oldKey] = key;
-
- if (nextKey) {
- var nextBlock = blockMapState.get(nextKey);
- if (nextBlock) {
- blockMapState.setIn([nextKey, 'prevSibling'], key);
- } else {
- // this can happen when generating random keys for fragments
- blockMapState.setIn([oldKey, 'nextSibling'], null);
- }
- }
-
- if (prevKey) {
- var prevBlock = blockMapState.get(prevKey);
- if (prevBlock) {
- blockMapState.setIn([prevKey, 'nextSibling'], key);
- } else {
- // this can happen when generating random keys for fragments
- blockMapState.setIn([oldKey, 'prevSibling'], null);
- }
- }
-
- if (parentKey && blockMapState.get(parentKey)) {
- var parentBlock = blockMapState.get(parentKey);
- var parentChildrenList = parentBlock.getChildKeys();
- blockMapState.setIn([parentKey, 'children'], parentChildrenList.set(parentChildrenList.indexOf(block.getKey()), key));
- } else {
- // blocks will then be treated as root block nodes
- blockMapState.setIn([oldKey, 'parent'], null);
-
- if (lastRootBlock) {
- blockMapState.setIn([lastRootBlock.getKey(), 'nextSibling'], key);
- blockMapState.setIn([oldKey, 'prevSibling'], newKeysRef[lastRootBlock.getKey()]);
- }
-
- lastRootBlock = blockMapState.get(oldKey);
- }
-
- childrenKeys.forEach(function (childKey) {
- var childBlock = blockMapState.get(childKey);
- if (childBlock) {
- blockMapState.setIn([childKey, 'parent'], key);
- } else {
- blockMapState.setIn([oldKey, 'children'], block.getChildKeys().filter(function (child) {
- return child !== childKey;
- }));
- }
- });
- });
- }).toArray().map(function (block) {
- return [newKeysRef[block.getKey()], block.set('key', newKeysRef[block.getKey()])];
- }));
- };
-
- var randomizeContentBlockKeys = function randomizeContentBlockKeys(blockMap) {
- return OrderedMap(blockMap.toArray().map(function (block) {
- var key = generateRandomKey();
- return [key, block.set('key', key)];
- }));
- };
-
- var randomizeBlockMapKeys = function randomizeBlockMapKeys(blockMap) {
- var isTreeBasedBlockMap = blockMap.first() instanceof ContentBlockNode;
-
- if (!isTreeBasedBlockMap) {
- return randomizeContentBlockKeys(blockMap);
- }
-
- return randomizeContentBlockNodeKeys(blockMap);
- };
-
- module.exports = randomizeBlockMapKeys;
-
- /***/ }),
- /* 32 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule ContentBlockNode
- * @format
- *
- *
- * This file is a fork of ContentBlock adding support for nesting references by
- * providing links to children, parent, prevSibling, and nextSibling.
- *
- * This is unstable and not part of the public API and should not be used by
- * production systems. This file may be update/removed without notice.
- */
-
-
-
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
- var CharacterMetadata = __webpack_require__(19);
- var Immutable = __webpack_require__(13);
-
- var findRangesImmutable = __webpack_require__(20);
-
- var List = Immutable.List,
- Map = Immutable.Map,
- OrderedSet = Immutable.OrderedSet,
- Record = Immutable.Record,
- Repeat = Immutable.Repeat;
-
-
- var EMPTY_SET = OrderedSet();
-
- var defaultRecord = {
- parent: null,
- characterList: List(),
- data: Map(),
- depth: 0,
- key: '',
- text: '',
- type: 'unstyled',
- children: List(),
- prevSibling: null,
- nextSibling: null
- };
-
- var haveEqualStyle = function haveEqualStyle(charA, charB) {
- return charA.getStyle() === charB.getStyle();
- };
-
- var haveEqualEntity = function haveEqualEntity(charA, charB) {
- return charA.getEntity() === charB.getEntity();
- };
-
- var decorateCharacterList = function decorateCharacterList(config) {
- if (!config) {
- return config;
- }
-
- var characterList = config.characterList,
- text = config.text;
-
-
- if (text && !characterList) {
- config.characterList = List(Repeat(CharacterMetadata.EMPTY, text.length));
- }
-
- return config;
- };
-
- var ContentBlockNode = function (_Record) {
- _inherits(ContentBlockNode, _Record);
-
- function ContentBlockNode() {
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultRecord;
-
- _classCallCheck(this, ContentBlockNode);
-
- return _possibleConstructorReturn(this, _Record.call(this, decorateCharacterList(props)));
- }
-
- ContentBlockNode.prototype.getKey = function getKey() {
- return this.get('key');
- };
-
- ContentBlockNode.prototype.getType = function getType() {
- return this.get('type');
- };
-
- ContentBlockNode.prototype.getText = function getText() {
- return this.get('text');
- };
-
- ContentBlockNode.prototype.getCharacterList = function getCharacterList() {
- return this.get('characterList');
- };
-
- ContentBlockNode.prototype.getLength = function getLength() {
- return this.getText().length;
- };
-
- ContentBlockNode.prototype.getDepth = function getDepth() {
- return this.get('depth');
- };
-
- ContentBlockNode.prototype.getData = function getData() {
- return this.get('data');
- };
-
- ContentBlockNode.prototype.getInlineStyleAt = function getInlineStyleAt(offset) {
- var character = this.getCharacterList().get(offset);
- return character ? character.getStyle() : EMPTY_SET;
- };
-
- ContentBlockNode.prototype.getEntityAt = function getEntityAt(offset) {
- var character = this.getCharacterList().get(offset);
- return character ? character.getEntity() : null;
- };
-
- ContentBlockNode.prototype.getChildKeys = function getChildKeys() {
- return this.get('children');
- };
-
- ContentBlockNode.prototype.getParentKey = function getParentKey() {
- return this.get('parent');
- };
-
- ContentBlockNode.prototype.getPrevSiblingKey = function getPrevSiblingKey() {
- return this.get('prevSibling');
- };
-
- ContentBlockNode.prototype.getNextSiblingKey = function getNextSiblingKey() {
- return this.get('nextSibling');
- };
-
- ContentBlockNode.prototype.findStyleRanges = function findStyleRanges(filterFn, callback) {
- findRangesImmutable(this.getCharacterList(), haveEqualStyle, filterFn, callback);
- };
-
- ContentBlockNode.prototype.findEntityRanges = function findEntityRanges(filterFn, callback) {
- findRangesImmutable(this.getCharacterList(), haveEqualEntity, filterFn, callback);
- };
-
- return ContentBlockNode;
- }(Record(defaultRecord));
-
- module.exports = ContentBlockNode;
-
- /***/ }),
- /* 33 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule generateRandomKey
- * @format
- *
- */
-
-
-
- var seenKeys = {};
- var MULTIPLIER = Math.pow(2, 24);
-
- function generateRandomKey() {
- var key = void 0;
- while (key === undefined || seenKeys.hasOwnProperty(key) || !isNaN(+key)) {
- key = Math.floor(Math.random() * MULTIPLIER).toString(32);
- }
- seenKeys[key] = true;
- return key;
- }
-
- module.exports = generateRandomKey;
-
- /***/ }),
- /* 34 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- * @providesModule removeEntitiesAtEdges
- * @format
- *
- */
-
-
-
- var CharacterMetadata = __webpack_require__(19);
-
- var findRangesImmutable = __webpack_require__(20);
- var invariant = __webpack_require__(35);
-
- function removeEntitiesAtEdges(contentState, selectionState) {
- var blockMap = contentState.getBlockMap();
- var entityMap = contentState.getEntityMap();
-
- var updatedBlocks = {};
-
- var startKey = selectionState.getStartKey();
- var startOffset = selectionState.getStartOffset();
- var startBlock = blockMap.get(startKey);
- var updatedStart = removeForBlock(entityMap, startBlock, startOffset);
-
- if (updatedStart !== startBlock) {
- updatedBlocks[startKey] = updatedStart;
- }
-
- var endKey = selectionState.getEndKey();
- var endOffset = selectionState.getEndOffset();
- var endBlock = blockMap.get(endKey);
- if (startKey === endKey) {
- endBlock = updatedStart;
- }
-
- var updatedEnd = removeForBlock(entityMap, endBlock, endOffset);
-
- if (updatedEnd !== endBlock) {
- updatedBlocks[endKey] = updatedEnd;
- }
-
- if (!Object.keys(updatedBlocks).length) {
- return contentState.set('selectionAfter', selectionState);
- }
-
- return contentState.merge({
- blockMap: blockMap.merge(updatedBlocks),
- selectionAfter: selectionState
- });
- }
-
- function getRemovalRange(characters, key, offset) {
- var removalRange;
- findRangesImmutable(characters, function (a, b) {
- return a.getEntity() === b.getEntity();
- }, function (element) {
- return element.getEntity() === key;
- }, function (start, end) {
- if (start <= offset && end >= offset) {
- removalRange = { start: start, end: end };
- }
- });
- !(typeof removalRange === 'object') ? invariant(false) : void 0;
- return removalRange;
- }
-
- function removeForBlock(entityMap, block, offset) {
- var chars = block.getCharacterList();
- var charBefore = offset > 0 ? chars.get(offset - 1) : undefined;
- var charAfter = offset < chars.count() ? chars.get(offset) : undefined;
- var entityBeforeCursor = charBefore ? charBefore.getEntity() : undefined;
- var entityAfterCursor = charAfter ? charAfter.getEntity() : undefined;
-
- if (entityAfterCursor && entityAfterCursor === entityBeforeCursor) {
- var entity = entityMap.__get(entityAfterCursor);
- if (entity.getMutability() !== 'MUTABLE') {
- var _getRemovalRange = getRemovalRange(chars, entityAfterCursor, offset),
- start = _getRemovalRange.start,
- end = _getRemovalRange.end;
-
- var current;
- while (start < end) {
- current = chars.get(start);
- chars = chars.set(start, CharacterMetadata.applyEntity(current, null));
- start++;
- }
- return block.set('characterList', chars);
- }
- }
-
- return block;
- }
-
- module.exports = removeEntitiesAtEdges;
-
- /***/ }),
- /* 35 */
- /***/ (function(module, exports, __webpack_require__) {
-
- function invariant(condition, format, a, b, c, d, e, f) {
-
- if (!condition) {
- var error;
- if (format === undefined) {
- error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
- } else {
- var args = [a, b, c, d, e, f];
- var argIndex = 0;
- error = new Error(format.replace(/%s/g, function () {
- return args[argIndex++];
- }));
- error.name = 'Invariant Violation';
- }
-
- error.framesToPop = 1; // we don't care about invariant's own frame
- throw error;
- }
- }
-
- module.exports = invariant;
-
- /***/ }),
- /* 36 */
- /***/ (function(module, exports) {
-
- function _arrayWithHoles(arr) {
- if (Array.isArray(arr)) return arr;
- }
-
- module.exports = _arrayWithHoles;
-
- /***/ }),
- /* 37 */
- /***/ (function(module, exports) {
-
- function _iterableToArrayLimit(arr, i) {
- var _arr = [];
- var _n = true;
- var _d = false;
- var _e = undefined;
-
- try {
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
- _arr.push(_s.value);
-
- if (i && _arr.length === i) break;
- }
- } catch (err) {
- _d = true;
- _e = err;
- } finally {
- try {
- if (!_n && _i["return"] != null) _i["return"]();
- } finally {
- if (_d) throw _e;
- }
- }
-
- return _arr;
- }
-
- module.exports = _iterableToArrayLimit;
-
- /***/ }),
- /* 38 */
- /***/ (function(module, exports) {
-
- function _nonIterableRest() {
- throw new TypeError("Invalid attempt to destructure non-iterable instance");
- }
-
- module.exports = _nonIterableRest;
-
- /***/ }),
- /* 39 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- __webpack_require__.r(__webpack_exports__);
-
- // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/typeof.js
- var helpers_typeof = __webpack_require__(15);
- var typeof_default = /*#__PURE__*/__webpack_require__.n(helpers_typeof);
-
- // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/objectSpread.js
- var objectSpread = __webpack_require__(5);
- var objectSpread_default = /*#__PURE__*/__webpack_require__.n(objectSpread);
-
- // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/objectWithoutProperties.js
- var objectWithoutProperties = __webpack_require__(21);
- var objectWithoutProperties_default = /*#__PURE__*/__webpack_require__.n(objectWithoutProperties);
-
- // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/classCallCheck.js
- var classCallCheck = __webpack_require__(4);
- var classCallCheck_default = /*#__PURE__*/__webpack_require__.n(classCallCheck);
-
- // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/createClass.js
- var createClass = __webpack_require__(7);
- var createClass_default = /*#__PURE__*/__webpack_require__.n(createClass);
-
- // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js
- var possibleConstructorReturn = __webpack_require__(8);
- var possibleConstructorReturn_default = /*#__PURE__*/__webpack_require__.n(possibleConstructorReturn);
-
- // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/getPrototypeOf.js
- var getPrototypeOf = __webpack_require__(9);
- var getPrototypeOf_default = /*#__PURE__*/__webpack_require__.n(getPrototypeOf);
-
- // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/inherits.js
- var inherits = __webpack_require__(10);
- var inherits_default = /*#__PURE__*/__webpack_require__.n(inherits);
-
- // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/assertThisInitialized.js
- var assertThisInitialized = __webpack_require__(1);
- var assertThisInitialized_default = /*#__PURE__*/__webpack_require__.n(assertThisInitialized);
-
- // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/defineProperty.js
- var defineProperty = __webpack_require__(2);
- var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty);
-
- // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/toConsumableArray.js
- var toConsumableArray = __webpack_require__(12);
- var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray);
-
- // EXTERNAL MODULE: ../node_modules/draft-js/dist/Draft.css
- var Draft = __webpack_require__(40);
-
- // EXTERNAL MODULE: ./assets/scss/_base.scss
- var _base = __webpack_require__(42);
-
- // EXTERNAL MODULE: external "react"
- var external_react_ = __webpack_require__(0);
- var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);
-
- // CONCATENATED MODULE: ./languages/en.js
- /* harmony default export */ var en = ({
- base: {
- remove: 'Remove',
- cancel: 'Cancel',
- confirm: 'Confirm',
- inert: 'Insert',
- width: 'Width',
- height: 'Height'
- },
- controls: {
- clear: 'Clear',
- undo: 'Undo',
- redo: 'Redo',
- fontSize: 'Font Size',
- color: 'Color',
- textColor: 'Text',
- tempColors: 'Temp Colors',
- backgroundColor: 'Background',
- bold: 'Bold',
- lineHeight: 'Line Height',
- letterSpacing: 'Letter Spacing',
- textIndent: 'Text Indent',
- increaseIndent: 'Increase Indent',
- decreaseIndent: 'Decrease Indent',
- italic: 'Italic',
- underline: 'Underline',
- strikeThrough: 'Strike Through',
- fontFamily: 'Font Family',
- textAlign: 'Text Alignment',
- alignLeft: 'Left Alignment',
- alignCenter: 'Center Alignment',
- alignRight: 'Right Alignment',
- alignJustify: 'Justify Alignment',
- floatLeft: 'Left Float',
- floatRight: 'Right Float',
- superScript: 'Super Script',
- subScript: 'Sub Script',
- removeStyles: 'Remove Styles',
- headings: 'Headings',
- header: 'Header',
- normal: 'Normal',
- orderedList: 'Ordered List',
- unorderedList: 'Unordered List',
- blockQuote: 'Quote',
- code: 'Code',
- link: 'Link',
- unlink: 'Unlink',
- hr: 'Horizontal Line',
- media: 'Media',
- mediaLibirary: 'Media Library',
- emoji: 'Emoji',
- fullscreen: 'Fullscreen',
- exitFullscreen: 'Exit Fullscreen'
- },
- linkEditor: {
- textInputPlaceHolder: 'Input link text',
- linkInputPlaceHolder: 'Input link URL',
- inputWithEnterPlaceHolder: 'Input link URL and press Enter',
- openInNewWindow: 'Open in new window',
- removeLink: 'Remove Link'
- },
- audioPlayer: {
- title: 'Play Audio'
- },
- videoPlayer: {
- title: 'Play Video',
- embedTitle: 'Embed Media'
- },
- media: {
- image: 'Image',
- video: 'Video',
- audio: 'Audio',
- embed: 'Embed'
- }
- });
- // CONCATENATED MODULE: ./languages/zh.js
- /* harmony default export */ var zh = ({
- base: {
- remove: '删除',
- cancel: '取消',
- confirm: '确定',
- inert: '插入',
- width: '宽度',
- height: '高度'
- },
- controls: {
- clear: '清除内容',
- undo: '撤销',
- redo: '重做',
- fontSize: '字号',
- lineHeight: '行高',
- letterSpacing: '字间距',
- textIndent: '段落缩进',
- increaseIndent: '增加缩进',
- decreaseIndent: '减少缩进',
- border: '边框',
- color: '颜色',
- textColor: '文字颜色',
- backgroundColor: '背景颜色',
- tempColors: '临时颜色',
- bold: '加粗',
- italic: '斜体',
- underline: '下划线',
- strikeThrough: '删除线',
- fontFamily: '字体',
- textAlign: '文本对齐',
- alignLeft: '居左',
- alignCenter: '居中',
- alignRight: '居右',
- alignJustify: '两端',
- floatLeft: '左浮动',
- floatRight: '右浮动',
- superScript: '上标',
- subScript: '下标',
- removeStyles: '清除样式',
- headings: '标题',
- header: '标题',
- normal: '常规',
- orderedList: '有序列表',
- unorderedList: '无序列表',
- blockQuote: '引用',
- code: '代码',
- link: '链接',
- unlink: '清除链接',
- hr: '水平线',
- media: '媒体',
- mediaLibirary: '媒体库',
- emoji: '小表情',
- fullscreen: '全屏',
- exitFullscreen: '退出全屏'
- },
- linkEditor: {
- textInputPlaceHolder: '输入链接文字',
- linkInputPlaceHolder: '输入链接地址',
- inputWithEnterPlaceHolder: '输入链接地址并回车',
- openInNewWindow: '在新窗口打开',
- removeLink: '移除链接'
- },
- audioPlayer: {
- title: '播放音频文件'
- },
- videoPlayer: {
- title: '播放视频文件',
- embedTitle: '嵌入式媒体'
- },
- media: {
- image: '图像',
- video: '视频',
- audio: '音频',
- embed: '嵌入式媒体'
- }
- });
- // CONCATENATED MODULE: ./languages/zh-hant.js
- /* harmony default export */ var zh_hant = ({
- base: {
- remove: '刪除',
- cancel: '取消',
- confirm: '確定',
- inert: '插入',
- width: '宽度',
- height: '高度'
- },
- controls: {
- clear: '清除内容',
- undo: '撤銷',
- redo: '重做',
- fontSize: '字號',
- color: '顏色',
- textColor: '文字顏色',
- backgroundColor: '背景顏色',
- tempColors: '臨時顏色',
- bold: '加粗',
- lineHeight: '行高',
- letterSpacing: '字間距',
- textIndent: '段落縮進',
- increaseIndent: '增加縮進',
- decreaseIndent: '减少縮進',
- border: '邊框',
- italic: '斜體',
- underline: '下劃線',
- strikeThrough: '刪除線',
- fontFamily: '字體',
- textAlign: '文本對齊',
- alignLeft: '居左',
- alignCenter: '居中',
- alignRight: '居右',
- alignJustify: '兩端對齊',
- floatLeft: '左浮動',
- floatRight: '右浮動',
- superScript: '上標',
- subScript: '下標',
- removeStyles: '清除样式',
- headings: '標題',
- header: '標題',
- normal: '常規',
- orderedList: '有序列表',
- unorderedList: '無序列表',
- blockQuote: '引用',
- code: '代碼',
- link: '鏈接',
- unlink: '清除鏈接',
- hr: '水平线',
- media: '媒體',
- mediaLibirary: '媒體库',
- emoji: '小表情',
- fullscreen: '全熒幕',
- exitFullscreen: '退出全熒幕'
- },
- linkEditor: {
- textInputPlaceHolder: '輸入鏈接文字',
- linkInputPlaceHolder: '輸入鏈接地址',
- inputWithEnterPlaceHolder: '輸入鏈接地址並回車',
- openInNewWindow: '在新窗口打開',
- removeLink: '移除鏈接'
- },
- audioPlayer: {
- title: '播放音頻文件'
- },
- videoPlayer: {
- title: '播放視頻文件',
- embedTitle: '嵌入式媒體'
- },
- media: {
- image: '圖像',
- video: '視頻',
- audio: '音頻',
- embed: '嵌入式媒體'
- }
- });
- // CONCATENATED MODULE: ./languages/pl.js
- /* harmony default export */ var pl = ({
- base: {
- remove: 'Usuń',
- cancel: 'Anuluj',
- confirm: 'Potwierdź',
- inert: 'Wstaw',
- width: 'Szerokość',
- height: 'Wysokość'
- },
- controls: {
- clear: 'Wyczyść',
- undo: 'Cofnij',
- redo: 'Przywróć',
- fontSize: 'Wielkość',
- color: 'Kolor',
- textColor: 'Kolor tekstu',
- tempColors: 'Kolory',
- backgroundColor: 'Tło',
- bold: 'Pogrubienie',
- lineHeight: 'Wysokość linii',
- letterSpacing: 'Odstęp znaków',
- textIndent: 'Wcięcie tekstu',
- increaseIndent: 'Zwiększ wcięcie',
- decreaseIndent: 'Zmniejsz wcięcie',
- italic: 'Italiki',
- underline: 'Podkreślenie',
- strikeThrough: 'Przekreślenie',
- fontFamily: 'Czcionka',
- textAlign: 'Wyrównanie tekstu',
- alignLeft: 'Do lewej',
- alignCenter: 'Wycentruj',
- alignRight: 'Do prawej',
- alignJustify: 'Wyjustuj',
- floatLeft: 'Do lewej',
- floatRight: 'Do prawej',
- superScript: 'Superskrypt',
- subScript: 'Subskrypt',
- removeStyles: 'Usuń stylowanie',
- headings: 'Nagłówki',
- header: 'Nagłówek',
- normal: 'Normalny',
- orderedList: 'Lista uporządkowana',
- unorderedList: 'Lista nieuporządkowana',
- blockQuote: 'Cytat',
- code: 'Kod',
- link: 'Link',
- unlink: 'Usuń link',
- hr: 'Linia pozioma',
- media: 'Media',
- mediaLibirary: 'Biblioteka mediów',
- emoji: 'Emoji'
- },
- linkEditor: {
- textInputPlaceHolder: 'Wpisz tekst linku',
- linkInputPlaceHolder: 'Wpisz Adres URL',
- inputWithEnterPlaceHolder: 'Wpisz adres URL i naciśnij Enter',
- openInNewWindow: 'Otwórz w nowym oknie',
- removeLink: 'Usuń link'
- },
- audioPlayer: {
- title: 'Odtwórz audio'
- },
- videoPlayer: {
- title: 'Odtwórz wideo',
- embedTitle: 'Tytuł'
- },
- media: {
- image: 'Obraz',
- video: 'Wideo',
- audio: 'Audio',
- embed: 'Obiekt osadzony'
- }
- });
- // CONCATENATED MODULE: ./languages/kr.js
- /* harmony default export */ var kr = ({
- base: {
- remove: '삭제',
- cancel: '취소',
- confirm: '결정',
- inert: '삽입',
- width: '너비',
- height: '높이'
- },
- controls: {
- clear: '콘텐츠지우기',
- undo: '취소',
- redo: '다시하기',
- fontSize: '글자크기',
- lineHeight: '행높이',
- letterSpacing: '단어간격',
- textIndent: '단락들여쓰기',
- increaseIndent: '들여쓰기늘리기',
- decreaseIndent: '들여쓰기줄이기',
- border: '국경',
- color: '색상',
- textColor: '텍스트색상',
- backgroundColor: '배경색상',
- tempColors: '임시색',
- bold: '굵게',
- italic: '기울임꼴',
- underline: '밑줄',
- strikeThrough: '취소선',
- fontFamily: '글꼴',
- textAlign: '텍스트정렬',
- alignLeft: '왼쪽',
- alignCenter: '중심',
- alignRight: '오른쪽',
- alignJustify: '양쪽끝',
- floatLeft: '떠다니기',
- floatRight: '오른쪽부동',
- superScript: '위첨자',
- subScript: '첨자',
- removeStyles: '스타일지우기',
- headings: '제목',
- header: '제목',
- normal: '재래식',
- orderedList: '순서가지정된목록',
- unorderedList: '정렬되지않은목록',
- blockQuote: '참고문헌',
- code: '코드',
- link: '링크',
- unlink: '링크삭제',
- hr: '수평선',
- media: '미디어',
- mediaLibirary: '미디어라이브러리',
- emoji: '작은표현',
- fullscreen: '전체화면',
- exitFullscreen: '전체화면종료'
- },
- linkEditor: {
- textInputPlaceHolder: '링크텍스트입력',
- linkInputPlaceHolder: '링크주소입력',
- inputWithEnterPlaceHolder: '링크주소입력.',
- openInNewWindow: '새창열기',
- removeLink: '링크삭제'
- },
- audioPlayer: {
- title: '오디오파일재생'
- },
- videoPlayer: {
- title: '비디오파일재생',
- embedTitle: '임베디드미디어'
- },
- media: {
- image: '이미지',
- video: '비디오',
- audio: '오디오',
- embed: '임베디드미디어'
- }
- });
- // CONCATENATED MODULE: ./languages/tr.js
- /* harmony default export */ var tr = ({
- base: {
- remove: 'Kaldır',
- cancel: 'İptal',
- confirm: 'Onayla',
- inert: 'Ekle',
- width: 'Genişlik',
- height: 'Yükseklik'
- },
- controls: {
- clear: 'Temizle',
- undo: 'Geri al',
- redo: 'İleri al',
- fontSize: 'Yazı boyutu',
- color: 'Renk',
- textColor: 'Yazı rengi',
- tempColors: 'Geçici renkler',
- backgroundColor: 'Arkaplan',
- bold: 'Kalın',
- lineHeight: 'Satır yüksekliği',
- letterSpacing: 'Harf aralığı',
- textIndent: 'Çentik aralığı',
- increaseIndent: 'Çentiği genişlet',
- decreaseIndent: 'Çentiği daralt',
- italic: 'Eğik',
- underline: 'Altı çizili',
- strikeThrough: 'Üstü çizili',
- fontFamily: 'Yazı tipi',
- textAlign: 'Metin Hizalama',
- alignLeft: 'Sola hizala',
- alignCenter: 'Ortaya hizala',
- alignRight: 'Sağa hizala',
- alignJustify: 'Her iki tarafa hizala',
- floatLeft: 'Sola yatır',
- floatRight: 'Sağa yatır',
- superScript: 'Ana kod',
- subScript: 'Alt kod',
- removeStyles: 'Stilleri kaldır',
- headings: 'Başlıklar',
- header: 'Başlık',
- normal: 'Normal',
- orderedList: 'Sıralı liste',
- unorderedList: 'Sırasız liste',
- blockQuote: 'Alıntı',
- code: 'Kod',
- link: 'Bağlantı',
- unlink: 'Bağlantıyı kaldır',
- hr: 'Yatay çizgi',
- media: 'Medya',
- mediaLibirary: 'Kütüphane',
- emoji: 'İfade',
- fullscreen: 'Tam ekran',
- exitFullscreen: 'Tam ekrandan çık'
- },
- linkEditor: {
- textInputPlaceHolder: 'Bağlantı metnini girin',
- linkInputPlaceHolder: 'Bağlantı URL\' si girin',
- inputWithEnterPlaceHolder: 'Bağlantı URL\'si girin ve Enter\' a basın',
- openInNewWindow: 'Yeni pencerede aç',
- removeLink: 'Bağlantıyı kaldır'
- },
- audioPlayer: {
- title: 'Ses çal'
- },
- videoPlayer: {
- title: 'Görüntü oynat',
- embedTitle: 'Görüntüyü göm'
- },
- media: {
- image: 'Resim',
- video: 'Görüntü',
- audio: 'Ses',
- embed: 'Gömülü nesne'
- }
- });
- // CONCATENATED MODULE: ./languages/jpn.js
- /* harmony default export */ var jpn = ({
- base: {
- remove: '削除',
- cancel: 'キャンセル',
- confirm: '決定',
- inert: '挿入',
- width: '幅',
- height: '高さ'
- },
- controls: {
- clear: 'クリアコンテンツ',
- undo: 'キャンセル',
- redo: 'キャンセル',
- fontSize: 'フォントサイズ',
- lineHeight: 'フォントサイズ',
- letterSpacing: 'ワード間隔',
- textIndent: '段落のインデント',
- increaseIndent: 'インデントを増やす',
- decreaseIndent: 'インデントを減らす',
- border: '国境',
- color: '色',
- textColor: 'テキストの色',
- backgroundColor: '背景色',
- tempColors: '仮色',
- bold: '太字',
- italic: 'イタリック体',
- underline: '下線',
- strikeThrough: '取り消し線',
- fontFamily: 'フォント',
- textAlign: 'テキストの配置',
- alignLeft: '左',
- alignCenter: '中央揃え',
- alignRight: '右に立つ',
- alignJustify: '両端',
- floatLeft: '左フローティング',
- floatRight: '右フローティング',
- superScript: '上付き',
- subScript: '下付き文字',
- removeStyles: 'クリアスタイル',
- headings: '役職',
- header: '役職',
- normal: '従来の',
- orderedList: '順序付きリスト',
- unorderedList: '番号なしリスト',
- blockQuote: '参照',
- code: 'コード',
- link: 'リンク',
- unlink: 'リンクを解除',
- hr: '横線',
- media: 'メディア',
- mediaLibirary: 'メディアライブラリー',
- emoji: '小さな表現',
- fullscreen: '全画面',
- exitFullscreen: '全画面を退く'
- },
- linkEditor: {
- textInputPlaceHolder: 'リンクテキストを入力',
- linkInputPlaceHolder: 'リンクアドレスを入力',
- inputWithEnterPlaceHolder: 'リンクアドレスを入力して戻ります',
- openInNewWindow: '新しいウィンドウで開く',
- removeLink: '新しいウィンドウで開く'
- },
- audioPlayer: {
- title: 'オーディオファイルを再生する'
- },
- videoPlayer: {
- title: 'ビデオファイルを再生する',
- embedTitle: '埋め込みメディア'
- },
- media: {
- image: '画像',
- video: 'ビデオ',
- audio: '音声',
- embed: '埋め込みメディア'
- }
- });
- // CONCATENATED MODULE: ./languages/ru.js
- /* harmony default export */ var ru = ({
- base: {
- remove: 'Удалить',
- cancel: 'Отмена',
- confirm: 'Подтвердить',
- insert: 'Вставить',
- width: 'Ширина',
- height: 'Высота'
- },
- controls: {
- clear: 'Очистить',
- undo: 'Отменить',
- redo: 'Повторить',
- fontSize: 'Размер шрифта',
- color: 'Цвет',
- textColor: 'Цвет текста',
- tempColors: 'Temp Colors',
- backgroundColor: 'Цвет фона',
- bold: 'Жирный',
- lineHeight: 'Межстрочный интервал',
- letterSpacing: 'Межбуквенный интервал',
- textIndent: 'Отступ',
- increaseIndent: 'Увеличить отступ',
- decreaseIndent: 'Уменьшить отступ',
- italic: 'Курсив',
- underline: 'Подчеркнутый',
- strikeThrough: 'Перечеркнутый',
- fontFamily: 'Шрифт',
- textAlign: 'Расположение текста',
- alignLeft: 'По левому краю',
- alignCenter: 'По центру',
- alignRight: 'По правому краю',
- alignJustify: 'По ширине',
- floatLeft: 'Обтекание слева',
- floatRight: 'Обтекание справа',
- superScript: 'Надстрочный индекс',
- subScript: 'Подстрочный индекс',
- removeStyles: 'Убрать стили',
- headings: 'Заголовки',
- header: 'Заголовок',
- normal: 'Обычный',
- orderedList: 'Упорядоченный список',
- unorderedList: 'Неупорядоченный список',
- blockQuote: 'Цитата',
- code: 'Код',
- link: 'Вставить ссылку',
- unlink: 'Убрать ссылку',
- hr: 'Горизонтальная линия',
- media: 'Медиа',
- mediaLibirary: 'Медиа библиотека',
- emoji: 'Emoji',
- fullscreen: 'Полноэкранный режим',
- exitFullscreen: 'Выйти из полноэкранного режима'
- },
- linkEditor: {
- textInputPlaceHolder: 'Введите текст ссылки',
- linkInputPlaceHolder: 'Вставить ссылку',
- inputWithEnterPlaceHolder: 'Вставить ссылку и нажать Enter',
- openInNewWindow: 'Открыть в новом окне',
- removeLink: 'Убрать ссылку'
- },
- audioPlayer: {
- title: 'Воспроизвести аудиофайл'
- },
- videoPlayer: {
- title: 'Воспроизвести видеофайл',
- embedTitle: 'Embed Media'
- },
- media: {
- image: 'Картинка',
- video: 'Видео',
- audio: 'Аудио',
- embed: 'Встроенное'
- }
- });
- // CONCATENATED MODULE: ./languages/fr.js
- /* harmony default export */ var fr = ({
- base: {
- remove: 'Supprimer',
- cancel: 'Annuler',
- confirm: 'Confirmer',
- inert: 'Insérer',
- width: 'Largeur',
- height: 'Hauteur'
- },
- controls: {
- clear: 'Effacer',
- undo: 'Annuler',
- redo: 'Refaire',
- fontSize: 'Taille de police',
- color: 'Couleur',
- textColor: 'Texte',
- tempColors: 'Couleurs temporaire',
- backgroundColor: 'Couleur d\'arrière plan',
- bold: 'Gras',
- lineHeight: 'Hauteur de ligne',
- letterSpacing: 'Espacement des lettres',
- textIndent: 'Indentation du texte',
- increaseIndent: 'Augmenter l\'indentation',
- decreaseIndent: 'Réduire l\'indentation',
- italic: 'Italique',
- underline: 'Souligner',
- strikeThrough: 'Barrer',
- fontFamily: 'Police d\'écriture',
- textAlign: 'Alignement du texte',
- alignLeft: 'Aligner à gauche',
- alignCenter: 'Aligner au centre',
- alignRight: 'Aligner à droite',
- alignJustify: 'Justifier',
- floatLeft: 'Déplacer à gauche',
- floatRight: 'Déplacer à droite',
- superScript: 'Super-script',
- subScript: 'Sous-script',
- removeStyles: 'Supprimer les styles',
- headings: 'Titres',
- header: 'Entêtes',
- normal: 'Normal',
- orderedList: 'Liste ordonnée',
- unorderedList: 'Liste non-ordonnée',
- blockQuote: 'Citation',
- code: 'Code',
- link: 'Insérer un lien',
- unlink: 'Supprimer le lien',
- hr: 'Ligne horizontale',
- media: 'Média',
- mediaLibirary: 'Bibliothêque',
- emoji: 'Emoji',
- fullscreen: 'Plein écran',
- exitFullscreen: 'Quitter le plein écran'
- },
- linkEditor: {
- textInputPlaceHolder: 'Insérer le texte à afficher',
- linkInputPlaceHolder: 'Insérer le lien URL',
- inputWithEnterPlaceHolder: 'Insérer le lien URL puis appuyer sur Entrée',
- openInNewWindow: 'Ouvrir dans une nouvelle fenêtre',
- removeLink: 'Supprimer le lien'
- },
- audioPlayer: {
- title: 'Lancer le son audio'
- },
- videoPlayer: {
- title: 'Lancer la video',
- embedTitle: 'Intégrer média'
- },
- media: {
- image: 'Image',
- video: 'Vidéo',
- audio: 'Audio',
- embed: 'Intégré'
- }
- });
- // CONCATENATED MODULE: ./languages/pt-br.js
- /* harmony default export */ var pt_br = ({
- base: {
- remove: 'Remover',
- cancel: 'Cancelar',
- confirm: 'Confirmar',
- inert: 'Inserir',
- width: 'Largura',
- height: 'Altura'
- },
- controls: {
- clear: 'Limpar',
- undo: 'Desfazer',
- redo: 'Refazer',
- fontSize: 'Tamanho da Fonte',
- color: 'Cor',
- textColor: 'Texto',
- tempColors: 'Temp Colors',
- backgroundColor: 'Cor de Fundo',
- bold: 'Negrito',
- lineHeight: 'Altura da LinhaLine Height',
- letterSpacing: 'Espaçamento entre Letras',
- textIndent: 'Identação de Texto',
- increaseIndent: 'Aumentar Identação',
- decreaseIndent: 'Diminuir Identção',
- italic: 'Itálico',
- underline: 'Sublinhado',
- strikeThrough: 'Riscado',
- fontFamily: 'Família da Fonte',
- textAlign: 'Alinhamento de Texto',
- alignLeft: 'Alinhamento à Esquerda',
- alignCenter: 'Alinhamento Centralizado',
- alignRight: 'Alinhamento à Direita',
- alignJustify: 'Alinhamento Justificado',
- floatLeft: 'Flutuação à Esquerda',
- floatRight: 'Flutuação à Direita',
- superScript: 'Sobrescrito',
- subScript: 'Subscrito',
- removeStyles: 'Remover Estilos',
- headings: 'Cabeçalhos',
- header: 'Cabeçalho',
- normal: 'Normal',
- orderedList: 'Lista Ordenada',
- unorderedList: 'Lista Não Ordenada',
- blockQuote: 'Citação',
- code: 'Código',
- link: 'Link',
- unlink: 'Remover Link',
- hr: 'Linha Horizontal',
- media: 'Mídia',
- mediaLibirary: 'Biblioteca de Mídia',
- emoji: 'Emoji',
- fullscreen: 'Tela Cheia',
- exitFullscreen: 'Sair de Tela Cheia'
- },
- linkEditor: {
- textInputPlaceHolder: 'Insira o texto do link',
- linkInputPlaceHolder: 'Insira a URL do link',
- inputWithEnterPlaceHolder: 'Insira a URL do link e aperte Enter',
- openInNewWindow: 'Abrir em nova janela',
- removeLink: 'Remover Link'
- },
- audioPlayer: {
- title: 'Tocar Áudio'
- },
- videoPlayer: {
- title: 'Tocar Vídeo',
- embedTitle: 'Mídia Embutida'
- },
- media: {
- image: 'Imagem',
- video: 'Vídeo',
- audio: 'Áudio',
- embed: 'Embutido'
- }
- });
- // CONCATENATED MODULE: ./languages/index.js
-
-
-
-
-
-
-
-
-
-
- /* harmony default export */ var languages = ({
- 'en': en,
- 'zh': zh,
- 'zh-hant': zh_hant,
- 'pl': pl,
- 'kr': kr,
- 'tr': tr,
- 'jpn': jpn,
- 'ru': ru,
- 'fr': fr,
- 'pt-br': pt_br
- });
- // EXTERNAL MODULE: external "braft-finder"
- var external_braft_finder_ = __webpack_require__(17);
- var external_braft_finder_default = /*#__PURE__*/__webpack_require__.n(external_braft_finder_);
-
- // EXTERNAL MODULE: external "braft-utils"
- var external_braft_utils_ = __webpack_require__(3);
-
- // EXTERNAL MODULE: external "draft-js"
- var external_draft_js_ = __webpack_require__(6);
-
- // EXTERNAL MODULE: external "immutable"
- var external_immutable_ = __webpack_require__(13);
- var external_immutable_default = /*#__PURE__*/__webpack_require__.n(external_immutable_);
-
- // CONCATENATED MODULE: ./configs/keybindings.js
- // TODO
- // 允许自定义的快捷键设置
-
- /* harmony default export */ var keybindings = (function (customKeyBindingFn) {
- return function (event) {
- if (event.keyCode === 83 && (external_draft_js_["KeyBindingUtil"].hasCommandModifier(event) || external_draft_js_["KeyBindingUtil"].isCtrlKeyCommand(event))) {
- return 'braft-save';
- }
-
- if (customKeyBindingFn) {
- return customKeyBindingFn(event) || Object(external_draft_js_["getDefaultKeyBinding"])(event);
- }
-
- return Object(external_draft_js_["getDefaultKeyBinding"])(event);
- };
- });
- // CONCATENATED MODULE: ./configs/props.js
- /* harmony default export */ var configs_props = ({
- language: 'zh',
- controls: ['undo', 'redo', 'separator', 'font-size', 'line-height', 'letter-spacing', 'separator', 'text-color', 'bold', 'italic', 'underline', 'strike-through', 'separator', 'superscript', 'subscript', 'remove-styles', 'emoji', 'separator', 'text-indent', 'text-align', 'separator', 'headings', 'list-ul', 'list-ol', 'blockquote', 'code', 'separator', 'media', 'link', 'table', 'split', 'hr', 'separator', 'clear', 'separator', 'fullscreen'],
- excludeControls: [],
- extendControls: [],
- extendAtomics: [],
- componentBelowControlBar: null,
- media: {
- pasteImage: true,
- imagePasteLimit: 5,
- image: true,
- video: true,
- audio: true,
- uploadFn: null,
- validateFn: null,
- onBeforeDeselect: null,
- onDeselect: null,
- onBeforeSelect: null,
- onSelect: null,
- onBeforeRemove: null,
- onRemove: null,
- onCancel: null,
- onFileSelect: null,
- onBeforeInsert: null,
- onInsert: null,
- onChange: null,
- accepts: {
- image: 'image/png,image/jpeg,image/gif,image/webp,image/apng,image/svg',
- video: 'video/mp4',
- audio: 'audio/mp3'
- },
- externals: {
- audio: true,
- video: true,
- image: true,
- embed: true
- }
- },
- imageControls: ['float-left', 'float-right', 'align-left', 'align-center', 'align-right', 'link', 'size', 'remove'],
- imageResizable: true,
- colors: ['#000000', '#333333', '#666666', '#999999', '#cccccc', '#ffffff', '#61a951', '#16a085', '#07a9fe', '#003ba5', '#8e44ad', '#f32784', '#c0392b', '#d35400', '#f39c12', '#fdda00'],
- colorPicker: null,
- colorPickerTheme: 'dark',
- colorPickerAutoHide: true,
- codeTabIndents: 2,
- headings: ['header-one', 'header-two', 'header-three', 'header-four', 'header-five', 'header-six', 'unstyled'],
- textAligns: ['left', 'center', 'right', 'justify'],
- textBackgroundColor: true,
- allowInsertLinkText: false,
- defaultLinkTarget: '',
- letterSpacings: [0, 1, 2, 3, 4, 5, 6],
- lineHeights: [1, 1.2, 1.5, 1.75, 2, 2.5, 3, 4],
- fontSizes: [12, 14, 16, 18, 20, 24, 28, 30, 32, 36, 40, 48, 56, 64, 72, 96, 120, 144],
- fontFamilies: [{
- name: 'Araial',
- family: 'Arial, Helvetica, sans-serif'
- }, {
- name: 'Georgia',
- family: 'Georgia, serif'
- }, {
- name: 'Impact',
- family: 'Impact, serif'
- }, {
- name: 'Monospace',
- family: '"Courier New", Courier, monospace'
- }, {
- name: 'Tahoma',
- family: 'tahoma, arial, "Hiragino Sans GB", 宋体, sans-serif'
- }],
- converts: {
- unitExportFn: function unitExportFn(value, type) {
- return type === 'line-height' ? value : "".concat(value, "px");
- }
- },
- emojis: ['🤣', '🙌', '💚', '💛', '👏', '😉', '💯', '💕', '💞', '💘', '💙', '💝', '🖤', '💜', '❤️', '😍', '😻', '💓', '💗', '😋', '😇', '😂', '😹', '😘', '💖', '😁', '😀', '🤞', '😲', '😄', '😊', '👍', '😌', '😃', '😅', '✌️', '🤗', '💋', '😗', '😽', '😚', '🤠', '😙', '😺', '👄', '😸', '😏', '😼', '👌', '😎', '😆', '😛', '🙏', '🤝', '🙂', '🤑', '😝', '😐', '😑', '🤤', '😤', '🙃', '🤡', '😶', '😪', '😴', '😵', '😓', '👊', '😦', '😷', '🤐', '😜', '🤓', '👻', '😥', '🙄', '🤔', '🤒', '🙁', '😔', '😯', '☹️', '☠️', '😰', '😩', '😖', '😕', '😒', '😣', '😢', '😮', '😿', '🤧', '😫', '🤥', '😞', '😬', '👎', '💀', '😳', '😨', '🤕', '🤢', '😱', '😭', '😠', '😈', '😧', '💔', '😟', '🙀', '💩', '👿', '😡', '😾', '🖕'],
- stripPastedStyles: false,
- triggerChangeOnMount: true,
- className: '',
- style: {},
- controlBarClassName: '',
- controlBarStyle: {},
- contentClassName: '',
- contentStyle: {},
- draftProps: {},
- hooks: {},
- onChange: null,
- onFocus: null,
- onBlur: null,
- onTab: null,
- onDelete: null,
- onSave: null,
- fixPlaceholder: false
- });
- // EXTERNAL MODULE: ../node_modules/draft-js/lib/getFragmentFromSelection.js
- var getFragmentFromSelection = __webpack_require__(22);
- var getFragmentFromSelection_default = /*#__PURE__*/__webpack_require__.n(getFragmentFromSelection);
-
- // EXTERNAL MODULE: external "draftjs-utils"
- var external_draftjs_utils_ = __webpack_require__(23);
-
- // CONCATENATED MODULE: ./configs/handlers.js
-
-
-
-
-
-
- var handlers_keyCommandHandlers = function keyCommandHandlers(command, editorState, editor) {
- if (editor.editorProps.handleKeyCommand && editor.editorProps.handleKeyCommand(command, editorState, editor) === 'handled') {
- return 'handled';
- }
-
- if (command === 'braft-save') {
- editor.editorProps.onSave && editor.editorProps.onSave(editorState);
- return 'handled';
- }
-
- var _editor$editorProps = editor.editorProps,
- controls = _editor$editorProps.controls,
- excludeControls = _editor$editorProps.excludeControls;
- var allowIndent = (controls.indexOf('text-indent') !== 0 || controls.find(function (item) {
- return item.key === 'text-indent';
- })) && excludeControls.indexOf('text-indent') === -1;
- var cursorStart = editorState.getSelection().getStartOffset();
- var cursorEnd = editorState.getSelection().getEndOffset();
- var cursorIsAtFirst = cursorStart === 0 && cursorEnd === 0;
-
- if (command === 'backspace') {
- if (editor.editorProps.onDelete && editor.editorProps.onDelete(editorState) === false) {
- return 'handled';
- }
-
- var blockType = external_braft_utils_["ContentUtils"].getSelectionBlockType(editorState);
-
- if (allowIndent && cursorIsAtFirst && blockType !== 'code-block') {
- editor.setValue(external_braft_utils_["ContentUtils"].decreaseSelectionIndent(editorState));
- }
- }
-
- if (command === 'tab') {
- var _blockType = external_braft_utils_["ContentUtils"].getSelectionBlockType(editorState);
-
- if (_blockType === 'code-block') {
- editor.setValue(external_braft_utils_["ContentUtils"].insertText(editorState, ' '.repeat(editor.editorProps.codeTabIndents)));
- return 'handled';
- } else if (_blockType === 'ordered-list-item' || _blockType === 'unordered-list-item') {
- var newEditorState = external_draft_js_["RichUtils"].onTab(event, editorState, 4);
-
- if (newEditorState !== editorState) {
- editor.setValue(newEditorState);
- }
-
- return 'handled';
- } else if (_blockType !== 'atomic' && allowIndent && cursorIsAtFirst) {
- editor.setValue(external_braft_utils_["ContentUtils"].increaseSelectionIndent(editorState));
- return 'handled';
- }
- }
-
- var nextEditorState = external_braft_utils_["ContentUtils"].handleKeyCommand(editorState, command);
-
- if (nextEditorState) {
- editor.setValue(nextEditorState);
- return 'handled';
- }
-
- return 'not-handled';
- };
- var handlers_returnHandlers = function returnHandlers(event, editorState, editor) {
- if (editor.editorProps.handleReturn && editor.editorProps.handleReturn(event, editorState, editor) === 'handled') {
- return 'handled';
- }
-
- var currentBlock = external_braft_utils_["ContentUtils"].getSelectionBlock(editorState);
- var currentBlockType = currentBlock.getType();
-
- if (currentBlockType === 'unordered-list-item' || currentBlockType === 'ordered-list-item') {
- if (currentBlock.getLength() === 0) {
- editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionBlockType(editorState, 'unstyled'));
- return 'handled';
- }
-
- return 'not-handled';
- } else if (currentBlockType === 'code-block') {
- if (event.which === 13 && (event.getModifierState('Shift') || event.getModifierState('Alt') || event.getModifierState('Control'))) {
- editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionBlockType(editorState, 'unstyled'));
- return 'handled';
- }
-
- return 'not-handled';
- } else if (currentBlockType === 'blockquote') {
- if (event.which === 13) {
- if (event.getModifierState('Shift') || event.getModifierState('Alt') || event.getModifierState('Control')) {
- event.which = 0;
- } else {
- editor.setValue(external_draft_js_["RichUtils"].insertSoftNewline(editorState));
- return 'handled';
- }
- }
- }
-
- var nextEditorState = Object(external_draftjs_utils_["handleNewLine"])(editorState, event);
-
- if (nextEditorState) {
- editor.setValue(nextEditorState);
- return 'handled';
- }
-
- return 'not-handled';
- };
- var beforeInputHandlers = function beforeInputHandlers(chars, editorState, editor) {
- if (editor.editorProps.handleBeforeInput && editor.editorProps.handleBeforeInput(chars, editorState, editor) === 'handled') {
- return 'handled';
- }
-
- return 'not-handled';
- };
- var handlers_compositionStartHandler = function compositionStartHandler(_, editor) {
- var editorState = editor.state.editorState;
- var selectedBlocks = external_braft_utils_["ContentUtils"].getSelectedBlocks(editorState);
-
- if (selectedBlocks && selectedBlocks.length > 1) {
- var nextEditorState = external_draft_js_["EditorState"].push(editorState, external_draft_js_["Modifier"].removeRange(editorState.getCurrentContent(), editorState.getSelection(), 'backward'), 'remove-range');
- editor.setValue(nextEditorState);
- }
- };
- var handlers_dropHandlers = function dropHandlers(selectionState, dataTransfer, editor) {
- if (editor.editorProps.readOnly || editor.editorProps.disabled) {
- return 'handled';
- }
-
- if (window && window.__BRAFT_DRAGING__IMAGE__) {
- var nextEditorState = external_draft_js_["EditorState"].forceSelection(editor.state.editorState, selectionState);
- nextEditorState = external_braft_utils_["ContentUtils"].insertMedias(nextEditorState, [window.__BRAFT_DRAGING__IMAGE__.mediaData]);
- nextEditorState = external_braft_utils_["ContentUtils"].removeBlock(nextEditorState, window.__BRAFT_DRAGING__IMAGE__.block, nextEditorState.getSelection());
- window.__BRAFT_DRAGING__IMAGE__ = null;
- editor.lockOrUnlockEditor(true);
- editor.setValue(nextEditorState);
- return 'handled';
- } else if (!dataTransfer || !dataTransfer.getText()) {
- return 'handled';
- }
-
- return 'not-handled';
- };
- var handlers_handleFiles = function handleFiles(files, editor) {
- var _editor$constructor$d = objectSpread_default()({}, editor.constructor.defaultProps.media, editor.editorProps.media),
- pasteImage = _editor$constructor$d.pasteImage,
- validateFn = _editor$constructor$d.validateFn,
- imagePasteLimit = _editor$constructor$d.imagePasteLimit;
-
- pasteImage && files.slice(0, imagePasteLimit).forEach(function (file) {
- if (file && file.type.indexOf('image') > -1 && editor.braftFinder) {
- var validateResult = validateFn ? validateFn(file) : true;
-
- if (validateResult instanceof Promise) {
- validateResult.then(function () {
- editor.braftFinder.uploadImage(file, function (image) {
- editor.isLiving && editor.setValue(external_braft_utils_["ContentUtils"].insertMedias(editor.state.editorState, [image]));
- });
- });
- } else if (validateResult) {
- editor.braftFinder.uploadImage(file, function (image) {
- editor.isLiving && editor.setValue(external_braft_utils_["ContentUtils"].insertMedias(editor.state.editorState, [image]));
- });
- }
- }
- });
-
- if (files[0] && files[0].type.indexOf('image') > -1 && pasteImage) {
- return 'handled';
- }
-
- return 'not-handled';
- };
- var droppedFilesHandlers = function droppedFilesHandlers(selectionState, files, editor) {
- if (editor.editorProps.handleDroppedFiles && editor.editorProps.handleDroppedFiles(selectionState, files, editor) === 'handled') {
- return 'handled';
- }
-
- return handlers_handleFiles(files, editor);
- };
- var pastedFilesHandlers = function pastedFilesHandlers(files, editor) {
- if (editor.editorProps.handlePastedFiles && editor.editorProps.handlePastedFiles(files, editor) === 'handled') {
- return 'handled';
- }
-
- return handlers_handleFiles(files, editor);
- };
- var handlers_copyHandlers = function copyHandlers(event, editor) {
- var blockMap = getFragmentFromSelection_default()(editor.state.editorState);
-
- if (blockMap && blockMap.toArray) {
- try {
- var tempContentState = external_draft_js_["ContentState"].createFromBlockArray(blockMap.toArray());
- var tempEditorState = external_draft_js_["EditorState"].createWithContent(tempContentState);
- var clipboardData = event.clipboardData || window.clipboardData || event.originalEvent.clipboardData;
- tempEditorState.setConvertOptions(editor.state.editorState.convertOptions);
- clipboardData.setData('text/html', tempEditorState.toHTML());
- clipboardData.setData('text/plain', tempEditorState.toText());
- event.preventDefault();
- } catch (error) {
- console.warn(error);
- }
- }
- };
- var handlers_pastedTextHandlers = function pastedTextHandlers(text, html, editorState, editor) {
- if (editor.editorProps.handlePastedText && editor.editorProps.handlePastedText(text, html, editorState, editor) === 'handled') {
- return 'handled';
- }
-
- if (!html || editor.editorProps.stripPastedStyles) {
- return false;
- }
-
- var tempColors = external_braft_utils_["ColorUtils"].detectColorsFromHTMLString(html);
- editor.setState({
- tempColors: toConsumableArray_default()(editor.state.tempColors).concat(toConsumableArray_default()(tempColors)).filter(function (item) {
- return editor.editorProps.colors.indexOf(item) === -1;
- }).filter(function (item, index, array) {
- return array.indexOf(item) === index;
- })
- }, function () {
- editor.setValue(external_braft_utils_["ContentUtils"].insertHTML(editorState, html, 'paste'));
- });
- return 'handled';
- };
- // CONCATENATED MODULE: ./helpers/extension.js
-
- // TODO
- // - block-style和atomic类型的扩展支持
-
- var extension_extensionControls = [];
- var extension_extensionDecorators = [];
- var extension_propInterceptors = [];
- var extension_extensionBlockRenderMaps = [];
- var extension_extensionBlockRendererFns = [];
- var extensionInlineStyleMaps = [];
- var extension_extensionInlineStyleFns = [];
- var extensionEntities = [];
- var inlineStyleImporters = [];
- var inlineStyleExporters = [];
- var blockImporters = [];
- var blockExporters = [];
-
- var filterByEditorId = function filterByEditorId(items, editorId) {
- if (!editorId) {
- return items.filter(function (item) {
- return !item.includeEditors;
- }).map(function (item) {
- return item.data;
- });
- }
-
- return items.map(function (item) {
- if (!item.includeEditors && !item.excludeEditors) {
- return item.data;
- }
-
- if (item.includeEditors) {
- return item.includeEditors.indexOf(editorId) !== -1 ? item.data : false;
- }
-
- if (item.excludeEditors) {
- return item.excludeEditors.indexOf(editorId) !== -1 ? false : item.data;
- }
-
- return false;
- }).filter(function (item) {
- return item;
- });
- };
-
- var getPropInterceptors = function getPropInterceptors(editorId) {
- return filterByEditorId(extension_propInterceptors, editorId);
- };
- var getExtensionControls = function getExtensionControls(editorId) {
- return filterByEditorId(extension_extensionControls, editorId);
- };
- var getExtensionDecorators = function getExtensionDecorators(editorId) {
- return filterByEditorId(extension_extensionDecorators, editorId);
- };
- var getExtensionBlockRenderMaps = function getExtensionBlockRenderMaps(editorId) {
- return filterByEditorId(extension_extensionBlockRenderMaps, editorId);
- };
- var getExtensionBlockRendererFns = function getExtensionBlockRendererFns(editorId) {
- return filterByEditorId(extension_extensionBlockRendererFns, editorId);
- };
- var getExtensionInlineStyleMap = function getExtensionInlineStyleMap(editorId) {
- var inlineStyleMap = {};
- filterByEditorId(extensionInlineStyleMaps, editorId).forEach(function (item) {
- inlineStyleMap[item.inlineStyleName] = item.styleMap;
- });
- return inlineStyleMap;
- };
- var getExtensionInlineStyleFns = function getExtensionInlineStyleFns(editorId) {
- return filterByEditorId(extension_extensionInlineStyleFns, editorId);
- };
- var compositeStyleImportFn = function compositeStyleImportFn(styleImportFn, editorId) {
- return function (nodeName, node, style) {
- filterByEditorId(inlineStyleImporters, editorId).forEach(function (styleImporter) {
- if (styleImporter.importer && styleImporter.importer(nodeName, node)) {
- style = style.add(styleImporter.inlineStyleName);
- }
- });
- return styleImportFn ? styleImportFn(nodeName, node, style) : style;
- };
- };
- var compositeStyleExportFn = function compositeStyleExportFn(styleExportFn, editorId) {
- return function (style) {
- style = style.toUpperCase();
- var result = styleExportFn ? styleExportFn(style) : undefined;
-
- if (result) {
- return result;
- }
-
- filterByEditorId(inlineStyleExporters, editorId).find(function (item) {
- if (item.inlineStyleName === style) {
- result = item.exporter;
- return true;
- }
- });
- return result;
- };
- };
- var compositeEntityImportFn = function compositeEntityImportFn(entityImportFn, editorId) {
- return function (nodeName, node, createEntity, source) {
- var result = entityImportFn ? entityImportFn(nodeName, node, createEntity, source) : null;
-
- if (result) {
- return result;
- }
-
- filterByEditorId(extensionEntities, editorId).find(function (entityItem) {
- var matched = entityItem.importer ? entityItem.importer(nodeName, node, source) : null;
- matched && (result = createEntity(entityItem.entityType, matched.mutability || 'MUTABLE', matched.data || {}));
- return !!matched;
- });
- return result;
- };
- };
- var compositeEntityExportFn = function compositeEntityExportFn(entityExportFn, editorId) {
- return function (entity, originalText) {
- var result = entityExportFn ? entityExportFn(entity, originalText) : undefined;
-
- if (result) {
- return result;
- }
-
- var entityType = entity.type.toUpperCase();
- filterByEditorId(extensionEntities, editorId).find(function (entityItem) {
- if (entityItem.entityType === entityType) {
- result = entityItem.exporter ? entityItem.exporter(entity, originalText) : undefined;
- return true;
- }
- });
- return result;
- };
- };
- var compositeBlockImportFn = function compositeBlockImportFn(blockImportFn, editorId) {
- return function (nodeName, node, source) {
- var result = blockImportFn ? blockImportFn(nodeName, node, source) : null;
-
- if (result) {
- return result;
- }
-
- filterByEditorId(blockImporters, editorId).find(function (blockImporter) {
- var matched = blockImporter.importer ? blockImporter.importer(nodeName, node, source) : undefined;
- matched && (result = matched);
- return !!matched;
- });
- return result;
- };
- };
- var compositeBlockExportFn = function compositeBlockExportFn(blockExportFn, editorId) {
- return function (contentState, block) {
- var result = blockExportFn ? blockExportFn(contentState, block) : null;
-
- if (result) {
- return result;
- }
-
- filterByEditorId(blockExporters, editorId).find(function (blockExporter) {
- var matched = blockExporter.exporter ? blockExporter.exporter(contentState, block) : undefined;
- matched && (result = matched);
- return !!matched;
- });
- return result;
- };
- };
-
- var extension_useExtension = function useExtension(extension) {
- if (extension instanceof Array) {
- extension.forEach(useExtension);
- return false;
- }
-
- if (!extension || !extension.type || typeof extension.type !== 'string') {
- return false;
- }
-
- var includeEditors = extension.includeEditors,
- excludeEditors = extension.excludeEditors;
-
- if (extension.type === 'control') {
- extension_extensionControls.push({
- includeEditors: includeEditors,
- excludeEditors: excludeEditors,
- data: extension.control
- });
- } else if (extension.type === 'inline-style') {
- var inlineStyleName = extension.name.toUpperCase();
-
- if (extension.control) {
- extension_extensionControls.push({
- includeEditors: includeEditors,
- excludeEditors: excludeEditors,
- data: objectSpread_default()({
- key: inlineStyleName,
- type: 'inline-style',
- command: inlineStyleName
- }, extension.control)
- });
- }
-
- if (extension.style) {
- extensionInlineStyleMaps.push({
- includeEditors: includeEditors,
- excludeEditors: excludeEditors,
- data: {
- inlineStyleName: inlineStyleName,
- styleMap: extension.style
- }
- });
- }
-
- if (extension.styleFn) {
- extension_extensionInlineStyleFns.push({
- includeEditors: includeEditors,
- excludeEditors: excludeEditors,
- data: {
- inlineStyleName: inlineStyleName,
- styleFn: extension.styleFn
- }
- });
- }
-
- if (extension.importer) {
- inlineStyleImporters.push({
- includeEditors: includeEditors,
- excludeEditors: excludeEditors,
- data: {
- inlineStyleName: inlineStyleName,
- importer: extension.importer
- }
- });
- }
-
- inlineStyleExporters.push({
- includeEditors: includeEditors,
- excludeEditors: excludeEditors,
- data: {
- inlineStyleName: inlineStyleName,
- exporter: extension.exporter ? extension.exporter(extension) : external_react_default.a.createElement("span", {
- style: extension.style
- })
- }
- });
- } else if (extension.type === 'block-style') ; else if (extension.type === 'entity') {
- var entityType = extension.name.toUpperCase();
-
- if (extension.control) {
- extension_extensionControls.push({
- includeEditors: includeEditors,
- excludeEditors: excludeEditors,
- data: typeof extension.control === 'function' ? extension.control : objectSpread_default()({
- key: entityType,
- type: 'entity',
- command: entityType,
- data: {
- mutability: extension.mutability || 'MUTABLE',
- data: extension.data || {}
- }
- }, extension.control)
- });
- }
-
- extensionEntities.push({
- includeEditors: includeEditors,
- excludeEditors: excludeEditors,
- data: {
- entityType: entityType,
- importer: extension.importer,
- exporter: extension.exporter
- }
- });
- extension_extensionDecorators.push({
- includeEditors: includeEditors,
- excludeEditors: excludeEditors,
- data: {
- type: 'entity',
- decorator: {
- key: entityType,
- component: extension.component
- }
- }
- });
- } else if (extension.type === 'block') {
- var blockType = extension.name;
-
- if (extension.renderMap) {
- extension_extensionBlockRenderMaps.push({
- includeEditors: includeEditors,
- excludeEditors: excludeEditors,
- data: {
- blockType: blockType,
- renderMap: extension.renderMap
- }
- });
- }
-
- if (extension.rendererFn) {
- extension_extensionBlockRendererFns.push({
- includeEditors: includeEditors,
- excludeEditors: excludeEditors,
- data: {
- blockType: blockType,
- rendererFn: extension.rendererFn
- }
- });
- }
-
- if (extension.importer) {
- blockImporters.push({
- includeEditors: includeEditors,
- excludeEditors: excludeEditors,
- data: {
- blockType: blockType,
- importer: extension.importer
- }
- });
- }
-
- if (extension.exporter) {
- blockExporters.push({
- includeEditors: includeEditors,
- excludeEditors: excludeEditors,
- data: {
- blockType: blockType,
- exporter: extension.exporter
- }
- });
- }
- } else if (extension.type === 'atomic') ; else if (extension.type === 'decorator') {
- var decorator = extension.decorator;
-
- if (decorator && decorator.strategy && decorator.component) {
- extension_extensionDecorators.push({
- includeEditors: includeEditors,
- excludeEditors: excludeEditors,
- data: {
- type: 'strategy',
- decorator: decorator
- }
- });
- } else if (decorator && decorator.getDecorations) {
- extension_extensionDecorators.push({
- includeEditors: includeEditors,
- excludeEditors: excludeEditors,
- data: {
- type: 'class',
- decorator: decorator
- }
- });
- }
- } else if (extension.type === 'prop-interception') {
- extension_propInterceptors.push({
- includeEditors: includeEditors,
- excludeEditors: excludeEditors,
- data: extension.interceptor
- });
- }
- };
-
- var createExtensibleEditor = function createExtensibleEditor(BraftEditor) {
- BraftEditor.use = extension_useExtension;
- return BraftEditor;
- };
- // CONCATENATED MODULE: ./renderers/block/blockRenderMap.js
-
-
-
-
- /* harmony default export */ var block_blockRenderMap = (function (props, blockRenderMap) {
- var customBlockRenderMap = Object(external_immutable_["Map"])({
- 'atomic': {
- element: ''
- },
- 'code-block': {
- element: 'code',
- wrapper: external_react_default.a.createElement("pre", {
- className: "braft-code-block"
- })
- }
- });
-
- try {
- var extensionBlockRenderMaps = getExtensionBlockRenderMaps(props.editorId);
- customBlockRenderMap = extensionBlockRenderMaps.reduce(function (customBlockRenderMap, item) {
- return customBlockRenderMap.merge(typeof item.renderMap === 'function' ? item.renderMap(props) : item.renderMap);
- }, customBlockRenderMap);
-
- if (blockRenderMap) {
- if (typeof blockRenderMap === 'function') {
- customBlockRenderMap = customBlockRenderMap.merge(blockRenderMap(props));
- } else {
- customBlockRenderMap = customBlockRenderMap.merge(blockRenderMap);
- }
- }
-
- customBlockRenderMap = external_draft_js_["DefaultDraftBlockRenderMap"].merge(customBlockRenderMap);
- } catch (error) {
- console.warn(error);
- }
-
- return customBlockRenderMap;
- });
- // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/extends.js
- var helpers_extends = __webpack_require__(11);
- var extends_default = /*#__PURE__*/__webpack_require__.n(helpers_extends);
-
- // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/slicedToArray.js
- var slicedToArray = __webpack_require__(24);
- var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
-
- // EXTERNAL MODULE: ./renderers/atomics/Image/style.scss
- var Image_style = __webpack_require__(45);
-
- // EXTERNAL MODULE: ./components/common/Switch/style.scss
- var Switch_style = __webpack_require__(46);
-
- // CONCATENATED MODULE: ./components/common/Switch/index.jsx
-
-
- /* harmony default export */ var Switch = (function (props) {
- var active = props.active,
- _onClick = props.onClick,
- className = props.className;
- return external_react_default.a.createElement("div", {
- onClick: function onClick() {
- return _onClick();
- },
- className: 'bf-switch ' + className + (active ? ' active' : '')
- });
- });
- // CONCATENATED MODULE: ./configs/controls.js
-
- /* harmony default export */ var configs_controls = (function (lang, editor) {
- return [{
- key: 'undo',
- title: lang.controls.undo,
- text: external_react_default.a.createElement("i", {
- className: "bfi-undo"
- }),
- type: 'editor-method',
- command: 'undo'
- }, {
- key: 'redo',
- title: lang.controls.redo,
- text: external_react_default.a.createElement("i", {
- className: "bfi-redo"
- }),
- type: 'editor-method',
- command: 'redo'
- }, {
- key: 'remove-styles',
- title: lang.controls.removeStyles,
- text: external_react_default.a.createElement("i", {
- className: "bfi-format_clear"
- }),
- type: 'editor-method',
- command: 'removeSelectionInlineStyles'
- }, {
- key: 'hr',
- title: lang.controls.hr,
- text: external_react_default.a.createElement("i", {
- className: "bfi-hr"
- }),
- type: 'editor-method',
- command: 'insertHorizontalLine'
- }, {
- key: 'bold',
- title: lang.controls.bold,
- text: external_react_default.a.createElement("i", {
- className: "bfi-bold"
- }),
- type: 'inline-style',
- command: 'bold'
- }, {
- key: 'italic',
- title: lang.controls.italic,
- text: external_react_default.a.createElement("i", {
- className: "bfi-italic"
- }),
- type: 'inline-style',
- command: 'italic'
- }, {
- key: 'underline',
- title: lang.controls.underline,
- text: external_react_default.a.createElement("i", {
- className: "bfi-underlined"
- }),
- type: 'inline-style',
- command: 'underline'
- }, {
- key: 'strike-through',
- title: lang.controls.strikeThrough,
- text: external_react_default.a.createElement("i", {
- className: "bfi-strikethrough"
- }),
- type: 'inline-style',
- command: 'strikethrough'
- }, {
- key: 'superscript',
- title: lang.controls.superScript,
- text: external_react_default.a.createElement("i", {
- className: "bfi-superscript"
- }),
- type: 'inline-style',
- command: 'superscript'
- }, {
- key: 'subscript',
- title: lang.controls.subScript,
- text: external_react_default.a.createElement("i", {
- className: "bfi-subscript"
- }),
- type: 'inline-style',
- command: 'subscript'
- }, {
- key: 'headings',
- title: lang.controls.headings,
- type: 'headings'
- }, {
- key: 'blockquote',
- title: lang.controls.blockQuote,
- text: external_react_default.a.createElement("i", {
- className: "bfi-quote"
- }),
- type: 'block-type',
- command: 'blockquote'
- }, {
- key: 'code',
- title: lang.controls.code,
- text: external_react_default.a.createElement("i", {
- className: "bfi-code"
- }),
- type: 'block-type',
- command: 'code-block'
- }, {
- key: 'list-ul',
- title: lang.controls.unorderedList,
- text: external_react_default.a.createElement("i", {
- className: "bfi-list"
- }),
- type: 'block-type',
- command: 'unordered-list-item'
- }, {
- key: 'list-ol',
- title: lang.controls.orderedList,
- text: external_react_default.a.createElement("i", {
- className: "bfi-list-numbered"
- }),
- type: 'block-type',
- command: 'ordered-list-item'
- }, {
- key: 'link',
- title: lang.controls.link,
- type: 'link'
- }, {
- key: 'text-color',
- title: lang.controls.color,
- type: 'text-color'
- }, {
- key: 'line-height',
- title: lang.controls.lineHeight,
- type: 'line-height'
- }, {
- key: 'letter-spacing',
- title: lang.controls.letterSpacing,
- type: 'letter-spacing'
- }, {
- key: 'text-indent',
- title: lang.controls.textIndent,
- type: 'text-indent'
- }, {
- key: 'font-size',
- title: lang.controls.fontSize,
- type: 'font-size'
- }, {
- key: 'font-family',
- title: lang.controls.fontFamily,
- type: 'font-family'
- }, {
- key: 'text-align',
- title: lang.controls.textAlign,
- type: 'text-align'
- }, {
- key: 'media',
- title: lang.controls.media,
- text: external_react_default.a.createElement("i", {
- className: "bfi-media"
- }),
- type: 'media'
- }, {
- key: 'emoji',
- title: lang.controls.emoji,
- text: external_react_default.a.createElement("i", {
- className: "bfi-emoji"
- }),
- type: 'emoji'
- }, {
- key: 'clear',
- title: lang.controls.clear,
- text: external_react_default.a.createElement("i", {
- className: "bfi-clear_all"
- }),
- type: 'editor-method',
- command: 'clearEditorContent'
- }, {
- key: 'fullscreen',
- title: editor.state.isFullscreen ? lang.controls.exitFullscreen : lang.controls.fullscreen,
- text: external_react_default.a.createElement("i", {
- className: editor.state.isFullscreen ? 'bfi-fullscreen-exit' : 'bfi-fullscreen'
- }),
- type: 'editor-method',
- command: 'toggleFullscreen'
- }, {
- key: 'modal',
- type: 'modal'
- }, {
- key: 'button',
- type: 'button'
- }, {
- key: 'dropdown',
- type: 'dropdown'
- }, {
- key: 'component',
- type: 'component'
- }];
- });
- var imageControlItems = {
- 'float-left': {
- text: external_react_default.a.createElement("span", {
- "data-float": "left"
- }, "\uE91E"),
- command: 'setImageFloat|left'
- },
- 'float-right': {
- text: external_react_default.a.createElement("span", {
- "data-float": "right"
- }, "\uE914"),
- command: 'setImageFloat|right'
- },
- 'align-left': {
- text: external_react_default.a.createElement("span", {
- "data-align": "left"
- }, "\uE027"),
- command: 'setImageAlignment|left'
- },
- 'align-center': {
- text: external_react_default.a.createElement("span", {
- "data-align": "center"
- }, "\uE028"),
- command: 'setImageAlignment|center'
- },
- 'align-right': {
- text: external_react_default.a.createElement("span", {
- "data-align": "right"
- }, "\uE029"),
- command: 'setImageAlignment|right'
- },
- 'size': {
- text: external_react_default.a.createElement("span", null, "\uE3C2"),
- command: 'toggleSizeEditor'
- },
- 'link': {
- text: external_react_default.a.createElement("span", null, "\uE91A"),
- command: 'toggleLinkEditor'
- },
- 'remove': {
- text: external_react_default.a.createElement("span", null, "\uE9AC"),
- command: 'removeImage'
- }
- };
- // CONCATENATED MODULE: ./renderers/atomics/Image/index.jsx
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var Image_Image =
- /*#__PURE__*/
- function (_React$Component) {
- inherits_default()(Image, _React$Component);
-
- function Image() {
- var _getPrototypeOf2;
-
- var _this;
-
- classCallCheck_default()(this, Image);
-
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(Image)).call.apply(_getPrototypeOf2, [this].concat(args)));
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
- toolbarVisible: false,
- toolbarOffset: 0,
- linkEditorVisible: false,
- sizeEditorVisible: false,
- tempLink: null,
- tempWidth: null,
- tempHeight: null
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "initialLeft", void 0);
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "initialTop", void 0);
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "initialWidth", void 0);
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "initialHeight", void 0);
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "reSizeType", void 0);
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "changeSize", function (e) {
- var type = _this.reSizeType;
-
- if (!_this.initialLeft) {
- _this.initialLeft = e.screenX;
- _this.initialTop = e.screenY;
- }
-
- if (type === 'rightbottom') {
- _this.initialHeight += e.screenY - _this.initialTop;
- _this.initialWidth += e.screenX - _this.initialLeft;
- }
-
- if (type === 'leftbottom') {
- _this.initialHeight += e.screenY - _this.initialTop;
- _this.initialWidth += -e.screenX + _this.initialLeft;
- }
-
- _this.initialLeft = e.screenX;
- _this.initialTop = e.screenY;
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "moveImage", function (e) {
- _this.changeSize(e);
-
- _this.setState({
- tempWidth: Math.abs(_this.initialWidth),
- tempHeight: Math.abs(_this.initialHeight)
- });
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "upImage", function () {
- _this.confirmImageSize();
-
- document.removeEventListener('mousemove', _this.moveImage);
- document.removeEventListener('mouseup', _this.upImage);
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "repareChangeSize", function (type) {
- return function (e) {
- _this.reSizeType = type;
-
- var imageRect = _this.imageElement.getBoundingClientRect();
-
- _this.initialLeft = _this.initialTop = 0;
- _this.initialWidth = imageRect.width;
- _this.initialHeight = imageRect.height;
- e.preventDefault();
- document.addEventListener('mousemove', _this.moveImage);
- document.addEventListener('mouseup', _this.upImage);
- };
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "preventDragEvent", function (event) {
- event.stopPropagation();
- event.preventDefault();
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleDragStart", function () {
- if (_this.props.editor.editorProps.readOnly || _this.props.editor.editorProps.disabled) {
- return false;
- }
-
- window.__BRAFT_DRAGING__IMAGE__ = {
- block: _this.props.block,
- mediaData: objectSpread_default()({
- type: 'IMAGE'
- }, _this.props.mediaData)
- };
-
- _this.setState({
- toolbarVisible: false
- }, function () {
- _this.unlockEditor();
- });
-
- return true;
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleDragEnd", function () {
- window.__BRAFT_DRAGING__IMAGE__ = null;
- return false;
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "executeCommand", function (command) {
- if (typeof command === 'string') {
- var _command$split = command.split('|'),
- _command$split2 = slicedToArray_default()(_command$split, 2),
- method = _command$split2[0],
- param = _command$split2[1];
-
- _this[method] && _this[method](param);
- } else if (typeof command === 'function') {
- command(_this.props.block, _this.props.mediaData, _this.props.editor.getValue());
- }
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeImage", function () {
- _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editor.getValue(), _this.props.block));
-
- _this.unlockEditor();
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggleLinkEditor", function () {
- _this.setState({
- linkEditorVisible: !_this.state.linkEditorVisible,
- sizeEditorVisible: false
- });
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggleSizeEditor", function () {
- _this.setState({
- linkEditorVisible: false,
- sizeEditorVisible: !_this.state.sizeEditorVisible
- });
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleLinkInputKeyDown", function (e) {
- if (e.keyCode === 13) {
- _this.confirmImageLink();
- } else {
- return;
- }
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageLink", function (e) {
- _this.setState({
- tempLink: e.currentTarget.value
- });
-
- return;
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "confirmImageLink", function () {
- var link = _this.state.tempLink;
-
- var hookReturns = _this.props.hooks('set-image-link', link)(link);
-
- if (hookReturns === false) {
- return false;
- }
-
- if (typeof hookReturns === 'string') {
- link = hookReturns;
- }
-
- if (link !== null) {
- _this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaData(_this.props.editor.getValue(), _this.props.entityKey, {
- link: link
- }));
-
- window.setImmediate(_this.props.editor.forceRender);
- }
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleSizeInputKeyDown", function (e) {
- if (e.keyCode === 13) {
- _this.confirmImageSize();
- } else {
- return;
- }
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageWidth", function (_ref) {
- var currentTarget = _ref.currentTarget;
- var value = currentTarget.value;
- value && !isNaN(value) && (value = value + 'px');
-
- _this.setState({
- tempWidth: value
- });
-
- return;
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageHeight", function (_ref2) {
- var currentTarget = _ref2.currentTarget;
- var value = currentTarget.value;
- value && !isNaN(value) && (value = value + 'px');
-
- _this.setState({
- tempHeight: value
- });
-
- return;
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "confirmImageSize", function () {
- var _this$state = _this.state,
- width = _this$state.tempWidth,
- height = _this$state.tempHeight;
- var newImageSize = {};
- width !== null && (newImageSize.width = width);
- height !== null && (newImageSize.height = height);
-
- var hookReturns = _this.props.hooks('set-image-size', newImageSize)(newImageSize);
-
- if (hookReturns === false) {
- return false;
- }
-
- if (hookReturns && (hookReturns.width || hookReturns.height)) {
- newImageSize = hookReturns;
- }
-
- _this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaData(_this.props.editor.getValue(), _this.props.entityKey, newImageSize));
-
- window.setImmediate(_this.props.editor.forceRender);
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageFloat", function (float) {
- var hookReturns = _this.props.hooks('set-image-float', float)(float);
-
- if (hookReturns === false) {
- return false;
- }
-
- if (typeof hookReturns === 'string') {
- float = hookReturns;
- }
-
- _this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaPosition(_this.props.editor.getValue(), _this.props.block, {
- float: float
- }));
-
- _this.unlockEditor();
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageAlignment", function (alignment) {
- var hookReturns = _this.props.hooks('set-image-alignment', alignment)(alignment);
-
- if (hookReturns === false) {
- return false;
- }
-
- if (typeof hookReturns === 'string') {
- alignment = hookReturns;
- }
-
- _this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaPosition(_this.props.editor.getValue(), _this.props.block, {
- alignment: alignment
- }));
-
- _this.unlockEditor();
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "showToolbar", function (event) {
- if (_this.props.editor.editorProps.readOnly || _this.props.editor.editorProps.disabled) {
- return false;
- }
-
- event.preventDefault();
-
- if (!_this.state.toolbarVisible) {
- _this.setState({
- toolbarVisible: true
- }, function () {
- _this.lockEditor();
-
- _this.setState({
- toolbarOffset: _this.calcToolbarOffset()
- });
- });
- }
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "hideToolbar", function (event) {
- event.preventDefault();
-
- _this.setState({
- toolbarVisible: false
- }, function () {
- _this.unlockEditor(); // this.props.editor.requestFocus()
-
- });
- });
-
- return _this;
- }
-
- createClass_default()(Image, [{
- key: "render",
- value: function render() {
- var _this2 = this;
-
- var _this$props = this.props,
- mediaData = _this$props.mediaData,
- language = _this$props.language,
- imageControls = _this$props.imageControls,
- imageResizable = _this$props.imageResizable;
- var _this$state2 = this.state,
- toolbarVisible = _this$state2.toolbarVisible,
- toolbarOffset = _this$state2.toolbarOffset,
- linkEditorVisible = _this$state2.linkEditorVisible,
- sizeEditorVisible = _this$state2.sizeEditorVisible,
- tempWidth = _this$state2.tempWidth,
- tempHeight = _this$state2.tempHeight;
- var blockData = this.props.block.getData();
- var float = blockData.get('float');
- var alignment = blockData.get('alignment');
- var url = mediaData.url,
- link = mediaData.link,
- link_target = mediaData.link_target,
- width = mediaData.width,
- height = mediaData.height,
- meta = mediaData.meta;
- var imageStyles = {};
- var clearFix = false;
-
- if (float) {
- alignment = null;
- } else if (alignment === 'left') {
- imageStyles.float = 'left';
- clearFix = true;
- } else if (alignment === 'right') {
- imageStyles.float = 'right';
- clearFix = true;
- } else if (alignment === 'center') {
- imageStyles.textAlign = 'center';
- } else {
- imageStyles.float = 'left';
- clearFix = true;
- }
-
- var renderedControlItems = imageControls.map(function (item, index) {
- if (typeof item === 'string' && imageControlItems[item]) {
- return external_react_default.a.createElement("a", {
- className: item === 'link' && link ? 'active' : '',
- key: index,
- onClick: function onClick() {
- return _this2.executeCommand(imageControlItems[item].command);
- }
- }, imageControlItems[item].text);
- } else if (item && (item.render || item.text)) {
- return item.render ? item.render(mediaData, _this2.props.block) : external_react_default.a.createElement("a", {
- key: index,
- onClick: function onClick() {
- return item.onClick && _this2.executeCommand(item.onClick);
- }
- }, item.text);
- } else {
- return null;
- }
- });
- return external_react_default.a.createElement("div", {
- className: "bf-media"
- }, external_react_default.a.createElement("div", {
- style: imageStyles,
- draggable: true,
- onMouseEnter: this.showToolbar,
- onMouseMove: this.showToolbar,
- onMouseLeave: this.hideToolbar,
- onDragStart: this.handleDragStart,
- onDragEnd: this.handleDragEnd,
- ref: function ref(instance) {
- return _this2.mediaEmbederInstance = instance;
- },
- className: "bf-image"
- }, toolbarVisible ? external_react_default.a.createElement("div", {
- style: {
- marginLeft: toolbarOffset
- },
- ref: function ref(instance) {
- return _this2.toolbarElement = instance;
- },
- "data-float": float,
- "data-align": alignment,
- className: "bf-media-toolbar"
- }, linkEditorVisible ? external_react_default.a.createElement("div", {
- className: "bf-image-link-editor"
- }, external_react_default.a.createElement("div", {
- className: "editor-input-group"
- }, external_react_default.a.createElement("input", {
- type: "text",
- placeholder: language.linkEditor.inputWithEnterPlaceHolder,
- onKeyDown: this.handleLinkInputKeyDown,
- onChange: this.setImageLink,
- defaultValue: link
- }), external_react_default.a.createElement("button", {
- type: "button",
- onClick: this.confirmImageLink
- }, language.base.confirm)), external_react_default.a.createElement("div", {
- className: "switch-group"
- }, external_react_default.a.createElement(Switch, {
- active: link_target === '_blank',
- onClick: function onClick() {
- return _this2.setImageLinkTarget(link_target);
- }
- }), external_react_default.a.createElement("label", null, language.linkEditor.openInNewWindow))) : null, sizeEditorVisible ? external_react_default.a.createElement("div", {
- className: "bf-image-size-editor"
- }, external_react_default.a.createElement("div", {
- className: "editor-input-group"
- }, external_react_default.a.createElement("input", {
- type: "text",
- placeholder: language.base.width,
- onKeyDown: this.handleSizeInputKeyDown,
- onChange: this.setImageWidth,
- defaultValue: width
- }), external_react_default.a.createElement("input", {
- type: "text",
- placeholder: language.base.height,
- onKeyDown: this.handleSizeInputKeyDown,
- onChange: this.setImageHeight,
- defaultValue: height
- }), external_react_default.a.createElement("button", {
- type: "button",
- onClick: this.confirmImageSize
- }, language.base.confirm))) : null, renderedControlItems, external_react_default.a.createElement("i", {
- style: {
- marginLeft: toolbarOffset * -1
- },
- className: "bf-media-toolbar-arrow"
- })) : null, external_react_default.a.createElement("div", {
- style: {
- position: 'relative',
- width: "".concat(width, "px"),
- height: "".concat(height, "px"),
- display: 'inline-block'
- }
- }, external_react_default.a.createElement("img", extends_default()({
- ref: function ref(instance) {
- return _this2.imageElement = instance;
- },
- src: url,
- width: width,
- height: height
- }, meta)), toolbarVisible && imageResizable ? external_react_default.a.createElement("div", {
- className: "bf-csize-icon right-bottom",
- onMouseDown: this.repareChangeSize('rightbottom')
- }) : null, toolbarVisible && imageResizable ? external_react_default.a.createElement("div", {
- className: "bf-csize-icon left-bottom",
- onMouseDown: this.repareChangeSize('leftbottom')
- }) : null, external_react_default.a.createElement("div", {
- className: "bf-pre-csize ".concat(this.reSizeType),
- style: {
- width: "".concat(tempWidth, "px"),
- height: "".concat(tempHeight, "px")
- }
- }))), clearFix && external_react_default.a.createElement("div", {
- className: "clearfix",
- style: {
- clear: 'both',
- height: 0,
- lineHeight: 0,
- float: 'none'
- }
- }));
- }
- }, {
- key: "lockEditor",
- value: function lockEditor() {
- this.props.editor.lockOrUnlockEditor(true);
- }
- }, {
- key: "unlockEditor",
- value: function unlockEditor() {
- this.props.editor.lockOrUnlockEditor(false);
- }
- }, {
- key: "calcToolbarOffset",
- value: function calcToolbarOffset() {
- var _this$props2 = this.props,
- getContainerNode = _this$props2.getContainerNode,
- containerNode = _this$props2.containerNode;
- var container = getContainerNode ? getContainerNode() : containerNode;
-
- if (!container) {
- return 0;
- }
-
- var viewRect = container.querySelector('.bf-content').getBoundingClientRect();
- var toolbarRect = this.toolbarElement.getBoundingClientRect();
- var imageRect = this.imageElement.getBoundingClientRect();
- var right = viewRect.right - (imageRect.right - imageRect.width / 2 + toolbarRect.width / 2);
- var left = imageRect.left + imageRect.width / 2 - toolbarRect.width / 2 - viewRect.left;
-
- if (right < 10) {
- return right - 10;
- } else if (left < 10) {
- return left * -1 + 10;
- } else {
- return 0;
- }
- }
- }, {
- key: "setImageLinkTarget",
- value: function setImageLinkTarget(link_target) {
- var hookReturns = this.props.hooks('set-image-link-target', link_target)(link_target);
-
- if (hookReturns === false) {
- return false;
- }
-
- if (typeof hookReturns === 'string') {
- link_target = hookReturns;
- }
-
- link_target = link_target === '_blank' ? '' : '_blank';
- this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaData(this.props.editor.getValue(), this.props.entityKey, {
- link_target: link_target
- }));
- window.setImmediate(this.props.editor.forceRender);
- }
- }]);
-
- return Image;
- }(external_react_default.a.Component);
-
-
- // EXTERNAL MODULE: ./renderers/atomics/Video/style.scss
- var Video_style = __webpack_require__(47);
-
- // EXTERNAL MODULE: ./components/common/Modal/style.scss
- var Modal_style = __webpack_require__(48);
-
- // EXTERNAL MODULE: external "react-dom"
- var external_react_dom_ = __webpack_require__(16);
- var external_react_dom_default = /*#__PURE__*/__webpack_require__.n(external_react_dom_);
-
- // CONCATENATED MODULE: ./components/common/Modal/index.jsx
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var Modal_Modal =
- /*#__PURE__*/
- function (_React$Component) {
- inherits_default()(Modal, _React$Component);
-
- function Modal(props) {
- var _this;
-
- classCallCheck_default()(this, Modal);
-
- _this = possibleConstructorReturn_default()(this, getPrototypeOf_default()(Modal).call(this, props));
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleTransitionEnd", function () {
- if (!_this.rootElement || !_this.rootElement.classList) {
- return false;
- }
-
- if (!_this.rootElement.classList.contains('active')) {
- external_react_dom_default.a.unmountComponentAtNode(_this.rootElement) && _this.rootElement.parentNode.removeChild(_this.rootElement);
- }
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleMouseDown", function (event) {
- var tagName = event.target.tagName.toLowerCase();
-
- if (tagName === 'input' || tagName === 'textarea') {
- return false;
- }
-
- event.preventDefault();
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleCancel", function () {
- _this.props.closeOnCancel && _this.close();
- _this.props.onCancel && _this.props.onCancel();
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleConfirm", function () {
- _this.props.closeOnConfirm && _this.close();
- _this.props.onConfirm && _this.props.onConfirm();
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleMaskClick", function () {
- _this.props.closeOnBlur && _this.close();
- _this.props.onBlue && _this.props.onBlue();
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "close", function () {
- _this.unrenderComponent();
-
- _this.props.onClose && _this.props.onClose();
- });
-
- _this.active = false;
- _this.componentId = 'BRAFT-MODAL-' + external_braft_utils_["BaseUtils"].UniqueIndex();
- return _this;
- }
-
- createClass_default()(Modal, [{
- key: "componentDidMount",
- value: function componentDidMount() {
- if (this.props.visible) {
- this.active = true;
- this.renderComponent(this.props);
- }
- }
- }, {
- key: "componentWillReceiveProps",
- value: function componentWillReceiveProps(next) {
- if (this.props.visible && !next.visible) {
- this.unrenderComponent();
- } else if (this.props.visible || next.visible) {
- this.active = true;
- this.renderComponent(next);
- }
- }
- }, {
- key: "render",
- value: function render() {
- return null;
- }
- }, {
- key: "unrenderComponent",
- value: function unrenderComponent() {
- this.active = false;
- this.activeId && window.clearImmediate(this.activeId);
-
- if (this.rootElement && this.rootElement.classList) {
- this.rootElement.classList.remove('active');
- }
- }
- }, {
- key: "renderComponent",
- value: function renderComponent(props) {
- var _this2 = this;
-
- if (!this.active) {
- return false;
- }
-
- var title = props.title,
- className = props.className,
- width = props.width,
- height = props.height,
- children = props.children,
- component = props.component,
- confirmable = props.confirmable,
- showFooter = props.showFooter,
- showCancel = props.showCancel,
- showConfirm = props.showConfirm,
- showClose = props.showClose,
- cancelText = props.cancelText,
- confirmText = props.confirmText,
- bottomText = props.bottomText,
- language = props.language;
- typeof showCancel === 'undefined' && (showCancel = true);
- typeof showClose === 'undefined' && (showClose = true);
- typeof showConfirm === 'undefined' && (showConfirm = true);
- typeof showFooter === 'undefined' && (showFooter = true);
- var childComponent = external_react_default.a.createElement("div", {
- onMouseDown: this.handleMouseDown,
- className: 'bf-modal ' + (className || '')
- }, external_react_default.a.createElement("div", {
- className: "bf-modal-mask",
- onClick: this.handleMaskClick
- }), external_react_default.a.createElement("div", {
- onTransitionEnd: this.handleTransitionEnd,
- style: {
- width: width,
- height: height
- },
- className: "bf-modal-content"
- }, external_react_default.a.createElement("div", {
- className: "bf-modal-header"
- }, external_react_default.a.createElement("h3", {
- className: "bf-modal-caption"
- }, title), showClose && external_react_default.a.createElement("button", {
- type: "button",
- onClick: this.close,
- className: "bf-modal-close-button"
- }, external_react_default.a.createElement("i", {
- className: "bfi-close"
- }))), external_react_default.a.createElement("div", {
- className: "bf-modal-body"
- }, children || component), showFooter ? external_react_default.a.createElement("div", {
- className: "bf-modal-footer"
- }, external_react_default.a.createElement("div", {
- className: "bf-modal-addon-text"
- }, bottomText), external_react_default.a.createElement("div", {
- className: "bf-modal-buttons"
- }, showCancel && external_react_default.a.createElement("button", {
- type: "button",
- onClick: this.handleCancel,
- className: "bf-modal-cancel"
- }, cancelText || language.base.cancel), showConfirm && external_react_default.a.createElement("button", {
- type: "button",
- onClick: this.handleConfirm,
- className: 'bf-modal-confirm ' + (!confirmable ? 'disabled' : '')
- }, confirmText || language.base.confirm))) : null));
- this.rootElement = document.querySelector('#' + this.componentId);
-
- if (!this.rootElement) {
- this.rootElement = document.createElement('div');
- this.rootElement.id = this.componentId;
- this.rootElement.className = 'bf-modal-root';
- document.body.appendChild(this.rootElement);
- }
-
- external_react_dom_default.a.render(childComponent, this.rootElement);
- this.activeId = window.setImmediate(function () {
- _this2.rootElement.classList.add('active');
- });
- }
- }]);
-
- return Modal;
- }(external_react_default.a.Component);
-
- defineProperty_default()(Modal_Modal, "defaultProps", {
- showFooter: true,
- closeOnBlur: true
- });
-
-
- var Modal_showModal = function showModal(props) {
- var hostNode = document.createElement('div');
- hostNode.style.display = 'none';
- document.body.appendChild(hostNode);
- props = objectSpread_default()({
- visible: true,
- closeOnConfirm: true,
- closeOnCancel: true
- }, props);
-
- var close = function close() {
- external_react_dom_default.a.unmountComponentAtNode(hostNode) && hostNode.parentNode.removeChild(hostNode);
- };
-
- var onConfirm = function onConfirm() {
- props.onConfirm && props.onConfirm();
- };
-
- var onCancel = function onCancel() {
- props.onCancel && props.onCancel();
- };
-
- var onClose = function onClose() {
- close();
- props.onClose && props.onClose();
- };
-
- var modalInstance = external_react_dom_default.a.render(external_react_default.a.createElement(Modal_Modal, extends_default()({}, props, {
- onConfirm: onConfirm,
- onCancel: onCancel,
- onClose: onClose
- })), hostNode);
- modalInstance.destroy = close;
- modalInstance.update = modalInstance.renderComponent;
- return modalInstance;
- };
- // EXTERNAL MODULE: ./components/business/PlayerModal/style.scss
- var PlayerModal_style = __webpack_require__(49);
-
- // CONCATENATED MODULE: ./components/business/PlayerModal/index.jsx
-
-
-
-
- var PlayerModal_playViaModal = function playViaModal(title, component, language) {
- return Modal_showModal({
- title: title,
- component: component,
- language: language,
- showFooter: false
- });
- };
-
- var typeIconsMap = {
- 'video': 'bfi-film',
- 'audio': 'bfi-music',
- 'embed': 'bfi-code'
- };
- /* harmony default export */ var PlayerModal = (function (_ref) {
- var title = _ref.title,
- type = _ref.type,
- language = _ref.language,
- name = _ref.name,
- url = _ref.url,
- poster = _ref.poster,
- children = _ref.children,
- onRemove = _ref.onRemove;
- return external_react_default.a.createElement("div", {
- className: "bf-player-holder ".concat(type)
- }, external_react_default.a.createElement("div", {
- className: "icon-badge"
- }, external_react_default.a.createElement("i", {
- className: typeIconsMap[type]
- }), external_react_default.a.createElement("span", {
- className: "text"
- }, language.media[type])), external_react_default.a.createElement("button", {
- onMouseDown: onRemove,
- className: "button-remove"
- }, external_react_default.a.createElement("i", {
- className: "bfi-close"
- })), external_react_default.a.createElement("button", {
- onMouseDown: function onMouseDown() {
- return PlayerModal_playViaModal(name ? "".concat(title, ":").concat(name) : title, children, language);
- },
- className: "button-play"
- }, external_react_default.a.createElement("i", {
- className: "bfi-play_arrow"
- })), name ? external_react_default.a.createElement("h5", {
- className: "bf-name"
- }, name) : null, external_react_default.a.createElement("h6", {
- className: "bf-url"
- }, url), poster ? external_react_default.a.createElement("div", {
- className: "bf-poster",
- style: {
- backgroundImage: "url(".concat(poster, ")")
- }
- }) : null);
- });
- // CONCATENATED MODULE: ./renderers/atomics/Video/index.jsx
-
-
-
-
-
-
-
-
-
-
-
-
- var Video_Video =
- /*#__PURE__*/
- function (_React$Component) {
- inherits_default()(Video, _React$Component);
-
- function Video() {
- var _getPrototypeOf2;
-
- var _this;
-
- classCallCheck_default()(this, Video);
-
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(Video)).call.apply(_getPrototypeOf2, [this].concat(args)));
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeVideo", function () {
- _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editorState, _this.props.block));
- });
-
- return _this;
- }
-
- createClass_default()(Video, [{
- key: "render",
- value: function render() {
- var _this$props = this.props,
- mediaData = _this$props.mediaData,
- language = _this$props.language;
- var url = mediaData.url,
- name = mediaData.name,
- meta = mediaData.meta;
- return external_react_default.a.createElement("div", {
- className: "bf-video-wrap"
- }, external_react_default.a.createElement(PlayerModal, {
- type: "video",
- onRemove: this.removeVideo,
- poster: meta ? meta.poster || '' : '',
- language: language,
- url: url,
- name: name,
- title: language.videoPlayer.title
- }, external_react_default.a.createElement("div", {
- className: "bf-video-player"
- }, external_react_default.a.createElement("video", {
- controls: true,
- poster: meta ? meta.poster || '' : ''
- }, external_react_default.a.createElement("source", {
- src: url
- })))));
- }
- }]);
-
- return Video;
- }(external_react_default.a.Component);
-
-
- // EXTERNAL MODULE: ./renderers/atomics/Audio/style.scss
- var Audio_style = __webpack_require__(50);
-
- // CONCATENATED MODULE: ./renderers/atomics/Audio/index.jsx
-
-
-
-
-
-
-
-
-
-
-
-
- var Audio_Audio =
- /*#__PURE__*/
- function (_React$Component) {
- inherits_default()(Audio, _React$Component);
-
- function Audio() {
- var _getPrototypeOf2;
-
- var _this;
-
- classCallCheck_default()(this, Audio);
-
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(Audio)).call.apply(_getPrototypeOf2, [this].concat(args)));
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeAudio", function () {
- _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editorState, _this.props.block));
- });
-
- return _this;
- }
-
- createClass_default()(Audio, [{
- key: "render",
- value: function render() {
- var _this$props = this.props,
- mediaData = _this$props.mediaData,
- language = _this$props.language;
- var url = mediaData.url,
- name = mediaData.name,
- meta = mediaData.meta;
- return external_react_default.a.createElement("div", {
- className: "bf-audio-wrap"
- }, external_react_default.a.createElement(PlayerModal, {
- type: "audio",
- onRemove: this.removeAudio,
- poster: meta ? meta.poster || '' : '',
- language: language,
- url: url,
- name: name,
- title: language.audioPlayer.title
- }, external_react_default.a.createElement("div", {
- className: "bf-audio-player"
- }, external_react_default.a.createElement("audio", {
- controls: true,
- src: url
- }))));
- }
- }]);
-
- return Audio;
- }(external_react_default.a.Component);
-
-
- // EXTERNAL MODULE: ./renderers/atomics/Embed/style.scss
- var Embed_style = __webpack_require__(51);
-
- // CONCATENATED MODULE: ./renderers/atomics/Embed/index.jsx
-
-
-
-
-
-
-
-
-
-
-
-
- var Embed_Embed =
- /*#__PURE__*/
- function (_React$Component) {
- inherits_default()(Embed, _React$Component);
-
- function Embed() {
- var _getPrototypeOf2;
-
- var _this;
-
- classCallCheck_default()(this, Embed);
-
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(Embed)).call.apply(_getPrototypeOf2, [this].concat(args)));
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeEmbed", function () {
- _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editorState, _this.props.block));
- });
-
- return _this;
- }
-
- createClass_default()(Embed, [{
- key: "render",
- value: function render() {
- var _this$props = this.props,
- mediaData = _this$props.mediaData,
- language = _this$props.language;
- var name = mediaData.name,
- url = mediaData.url,
- meta = mediaData.meta;
- return external_react_default.a.createElement("div", {
- className: "bf-embed-wrap"
- }, external_react_default.a.createElement(PlayerModal, {
- type: "embed",
- onRemove: this.removeEmbed,
- poster: meta ? meta.poster || '' : '',
- language: language,
- url: url,
- name: name,
- title: language.videoPlayer.embedTitle
- }, external_react_default.a.createElement("div", {
- className: "bf-embed-player",
- dangerouslySetInnerHTML: {
- __html: url
- }
- })));
- }
- }]);
-
- return Embed;
- }(external_react_default.a.Component);
-
-
- // EXTERNAL MODULE: ./renderers/atomics/HorizontalLine/style.scss
- var HorizontalLine_style = __webpack_require__(52);
-
- // CONCATENATED MODULE: ./renderers/atomics/HorizontalLine/index.jsx
-
-
-
-
-
-
-
-
-
-
-
- var HorizontalLine_HorizontalLine =
- /*#__PURE__*/
- function (_React$Component) {
- inherits_default()(HorizontalLine, _React$Component);
-
- function HorizontalLine() {
- var _getPrototypeOf2;
-
- var _this;
-
- classCallCheck_default()(this, HorizontalLine);
-
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(HorizontalLine)).call.apply(_getPrototypeOf2, [this].concat(args)));
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeHorizontalLine", function () {
- _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editorState, _this.props.block));
- });
-
- return _this;
- }
-
- createClass_default()(HorizontalLine, [{
- key: "render",
- value: function render() {
- return external_react_default.a.createElement("div", {
- className: "bf-hr"
- }, external_react_default.a.createElement("div", {
- className: "bf-media-toolbar"
- }, external_react_default.a.createElement("a", {
- onClick: this.removeHorizontalLine
- }, "\uE9AC")));
- }
- }]);
-
- return HorizontalLine;
- }(external_react_default.a.Component);
-
-
- // CONCATENATED MODULE: ./renderers/block/blockRendererFn.js
-
-
-
-
-
-
-
-
-
-
-
- var blockRendererFn_BlockRenderFnContext = function BlockRenderFnContext() {
- var _this = this;
-
- classCallCheck_default()(this, BlockRenderFnContext);
-
- defineProperty_default()(this, "superProps", void 0);
-
- defineProperty_default()(this, "customBlockRendererFn", void 0);
-
- defineProperty_default()(this, "getRenderFn", function (superProps, customBlockRendererFn) {
- _this.superProps = superProps;
- _this.customBlockRendererFn = customBlockRendererFn;
- return _this.blockRendererFn;
- });
-
- defineProperty_default()(this, "renderAtomicBlock", function (props) {
- var superProps = _this.superProps;
- var entityKey = props.block.getEntityAt(0);
-
- if (!entityKey) {
- return null;
- }
-
- var entity = props.contentState.getEntity(entityKey);
- var mediaData = entity.getData();
- var mediaType = entity.getType();
-
- var mediaProps = objectSpread_default()({}, superProps, {
- block: props.block,
- mediaData: mediaData,
- entityKey: entityKey
- });
-
- if (mediaType === 'IMAGE') {
- return external_react_default.a.createElement(Image_Image, mediaProps);
- } else if (mediaType === 'AUDIO') {
- return external_react_default.a.createElement(Audio_Audio, mediaProps);
- } else if (mediaType === 'VIDEO') {
- return external_react_default.a.createElement(Video_Video, mediaProps);
- } else if (mediaType === 'EMBED') {
- return external_react_default.a.createElement(Embed_Embed, mediaProps);
- } else if (mediaType === 'HR') {
- return external_react_default.a.createElement(HorizontalLine_HorizontalLine, mediaProps);
- }
-
- if (superProps.extendAtomics) {
- var atomics = superProps.extendAtomics;
-
- for (var i = 0; i < atomics.length; i++) {
- if (mediaType === atomics[i].type) {
- var Component = atomics[i].component;
- return external_react_default.a.createElement(Component, mediaProps);
- }
- }
- }
-
- return null;
- });
-
- defineProperty_default()(this, "blockRendererFn", function (block) {
- var customBlockRendererFn = _this.customBlockRendererFn,
- superProps = _this.superProps;
- var blockType = block.getType();
- var blockRenderer = null;
-
- if (customBlockRendererFn) {
- blockRenderer = customBlockRendererFn(block, superProps) || null;
- }
-
- if (blockRenderer) {
- return blockRenderer;
- }
-
- var extensionBlockRendererFns = getExtensionBlockRendererFns(superProps.editorId);
- extensionBlockRendererFns.find(function (item) {
- if (item.blockType === blockType || item.blockType instanceof RegExp && item.blockType.test(blockType)) {
- blockRenderer = item.rendererFn ? item.rendererFn(superProps) : null;
- return true;
- }
- });
-
- if (blockRenderer) {
- return blockRenderer;
- }
-
- if (blockType === 'atomic') {
- blockRenderer = {
- component: _this.renderAtomicBlock,
- editable: false
- };
- }
-
- return blockRenderer;
- });
- };
-
- var blockRenderFnContext = new blockRendererFn_BlockRenderFnContext();
- /* harmony default export */ var block_blockRendererFn = (blockRenderFnContext.getRenderFn);
- // CONCATENATED MODULE: ./renderers/block/blockStyleFn.js
- /* harmony default export */ var block_blockStyleFn = (function (customBlockStyleFn) {
- return function (block) {
- var blockAlignment = block.getData() && block.getData().get('textAlign');
- var blockIndent = block.getData() && block.getData().get('textIndent');
- var blockFloat = block.getData() && block.getData().get('float');
- var result = '';
-
- if (blockAlignment) {
- result = "bfa-".concat(blockAlignment);
- }
-
- if (blockIndent && blockIndent !== 0) {
- result += " bftd-".concat(blockIndent);
- }
-
- if (blockFloat) {
- result += " bff-".concat(blockFloat);
- }
-
- if (customBlockStyleFn) {
- result += customBlockStyleFn(block) || '';
- }
-
- return result;
- };
- });
- // CONCATENATED MODULE: ./renderers/inline/inlineStyleMap.js
-
-
- /* harmony default export */ var inlineStyleMap = (function (props) {
- var customStyleMap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var extensionInlineStyleMap = getExtensionInlineStyleMap(props.editorId);
- return objectSpread_default()({
- 'SUPERSCRIPT': {
- position: 'relative',
- top: '-8px',
- fontSize: '11px'
- },
- 'SUBSCRIPT': {
- position: 'relative',
- bottom: '-8px',
- fontSize: '11px'
- }
- }, extensionInlineStyleMap, customStyleMap);
- });
- // CONCATENATED MODULE: ./renderers/inline/inlineStyleFn.js
-
-
- var getStyleValue = function getStyleValue(style) {
- return style.split('-')[1];
- };
-
- /* harmony default export */ var inlineStyleFn = (function (props, options) {
- return function (styles, block) {
- var output = {};
- var fontFamilies = options.fontFamilies,
- unitExportFn = options.unitExportFn,
- customStyleFn = options.customStyleFn;
- var extensionInlineStyleFns = getExtensionInlineStyleFns(props.editorId);
- extensionInlineStyleFns.forEach(function (item) {
- output = item.styleFn ? item.styleFn(styles, block, output) : output;
- });
- output = customStyleFn ? customStyleFn(styles, block, output) : {};
- styles.forEach(function (style) {
- if (style.indexOf('COLOR-') === 0) {
- output.color = '#' + getStyleValue(style);
- } else if (style.indexOf('BGCOLOR-') === 0) {
- output.backgroundColor = '#' + getStyleValue(style);
- } else if (style.indexOf('FONTSIZE-') === 0) {
- output.fontSize = unitExportFn(getStyleValue(style), 'font-size', 'editor');
- } else if (style.indexOf('LINEHEIGHT-') === 0) {
- output.lineHeight = unitExportFn(getStyleValue(style), 'line-height', 'editor');
- } else if (style.indexOf('LETTERSPACING-') === 0) {
- output.letterSpacing = unitExportFn(getStyleValue(style), 'letter-spacing', 'editor');
- } else if (style.indexOf('TEXTINDENT-') === 0) {
- output.textIndent = unitExportFn(getStyleValue(style), 'text-indent', 'editor');
- } else if (style.indexOf('FONTFAMILY-') === 0) {
- output.fontFamily = (fontFamilies.find(function (item) {
- return item.name.toUpperCase() === getStyleValue(style);
- }) || {}).family || '';
- }
- });
- return output;
- };
- });
- // EXTERNAL MODULE: ../node_modules/draft-js-multidecorators/index.js
- var draft_js_multidecorators = __webpack_require__(18);
- var draft_js_multidecorators_default = /*#__PURE__*/__webpack_require__.n(draft_js_multidecorators);
-
- // CONCATENATED MODULE: ./renderers/decorators/Link/index.jsx
-
- /* harmony default export */ var Link = (function (props) {
- var children = props.children,
- entityKey = props.entityKey,
- contentState = props.contentState;
-
- var _contentState$getEnti = contentState.getEntity(entityKey).getData(),
- href = _contentState$getEnti.href,
- target = _contentState$getEnti.target;
-
- return external_react_default.a.createElement("span", {
- className: "bf-link-wrap"
- }, external_react_default.a.createElement("a", {
- onClick: function onClick(event) {
- return viewLink(event, href);
- },
- className: "bf-link",
- href: href,
- target: target
- }, children));
- });
-
- var viewLink = function viewLink(event, link) {
- // 当按下Ctrl/command键时,点击打开链接文字中的url
- if (event.getModifierState('Control') || event.getModifierState('Meta')) {
- var tempLink = document.createElement('a');
- tempLink.href = link;
- tempLink.target = event.currentTarget.target;
- tempLink.click();
- }
- };
- // CONCATENATED MODULE: ./renderers/decorators/index.js
-
-
-
-
-
-
- var KEY_SEPARATOR = '-';
-
- draft_js_multidecorators_default.a.prototype.getDecorations = function (block, contentState) {
- var decorations = Array(block.getText().length).fill(null);
- this.decorators.forEach(function (decorator, i) {
- decorator.getDecorations(block, contentState).forEach(function (key, offset) {
- if (!key) {
- return;
- }
-
- key = i + KEY_SEPARATOR + key;
- decorations[offset] = key;
- });
- });
- return external_immutable_default.a.List(decorations);
- };
-
- var builtinDecorators = [{
- type: 'entity',
- decorator: {
- key: 'LINK',
- component: Link
- }
- }];
-
- var createStrategy = function createStrategy(type) {
- return function (block, callback, contentState) {
- block.findEntityRanges(function (character) {
- var entityKey = character.getEntity();
- return entityKey !== null && contentState.getEntity(entityKey).getType() === type;
- }, callback);
- };
- };
-
- /* harmony default export */ var decorators = (function (editorId) {
- var extensionDecorators = getExtensionDecorators(editorId);
- var entityDecorators = builtinDecorators.concat(toConsumableArray_default()(extensionDecorators.filter(function (item) {
- return item.type === 'entity';
- })));
- var strategyDecorators = extensionDecorators.filter(function (item) {
- return item.type === 'strategy';
- });
- var classDecorators = extensionDecorators.filter(function (item) {
- return item.type === 'class';
- });
- return new draft_js_multidecorators_default.a(toConsumableArray_default()(classDecorators.map(function (item) {
- return item.decorator;
- })).concat([// combine decorators created with strategy
- new external_draft_js_["CompositeDecorator"](strategyDecorators.map(function (item) {
- return item.decorator;
- })), // combine decorators for entities
- new external_draft_js_["CompositeDecorator"](entityDecorators.map(function (item) {
- return {
- strategy: createStrategy(item.decorator.key),
- component: item.decorator.component
- };
- }))]));
- });
- // CONCATENATED MODULE: ./renderers/index.js
-
-
-
-
-
-
- var getBlockRenderMap = block_blockRenderMap;
- var getBlockRendererFn = block_blockRendererFn;
- var getBlockStyleFn = block_blockStyleFn;
- var getCustomStyleMap = inlineStyleMap;
- var getCustomStyleFn = inlineStyleFn;
- var getDecorators = decorators;
- // EXTERNAL MODULE: ./components/business/ControlBar/style.scss
- var ControlBar_style = __webpack_require__(53);
-
- // EXTERNAL MODULE: ./components/business/LinkEditor/style.scss
- var LinkEditor_style = __webpack_require__(54);
-
- // EXTERNAL MODULE: ./components/common/DropDown/style.scss
- var DropDown_style = __webpack_require__(55);
-
- // CONCATENATED MODULE: ./helpers/responsive.js
-
-
- var resizeEventHandlers = [];
- var responsiveHelperInited = false;
- var debouce = false;
- /* harmony default export */ var responsive = ({
- resolve: function resolve(eventHandler) {
- var id = external_braft_utils_["BaseUtils"].UniqueIndex();
- resizeEventHandlers.push({
- id: id,
- eventHandler: eventHandler
- });
- return id;
- },
- unresolve: function unresolve(id) {
- resizeEventHandlers = resizeEventHandlers.filter(function (item) {
- return item.id !== id;
- });
- }
- });
-
- if (!responsiveHelperInited && (typeof window === "undefined" ? "undefined" : typeof_default()(window)) === 'object') {
- window.addEventListener('resize', function (event) {
- clearTimeout(debouce);
- debouce = setTimeout(function () {
- resizeEventHandlers.map(function (item) {
- typeof item.eventHandler === 'function' && item.eventHandler(event);
- });
- debouce = false;
- }, 100);
- });
- responsiveHelperInited = true;
- }
- // CONCATENATED MODULE: ./components/common/DropDown/index.jsx
-
-
-
-
-
-
-
-
-
-
-
- var DropDown_DropDown =
- /*#__PURE__*/
- function (_React$Component) {
- inherits_default()(DropDown, _React$Component);
-
- function DropDown() {
- var _getPrototypeOf2;
-
- var _this;
-
- classCallCheck_default()(this, DropDown);
-
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(DropDown)).call.apply(_getPrototypeOf2, [this].concat(args)));
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "responsiveResolveId", null);
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "dropDownHandlerElement", null);
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "dropDownContentElement", null);
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
- active: false,
- offset: 0
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "fixDropDownPosition", function () {
- var viewRect = _this.props.getContainerNode().getBoundingClientRect();
-
- var handlerRect = _this.dropDownHandlerElement.getBoundingClientRect();
-
- var contentRect = _this.dropDownContentElement.getBoundingClientRect();
-
- var offset = 0;
- var right = handlerRect.right - handlerRect.width / 2 + contentRect.width / 2;
- var left = handlerRect.left + handlerRect.width / 2 - contentRect.width / 2;
- right = viewRect.right - right;
- left = left - viewRect.left;
-
- if (right < 10) {
- offset = right - 10;
- } else if (left < 10) {
- offset = left * -1 + 10;
- }
-
- if (offset !== _this.state.offset) {
- _this.setState({
- offset: offset
- });
- }
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "registerClickEvent", function (event) {
- var autoHide = _this.props.autoHide;
- var active = _this.state.active;
-
- if (_this.dropDownContentElement.contains(event.target) || _this.dropDownHandlerElement.contains(event.target)) {
- return false;
- }
-
- autoHide && active && _this.hide();
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggle", function () {
- _this.setState({
- active: !_this.state.active
- });
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "show", function () {
- _this.setState({
- active: true
- });
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "hide", function () {
- _this.setState({
- active: false
- });
- });
-
- return _this;
- }
-
- createClass_default()(DropDown, [{
- key: "componentDidMount",
- value: function componentDidMount() {
- if (document) {
- document.body.addEventListener('click', this.registerClickEvent);
- this.responsiveResolveId = responsive.resolve(this.fixDropDownPosition);
- }
- }
- }, {
- key: "componentWillReceiveProps",
- value: function componentWillReceiveProps(next) {
- if (!this.props.disabled && next.disabled) {
- this.hide();
- }
- }
- }, {
- key: "componentDidUpdate",
- value: function componentDidUpdate(prevState) {
- if (!prevState.active && this.state.active) {
- this.fixDropDownPosition();
- }
- }
- }, {
- key: "componentWillUnmount",
- value: function componentWillUnmount() {
- if (document) {
- document.body.removeEventListener('click', this.registerClickEvent);
- responsive.unresolve(this.responsiveResolveId);
- }
- }
- }, {
- key: "render",
- value: function render() {
- var _this2 = this;
-
- var _this$state = this.state,
- active = _this$state.active,
- offset = _this$state.offset;
- var _this$props = this.props,
- caption = _this$props.caption,
- htmlCaption = _this$props.htmlCaption,
- title = _this$props.title,
- disabled = _this$props.disabled,
- showArrow = _this$props.showArrow,
- arrowActive = _this$props.arrowActive,
- className = _this$props.className,
- children = _this$props.children,
- theme = _this$props.theme;
- disabled && (active = false);
- theme === 'light' && (className = ' light-theme ' + className);
- return external_react_default.a.createElement("div", {
- className: 'bf-dropdown ' + (active ? 'active ' : '') + (disabled ? 'disabled ' : '') + className
- }, htmlCaption ? external_react_default.a.createElement("button", {
- type: "button",
- className: "dropdown-handler",
- "data-title": title,
- onClick: this.toggle,
- dangerouslySetInnerHTML: htmlCaption ? {
- __html: htmlCaption
- } : null,
- ref: function ref(instance) {
- return _this2.dropDownHandlerElement = instance;
- }
- }) : external_react_default.a.createElement("button", {
- type: "button",
- className: "dropdown-handler",
- "data-title": title,
- onClick: this.toggle,
- ref: function ref(instance) {
- return _this2.dropDownHandlerElement = instance;
- }
- }, external_react_default.a.createElement("span", null, caption), showArrow !== false ? external_react_default.a.createElement("i", {
- className: "bfi-drop-down"
- }) : null), external_react_default.a.createElement("div", {
- className: "dropdown-content",
- style: {
- marginLeft: offset
- },
- ref: function ref(instance) {
- return _this2.dropDownContentElement = instance;
- }
- }, external_react_default.a.createElement("i", {
- style: {
- marginLeft: offset * -1
- },
- className: 'dropdown-arrow' + (arrowActive ? ' active' : '')
- }), external_react_default.a.createElement("div", {
- className: "dropdown-content-inner"
- }, children)));
- }
- }]);
-
- return DropDown;
- }(external_react_default.a.Component);
-
-
- // CONCATENATED MODULE: ./components/business/ControlGroup/index.jsx
-
- /* harmony default export */ var ControlGroup = (function (props) {
- if (external_react_default.a.Fragment) {
- return external_react_default.a.createElement(external_react_default.a.Fragment, null, props.children);
- } else {
- return external_react_default.a.createElement("div", {
- className: "control-item-group"
- }, props.children);
- }
- });
- // CONCATENATED MODULE: ./components/business/LinkEditor/index.jsx
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var LinkEditor_LinkEditor =
- /*#__PURE__*/
- function (_React$Component) {
- inherits_default()(LinkEditor, _React$Component);
-
- function LinkEditor(props) {
- var _this;
-
- classCallCheck_default()(this, LinkEditor);
-
- _this = possibleConstructorReturn_default()(this, getPrototypeOf_default()(LinkEditor).call(this, props));
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "dropDownInstance", null);
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handeKeyDown", function (e) {
- if (e.keyCode === 13) {
- _this.handleConfirm();
-
- e.preventDefault();
- return false;
- }
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleTnputText", function (e) {
- _this.setState({
- text: e.currentTarget.value
- });
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleInputLink", function (e) {
- _this.setState({
- href: e.currentTarget.value
- });
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setTarget", function () {
- _this.setState({
- target: _this.state.target === '_blank' ? '' : '_blank'
- });
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleCancel", function () {
- _this.dropDownInstance.hide();
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleUnlink", function () {
- _this.dropDownInstance.hide();
-
- _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLink(_this.props.editorState, false));
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleConfirm", function () {
- var _this$state = _this.state,
- text = _this$state.text,
- href = _this$state.href,
- target = _this$state.target,
- textSelected = _this$state.textSelected;
-
- var hookReturns = _this.props.hooks('toggle-link', {
- href: href,
- target: target
- })({
- href: href,
- target: target
- });
-
- _this.dropDownInstance.hide();
-
- _this.props.editor.requestFocus();
-
- if (hookReturns === false) {
- return false;
- }
-
- if (hookReturns) {
- typeof hookReturns.href === 'string' && (href = hookReturns.href);
- typeof hookReturns.target === 'string' && (target = hookReturns.target);
- }
-
- if (textSelected) {
- if (href) {
- _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLink(_this.props.editorState, href, target));
- } else {
- _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLink(_this.props.editorState, false));
- }
- } else {
- _this.props.editor.setValue(external_braft_utils_["ContentUtils"].insertText(_this.props.editorState, text || href, null, {
- type: 'LINK',
- data: {
- href: href,
- target: target
- }
- }));
- }
- });
-
- _this.state = {
- text: '',
- href: '',
- target: props.defaultLinkTarget || '',
- textSelected: false
- };
- return _this;
- }
-
- createClass_default()(LinkEditor, [{
- key: "componentWillReceiveProps",
- value: function componentWillReceiveProps(nextProps) {
- var _ContentUtils$getSele = external_braft_utils_["ContentUtils"].getSelectionEntityData(nextProps.editorState, 'LINK'),
- href = _ContentUtils$getSele.href,
- target = _ContentUtils$getSele.target;
-
- var textSelected = !external_braft_utils_["ContentUtils"].isSelectionCollapsed(this.props.editorState) && external_braft_utils_["ContentUtils"].getSelectionBlockType(this.props.editorState) !== 'atomic';
- var selectedText = '';
-
- if (textSelected) {
- selectedText = external_braft_utils_["ContentUtils"].getSelectionText(this.props.editorState);
- }
-
- this.setState({
- textSelected: textSelected,
- text: selectedText,
- href: href || '',
- target: typeof target === 'undefined' ? nextProps.defaultLinkTarget || '' : target || ''
- });
- }
- }, {
- key: "render",
- value: function render() {
- var _this2 = this;
-
- var allowInsertLinkText = this.props.allowInsertLinkText;
- var _this$state2 = this.state,
- text = _this$state2.text,
- href = _this$state2.href,
- target = _this$state2.target,
- textSelected = _this$state2.textSelected;
- var caption = external_react_default.a.createElement("i", {
- className: "bfi-link"
- });
- return external_react_default.a.createElement(ControlGroup, null, external_react_default.a.createElement(DropDown_DropDown, {
- key: 0,
- caption: caption,
- title: this.props.language.controls.link,
- autoHide: true,
- getContainerNode: this.props.getContainerNode,
- showArrow: false,
- ref: function ref(instance) {
- return _this2.dropDownInstance = instance;
- },
- className: 'control-item dropdown link-editor-dropdown'
- }, external_react_default.a.createElement("div", {
- className: "bf-link-editor"
- }, allowInsertLinkText ? external_react_default.a.createElement("div", {
- className: "input-group"
- }, external_react_default.a.createElement("input", {
- type: "text",
- value: text,
- spellCheck: false,
- disabled: textSelected,
- placeholder: this.props.language.linkEditor.textInputPlaceHolder,
- onKeyDown: this.handeKeyDown,
- onChange: this.handleTnputText
- })) : null, external_react_default.a.createElement("div", {
- className: "input-group"
- }, external_react_default.a.createElement("input", {
- type: "text",
- value: href,
- spellCheck: false,
- placeholder: this.props.language.linkEditor.linkInputPlaceHolder,
- onKeyDown: this.handeKeyDown,
- onChange: this.handleInputLink
- })), external_react_default.a.createElement("div", {
- className: "switch-group"
- }, external_react_default.a.createElement(Switch, {
- active: target === '_blank',
- onClick: this.setTarget
- }), external_react_default.a.createElement("label", null, this.props.language.linkEditor.openInNewWindow)), external_react_default.a.createElement("div", {
- className: "buttons"
- }, external_react_default.a.createElement("a", {
- onClick: this.handleUnlink,
- className: "primary button-remove-link pull-left"
- }, external_react_default.a.createElement("i", {
- className: "bfi-close"
- }), external_react_default.a.createElement("span", null, this.props.language.linkEditor.removeLink)), external_react_default.a.createElement("button", {
- type: "button",
- onClick: this.handleConfirm,
- className: "primary pull-right"
- }, this.props.language.base.confirm), external_react_default.a.createElement("button", {
- type: "button",
- onClick: this.handleCancel,
- className: "default pull-right"
- }, this.props.language.base.cancel)))), external_react_default.a.createElement("button", {
- key: 1,
- type: "button",
- "data-title": this.props.language.controls.unlink,
- className: "control-item button",
- onClick: this.handleUnlink,
- disabled: !textSelected || !href
- }, external_react_default.a.createElement("i", {
- className: "bfi-link-off"
- })));
- }
- }]);
-
- return LinkEditor;
- }(external_react_default.a.Component);
-
-
- // EXTERNAL MODULE: ./components/business/Headings/style.scss
- var Headings_style = __webpack_require__(56);
-
- // CONCATENATED MODULE: ./configs/maps.js
-
- var maps_getHeadings = function getHeadings(lang) {
- return [{
- key: 'header-one',
- title: lang.controls.header + ' 1',
- text: external_react_default.a.createElement("h1", null, lang.controls.header, " 1"),
- type: 'block-type',
- command: 'header-one'
- }, {
- key: 'header-two',
- title: lang.controls.header + ' 2',
- text: external_react_default.a.createElement("h2", null, lang.controls.header, " 2"),
- type: 'block-type',
- command: 'header-two'
- }, {
- key: 'header-three',
- title: lang.controls.header + ' 3',
- text: external_react_default.a.createElement("h3", null, lang.controls.header, " 3"),
- type: 'block-type',
- command: 'header-three'
- }, {
- key: 'header-four',
- title: lang.controls.header + ' 4',
- text: external_react_default.a.createElement("h4", null, lang.controls.header, " 4"),
- type: 'block-type',
- command: 'header-four'
- }, {
- key: 'header-five',
- title: lang.controls.header + ' 5',
- text: external_react_default.a.createElement("h5", null, lang.controls.header, " 5"),
- type: 'block-type',
- command: 'header-five'
- }, {
- key: 'header-six',
- title: lang.controls.header + ' 6',
- text: external_react_default.a.createElement("h6", null, lang.controls.header, " 6"),
- type: 'block-type',
- command: 'header-six'
- }, {
- key: 'unstyled',
- title: lang.controls.normal,
- text: lang.controls.normal,
- type: 'block-type',
- command: 'unstyled'
- }];
- };
- // CONCATENATED MODULE: ./components/business/Headings/index.jsx
-
-
-
-
- /* harmony default export */ var Headings = (function (props) {
- var dropDownInstance = null;
- var headings = maps_getHeadings(props.language).filter(function (item) {
- return props.headings.indexOf(item.key) !== -1;
- });
- var currentHeadingIndex = headings.findIndex(function (item) {
- return item.command === props.current;
- });
- var caption = headings[currentHeadingIndex] ? headings[currentHeadingIndex].title : props.language.controls.normal;
- return external_react_default.a.createElement(DropDown_DropDown, {
- caption: caption,
- autoHide: true,
- getContainerNode: props.getContainerNode,
- title: props.language.controls.headings,
- arrowActive: currentHeadingIndex === 0,
- ref: function ref(instance) {
- return dropDownInstance = instance;
- },
- className: 'control-item dropdown headings-dropdown'
- }, external_react_default.a.createElement("ul", {
- className: "menu"
- }, headings.map(function (item, index) {
- var isActive = props.current === item.command;
- return external_react_default.a.createElement("li", {
- key: index,
- className: 'menu-item' + (isActive ? ' active' : ''),
- onClick: function onClick() {
- props.onChange(item.command, item.type), dropDownInstance.hide();
- }
- }, item.text);
- })));
- });
- // EXTERNAL MODULE: ./components/business/TextColor/style.scss
- var TextColor_style = __webpack_require__(57);
-
- // EXTERNAL MODULE: ./components/common/ColorPicker/style.scss
- var ColorPicker_style = __webpack_require__(58);
-
- // CONCATENATED MODULE: ./components/common/ColorPicker/index.jsx
-
-
- /* harmony default export */ var common_ColorPicker = (function (props) {
- return external_react_default.a.createElement("div", {
- className: "bf-colors-wrap"
- }, external_react_default.a.createElement("ul", {
- className: "bf-colors"
- }, props.presetColors.map(function (item, index) {
- var className = props.color && item.toLowerCase() === props.color.toLowerCase() ? 'color-item active' : 'color-item';
- return external_react_default.a.createElement("li", {
- key: index,
- title: item,
- className: className,
- style: {
- color: item
- },
- "data-color": item.replace('#', ''),
- onClick: function onClick(e) {
- props.onChange(e.currentTarget.dataset.color, true);
- }
- });
- })));
- });
- // CONCATENATED MODULE: ./components/business/TextColor/index.jsx
-
-
-
-
-
-
-
-
-
-
-
-
-
- var TextColor_TextColor =
- /*#__PURE__*/
- function (_React$Component) {
- inherits_default()(TextColor, _React$Component);
-
- function TextColor() {
- var _getPrototypeOf2;
-
- var _this;
-
- classCallCheck_default()(this, TextColor);
-
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(TextColor)).call.apply(_getPrototypeOf2, [this].concat(args)));
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
- colorType: 'color'
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "switchColorType", function (_ref) {
- var currentTarget = _ref.currentTarget;
-
- _this.setState({
- colorType: currentTarget.dataset.type
- });
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggleColor", function (color, closePicker) {
- if (color) {
- var hookReturns = _this.props.hooks("toggle-text-".concat(_this.state.colorType), color)(color);
-
- if (hookReturns === false) {
- return false;
- }
-
- if (typeof hookReturns === 'string') {
- color = hookReturns;
- }
-
- if (_this.state.colorType === 'color') {
- _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionColor(_this.props.editorState, color));
- } else {
- _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionBackgroundColor(_this.props.editorState, color));
- }
- }
-
- if (closePicker) {
- _this.dropDownInstance.hide();
-
- _this.props.editor.requestFocus();
- }
- });
-
- return _this;
- }
-
- createClass_default()(TextColor, [{
- key: "render",
- value: function render() {
- var _this2 = this;
-
- var captionStyle = {};
- var currentColor = null;
- var colorType = this.state.colorType;
- var selectionStyles = this.props.editorState.getCurrentInlineStyle().toJS();
- selectionStyles.forEach(function (style) {
- if (style.indexOf('COLOR-') === 0) {
- captionStyle.color = '#' + style.split('-')[1];
- colorType === 'color' && (currentColor = captionStyle.color);
- }
-
- if (style.indexOf('BGCOLOR-') === 0) {
- captionStyle.backgroundColor = '#' + style.split('-')[1];
- colorType === 'background-color' && (currentColor = captionStyle.backgroundColor);
- }
- });
- var caption = external_react_default.a.createElement("i", {
- style: captionStyle,
- className: "bfi-text-color"
- }, external_react_default.a.createElement("span", {
- className: "path1"
- }), external_react_default.a.createElement("span", {
- className: "path2"
- }));
- var ColorPicker = this.props.colorPicker || common_ColorPicker;
- return external_react_default.a.createElement(DropDown_DropDown, {
- caption: caption,
- title: this.props.language.controls.color,
- showArrow: false,
- autoHide: this.props.autoHide,
- theme: this.props.theme,
- getContainerNode: this.props.getContainerNode,
- ref: function ref(instance) {
- return _this2.dropDownInstance = instance;
- },
- className: 'control-item dropdown text-color-dropdown'
- }, external_react_default.a.createElement("div", {
- className: "bf-text-color-picker-wrap"
- }, external_react_default.a.createElement("div", {
- className: "bf-color-switch-buttons",
- style: this.props.enableBackgroundColor ? {} : {
- display: 'none'
- }
- }, external_react_default.a.createElement("button", {
- type: "button",
- "data-type": "color",
- className: colorType === 'color' ? 'active' : '',
- onClick: this.switchColorType
- }, this.props.language.controls.textColor), external_react_default.a.createElement("button", {
- type: "button",
- "data-type": "background-color",
- className: colorType === 'background-color' ? 'active' : '',
- onClick: this.switchColorType
- }, this.props.language.controls.backgroundColor)), external_react_default.a.createElement(ColorPicker, {
- width: 200,
- color: currentColor,
- disableAlpha: true,
- presetColors: this.props.colors,
- onChange: this.toggleColor
- })));
- }
- }]);
-
- return TextColor;
- }(external_react_default.a.Component);
-
-
- // EXTERNAL MODULE: ./components/business/FontSize/style.scss
- var FontSize_style = __webpack_require__(59);
-
- // CONCATENATED MODULE: ./components/business/FontSize/index.jsx
-
-
-
-
-
- var FontSize_toggleFontSize = function toggleFontSize(event, props) {
- var fontSize = event.currentTarget.dataset.size;
- var hookReturns = props.hooks('toggle-font-size', fontSize)(fontSize);
-
- if (hookReturns === false) {
- return false;
- }
-
- if (!isNaN(fontSize)) {
- fontSize = hookReturns;
- }
-
- props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionFontSize(props.editorState, fontSize));
- props.editor.requestFocus();
- };
-
- /* harmony default export */ var FontSize = (function (props) {
- var caption = null;
- var currentFontSize = null;
- var dropDownInstance = null;
- props.fontSizes.find(function (item) {
- if (external_braft_utils_["ContentUtils"].selectionHasInlineStyle(props.editorState, 'FONTSIZE-' + item)) {
- caption = item;
- currentFontSize = item;
- return true;
- }
-
- return false;
- });
- return external_react_default.a.createElement(DropDown_DropDown, {
- autoHide: true,
- caption: caption || props.defaultCaption,
- getContainerNode: props.getContainerNode,
- title: props.language.controls.fontSize,
- ref: function ref(instance) {
- return dropDownInstance = instance;
- },
- className: 'control-item dropdown bf-font-size-dropdown'
- }, external_react_default.a.createElement("ul", {
- className: "bf-font-sizes"
- }, props.fontSizes.map(function (item, index) {
- return external_react_default.a.createElement("li", {
- key: index,
- className: item === currentFontSize ? 'active' : null,
- "data-size": item,
- onClick: function onClick(event) {
- FontSize_toggleFontSize(event, props), dropDownInstance.hide();
- }
- }, item);
- })));
- });
- // EXTERNAL MODULE: ./components/business/LineHeight/style.scss
- var LineHeight_style = __webpack_require__(60);
-
- // CONCATENATED MODULE: ./components/business/LineHeight/index.jsx
-
-
-
-
-
- var LineHeight_toggleLineHeight = function toggleLineHeight(event, props) {
- var lineHeight = event.currentTarget.dataset.size;
- var hookReturns = props.hooks('toggle-line-height', lineHeight)(lineHeight);
-
- if (hookReturns === false) {
- return false;
- }
-
- if (!isNaN(hookReturns)) {
- lineHeight = hookReturns;
- }
-
- props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLineHeight(props.editorState, lineHeight));
- props.editor.requestFocus();
- };
-
- /* harmony default export */ var LineHeight = (function (props) {
- var caption = null;
- var currentLineHeight = null;
- var dropDownInstance = null;
- props.lineHeights.find(function (item) {
- if (external_braft_utils_["ContentUtils"].selectionHasInlineStyle(props.editorState, 'LINEHEIGHT-' + item)) {
- caption = item;
- currentLineHeight = item;
- return true;
- }
-
- return false;
- });
- return external_react_default.a.createElement(DropDown_DropDown, {
- autoHide: true,
- caption: caption || props.defaultCaption,
- getContainerNode: props.getContainerNode,
- title: props.language.controls.lineHeight,
- ref: function ref(instance) {
- return dropDownInstance = instance;
- },
- className: 'control-item dropdown bf-line-height-dropdown'
- }, external_react_default.a.createElement("ul", {
- className: "bf-line-heights"
- }, props.lineHeights.map(function (item, index) {
- return external_react_default.a.createElement("li", {
- key: index,
- className: item === currentLineHeight ? 'active' : null,
- "data-size": item,
- onClick: function onClick(event) {
- LineHeight_toggleLineHeight(event, props), dropDownInstance.hide();
- }
- }, item);
- })));
- });
- // EXTERNAL MODULE: ./components/business/FontFamily/style.scss
- var FontFamily_style = __webpack_require__(61);
-
- // CONCATENATED MODULE: ./components/business/FontFamily/index.jsx
-
-
-
-
-
- var FontFamily_toggleFontFamily = function toggleFontFamily(event, props) {
- var fontFamilyName = event.currentTarget.dataset.name;
- var hookReturns = props.hooks('toggle-font-family', fontFamilyName)(fontFamilyName, props.fontFamilies);
-
- if (hookReturns === false) {
- return false;
- }
-
- if (typeof hookReturns === 'string') {
- fontFamilyName = hookReturns;
- }
-
- props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionFontFamily(props.editorState, fontFamilyName));
- props.editor.requestFocus();
- };
-
- /* harmony default export */ var FontFamily = (function (props) {
- var caption = null;
- var currentIndex = null;
- var dropDownInstance = null;
- props.fontFamilies.find(function (item, index) {
- if (external_braft_utils_["ContentUtils"].selectionHasInlineStyle(props.editorState, 'FONTFAMILY-' + item.name)) {
- caption = item.name;
- currentIndex = index;
- return true;
- }
-
- return false;
- });
- return external_react_default.a.createElement(DropDown_DropDown, {
- caption: caption || props.defaultCaption,
- getContainerNode: props.getContainerNode,
- title: props.language.controls.fontFamily,
- autoHide: true,
- arrowActive: currentIndex === 0,
- ref: function ref(instance) {
- return dropDownInstance = instance;
- },
- className: 'control-item dropdown font-family-dropdown'
- }, external_react_default.a.createElement("ul", {
- className: "menu"
- }, props.fontFamilies.map(function (item, index) {
- return external_react_default.a.createElement("li", {
- key: index,
- className: 'menu-item ' + (index === currentIndex ? 'active' : ''),
- "data-name": item.name,
- onClick: function onClick(event) {
- FontFamily_toggleFontFamily(event, props), dropDownInstance.hide();
- }
- }, external_react_default.a.createElement("span", {
- style: {
- fontFamily: item.family
- }
- }, item.name));
- })));
- });
- // CONCATENATED MODULE: ./components/business/TextAlign/index.jsx
-
-
-
-
-
-
-
-
-
-
-
- var TextAlign_TextAlign =
- /*#__PURE__*/
- function (_React$Component) {
- inherits_default()(TextAlign, _React$Component);
-
- function TextAlign() {
- var _getPrototypeOf2;
-
- var _this;
-
- classCallCheck_default()(this, TextAlign);
-
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(TextAlign)).call.apply(_getPrototypeOf2, [this].concat(args)));
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
- currentAlignment: undefined
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setAlignment", function (event) {
- var alignment = event.currentTarget.dataset.alignment;
-
- var hookReturns = _this.props.hooks('toggle-text-alignment', alignment)(alignment);
-
- if (_this.props.textAligns.indexOf(hookReturns) > -1) {
- alignment = hookReturns;
- }
-
- _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionAlignment(_this.props.editorState, alignment));
-
- _this.props.editor.requestFocus();
- });
-
- return _this;
- }
-
- createClass_default()(TextAlign, [{
- key: "componentWillReceiveProps",
- value: function componentWillReceiveProps(next) {
- this.setState({
- currentAlignment: external_braft_utils_["ContentUtils"].getSelectionBlockData(next.editorState, 'textAlign')
- });
- }
- }, {
- key: "render",
- value: function render() {
- var _this2 = this;
-
- var textAlignmentTitles = [this.props.language.controls.alignLeft, this.props.language.controls.alignCenter, this.props.language.controls.alignRight, this.props.language.controls.alignJustify];
- return external_react_default.a.createElement(ControlGroup, null, this.props.textAligns.map(function (item, index) {
- return external_react_default.a.createElement("button", {
- type: "button",
- key: index,
- "data-title": textAlignmentTitles[index],
- "data-alignment": item,
- className: 'control-item button ' + (item === _this2.state.currentAlignment ? 'active' : null),
- onClick: _this2.setAlignment
- }, external_react_default.a.createElement("i", {
- className: 'bfi-align-' + item
- }));
- }));
- }
- }]);
-
- return TextAlign;
- }(external_react_default.a.Component);
-
-
- // EXTERNAL MODULE: ./components/business/EmojiPicker/style.scss
- var EmojiPicker_style = __webpack_require__(62);
-
- // CONCATENATED MODULE: ./components/business/EmojiPicker/index.jsx
-
-
-
-
-
- var EmojiPicker_insertEmoji = function insertEmoji(event, props) {
- var emoji = event.currentTarget.dataset.emoji;
- var hookReturns = props.hooks('insert-emoji', emoji)(emoji);
-
- if (hookReturns === false) {
- return false;
- }
-
- if (typeof hookReturns === 'string') {
- emoji = hookReturns;
- }
-
- props.editor.setValue(external_braft_utils_["ContentUtils"].insertText(props.editorState, emoji));
- props.editor.requestFocus();
- };
-
- /* harmony default export */ var EmojiPicker = (function (props) {
- return external_react_default.a.createElement(DropDown_DropDown, {
- caption: props.defaultCaption,
- autoHide: true,
- showArrow: false,
- getContainerNode: props.getContainerNode,
- title: props.language.controls.emoji,
- className: 'control-item dropdown bf-emoji-dropdown'
- }, external_react_default.a.createElement("div", {
- className: "bf-emojis-wrap"
- }, external_react_default.a.createElement("ul", {
- className: "bf-emojis"
- }, props.emojis.map(function (item, index) {
- return external_react_default.a.createElement("li", {
- key: index,
- "data-emoji": item,
- onClick: function onClick(event) {
- return EmojiPicker_insertEmoji(event, props);
- }
- }, item);
- }))));
- });
- // EXTERNAL MODULE: ./components/business/LetterSpacing/style.scss
- var LetterSpacing_style = __webpack_require__(63);
-
- // CONCATENATED MODULE: ./components/business/LetterSpacing/index.jsx
-
-
-
-
-
- var LetterSpacing_toggleLetterSpacing = function toggleLetterSpacing(event, props) {
- var letterSpacing = event.currentTarget.dataset.size;
- var hookReturns = props.hooks('toggle-letter-spacing', letterSpacing)(letterSpacing);
-
- if (hookReturns === false) {
- return false;
- }
-
- if (!isNaN(hookReturns)) {
- letterSpacing = hookReturns;
- }
-
- props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLetterSpacing(props.editorState, letterSpacing));
- props.editor.requestFocus();
- };
-
- /* harmony default export */ var LetterSpacing = (function (props) {
- var caption = null;
- var currentLetterSpacing = null;
- var dropDownInstance = null;
- props.letterSpacings.find(function (item) {
- if (external_braft_utils_["ContentUtils"].selectionHasInlineStyle(props.editorState, 'LETTERSPACING-' + item)) {
- caption = item;
- currentLetterSpacing = item;
- return true;
- }
-
- return false;
- });
- return external_react_default.a.createElement(DropDown_DropDown, {
- autoHide: true,
- caption: caption || props.defaultCaption,
- getContainerNode: props.getContainerNode,
- title: props.language.controls.letterSpacing,
- ref: function ref(instance) {
- return dropDownInstance = instance;
- },
- className: 'control-item dropdown bf-letter-spacing-dropdown'
- }, external_react_default.a.createElement("ul", {
- className: "bf-letter-spacings"
- }, props.letterSpacings.map(function (item, index) {
- return external_react_default.a.createElement("li", {
- key: index,
- className: item === currentLetterSpacing ? 'active' : null,
- "data-size": item,
- onClick: function onClick(event) {
- LetterSpacing_toggleLetterSpacing(event, props), dropDownInstance.hide();
- }
- }, item);
- })));
- });
- // CONCATENATED MODULE: ./components/business/TextIndent/index.jsx
-
-
-
-
-
-
-
-
-
-
-
- var TextIndent_TextAlign =
- /*#__PURE__*/
- function (_React$Component) {
- inherits_default()(TextAlign, _React$Component);
-
- function TextAlign() {
- var _getPrototypeOf2;
-
- var _this;
-
- classCallCheck_default()(this, TextAlign);
-
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(TextAlign)).call.apply(_getPrototypeOf2, [this].concat(args)));
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
- currentIndent: 0
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "increaseIndent", function () {
- _this.props.editor.setValue(external_braft_utils_["ContentUtils"].increaseSelectionIndent(_this.props.editorState));
-
- _this.props.editor.requestFocus();
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "decreaseIndent", function () {
- _this.props.editor.setValue(external_braft_utils_["ContentUtils"].decreaseSelectionIndent(_this.props.editorState));
-
- _this.props.editor.requestFocus();
- });
-
- return _this;
- }
-
- createClass_default()(TextAlign, [{
- key: "componentWillReceiveProps",
- value: function componentWillReceiveProps(nextProps) {
- this.setState({
- currentIndent: external_braft_utils_["ContentUtils"].getSelectionBlockData(nextProps.editorState, 'textIndent') || 0
- });
- }
- }, {
- key: "render",
- value: function render() {
- var currentIndent = this.state.currentIndent;
- var language = this.props.language;
- return external_react_default.a.createElement(ControlGroup, null, external_react_default.a.createElement("button", {
- key: 0,
- type: "button",
- "data-title": language.controls.increaseIndent,
- disabled: currentIndent >= 6,
- className: "control-item button button-indent-increase".concat(currentIndent > 0 && currentIndent < 6 ? ' active' : ''),
- onClick: this.increaseIndent
- }, external_react_default.a.createElement("i", {
- className: 'bfi-indent-increase'
- })), external_react_default.a.createElement("button", {
- key: 1,
- type: "button",
- "data-title": language.controls.decreaseIndent,
- disabled: currentIndent <= 0,
- className: "control-item button button-indent-decrease",
- onClick: this.decreaseIndent
- }, external_react_default.a.createElement("i", {
- className: 'bfi-indent-decrease'
- })));
- }
- }]);
-
- return TextAlign;
- }(external_react_default.a.Component);
-
-
- // CONCATENATED MODULE: ./components/business/ControlBar/index.jsx
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var commandHookMap = {
- 'inline-style': 'toggle-inline-style',
- 'block-type': 'change-block-type',
- 'editor-method': 'exec-editor-command'
- };
- var exclusiveInlineStyles = {
- 'superscript': 'subscript',
- 'subscript': 'superscript'
- };
-
- var mergeControls = function mergeControls(commonProps, builtControls, extensionControls, extendControls) {
- extensionControls = extensionControls.map(function (item) {
- return typeof item === 'function' ? item(commonProps) : item;
- });
- extendControls = extendControls.map(function (item) {
- return typeof item === 'function' ? item(commonProps) : item;
- });
-
- if (extensionControls.length === 0 && extendControls.length === 0) {
- return builtControls;
- }
-
- return builtControls.map(function (item) {
- return extendControls.find(function (subItem) {
- return subItem.replace === (item.key || item);
- }) || extensionControls.find(function (subItem) {
- return subItem.replace === (item.key || item);
- }) || item;
- }).concat(extensionControls.length ? 'separator' : '').concat(extensionControls.filter(function (item) {
- return !item.replace;
- })).concat(extendControls.filter(function (item) {
- return typeof item === 'string' || !item.replace;
- }));
- };
-
- var ControlBar_ControlBar =
- /*#__PURE__*/
- function (_React$Component) {
- inherits_default()(ControlBar, _React$Component);
-
- function ControlBar() {
- var _getPrototypeOf2;
-
- var _this;
-
- classCallCheck_default()(this, ControlBar);
-
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(ControlBar)).call.apply(_getPrototypeOf2, [this].concat(args)));
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "allControls", []);
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "mediaLibiraryModal", null);
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "extendedModals", {});
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "openBraftFinder", function () {
- if (!_this.props.braftFinder || !_this.props.braftFinder.ReactComponent) {
- return false;
- }
-
- if (_this.props.hooks('open-braft-finder')() === false) {
- return false;
- }
-
- var mediaProps = _this.props.media;
- var MediaLibrary = _this.props.braftFinder.ReactComponent;
- _this.mediaLibiraryModal = Modal_showModal({
- title: _this.props.language.controls.mediaLibirary,
- language: _this.props.language,
- width: 640,
- showFooter: false,
- component: external_react_default.a.createElement(MediaLibrary, {
- accepts: mediaProps.accepts,
- onCancel: _this.closeBraftFinder,
- onInsert: _this.insertMedias,
- onChange: mediaProps.onChange,
- externals: mediaProps.externals,
- onBeforeSelect: _this.bindBraftFinderHook('select-medias'),
- onBeforeDeselect: _this.bindBraftFinderHook('deselect-medias'),
- onBeforeRemove: _this.bindBraftFinderHook('remove-medias'),
- onBeforeInsert: _this.bindBraftFinderHook('insert-medias'),
- onFileSelect: _this.bindBraftFinderHook('select-files')
- })
- });
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "bindBraftFinderHook", function (hookName) {
- return function () {
- return _this.props.hooks(hookName, arguments.length <= 0 ? undefined : arguments[0]).apply(void 0, arguments);
- };
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "insertMedias", function (medias) {
- _this.props.editor.setValue(external_braft_utils_["ContentUtils"].insertMedias(_this.props.editorState, medias));
-
- _this.props.editor.requestFocus();
-
- _this.props.media.onInsert && _this.props.media.onInsert(medias);
-
- _this.closeBraftFinder();
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "closeBraftFinder", function () {
- _this.props.media.onCancel && _this.props.media.onCancel();
- _this.mediaLibiraryModal && _this.mediaLibiraryModal.close();
- });
-
- return _this;
- }
-
- createClass_default()(ControlBar, [{
- key: "componentDidUpdate",
- value: function componentDidUpdate() {
- var _this2 = this;
-
- var language = this.props.language;
- this.allControls.forEach(function (item) {
- if (item.type === 'modal') {
- if (item.modal && item.modal.id && _this2.extendedModals[item.modal.id]) {
- _this2.extendedModals[item.modal.id].update(objectSpread_default()({}, item.modal, {
- language: language
- }));
- }
- }
- });
- }
- }, {
- key: "getControlItemClassName",
- value: function getControlItemClassName(data) {
- var className = 'control-item button';
- var type = data.type,
- command = data.command;
-
- if (type === 'inline-style' && external_braft_utils_["ContentUtils"].selectionHasInlineStyle(this.props.editorState, command)) {
- className += ' active';
- } else if (type === 'block-type' && external_braft_utils_["ContentUtils"].getSelectionBlockType(this.props.editorState) === command) {
- className += ' active';
- } else if (type === 'entity' && external_braft_utils_["ContentUtils"].getSelectionEntityType(this.props.editorState) === command) {
- className += ' active';
- }
-
- return className;
- }
- }, {
- key: "applyControl",
- value: function applyControl(command, type) {
- var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- var hookReturns = this.props.hooks(commandHookMap[type] || type, command)(command);
- var editorState = this.props.editorState;
-
- if (hookReturns === false) {
- return false;
- }
-
- if (typeof hookReturns === 'string') {
- command = hookReturns;
- }
-
- if (type === 'inline-style') {
- var exclusiveInlineStyle = exclusiveInlineStyles[command];
-
- if (exclusiveInlineStyle && external_braft_utils_["ContentUtils"].selectionHasInlineStyle(editorState, exclusiveInlineStyle)) {
- editorState = external_braft_utils_["ContentUtils"].toggleSelectionInlineStyle(editorState, exclusiveInlineStyle);
- }
-
- this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionInlineStyle(editorState, command));
- } else if (type === 'block-type') {
- this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionBlockType(editorState, command));
- } else if (type === 'entity') {
- this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionEntity(editorState, {
- type: command,
- mutability: data.mutability || 'MUTABLE',
- data: data.data || {}
- }));
- } else if (type === 'editor-method') {
- this.props.editor[command] && this.props.editor[command]();
- }
- }
- }, {
- key: "render",
- value: function render() {
- var _this3 = this;
-
- var _this$props = this.props,
- editor = _this$props.editor,
- editorId = _this$props.editorId,
- editorState = _this$props.editorState,
- className = _this$props.className,
- style = _this$props.style,
- controls = _this$props.controls,
- media = _this$props.media,
- extendControls = _this$props.extendControls,
- language = _this$props.language,
- hooks = _this$props.hooks,
- colors = _this$props.colors,
- colorPicker = _this$props.colorPicker,
- colorPickerTheme = _this$props.colorPickerTheme,
- colorPickerAutoHide = _this$props.colorPickerAutoHide,
- headings = _this$props.headings,
- fontSizes = _this$props.fontSizes,
- fontFamilies = _this$props.fontFamilies,
- emojis = _this$props.emojis,
- getContainerNode = _this$props.getContainerNode,
- lineHeights = _this$props.lineHeights,
- letterSpacings = _this$props.letterSpacings,
- textAligns = _this$props.textAligns,
- textBackgroundColor = _this$props.textBackgroundColor,
- allowInsertLinkText = _this$props.allowInsertLinkText,
- defaultLinkTarget = _this$props.defaultLinkTarget;
- var currentBlockType = external_braft_utils_["ContentUtils"].getSelectionBlockType(editorState);
- var commonProps = {
- editor: editor,
- editorId: editorId,
- editorState: editorState,
- language: language,
- getContainerNode: getContainerNode,
- hooks: hooks
- };
- var renderedControls = [];
- var editorControls = configs_controls(language, editor);
- var extensionControls = getExtensionControls(editorId);
- var allControls = mergeControls(commonProps, controls, extensionControls, extendControls);
- this.allControls = allControls;
- return external_react_default.a.createElement("div", {
- className: "bf-controlbar ".concat(className || ''),
- style: style,
- onMouseDown: this.preventDefault
- }, allControls.map(function (item, index) {
- var itemKey = typeof item === 'string' ? item : item.key;
-
- if (typeof itemKey !== 'string') {
- return null;
- }
-
- if (renderedControls.indexOf(itemKey) > -1) {
- return null;
- }
-
- if (itemKey.toLowerCase() === 'separator') {
- return external_react_default.a.createElement("span", {
- key: index,
- className: "separator-line"
- });
- }
-
- var controlItem = editorControls.find(function (subItem) {
- return subItem.key.toLowerCase() === itemKey.toLowerCase();
- });
-
- if (typeof item !== 'string') {
- controlItem = objectSpread_default()({}, controlItem, item);
- }
-
- if (!controlItem) {
- return null;
- }
-
- renderedControls.push(itemKey);
-
- if (controlItem.type === 'headings') {
- return external_react_default.a.createElement(Headings, extends_default()({
- key: index,
- headings: headings,
- current: currentBlockType,
- onChange: function onChange(command) {
- return _this3.applyControl(command, 'block-type');
- }
- }, commonProps));
- } else if (controlItem.type === 'text-color') {
- return external_react_default.a.createElement(TextColor_TextColor, extends_default()({
- key: index,
- colors: colors,
- colorPicker: colorPicker,
- theme: colorPickerTheme,
- autoHide: colorPickerAutoHide,
- enableBackgroundColor: textBackgroundColor
- }, commonProps));
- } else if (controlItem.type === 'font-size') {
- return external_react_default.a.createElement(FontSize, extends_default()({
- key: index,
- fontSizes: fontSizes,
- defaultCaption: controlItem.title
- }, commonProps));
- } else if (controlItem.type === 'line-height') {
- return external_react_default.a.createElement(LineHeight, extends_default()({
- key: index,
- lineHeights: lineHeights,
- defaultCaption: controlItem.title
- }, commonProps));
- } else if (controlItem.type === 'letter-spacing') {
- return external_react_default.a.createElement(LetterSpacing, extends_default()({
- key: index,
- letterSpacings: letterSpacings,
- defaultCaption: controlItem.title
- }, commonProps));
- } else if (controlItem.type === 'text-indent') {
- return external_react_default.a.createElement(TextIndent_TextAlign, extends_default()({
- key: index,
- defaultCaption: controlItem.title
- }, commonProps));
- } else if (controlItem.type === 'font-family') {
- return external_react_default.a.createElement(FontFamily, extends_default()({
- key: index,
- fontFamilies: fontFamilies,
- defaultCaption: controlItem.title
- }, commonProps));
- } else if (controlItem.type === 'emoji') {
- return external_react_default.a.createElement(EmojiPicker, extends_default()({
- key: index,
- emojis: emojis,
- defaultCaption: controlItem.text
- }, commonProps));
- } else if (controlItem.type === 'link') {
- return external_react_default.a.createElement(LinkEditor_LinkEditor, extends_default()({
- key: index,
- defaultLinkTarget: defaultLinkTarget,
- allowInsertLinkText: allowInsertLinkText
- }, commonProps));
- } else if (controlItem.type === 'text-align') {
- return external_react_default.a.createElement(TextAlign_TextAlign, extends_default()({
- key: index,
- textAligns: textAligns
- }, commonProps));
- } else if (controlItem.type === 'media') {
- if (!media.image && !media.video && !media.audio) {
- return null;
- }
-
- return external_react_default.a.createElement("button", {
- type: "button",
- key: index,
- "data-title": controlItem.title,
- disabled: controlItem.disabled,
- className: "control-item media button",
- onClick: _this3.openBraftFinder
- }, controlItem.text);
- } else if (controlItem.type === 'dropdown') {
- return external_react_default.a.createElement(DropDown_DropDown, extends_default()({
- key: index,
- className: "control-item extend-control-item dropdown ".concat(controlItem.className || ''),
- caption: controlItem.text,
- htmlCaption: controlItem.html,
- showArrow: controlItem.showArrow,
- title: controlItem.title,
- arrowActive: controlItem.arrowActive,
- theme: controlItem.theme,
- autoHide: controlItem.autoHide,
- disabled: controlItem.disabled,
- ref: controlItem.ref
- }, commonProps), controlItem.component);
- } else if (controlItem.type === 'modal') {
- return external_react_default.a.createElement("button", {
- type: "button",
- key: index,
- "data-title": controlItem.title,
- disabled: controlItem.disabled,
- className: "control-item extend-control-item button ".concat(controlItem.className || ''),
- dangerouslySetInnerHTML: controlItem.html ? {
- __html: controlItem.html
- } : null,
- onClick: function onClick(event) {
- if (controlItem.modal && controlItem.modal.id) {
- if (_this3.extendedModals[controlItem.modal.id]) {
- _this3.extendedModals[controlItem.modal.id].active = true;
-
- _this3.extendedModals[controlItem.modal.id].update(objectSpread_default()({}, controlItem.modal, {
- language: language
- }));
- } else {
- _this3.extendedModals[controlItem.modal.id] = Modal_showModal(objectSpread_default()({}, controlItem.modal, {
- language: language
- }));
- controlItem.modal.onCreate && controlItem.modal.onCreate(_this3.extendedModals[controlItem.modal.id]);
- }
- }
-
- controlItem.onClick && controlItem.onClick(event);
- }
- }, !controlItem.html ? controlItem.text : null);
- } else if (controlItem.type === 'component') {
- return external_react_default.a.createElement("div", {
- key: index,
- className: "component-wrapper ".concat(controlItem.className || '')
- }, controlItem.component);
- } else if (controlItem.type === 'button') {
- return external_react_default.a.createElement("button", {
- type: "button",
- key: index,
- "data-title": controlItem.title,
- disabled: controlItem.disabled,
- className: "control-item button ".concat(controlItem.className || ''),
- dangerouslySetInnerHTML: controlItem.html ? {
- __html: controlItem.html
- } : null,
- onClick: function onClick(event) {
- return controlItem.onClick && controlItem.onClick(event);
- }
- }, !controlItem.html ? controlItem.text : null);
- } else if (controlItem) {
- var disabled = false;
-
- if (controlItem.command === 'undo') {
- disabled = editorState.getUndoStack().size === 0;
- } else if (controlItem.command === 'redo') {
- disabled = editorState.getRedoStack().size === 0;
- }
-
- return external_react_default.a.createElement("button", {
- type: "button",
- key: index,
- disabled: disabled,
- "data-title": controlItem.title,
- className: _this3.getControlItemClassName({
- type: controlItem.type,
- command: controlItem.command
- }),
- onClick: function onClick() {
- return _this3.applyControl(controlItem.command, controlItem.type, controlItem.data);
- }
- }, controlItem.text);
- }
- }));
- }
- }, {
- key: "preventDefault",
- value: function preventDefault(event) {
- var tagName = event.target.tagName.toLowerCase();
-
- if (tagName === 'input' || tagName === 'label') ; else {
- event.preventDefault();
- }
- }
- }]);
-
- return ControlBar;
- }(external_react_default.a.Component);
-
-
- // CONCATENATED MODULE: ./editor/index.jsx
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var buildHooks = function buildHooks(hooks) {
- return function (hookName) {
- var defaultReturns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- return hooks[hookName] || function () {
- return defaultReturns;
- };
- };
- };
-
- var filterColors = function filterColors(colors, colors2) {
- return colors.filter(function (item) {
- return !colors2.find(function (color) {
- return color.toLowerCase() === item.toLowerCase();
- });
- }).filter(function (item, index, array) {
- return array.indexOf(item) === index;
- });
- };
-
- var editor_isControlEnabled = function isControlEnabled(props, controlName) {
- return toConsumableArray_default()(props.controls).concat(toConsumableArray_default()(props.extendControls)).find(function (item) {
- return item === controlName || item.key === controlName;
- }) && props.excludeControls.indexOf(controlName) === -1;
- };
-
- var editor_getConvertOptions = function getConvertOptions(props) {
- var editorId = props.editorId || props.id;
-
- var convertOptions = objectSpread_default()({}, configs_props.converts, props.converts, {
- fontFamilies: props.fontFamilies
- });
-
- convertOptions.styleImportFn = compositeStyleImportFn(convertOptions.styleImportFn, editorId);
- convertOptions.styleExportFn = compositeStyleExportFn(convertOptions.styleExportFn, editorId);
- convertOptions.entityImportFn = compositeEntityImportFn(convertOptions.entityImportFn, editorId);
- convertOptions.entityExportFn = compositeEntityExportFn(convertOptions.entityExportFn, editorId);
- convertOptions.blockImportFn = compositeBlockImportFn(convertOptions.blockImportFn, editorId);
- convertOptions.blockExportFn = compositeBlockExportFn(convertOptions.blockExportFn, editorId);
- return convertOptions;
- };
-
- var editor_BraftEditor =
- /*#__PURE__*/
- function (_React$Component) {
- inherits_default()(BraftEditor, _React$Component);
-
- function BraftEditor(props) {
- var _this;
-
- classCallCheck_default()(this, BraftEditor);
-
- _this = possibleConstructorReturn_default()(this, getPrototypeOf_default()(BraftEditor).call(this, props));
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "onChange", function (editorState, callback) {
- if (!(editorState instanceof external_draft_js_["EditorState"])) {
- editorState = external_draft_js_["EditorState"].set(editorState, {
- decorator: _this.editorDecorators
- });
- }
-
- if (!editorState.convertOptions) {
- editorState.setConvertOptions(editor_getConvertOptions(_this.editorProps));
- }
-
- _this.setState({
- editorState: editorState
- }, function () {
- _this.props.onChange && _this.props.onChange(editorState);
- callback && callback(editorState);
- });
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "getDraftInstance", function () {
- return _this.draftInstance;
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "getFinderInstance", function () {
- return _this.braftFinder;
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "getValue", function () {
- return _this.state.editorState;
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setValue", function (editorState, callback) {
- return _this.onChange(editorState, callback);
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "forceRender", function () {
- var selectionState = _this.state.editorState.getSelection();
-
- _this.setValue(external_draft_js_["EditorState"].set(_this.state.editorState, {
- decorator: _this.editorDecorators
- }), function () {
- _this.setValue(external_draft_js_["EditorState"].forceSelection(_this.state.editorState, selectionState));
- });
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "onTab", function (event) {
- if (handlers_keyCommandHandlers('tab', _this.state.editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this))) === 'handled') {
- event.preventDefault();
- }
-
- _this.editorProps.onTab && _this.editorProps.onTab(event);
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "onFocus", function () {
- _this.isFocused = true;
- _this.editorProps.onFocus && _this.editorProps.onFocus(_this.state.editorState);
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "onBlur", function () {
- _this.isFocused = false;
- _this.editorProps.onBlur && _this.editorProps.onBlur(_this.state.editorState);
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "requestFocus", function () {
- setTimeout(function () {
- return _this.draftInstance.focus();
- }, 0);
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleKeyCommand", function (command, editorState) {
- return handlers_keyCommandHandlers(command, editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleReturn", function (event, editorState) {
- return handlers_returnHandlers(event, editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleBeforeInput", function (chars, editorState) {
- return beforeInputHandlers(chars, editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleDrop", function (selectionState, dataTransfer) {
- return handlers_dropHandlers(selectionState, dataTransfer, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleDroppedFiles", function (selectionState, files) {
- return droppedFilesHandlers(selectionState, files, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handlePastedFiles", function (files) {
- return pastedFilesHandlers(files, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleCopyContent", function (event) {
- return handlers_copyHandlers(event, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handlePastedText", function (text, html, editorState) {
- return handlers_pastedTextHandlers(text, html, editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleCompositionStart", function (event) {
- return handlers_compositionStartHandler(event, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "undo", function () {
- _this.setValue(external_braft_utils_["ContentUtils"].undo(_this.state.editorState));
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "redo", function () {
- _this.setValue(external_braft_utils_["ContentUtils"].redo(_this.state.editorState));
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeSelectionInlineStyles", function () {
- _this.setValue(external_braft_utils_["ContentUtils"].removeSelectionInlineStyles(_this.state.editorState));
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "insertHorizontalLine", function () {
- _this.setValue(external_braft_utils_["ContentUtils"].insertHorizontalLine(_this.state.editorState));
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "clearEditorContent", function () {
- _this.setValue(external_braft_utils_["ContentUtils"].clear(_this.state.editorState), function (editorState) {
- _this.setValue(external_braft_utils_["ContentUtils"].toggleSelectionIndent(editorState, 0));
- });
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggleFullscreen", function (fullscreen) {
- _this.setState({
- isFullscreen: typeof fullscreen !== 'undefined' ? fullscreen : !_this.state.isFullscreen
- }, function () {
- _this.editorProps.onFullscreen && _this.editorProps.onFullscreen(_this.state.isFullscreen);
- });
- });
-
- defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setEditorContainerNode", function (containerNode) {
- _this.containerNode = containerNode;
- });
-
- _this.editorProps = _this.getEditorProps(props);
- _this.editorDecorators = getDecorators(_this.editorProps.editorId || _this.editorProps.id);
- _this.isFocused = false;
- _this.isLiving = false;
- _this.braftFinder = null;
- _this.valueInitialized = !!(_this.props.defaultValue || _this.props.value);
- var defaultEditorState = (_this.props.defaultValue || _this.props.value) instanceof external_draft_js_["EditorState"] ? _this.props.defaultValue || _this.props.value : external_draft_js_["EditorState"].createEmpty(_this.editorDecorators);
- defaultEditorState.setConvertOptions(editor_getConvertOptions(_this.editorProps));
- var tempColors = [];
-
- if (external_braft_utils_["ContentUtils"].isEditorState(defaultEditorState)) {
- var colors = external_braft_utils_["ColorUtils"].detectColorsFromDraftState(defaultEditorState.toRAW(true));
- defaultEditorState.setConvertOptions(editor_getConvertOptions(_this.editorProps));
- tempColors = filterColors(colors, _this.editorProps.colors);
- }
-
- _this.state = {
- tempColors: tempColors,
- editorState: defaultEditorState,
- isFullscreen: false,
- draftProps: {}
- };
- _this.containerNode = null;
- return _this;
- }
-
- createClass_default()(BraftEditor, [{
- key: "getEditorProps",
- value: function getEditorProps(props) {
- var _this2 = this;
-
- props = props || this.props;
-
- var _props = props,
- value = _props.value,
- defaultValue = _props.defaultValue,
- onChange = _props.onChange,
- restProps = objectWithoutProperties_default()(_props, ["value", "defaultValue", "onChange"]); // eslint-disable-line no-unused-vars
-
-
- var propInterceptors = getPropInterceptors(restProps.editorId || restProps.id);
-
- if (propInterceptors.length === 0) {
- return restProps;
- }
-
- var porpsMap = Object(external_immutable_["Map"])(restProps);
- propInterceptors.forEach(function (interceptor) {
- porpsMap = porpsMap.merge(Object(external_immutable_["Map"])(interceptor(porpsMap.toJS(), _this2) || {}));
- });
- return porpsMap.toJS();
- }
- }, {
- key: "componentWillMount",
- value: function componentWillMount() {
- if (editor_isControlEnabled(this.editorProps, 'media')) {
- var _this$editorProps = this.editorProps,
- language = _this$editorProps.language,
- media = _this$editorProps.media;
-
- var _defaultProps$media$m = objectSpread_default()({}, configs_props.media, media),
- uploadFn = _defaultProps$media$m.uploadFn,
- validateFn = _defaultProps$media$m.validateFn,
- items = _defaultProps$media$m.items;
-
- this.braftFinder = new external_braft_finder_default.a({
- items: items,
- language: language,
- uploader: uploadFn,
- validator: validateFn
- });
- this.forceUpdate();
- }
- }
- }, {
- key: "componentDidMount",
- value: function componentDidMount() {
- this.isLiving = true;
- }
- }, {
- key: "componentDidUpdate",
- value: function componentDidUpdate(_, prevState) {
- if (prevState.editorState !== this.state.editorState) {
- this.state.editorState.setConvertOptions(editor_getConvertOptions(this.editorProps));
- }
- }
- }, {
- key: "componentWillReceiveProps",
- value: function componentWillReceiveProps(props) {
- var _this3 = this;
-
- this.editorProps = this.getEditorProps(props);
- var editorState = props.value;
- var _this$editorProps2 = this.editorProps,
- media = _this$editorProps2.media,
- language = _this$editorProps2.language;
- var currentProps = this.getEditorProps();
-
- if (!editor_isControlEnabled(currentProps, 'media') && editor_isControlEnabled(this.editorProps, 'media') && !this.braftFinder) {
- var _defaultProps$media$m2 = objectSpread_default()({}, configs_props.media, media),
- uploadFn = _defaultProps$media$m2.uploadFn,
- validateFn = _defaultProps$media$m2.validateFn,
- items = _defaultProps$media$m2.items;
-
- this.braftFinder = new external_braft_finder_default.a({
- items: items,
- language: language,
- uploader: uploadFn,
- validator: validateFn
- });
- this.forceUpdate();
- }
-
- if (media && media.items && this.braftFinder) {
- this.braftFinder.setItems(media.items);
- }
-
- var nextEditorState;
-
- if (!this.valueInitialized && typeof this.props.defaultValue === 'undefined' && external_braft_utils_["ContentUtils"].isEditorState(props.defaultValue)) {
- nextEditorState = props.defaultValue;
- } else if (external_braft_utils_["ContentUtils"].isEditorState(editorState)) {
- nextEditorState = editorState;
- }
-
- if (nextEditorState) {
- if (nextEditorState && nextEditorState !== this.state.editorState) {
- var tempColors = external_braft_utils_["ColorUtils"].detectColorsFromDraftState(nextEditorState.toRAW(true));
- nextEditorState.setConvertOptions(editor_getConvertOptions(this.editorProps));
- this.setState({
- tempColors: filterColors(toConsumableArray_default()(this.state.tempColors).concat(toConsumableArray_default()(tempColors)), currentProps.colors),
- editorState: nextEditorState
- }, function () {
- _this3.props.onChange && _this3.props.onChange(nextEditorState);
- });
- } else {
- this.setState({
- editorState: nextEditorState
- });
- }
- }
- }
- }, {
- key: "componentWillUnmount",
- value: function componentWillUnmount() {
- this.isLiving = false;
- this.controlBarInstance && this.controlBarInstance.closeBraftFinder();
- }
- }, {
- key: "lockOrUnlockEditor",
- value: function lockOrUnlockEditor(editorLocked) {
- this.setState({
- editorLocked: editorLocked
- });
- }
- }, {
- key: "render",
- value: function render() {
- var _this4 = this;
-
- var _this$editorProps3 = this.editorProps,
- id = _this$editorProps3.id,
- editorId = _this$editorProps3.editorId,
- controls = _this$editorProps3.controls,
- excludeControls = _this$editorProps3.excludeControls,
- extendControls = _this$editorProps3.extendControls,
- readOnly = _this$editorProps3.readOnly,
- disabled = _this$editorProps3.disabled,
- media = _this$editorProps3.media,
- language = _this$editorProps3.language,
- colors = _this$editorProps3.colors,
- colorPicker = _this$editorProps3.colorPicker,
- colorPickerTheme = _this$editorProps3.colorPickerTheme,
- colorPickerAutoHide = _this$editorProps3.colorPickerAutoHide,
- hooks = _this$editorProps3.hooks,
- fontSizes = _this$editorProps3.fontSizes,
- fontFamilies = _this$editorProps3.fontFamilies,
- emojis = _this$editorProps3.emojis,
- placeholder = _this$editorProps3.placeholder,
- fixPlaceholder = _this$editorProps3.fixPlaceholder,
- headings = _this$editorProps3.headings,
- imageControls = _this$editorProps3.imageControls,
- imageResizable = _this$editorProps3.imageResizable,
- lineHeights = _this$editorProps3.lineHeights,
- letterSpacings = _this$editorProps3.letterSpacings,
- textAligns = _this$editorProps3.textAligns,
- textBackgroundColor = _this$editorProps3.textBackgroundColor,
- allowInsertLinkText = _this$editorProps3.allowInsertLinkText,
- defaultLinkTarget = _this$editorProps3.defaultLinkTarget,
- extendAtomics = _this$editorProps3.extendAtomics,
- className = _this$editorProps3.className,
- style = _this$editorProps3.style,
- controlBarClassName = _this$editorProps3.controlBarClassName,
- controlBarStyle = _this$editorProps3.controlBarStyle,
- contentClassName = _this$editorProps3.contentClassName,
- contentStyle = _this$editorProps3.contentStyle,
- stripPastedStyles = _this$editorProps3.stripPastedStyles,
- componentBelowControlBar = _this$editorProps3.componentBelowControlBar;
- var _this$state = this.state,
- isFullscreen = _this$state.isFullscreen,
- editorState = _this$state.editorState;
- editorId = editorId || id;
- hooks = buildHooks(hooks);
- controls = controls.filter(function (item) {
- return excludeControls.indexOf(item) === -1;
- });
- language = (typeof language === 'function' ? language(languages, 'braft-editor') : languages[language]) || languages[configs_props.language];
- var externalMedias = media && media.externals ? objectSpread_default()({}, configs_props.media.externals, media.externals) : configs_props.media.externals;
- var accepts = media && media.accepts ? objectSpread_default()({}, configs_props.media.accepts, media.accepts) : configs_props.media.accepts;
- media = objectSpread_default()({}, configs_props.media, media, {
- externalMedias: externalMedias,
- accepts: accepts
- });
-
- if (!media.uploadFn) {
- media.video = false;
- media.audio = false;
- }
-
- var controlBarProps = {
- editor: this,
- editorState: editorState,
- braftFinder: this.braftFinder,
- ref: function ref(instance) {
- return _this4.controlBarInstance = instance;
- },
- getContainerNode: function getContainerNode() {
- return _this4.containerNode;
- },
- className: controlBarClassName,
- style: controlBarStyle,
- colors: toConsumableArray_default()(colors).concat(toConsumableArray_default()(this.state.tempColors)),
- colorPicker: colorPicker,
- colorPickerTheme: colorPickerTheme,
- colorPickerAutoHide: colorPickerAutoHide,
- hooks: hooks,
- editorId: editorId,
- media: media,
- controls: controls,
- language: language,
- extendControls: extendControls,
- headings: headings,
- fontSizes: fontSizes,
- fontFamilies: fontFamilies,
- emojis: emojis,
- lineHeights: lineHeights,
- letterSpacings: letterSpacings,
- textAligns: textAligns,
- textBackgroundColor: textBackgroundColor,
- allowInsertLinkText: allowInsertLinkText,
- defaultLinkTarget: defaultLinkTarget
- };
- var unitExportFn = editorState.convertOptions.unitExportFn;
- var commonProps = {
- editor: this,
- editorId: editorId,
- hooks: hooks,
- editorState: editorState,
- containerNode: this.containerNode,
- imageControls: imageControls,
- imageResizable: imageResizable,
- language: language,
- extendAtomics: extendAtomics
- };
- var blockRendererFn = getBlockRendererFn(commonProps, this.editorProps.blockRendererFn);
- var blockRenderMap = getBlockRenderMap(commonProps, this.editorProps.blockRenderMap);
- var blockStyleFn = getBlockStyleFn(this.editorProps.blockStyleFn);
- var customStyleMap = getCustomStyleMap(commonProps, this.editorProps.customStyleMap);
- var customStyleFn = getCustomStyleFn(commonProps, {
- fontFamilies: fontFamilies,
- unitExportFn: unitExportFn,
- customStyleFn: this.editorProps.customStyleFn
- });
- var keyBindingFn = keybindings(this.editorProps.keyBindingFn);
- var mixedProps = {};
-
- if (this.state.editorLocked || this.editorProps.disabled || this.editorProps.readOnly || this.editorProps.draftProps.readOnly) {
- mixedProps.readOnly = true;
- }
-
- if (placeholder && fixPlaceholder && editorState.isEmpty() && editorState.getCurrentContent().getFirstBlock().getType() !== 'unstyled') {
- placeholder = '';
- }
-
- var draftProps = objectSpread_default()({
- ref: function ref(instance) {
- _this4.draftInstance = instance;
- },
- editorState: editorState,
- handleKeyCommand: this.handleKeyCommand,
- handleReturn: this.handleReturn,
- handleBeforeInput: this.handleBeforeInput,
- handleDrop: this.handleDrop,
- handleDroppedFiles: this.handleDroppedFiles,
- handlePastedText: this.handlePastedText,
- handlePastedFiles: this.handlePastedFiles,
- onChange: this.onChange,
- onTab: this.onTab,
- onFocus: this.onFocus,
- onBlur: this.onBlur,
- blockRenderMap: blockRenderMap,
- blockRendererFn: blockRendererFn,
- blockStyleFn: blockStyleFn,
- customStyleMap: customStyleMap,
- customStyleFn: customStyleFn,
- keyBindingFn: keyBindingFn,
- placeholder: placeholder,
- stripPastedStyles: stripPastedStyles
- }, this.editorProps.draftProps, mixedProps);
-
- return external_react_default.a.createElement("div", {
- style: style,
- ref: this.setEditorContainerNode,
- className: "bf-container ".concat(className).concat(disabled ? ' disabled' : '').concat(readOnly ? ' read-only' : '').concat(isFullscreen ? ' fullscreen' : '')
- }, external_react_default.a.createElement(ControlBar_ControlBar, controlBarProps), componentBelowControlBar, external_react_default.a.createElement("div", {
- onCompositionStart: this.handleCompositionStart,
- className: "bf-content ".concat(contentClassName),
- onCopy: this.handleCopyContent,
- style: contentStyle
- }, external_react_default.a.createElement(external_draft_js_["Editor"], draftProps)));
- }
- }]);
-
- return BraftEditor;
- }(external_react_default.a.Component);
-
- defineProperty_default()(editor_BraftEditor, "defaultProps", configs_props);
-
-
-
- // EXTERNAL MODULE: external "braft-convert"
- var external_braft_convert_ = __webpack_require__(14);
-
- // CONCATENATED MODULE: ./index.jsx
- /* concated harmony reexport EditorState */__webpack_require__.d(__webpack_exports__, "EditorState", function() { return external_draft_js_["EditorState"]; });
- /* concated harmony reexport getDecorators */__webpack_require__.d(__webpack_exports__, "getDecorators", function() { return getDecorators; });
-
-
-
-
-
-
-
- external_draft_js_["EditorState"].prototype.setConvertOptions = function () {
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- this.convertOptions = options;
- };
-
- external_draft_js_["EditorState"].prototype.toHTML = function () {
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- var convertOptions = this.convertOptions || {};
- return Object(external_braft_convert_["convertEditorStateToHTML"])(this, objectSpread_default()({}, convertOptions, options));
- };
-
- external_draft_js_["EditorState"].prototype.toRAW = function (noStringify) {
- return noStringify ? Object(external_braft_convert_["convertEditorStateToRaw"])(this) : JSON.stringify(Object(external_braft_convert_["convertEditorStateToRaw"])(this));
- };
-
- external_draft_js_["EditorState"].prototype.toText = function () {
- return this.getCurrentContent().getPlainText();
- };
-
- external_draft_js_["EditorState"].prototype.isEmpty = function () {
- return !this.getCurrentContent().hasText();
- };
-
- editor_BraftEditor.createEditorState = external_draft_js_["EditorState"].createFrom = function (content) {
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- options.unitExportFn = options.unitExportFn || editor_BraftEditor.defaultProps.converts.unitExportFn;
- options.styleImportFn = compositeStyleImportFn(options.styleImportFn, options.editorId);
- options.entityImportFn = compositeEntityImportFn(options.entityImportFn, options.editorId);
- options.blockImportFn = compositeBlockImportFn(options.blockImportFn, options.editorId);
- var editorState = null;
-
- if (content instanceof external_draft_js_["EditorState"]) {
- editorState = content;
- } else if (typeof_default()(content) === 'object' && content && content.blocks && content.entityMap) {
- editorState = Object(external_braft_convert_["convertRawToEditorState"])(content, getDecorators(options.editorId));
- } else if (typeof content === 'string') {
- try {
- if (/^(-)?\d+$/.test(content)) {
- editorState = Object(external_braft_convert_["convertHTMLToEditorState"])(content, getDecorators(options.editorId), options, 'create');
- } else {
- editorState = external_draft_js_["EditorState"].createFrom(JSON.parse(content), options);
- }
- } catch (error) {
- editorState = Object(external_braft_convert_["convertHTMLToEditorState"])(content, getDecorators(options.editorId), options, 'create');
- }
- } else if (typeof content === 'number') {
- editorState = Object(external_braft_convert_["convertHTMLToEditorState"])(content.toLocaleString().replace(/,/g, ''), getDecorators(options.editorId), options, 'create');
- } else {
- editorState = external_draft_js_["EditorState"].createEmpty(getDecorators(options.editorId));
- }
-
- options.styleExportFn = compositeStyleExportFn(options.styleExportFn, options.editorId);
- options.entityExportFn = compositeEntityExportFn(options.entityExportFn, options.editorId);
- options.blockExportFn = compositeBlockExportFn(options.blockExportFn, options.editorId);
- editorState.setConvertOptions(options);
- return editorState;
- };
-
- /* harmony default export */ var index_0 = __webpack_exports__["default"] = (createExtensibleEditor(editor_BraftEditor));
- // 2.1版本开发计划
- // [ ]优化选中多行文字是插入链接报错的问题
- // [ ]新增编辑器内图片删除hook
- // 2.2版本开发计划
- // [ ]表格功能
- // [ ]美化UI,包括图标和界面风格
- // 2.3版本开发计划
- // [ ]初级md快捷输入支持
- // [ ]图片裁切等简单的编辑功能
- // [ ]允许自定义快捷键
-
- /***/ }),
- /* 40 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
- /* 41 */,
- /* 42 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
- /* 43 */,
- /* 44 */,
- /* 45 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
- /* 46 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
- /* 47 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
- /* 48 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
- /* 49 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
- /* 50 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
- /* 51 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
- /* 52 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
- /* 53 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
- /* 54 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
- /* 55 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
- /* 56 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
- /* 57 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
- /* 58 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
- /* 59 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
- /* 60 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
- /* 61 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
- /* 62 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
- /* 63 */
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ })
- /******/ ]);
- });
-
- });
-
- var BraftEditor = unwrapExports(dist$3);
-
- var css = ".index_bf-controlbar__ej8fA{margin:0;padding:0 5px;box-shadow:inset 0 -1px 0 0 rgba(0,0,0,.2)}.index_bf-controlbar__ej8fA:after{display:block;content:\"\";clear:both}.index_bf-controlbar__ej8fA button{padding:0;outline:none}.index_bf-controlbar__ej8fA button[disabled]{pointer-events:none;opacity:.3}.index_bf-controlbar__ej8fA [data-title]{position:relative}.index_bf-controlbar__ej8fA [data-title]:after,.index_bf-controlbar__ej8fA [data-title]:before{position:absolute;z-index:10;top:100%;left:50%;pointer-events:none;opacity:0;transform:translateX(-50%) translateY(-5px);transition:opacity .3s,transform .3s}.index_bf-controlbar__ej8fA [data-title]:before{margin-top:3px;border:5px solid transparent;border-bottom-color:#21242a;content:\"\"}.index_bf-controlbar__ej8fA [data-title]:after{margin-top:12px;padding:5px;background-color:#21242a;border-radius:2px;box-shadow:0 5px 15px rgba(0,0,0,.2);color:#fff;font-size:12px;line-height:16px;white-space:nowrap;content:attr(data-title)}.index_bf-controlbar__ej8fA [data-title]:hover:after,.index_bf-controlbar__ej8fA [data-title]:hover:before{opacity:1;transform:translateX(-50%) translateY(0)}.index_bf-controlbar__ej8fA input{outline:none}.index_bf-controlbar__ej8fA .index_separator-line__3SV92{display:block;float:left;height:26px;width:1px;margin:10px;box-shadow:inset -1px 0 0 0 rgba(0,0,0,.1)}.index_bf-controlbar__ej8fA .index_separator-line__3SV92+.index_control-item__2E9Ul,.index_bf-controlbar__ej8fA .index_separator-line__3SV92+.index_control-item-group__2GENZ{margin-left:0}.index_bf-controlbar__ej8fA .index_separator-line__3SV92+.index_separator-line__3SV92,.index_bf-controlbar__ej8fA .index_separator-line__3SV92.index_first-child__2fRfM,.index_bf-controlbar__ej8fA .index_separator-line__3SV92.index_last-child__1d0yb{display:none}.index_bf-controlbar__ej8fA .index_control-item-group__2GENZ{float:left;height:36px;margin:5px 0 5px 3px}.index_bf-controlbar__ej8fA .index_control-item-group__2GENZ:first-child{margin-left:0}.index_bf-controlbar__ej8fA .index_control-item-group__2GENZ>.index_control-item__2E9Ul{margin-top:0;margin-bottom:0}.index_bf-controlbar__ej8fA .index_dropdown-handler__1xChS{border-radius:2px}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul{display:block;float:left;height:36px;margin:5px 0 5px 3px;border-radius:2px;cursor:pointer}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_component-wrapper__OLlmp{cursor:default}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul:first-child{margin-left:0}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_button__2IaUw{box-sizing:border-box;min-width:36px;padding:0 8px;background-color:transparent;border:none;color:#6a6f7b;font-size:14px}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_button__2IaUw:hover{background-color:rgba(0,0,0,.05)}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_button__2IaUw.index_active__3_mlp{color:#3498db}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_button__2IaUw i:before{display:block;height:36px;font-size:18px;line-height:36px}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_button__2IaUw .index_bfi-redo__1Q-LG:before,.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_button__2IaUw .index_bfi-undo___pDce:before{font-size:14px}.index_bf-controlbar__ej8fA .index_dropdown__1rkgF .index_control-item__2E9Ul{width:100%;float:none;margin:0}.index_DraftEditor-editorContainer__1FR0o,.index_DraftEditor-root__mlfOI,.index_public-DraftEditor-content__T2mZu{height:inherit;text-align:initial}.index_public-DraftEditor-content__T2mZu[contenteditable=true]{-webkit-user-modify:read-write-plaintext-only}.index_DraftEditor-root__mlfOI{position:relative}.index_DraftEditor-editorContainer__1FR0o{background-color:hsla(0,0%,100%,0);border-left:.1px solid transparent;position:relative;z-index:1}.index_public-DraftEditor-block__IOQ0s{position:relative}.index_DraftEditor-alignLeft__gR9_E .index_public-DraftStyleDefault-block__3m05I{text-align:left}.index_DraftEditor-alignLeft__gR9_E .index_public-DraftEditorPlaceholder-root__1T6lJ{left:0;text-align:left}.index_DraftEditor-alignCenter__3Fyko .index_public-DraftStyleDefault-block__3m05I{text-align:center}.index_DraftEditor-alignCenter__3Fyko .index_public-DraftEditorPlaceholder-root__1T6lJ{margin:0 auto;text-align:center;width:100%}.index_DraftEditor-alignRight__3ghf4 .index_public-DraftStyleDefault-block__3m05I{text-align:right}.index_DraftEditor-alignRight__3ghf4 .index_public-DraftEditorPlaceholder-root__1T6lJ{right:0;text-align:right}.index_public-DraftEditorPlaceholder-root__1T6lJ{color:#9197a3;position:absolute;z-index:1}.index_public-DraftEditorPlaceholder-hasFocus__kQoHC{color:#bdc1c9}.index_DraftEditorPlaceholder-hidden__22I_U{display:none}.index_public-DraftStyleDefault-block__3m05I{position:relative;white-space:pre-wrap}.index_public-DraftStyleDefault-ltr__3qMdW{direction:ltr;text-align:left}.index_public-DraftStyleDefault-rtl__2k3sG{direction:rtl;text-align:right}.index_public-DraftStyleDefault-listLTR__Mmamr{direction:ltr}.index_public-DraftStyleDefault-listRTL__2WhLE{direction:rtl}.index_public-DraftStyleDefault-ol__32plX,.index_public-DraftStyleDefault-ul__1_opE{margin:16px 0;padding:0}.index_public-DraftStyleDefault-depth0__2YvNJ.index_public-DraftStyleDefault-listLTR__Mmamr{margin-left:1.5em}.index_public-DraftStyleDefault-depth0__2YvNJ.index_public-DraftStyleDefault-listRTL__2WhLE{margin-right:1.5em}.index_public-DraftStyleDefault-depth1__3dbfg.index_public-DraftStyleDefault-listLTR__Mmamr{margin-left:3em}.index_public-DraftStyleDefault-depth1__3dbfg.index_public-DraftStyleDefault-listRTL__2WhLE{margin-right:3em}.index_public-DraftStyleDefault-depth2__2mADP.index_public-DraftStyleDefault-listLTR__Mmamr{margin-left:4.5em}.index_public-DraftStyleDefault-depth2__2mADP.index_public-DraftStyleDefault-listRTL__2WhLE{margin-right:4.5em}.index_public-DraftStyleDefault-depth3__1V80Q.index_public-DraftStyleDefault-listLTR__Mmamr{margin-left:6em}.index_public-DraftStyleDefault-depth3__1V80Q.index_public-DraftStyleDefault-listRTL__2WhLE{margin-right:6em}.index_public-DraftStyleDefault-depth4__9Zzf6.index_public-DraftStyleDefault-listLTR__Mmamr{margin-left:7.5em}.index_public-DraftStyleDefault-depth4__9Zzf6.index_public-DraftStyleDefault-listRTL__2WhLE{margin-right:7.5em}.index_public-DraftStyleDefault-unorderedListItem__fNkjl{list-style-type:square;position:relative}.index_public-DraftStyleDefault-unorderedListItem__fNkjl.index_public-DraftStyleDefault-depth0__2YvNJ{list-style-type:disc}.index_public-DraftStyleDefault-unorderedListItem__fNkjl.index_public-DraftStyleDefault-depth1__3dbfg{list-style-type:circle}.index_public-DraftStyleDefault-orderedListItem__3J0MZ{list-style-type:none;position:relative}.index_public-DraftStyleDefault-orderedListItem__3J0MZ.index_public-DraftStyleDefault-listLTR__Mmamr:before{left:-36px;position:absolute;text-align:right;width:30px}.index_public-DraftStyleDefault-orderedListItem__3J0MZ.index_public-DraftStyleDefault-listRTL__2WhLE:before{position:absolute;right:-36px;text-align:left;width:30px}.index_public-DraftStyleDefault-orderedListItem__3J0MZ:before{content:counter(a) \". \";counter-increment:a}.index_public-DraftStyleDefault-orderedListItem__3J0MZ.index_public-DraftStyleDefault-depth1__3dbfg:before{content:counter(b) \". \";counter-increment:b}.index_public-DraftStyleDefault-orderedListItem__3J0MZ.index_public-DraftStyleDefault-depth2__2mADP:before{content:counter(c) \". \";counter-increment:c}.index_public-DraftStyleDefault-orderedListItem__3J0MZ.index_public-DraftStyleDefault-depth3__1V80Q:before{content:counter(d) \". \";counter-increment:d}.index_public-DraftStyleDefault-orderedListItem__3J0MZ.index_public-DraftStyleDefault-depth4__9Zzf6:before{content:counter(e) \". \";counter-increment:e}.index_public-DraftStyleDefault-depth0__2YvNJ.index_public-DraftStyleDefault-reset__1awm7{counter-reset:a}.index_public-DraftStyleDefault-depth1__3dbfg.index_public-DraftStyleDefault-reset__1awm7{counter-reset:b}.index_public-DraftStyleDefault-depth2__2mADP.index_public-DraftStyleDefault-reset__1awm7{counter-reset:c}.index_public-DraftStyleDefault-depth3__1V80Q.index_public-DraftStyleDefault-reset__1awm7{counter-reset:d}.index_public-DraftStyleDefault-depth4__9Zzf6.index_public-DraftStyleDefault-reset__1awm7{counter-reset:e}.index_bf-switch__1LPr-{position:relative;width:32px;height:16px;background-color:hsla(0,0%,100%,.15);border-radius:8px;transition:background .3s}.index_bf-switch__1LPr-.index_active__3_mlp{background-color:#3498db}.index_bf-switch__1LPr-.index_active__3_mlp:before{left:16px}.index_bf-switch__1LPr-:before{position:absolute;left:0;display:block;width:16px;height:16px;border-radius:8px;background-color:#eee;content:\"\";transform:scale(1.2);transition:.3s}@font-face{font-family:braft-icons;src:url(data:application/font-woff;base64,d09GRgABAAAAACxUAAsAAAAALAgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABPUy8yAAABCAAAAGAAAABgDxIH02NtYXAAAAFoAAAA9AAAAPQXCcwWZ2FzcAAAAlwAAAAIAAAACAAAABBnbHlmAAACZAAAJggAACYI9aImY2hlYWQAAChsAAAANgAAADYTSfwFaGhlYQAAKKQAAAAkAAAAJAfCBAxobXR4AAAoyAAAASwAAAEsIgAgXGxvY2EAACn0AAAAmAAAAJhQxVqgbWF4cAAAKowAAAAgAAAAIABVAH1uYW1lAAAqrAAAAYYAAAGGmUoJ+3Bvc3QAACw0AAAAIAAAACAAAwAAAAMD+QGQAAUAAAKZAswAAACPApkCzAAAAesAMwEJAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAQAAA6rADwP/AAEADwABAAAAAAQAAAAAAAAAAAAAAIAAAAAAAAwAAAAMAAAAcAAEAAwAAABwAAwABAAAAHAAEANgAAAAyACAABAASAAEAIOAp4DTgN+BC4LjiKOI547jjwuQp6SbpMelG6WjpgOms6mjqbOpu6nXqsP/9//8AAAAAACDgJuA04DfgQuC44ijiOeO448LkKekA6SzpRuln6YDprOpo6mvqbupz6rD//f//AAH/4x/eH9Qf0h/IH1Md5B3UHFYcTRvnFxEXDBb4FtgWwRaWFdsV2RXYFdQVmgADAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAH//wAPAAEAAAAAAAAAAAACAAA3OQEAAAAAAQAAAAAAAAAAAAIAADc5AQAAAAABAAAAAAAAAAAAAgAANzkBAAAAAAQAVQCAA6sC1QARACMANQBHAAATITIXFhUUBwYjISInJjU0NzYTITIXFhUUBwYjISInJjU0NzY3ITIXFhUUBwYjISInJjU0NzY3ITIXFhUUBwYjISInJjU0NzaAAwASDA0NDBL9ABIMDQ0MEgMAEgwNDQwS/QASDA0NDBIDABIMDQ0MEv0AEgwNDQwSAwASDA0NDBL9ABIMDQ0MAtUMDRESDQwMDRIRDQz+AAwNERINDAwNEhENDKsNDBIRDQwMDRESDA2rDQwSEgwNDQwSEgwNAAAABABVAIADqwLVABEAIwA1AEcAABMhMhcWFRQHBiMhIicmNTQ3NhMhMhcWFRQHBiMhIicmNTQ3NjchMhcWFRQHBiMhIicmNTQ3NjchMhcWFRQHBiMhIicmNTQ3NoADABIMDQ0MEv0AEgwNDQwSAlUSDA0MDRL9qxIMDQ0MEgMAEgwNDQwS/QASDA0NDBICVRIMDQwNEv2rEgwNDQwC1QwNERINDAwNEhENDP4ADA0REg0MDA0SEQ0Mqw0MEhENDAwNERIMDasNDBISDA0NDBISDA0AAAAEAFUAgAOrAtUAEQAkADYASQAAEyEyFxYVFAcGIyEiJyY1NDc2EyEyFxYVFAcGIyEiJyY1NDc2MychMhcWFRQHBiMhIicmNTQ3NjchMhcWFRQHBiMhIicmNTQ3NjOAAwASDA0NDBL9ABIMDQ0MZwJWEQ0MDA0R/aoRDQwMDRFVAwASDA0NDBL9ABIMDQ0MZwJWEQ0MDA0R/aoRDQwMDREC1QwNERINDAwNEhENDP4ADA0REg0MDA0SEQ0Mqw0MEhENDAwNERIMDasNDBISDA0NDBISDA0AAAAEAFUAgAOrAtUAEQAkADYASQAAEyEyFxYVFAcGIyEiJyY1NDc2EyEyFxYVFAcGIyEiJyY1NDc2MychMhcWFRQHBiMhIicmNTQ3NjchMhcWFRQHBiMhIicmNTQ3NjOAAwASDA0NDBL9ABIMDQ0MvQJVEgwNDQwS/asSDA0MDRKrAwASDA0NDBL9ABIMDQ0MvQJVEgwNDQwS/asSDA0MDRIC1QwNERINDAwNEhENDP4ADA0REg0MDA0SEQ0Mqw0MEhENDAwNERIMDasNDBISDA0NDBISDA0AAAACAQAAgQMAAtUAAwAHAAABMxEjIREzEQJWqqr+qqoC1f2sAlT9rAAAAQFWAIEDKgLVAAIAAAkCAVYB1P4sAtX+1v7WAAEAqgArA1YDgQAuAAABMhceARcWFRQHDgEHBiMiJy4BJyY1MxQXHgEXFjMyNz4BNzY1NCcuAScmIxUnNwIARj8+XRsbGxtdPj5HRj8+XRsbVhQURS8vNTUvL0UUFBQURS8vNdbWAtUbG1w+PkZHPj5dGxsbG10+Pkc2Li9FFBQUFEUvLjY1Ly5GFBSs1tYAAAMAMwCqA80CqwAEAAkADQAAEyEVITUDNSEVITc1IRX/As79MswCzv0yaALKAqtnZ/3/Z2fOZWUABQCAACsDgAMrAAMABwALAA8AEwAAAREhEQERIREDESERAREhEQMhESEDKv8AAQD/AFT/AAEA/wBWAwD9AAHVAQD/AP6sAQD/AAFUAQD/AP6sAQD/AAKq/QAAAAACAFYAKwNWAtUACAARAAABIRUjByc3IycnFwEHJwcjNwEBAAJW+ERaHmZ4dAwCaDbyQoBo/tgC1YCgWEh4CAr9ljbynPYBKAACAIAAKwN0Ax8AAwAWAAAlAScBAR4BDwEXBycBIzUBJzcXNzYyFwEoAVhS/qgCngwBDYZSPDz+gsoBfDw8UoYMJAyBAVhS/qgB6AwjDYZSPDz+hMoBfjw8UoYMDAAAAAAEAIAAKwOAAysACAARABoAIwAAATIWHQEjNSM1EzUzFRQGKwE1JRUzFSMiJj0BETQ2OwEVIxUjAyoiNFaqqlYzI6r+VqqqIjQzI6qqVgMrNCKqqlb9VqqqIzNWqqpWMyOqAaoiNFaqAAYAgAArA4ADKwAHAAsAEwAbAB8AIwAAAREzFTMVIxUXITUhJTMRIzUjNTMBIxEzFSEVIQEhFSERIRUhAoBWqqqq/lYBqv2qVlaqqgEAVFQBVv6q/lYBqv5WAQD/AAIrAQBWVFaqVFb/AFZU/lYBAFZUAlRU/lRUAAIAgABNA4ADTQATAB0AACUhESE1ISIGFREUFjMhMjY1ESMRAxUzARcBFTMRIQMr/aoBK/7VIzIyIwJWIzJV1pr+XDwBpFX+1aICVVYyJP2rIzIyIwEr/tUCq1b+XTwBo5kBKwAEAFUAIgOrA3cABAAhAD0AQgAAJTMRIxETIgcOAQcGFRQXHgEXFjMyNz4BNzY1NCcuAScmIxEiJy4BJyY1NDc+ATc2MzIXHgEXFhUUBw4BBwYDMzUjFQHVVlYrWE5OdCEiIiF0Tk5YWE5OdCEiIiF0Tk5YRz4+XRobGxpdPj5HRz4+XRobGxpdPj5yVlb3AQD/AAKAISJzTk5YWU1OdCEiIiF0Tk1ZWE5OcyIh/QAbG10+PkdGPz5cGxsbG1w+P0ZHPj5dGxsB1lVVAAAEAFUAIgOrA3cABAAhAD0AUgAAJTM1IxUTIgcOAQcGFRQXHgEXFjMyNz4BNzY1NCcuAScmIxEiJy4BJyY1NDc+ATc2MzIXHgEXFhUUBw4BBwYDIgYVMzQ2MzIWFRQGFTM0NjU0JiMB1VZWK1hOTnQhIiIhdE5OWFhOTnQhIiIhdE5OWEc+Pl0aGxsaXT4+R0c+Pl0aGxsaXT4+R0dkVjIjIzKAVoBkR81VVQKqISJzTk5YWU1OdCEiIiF0Tk1ZWE5OcyIh/QAbG10+PkdGPz5cGxsbG1w+P0ZHPj5dGxsCVmRHIzIyI0AtaEg9UEdkAAACAFUAzQOrAs0ABQALAAABJzcnCQElNyc3CQEBkcTEPP8AAQABGsTEPAEA/wABCcTEPP8A/wA8xMQ8/wD/AAAAAwErAM0C9QMiAA8AGQAiAAABPgE1NCYjIREhMjY1NCYnJzMyFhUUBisBNRMjNTMyFhUUBgKaHydjSP72ASxDWzIp74AaJiYagJWVlRslJQIAFkEgSWL9q19DME4TtyUbGiaA/oCAJRsaJgAAAQCAACYDgAN3ADQAAAEiBgclPgE1NCYnJR4BMzI2NTQmIyIGFRQWFwUuASMiBhUUFjMyNjcFDgEVFBYzMjY1NCYjAwAYKxH+0AICAgIBLREtGTVLSzU1SwIC/tMRLRk1S0s1GS0RATACAkk0NElJNAEfEg+xBw8IBw8IrxATSzU2Sko2Bw8HsBATSzU1SxIQsQcOBzNJSTM0SQAAAQErAU0C1QIiAAIAAAEXNwEr1dUCItXVAAAAAAMAVQAiA6sDdwAcACsAOgAAASIHDgEHBhUUFx4BFxYzMjc+ATc2NTQnLgEnJiMBNDc+ATc2MzIWFwEuATUBIiYnAR4BFRQHDgEHBiMCAFhOTXQiIiIidE1OWFhOTXQiIiIidE1OWP6rGxtcPj9GOmot/iIjJQFVOmotAd4jJRsbXD4/RgN3ISJ0Tk1YWE5OdCEiIiF0Tk5YWE1OdCIh/lZGPj5dGxslI/4iLWo6/qomIwHeLWs5Rz4+XRsbAAAAAAMAgADNA4ACzQADAAcACwAANyE1ITUhNSE1FSE1gAMA/QADAP0AAwDNVYBV1lZWAAEBKwF3AtUCTQACAAABNxcBK9XVAXfW1gAAAAADAasAdwJVAyIADAAYACQAAAEyNjU0JiMiBhUUFjMVIgYVFBYzMjY1NCYDIgYVFBYzMjY1NCYCACMyMiMjMjIjIzIyIyMyMiMjMjIjIzIyAnczIyMyMiMjM1UyIyMzMyMjMv8AMiMjMzMjIzIAAAAAAwCrAXcDVQIiAAwAGAAkAAABIgYVFBYzMjY1NCYjISIGFRQWMzI2NTQmISIGFRQWMzI2NTQmAQAjMjIjIzIyIwIAIzIyIyMyMv7dIzIyIyMyMgIiMiMjMzMjIzIyIyMzMyMjMjIjIzMzIyMyAAAAAAIAAP/ABAADgAApAC0AAAERIzU0JiMhIgYdARQWMyEyNj0BMxEhFSMiBhURFBY7ATI2NRE0JisBNQEhNSEEAMAmGv1AGiYmGgLAGiaA/cAgDRMTDYANExMNIAFA/UACwAGAAYBAGiYmGsAaJiYaQP8AgBMN/sANExMNAUANE0ABgEAAAAQA1QCiAysC9wAGAA0AEwAaAAATMxUzNSMVEyMVMzUjFQEzNTM1IxM1IxUzNSPVgFbWgIDWVgEAVoDWVlbWgAEigNVVAVVV1YD+K4BVAQCA1VUAAAEAZAAlA1wDXABEAAABERQHBgcGBwYjIicmJyYnJjU0NzY3Njc2MzIXEQURFAcGBwYHBiMiJyYnJicmNTQ3Njc2NzYzMhcRNDc2NyU2MzIXFhUDXBERGhkaGRYXGRoZGhEREREaGRoZFzMr/oURERoZGhkXFhkaGRoRERERGhkaGRY0KwoJDwGbBggUDg4DLP3WGBQTCgsFBQUFCwoTFBgZExQKCwUFEwEKdv6iGRMTCwsFBQUFCwsTExkZExMLCgYFEwHeDw0MBX8CDg4UAAAEAHUAQgOJA1YALwA8AGIAeAAAAS4BBw4BJy4BJy4BBwYiJyYGBw4BJyYGBxQVHAEVFBUeATM2MzoBMzIzMjY3PAE1BSImNTQ2MzIWFRQGJyUqASM8ATU6ATMUFhUUFxwBFQYHFAYHDgEnLgE3PgE3OgEzPAE1BT4BNzoBMxQWBw4BJy4BNz4BNzoBMwKBARkZChUJCxcEFEMvBw8HHikMDCgdFyILCxgWNDM0ZzQzNBsaAf77L0FBMDBAQDEBtx8/IDRoNgEBAQENCxVFICIlBgc3JAcNCf7OAQICEyQTAwUFSiMmOAIBOiYHEAkCzhcaAQEBAwIJCC0fCAEBBhgbGxYGBBMVKCgpUCgoKQ8VARcaSpRK7T8uMEA/LzBAARchPyAKEgkzMjNmMjMzFCwRIBAOD0IjJjQDN2053QwUCi5dLSUsBgVEJig+BAAAAAAEANUAogMrAvcABQALABEAFwAAASMVMzUjAzM1MzUjASMVMzUjAxUzFTM1AStW1oBWVoDWAgCA1laAgFYBd9VVASuAVf4AVdUBgFWA1QAAAAQAAAAABAADQAAbADMATwBTAAABFBceARcWMzI3PgE3NjU0Jy4BJyYjIgcOAQcGASMuASMhIgYHIyIGFREUFjMhMjY1ETQmASInLgEnJjU0Nz4BNzYzMhceARcWFRQHDgEHBgEjNTMBMBAROCYmKysmJjgREBAROCYmKysmJjgREAKQ4AwkMP8AMCQM4BomJhoDgBomJv4mOzQzTRcWFhdNMzQ7OzQzTRcWFhdNMzQBhYCAAWArJiY4ERAQETgmJisrJiY4ERAQETgmJgE1MFBQMCYa/cAaJiYaAkAaJv2EFhdNMzQ7OzQzTRcWFhdNMzQ7OzQzTRcWAbxAAAEAkQCiA4AC3gAGAAABJwcXAScBAYCzPO8CADz+PAEaszzvAgA8/jwAAAAAAQDiAIADHgLJACYAAAE3NjQnJiIPAScmIgcGFB8BBwYUFx4BMzI2PwEXHgEzMjY3NjQvAQI84g0NDCQM4uIMJAwNDeLiDQ0GEAgIEAbi4gYQCAgQBg0N4gGr4gwjDQwM4uIMDA0jDOLiDSMMBwYGB+HhBwYGBwwjDeIAAAUAVQCVA6sC6wAZACoARABeAHgAAAEhIgYHDgEVFBYXHgEzITI2Nz4BNTQmJy4BJTQmIyEiBh0BFBYzITI2PQEDISIGBw4BFRQWFx4BMyEyNjc+ATU0JicuAQMhIgYHDgEVFBYXHgEzITI2Nz4BNTQmJy4BBSEiBgcOARUUFhceATMhMjY3PgE1NCYnLgEB1f6rCQ8GBgcHBgYPCQFVCQ8GBwYGBwYPAc0ZEv8AEhkZEgEAEhkr/QAJDwYGBwcGBg8JAwAJDwYGBwcGBg8J/QAJDwYGBwcGBg8JAwAJDwYGBwcGBg/+TP6rCQ8GBgcHBgYPCQFVCQ8GBwYGBwYPAZUGBgYQCAkPBgcGBgcGDwkIEAYGBoERGRkRrBEZGRGs/tUHBgYPCQkPBgYHBwYGDwkJDwYGBwIABwYGDwkJDwYGBwcGBg8JCQ8GBgerBgcGDwkIEAYGBgYGBhAICQ8GBwYAAAAABABVAE0DqwNNAA4AEgAeACIAAAEhIgYVETMVITUzETQmIwMhNSE3IiY1NDYzMhYVFAYDIRUhAyv9qjVLqwIAq0s1gP6qAVaAEhkZEhEZGTz+AAIAAndKNv8AqqoBADZK/ivVVhkREhkZEhEZAYCrAAIAgABjA2oDTQAiAC8AAAEjJz4BNTQnLgEnJiMiBw4BBwYVFBceARcWMzI2NxcVFzcnISImNTQ2MzIWFRQGIwKVIQwfJBYWSzMyOjkzMksWFhYWSzIzOTRcJQvWP9X/AE9xcU9QcHBQAXcMJF0zOjIzSxYWFhZLMzI6OTIzSxYWJB8MItQ/1XFPUHBwUE9xAAIAZAAiA5wDdwBNAFkAAAE+ATU0Jic3PgEvAS4BDwEuAS8BLgErASIGDwEOAQcnJgYPAQYWHwEOARUUFhcHDgEfAR4BPwEeAR8BHgE7ATI2PwE+ATcXFjY/ATYmJwUiJjU0NjMyFhUUBgM9AQICAVoGAwRVBA8HahEkFBABDAiqCAwBEBQkEWoHDwRVBAMGWgECAgFaBgMEVQQPB2oRJBQQAQwIqggMARAUJBFqBw8EVQQDBv5pPldXPj5XVwGjChULCxQLRgUPB5QHBQMqDBUIcgcKCgdyCBUMKgMFB5QHDwVGCxUKCxUKRgUQB5MHBQIrDRUIcQgKCghxCBUNKwMGB5MHEAUmWD4+V1c+PlgAAQDVAKIDKwL3AAsAAAEhESMRITUhETMRIQMr/wBW/wABAFYBAAGi/wABAFUBAP8AAAAAAAQAVf/vA6sC7wAeADMAOAA9AAATNwEHJyM1JyM1Jw4BFRQWOwEVIyInLgEnJjU0NjcnBTIXHgEXFhUUBgcnPgE1NCYrATUzITMVIycFFSMnM1U3Ask2q0mMSmogJWdIgIA1Li9FFRQyKlwCVjUuL0UVFEc5PC88Z0iAgP6qgDZRAV0zVYgCuTb9NzerSYxKaxhIKklmURQURS8vNTpnIlwfFRRFLy41R3YhPRRWN0hnUVFR1lVVAAADAFUAmgOrApoAGgA1ADkAAAEjFTMyFhUUBisBFTMyNz4BNzY1NCcuAScmIwE0NjsBNSMiBw4BBwYVFBceARcWOwE1IyImNRchNSECq4CASGdnSICANS4vRRUUFBVFLy41/ftnSICANS4vRRUUFBVFLy41gIBIZ68BVv6qAppRZ0hJZlEUFEUvLzU1Li9FFRT/AEhnURUURS8uNTUvL0UUFFFmSStVAAAFAFUAIgOrA3cAHAA4AEQAUABYAAABIgcOAQcGFRQXHgEXFjMyNz4BNzY1NCcuAScmIxEiJy4BJyY1NDc+ATc2MzIXHgEXFhUUBw4BBwYTMjY1NCYjIgYVFBYhMjY1NCYjIgYVFBYTMjY3IR4BMwIAWU1OdCEiIiF0Tk1ZWE5OdCEiIiF0Tk5YRz4+XRsaGhtdPj5HRz4+XRsaGhtdPj5OGyUlGxomJv7wGiYmGhslJbBLdRr+TBp1SwN3ISJzTk5YWU1OdCEiIiF0Tk1ZWE5OcyIh/QAbG10+PkdHPj5dGhsbGl0+PkdHPj5dGxsBgCYaGyUlGxomJhobJSUbGib+61RBQVQAAAAJAAAAQAQAA0AAAwAHAAsADwATABcAGwAfACIAABMRIREBIzUzNSM1MzUjNTMBIREhEyM1MzUjNTM1IzUzBRElAAQA/MCAgICAgIACQP4AAgDAgICAgICA/cABAANA/QADAP1AgICAgID9gAKA/YCAgICAgID+gMAAAAAAAgDVAE0DKwNNABkAHgAAJTI3PgE3NjURIxEUBiMiJjURIxEUFx4BFxYHFSE1IQIANS8uRhQUa1c+PldrFBRGLi/2Alb9qvcVFEUvLzQBVv6qPVhYPQFW/qo0Ly9FFBVVVVUAAAUAVQCVA6sC6wAaACsARQBfAHoAAAEhMhYXHgEVFAYHDgEjISImJy4BNTQ2Nz4BMyU0NjMhMhYdARQGIyEiJj0BEyEyFhceARUUBgcOASMhIiYnLgE1NDY3PgETITIWFx4BFRQGBw4BIyEiJicuATU0Njc+AQUhMhYXHgEVFAYHDgEjISImJy4BNTQ2Nz4BMwIrAVUJDwYGBwcGBg8J/qsJDwYHBgYHBg8J/ioZEgEAEhkZEv8AEhkrAwAJDwYGBwcGBg8J/QAJDwYGBwcGBg8JAwAJDwYGBwcGBg8J/QAJDwYGBwcGBg8BtAFVCQ8GBgcHBgYPCf6rCQ8GBwYGBwYPCQGVBgYGEAgJDwYHBgYHBg8JCBAGBgaBERkZEawRGRkRrP7VBwYGDwkJDwYGBwcGBg8JCQ8GBgcCAAcGBg8JCQ8GBgcHBgYPCQkPBgYHqwYHBg8JCBAGBgYGBgYQCAkPBgcGAAAAAAMAgACiA4ADIgAEAA0AEQAAJTM1IxUDFTMVMzUzNSEDITUhAauqqtbWqtb9qlUDAP0AooCAAoCAgICA/lVWAAACAIAAogOrAyIACAARAAABFTMRMxEzNSEBMxEzETM1IRUBgNWA1v3V/wCAgID+gAMigP4AAgCA/qv+1QErgIAAAgDVAPcDKwKiAAYADQAAJTM3ESERMwUzNxEhETMBAIBV/wCAAQCAVv8AgPerAQD/AKurAQD/AAAGAFUAdwOAAyIACwASAB0AIgAnACwAADczFSMVMxUjFTM1IxMzNSMVMxUHMwcVMzUjNzUjFRMVITUhESE1IRURITUhFVVWKytWgIArK1YrK01NgExMgNYCVf2rAlX9qwJV/av3FSsVK6sBVasrgIBZJytaJisBAFVV/atVVQEAVVUAAAAGAGsAjQOAAw0ACwAXACMAKAAtADIAABMiBhUUFjMyNjU0JgMiBhUUFjMyNjU0JgMiBhUUFjMyNjU0JhchNSEVESE1IRURFSE1IasbJSUbGiYmGhslJRsaJiYaGyUlGxomJmYCVf2rAlX9qwJV/asCDSYaGyUlGxomAQAmGhslJRsaJv4AJhoaJiYaGiZrVVUBAFVVAVVVVQAAAAABAQAAzQMAAyIACwAAARUzAyMVITUjEzM1AatekncBVV6SdwMigP6rgIABVYAAAAABAAABawQAAesAAwAAEyEVIQAEAPwAAeuAAAAABgBA/8ADwAPAABkAIQA5AEcAVQBjAAABLgEnLgEnLgEjISIGFREUFjMhMjY1ETQmJyceARcjNR4BExQGIyEiJjURNDYzMDM6ATMyMRUUFjsBAyEiJjU0NjMhMhYVFAYnISImNTQ2MyEyFhUUBichIiY1NDYzITIWFRQGA5YRLRkaMxcnKQv+ECEvLyEC4CEvDhyFFyUNmhEphgkH/SAHCQkHTU66TU4TDeCg/kANExMNAcANExMN/kANExMNAcANExMN/kANExMNAcANExMC2xczGhktERwOLyH8oCEvLyECcAspJzYXKRGaDSX86AcJCQcDYAcJ4A0T/gATDQ0TEw0NE4ATDQ0TEw0NE4ATDQ0TEw0NEwAAAAUAAP/ABAADwAAIAAsAEwAWABwAAAERIQcRIREhESUVIwMRMzUhFQcRExUjASERMzUhAoD+QMABgAKA/MBlG8ABQMDAZQHl/gDAAUACwAEAwP3A/wADAKVl/gABwMDAwP8AAWVl/gABwMAAAAUAQP/ABAADwAANABgANAA3AD0AAAEjNTQmKwEiBh0BIxUhJyM1OAExMzgBMRUFNTQmKwEVMxUjBxEhETM1IyIGFREUFjMhFSERBRUjASERMzUhAsCAJhqAGiaAAgDAgIABQBMNQCDAwP8AIEANExMNASACgP5AZQHl/gDAAUADQEAaJiYaQICAQEDAoA0TQIDA/wACQEATDf2ADRPAAsBbZf5AAYDAAAYAgABNA4ADTQADAAcACwAPABMAFwAANyE1IRkBNycBITUhARUhNQEhNSERITUhgAMA/QCrqwFVAav+Vf6rAwD+VQGr/lUBq/5VTVUB1f6rq6r+gFYCAFZW/wBV/wBVAAYAgABNA4ADTQADAAcACwAPABMAFwAAJSE1ISUXEQcRITUhERUhNQEhNSERITUhAdUBq/5V/qurqwMA/QADAP5VAav+VQGr/lX3VoCrAVWq/oBVAqtWVv8AVf8AVQAAAAEAAP/NBAAAdwADAAA3IRUhAAQA/AB3qgAAAAACAOsA9wMVA00ACAAMAAABAzM3IRczAyMDGwEjAdXqYC8BCzBg6lY7ZmbMA039qoCAAlb+gAEO/vIAAAACAAD/wAQAA8AADgASAAABBxcDIxcBFTMBFzUlFzcFJzcXAiBgYODgsP7wJwFpsAEAYGD9wEDgQAPAYGD/ALD+lycBELDg4GBgQEDgQAAAAAEAQP/AA4oDwAARAAAFNjc2JicmBxUJARU2Fx4BBwYC+isTEzhVVqj+gAGAyXFyRignQE1bW5ozMgT+AYABgPgFTk7siokAAAEAdv/AA8ADwAASAAABNQkBNSYHDgEXFhcmJyY2NzYXAkABgP6AqFZVOBMTK2knKEZycckCyPj+gP6A/gQyM5pbW01yiYrsTk4FAAAHAAD/wAQAA0YACwAXACMALwA7AEcAUwAAJTQ2MzIWFRQGIyImATQ2MzIWFRQGIyImJTQ2MzIWFRQGIyImATQ2MzIWFRQGIyImATQ2MzIWFRQGIyImJTQ2MzIWFRQGIyImATQ2MzIWFRQGIyImAaA4KCg4OCgoOP5gOCgoODgoKDgDQDgoKDg4KCg4/To4KCg4OCgoOAJMOCgoODgoKDj9tDgoKDg4KCg4Akw4KCg4OCgoOCAoODgoKDg4AcgoODgoKDg4KCg4OCgoODgBTig4OCgoODj93Cg4OCgoODgoKDg4KCg4OAJ0KDg4KCg4OAAFAHwAAAOEA1UAIgAtADgARgBUAAABIzU0JisBIgYdASMiBhUUFjsBERQWMyEyNjURMzI2NTQmIyU0NjsBMhYdASM1ARQGIyEiJjURIREBIgYdARQWMzI2PQE0JjMiBh0BFBYzMjY9ATQmA12bRDCcMESbEBcXECdEMAGEMEQnEBcXEP4vFhCcEBboAV0XEP58EBcB0v7JEBYWEBAXF4wQFxcQEBYWAronMEREMCcXEBAW/gcwREQwAfkWEBAXJxAXFxAnJ/2TEBYWEAH5/gcBhBcQ6BAXFxDoEBcXEOgQFxcQ6BAXAAAABwAA/8AEAAPAAAMABwALAA8AEwAbACMAABMzFSM3MxUjJTMVIzczFSMlMxUjAxMhEzMTIRMBAyEDIwMhAwCAgMDAwAEAgIDAwMABAICAEBD9ABAgEAKAEP1AEAMAECAQ/YAQAcBAQEBAQEBAQEACQP5AAcD+gAGA/AABgP6AAUD+wAAABABQAIAEAAPAAAgADQAQAEAAAD8BIRczAyMDMxMzFyM3ARsBAyMiJjU0NjsBMjY1NCYrASIGFRQWFx4BOwEyFhUUBisBIgYVFBY7ATI2NTQmJy4BwjoBCDpywODAcppIOrw6AWSgoKBADRMTDYANExMNgCg4DQwNJRVADRMTDYANExMNgCg4DQwNJYDAwAKA/YACAMDA/gABAP8AAsATDQ0TEw0NEzgoEiENDxETDQ0TEw0NEzgoEiENDxEAAAAABABQ/8AEAAMAAAgADQAQAEAAAD8BIRczAyMDMxMzFyM3JQsBEyMiJjU0NjsBMjY1NCYrASIGFRQWFx4BOwEyFhUUBisBIgYVFBY7ATI2NTQmJy4BwjoBCDpywODAcppIOrw6AqSgoKBADRMTDYANExMNgCg4DQwNJRVADRMTDYANExMNgCg4DQwNJYDAwAKA/YACAMDAgP8AAQD9gBMNDRMTDQ0TOCgSIQ0PERMNDRMTDQ0TOCgSIQ0PEQAHAAD/wAQAA8AABwAPABMAFwAbAB8AIgAAAREhESMRIREFESERMxEhESUzFSMnMxUjJTMVIzczFSMlFwcBAAMAQP2AAsD9AEACgP5AgIDAgIABgICAwICA/IDAwAJAAYD+gAFA/sDA/kABwP6AAYCAQEBAQEBAQODAwAAAAQCA/8ADgAPAABcAAAEhFSMRIxEjESMRIicuAScmNTQ3PgE3NgGAAgCAgICANS8uRhQUFBRGLi8DwID8gAOA/IACABQURi4vNTUvLkYUFAACAAD/wAQAA8AAFwAaAAABIgcOAQcGFRQXHgEXFjMRMxEzETMRMzUJAgIANS8uRhQUFBRGLi81gICAgPwAAQD/AAPAFBRGLi81NS8uRhQU/gADgPyAA4CA/UABAAEAAAACAAD/wAQAA8AAFwAaAAABIgcOAQcGFRQXHgEXFjMRMxEzETMRMzUFCQEBADUvLkYUFBQURi4vNYCAgIABAP8AAQADwBQURi4vNTUvLkYUFP4AA4D8gAOAgMD/AP8AAAABAAD/zgQAA7MAYwAAASIHDgEHBhUUFx4BFxYXFjY1PAEnBiYxLgExJjYxHgExFjY3PgE3JicuAScmNTQ2Ny4BNzAWFz4BMzIWFz4BMRYGBx4BFRQHDgEHBgceARUUBhUUFjc2Nz4BNzY1NCcuAScmIwIAal1eiygoGhpdQUBMExABakISJyMnJigiXRYEEgsrKipCFBUcGQQMFUNKHkEhIUEeSkMVDAQZHBUUQyopKw4VARATTEFAXRoaKCiLXl1qA7MoKItdXmpUTU2ALy8ZBBIKCTYgF1QsHxgHAzI7BwoYIgoFDA04Ly9JKkUbCUk1AzEICQkIMQM1SQkbRSpKLy44DA0FCzAjNEwNChIEGS8wf01NVGpeXYsoKAAAAAABAAAAAQAAt9HlfV8PPPUACwQAAAAAANgVW8QAAAAA2BVbxAAA/8AEAAPAAAAACAACAAAAAAAAAAEAAAPA/8AAAAQAAAAAAAQAAAEAAAAAAAAAAAAAAAAAAABLBAAAAAAAAAAAAAAAAgAAAAQAAFUEAABVBAAAVQQAAFUEAAEABAABVgQAAKoEAAAzBAAAgAQAAFYEAACABAAAgAQAAIAEAACABAAAVQQAAFUEAABVBAABKwQAAIAEAAErBAAAVQQAAIAEAAErBAABqwQAAKsEAAAABAAA1QQAAGQEAAB1BAAA1QQAAAAEAACRBAAA4gQAAFUEAABVBAAAgAQAAGQEAADVBAAAVQQAAFUEAABVBAAAAAQAANUEAABVBAAAgAQAAIAEAADVBAAAVQQAAGsEAAEABAAAAAQAAEAEAAAABAAAQAQAAIAEAACABAAAAAQAAOsEAAAABAAAQAQAAHYEAAAABAAAfAQAAAAEAABQBAAAUAQAAAAEAACABAAAAAQAAAAEAAAAAAAAAAAKABQAHgCIAPIBXgHKAd4B7AI0AlACfgKiAtIDBgNCA3QD2gRSBHIEqAT2BQQFZAV8BYoFwgX6BjwGZgbOB3YHnggcCDIIcAkiCVoJogoqCkQKoAr0C3gLtgvoDJwMvAzcDPgNOg2IDaANrg46DnAOxA70DyQPMg9QD3gPnA/CEDoQrhDwEVARrhHsEhQSRBJ0EwQAAQAAAEsAewAJAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAA4ArgABAAAAAAABAAcAAAABAAAAAAACAAcAYAABAAAAAAADAAcANgABAAAAAAAEAAcAdQABAAAAAAAFAAsAFQABAAAAAAAGAAcASwABAAAAAAAKABoAigADAAEECQABAA4ABwADAAEECQACAA4AZwADAAEECQADAA4APQADAAEECQAEAA4AfAADAAEECQAFABYAIAADAAEECQAGAA4AUgADAAEECQAKADQApGljb21vb24AaQBjAG8AbQBvAG8AblZlcnNpb24gMS4wAFYAZQByAHMAaQBvAG4AIAAxAC4AMGljb21vb24AaQBjAG8AbQBvAG8Abmljb21vb24AaQBjAG8AbQBvAG8AblJlZ3VsYXIAUgBlAGcAdQBsAGEAcmljb21vb24AaQBjAG8AbQBvAG8AbkZvbnQgZ2VuZXJhdGVkIGJ5IEljb01vb24uAEYAbwBuAHQAIABnAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAEkAYwBvAE0AbwBvAG4ALgAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=);font-weight:400;font-style:normal}.index_bf-container__1HxhF [class*=\" bfi-\"],.index_bf-container__1HxhF [class^=bfi-],.index_bf-modal-root__1P_VQ [class*=\" bfi-\"],.index_bf-modal-root__1P_VQ [class^=bfi-]{font-family:braft-icons!important;speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.index_bf-container__1HxhF .index_bfi-table__2fSIV:before,.index_bf-modal-root__1P_VQ .index_bfi-table__2fSIV:before{content:\"\\E228\"}.index_bf-container__1HxhF .index_bfi-clear_all__2OHjw:before,.index_bf-modal-root__1P_VQ .index_bfi-clear_all__2OHjw:before{content:\"\\E0B8\"}.index_bf-container__1HxhF .index_bfi-format_clear__2Z6-D:before,.index_bf-modal-root__1P_VQ .index_bfi-format_clear__2Z6-D:before{content:\"\\E239\"}.index_bf-container__1HxhF .index_bfi-hr__1-frF:before,.index_bf-modal-root__1P_VQ .index_bfi-hr__1-frF:before{content:\"\\E925\"}.index_bf-container__1HxhF .index_bfi-colorize__itEld:before,.index_bf-modal-root__1P_VQ .index_bfi-colorize__itEld:before{content:\"\\E3B8\"}.index_bf-container__1HxhF .index_bfi-crop_free__1UXYS:before,.index_bf-modal-root__1P_VQ .index_bfi-crop_free__1UXYS:before{content:\"\\E3C2\"}.index_bf-container__1HxhF .index_bfi-pause__1OwwZ:before,.index_bf-modal-root__1P_VQ .index_bfi-pause__1OwwZ:before{content:\"\\E034\"}.index_bf-container__1HxhF .index_bfi-play_arrow__1hL7J:before,.index_bf-modal-root__1P_VQ .index_bfi-play_arrow__1hL7J:before{content:\"\\E037\"}.index_bf-container__1HxhF .index_bfi-bin__h1RKN:before,.index_bf-modal-root__1P_VQ .index_bfi-bin__h1RKN:before{content:\"\\E9AC\"}.index_bf-container__1HxhF .index_bfi-replay__11NQk:before,.index_bf-modal-root__1P_VQ .index_bfi-replay__11NQk:before{content:\"\\E042\"}.index_bf-container__1HxhF .index_bfi-tune__axH8Q:before,.index_bf-modal-root__1P_VQ .index_bfi-tune__axH8Q:before{content:\"\\E429\"}.index_bf-container__1HxhF .index_bfi-close__3PhYm:before,.index_bf-modal-root__1P_VQ .index_bfi-close__3PhYm:before{content:\"\\E913\"}.index_bf-container__1HxhF .index_bfi-align-center__3WjMb:before,.index_bf-modal-root__1P_VQ .index_bfi-align-center__3WjMb:before{content:\"\\E028\"}.index_bf-container__1HxhF .index_bfi-align-justify__1QkRU:before,.index_bf-modal-root__1P_VQ .index_bfi-align-justify__1QkRU:before{content:\"\\E026\"}.index_bf-container__1HxhF .index_bfi-align-left__1oX7J:before,.index_bf-modal-root__1P_VQ .index_bfi-align-left__1oX7J:before{content:\"\\E027\"}.index_bf-container__1HxhF .index_bfi-align-right__1eM5M:before,.index_bf-modal-root__1P_VQ .index_bfi-align-right__1eM5M:before{content:\"\\E029\"}.index_bf-container__1HxhF .index_bfi-image-right__2H-ST:before,.index_bf-modal-root__1P_VQ .index_bfi-image-right__2H-ST:before{content:\"\\E914\"}.index_bf-container__1HxhF .index_bfi-image-left__zW8ok:before,.index_bf-modal-root__1P_VQ .index_bfi-image-left__zW8ok:before{content:\"\\E91E\"}.index_bf-container__1HxhF .index_bfi-music__1XtpY:before,.index_bf-modal-root__1P_VQ .index_bfi-music__1XtpY:before{content:\"\\E90E\"}.index_bf-container__1HxhF .index_bfi-camera__2X5Zb:before,.index_bf-modal-root__1P_VQ .index_bfi-camera__2X5Zb:before{content:\"\\E911\"}.index_bf-container__1HxhF .index_bfi-copy__16C-6:before,.index_bf-modal-root__1P_VQ .index_bfi-copy__16C-6:before{content:\"\\E92C\"}.index_bf-container__1HxhF .index_bfi-file-text__12Obf:before,.index_bf-modal-root__1P_VQ .index_bfi-file-text__12Obf:before{content:\"\\E926\"}.index_bf-container__1HxhF .index_bfi-film__2C48n:before,.index_bf-modal-root__1P_VQ .index_bfi-film__2C48n:before{content:\"\\E91C\"}.index_bf-container__1HxhF .index_bfi-github__3XePr:before,.index_bf-modal-root__1P_VQ .index_bfi-github__3XePr:before{content:\"\\EAB0\"}.index_bf-container__1HxhF .index_bfi-ltr__rDkrQ:before,.index_bf-modal-root__1P_VQ .index_bfi-ltr__rDkrQ:before{content:\"\\EA74\"}.index_bf-container__1HxhF .index_bfi-page-break__DhcNp:before,.index_bf-modal-root__1P_VQ .index_bfi-page-break__DhcNp:before{content:\"\\EA68\"}.index_bf-container__1HxhF .index_bfi-pagebreak__m3gAm:before,.index_bf-modal-root__1P_VQ .index_bfi-pagebreak__m3gAm:before{content:\"\\EA6E\"}.index_bf-container__1HxhF .index_bfi-paint-format__pjAiv:before,.index_bf-modal-root__1P_VQ .index_bfi-paint-format__pjAiv:before{content:\"\\E90C\"}.index_bf-container__1HxhF .index_bfi-paste__G7Hrh:before,.index_bf-modal-root__1P_VQ .index_bfi-paste__G7Hrh:before{content:\"\\E92D\"}.index_bf-container__1HxhF .index_bfi-pilcrow__4zJYM:before,.index_bf-modal-root__1P_VQ .index_bfi-pilcrow__4zJYM:before{content:\"\\EA73\"}.index_bf-container__1HxhF .index_bfi-pushpin__3PUoC:before,.index_bf-modal-root__1P_VQ .index_bfi-pushpin__3PUoC:before{content:\"\\E946\"}.index_bf-container__1HxhF .index_bfi-redo__1Q-LG:before,.index_bf-modal-root__1P_VQ .index_bfi-redo__1Q-LG:before{content:\"\\E968\"}.index_bf-container__1HxhF .index_bfi-rtl__sPVOR:before,.index_bf-modal-root__1P_VQ .index_bfi-rtl__sPVOR:before{content:\"\\EA75\"}.index_bf-container__1HxhF .index_bfi-spinner__Dek6M:before,.index_bf-modal-root__1P_VQ .index_bfi-spinner__Dek6M:before{content:\"\\E980\"}.index_bf-container__1HxhF .index_bfi-subscript__kYu6m:before,.index_bf-modal-root__1P_VQ .index_bfi-subscript__kYu6m:before{content:\"\\EA6C\"}.index_bf-container__1HxhF .index_bfi-superscript__3qvwy:before,.index_bf-modal-root__1P_VQ .index_bfi-superscript__3qvwy:before{content:\"\\EA6B\"}.index_bf-container__1HxhF .index_bfi-undo___pDce:before,.index_bf-modal-root__1P_VQ .index_bfi-undo___pDce:before{content:\"\\E967\"}.index_bf-container__1HxhF .index_bfi-media__3Ijxb:before,.index_bf-modal-root__1P_VQ .index_bfi-media__3Ijxb:before{content:\"\\E90F\"}.index_bf-container__1HxhF .index_bfi-add__LigZq:before,.index_bf-modal-root__1P_VQ .index_bfi-add__LigZq:before{content:\"\\E918\"}.index_bf-container__1HxhF .index_bfi-bold__dn9AC:before,.index_bf-modal-root__1P_VQ .index_bfi-bold__dn9AC:before{content:\"\\E904\"}.index_bf-container__1HxhF .index_bfi-code__3tDKj:before,.index_bf-modal-root__1P_VQ .index_bfi-code__3tDKj:before{content:\"\\E903\"}.index_bf-container__1HxhF .index_bfi-done__J_3zM:before,.index_bf-modal-root__1P_VQ .index_bfi-done__J_3zM:before{content:\"\\E912\"}.index_bf-container__1HxhF .index_bfi-drop-down__2-Azn:before,.index_bf-modal-root__1P_VQ .index_bfi-drop-down__2-Azn:before{content:\"\\E906\"}.index_bf-container__1HxhF .index_bfi-drop-up__f9cHI:before,.index_bf-modal-root__1P_VQ .index_bfi-drop-up__f9cHI:before{content:\"\\E909\"}.index_bf-container__1HxhF .index_bfi-emoji__37yM6:before,.index_bf-modal-root__1P_VQ .index_bfi-emoji__37yM6:before{content:\"\\E91B\"}.index_bf-container__1HxhF .index_bfi-font-size__1cbPf:before,.index_bf-modal-root__1P_VQ .index_bfi-font-size__1cbPf:before{content:\"\\E920\"}.index_bf-container__1HxhF .index_bfi-fullscreen__2txWy:before,.index_bf-modal-root__1P_VQ .index_bfi-fullscreen__2txWy:before{content:\"\\E910\"}.index_bf-container__1HxhF .index_bfi-fullscreen-exit__33svQ:before,.index_bf-modal-root__1P_VQ .index_bfi-fullscreen-exit__33svQ:before{content:\"\\E90D\"}.index_bf-container__1HxhF .index_bfi-help__xa9vi:before,.index_bf-modal-root__1P_VQ .index_bfi-help__xa9vi:before{content:\"\\E902\"}.index_bf-container__1HxhF .index_bfi-indent-decrease__1CtRw:before,.index_bf-modal-root__1P_VQ .index_bfi-indent-decrease__1CtRw:before{content:\"\\E92F\"}.index_bf-container__1HxhF .index_bfi-indent-increase__2kSOy:before,.index_bf-modal-root__1P_VQ .index_bfi-indent-increase__2kSOy:before{content:\"\\E92E\"}.index_bf-container__1HxhF .index_bfi-info__3gDtD:before,.index_bf-modal-root__1P_VQ .index_bfi-info__3gDtD:before{content:\"\\E901\"}.index_bf-container__1HxhF .index_bfi-italic__1ENXj:before,.index_bf-modal-root__1P_VQ .index_bfi-italic__1ENXj:before{content:\"\\E924\"}.index_bf-container__1HxhF .index_bfi-link__3-0Rp:before,.index_bf-modal-root__1P_VQ .index_bfi-link__3-0Rp:before{content:\"\\E91A\"}.index_bf-container__1HxhF .index_bfi-link-off__2xzYa:before,.index_bf-modal-root__1P_VQ .index_bfi-link-off__2xzYa:before{content:\"\\E919\"}.index_bf-container__1HxhF .index_bfi-list__3GI0k:before,.index_bf-modal-root__1P_VQ .index_bfi-list__3GI0k:before{content:\"\\E923\"}.index_bf-container__1HxhF .index_bfi-list-numbered__U2An6:before,.index_bf-modal-root__1P_VQ .index_bfi-list-numbered__U2An6:before{content:\"\\E922\"}.index_bf-container__1HxhF .index_bfi-menu__YEtEG:before,.index_bf-modal-root__1P_VQ .index_bfi-menu__YEtEG:before{content:\"\\E908\"}.index_bf-container__1HxhF .index_bfi-more-horiz__38Kqk:before,.index_bf-modal-root__1P_VQ .index_bfi-more-horiz__38Kqk:before{content:\"\\E90B\"}.index_bf-container__1HxhF .index_bfi-more-vert__1Xpoy:before,.index_bf-modal-root__1P_VQ .index_bfi-more-vert__1Xpoy:before{content:\"\\E90A\"}.index_bf-container__1HxhF .index_bfi-not-disturb__2wwfA:before,.index_bf-modal-root__1P_VQ .index_bfi-not-disturb__2wwfA:before{content:\"\\E907\"}.index_bf-container__1HxhF .index_bfi-print__1Vdsh:before,.index_bf-modal-root__1P_VQ .index_bfi-print__1Vdsh:before{content:\"\\E915\"}.index_bf-container__1HxhF .index_bfi-quote__1xD3O:before,.index_bf-modal-root__1P_VQ .index_bfi-quote__1xD3O:before{content:\"\\E921\"}.index_bf-container__1HxhF .index_bfi-search__2G21G:before,.index_bf-modal-root__1P_VQ .index_bfi-search__2G21G:before{content:\"\\E916\"}.index_bf-container__1HxhF .index_bfi-settingsx__5qqai:before,.index_bf-modal-root__1P_VQ .index_bfi-settingsx__5qqai:before{content:\"\\E917\"}.index_bf-container__1HxhF .index_bfi-share__LmF7D:before,.index_bf-modal-root__1P_VQ .index_bfi-share__LmF7D:before{content:\"\\E905\"}.index_bf-container__1HxhF .index_bfi-share-square__sA_aV:before,.index_bf-modal-root__1P_VQ .index_bfi-share-square__sA_aV:before{content:\"\\E900\"}.index_bf-container__1HxhF .index_bfi-strikethrough__3Oij6:before,.index_bf-modal-root__1P_VQ .index_bfi-strikethrough__3Oij6:before{content:\"\\E91F\"}.index_bf-container__1HxhF .index_bfi-text-color__1p69s .index_path1__1i_Zc:before,.index_bf-modal-root__1P_VQ .index_bfi-text-color__1p69s .index_path1__1i_Zc:before{font-family:braft-icons!important;content:\"\\E930\";opacity:.36}.index_bf-container__1HxhF .index_bfi-text-color__1p69s .index_path2__DFG_e:before,.index_bf-modal-root__1P_VQ .index_bfi-text-color__1p69s .index_path2__DFG_e:before{font-family:braft-icons!important;content:\"\\E931\";margin-left:-1em}.index_bf-container__1HxhF .index_bfi-underlined__oAOe6:before,.index_bf-modal-root__1P_VQ .index_bfi-underlined__oAOe6:before{content:\"\\E91D\"}.index_bf-content__5lf-j{height:500px;padding-bottom:10px;overflow:auto;font-size:16px}.index_bf-content__5lf-j img{-webkit-user-select:none;user-select:none}.index_bf-content__5lf-j *{line-height:normal}.index_bf-container__1HxhF{position:relative;height:100%;padding:0}.index_bf-container__1HxhF.index_disabled__KFBp_{pointer-events:none;opacity:.7;filter:grayscale(70%)}.index_bf-container__1HxhF.index_read-only__3HgNB .index_bf-controlbar__ej8fA{pointer-events:none}.index_bf-container__1HxhF.index_read-only__3HgNB .index_bf-image__1MXDI img:hover{outline:none}.index_bf-container__1HxhF.index_read-only__3HgNB .index_bf-hr__39L4E{pointer-events:none}.index_bf-container__1HxhF.index_fullscreen__2MrQv{position:fixed;display:flex;flex-direction:column;z-index:99999;top:0;right:0;bottom:0;left:0;background-color:#fff;height:100%!important}.index_bf-container__1HxhF.index_fullscreen__2MrQv .index_bf-content__5lf-j{flex-grow:1;height:auto}.index_bf-container__1HxhF .index_input-group__1Y0_d{display:block}.index_bf-container__1HxhF .index_input-group__1Y0_d input{box-sizing:border-box;width:100%;height:36px;padding:0 15px;font-size:14px}.index_bf-container__1HxhF .index_pull-left__33hHK{float:left}.index_bf-container__1HxhF .index_pull-right__22QW0{float:right}.index_bf-container__1HxhF button{line-height:normal}.index_bf-container__1HxhF button.index_default__11aE1,.index_bf-container__1HxhF button.index_ghost__q2A8s,.index_bf-container__1HxhF button.index_primary__1ex4f{height:32px;padding:0 20px;color:#fff;font-size:12px}.index_bf-container__1HxhF button.index_default__11aE1{background-color:hsla(0,0%,100%,.15);border:none}.index_bf-container__1HxhF button.index_default__11aE1:hover{background-color:hsla(0,0%,100%,.1)}.index_bf-container__1HxhF button.index_ghost__q2A8s{background-color:transparent;border:none;box-shadow:inset 0 0 0 .5px hsla(0,0%,100%,.5)}.index_bf-container__1HxhF button.index_ghost__q2A8s:hover{box-shadow:inset 0 0 0 .5px hsla(0,0%,100%,.7)}.index_bf-container__1HxhF button.index_primary__1ex4f{background-color:#3498db;border:none;color:#fff}.index_bf-container__1HxhF button.index_primary__1ex4f:hover{background-color:#2084c7}.index_bf-container__1HxhF .index_public-DraftEditorPlaceholder-root__1T6lJ{top:15px;left:15px;font-size:16px;pointer-events:none}.index_bf-container__1HxhF .index_DraftEditor-editorContainer__1FR0o{box-sizing:border-box;border:none}.index_bf-container__1HxhF .index_DraftEditor-root__mlfOI,.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu{height:100%}.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu{box-sizing:border-box;padding:15px;word-wrap:break-word;word-break:break-all}.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu>div{padding-bottom:20px}.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu .index_braft-link__1ZeMr{color:#4078c0}.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu blockquote{margin:0 0 10px;padding:15px 20px;background-color:#f1f2f3;border-left:5px solid #ccc;color:#666;font-style:italic}.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu pre{max-width:100%;max-height:100%;margin:10px 0;padding:15px;overflow:auto;background-color:#f1f2f3;border-radius:3px;color:#666;font-family:monospace;font-size:14px;font-weight:400;line-height:16px;word-wrap:break-word;white-space:pre-wrap}.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu pre pre{margin:0;padding:0}.index_bf-container__1HxhF .index_bfa-left__3CWAj,.index_bf-container__1HxhF .index_bfa-left__3CWAj .index_public-DraftStyleDefault-ltr__3qMdW{text-align:left}.index_bf-container__1HxhF .index_bfa-right__Sy5sn,.index_bf-container__1HxhF .index_bfa-right__Sy5sn .index_public-DraftStyleDefault-ltr__3qMdW{text-align:right}.index_bf-container__1HxhF .index_bfa-center__3iBxk,.index_bf-container__1HxhF .index_bfa-center__3iBxk .index_public-DraftStyleDefault-ltr__3qMdW{text-align:center}.index_bf-container__1HxhF .index_bfa-justify__C4cm4,.index_bf-container__1HxhF .index_bfa-justify__C4cm4 .index_public-DraftStyleDefault-ltr__3qMdW{text-align:justify}.index_bf-container__1HxhF .index_bfa-center__3iBxk>div,.index_bf-container__1HxhF .index_bfa-justify__C4cm4>div,.index_bf-container__1HxhF .index_bfa-left__3CWAj>div,.index_bf-container__1HxhF .index_bfa-right__Sy5sn>div{display:inline-block}.index_bf-container__1HxhF .index_bff-left__pCNho:hover,.index_bf-container__1HxhF .index_bff-right__vpxtc:hover{z-index:2}.index_bf-container__1HxhF .index_bff-left__pCNho{position:relative;z-index:1;float:left;margin:0 10px 0 0}.index_bf-container__1HxhF .index_bff-right__vpxtc{position:relative;z-index:1;float:right;margin:0 0 0 10px}.index_bf-container__1HxhF .index_bftd-1__382qR{text-indent:2em;display:initial}.index_bf-container__1HxhF .index_bftd-2__11te-{text-indent:4em;display:initial}.index_bf-container__1HxhF .index_bftd-3__2BZeG{text-indent:6em;display:initial}.index_bf-container__1HxhF .index_bftd-4__4c1Sw{text-indent:8em;display:initial}.index_bf-container__1HxhF .index_bftd-5__34mlP{text-indent:10em;display:initial}.index_bf-container__1HxhF .index_bftd-6__1bsox{text-indent:12em;display:initial}.index_bf-container__1HxhF .index_bf-image__1MXDI,.index_bf-container__1HxhF .index_bf-media__33Dic{position:relative}.index_bf-container__1HxhF .index_bf-image__1MXDI img{display:block;max-width:100%;font-size:0;resize:both;outline-offset:1px}.index_bf-container__1HxhF .index_bf-image__1MXDI img:hover{outline:1px solid #3498db}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5{position:absolute;z-index:3;bottom:15px;left:50%;width:auto;background-color:#21242a;border-radius:2px;font-weight:400;text-align:center;white-space:nowrap;transform:translateX(-50%);box-shadow:0 5px 15px rgba(0,0,0,.2);-webkit-user-select:none;user-select:none}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5 .index_bf-media-toolbar-arrow__M3uMb,.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5:before{position:absolute;bottom:-10px;left:50%;display:block;border:5px solid transparent;border-top-color:#21242a;content:\"\";transform:translateX(-5px)}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5 a{display:inline-block;min-width:40px;height:40px;color:hsla(0,0%,100%,.5);font-family:braft-icons!important;font-size:18px;font-weight:400;line-height:40px;text-align:center;text-decoration:none;text-transform:uppercase;cursor:pointer}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5 a:hover{color:#fff}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5 a:first-child{border-radius:2px 0 0 2px}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5 a:last-child{border-radius:0 2px 2px 0}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5 a.index_active__3_mlp{color:#3498db}.index_bf-video-player__3Eqxs video{display:block;width:640px;max-width:80vw;height:auto;margin:0 10px 10px;object-fit:contain}.index_bf-audio-player__67sKu audio{width:480px;max-width:80vw;margin:0 10px 10px}.index_bf-player-holder__1k4R5{position:relative;height:240px;overflow:hidden;background-color:#21242a;border-radius:3px}.index_bf-player-holder__1k4R5 .index_icon-badge__35ukN{position:absolute;z-index:2;top:0;left:0;height:30px;padding:0 15px;border-radius:0 0 3px 0;color:#fff;background-color:hsla(0,0%,100%,.1)}.index_bf-player-holder__1k4R5 .index_icon-badge__35ukN i,.index_bf-player-holder__1k4R5 .index_icon-badge__35ukN span{display:block;float:left;line-height:30px}.index_bf-player-holder__1k4R5 .index_icon-badge__35ukN span{margin-left:5px;font-size:12px}.index_bf-player-holder__1k4R5 .index_button-remove__cTw4D{position:absolute;z-index:2;top:5px;right:5px;width:40px;height:40px;background-color:transparent;border:none;border-radius:50%;outline:none;color:#fff;font-size:24px;text-align:center;cursor:pointer}.index_bf-player-holder__1k4R5 .index_button-remove__cTw4D:hover{color:#e74c3c}.index_bf-player-holder__1k4R5 .index_button-play__1GpMM{position:relative;z-index:2;display:block;width:80px;height:80px;margin:40px auto 20px;background-color:rgba(0,0,0,.7);border:none;border-radius:50%;outline:none;color:#fff;font-size:48px;line-height:80px;text-align:center;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);cursor:pointer}.index_bf-player-holder__1k4R5 .index_button-play__1GpMM:hover{background-color:#3498db}.index_bf-player-holder__1k4R5 .index_bf-name__3FBAI{position:relative;z-index:2;margin:0;color:#fff;font-size:14px;font-weight:500;text-align:center}.index_bf-player-holder__1k4R5 .index_bf-url__1di3g{position:relative;z-index:2;width:70%;margin:10px auto;color:hsla(0,0%,100%,.5);font-size:12px;font-weight:400;text-align:center}.index_bf-player-holder__1k4R5 .index_bf-poster__drCvq{position:absolute;top:0;left:0;width:100%;height:100%;background-repeat:no-repeat;background-position:50% 50%;background-size:cover;opacity:.3}.index_bf-modal__23mEu{position:fixed;z-index:99999;top:0;left:0;width:100%;height:100%}.index_bf-modal__23mEu button{outline:none}.index_bf-modal-mask__3MKbg{position:absolute;z-index:1;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,.1);opacity:0;transition:opacity .2s}.index_bf-modal-content__1RScF{position:absolute;z-index:2;top:45%;left:50%;max-width:95%;background-color:#fff;border-radius:2px;box-shadow:0 15px 30px rgba(0,0,0,.1);opacity:0;transform:translate(-50%,-40%);transition:transform .2s,opacity .2s}.index_bf-modal-header__3jeX-{height:50px}.index_bf-modal-caption__2z9hD{float:left;margin:0;padding:0 15px;color:#999;font-size:14px;font-weight:400;line-height:50px}.index_bf-modal-close-button__13UMv{float:right;width:50px;height:50px;background-color:transparent;border:none;color:#ccc;font-size:18px;cursor:pointer}.index_bf-modal-close-button__13UMv:hover{color:#e74c3c}.index_bf-modal-body__3MjbZ{overflow:auto}.index_bf-modal-footer__3Pc0k{min-height:15px;padding:0 15px;overflow:hidden}.index_bf-modal-addon-text__3dQDG{float:left;color:#999;font-size:12px;line-height:60px}.index_bf-modal-buttons__2IuAO{float:right}.index_bf-modal-cancel__30ePe,.index_bf-modal-confirm__3woeJ{height:36px;margin:12px 0 12px 15px;padding:0 30px;border:none;border-radius:2px;font-size:12px;font-weight:700;cursor:pointer}.index_bf-modal-cancel__30ePe{background-color:#e8e9ea;color:#999}.index_bf-modal-cancel__30ePe:hover{background-color:#d8d9da}.index_bf-modal-confirm__3woeJ{background-color:#3498db;color:#fff}.index_bf-modal-confirm__3woeJ:hover{background-color:#2084c7}.index_bf-modal-confirm__3woeJ.index_disabled__KFBp_{opacity:.3;pointer-events:none;filter:grayscale(.4)}.index_bf-modal-root__1P_VQ.index_active__3_mlp .index_bf-modal-mask__3MKbg{opacity:1}.index_bf-modal-root__1P_VQ.index_active__3_mlp .index_bf-modal-content__1RScF{opacity:1;transform:translate(-50%,-50%)}.index_bf-content__5lf-j .index_bf-hr__39L4E{position:relative;box-sizing:content-box;height:15px;padding-top:15px;text-align:center}.index_bf-content__5lf-j .index_bf-hr__39L4E:before{display:block;height:1px;background-color:rgba(0,0,0,.1);content:\"\"}.index_bf-content__5lf-j .index_bf-hr__39L4E:hover:before{background-color:rgba(0,0,0,.3)}.index_bf-content__5lf-j .index_bf-hr__39L4E:hover .index_bf-media-toolbar__28qi5{display:block}.index_bf-content__5lf-j .index_bf-hr__39L4E .index_bf-media-toolbar__28qi5{display:none}.index_bf-image-link-editor__L5XLU,.index_bf-image-size-editor__3DAVi{padding-bottom:1px;overflow:hidden;border-radius:2px 2px 0 0;box-shadow:inset 0 -1px 0 0 hsla(0,0%,100%,.1)}.index_bf-image-link-editor__L5XLU .index_editor-input-group__1hcX3,.index_bf-image-size-editor__3DAVi .index_editor-input-group__1hcX3{width:300px;margin:8px 10px;overflow:hidden}.index_bf-image-link-editor__L5XLU input,.index_bf-image-size-editor__3DAVi input{display:block;float:left;box-sizing:content-box;height:32px;margin:0 5px 0 0;padding:0 10px;background-color:hsla(0,0%,100%,.1);border:none;border-radius:2px;outline:none;box-shadow:inset 0 0 0 1px hsla(0,0%,100%,.1);color:#fff;font-weight:700}.index_bf-image-link-editor__L5XLU input:hover,.index_bf-image-size-editor__3DAVi input:hover{box-shadow:inset 0 0 0 1px rgba(52,152,219,.5)}.index_bf-image-link-editor__L5XLU input:focus,.index_bf-image-size-editor__3DAVi input:focus{box-shadow:inset 0 0 0 1px #3498db}.index_bf-image-link-editor__L5XLU button,.index_bf-image-size-editor__3DAVi button{float:left;width:90px;height:32px;margin:0;padding:0 20px;background-color:#3498db;border:none;color:#fff;font-size:12px;border-radius:2px;cursor:pointer}.index_bf-image-link-editor__L5XLU button:hover,.index_bf-image-size-editor__3DAVi button:hover{background-color:#2084c7}.index_bf-image-size-editor__3DAVi input{width:80px}.index_bf-image-link-editor__L5XLU input{width:185px}.index_bf-image-link-editor__L5XLU .index_switch-group__3nsEF{height:16px;margin:10px}.index_bf-image-link-editor__L5XLU .index_switch-group__3nsEF .index_bf-switch__1LPr-{float:left}.index_bf-image-link-editor__L5XLU .index_switch-group__3nsEF label{float:left;margin-left:15px;color:#999;font-size:12px;line-height:16px}.index_bf-content__5lf-j .index_bf-image__1MXDI{position:relative}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-csize-icon__13EM-{position:absolute;z-index:2;width:10px;height:10px;background-color:rgba(52,152,219,.3)}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-csize-icon__13EM-.index_right-bottom__2jlUD{right:0;bottom:0;cursor:se-resize}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-csize-icon__13EM-.index_left-bottom__1H0sb{left:0;bottom:0;cursor:sw-resize}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-pre-csize__2lLOX{position:absolute;z-index:1;background:transparent}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-pre-csize__2lLOX.index_rightbottom__S1Zly{left:0;top:0;border:1px dashed #00bfff}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-pre-csize__2lLOX.index_leftbottom__wbQiO{right:0;top:0;border:1px dashed #00bfff}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-media-toolbar__28qi5:before{visibility:hidden}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-media-toolbar__28qi5[data-align=center] [data-align=center],.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-media-toolbar__28qi5[data-align=left] [data-align=left],.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-media-toolbar__28qi5[data-align=right] [data-align=right],.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-media-toolbar__28qi5[data-float=left] [data-float=left],.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-media-toolbar__28qi5[data-float=right] [data-float=right]{color:#3498db}.index_headings-dropdown__1KzQP{min-width:110px}.index_headings-dropdown__1KzQP .index_menu__10kCt{width:200px;overflow:hidden}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov-{padding:15px 20px;text-align:left;line-height:normal}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h1,.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h2,.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h3,.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h4,.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h5,.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h6{margin:0;padding:0;color:inherit}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h1{font-size:28px}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h2{font-size:24px}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h3{font-size:20px}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h4{font-size:16px}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h5{font-size:14px}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h6{font-size:12px}.index_bf-link-editor__w7aBK{width:360px;padding-top:25px}.index_bf-link-editor__w7aBK .index_input-group__1Y0_d{margin:0 15px 8px}.index_bf-link-editor__w7aBK .index_input-group__1Y0_d input{background-color:hsla(0,0%,100%,.07);border:none;border-radius:2px;box-shadow:inset 0 0 0 1px hsla(0,0%,100%,.1);color:#fff;font-weight:700}.index_bf-link-editor__w7aBK .index_input-group__1Y0_d input:hover{box-shadow:inset 0 0 0 1px rgba(52,152,219,.5)}.index_bf-link-editor__w7aBK .index_input-group__1Y0_d input:focus{box-shadow:inset 0 0 0 1px #3498db}.index_bf-link-editor__w7aBK .index_input-group__1Y0_d input:disabled{color:hsla(0,0%,100%,.7);box-shadow:none}.index_bf-link-editor__w7aBK .index_switch-group__3nsEF{height:16px;margin:15px}.index_bf-link-editor__w7aBK .index_switch-group__3nsEF .index_bf-switch__1LPr-{float:left}.index_bf-link-editor__w7aBK .index_switch-group__3nsEF label{float:left;margin-left:15px;color:#999;font-size:12px;line-height:16px}.index_bf-link-editor__w7aBK .index_buttons__3QT_I{box-sizing:content-box;height:32px;margin-top:20px;padding:15px;overflow:hidden;box-shadow:inset 0 1px 0 0 hsla(0,0%,100%,.1)}.index_bf-link-editor__w7aBK .index_buttons__3QT_I .index_button-remove-link__2004W{color:#999;font-size:12px;line-height:32px;cursor:pointer}.index_bf-link-editor__w7aBK .index_buttons__3QT_I .index_button-remove-link__2004W:hover{color:#e74c3c}.index_bf-link-editor__w7aBK .index_buttons__3QT_I .index_button-remove-link__2004W i{margin-right:5px;font-size:16px}.index_bf-link-editor__w7aBK .index_buttons__3QT_I .index_button-remove-link__2004W i,.index_bf-link-editor__w7aBK .index_buttons__3QT_I .index_button-remove-link__2004W span{display:block;float:left;line-height:32px}.index_bf-link-editor__w7aBK .index_buttons__3QT_I button{margin-left:10px;border-radius:2px;font-weight:700;cursor:pointer}.index_bf-dropdown__zgKp1{position:relative;width:auto;height:36px;margin:0}.index_bf-dropdown__zgKp1.index_disabled__KFBp_{pointer-events:none;opacity:.3}.index_bf-dropdown__zgKp1.index_light-theme__iYoel .index_dropdown-content__2HerW{border:1px solid #ccc}.index_bf-dropdown__zgKp1.index_light-theme__iYoel .index_dropdown-content__2HerW .index_dropdown-arrow__3KWgU{background-color:#fff;border:1px solid #ccc}.index_bf-dropdown__zgKp1.index_light-theme__iYoel .index_dropdown-content__2HerW .index_dropdown-content-inner__5r4YN{background-color:#fff}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW{box-sizing:content-box;position:absolute;z-index:10;top:100%;left:50%;visibility:hidden;float:left;width:auto;min-width:100%;margin-top:9px;border-radius:2px;box-shadow:0 5px 15px rgba(0,0,0,.2);opacity:0;cursor:default;transform:translate(-50%,20px);transition:.2s}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW ::-webkit-scrollbar-track{background-color:transparent}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW ::-webkit-scrollbar{width:4px;background-color:transparent;border-radius:2px}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW ::-webkit-scrollbar-thumb{background-color:hsla(0,0%,100%,.3);border-radius:2px}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_dropdown-arrow__3KWgU{position:absolute;z-index:1;top:-3px;left:50%;width:10px;height:10px;background-color:#21242a;transform:translateX(-50%) rotate(45deg);transition:margin .2s}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_dropdown-arrow__3KWgU.index_active__3_mlp{background-color:#3498db}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_menu__10kCt{list-style:none;margin:0;padding:0;overflow:hidden;border-radius:2px}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_menu-item__2_Ov-{display:block;list-style:none;margin:0;font-size:16px;cursor:pointer}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_menu-item__2_Ov-:hover{background-color:rgba(0,0,0,.1)}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_menu-item__2_Ov-.index_active__3_mlp{background-color:#3498db;color:#fff}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_menu-item__2_Ov-:not(.index_active__3_mlp){color:hsla(0,0%,100%,.6);box-shadow:inset 0 -1px 0 0 hsla(0,0%,100%,.1)}.index_bf-dropdown__zgKp1 .index_dropdown-content-inner__5r4YN{position:relative;z-index:2;overflow:auto;background-color:#21242a;border-radius:2px}.index_bf-dropdown__zgKp1 .index_dropdown-handler__1xChS{position:relative;display:block;width:100%;height:36px;background-color:transparent;border:none;color:#6a6f7b;cursor:pointer}.index_bf-dropdown__zgKp1 .index_dropdown-handler__1xChS:hover{background-color:rgba(0,0,0,.05)}.index_bf-dropdown__zgKp1 .index_dropdown-handler__1xChS *{display:inline;padding:0;font-size:inherit;font-weight:400}.index_bf-dropdown__zgKp1 .index_dropdown-handler__1xChS>span{float:left;padding:0 10px;font-size:14px;line-height:36px;pointer-events:none}.index_bf-dropdown__zgKp1 .index_dropdown-handler__1xChS>span i{display:block;height:36px;font-size:16px;line-height:36px;text-align:center}.index_bf-dropdown__zgKp1 .index_dropdown-handler__1xChS .index_bfi-drop-down__2-Azn{float:right;width:30px;height:36px;font-size:16px;line-height:36px;text-align:center;pointer-events:none}.index_bf-dropdown__zgKp1.index_active__3_mlp .index_dropdown-handler__1xChS{background-color:rgba(0,0,0,.05)}.index_bf-dropdown__zgKp1.index_active__3_mlp .index_dropdown-content__2HerW{visibility:visible;opacity:1;transform:translate(-50%)}.index_text-color-dropdown__pnJCI.index_light-theme__iYoel .index_bf-color-switch-buttons__R4l-y button{border-bottom:1px solid #ccc;color:#616569}.index_text-color-dropdown__pnJCI.index_light-theme__iYoel .index_bf-color-switch-buttons__R4l-y button.index_active__3_mlp{border-bottom-color:#3498db;color:#3498db}.index_text-color-dropdown__pnJCI button.index_dropdown-handler__1xChS span{width:36px;padding:0;overflow:hidden;border-radius:2px}.index_text-color-dropdown__pnJCI .index_bf-text-color-picker-wrap__2xWAh{overflow:hidden}.index_text-color-dropdown__pnJCI .index_bf-color-switch-buttons__R4l-y{height:36px}.index_text-color-dropdown__pnJCI .index_bf-color-switch-buttons__R4l-y button{float:left;width:50%;height:36px;background-color:transparent;border:none;border-bottom:1px solid hsla(0,0%,100%,.1);color:hsla(0,0%,100%,.5);font-size:12px;font-weight:400;text-transform:uppercase;cursor:pointer}.index_text-color-dropdown__pnJCI .index_bf-color-switch-buttons__R4l-y button.index_active__3_mlp{border-bottom-color:#3498db;color:#3498db}.index_bf-colors__2Jog3{box-sizing:content-box;list-style:none;width:240px;margin:0;padding:15px;overflow:hidden}.index_bf-colors__2Jog3 li{box-sizing:content-box;display:block;float:left;width:24px;height:24px;margin:5px;padding:0;background-color:currentColor;border:3px solid transparent;border-radius:50%;cursor:pointer;transition:transform .2s}.index_bf-colors__2Jog3 li:hover{transform:scale(1.3)}.index_bf-colors__2Jog3 li.index_active__3_mlp{box-shadow:0 0 0 2px #3498db}.index_bf-font-size-dropdown__38pES{min-width:95px}.index_bf-font-sizes__2rRGp{box-sizing:content-box;width:210px;list-style:none;margin:0;padding:5px;overflow:hidden}.index_bf-font-sizes__2rRGp li{display:block;float:left;width:60px;height:30px;background-color:hsla(0,0%,100%,.1);border-radius:2px;margin:5px;color:#fff;font-size:12px;line-height:30px;text-align:center;text-transform:uppercase;cursor:pointer}.index_bf-font-sizes__2rRGp li:hover{background-color:hsla(0,0%,100%,.2)}.index_bf-font-sizes__2rRGp li.index_active__3_mlp{background-color:#3498db}.index_font-family-dropdown__rYXD5{min-width:120px}.index_font-family-dropdown__rYXD5 .index_dropdown-content__2HerW{width:180px}.index_font-family-dropdown__rYXD5 .index_menu-item__2_Ov-{padding:12px 15px}.index_bf-line-height-dropdown__ee0Ld{min-width:95px}.index_bf-line-heights__2Oa0w{box-sizing:content-box;width:210px;list-style:none;margin:0;padding:5px;overflow:hidden}.index_bf-line-heights__2Oa0w li{display:block;float:left;width:60px;height:30px;background-color:hsla(0,0%,100%,.1);border-radius:2px;margin:5px;color:#fff;font-size:12px;line-height:30px;text-align:center;text-transform:uppercase;cursor:pointer}.index_bf-line-heights__2Oa0w li:hover{background-color:hsla(0,0%,100%,.2)}.index_bf-line-heights__2Oa0w li.index_active__3_mlp{background-color:#3498db}.index_bf-letter-spacing-dropdown__1t21I{min-width:95px}.index_bf-letter-spacings__MYcL5{box-sizing:content-box;width:210px;list-style:none;margin:0;padding:5px;overflow:hidden}.index_bf-letter-spacings__MYcL5 li{display:block;float:left;width:60px;height:30px;background-color:hsla(0,0%,100%,.1);border-radius:2px;margin:5px;color:#fff;font-size:12px;line-height:30px;text-align:center;text-transform:uppercase;cursor:pointer}.index_bf-letter-spacings__MYcL5 li:hover{background-color:hsla(0,0%,100%,.2)}.index_bf-letter-spacings__MYcL5 li.index_active__3_mlp{background-color:#3498db}.index_bf-emojis-wrap__3FqEM{position:relative;width:210px;height:220px;overflow:hidden}.index_bf-emojis-wrap__3FqEM:after,.index_bf-emojis-wrap__3FqEM:before{position:absolute;z-index:1;right:0;left:0;height:30px;border-radius:2px;content:\"\";pointer-events:none}.index_bf-emojis-wrap__3FqEM:before{top:0;background-image:linear-gradient(0deg,rgba(33,36,42,0),#21242a)}.index_bf-emojis-wrap__3FqEM:after{bottom:0;background-image:linear-gradient(rgba(33,36,42,0),#21242a)}.index_bf-emojis__3p4Ps{box-sizing:content-box;width:200px;height:195px;list-style:none;margin:0;padding:15px 15px 20px;overflow:auto}.index_bf-emojis__3p4Ps li{display:block;float:left;width:30px;height:30px;margin:0;padding:0;color:#fff;border-radius:2px;font-family:Apple Color Emoji,Segoe UI,Segoe UI Emoji,Segoe UI Symbol;font-size:18px;line-height:32px;text-align:center;cursor:pointer;-webkit-user-select:none;user-select:none;transition:transform .2s}.index_bf-emojis__3p4Ps li:hover{transform:scale(1.5)}";
- styleInject(css);
-
- var css$1 = ".emoticon_braft-emoticon-picker__26_HU{box-sizing:border-box;width:210px;height:210px;overflow:hidden}.emoticon_braft-emoticon-picker__26_HU:after,.emoticon_braft-emoticon-picker__26_HU:before{position:absolute;z-index:1;right:0;left:0;height:30px;border-radius:2px;content:\"\";pointer-events:none}.emoticon_braft-emoticon-picker__26_HU:before{top:0;background-image:linear-gradient(0deg,rgba(33,36,42,0),#21242a)}.emoticon_braft-emoticon-picker__26_HU:after{bottom:0;background-image:linear-gradient(rgba(33,36,42,0),#21242a)}.emoticon_braft-emoticon-picker__26_HU .emoticon_braft-emoticons-list__P1AeK{box-sizing:content-box;width:200px;height:190px;margin:0;padding:15px 15px 20px;overflow:auto}.emoticon_braft-emoticon-picker__26_HU .emoticon_braft-emoticons-list__P1AeK img{display:block;box-sizing:content-box;float:left;width:20px;height:20px;margin:3px;padding:5px;border-radius:3px}.emoticon_braft-emoticon-picker__26_HU .emoticon_braft-emoticons-list__P1AeK img:hover{background-color:#3498db}.emoticon_braft-emoticon-in-editor__10cwl{position:relative;padding:0 2px;letter-spacing:12px}.emoticon_braft-emoticon-in-editor__10cwl img{position:absolute;top:0;left:2px;width:16px;height:16px}";
- styleInject(css$1);
-
- var immutable$3 = createCommonjsModule(function (module, exports) {
- /**
- * Copyright (c) 2014-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
-
- (function (global, factory) {
- factory(exports) ;
- }(commonjsGlobal, (function (exports) {
- // Used for setting prototype methods that IE8 chokes on.
- var DELETE = 'delete';
-
- // Constants describing the size of trie nodes.
- var SHIFT = 5; // Resulted in best performance after ______?
- var SIZE = 1 << SHIFT;
- var MASK = SIZE - 1;
-
- // A consistent shared value representing "not set" which equals nothing other
- // than itself, and nothing that could be provided externally.
- var NOT_SET = {};
-
- // Boolean references, Rough equivalent of `bool &`.
- function MakeRef() {
- return { value: false };
- }
-
- function SetRef(ref) {
- if (ref) {
- ref.value = true;
- }
- }
-
- // A function which returns a value representing an "owner" for transient writes
- // to tries. The return value will only ever equal itself, and will not equal
- // the return of any subsequent call of this function.
- function OwnerID() {}
-
- function ensureSize(iter) {
- if (iter.size === undefined) {
- iter.size = iter.__iterate(returnTrue);
- }
- return iter.size;
- }
-
- function wrapIndex(iter, index) {
- // This implements "is array index" which the ECMAString spec defines as:
- //
- // A String property name P is an array index if and only if
- // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
- // to 2^32−1.
- //
- // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
- if (typeof index !== 'number') {
- var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
- if ('' + uint32Index !== index || uint32Index === 4294967295) {
- return NaN;
- }
- index = uint32Index;
- }
- return index < 0 ? ensureSize(iter) + index : index;
- }
-
- function returnTrue() {
- return true;
- }
-
- function wholeSlice(begin, end, size) {
- return (
- ((begin === 0 && !isNeg(begin)) ||
- (size !== undefined && begin <= -size)) &&
- (end === undefined || (size !== undefined && end >= size))
- );
- }
-
- function resolveBegin(begin, size) {
- return resolveIndex(begin, size, 0);
- }
-
- function resolveEnd(end, size) {
- return resolveIndex(end, size, size);
- }
-
- function resolveIndex(index, size, defaultIndex) {
- // Sanitize indices using this shorthand for ToInt32(argument)
- // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
- return index === undefined
- ? defaultIndex
- : isNeg(index)
- ? size === Infinity
- ? size
- : Math.max(0, size + index) | 0
- : size === undefined || size === index
- ? index
- : Math.min(size, index) | 0;
- }
-
- function isNeg(value) {
- // Account for -0 which is negative, but not less than 0.
- return value < 0 || (value === 0 && 1 / value === -Infinity);
- }
-
- // Note: value is unchanged to not break immutable-devtools.
- var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@';
-
- function isCollection(maybeCollection) {
- return Boolean(maybeCollection && maybeCollection[IS_COLLECTION_SYMBOL]);
- }
-
- var IS_KEYED_SYMBOL = '@@__IMMUTABLE_KEYED__@@';
-
- function isKeyed(maybeKeyed) {
- return Boolean(maybeKeyed && maybeKeyed[IS_KEYED_SYMBOL]);
- }
-
- var IS_INDEXED_SYMBOL = '@@__IMMUTABLE_INDEXED__@@';
-
- function isIndexed(maybeIndexed) {
- return Boolean(maybeIndexed && maybeIndexed[IS_INDEXED_SYMBOL]);
- }
-
- function isAssociative(maybeAssociative) {
- return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
- }
-
- var Collection = function Collection(value) {
- return isCollection(value) ? value : Seq(value);
- };
-
- var KeyedCollection = /*@__PURE__*/(function (Collection) {
- function KeyedCollection(value) {
- return isKeyed(value) ? value : KeyedSeq(value);
- }
-
- if ( Collection ) KeyedCollection.__proto__ = Collection;
- KeyedCollection.prototype = Object.create( Collection && Collection.prototype );
- KeyedCollection.prototype.constructor = KeyedCollection;
-
- return KeyedCollection;
- }(Collection));
-
- var IndexedCollection = /*@__PURE__*/(function (Collection) {
- function IndexedCollection(value) {
- return isIndexed(value) ? value : IndexedSeq(value);
- }
-
- if ( Collection ) IndexedCollection.__proto__ = Collection;
- IndexedCollection.prototype = Object.create( Collection && Collection.prototype );
- IndexedCollection.prototype.constructor = IndexedCollection;
-
- return IndexedCollection;
- }(Collection));
-
- var SetCollection = /*@__PURE__*/(function (Collection) {
- function SetCollection(value) {
- return isCollection(value) && !isAssociative(value) ? value : SetSeq(value);
- }
-
- if ( Collection ) SetCollection.__proto__ = Collection;
- SetCollection.prototype = Object.create( Collection && Collection.prototype );
- SetCollection.prototype.constructor = SetCollection;
-
- return SetCollection;
- }(Collection));
-
- Collection.Keyed = KeyedCollection;
- Collection.Indexed = IndexedCollection;
- Collection.Set = SetCollection;
-
- var IS_SEQ_SYMBOL = '@@__IMMUTABLE_SEQ__@@';
-
- function isSeq(maybeSeq) {
- return Boolean(maybeSeq && maybeSeq[IS_SEQ_SYMBOL]);
- }
-
- var IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@';
-
- function isRecord(maybeRecord) {
- return Boolean(maybeRecord && maybeRecord[IS_RECORD_SYMBOL]);
- }
-
- function isImmutable(maybeImmutable) {
- return isCollection(maybeImmutable) || isRecord(maybeImmutable);
- }
-
- var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@';
-
- function isOrdered(maybeOrdered) {
- return Boolean(maybeOrdered && maybeOrdered[IS_ORDERED_SYMBOL]);
- }
-
- var ITERATE_KEYS = 0;
- var ITERATE_VALUES = 1;
- var ITERATE_ENTRIES = 2;
-
- var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
- var FAUX_ITERATOR_SYMBOL = '@@iterator';
-
- var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
-
- var Iterator = function Iterator(next) {
- this.next = next;
- };
-
- Iterator.prototype.toString = function toString () {
- return '[Iterator]';
- };
-
- Iterator.KEYS = ITERATE_KEYS;
- Iterator.VALUES = ITERATE_VALUES;
- Iterator.ENTRIES = ITERATE_ENTRIES;
-
- Iterator.prototype.inspect = Iterator.prototype.toSource = function() {
- return this.toString();
- };
- Iterator.prototype[ITERATOR_SYMBOL] = function() {
- return this;
- };
-
- function iteratorValue(type, k, v, iteratorResult) {
- var value = type === 0 ? k : type === 1 ? v : [k, v];
- iteratorResult
- ? (iteratorResult.value = value)
- : (iteratorResult = {
- value: value,
- done: false,
- });
- return iteratorResult;
- }
-
- function iteratorDone() {
- return { value: undefined, done: true };
- }
-
- function hasIterator(maybeIterable) {
- return !!getIteratorFn(maybeIterable);
- }
-
- function isIterator(maybeIterator) {
- return maybeIterator && typeof maybeIterator.next === 'function';
- }
-
- function getIterator(iterable) {
- var iteratorFn = getIteratorFn(iterable);
- return iteratorFn && iteratorFn.call(iterable);
- }
-
- function getIteratorFn(iterable) {
- var iteratorFn =
- iterable &&
- ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
- iterable[FAUX_ITERATOR_SYMBOL]);
- if (typeof iteratorFn === 'function') {
- return iteratorFn;
- }
- }
-
- var hasOwnProperty = Object.prototype.hasOwnProperty;
-
- function isArrayLike(value) {
- if (Array.isArray(value) || typeof value === 'string') {
- return true;
- }
-
- return (
- value &&
- typeof value === 'object' &&
- Number.isInteger(value.length) &&
- value.length >= 0 &&
- (value.length === 0
- ? // Only {length: 0} is considered Array-like.
- Object.keys(value).length === 1
- : // An object is only Array-like if it has a property where the last value
- // in the array-like may be found (which could be undefined).
- value.hasOwnProperty(value.length - 1))
- );
- }
-
- var Seq = /*@__PURE__*/(function (Collection$$1) {
- function Seq(value) {
- return value === null || value === undefined
- ? emptySequence()
- : isImmutable(value)
- ? value.toSeq()
- : seqFromValue(value);
- }
-
- if ( Collection$$1 ) Seq.__proto__ = Collection$$1;
- Seq.prototype = Object.create( Collection$$1 && Collection$$1.prototype );
- Seq.prototype.constructor = Seq;
-
- Seq.prototype.toSeq = function toSeq () {
- return this;
- };
-
- Seq.prototype.toString = function toString () {
- return this.__toString('Seq {', '}');
- };
-
- Seq.prototype.cacheResult = function cacheResult () {
- if (!this._cache && this.__iterateUncached) {
- this._cache = this.entrySeq().toArray();
- this.size = this._cache.length;
- }
- return this;
- };
-
- // abstract __iterateUncached(fn, reverse)
-
- Seq.prototype.__iterate = function __iterate (fn, reverse) {
- var cache = this._cache;
- if (cache) {
- var size = cache.length;
- var i = 0;
- while (i !== size) {
- var entry = cache[reverse ? size - ++i : i++];
- if (fn(entry[1], entry[0], this) === false) {
- break;
- }
- }
- return i;
- }
- return this.__iterateUncached(fn, reverse);
- };
-
- // abstract __iteratorUncached(type, reverse)
-
- Seq.prototype.__iterator = function __iterator (type, reverse) {
- var cache = this._cache;
- if (cache) {
- var size = cache.length;
- var i = 0;
- return new Iterator(function () {
- if (i === size) {
- return iteratorDone();
- }
- var entry = cache[reverse ? size - ++i : i++];
- return iteratorValue(type, entry[0], entry[1]);
- });
- }
- return this.__iteratorUncached(type, reverse);
- };
-
- return Seq;
- }(Collection));
-
- var KeyedSeq = /*@__PURE__*/(function (Seq) {
- function KeyedSeq(value) {
- return value === null || value === undefined
- ? emptySequence().toKeyedSeq()
- : isCollection(value)
- ? isKeyed(value)
- ? value.toSeq()
- : value.fromEntrySeq()
- : isRecord(value)
- ? value.toSeq()
- : keyedSeqFromValue(value);
- }
-
- if ( Seq ) KeyedSeq.__proto__ = Seq;
- KeyedSeq.prototype = Object.create( Seq && Seq.prototype );
- KeyedSeq.prototype.constructor = KeyedSeq;
-
- KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq () {
- return this;
- };
-
- return KeyedSeq;
- }(Seq));
-
- var IndexedSeq = /*@__PURE__*/(function (Seq) {
- function IndexedSeq(value) {
- return value === null || value === undefined
- ? emptySequence()
- : isCollection(value)
- ? isKeyed(value)
- ? value.entrySeq()
- : value.toIndexedSeq()
- : isRecord(value)
- ? value.toSeq().entrySeq()
- : indexedSeqFromValue(value);
- }
-
- if ( Seq ) IndexedSeq.__proto__ = Seq;
- IndexedSeq.prototype = Object.create( Seq && Seq.prototype );
- IndexedSeq.prototype.constructor = IndexedSeq;
-
- IndexedSeq.of = function of (/*...values*/) {
- return IndexedSeq(arguments);
- };
-
- IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq () {
- return this;
- };
-
- IndexedSeq.prototype.toString = function toString () {
- return this.__toString('Seq [', ']');
- };
-
- return IndexedSeq;
- }(Seq));
-
- var SetSeq = /*@__PURE__*/(function (Seq) {
- function SetSeq(value) {
- return (isCollection(value) && !isAssociative(value)
- ? value
- : IndexedSeq(value)
- ).toSetSeq();
- }
-
- if ( Seq ) SetSeq.__proto__ = Seq;
- SetSeq.prototype = Object.create( Seq && Seq.prototype );
- SetSeq.prototype.constructor = SetSeq;
-
- SetSeq.of = function of (/*...values*/) {
- return SetSeq(arguments);
- };
-
- SetSeq.prototype.toSetSeq = function toSetSeq () {
- return this;
- };
-
- return SetSeq;
- }(Seq));
-
- Seq.isSeq = isSeq;
- Seq.Keyed = KeyedSeq;
- Seq.Set = SetSeq;
- Seq.Indexed = IndexedSeq;
-
- Seq.prototype[IS_SEQ_SYMBOL] = true;
-
- // #pragma Root Sequences
-
- var ArraySeq = /*@__PURE__*/(function (IndexedSeq) {
- function ArraySeq(array) {
- this._array = array;
- this.size = array.length;
- }
-
- if ( IndexedSeq ) ArraySeq.__proto__ = IndexedSeq;
- ArraySeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
- ArraySeq.prototype.constructor = ArraySeq;
-
- ArraySeq.prototype.get = function get (index, notSetValue) {
- return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
- };
-
- ArraySeq.prototype.__iterate = function __iterate (fn, reverse) {
- var array = this._array;
- var size = array.length;
- var i = 0;
- while (i !== size) {
- var ii = reverse ? size - ++i : i++;
- if (fn(array[ii], ii, this) === false) {
- break;
- }
- }
- return i;
- };
-
- ArraySeq.prototype.__iterator = function __iterator (type, reverse) {
- var array = this._array;
- var size = array.length;
- var i = 0;
- return new Iterator(function () {
- if (i === size) {
- return iteratorDone();
- }
- var ii = reverse ? size - ++i : i++;
- return iteratorValue(type, ii, array[ii]);
- });
- };
-
- return ArraySeq;
- }(IndexedSeq));
-
- var ObjectSeq = /*@__PURE__*/(function (KeyedSeq) {
- function ObjectSeq(object) {
- var keys = Object.keys(object);
- this._object = object;
- this._keys = keys;
- this.size = keys.length;
- }
-
- if ( KeyedSeq ) ObjectSeq.__proto__ = KeyedSeq;
- ObjectSeq.prototype = Object.create( KeyedSeq && KeyedSeq.prototype );
- ObjectSeq.prototype.constructor = ObjectSeq;
-
- ObjectSeq.prototype.get = function get (key, notSetValue) {
- if (notSetValue !== undefined && !this.has(key)) {
- return notSetValue;
- }
- return this._object[key];
- };
-
- ObjectSeq.prototype.has = function has (key) {
- return hasOwnProperty.call(this._object, key);
- };
-
- ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) {
- var object = this._object;
- var keys = this._keys;
- var size = keys.length;
- var i = 0;
- while (i !== size) {
- var key = keys[reverse ? size - ++i : i++];
- if (fn(object[key], key, this) === false) {
- break;
- }
- }
- return i;
- };
-
- ObjectSeq.prototype.__iterator = function __iterator (type, reverse) {
- var object = this._object;
- var keys = this._keys;
- var size = keys.length;
- var i = 0;
- return new Iterator(function () {
- if (i === size) {
- return iteratorDone();
- }
- var key = keys[reverse ? size - ++i : i++];
- return iteratorValue(type, key, object[key]);
- });
- };
-
- return ObjectSeq;
- }(KeyedSeq));
- ObjectSeq.prototype[IS_ORDERED_SYMBOL] = true;
-
- var CollectionSeq = /*@__PURE__*/(function (IndexedSeq) {
- function CollectionSeq(collection) {
- this._collection = collection;
- this.size = collection.length || collection.size;
- }
-
- if ( IndexedSeq ) CollectionSeq.__proto__ = IndexedSeq;
- CollectionSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
- CollectionSeq.prototype.constructor = CollectionSeq;
-
- CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) {
- if (reverse) {
- return this.cacheResult().__iterate(fn, reverse);
- }
- var collection = this._collection;
- var iterator = getIterator(collection);
- var iterations = 0;
- if (isIterator(iterator)) {
- var step;
- while (!(step = iterator.next()).done) {
- if (fn(step.value, iterations++, this) === false) {
- break;
- }
- }
- }
- return iterations;
- };
-
- CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) {
- if (reverse) {
- return this.cacheResult().__iterator(type, reverse);
- }
- var collection = this._collection;
- var iterator = getIterator(collection);
- if (!isIterator(iterator)) {
- return new Iterator(iteratorDone);
- }
- var iterations = 0;
- return new Iterator(function () {
- var step = iterator.next();
- return step.done ? step : iteratorValue(type, iterations++, step.value);
- });
- };
-
- return CollectionSeq;
- }(IndexedSeq));
-
- // # pragma Helper functions
-
- var EMPTY_SEQ;
-
- function emptySequence() {
- return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
- }
-
- function keyedSeqFromValue(value) {
- var seq = Array.isArray(value)
- ? new ArraySeq(value)
- : hasIterator(value)
- ? new CollectionSeq(value)
- : undefined;
- if (seq) {
- return seq.fromEntrySeq();
- }
- if (typeof value === 'object') {
- return new ObjectSeq(value);
- }
- throw new TypeError(
- 'Expected Array or collection object of [k, v] entries, or keyed object: ' +
- value
- );
- }
-
- function indexedSeqFromValue(value) {
- var seq = maybeIndexedSeqFromValue(value);
- if (seq) {
- return seq;
- }
- throw new TypeError(
- 'Expected Array or collection object of values: ' + value
- );
- }
-
- function seqFromValue(value) {
- var seq = maybeIndexedSeqFromValue(value);
- if (seq) {
- return seq;
- }
- if (typeof value === 'object') {
- return new ObjectSeq(value);
- }
- throw new TypeError(
- 'Expected Array or collection object of values, or keyed object: ' + value
- );
- }
-
- function maybeIndexedSeqFromValue(value) {
- return isArrayLike(value)
- ? new ArraySeq(value)
- : hasIterator(value)
- ? new CollectionSeq(value)
- : undefined;
- }
-
- var IS_MAP_SYMBOL = '@@__IMMUTABLE_MAP__@@';
-
- function isMap(maybeMap) {
- return Boolean(maybeMap && maybeMap[IS_MAP_SYMBOL]);
- }
-
- function isOrderedMap(maybeOrderedMap) {
- return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
- }
-
- function isValueObject(maybeValue) {
- return Boolean(
- maybeValue &&
- typeof maybeValue.equals === 'function' &&
- typeof maybeValue.hashCode === 'function'
- );
- }
-
- /**
- * An extension of the "same-value" algorithm as [described for use by ES6 Map
- * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
- *
- * NaN is considered the same as NaN, however -0 and 0 are considered the same
- * value, which is different from the algorithm described by
- * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
- *
- * This is extended further to allow Objects to describe the values they
- * represent, by way of `valueOf` or `equals` (and `hashCode`).
- *
- * Note: because of this extension, the key equality of Immutable.Map and the
- * value equality of Immutable.Set will differ from ES6 Map and Set.
- *
- * ### Defining custom values
- *
- * The easiest way to describe the value an object represents is by implementing
- * `valueOf`. For example, `Date` represents a value by returning a unix
- * timestamp for `valueOf`:
- *
- * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
- * var date2 = new Date(1234567890000);
- * date1.valueOf(); // 1234567890000
- * assert( date1 !== date2 );
- * assert( Immutable.is( date1, date2 ) );
- *
- * Note: overriding `valueOf` may have other implications if you use this object
- * where JavaScript expects a primitive, such as implicit string coercion.
- *
- * For more complex types, especially collections, implementing `valueOf` may
- * not be performant. An alternative is to implement `equals` and `hashCode`.
- *
- * `equals` takes another object, presumably of similar type, and returns true
- * if it is equal. Equality is symmetrical, so the same result should be
- * returned if this and the argument are flipped.
- *
- * assert( a.equals(b) === b.equals(a) );
- *
- * `hashCode` returns a 32bit integer number representing the object which will
- * be used to determine how to store the value object in a Map or Set. You must
- * provide both or neither methods, one must not exist without the other.
- *
- * Also, an important relationship between these methods must be upheld: if two
- * values are equal, they *must* return the same hashCode. If the values are not
- * equal, they might have the same hashCode; this is called a hash collision,
- * and while undesirable for performance reasons, it is acceptable.
- *
- * if (a.equals(b)) {
- * assert( a.hashCode() === b.hashCode() );
- * }
- *
- * All Immutable collections are Value Objects: they implement `equals()`
- * and `hashCode()`.
- */
- function is(valueA, valueB) {
- if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
- return true;
- }
- if (!valueA || !valueB) {
- return false;
- }
- if (
- typeof valueA.valueOf === 'function' &&
- typeof valueB.valueOf === 'function'
- ) {
- valueA = valueA.valueOf();
- valueB = valueB.valueOf();
- if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
- return true;
- }
- if (!valueA || !valueB) {
- return false;
- }
- }
- return !!(
- isValueObject(valueA) &&
- isValueObject(valueB) &&
- valueA.equals(valueB)
- );
- }
-
- var imul =
- typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2
- ? Math.imul
- : function imul(a, b) {
- a |= 0; // int
- b |= 0; // int
- var c = a & 0xffff;
- var d = b & 0xffff;
- // Shift by 0 fixes the sign on the high part.
- return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int
- };
-
- // v8 has an optimization for storing 31-bit signed numbers.
- // Values which have either 00 or 11 as the high order bits qualify.
- // This function drops the highest order bit in a signed number, maintaining
- // the sign bit.
- function smi(i32) {
- return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff);
- }
-
- var defaultValueOf = Object.prototype.valueOf;
-
- function hash(o) {
- switch (typeof o) {
- case 'boolean':
- // The hash values for built-in constants are a 1 value for each 5-byte
- // shift region expect for the first, which encodes the value. This
- // reduces the odds of a hash collision for these common values.
- return o ? 0x42108421 : 0x42108420;
- case 'number':
- return hashNumber(o);
- case 'string':
- return o.length > STRING_HASH_CACHE_MIN_STRLEN
- ? cachedHashString(o)
- : hashString(o);
- case 'object':
- case 'function':
- if (o === null) {
- return 0x42108422;
- }
- if (typeof o.hashCode === 'function') {
- // Drop any high bits from accidentally long hash codes.
- return smi(o.hashCode(o));
- }
- if (o.valueOf !== defaultValueOf && typeof o.valueOf === 'function') {
- o = o.valueOf(o);
- }
- return hashJSObj(o);
- case 'undefined':
- return 0x42108423;
- default:
- if (typeof o.toString === 'function') {
- return hashString(o.toString());
- }
- throw new Error('Value type ' + typeof o + ' cannot be hashed.');
- }
- }
-
- // Compress arbitrarily large numbers into smi hashes.
- function hashNumber(n) {
- if (n !== n || n === Infinity) {
- return 0;
- }
- var hash = n | 0;
- if (hash !== n) {
- hash ^= n * 0xffffffff;
- }
- while (n > 0xffffffff) {
- n /= 0xffffffff;
- hash ^= n;
- }
- return smi(hash);
- }
-
- function cachedHashString(string) {
- var hashed = stringHashCache[string];
- if (hashed === undefined) {
- hashed = hashString(string);
- if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
- STRING_HASH_CACHE_SIZE = 0;
- stringHashCache = {};
- }
- STRING_HASH_CACHE_SIZE++;
- stringHashCache[string] = hashed;
- }
- return hashed;
- }
-
- // http://jsperf.com/hashing-strings
- function hashString(string) {
- // This is the hash from JVM
- // The hash code for a string is computed as
- // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
- // where s[i] is the ith character of the string and n is the length of
- // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
- // (exclusive) by dropping high bits.
- var hashed = 0;
- for (var ii = 0; ii < string.length; ii++) {
- hashed = (31 * hashed + string.charCodeAt(ii)) | 0;
- }
- return smi(hashed);
- }
-
- function hashJSObj(obj) {
- var hashed;
- if (usingWeakMap) {
- hashed = weakMap.get(obj);
- if (hashed !== undefined) {
- return hashed;
- }
- }
-
- hashed = obj[UID_HASH_KEY];
- if (hashed !== undefined) {
- return hashed;
- }
-
- if (!canDefineProperty) {
- hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
- if (hashed !== undefined) {
- return hashed;
- }
-
- hashed = getIENodeHash(obj);
- if (hashed !== undefined) {
- return hashed;
- }
- }
-
- hashed = ++objHashUID;
- if (objHashUID & 0x40000000) {
- objHashUID = 0;
- }
-
- if (usingWeakMap) {
- weakMap.set(obj, hashed);
- } else if (isExtensible !== undefined && isExtensible(obj) === false) {
- throw new Error('Non-extensible objects are not allowed as keys.');
- } else if (canDefineProperty) {
- Object.defineProperty(obj, UID_HASH_KEY, {
- enumerable: false,
- configurable: false,
- writable: false,
- value: hashed,
- });
- } else if (
- obj.propertyIsEnumerable !== undefined &&
- obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable
- ) {
- // Since we can't define a non-enumerable property on the object
- // we'll hijack one of the less-used non-enumerable properties to
- // save our hash on it. Since this is a function it will not show up in
- // `JSON.stringify` which is what we want.
- obj.propertyIsEnumerable = function() {
- return this.constructor.prototype.propertyIsEnumerable.apply(
- this,
- arguments
- );
- };
- obj.propertyIsEnumerable[UID_HASH_KEY] = hashed;
- } else if (obj.nodeType !== undefined) {
- // At this point we couldn't get the IE `uniqueID` to use as a hash
- // and we couldn't use a non-enumerable property to exploit the
- // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
- // itself.
- obj[UID_HASH_KEY] = hashed;
- } else {
- throw new Error('Unable to set a non-enumerable property on object.');
- }
-
- return hashed;
- }
-
- // Get references to ES5 object methods.
- var isExtensible = Object.isExtensible;
-
- // True if Object.defineProperty works as expected. IE8 fails this test.
- var canDefineProperty = (function() {
- try {
- Object.defineProperty({}, '@', {});
- return true;
- } catch (e) {
- return false;
- }
- })();
-
- // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
- // and avoid memory leaks from the IE cloneNode bug.
- function getIENodeHash(node) {
- if (node && node.nodeType > 0) {
- switch (node.nodeType) {
- case 1: // Element
- return node.uniqueID;
- case 9: // Document
- return node.documentElement && node.documentElement.uniqueID;
- }
- }
- }
-
- // If possible, use a WeakMap.
- var usingWeakMap = typeof WeakMap === 'function';
- var weakMap;
- if (usingWeakMap) {
- weakMap = new WeakMap();
- }
-
- var objHashUID = 0;
-
- var UID_HASH_KEY = '__immutablehash__';
- if (typeof Symbol === 'function') {
- UID_HASH_KEY = Symbol(UID_HASH_KEY);
- }
-
- var STRING_HASH_CACHE_MIN_STRLEN = 16;
- var STRING_HASH_CACHE_MAX_SIZE = 255;
- var STRING_HASH_CACHE_SIZE = 0;
- var stringHashCache = {};
-
- var ToKeyedSequence = /*@__PURE__*/(function (KeyedSeq$$1) {
- function ToKeyedSequence(indexed, useKeys) {
- this._iter = indexed;
- this._useKeys = useKeys;
- this.size = indexed.size;
- }
-
- if ( KeyedSeq$$1 ) ToKeyedSequence.__proto__ = KeyedSeq$$1;
- ToKeyedSequence.prototype = Object.create( KeyedSeq$$1 && KeyedSeq$$1.prototype );
- ToKeyedSequence.prototype.constructor = ToKeyedSequence;
-
- ToKeyedSequence.prototype.get = function get (key, notSetValue) {
- return this._iter.get(key, notSetValue);
- };
-
- ToKeyedSequence.prototype.has = function has (key) {
- return this._iter.has(key);
- };
-
- ToKeyedSequence.prototype.valueSeq = function valueSeq () {
- return this._iter.valueSeq();
- };
-
- ToKeyedSequence.prototype.reverse = function reverse () {
- var this$1 = this;
-
- var reversedSequence = reverseFactory(this, true);
- if (!this._useKeys) {
- reversedSequence.valueSeq = function () { return this$1._iter.toSeq().reverse(); };
- }
- return reversedSequence;
- };
-
- ToKeyedSequence.prototype.map = function map (mapper, context) {
- var this$1 = this;
-
- var mappedSequence = mapFactory(this, mapper, context);
- if (!this._useKeys) {
- mappedSequence.valueSeq = function () { return this$1._iter.toSeq().map(mapper, context); };
- }
- return mappedSequence;
- };
-
- ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) {
- var this$1 = this;
-
- return this._iter.__iterate(function (v, k) { return fn(v, k, this$1); }, reverse);
- };
-
- ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) {
- return this._iter.__iterator(type, reverse);
- };
-
- return ToKeyedSequence;
- }(KeyedSeq));
- ToKeyedSequence.prototype[IS_ORDERED_SYMBOL] = true;
-
- var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq$$1) {
- function ToIndexedSequence(iter) {
- this._iter = iter;
- this.size = iter.size;
- }
-
- if ( IndexedSeq$$1 ) ToIndexedSequence.__proto__ = IndexedSeq$$1;
- ToIndexedSequence.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype );
- ToIndexedSequence.prototype.constructor = ToIndexedSequence;
-
- ToIndexedSequence.prototype.includes = function includes (value) {
- return this._iter.includes(value);
- };
-
- ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) {
- var this$1 = this;
-
- var i = 0;
- reverse && ensureSize(this);
- return this._iter.__iterate(
- function (v) { return fn(v, reverse ? this$1.size - ++i : i++, this$1); },
- reverse
- );
- };
-
- ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) {
- var this$1 = this;
-
- var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
- var i = 0;
- reverse && ensureSize(this);
- return new Iterator(function () {
- var step = iterator.next();
- return step.done
- ? step
- : iteratorValue(
- type,
- reverse ? this$1.size - ++i : i++,
- step.value,
- step
- );
- });
- };
-
- return ToIndexedSequence;
- }(IndexedSeq));
-
- var ToSetSequence = /*@__PURE__*/(function (SetSeq$$1) {
- function ToSetSequence(iter) {
- this._iter = iter;
- this.size = iter.size;
- }
-
- if ( SetSeq$$1 ) ToSetSequence.__proto__ = SetSeq$$1;
- ToSetSequence.prototype = Object.create( SetSeq$$1 && SetSeq$$1.prototype );
- ToSetSequence.prototype.constructor = ToSetSequence;
-
- ToSetSequence.prototype.has = function has (key) {
- return this._iter.includes(key);
- };
-
- ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) {
- var this$1 = this;
-
- return this._iter.__iterate(function (v) { return fn(v, v, this$1); }, reverse);
- };
-
- ToSetSequence.prototype.__iterator = function __iterator (type, reverse) {
- var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
- return new Iterator(function () {
- var step = iterator.next();
- return step.done
- ? step
- : iteratorValue(type, step.value, step.value, step);
- });
- };
-
- return ToSetSequence;
- }(SetSeq));
-
- var FromEntriesSequence = /*@__PURE__*/(function (KeyedSeq$$1) {
- function FromEntriesSequence(entries) {
- this._iter = entries;
- this.size = entries.size;
- }
-
- if ( KeyedSeq$$1 ) FromEntriesSequence.__proto__ = KeyedSeq$$1;
- FromEntriesSequence.prototype = Object.create( KeyedSeq$$1 && KeyedSeq$$1.prototype );
- FromEntriesSequence.prototype.constructor = FromEntriesSequence;
-
- FromEntriesSequence.prototype.entrySeq = function entrySeq () {
- return this._iter.toSeq();
- };
-
- FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) {
- var this$1 = this;
-
- return this._iter.__iterate(function (entry) {
- // Check if entry exists first so array access doesn't throw for holes
- // in the parent iteration.
- if (entry) {
- validateEntry(entry);
- var indexedCollection = isCollection(entry);
- return fn(
- indexedCollection ? entry.get(1) : entry[1],
- indexedCollection ? entry.get(0) : entry[0],
- this$1
- );
- }
- }, reverse);
- };
-
- FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) {
- var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
- return new Iterator(function () {
- while (true) {
- var step = iterator.next();
- if (step.done) {
- return step;
- }
- var entry = step.value;
- // Check if entry exists first so array access doesn't throw for holes
- // in the parent iteration.
- if (entry) {
- validateEntry(entry);
- var indexedCollection = isCollection(entry);
- return iteratorValue(
- type,
- indexedCollection ? entry.get(0) : entry[0],
- indexedCollection ? entry.get(1) : entry[1],
- step
- );
- }
- }
- });
- };
-
- return FromEntriesSequence;
- }(KeyedSeq));
-
- ToIndexedSequence.prototype.cacheResult = ToKeyedSequence.prototype.cacheResult = ToSetSequence.prototype.cacheResult = FromEntriesSequence.prototype.cacheResult = cacheResultThrough;
-
- function flipFactory(collection) {
- var flipSequence = makeSequence(collection);
- flipSequence._iter = collection;
- flipSequence.size = collection.size;
- flipSequence.flip = function () { return collection; };
- flipSequence.reverse = function() {
- var reversedSequence = collection.reverse.apply(this); // super.reverse()
- reversedSequence.flip = function () { return collection.reverse(); };
- return reversedSequence;
- };
- flipSequence.has = function (key) { return collection.includes(key); };
- flipSequence.includes = function (key) { return collection.has(key); };
- flipSequence.cacheResult = cacheResultThrough;
- flipSequence.__iterateUncached = function(fn, reverse) {
- var this$1 = this;
-
- return collection.__iterate(function (v, k) { return fn(k, v, this$1) !== false; }, reverse);
- };
- flipSequence.__iteratorUncached = function(type, reverse) {
- if (type === ITERATE_ENTRIES) {
- var iterator = collection.__iterator(type, reverse);
- return new Iterator(function () {
- var step = iterator.next();
- if (!step.done) {
- var k = step.value[0];
- step.value[0] = step.value[1];
- step.value[1] = k;
- }
- return step;
- });
- }
- return collection.__iterator(
- type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
- reverse
- );
- };
- return flipSequence;
- }
-
- function mapFactory(collection, mapper, context) {
- var mappedSequence = makeSequence(collection);
- mappedSequence.size = collection.size;
- mappedSequence.has = function (key) { return collection.has(key); };
- mappedSequence.get = function (key, notSetValue) {
- var v = collection.get(key, NOT_SET);
- return v === NOT_SET
- ? notSetValue
- : mapper.call(context, v, key, collection);
- };
- mappedSequence.__iterateUncached = function(fn, reverse) {
- var this$1 = this;
-
- return collection.__iterate(
- function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1) !== false; },
- reverse
- );
- };
- mappedSequence.__iteratorUncached = function(type, reverse) {
- var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
- return new Iterator(function () {
- var step = iterator.next();
- if (step.done) {
- return step;
- }
- var entry = step.value;
- var key = entry[0];
- return iteratorValue(
- type,
- key,
- mapper.call(context, entry[1], key, collection),
- step
- );
- });
- };
- return mappedSequence;
- }
-
- function reverseFactory(collection, useKeys) {
- var this$1 = this;
-
- var reversedSequence = makeSequence(collection);
- reversedSequence._iter = collection;
- reversedSequence.size = collection.size;
- reversedSequence.reverse = function () { return collection; };
- if (collection.flip) {
- reversedSequence.flip = function() {
- var flipSequence = flipFactory(collection);
- flipSequence.reverse = function () { return collection.flip(); };
- return flipSequence;
- };
- }
- reversedSequence.get = function (key, notSetValue) { return collection.get(useKeys ? key : -1 - key, notSetValue); };
- reversedSequence.has = function (key) { return collection.has(useKeys ? key : -1 - key); };
- reversedSequence.includes = function (value) { return collection.includes(value); };
- reversedSequence.cacheResult = cacheResultThrough;
- reversedSequence.__iterate = function(fn, reverse) {
- var this$1 = this;
-
- var i = 0;
- reverse && ensureSize(collection);
- return collection.__iterate(
- function (v, k) { return fn(v, useKeys ? k : reverse ? this$1.size - ++i : i++, this$1); },
- !reverse
- );
- };
- reversedSequence.__iterator = function (type, reverse) {
- var i = 0;
- reverse && ensureSize(collection);
- var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse);
- return new Iterator(function () {
- var step = iterator.next();
- if (step.done) {
- return step;
- }
- var entry = step.value;
- return iteratorValue(
- type,
- useKeys ? entry[0] : reverse ? this$1.size - ++i : i++,
- entry[1],
- step
- );
- });
- };
- return reversedSequence;
- }
-
- function filterFactory(collection, predicate, context, useKeys) {
- var filterSequence = makeSequence(collection);
- if (useKeys) {
- filterSequence.has = function (key) {
- var v = collection.get(key, NOT_SET);
- return v !== NOT_SET && !!predicate.call(context, v, key, collection);
- };
- filterSequence.get = function (key, notSetValue) {
- var v = collection.get(key, NOT_SET);
- return v !== NOT_SET && predicate.call(context, v, key, collection)
- ? v
- : notSetValue;
- };
- }
- filterSequence.__iterateUncached = function(fn, reverse) {
- var this$1 = this;
-
- var iterations = 0;
- collection.__iterate(function (v, k, c) {
- if (predicate.call(context, v, k, c)) {
- iterations++;
- return fn(v, useKeys ? k : iterations - 1, this$1);
- }
- }, reverse);
- return iterations;
- };
- filterSequence.__iteratorUncached = function(type, reverse) {
- var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
- var iterations = 0;
- return new Iterator(function () {
- while (true) {
- var step = iterator.next();
- if (step.done) {
- return step;
- }
- var entry = step.value;
- var key = entry[0];
- var value = entry[1];
- if (predicate.call(context, value, key, collection)) {
- return iteratorValue(type, useKeys ? key : iterations++, value, step);
- }
- }
- });
- };
- return filterSequence;
- }
-
- function countByFactory(collection, grouper, context) {
- var groups = Map().asMutable();
- collection.__iterate(function (v, k) {
- groups.update(grouper.call(context, v, k, collection), 0, function (a) { return a + 1; });
- });
- return groups.asImmutable();
- }
-
- function groupByFactory(collection, grouper, context) {
- var isKeyedIter = isKeyed(collection);
- var groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable();
- collection.__iterate(function (v, k) {
- groups.update(
- grouper.call(context, v, k, collection),
- function (a) { return ((a = a || []), a.push(isKeyedIter ? [k, v] : v), a); }
- );
- });
- var coerce = collectionClass(collection);
- return groups.map(function (arr) { return reify(collection, coerce(arr)); }).asImmutable();
- }
-
- function sliceFactory(collection, begin, end, useKeys) {
- var originalSize = collection.size;
-
- if (wholeSlice(begin, end, originalSize)) {
- return collection;
- }
-
- var resolvedBegin = resolveBegin(begin, originalSize);
- var resolvedEnd = resolveEnd(end, originalSize);
-
- // begin or end will be NaN if they were provided as negative numbers and
- // this collection's size is unknown. In that case, cache first so there is
- // a known size and these do not resolve to NaN.
- if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
- return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys);
- }
-
- // Note: resolvedEnd is undefined when the original sequence's length is
- // unknown and this slice did not supply an end and should contain all
- // elements after resolvedBegin.
- // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
- var resolvedSize = resolvedEnd - resolvedBegin;
- var sliceSize;
- if (resolvedSize === resolvedSize) {
- sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
- }
-
- var sliceSeq = makeSequence(collection);
-
- // If collection.size is undefined, the size of the realized sliceSeq is
- // unknown at this point unless the number of items to slice is 0
- sliceSeq.size =
- sliceSize === 0 ? sliceSize : (collection.size && sliceSize) || undefined;
-
- if (!useKeys && isSeq(collection) && sliceSize >= 0) {
- sliceSeq.get = function(index, notSetValue) {
- index = wrapIndex(this, index);
- return index >= 0 && index < sliceSize
- ? collection.get(index + resolvedBegin, notSetValue)
- : notSetValue;
- };
- }
-
- sliceSeq.__iterateUncached = function(fn, reverse) {
- var this$1 = this;
-
- if (sliceSize === 0) {
- return 0;
- }
- if (reverse) {
- return this.cacheResult().__iterate(fn, reverse);
- }
- var skipped = 0;
- var isSkipping = true;
- var iterations = 0;
- collection.__iterate(function (v, k) {
- if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
- iterations++;
- return (
- fn(v, useKeys ? k : iterations - 1, this$1) !== false &&
- iterations !== sliceSize
- );
- }
- });
- return iterations;
- };
-
- sliceSeq.__iteratorUncached = function(type, reverse) {
- if (sliceSize !== 0 && reverse) {
- return this.cacheResult().__iterator(type, reverse);
- }
- // Don't bother instantiating parent iterator if taking 0.
- if (sliceSize === 0) {
- return new Iterator(iteratorDone);
- }
- var iterator = collection.__iterator(type, reverse);
- var skipped = 0;
- var iterations = 0;
- return new Iterator(function () {
- while (skipped++ < resolvedBegin) {
- iterator.next();
- }
- if (++iterations > sliceSize) {
- return iteratorDone();
- }
- var step = iterator.next();
- if (useKeys || type === ITERATE_VALUES || step.done) {
- return step;
- }
- if (type === ITERATE_KEYS) {
- return iteratorValue(type, iterations - 1, undefined, step);
- }
- return iteratorValue(type, iterations - 1, step.value[1], step);
- });
- };
-
- return sliceSeq;
- }
-
- function takeWhileFactory(collection, predicate, context) {
- var takeSequence = makeSequence(collection);
- takeSequence.__iterateUncached = function(fn, reverse) {
- var this$1 = this;
-
- if (reverse) {
- return this.cacheResult().__iterate(fn, reverse);
- }
- var iterations = 0;
- collection.__iterate(
- function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1); }
- );
- return iterations;
- };
- takeSequence.__iteratorUncached = function(type, reverse) {
- var this$1 = this;
-
- if (reverse) {
- return this.cacheResult().__iterator(type, reverse);
- }
- var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
- var iterating = true;
- return new Iterator(function () {
- if (!iterating) {
- return iteratorDone();
- }
- var step = iterator.next();
- if (step.done) {
- return step;
- }
- var entry = step.value;
- var k = entry[0];
- var v = entry[1];
- if (!predicate.call(context, v, k, this$1)) {
- iterating = false;
- return iteratorDone();
- }
- return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step);
- });
- };
- return takeSequence;
- }
-
- function skipWhileFactory(collection, predicate, context, useKeys) {
- var skipSequence = makeSequence(collection);
- skipSequence.__iterateUncached = function(fn, reverse) {
- var this$1 = this;
-
- if (reverse) {
- return this.cacheResult().__iterate(fn, reverse);
- }
- var isSkipping = true;
- var iterations = 0;
- collection.__iterate(function (v, k, c) {
- if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
- iterations++;
- return fn(v, useKeys ? k : iterations - 1, this$1);
- }
- });
- return iterations;
- };
- skipSequence.__iteratorUncached = function(type, reverse) {
- var this$1 = this;
-
- if (reverse) {
- return this.cacheResult().__iterator(type, reverse);
- }
- var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
- var skipping = true;
- var iterations = 0;
- return new Iterator(function () {
- var step;
- var k;
- var v;
- do {
- step = iterator.next();
- if (step.done) {
- if (useKeys || type === ITERATE_VALUES) {
- return step;
- }
- if (type === ITERATE_KEYS) {
- return iteratorValue(type, iterations++, undefined, step);
- }
- return iteratorValue(type, iterations++, step.value[1], step);
- }
- var entry = step.value;
- k = entry[0];
- v = entry[1];
- skipping && (skipping = predicate.call(context, v, k, this$1));
- } while (skipping);
- return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step);
- });
- };
- return skipSequence;
- }
-
- function concatFactory(collection, values) {
- var isKeyedCollection = isKeyed(collection);
- var iters = [collection]
- .concat(values)
- .map(function (v) {
- if (!isCollection(v)) {
- v = isKeyedCollection
- ? keyedSeqFromValue(v)
- : indexedSeqFromValue(Array.isArray(v) ? v : [v]);
- } else if (isKeyedCollection) {
- v = KeyedCollection(v);
- }
- return v;
- })
- .filter(function (v) { return v.size !== 0; });
-
- if (iters.length === 0) {
- return collection;
- }
-
- if (iters.length === 1) {
- var singleton = iters[0];
- if (
- singleton === collection ||
- (isKeyedCollection && isKeyed(singleton)) ||
- (isIndexed(collection) && isIndexed(singleton))
- ) {
- return singleton;
- }
- }
-
- var concatSeq = new ArraySeq(iters);
- if (isKeyedCollection) {
- concatSeq = concatSeq.toKeyedSeq();
- } else if (!isIndexed(collection)) {
- concatSeq = concatSeq.toSetSeq();
- }
- concatSeq = concatSeq.flatten(true);
- concatSeq.size = iters.reduce(function (sum, seq) {
- if (sum !== undefined) {
- var size = seq.size;
- if (size !== undefined) {
- return sum + size;
- }
- }
- }, 0);
- return concatSeq;
- }
-
- function flattenFactory(collection, depth, useKeys) {
- var flatSequence = makeSequence(collection);
- flatSequence.__iterateUncached = function(fn, reverse) {
- if (reverse) {
- return this.cacheResult().__iterate(fn, reverse);
- }
- var iterations = 0;
- var stopped = false;
- function flatDeep(iter, currentDepth) {
- iter.__iterate(function (v, k) {
- if ((!depth || currentDepth < depth) && isCollection(v)) {
- flatDeep(v, currentDepth + 1);
- } else {
- iterations++;
- if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) {
- stopped = true;
- }
- }
- return !stopped;
- }, reverse);
- }
- flatDeep(collection, 0);
- return iterations;
- };
- flatSequence.__iteratorUncached = function(type, reverse) {
- if (reverse) {
- return this.cacheResult().__iterator(type, reverse);
- }
- var iterator = collection.__iterator(type, reverse);
- var stack = [];
- var iterations = 0;
- return new Iterator(function () {
- while (iterator) {
- var step = iterator.next();
- if (step.done !== false) {
- iterator = stack.pop();
- continue;
- }
- var v = step.value;
- if (type === ITERATE_ENTRIES) {
- v = v[1];
- }
- if ((!depth || stack.length < depth) && isCollection(v)) {
- stack.push(iterator);
- iterator = v.__iterator(type, reverse);
- } else {
- return useKeys ? step : iteratorValue(type, iterations++, v, step);
- }
- }
- return iteratorDone();
- });
- };
- return flatSequence;
- }
-
- function flatMapFactory(collection, mapper, context) {
- var coerce = collectionClass(collection);
- return collection
- .toSeq()
- .map(function (v, k) { return coerce(mapper.call(context, v, k, collection)); })
- .flatten(true);
- }
-
- function interposeFactory(collection, separator) {
- var interposedSequence = makeSequence(collection);
- interposedSequence.size = collection.size && collection.size * 2 - 1;
- interposedSequence.__iterateUncached = function(fn, reverse) {
- var this$1 = this;
-
- var iterations = 0;
- collection.__iterate(
- function (v) { return (!iterations || fn(separator, iterations++, this$1) !== false) &&
- fn(v, iterations++, this$1) !== false; },
- reverse
- );
- return iterations;
- };
- interposedSequence.__iteratorUncached = function(type, reverse) {
- var iterator = collection.__iterator(ITERATE_VALUES, reverse);
- var iterations = 0;
- var step;
- return new Iterator(function () {
- if (!step || iterations % 2) {
- step = iterator.next();
- if (step.done) {
- return step;
- }
- }
- return iterations % 2
- ? iteratorValue(type, iterations++, separator)
- : iteratorValue(type, iterations++, step.value, step);
- });
- };
- return interposedSequence;
- }
-
- function sortFactory(collection, comparator, mapper) {
- if (!comparator) {
- comparator = defaultComparator;
- }
- var isKeyedCollection = isKeyed(collection);
- var index = 0;
- var entries = collection
- .toSeq()
- .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; })
- .valueSeq()
- .toArray();
- entries.sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; }).forEach(
- isKeyedCollection
- ? function (v, i) {
- entries[i].length = 2;
- }
- : function (v, i) {
- entries[i] = v[1];
- }
- );
- return isKeyedCollection
- ? KeyedSeq(entries)
- : isIndexed(collection)
- ? IndexedSeq(entries)
- : SetSeq(entries);
- }
-
- function maxFactory(collection, comparator, mapper) {
- if (!comparator) {
- comparator = defaultComparator;
- }
- if (mapper) {
- var entry = collection
- .toSeq()
- .map(function (v, k) { return [v, mapper(v, k, collection)]; })
- .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); });
- return entry && entry[0];
- }
- return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); });
- }
-
- function maxCompare(comparator, a, b) {
- var comp = comparator(b, a);
- // b is considered the new max if the comparator declares them equal, but
- // they are not equal and b is in fact a nullish value.
- return (
- (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) ||
- comp > 0
- );
- }
-
- function zipWithFactory(keyIter, zipper, iters, zipAll) {
- var zipSequence = makeSequence(keyIter);
- var sizes = new ArraySeq(iters).map(function (i) { return i.size; });
- zipSequence.size = zipAll ? sizes.max() : sizes.min();
- // Note: this a generic base implementation of __iterate in terms of
- // __iterator which may be more generically useful in the future.
- zipSequence.__iterate = function(fn, reverse) {
- /* generic:
- var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
- var step;
- var iterations = 0;
- while (!(step = iterator.next()).done) {
- iterations++;
- if (fn(step.value[1], step.value[0], this) === false) {
- break;
- }
- }
- return iterations;
- */
- // indexed:
- var iterator = this.__iterator(ITERATE_VALUES, reverse);
- var step;
- var iterations = 0;
- while (!(step = iterator.next()).done) {
- if (fn(step.value, iterations++, this) === false) {
- break;
- }
- }
- return iterations;
- };
- zipSequence.__iteratorUncached = function(type, reverse) {
- var iterators = iters.map(
- function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); }
- );
- var iterations = 0;
- var isDone = false;
- return new Iterator(function () {
- var steps;
- if (!isDone) {
- steps = iterators.map(function (i) { return i.next(); });
- isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; });
- }
- if (isDone) {
- return iteratorDone();
- }
- return iteratorValue(
- type,
- iterations++,
- zipper.apply(null, steps.map(function (s) { return s.value; }))
- );
- });
- };
- return zipSequence;
- }
-
- // #pragma Helper Functions
-
- function reify(iter, seq) {
- return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq);
- }
-
- function validateEntry(entry) {
- if (entry !== Object(entry)) {
- throw new TypeError('Expected [K, V] tuple: ' + entry);
- }
- }
-
- function collectionClass(collection) {
- return isKeyed(collection)
- ? KeyedCollection
- : isIndexed(collection)
- ? IndexedCollection
- : SetCollection;
- }
-
- function makeSequence(collection) {
- return Object.create(
- (isKeyed(collection)
- ? KeyedSeq
- : isIndexed(collection)
- ? IndexedSeq
- : SetSeq
- ).prototype
- );
- }
-
- function cacheResultThrough() {
- if (this._iter.cacheResult) {
- this._iter.cacheResult();
- this.size = this._iter.size;
- return this;
- }
- return Seq.prototype.cacheResult.call(this);
- }
-
- function defaultComparator(a, b) {
- if (a === undefined && b === undefined) {
- return 0;
- }
-
- if (a === undefined) {
- return 1;
- }
-
- if (b === undefined) {
- return -1;
- }
-
- return a > b ? 1 : a < b ? -1 : 0;
- }
-
- // http://jsperf.com/copy-array-inline
- function arrCopy(arr, offset) {
- offset = offset || 0;
- var len = Math.max(0, arr.length - offset);
- var newArr = new Array(len);
- for (var ii = 0; ii < len; ii++) {
- newArr[ii] = arr[ii + offset];
- }
- return newArr;
- }
-
- function invariant(condition, error) {
- if (!condition) { throw new Error(error); }
- }
-
- function assertNotInfinite(size) {
- invariant(
- size !== Infinity,
- 'Cannot perform this action with an infinite size.'
- );
- }
-
- function coerceKeyPath(keyPath) {
- if (isArrayLike(keyPath) && typeof keyPath !== 'string') {
- return keyPath;
- }
- if (isOrdered(keyPath)) {
- return keyPath.toArray();
- }
- throw new TypeError(
- 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath
- );
- }
-
- function isPlainObj(value) {
- return (
- value &&
- (typeof value.constructor !== 'function' ||
- value.constructor.name === 'Object')
- );
- }
-
- /**
- * Returns true if the value is a potentially-persistent data structure, either
- * provided by Immutable.js or a plain Array or Object.
- */
- function isDataStructure(value) {
- return (
- typeof value === 'object' &&
- (isImmutable(value) || Array.isArray(value) || isPlainObj(value))
- );
- }
-
- /**
- * Converts a value to a string, adding quotes if a string was provided.
- */
- function quoteString(value) {
- try {
- return typeof value === 'string' ? JSON.stringify(value) : String(value);
- } catch (_ignoreError) {
- return JSON.stringify(value);
- }
- }
-
- function has(collection, key) {
- return isImmutable(collection)
- ? collection.has(key)
- : isDataStructure(collection) && hasOwnProperty.call(collection, key);
- }
-
- function get(collection, key, notSetValue) {
- return isImmutable(collection)
- ? collection.get(key, notSetValue)
- : !has(collection, key)
- ? notSetValue
- : typeof collection.get === 'function'
- ? collection.get(key)
- : collection[key];
- }
-
- function shallowCopy(from) {
- if (Array.isArray(from)) {
- return arrCopy(from);
- }
- var to = {};
- for (var key in from) {
- if (hasOwnProperty.call(from, key)) {
- to[key] = from[key];
- }
- }
- return to;
- }
-
- function remove(collection, key) {
- if (!isDataStructure(collection)) {
- throw new TypeError(
- 'Cannot update non-data-structure value: ' + collection
- );
- }
- if (isImmutable(collection)) {
- if (!collection.remove) {
- throw new TypeError(
- 'Cannot update immutable value without .remove() method: ' + collection
- );
- }
- return collection.remove(key);
- }
- if (!hasOwnProperty.call(collection, key)) {
- return collection;
- }
- var collectionCopy = shallowCopy(collection);
- if (Array.isArray(collectionCopy)) {
- collectionCopy.splice(key, 1);
- } else {
- delete collectionCopy[key];
- }
- return collectionCopy;
- }
-
- function set(collection, key, value) {
- if (!isDataStructure(collection)) {
- throw new TypeError(
- 'Cannot update non-data-structure value: ' + collection
- );
- }
- if (isImmutable(collection)) {
- if (!collection.set) {
- throw new TypeError(
- 'Cannot update immutable value without .set() method: ' + collection
- );
- }
- return collection.set(key, value);
- }
- if (hasOwnProperty.call(collection, key) && value === collection[key]) {
- return collection;
- }
- var collectionCopy = shallowCopy(collection);
- collectionCopy[key] = value;
- return collectionCopy;
- }
-
- function updateIn(collection, keyPath, notSetValue, updater) {
- if (!updater) {
- updater = notSetValue;
- notSetValue = undefined;
- }
- var updatedValue = updateInDeeply(
- isImmutable(collection),
- collection,
- coerceKeyPath(keyPath),
- 0,
- notSetValue,
- updater
- );
- return updatedValue === NOT_SET ? notSetValue : updatedValue;
- }
-
- function updateInDeeply(
- inImmutable,
- existing,
- keyPath,
- i,
- notSetValue,
- updater
- ) {
- var wasNotSet = existing === NOT_SET;
- if (i === keyPath.length) {
- var existingValue = wasNotSet ? notSetValue : existing;
- var newValue = updater(existingValue);
- return newValue === existingValue ? existing : newValue;
- }
- if (!wasNotSet && !isDataStructure(existing)) {
- throw new TypeError(
- 'Cannot update within non-data-structure value in path [' +
- keyPath.slice(0, i).map(quoteString) +
- ']: ' +
- existing
- );
- }
- var key = keyPath[i];
- var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET);
- var nextUpdated = updateInDeeply(
- nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting),
- nextExisting,
- keyPath,
- i + 1,
- notSetValue,
- updater
- );
- return nextUpdated === nextExisting
- ? existing
- : nextUpdated === NOT_SET
- ? remove(existing, key)
- : set(
- wasNotSet ? (inImmutable ? emptyMap() : {}) : existing,
- key,
- nextUpdated
- );
- }
-
- function setIn(collection, keyPath, value) {
- return updateIn(collection, keyPath, NOT_SET, function () { return value; });
- }
-
- function setIn$1(keyPath, v) {
- return setIn(this, keyPath, v);
- }
-
- function removeIn(collection, keyPath) {
- return updateIn(collection, keyPath, function () { return NOT_SET; });
- }
-
- function deleteIn(keyPath) {
- return removeIn(this, keyPath);
- }
-
- function update(collection, key, notSetValue, updater) {
- return updateIn(collection, [key], notSetValue, updater);
- }
-
- function update$1(key, notSetValue, updater) {
- return arguments.length === 1
- ? key(this)
- : update(this, key, notSetValue, updater);
- }
-
- function updateIn$1(keyPath, notSetValue, updater) {
- return updateIn(this, keyPath, notSetValue, updater);
- }
-
- function merge() {
- var iters = [], len = arguments.length;
- while ( len-- ) iters[ len ] = arguments[ len ];
-
- return mergeIntoKeyedWith(this, iters);
- }
-
- function mergeWith(merger) {
- var iters = [], len = arguments.length - 1;
- while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
-
- if (typeof merger !== 'function') {
- throw new TypeError('Invalid merger function: ' + merger);
- }
- return mergeIntoKeyedWith(this, iters, merger);
- }
-
- function mergeIntoKeyedWith(collection, collections, merger) {
- var iters = [];
- for (var ii = 0; ii < collections.length; ii++) {
- var collection$1 = KeyedCollection(collections[ii]);
- if (collection$1.size !== 0) {
- iters.push(collection$1);
- }
- }
- if (iters.length === 0) {
- return collection;
- }
- if (
- collection.toSeq().size === 0 &&
- !collection.__ownerID &&
- iters.length === 1
- ) {
- return collection.constructor(iters[0]);
- }
- return collection.withMutations(function (collection) {
- var mergeIntoCollection = merger
- ? function (value, key) {
- update(
- collection,
- key,
- NOT_SET,
- function (oldVal) { return (oldVal === NOT_SET ? value : merger(oldVal, value, key)); }
- );
- }
- : function (value, key) {
- collection.set(key, value);
- };
- for (var ii = 0; ii < iters.length; ii++) {
- iters[ii].forEach(mergeIntoCollection);
- }
- });
- }
-
- function merge$1(collection) {
- var sources = [], len = arguments.length - 1;
- while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
-
- return mergeWithSources(collection, sources);
- }
-
- function mergeWith$1(merger, collection) {
- var sources = [], len = arguments.length - 2;
- while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
-
- return mergeWithSources(collection, sources, merger);
- }
-
- function mergeDeep(collection) {
- var sources = [], len = arguments.length - 1;
- while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
-
- return mergeDeepWithSources(collection, sources);
- }
-
- function mergeDeepWith(merger, collection) {
- var sources = [], len = arguments.length - 2;
- while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
-
- return mergeDeepWithSources(collection, sources, merger);
- }
-
- function mergeDeepWithSources(collection, sources, merger) {
- return mergeWithSources(collection, sources, deepMergerWith(merger));
- }
-
- function mergeWithSources(collection, sources, merger) {
- if (!isDataStructure(collection)) {
- throw new TypeError(
- 'Cannot merge into non-data-structure value: ' + collection
- );
- }
- if (isImmutable(collection)) {
- return typeof merger === 'function' && collection.mergeWith
- ? collection.mergeWith.apply(collection, [ merger ].concat( sources ))
- : collection.merge
- ? collection.merge.apply(collection, sources)
- : collection.concat.apply(collection, sources);
- }
- var isArray = Array.isArray(collection);
- var merged = collection;
- var Collection$$1 = isArray ? IndexedCollection : KeyedCollection;
- var mergeItem = isArray
- ? function (value) {
- // Copy on write
- if (merged === collection) {
- merged = shallowCopy(merged);
- }
- merged.push(value);
- }
- : function (value, key) {
- var hasVal = hasOwnProperty.call(merged, key);
- var nextVal =
- hasVal && merger ? merger(merged[key], value, key) : value;
- if (!hasVal || nextVal !== merged[key]) {
- // Copy on write
- if (merged === collection) {
- merged = shallowCopy(merged);
- }
- merged[key] = nextVal;
- }
- };
- for (var i = 0; i < sources.length; i++) {
- Collection$$1(sources[i]).forEach(mergeItem);
- }
- return merged;
- }
-
- function deepMergerWith(merger) {
- function deepMerger(oldValue, newValue, key) {
- return isDataStructure(oldValue) && isDataStructure(newValue)
- ? mergeWithSources(oldValue, [newValue], deepMerger)
- : merger
- ? merger(oldValue, newValue, key)
- : newValue;
- }
- return deepMerger;
- }
-
- function mergeDeep$1() {
- var iters = [], len = arguments.length;
- while ( len-- ) iters[ len ] = arguments[ len ];
-
- return mergeDeepWithSources(this, iters);
- }
-
- function mergeDeepWith$1(merger) {
- var iters = [], len = arguments.length - 1;
- while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
-
- return mergeDeepWithSources(this, iters, merger);
- }
-
- function mergeIn(keyPath) {
- var iters = [], len = arguments.length - 1;
- while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
-
- return updateIn(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); });
- }
-
- function mergeDeepIn(keyPath) {
- var iters = [], len = arguments.length - 1;
- while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
-
- return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); }
- );
- }
-
- function withMutations(fn) {
- var mutable = this.asMutable();
- fn(mutable);
- return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
- }
-
- function asMutable() {
- return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
- }
-
- function asImmutable() {
- return this.__ensureOwner();
- }
-
- function wasAltered() {
- return this.__altered;
- }
-
- var Map = /*@__PURE__*/(function (KeyedCollection$$1) {
- function Map(value) {
- return value === null || value === undefined
- ? emptyMap()
- : isMap(value) && !isOrdered(value)
- ? value
- : emptyMap().withMutations(function (map) {
- var iter = KeyedCollection$$1(value);
- assertNotInfinite(iter.size);
- iter.forEach(function (v, k) { return map.set(k, v); });
- });
- }
-
- if ( KeyedCollection$$1 ) Map.__proto__ = KeyedCollection$$1;
- Map.prototype = Object.create( KeyedCollection$$1 && KeyedCollection$$1.prototype );
- Map.prototype.constructor = Map;
-
- Map.of = function of () {
- var keyValues = [], len = arguments.length;
- while ( len-- ) keyValues[ len ] = arguments[ len ];
-
- return emptyMap().withMutations(function (map) {
- for (var i = 0; i < keyValues.length; i += 2) {
- if (i + 1 >= keyValues.length) {
- throw new Error('Missing value for key: ' + keyValues[i]);
- }
- map.set(keyValues[i], keyValues[i + 1]);
- }
- });
- };
-
- Map.prototype.toString = function toString () {
- return this.__toString('Map {', '}');
- };
-
- // @pragma Access
-
- Map.prototype.get = function get (k, notSetValue) {
- return this._root
- ? this._root.get(0, undefined, k, notSetValue)
- : notSetValue;
- };
-
- // @pragma Modification
-
- Map.prototype.set = function set (k, v) {
- return updateMap(this, k, v);
- };
-
- Map.prototype.remove = function remove (k) {
- return updateMap(this, k, NOT_SET);
- };
-
- Map.prototype.deleteAll = function deleteAll (keys) {
- var collection = Collection(keys);
-
- if (collection.size === 0) {
- return this;
- }
-
- return this.withMutations(function (map) {
- collection.forEach(function (key) { return map.remove(key); });
- });
- };
-
- Map.prototype.clear = function clear () {
- if (this.size === 0) {
- return this;
- }
- if (this.__ownerID) {
- this.size = 0;
- this._root = null;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return emptyMap();
- };
-
- // @pragma Composition
-
- Map.prototype.sort = function sort (comparator) {
- // Late binding
- return OrderedMap(sortFactory(this, comparator));
- };
-
- Map.prototype.sortBy = function sortBy (mapper, comparator) {
- // Late binding
- return OrderedMap(sortFactory(this, comparator, mapper));
- };
-
- Map.prototype.map = function map (mapper, context) {
- return this.withMutations(function (map) {
- map.forEach(function (value, key) {
- map.set(key, mapper.call(context, value, key, map));
- });
- });
- };
-
- // @pragma Mutability
-
- Map.prototype.__iterator = function __iterator (type, reverse) {
- return new MapIterator(this, type, reverse);
- };
-
- Map.prototype.__iterate = function __iterate (fn, reverse) {
- var this$1 = this;
-
- var iterations = 0;
- this._root &&
- this._root.iterate(function (entry) {
- iterations++;
- return fn(entry[1], entry[0], this$1);
- }, reverse);
- return iterations;
- };
-
- Map.prototype.__ensureOwner = function __ensureOwner (ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- if (!ownerID) {
- if (this.size === 0) {
- return emptyMap();
- }
- this.__ownerID = ownerID;
- this.__altered = false;
- return this;
- }
- return makeMap(this.size, this._root, ownerID, this.__hash);
- };
-
- return Map;
- }(KeyedCollection));
-
- Map.isMap = isMap;
-
- var MapPrototype = Map.prototype;
- MapPrototype[IS_MAP_SYMBOL] = true;
- MapPrototype[DELETE] = MapPrototype.remove;
- MapPrototype.removeAll = MapPrototype.deleteAll;
- MapPrototype.setIn = setIn$1;
- MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn;
- MapPrototype.update = update$1;
- MapPrototype.updateIn = updateIn$1;
- MapPrototype.merge = MapPrototype.concat = merge;
- MapPrototype.mergeWith = mergeWith;
- MapPrototype.mergeDeep = mergeDeep$1;
- MapPrototype.mergeDeepWith = mergeDeepWith$1;
- MapPrototype.mergeIn = mergeIn;
- MapPrototype.mergeDeepIn = mergeDeepIn;
- MapPrototype.withMutations = withMutations;
- MapPrototype.wasAltered = wasAltered;
- MapPrototype.asImmutable = asImmutable;
- MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable;
- MapPrototype['@@transducer/step'] = function(result, arr) {
- return result.set(arr[0], arr[1]);
- };
- MapPrototype['@@transducer/result'] = function(obj) {
- return obj.asImmutable();
- };
-
- // #pragma Trie Nodes
-
- var ArrayMapNode = function ArrayMapNode(ownerID, entries) {
- this.ownerID = ownerID;
- this.entries = entries;
- };
-
- ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
- var entries = this.entries;
- for (var ii = 0, len = entries.length; ii < len; ii++) {
- if (is(key, entries[ii][0])) {
- return entries[ii][1];
- }
- }
- return notSetValue;
- };
-
- ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- var removed = value === NOT_SET;
-
- var entries = this.entries;
- var idx = 0;
- var len = entries.length;
- for (; idx < len; idx++) {
- if (is(key, entries[idx][0])) {
- break;
- }
- }
- var exists = idx < len;
-
- if (exists ? entries[idx][1] === value : removed) {
- return this;
- }
-
- SetRef(didAlter);
- (removed || !exists) && SetRef(didChangeSize);
-
- if (removed && entries.length === 1) {
- return; // undefined
- }
-
- if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
- return createNodes(ownerID, entries, key, value);
- }
-
- var isEditable = ownerID && ownerID === this.ownerID;
- var newEntries = isEditable ? entries : arrCopy(entries);
-
- if (exists) {
- if (removed) {
- idx === len - 1
- ? newEntries.pop()
- : (newEntries[idx] = newEntries.pop());
- } else {
- newEntries[idx] = [key, value];
- }
- } else {
- newEntries.push([key, value]);
- }
-
- if (isEditable) {
- this.entries = newEntries;
- return this;
- }
-
- return new ArrayMapNode(ownerID, newEntries);
- };
-
- var BitmapIndexedNode = function BitmapIndexedNode(ownerID, bitmap, nodes) {
- this.ownerID = ownerID;
- this.bitmap = bitmap;
- this.nodes = nodes;
- };
-
- BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
- if (keyHash === undefined) {
- keyHash = hash(key);
- }
- var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK);
- var bitmap = this.bitmap;
- return (bitmap & bit) === 0
- ? notSetValue
- : this.nodes[popCount(bitmap & (bit - 1))].get(
- shift + SHIFT,
- keyHash,
- key,
- notSetValue
- );
- };
-
- BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- if (keyHash === undefined) {
- keyHash = hash(key);
- }
- var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
- var bit = 1 << keyHashFrag;
- var bitmap = this.bitmap;
- var exists = (bitmap & bit) !== 0;
-
- if (!exists && value === NOT_SET) {
- return this;
- }
-
- var idx = popCount(bitmap & (bit - 1));
- var nodes = this.nodes;
- var node = exists ? nodes[idx] : undefined;
- var newNode = updateNode(
- node,
- ownerID,
- shift + SHIFT,
- keyHash,
- key,
- value,
- didChangeSize,
- didAlter
- );
-
- if (newNode === node) {
- return this;
- }
-
- if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
- return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
- }
-
- if (
- exists &&
- !newNode &&
- nodes.length === 2 &&
- isLeafNode(nodes[idx ^ 1])
- ) {
- return nodes[idx ^ 1];
- }
-
- if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
- return newNode;
- }
-
- var isEditable = ownerID && ownerID === this.ownerID;
- var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit;
- var newNodes = exists
- ? newNode
- ? setAt(nodes, idx, newNode, isEditable)
- : spliceOut(nodes, idx, isEditable)
- : spliceIn(nodes, idx, newNode, isEditable);
-
- if (isEditable) {
- this.bitmap = newBitmap;
- this.nodes = newNodes;
- return this;
- }
-
- return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
- };
-
- var HashArrayMapNode = function HashArrayMapNode(ownerID, count, nodes) {
- this.ownerID = ownerID;
- this.count = count;
- this.nodes = nodes;
- };
-
- HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
- if (keyHash === undefined) {
- keyHash = hash(key);
- }
- var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
- var node = this.nodes[idx];
- return node
- ? node.get(shift + SHIFT, keyHash, key, notSetValue)
- : notSetValue;
- };
-
- HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- if (keyHash === undefined) {
- keyHash = hash(key);
- }
- var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
- var removed = value === NOT_SET;
- var nodes = this.nodes;
- var node = nodes[idx];
-
- if (removed && !node) {
- return this;
- }
-
- var newNode = updateNode(
- node,
- ownerID,
- shift + SHIFT,
- keyHash,
- key,
- value,
- didChangeSize,
- didAlter
- );
- if (newNode === node) {
- return this;
- }
-
- var newCount = this.count;
- if (!node) {
- newCount++;
- } else if (!newNode) {
- newCount--;
- if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
- return packNodes(ownerID, nodes, newCount, idx);
- }
- }
-
- var isEditable = ownerID && ownerID === this.ownerID;
- var newNodes = setAt(nodes, idx, newNode, isEditable);
-
- if (isEditable) {
- this.count = newCount;
- this.nodes = newNodes;
- return this;
- }
-
- return new HashArrayMapNode(ownerID, newCount, newNodes);
- };
-
- var HashCollisionNode = function HashCollisionNode(ownerID, keyHash, entries) {
- this.ownerID = ownerID;
- this.keyHash = keyHash;
- this.entries = entries;
- };
-
- HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
- var entries = this.entries;
- for (var ii = 0, len = entries.length; ii < len; ii++) {
- if (is(key, entries[ii][0])) {
- return entries[ii][1];
- }
- }
- return notSetValue;
- };
-
- HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- if (keyHash === undefined) {
- keyHash = hash(key);
- }
-
- var removed = value === NOT_SET;
-
- if (keyHash !== this.keyHash) {
- if (removed) {
- return this;
- }
- SetRef(didAlter);
- SetRef(didChangeSize);
- return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
- }
-
- var entries = this.entries;
- var idx = 0;
- var len = entries.length;
- for (; idx < len; idx++) {
- if (is(key, entries[idx][0])) {
- break;
- }
- }
- var exists = idx < len;
-
- if (exists ? entries[idx][1] === value : removed) {
- return this;
- }
-
- SetRef(didAlter);
- (removed || !exists) && SetRef(didChangeSize);
-
- if (removed && len === 2) {
- return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
- }
-
- var isEditable = ownerID && ownerID === this.ownerID;
- var newEntries = isEditable ? entries : arrCopy(entries);
-
- if (exists) {
- if (removed) {
- idx === len - 1
- ? newEntries.pop()
- : (newEntries[idx] = newEntries.pop());
- } else {
- newEntries[idx] = [key, value];
- }
- } else {
- newEntries.push([key, value]);
- }
-
- if (isEditable) {
- this.entries = newEntries;
- return this;
- }
-
- return new HashCollisionNode(ownerID, this.keyHash, newEntries);
- };
-
- var ValueNode = function ValueNode(ownerID, keyHash, entry) {
- this.ownerID = ownerID;
- this.keyHash = keyHash;
- this.entry = entry;
- };
-
- ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
- return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
- };
-
- ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
- var removed = value === NOT_SET;
- var keyMatch = is(key, this.entry[0]);
- if (keyMatch ? value === this.entry[1] : removed) {
- return this;
- }
-
- SetRef(didAlter);
-
- if (removed) {
- SetRef(didChangeSize);
- return; // undefined
- }
-
- if (keyMatch) {
- if (ownerID && ownerID === this.ownerID) {
- this.entry[1] = value;
- return this;
- }
- return new ValueNode(ownerID, this.keyHash, [key, value]);
- }
-
- SetRef(didChangeSize);
- return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
- };
-
- // #pragma Iterators
-
- ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = function(
- fn,
- reverse
- ) {
- var entries = this.entries;
- for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
- if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
- return false;
- }
- }
- };
-
- BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = function(
- fn,
- reverse
- ) {
- var nodes = this.nodes;
- for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
- var node = nodes[reverse ? maxIndex - ii : ii];
- if (node && node.iterate(fn, reverse) === false) {
- return false;
- }
- }
- };
-
- // eslint-disable-next-line no-unused-vars
- ValueNode.prototype.iterate = function(fn, reverse) {
- return fn(this.entry);
- };
-
- var MapIterator = /*@__PURE__*/(function (Iterator$$1) {
- function MapIterator(map, type, reverse) {
- this._type = type;
- this._reverse = reverse;
- this._stack = map._root && mapIteratorFrame(map._root);
- }
-
- if ( Iterator$$1 ) MapIterator.__proto__ = Iterator$$1;
- MapIterator.prototype = Object.create( Iterator$$1 && Iterator$$1.prototype );
- MapIterator.prototype.constructor = MapIterator;
-
- MapIterator.prototype.next = function next () {
- var type = this._type;
- var stack = this._stack;
- while (stack) {
- var node = stack.node;
- var index = stack.index++;
- var maxIndex = (void 0);
- if (node.entry) {
- if (index === 0) {
- return mapIteratorValue(type, node.entry);
- }
- } else if (node.entries) {
- maxIndex = node.entries.length - 1;
- if (index <= maxIndex) {
- return mapIteratorValue(
- type,
- node.entries[this._reverse ? maxIndex - index : index]
- );
- }
- } else {
- maxIndex = node.nodes.length - 1;
- if (index <= maxIndex) {
- var subNode = node.nodes[this._reverse ? maxIndex - index : index];
- if (subNode) {
- if (subNode.entry) {
- return mapIteratorValue(type, subNode.entry);
- }
- stack = this._stack = mapIteratorFrame(subNode, stack);
- }
- continue;
- }
- }
- stack = this._stack = this._stack.__prev;
- }
- return iteratorDone();
- };
-
- return MapIterator;
- }(Iterator));
-
- function mapIteratorValue(type, entry) {
- return iteratorValue(type, entry[0], entry[1]);
- }
-
- function mapIteratorFrame(node, prev) {
- return {
- node: node,
- index: 0,
- __prev: prev,
- };
- }
-
- function makeMap(size, root, ownerID, hash$$1) {
- var map = Object.create(MapPrototype);
- map.size = size;
- map._root = root;
- map.__ownerID = ownerID;
- map.__hash = hash$$1;
- map.__altered = false;
- return map;
- }
-
- var EMPTY_MAP;
- function emptyMap() {
- return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
- }
-
- function updateMap(map, k, v) {
- var newRoot;
- var newSize;
- if (!map._root) {
- if (v === NOT_SET) {
- return map;
- }
- newSize = 1;
- newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
- } else {
- var didChangeSize = MakeRef();
- var didAlter = MakeRef();
- newRoot = updateNode(
- map._root,
- map.__ownerID,
- 0,
- undefined,
- k,
- v,
- didChangeSize,
- didAlter
- );
- if (!didAlter.value) {
- return map;
- }
- newSize = map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0);
- }
- if (map.__ownerID) {
- map.size = newSize;
- map._root = newRoot;
- map.__hash = undefined;
- map.__altered = true;
- return map;
- }
- return newRoot ? makeMap(newSize, newRoot) : emptyMap();
- }
-
- function updateNode(
- node,
- ownerID,
- shift,
- keyHash,
- key,
- value,
- didChangeSize,
- didAlter
- ) {
- if (!node) {
- if (value === NOT_SET) {
- return node;
- }
- SetRef(didAlter);
- SetRef(didChangeSize);
- return new ValueNode(ownerID, keyHash, [key, value]);
- }
- return node.update(
- ownerID,
- shift,
- keyHash,
- key,
- value,
- didChangeSize,
- didAlter
- );
- }
-
- function isLeafNode(node) {
- return (
- node.constructor === ValueNode || node.constructor === HashCollisionNode
- );
- }
-
- function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
- if (node.keyHash === keyHash) {
- return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
- }
-
- var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
- var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
-
- var newNode;
- var nodes =
- idx1 === idx2
- ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)]
- : ((newNode = new ValueNode(ownerID, keyHash, entry)),
- idx1 < idx2 ? [node, newNode] : [newNode, node]);
-
- return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
- }
-
- function createNodes(ownerID, entries, key, value) {
- if (!ownerID) {
- ownerID = new OwnerID();
- }
- var node = new ValueNode(ownerID, hash(key), [key, value]);
- for (var ii = 0; ii < entries.length; ii++) {
- var entry = entries[ii];
- node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
- }
- return node;
- }
-
- function packNodes(ownerID, nodes, count, excluding) {
- var bitmap = 0;
- var packedII = 0;
- var packedNodes = new Array(count);
- for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
- var node = nodes[ii];
- if (node !== undefined && ii !== excluding) {
- bitmap |= bit;
- packedNodes[packedII++] = node;
- }
- }
- return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
- }
-
- function expandNodes(ownerID, nodes, bitmap, including, node) {
- var count = 0;
- var expandedNodes = new Array(SIZE);
- for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
- expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
- }
- expandedNodes[including] = node;
- return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
- }
-
- function popCount(x) {
- x -= (x >> 1) & 0x55555555;
- x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
- x = (x + (x >> 4)) & 0x0f0f0f0f;
- x += x >> 8;
- x += x >> 16;
- return x & 0x7f;
- }
-
- function setAt(array, idx, val, canEdit) {
- var newArray = canEdit ? array : arrCopy(array);
- newArray[idx] = val;
- return newArray;
- }
-
- function spliceIn(array, idx, val, canEdit) {
- var newLen = array.length + 1;
- if (canEdit && idx + 1 === newLen) {
- array[idx] = val;
- return array;
- }
- var newArray = new Array(newLen);
- var after = 0;
- for (var ii = 0; ii < newLen; ii++) {
- if (ii === idx) {
- newArray[ii] = val;
- after = -1;
- } else {
- newArray[ii] = array[ii + after];
- }
- }
- return newArray;
- }
-
- function spliceOut(array, idx, canEdit) {
- var newLen = array.length - 1;
- if (canEdit && idx === newLen) {
- array.pop();
- return array;
- }
- var newArray = new Array(newLen);
- var after = 0;
- for (var ii = 0; ii < newLen; ii++) {
- if (ii === idx) {
- after = 1;
- }
- newArray[ii] = array[ii + after];
- }
- return newArray;
- }
-
- var MAX_ARRAY_MAP_SIZE = SIZE / 4;
- var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
- var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
-
- var IS_LIST_SYMBOL = '@@__IMMUTABLE_LIST__@@';
-
- function isList(maybeList) {
- return Boolean(maybeList && maybeList[IS_LIST_SYMBOL]);
- }
-
- var List = /*@__PURE__*/(function (IndexedCollection$$1) {
- function List(value) {
- var empty = emptyList();
- if (value === null || value === undefined) {
- return empty;
- }
- if (isList(value)) {
- return value;
- }
- var iter = IndexedCollection$$1(value);
- var size = iter.size;
- if (size === 0) {
- return empty;
- }
- assertNotInfinite(size);
- if (size > 0 && size < SIZE) {
- return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
- }
- return empty.withMutations(function (list) {
- list.setSize(size);
- iter.forEach(function (v, i) { return list.set(i, v); });
- });
- }
-
- if ( IndexedCollection$$1 ) List.__proto__ = IndexedCollection$$1;
- List.prototype = Object.create( IndexedCollection$$1 && IndexedCollection$$1.prototype );
- List.prototype.constructor = List;
-
- List.of = function of (/*...values*/) {
- return this(arguments);
- };
-
- List.prototype.toString = function toString () {
- return this.__toString('List [', ']');
- };
-
- // @pragma Access
-
- List.prototype.get = function get (index, notSetValue) {
- index = wrapIndex(this, index);
- if (index >= 0 && index < this.size) {
- index += this._origin;
- var node = listNodeFor(this, index);
- return node && node.array[index & MASK];
- }
- return notSetValue;
- };
-
- // @pragma Modification
-
- List.prototype.set = function set (index, value) {
- return updateList(this, index, value);
- };
-
- List.prototype.remove = function remove (index) {
- return !this.has(index)
- ? this
- : index === 0
- ? this.shift()
- : index === this.size - 1
- ? this.pop()
- : this.splice(index, 1);
- };
-
- List.prototype.insert = function insert (index, value) {
- return this.splice(index, 0, value);
- };
-
- List.prototype.clear = function clear () {
- if (this.size === 0) {
- return this;
- }
- if (this.__ownerID) {
- this.size = this._origin = this._capacity = 0;
- this._level = SHIFT;
- this._root = this._tail = null;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return emptyList();
- };
-
- List.prototype.push = function push (/*...values*/) {
- var values = arguments;
- var oldSize = this.size;
- return this.withMutations(function (list) {
- setListBounds(list, 0, oldSize + values.length);
- for (var ii = 0; ii < values.length; ii++) {
- list.set(oldSize + ii, values[ii]);
- }
- });
- };
-
- List.prototype.pop = function pop () {
- return setListBounds(this, 0, -1);
- };
-
- List.prototype.unshift = function unshift (/*...values*/) {
- var values = arguments;
- return this.withMutations(function (list) {
- setListBounds(list, -values.length);
- for (var ii = 0; ii < values.length; ii++) {
- list.set(ii, values[ii]);
- }
- });
- };
-
- List.prototype.shift = function shift () {
- return setListBounds(this, 1);
- };
-
- // @pragma Composition
-
- List.prototype.concat = function concat (/*...collections*/) {
- var arguments$1 = arguments;
-
- var seqs = [];
- for (var i = 0; i < arguments.length; i++) {
- var argument = arguments$1[i];
- var seq = IndexedCollection$$1(
- typeof argument !== 'string' && hasIterator(argument)
- ? argument
- : [argument]
- );
- if (seq.size !== 0) {
- seqs.push(seq);
- }
- }
- if (seqs.length === 0) {
- return this;
- }
- if (this.size === 0 && !this.__ownerID && seqs.length === 1) {
- return this.constructor(seqs[0]);
- }
- return this.withMutations(function (list) {
- seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); });
- });
- };
-
- List.prototype.setSize = function setSize (size) {
- return setListBounds(this, 0, size);
- };
-
- List.prototype.map = function map (mapper, context) {
- var this$1 = this;
-
- return this.withMutations(function (list) {
- for (var i = 0; i < this$1.size; i++) {
- list.set(i, mapper.call(context, list.get(i), i, list));
- }
- });
- };
-
- // @pragma Iteration
-
- List.prototype.slice = function slice (begin, end) {
- var size = this.size;
- if (wholeSlice(begin, end, size)) {
- return this;
- }
- return setListBounds(
- this,
- resolveBegin(begin, size),
- resolveEnd(end, size)
- );
- };
-
- List.prototype.__iterator = function __iterator (type, reverse) {
- var index = reverse ? this.size : 0;
- var values = iterateList(this, reverse);
- return new Iterator(function () {
- var value = values();
- return value === DONE
- ? iteratorDone()
- : iteratorValue(type, reverse ? --index : index++, value);
- });
- };
-
- List.prototype.__iterate = function __iterate (fn, reverse) {
- var index = reverse ? this.size : 0;
- var values = iterateList(this, reverse);
- var value;
- while ((value = values()) !== DONE) {
- if (fn(value, reverse ? --index : index++, this) === false) {
- break;
- }
- }
- return index;
- };
-
- List.prototype.__ensureOwner = function __ensureOwner (ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- if (!ownerID) {
- if (this.size === 0) {
- return emptyList();
- }
- this.__ownerID = ownerID;
- this.__altered = false;
- return this;
- }
- return makeList(
- this._origin,
- this._capacity,
- this._level,
- this._root,
- this._tail,
- ownerID,
- this.__hash
- );
- };
-
- return List;
- }(IndexedCollection));
-
- List.isList = isList;
-
- var ListPrototype = List.prototype;
- ListPrototype[IS_LIST_SYMBOL] = true;
- ListPrototype[DELETE] = ListPrototype.remove;
- ListPrototype.merge = ListPrototype.concat;
- ListPrototype.setIn = setIn$1;
- ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn;
- ListPrototype.update = update$1;
- ListPrototype.updateIn = updateIn$1;
- ListPrototype.mergeIn = mergeIn;
- ListPrototype.mergeDeepIn = mergeDeepIn;
- ListPrototype.withMutations = withMutations;
- ListPrototype.wasAltered = wasAltered;
- ListPrototype.asImmutable = asImmutable;
- ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable;
- ListPrototype['@@transducer/step'] = function(result, arr) {
- return result.push(arr);
- };
- ListPrototype['@@transducer/result'] = function(obj) {
- return obj.asImmutable();
- };
-
- var VNode = function VNode(array, ownerID) {
- this.array = array;
- this.ownerID = ownerID;
- };
-
- // TODO: seems like these methods are very similar
-
- VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) {
- if (index === level ? 1 << level : this.array.length === 0) {
- return this;
- }
- var originIndex = (index >>> level) & MASK;
- if (originIndex >= this.array.length) {
- return new VNode([], ownerID);
- }
- var removingFirst = originIndex === 0;
- var newChild;
- if (level > 0) {
- var oldChild = this.array[originIndex];
- newChild =
- oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
- if (newChild === oldChild && removingFirst) {
- return this;
- }
- }
- if (removingFirst && !newChild) {
- return this;
- }
- var editable = editableVNode(this, ownerID);
- if (!removingFirst) {
- for (var ii = 0; ii < originIndex; ii++) {
- editable.array[ii] = undefined;
- }
- }
- if (newChild) {
- editable.array[originIndex] = newChild;
- }
- return editable;
- };
-
- VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) {
- if (index === (level ? 1 << level : 0) || this.array.length === 0) {
- return this;
- }
- var sizeIndex = ((index - 1) >>> level) & MASK;
- if (sizeIndex >= this.array.length) {
- return this;
- }
-
- var newChild;
- if (level > 0) {
- var oldChild = this.array[sizeIndex];
- newChild =
- oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
- if (newChild === oldChild && sizeIndex === this.array.length - 1) {
- return this;
- }
- }
-
- var editable = editableVNode(this, ownerID);
- editable.array.splice(sizeIndex + 1);
- if (newChild) {
- editable.array[sizeIndex] = newChild;
- }
- return editable;
- };
-
- var DONE = {};
-
- function iterateList(list, reverse) {
- var left = list._origin;
- var right = list._capacity;
- var tailPos = getTailOffset(right);
- var tail = list._tail;
-
- return iterateNodeOrLeaf(list._root, list._level, 0);
-
- function iterateNodeOrLeaf(node, level, offset) {
- return level === 0
- ? iterateLeaf(node, offset)
- : iterateNode(node, level, offset);
- }
-
- function iterateLeaf(node, offset) {
- var array = offset === tailPos ? tail && tail.array : node && node.array;
- var from = offset > left ? 0 : left - offset;
- var to = right - offset;
- if (to > SIZE) {
- to = SIZE;
- }
- return function () {
- if (from === to) {
- return DONE;
- }
- var idx = reverse ? --to : from++;
- return array && array[idx];
- };
- }
-
- function iterateNode(node, level, offset) {
- var values;
- var array = node && node.array;
- var from = offset > left ? 0 : (left - offset) >> level;
- var to = ((right - offset) >> level) + 1;
- if (to > SIZE) {
- to = SIZE;
- }
- return function () {
- while (true) {
- if (values) {
- var value = values();
- if (value !== DONE) {
- return value;
- }
- values = null;
- }
- if (from === to) {
- return DONE;
- }
- var idx = reverse ? --to : from++;
- values = iterateNodeOrLeaf(
- array && array[idx],
- level - SHIFT,
- offset + (idx << level)
- );
- }
- };
- }
- }
-
- function makeList(origin, capacity, level, root, tail, ownerID, hash) {
- var list = Object.create(ListPrototype);
- list.size = capacity - origin;
- list._origin = origin;
- list._capacity = capacity;
- list._level = level;
- list._root = root;
- list._tail = tail;
- list.__ownerID = ownerID;
- list.__hash = hash;
- list.__altered = false;
- return list;
- }
-
- var EMPTY_LIST;
- function emptyList() {
- return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
- }
-
- function updateList(list, index, value) {
- index = wrapIndex(list, index);
-
- if (index !== index) {
- return list;
- }
-
- if (index >= list.size || index < 0) {
- return list.withMutations(function (list) {
- index < 0
- ? setListBounds(list, index).set(0, value)
- : setListBounds(list, 0, index + 1).set(index, value);
- });
- }
-
- index += list._origin;
-
- var newTail = list._tail;
- var newRoot = list._root;
- var didAlter = MakeRef();
- if (index >= getTailOffset(list._capacity)) {
- newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
- } else {
- newRoot = updateVNode(
- newRoot,
- list.__ownerID,
- list._level,
- index,
- value,
- didAlter
- );
- }
-
- if (!didAlter.value) {
- return list;
- }
-
- if (list.__ownerID) {
- list._root = newRoot;
- list._tail = newTail;
- list.__hash = undefined;
- list.__altered = true;
- return list;
- }
- return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
- }
-
- function updateVNode(node, ownerID, level, index, value, didAlter) {
- var idx = (index >>> level) & MASK;
- var nodeHas = node && idx < node.array.length;
- if (!nodeHas && value === undefined) {
- return node;
- }
-
- var newNode;
-
- if (level > 0) {
- var lowerNode = node && node.array[idx];
- var newLowerNode = updateVNode(
- lowerNode,
- ownerID,
- level - SHIFT,
- index,
- value,
- didAlter
- );
- if (newLowerNode === lowerNode) {
- return node;
- }
- newNode = editableVNode(node, ownerID);
- newNode.array[idx] = newLowerNode;
- return newNode;
- }
-
- if (nodeHas && node.array[idx] === value) {
- return node;
- }
-
- if (didAlter) {
- SetRef(didAlter);
- }
-
- newNode = editableVNode(node, ownerID);
- if (value === undefined && idx === newNode.array.length - 1) {
- newNode.array.pop();
- } else {
- newNode.array[idx] = value;
- }
- return newNode;
- }
-
- function editableVNode(node, ownerID) {
- if (ownerID && node && ownerID === node.ownerID) {
- return node;
- }
- return new VNode(node ? node.array.slice() : [], ownerID);
- }
-
- function listNodeFor(list, rawIndex) {
- if (rawIndex >= getTailOffset(list._capacity)) {
- return list._tail;
- }
- if (rawIndex < 1 << (list._level + SHIFT)) {
- var node = list._root;
- var level = list._level;
- while (node && level > 0) {
- node = node.array[(rawIndex >>> level) & MASK];
- level -= SHIFT;
- }
- return node;
- }
- }
-
- function setListBounds(list, begin, end) {
- // Sanitize begin & end using this shorthand for ToInt32(argument)
- // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
- if (begin !== undefined) {
- begin |= 0;
- }
- if (end !== undefined) {
- end |= 0;
- }
- var owner = list.__ownerID || new OwnerID();
- var oldOrigin = list._origin;
- var oldCapacity = list._capacity;
- var newOrigin = oldOrigin + begin;
- var newCapacity =
- end === undefined
- ? oldCapacity
- : end < 0
- ? oldCapacity + end
- : oldOrigin + end;
- if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
- return list;
- }
-
- // If it's going to end after it starts, it's empty.
- if (newOrigin >= newCapacity) {
- return list.clear();
- }
-
- var newLevel = list._level;
- var newRoot = list._root;
-
- // New origin might need creating a higher root.
- var offsetShift = 0;
- while (newOrigin + offsetShift < 0) {
- newRoot = new VNode(
- newRoot && newRoot.array.length ? [undefined, newRoot] : [],
- owner
- );
- newLevel += SHIFT;
- offsetShift += 1 << newLevel;
- }
- if (offsetShift) {
- newOrigin += offsetShift;
- oldOrigin += offsetShift;
- newCapacity += offsetShift;
- oldCapacity += offsetShift;
- }
-
- var oldTailOffset = getTailOffset(oldCapacity);
- var newTailOffset = getTailOffset(newCapacity);
-
- // New size might need creating a higher root.
- while (newTailOffset >= 1 << (newLevel + SHIFT)) {
- newRoot = new VNode(
- newRoot && newRoot.array.length ? [newRoot] : [],
- owner
- );
- newLevel += SHIFT;
- }
-
- // Locate or create the new tail.
- var oldTail = list._tail;
- var newTail =
- newTailOffset < oldTailOffset
- ? listNodeFor(list, newCapacity - 1)
- : newTailOffset > oldTailOffset
- ? new VNode([], owner)
- : oldTail;
-
- // Merge Tail into tree.
- if (
- oldTail &&
- newTailOffset > oldTailOffset &&
- newOrigin < oldCapacity &&
- oldTail.array.length
- ) {
- newRoot = editableVNode(newRoot, owner);
- var node = newRoot;
- for (var level = newLevel; level > SHIFT; level -= SHIFT) {
- var idx = (oldTailOffset >>> level) & MASK;
- node = node.array[idx] = editableVNode(node.array[idx], owner);
- }
- node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
- }
-
- // If the size has been reduced, there's a chance the tail needs to be trimmed.
- if (newCapacity < oldCapacity) {
- newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
- }
-
- // If the new origin is within the tail, then we do not need a root.
- if (newOrigin >= newTailOffset) {
- newOrigin -= newTailOffset;
- newCapacity -= newTailOffset;
- newLevel = SHIFT;
- newRoot = null;
- newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
-
- // Otherwise, if the root has been trimmed, garbage collect.
- } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
- offsetShift = 0;
-
- // Identify the new top root node of the subtree of the old root.
- while (newRoot) {
- var beginIndex = (newOrigin >>> newLevel) & MASK;
- if ((beginIndex !== newTailOffset >>> newLevel) & MASK) {
- break;
- }
- if (beginIndex) {
- offsetShift += (1 << newLevel) * beginIndex;
- }
- newLevel -= SHIFT;
- newRoot = newRoot.array[beginIndex];
- }
-
- // Trim the new sides of the new root.
- if (newRoot && newOrigin > oldOrigin) {
- newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
- }
- if (newRoot && newTailOffset < oldTailOffset) {
- newRoot = newRoot.removeAfter(
- owner,
- newLevel,
- newTailOffset - offsetShift
- );
- }
- if (offsetShift) {
- newOrigin -= offsetShift;
- newCapacity -= offsetShift;
- }
- }
-
- if (list.__ownerID) {
- list.size = newCapacity - newOrigin;
- list._origin = newOrigin;
- list._capacity = newCapacity;
- list._level = newLevel;
- list._root = newRoot;
- list._tail = newTail;
- list.__hash = undefined;
- list.__altered = true;
- return list;
- }
- return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
- }
-
- function getTailOffset(size) {
- return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT;
- }
-
- var OrderedMap = /*@__PURE__*/(function (Map$$1) {
- function OrderedMap(value) {
- return value === null || value === undefined
- ? emptyOrderedMap()
- : isOrderedMap(value)
- ? value
- : emptyOrderedMap().withMutations(function (map) {
- var iter = KeyedCollection(value);
- assertNotInfinite(iter.size);
- iter.forEach(function (v, k) { return map.set(k, v); });
- });
- }
-
- if ( Map$$1 ) OrderedMap.__proto__ = Map$$1;
- OrderedMap.prototype = Object.create( Map$$1 && Map$$1.prototype );
- OrderedMap.prototype.constructor = OrderedMap;
-
- OrderedMap.of = function of (/*...values*/) {
- return this(arguments);
- };
-
- OrderedMap.prototype.toString = function toString () {
- return this.__toString('OrderedMap {', '}');
- };
-
- // @pragma Access
-
- OrderedMap.prototype.get = function get (k, notSetValue) {
- var index = this._map.get(k);
- return index !== undefined ? this._list.get(index)[1] : notSetValue;
- };
-
- // @pragma Modification
-
- OrderedMap.prototype.clear = function clear () {
- if (this.size === 0) {
- return this;
- }
- if (this.__ownerID) {
- this.size = 0;
- this._map.clear();
- this._list.clear();
- return this;
- }
- return emptyOrderedMap();
- };
-
- OrderedMap.prototype.set = function set (k, v) {
- return updateOrderedMap(this, k, v);
- };
-
- OrderedMap.prototype.remove = function remove (k) {
- return updateOrderedMap(this, k, NOT_SET);
- };
-
- OrderedMap.prototype.wasAltered = function wasAltered () {
- return this._map.wasAltered() || this._list.wasAltered();
- };
-
- OrderedMap.prototype.__iterate = function __iterate (fn, reverse) {
- var this$1 = this;
-
- return this._list.__iterate(
- function (entry) { return entry && fn(entry[1], entry[0], this$1); },
- reverse
- );
- };
-
- OrderedMap.prototype.__iterator = function __iterator (type, reverse) {
- return this._list.fromEntrySeq().__iterator(type, reverse);
- };
-
- OrderedMap.prototype.__ensureOwner = function __ensureOwner (ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- var newMap = this._map.__ensureOwner(ownerID);
- var newList = this._list.__ensureOwner(ownerID);
- if (!ownerID) {
- if (this.size === 0) {
- return emptyOrderedMap();
- }
- this.__ownerID = ownerID;
- this._map = newMap;
- this._list = newList;
- return this;
- }
- return makeOrderedMap(newMap, newList, ownerID, this.__hash);
- };
-
- return OrderedMap;
- }(Map));
-
- OrderedMap.isOrderedMap = isOrderedMap;
-
- OrderedMap.prototype[IS_ORDERED_SYMBOL] = true;
- OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
-
- function makeOrderedMap(map, list, ownerID, hash) {
- var omap = Object.create(OrderedMap.prototype);
- omap.size = map ? map.size : 0;
- omap._map = map;
- omap._list = list;
- omap.__ownerID = ownerID;
- omap.__hash = hash;
- return omap;
- }
-
- var EMPTY_ORDERED_MAP;
- function emptyOrderedMap() {
- return (
- EMPTY_ORDERED_MAP ||
- (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()))
- );
- }
-
- function updateOrderedMap(omap, k, v) {
- var map = omap._map;
- var list = omap._list;
- var i = map.get(k);
- var has = i !== undefined;
- var newMap;
- var newList;
- if (v === NOT_SET) {
- // removed
- if (!has) {
- return omap;
- }
- if (list.size >= SIZE && list.size >= map.size * 2) {
- newList = list.filter(function (entry, idx) { return entry !== undefined && i !== idx; });
- newMap = newList
- .toKeyedSeq()
- .map(function (entry) { return entry[0]; })
- .flip()
- .toMap();
- if (omap.__ownerID) {
- newMap.__ownerID = newList.__ownerID = omap.__ownerID;
- }
- } else {
- newMap = map.remove(k);
- newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
- }
- } else if (has) {
- if (v === list.get(i)[1]) {
- return omap;
- }
- newMap = map;
- newList = list.set(i, [k, v]);
- } else {
- newMap = map.set(k, list.size);
- newList = list.set(list.size, [k, v]);
- }
- if (omap.__ownerID) {
- omap.size = newMap.size;
- omap._map = newMap;
- omap._list = newList;
- omap.__hash = undefined;
- return omap;
- }
- return makeOrderedMap(newMap, newList);
- }
-
- var IS_STACK_SYMBOL = '@@__IMMUTABLE_STACK__@@';
-
- function isStack(maybeStack) {
- return Boolean(maybeStack && maybeStack[IS_STACK_SYMBOL]);
- }
-
- var Stack = /*@__PURE__*/(function (IndexedCollection$$1) {
- function Stack(value) {
- return value === null || value === undefined
- ? emptyStack()
- : isStack(value)
- ? value
- : emptyStack().pushAll(value);
- }
-
- if ( IndexedCollection$$1 ) Stack.__proto__ = IndexedCollection$$1;
- Stack.prototype = Object.create( IndexedCollection$$1 && IndexedCollection$$1.prototype );
- Stack.prototype.constructor = Stack;
-
- Stack.of = function of (/*...values*/) {
- return this(arguments);
- };
-
- Stack.prototype.toString = function toString () {
- return this.__toString('Stack [', ']');
- };
-
- // @pragma Access
-
- Stack.prototype.get = function get (index, notSetValue) {
- var head = this._head;
- index = wrapIndex(this, index);
- while (head && index--) {
- head = head.next;
- }
- return head ? head.value : notSetValue;
- };
-
- Stack.prototype.peek = function peek () {
- return this._head && this._head.value;
- };
-
- // @pragma Modification
-
- Stack.prototype.push = function push (/*...values*/) {
- var arguments$1 = arguments;
-
- if (arguments.length === 0) {
- return this;
- }
- var newSize = this.size + arguments.length;
- var head = this._head;
- for (var ii = arguments.length - 1; ii >= 0; ii--) {
- head = {
- value: arguments$1[ii],
- next: head,
- };
- }
- if (this.__ownerID) {
- this.size = newSize;
- this._head = head;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return makeStack(newSize, head);
- };
-
- Stack.prototype.pushAll = function pushAll (iter) {
- iter = IndexedCollection$$1(iter);
- if (iter.size === 0) {
- return this;
- }
- if (this.size === 0 && isStack(iter)) {
- return iter;
- }
- assertNotInfinite(iter.size);
- var newSize = this.size;
- var head = this._head;
- iter.__iterate(function (value) {
- newSize++;
- head = {
- value: value,
- next: head,
- };
- }, /* reverse */ true);
- if (this.__ownerID) {
- this.size = newSize;
- this._head = head;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return makeStack(newSize, head);
- };
-
- Stack.prototype.pop = function pop () {
- return this.slice(1);
- };
-
- Stack.prototype.clear = function clear () {
- if (this.size === 0) {
- return this;
- }
- if (this.__ownerID) {
- this.size = 0;
- this._head = undefined;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return emptyStack();
- };
-
- Stack.prototype.slice = function slice (begin, end) {
- if (wholeSlice(begin, end, this.size)) {
- return this;
- }
- var resolvedBegin = resolveBegin(begin, this.size);
- var resolvedEnd = resolveEnd(end, this.size);
- if (resolvedEnd !== this.size) {
- // super.slice(begin, end);
- return IndexedCollection$$1.prototype.slice.call(this, begin, end);
- }
- var newSize = this.size - resolvedBegin;
- var head = this._head;
- while (resolvedBegin--) {
- head = head.next;
- }
- if (this.__ownerID) {
- this.size = newSize;
- this._head = head;
- this.__hash = undefined;
- this.__altered = true;
- return this;
- }
- return makeStack(newSize, head);
- };
-
- // @pragma Mutability
-
- Stack.prototype.__ensureOwner = function __ensureOwner (ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- if (!ownerID) {
- if (this.size === 0) {
- return emptyStack();
- }
- this.__ownerID = ownerID;
- this.__altered = false;
- return this;
- }
- return makeStack(this.size, this._head, ownerID, this.__hash);
- };
-
- // @pragma Iteration
-
- Stack.prototype.__iterate = function __iterate (fn, reverse) {
- var this$1 = this;
-
- if (reverse) {
- return new ArraySeq(this.toArray()).__iterate(
- function (v, k) { return fn(v, k, this$1); },
- reverse
- );
- }
- var iterations = 0;
- var node = this._head;
- while (node) {
- if (fn(node.value, iterations++, this) === false) {
- break;
- }
- node = node.next;
- }
- return iterations;
- };
-
- Stack.prototype.__iterator = function __iterator (type, reverse) {
- if (reverse) {
- return new ArraySeq(this.toArray()).__iterator(type, reverse);
- }
- var iterations = 0;
- var node = this._head;
- return new Iterator(function () {
- if (node) {
- var value = node.value;
- node = node.next;
- return iteratorValue(type, iterations++, value);
- }
- return iteratorDone();
- });
- };
-
- return Stack;
- }(IndexedCollection));
-
- Stack.isStack = isStack;
-
- var StackPrototype = Stack.prototype;
- StackPrototype[IS_STACK_SYMBOL] = true;
- StackPrototype.shift = StackPrototype.pop;
- StackPrototype.unshift = StackPrototype.push;
- StackPrototype.unshiftAll = StackPrototype.pushAll;
- StackPrototype.withMutations = withMutations;
- StackPrototype.wasAltered = wasAltered;
- StackPrototype.asImmutable = asImmutable;
- StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable;
- StackPrototype['@@transducer/step'] = function(result, arr) {
- return result.unshift(arr);
- };
- StackPrototype['@@transducer/result'] = function(obj) {
- return obj.asImmutable();
- };
-
- function makeStack(size, head, ownerID, hash) {
- var map = Object.create(StackPrototype);
- map.size = size;
- map._head = head;
- map.__ownerID = ownerID;
- map.__hash = hash;
- map.__altered = false;
- return map;
- }
-
- var EMPTY_STACK;
- function emptyStack() {
- return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
- }
-
- var IS_SET_SYMBOL = '@@__IMMUTABLE_SET__@@';
-
- function isSet(maybeSet) {
- return Boolean(maybeSet && maybeSet[IS_SET_SYMBOL]);
- }
-
- function isOrderedSet(maybeOrderedSet) {
- return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
- }
-
- function deepEqual(a, b) {
- if (a === b) {
- return true;
- }
-
- if (
- !isCollection(b) ||
- (a.size !== undefined && b.size !== undefined && a.size !== b.size) ||
- (a.__hash !== undefined &&
- b.__hash !== undefined &&
- a.__hash !== b.__hash) ||
- isKeyed(a) !== isKeyed(b) ||
- isIndexed(a) !== isIndexed(b) ||
- isOrdered(a) !== isOrdered(b)
- ) {
- return false;
- }
-
- if (a.size === 0 && b.size === 0) {
- return true;
- }
-
- var notAssociative = !isAssociative(a);
-
- if (isOrdered(a)) {
- var entries = a.entries();
- return (
- b.every(function (v, k) {
- var entry = entries.next().value;
- return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
- }) && entries.next().done
- );
- }
-
- var flipped = false;
-
- if (a.size === undefined) {
- if (b.size === undefined) {
- if (typeof a.cacheResult === 'function') {
- a.cacheResult();
- }
- } else {
- flipped = true;
- var _ = a;
- a = b;
- b = _;
- }
- }
-
- var allEqual = true;
- var bSize = b.__iterate(function (v, k) {
- if (
- notAssociative
- ? !a.has(v)
- : flipped
- ? !is(v, a.get(k, NOT_SET))
- : !is(a.get(k, NOT_SET), v)
- ) {
- allEqual = false;
- return false;
- }
- });
-
- return allEqual && a.size === bSize;
- }
-
- /**
- * Contributes additional methods to a constructor
- */
- function mixin(ctor, methods) {
- var keyCopier = function (key) {
- ctor.prototype[key] = methods[key];
- };
- Object.keys(methods).forEach(keyCopier);
- Object.getOwnPropertySymbols &&
- Object.getOwnPropertySymbols(methods).forEach(keyCopier);
- return ctor;
- }
-
- function toJS(value) {
- if (!value || typeof value !== 'object') {
- return value;
- }
- if (!isCollection(value)) {
- if (!isDataStructure(value)) {
- return value;
- }
- value = Seq(value);
- }
- if (isKeyed(value)) {
- var result$1 = {};
- value.__iterate(function (v, k) {
- result$1[k] = toJS(v);
- });
- return result$1;
- }
- var result = [];
- value.__iterate(function (v) {
- result.push(toJS(v));
- });
- return result;
- }
-
- var Set = /*@__PURE__*/(function (SetCollection$$1) {
- function Set(value) {
- return value === null || value === undefined
- ? emptySet()
- : isSet(value) && !isOrdered(value)
- ? value
- : emptySet().withMutations(function (set) {
- var iter = SetCollection$$1(value);
- assertNotInfinite(iter.size);
- iter.forEach(function (v) { return set.add(v); });
- });
- }
-
- if ( SetCollection$$1 ) Set.__proto__ = SetCollection$$1;
- Set.prototype = Object.create( SetCollection$$1 && SetCollection$$1.prototype );
- Set.prototype.constructor = Set;
-
- Set.of = function of (/*...values*/) {
- return this(arguments);
- };
-
- Set.fromKeys = function fromKeys (value) {
- return this(KeyedCollection(value).keySeq());
- };
-
- Set.intersect = function intersect (sets) {
- sets = Collection(sets).toArray();
- return sets.length
- ? SetPrototype.intersect.apply(Set(sets.pop()), sets)
- : emptySet();
- };
-
- Set.union = function union (sets) {
- sets = Collection(sets).toArray();
- return sets.length
- ? SetPrototype.union.apply(Set(sets.pop()), sets)
- : emptySet();
- };
-
- Set.prototype.toString = function toString () {
- return this.__toString('Set {', '}');
- };
-
- // @pragma Access
-
- Set.prototype.has = function has (value) {
- return this._map.has(value);
- };
-
- // @pragma Modification
-
- Set.prototype.add = function add (value) {
- return updateSet(this, this._map.set(value, value));
- };
-
- Set.prototype.remove = function remove (value) {
- return updateSet(this, this._map.remove(value));
- };
-
- Set.prototype.clear = function clear () {
- return updateSet(this, this._map.clear());
- };
-
- // @pragma Composition
-
- Set.prototype.map = function map (mapper, context) {
- var this$1 = this;
-
- var removes = [];
- var adds = [];
- this.forEach(function (value) {
- var mapped = mapper.call(context, value, value, this$1);
- if (mapped !== value) {
- removes.push(value);
- adds.push(mapped);
- }
- });
- return this.withMutations(function (set) {
- removes.forEach(function (value) { return set.remove(value); });
- adds.forEach(function (value) { return set.add(value); });
- });
- };
-
- Set.prototype.union = function union () {
- var iters = [], len = arguments.length;
- while ( len-- ) iters[ len ] = arguments[ len ];
-
- iters = iters.filter(function (x) { return x.size !== 0; });
- if (iters.length === 0) {
- return this;
- }
- if (this.size === 0 && !this.__ownerID && iters.length === 1) {
- return this.constructor(iters[0]);
- }
- return this.withMutations(function (set) {
- for (var ii = 0; ii < iters.length; ii++) {
- SetCollection$$1(iters[ii]).forEach(function (value) { return set.add(value); });
- }
- });
- };
-
- Set.prototype.intersect = function intersect () {
- var iters = [], len = arguments.length;
- while ( len-- ) iters[ len ] = arguments[ len ];
-
- if (iters.length === 0) {
- return this;
- }
- iters = iters.map(function (iter) { return SetCollection$$1(iter); });
- var toRemove = [];
- this.forEach(function (value) {
- if (!iters.every(function (iter) { return iter.includes(value); })) {
- toRemove.push(value);
- }
- });
- return this.withMutations(function (set) {
- toRemove.forEach(function (value) {
- set.remove(value);
- });
- });
- };
-
- Set.prototype.subtract = function subtract () {
- var iters = [], len = arguments.length;
- while ( len-- ) iters[ len ] = arguments[ len ];
-
- if (iters.length === 0) {
- return this;
- }
- iters = iters.map(function (iter) { return SetCollection$$1(iter); });
- var toRemove = [];
- this.forEach(function (value) {
- if (iters.some(function (iter) { return iter.includes(value); })) {
- toRemove.push(value);
- }
- });
- return this.withMutations(function (set) {
- toRemove.forEach(function (value) {
- set.remove(value);
- });
- });
- };
-
- Set.prototype.sort = function sort (comparator) {
- // Late binding
- return OrderedSet(sortFactory(this, comparator));
- };
-
- Set.prototype.sortBy = function sortBy (mapper, comparator) {
- // Late binding
- return OrderedSet(sortFactory(this, comparator, mapper));
- };
-
- Set.prototype.wasAltered = function wasAltered () {
- return this._map.wasAltered();
- };
-
- Set.prototype.__iterate = function __iterate (fn, reverse) {
- var this$1 = this;
-
- return this._map.__iterate(function (k) { return fn(k, k, this$1); }, reverse);
- };
-
- Set.prototype.__iterator = function __iterator (type, reverse) {
- return this._map.__iterator(type, reverse);
- };
-
- Set.prototype.__ensureOwner = function __ensureOwner (ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- var newMap = this._map.__ensureOwner(ownerID);
- if (!ownerID) {
- if (this.size === 0) {
- return this.__empty();
- }
- this.__ownerID = ownerID;
- this._map = newMap;
- return this;
- }
- return this.__make(newMap, ownerID);
- };
-
- return Set;
- }(SetCollection));
-
- Set.isSet = isSet;
-
- var SetPrototype = Set.prototype;
- SetPrototype[IS_SET_SYMBOL] = true;
- SetPrototype[DELETE] = SetPrototype.remove;
- SetPrototype.merge = SetPrototype.concat = SetPrototype.union;
- SetPrototype.withMutations = withMutations;
- SetPrototype.asImmutable = asImmutable;
- SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable;
- SetPrototype['@@transducer/step'] = function(result, arr) {
- return result.add(arr);
- };
- SetPrototype['@@transducer/result'] = function(obj) {
- return obj.asImmutable();
- };
-
- SetPrototype.__empty = emptySet;
- SetPrototype.__make = makeSet;
-
- function updateSet(set, newMap) {
- if (set.__ownerID) {
- set.size = newMap.size;
- set._map = newMap;
- return set;
- }
- return newMap === set._map
- ? set
- : newMap.size === 0
- ? set.__empty()
- : set.__make(newMap);
- }
-
- function makeSet(map, ownerID) {
- var set = Object.create(SetPrototype);
- set.size = map ? map.size : 0;
- set._map = map;
- set.__ownerID = ownerID;
- return set;
- }
-
- var EMPTY_SET;
- function emptySet() {
- return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
- }
-
- /**
- * Returns a lazy seq of nums from start (inclusive) to end
- * (exclusive), by step, where start defaults to 0, step to 1, and end to
- * infinity. When start is equal to end, returns empty list.
- */
- var Range = /*@__PURE__*/(function (IndexedSeq$$1) {
- function Range(start, end, step) {
- if (!(this instanceof Range)) {
- return new Range(start, end, step);
- }
- invariant(step !== 0, 'Cannot step a Range by 0');
- start = start || 0;
- if (end === undefined) {
- end = Infinity;
- }
- step = step === undefined ? 1 : Math.abs(step);
- if (end < start) {
- step = -step;
- }
- this._start = start;
- this._end = end;
- this._step = step;
- this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
- if (this.size === 0) {
- if (EMPTY_RANGE) {
- return EMPTY_RANGE;
- }
- EMPTY_RANGE = this;
- }
- }
-
- if ( IndexedSeq$$1 ) Range.__proto__ = IndexedSeq$$1;
- Range.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype );
- Range.prototype.constructor = Range;
-
- Range.prototype.toString = function toString () {
- if (this.size === 0) {
- return 'Range []';
- }
- return (
- 'Range [ ' +
- this._start +
- '...' +
- this._end +
- (this._step !== 1 ? ' by ' + this._step : '') +
- ' ]'
- );
- };
-
- Range.prototype.get = function get (index, notSetValue) {
- return this.has(index)
- ? this._start + wrapIndex(this, index) * this._step
- : notSetValue;
- };
-
- Range.prototype.includes = function includes (searchValue) {
- var possibleIndex = (searchValue - this._start) / this._step;
- return (
- possibleIndex >= 0 &&
- possibleIndex < this.size &&
- possibleIndex === Math.floor(possibleIndex)
- );
- };
-
- Range.prototype.slice = function slice (begin, end) {
- if (wholeSlice(begin, end, this.size)) {
- return this;
- }
- begin = resolveBegin(begin, this.size);
- end = resolveEnd(end, this.size);
- if (end <= begin) {
- return new Range(0, 0);
- }
- return new Range(
- this.get(begin, this._end),
- this.get(end, this._end),
- this._step
- );
- };
-
- Range.prototype.indexOf = function indexOf (searchValue) {
- var offsetValue = searchValue - this._start;
- if (offsetValue % this._step === 0) {
- var index = offsetValue / this._step;
- if (index >= 0 && index < this.size) {
- return index;
- }
- }
- return -1;
- };
-
- Range.prototype.lastIndexOf = function lastIndexOf (searchValue) {
- return this.indexOf(searchValue);
- };
-
- Range.prototype.__iterate = function __iterate (fn, reverse) {
- var size = this.size;
- var step = this._step;
- var value = reverse ? this._start + (size - 1) * step : this._start;
- var i = 0;
- while (i !== size) {
- if (fn(value, reverse ? size - ++i : i++, this) === false) {
- break;
- }
- value += reverse ? -step : step;
- }
- return i;
- };
-
- Range.prototype.__iterator = function __iterator (type, reverse) {
- var size = this.size;
- var step = this._step;
- var value = reverse ? this._start + (size - 1) * step : this._start;
- var i = 0;
- return new Iterator(function () {
- if (i === size) {
- return iteratorDone();
- }
- var v = value;
- value += reverse ? -step : step;
- return iteratorValue(type, reverse ? size - ++i : i++, v);
- });
- };
-
- Range.prototype.equals = function equals (other) {
- return other instanceof Range
- ? this._start === other._start &&
- this._end === other._end &&
- this._step === other._step
- : deepEqual(this, other);
- };
-
- return Range;
- }(IndexedSeq));
-
- var EMPTY_RANGE;
-
- function getIn(collection, searchKeyPath, notSetValue) {
- var keyPath = coerceKeyPath(searchKeyPath);
- var i = 0;
- while (i !== keyPath.length) {
- collection = get(collection, keyPath[i++], NOT_SET);
- if (collection === NOT_SET) {
- return notSetValue;
- }
- }
- return collection;
- }
-
- function getIn$1(searchKeyPath, notSetValue) {
- return getIn(this, searchKeyPath, notSetValue);
- }
-
- function hasIn(collection, keyPath) {
- return getIn(collection, keyPath, NOT_SET) !== NOT_SET;
- }
-
- function hasIn$1(searchKeyPath) {
- return hasIn(this, searchKeyPath);
- }
-
- function toObject() {
- assertNotInfinite(this.size);
- var object = {};
- this.__iterate(function (v, k) {
- object[k] = v;
- });
- return object;
- }
-
- // Note: all of these methods are deprecated.
- Collection.isIterable = isCollection;
- Collection.isKeyed = isKeyed;
- Collection.isIndexed = isIndexed;
- Collection.isAssociative = isAssociative;
- Collection.isOrdered = isOrdered;
-
- Collection.Iterator = Iterator;
-
- mixin(Collection, {
- // ### Conversion to other types
-
- toArray: function toArray() {
- assertNotInfinite(this.size);
- var array = new Array(this.size || 0);
- var useTuples = isKeyed(this);
- var i = 0;
- this.__iterate(function (v, k) {
- // Keyed collections produce an array of tuples.
- array[i++] = useTuples ? [k, v] : v;
- });
- return array;
- },
-
- toIndexedSeq: function toIndexedSeq() {
- return new ToIndexedSequence(this);
- },
-
- toJS: function toJS$1() {
- return toJS(this);
- },
-
- toKeyedSeq: function toKeyedSeq() {
- return new ToKeyedSequence(this, true);
- },
-
- toMap: function toMap() {
- // Use Late Binding here to solve the circular dependency.
- return Map(this.toKeyedSeq());
- },
-
- toObject: toObject,
-
- toOrderedMap: function toOrderedMap() {
- // Use Late Binding here to solve the circular dependency.
- return OrderedMap(this.toKeyedSeq());
- },
-
- toOrderedSet: function toOrderedSet() {
- // Use Late Binding here to solve the circular dependency.
- return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
- },
-
- toSet: function toSet() {
- // Use Late Binding here to solve the circular dependency.
- return Set(isKeyed(this) ? this.valueSeq() : this);
- },
-
- toSetSeq: function toSetSeq() {
- return new ToSetSequence(this);
- },
-
- toSeq: function toSeq() {
- return isIndexed(this)
- ? this.toIndexedSeq()
- : isKeyed(this)
- ? this.toKeyedSeq()
- : this.toSetSeq();
- },
-
- toStack: function toStack() {
- // Use Late Binding here to solve the circular dependency.
- return Stack(isKeyed(this) ? this.valueSeq() : this);
- },
-
- toList: function toList() {
- // Use Late Binding here to solve the circular dependency.
- return List(isKeyed(this) ? this.valueSeq() : this);
- },
-
- // ### Common JavaScript methods and properties
-
- toString: function toString() {
- return '[Collection]';
- },
-
- __toString: function __toString(head, tail) {
- if (this.size === 0) {
- return head + tail;
- }
- return (
- head +
- ' ' +
- this.toSeq()
- .map(this.__toStringMapper)
- .join(', ') +
- ' ' +
- tail
- );
- },
-
- // ### ES6 Collection methods (ES6 Array and Map)
-
- concat: function concat() {
- var values = [], len = arguments.length;
- while ( len-- ) values[ len ] = arguments[ len ];
-
- return reify(this, concatFactory(this, values));
- },
-
- includes: function includes(searchValue) {
- return this.some(function (value) { return is(value, searchValue); });
- },
-
- entries: function entries() {
- return this.__iterator(ITERATE_ENTRIES);
- },
-
- every: function every(predicate, context) {
- assertNotInfinite(this.size);
- var returnValue = true;
- this.__iterate(function (v, k, c) {
- if (!predicate.call(context, v, k, c)) {
- returnValue = false;
- return false;
- }
- });
- return returnValue;
- },
-
- filter: function filter(predicate, context) {
- return reify(this, filterFactory(this, predicate, context, true));
- },
-
- find: function find(predicate, context, notSetValue) {
- var entry = this.findEntry(predicate, context);
- return entry ? entry[1] : notSetValue;
- },
-
- forEach: function forEach(sideEffect, context) {
- assertNotInfinite(this.size);
- return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
- },
-
- join: function join(separator) {
- assertNotInfinite(this.size);
- separator = separator !== undefined ? '' + separator : ',';
- var joined = '';
- var isFirst = true;
- this.__iterate(function (v) {
- isFirst ? (isFirst = false) : (joined += separator);
- joined += v !== null && v !== undefined ? v.toString() : '';
- });
- return joined;
- },
-
- keys: function keys() {
- return this.__iterator(ITERATE_KEYS);
- },
-
- map: function map(mapper, context) {
- return reify(this, mapFactory(this, mapper, context));
- },
-
- reduce: function reduce$1(reducer, initialReduction, context) {
- return reduce(
- this,
- reducer,
- initialReduction,
- context,
- arguments.length < 2,
- false
- );
- },
-
- reduceRight: function reduceRight(reducer, initialReduction, context) {
- return reduce(
- this,
- reducer,
- initialReduction,
- context,
- arguments.length < 2,
- true
- );
- },
-
- reverse: function reverse() {
- return reify(this, reverseFactory(this, true));
- },
-
- slice: function slice(begin, end) {
- return reify(this, sliceFactory(this, begin, end, true));
- },
-
- some: function some(predicate, context) {
- return !this.every(not(predicate), context);
- },
-
- sort: function sort(comparator) {
- return reify(this, sortFactory(this, comparator));
- },
-
- values: function values() {
- return this.__iterator(ITERATE_VALUES);
- },
-
- // ### More sequential methods
-
- butLast: function butLast() {
- return this.slice(0, -1);
- },
-
- isEmpty: function isEmpty() {
- return this.size !== undefined ? this.size === 0 : !this.some(function () { return true; });
- },
-
- count: function count(predicate, context) {
- return ensureSize(
- predicate ? this.toSeq().filter(predicate, context) : this
- );
- },
-
- countBy: function countBy(grouper, context) {
- return countByFactory(this, grouper, context);
- },
-
- equals: function equals(other) {
- return deepEqual(this, other);
- },
-
- entrySeq: function entrySeq() {
- var collection = this;
- if (collection._cache) {
- // We cache as an entries array, so we can just return the cache!
- return new ArraySeq(collection._cache);
- }
- var entriesSequence = collection
- .toSeq()
- .map(entryMapper)
- .toIndexedSeq();
- entriesSequence.fromEntrySeq = function () { return collection.toSeq(); };
- return entriesSequence;
- },
-
- filterNot: function filterNot(predicate, context) {
- return this.filter(not(predicate), context);
- },
-
- findEntry: function findEntry(predicate, context, notSetValue) {
- var found = notSetValue;
- this.__iterate(function (v, k, c) {
- if (predicate.call(context, v, k, c)) {
- found = [k, v];
- return false;
- }
- });
- return found;
- },
-
- findKey: function findKey(predicate, context) {
- var entry = this.findEntry(predicate, context);
- return entry && entry[0];
- },
-
- findLast: function findLast(predicate, context, notSetValue) {
- return this.toKeyedSeq()
- .reverse()
- .find(predicate, context, notSetValue);
- },
-
- findLastEntry: function findLastEntry(predicate, context, notSetValue) {
- return this.toKeyedSeq()
- .reverse()
- .findEntry(predicate, context, notSetValue);
- },
-
- findLastKey: function findLastKey(predicate, context) {
- return this.toKeyedSeq()
- .reverse()
- .findKey(predicate, context);
- },
-
- first: function first(notSetValue) {
- return this.find(returnTrue, null, notSetValue);
- },
-
- flatMap: function flatMap(mapper, context) {
- return reify(this, flatMapFactory(this, mapper, context));
- },
-
- flatten: function flatten(depth) {
- return reify(this, flattenFactory(this, depth, true));
- },
-
- fromEntrySeq: function fromEntrySeq() {
- return new FromEntriesSequence(this);
- },
-
- get: function get(searchKey, notSetValue) {
- return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue);
- },
-
- getIn: getIn$1,
-
- groupBy: function groupBy(grouper, context) {
- return groupByFactory(this, grouper, context);
- },
-
- has: function has(searchKey) {
- return this.get(searchKey, NOT_SET) !== NOT_SET;
- },
-
- hasIn: hasIn$1,
-
- isSubset: function isSubset(iter) {
- iter = typeof iter.includes === 'function' ? iter : Collection(iter);
- return this.every(function (value) { return iter.includes(value); });
- },
-
- isSuperset: function isSuperset(iter) {
- iter = typeof iter.isSubset === 'function' ? iter : Collection(iter);
- return iter.isSubset(this);
- },
-
- keyOf: function keyOf(searchValue) {
- return this.findKey(function (value) { return is(value, searchValue); });
- },
-
- keySeq: function keySeq() {
- return this.toSeq()
- .map(keyMapper)
- .toIndexedSeq();
- },
-
- last: function last(notSetValue) {
- return this.toSeq()
- .reverse()
- .first(notSetValue);
- },
-
- lastKeyOf: function lastKeyOf(searchValue) {
- return this.toKeyedSeq()
- .reverse()
- .keyOf(searchValue);
- },
-
- max: function max(comparator) {
- return maxFactory(this, comparator);
- },
-
- maxBy: function maxBy(mapper, comparator) {
- return maxFactory(this, comparator, mapper);
- },
-
- min: function min(comparator) {
- return maxFactory(
- this,
- comparator ? neg(comparator) : defaultNegComparator
- );
- },
-
- minBy: function minBy(mapper, comparator) {
- return maxFactory(
- this,
- comparator ? neg(comparator) : defaultNegComparator,
- mapper
- );
- },
-
- rest: function rest() {
- return this.slice(1);
- },
-
- skip: function skip(amount) {
- return amount === 0 ? this : this.slice(Math.max(0, amount));
- },
-
- skipLast: function skipLast(amount) {
- return amount === 0 ? this : this.slice(0, -Math.max(0, amount));
- },
-
- skipWhile: function skipWhile(predicate, context) {
- return reify(this, skipWhileFactory(this, predicate, context, true));
- },
-
- skipUntil: function skipUntil(predicate, context) {
- return this.skipWhile(not(predicate), context);
- },
-
- sortBy: function sortBy(mapper, comparator) {
- return reify(this, sortFactory(this, comparator, mapper));
- },
-
- take: function take(amount) {
- return this.slice(0, Math.max(0, amount));
- },
-
- takeLast: function takeLast(amount) {
- return this.slice(-Math.max(0, amount));
- },
-
- takeWhile: function takeWhile(predicate, context) {
- return reify(this, takeWhileFactory(this, predicate, context));
- },
-
- takeUntil: function takeUntil(predicate, context) {
- return this.takeWhile(not(predicate), context);
- },
-
- update: function update(fn) {
- return fn(this);
- },
-
- valueSeq: function valueSeq() {
- return this.toIndexedSeq();
- },
-
- // ### Hashable Object
-
- hashCode: function hashCode() {
- return this.__hash || (this.__hash = hashCollection(this));
- },
-
- // ### Internal
-
- // abstract __iterate(fn, reverse)
-
- // abstract __iterator(type, reverse)
- });
-
- var CollectionPrototype = Collection.prototype;
- CollectionPrototype[IS_COLLECTION_SYMBOL] = true;
- CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values;
- CollectionPrototype.toJSON = CollectionPrototype.toArray;
- CollectionPrototype.__toStringMapper = quoteString;
- CollectionPrototype.inspect = CollectionPrototype.toSource = function() {
- return this.toString();
- };
- CollectionPrototype.chain = CollectionPrototype.flatMap;
- CollectionPrototype.contains = CollectionPrototype.includes;
-
- mixin(KeyedCollection, {
- // ### More sequential methods
-
- flip: function flip() {
- return reify(this, flipFactory(this));
- },
-
- mapEntries: function mapEntries(mapper, context) {
- var this$1 = this;
-
- var iterations = 0;
- return reify(
- this,
- this.toSeq()
- .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1); })
- .fromEntrySeq()
- );
- },
-
- mapKeys: function mapKeys(mapper, context) {
- var this$1 = this;
-
- return reify(
- this,
- this.toSeq()
- .flip()
- .map(function (k, v) { return mapper.call(context, k, v, this$1); })
- .flip()
- );
- },
- });
-
- var KeyedCollectionPrototype = KeyedCollection.prototype;
- KeyedCollectionPrototype[IS_KEYED_SYMBOL] = true;
- KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries;
- KeyedCollectionPrototype.toJSON = toObject;
- KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); };
-
- mixin(IndexedCollection, {
- // ### Conversion to other types
-
- toKeyedSeq: function toKeyedSeq() {
- return new ToKeyedSequence(this, false);
- },
-
- // ### ES6 Collection methods (ES6 Array and Map)
-
- filter: function filter(predicate, context) {
- return reify(this, filterFactory(this, predicate, context, false));
- },
-
- findIndex: function findIndex(predicate, context) {
- var entry = this.findEntry(predicate, context);
- return entry ? entry[0] : -1;
- },
-
- indexOf: function indexOf(searchValue) {
- var key = this.keyOf(searchValue);
- return key === undefined ? -1 : key;
- },
-
- lastIndexOf: function lastIndexOf(searchValue) {
- var key = this.lastKeyOf(searchValue);
- return key === undefined ? -1 : key;
- },
-
- reverse: function reverse() {
- return reify(this, reverseFactory(this, false));
- },
-
- slice: function slice(begin, end) {
- return reify(this, sliceFactory(this, begin, end, false));
- },
-
- splice: function splice(index, removeNum /*, ...values*/) {
- var numArgs = arguments.length;
- removeNum = Math.max(removeNum || 0, 0);
- if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
- return this;
- }
- // If index is negative, it should resolve relative to the size of the
- // collection. However size may be expensive to compute if not cached, so
- // only call count() if the number is in fact negative.
- index = resolveBegin(index, index < 0 ? this.count() : this.size);
- var spliced = this.slice(0, index);
- return reify(
- this,
- numArgs === 1
- ? spliced
- : spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
- );
- },
-
- // ### More collection methods
-
- findLastIndex: function findLastIndex(predicate, context) {
- var entry = this.findLastEntry(predicate, context);
- return entry ? entry[0] : -1;
- },
-
- first: function first(notSetValue) {
- return this.get(0, notSetValue);
- },
-
- flatten: function flatten(depth) {
- return reify(this, flattenFactory(this, depth, false));
- },
-
- get: function get(index, notSetValue) {
- index = wrapIndex(this, index);
- return index < 0 ||
- (this.size === Infinity || (this.size !== undefined && index > this.size))
- ? notSetValue
- : this.find(function (_, key) { return key === index; }, undefined, notSetValue);
- },
-
- has: function has(index) {
- index = wrapIndex(this, index);
- return (
- index >= 0 &&
- (this.size !== undefined
- ? this.size === Infinity || index < this.size
- : this.indexOf(index) !== -1)
- );
- },
-
- interpose: function interpose(separator) {
- return reify(this, interposeFactory(this, separator));
- },
-
- interleave: function interleave(/*...collections*/) {
- var collections = [this].concat(arrCopy(arguments));
- var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, collections);
- var interleaved = zipped.flatten(true);
- if (zipped.size) {
- interleaved.size = zipped.size * collections.length;
- }
- return reify(this, interleaved);
- },
-
- keySeq: function keySeq() {
- return Range(0, this.size);
- },
-
- last: function last(notSetValue) {
- return this.get(-1, notSetValue);
- },
-
- skipWhile: function skipWhile(predicate, context) {
- return reify(this, skipWhileFactory(this, predicate, context, false));
- },
-
- zip: function zip(/*, ...collections */) {
- var collections = [this].concat(arrCopy(arguments));
- return reify(this, zipWithFactory(this, defaultZipper, collections));
- },
-
- zipAll: function zipAll(/*, ...collections */) {
- var collections = [this].concat(arrCopy(arguments));
- return reify(this, zipWithFactory(this, defaultZipper, collections, true));
- },
-
- zipWith: function zipWith(zipper /*, ...collections */) {
- var collections = arrCopy(arguments);
- collections[0] = this;
- return reify(this, zipWithFactory(this, zipper, collections));
- },
- });
-
- var IndexedCollectionPrototype = IndexedCollection.prototype;
- IndexedCollectionPrototype[IS_INDEXED_SYMBOL] = true;
- IndexedCollectionPrototype[IS_ORDERED_SYMBOL] = true;
-
- mixin(SetCollection, {
- // ### ES6 Collection methods (ES6 Array and Map)
-
- get: function get(value, notSetValue) {
- return this.has(value) ? value : notSetValue;
- },
-
- includes: function includes(value) {
- return this.has(value);
- },
-
- // ### More sequential methods
-
- keySeq: function keySeq() {
- return this.valueSeq();
- },
- });
-
- SetCollection.prototype.has = CollectionPrototype.includes;
- SetCollection.prototype.contains = SetCollection.prototype.includes;
-
- // Mixin subclasses
-
- mixin(KeyedSeq, KeyedCollection.prototype);
- mixin(IndexedSeq, IndexedCollection.prototype);
- mixin(SetSeq, SetCollection.prototype);
-
- // #pragma Helper functions
-
- function reduce(collection, reducer, reduction, context, useFirst, reverse) {
- assertNotInfinite(collection.size);
- collection.__iterate(function (v, k, c) {
- if (useFirst) {
- useFirst = false;
- reduction = v;
- } else {
- reduction = reducer.call(context, reduction, v, k, c);
- }
- }, reverse);
- return reduction;
- }
-
- function keyMapper(v, k) {
- return k;
- }
-
- function entryMapper(v, k) {
- return [k, v];
- }
-
- function not(predicate) {
- return function() {
- return !predicate.apply(this, arguments);
- };
- }
-
- function neg(predicate) {
- return function() {
- return -predicate.apply(this, arguments);
- };
- }
-
- function defaultZipper() {
- return arrCopy(arguments);
- }
-
- function defaultNegComparator(a, b) {
- return a < b ? 1 : a > b ? -1 : 0;
- }
-
- function hashCollection(collection) {
- if (collection.size === Infinity) {
- return 0;
- }
- var ordered = isOrdered(collection);
- var keyed = isKeyed(collection);
- var h = ordered ? 1 : 0;
- var size = collection.__iterate(
- keyed
- ? ordered
- ? function (v, k) {
- h = (31 * h + hashMerge(hash(v), hash(k))) | 0;
- }
- : function (v, k) {
- h = (h + hashMerge(hash(v), hash(k))) | 0;
- }
- : ordered
- ? function (v) {
- h = (31 * h + hash(v)) | 0;
- }
- : function (v) {
- h = (h + hash(v)) | 0;
- }
- );
- return murmurHashOfSize(size, h);
- }
-
- function murmurHashOfSize(size, h) {
- h = imul(h, 0xcc9e2d51);
- h = imul((h << 15) | (h >>> -15), 0x1b873593);
- h = imul((h << 13) | (h >>> -13), 5);
- h = ((h + 0xe6546b64) | 0) ^ size;
- h = imul(h ^ (h >>> 16), 0x85ebca6b);
- h = imul(h ^ (h >>> 13), 0xc2b2ae35);
- h = smi(h ^ (h >>> 16));
- return h;
- }
-
- function hashMerge(a, b) {
- return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int
- }
-
- var OrderedSet = /*@__PURE__*/(function (Set$$1) {
- function OrderedSet(value) {
- return value === null || value === undefined
- ? emptyOrderedSet()
- : isOrderedSet(value)
- ? value
- : emptyOrderedSet().withMutations(function (set) {
- var iter = SetCollection(value);
- assertNotInfinite(iter.size);
- iter.forEach(function (v) { return set.add(v); });
- });
- }
-
- if ( Set$$1 ) OrderedSet.__proto__ = Set$$1;
- OrderedSet.prototype = Object.create( Set$$1 && Set$$1.prototype );
- OrderedSet.prototype.constructor = OrderedSet;
-
- OrderedSet.of = function of (/*...values*/) {
- return this(arguments);
- };
-
- OrderedSet.fromKeys = function fromKeys (value) {
- return this(KeyedCollection(value).keySeq());
- };
-
- OrderedSet.prototype.toString = function toString () {
- return this.__toString('OrderedSet {', '}');
- };
-
- return OrderedSet;
- }(Set));
-
- OrderedSet.isOrderedSet = isOrderedSet;
-
- var OrderedSetPrototype = OrderedSet.prototype;
- OrderedSetPrototype[IS_ORDERED_SYMBOL] = true;
- OrderedSetPrototype.zip = IndexedCollectionPrototype.zip;
- OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith;
-
- OrderedSetPrototype.__empty = emptyOrderedSet;
- OrderedSetPrototype.__make = makeOrderedSet;
-
- function makeOrderedSet(map, ownerID) {
- var set = Object.create(OrderedSetPrototype);
- set.size = map ? map.size : 0;
- set._map = map;
- set.__ownerID = ownerID;
- return set;
- }
-
- var EMPTY_ORDERED_SET;
- function emptyOrderedSet() {
- return (
- EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()))
- );
- }
-
- var Record = function Record(defaultValues, name) {
- var hasInitialized;
-
- var RecordType = function Record(values) {
- var this$1 = this;
-
- if (values instanceof RecordType) {
- return values;
- }
- if (!(this instanceof RecordType)) {
- return new RecordType(values);
- }
- if (!hasInitialized) {
- hasInitialized = true;
- var keys = Object.keys(defaultValues);
- var indices = (RecordTypePrototype._indices = {});
- // Deprecated: left to attempt not to break any external code which
- // relies on a ._name property existing on record instances.
- // Use Record.getDescriptiveName() instead
- RecordTypePrototype._name = name;
- RecordTypePrototype._keys = keys;
- RecordTypePrototype._defaultValues = defaultValues;
- for (var i = 0; i < keys.length; i++) {
- var propName = keys[i];
- indices[propName] = i;
- if (RecordTypePrototype[propName]) {
- /* eslint-disable no-console */
- typeof console === 'object' &&
- console.warn &&
- console.warn(
- 'Cannot define ' +
- recordName(this) +
- ' with property "' +
- propName +
- '" since that property name is part of the Record API.'
- );
- /* eslint-enable no-console */
- } else {
- setProp(RecordTypePrototype, propName);
- }
- }
- }
- this.__ownerID = undefined;
- this._values = List().withMutations(function (l) {
- l.setSize(this$1._keys.length);
- KeyedCollection(values).forEach(function (v, k) {
- l.set(this$1._indices[k], v === this$1._defaultValues[k] ? undefined : v);
- });
- });
- };
-
- var RecordTypePrototype = (RecordType.prototype = Object.create(
- RecordPrototype
- ));
- RecordTypePrototype.constructor = RecordType;
-
- if (name) {
- RecordType.displayName = name;
- }
-
- return RecordType;
- };
-
- Record.prototype.toString = function toString () {
- var str = recordName(this) + ' { ';
- var keys = this._keys;
- var k;
- for (var i = 0, l = keys.length; i !== l; i++) {
- k = keys[i];
- str += (i ? ', ' : '') + k + ': ' + quoteString(this.get(k));
- }
- return str + ' }';
- };
-
- Record.prototype.equals = function equals (other) {
- return (
- this === other ||
- (other &&
- this._keys === other._keys &&
- recordSeq(this).equals(recordSeq(other)))
- );
- };
-
- Record.prototype.hashCode = function hashCode () {
- return recordSeq(this).hashCode();
- };
-
- // @pragma Access
-
- Record.prototype.has = function has (k) {
- return this._indices.hasOwnProperty(k);
- };
-
- Record.prototype.get = function get (k, notSetValue) {
- if (!this.has(k)) {
- return notSetValue;
- }
- var index = this._indices[k];
- var value = this._values.get(index);
- return value === undefined ? this._defaultValues[k] : value;
- };
-
- // @pragma Modification
-
- Record.prototype.set = function set (k, v) {
- if (this.has(k)) {
- var newValues = this._values.set(
- this._indices[k],
- v === this._defaultValues[k] ? undefined : v
- );
- if (newValues !== this._values && !this.__ownerID) {
- return makeRecord(this, newValues);
- }
- }
- return this;
- };
-
- Record.prototype.remove = function remove (k) {
- return this.set(k);
- };
-
- Record.prototype.clear = function clear () {
- var newValues = this._values.clear().setSize(this._keys.length);
- return this.__ownerID ? this : makeRecord(this, newValues);
- };
-
- Record.prototype.wasAltered = function wasAltered () {
- return this._values.wasAltered();
- };
-
- Record.prototype.toSeq = function toSeq () {
- return recordSeq(this);
- };
-
- Record.prototype.toJS = function toJS$1 () {
- return toJS(this);
- };
-
- Record.prototype.entries = function entries () {
- return this.__iterator(ITERATE_ENTRIES);
- };
-
- Record.prototype.__iterator = function __iterator (type, reverse) {
- return recordSeq(this).__iterator(type, reverse);
- };
-
- Record.prototype.__iterate = function __iterate (fn, reverse) {
- return recordSeq(this).__iterate(fn, reverse);
- };
-
- Record.prototype.__ensureOwner = function __ensureOwner (ownerID) {
- if (ownerID === this.__ownerID) {
- return this;
- }
- var newValues = this._values.__ensureOwner(ownerID);
- if (!ownerID) {
- this.__ownerID = ownerID;
- this._values = newValues;
- return this;
- }
- return makeRecord(this, newValues, ownerID);
- };
-
- Record.isRecord = isRecord;
- Record.getDescriptiveName = recordName;
- var RecordPrototype = Record.prototype;
- RecordPrototype[IS_RECORD_SYMBOL] = true;
- RecordPrototype[DELETE] = RecordPrototype.remove;
- RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn;
- RecordPrototype.getIn = getIn$1;
- RecordPrototype.hasIn = CollectionPrototype.hasIn;
- RecordPrototype.merge = merge;
- RecordPrototype.mergeWith = mergeWith;
- RecordPrototype.mergeIn = mergeIn;
- RecordPrototype.mergeDeep = mergeDeep$1;
- RecordPrototype.mergeDeepWith = mergeDeepWith$1;
- RecordPrototype.mergeDeepIn = mergeDeepIn;
- RecordPrototype.setIn = setIn$1;
- RecordPrototype.update = update$1;
- RecordPrototype.updateIn = updateIn$1;
- RecordPrototype.withMutations = withMutations;
- RecordPrototype.asMutable = asMutable;
- RecordPrototype.asImmutable = asImmutable;
- RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries;
- RecordPrototype.toJSON = RecordPrototype.toObject =
- CollectionPrototype.toObject;
- RecordPrototype.inspect = RecordPrototype.toSource = function() {
- return this.toString();
- };
-
- function makeRecord(likeRecord, values, ownerID) {
- var record = Object.create(Object.getPrototypeOf(likeRecord));
- record._values = values;
- record.__ownerID = ownerID;
- return record;
- }
-
- function recordName(record) {
- return record.constructor.displayName || record.constructor.name || 'Record';
- }
-
- function recordSeq(record) {
- return keyedSeqFromValue(record._keys.map(function (k) { return [k, record.get(k)]; }));
- }
-
- function setProp(prototype, name) {
- try {
- Object.defineProperty(prototype, name, {
- get: function() {
- return this.get(name);
- },
- set: function(value) {
- invariant(this.__ownerID, 'Cannot set on an immutable record.');
- this.set(name, value);
- },
- });
- } catch (error) {
- // Object.defineProperty failed. Probably IE8.
- }
- }
-
- /**
- * Returns a lazy Seq of `value` repeated `times` times. When `times` is
- * undefined, returns an infinite sequence of `value`.
- */
- var Repeat = /*@__PURE__*/(function (IndexedSeq$$1) {
- function Repeat(value, times) {
- if (!(this instanceof Repeat)) {
- return new Repeat(value, times);
- }
- this._value = value;
- this.size = times === undefined ? Infinity : Math.max(0, times);
- if (this.size === 0) {
- if (EMPTY_REPEAT) {
- return EMPTY_REPEAT;
- }
- EMPTY_REPEAT = this;
- }
- }
-
- if ( IndexedSeq$$1 ) Repeat.__proto__ = IndexedSeq$$1;
- Repeat.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype );
- Repeat.prototype.constructor = Repeat;
-
- Repeat.prototype.toString = function toString () {
- if (this.size === 0) {
- return 'Repeat []';
- }
- return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
- };
-
- Repeat.prototype.get = function get (index, notSetValue) {
- return this.has(index) ? this._value : notSetValue;
- };
-
- Repeat.prototype.includes = function includes (searchValue) {
- return is(this._value, searchValue);
- };
-
- Repeat.prototype.slice = function slice (begin, end) {
- var size = this.size;
- return wholeSlice(begin, end, size)
- ? this
- : new Repeat(
- this._value,
- resolveEnd(end, size) - resolveBegin(begin, size)
- );
- };
-
- Repeat.prototype.reverse = function reverse () {
- return this;
- };
-
- Repeat.prototype.indexOf = function indexOf (searchValue) {
- if (is(this._value, searchValue)) {
- return 0;
- }
- return -1;
- };
-
- Repeat.prototype.lastIndexOf = function lastIndexOf (searchValue) {
- if (is(this._value, searchValue)) {
- return this.size;
- }
- return -1;
- };
-
- Repeat.prototype.__iterate = function __iterate (fn, reverse) {
- var size = this.size;
- var i = 0;
- while (i !== size) {
- if (fn(this._value, reverse ? size - ++i : i++, this) === false) {
- break;
- }
- }
- return i;
- };
-
- Repeat.prototype.__iterator = function __iterator (type, reverse) {
- var this$1 = this;
-
- var size = this.size;
- var i = 0;
- return new Iterator(
- function () { return i === size
- ? iteratorDone()
- : iteratorValue(type, reverse ? size - ++i : i++, this$1._value); }
- );
- };
-
- Repeat.prototype.equals = function equals (other) {
- return other instanceof Repeat
- ? is(this._value, other._value)
- : deepEqual(other);
- };
-
- return Repeat;
- }(IndexedSeq));
-
- var EMPTY_REPEAT;
-
- function fromJS(value, converter) {
- return fromJSWith(
- [],
- converter || defaultConverter,
- value,
- '',
- converter && converter.length > 2 ? [] : undefined,
- { '': value }
- );
- }
-
- function fromJSWith(stack, converter, value, key, keyPath, parentValue) {
- var toSeq = Array.isArray(value)
- ? IndexedSeq
- : isPlainObj(value)
- ? KeyedSeq
- : null;
- if (toSeq) {
- if (~stack.indexOf(value)) {
- throw new TypeError('Cannot convert circular structure to Immutable');
- }
- stack.push(value);
- keyPath && key !== '' && keyPath.push(key);
- var converted = converter.call(
- parentValue,
- key,
- toSeq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); }
- ),
- keyPath && keyPath.slice()
- );
- stack.pop();
- keyPath && keyPath.pop();
- return converted;
- }
- return value;
- }
-
- function defaultConverter(k, v) {
- return isKeyed(v) ? v.toMap() : v.toList();
- }
-
- var version = "4.0.0-rc.11";
-
- var Immutable = {
- version: version,
-
- Collection: Collection,
- // Note: Iterable is deprecated
- Iterable: Collection,
-
- Seq: Seq,
- Map: Map,
- OrderedMap: OrderedMap,
- List: List,
- Stack: Stack,
- Set: Set,
- OrderedSet: OrderedSet,
-
- Record: Record,
- Range: Range,
- Repeat: Repeat,
-
- is: is,
- fromJS: fromJS,
- hash: hash,
-
- isImmutable: isImmutable,
- isCollection: isCollection,
- isKeyed: isKeyed,
- isIndexed: isIndexed,
- isAssociative: isAssociative,
- isOrdered: isOrdered,
- isValueObject: isValueObject,
- isSeq: isSeq,
- isList: isList,
- isMap: isMap,
- isOrderedMap: isOrderedMap,
- isStack: isStack,
- isSet: isSet,
- isOrderedSet: isOrderedSet,
- isRecord: isRecord,
-
- get: get,
- getIn: getIn,
- has: has,
- hasIn: hasIn,
- merge: merge$1,
- mergeDeep: mergeDeep,
- mergeWith: mergeWith$1,
- mergeDeepWith: mergeDeepWith,
- remove: remove,
- removeIn: removeIn,
- set: set,
- setIn: setIn,
- update: update,
- updateIn: updateIn,
- };
-
- // Note: Iterable is deprecated
- var Iterable = Collection;
-
- exports.default = Immutable;
- exports.version = version;
- exports.Collection = Collection;
- exports.Iterable = Iterable;
- exports.Seq = Seq;
- exports.Map = Map;
- exports.OrderedMap = OrderedMap;
- exports.List = List;
- exports.Stack = Stack;
- exports.Set = Set;
- exports.OrderedSet = OrderedSet;
- exports.Record = Record;
- exports.Range = Range;
- exports.Repeat = Repeat;
- exports.is = is;
- exports.fromJS = fromJS;
- exports.hash = hash;
- exports.isImmutable = isImmutable;
- exports.isCollection = isCollection;
- exports.isKeyed = isKeyed;
- exports.isIndexed = isIndexed;
- exports.isAssociative = isAssociative;
- exports.isOrdered = isOrdered;
- exports.isValueObject = isValueObject;
- exports.get = get;
- exports.getIn = getIn;
- exports.has = has;
- exports.hasIn = hasIn;
- exports.merge = merge$1;
- exports.mergeDeep = mergeDeep;
- exports.mergeWith = mergeWith$1;
- exports.mergeDeepWith = mergeDeepWith;
- exports.remove = remove;
- exports.removeIn = removeIn;
- exports.set = set;
- exports.setIn = setIn;
- exports.update = update;
- exports.updateIn = updateIn;
-
- Object.defineProperty(exports, '__esModule', { value: true });
-
- })));
- });
-
- unwrapExports(immutable$3);
-
- var draftjsUtils$1 = createCommonjsModule(function (module, exports) {
- !function(t,e){module.exports=e(Draft,immutable$3);}(window,function(n,r){return u={},o.m=i=[function(t,e){t.exports=n;},function(t,e){t.exports=r;},function(t,e,n){t.exports=n(3);},function(t,e,n){n.r(e);var C=n(0),i=n(1);function m(t){var e=t.getSelection(),n=t.getCurrentContent(),r=e.getStartKey(),o=e.getEndKey(),i=n.getBlockMap();return i.toSeq().skipUntil(function(t,e){return e===r}).takeUntil(function(t,e){return e===o}).concat([[o,i.get(o)]])}function a(t){return m(t).toList()}function f(t){if(t)return a(t).get(0)}function r(t){if(t){var n=f(t),e=t.getCurrentContent().getBlockMap().toSeq().toList(),r=0;if(e.forEach(function(t,e){t.get("key")===n.get("key")&&(r=e-1);}),-1<r)return e.get(r)}}function o(t){return t?t.getCurrentContent().getBlockMap().toList():new i.List}function u(t){var e=a(t);if(!e.some(function(t){return t.type!==e.get(0).type}))return e.get(0).type}function c(t){var e=C.RichUtils.tryToRemoveBlockStyle(t);return e?C.EditorState.push(t,e,"change-block-type"):t}function l(t){var e="",n=t.getSelection(),r=n.getAnchorOffset(),o=n.getFocusOffset(),i=a(t);if(0<i.size){if(n.getIsBackward()){var u=r;r=o,o=u;}for(var c=0;c<i.size;c+=1){var f=0===c?r:0,l=c===i.size-1?o:i.get(c).getText().length;e+=i.get(c).getText().slice(f,l);}}return e}function s(t){var e=t.getCurrentContent(),n=t.getSelection(),r=C.Modifier.removeRange(e,n,"forward"),o=r.getSelectionAfter(),i=r.getBlockForKey(o.getStartKey());return r=C.Modifier.insertText(r,o,"\n",i.getInlineStyleAt(o.getStartOffset()),null),C.EditorState.push(t,r,"insert-fragment")}function g(t){var e=C.Modifier.splitBlock(t.getCurrentContent(),t.getSelection());return c(C.EditorState.push(t,e,"split-block"))}function d(t){var e=t.getCurrentContent().getBlockMap().toList(),n=t.getSelection().merge({anchorKey:e.first().get("key"),anchorOffset:0,focusKey:e.last().get("key"),focusOffset:e.last().getLength()}),r=C.Modifier.removeRange(t.getCurrentContent(),n,"forward");return C.EditorState.push(t,r,"remove-range")}function S(t,e){var n=C.Modifier.setBlockData(t.getCurrentContent(),t.getSelection(),e);return C.EditorState.push(t,n,"change-block-data")}function p(t){var r=new i.Map({}),e=a(t);if(e&&0<e.size)for(var n=function(t){var n=e.get(t).getData();if(!n||0===n.size)return r=r.clear(),"break";if(0===t)r=n;else if(r.forEach(function(t,e){n.get(e)&&n.get(e)===t||(r=r.delete(e));}),0===r.size)return r=r.clear(),"break"},o=0;o<e.size;o+=1){if("break"===n(o))break}return r}var y=Object(i.Map)({code:{element:"pre"}}),v=C.DefaultDraftBlockRenderMap.merge(y);function b(t){if(t){var e=t.getType();return "unordered-list-item"===e||"ordered-list-item"===e}return !1}function h(t,e,n){var r,o=t.getSelection();r=o.getIsBackward()?o.getFocusKey():o.getAnchorKey();var i=t.getCurrentContent(),u=i.getBlockForKey(r),c=u.getType();if("unordered-list-item"!==c&&"ordered-list-item"!==c)return t;var f=i.getBlockBefore(r);if(!f)return t;if(f.getType()!==c)return t;var l=u.getDepth();if(1===e&&l===n)return t;var a,s,g,d,S,p,y,v=Math.min(f.getDepth()+1,n),b=(s=e,g=v,d=(a=t).getSelection(),S=a.getCurrentContent(),p=S.getBlockMap(),y=m(a).map(function(t){var e=t.getDepth()+s;return e=Math.max(0,Math.min(e,g)),t.set("depth",e)}),p=p.merge(y),S.merge({blockMap:p,selectionBefore:d,selectionAfter:d}));return C.EditorState.push(t,b,"adjust-depth")}function O(t,e){var n;return 13===(n=e).which&&(n.getModifierState("Shift")||n.getModifierState("Alt")||n.getModifierState("Control"))?t.getSelection().isCollapsed()?C.RichUtils.insertSoftNewline(t):s(t):function(t){var e=t.getSelection();if(e.isCollapsed()){var n=t.getCurrentContent(),r=e.getStartKey(),o=n.getBlockForKey(r);if(!b(o)&&"unstyled"!==o.getType()&&o.getLength()===e.getStartOffset())return g(t);if(b(o)&&0===o.getLength()){var i=o.getDepth();if(0===i)return c(t);if(0<i)return h(t,-1,i)}}}(t)}function k(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r);}return n}function E(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function I(t){return (I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function R(t){var e=t.getSelection();if(e.isCollapsed()){var n={},r=t.getCurrentInlineStyle().toList().toJS();if(r)return ["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"].forEach(function(t){n[t]=0<=r.indexOf(t);}),n}var u=e.getStartOffset(),c=e.getEndOffset(),f=a(t);if(0<f.size){var o=function(){for(var n={BOLD:!0,ITALIC:!0,UNDERLINE:!0,STRIKETHROUGH:!0,CODE:!0,SUPERSCRIPT:!0,SUBSCRIPT:!0},r=0;r<f.size;r+=1){var t=0===r?u:0,e=r===f.size-1?c:f.get(r).getText().length;t===e&&0===t?(t=1,e=2):t===e&&--t;for(var o=function(t){var e=f.get(r).getInlineStyleAt(t);["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"].forEach(function(t){n[t]=n[t]&&e.get(t)===t;});},i=t;i<e;i+=1)o(i);}return {v:n}}();if("object"===I(o))return o.v}return {}}function B(t){var e,n=t.getSelection(),r=n.getStartOffset(),o=n.getEndOffset();r===o&&0===r?o=1:r===o&&--r;for(var i=f(t),u=r;u<o;u+=1){var c=i.getEntityAt(u);if(!c){e=void 0;break}if(u===r)e=c;else if(e!==c){e=void 0;break}}return e}function T(t,e){var n,r=f(t);return r.findEntityRanges(function(t){return t.get("entity")===e},function(t,e){n={start:t,end:e,text:r.get("text").slice(t,e)};}),n}function P(t,e,n){x[t]["".concat(t.toLowerCase(),"-").concat(n)]=E({},"".concat(e),n);}function j(){return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?k(Object(n),!0).forEach(function(t){E(e,t,n[t]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):k(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t));});}return e}({},x.color,{},x.bgcolor,{},x.fontSize,{},x.fontFamily,{CODE:x.CODE,SUPERSCRIPT:x.SUPERSCRIPT,SUBSCRIPT:x.SUBSCRIPT})}var x={color:{},bgcolor:{},fontSize:{},fontFamily:{},CODE:{fontFamily:"monospace",wordWrap:"break-word",background:"#f1f1f1",borderRadius:3,padding:"1px 3px"},SUPERSCRIPT:{fontSize:11,position:"relative",top:-8,display:"inline-flex"},SUBSCRIPT:{fontSize:11,position:"relative",bottom:-8,display:"inline-flex"}};function M(t,e,n){var r=t.getSelection(),o=Object.keys(x[e]).reduce(function(t,e){return C.Modifier.removeInlineStyle(t,r,e)},t.getCurrentContent()),i=C.EditorState.push(t,o,"changeinline-style"),u=t.getCurrentInlineStyle();if(r.isCollapsed()&&(i=u.reduce(function(t,e){return C.RichUtils.toggleInlineStyle(t,e)},i)),"SUPERSCRIPT"===e||"SUBSCRIPT"==e)u.has(n)||(i=C.RichUtils.toggleInlineStyle(i,n));else{var c="bgcolor"===e?"backgroundColor":e;u.has("".concat(c,"-").concat(n))||(i=C.RichUtils.toggleInlineStyle(i,"".concat(e.toLowerCase(),"-").concat(n)),P(e,c,n));}return i}function L(t){t&&t.getCurrentContent().getBlockMap().map(function(t){return t.get("characterList")}).toList().flatten().forEach(function(t){t&&0===t.indexOf("color-")?P("color","color",t.substr(6)):t&&0===t.indexOf("bgcolor-")?P("bgcolor","backgroundColor",t.substr(8)):t&&0===t.indexOf("fontsize-")?P("fontSize","fontSize",+t.substr(9)):t&&0===t.indexOf("fontfamily-")&&P("fontFamily","fontFamily",t.substr(11));});}function U(t,e,n){var r=t.getInlineStyleAt(n).toList().filter(function(t){return t.startsWith(e.toLowerCase())});if(r&&0<r.size)return r.get(0)}function w(r,l){if(r&&l&&0<l.length){var t=function(){var t=r.getSelection(),i={};if(t.isCollapsed())return l.forEach(function(t){i[t]=function(t,e){var n=t.getCurrentInlineStyle().toList().filter(function(t){return t.startsWith(e.toLowerCase())});if(n&&0<n.size)return n.get(0)}(r,t);}),{v:i};var u=t.getStartOffset(),c=t.getEndOffset(),f=a(r);if(0<f.size){for(var e=function(n){var t=0===n?u:0,e=n===f.size-1?c:f.get(n).getText().length;t===e&&0===t?(t=1,e=2):t===e&&--t;for(var r=function(e){e===t?l.forEach(function(t){i[t]=U(f.get(n),t,e);}):l.forEach(function(t){i[t]&&i[t]!==U(f.get(n),t,e)&&(i[t]=void 0);});},o=t;o<e;o+=1)r(o);},n=0;n<f.size;n+=1)e(n);return {v:i}}}();if("object"===I(t))return t.v}return {}}function D(e){var t=e.getCurrentInlineStyle(),n=e.getCurrentContent();return t.forEach(function(t){n=C.Modifier.removeInlineStyle(n,e.getSelection(),t);}),C.EditorState.push(e,n,"change-inline-style")}n.d(e,"isListBlock",function(){return b}),n.d(e,"changeDepth",function(){return h}),n.d(e,"handleNewLine",function(){return O}),n.d(e,"getEntityRange",function(){return T}),n.d(e,"getCustomStyleMap",function(){return j}),n.d(e,"toggleCustomInlineStyle",function(){return M}),n.d(e,"getSelectionEntity",function(){return B}),n.d(e,"extractInlineStyle",function(){return L}),n.d(e,"removeAllInlineStyles",function(){return D}),n.d(e,"getSelectionInlineStyle",function(){return R}),n.d(e,"getSelectionCustomInlineStyle",function(){return w}),n.d(e,"getSelectedBlocksMap",function(){return m}),n.d(e,"getSelectedBlocksList",function(){return a}),n.d(e,"getSelectedBlock",function(){return f}),n.d(e,"getBlockBeforeSelectedBlock",function(){return r}),n.d(e,"getAllBlocks",function(){return o}),n.d(e,"getSelectedBlocksType",function(){return u}),n.d(e,"removeSelectedBlocksStyle",function(){return c}),n.d(e,"getSelectionText",function(){return l}),n.d(e,"addLineBreakRemovingSelection",function(){return s}),n.d(e,"insertNewUnstyledBlock",function(){return g}),n.d(e,"clearEditorContent",function(){return d}),n.d(e,"setBlockData",function(){return S}),n.d(e,"getSelectedBlocksMetadata",function(){return p}),n.d(e,"blockRenderMap",function(){return v});}],o.c=u,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n});},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0});},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=2);function o(t){if(u[t])return u[t].exports;var e=u[t]={i:t,l:!1,exports:{}};return i[t].call(e.exports,e,e.exports,o),e.l=!0,e.exports}var i,u;});
- });
-
- unwrapExports(draftjsUtils$1);
- var draftjsUtils_1$1 = draftjsUtils$1.draftjsUtils;
-
- var content$1 = createCommonjsModule(function (module, exports) {
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- 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;
-
-
-
-
-
-
-
-
-
- var _immutable2 = _interopRequireDefault(immutable$3);
-
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
- var strictBlockTypes = ['atomic'];
-
- var registerStrictBlockType = exports.registerStrictBlockType = function registerStrictBlockType(blockType) {
- strictBlockTypes.indexOf(blockType) === -1 && strictBlockTypes.push(blockType);
- };
-
- var isEditorState = exports.isEditorState = function isEditorState(editorState) {
- return editorState instanceof Draft.EditorState;
- };
-
- var createEmptyEditorState = exports.createEmptyEditorState = function createEmptyEditorState(editorDecorators) {
- return Draft.EditorState.createEmpty(editorDecorators);
- };
-
- var createEditorState = exports.createEditorState = function createEditorState(contentState, editorDecorators) {
- return Draft.EditorState.createWithContent(contentState, editorDecorators);
- };
-
- var isSelectionCollapsed = exports.isSelectionCollapsed = function isSelectionCollapsed(editorState) {
- return editorState.getSelection().isCollapsed();
- };
-
- var selectionContainsBlockType = exports.selectionContainsBlockType = function selectionContainsBlockType(editorState, blockType) {
- return getSelectedBlocks(editorState).find(function (block) {
- return block.getType() === blockType;
- });
- };
-
- var selectionContainsStrictBlock = exports.selectionContainsStrictBlock = function selectionContainsStrictBlock(editorState) {
- return getSelectedBlocks(editorState).find(function (block) {
- return ~strictBlockTypes.indexOf(block.getType());
- });
- };
-
- var selectBlock = exports.selectBlock = function selectBlock(editorState, block) {
-
- var blockKey = block.getKey();
-
- return Draft.EditorState.forceSelection(editorState, new Draft.SelectionState({
- anchorKey: blockKey,
- anchorOffset: 0,
- focusKey: blockKey,
- focusOffset: block.getLength()
- }));
- };
-
- var selectNextBlock = exports.selectNextBlock = function selectNextBlock(editorState, block) {
- var nextBlock = editorState.getCurrentContent().getBlockAfter(block.getKey());
- return nextBlock ? selectBlock(editorState, nextBlock) : editorState;
- };
-
- var removeBlock = exports.removeBlock = function removeBlock(editorState, block) {
- var lastSelection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
-
-
- var nextContentState = void 0,
- nextEditorState = void 0;
- var blockKey = block.getKey();
-
- nextContentState = Draft.Modifier.removeRange(editorState.getCurrentContent(), new Draft.SelectionState({
- anchorKey: blockKey,
- anchorOffset: 0,
- focusKey: blockKey,
- focusOffset: block.getLength()
- }), 'backward');
-
- nextContentState = Draft.Modifier.setBlockType(nextContentState, nextContentState.getSelectionAfter(), 'unstyled');
- nextEditorState = Draft.EditorState.push(editorState, nextContentState, 'remove-range');
- return Draft.EditorState.forceSelection(nextEditorState, lastSelection || nextContentState.getSelectionAfter());
- };
-
- var getSelectionBlock = exports.getSelectionBlock = function getSelectionBlock(editorState) {
- return editorState.getCurrentContent().getBlockForKey(editorState.getSelection().getAnchorKey());
- };
-
- var updateEachCharacterOfSelection = exports.updateEachCharacterOfSelection = function updateEachCharacterOfSelection(editorState, callback) {
-
- var selectionState = editorState.getSelection();
- var contentState = editorState.getCurrentContent();
- var contentBlocks = contentState.getBlockMap();
- var selectedBlocks = getSelectedBlocks(editorState);
-
- if (selectedBlocks.length === 0) {
- return editorState;
- }
-
- var startKey = selectionState.getStartKey();
- var startOffset = selectionState.getStartOffset();
- var endKey = selectionState.getEndKey();
- var endOffset = selectionState.getEndOffset();
-
- var nextContentBlocks = contentBlocks.map(function (block) {
-
- if (selectedBlocks.indexOf(block) === -1) {
- return block;
- }
-
- var blockKey = block.getKey();
- var charactersList = block.getCharacterList();
- var nextCharactersList = null;
-
- if (blockKey === startKey && blockKey === endKey) {
- nextCharactersList = charactersList.map(function (character, index) {
- if (index >= startOffset && index < endOffset) {
- return callback(character);
- }
- return character;
- });
- } else if (blockKey === startKey) {
- nextCharactersList = charactersList.map(function (character, index) {
- if (index >= startOffset) {
- return callback(character);
- }
- return character;
- });
- } else if (blockKey === endKey) {
- nextCharactersList = charactersList.map(function (character, index) {
- if (index < endOffset) {
- return callback(character);
- }
- return character;
- });
- } else {
- nextCharactersList = charactersList.map(function (character) {
- return callback(character);
- });
- }
-
- return block.merge({
- 'characterList': nextCharactersList
- });
- });
-
- return Draft.EditorState.push(editorState, contentState.merge({
- blockMap: nextContentBlocks,
- selectionBefore: selectionState,
- selectionAfter: selectionState
- }), 'update-selection-character-list');
- };
-
- var getSelectedBlocks = exports.getSelectedBlocks = function getSelectedBlocks(editorState) {
-
- var selectionState = editorState.getSelection();
- var contentState = editorState.getCurrentContent();
-
- var startKey = selectionState.getStartKey();
- var endKey = selectionState.getEndKey();
- var isSameBlock = startKey === endKey;
- var startingBlock = contentState.getBlockForKey(startKey);
- var selectedBlocks = [startingBlock];
-
- if (!isSameBlock) {
- var blockKey = startKey;
-
- while (blockKey !== endKey) {
- var nextBlock = contentState.getBlockAfter(blockKey);
- selectedBlocks.push(nextBlock);
- blockKey = nextBlock.getKey();
- }
- }
-
- return selectedBlocks;
- };
-
- var setSelectionBlockData = exports.setSelectionBlockData = function setSelectionBlockData(editorState, blockData, override) {
-
- var newBlockData = override ? blockData : Object.assign({}, getSelectionBlockData(editorState).toJS(), blockData);
-
- Object.keys(newBlockData).forEach(function (key) {
- if (newBlockData.hasOwnProperty(key) && newBlockData[key] === undefined) {
- delete newBlockData[key];
- }
- });
-
- return (0, draftjsUtils$1.setBlockData)(editorState, newBlockData);
- };
-
- var getSelectionBlockData = exports.getSelectionBlockData = function getSelectionBlockData(editorState, name) {
- var blockData = getSelectionBlock(editorState).getData();
- return name ? blockData.get(name) : blockData;
- };
-
- var getSelectionBlockType = exports.getSelectionBlockType = function getSelectionBlockType(editorState) {
- return getSelectionBlock(editorState).getType();
- };
-
- var getSelectionText = exports.getSelectionText = function getSelectionText(editorState) {
-
- var selectionState = editorState.getSelection();
- var contentState = editorState.getCurrentContent();
-
- if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
- return '';
- }
-
- var anchorKey = selectionState.getAnchorKey();
- var currentContentBlock = contentState.getBlockForKey(anchorKey);
- var start = selectionState.getStartOffset();
- var end = selectionState.getEndOffset();
-
- return currentContentBlock.getText().slice(start, end);
- };
-
- var toggleSelectionBlockType = exports.toggleSelectionBlockType = function toggleSelectionBlockType(editorState, blockType) {
-
- if (selectionContainsStrictBlock(editorState)) {
- return editorState;
- }
-
- return Draft.RichUtils.toggleBlockType(editorState, blockType);
- };
-
- var getSelectionEntityType = exports.getSelectionEntityType = function getSelectionEntityType(editorState) {
-
- var entityKey = (0, draftjsUtils$1.getSelectionEntity)(editorState);
-
- if (entityKey) {
- var entity = editorState.getCurrentContent().getEntity(entityKey);
- return entity ? entity.get('type') : null;
- }
-
- return null;
- };
-
- var getSelectionEntityData = exports.getSelectionEntityData = function getSelectionEntityData(editorState, type) {
-
- var entityKey = (0, draftjsUtils$1.getSelectionEntity)(editorState);
-
- if (entityKey) {
- var entity = editorState.getCurrentContent().getEntity(entityKey);
- if (entity && entity.get('type') === type) {
- return entity.getData();
- } else {
- return {};
- }
- } else {
- return {};
- }
- };
-
- var toggleSelectionEntity = exports.toggleSelectionEntity = function toggleSelectionEntity(editorState, entity) {
-
- var contentState = editorState.getCurrentContent();
- var selectionState = editorState.getSelection();
-
- if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
- return editorState;
- }
-
- if (!entity || !entity.type || getSelectionEntityType(editorState) === entity.type) {
- return Draft.EditorState.push(editorState, Draft.Modifier.applyEntity(contentState, selectionState, null), 'apply-entity');
- }
-
- try {
-
- var nextContentState = contentState.createEntity(entity.type, entity.mutability, entity.data);
- var entityKey = nextContentState.getLastCreatedEntityKey();
-
- var nextEditorState = Draft.EditorState.set(editorState, {
- currentContent: nextContentState
- });
-
- return Draft.EditorState.push(nextEditorState, Draft.Modifier.applyEntity(nextContentState, selectionState, entityKey), 'apply-entity');
- } catch (error) {
- console.warn(error);
- return editorState;
- }
- };
-
- var toggleSelectionLink = exports.toggleSelectionLink = function toggleSelectionLink(editorState, href, target) {
-
- var contentState = editorState.getCurrentContent();
- var selectionState = editorState.getSelection();
-
- var entityData = { href: href, target: target };
-
- if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
- return editorState;
- }
-
- if (href === false) {
- return Draft.RichUtils.toggleLink(editorState, selectionState, null);
- }
-
- if (href === null) {
- delete entityData.href;
- }
-
- try {
-
- var nextContentState = contentState.createEntity('LINK', 'MUTABLE', entityData);
- var entityKey = nextContentState.getLastCreatedEntityKey();
-
- var nextEditorState = Draft.EditorState.set(editorState, {
- currentContent: nextContentState
- });
-
- nextEditorState = Draft.RichUtils.toggleLink(nextEditorState, selectionState, entityKey);
- nextEditorState = Draft.EditorState.forceSelection(nextEditorState, selectionState.merge({
- anchorOffset: selectionState.getEndOffset(),
- focusOffset: selectionState.getEndOffset()
- }));
-
- nextEditorState = Draft.EditorState.push(nextEditorState, Draft.Modifier.insertText(nextEditorState.getCurrentContent(), nextEditorState.getSelection(), ''), 'insert-text');
-
- return nextEditorState;
- } catch (error) {
- console.warn(error);
- return editorState;
- }
- };
-
- var getSelectionInlineStyle = exports.getSelectionInlineStyle = function getSelectionInlineStyle(editorState) {
- return editorState.getCurrentInlineStyle();
- };
-
- var selectionHasInlineStyle = exports.selectionHasInlineStyle = function selectionHasInlineStyle(editorState, style) {
- return getSelectionInlineStyle(editorState).has(style.toUpperCase());
- };
-
- var toggleSelectionInlineStyle = exports.toggleSelectionInlineStyle = function toggleSelectionInlineStyle(editorState, style) {
- var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
-
-
- var nextEditorState = editorState;
- style = prefix + style.toUpperCase();
-
- if (prefix) {
-
- nextEditorState = updateEachCharacterOfSelection(nextEditorState, function (characterMetadata) {
-
- return characterMetadata.toJS().style.reduce(function (characterMetadata, characterStyle) {
- if (characterStyle.indexOf(prefix) === 0 && style !== characterStyle) {
- return Draft.CharacterMetadata.removeStyle(characterMetadata, characterStyle);
- } else {
- return characterMetadata;
- }
- }, characterMetadata);
- });
- }
-
- return Draft.RichUtils.toggleInlineStyle(nextEditorState, style);
- };
-
- var removeSelectionInlineStyles = exports.removeSelectionInlineStyles = function removeSelectionInlineStyles(editorState) {
-
- return updateEachCharacterOfSelection(editorState, function (characterMetadata) {
- return characterMetadata.merge({
- style: _immutable2.default.OrderedSet([])
- });
- });
- };
-
- var toggleSelectionAlignment = exports.toggleSelectionAlignment = function toggleSelectionAlignment(editorState, alignment) {
- return setSelectionBlockData(editorState, {
- textAlign: getSelectionBlockData(editorState, 'textAlign') !== alignment ? alignment : undefined
- });
- };
-
- var toggleSelectionIndent = exports.toggleSelectionIndent = function toggleSelectionIndent(editorState, textIndent) {
- var maxIndent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 6;
-
- return textIndent < 0 || textIndent > maxIndent || isNaN(textIndent) ? editorState : setSelectionBlockData(editorState, {
- textIndent: textIndent || undefined
- });
- };
-
- var increaseSelectionIndent = exports.increaseSelectionIndent = function increaseSelectionIndent(editorState) {
- var maxIndent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
-
- var currentIndent = getSelectionBlockData(editorState, 'textIndent') || 0;
- return toggleSelectionIndent(editorState, currentIndent + 1, maxIndent);
- };
-
- var decreaseSelectionIndent = exports.decreaseSelectionIndent = function decreaseSelectionIndent(editorState) {
- var currentIndent = getSelectionBlockData(editorState, 'textIndent') || 0;
- return toggleSelectionIndent(editorState, currentIndent - 1);
- };
-
- var toggleSelectionColor = exports.toggleSelectionColor = function toggleSelectionColor(editorState, color) {
- return toggleSelectionInlineStyle(editorState, color.replace('#', ''), 'COLOR-');
- };
-
- var toggleSelectionBackgroundColor = exports.toggleSelectionBackgroundColor = function toggleSelectionBackgroundColor(editorState, color) {
- return toggleSelectionInlineStyle(editorState, color.replace('#', ''), 'BGCOLOR-');
- };
-
- var toggleSelectionFontSize = exports.toggleSelectionFontSize = function toggleSelectionFontSize(editorState, fontSize) {
- return toggleSelectionInlineStyle(editorState, fontSize, 'FONTSIZE-');
- };
-
- var toggleSelectionLineHeight = exports.toggleSelectionLineHeight = function toggleSelectionLineHeight(editorState, lineHeight) {
- return toggleSelectionInlineStyle(editorState, lineHeight, 'LINEHEIGHT-');
- };
-
- var toggleSelectionFontFamily = exports.toggleSelectionFontFamily = function toggleSelectionFontFamily(editorState, fontFamily) {
- return toggleSelectionInlineStyle(editorState, fontFamily, 'FONTFAMILY-');
- };
-
- var toggleSelectionLetterSpacing = exports.toggleSelectionLetterSpacing = function toggleSelectionLetterSpacing(editorState, letterSpacing) {
- return toggleSelectionInlineStyle(editorState, letterSpacing, 'LETTERSPACING-');
- };
-
- var insertText = exports.insertText = function insertText(editorState, text, inlineStyle, entity) {
-
- var selectionState = editorState.getSelection();
- var currentSelectedBlockType = getSelectionBlockType(editorState);
-
- if (currentSelectedBlockType === 'atomic') {
- return editorState;
- }
-
- var entityKey = void 0;
- var contentState = editorState.getCurrentContent();
-
- if (entity && entity.type) {
- contentState = contentState.createEntity(entity.type, entity.mutability || 'MUTABLE', entity.data || entityData);
- entityKey = contentState.getLastCreatedEntityKey();
- }
-
- if (!selectionState.isCollapsed()) {
- return Draft.EditorState.push(editorState, Draft.Modifier.replaceText(contentState, selectionState, text, inlineStyle, entityKey), 'replace-text');
- } else {
- return Draft.EditorState.push(editorState, Draft.Modifier.insertText(contentState, selectionState, text, inlineStyle, entityKey), 'insert-text');
- }
- };
-
- var insertHTML = exports.insertHTML = function insertHTML(editorState, htmlString, source) {
-
- if (!htmlString) {
- return editorState;
- }
-
- var selectionState = editorState.getSelection();
- var contentState = editorState.getCurrentContent();
- var options = editorState.convertOptions || {};
-
- try {
- var _convertFromRaw = (0, Draft.convertFromRaw)((0, dist.convertHTMLToRaw)(htmlString, options, source)),
- blockMap = _convertFromRaw.blockMap;
-
- return Draft.EditorState.push(editorState, Draft.Modifier.replaceWithFragment(contentState, selectionState, blockMap), 'insert-fragment');
- } catch (error) {
- console.warn(error);
- return editorState;
- }
- };
-
- var insertAtomicBlock = exports.insertAtomicBlock = function insertAtomicBlock(editorState, type) {
- var immutable = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
- var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
-
-
- if (selectionContainsStrictBlock(editorState)) {
- return insertAtomicBlock(selectNextBlock(editorState, getSelectionBlock(editorState)), type, immutable, data);
- }
-
- var selectionState = editorState.getSelection();
- var contentState = editorState.getCurrentContent();
-
- if (!selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
- return editorState;
- }
-
- var contentStateWithEntity = contentState.createEntity(type, immutable ? 'IMMUTABLE' : 'MUTABLE', data);
- var entityKey = contentStateWithEntity.getLastCreatedEntityKey();
- var newEditorState = Draft.AtomicBlockUtils.insertAtomicBlock(editorState, entityKey, ' ');
-
- return newEditorState;
- };
-
- var insertHorizontalLine = exports.insertHorizontalLine = function insertHorizontalLine(editorState) {
- return insertAtomicBlock(editorState, 'HR');
- };
-
- var insertMedias = exports.insertMedias = function insertMedias(editorState) {
- var medias = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
-
-
- if (!medias.length) {
- return editorState;
- }
-
- return medias.reduce(function (editorState, media) {
- var url = media.url,
- link = media.link,
- link_target = media.link_target,
- name = media.name,
- type = media.type,
- width = media.width,
- height = media.height,
- meta = media.meta;
-
- return insertAtomicBlock(editorState, type, true, { url: url, link: link, link_target: link_target, name: name, type: type, width: width, height: height, meta: meta });
- }, editorState);
- };
-
- var setMediaData = exports.setMediaData = function setMediaData(editorState, entityKey, data) {
- return Draft.EditorState.push(editorState, editorState.getCurrentContent().mergeEntityData(entityKey, data), 'change-block-data');
- };
-
- var removeMedia = exports.removeMedia = function removeMedia(editorState, mediaBlock) {
- return removeBlock(editorState, mediaBlock);
- };
-
- var setMediaPosition = exports.setMediaPosition = function setMediaPosition(editorState, mediaBlock, position) {
-
- var newPosition = {};
- var float = position.float,
- alignment = position.alignment;
-
-
- if (typeof float !== 'undefined') {
- newPosition.float = mediaBlock.getData().get('float') === float ? null : float;
- }
-
- if (typeof alignment !== 'undefined') {
- newPosition.alignment = mediaBlock.getData().get('alignment') === alignment ? null : alignment;
- }
-
- return setSelectionBlockData(selectBlock(editorState, mediaBlock), newPosition);
- };
-
- var clear = exports.clear = function clear(editorState) {
-
- var contentState = editorState.getCurrentContent();
-
- var firstBlock = contentState.getFirstBlock();
- var lastBlock = contentState.getLastBlock();
-
- var allSelected = new Draft.SelectionState({
- anchorKey: firstBlock.getKey(),
- anchorOffset: 0,
- focusKey: lastBlock.getKey(),
- focusOffset: lastBlock.getLength(),
- hasFocus: true
- });
-
- return Draft.RichUtils.toggleBlockType(Draft.EditorState.push(editorState, Draft.Modifier.removeRange(contentState, allSelected, 'backward'), 'remove-range'), 'unstyled');
- };
-
- var handleKeyCommand = exports.handleKeyCommand = function handleKeyCommand(editorState, command) {
- return Draft.RichUtils.handleKeyCommand(editorState, command);
- };
-
- var undo = exports.undo = function undo(editorState) {
- return Draft.EditorState.undo(editorState);
- };
-
- var redo = exports.redo = function redo(editorState) {
- return Draft.EditorState.redo(editorState);
- };
- });
-
- unwrapExports(content$1);
- var content_1$1 = content$1.redo;
- var content_2$1 = content$1.undo;
- var content_3$1 = content$1.handleKeyCommand;
- var content_4$1 = content$1.clear;
- var content_5$1 = content$1.setMediaPosition;
- var content_6$1 = content$1.removeMedia;
- var content_7$1 = content$1.setMediaData;
- var content_8$1 = content$1.insertMedias;
- var content_9$1 = content$1.insertHorizontalLine;
- var content_10$1 = content$1.insertAtomicBlock;
- var content_11$1 = content$1.insertHTML;
- var content_12$1 = content$1.insertText;
- var content_13$1 = content$1.toggleSelectionLetterSpacing;
- var content_14$1 = content$1.toggleSelectionFontFamily;
- var content_15$1 = content$1.toggleSelectionLineHeight;
- var content_16$1 = content$1.toggleSelectionFontSize;
- var content_17$1 = content$1.toggleSelectionBackgroundColor;
- var content_18$1 = content$1.toggleSelectionColor;
- var content_19$1 = content$1.decreaseSelectionIndent;
- var content_20$1 = content$1.increaseSelectionIndent;
- var content_21$1 = content$1.toggleSelectionIndent;
- var content_22$1 = content$1.toggleSelectionAlignment;
- var content_23$1 = content$1.removeSelectionInlineStyles;
- var content_24$1 = content$1.toggleSelectionInlineStyle;
- var content_25$1 = content$1.selectionHasInlineStyle;
- var content_26$1 = content$1.getSelectionInlineStyle;
- var content_27$1 = content$1.toggleSelectionLink;
- var content_28$1 = content$1.toggleSelectionEntity;
- var content_29$1 = content$1.getSelectionEntityData;
- var content_30$1 = content$1.getSelectionEntityType;
- var content_31$1 = content$1.toggleSelectionBlockType;
- var content_32$1 = content$1.getSelectionText;
- var content_33$1 = content$1.getSelectionBlockType;
- var content_34$1 = content$1.getSelectionBlockData;
- var content_35$1 = content$1.setSelectionBlockData;
- var content_36$1 = content$1.getSelectedBlocks;
- var content_37$1 = content$1.updateEachCharacterOfSelection;
- var content_38$1 = content$1.getSelectionBlock;
- var content_39$1 = content$1.removeBlock;
- var content_40$1 = content$1.selectNextBlock;
- var content_41$1 = content$1.selectBlock;
- var content_42$1 = content$1.selectionContainsStrictBlock;
- var content_43$1 = content$1.selectionContainsBlockType;
- var content_44$1 = content$1.isSelectionCollapsed;
- var content_45$1 = content$1.createEditorState;
- var content_46$1 = content$1.createEmptyEditorState;
- var content_47$1 = content$1.isEditorState;
- var content_48$1 = content$1.registerStrictBlockType;
-
- var base$1 = createCommonjsModule(function (module, exports) {
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var braftUniqueIndex = 0;
-
- var UniqueIndex = exports.UniqueIndex = function UniqueIndex() {
- return braftUniqueIndex += 1;
- };
- });
-
- unwrapExports(base$1);
- var base_1$1 = base$1.UniqueIndex;
-
- var color$1 = createCommonjsModule(function (module, exports) {
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var _namedColors = {
- "aliceblue": "#f0f8ff",
- "antiquewhite": "#faebd7",
- "aqua": "#00ffff",
- "aquamarine": "#7fffd4",
- "azure": "#f0ffff",
- "beige": "#f5f5dc",
- "bisque": "#ffe4c4",
- "black": "#000000",
- "blanchedalmond": "#ffebcd",
- "blue": "#0000ff",
- "blueviolet": "#8a2be2",
- "brown": "#a52a2a",
- "burlywood": "#deb887",
- "cadetblue": "#5f9ea0",
- "chartreuse": "#7fff00",
- "chocolate": "#d2691e",
- "coral": "#ff7f50",
- "cornflowerblue": "#6495ed",
- "cornsilk": "#fff8dc",
- "crimson": "#dc143c",
- "cyan": "#00ffff",
- "darkblue": "#00008b",
- "darkcyan": "#008b8b",
- "darkgoldenrod": "#b8860b",
- "darkgray": "#a9a9a9",
- "darkgreen": "#006400",
- "darkkhaki": "#bdb76b",
- "darkmagenta": "#8b008b",
- "darkolivegreen": "#556b2f",
- "darkorange": "#ff8c00",
- "darkorchid": "#9932cc",
- "darkred": "#8b0000",
- "darksalmon": "#e9967a",
- "darkseagreen": "#8fbc8f",
- "darkslateblue": "#483d8b",
- "darkslategray": "#2f4f4f",
- "darkturquoise": "#00ced1",
- "darkviolet": "#9400d3",
- "deeppink": "#ff1493",
- "deepskyblue": "#00bfff",
- "dimgray": "#696969",
- "dodgerblue": "#1e90ff",
- "firebrick": "#b22222",
- "floralwhite": "#fffaf0",
- "forestgreen": "#228b22",
- "fuchsia": "#ff00ff",
- "gainsboro": "#dcdcdc",
- "ghostwhite": "#f8f8ff",
- "gold": "#ffd700",
- "goldenrod": "#daa520",
- "gray": "#808080",
- "green": "#008000",
- "greenyellow": "#adff2f",
- "honeydew": "#f0fff0",
- "hotpink": "#ff69b4",
- "indianred ": "#cd5c5c",
- "indigo": "#4b0082",
- "ivory": "#fffff0",
- "khaki": "#f0e68c",
- "lavender": "#e6e6fa",
- "lavenderblush": "#fff0f5",
- "lawngreen": "#7cfc00",
- "lemonchiffon": "#fffacd",
- "lightblue": "#add8e6",
- "lightcoral": "#f08080",
- "lightcyan": "#e0ffff",
- "lightgoldenrodyellow": "#fafad2",
- "lightgrey": "#d3d3d3",
- "lightgreen": "#90ee90",
- "lightpink": "#ffb6c1",
- "lightsalmon": "#ffa07a",
- "lightseagreen": "#20b2aa",
- "lightskyblue": "#87cefa",
- "lightslategray": "#778899",
- "lightsteelblue": "#b0c4de",
- "lightyellow": "#ffffe0",
- "lime": "#00ff00",
- "limegreen": "#32cd32",
- "linen": "#faf0e6",
- "magenta": "#ff00ff",
- "maroon": "#800000",
- "mediumaquamarine": "#66cdaa",
- "mediumblue": "#0000cd",
- "mediumorchid": "#ba55d3",
- "mediumpurple": "#9370d8",
- "mediumseagreen": "#3cb371",
- "mediumslateblue": "#7b68ee",
- "mediumspringgreen": "#00fa9a",
- "mediumturquoise": "#48d1cc",
- "mediumvioletred": "#c71585",
- "midnightblue": "#191970",
- "mintcream": "#f5fffa",
- "mistyrose": "#ffe4e1",
- "moccasin": "#ffe4b5",
- "navajowhite": "#ffdead",
- "navy": "#000080",
- "oldlace": "#fdf5e6",
- "olive": "#808000",
- "olivedrab": "#6b8e23",
- "orange": "#ffa500",
- "orangered": "#ff4500",
- "orchid": "#da70d6",
- "palegoldenrod": "#eee8aa",
- "palegreen": "#98fb98",
- "paleturquoise": "#afeeee",
- "palevioletred": "#d87093",
- "papayawhip": "#ffefd5",
- "peachpuff": "#ffdab9",
- "peru": "#cd853f",
- "pink": "#ffc0cb",
- "plum": "#dda0dd",
- "powderblue": "#b0e0e6",
- "purple": "#800080",
- "rebeccapurple": "#663399",
- "red": "#ff0000",
- "rosybrown": "#bc8f8f",
- "royalblue": "#4169e1",
- "saddlebrown": "#8b4513",
- "salmon": "#fa8072",
- "sandybrown": "#f4a460",
- "seagreen": "#2e8b57",
- "seashell": "#fff5ee",
- "sienna": "#a0522d",
- "silver": "#c0c0c0",
- "skyblue": "#87ceeb",
- "slateblue": "#6a5acd",
- "slategray": "#708090",
- "snow": "#fffafa",
- "springgreen": "#00ff7f",
- "steelblue": "#4682b4",
- "tan": "#d2b48c",
- "teal": "#008080",
- "thistle": "#d8bfd8",
- "tomato": "#ff6347",
- "turquoise": "#40e0d0",
- "violet": "#ee82ee",
- "wheat": "#f5deb3",
- "white": "#ffffff",
- "whitesmoke": "#f5f5f5",
- "yellow": "#ffff00",
- "yellowgreen": "#9acd32"
- };
-
- var _getHexColor = function _getHexColor(color) {
-
- color = color.replace('color:', '').replace(';', '').replace(' ', '');
-
- if (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(color)) {
- return color;
- } else if (namedColors[color]) {
- return namedColors[color];
- } else if (color.indexOf('rgb') === 0) {
-
- var rgbArray = color.split(',');
- var convertedColor = rgbArray.length < 3 ? null : '#' + [rgbArray[0], rgbArray[1], rgbArray[2]].map(function (x) {
- var hex = parseInt(x.replace(/\D/g, ''), 10).toString(16);
- return hex.length === 1 ? '0' + hex : hex;
- }).join('');
-
- return (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(convertedColor) ? convertedColor : null
- );
- } else {
- return null;
- }
- };
-
- var namedColors = exports.namedColors = _namedColors;
- var getHexColor = exports.getHexColor = _getHexColor;
-
- var detectColorsFromHTMLString = exports.detectColorsFromHTMLString = function detectColorsFromHTMLString(html) {
- return typeof html !== 'string' ? [] : (html.match(/color:[^;]{3,24};/g) || []).map(getHexColor).filter(function (color) {
- return color;
- });
- };
-
- var detectColorsFromDraftState = exports.detectColorsFromDraftState = function detectColorsFromDraftState(draftState) {
-
- var result = [];
-
- if (!draftState || !draftState.blocks || !draftState.blocks.length) {
- return result;
- }
-
- draftState.blocks.forEach(function (block) {
- if (block && block.inlineStyleRanges && block.inlineStyleRanges.length) {
- block.inlineStyleRanges.forEach(function (inlineStyle) {
- if (inlineStyle.style && inlineStyle.style.indexOf('COLOR-') >= 0) {
- result.push('#' + inlineStyle.style.split('COLOR-')[1]);
- }
- });
- }
- });
-
- return result.filter(function (color) {
- return color;
- });
- };
- });
-
- unwrapExports(color$1);
- var color_1$1 = color$1.namedColors;
- var color_2$1 = color$1.getHexColor;
- var color_3$1 = color$1.detectColorsFromHTMLString;
- var color_4$1 = color$1.detectColorsFromDraftState;
-
- var dist$4 = createCommonjsModule(function (module, exports) {
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.ColorUtils = exports.BaseUtils = exports.ContentUtils = undefined;
-
-
-
- var _ContentUtils = _interopRequireWildcard(content$1);
-
-
-
- var _BaseUtils = _interopRequireWildcard(base$1);
-
-
-
- var _ColorUtils = _interopRequireWildcard(color$1);
-
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
-
- var ContentUtils = exports.ContentUtils = _ContentUtils;
- var BaseUtils = exports.BaseUtils = _BaseUtils;
- var ColorUtils = exports.ColorUtils = _ColorUtils;
- });
-
- unwrapExports(dist$4);
- var dist_1$2 = dist$4.ColorUtils;
- var dist_2$2 = dist$4.BaseUtils;
- var dist_3$2 = dist$4.ContentUtils;
-
- var emoticon = createCommonjsModule(function (module, exports) {
- (function webpackUniversalModuleDefinition(root, factory) {
- module.exports = factory(React, dist$4);
- })(window, function(__WEBPACK_EXTERNAL_MODULE__1__, __WEBPACK_EXTERNAL_MODULE__6__) {
- return /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
- /******/ }
- /******/ };
- /******/
- /******/ // define __esModule on exports
- /******/ __webpack_require__.r = function(exports) {
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
- /******/ }
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
- /******/ };
- /******/
- /******/ // 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
- /******/ __webpack_require__.t = function(value, mode) {
- /******/ if(mode & 1) value = __webpack_require__(value);
- /******/ if(mode & 8) return value;
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
- /******/ var ns = Object.create(null);
- /******/ __webpack_require__.r(ns);
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
- /******/ return ns;
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "/";
- /******/
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 33);
- /******/ })
- /************************************************************************/
- /******/ ({
-
- /***/ 1:
- /***/ (function(module, exports) {
-
- module.exports = __WEBPACK_EXTERNAL_MODULE__1__;
-
- /***/ }),
-
- /***/ 2:
- /***/ (function(module, exports) {
-
- function _defineProperty(obj, key, value) {
- if (key in obj) {
- Object.defineProperty(obj, key, {
- value: value,
- enumerable: true,
- configurable: true,
- writable: true
- });
- } else {
- obj[key] = value;
- }
-
- return obj;
- }
-
- module.exports = _defineProperty;
-
- /***/ }),
-
- /***/ 33:
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- __webpack_require__.r(__webpack_exports__);
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultEmoticons", function() { return defaultEmoticons; });
- /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
- /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__);
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
- /* harmony import */ var braft_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6);
- /* harmony import */ var _styles_scss__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(48);
-
-
-
- // https://www.iconfinder.com/iconsets/emoji-18
-
- var defaultEmoticons = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25].map(function (item) {
- return "".concat(item, ".png");
- });
-
- var insertEmoticon = function insertEmoticon(editor, editorState, src) {
- editor.setValue(braft_utils__WEBPACK_IMPORTED_MODULE_2__["ContentUtils"].insertText(editorState, ' ', null, {
- type: 'EMOTICON',
- mutability: 'IMMUTABLE',
- data: {
- src: src
- }
- }));
- };
-
- var controlRef = null;
-
- var bindControlRef = function bindControlRef(ref) {
- return controlRef = ref;
- };
-
- /* harmony default export */ __webpack_exports__["default"] = (function (options) {
- options = _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default()({
- emoticons: [],
- closeOnSelect: false,
- closeOnBlur: false
- }, options);
- var _options = options,
- emoticons = _options.emoticons,
- closeOnSelect = _options.closeOnSelect,
- closeOnBlur = _options.closeOnBlur,
- includeEditors = _options.includeEditors,
- excludeEditors = _options.excludeEditors;
- return {
- type: 'entity',
- includeEditors: includeEditors,
- excludeEditors: excludeEditors,
- name: 'EMOTICON',
- control: function control(props) {
- return {
- key: 'EMOTICON',
- replace: 'emoji',
- type: 'dropdown',
- text: react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("i", {
- className: "bfi-emoji"
- }),
- showArrow: false,
- ref: bindControlRef,
- autoHide: closeOnBlur,
- component: react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("div", {
- className: "braft-emoticon-picker"
- }, react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("div", {
- className: "braft-emoticons-list"
- }, emoticons.map(function (item, index) {
- return react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("img", {
- onClick: function onClick() {
- insertEmoticon(props.editor, props.editorState, item);
- closeOnSelect && controlRef && controlRef.hide();
- },
- key: index,
- src: item
- });
- })))
- };
- },
- mutability: 'IMMUTABLE',
- component: function component(props) {
- var entity = props.contentState.getEntity(props.entityKey);
-
- var _entity$getData = entity.getData(),
- src = _entity$getData.src;
-
- return react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("span", {
- className: "braft-emoticon-in-editor"
- }, react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("img", {
- src: src
- }), props.children);
- },
- importer: function importer(nodeName, node) {
- if (nodeName.toLowerCase() === 'span' && node.classList && node.classList.contains('braft-emoticon-wrap')) {
- var imgNode = node.querySelector('img');
- var src = imgNode.getAttribute('src'); // 移除img节点以避免生成atomic block
-
- node.removeChild(imgNode);
- return {
- mutability: 'IMMUTABLE',
- data: {
- src: src
- }
- };
- }
- },
- exporter: function exporter(entityObject, initialText) {
- var src = entityObject.data.src;
- return react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("span", {
- className: "braft-emoticon-wrap"
- }, react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("img", {
- src: src
- }), initialText);
- }
- };
- });
-
- /***/ }),
-
- /***/ 48:
- /***/ (function(module, exports) {
-
- // removed by extract-text-webpack-plugin
-
- /***/ }),
-
- /***/ 5:
- /***/ (function(module, exports, __webpack_require__) {
-
- var defineProperty = __webpack_require__(2);
-
- function _objectSpread(target) {
- for (var i = 1; i < arguments.length; i++) {
- var source = arguments[i] != null ? arguments[i] : {};
- var ownKeys = Object.keys(source);
-
- if (typeof Object.getOwnPropertySymbols === 'function') {
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
- }));
- }
-
- ownKeys.forEach(function (key) {
- defineProperty(target, key, source[key]);
- });
- }
-
- return target;
- }
-
- module.exports = _objectSpread;
-
- /***/ }),
-
- /***/ 6:
- /***/ (function(module, exports) {
-
- module.exports = __WEBPACK_EXTERNAL_MODULE__6__;
-
- /***/ })
-
- /******/ });
- });
- });
-
- var Emoticon = unwrapExports(emoticon);
- var emoticon_1 = emoticon.defaultEmoticons;
-
- var maxLength = createCommonjsModule(function (module, exports) {
- (function webpackUniversalModuleDefinition(root, factory) {
- module.exports = factory();
- })(window, function() {
- return /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
- /******/ }
- /******/ };
- /******/
- /******/ // define __esModule on exports
- /******/ __webpack_require__.r = function(exports) {
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
- /******/ }
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
- /******/ };
- /******/
- /******/ // 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
- /******/ __webpack_require__.t = function(value, mode) {
- /******/ if(mode & 1) value = __webpack_require__(value);
- /******/ if(mode & 8) return value;
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
- /******/ var ns = Object.create(null);
- /******/ __webpack_require__.r(ns);
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
- /******/ return ns;
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "/";
- /******/
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 34);
- /******/ })
- /************************************************************************/
- /******/ ({
-
- /***/ 2:
- /***/ (function(module, exports) {
-
- function _defineProperty(obj, key, value) {
- if (key in obj) {
- Object.defineProperty(obj, key, {
- value: value,
- enumerable: true,
- configurable: true,
- writable: true
- });
- } else {
- obj[key] = value;
- }
-
- return obj;
- }
-
- module.exports = _defineProperty;
-
- /***/ }),
-
- /***/ 34:
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- __webpack_require__.r(__webpack_exports__);
- /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
- /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__);
-
-
- var getSelectedTextLength = function getSelectedTextLength(editorState) {
- var currentSelection = editorState.getSelection();
- var isCollapsed = currentSelection.isCollapsed();
- var length = 0;
-
- if (!isCollapsed) {
- var currentContent = editorState.getCurrentContent();
- var startKey = currentSelection.getStartKey();
- var endKey = currentSelection.getEndKey();
- var startBlock = currentContent.getBlockForKey(startKey);
- var isStartAndEndBlockAreTheSame = startKey === endKey;
- var startBlockTextLength = startBlock.getLength();
- var startSelectedTextLength = startBlockTextLength - currentSelection.getStartOffset();
- var endSelectedTextLength = currentSelection.getEndOffset();
- var keyAfterEnd = currentContent.getKeyAfter(endKey);
-
- if (isStartAndEndBlockAreTheSame) {
- length += currentSelection.getEndOffset() - currentSelection.getStartOffset();
- } else {
- var currentKey = startKey;
-
- while (currentKey && currentKey !== keyAfterEnd) {
- if (currentKey === startKey) {
- length += startSelectedTextLength + 1;
- } else if (currentKey === endKey) {
- length += endSelectedTextLength;
- } else {
- length += currentContent.getBlockForKey(currentKey).getLength() + 1;
- }
-
- currentKey = currentContent.getKeyAfter(currentKey);
- }
- }
- }
-
- return length;
- };
-
- /* harmony default export */ __webpack_exports__["default"] = (function (options) {
- options = _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default()({
- defaultValue: Infinity
- }, options);
- var _options = options,
- includeEditors = _options.includeEditors,
- excludeEditors = _options.excludeEditors,
- defaultValue = _options.defaultValue;
- return {
- type: 'prop-interception',
- includeEditors: includeEditors,
- excludeEditors: excludeEditors,
- interceptor: function interceptor(editorProps) {
- var maxLength = editorProps.maxLength || defaultValue;
-
- editorProps.handleBeforeInput = function (_, editorState) {
- if (maxLength === Infinity) {
- return 'not-handled';
- }
-
- var currentContentLength = editorState.toText().length;
- var selectedTextLength = getSelectedTextLength(editorState);
-
- if (currentContentLength - selectedTextLength > maxLength - 1) {
- editorProps.onReachMaxLength && editorProps.onReachMaxLength(maxLength);
- return 'handled';
- }
- };
-
- editorProps.handlePastedText = function (pastedText, _, editorState) {
- if (maxLength === Infinity) {
- return 'not-handled';
- }
-
- var currentContentLength = editorState.toText().length;
- var selectedTextLength = getSelectedTextLength(editorState);
-
- if (currentContentLength + pastedText.length - selectedTextLength > maxLength) {
- editorProps.onReachMaxLength && editorProps.onReachMaxLength(maxLength);
- return 'handled';
- }
- };
-
- return editorProps;
- }
- };
- });
-
- /***/ }),
-
- /***/ 5:
- /***/ (function(module, exports, __webpack_require__) {
-
- var defineProperty = __webpack_require__(2);
-
- function _objectSpread(target) {
- for (var i = 1; i < arguments.length; i++) {
- var source = arguments[i] != null ? arguments[i] : {};
- var ownKeys = Object.keys(source);
-
- if (typeof Object.getOwnPropertySymbols === 'function') {
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
- }));
- }
-
- ownKeys.forEach(function (key) {
- defineProperty(target, key, source[key]);
- });
- }
-
- return target;
- }
-
- module.exports = _objectSpread;
-
- /***/ })
-
- /******/ });
- });
- });
-
- var MaxLength = unwrapExports(maxLength);
-
- var lengthOptions = {
- defaultValue: 100
- };
- BraftEditor.use(MaxLength(lengthOptions));
- var emoticons = emoticon_1.map(function (item) {
- return require("braft-extensions/dist/assets/".concat(item));
- });
- var emotionOptions = {
- emoticons: emoticons,
- closeOnBlur: true,
- closeOnSelect: false
- };
- BraftEditor.use(Emoticon(emotionOptions));
- var BarftEditorPage = function BarftEditorPage(_ref) {
- var value = _ref.value;
- var controls = ["bold", "italic", "underline", "separator", "link", "emoji", "separator", "media"];
-
- var _useState = useState(BraftEditor.createEditorState(value || "<p>Hello <b>World!</b></p>")),
- _useState2 = _slicedToArray(_useState, 2),
- editorState = _useState2[0],
- setEditorState = _useState2[1];
-
- return React.createElement("div", {
- className: "editor-wrapper"
- }, React.createElement(BraftEditor, {
- value: editorState,
- onChange: setEditorState,
- controls: controls,
- contentStyle: {
- boxShadow: "inset 0 1px 3px rgba(0,0,0,.1)"
- }
- }));
- };
-
- export default BarftEditorPage;
- export { BarftEditorPage };
- //# sourceMappingURL=index.js.map
|