Sin descripción

blocks.js 483KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083
  1. this["wp"] = this["wp"] || {}; this["wp"]["blocks"] =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41. /******/ }
  42. /******/ };
  43. /******/
  44. /******/ // define __esModule on exports
  45. /******/ __webpack_require__.r = function(exports) {
  46. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48. /******/ }
  49. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  50. /******/ };
  51. /******/
  52. /******/ // create a fake namespace object
  53. /******/ // mode & 1: value is a module id, require it
  54. /******/ // mode & 2: merge all properties of value into the ns
  55. /******/ // mode & 4: return value when already ns object
  56. /******/ // mode & 8|1: behave like require
  57. /******/ __webpack_require__.t = function(value, mode) {
  58. /******/ if(mode & 1) value = __webpack_require__(value);
  59. /******/ if(mode & 8) return value;
  60. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61. /******/ var ns = Object.create(null);
  62. /******/ __webpack_require__.r(ns);
  63. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65. /******/ return ns;
  66. /******/ };
  67. /******/
  68. /******/ // getDefaultExport function for compatibility with non-harmony modules
  69. /******/ __webpack_require__.n = function(module) {
  70. /******/ var getter = module && module.__esModule ?
  71. /******/ function getDefault() { return module['default']; } :
  72. /******/ function getModuleExports() { return module; };
  73. /******/ __webpack_require__.d(getter, 'a', getter);
  74. /******/ return getter;
  75. /******/ };
  76. /******/
  77. /******/ // Object.prototype.hasOwnProperty.call
  78. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79. /******/
  80. /******/ // __webpack_public_path__
  81. /******/ __webpack_require__.p = "";
  82. /******/
  83. /******/
  84. /******/ // Load entry module and return exports
  85. /******/ return __webpack_require__(__webpack_require__.s = "0ATp");
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ "//Lo":
  90. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91. "use strict";
  92. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  93. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  94. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  95. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  96. /**
  97. * WordPress dependencies
  98. */
  99. const blockDefault = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  100. xmlns: "http://www.w3.org/2000/svg",
  101. viewBox: "0 0 24 24"
  102. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  103. d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z"
  104. }));
  105. /* harmony default export */ __webpack_exports__["a"] = (blockDefault);
  106. /***/ }),
  107. /***/ "0ATp":
  108. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109. "use strict";
  110. // ESM COMPAT FLAG
  111. __webpack_require__.r(__webpack_exports__);
  112. // EXPORTS
  113. __webpack_require__.d(__webpack_exports__, "store", function() { return /* reexport */ store; });
  114. __webpack_require__.d(__webpack_exports__, "createBlock", function() { return /* reexport */ createBlock; });
  115. __webpack_require__.d(__webpack_exports__, "createBlocksFromInnerBlocksTemplate", function() { return /* reexport */ createBlocksFromInnerBlocksTemplate; });
  116. __webpack_require__.d(__webpack_exports__, "cloneBlock", function() { return /* reexport */ cloneBlock; });
  117. __webpack_require__.d(__webpack_exports__, "__experimentalCloneSanitizedBlock", function() { return /* reexport */ __experimentalCloneSanitizedBlock; });
  118. __webpack_require__.d(__webpack_exports__, "getPossibleBlockTransformations", function() { return /* reexport */ getPossibleBlockTransformations; });
  119. __webpack_require__.d(__webpack_exports__, "switchToBlockType", function() { return /* reexport */ switchToBlockType; });
  120. __webpack_require__.d(__webpack_exports__, "getBlockTransforms", function() { return /* reexport */ getBlockTransforms; });
  121. __webpack_require__.d(__webpack_exports__, "findTransform", function() { return /* reexport */ findTransform; });
  122. __webpack_require__.d(__webpack_exports__, "getBlockFromExample", function() { return /* reexport */ getBlockFromExample; });
  123. __webpack_require__.d(__webpack_exports__, "parse", function() { return /* reexport */ parser; });
  124. __webpack_require__.d(__webpack_exports__, "getBlockAttributes", function() { return /* reexport */ getBlockAttributes; });
  125. __webpack_require__.d(__webpack_exports__, "parseWithAttributeSchema", function() { return /* reexport */ parseWithAttributeSchema; });
  126. __webpack_require__.d(__webpack_exports__, "pasteHandler", function() { return /* reexport */ pasteHandler; });
  127. __webpack_require__.d(__webpack_exports__, "rawHandler", function() { return /* reexport */ rawHandler; });
  128. __webpack_require__.d(__webpack_exports__, "getPhrasingContentSchema", function() { return /* reexport */ deprecatedGetPhrasingContentSchema; });
  129. __webpack_require__.d(__webpack_exports__, "serialize", function() { return /* reexport */ serialize; });
  130. __webpack_require__.d(__webpack_exports__, "getBlockContent", function() { return /* reexport */ getBlockInnerHTML; });
  131. __webpack_require__.d(__webpack_exports__, "getBlockDefaultClassName", function() { return /* reexport */ getBlockDefaultClassName; });
  132. __webpack_require__.d(__webpack_exports__, "getBlockMenuDefaultClassName", function() { return /* reexport */ getBlockMenuDefaultClassName; });
  133. __webpack_require__.d(__webpack_exports__, "getSaveElement", function() { return /* reexport */ getSaveElement; });
  134. __webpack_require__.d(__webpack_exports__, "getSaveContent", function() { return /* reexport */ getSaveContent; });
  135. __webpack_require__.d(__webpack_exports__, "__unstableGetBlockProps", function() { return /* reexport */ getBlockProps; });
  136. __webpack_require__.d(__webpack_exports__, "__unstableSerializeAndClean", function() { return /* reexport */ __unstableSerializeAndClean; });
  137. __webpack_require__.d(__webpack_exports__, "isValidBlockContent", function() { return /* reexport */ isValidBlockContent; });
  138. __webpack_require__.d(__webpack_exports__, "getCategories", function() { return /* reexport */ categories_getCategories; });
  139. __webpack_require__.d(__webpack_exports__, "setCategories", function() { return /* reexport */ categories_setCategories; });
  140. __webpack_require__.d(__webpack_exports__, "updateCategory", function() { return /* reexport */ categories_updateCategory; });
  141. __webpack_require__.d(__webpack_exports__, "registerBlockType", function() { return /* reexport */ registerBlockType; });
  142. __webpack_require__.d(__webpack_exports__, "registerBlockTypeFromMetadata", function() { return /* reexport */ registerBlockTypeFromMetadata; });
  143. __webpack_require__.d(__webpack_exports__, "registerBlockCollection", function() { return /* reexport */ registerBlockCollection; });
  144. __webpack_require__.d(__webpack_exports__, "unregisterBlockType", function() { return /* reexport */ unregisterBlockType; });
  145. __webpack_require__.d(__webpack_exports__, "setFreeformContentHandlerName", function() { return /* reexport */ setFreeformContentHandlerName; });
  146. __webpack_require__.d(__webpack_exports__, "getFreeformContentHandlerName", function() { return /* reexport */ getFreeformContentHandlerName; });
  147. __webpack_require__.d(__webpack_exports__, "setUnregisteredTypeHandlerName", function() { return /* reexport */ setUnregisteredTypeHandlerName; });
  148. __webpack_require__.d(__webpack_exports__, "getUnregisteredTypeHandlerName", function() { return /* reexport */ getUnregisteredTypeHandlerName; });
  149. __webpack_require__.d(__webpack_exports__, "setDefaultBlockName", function() { return /* reexport */ registration_setDefaultBlockName; });
  150. __webpack_require__.d(__webpack_exports__, "getDefaultBlockName", function() { return /* reexport */ registration_getDefaultBlockName; });
  151. __webpack_require__.d(__webpack_exports__, "setGroupingBlockName", function() { return /* reexport */ registration_setGroupingBlockName; });
  152. __webpack_require__.d(__webpack_exports__, "getGroupingBlockName", function() { return /* reexport */ registration_getGroupingBlockName; });
  153. __webpack_require__.d(__webpack_exports__, "getBlockType", function() { return /* reexport */ registration_getBlockType; });
  154. __webpack_require__.d(__webpack_exports__, "getBlockTypes", function() { return /* reexport */ registration_getBlockTypes; });
  155. __webpack_require__.d(__webpack_exports__, "getBlockSupport", function() { return /* reexport */ registration_getBlockSupport; });
  156. __webpack_require__.d(__webpack_exports__, "hasBlockSupport", function() { return /* reexport */ registration_hasBlockSupport; });
  157. __webpack_require__.d(__webpack_exports__, "getBlockVariations", function() { return /* reexport */ registration_getBlockVariations; });
  158. __webpack_require__.d(__webpack_exports__, "isReusableBlock", function() { return /* reexport */ isReusableBlock; });
  159. __webpack_require__.d(__webpack_exports__, "isTemplatePart", function() { return /* reexport */ isTemplatePart; });
  160. __webpack_require__.d(__webpack_exports__, "getChildBlockNames", function() { return /* reexport */ registration_getChildBlockNames; });
  161. __webpack_require__.d(__webpack_exports__, "hasChildBlocks", function() { return /* reexport */ registration_hasChildBlocks; });
  162. __webpack_require__.d(__webpack_exports__, "hasChildBlocksWithInserterSupport", function() { return /* reexport */ registration_hasChildBlocksWithInserterSupport; });
  163. __webpack_require__.d(__webpack_exports__, "unstable__bootstrapServerSideBlockDefinitions", function() { return /* reexport */ unstable__bootstrapServerSideBlockDefinitions; });
  164. __webpack_require__.d(__webpack_exports__, "registerBlockStyle", function() { return /* reexport */ registerBlockStyle; });
  165. __webpack_require__.d(__webpack_exports__, "unregisterBlockStyle", function() { return /* reexport */ unregisterBlockStyle; });
  166. __webpack_require__.d(__webpack_exports__, "registerBlockVariation", function() { return /* reexport */ registerBlockVariation; });
  167. __webpack_require__.d(__webpack_exports__, "unregisterBlockVariation", function() { return /* reexport */ unregisterBlockVariation; });
  168. __webpack_require__.d(__webpack_exports__, "isUnmodifiedDefaultBlock", function() { return /* reexport */ isUnmodifiedDefaultBlock; });
  169. __webpack_require__.d(__webpack_exports__, "normalizeIconObject", function() { return /* reexport */ normalizeIconObject; });
  170. __webpack_require__.d(__webpack_exports__, "isValidIcon", function() { return /* reexport */ isValidIcon; });
  171. __webpack_require__.d(__webpack_exports__, "__experimentalGetBlockLabel", function() { return /* reexport */ getBlockLabel; });
  172. __webpack_require__.d(__webpack_exports__, "__experimentalGetAccessibleBlockLabel", function() { return /* reexport */ getAccessibleBlockLabel; });
  173. __webpack_require__.d(__webpack_exports__, "__experimentalSanitizeBlockAttributes", function() { return /* reexport */ __experimentalSanitizeBlockAttributes; });
  174. __webpack_require__.d(__webpack_exports__, "__experimentalGetBlockAttributesNamesByRole", function() { return /* reexport */ __experimentalGetBlockAttributesNamesByRole; });
  175. __webpack_require__.d(__webpack_exports__, "doBlocksMatchTemplate", function() { return /* reexport */ doBlocksMatchTemplate; });
  176. __webpack_require__.d(__webpack_exports__, "synchronizeBlocksWithTemplate", function() { return /* reexport */ synchronizeBlocksWithTemplate; });
  177. __webpack_require__.d(__webpack_exports__, "children", function() { return /* reexport */ api_children; });
  178. __webpack_require__.d(__webpack_exports__, "node", function() { return /* reexport */ api_node; });
  179. __webpack_require__.d(__webpack_exports__, "__EXPERIMENTAL_STYLE_PROPERTY", function() { return /* reexport */ __EXPERIMENTAL_STYLE_PROPERTY; });
  180. __webpack_require__.d(__webpack_exports__, "__EXPERIMENTAL_ELEMENTS", function() { return /* reexport */ __EXPERIMENTAL_ELEMENTS; });
  181. __webpack_require__.d(__webpack_exports__, "withBlockContentContext", function() { return /* reexport */ withBlockContentContext; });
  182. // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/selectors.js
  183. var selectors_namespaceObject = {};
  184. __webpack_require__.r(selectors_namespaceObject);
  185. __webpack_require__.d(selectors_namespaceObject, "getBlockTypes", function() { return getBlockTypes; });
  186. __webpack_require__.d(selectors_namespaceObject, "getBlockType", function() { return getBlockType; });
  187. __webpack_require__.d(selectors_namespaceObject, "getBlockStyles", function() { return getBlockStyles; });
  188. __webpack_require__.d(selectors_namespaceObject, "getBlockVariations", function() { return getBlockVariations; });
  189. __webpack_require__.d(selectors_namespaceObject, "getActiveBlockVariation", function() { return getActiveBlockVariation; });
  190. __webpack_require__.d(selectors_namespaceObject, "getDefaultBlockVariation", function() { return getDefaultBlockVariation; });
  191. __webpack_require__.d(selectors_namespaceObject, "getCategories", function() { return getCategories; });
  192. __webpack_require__.d(selectors_namespaceObject, "getCollections", function() { return getCollections; });
  193. __webpack_require__.d(selectors_namespaceObject, "getDefaultBlockName", function() { return getDefaultBlockName; });
  194. __webpack_require__.d(selectors_namespaceObject, "getFreeformFallbackBlockName", function() { return getFreeformFallbackBlockName; });
  195. __webpack_require__.d(selectors_namespaceObject, "getUnregisteredFallbackBlockName", function() { return getUnregisteredFallbackBlockName; });
  196. __webpack_require__.d(selectors_namespaceObject, "getGroupingBlockName", function() { return getGroupingBlockName; });
  197. __webpack_require__.d(selectors_namespaceObject, "getChildBlockNames", function() { return getChildBlockNames; });
  198. __webpack_require__.d(selectors_namespaceObject, "getBlockSupport", function() { return getBlockSupport; });
  199. __webpack_require__.d(selectors_namespaceObject, "hasBlockSupport", function() { return hasBlockSupport; });
  200. __webpack_require__.d(selectors_namespaceObject, "isMatchingSearchTerm", function() { return isMatchingSearchTerm; });
  201. __webpack_require__.d(selectors_namespaceObject, "hasChildBlocks", function() { return hasChildBlocks; });
  202. __webpack_require__.d(selectors_namespaceObject, "hasChildBlocksWithInserterSupport", function() { return hasChildBlocksWithInserterSupport; });
  203. // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/actions.js
  204. var actions_namespaceObject = {};
  205. __webpack_require__.r(actions_namespaceObject);
  206. __webpack_require__.d(actions_namespaceObject, "addBlockTypes", function() { return addBlockTypes; });
  207. __webpack_require__.d(actions_namespaceObject, "removeBlockTypes", function() { return removeBlockTypes; });
  208. __webpack_require__.d(actions_namespaceObject, "addBlockStyles", function() { return addBlockStyles; });
  209. __webpack_require__.d(actions_namespaceObject, "removeBlockStyles", function() { return removeBlockStyles; });
  210. __webpack_require__.d(actions_namespaceObject, "addBlockVariations", function() { return addBlockVariations; });
  211. __webpack_require__.d(actions_namespaceObject, "removeBlockVariations", function() { return removeBlockVariations; });
  212. __webpack_require__.d(actions_namespaceObject, "setDefaultBlockName", function() { return setDefaultBlockName; });
  213. __webpack_require__.d(actions_namespaceObject, "setFreeformFallbackBlockName", function() { return setFreeformFallbackBlockName; });
  214. __webpack_require__.d(actions_namespaceObject, "setUnregisteredFallbackBlockName", function() { return setUnregisteredFallbackBlockName; });
  215. __webpack_require__.d(actions_namespaceObject, "setGroupingBlockName", function() { return setGroupingBlockName; });
  216. __webpack_require__.d(actions_namespaceObject, "setCategories", function() { return setCategories; });
  217. __webpack_require__.d(actions_namespaceObject, "updateCategory", function() { return updateCategory; });
  218. __webpack_require__.d(actions_namespaceObject, "addBlockCollection", function() { return addBlockCollection; });
  219. __webpack_require__.d(actions_namespaceObject, "removeBlockCollection", function() { return removeBlockCollection; });
  220. // EXTERNAL MODULE: external ["wp","data"]
  221. var external_wp_data_ = __webpack_require__("1ZqX");
  222. // EXTERNAL MODULE: external "lodash"
  223. var external_lodash_ = __webpack_require__("YLtl");
  224. // EXTERNAL MODULE: external ["wp","i18n"]
  225. var external_wp_i18n_ = __webpack_require__("l3Sj");
  226. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/reducer.js
  227. /**
  228. * External dependencies
  229. */
  230. /**
  231. * WordPress dependencies
  232. */
  233. /**
  234. * @typedef {Object} WPBlockCategory
  235. *
  236. * @property {string} slug Unique category slug.
  237. * @property {string} title Category label, for display in user interface.
  238. */
  239. /**
  240. * Default set of categories.
  241. *
  242. * @type {WPBlockCategory[]}
  243. */
  244. const DEFAULT_CATEGORIES = [{
  245. slug: 'text',
  246. title: Object(external_wp_i18n_["__"])('Text')
  247. }, {
  248. slug: 'media',
  249. title: Object(external_wp_i18n_["__"])('Media')
  250. }, {
  251. slug: 'design',
  252. title: Object(external_wp_i18n_["__"])('Design')
  253. }, {
  254. slug: 'widgets',
  255. title: Object(external_wp_i18n_["__"])('Widgets')
  256. }, {
  257. slug: 'theme',
  258. title: Object(external_wp_i18n_["__"])('Theme')
  259. }, {
  260. slug: 'embed',
  261. title: Object(external_wp_i18n_["__"])('Embeds')
  262. }, {
  263. slug: 'reusable',
  264. title: Object(external_wp_i18n_["__"])('Reusable blocks')
  265. }];
  266. /**
  267. * Reducer managing the block types
  268. *
  269. * @param {Object} state Current state.
  270. * @param {Object} action Dispatched action.
  271. *
  272. * @return {Object} Updated state.
  273. */
  274. function reducer_blockTypes(state = {}, action) {
  275. switch (action.type) {
  276. case 'ADD_BLOCK_TYPES':
  277. return { ...state,
  278. ...Object(external_lodash_["keyBy"])(Object(external_lodash_["map"])(action.blockTypes, blockType => Object(external_lodash_["omit"])(blockType, 'styles ')), 'name')
  279. };
  280. case 'REMOVE_BLOCK_TYPES':
  281. return Object(external_lodash_["omit"])(state, action.names);
  282. }
  283. return state;
  284. }
  285. /**
  286. * Reducer managing the block style variations.
  287. *
  288. * @param {Object} state Current state.
  289. * @param {Object} action Dispatched action.
  290. *
  291. * @return {Object} Updated state.
  292. */
  293. function blockStyles(state = {}, action) {
  294. switch (action.type) {
  295. case 'ADD_BLOCK_TYPES':
  296. return { ...state,
  297. ...Object(external_lodash_["mapValues"])(Object(external_lodash_["keyBy"])(action.blockTypes, 'name'), blockType => {
  298. return Object(external_lodash_["uniqBy"])([...Object(external_lodash_["get"])(blockType, ['styles'], []), ...Object(external_lodash_["get"])(state, [blockType.name], [])], style => style.name);
  299. })
  300. };
  301. case 'ADD_BLOCK_STYLES':
  302. return { ...state,
  303. [action.blockName]: Object(external_lodash_["uniqBy"])([...Object(external_lodash_["get"])(state, [action.blockName], []), ...action.styles], style => style.name)
  304. };
  305. case 'REMOVE_BLOCK_STYLES':
  306. return { ...state,
  307. [action.blockName]: Object(external_lodash_["filter"])(Object(external_lodash_["get"])(state, [action.blockName], []), style => action.styleNames.indexOf(style.name) === -1)
  308. };
  309. }
  310. return state;
  311. }
  312. /**
  313. * Reducer managing the block variations.
  314. *
  315. * @param {Object} state Current state.
  316. * @param {Object} action Dispatched action.
  317. *
  318. * @return {Object} Updated state.
  319. */
  320. function blockVariations(state = {}, action) {
  321. switch (action.type) {
  322. case 'ADD_BLOCK_TYPES':
  323. return { ...state,
  324. ...Object(external_lodash_["mapValues"])(Object(external_lodash_["keyBy"])(action.blockTypes, 'name'), blockType => {
  325. return Object(external_lodash_["uniqBy"])([...Object(external_lodash_["get"])(blockType, ['variations'], []), ...Object(external_lodash_["get"])(state, [blockType.name], [])], variation => variation.name);
  326. })
  327. };
  328. case 'ADD_BLOCK_VARIATIONS':
  329. return { ...state,
  330. [action.blockName]: Object(external_lodash_["uniqBy"])([...Object(external_lodash_["get"])(state, [action.blockName], []), ...action.variations], variation => variation.name)
  331. };
  332. case 'REMOVE_BLOCK_VARIATIONS':
  333. return { ...state,
  334. [action.blockName]: Object(external_lodash_["filter"])(Object(external_lodash_["get"])(state, [action.blockName], []), variation => action.variationNames.indexOf(variation.name) === -1)
  335. };
  336. }
  337. return state;
  338. }
  339. /**
  340. * Higher-order Reducer creating a reducer keeping track of given block name.
  341. *
  342. * @param {string} setActionType Action type.
  343. *
  344. * @return {Function} Reducer.
  345. */
  346. function createBlockNameSetterReducer(setActionType) {
  347. return (state = null, action) => {
  348. switch (action.type) {
  349. case 'REMOVE_BLOCK_TYPES':
  350. if (action.names.indexOf(state) !== -1) {
  351. return null;
  352. }
  353. return state;
  354. case setActionType:
  355. return action.name || null;
  356. }
  357. return state;
  358. };
  359. }
  360. const reducer_defaultBlockName = createBlockNameSetterReducer('SET_DEFAULT_BLOCK_NAME');
  361. const freeformFallbackBlockName = createBlockNameSetterReducer('SET_FREEFORM_FALLBACK_BLOCK_NAME');
  362. const unregisteredFallbackBlockName = createBlockNameSetterReducer('SET_UNREGISTERED_FALLBACK_BLOCK_NAME');
  363. const groupingBlockName = createBlockNameSetterReducer('SET_GROUPING_BLOCK_NAME');
  364. /**
  365. * Reducer managing the categories
  366. *
  367. * @param {WPBlockCategory[]} state Current state.
  368. * @param {Object} action Dispatched action.
  369. *
  370. * @return {WPBlockCategory[]} Updated state.
  371. */
  372. function reducer_categories(state = DEFAULT_CATEGORIES, action) {
  373. switch (action.type) {
  374. case 'SET_CATEGORIES':
  375. return action.categories || [];
  376. case 'UPDATE_CATEGORY':
  377. {
  378. if (!action.category || Object(external_lodash_["isEmpty"])(action.category)) {
  379. return state;
  380. }
  381. const categoryToChange = Object(external_lodash_["find"])(state, ['slug', action.slug]);
  382. if (categoryToChange) {
  383. return Object(external_lodash_["map"])(state, category => {
  384. if (category.slug === action.slug) {
  385. return { ...category,
  386. ...action.category
  387. };
  388. }
  389. return category;
  390. });
  391. }
  392. }
  393. }
  394. return state;
  395. }
  396. function collections(state = {}, action) {
  397. switch (action.type) {
  398. case 'ADD_BLOCK_COLLECTION':
  399. return { ...state,
  400. [action.namespace]: {
  401. title: action.title,
  402. icon: action.icon
  403. }
  404. };
  405. case 'REMOVE_BLOCK_COLLECTION':
  406. return Object(external_lodash_["omit"])(state, action.namespace);
  407. }
  408. return state;
  409. }
  410. /* harmony default export */ var reducer = (Object(external_wp_data_["combineReducers"])({
  411. blockTypes: reducer_blockTypes,
  412. blockStyles,
  413. blockVariations,
  414. defaultBlockName: reducer_defaultBlockName,
  415. freeformFallbackBlockName,
  416. unregisteredFallbackBlockName,
  417. groupingBlockName,
  418. categories: reducer_categories,
  419. collections
  420. }));
  421. // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js
  422. var rememo = __webpack_require__("pPDe");
  423. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/selectors.js
  424. /**
  425. * External dependencies
  426. */
  427. /** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */
  428. /** @typedef {import('../api/registration').WPBlockVariationScope} WPBlockVariationScope */
  429. /** @typedef {import('./reducer').WPBlockCategory} WPBlockCategory */
  430. /**
  431. * Given a block name or block type object, returns the corresponding
  432. * normalized block type object.
  433. *
  434. * @param {Object} state Blocks state.
  435. * @param {(string|Object)} nameOrType Block name or type object
  436. *
  437. * @return {Object} Block type object.
  438. */
  439. const getNormalizedBlockType = (state, nameOrType) => 'string' === typeof nameOrType ? getBlockType(state, nameOrType) : nameOrType;
  440. /**
  441. * Returns all the available block types.
  442. *
  443. * @param {Object} state Data state.
  444. *
  445. * @return {Array} Block Types.
  446. */
  447. const getBlockTypes = Object(rememo["a" /* default */])(state => {
  448. return Object.values(state.blockTypes).map(blockType => {
  449. return { ...blockType,
  450. variations: getBlockVariations(state, blockType.name)
  451. };
  452. });
  453. }, state => [state.blockTypes, state.blockVariations]);
  454. /**
  455. * Returns a block type by name.
  456. *
  457. * @param {Object} state Data state.
  458. * @param {string} name Block type name.
  459. *
  460. * @return {Object?} Block Type.
  461. */
  462. function getBlockType(state, name) {
  463. return state.blockTypes[name];
  464. }
  465. /**
  466. * Returns block styles by block name.
  467. *
  468. * @param {Object} state Data state.
  469. * @param {string} name Block type name.
  470. *
  471. * @return {Array?} Block Styles.
  472. */
  473. function getBlockStyles(state, name) {
  474. return state.blockStyles[name];
  475. }
  476. /**
  477. * Returns block variations by block name.
  478. *
  479. * @param {Object} state Data state.
  480. * @param {string} blockName Block type name.
  481. * @param {WPBlockVariationScope} [scope] Block variation scope name.
  482. *
  483. * @return {(WPBlockVariation[]|void)} Block variations.
  484. */
  485. const getBlockVariations = Object(rememo["a" /* default */])((state, blockName, scope) => {
  486. const variations = state.blockVariations[blockName];
  487. if (!variations || !scope) {
  488. return variations;
  489. }
  490. return variations.filter(variation => {
  491. // For backward compatibility reasons, variation's scope defaults to
  492. // `block` and `inserter` when not set.
  493. return (variation.scope || ['block', 'inserter']).includes(scope);
  494. });
  495. }, (state, blockName) => [state.blockVariations[blockName]]);
  496. /**
  497. * Returns the active block variation for a given block based on its attributes.
  498. * Variations are determined by their `isActive` property.
  499. * Which is either an array of block attribute keys or a function.
  500. *
  501. * In case of an array of block attribute keys, the `attributes` are compared
  502. * to the variation's attributes using strict equality check.
  503. *
  504. * In case of function type, the function should accept a block's attributes
  505. * and the variation's attributes and determines if a variation is active.
  506. * A function that accepts a block's attributes and the variation's attributes and determines if a variation is active.
  507. *
  508. * @param {Object} state Data state.
  509. * @param {string} blockName Name of block (example: “core/columns”).
  510. * @param {Object} attributes Block attributes used to determine active variation.
  511. * @param {WPBlockVariationScope} [scope] Block variation scope name.
  512. *
  513. * @return {(WPBlockVariation|undefined)} Active block variation.
  514. */
  515. function getActiveBlockVariation(state, blockName, attributes, scope) {
  516. const variations = getBlockVariations(state, blockName, scope);
  517. const match = variations === null || variations === void 0 ? void 0 : variations.find(variation => {
  518. var _variation$isActive;
  519. if (Array.isArray(variation.isActive)) {
  520. const blockType = getBlockType(state, blockName);
  521. const attributeKeys = Object.keys(blockType.attributes || {});
  522. const definedAttributes = variation.isActive.filter(attribute => attributeKeys.includes(attribute));
  523. if (definedAttributes.length === 0) {
  524. return false;
  525. }
  526. return definedAttributes.every(attribute => attributes[attribute] === variation.attributes[attribute]);
  527. }
  528. return (_variation$isActive = variation.isActive) === null || _variation$isActive === void 0 ? void 0 : _variation$isActive.call(variation, attributes, variation.attributes);
  529. });
  530. return match;
  531. }
  532. /**
  533. * Returns the default block variation for the given block type.
  534. * When there are multiple variations annotated as the default one,
  535. * the last added item is picked. This simplifies registering overrides.
  536. * When there is no default variation set, it returns the first item.
  537. *
  538. * @param {Object} state Data state.
  539. * @param {string} blockName Block type name.
  540. * @param {WPBlockVariationScope} [scope] Block variation scope name.
  541. *
  542. * @return {?WPBlockVariation} The default block variation.
  543. */
  544. function getDefaultBlockVariation(state, blockName, scope) {
  545. const variations = getBlockVariations(state, blockName, scope);
  546. return Object(external_lodash_["findLast"])(variations, 'isDefault') || Object(external_lodash_["first"])(variations);
  547. }
  548. /**
  549. * Returns all the available categories.
  550. *
  551. * @param {Object} state Data state.
  552. *
  553. * @return {WPBlockCategory[]} Categories list.
  554. */
  555. function getCategories(state) {
  556. return state.categories;
  557. }
  558. /**
  559. * Returns all the available collections.
  560. *
  561. * @param {Object} state Data state.
  562. *
  563. * @return {Object} Collections list.
  564. */
  565. function getCollections(state) {
  566. return state.collections;
  567. }
  568. /**
  569. * Returns the name of the default block name.
  570. *
  571. * @param {Object} state Data state.
  572. *
  573. * @return {string?} Default block name.
  574. */
  575. function getDefaultBlockName(state) {
  576. return state.defaultBlockName;
  577. }
  578. /**
  579. * Returns the name of the block for handling non-block content.
  580. *
  581. * @param {Object} state Data state.
  582. *
  583. * @return {string?} Name of the block for handling non-block content.
  584. */
  585. function getFreeformFallbackBlockName(state) {
  586. return state.freeformFallbackBlockName;
  587. }
  588. /**
  589. * Returns the name of the block for handling unregistered blocks.
  590. *
  591. * @param {Object} state Data state.
  592. *
  593. * @return {string?} Name of the block for handling unregistered blocks.
  594. */
  595. function getUnregisteredFallbackBlockName(state) {
  596. return state.unregisteredFallbackBlockName;
  597. }
  598. /**
  599. * Returns the name of the block for handling unregistered blocks.
  600. *
  601. * @param {Object} state Data state.
  602. *
  603. * @return {string?} Name of the block for handling unregistered blocks.
  604. */
  605. function getGroupingBlockName(state) {
  606. return state.groupingBlockName;
  607. }
  608. /**
  609. * Returns an array with the child blocks of a given block.
  610. *
  611. * @param {Object} state Data state.
  612. * @param {string} blockName Block type name.
  613. *
  614. * @return {Array} Array of child block names.
  615. */
  616. const getChildBlockNames = Object(rememo["a" /* default */])((state, blockName) => {
  617. return Object(external_lodash_["map"])(Object(external_lodash_["filter"])(state.blockTypes, blockType => {
  618. return Object(external_lodash_["includes"])(blockType.parent, blockName);
  619. }), ({
  620. name
  621. }) => name);
  622. }, state => [state.blockTypes]);
  623. /**
  624. * Returns the block support value for a feature, if defined.
  625. *
  626. * @param {Object} state Data state.
  627. * @param {(string|Object)} nameOrType Block name or type object
  628. * @param {string} feature Feature to retrieve
  629. * @param {*} defaultSupports Default value to return if not
  630. * explicitly defined
  631. *
  632. * @return {?*} Block support value
  633. */
  634. const getBlockSupport = (state, nameOrType, feature, defaultSupports) => {
  635. const blockType = getNormalizedBlockType(state, nameOrType);
  636. return Object(external_lodash_["get"])(blockType, ['supports', ...feature.split('.')], defaultSupports);
  637. };
  638. /**
  639. * Returns true if the block defines support for a feature, or false otherwise.
  640. *
  641. * @param {Object} state Data state.
  642. * @param {(string|Object)} nameOrType Block name or type object.
  643. * @param {string} feature Feature to test.
  644. * @param {boolean} defaultSupports Whether feature is supported by
  645. * default if not explicitly defined.
  646. *
  647. * @return {boolean} Whether block supports feature.
  648. */
  649. function hasBlockSupport(state, nameOrType, feature, defaultSupports) {
  650. return !!getBlockSupport(state, nameOrType, feature, defaultSupports);
  651. }
  652. /**
  653. * Returns true if the block type by the given name or object value matches a
  654. * search term, or false otherwise.
  655. *
  656. * @param {Object} state Blocks state.
  657. * @param {(string|Object)} nameOrType Block name or type object.
  658. * @param {string} searchTerm Search term by which to filter.
  659. *
  660. * @return {Object[]} Whether block type matches search term.
  661. */
  662. function isMatchingSearchTerm(state, nameOrType, searchTerm) {
  663. const blockType = getNormalizedBlockType(state, nameOrType);
  664. const getNormalizedSearchTerm = Object(external_lodash_["flow"])([// Disregard diacritics.
  665. // Input: "média"
  666. external_lodash_["deburr"], // Lowercase.
  667. // Input: "MEDIA"
  668. term => term.toLowerCase(), // Strip leading and trailing whitespace.
  669. // Input: " media "
  670. term => term.trim()]);
  671. const normalizedSearchTerm = getNormalizedSearchTerm(searchTerm);
  672. const isSearchMatch = Object(external_lodash_["flow"])([getNormalizedSearchTerm, normalizedCandidate => Object(external_lodash_["includes"])(normalizedCandidate, normalizedSearchTerm)]);
  673. return isSearchMatch(blockType.title) || Object(external_lodash_["some"])(blockType.keywords, isSearchMatch) || isSearchMatch(blockType.category);
  674. }
  675. /**
  676. * Returns a boolean indicating if a block has child blocks or not.
  677. *
  678. * @param {Object} state Data state.
  679. * @param {string} blockName Block type name.
  680. *
  681. * @return {boolean} True if a block contains child blocks and false otherwise.
  682. */
  683. const hasChildBlocks = (state, blockName) => {
  684. return getChildBlockNames(state, blockName).length > 0;
  685. };
  686. /**
  687. * Returns a boolean indicating if a block has at least one child block with inserter support.
  688. *
  689. * @param {Object} state Data state.
  690. * @param {string} blockName Block type name.
  691. *
  692. * @return {boolean} True if a block contains at least one child blocks with inserter support
  693. * and false otherwise.
  694. */
  695. const hasChildBlocksWithInserterSupport = (state, blockName) => {
  696. return Object(external_lodash_["some"])(getChildBlockNames(state, blockName), childBlockName => {
  697. return hasBlockSupport(state, childBlockName, 'inserter', true);
  698. });
  699. };
  700. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/actions.js
  701. /**
  702. * External dependencies
  703. */
  704. /** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */
  705. /**
  706. * Returns an action object used in signalling that block types have been added.
  707. *
  708. * @param {Array|Object} blockTypes Block types received.
  709. *
  710. * @return {Object} Action object.
  711. */
  712. function addBlockTypes(blockTypes) {
  713. return {
  714. type: 'ADD_BLOCK_TYPES',
  715. blockTypes: Object(external_lodash_["castArray"])(blockTypes)
  716. };
  717. }
  718. /**
  719. * Returns an action object used to remove a registered block type.
  720. *
  721. * @param {string|Array} names Block name.
  722. *
  723. * @return {Object} Action object.
  724. */
  725. function removeBlockTypes(names) {
  726. return {
  727. type: 'REMOVE_BLOCK_TYPES',
  728. names: Object(external_lodash_["castArray"])(names)
  729. };
  730. }
  731. /**
  732. * Returns an action object used in signalling that new block styles have been added.
  733. *
  734. * @param {string} blockName Block name.
  735. * @param {Array|Object} styles Block styles.
  736. *
  737. * @return {Object} Action object.
  738. */
  739. function addBlockStyles(blockName, styles) {
  740. return {
  741. type: 'ADD_BLOCK_STYLES',
  742. styles: Object(external_lodash_["castArray"])(styles),
  743. blockName
  744. };
  745. }
  746. /**
  747. * Returns an action object used in signalling that block styles have been removed.
  748. *
  749. * @param {string} blockName Block name.
  750. * @param {Array|string} styleNames Block style names.
  751. *
  752. * @return {Object} Action object.
  753. */
  754. function removeBlockStyles(blockName, styleNames) {
  755. return {
  756. type: 'REMOVE_BLOCK_STYLES',
  757. styleNames: Object(external_lodash_["castArray"])(styleNames),
  758. blockName
  759. };
  760. }
  761. /**
  762. * Returns an action object used in signalling that new block variations have been added.
  763. *
  764. * @param {string} blockName Block name.
  765. * @param {WPBlockVariation|WPBlockVariation[]} variations Block variations.
  766. *
  767. * @return {Object} Action object.
  768. */
  769. function addBlockVariations(blockName, variations) {
  770. return {
  771. type: 'ADD_BLOCK_VARIATIONS',
  772. variations: Object(external_lodash_["castArray"])(variations),
  773. blockName
  774. };
  775. }
  776. /**
  777. * Returns an action object used in signalling that block variations have been removed.
  778. *
  779. * @param {string} blockName Block name.
  780. * @param {string|string[]} variationNames Block variation names.
  781. *
  782. * @return {Object} Action object.
  783. */
  784. function removeBlockVariations(blockName, variationNames) {
  785. return {
  786. type: 'REMOVE_BLOCK_VARIATIONS',
  787. variationNames: Object(external_lodash_["castArray"])(variationNames),
  788. blockName
  789. };
  790. }
  791. /**
  792. * Returns an action object used to set the default block name.
  793. *
  794. * @param {string} name Block name.
  795. *
  796. * @return {Object} Action object.
  797. */
  798. function setDefaultBlockName(name) {
  799. return {
  800. type: 'SET_DEFAULT_BLOCK_NAME',
  801. name
  802. };
  803. }
  804. /**
  805. * Returns an action object used to set the name of the block used as a fallback
  806. * for non-block content.
  807. *
  808. * @param {string} name Block name.
  809. *
  810. * @return {Object} Action object.
  811. */
  812. function setFreeformFallbackBlockName(name) {
  813. return {
  814. type: 'SET_FREEFORM_FALLBACK_BLOCK_NAME',
  815. name
  816. };
  817. }
  818. /**
  819. * Returns an action object used to set the name of the block used as a fallback
  820. * for unregistered blocks.
  821. *
  822. * @param {string} name Block name.
  823. *
  824. * @return {Object} Action object.
  825. */
  826. function setUnregisteredFallbackBlockName(name) {
  827. return {
  828. type: 'SET_UNREGISTERED_FALLBACK_BLOCK_NAME',
  829. name
  830. };
  831. }
  832. /**
  833. * Returns an action object used to set the name of the block used
  834. * when grouping other blocks
  835. * eg: in "Group/Ungroup" interactions
  836. *
  837. * @param {string} name Block name.
  838. *
  839. * @return {Object} Action object.
  840. */
  841. function setGroupingBlockName(name) {
  842. return {
  843. type: 'SET_GROUPING_BLOCK_NAME',
  844. name
  845. };
  846. }
  847. /**
  848. * Returns an action object used to set block categories.
  849. *
  850. * @param {Object[]} categories Block categories.
  851. *
  852. * @return {Object} Action object.
  853. */
  854. function setCategories(categories) {
  855. return {
  856. type: 'SET_CATEGORIES',
  857. categories
  858. };
  859. }
  860. /**
  861. * Returns an action object used to update a category.
  862. *
  863. * @param {string} slug Block category slug.
  864. * @param {Object} category Object containing the category properties that should be updated.
  865. *
  866. * @return {Object} Action object.
  867. */
  868. function updateCategory(slug, category) {
  869. return {
  870. type: 'UPDATE_CATEGORY',
  871. slug,
  872. category
  873. };
  874. }
  875. /**
  876. * Returns an action object used to add block collections
  877. *
  878. * @param {string} namespace The namespace of the blocks to put in the collection
  879. * @param {string} title The title to display in the block inserter
  880. * @param {Object} icon (optional) The icon to display in the block inserter
  881. *
  882. * @return {Object} Action object.
  883. */
  884. function addBlockCollection(namespace, title, icon) {
  885. return {
  886. type: 'ADD_BLOCK_COLLECTION',
  887. namespace,
  888. title,
  889. icon
  890. };
  891. }
  892. /**
  893. * Returns an action object used to remove block collections
  894. *
  895. * @param {string} namespace The namespace of the blocks to put in the collection
  896. *
  897. * @return {Object} Action object.
  898. */
  899. function removeBlockCollection(namespace) {
  900. return {
  901. type: 'REMOVE_BLOCK_COLLECTION',
  902. namespace
  903. };
  904. }
  905. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/constants.js
  906. const STORE_NAME = 'core/blocks';
  907. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/index.js
  908. /**
  909. * WordPress dependencies
  910. */
  911. /**
  912. * Internal dependencies
  913. */
  914. /**
  915. * Store definition for the blocks namespace.
  916. *
  917. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  918. *
  919. * @type {Object}
  920. */
  921. const store = Object(external_wp_data_["createReduxStore"])(STORE_NAME, {
  922. reducer: reducer,
  923. selectors: selectors_namespaceObject,
  924. actions: actions_namespaceObject
  925. });
  926. Object(external_wp_data_["register"])(store);
  927. // EXTERNAL MODULE: ./node_modules/uuid/dist/esm-browser/v4.js + 4 modules
  928. var v4 = __webpack_require__("7Cbv");
  929. // EXTERNAL MODULE: external ["wp","hooks"]
  930. var external_wp_hooks_ = __webpack_require__("g56x");
  931. // EXTERNAL MODULE: external ["wp","deprecated"]
  932. var external_wp_deprecated_ = __webpack_require__("NMb1");
  933. var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_);
  934. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/block-default.js
  935. var block_default = __webpack_require__("//Lo");
  936. // EXTERNAL MODULE: ./node_modules/tinycolor2/tinycolor.js
  937. var tinycolor = __webpack_require__("Zss7");
  938. var tinycolor_default = /*#__PURE__*/__webpack_require__.n(tinycolor);
  939. // EXTERNAL MODULE: external ["wp","element"]
  940. var external_wp_element_ = __webpack_require__("GRId");
  941. // EXTERNAL MODULE: external ["wp","dom"]
  942. var external_wp_dom_ = __webpack_require__("1CF3");
  943. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/utils.js
  944. /**
  945. * External dependencies
  946. */
  947. /**
  948. * WordPress dependencies
  949. */
  950. /**
  951. * Internal dependencies
  952. */
  953. /**
  954. * Array of icon colors containing a color to be used if the icon color
  955. * was not explicitly set but the icon background color was.
  956. *
  957. * @type {Object}
  958. */
  959. const ICON_COLORS = ['#191e23', '#f8f9f9'];
  960. /**
  961. * Determines whether the block is a default block
  962. * and its attributes are equal to the default attributes
  963. * which means the block is unmodified.
  964. *
  965. * @param {WPBlock} block Block Object
  966. *
  967. * @return {boolean} Whether the block is an unmodified default block
  968. */
  969. function isUnmodifiedDefaultBlock(block) {
  970. const defaultBlockName = registration_getDefaultBlockName();
  971. if (block.name !== defaultBlockName) {
  972. return false;
  973. } // Cache a created default block if no cache exists or the default block
  974. // name changed.
  975. if (!isUnmodifiedDefaultBlock.block || isUnmodifiedDefaultBlock.block.name !== defaultBlockName) {
  976. isUnmodifiedDefaultBlock.block = createBlock(defaultBlockName);
  977. }
  978. const newDefaultBlock = isUnmodifiedDefaultBlock.block;
  979. const blockType = registration_getBlockType(defaultBlockName);
  980. return Object(external_lodash_["every"])(blockType.attributes, (value, key) => newDefaultBlock.attributes[key] === block.attributes[key]);
  981. }
  982. /**
  983. * Function that checks if the parameter is a valid icon.
  984. *
  985. * @param {*} icon Parameter to be checked.
  986. *
  987. * @return {boolean} True if the parameter is a valid icon and false otherwise.
  988. */
  989. function isValidIcon(icon) {
  990. return !!icon && (Object(external_lodash_["isString"])(icon) || Object(external_wp_element_["isValidElement"])(icon) || Object(external_lodash_["isFunction"])(icon) || icon instanceof external_wp_element_["Component"]);
  991. }
  992. /**
  993. * Function that receives an icon as set by the blocks during the registration
  994. * and returns a new icon object that is normalized so we can rely on just on possible icon structure
  995. * in the codebase.
  996. *
  997. * @param {WPBlockTypeIconRender} icon Render behavior of a block type icon;
  998. * one of a Dashicon slug, an element, or a
  999. * component.
  1000. *
  1001. * @return {WPBlockTypeIconDescriptor} Object describing the icon.
  1002. */
  1003. function normalizeIconObject(icon) {
  1004. if (isValidIcon(icon)) {
  1005. return {
  1006. src: icon
  1007. };
  1008. }
  1009. if (Object(external_lodash_["has"])(icon, ['background'])) {
  1010. const tinyBgColor = tinycolor_default()(icon.background);
  1011. return { ...icon,
  1012. foreground: icon.foreground ? icon.foreground : Object(tinycolor["mostReadable"])(tinyBgColor, ICON_COLORS, {
  1013. includeFallbackColors: true,
  1014. level: 'AA',
  1015. size: 'large'
  1016. }).toHexString(),
  1017. shadowColor: tinyBgColor.setAlpha(0.3).toRgbString()
  1018. };
  1019. }
  1020. return icon;
  1021. }
  1022. /**
  1023. * Normalizes block type passed as param. When string is passed then
  1024. * it converts it to the matching block type object.
  1025. * It passes the original object otherwise.
  1026. *
  1027. * @param {string|Object} blockTypeOrName Block type or name.
  1028. *
  1029. * @return {?Object} Block type.
  1030. */
  1031. function normalizeBlockType(blockTypeOrName) {
  1032. if (Object(external_lodash_["isString"])(blockTypeOrName)) {
  1033. return registration_getBlockType(blockTypeOrName);
  1034. }
  1035. return blockTypeOrName;
  1036. }
  1037. /**
  1038. * Get the label for the block, usually this is either the block title,
  1039. * or the value of the block's `label` function when that's specified.
  1040. *
  1041. * @param {Object} blockType The block type.
  1042. * @param {Object} attributes The values of the block's attributes.
  1043. * @param {Object} context The intended use for the label.
  1044. *
  1045. * @return {string} The block label.
  1046. */
  1047. function getBlockLabel(blockType, attributes, context = 'visual') {
  1048. const {
  1049. __experimentalLabel: getLabel,
  1050. title
  1051. } = blockType;
  1052. const label = getLabel && getLabel(attributes, {
  1053. context
  1054. });
  1055. if (!label) {
  1056. return title;
  1057. } // Strip any HTML (i.e. RichText formatting) before returning.
  1058. return Object(external_wp_dom_["__unstableStripHTML"])(label);
  1059. }
  1060. /**
  1061. * Get a label for the block for use by screenreaders, this is more descriptive
  1062. * than the visual label and includes the block title and the value of the
  1063. * `getLabel` function if it's specified.
  1064. *
  1065. * @param {Object} blockType The block type.
  1066. * @param {Object} attributes The values of the block's attributes.
  1067. * @param {?number} position The position of the block in the block list.
  1068. * @param {string} [direction='vertical'] The direction of the block layout.
  1069. *
  1070. * @return {string} The block label.
  1071. */
  1072. function getAccessibleBlockLabel(blockType, attributes, position, direction = 'vertical') {
  1073. // `title` is already localized, `label` is a user-supplied value.
  1074. const {
  1075. title
  1076. } = blockType;
  1077. const label = getBlockLabel(blockType, attributes, 'accessibility');
  1078. const hasPosition = position !== undefined; // getBlockLabel returns the block title as a fallback when there's no label,
  1079. // if it did return the title, this function needs to avoid adding the
  1080. // title twice within the accessible label. Use this `hasLabel` boolean to
  1081. // handle that.
  1082. const hasLabel = label && label !== title;
  1083. if (hasPosition && direction === 'vertical') {
  1084. if (hasLabel) {
  1085. return Object(external_wp_i18n_["sprintf"])(
  1086. /* translators: accessibility text. 1: The block title. 2: The block row number. 3: The block label.. */
  1087. Object(external_wp_i18n_["__"])('%1$s Block. Row %2$d. %3$s'), title, position, label);
  1088. }
  1089. return Object(external_wp_i18n_["sprintf"])(
  1090. /* translators: accessibility text. 1: The block title. 2: The block row number. */
  1091. Object(external_wp_i18n_["__"])('%1$s Block. Row %2$d'), title, position);
  1092. } else if (hasPosition && direction === 'horizontal') {
  1093. if (hasLabel) {
  1094. return Object(external_wp_i18n_["sprintf"])(
  1095. /* translators: accessibility text. 1: The block title. 2: The block column number. 3: The block label.. */
  1096. Object(external_wp_i18n_["__"])('%1$s Block. Column %2$d. %3$s'), title, position, label);
  1097. }
  1098. return Object(external_wp_i18n_["sprintf"])(
  1099. /* translators: accessibility text. 1: The block title. 2: The block column number. */
  1100. Object(external_wp_i18n_["__"])('%1$s Block. Column %2$d'), title, position);
  1101. }
  1102. if (hasLabel) {
  1103. return Object(external_wp_i18n_["sprintf"])(
  1104. /* translators: accessibility text. %1: The block title. %2: The block label. */
  1105. Object(external_wp_i18n_["__"])('%1$s Block. %2$s'), title, label);
  1106. }
  1107. return Object(external_wp_i18n_["sprintf"])(
  1108. /* translators: accessibility text. %s: The block title. */
  1109. Object(external_wp_i18n_["__"])('%s Block'), title);
  1110. }
  1111. /**
  1112. * Ensure attributes contains only values defined by block type, and merge
  1113. * default values for missing attributes.
  1114. *
  1115. * @param {string} name The block's name.
  1116. * @param {Object} attributes The block's attributes.
  1117. * @return {Object} The sanitized attributes.
  1118. */
  1119. function __experimentalSanitizeBlockAttributes(name, attributes) {
  1120. // Get the type definition associated with a registered block.
  1121. const blockType = registration_getBlockType(name);
  1122. if (undefined === blockType) {
  1123. throw new Error(`Block type '${name}' is not registered.`);
  1124. }
  1125. return Object(external_lodash_["reduce"])(blockType.attributes, (accumulator, schema, key) => {
  1126. const value = attributes[key];
  1127. if (undefined !== value) {
  1128. accumulator[key] = value;
  1129. } else if (schema.hasOwnProperty('default')) {
  1130. accumulator[key] = schema.default;
  1131. }
  1132. if (['node', 'children'].indexOf(schema.source) !== -1) {
  1133. // Ensure value passed is always an array, which we're expecting in
  1134. // the RichText component to handle the deprecated value.
  1135. if (typeof accumulator[key] === 'string') {
  1136. accumulator[key] = [accumulator[key]];
  1137. } else if (!Array.isArray(accumulator[key])) {
  1138. accumulator[key] = [];
  1139. }
  1140. }
  1141. return accumulator;
  1142. }, {});
  1143. }
  1144. /**
  1145. * Filter block attributes by `role` and return their names.
  1146. *
  1147. * @param {string} name Block attribute's name.
  1148. * @param {string} role The role of a block attribute.
  1149. *
  1150. * @return {string[]} The attribute names that have the provided role.
  1151. */
  1152. function __experimentalGetBlockAttributesNamesByRole(name, role) {
  1153. var _getBlockType;
  1154. const attributes = (_getBlockType = registration_getBlockType(name)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.attributes;
  1155. if (!attributes) return [];
  1156. const attributesNames = Object.keys(attributes);
  1157. if (!role) return attributesNames;
  1158. return attributesNames.filter(attributeName => {
  1159. var _attributes$attribute;
  1160. return ((_attributes$attribute = attributes[attributeName]) === null || _attributes$attribute === void 0 ? void 0 : _attributes$attribute.__experimentalRole) === role;
  1161. });
  1162. }
  1163. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/constants.js
  1164. /**
  1165. * Array of valid keys in a block type settings deprecation object.
  1166. *
  1167. * @type {string[]}
  1168. */
  1169. const DEPRECATED_ENTRY_KEYS = ['attributes', 'supports', 'save', 'migrate', 'isEligible', 'apiVersion'];
  1170. const __EXPERIMENTAL_STYLE_PROPERTY = {
  1171. //kept for back-compatibility purposes.
  1172. '--wp--style--color--link': {
  1173. value: ['color', 'link'],
  1174. support: ['color', 'link']
  1175. },
  1176. background: {
  1177. value: ['color', 'gradient'],
  1178. support: ['color', 'gradients']
  1179. },
  1180. backgroundColor: {
  1181. value: ['color', 'background'],
  1182. support: ['color']
  1183. },
  1184. borderColor: {
  1185. value: ['border', 'color'],
  1186. support: ['__experimentalBorder', 'color']
  1187. },
  1188. borderRadius: {
  1189. value: ['border', 'radius'],
  1190. support: ['__experimentalBorder', 'radius']
  1191. },
  1192. borderStyle: {
  1193. value: ['border', 'style'],
  1194. support: ['__experimentalBorder', 'style']
  1195. },
  1196. borderWidth: {
  1197. value: ['border', 'width'],
  1198. support: ['__experimentalBorder', 'width']
  1199. },
  1200. color: {
  1201. value: ['color', 'text'],
  1202. support: ['color']
  1203. },
  1204. linkColor: {
  1205. value: ['elements', 'link', 'color', 'text'],
  1206. support: ['color', 'link']
  1207. },
  1208. fontFamily: {
  1209. value: ['typography', 'fontFamily'],
  1210. support: ['typography', '__experimentalFontFamily']
  1211. },
  1212. fontSize: {
  1213. value: ['typography', 'fontSize'],
  1214. support: ['typography', 'fontSize']
  1215. },
  1216. fontStyle: {
  1217. value: ['typography', 'fontStyle'],
  1218. support: ['typography', '__experimentalFontStyle']
  1219. },
  1220. fontWeight: {
  1221. value: ['typography', 'fontWeight'],
  1222. support: ['typography', '__experimentalFontWeight']
  1223. },
  1224. lineHeight: {
  1225. value: ['typography', 'lineHeight'],
  1226. support: ['typography', 'lineHeight']
  1227. },
  1228. margin: {
  1229. value: ['spacing', 'margin'],
  1230. support: ['spacing', 'margin'],
  1231. properties: ['top', 'right', 'bottom', 'left']
  1232. },
  1233. padding: {
  1234. value: ['spacing', 'padding'],
  1235. support: ['spacing', 'padding'],
  1236. properties: ['top', 'right', 'bottom', 'left']
  1237. },
  1238. textDecoration: {
  1239. value: ['typography', 'textDecoration'],
  1240. support: ['typography', '__experimentalTextDecoration']
  1241. },
  1242. textTransform: {
  1243. value: ['typography', 'textTransform'],
  1244. support: ['typography', '__experimentalTextTransform']
  1245. }
  1246. };
  1247. const __EXPERIMENTAL_ELEMENTS = {
  1248. link: 'a',
  1249. h1: 'h1',
  1250. h2: 'h2',
  1251. h3: 'h3',
  1252. h4: 'h4',
  1253. h5: 'h5',
  1254. h6: 'h6'
  1255. };
  1256. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/registration.js
  1257. /* eslint no-console: [ 'error', { allow: [ 'error', 'warn' ] } ] */
  1258. /**
  1259. * External dependencies
  1260. */
  1261. /**
  1262. * WordPress dependencies
  1263. */
  1264. /**
  1265. * Internal dependencies
  1266. */
  1267. const i18nBlockSchema = {
  1268. title: "block title",
  1269. description: "block description",
  1270. keywords: ["block keyword"],
  1271. styles: [{
  1272. label: "block style label"
  1273. }],
  1274. variations: [{
  1275. title: "block variation title",
  1276. description: "block variation description",
  1277. keywords: ["block variation keyword"]
  1278. }]
  1279. };
  1280. /**
  1281. * An icon type definition. One of a Dashicon slug, an element,
  1282. * or a component.
  1283. *
  1284. * @typedef {(string|WPElement|WPComponent)} WPIcon
  1285. *
  1286. * @see https://developer.wordpress.org/resource/dashicons/
  1287. */
  1288. /**
  1289. * Render behavior of a block type icon; one of a Dashicon slug, an element,
  1290. * or a component.
  1291. *
  1292. * @typedef {WPIcon} WPBlockTypeIconRender
  1293. */
  1294. /**
  1295. * An object describing a normalized block type icon.
  1296. *
  1297. * @typedef {Object} WPBlockTypeIconDescriptor
  1298. *
  1299. * @property {WPBlockTypeIconRender} src Render behavior of the icon,
  1300. * one of a Dashicon slug, an
  1301. * element, or a component.
  1302. * @property {string} background Optimal background hex string
  1303. * color when displaying icon.
  1304. * @property {string} foreground Optimal foreground hex string
  1305. * color when displaying icon.
  1306. * @property {string} shadowColor Optimal shadow hex string
  1307. * color when displaying icon.
  1308. */
  1309. /**
  1310. * Value to use to render the icon for a block type in an editor interface,
  1311. * either a Dashicon slug, an element, a component, or an object describing
  1312. * the icon.
  1313. *
  1314. * @typedef {(WPBlockTypeIconDescriptor|WPBlockTypeIconRender)} WPBlockTypeIcon
  1315. */
  1316. /**
  1317. * Named block variation scopes.
  1318. *
  1319. * @typedef {'block'|'inserter'|'transform'} WPBlockVariationScope
  1320. */
  1321. /**
  1322. * An object describing a variation defined for the block type.
  1323. *
  1324. * @typedef {Object} WPBlockVariation
  1325. *
  1326. * @property {string} name The unique and machine-readable name.
  1327. * @property {string} title A human-readable variation title.
  1328. * @property {string} [description] A detailed variation description.
  1329. * @property {string} [category] Block type category classification,
  1330. * used in search interfaces to arrange
  1331. * block types by category.
  1332. * @property {WPIcon} [icon] An icon helping to visualize the variation.
  1333. * @property {boolean} [isDefault] Indicates whether the current variation is
  1334. * the default one. Defaults to `false`.
  1335. * @property {Object} [attributes] Values which override block attributes.
  1336. * @property {Array[]} [innerBlocks] Initial configuration of nested blocks.
  1337. * @property {Object} [example] Example provides structured data for
  1338. * the block preview. You can set to
  1339. * `undefined` to disable the preview shown
  1340. * for the block type.
  1341. * @property {WPBlockVariationScope[]} [scope] The list of scopes where the variation
  1342. * is applicable. When not provided, it
  1343. * assumes all available scopes.
  1344. * @property {string[]} [keywords] An array of terms (which can be translated)
  1345. * that help users discover the variation
  1346. * while searching.
  1347. * @property {Function|string[]} [isActive] This can be a function or an array of block attributes.
  1348. * Function that accepts a block's attributes and the
  1349. * variation's attributes and determines if a variation is active.
  1350. * This function doesn't try to find a match dynamically based
  1351. * on all block's attributes, as in many cases some attributes are irrelevant.
  1352. * An example would be for `embed` block where we only care
  1353. * about `providerNameSlug` attribute's value.
  1354. * We can also use a `string[]` to tell which attributes
  1355. * should be compared as a shorthand. Each attributes will
  1356. * be matched and the variation will be active if all of them are matching.
  1357. */
  1358. /**
  1359. * Defined behavior of a block type.
  1360. *
  1361. * @typedef {Object} WPBlock
  1362. *
  1363. * @property {string} name Block type's namespaced name.
  1364. * @property {string} title Human-readable block type label.
  1365. * @property {string} [description] A detailed block type description.
  1366. * @property {string} [category] Block type category classification,
  1367. * used in search interfaces to arrange
  1368. * block types by category.
  1369. * @property {WPBlockTypeIcon} [icon] Block type icon.
  1370. * @property {string[]} [keywords] Additional keywords to produce block
  1371. * type as result in search interfaces.
  1372. * @property {Object} [attributes] Block type attributes.
  1373. * @property {WPComponent} [save] Optional component describing
  1374. * serialized markup structure of a
  1375. * block type.
  1376. * @property {WPComponent} edit Component rendering an element to
  1377. * manipulate the attributes of a block
  1378. * in the context of an editor.
  1379. * @property {WPBlockVariation[]} [variations] The list of block variations.
  1380. * @property {Object} [example] Example provides structured data for
  1381. * the block preview. When not defined
  1382. * then no preview is shown.
  1383. */
  1384. /**
  1385. * Mapping of legacy category slugs to their latest normal values, used to
  1386. * accommodate updates of the default set of block categories.
  1387. *
  1388. * @type {Record<string,string>}
  1389. */
  1390. const LEGACY_CATEGORY_MAPPING = {
  1391. common: 'text',
  1392. formatting: 'text',
  1393. layout: 'design'
  1394. };
  1395. const serverSideBlockDefinitions = {};
  1396. /**
  1397. * Sets the server side block definition of blocks.
  1398. *
  1399. * @param {Object} definitions Server-side block definitions
  1400. */
  1401. // eslint-disable-next-line camelcase
  1402. function unstable__bootstrapServerSideBlockDefinitions(definitions) {
  1403. for (const blockName of Object.keys(definitions)) {
  1404. // Don't overwrite if already set. It covers the case when metadata
  1405. // was initialized from the server.
  1406. if (serverSideBlockDefinitions[blockName]) {
  1407. // We still need to polyfill `apiVersion` for WordPress version
  1408. // lower than 5.7. If it isn't present in the definition shared
  1409. // from the server, we try to fallback to the definition passed.
  1410. // @see https://github.com/WordPress/gutenberg/pull/29279
  1411. if (serverSideBlockDefinitions[blockName].apiVersion === undefined && definitions[blockName].apiVersion) {
  1412. serverSideBlockDefinitions[blockName].apiVersion = definitions[blockName].apiVersion;
  1413. }
  1414. continue;
  1415. }
  1416. serverSideBlockDefinitions[blockName] = Object(external_lodash_["mapKeys"])(Object(external_lodash_["pickBy"])(definitions[blockName], value => !Object(external_lodash_["isNil"])(value)), (value, key) => Object(external_lodash_["camelCase"])(key));
  1417. }
  1418. }
  1419. /**
  1420. * Gets block settings from metadata loaded from `block.json` file.
  1421. *
  1422. * @param {Object} metadata Block metadata loaded from `block.json`.
  1423. * @param {string} metadata.textdomain Textdomain to use with translations.
  1424. *
  1425. * @return {Object} Block settings.
  1426. */
  1427. function getBlockSettingsFromMetadata({
  1428. textdomain,
  1429. ...metadata
  1430. }) {
  1431. const allowedFields = ['apiVersion', 'title', 'category', 'parent', 'icon', 'description', 'keywords', 'attributes', 'providesContext', 'usesContext', 'supports', 'styles', 'example', 'variations'];
  1432. const settings = Object(external_lodash_["pick"])(metadata, allowedFields);
  1433. if (textdomain) {
  1434. Object.keys(i18nBlockSchema).forEach(key => {
  1435. if (!settings[key]) {
  1436. return;
  1437. }
  1438. settings[key] = translateBlockSettingUsingI18nSchema(i18nBlockSchema[key], settings[key], textdomain);
  1439. });
  1440. }
  1441. return settings;
  1442. }
  1443. /**
  1444. * Registers a new block provided a unique name and an object defining its
  1445. * behavior. Once registered, the block is made available as an option to any
  1446. * editor interface where blocks are implemented.
  1447. *
  1448. * @param {string|Object} blockNameOrMetadata Block type name or its metadata.
  1449. * @param {Object} settings Block settings.
  1450. *
  1451. * @return {?WPBlock} The block, if it has been successfully registered;
  1452. * otherwise `undefined`.
  1453. */
  1454. function registerBlockType(blockNameOrMetadata, settings) {
  1455. const name = Object(external_lodash_["isObject"])(blockNameOrMetadata) ? blockNameOrMetadata.name : blockNameOrMetadata;
  1456. if (typeof name !== 'string') {
  1457. console.error('Block names must be strings.');
  1458. return;
  1459. }
  1460. if (Object(external_lodash_["isObject"])(blockNameOrMetadata)) {
  1461. unstable__bootstrapServerSideBlockDefinitions({
  1462. [name]: getBlockSettingsFromMetadata(blockNameOrMetadata)
  1463. });
  1464. }
  1465. settings = {
  1466. name,
  1467. icon: block_default["a" /* default */],
  1468. keywords: [],
  1469. attributes: {},
  1470. providesContext: {},
  1471. usesContext: [],
  1472. supports: {},
  1473. styles: [],
  1474. save: () => null,
  1475. ...(serverSideBlockDefinitions === null || serverSideBlockDefinitions === void 0 ? void 0 : serverSideBlockDefinitions[name]),
  1476. ...settings
  1477. };
  1478. if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(name)) {
  1479. console.error('Block names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-block');
  1480. return;
  1481. }
  1482. if (Object(external_wp_data_["select"])(store).getBlockType(name)) {
  1483. console.error('Block "' + name + '" is already registered.');
  1484. return;
  1485. }
  1486. const preFilterSettings = { ...settings
  1487. };
  1488. settings = Object(external_wp_hooks_["applyFilters"])('blocks.registerBlockType', settings, name);
  1489. if (settings.deprecated) {
  1490. settings.deprecated = settings.deprecated.map(deprecation => Object(external_lodash_["pick"])( // Only keep valid deprecation keys.
  1491. Object(external_wp_hooks_["applyFilters"])('blocks.registerBlockType', // Merge deprecation keys with pre-filter settings
  1492. // so that filters that depend on specific keys being
  1493. // present don't fail.
  1494. { // Omit deprecation keys here so that deprecations
  1495. // can opt out of specific keys like "supports".
  1496. ...Object(external_lodash_["omit"])(preFilterSettings, DEPRECATED_ENTRY_KEYS),
  1497. ...deprecation
  1498. }, name), DEPRECATED_ENTRY_KEYS));
  1499. }
  1500. if (!Object(external_lodash_["isPlainObject"])(settings)) {
  1501. console.error('Block settings must be a valid object.');
  1502. return;
  1503. }
  1504. if (!Object(external_lodash_["isFunction"])(settings.save)) {
  1505. console.error('The "save" property must be a valid function.');
  1506. return;
  1507. }
  1508. if ('edit' in settings && !Object(external_lodash_["isFunction"])(settings.edit)) {
  1509. console.error('The "edit" property must be a valid function.');
  1510. return;
  1511. } // Canonicalize legacy categories to equivalent fallback.
  1512. if (LEGACY_CATEGORY_MAPPING.hasOwnProperty(settings.category)) {
  1513. settings.category = LEGACY_CATEGORY_MAPPING[settings.category];
  1514. }
  1515. if ('category' in settings && !Object(external_lodash_["some"])(Object(external_wp_data_["select"])(store).getCategories(), {
  1516. slug: settings.category
  1517. })) {
  1518. console.warn('The block "' + name + '" is registered with an invalid category "' + settings.category + '".');
  1519. delete settings.category;
  1520. }
  1521. if (!('title' in settings) || settings.title === '') {
  1522. console.error('The block "' + name + '" must have a title.');
  1523. return;
  1524. }
  1525. if (typeof settings.title !== 'string') {
  1526. console.error('Block titles must be strings.');
  1527. return;
  1528. }
  1529. settings.icon = normalizeIconObject(settings.icon);
  1530. if (!isValidIcon(settings.icon.src)) {
  1531. console.error('The icon passed is invalid. ' + 'The icon should be a string, an element, a function, or an object following the specifications documented in https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#icon-optional');
  1532. return;
  1533. }
  1534. Object(external_wp_data_["dispatch"])(store).addBlockTypes(settings);
  1535. return settings;
  1536. }
  1537. /**
  1538. * Translates block settings provided with metadata using the i18n schema.
  1539. *
  1540. * @param {string|string[]|Object[]} i18nSchema I18n schema for the block setting.
  1541. * @param {string|string[]|Object[]} settingValue Value for the block setting.
  1542. * @param {string} textdomain Textdomain to use with translations.
  1543. *
  1544. * @return {string|string[]|Object[]} Translated setting.
  1545. */
  1546. function translateBlockSettingUsingI18nSchema(i18nSchema, settingValue, textdomain) {
  1547. if (Object(external_lodash_["isString"])(i18nSchema) && Object(external_lodash_["isString"])(settingValue)) {
  1548. // eslint-disable-next-line @wordpress/i18n-no-variables, @wordpress/i18n-text-domain
  1549. return Object(external_wp_i18n_["_x"])(settingValue, i18nSchema, textdomain);
  1550. }
  1551. if (Object(external_lodash_["isArray"])(i18nSchema) && !Object(external_lodash_["isEmpty"])(i18nSchema) && Object(external_lodash_["isArray"])(settingValue)) {
  1552. return settingValue.map(value => translateBlockSettingUsingI18nSchema(i18nSchema[0], value, textdomain));
  1553. }
  1554. if (Object(external_lodash_["isObject"])(i18nSchema) && !Object(external_lodash_["isEmpty"])(i18nSchema) && Object(external_lodash_["isObject"])(settingValue)) {
  1555. return Object.keys(settingValue).reduce((accumulator, key) => {
  1556. if (!i18nSchema[key]) {
  1557. accumulator[key] = settingValue[key];
  1558. return accumulator;
  1559. }
  1560. accumulator[key] = translateBlockSettingUsingI18nSchema(i18nSchema[key], settingValue[key], textdomain);
  1561. return accumulator;
  1562. }, {});
  1563. }
  1564. return settingValue;
  1565. }
  1566. /**
  1567. * Registers a new block provided from metadata stored in `block.json` file.
  1568. *
  1569. * @deprecated Use `registerBlockType` instead.
  1570. *
  1571. * @param {Object} metadata Block metadata loaded from `block.json`.
  1572. * @param {Object} additionalSettings Additional block settings.
  1573. *
  1574. * @return {?WPBlock} The block, if it has been successfully registered;
  1575. * otherwise `undefined`.
  1576. */
  1577. function registerBlockTypeFromMetadata(metadata, additionalSettings) {
  1578. external_wp_deprecated_default()('wp.blocks.registerBlockTypeFromMetadata', {
  1579. since: '10.7',
  1580. plugin: 'Gutenberg',
  1581. alternative: 'wp.blocks.registerBlockType',
  1582. version: '11.0'
  1583. });
  1584. return registerBlockType(metadata, additionalSettings);
  1585. }
  1586. /**
  1587. * Registers a new block collection to group blocks in the same namespace in the inserter.
  1588. *
  1589. * @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace.
  1590. * @param {Object} settings The block collection settings.
  1591. * @param {string} settings.title The title to display in the block inserter.
  1592. * @param {Object} [settings.icon] The icon to display in the block inserter.
  1593. */
  1594. function registerBlockCollection(namespace, {
  1595. title,
  1596. icon
  1597. }) {
  1598. Object(external_wp_data_["dispatch"])(store).addBlockCollection(namespace, title, icon);
  1599. }
  1600. /**
  1601. * Unregisters a block collection
  1602. *
  1603. * @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace
  1604. *
  1605. */
  1606. function unregisterBlockCollection(namespace) {
  1607. Object(external_wp_data_["dispatch"])(store).removeBlockCollection(namespace);
  1608. }
  1609. /**
  1610. * Unregisters a block.
  1611. *
  1612. * @param {string} name Block name.
  1613. *
  1614. * @return {?WPBlock} The previous block value, if it has been successfully
  1615. * unregistered; otherwise `undefined`.
  1616. */
  1617. function unregisterBlockType(name) {
  1618. const oldBlock = Object(external_wp_data_["select"])(store).getBlockType(name);
  1619. if (!oldBlock) {
  1620. console.error('Block "' + name + '" is not registered.');
  1621. return;
  1622. }
  1623. Object(external_wp_data_["dispatch"])(store).removeBlockTypes(name);
  1624. return oldBlock;
  1625. }
  1626. /**
  1627. * Assigns name of block for handling non-block content.
  1628. *
  1629. * @param {string} blockName Block name.
  1630. */
  1631. function setFreeformContentHandlerName(blockName) {
  1632. Object(external_wp_data_["dispatch"])(store).setFreeformFallbackBlockName(blockName);
  1633. }
  1634. /**
  1635. * Retrieves name of block handling non-block content, or undefined if no
  1636. * handler has been defined.
  1637. *
  1638. * @return {?string} Block name.
  1639. */
  1640. function getFreeformContentHandlerName() {
  1641. return Object(external_wp_data_["select"])(store).getFreeformFallbackBlockName();
  1642. }
  1643. /**
  1644. * Retrieves name of block used for handling grouping interactions.
  1645. *
  1646. * @return {?string} Block name.
  1647. */
  1648. function registration_getGroupingBlockName() {
  1649. return Object(external_wp_data_["select"])(store).getGroupingBlockName();
  1650. }
  1651. /**
  1652. * Assigns name of block handling unregistered block types.
  1653. *
  1654. * @param {string} blockName Block name.
  1655. */
  1656. function setUnregisteredTypeHandlerName(blockName) {
  1657. Object(external_wp_data_["dispatch"])(store).setUnregisteredFallbackBlockName(blockName);
  1658. }
  1659. /**
  1660. * Retrieves name of block handling unregistered block types, or undefined if no
  1661. * handler has been defined.
  1662. *
  1663. * @return {?string} Block name.
  1664. */
  1665. function getUnregisteredTypeHandlerName() {
  1666. return Object(external_wp_data_["select"])(store).getUnregisteredFallbackBlockName();
  1667. }
  1668. /**
  1669. * Assigns the default block name.
  1670. *
  1671. * @param {string} name Block name.
  1672. */
  1673. function registration_setDefaultBlockName(name) {
  1674. Object(external_wp_data_["dispatch"])(store).setDefaultBlockName(name);
  1675. }
  1676. /**
  1677. * Assigns name of block for handling block grouping interactions.
  1678. *
  1679. * @param {string} name Block name.
  1680. */
  1681. function registration_setGroupingBlockName(name) {
  1682. Object(external_wp_data_["dispatch"])(store).setGroupingBlockName(name);
  1683. }
  1684. /**
  1685. * Retrieves the default block name.
  1686. *
  1687. * @return {?string} Block name.
  1688. */
  1689. function registration_getDefaultBlockName() {
  1690. return Object(external_wp_data_["select"])(store).getDefaultBlockName();
  1691. }
  1692. /**
  1693. * Returns a registered block type.
  1694. *
  1695. * @param {string} name Block name.
  1696. *
  1697. * @return {?Object} Block type.
  1698. */
  1699. function registration_getBlockType(name) {
  1700. return Object(external_wp_data_["select"])(store).getBlockType(name);
  1701. }
  1702. /**
  1703. * Returns all registered blocks.
  1704. *
  1705. * @return {Array} Block settings.
  1706. */
  1707. function registration_getBlockTypes() {
  1708. return Object(external_wp_data_["select"])(store).getBlockTypes();
  1709. }
  1710. /**
  1711. * Returns the block support value for a feature, if defined.
  1712. *
  1713. * @param {(string|Object)} nameOrType Block name or type object
  1714. * @param {string} feature Feature to retrieve
  1715. * @param {*} defaultSupports Default value to return if not
  1716. * explicitly defined
  1717. *
  1718. * @return {?*} Block support value
  1719. */
  1720. function registration_getBlockSupport(nameOrType, feature, defaultSupports) {
  1721. return Object(external_wp_data_["select"])(store).getBlockSupport(nameOrType, feature, defaultSupports);
  1722. }
  1723. /**
  1724. * Returns true if the block defines support for a feature, or false otherwise.
  1725. *
  1726. * @param {(string|Object)} nameOrType Block name or type object.
  1727. * @param {string} feature Feature to test.
  1728. * @param {boolean} defaultSupports Whether feature is supported by
  1729. * default if not explicitly defined.
  1730. *
  1731. * @return {boolean} Whether block supports feature.
  1732. */
  1733. function registration_hasBlockSupport(nameOrType, feature, defaultSupports) {
  1734. return Object(external_wp_data_["select"])(store).hasBlockSupport(nameOrType, feature, defaultSupports);
  1735. }
  1736. /**
  1737. * Determines whether or not the given block is a reusable block. This is a
  1738. * special block type that is used to point to a global block stored via the
  1739. * API.
  1740. *
  1741. * @param {Object} blockOrType Block or Block Type to test.
  1742. *
  1743. * @return {boolean} Whether the given block is a reusable block.
  1744. */
  1745. function isReusableBlock(blockOrType) {
  1746. return blockOrType.name === 'core/block';
  1747. }
  1748. /**
  1749. * Determines whether or not the given block is a template part. This is a
  1750. * special block type that allows composing a page template out of reusable
  1751. * design elements.
  1752. *
  1753. * @param {Object} blockOrType Block or Block Type to test.
  1754. *
  1755. * @return {boolean} Whether the given block is a template part.
  1756. */
  1757. function isTemplatePart(blockOrType) {
  1758. return blockOrType.name === 'core/template-part';
  1759. }
  1760. /**
  1761. * Returns an array with the child blocks of a given block.
  1762. *
  1763. * @param {string} blockName Name of block (example: “latest-posts”).
  1764. *
  1765. * @return {Array} Array of child block names.
  1766. */
  1767. const registration_getChildBlockNames = blockName => {
  1768. return Object(external_wp_data_["select"])(store).getChildBlockNames(blockName);
  1769. };
  1770. /**
  1771. * Returns a boolean indicating if a block has child blocks or not.
  1772. *
  1773. * @param {string} blockName Name of block (example: “latest-posts”).
  1774. *
  1775. * @return {boolean} True if a block contains child blocks and false otherwise.
  1776. */
  1777. const registration_hasChildBlocks = blockName => {
  1778. return Object(external_wp_data_["select"])(store).hasChildBlocks(blockName);
  1779. };
  1780. /**
  1781. * Returns a boolean indicating if a block has at least one child block with inserter support.
  1782. *
  1783. * @param {string} blockName Block type name.
  1784. *
  1785. * @return {boolean} True if a block contains at least one child blocks with inserter support
  1786. * and false otherwise.
  1787. */
  1788. const registration_hasChildBlocksWithInserterSupport = blockName => {
  1789. return Object(external_wp_data_["select"])(store).hasChildBlocksWithInserterSupport(blockName);
  1790. };
  1791. /**
  1792. * Registers a new block style variation for the given block.
  1793. *
  1794. * @param {string} blockName Name of block (example: “core/latest-posts”).
  1795. * @param {Object} styleVariation Object containing `name` which is the class name applied to the block and `label` which identifies the variation to the user.
  1796. */
  1797. const registerBlockStyle = (blockName, styleVariation) => {
  1798. Object(external_wp_data_["dispatch"])(store).addBlockStyles(blockName, styleVariation);
  1799. };
  1800. /**
  1801. * Unregisters a block style variation for the given block.
  1802. *
  1803. * @param {string} blockName Name of block (example: “core/latest-posts”).
  1804. * @param {string} styleVariationName Name of class applied to the block.
  1805. */
  1806. const unregisterBlockStyle = (blockName, styleVariationName) => {
  1807. Object(external_wp_data_["dispatch"])(store).removeBlockStyles(blockName, styleVariationName);
  1808. };
  1809. /**
  1810. * Returns an array with the variations of a given block type.
  1811. *
  1812. * @param {string} blockName Name of block (example: “core/columns”).
  1813. * @param {WPBlockVariationScope} [scope] Block variation scope name.
  1814. *
  1815. * @return {(WPBlockVariation[]|void)} Block variations.
  1816. */
  1817. const registration_getBlockVariations = (blockName, scope) => {
  1818. return Object(external_wp_data_["select"])(store).getBlockVariations(blockName, scope);
  1819. };
  1820. /**
  1821. * Registers a new block variation for the given block type.
  1822. *
  1823. * @param {string} blockName Name of the block (example: “core/columns”).
  1824. * @param {WPBlockVariation} variation Object describing a block variation.
  1825. */
  1826. const registerBlockVariation = (blockName, variation) => {
  1827. Object(external_wp_data_["dispatch"])(store).addBlockVariations(blockName, variation);
  1828. };
  1829. /**
  1830. * Unregisters a block variation defined for the given block type.
  1831. *
  1832. * @param {string} blockName Name of the block (example: “core/columns”).
  1833. * @param {string} variationName Name of the variation defined for the block.
  1834. */
  1835. const unregisterBlockVariation = (blockName, variationName) => {
  1836. Object(external_wp_data_["dispatch"])(store).removeBlockVariations(blockName, variationName);
  1837. };
  1838. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/factory.js
  1839. /**
  1840. * External dependencies
  1841. */
  1842. /**
  1843. * WordPress dependencies
  1844. */
  1845. /**
  1846. * Internal dependencies
  1847. */
  1848. /**
  1849. * Returns a block object given its type and attributes.
  1850. *
  1851. * @param {string} name Block name.
  1852. * @param {Object} attributes Block attributes.
  1853. * @param {?Array} innerBlocks Nested blocks.
  1854. *
  1855. * @return {Object} Block object.
  1856. */
  1857. function createBlock(name, attributes = {}, innerBlocks = []) {
  1858. const sanitizedAttributes = __experimentalSanitizeBlockAttributes(name, attributes);
  1859. const clientId = Object(v4["a" /* default */])(); // Blocks are stored with a unique ID, the assigned type name, the block
  1860. // attributes, and their inner blocks.
  1861. return {
  1862. clientId,
  1863. name,
  1864. isValid: true,
  1865. attributes: sanitizedAttributes,
  1866. innerBlocks
  1867. };
  1868. }
  1869. /**
  1870. * Given an array of InnerBlocks templates or Block Objects,
  1871. * returns an array of created Blocks from them.
  1872. * It handles the case of having InnerBlocks as Blocks by
  1873. * converting them to the proper format to continue recursively.
  1874. *
  1875. * @param {Array} innerBlocksOrTemplate Nested blocks or InnerBlocks templates.
  1876. *
  1877. * @return {Object[]} Array of Block objects.
  1878. */
  1879. function createBlocksFromInnerBlocksTemplate(innerBlocksOrTemplate = []) {
  1880. return innerBlocksOrTemplate.map(innerBlock => {
  1881. const innerBlockTemplate = Array.isArray(innerBlock) ? innerBlock : [innerBlock.name, innerBlock.attributes, innerBlock.innerBlocks];
  1882. const [name, attributes, innerBlocks = []] = innerBlockTemplate;
  1883. return createBlock(name, attributes, createBlocksFromInnerBlocksTemplate(innerBlocks));
  1884. });
  1885. }
  1886. /**
  1887. * Given a block object, returns a copy of the block object while sanitizing its attributes,
  1888. * optionally merging new attributes and/or replacing its inner blocks.
  1889. *
  1890. * @param {Object} block Block instance.
  1891. * @param {Object} mergeAttributes Block attributes.
  1892. * @param {?Array} newInnerBlocks Nested blocks.
  1893. *
  1894. * @return {Object} A cloned block.
  1895. */
  1896. function __experimentalCloneSanitizedBlock(block, mergeAttributes = {}, newInnerBlocks) {
  1897. const clientId = Object(v4["a" /* default */])();
  1898. const sanitizedAttributes = __experimentalSanitizeBlockAttributes(block.name, { ...block.attributes,
  1899. ...mergeAttributes
  1900. });
  1901. return { ...block,
  1902. clientId,
  1903. attributes: sanitizedAttributes,
  1904. innerBlocks: newInnerBlocks || block.innerBlocks.map(innerBlock => __experimentalCloneSanitizedBlock(innerBlock))
  1905. };
  1906. }
  1907. /**
  1908. * Given a block object, returns a copy of the block object,
  1909. * optionally merging new attributes and/or replacing its inner blocks.
  1910. *
  1911. * @param {Object} block Block instance.
  1912. * @param {Object} mergeAttributes Block attributes.
  1913. * @param {?Array} newInnerBlocks Nested blocks.
  1914. *
  1915. * @return {Object} A cloned block.
  1916. */
  1917. function cloneBlock(block, mergeAttributes = {}, newInnerBlocks) {
  1918. const clientId = Object(v4["a" /* default */])();
  1919. return { ...block,
  1920. clientId,
  1921. attributes: { ...block.attributes,
  1922. ...mergeAttributes
  1923. },
  1924. innerBlocks: newInnerBlocks || block.innerBlocks.map(innerBlock => cloneBlock(innerBlock))
  1925. };
  1926. }
  1927. /**
  1928. * Returns a boolean indicating whether a transform is possible based on
  1929. * various bits of context.
  1930. *
  1931. * @param {Object} transform The transform object to validate.
  1932. * @param {string} direction Is this a 'from' or 'to' transform.
  1933. * @param {Array} blocks The blocks to transform from.
  1934. *
  1935. * @return {boolean} Is the transform possible?
  1936. */
  1937. const isPossibleTransformForSource = (transform, direction, blocks) => {
  1938. if (Object(external_lodash_["isEmpty"])(blocks)) {
  1939. return false;
  1940. } // If multiple blocks are selected, only multi block transforms
  1941. // or wildcard transforms are allowed.
  1942. const isMultiBlock = blocks.length > 1;
  1943. const firstBlockName = Object(external_lodash_["first"])(blocks).name;
  1944. const isValidForMultiBlocks = isWildcardBlockTransform(transform) || !isMultiBlock || transform.isMultiBlock;
  1945. if (!isValidForMultiBlocks) {
  1946. return false;
  1947. } // Check non-wildcard transforms to ensure that transform is valid
  1948. // for a block selection of multiple blocks of different types
  1949. if (!isWildcardBlockTransform(transform) && !Object(external_lodash_["every"])(blocks, {
  1950. name: firstBlockName
  1951. })) {
  1952. return false;
  1953. } // Only consider 'block' type transforms as valid.
  1954. const isBlockType = transform.type === 'block';
  1955. if (!isBlockType) {
  1956. return false;
  1957. } // Check if the transform's block name matches the source block (or is a wildcard)
  1958. // only if this is a transform 'from'.
  1959. const sourceBlock = Object(external_lodash_["first"])(blocks);
  1960. const hasMatchingName = direction !== 'from' || transform.blocks.indexOf(sourceBlock.name) !== -1 || isWildcardBlockTransform(transform);
  1961. if (!hasMatchingName) {
  1962. return false;
  1963. } // Don't allow single Grouping blocks to be transformed into
  1964. // a Grouping block.
  1965. if (!isMultiBlock && isContainerGroupBlock(sourceBlock.name) && isContainerGroupBlock(transform.blockName)) {
  1966. return false;
  1967. } // If the transform has a `isMatch` function specified, check that it returns true.
  1968. if (Object(external_lodash_["isFunction"])(transform.isMatch)) {
  1969. const attributes = transform.isMultiBlock ? blocks.map(block => block.attributes) : sourceBlock.attributes;
  1970. if (!transform.isMatch(attributes)) {
  1971. return false;
  1972. }
  1973. }
  1974. if (transform.usingMobileTransformations && isWildcardBlockTransform(transform) && !isContainerGroupBlock(sourceBlock.name)) {
  1975. return false;
  1976. }
  1977. return true;
  1978. };
  1979. /**
  1980. * Returns block types that the 'blocks' can be transformed into, based on
  1981. * 'from' transforms on other blocks.
  1982. *
  1983. * @param {Array} blocks The blocks to transform from.
  1984. *
  1985. * @return {Array} Block types that the blocks can be transformed into.
  1986. */
  1987. const getBlockTypesForPossibleFromTransforms = blocks => {
  1988. if (Object(external_lodash_["isEmpty"])(blocks)) {
  1989. return [];
  1990. }
  1991. const allBlockTypes = registration_getBlockTypes(); // filter all blocks to find those with a 'from' transform.
  1992. const blockTypesWithPossibleFromTransforms = Object(external_lodash_["filter"])(allBlockTypes, blockType => {
  1993. const fromTransforms = getBlockTransforms('from', blockType.name);
  1994. return !!findTransform(fromTransforms, transform => {
  1995. return isPossibleTransformForSource(transform, 'from', blocks);
  1996. });
  1997. });
  1998. return blockTypesWithPossibleFromTransforms;
  1999. };
  2000. /**
  2001. * Returns block types that the 'blocks' can be transformed into, based on
  2002. * the source block's own 'to' transforms.
  2003. *
  2004. * @param {Array} blocks The blocks to transform from.
  2005. *
  2006. * @return {Array} Block types that the source can be transformed into.
  2007. */
  2008. const getBlockTypesForPossibleToTransforms = blocks => {
  2009. if (Object(external_lodash_["isEmpty"])(blocks)) {
  2010. return [];
  2011. }
  2012. const sourceBlock = Object(external_lodash_["first"])(blocks);
  2013. const blockType = registration_getBlockType(sourceBlock.name);
  2014. const transformsTo = getBlockTransforms('to', blockType.name); // filter all 'to' transforms to find those that are possible.
  2015. const possibleTransforms = Object(external_lodash_["filter"])(transformsTo, transform => {
  2016. return transform && isPossibleTransformForSource(transform, 'to', blocks);
  2017. }); // Build a list of block names using the possible 'to' transforms.
  2018. const blockNames = Object(external_lodash_["flatMap"])(possibleTransforms, transformation => transformation.blocks); // Map block names to block types.
  2019. return blockNames.map(name => registration_getBlockType(name));
  2020. };
  2021. /**
  2022. * Determines whether transform is a "block" type
  2023. * and if so whether it is a "wildcard" transform
  2024. * ie: targets "any" block type
  2025. *
  2026. * @param {Object} t the Block transform object
  2027. *
  2028. * @return {boolean} whether transform is a wildcard transform
  2029. */
  2030. const isWildcardBlockTransform = t => t && t.type === 'block' && Array.isArray(t.blocks) && t.blocks.includes('*');
  2031. /**
  2032. * Determines whether the given Block is the core Block which
  2033. * acts as a container Block for other Blocks as part of the
  2034. * Grouping mechanics
  2035. *
  2036. * @param {string} name the name of the Block to test against
  2037. *
  2038. * @return {boolean} whether or not the Block is the container Block type
  2039. */
  2040. const isContainerGroupBlock = name => name === registration_getGroupingBlockName();
  2041. /**
  2042. * Returns an array of block types that the set of blocks received as argument
  2043. * can be transformed into.
  2044. *
  2045. * @param {Array} blocks Blocks array.
  2046. *
  2047. * @return {Array} Block types that the blocks argument can be transformed to.
  2048. */
  2049. function getPossibleBlockTransformations(blocks) {
  2050. if (Object(external_lodash_["isEmpty"])(blocks)) {
  2051. return [];
  2052. }
  2053. const blockTypesForFromTransforms = getBlockTypesForPossibleFromTransforms(blocks);
  2054. const blockTypesForToTransforms = getBlockTypesForPossibleToTransforms(blocks);
  2055. return Object(external_lodash_["uniq"])([...blockTypesForFromTransforms, ...blockTypesForToTransforms]);
  2056. }
  2057. /**
  2058. * Given an array of transforms, returns the highest-priority transform where
  2059. * the predicate function returns a truthy value. A higher-priority transform
  2060. * is one with a lower priority value (i.e. first in priority order). Returns
  2061. * null if the transforms set is empty or the predicate function returns a
  2062. * falsey value for all entries.
  2063. *
  2064. * @param {Object[]} transforms Transforms to search.
  2065. * @param {Function} predicate Function returning true on matching transform.
  2066. *
  2067. * @return {?Object} Highest-priority transform candidate.
  2068. */
  2069. function findTransform(transforms, predicate) {
  2070. // The hooks library already has built-in mechanisms for managing priority
  2071. // queue, so leverage via locally-defined instance.
  2072. const hooks = Object(external_wp_hooks_["createHooks"])();
  2073. for (let i = 0; i < transforms.length; i++) {
  2074. const candidate = transforms[i];
  2075. if (predicate(candidate)) {
  2076. hooks.addFilter('transform', 'transform/' + i.toString(), result => result ? result : candidate, candidate.priority);
  2077. }
  2078. } // Filter name is arbitrarily chosen but consistent with above aggregation.
  2079. return hooks.applyFilters('transform', null);
  2080. }
  2081. /**
  2082. * Returns normal block transforms for a given transform direction, optionally
  2083. * for a specific block by name, or an empty array if there are no transforms.
  2084. * If no block name is provided, returns transforms for all blocks. A normal
  2085. * transform object includes `blockName` as a property.
  2086. *
  2087. * @param {string} direction Transform direction ("to", "from").
  2088. * @param {string|Object} blockTypeOrName Block type or name.
  2089. *
  2090. * @return {Array} Block transforms for direction.
  2091. */
  2092. function getBlockTransforms(direction, blockTypeOrName) {
  2093. // When retrieving transforms for all block types, recurse into self.
  2094. if (blockTypeOrName === undefined) {
  2095. return Object(external_lodash_["flatMap"])(registration_getBlockTypes(), ({
  2096. name
  2097. }) => getBlockTransforms(direction, name));
  2098. } // Validate that block type exists and has array of direction.
  2099. const blockType = normalizeBlockType(blockTypeOrName);
  2100. const {
  2101. name: blockName,
  2102. transforms
  2103. } = blockType || {};
  2104. if (!transforms || !Array.isArray(transforms[direction])) {
  2105. return [];
  2106. }
  2107. const usingMobileTransformations = transforms.supportedMobileTransforms && Array.isArray(transforms.supportedMobileTransforms);
  2108. const filteredTransforms = usingMobileTransformations ? Object(external_lodash_["filter"])(transforms[direction], t => {
  2109. if (t.type === 'raw') {
  2110. return true;
  2111. }
  2112. if (!t.blocks || !t.blocks.length) {
  2113. return false;
  2114. }
  2115. if (isWildcardBlockTransform(t)) {
  2116. return true;
  2117. }
  2118. return Object(external_lodash_["every"])(t.blocks, transformBlockName => transforms.supportedMobileTransforms.includes(transformBlockName));
  2119. }) : transforms[direction]; // Map transforms to normal form.
  2120. return filteredTransforms.map(transform => ({ ...transform,
  2121. blockName,
  2122. usingMobileTransformations
  2123. }));
  2124. }
  2125. /**
  2126. * Switch one or more blocks into one or more blocks of the new block type.
  2127. *
  2128. * @param {Array|Object} blocks Blocks array or block object.
  2129. * @param {string} name Block name.
  2130. *
  2131. * @return {?Array} Array of blocks or null.
  2132. */
  2133. function switchToBlockType(blocks, name) {
  2134. const blocksArray = Object(external_lodash_["castArray"])(blocks);
  2135. const isMultiBlock = blocksArray.length > 1;
  2136. const firstBlock = blocksArray[0];
  2137. const sourceName = firstBlock.name; // Find the right transformation by giving priority to the "to"
  2138. // transformation.
  2139. const transformationsFrom = getBlockTransforms('from', name);
  2140. const transformationsTo = getBlockTransforms('to', sourceName);
  2141. const transformation = findTransform(transformationsTo, t => t.type === 'block' && (isWildcardBlockTransform(t) || t.blocks.indexOf(name) !== -1) && (!isMultiBlock || t.isMultiBlock)) || findTransform(transformationsFrom, t => t.type === 'block' && (isWildcardBlockTransform(t) || t.blocks.indexOf(sourceName) !== -1) && (!isMultiBlock || t.isMultiBlock)); // Stop if there is no valid transformation.
  2142. if (!transformation) {
  2143. return null;
  2144. }
  2145. let transformationResults;
  2146. if (transformation.isMultiBlock) {
  2147. if (Object(external_lodash_["has"])(transformation, '__experimentalConvert')) {
  2148. transformationResults = transformation.__experimentalConvert(blocksArray);
  2149. } else {
  2150. transformationResults = transformation.transform(blocksArray.map(currentBlock => currentBlock.attributes), blocksArray.map(currentBlock => currentBlock.innerBlocks));
  2151. }
  2152. } else if (Object(external_lodash_["has"])(transformation, '__experimentalConvert')) {
  2153. transformationResults = transformation.__experimentalConvert(firstBlock);
  2154. } else {
  2155. transformationResults = transformation.transform(firstBlock.attributes, firstBlock.innerBlocks);
  2156. } // Ensure that the transformation function returned an object or an array
  2157. // of objects.
  2158. if (!Object(external_lodash_["isObjectLike"])(transformationResults)) {
  2159. return null;
  2160. } // If the transformation function returned a single object, we want to work
  2161. // with an array instead.
  2162. transformationResults = Object(external_lodash_["castArray"])(transformationResults); // Ensure that every block object returned by the transformation has a
  2163. // valid block type.
  2164. if (transformationResults.some(result => !registration_getBlockType(result.name))) {
  2165. return null;
  2166. }
  2167. const hasSwitchedBlock = Object(external_lodash_["some"])(transformationResults, result => result.name === name); // Ensure that at least one block object returned by the transformation has
  2168. // the expected "destination" block type.
  2169. if (!hasSwitchedBlock) {
  2170. return null;
  2171. }
  2172. const ret = transformationResults.map(result => {
  2173. /**
  2174. * Filters an individual transform result from block transformation.
  2175. * All of the original blocks are passed, since transformations are
  2176. * many-to-many, not one-to-one.
  2177. *
  2178. * @param {Object} transformedBlock The transformed block.
  2179. * @param {Object[]} blocks Original blocks transformed.
  2180. */
  2181. return Object(external_wp_hooks_["applyFilters"])('blocks.switchToBlockType.transformedBlock', result, blocks);
  2182. });
  2183. return ret;
  2184. }
  2185. /**
  2186. * Create a block object from the example API.
  2187. *
  2188. * @param {string} name
  2189. * @param {Object} example
  2190. *
  2191. * @return {Object} block.
  2192. */
  2193. const getBlockFromExample = (name, example) => {
  2194. return createBlock(name, example.attributes, Object(external_lodash_["map"])(example.innerBlocks, innerBlock => getBlockFromExample(innerBlock.name, innerBlock)));
  2195. };
  2196. // CONCATENATED MODULE: ./node_modules/hpq/es/get-path.js
  2197. /**
  2198. * Given object and string of dot-delimited path segments, returns value at
  2199. * path or undefined if path cannot be resolved.
  2200. *
  2201. * @param {Object} object Lookup object
  2202. * @param {string} path Path to resolve
  2203. * @return {?*} Resolved value
  2204. */
  2205. function getPath(object, path) {
  2206. var segments = path.split('.');
  2207. var segment;
  2208. while (segment = segments.shift()) {
  2209. if (!(segment in object)) {
  2210. return;
  2211. }
  2212. object = object[segment];
  2213. }
  2214. return object;
  2215. }
  2216. // CONCATENATED MODULE: ./node_modules/hpq/es/index.js
  2217. /**
  2218. * Internal dependencies
  2219. */
  2220. /**
  2221. * Function returning a DOM document created by `createHTMLDocument`. The same
  2222. * document is returned between invocations.
  2223. *
  2224. * @return {Document} DOM document.
  2225. */
  2226. var getDocument = function () {
  2227. var doc;
  2228. return function () {
  2229. if (!doc) {
  2230. doc = document.implementation.createHTMLDocument('');
  2231. }
  2232. return doc;
  2233. };
  2234. }();
  2235. /**
  2236. * Given a markup string or DOM element, creates an object aligning with the
  2237. * shape of the matchers object, or the value returned by the matcher.
  2238. *
  2239. * @param {(string|Element)} source Source content
  2240. * @param {(Object|Function)} matchers Matcher function or object of matchers
  2241. * @return {(Object|*)} Matched value(s), shaped by object
  2242. */
  2243. function parse(source, matchers) {
  2244. if (!matchers) {
  2245. return;
  2246. } // Coerce to element
  2247. if ('string' === typeof source) {
  2248. var doc = getDocument();
  2249. doc.body.innerHTML = source;
  2250. source = doc.body;
  2251. } // Return singular value
  2252. if ('function' === typeof matchers) {
  2253. return matchers(source);
  2254. } // Bail if we can't handle matchers
  2255. if (Object !== matchers.constructor) {
  2256. return;
  2257. } // Shape result by matcher object
  2258. return Object.keys(matchers).reduce(function (memo, key) {
  2259. memo[key] = parse(source, matchers[key]);
  2260. return memo;
  2261. }, {});
  2262. }
  2263. /**
  2264. * Generates a function which matches node of type selector, returning an
  2265. * attribute by property if the attribute exists. If no selector is passed,
  2266. * returns property of the query element.
  2267. *
  2268. * @param {?string} selector Optional selector
  2269. * @param {string} name Property name
  2270. * @return {*} Property value
  2271. */
  2272. function prop(selector, name) {
  2273. if (1 === arguments.length) {
  2274. name = selector;
  2275. selector = undefined;
  2276. }
  2277. return function (node) {
  2278. var match = node;
  2279. if (selector) {
  2280. match = node.querySelector(selector);
  2281. }
  2282. if (match) {
  2283. return getPath(match, name);
  2284. }
  2285. };
  2286. }
  2287. /**
  2288. * Generates a function which matches node of type selector, returning an
  2289. * attribute by name if the attribute exists. If no selector is passed,
  2290. * returns attribute of the query element.
  2291. *
  2292. * @param {?string} selector Optional selector
  2293. * @param {string} name Attribute name
  2294. * @return {?string} Attribute value
  2295. */
  2296. function attr(selector, name) {
  2297. if (1 === arguments.length) {
  2298. name = selector;
  2299. selector = undefined;
  2300. }
  2301. return function (node) {
  2302. var attributes = prop(selector, 'attributes')(node);
  2303. if (attributes && attributes.hasOwnProperty(name)) {
  2304. return attributes[name].value;
  2305. }
  2306. };
  2307. }
  2308. /**
  2309. * Convenience for `prop( selector, 'innerHTML' )`.
  2310. *
  2311. * @see prop()
  2312. *
  2313. * @param {?string} selector Optional selector
  2314. * @return {string} Inner HTML
  2315. */
  2316. function es_html(selector) {
  2317. return prop(selector, 'innerHTML');
  2318. }
  2319. /**
  2320. * Convenience for `prop( selector, 'textContent' )`.
  2321. *
  2322. * @see prop()
  2323. *
  2324. * @param {?string} selector Optional selector
  2325. * @return {string} Text content
  2326. */
  2327. function es_text(selector) {
  2328. return prop(selector, 'textContent');
  2329. }
  2330. /**
  2331. * Creates a new matching context by first finding elements matching selector
  2332. * using querySelectorAll before then running another `parse` on `matchers`
  2333. * scoped to the matched elements.
  2334. *
  2335. * @see parse()
  2336. *
  2337. * @param {string} selector Selector to match
  2338. * @param {(Object|Function)} matchers Matcher function or object of matchers
  2339. * @return {Array.<*,Object>} Array of matched value(s)
  2340. */
  2341. function query(selector, matchers) {
  2342. return function (node) {
  2343. var matches = node.querySelectorAll(selector);
  2344. return [].map.call(matches, function (match) {
  2345. return parse(match, matchers);
  2346. });
  2347. };
  2348. }
  2349. // EXTERNAL MODULE: external ["wp","autop"]
  2350. var external_wp_autop_ = __webpack_require__("UuzZ");
  2351. // EXTERNAL MODULE: external ["wp","blockSerializationDefaultParser"]
  2352. var external_wp_blockSerializationDefaultParser_ = __webpack_require__("ouCq");
  2353. // CONCATENATED MODULE: ./node_modules/simple-html-tokenizer/dist/es6/index.js
  2354. /**
  2355. * generated from https://raw.githubusercontent.com/w3c/html/26b5126f96f736f796b9e29718138919dd513744/entities.json
  2356. * do not edit
  2357. */
  2358. var namedCharRefs = {
  2359. Aacute: "Á", aacute: "á", Abreve: "Ă", abreve: "ă", ac: "∾", acd: "∿", acE: "∾̳", Acirc: "Â", acirc: "â", acute: "´", Acy: "А", acy: "а", AElig: "Æ", aelig: "æ", af: "\u2061", Afr: "𝔄", afr: "𝔞", Agrave: "À", agrave: "à", alefsym: "ℵ", aleph: "ℵ", Alpha: "Α", alpha: "α", Amacr: "Ā", amacr: "ā", amalg: "⨿", amp: "&", AMP: "&", andand: "⩕", And: "⩓", and: "∧", andd: "⩜", andslope: "⩘", andv: "⩚", ang: "∠", ange: "⦤", angle: "∠", angmsdaa: "⦨", angmsdab: "⦩", angmsdac: "⦪", angmsdad: "⦫", angmsdae: "⦬", angmsdaf: "⦭", angmsdag: "⦮", angmsdah: "⦯", angmsd: "∡", angrt: "∟", angrtvb: "⊾", angrtvbd: "⦝", angsph: "∢", angst: "Å", angzarr: "⍼", Aogon: "Ą", aogon: "ą", Aopf: "𝔸", aopf: "𝕒", apacir: "⩯", ap: "≈", apE: "⩰", ape: "≊", apid: "≋", apos: "'", ApplyFunction: "\u2061", approx: "≈", approxeq: "≊", Aring: "Å", aring: "å", Ascr: "𝒜", ascr: "𝒶", Assign: "≔", ast: "*", asymp: "≈", asympeq: "≍", Atilde: "Ã", atilde: "ã", Auml: "Ä", auml: "ä", awconint: "∳", awint: "⨑", backcong: "≌", backepsilon: "϶", backprime: "‵", backsim: "∽", backsimeq: "⋍", Backslash: "∖", Barv: "⫧", barvee: "⊽", barwed: "⌅", Barwed: "⌆", barwedge: "⌅", bbrk: "⎵", bbrktbrk: "⎶", bcong: "≌", Bcy: "Б", bcy: "б", bdquo: "„", becaus: "∵", because: "∵", Because: "∵", bemptyv: "⦰", bepsi: "϶", bernou: "ℬ", Bernoullis: "ℬ", Beta: "Β", beta: "β", beth: "ℶ", between: "≬", Bfr: "𝔅", bfr: "𝔟", bigcap: "⋂", bigcirc: "◯", bigcup: "⋃", bigodot: "⨀", bigoplus: "⨁", bigotimes: "⨂", bigsqcup: "⨆", bigstar: "★", bigtriangledown: "▽", bigtriangleup: "△", biguplus: "⨄", bigvee: "⋁", bigwedge: "⋀", bkarow: "⤍", blacklozenge: "⧫", blacksquare: "▪", blacktriangle: "▴", blacktriangledown: "▾", blacktriangleleft: "◂", blacktriangleright: "▸", blank: "␣", blk12: "▒", blk14: "░", blk34: "▓", block: "█", bne: "=⃥", bnequiv: "≡⃥", bNot: "⫭", bnot: "⌐", Bopf: "𝔹", bopf: "𝕓", bot: "⊥", bottom: "⊥", bowtie: "⋈", boxbox: "⧉", boxdl: "┐", boxdL: "╕", boxDl: "╖", boxDL: "╗", boxdr: "┌", boxdR: "╒", boxDr: "╓", boxDR: "╔", boxh: "─", boxH: "═", boxhd: "┬", boxHd: "╤", boxhD: "╥", boxHD: "╦", boxhu: "┴", boxHu: "╧", boxhU: "╨", boxHU: "╩", boxminus: "⊟", boxplus: "⊞", boxtimes: "⊠", boxul: "┘", boxuL: "╛", boxUl: "╜", boxUL: "╝", boxur: "└", boxuR: "╘", boxUr: "╙", boxUR: "╚", boxv: "│", boxV: "║", boxvh: "┼", boxvH: "╪", boxVh: "╫", boxVH: "╬", boxvl: "┤", boxvL: "╡", boxVl: "╢", boxVL: "╣", boxvr: "├", boxvR: "╞", boxVr: "╟", boxVR: "╠", bprime: "‵", breve: "˘", Breve: "˘", brvbar: "¦", bscr: "𝒷", Bscr: "ℬ", bsemi: "⁏", bsim: "∽", bsime: "⋍", bsolb: "⧅", bsol: "\\", bsolhsub: "⟈", bull: "•", bullet: "•", bump: "≎", bumpE: "⪮", bumpe: "≏", Bumpeq: "≎", bumpeq: "≏", Cacute: "Ć", cacute: "ć", capand: "⩄", capbrcup: "⩉", capcap: "⩋", cap: "∩", Cap: "⋒", capcup: "⩇", capdot: "⩀", CapitalDifferentialD: "ⅅ", caps: "∩︀", caret: "⁁", caron: "ˇ", Cayleys: "ℭ", ccaps: "⩍", Ccaron: "Č", ccaron: "č", Ccedil: "Ç", ccedil: "ç", Ccirc: "Ĉ", ccirc: "ĉ", Cconint: "∰", ccups: "⩌", ccupssm: "⩐", Cdot: "Ċ", cdot: "ċ", cedil: "¸", Cedilla: "¸", cemptyv: "⦲", cent: "¢", centerdot: "·", CenterDot: "·", cfr: "𝔠", Cfr: "ℭ", CHcy: "Ч", chcy: "ч", check: "✓", checkmark: "✓", Chi: "Χ", chi: "χ", circ: "ˆ", circeq: "≗", circlearrowleft: "↺", circlearrowright: "↻", circledast: "⊛", circledcirc: "⊚", circleddash: "⊝", CircleDot: "⊙", circledR: "®", circledS: "Ⓢ", CircleMinus: "⊖", CirclePlus: "⊕", CircleTimes: "⊗", cir: "○", cirE: "⧃", cire: "≗", cirfnint: "⨐", cirmid: "⫯", cirscir: "⧂", ClockwiseContourIntegral: "∲", CloseCurlyDoubleQuote: "”", CloseCurlyQuote: "’", clubs: "♣", clubsuit: "♣", colon: ":", Colon: "∷", Colone: "⩴", colone: "≔", coloneq: "≔", comma: ",", commat: "@", comp: "∁", compfn: "∘", complement: "∁", complexes: "ℂ", cong: "≅", congdot: "⩭", Congruent: "≡", conint: "∮", Conint: "∯", ContourIntegral: "∮", copf: "𝕔", Copf: "ℂ", coprod: "∐", Coproduct: "∐", copy: "©", COPY: "©", copysr: "℗", CounterClockwiseContourIntegral: "∳", crarr: "↵", cross: "✗", Cross: "⨯", Cscr: "𝒞", cscr: "𝒸", csub: "⫏", csube: "⫑", csup: "⫐", csupe: "⫒", ctdot: "⋯", cudarrl: "⤸", cudarrr: "⤵", cuepr: "⋞", cuesc: "⋟", cularr: "↶", cularrp: "⤽", cupbrcap: "⩈", cupcap: "⩆", CupCap: "≍", cup: "∪", Cup: "⋓", cupcup: "⩊", cupdot: "⊍", cupor: "⩅", cups: "∪︀", curarr: "↷", curarrm: "⤼", curlyeqprec: "⋞", curlyeqsucc: "⋟", curlyvee: "⋎", curlywedge: "⋏", curren: "¤", curvearrowleft: "↶", curvearrowright: "↷", cuvee: "⋎", cuwed: "⋏", cwconint: "∲", cwint: "∱", cylcty: "⌭", dagger: "†", Dagger: "‡", daleth: "ℸ", darr: "↓", Darr: "↡", dArr: "⇓", dash: "‐", Dashv: "⫤", dashv: "⊣", dbkarow: "⤏", dblac: "˝", Dcaron: "Ď", dcaron: "ď", Dcy: "Д", dcy: "д", ddagger: "‡", ddarr: "⇊", DD: "ⅅ", dd: "ⅆ", DDotrahd: "⤑", ddotseq: "⩷", deg: "°", Del: "∇", Delta: "Δ", delta: "δ", demptyv: "⦱", dfisht: "⥿", Dfr: "𝔇", dfr: "𝔡", dHar: "⥥", dharl: "⇃", dharr: "⇂", DiacriticalAcute: "´", DiacriticalDot: "˙", DiacriticalDoubleAcute: "˝", DiacriticalGrave: "`", DiacriticalTilde: "˜", diam: "⋄", diamond: "⋄", Diamond: "⋄", diamondsuit: "♦", diams: "♦", die: "¨", DifferentialD: "ⅆ", digamma: "ϝ", disin: "⋲", div: "÷", divide: "÷", divideontimes: "⋇", divonx: "⋇", DJcy: "Ђ", djcy: "ђ", dlcorn: "⌞", dlcrop: "⌍", dollar: "$", Dopf: "𝔻", dopf: "𝕕", Dot: "¨", dot: "˙", DotDot: "⃜", doteq: "≐", doteqdot: "≑", DotEqual: "≐", dotminus: "∸", dotplus: "∔", dotsquare: "⊡", doublebarwedge: "⌆", DoubleContourIntegral: "∯", DoubleDot: "¨", DoubleDownArrow: "⇓", DoubleLeftArrow: "⇐", DoubleLeftRightArrow: "⇔", DoubleLeftTee: "⫤", DoubleLongLeftArrow: "⟸", DoubleLongLeftRightArrow: "⟺", DoubleLongRightArrow: "⟹", DoubleRightArrow: "⇒", DoubleRightTee: "⊨", DoubleUpArrow: "⇑", DoubleUpDownArrow: "⇕", DoubleVerticalBar: "∥", DownArrowBar: "⤓", downarrow: "↓", DownArrow: "↓", Downarrow: "⇓", DownArrowUpArrow: "⇵", DownBreve: "̑", downdownarrows: "⇊", downharpoonleft: "⇃", downharpoonright: "⇂", DownLeftRightVector: "⥐", DownLeftTeeVector: "⥞", DownLeftVectorBar: "⥖", DownLeftVector: "↽", DownRightTeeVector: "⥟", DownRightVectorBar: "⥗", DownRightVector: "⇁", DownTeeArrow: "↧", DownTee: "⊤", drbkarow: "⤐", drcorn: "⌟", drcrop: "⌌", Dscr: "𝒟", dscr: "𝒹", DScy: "Ѕ", dscy: "ѕ", dsol: "⧶", Dstrok: "Đ", dstrok: "đ", dtdot: "⋱", dtri: "▿", dtrif: "▾", duarr: "⇵", duhar: "⥯", dwangle: "⦦", DZcy: "Џ", dzcy: "џ", dzigrarr: "⟿", Eacute: "É", eacute: "é", easter: "⩮", Ecaron: "Ě", ecaron: "ě", Ecirc: "Ê", ecirc: "ê", ecir: "≖", ecolon: "≕", Ecy: "Э", ecy: "э", eDDot: "⩷", Edot: "Ė", edot: "ė", eDot: "≑", ee: "ⅇ", efDot: "≒", Efr: "𝔈", efr: "𝔢", eg: "⪚", Egrave: "È", egrave: "è", egs: "⪖", egsdot: "⪘", el: "⪙", Element: "∈", elinters: "⏧", ell: "ℓ", els: "⪕", elsdot: "⪗", Emacr: "Ē", emacr: "ē", empty: "∅", emptyset: "∅", EmptySmallSquare: "◻", emptyv: "∅", EmptyVerySmallSquare: "▫", emsp13: " ", emsp14: " ", emsp: " ", ENG: "Ŋ", eng: "ŋ", ensp: " ", Eogon: "Ę", eogon: "ę", Eopf: "𝔼", eopf: "𝕖", epar: "⋕", eparsl: "⧣", eplus: "⩱", epsi: "ε", Epsilon: "Ε", epsilon: "ε", epsiv: "ϵ", eqcirc: "≖", eqcolon: "≕", eqsim: "≂", eqslantgtr: "⪖", eqslantless: "⪕", Equal: "⩵", equals: "=", EqualTilde: "≂", equest: "≟", Equilibrium: "⇌", equiv: "≡", equivDD: "⩸", eqvparsl: "⧥", erarr: "⥱", erDot: "≓", escr: "ℯ", Escr: "ℰ", esdot: "≐", Esim: "⩳", esim: "≂", Eta: "Η", eta: "η", ETH: "Ð", eth: "ð", Euml: "Ë", euml: "ë", euro: "€", excl: "!", exist: "∃", Exists: "∃", expectation: "ℰ", exponentiale: "ⅇ", ExponentialE: "ⅇ", fallingdotseq: "≒", Fcy: "Ф", fcy: "ф", female: "♀", ffilig: "ffi", fflig: "ff", ffllig: "ffl", Ffr: "𝔉", ffr: "𝔣", filig: "fi", FilledSmallSquare: "◼", FilledVerySmallSquare: "▪", fjlig: "fj", flat: "♭", fllig: "fl", fltns: "▱", fnof: "ƒ", Fopf: "𝔽", fopf: "𝕗", forall: "∀", ForAll: "∀", fork: "⋔", forkv: "⫙", Fouriertrf: "ℱ", fpartint: "⨍", frac12: "½", frac13: "⅓", frac14: "¼", frac15: "⅕", frac16: "⅙", frac18: "⅛", frac23: "⅔", frac25: "⅖", frac34: "¾", frac35: "⅗", frac38: "⅜", frac45: "⅘", frac56: "⅚", frac58: "⅝", frac78: "⅞", frasl: "⁄", frown: "⌢", fscr: "𝒻", Fscr: "ℱ", gacute: "ǵ", Gamma: "Γ", gamma: "γ", Gammad: "Ϝ", gammad: "ϝ", gap: "⪆", Gbreve: "Ğ", gbreve: "ğ", Gcedil: "Ģ", Gcirc: "Ĝ", gcirc: "ĝ", Gcy: "Г", gcy: "г", Gdot: "Ġ", gdot: "ġ", ge: "≥", gE: "≧", gEl: "⪌", gel: "⋛", geq: "≥", geqq: "≧", geqslant: "⩾", gescc: "⪩", ges: "⩾", gesdot: "⪀", gesdoto: "⪂", gesdotol: "⪄", gesl: "⋛︀", gesles: "⪔", Gfr: "𝔊", gfr: "𝔤", gg: "≫", Gg: "⋙", ggg: "⋙", gimel: "ℷ", GJcy: "Ѓ", gjcy: "ѓ", gla: "⪥", gl: "≷", glE: "⪒", glj: "⪤", gnap: "⪊", gnapprox: "⪊", gne: "⪈", gnE: "≩", gneq: "⪈", gneqq: "≩", gnsim: "⋧", Gopf: "𝔾", gopf: "𝕘", grave: "`", GreaterEqual: "≥", GreaterEqualLess: "⋛", GreaterFullEqual: "≧", GreaterGreater: "⪢", GreaterLess: "≷", GreaterSlantEqual: "⩾", GreaterTilde: "≳", Gscr: "𝒢", gscr: "ℊ", gsim: "≳", gsime: "⪎", gsiml: "⪐", gtcc: "⪧", gtcir: "⩺", gt: ">", GT: ">", Gt: "≫", gtdot: "⋗", gtlPar: "⦕", gtquest: "⩼", gtrapprox: "⪆", gtrarr: "⥸", gtrdot: "⋗", gtreqless: "⋛", gtreqqless: "⪌", gtrless: "≷", gtrsim: "≳", gvertneqq: "≩︀", gvnE: "≩︀", Hacek: "ˇ", hairsp: " ", half: "½", hamilt: "ℋ", HARDcy: "Ъ", hardcy: "ъ", harrcir: "⥈", harr: "↔", hArr: "⇔", harrw: "↭", Hat: "^", hbar: "ℏ", Hcirc: "Ĥ", hcirc: "ĥ", hearts: "♥", heartsuit: "♥", hellip: "…", hercon: "⊹", hfr: "𝔥", Hfr: "ℌ", HilbertSpace: "ℋ", hksearow: "⤥", hkswarow: "⤦", hoarr: "⇿", homtht: "∻", hookleftarrow: "↩", hookrightarrow: "↪", hopf: "𝕙", Hopf: "ℍ", horbar: "―", HorizontalLine: "─", hscr: "𝒽", Hscr: "ℋ", hslash: "ℏ", Hstrok: "Ħ", hstrok: "ħ", HumpDownHump: "≎", HumpEqual: "≏", hybull: "⁃", hyphen: "‐", Iacute: "Í", iacute: "í", ic: "\u2063", Icirc: "Î", icirc: "î", Icy: "И", icy: "и", Idot: "İ", IEcy: "Е", iecy: "е", iexcl: "¡", iff: "⇔", ifr: "𝔦", Ifr: "ℑ", Igrave: "Ì", igrave: "ì", ii: "ⅈ", iiiint: "⨌", iiint: "∭", iinfin: "⧜", iiota: "℩", IJlig: "IJ", ijlig: "ij", Imacr: "Ī", imacr: "ī", image: "ℑ", ImaginaryI: "ⅈ", imagline: "ℐ", imagpart: "ℑ", imath: "ı", Im: "ℑ", imof: "⊷", imped: "Ƶ", Implies: "⇒", incare: "℅", in: "∈", infin: "∞", infintie: "⧝", inodot: "ı", intcal: "⊺", int: "∫", Int: "∬", integers: "ℤ", Integral: "∫", intercal: "⊺", Intersection: "⋂", intlarhk: "⨗", intprod: "⨼", InvisibleComma: "\u2063", InvisibleTimes: "\u2062", IOcy: "Ё", iocy: "ё", Iogon: "Į", iogon: "į", Iopf: "𝕀", iopf: "𝕚", Iota: "Ι", iota: "ι", iprod: "⨼", iquest: "¿", iscr: "𝒾", Iscr: "ℐ", isin: "∈", isindot: "⋵", isinE: "⋹", isins: "⋴", isinsv: "⋳", isinv: "∈", it: "\u2062", Itilde: "Ĩ", itilde: "ĩ", Iukcy: "І", iukcy: "і", Iuml: "Ï", iuml: "ï", Jcirc: "Ĵ", jcirc: "ĵ", Jcy: "Й", jcy: "й", Jfr: "𝔍", jfr: "𝔧", jmath: "ȷ", Jopf: "𝕁", jopf: "𝕛", Jscr: "𝒥", jscr: "𝒿", Jsercy: "Ј", jsercy: "ј", Jukcy: "Є", jukcy: "є", Kappa: "Κ", kappa: "κ", kappav: "ϰ", Kcedil: "Ķ", kcedil: "ķ", Kcy: "К", kcy: "к", Kfr: "𝔎", kfr: "𝔨", kgreen: "ĸ", KHcy: "Х", khcy: "х", KJcy: "Ќ", kjcy: "ќ", Kopf: "𝕂", kopf: "𝕜", Kscr: "𝒦", kscr: "𝓀", lAarr: "⇚", Lacute: "Ĺ", lacute: "ĺ", laemptyv: "⦴", lagran: "ℒ", Lambda: "Λ", lambda: "λ", lang: "⟨", Lang: "⟪", langd: "⦑", langle: "⟨", lap: "⪅", Laplacetrf: "ℒ", laquo: "«", larrb: "⇤", larrbfs: "⤟", larr: "←", Larr: "↞", lArr: "⇐", larrfs: "⤝", larrhk: "↩", larrlp: "↫", larrpl: "⤹", larrsim: "⥳", larrtl: "↢", latail: "⤙", lAtail: "⤛", lat: "⪫", late: "⪭", lates: "⪭︀", lbarr: "⤌", lBarr: "⤎", lbbrk: "❲", lbrace: "{", lbrack: "[", lbrke: "⦋", lbrksld: "⦏", lbrkslu: "⦍", Lcaron: "Ľ", lcaron: "ľ", Lcedil: "Ļ", lcedil: "ļ", lceil: "⌈", lcub: "{", Lcy: "Л", lcy: "л", ldca: "⤶", ldquo: "“", ldquor: "„", ldrdhar: "⥧", ldrushar: "⥋", ldsh: "↲", le: "≤", lE: "≦", LeftAngleBracket: "⟨", LeftArrowBar: "⇤", leftarrow: "←", LeftArrow: "←", Leftarrow: "⇐", LeftArrowRightArrow: "⇆", leftarrowtail: "↢", LeftCeiling: "⌈", LeftDoubleBracket: "⟦", LeftDownTeeVector: "⥡", LeftDownVectorBar: "⥙", LeftDownVector: "⇃", LeftFloor: "⌊", leftharpoondown: "↽", leftharpoonup: "↼", leftleftarrows: "⇇", leftrightarrow: "↔", LeftRightArrow: "↔", Leftrightarrow: "⇔", leftrightarrows: "⇆", leftrightharpoons: "⇋", leftrightsquigarrow: "↭", LeftRightVector: "⥎", LeftTeeArrow: "↤", LeftTee: "⊣", LeftTeeVector: "⥚", leftthreetimes: "⋋", LeftTriangleBar: "⧏", LeftTriangle: "⊲", LeftTriangleEqual: "⊴", LeftUpDownVector: "⥑", LeftUpTeeVector: "⥠", LeftUpVectorBar: "⥘", LeftUpVector: "↿", LeftVectorBar: "⥒", LeftVector: "↼", lEg: "⪋", leg: "⋚", leq: "≤", leqq: "≦", leqslant: "⩽", lescc: "⪨", les: "⩽", lesdot: "⩿", lesdoto: "⪁", lesdotor: "⪃", lesg: "⋚︀", lesges: "⪓", lessapprox: "⪅", lessdot: "⋖", lesseqgtr: "⋚", lesseqqgtr: "⪋", LessEqualGreater: "⋚", LessFullEqual: "≦", LessGreater: "≶", lessgtr: "≶", LessLess: "⪡", lesssim: "≲", LessSlantEqual: "⩽", LessTilde: "≲", lfisht: "⥼", lfloor: "⌊", Lfr: "𝔏", lfr: "𝔩", lg: "≶", lgE: "⪑", lHar: "⥢", lhard: "↽", lharu: "↼", lharul: "⥪", lhblk: "▄", LJcy: "Љ", ljcy: "љ", llarr: "⇇", ll: "≪", Ll: "⋘", llcorner: "⌞", Lleftarrow: "⇚", llhard: "⥫", lltri: "◺", Lmidot: "Ŀ", lmidot: "ŀ", lmoustache: "⎰", lmoust: "⎰", lnap: "⪉", lnapprox: "⪉", lne: "⪇", lnE: "≨", lneq: "⪇", lneqq: "≨", lnsim: "⋦", loang: "⟬", loarr: "⇽", lobrk: "⟦", longleftarrow: "⟵", LongLeftArrow: "⟵", Longleftarrow: "⟸", longleftrightarrow: "⟷", LongLeftRightArrow: "⟷", Longleftrightarrow: "⟺", longmapsto: "⟼", longrightarrow: "⟶", LongRightArrow: "⟶", Longrightarrow: "⟹", looparrowleft: "↫", looparrowright: "↬", lopar: "⦅", Lopf: "𝕃", lopf: "𝕝", loplus: "⨭", lotimes: "⨴", lowast: "∗", lowbar: "_", LowerLeftArrow: "↙", LowerRightArrow: "↘", loz: "◊", lozenge: "◊", lozf: "⧫", lpar: "(", lparlt: "⦓", lrarr: "⇆", lrcorner: "⌟", lrhar: "⇋", lrhard: "⥭", lrm: "\u200e", lrtri: "⊿", lsaquo: "‹", lscr: "𝓁", Lscr: "ℒ", lsh: "↰", Lsh: "↰", lsim: "≲", lsime: "⪍", lsimg: "⪏", lsqb: "[", lsquo: "‘", lsquor: "‚", Lstrok: "Ł", lstrok: "ł", ltcc: "⪦", ltcir: "⩹", lt: "<", LT: "<", Lt: "≪", ltdot: "⋖", lthree: "⋋", ltimes: "⋉", ltlarr: "⥶", ltquest: "⩻", ltri: "◃", ltrie: "⊴", ltrif: "◂", ltrPar: "⦖", lurdshar: "⥊", luruhar: "⥦", lvertneqq: "≨︀", lvnE: "≨︀", macr: "¯", male: "♂", malt: "✠", maltese: "✠", Map: "⤅", map: "↦", mapsto: "↦", mapstodown: "↧", mapstoleft: "↤", mapstoup: "↥", marker: "▮", mcomma: "⨩", Mcy: "М", mcy: "м", mdash: "—", mDDot: "∺", measuredangle: "∡", MediumSpace: " ", Mellintrf: "ℳ", Mfr: "𝔐", mfr: "𝔪", mho: "℧", micro: "µ", midast: "*", midcir: "⫰", mid: "∣", middot: "·", minusb: "⊟", minus: "−", minusd: "∸", minusdu: "⨪", MinusPlus: "∓", mlcp: "⫛", mldr: "…", mnplus: "∓", models: "⊧", Mopf: "𝕄", mopf: "𝕞", mp: "∓", mscr: "𝓂", Mscr: "ℳ", mstpos: "∾", Mu: "Μ", mu: "μ", multimap: "⊸", mumap: "⊸", nabla: "∇", Nacute: "Ń", nacute: "ń", nang: "∠⃒", nap: "≉", napE: "⩰̸", napid: "≋̸", napos: "ʼn", napprox: "≉", natural: "♮", naturals: "ℕ", natur: "♮", nbsp: " ", nbump: "≎̸", nbumpe: "≏̸", ncap: "⩃", Ncaron: "Ň", ncaron: "ň", Ncedil: "Ņ", ncedil: "ņ", ncong: "≇", ncongdot: "⩭̸", ncup: "⩂", Ncy: "Н", ncy: "н", ndash: "–", nearhk: "⤤", nearr: "↗", neArr: "⇗", nearrow: "↗", ne: "≠", nedot: "≐̸", NegativeMediumSpace: "​", NegativeThickSpace: "​", NegativeThinSpace: "​", NegativeVeryThinSpace: "​", nequiv: "≢", nesear: "⤨", nesim: "≂̸", NestedGreaterGreater: "≫", NestedLessLess: "≪", NewLine: "\u000a", nexist: "∄", nexists: "∄", Nfr: "𝔑", nfr: "𝔫", ngE: "≧̸", nge: "≱", ngeq: "≱", ngeqq: "≧̸", ngeqslant: "⩾̸", nges: "⩾̸", nGg: "⋙̸", ngsim: "≵", nGt: "≫⃒", ngt: "≯", ngtr: "≯", nGtv: "≫̸", nharr: "↮", nhArr: "⇎", nhpar: "⫲", ni: "∋", nis: "⋼", nisd: "⋺", niv: "∋", NJcy: "Њ", njcy: "њ", nlarr: "↚", nlArr: "⇍", nldr: "‥", nlE: "≦̸", nle: "≰", nleftarrow: "↚", nLeftarrow: "⇍", nleftrightarrow: "↮", nLeftrightarrow: "⇎", nleq: "≰", nleqq: "≦̸", nleqslant: "⩽̸", nles: "⩽̸", nless: "≮", nLl: "⋘̸", nlsim: "≴", nLt: "≪⃒", nlt: "≮", nltri: "⋪", nltrie: "⋬", nLtv: "≪̸", nmid: "∤", NoBreak: "\u2060", NonBreakingSpace: " ", nopf: "𝕟", Nopf: "ℕ", Not: "⫬", not: "¬", NotCongruent: "≢", NotCupCap: "≭", NotDoubleVerticalBar: "∦", NotElement: "∉", NotEqual: "≠", NotEqualTilde: "≂̸", NotExists: "∄", NotGreater: "≯", NotGreaterEqual: "≱", NotGreaterFullEqual: "≧̸", NotGreaterGreater: "≫̸", NotGreaterLess: "≹", NotGreaterSlantEqual: "⩾̸", NotGreaterTilde: "≵", NotHumpDownHump: "≎̸", NotHumpEqual: "≏̸", notin: "∉", notindot: "⋵̸", notinE: "⋹̸", notinva: "∉", notinvb: "⋷", notinvc: "⋶", NotLeftTriangleBar: "⧏̸", NotLeftTriangle: "⋪", NotLeftTriangleEqual: "⋬", NotLess: "≮", NotLessEqual: "≰", NotLessGreater: "≸", NotLessLess: "≪̸", NotLessSlantEqual: "⩽̸", NotLessTilde: "≴", NotNestedGreaterGreater: "⪢̸", NotNestedLessLess: "⪡̸", notni: "∌", notniva: "∌", notnivb: "⋾", notnivc: "⋽", NotPrecedes: "⊀", NotPrecedesEqual: "⪯̸", NotPrecedesSlantEqual: "⋠", NotReverseElement: "∌", NotRightTriangleBar: "⧐̸", NotRightTriangle: "⋫", NotRightTriangleEqual: "⋭", NotSquareSubset: "⊏̸", NotSquareSubsetEqual: "⋢", NotSquareSuperset: "⊐̸", NotSquareSupersetEqual: "⋣", NotSubset: "⊂⃒", NotSubsetEqual: "⊈", NotSucceeds: "⊁", NotSucceedsEqual: "⪰̸", NotSucceedsSlantEqual: "⋡", NotSucceedsTilde: "≿̸", NotSuperset: "⊃⃒", NotSupersetEqual: "⊉", NotTilde: "≁", NotTildeEqual: "≄", NotTildeFullEqual: "≇", NotTildeTilde: "≉", NotVerticalBar: "∤", nparallel: "∦", npar: "∦", nparsl: "⫽⃥", npart: "∂̸", npolint: "⨔", npr: "⊀", nprcue: "⋠", nprec: "⊀", npreceq: "⪯̸", npre: "⪯̸", nrarrc: "⤳̸", nrarr: "↛", nrArr: "⇏", nrarrw: "↝̸", nrightarrow: "↛", nRightarrow: "⇏", nrtri: "⋫", nrtrie: "⋭", nsc: "⊁", nsccue: "⋡", nsce: "⪰̸", Nscr: "𝒩", nscr: "𝓃", nshortmid: "∤", nshortparallel: "∦", nsim: "≁", nsime: "≄", nsimeq: "≄", nsmid: "∤", nspar: "∦", nsqsube: "⋢", nsqsupe: "⋣", nsub: "⊄", nsubE: "⫅̸", nsube: "⊈", nsubset: "⊂⃒", nsubseteq: "⊈", nsubseteqq: "⫅̸", nsucc: "⊁", nsucceq: "⪰̸", nsup: "⊅", nsupE: "⫆̸", nsupe: "⊉", nsupset: "⊃⃒", nsupseteq: "⊉", nsupseteqq: "⫆̸", ntgl: "≹", Ntilde: "Ñ", ntilde: "ñ", ntlg: "≸", ntriangleleft: "⋪", ntrianglelefteq: "⋬", ntriangleright: "⋫", ntrianglerighteq: "⋭", Nu: "Ν", nu: "ν", num: "#", numero: "№", numsp: " ", nvap: "≍⃒", nvdash: "⊬", nvDash: "⊭", nVdash: "⊮", nVDash: "⊯", nvge: "≥⃒", nvgt: ">⃒", nvHarr: "⤄", nvinfin: "⧞", nvlArr: "⤂", nvle: "≤⃒", nvlt: "<⃒", nvltrie: "⊴⃒", nvrArr: "⤃", nvrtrie: "⊵⃒", nvsim: "∼⃒", nwarhk: "⤣", nwarr: "↖", nwArr: "⇖", nwarrow: "↖", nwnear: "⤧", Oacute: "Ó", oacute: "ó", oast: "⊛", Ocirc: "Ô", ocirc: "ô", ocir: "⊚", Ocy: "О", ocy: "о", odash: "⊝", Odblac: "Ő", odblac: "ő", odiv: "⨸", odot: "⊙", odsold: "⦼", OElig: "Œ", oelig: "œ", ofcir: "⦿", Ofr: "𝔒", ofr: "𝔬", ogon: "˛", Ograve: "Ò", ograve: "ò", ogt: "⧁", ohbar: "⦵", ohm: "Ω", oint: "∮", olarr: "↺", olcir: "⦾", olcross: "⦻", oline: "‾", olt: "⧀", Omacr: "Ō", omacr: "ō", Omega: "Ω", omega: "ω", Omicron: "Ο", omicron: "ο", omid: "⦶", ominus: "⊖", Oopf: "𝕆", oopf: "𝕠", opar: "⦷", OpenCurlyDoubleQuote: "“", OpenCurlyQuote: "‘", operp: "⦹", oplus: "⊕", orarr: "↻", Or: "⩔", or: "∨", ord: "⩝", order: "ℴ", orderof: "ℴ", ordf: "ª", ordm: "º", origof: "⊶", oror: "⩖", orslope: "⩗", orv: "⩛", oS: "Ⓢ", Oscr: "𝒪", oscr: "ℴ", Oslash: "Ø", oslash: "ø", osol: "⊘", Otilde: "Õ", otilde: "õ", otimesas: "⨶", Otimes: "⨷", otimes: "⊗", Ouml: "Ö", ouml: "ö", ovbar: "⌽", OverBar: "‾", OverBrace: "⏞", OverBracket: "⎴", OverParenthesis: "⏜", para: "¶", parallel: "∥", par: "∥", parsim: "⫳", parsl: "⫽", part: "∂", PartialD: "∂", Pcy: "П", pcy: "п", percnt: "%", period: ".", permil: "‰", perp: "⊥", pertenk: "‱", Pfr: "𝔓", pfr: "𝔭", Phi: "Φ", phi: "φ", phiv: "ϕ", phmmat: "ℳ", phone: "☎", Pi: "Π", pi: "π", pitchfork: "⋔", piv: "ϖ", planck: "ℏ", planckh: "ℎ", plankv: "ℏ", plusacir: "⨣", plusb: "⊞", pluscir: "⨢", plus: "+", plusdo: "∔", plusdu: "⨥", pluse: "⩲", PlusMinus: "±", plusmn: "±", plussim: "⨦", plustwo: "⨧", pm: "±", Poincareplane: "ℌ", pointint: "⨕", popf: "𝕡", Popf: "ℙ", pound: "£", prap: "⪷", Pr: "⪻", pr: "≺", prcue: "≼", precapprox: "⪷", prec: "≺", preccurlyeq: "≼", Precedes: "≺", PrecedesEqual: "⪯", PrecedesSlantEqual: "≼", PrecedesTilde: "≾", preceq: "⪯", precnapprox: "⪹", precneqq: "⪵", precnsim: "⋨", pre: "⪯", prE: "⪳", precsim: "≾", prime: "′", Prime: "″", primes: "ℙ", prnap: "⪹", prnE: "⪵", prnsim: "⋨", prod: "∏", Product: "∏", profalar: "⌮", profline: "⌒", profsurf: "⌓", prop: "∝", Proportional: "∝", Proportion: "∷", propto: "∝", prsim: "≾", prurel: "⊰", Pscr: "𝒫", pscr: "𝓅", Psi: "Ψ", psi: "ψ", puncsp: " ", Qfr: "𝔔", qfr: "𝔮", qint: "⨌", qopf: "𝕢", Qopf: "ℚ", qprime: "⁗", Qscr: "𝒬", qscr: "𝓆", quaternions: "ℍ", quatint: "⨖", quest: "?", questeq: "≟", quot: "\"", QUOT: "\"", rAarr: "⇛", race: "∽̱", Racute: "Ŕ", racute: "ŕ", radic: "√", raemptyv: "⦳", rang: "⟩", Rang: "⟫", rangd: "⦒", range: "⦥", rangle: "⟩", raquo: "»", rarrap: "⥵", rarrb: "⇥", rarrbfs: "⤠", rarrc: "⤳", rarr: "→", Rarr: "↠", rArr: "⇒", rarrfs: "⤞", rarrhk: "↪", rarrlp: "↬", rarrpl: "⥅", rarrsim: "⥴", Rarrtl: "⤖", rarrtl: "↣", rarrw: "↝", ratail: "⤚", rAtail: "⤜", ratio: "∶", rationals: "ℚ", rbarr: "⤍", rBarr: "⤏", RBarr: "⤐", rbbrk: "❳", rbrace: "}", rbrack: "]", rbrke: "⦌", rbrksld: "⦎", rbrkslu: "⦐", Rcaron: "Ř", rcaron: "ř", Rcedil: "Ŗ", rcedil: "ŗ", rceil: "⌉", rcub: "}", Rcy: "Р", rcy: "р", rdca: "⤷", rdldhar: "⥩", rdquo: "”", rdquor: "”", rdsh: "↳", real: "ℜ", realine: "ℛ", realpart: "ℜ", reals: "ℝ", Re: "ℜ", rect: "▭", reg: "®", REG: "®", ReverseElement: "∋", ReverseEquilibrium: "⇋", ReverseUpEquilibrium: "⥯", rfisht: "⥽", rfloor: "⌋", rfr: "𝔯", Rfr: "ℜ", rHar: "⥤", rhard: "⇁", rharu: "⇀", rharul: "⥬", Rho: "Ρ", rho: "ρ", rhov: "ϱ", RightAngleBracket: "⟩", RightArrowBar: "⇥", rightarrow: "→", RightArrow: "→", Rightarrow: "⇒", RightArrowLeftArrow: "⇄", rightarrowtail: "↣", RightCeiling: "⌉", RightDoubleBracket: "⟧", RightDownTeeVector: "⥝", RightDownVectorBar: "⥕", RightDownVector: "⇂", RightFloor: "⌋", rightharpoondown: "⇁", rightharpoonup: "⇀", rightleftarrows: "⇄", rightleftharpoons: "⇌", rightrightarrows: "⇉", rightsquigarrow: "↝", RightTeeArrow: "↦", RightTee: "⊢", RightTeeVector: "⥛", rightthreetimes: "⋌", RightTriangleBar: "⧐", RightTriangle: "⊳", RightTriangleEqual: "⊵", RightUpDownVector: "⥏", RightUpTeeVector: "⥜", RightUpVectorBar: "⥔", RightUpVector: "↾", RightVectorBar: "⥓", RightVector: "⇀", ring: "˚", risingdotseq: "≓", rlarr: "⇄", rlhar: "⇌", rlm: "\u200f", rmoustache: "⎱", rmoust: "⎱", rnmid: "⫮", roang: "⟭", roarr: "⇾", robrk: "⟧", ropar: "⦆", ropf: "𝕣", Ropf: "ℝ", roplus: "⨮", rotimes: "⨵", RoundImplies: "⥰", rpar: ")", rpargt: "⦔", rppolint: "⨒", rrarr: "⇉", Rrightarrow: "⇛", rsaquo: "›", rscr: "𝓇", Rscr: "ℛ", rsh: "↱", Rsh: "↱", rsqb: "]", rsquo: "’", rsquor: "’", rthree: "⋌", rtimes: "⋊", rtri: "▹", rtrie: "⊵", rtrif: "▸", rtriltri: "⧎", RuleDelayed: "⧴", ruluhar: "⥨", rx: "℞", Sacute: "Ś", sacute: "ś", sbquo: "‚", scap: "⪸", Scaron: "Š", scaron: "š", Sc: "⪼", sc: "≻", sccue: "≽", sce: "⪰", scE: "⪴", Scedil: "Ş", scedil: "ş", Scirc: "Ŝ", scirc: "ŝ", scnap: "⪺", scnE: "⪶", scnsim: "⋩", scpolint: "⨓", scsim: "≿", Scy: "С", scy: "с", sdotb: "⊡", sdot: "⋅", sdote: "⩦", searhk: "⤥", searr: "↘", seArr: "⇘", searrow: "↘", sect: "§", semi: ";", seswar: "⤩", setminus: "∖", setmn: "∖", sext: "✶", Sfr: "𝔖", sfr: "𝔰", sfrown: "⌢", sharp: "♯", SHCHcy: "Щ", shchcy: "щ", SHcy: "Ш", shcy: "ш", ShortDownArrow: "↓", ShortLeftArrow: "←", shortmid: "∣", shortparallel: "∥", ShortRightArrow: "→", ShortUpArrow: "↑", shy: "\u00ad", Sigma: "Σ", sigma: "σ", sigmaf: "ς", sigmav: "ς", sim: "∼", simdot: "⩪", sime: "≃", simeq: "≃", simg: "⪞", simgE: "⪠", siml: "⪝", simlE: "⪟", simne: "≆", simplus: "⨤", simrarr: "⥲", slarr: "←", SmallCircle: "∘", smallsetminus: "∖", smashp: "⨳", smeparsl: "⧤", smid: "∣", smile: "⌣", smt: "⪪", smte: "⪬", smtes: "⪬︀", SOFTcy: "Ь", softcy: "ь", solbar: "⌿", solb: "⧄", sol: "/", Sopf: "𝕊", sopf: "𝕤", spades: "♠", spadesuit: "♠", spar: "∥", sqcap: "⊓", sqcaps: "⊓︀", sqcup: "⊔", sqcups: "⊔︀", Sqrt: "√", sqsub: "⊏", sqsube: "⊑", sqsubset: "⊏", sqsubseteq: "⊑", sqsup: "⊐", sqsupe: "⊒", sqsupset: "⊐", sqsupseteq: "⊒", square: "□", Square: "□", SquareIntersection: "⊓", SquareSubset: "⊏", SquareSubsetEqual: "⊑", SquareSuperset: "⊐", SquareSupersetEqual: "⊒", SquareUnion: "⊔", squarf: "▪", squ: "□", squf: "▪", srarr: "→", Sscr: "𝒮", sscr: "𝓈", ssetmn: "∖", ssmile: "⌣", sstarf: "⋆", Star: "⋆", star: "☆", starf: "★", straightepsilon: "ϵ", straightphi: "ϕ", strns: "¯", sub: "⊂", Sub: "⋐", subdot: "⪽", subE: "⫅", sube: "⊆", subedot: "⫃", submult: "⫁", subnE: "⫋", subne: "⊊", subplus: "⪿", subrarr: "⥹", subset: "⊂", Subset: "⋐", subseteq: "⊆", subseteqq: "⫅", SubsetEqual: "⊆", subsetneq: "⊊", subsetneqq: "⫋", subsim: "⫇", subsub: "⫕", subsup: "⫓", succapprox: "⪸", succ: "≻", succcurlyeq: "≽", Succeeds: "≻", SucceedsEqual: "⪰", SucceedsSlantEqual: "≽", SucceedsTilde: "≿", succeq: "⪰", succnapprox: "⪺", succneqq: "⪶", succnsim: "⋩", succsim: "≿", SuchThat: "∋", sum: "∑", Sum: "∑", sung: "♪", sup1: "¹", sup2: "²", sup3: "³", sup: "⊃", Sup: "⋑", supdot: "⪾", supdsub: "⫘", supE: "⫆", supe: "⊇", supedot: "⫄", Superset: "⊃", SupersetEqual: "⊇", suphsol: "⟉", suphsub: "⫗", suplarr: "⥻", supmult: "⫂", supnE: "⫌", supne: "⊋", supplus: "⫀", supset: "⊃", Supset: "⋑", supseteq: "⊇", supseteqq: "⫆", supsetneq: "⊋", supsetneqq: "⫌", supsim: "⫈", supsub: "⫔", supsup: "⫖", swarhk: "⤦", swarr: "↙", swArr: "⇙", swarrow: "↙", swnwar: "⤪", szlig: "ß", Tab: "\u0009", target: "⌖", Tau: "Τ", tau: "τ", tbrk: "⎴", Tcaron: "Ť", tcaron: "ť", Tcedil: "Ţ", tcedil: "ţ", Tcy: "Т", tcy: "т", tdot: "⃛", telrec: "⌕", Tfr: "𝔗", tfr: "𝔱", there4: "∴", therefore: "∴", Therefore: "∴", Theta: "Θ", theta: "θ", thetasym: "ϑ", thetav: "ϑ", thickapprox: "≈", thicksim: "∼", ThickSpace: "  ", ThinSpace: " ", thinsp: " ", thkap: "≈", thksim: "∼", THORN: "Þ", thorn: "þ", tilde: "˜", Tilde: "∼", TildeEqual: "≃", TildeFullEqual: "≅", TildeTilde: "≈", timesbar: "⨱", timesb: "⊠", times: "×", timesd: "⨰", tint: "∭", toea: "⤨", topbot: "⌶", topcir: "⫱", top: "⊤", Topf: "𝕋", topf: "𝕥", topfork: "⫚", tosa: "⤩", tprime: "‴", trade: "™", TRADE: "™", triangle: "▵", triangledown: "▿", triangleleft: "◃", trianglelefteq: "⊴", triangleq: "≜", triangleright: "▹", trianglerighteq: "⊵", tridot: "◬", trie: "≜", triminus: "⨺", TripleDot: "⃛", triplus: "⨹", trisb: "⧍", tritime: "⨻", trpezium: "⏢", Tscr: "𝒯", tscr: "𝓉", TScy: "Ц", tscy: "ц", TSHcy: "Ћ", tshcy: "ћ", Tstrok: "Ŧ", tstrok: "ŧ", twixt: "≬", twoheadleftarrow: "↞", twoheadrightarrow: "↠", Uacute: "Ú", uacute: "ú", uarr: "↑", Uarr: "↟", uArr: "⇑", Uarrocir: "⥉", Ubrcy: "Ў", ubrcy: "ў", Ubreve: "Ŭ", ubreve: "ŭ", Ucirc: "Û", ucirc: "û", Ucy: "У", ucy: "у", udarr: "⇅", Udblac: "Ű", udblac: "ű", udhar: "⥮", ufisht: "⥾", Ufr: "𝔘", ufr: "𝔲", Ugrave: "Ù", ugrave: "ù", uHar: "⥣", uharl: "↿", uharr: "↾", uhblk: "▀", ulcorn: "⌜", ulcorner: "⌜", ulcrop: "⌏", ultri: "◸", Umacr: "Ū", umacr: "ū", uml: "¨", UnderBar: "_", UnderBrace: "⏟", UnderBracket: "⎵", UnderParenthesis: "⏝", Union: "⋃", UnionPlus: "⊎", Uogon: "Ų", uogon: "ų", Uopf: "𝕌", uopf: "𝕦", UpArrowBar: "⤒", uparrow: "↑", UpArrow: "↑", Uparrow: "⇑", UpArrowDownArrow: "⇅", updownarrow: "↕", UpDownArrow: "↕", Updownarrow: "⇕", UpEquilibrium: "⥮", upharpoonleft: "↿", upharpoonright: "↾", uplus: "⊎", UpperLeftArrow: "↖", UpperRightArrow: "↗", upsi: "υ", Upsi: "ϒ", upsih: "ϒ", Upsilon: "Υ", upsilon: "υ", UpTeeArrow: "↥", UpTee: "⊥", upuparrows: "⇈", urcorn: "⌝", urcorner: "⌝", urcrop: "⌎", Uring: "Ů", uring: "ů", urtri: "◹", Uscr: "𝒰", uscr: "𝓊", utdot: "⋰", Utilde: "Ũ", utilde: "ũ", utri: "▵", utrif: "▴", uuarr: "⇈", Uuml: "Ü", uuml: "ü", uwangle: "⦧", vangrt: "⦜", varepsilon: "ϵ", varkappa: "ϰ", varnothing: "∅", varphi: "ϕ", varpi: "ϖ", varpropto: "∝", varr: "↕", vArr: "⇕", varrho: "ϱ", varsigma: "ς", varsubsetneq: "⊊︀", varsubsetneqq: "⫋︀", varsupsetneq: "⊋︀", varsupsetneqq: "⫌︀", vartheta: "ϑ", vartriangleleft: "⊲", vartriangleright: "⊳", vBar: "⫨", Vbar: "⫫", vBarv: "⫩", Vcy: "В", vcy: "в", vdash: "⊢", vDash: "⊨", Vdash: "⊩", VDash: "⊫", Vdashl: "⫦", veebar: "⊻", vee: "∨", Vee: "⋁", veeeq: "≚", vellip: "⋮", verbar: "|", Verbar: "‖", vert: "|", Vert: "‖", VerticalBar: "∣", VerticalLine: "|", VerticalSeparator: "❘", VerticalTilde: "≀", VeryThinSpace: " ", Vfr: "𝔙", vfr: "𝔳", vltri: "⊲", vnsub: "⊂⃒", vnsup: "⊃⃒", Vopf: "𝕍", vopf: "𝕧", vprop: "∝", vrtri: "⊳", Vscr: "𝒱", vscr: "𝓋", vsubnE: "⫋︀", vsubne: "⊊︀", vsupnE: "⫌︀", vsupne: "⊋︀", Vvdash: "⊪", vzigzag: "⦚", Wcirc: "Ŵ", wcirc: "ŵ", wedbar: "⩟", wedge: "∧", Wedge: "⋀", wedgeq: "≙", weierp: "℘", Wfr: "𝔚", wfr: "𝔴", Wopf: "𝕎", wopf: "𝕨", wp: "℘", wr: "≀", wreath: "≀", Wscr: "𝒲", wscr: "𝓌", xcap: "⋂", xcirc: "◯", xcup: "⋃", xdtri: "▽", Xfr: "𝔛", xfr: "𝔵", xharr: "⟷", xhArr: "⟺", Xi: "Ξ", xi: "ξ", xlarr: "⟵", xlArr: "⟸", xmap: "⟼", xnis: "⋻", xodot: "⨀", Xopf: "𝕏", xopf: "𝕩", xoplus: "⨁", xotime: "⨂", xrarr: "⟶", xrArr: "⟹", Xscr: "𝒳", xscr: "𝓍", xsqcup: "⨆", xuplus: "⨄", xutri: "△", xvee: "⋁", xwedge: "⋀", Yacute: "Ý", yacute: "ý", YAcy: "Я", yacy: "я", Ycirc: "Ŷ", ycirc: "ŷ", Ycy: "Ы", ycy: "ы", yen: "¥", Yfr: "𝔜", yfr: "𝔶", YIcy: "Ї", yicy: "ї", Yopf: "𝕐", yopf: "𝕪", Yscr: "𝒴", yscr: "𝓎", YUcy: "Ю", yucy: "ю", yuml: "ÿ", Yuml: "Ÿ", Zacute: "Ź", zacute: "ź", Zcaron: "Ž", zcaron: "ž", Zcy: "З", zcy: "з", Zdot: "Ż", zdot: "ż", zeetrf: "ℨ", ZeroWidthSpace: "​", Zeta: "Ζ", zeta: "ζ", zfr: "𝔷", Zfr: "ℨ", ZHcy: "Ж", zhcy: "ж", zigrarr: "⇝", zopf: "𝕫", Zopf: "ℤ", Zscr: "𝒵", zscr: "𝓏", zwj: "\u200d", zwnj: "\u200c"
  2360. };
  2361. var HEXCHARCODE = /^#[xX]([A-Fa-f0-9]+)$/;
  2362. var CHARCODE = /^#([0-9]+)$/;
  2363. var NAMED = /^([A-Za-z0-9]+)$/;
  2364. var EntityParser = /** @class */ (function () {
  2365. function EntityParser(named) {
  2366. this.named = named;
  2367. }
  2368. EntityParser.prototype.parse = function (entity) {
  2369. if (!entity) {
  2370. return;
  2371. }
  2372. var matches = entity.match(HEXCHARCODE);
  2373. if (matches) {
  2374. return String.fromCharCode(parseInt(matches[1], 16));
  2375. }
  2376. matches = entity.match(CHARCODE);
  2377. if (matches) {
  2378. return String.fromCharCode(parseInt(matches[1], 10));
  2379. }
  2380. matches = entity.match(NAMED);
  2381. if (matches) {
  2382. return this.named[matches[1]];
  2383. }
  2384. };
  2385. return EntityParser;
  2386. }());
  2387. var WSP = /[\t\n\f ]/;
  2388. var ALPHA = /[A-Za-z]/;
  2389. var CRLF = /\r\n?/g;
  2390. function isSpace(char) {
  2391. return WSP.test(char);
  2392. }
  2393. function isAlpha(char) {
  2394. return ALPHA.test(char);
  2395. }
  2396. function preprocessInput(input) {
  2397. return input.replace(CRLF, '\n');
  2398. }
  2399. var EventedTokenizer = /** @class */ (function () {
  2400. function EventedTokenizer(delegate, entityParser, mode) {
  2401. if (mode === void 0) { mode = 'precompile'; }
  2402. this.delegate = delegate;
  2403. this.entityParser = entityParser;
  2404. this.mode = mode;
  2405. this.state = "beforeData" /* beforeData */;
  2406. this.line = -1;
  2407. this.column = -1;
  2408. this.input = '';
  2409. this.index = -1;
  2410. this.tagNameBuffer = '';
  2411. this.states = {
  2412. beforeData: function () {
  2413. var char = this.peek();
  2414. if (char === '<' && !this.isIgnoredEndTag()) {
  2415. this.transitionTo("tagOpen" /* tagOpen */);
  2416. this.markTagStart();
  2417. this.consume();
  2418. }
  2419. else {
  2420. if (this.mode === 'precompile' && char === '\n') {
  2421. var tag = this.tagNameBuffer.toLowerCase();
  2422. if (tag === 'pre' || tag === 'textarea') {
  2423. this.consume();
  2424. }
  2425. }
  2426. this.transitionTo("data" /* data */);
  2427. this.delegate.beginData();
  2428. }
  2429. },
  2430. data: function () {
  2431. var char = this.peek();
  2432. var tag = this.tagNameBuffer;
  2433. if (char === '<' && !this.isIgnoredEndTag()) {
  2434. this.delegate.finishData();
  2435. this.transitionTo("tagOpen" /* tagOpen */);
  2436. this.markTagStart();
  2437. this.consume();
  2438. }
  2439. else if (char === '&' && tag !== 'script' && tag !== 'style') {
  2440. this.consume();
  2441. this.delegate.appendToData(this.consumeCharRef() || '&');
  2442. }
  2443. else {
  2444. this.consume();
  2445. this.delegate.appendToData(char);
  2446. }
  2447. },
  2448. tagOpen: function () {
  2449. var char = this.consume();
  2450. if (char === '!') {
  2451. this.transitionTo("markupDeclarationOpen" /* markupDeclarationOpen */);
  2452. }
  2453. else if (char === '/') {
  2454. this.transitionTo("endTagOpen" /* endTagOpen */);
  2455. }
  2456. else if (char === '@' || char === ':' || isAlpha(char)) {
  2457. this.transitionTo("tagName" /* tagName */);
  2458. this.tagNameBuffer = '';
  2459. this.delegate.beginStartTag();
  2460. this.appendToTagName(char);
  2461. }
  2462. },
  2463. markupDeclarationOpen: function () {
  2464. var char = this.consume();
  2465. if (char === '-' && this.peek() === '-') {
  2466. this.consume();
  2467. this.transitionTo("commentStart" /* commentStart */);
  2468. this.delegate.beginComment();
  2469. }
  2470. else {
  2471. var maybeDoctype = char.toUpperCase() + this.input.substring(this.index, this.index + 6).toUpperCase();
  2472. if (maybeDoctype === 'DOCTYPE') {
  2473. this.consume();
  2474. this.consume();
  2475. this.consume();
  2476. this.consume();
  2477. this.consume();
  2478. this.consume();
  2479. this.transitionTo("doctype" /* doctype */);
  2480. if (this.delegate.beginDoctype)
  2481. this.delegate.beginDoctype();
  2482. }
  2483. }
  2484. },
  2485. doctype: function () {
  2486. var char = this.consume();
  2487. if (isSpace(char)) {
  2488. this.transitionTo("beforeDoctypeName" /* beforeDoctypeName */);
  2489. }
  2490. },
  2491. beforeDoctypeName: function () {
  2492. var char = this.consume();
  2493. if (isSpace(char)) {
  2494. return;
  2495. }
  2496. else {
  2497. this.transitionTo("doctypeName" /* doctypeName */);
  2498. if (this.delegate.appendToDoctypeName)
  2499. this.delegate.appendToDoctypeName(char.toLowerCase());
  2500. }
  2501. },
  2502. doctypeName: function () {
  2503. var char = this.consume();
  2504. if (isSpace(char)) {
  2505. this.transitionTo("afterDoctypeName" /* afterDoctypeName */);
  2506. }
  2507. else if (char === '>') {
  2508. if (this.delegate.endDoctype)
  2509. this.delegate.endDoctype();
  2510. this.transitionTo("beforeData" /* beforeData */);
  2511. }
  2512. else {
  2513. if (this.delegate.appendToDoctypeName)
  2514. this.delegate.appendToDoctypeName(char.toLowerCase());
  2515. }
  2516. },
  2517. afterDoctypeName: function () {
  2518. var char = this.consume();
  2519. if (isSpace(char)) {
  2520. return;
  2521. }
  2522. else if (char === '>') {
  2523. if (this.delegate.endDoctype)
  2524. this.delegate.endDoctype();
  2525. this.transitionTo("beforeData" /* beforeData */);
  2526. }
  2527. else {
  2528. var nextSixChars = char.toUpperCase() + this.input.substring(this.index, this.index + 5).toUpperCase();
  2529. var isPublic = nextSixChars.toUpperCase() === 'PUBLIC';
  2530. var isSystem = nextSixChars.toUpperCase() === 'SYSTEM';
  2531. if (isPublic || isSystem) {
  2532. this.consume();
  2533. this.consume();
  2534. this.consume();
  2535. this.consume();
  2536. this.consume();
  2537. this.consume();
  2538. }
  2539. if (isPublic) {
  2540. this.transitionTo("afterDoctypePublicKeyword" /* afterDoctypePublicKeyword */);
  2541. }
  2542. else if (isSystem) {
  2543. this.transitionTo("afterDoctypeSystemKeyword" /* afterDoctypeSystemKeyword */);
  2544. }
  2545. }
  2546. },
  2547. afterDoctypePublicKeyword: function () {
  2548. var char = this.peek();
  2549. if (isSpace(char)) {
  2550. this.transitionTo("beforeDoctypePublicIdentifier" /* beforeDoctypePublicIdentifier */);
  2551. this.consume();
  2552. }
  2553. else if (char === '"') {
  2554. this.transitionTo("doctypePublicIdentifierDoubleQuoted" /* doctypePublicIdentifierDoubleQuoted */);
  2555. this.consume();
  2556. }
  2557. else if (char === "'") {
  2558. this.transitionTo("doctypePublicIdentifierSingleQuoted" /* doctypePublicIdentifierSingleQuoted */);
  2559. this.consume();
  2560. }
  2561. else if (char === '>') {
  2562. this.consume();
  2563. if (this.delegate.endDoctype)
  2564. this.delegate.endDoctype();
  2565. this.transitionTo("beforeData" /* beforeData */);
  2566. }
  2567. },
  2568. doctypePublicIdentifierDoubleQuoted: function () {
  2569. var char = this.consume();
  2570. if (char === '"') {
  2571. this.transitionTo("afterDoctypePublicIdentifier" /* afterDoctypePublicIdentifier */);
  2572. }
  2573. else if (char === '>') {
  2574. if (this.delegate.endDoctype)
  2575. this.delegate.endDoctype();
  2576. this.transitionTo("beforeData" /* beforeData */);
  2577. }
  2578. else {
  2579. if (this.delegate.appendToDoctypePublicIdentifier)
  2580. this.delegate.appendToDoctypePublicIdentifier(char);
  2581. }
  2582. },
  2583. doctypePublicIdentifierSingleQuoted: function () {
  2584. var char = this.consume();
  2585. if (char === "'") {
  2586. this.transitionTo("afterDoctypePublicIdentifier" /* afterDoctypePublicIdentifier */);
  2587. }
  2588. else if (char === '>') {
  2589. if (this.delegate.endDoctype)
  2590. this.delegate.endDoctype();
  2591. this.transitionTo("beforeData" /* beforeData */);
  2592. }
  2593. else {
  2594. if (this.delegate.appendToDoctypePublicIdentifier)
  2595. this.delegate.appendToDoctypePublicIdentifier(char);
  2596. }
  2597. },
  2598. afterDoctypePublicIdentifier: function () {
  2599. var char = this.consume();
  2600. if (isSpace(char)) {
  2601. this.transitionTo("betweenDoctypePublicAndSystemIdentifiers" /* betweenDoctypePublicAndSystemIdentifiers */);
  2602. }
  2603. else if (char === '>') {
  2604. if (this.delegate.endDoctype)
  2605. this.delegate.endDoctype();
  2606. this.transitionTo("beforeData" /* beforeData */);
  2607. }
  2608. else if (char === '"') {
  2609. this.transitionTo("doctypeSystemIdentifierDoubleQuoted" /* doctypeSystemIdentifierDoubleQuoted */);
  2610. }
  2611. else if (char === "'") {
  2612. this.transitionTo("doctypeSystemIdentifierSingleQuoted" /* doctypeSystemIdentifierSingleQuoted */);
  2613. }
  2614. },
  2615. betweenDoctypePublicAndSystemIdentifiers: function () {
  2616. var char = this.consume();
  2617. if (isSpace(char)) {
  2618. return;
  2619. }
  2620. else if (char === '>') {
  2621. if (this.delegate.endDoctype)
  2622. this.delegate.endDoctype();
  2623. this.transitionTo("beforeData" /* beforeData */);
  2624. }
  2625. else if (char === '"') {
  2626. this.transitionTo("doctypeSystemIdentifierDoubleQuoted" /* doctypeSystemIdentifierDoubleQuoted */);
  2627. }
  2628. else if (char === "'") {
  2629. this.transitionTo("doctypeSystemIdentifierSingleQuoted" /* doctypeSystemIdentifierSingleQuoted */);
  2630. }
  2631. },
  2632. doctypeSystemIdentifierDoubleQuoted: function () {
  2633. var char = this.consume();
  2634. if (char === '"') {
  2635. this.transitionTo("afterDoctypeSystemIdentifier" /* afterDoctypeSystemIdentifier */);
  2636. }
  2637. else if (char === '>') {
  2638. if (this.delegate.endDoctype)
  2639. this.delegate.endDoctype();
  2640. this.transitionTo("beforeData" /* beforeData */);
  2641. }
  2642. else {
  2643. if (this.delegate.appendToDoctypeSystemIdentifier)
  2644. this.delegate.appendToDoctypeSystemIdentifier(char);
  2645. }
  2646. },
  2647. doctypeSystemIdentifierSingleQuoted: function () {
  2648. var char = this.consume();
  2649. if (char === "'") {
  2650. this.transitionTo("afterDoctypeSystemIdentifier" /* afterDoctypeSystemIdentifier */);
  2651. }
  2652. else if (char === '>') {
  2653. if (this.delegate.endDoctype)
  2654. this.delegate.endDoctype();
  2655. this.transitionTo("beforeData" /* beforeData */);
  2656. }
  2657. else {
  2658. if (this.delegate.appendToDoctypeSystemIdentifier)
  2659. this.delegate.appendToDoctypeSystemIdentifier(char);
  2660. }
  2661. },
  2662. afterDoctypeSystemIdentifier: function () {
  2663. var char = this.consume();
  2664. if (isSpace(char)) {
  2665. return;
  2666. }
  2667. else if (char === '>') {
  2668. if (this.delegate.endDoctype)
  2669. this.delegate.endDoctype();
  2670. this.transitionTo("beforeData" /* beforeData */);
  2671. }
  2672. },
  2673. commentStart: function () {
  2674. var char = this.consume();
  2675. if (char === '-') {
  2676. this.transitionTo("commentStartDash" /* commentStartDash */);
  2677. }
  2678. else if (char === '>') {
  2679. this.delegate.finishComment();
  2680. this.transitionTo("beforeData" /* beforeData */);
  2681. }
  2682. else {
  2683. this.delegate.appendToCommentData(char);
  2684. this.transitionTo("comment" /* comment */);
  2685. }
  2686. },
  2687. commentStartDash: function () {
  2688. var char = this.consume();
  2689. if (char === '-') {
  2690. this.transitionTo("commentEnd" /* commentEnd */);
  2691. }
  2692. else if (char === '>') {
  2693. this.delegate.finishComment();
  2694. this.transitionTo("beforeData" /* beforeData */);
  2695. }
  2696. else {
  2697. this.delegate.appendToCommentData('-');
  2698. this.transitionTo("comment" /* comment */);
  2699. }
  2700. },
  2701. comment: function () {
  2702. var char = this.consume();
  2703. if (char === '-') {
  2704. this.transitionTo("commentEndDash" /* commentEndDash */);
  2705. }
  2706. else {
  2707. this.delegate.appendToCommentData(char);
  2708. }
  2709. },
  2710. commentEndDash: function () {
  2711. var char = this.consume();
  2712. if (char === '-') {
  2713. this.transitionTo("commentEnd" /* commentEnd */);
  2714. }
  2715. else {
  2716. this.delegate.appendToCommentData('-' + char);
  2717. this.transitionTo("comment" /* comment */);
  2718. }
  2719. },
  2720. commentEnd: function () {
  2721. var char = this.consume();
  2722. if (char === '>') {
  2723. this.delegate.finishComment();
  2724. this.transitionTo("beforeData" /* beforeData */);
  2725. }
  2726. else {
  2727. this.delegate.appendToCommentData('--' + char);
  2728. this.transitionTo("comment" /* comment */);
  2729. }
  2730. },
  2731. tagName: function () {
  2732. var char = this.consume();
  2733. if (isSpace(char)) {
  2734. this.transitionTo("beforeAttributeName" /* beforeAttributeName */);
  2735. }
  2736. else if (char === '/') {
  2737. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  2738. }
  2739. else if (char === '>') {
  2740. this.delegate.finishTag();
  2741. this.transitionTo("beforeData" /* beforeData */);
  2742. }
  2743. else {
  2744. this.appendToTagName(char);
  2745. }
  2746. },
  2747. endTagName: function () {
  2748. var char = this.consume();
  2749. if (isSpace(char)) {
  2750. this.transitionTo("beforeAttributeName" /* beforeAttributeName */);
  2751. this.tagNameBuffer = '';
  2752. }
  2753. else if (char === '/') {
  2754. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  2755. this.tagNameBuffer = '';
  2756. }
  2757. else if (char === '>') {
  2758. this.delegate.finishTag();
  2759. this.transitionTo("beforeData" /* beforeData */);
  2760. this.tagNameBuffer = '';
  2761. }
  2762. else {
  2763. this.appendToTagName(char);
  2764. }
  2765. },
  2766. beforeAttributeName: function () {
  2767. var char = this.peek();
  2768. if (isSpace(char)) {
  2769. this.consume();
  2770. return;
  2771. }
  2772. else if (char === '/') {
  2773. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  2774. this.consume();
  2775. }
  2776. else if (char === '>') {
  2777. this.consume();
  2778. this.delegate.finishTag();
  2779. this.transitionTo("beforeData" /* beforeData */);
  2780. }
  2781. else if (char === '=') {
  2782. this.delegate.reportSyntaxError('attribute name cannot start with equals sign');
  2783. this.transitionTo("attributeName" /* attributeName */);
  2784. this.delegate.beginAttribute();
  2785. this.consume();
  2786. this.delegate.appendToAttributeName(char);
  2787. }
  2788. else {
  2789. this.transitionTo("attributeName" /* attributeName */);
  2790. this.delegate.beginAttribute();
  2791. }
  2792. },
  2793. attributeName: function () {
  2794. var char = this.peek();
  2795. if (isSpace(char)) {
  2796. this.transitionTo("afterAttributeName" /* afterAttributeName */);
  2797. this.consume();
  2798. }
  2799. else if (char === '/') {
  2800. this.delegate.beginAttributeValue(false);
  2801. this.delegate.finishAttributeValue();
  2802. this.consume();
  2803. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  2804. }
  2805. else if (char === '=') {
  2806. this.transitionTo("beforeAttributeValue" /* beforeAttributeValue */);
  2807. this.consume();
  2808. }
  2809. else if (char === '>') {
  2810. this.delegate.beginAttributeValue(false);
  2811. this.delegate.finishAttributeValue();
  2812. this.consume();
  2813. this.delegate.finishTag();
  2814. this.transitionTo("beforeData" /* beforeData */);
  2815. }
  2816. else if (char === '"' || char === "'" || char === '<') {
  2817. this.delegate.reportSyntaxError(char + ' is not a valid character within attribute names');
  2818. this.consume();
  2819. this.delegate.appendToAttributeName(char);
  2820. }
  2821. else {
  2822. this.consume();
  2823. this.delegate.appendToAttributeName(char);
  2824. }
  2825. },
  2826. afterAttributeName: function () {
  2827. var char = this.peek();
  2828. if (isSpace(char)) {
  2829. this.consume();
  2830. return;
  2831. }
  2832. else if (char === '/') {
  2833. this.delegate.beginAttributeValue(false);
  2834. this.delegate.finishAttributeValue();
  2835. this.consume();
  2836. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  2837. }
  2838. else if (char === '=') {
  2839. this.consume();
  2840. this.transitionTo("beforeAttributeValue" /* beforeAttributeValue */);
  2841. }
  2842. else if (char === '>') {
  2843. this.delegate.beginAttributeValue(false);
  2844. this.delegate.finishAttributeValue();
  2845. this.consume();
  2846. this.delegate.finishTag();
  2847. this.transitionTo("beforeData" /* beforeData */);
  2848. }
  2849. else {
  2850. this.delegate.beginAttributeValue(false);
  2851. this.delegate.finishAttributeValue();
  2852. this.transitionTo("attributeName" /* attributeName */);
  2853. this.delegate.beginAttribute();
  2854. this.consume();
  2855. this.delegate.appendToAttributeName(char);
  2856. }
  2857. },
  2858. beforeAttributeValue: function () {
  2859. var char = this.peek();
  2860. if (isSpace(char)) {
  2861. this.consume();
  2862. }
  2863. else if (char === '"') {
  2864. this.transitionTo("attributeValueDoubleQuoted" /* attributeValueDoubleQuoted */);
  2865. this.delegate.beginAttributeValue(true);
  2866. this.consume();
  2867. }
  2868. else if (char === "'") {
  2869. this.transitionTo("attributeValueSingleQuoted" /* attributeValueSingleQuoted */);
  2870. this.delegate.beginAttributeValue(true);
  2871. this.consume();
  2872. }
  2873. else if (char === '>') {
  2874. this.delegate.beginAttributeValue(false);
  2875. this.delegate.finishAttributeValue();
  2876. this.consume();
  2877. this.delegate.finishTag();
  2878. this.transitionTo("beforeData" /* beforeData */);
  2879. }
  2880. else {
  2881. this.transitionTo("attributeValueUnquoted" /* attributeValueUnquoted */);
  2882. this.delegate.beginAttributeValue(false);
  2883. this.consume();
  2884. this.delegate.appendToAttributeValue(char);
  2885. }
  2886. },
  2887. attributeValueDoubleQuoted: function () {
  2888. var char = this.consume();
  2889. if (char === '"') {
  2890. this.delegate.finishAttributeValue();
  2891. this.transitionTo("afterAttributeValueQuoted" /* afterAttributeValueQuoted */);
  2892. }
  2893. else if (char === '&') {
  2894. this.delegate.appendToAttributeValue(this.consumeCharRef() || '&');
  2895. }
  2896. else {
  2897. this.delegate.appendToAttributeValue(char);
  2898. }
  2899. },
  2900. attributeValueSingleQuoted: function () {
  2901. var char = this.consume();
  2902. if (char === "'") {
  2903. this.delegate.finishAttributeValue();
  2904. this.transitionTo("afterAttributeValueQuoted" /* afterAttributeValueQuoted */);
  2905. }
  2906. else if (char === '&') {
  2907. this.delegate.appendToAttributeValue(this.consumeCharRef() || '&');
  2908. }
  2909. else {
  2910. this.delegate.appendToAttributeValue(char);
  2911. }
  2912. },
  2913. attributeValueUnquoted: function () {
  2914. var char = this.peek();
  2915. if (isSpace(char)) {
  2916. this.delegate.finishAttributeValue();
  2917. this.consume();
  2918. this.transitionTo("beforeAttributeName" /* beforeAttributeName */);
  2919. }
  2920. else if (char === '/') {
  2921. this.delegate.finishAttributeValue();
  2922. this.consume();
  2923. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  2924. }
  2925. else if (char === '&') {
  2926. this.consume();
  2927. this.delegate.appendToAttributeValue(this.consumeCharRef() || '&');
  2928. }
  2929. else if (char === '>') {
  2930. this.delegate.finishAttributeValue();
  2931. this.consume();
  2932. this.delegate.finishTag();
  2933. this.transitionTo("beforeData" /* beforeData */);
  2934. }
  2935. else {
  2936. this.consume();
  2937. this.delegate.appendToAttributeValue(char);
  2938. }
  2939. },
  2940. afterAttributeValueQuoted: function () {
  2941. var char = this.peek();
  2942. if (isSpace(char)) {
  2943. this.consume();
  2944. this.transitionTo("beforeAttributeName" /* beforeAttributeName */);
  2945. }
  2946. else if (char === '/') {
  2947. this.consume();
  2948. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  2949. }
  2950. else if (char === '>') {
  2951. this.consume();
  2952. this.delegate.finishTag();
  2953. this.transitionTo("beforeData" /* beforeData */);
  2954. }
  2955. else {
  2956. this.transitionTo("beforeAttributeName" /* beforeAttributeName */);
  2957. }
  2958. },
  2959. selfClosingStartTag: function () {
  2960. var char = this.peek();
  2961. if (char === '>') {
  2962. this.consume();
  2963. this.delegate.markTagAsSelfClosing();
  2964. this.delegate.finishTag();
  2965. this.transitionTo("beforeData" /* beforeData */);
  2966. }
  2967. else {
  2968. this.transitionTo("beforeAttributeName" /* beforeAttributeName */);
  2969. }
  2970. },
  2971. endTagOpen: function () {
  2972. var char = this.consume();
  2973. if (char === '@' || char === ':' || isAlpha(char)) {
  2974. this.transitionTo("endTagName" /* endTagName */);
  2975. this.tagNameBuffer = '';
  2976. this.delegate.beginEndTag();
  2977. this.appendToTagName(char);
  2978. }
  2979. }
  2980. };
  2981. this.reset();
  2982. }
  2983. EventedTokenizer.prototype.reset = function () {
  2984. this.transitionTo("beforeData" /* beforeData */);
  2985. this.input = '';
  2986. this.tagNameBuffer = '';
  2987. this.index = 0;
  2988. this.line = 1;
  2989. this.column = 0;
  2990. this.delegate.reset();
  2991. };
  2992. EventedTokenizer.prototype.transitionTo = function (state) {
  2993. this.state = state;
  2994. };
  2995. EventedTokenizer.prototype.tokenize = function (input) {
  2996. this.reset();
  2997. this.tokenizePart(input);
  2998. this.tokenizeEOF();
  2999. };
  3000. EventedTokenizer.prototype.tokenizePart = function (input) {
  3001. this.input += preprocessInput(input);
  3002. while (this.index < this.input.length) {
  3003. var handler = this.states[this.state];
  3004. if (handler !== undefined) {
  3005. handler.call(this);
  3006. }
  3007. else {
  3008. throw new Error("unhandled state " + this.state);
  3009. }
  3010. }
  3011. };
  3012. EventedTokenizer.prototype.tokenizeEOF = function () {
  3013. this.flushData();
  3014. };
  3015. EventedTokenizer.prototype.flushData = function () {
  3016. if (this.state === 'data') {
  3017. this.delegate.finishData();
  3018. this.transitionTo("beforeData" /* beforeData */);
  3019. }
  3020. };
  3021. EventedTokenizer.prototype.peek = function () {
  3022. return this.input.charAt(this.index);
  3023. };
  3024. EventedTokenizer.prototype.consume = function () {
  3025. var char = this.peek();
  3026. this.index++;
  3027. if (char === '\n') {
  3028. this.line++;
  3029. this.column = 0;
  3030. }
  3031. else {
  3032. this.column++;
  3033. }
  3034. return char;
  3035. };
  3036. EventedTokenizer.prototype.consumeCharRef = function () {
  3037. var endIndex = this.input.indexOf(';', this.index);
  3038. if (endIndex === -1) {
  3039. return;
  3040. }
  3041. var entity = this.input.slice(this.index, endIndex);
  3042. var chars = this.entityParser.parse(entity);
  3043. if (chars) {
  3044. var count = entity.length;
  3045. // consume the entity chars
  3046. while (count) {
  3047. this.consume();
  3048. count--;
  3049. }
  3050. // consume the `;`
  3051. this.consume();
  3052. return chars;
  3053. }
  3054. };
  3055. EventedTokenizer.prototype.markTagStart = function () {
  3056. this.delegate.tagOpen();
  3057. };
  3058. EventedTokenizer.prototype.appendToTagName = function (char) {
  3059. this.tagNameBuffer += char;
  3060. this.delegate.appendToTagName(char);
  3061. };
  3062. EventedTokenizer.prototype.isIgnoredEndTag = function () {
  3063. var tag = this.tagNameBuffer;
  3064. return (tag === 'title' && this.input.substring(this.index, this.index + 8) !== '</title>') ||
  3065. (tag === 'style' && this.input.substring(this.index, this.index + 8) !== '</style>') ||
  3066. (tag === 'script' && this.input.substring(this.index, this.index + 9) !== '</script>');
  3067. };
  3068. return EventedTokenizer;
  3069. }());
  3070. var Tokenizer = /** @class */ (function () {
  3071. function Tokenizer(entityParser, options) {
  3072. if (options === void 0) { options = {}; }
  3073. this.options = options;
  3074. this.token = null;
  3075. this.startLine = 1;
  3076. this.startColumn = 0;
  3077. this.tokens = [];
  3078. this.tokenizer = new EventedTokenizer(this, entityParser, options.mode);
  3079. this._currentAttribute = undefined;
  3080. }
  3081. Tokenizer.prototype.tokenize = function (input) {
  3082. this.tokens = [];
  3083. this.tokenizer.tokenize(input);
  3084. return this.tokens;
  3085. };
  3086. Tokenizer.prototype.tokenizePart = function (input) {
  3087. this.tokens = [];
  3088. this.tokenizer.tokenizePart(input);
  3089. return this.tokens;
  3090. };
  3091. Tokenizer.prototype.tokenizeEOF = function () {
  3092. this.tokens = [];
  3093. this.tokenizer.tokenizeEOF();
  3094. return this.tokens[0];
  3095. };
  3096. Tokenizer.prototype.reset = function () {
  3097. this.token = null;
  3098. this.startLine = 1;
  3099. this.startColumn = 0;
  3100. };
  3101. Tokenizer.prototype.current = function () {
  3102. var token = this.token;
  3103. if (token === null) {
  3104. throw new Error('token was unexpectedly null');
  3105. }
  3106. if (arguments.length === 0) {
  3107. return token;
  3108. }
  3109. for (var i = 0; i < arguments.length; i++) {
  3110. if (token.type === arguments[i]) {
  3111. return token;
  3112. }
  3113. }
  3114. throw new Error("token type was unexpectedly " + token.type);
  3115. };
  3116. Tokenizer.prototype.push = function (token) {
  3117. this.token = token;
  3118. this.tokens.push(token);
  3119. };
  3120. Tokenizer.prototype.currentAttribute = function () {
  3121. return this._currentAttribute;
  3122. };
  3123. Tokenizer.prototype.addLocInfo = function () {
  3124. if (this.options.loc) {
  3125. this.current().loc = {
  3126. start: {
  3127. line: this.startLine,
  3128. column: this.startColumn
  3129. },
  3130. end: {
  3131. line: this.tokenizer.line,
  3132. column: this.tokenizer.column
  3133. }
  3134. };
  3135. }
  3136. this.startLine = this.tokenizer.line;
  3137. this.startColumn = this.tokenizer.column;
  3138. };
  3139. // Data
  3140. Tokenizer.prototype.beginDoctype = function () {
  3141. this.push({
  3142. type: "Doctype" /* Doctype */,
  3143. name: '',
  3144. });
  3145. };
  3146. Tokenizer.prototype.appendToDoctypeName = function (char) {
  3147. this.current("Doctype" /* Doctype */).name += char;
  3148. };
  3149. Tokenizer.prototype.appendToDoctypePublicIdentifier = function (char) {
  3150. var doctype = this.current("Doctype" /* Doctype */);
  3151. if (doctype.publicIdentifier === undefined) {
  3152. doctype.publicIdentifier = char;
  3153. }
  3154. else {
  3155. doctype.publicIdentifier += char;
  3156. }
  3157. };
  3158. Tokenizer.prototype.appendToDoctypeSystemIdentifier = function (char) {
  3159. var doctype = this.current("Doctype" /* Doctype */);
  3160. if (doctype.systemIdentifier === undefined) {
  3161. doctype.systemIdentifier = char;
  3162. }
  3163. else {
  3164. doctype.systemIdentifier += char;
  3165. }
  3166. };
  3167. Tokenizer.prototype.endDoctype = function () {
  3168. this.addLocInfo();
  3169. };
  3170. Tokenizer.prototype.beginData = function () {
  3171. this.push({
  3172. type: "Chars" /* Chars */,
  3173. chars: ''
  3174. });
  3175. };
  3176. Tokenizer.prototype.appendToData = function (char) {
  3177. this.current("Chars" /* Chars */).chars += char;
  3178. };
  3179. Tokenizer.prototype.finishData = function () {
  3180. this.addLocInfo();
  3181. };
  3182. // Comment
  3183. Tokenizer.prototype.beginComment = function () {
  3184. this.push({
  3185. type: "Comment" /* Comment */,
  3186. chars: ''
  3187. });
  3188. };
  3189. Tokenizer.prototype.appendToCommentData = function (char) {
  3190. this.current("Comment" /* Comment */).chars += char;
  3191. };
  3192. Tokenizer.prototype.finishComment = function () {
  3193. this.addLocInfo();
  3194. };
  3195. // Tags - basic
  3196. Tokenizer.prototype.tagOpen = function () { };
  3197. Tokenizer.prototype.beginStartTag = function () {
  3198. this.push({
  3199. type: "StartTag" /* StartTag */,
  3200. tagName: '',
  3201. attributes: [],
  3202. selfClosing: false
  3203. });
  3204. };
  3205. Tokenizer.prototype.beginEndTag = function () {
  3206. this.push({
  3207. type: "EndTag" /* EndTag */,
  3208. tagName: ''
  3209. });
  3210. };
  3211. Tokenizer.prototype.finishTag = function () {
  3212. this.addLocInfo();
  3213. };
  3214. Tokenizer.prototype.markTagAsSelfClosing = function () {
  3215. this.current("StartTag" /* StartTag */).selfClosing = true;
  3216. };
  3217. // Tags - name
  3218. Tokenizer.prototype.appendToTagName = function (char) {
  3219. this.current("StartTag" /* StartTag */, "EndTag" /* EndTag */).tagName += char;
  3220. };
  3221. // Tags - attributes
  3222. Tokenizer.prototype.beginAttribute = function () {
  3223. this._currentAttribute = ['', '', false];
  3224. };
  3225. Tokenizer.prototype.appendToAttributeName = function (char) {
  3226. this.currentAttribute()[0] += char;
  3227. };
  3228. Tokenizer.prototype.beginAttributeValue = function (isQuoted) {
  3229. this.currentAttribute()[2] = isQuoted;
  3230. };
  3231. Tokenizer.prototype.appendToAttributeValue = function (char) {
  3232. this.currentAttribute()[1] += char;
  3233. };
  3234. Tokenizer.prototype.finishAttributeValue = function () {
  3235. this.current("StartTag" /* StartTag */).attributes.push(this._currentAttribute);
  3236. };
  3237. Tokenizer.prototype.reportSyntaxError = function (message) {
  3238. this.current().syntaxError = message;
  3239. };
  3240. return Tokenizer;
  3241. }());
  3242. function tokenize(input, options) {
  3243. var tokenizer = new Tokenizer(new EntityParser(namedCharRefs), options);
  3244. return tokenizer.tokenize(input);
  3245. }
  3246. // EXTERNAL MODULE: external ["wp","htmlEntities"]
  3247. var external_wp_htmlEntities_ = __webpack_require__("rmEH");
  3248. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/validation/logger.js
  3249. function createLogger() {
  3250. /**
  3251. * Creates a log handler with block validation prefix.
  3252. *
  3253. * @param {Function} logger Original logger function.
  3254. *
  3255. * @return {Function} Augmented logger function.
  3256. */
  3257. function createLogHandler(logger) {
  3258. let log = (message, ...args) => logger('Block validation: ' + message, ...args); // In test environments, pre-process string substitutions to improve
  3259. // readability of error messages. We'd prefer to avoid pulling in this
  3260. // dependency in runtime environments, and it can be dropped by a combo
  3261. // of Webpack env substitution + UglifyJS dead code elimination.
  3262. if (false) {}
  3263. return log;
  3264. }
  3265. return {
  3266. // eslint-disable-next-line no-console
  3267. error: createLogHandler(console.error),
  3268. // eslint-disable-next-line no-console
  3269. warning: createLogHandler(console.warn),
  3270. getItems() {
  3271. return [];
  3272. }
  3273. };
  3274. }
  3275. function createQueuedLogger() {
  3276. /**
  3277. * The list of enqueued log actions to print.
  3278. *
  3279. * @type {Array}
  3280. */
  3281. const queue = [];
  3282. const logger = createLogger();
  3283. return {
  3284. error(...args) {
  3285. queue.push({
  3286. log: logger.error,
  3287. args
  3288. });
  3289. },
  3290. warning(...args) {
  3291. queue.push({
  3292. log: logger.warning,
  3293. args
  3294. });
  3295. },
  3296. getItems() {
  3297. return queue;
  3298. }
  3299. };
  3300. }
  3301. // EXTERNAL MODULE: external ["wp","isShallowEqual"]
  3302. var external_wp_isShallowEqual_ = __webpack_require__("rl8x");
  3303. var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_);
  3304. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
  3305. var esm_extends = __webpack_require__("wx14");
  3306. // EXTERNAL MODULE: external ["wp","compose"]
  3307. var external_wp_compose_ = __webpack_require__("K9lf");
  3308. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/block-content-provider/index.js
  3309. /**
  3310. * WordPress dependencies
  3311. */
  3312. /**
  3313. * Internal dependencies
  3314. */
  3315. const {
  3316. Consumer,
  3317. Provider
  3318. } = Object(external_wp_element_["createContext"])(() => {});
  3319. /**
  3320. * An internal block component used in block content serialization to inject
  3321. * nested block content within the `save` implementation of the ancestor
  3322. * component in which it is nested. The component provides a pre-bound
  3323. * `BlockContent` component via context, which is used by the developer-facing
  3324. * `InnerBlocks.Content` component to render block content.
  3325. *
  3326. * @example
  3327. *
  3328. * ```jsx
  3329. * <BlockContentProvider innerBlocks={ innerBlocks }>
  3330. * { blockSaveElement }
  3331. * </BlockContentProvider>
  3332. * ```
  3333. *
  3334. * @param {Object} props Component props.
  3335. * @param {WPElement} props.children Block save result.
  3336. * @param {Array} props.innerBlocks Block(s) to serialize.
  3337. *
  3338. * @return {WPComponent} Element with BlockContent injected via context.
  3339. */
  3340. const BlockContentProvider = ({
  3341. children,
  3342. innerBlocks
  3343. }) => {
  3344. const BlockContent = () => {
  3345. // Value is an array of blocks, so defer to block serializer
  3346. const html = serialize(innerBlocks, {
  3347. isInnerBlocks: true
  3348. }); // Use special-cased raw HTML tag to avoid default escaping
  3349. return Object(external_wp_element_["createElement"])(external_wp_element_["RawHTML"], null, html);
  3350. };
  3351. return Object(external_wp_element_["createElement"])(Provider, {
  3352. value: BlockContent
  3353. }, children);
  3354. };
  3355. /**
  3356. * A Higher Order Component used to inject BlockContent using context to the
  3357. * wrapped component.
  3358. *
  3359. * @return {WPComponent} Enhanced component with injected BlockContent as prop.
  3360. */
  3361. const withBlockContentContext = Object(external_wp_compose_["createHigherOrderComponent"])(OriginalComponent => {
  3362. return props => Object(external_wp_element_["createElement"])(Consumer, null, context => Object(external_wp_element_["createElement"])(OriginalComponent, Object(esm_extends["a" /* default */])({}, props, {
  3363. BlockContent: context
  3364. })));
  3365. }, 'withBlockContentContext');
  3366. /* harmony default export */ var block_content_provider = (BlockContentProvider);
  3367. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/serializer.js
  3368. /**
  3369. * External dependencies
  3370. */
  3371. /**
  3372. * WordPress dependencies
  3373. */
  3374. /**
  3375. * Internal dependencies
  3376. */
  3377. /**
  3378. * @typedef {Object} WPBlockSerializationOptions Serialization Options.
  3379. *
  3380. * @property {boolean} isInnerBlocks Whether we are serializing inner blocks.
  3381. */
  3382. /**
  3383. * Returns the block's default classname from its name.
  3384. *
  3385. * @param {string} blockName The block name.
  3386. *
  3387. * @return {string} The block's default class.
  3388. */
  3389. function getBlockDefaultClassName(blockName) {
  3390. // Generated HTML classes for blocks follow the `wp-block-{name}` nomenclature.
  3391. // Blocks provided by WordPress drop the prefixes 'core/' or 'core-' (historically used in 'core-embed/').
  3392. const className = 'wp-block-' + blockName.replace(/\//, '-').replace(/^core-/, '');
  3393. return Object(external_wp_hooks_["applyFilters"])('blocks.getBlockDefaultClassName', className, blockName);
  3394. }
  3395. /**
  3396. * Returns the block's default menu item classname from its name.
  3397. *
  3398. * @param {string} blockName The block name.
  3399. *
  3400. * @return {string} The block's default menu item class.
  3401. */
  3402. function getBlockMenuDefaultClassName(blockName) {
  3403. // Generated HTML classes for blocks follow the `editor-block-list-item-{name}` nomenclature.
  3404. // Blocks provided by WordPress drop the prefixes 'core/' or 'core-' (historically used in 'core-embed/').
  3405. const className = 'editor-block-list-item-' + blockName.replace(/\//, '-').replace(/^core-/, '');
  3406. return Object(external_wp_hooks_["applyFilters"])('blocks.getBlockMenuDefaultClassName', className, blockName);
  3407. }
  3408. const blockPropsProvider = {};
  3409. /**
  3410. * Call within a save function to get the props for the block wrapper.
  3411. *
  3412. * @param {Object} props Optional. Props to pass to the element.
  3413. */
  3414. function getBlockProps(props = {}) {
  3415. const {
  3416. blockType,
  3417. attributes
  3418. } = blockPropsProvider;
  3419. return Object(external_wp_hooks_["applyFilters"])('blocks.getSaveContent.extraProps', { ...props
  3420. }, blockType, attributes);
  3421. }
  3422. /**
  3423. * Given a block type containing a save render implementation and attributes, returns the
  3424. * enhanced element to be saved or string when raw HTML expected.
  3425. *
  3426. * @param {string|Object} blockTypeOrName Block type or name.
  3427. * @param {Object} attributes Block attributes.
  3428. * @param {?Array} innerBlocks Nested blocks.
  3429. *
  3430. * @return {Object|string} Save element or raw HTML string.
  3431. */
  3432. function getSaveElement(blockTypeOrName, attributes, innerBlocks = []) {
  3433. const blockType = normalizeBlockType(blockTypeOrName);
  3434. let {
  3435. save
  3436. } = blockType; // Component classes are unsupported for save since serialization must
  3437. // occur synchronously. For improved interoperability with higher-order
  3438. // components which often return component class, emulate basic support.
  3439. if (save.prototype instanceof external_wp_element_["Component"]) {
  3440. const instance = new save({
  3441. attributes
  3442. });
  3443. save = instance.render.bind(instance);
  3444. }
  3445. blockPropsProvider.blockType = blockType;
  3446. blockPropsProvider.attributes = attributes;
  3447. let element = save({
  3448. attributes,
  3449. innerBlocks
  3450. });
  3451. const hasLightBlockWrapper = blockType.apiVersion > 1 || registration_hasBlockSupport(blockType, 'lightBlockWrapper', false);
  3452. if (Object(external_lodash_["isObject"])(element) && Object(external_wp_hooks_["hasFilter"])('blocks.getSaveContent.extraProps') && !hasLightBlockWrapper) {
  3453. /**
  3454. * Filters the props applied to the block save result element.
  3455. *
  3456. * @param {Object} props Props applied to save element.
  3457. * @param {WPBlock} blockType Block type definition.
  3458. * @param {Object} attributes Block attributes.
  3459. */
  3460. const props = Object(external_wp_hooks_["applyFilters"])('blocks.getSaveContent.extraProps', { ...element.props
  3461. }, blockType, attributes);
  3462. if (!external_wp_isShallowEqual_default()(props, element.props)) {
  3463. element = Object(external_wp_element_["cloneElement"])(element, props);
  3464. }
  3465. }
  3466. /**
  3467. * Filters the save result of a block during serialization.
  3468. *
  3469. * @param {WPElement} element Block save result.
  3470. * @param {WPBlock} blockType Block type definition.
  3471. * @param {Object} attributes Block attributes.
  3472. */
  3473. element = Object(external_wp_hooks_["applyFilters"])('blocks.getSaveElement', element, blockType, attributes);
  3474. return Object(external_wp_element_["createElement"])(block_content_provider, {
  3475. innerBlocks: innerBlocks
  3476. }, element);
  3477. }
  3478. /**
  3479. * Given a block type containing a save render implementation and attributes, returns the
  3480. * static markup to be saved.
  3481. *
  3482. * @param {string|Object} blockTypeOrName Block type or name.
  3483. * @param {Object} attributes Block attributes.
  3484. * @param {?Array} innerBlocks Nested blocks.
  3485. *
  3486. * @return {string} Save content.
  3487. */
  3488. function getSaveContent(blockTypeOrName, attributes, innerBlocks) {
  3489. const blockType = normalizeBlockType(blockTypeOrName);
  3490. return Object(external_wp_element_["renderToString"])(getSaveElement(blockType, attributes, innerBlocks));
  3491. }
  3492. /**
  3493. * Returns attributes which are to be saved and serialized into the block
  3494. * comment delimiter.
  3495. *
  3496. * When a block exists in memory it contains as its attributes both those
  3497. * parsed the block comment delimiter _and_ those which matched from the
  3498. * contents of the block.
  3499. *
  3500. * This function returns only those attributes which are needed to persist and
  3501. * which cannot be matched from the block content.
  3502. *
  3503. * @param {Object<string,*>} blockType Block type.
  3504. * @param {Object<string,*>} attributes Attributes from in-memory block data.
  3505. *
  3506. * @return {Object<string,*>} Subset of attributes for comment serialization.
  3507. */
  3508. function getCommentAttributes(blockType, attributes) {
  3509. return Object(external_lodash_["reduce"])(blockType.attributes, (accumulator, attributeSchema, key) => {
  3510. const value = attributes[key]; // Ignore undefined values.
  3511. if (undefined === value) {
  3512. return accumulator;
  3513. } // Ignore all attributes but the ones with an "undefined" source
  3514. // "undefined" source refers to attributes saved in the block comment.
  3515. if (attributeSchema.source !== undefined) {
  3516. return accumulator;
  3517. } // Ignore default value.
  3518. if ('default' in attributeSchema && attributeSchema.default === value) {
  3519. return accumulator;
  3520. } // Otherwise, include in comment set.
  3521. accumulator[key] = value;
  3522. return accumulator;
  3523. }, {});
  3524. }
  3525. /**
  3526. * Given an attributes object, returns a string in the serialized attributes
  3527. * format prepared for post content.
  3528. *
  3529. * @param {Object} attributes Attributes object.
  3530. *
  3531. * @return {string} Serialized attributes.
  3532. */
  3533. function serializeAttributes(attributes) {
  3534. return JSON.stringify(attributes) // Don't break HTML comments.
  3535. .replace(/--/g, '\\u002d\\u002d') // Don't break non-standard-compliant tools.
  3536. .replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/&/g, '\\u0026') // Bypass server stripslashes behavior which would unescape stringify's
  3537. // escaping of quotation mark.
  3538. //
  3539. // See: https://developer.wordpress.org/reference/functions/wp_kses_stripslashes/
  3540. .replace(/\\"/g, '\\u0022');
  3541. }
  3542. /**
  3543. * Given a block object, returns the Block's Inner HTML markup.
  3544. *
  3545. * @param {Object} block Block instance.
  3546. *
  3547. * @return {string} HTML.
  3548. */
  3549. function getBlockInnerHTML(block) {
  3550. // If block was parsed as invalid or encounters an error while generating
  3551. // save content, use original content instead to avoid content loss. If a
  3552. // block contains nested content, exempt it from this condition because we
  3553. // otherwise have no access to its original content and content loss would
  3554. // still occur.
  3555. let saveContent = block.originalContent;
  3556. if (block.isValid || block.innerBlocks.length) {
  3557. try {
  3558. saveContent = getSaveContent(block.name, block.attributes, block.innerBlocks);
  3559. } catch (error) {}
  3560. }
  3561. return saveContent;
  3562. }
  3563. /**
  3564. * Returns the content of a block, including comment delimiters.
  3565. *
  3566. * @param {string} rawBlockName Block name.
  3567. * @param {Object} attributes Block attributes.
  3568. * @param {string} content Block save content.
  3569. *
  3570. * @return {string} Comment-delimited block content.
  3571. */
  3572. function getCommentDelimitedContent(rawBlockName, attributes, content) {
  3573. const serializedAttributes = !Object(external_lodash_["isEmpty"])(attributes) ? serializeAttributes(attributes) + ' ' : ''; // Strip core blocks of their namespace prefix.
  3574. const blockName = Object(external_lodash_["startsWith"])(rawBlockName, 'core/') ? rawBlockName.slice(5) : rawBlockName; // @todo make the `wp:` prefix potentially configurable.
  3575. if (!content) {
  3576. return `<!-- wp:${blockName} ${serializedAttributes}/-->`;
  3577. }
  3578. return `<!-- wp:${blockName} ${serializedAttributes}-->\n` + content + `\n<!-- /wp:${blockName} -->`;
  3579. }
  3580. /**
  3581. * Returns the content of a block, including comment delimiters, determining
  3582. * serialized attributes and content form from the current state of the block.
  3583. *
  3584. * @param {Object} block Block instance.
  3585. * @param {WPBlockSerializationOptions} options Serialization options.
  3586. *
  3587. * @return {string} Serialized block.
  3588. */
  3589. function serializeBlock(block, {
  3590. isInnerBlocks = false
  3591. } = {}) {
  3592. const blockName = block.name;
  3593. const saveContent = getBlockInnerHTML(block);
  3594. if (blockName === getUnregisteredTypeHandlerName() || !isInnerBlocks && blockName === getFreeformContentHandlerName()) {
  3595. return saveContent;
  3596. }
  3597. const blockType = registration_getBlockType(blockName);
  3598. const saveAttributes = getCommentAttributes(blockType, block.attributes);
  3599. return getCommentDelimitedContent(blockName, saveAttributes, saveContent);
  3600. }
  3601. function __unstableSerializeAndClean(blocks) {
  3602. // A single unmodified default block is assumed to
  3603. // be equivalent to an empty post.
  3604. if (blocks.length === 1 && isUnmodifiedDefaultBlock(blocks[0])) {
  3605. blocks = [];
  3606. }
  3607. let content = serialize(blocks); // For compatibility, treat a post consisting of a
  3608. // single freeform block as legacy content and apply
  3609. // pre-block-editor removep'd content formatting.
  3610. if (blocks.length === 1 && blocks[0].name === getFreeformContentHandlerName()) {
  3611. content = Object(external_wp_autop_["removep"])(content);
  3612. }
  3613. return content;
  3614. }
  3615. /**
  3616. * Takes a block or set of blocks and returns the serialized post content.
  3617. *
  3618. * @param {Array} blocks Block(s) to serialize.
  3619. * @param {WPBlockSerializationOptions} options Serialization options.
  3620. *
  3621. * @return {string} The post content.
  3622. */
  3623. function serialize(blocks, options) {
  3624. return Object(external_lodash_["castArray"])(blocks).map(block => serializeBlock(block, options)).join('\n\n');
  3625. }
  3626. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/validation/index.js
  3627. /**
  3628. * External dependencies
  3629. */
  3630. /**
  3631. * WordPress dependencies
  3632. */
  3633. /**
  3634. * Internal dependencies
  3635. */
  3636. /**
  3637. * Globally matches any consecutive whitespace
  3638. *
  3639. * @type {RegExp}
  3640. */
  3641. const REGEXP_WHITESPACE = /[\t\n\r\v\f ]+/g;
  3642. /**
  3643. * Matches a string containing only whitespace
  3644. *
  3645. * @type {RegExp}
  3646. */
  3647. const REGEXP_ONLY_WHITESPACE = /^[\t\n\r\v\f ]*$/;
  3648. /**
  3649. * Matches a CSS URL type value
  3650. *
  3651. * @type {RegExp}
  3652. */
  3653. const REGEXP_STYLE_URL_TYPE = /^url\s*\(['"\s]*(.*?)['"\s]*\)$/;
  3654. /**
  3655. * Boolean attributes are attributes whose presence as being assigned is
  3656. * meaningful, even if only empty.
  3657. *
  3658. * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes
  3659. * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
  3660. *
  3661. * Object.keys( Array.from( document.querySelectorAll( '#attributes-1 > tbody > tr' ) )
  3662. * .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 )
  3663. * .reduce( ( result, tr ) => Object.assign( result, {
  3664. * [ tr.firstChild.textContent.trim() ]: true
  3665. * } ), {} ) ).sort();
  3666. *
  3667. * @type {Array}
  3668. */
  3669. const BOOLEAN_ATTRIBUTES = ['allowfullscreen', 'allowpaymentrequest', 'allowusermedia', 'async', 'autofocus', 'autoplay', 'checked', 'controls', 'default', 'defer', 'disabled', 'download', 'formnovalidate', 'hidden', 'ismap', 'itemscope', 'loop', 'multiple', 'muted', 'nomodule', 'novalidate', 'open', 'playsinline', 'readonly', 'required', 'reversed', 'selected', 'typemustmatch'];
  3670. /**
  3671. * Enumerated attributes are attributes which must be of a specific value form.
  3672. * Like boolean attributes, these are meaningful if specified, even if not of a
  3673. * valid enumerated value.
  3674. *
  3675. * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute
  3676. * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
  3677. *
  3678. * Object.keys( Array.from( document.querySelectorAll( '#attributes-1 > tbody > tr' ) )
  3679. * .filter( ( tr ) => /^("(.+?)";?\s*)+/.test( tr.lastChild.textContent.trim() ) )
  3680. * .reduce( ( result, tr ) => Object.assign( result, {
  3681. * [ tr.firstChild.textContent.trim() ]: true
  3682. * } ), {} ) ).sort();
  3683. *
  3684. * @type {Array}
  3685. */
  3686. const ENUMERATED_ATTRIBUTES = ['autocapitalize', 'autocomplete', 'charset', 'contenteditable', 'crossorigin', 'decoding', 'dir', 'draggable', 'enctype', 'formenctype', 'formmethod', 'http-equiv', 'inputmode', 'kind', 'method', 'preload', 'scope', 'shape', 'spellcheck', 'translate', 'type', 'wrap'];
  3687. /**
  3688. * Meaningful attributes are those who cannot be safely ignored when omitted in
  3689. * one HTML markup string and not another.
  3690. *
  3691. * @type {Array}
  3692. */
  3693. const MEANINGFUL_ATTRIBUTES = [...BOOLEAN_ATTRIBUTES, ...ENUMERATED_ATTRIBUTES];
  3694. /**
  3695. * Array of functions which receive a text string on which to apply normalizing
  3696. * behavior for consideration in text token equivalence, carefully ordered from
  3697. * least-to-most expensive operations.
  3698. *
  3699. * @type {Array}
  3700. */
  3701. const TEXT_NORMALIZATIONS = [external_lodash_["identity"], getTextWithCollapsedWhitespace];
  3702. /**
  3703. * Regular expression matching a named character reference. In lieu of bundling
  3704. * a full set of references, the pattern covers the minimal necessary to test
  3705. * positively against the full set.
  3706. *
  3707. * "The ampersand must be followed by one of the names given in the named
  3708. * character references section, using the same case."
  3709. *
  3710. * Tested aginst "12.5 Named character references":
  3711. *
  3712. * ```
  3713. * const references = Array.from( document.querySelectorAll(
  3714. * '#named-character-references-table tr[id^=entity-] td:first-child'
  3715. * ) ).map( ( code ) => code.textContent )
  3716. * references.every( ( reference ) => /^[\da-z]+$/i.test( reference ) )
  3717. * ```
  3718. *
  3719. * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references
  3720. * @see https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references
  3721. *
  3722. * @type {RegExp}
  3723. */
  3724. const REGEXP_NAMED_CHARACTER_REFERENCE = /^[\da-z]+$/i;
  3725. /**
  3726. * Regular expression matching a decimal character reference.
  3727. *
  3728. * "The ampersand must be followed by a U+0023 NUMBER SIGN character (#),
  3729. * followed by one or more ASCII digits, representing a base-ten integer"
  3730. *
  3731. * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references
  3732. *
  3733. * @type {RegExp}
  3734. */
  3735. const REGEXP_DECIMAL_CHARACTER_REFERENCE = /^#\d+$/;
  3736. /**
  3737. * Regular expression matching a hexadecimal character reference.
  3738. *
  3739. * "The ampersand must be followed by a U+0023 NUMBER SIGN character (#), which
  3740. * must be followed by either a U+0078 LATIN SMALL LETTER X character (x) or a
  3741. * U+0058 LATIN CAPITAL LETTER X character (X), which must then be followed by
  3742. * one or more ASCII hex digits, representing a hexadecimal integer"
  3743. *
  3744. * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references
  3745. *
  3746. * @type {RegExp}
  3747. */
  3748. const REGEXP_HEXADECIMAL_CHARACTER_REFERENCE = /^#x[\da-f]+$/i;
  3749. /**
  3750. * Returns true if the given string is a valid character reference segment, or
  3751. * false otherwise. The text should be stripped of `&` and `;` demarcations.
  3752. *
  3753. * @param {string} text Text to test.
  3754. *
  3755. * @return {boolean} Whether text is valid character reference.
  3756. */
  3757. function isValidCharacterReference(text) {
  3758. return REGEXP_NAMED_CHARACTER_REFERENCE.test(text) || REGEXP_DECIMAL_CHARACTER_REFERENCE.test(text) || REGEXP_HEXADECIMAL_CHARACTER_REFERENCE.test(text);
  3759. }
  3760. /**
  3761. * Subsitute EntityParser class for `simple-html-tokenizer` which uses the
  3762. * implementation of `decodeEntities` from `html-entities`, in order to avoid
  3763. * bundling a massive named character reference.
  3764. *
  3765. * @see https://github.com/tildeio/simple-html-tokenizer/tree/HEAD/src/entity-parser.ts
  3766. */
  3767. class validation_DecodeEntityParser {
  3768. /**
  3769. * Returns a substitute string for an entity string sequence between `&`
  3770. * and `;`, or undefined if no substitution should occur.
  3771. *
  3772. * @param {string} entity Entity fragment discovered in HTML.
  3773. *
  3774. * @return {?string} Entity substitute value.
  3775. */
  3776. parse(entity) {
  3777. if (isValidCharacterReference(entity)) {
  3778. return Object(external_wp_htmlEntities_["decodeEntities"])('&' + entity + ';');
  3779. }
  3780. }
  3781. }
  3782. /**
  3783. * Given a specified string, returns an array of strings split by consecutive
  3784. * whitespace, ignoring leading or trailing whitespace.
  3785. *
  3786. * @param {string} text Original text.
  3787. *
  3788. * @return {string[]} Text pieces split on whitespace.
  3789. */
  3790. function getTextPiecesSplitOnWhitespace(text) {
  3791. return text.trim().split(REGEXP_WHITESPACE);
  3792. }
  3793. /**
  3794. * Given a specified string, returns a new trimmed string where all consecutive
  3795. * whitespace is collapsed to a single space.
  3796. *
  3797. * @param {string} text Original text.
  3798. *
  3799. * @return {string} Trimmed text with consecutive whitespace collapsed.
  3800. */
  3801. function getTextWithCollapsedWhitespace(text) {
  3802. // This is an overly simplified whitespace comparison. The specification is
  3803. // more prescriptive of whitespace behavior in inline and block contexts.
  3804. //
  3805. // See: https://medium.com/@patrickbrosset/when-does-white-space-matter-in-html-b90e8a7cdd33
  3806. return getTextPiecesSplitOnWhitespace(text).join(' ');
  3807. }
  3808. /**
  3809. * Returns attribute pairs of the given StartTag token, including only pairs
  3810. * where the value is non-empty or the attribute is a boolean attribute, an
  3811. * enumerated attribute, or a custom data- attribute.
  3812. *
  3813. * @see MEANINGFUL_ATTRIBUTES
  3814. *
  3815. * @param {Object} token StartTag token.
  3816. *
  3817. * @return {Array[]} Attribute pairs.
  3818. */
  3819. function getMeaningfulAttributePairs(token) {
  3820. return token.attributes.filter(pair => {
  3821. const [key, value] = pair;
  3822. return value || key.indexOf('data-') === 0 || Object(external_lodash_["includes"])(MEANINGFUL_ATTRIBUTES, key);
  3823. });
  3824. }
  3825. /**
  3826. * Returns true if two text tokens (with `chars` property) are equivalent, or
  3827. * false otherwise.
  3828. *
  3829. * @param {Object} actual Actual token.
  3830. * @param {Object} expected Expected token.
  3831. * @param {Object} logger Validation logger object.
  3832. *
  3833. * @return {boolean} Whether two text tokens are equivalent.
  3834. */
  3835. function isEquivalentTextTokens(actual, expected, logger = createLogger()) {
  3836. // This function is intentionally written as syntactically "ugly" as a hot
  3837. // path optimization. Text is progressively normalized in order from least-
  3838. // to-most operationally expensive, until the earliest point at which text
  3839. // can be confidently inferred as being equal.
  3840. let actualChars = actual.chars;
  3841. let expectedChars = expected.chars;
  3842. for (let i = 0; i < TEXT_NORMALIZATIONS.length; i++) {
  3843. const normalize = TEXT_NORMALIZATIONS[i];
  3844. actualChars = normalize(actualChars);
  3845. expectedChars = normalize(expectedChars);
  3846. if (actualChars === expectedChars) {
  3847. return true;
  3848. }
  3849. }
  3850. logger.warning('Expected text `%s`, saw `%s`.', expected.chars, actual.chars);
  3851. return false;
  3852. }
  3853. /**
  3854. * Given a CSS length value, returns a normalized CSS length value for strict equality
  3855. * comparison.
  3856. *
  3857. * @param {string} value CSS length value.
  3858. *
  3859. * @return {string} Normalized CSS length value.
  3860. */
  3861. function getNormalizedLength(value) {
  3862. return 0 === parseFloat(value) ? '0' : value;
  3863. }
  3864. /**
  3865. * Given a style value, returns a normalized style value for strict equality
  3866. * comparison.
  3867. *
  3868. * @param {string} value Style value.
  3869. *
  3870. * @return {string} Normalized style value.
  3871. */
  3872. function getNormalizedStyleValue(value) {
  3873. const textPieces = getTextPiecesSplitOnWhitespace(value);
  3874. const normalizedPieces = textPieces.map(getNormalizedLength);
  3875. const result = normalizedPieces.join(' ');
  3876. return result // Normalize URL type to omit whitespace or quotes
  3877. .replace(REGEXP_STYLE_URL_TYPE, 'url($1)');
  3878. }
  3879. /**
  3880. * Given a style attribute string, returns an object of style properties.
  3881. *
  3882. * @param {string} text Style attribute.
  3883. *
  3884. * @return {Object} Style properties.
  3885. */
  3886. function getStyleProperties(text) {
  3887. const pairs = text // Trim ending semicolon (avoid including in split)
  3888. .replace(/;?\s*$/, '') // Split on property assignment
  3889. .split(';') // For each property assignment...
  3890. .map(style => {
  3891. // ...split further into key-value pairs
  3892. const [key, ...valueParts] = style.split(':');
  3893. const value = valueParts.join(':');
  3894. return [key.trim(), getNormalizedStyleValue(value.trim())];
  3895. });
  3896. return Object(external_lodash_["fromPairs"])(pairs);
  3897. }
  3898. /**
  3899. * Attribute-specific equality handlers
  3900. *
  3901. * @type {Object}
  3902. */
  3903. const isEqualAttributesOfName = {
  3904. class: (actual, expected) => {
  3905. // Class matches if members are the same, even if out of order or
  3906. // superfluous whitespace between.
  3907. return !Object(external_lodash_["xor"])(...[actual, expected].map(getTextPiecesSplitOnWhitespace)).length;
  3908. },
  3909. style: (actual, expected) => {
  3910. return Object(external_lodash_["isEqual"])(...[actual, expected].map(getStyleProperties));
  3911. },
  3912. // For each boolean attribute, mere presence of attribute in both is enough
  3913. // to assume equivalence.
  3914. ...Object(external_lodash_["fromPairs"])(BOOLEAN_ATTRIBUTES.map(attribute => [attribute, external_lodash_["stubTrue"]]))
  3915. };
  3916. /**
  3917. * Given two sets of attribute tuples, returns true if the attribute sets are
  3918. * equivalent.
  3919. *
  3920. * @param {Array[]} actual Actual attributes tuples.
  3921. * @param {Array[]} expected Expected attributes tuples.
  3922. * @param {Object} logger Validation logger object.
  3923. *
  3924. * @return {boolean} Whether attributes are equivalent.
  3925. */
  3926. function isEqualTagAttributePairs(actual, expected, logger = createLogger()) {
  3927. // Attributes is tokenized as tuples. Their lengths should match. This also
  3928. // avoids us needing to check both attributes sets, since if A has any keys
  3929. // which do not exist in B, we know the sets to be different.
  3930. if (actual.length !== expected.length) {
  3931. logger.warning('Expected attributes %o, instead saw %o.', expected, actual);
  3932. return false;
  3933. } // Attributes are not guaranteed to occur in the same order. For validating
  3934. // actual attributes, first convert the set of expected attribute values to
  3935. // an object, for lookup by key.
  3936. const expectedAttributes = {};
  3937. for (let i = 0; i < expected.length; i++) {
  3938. expectedAttributes[expected[i][0].toLowerCase()] = expected[i][1];
  3939. }
  3940. for (let i = 0; i < actual.length; i++) {
  3941. const [name, actualValue] = actual[i];
  3942. const nameLower = name.toLowerCase(); // As noted above, if missing member in B, assume different
  3943. if (!expectedAttributes.hasOwnProperty(nameLower)) {
  3944. logger.warning('Encountered unexpected attribute `%s`.', name);
  3945. return false;
  3946. }
  3947. const expectedValue = expectedAttributes[nameLower];
  3948. const isEqualAttributes = isEqualAttributesOfName[nameLower];
  3949. if (isEqualAttributes) {
  3950. // Defer custom attribute equality handling
  3951. if (!isEqualAttributes(actualValue, expectedValue)) {
  3952. logger.warning('Expected attribute `%s` of value `%s`, saw `%s`.', name, expectedValue, actualValue);
  3953. return false;
  3954. }
  3955. } else if (actualValue !== expectedValue) {
  3956. // Otherwise strict inequality should bail
  3957. logger.warning('Expected attribute `%s` of value `%s`, saw `%s`.', name, expectedValue, actualValue);
  3958. return false;
  3959. }
  3960. }
  3961. return true;
  3962. }
  3963. /**
  3964. * Token-type-specific equality handlers
  3965. *
  3966. * @type {Object}
  3967. */
  3968. const isEqualTokensOfType = {
  3969. StartTag: (actual, expected, logger = createLogger()) => {
  3970. if (actual.tagName !== expected.tagName && // Optimization: Use short-circuit evaluation to defer case-
  3971. // insensitive check on the assumption that the majority case will
  3972. // have exactly equal tag names.
  3973. actual.tagName.toLowerCase() !== expected.tagName.toLowerCase()) {
  3974. logger.warning('Expected tag name `%s`, instead saw `%s`.', expected.tagName, actual.tagName);
  3975. return false;
  3976. }
  3977. return isEqualTagAttributePairs(...[actual, expected].map(getMeaningfulAttributePairs), logger);
  3978. },
  3979. Chars: isEquivalentTextTokens,
  3980. Comment: isEquivalentTextTokens
  3981. };
  3982. /**
  3983. * Given an array of tokens, returns the first token which is not purely
  3984. * whitespace.
  3985. *
  3986. * Mutates the tokens array.
  3987. *
  3988. * @param {Object[]} tokens Set of tokens to search.
  3989. *
  3990. * @return {Object} Next non-whitespace token.
  3991. */
  3992. function getNextNonWhitespaceToken(tokens) {
  3993. let token;
  3994. while (token = tokens.shift()) {
  3995. if (token.type !== 'Chars') {
  3996. return token;
  3997. }
  3998. if (!REGEXP_ONLY_WHITESPACE.test(token.chars)) {
  3999. return token;
  4000. }
  4001. }
  4002. }
  4003. /**
  4004. * Tokenize an HTML string, gracefully handling any errors thrown during
  4005. * underlying tokenization.
  4006. *
  4007. * @param {string} html HTML string to tokenize.
  4008. * @param {Object} logger Validation logger object.
  4009. *
  4010. * @return {Object[]|null} Array of valid tokenized HTML elements, or null on error
  4011. */
  4012. function getHTMLTokens(html, logger = createLogger()) {
  4013. try {
  4014. return new Tokenizer(new validation_DecodeEntityParser()).tokenize(html);
  4015. } catch (e) {
  4016. logger.warning('Malformed HTML detected: %s', html);
  4017. }
  4018. return null;
  4019. }
  4020. /**
  4021. * Returns true if the next HTML token closes the current token.
  4022. *
  4023. * @param {Object} currentToken Current token to compare with.
  4024. * @param {Object|undefined} nextToken Next token to compare against.
  4025. *
  4026. * @return {boolean} true if `nextToken` closes `currentToken`, false otherwise
  4027. */
  4028. function isClosedByToken(currentToken, nextToken) {
  4029. // Ensure this is a self closed token
  4030. if (!currentToken.selfClosing) {
  4031. return false;
  4032. } // Check token names and determine if nextToken is the closing tag for currentToken
  4033. if (nextToken && nextToken.tagName === currentToken.tagName && nextToken.type === 'EndTag') {
  4034. return true;
  4035. }
  4036. return false;
  4037. }
  4038. /**
  4039. * Returns true if the given HTML strings are effectively equivalent, or
  4040. * false otherwise. Invalid HTML is not considered equivalent, even if the
  4041. * strings directly match.
  4042. *
  4043. * @param {string} actual Actual HTML string.
  4044. * @param {string} expected Expected HTML string.
  4045. * @param {Object} logger Validation logger object.
  4046. *
  4047. * @return {boolean} Whether HTML strings are equivalent.
  4048. */
  4049. function isEquivalentHTML(actual, expected, logger = createLogger()) {
  4050. // Short-circuit if markup is identical.
  4051. if (actual === expected) {
  4052. return true;
  4053. } // Tokenize input content and reserialized save content
  4054. const [actualTokens, expectedTokens] = [actual, expected].map(html => getHTMLTokens(html, logger)); // If either is malformed then stop comparing - the strings are not equivalent
  4055. if (!actualTokens || !expectedTokens) {
  4056. return false;
  4057. }
  4058. let actualToken, expectedToken;
  4059. while (actualToken = getNextNonWhitespaceToken(actualTokens)) {
  4060. expectedToken = getNextNonWhitespaceToken(expectedTokens); // Inequal if exhausted all expected tokens
  4061. if (!expectedToken) {
  4062. logger.warning('Expected end of content, instead saw %o.', actualToken);
  4063. return false;
  4064. } // Inequal if next non-whitespace token of each set are not same type
  4065. if (actualToken.type !== expectedToken.type) {
  4066. logger.warning('Expected token of type `%s` (%o), instead saw `%s` (%o).', expectedToken.type, expectedToken, actualToken.type, actualToken);
  4067. return false;
  4068. } // Defer custom token type equality handling, otherwise continue and
  4069. // assume as equal
  4070. const isEqualTokens = isEqualTokensOfType[actualToken.type];
  4071. if (isEqualTokens && !isEqualTokens(actualToken, expectedToken, logger)) {
  4072. return false;
  4073. } // Peek at the next tokens (actual and expected) to see if they close
  4074. // a self-closing tag
  4075. if (isClosedByToken(actualToken, expectedTokens[0])) {
  4076. // Consume the next expected token that closes the current actual
  4077. // self-closing token
  4078. getNextNonWhitespaceToken(expectedTokens);
  4079. } else if (isClosedByToken(expectedToken, actualTokens[0])) {
  4080. // Consume the next actual token that closes the current expected
  4081. // self-closing token
  4082. getNextNonWhitespaceToken(actualTokens);
  4083. }
  4084. }
  4085. if (expectedToken = getNextNonWhitespaceToken(expectedTokens)) {
  4086. // If any non-whitespace tokens remain in expected token set, this
  4087. // indicates inequality
  4088. logger.warning('Expected %o, instead saw end of content.', expectedToken);
  4089. return false;
  4090. }
  4091. return true;
  4092. }
  4093. /**
  4094. * Returns an object with `isValid` property set to `true` if the parsed block
  4095. * is valid given the input content. A block is considered valid if, when serialized
  4096. * with assumed attributes, the content matches the original value. If block is
  4097. * invalid, this function returns all validations issues as well.
  4098. *
  4099. * @param {string|Object} blockTypeOrName Block type.
  4100. * @param {Object} attributes Parsed block attributes.
  4101. * @param {string} originalBlockContent Original block content.
  4102. * @param {Object} logger Validation logger object.
  4103. *
  4104. * @return {Object} Whether block is valid and contains validation messages.
  4105. */
  4106. function getBlockContentValidationResult(blockTypeOrName, attributes, originalBlockContent, logger = createQueuedLogger()) {
  4107. const blockType = normalizeBlockType(blockTypeOrName);
  4108. let generatedBlockContent;
  4109. try {
  4110. generatedBlockContent = getSaveContent(blockType, attributes);
  4111. } catch (error) {
  4112. logger.error('Block validation failed because an error occurred while generating block content:\n\n%s', error.toString());
  4113. return {
  4114. isValid: false,
  4115. validationIssues: logger.getItems()
  4116. };
  4117. }
  4118. const isValid = isEquivalentHTML(originalBlockContent, generatedBlockContent, logger);
  4119. if (!isValid) {
  4120. logger.error('Block validation failed for `%s` (%o).\n\nContent generated by `save` function:\n\n%s\n\nContent retrieved from post body:\n\n%s', blockType.name, blockType, generatedBlockContent, originalBlockContent);
  4121. }
  4122. return {
  4123. isValid,
  4124. validationIssues: logger.getItems()
  4125. };
  4126. }
  4127. /**
  4128. * Returns true if the parsed block is valid given the input content. A block
  4129. * is considered valid if, when serialized with assumed attributes, the content
  4130. * matches the original value.
  4131. *
  4132. * Logs to console in development environments when invalid.
  4133. *
  4134. * @param {string|Object} blockTypeOrName Block type.
  4135. * @param {Object} attributes Parsed block attributes.
  4136. * @param {string} originalBlockContent Original block content.
  4137. *
  4138. * @return {boolean} Whether block is valid.
  4139. */
  4140. function isValidBlockContent(blockTypeOrName, attributes, originalBlockContent) {
  4141. const {
  4142. isValid
  4143. } = getBlockContentValidationResult(blockTypeOrName, attributes, originalBlockContent, createLogger());
  4144. return isValid;
  4145. }
  4146. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/matchers.js
  4147. /**
  4148. * External dependencies
  4149. */
  4150. /**
  4151. * Internal dependencies
  4152. */
  4153. function matchers_html(selector, multilineTag) {
  4154. return domNode => {
  4155. let match = domNode;
  4156. if (selector) {
  4157. match = domNode.querySelector(selector);
  4158. }
  4159. if (!match) {
  4160. return '';
  4161. }
  4162. if (multilineTag) {
  4163. let value = '';
  4164. const length = match.children.length;
  4165. for (let index = 0; index < length; index++) {
  4166. const child = match.children[index];
  4167. if (child.nodeName.toLowerCase() !== multilineTag) {
  4168. continue;
  4169. }
  4170. value += child.outerHTML;
  4171. }
  4172. return value;
  4173. }
  4174. return match.innerHTML;
  4175. };
  4176. }
  4177. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/node.js
  4178. /**
  4179. * Internal dependencies
  4180. */
  4181. /**
  4182. * A representation of a single node within a block's rich text value. If
  4183. * representing a text node, the value is simply a string of the node value.
  4184. * As representing an element node, it is an object of:
  4185. *
  4186. * 1. `type` (string): Tag name.
  4187. * 2. `props` (object): Attributes and children array of WPBlockNode.
  4188. *
  4189. * @typedef {string|Object} WPBlockNode
  4190. */
  4191. /**
  4192. * Given a single node and a node type (e.g. `'br'`), returns true if the node
  4193. * corresponds to that type, false otherwise.
  4194. *
  4195. * @param {WPBlockNode} node Block node to test
  4196. * @param {string} type Node to type to test against.
  4197. *
  4198. * @return {boolean} Whether node is of intended type.
  4199. */
  4200. function isNodeOfType(node, type) {
  4201. return node && node.type === type;
  4202. }
  4203. /**
  4204. * Given an object implementing the NamedNodeMap interface, returns a plain
  4205. * object equivalent value of name, value key-value pairs.
  4206. *
  4207. * @see https://dom.spec.whatwg.org/#interface-namednodemap
  4208. *
  4209. * @param {NamedNodeMap} nodeMap NamedNodeMap to convert to object.
  4210. *
  4211. * @return {Object} Object equivalent value of NamedNodeMap.
  4212. */
  4213. function getNamedNodeMapAsObject(nodeMap) {
  4214. const result = {};
  4215. for (let i = 0; i < nodeMap.length; i++) {
  4216. const {
  4217. name,
  4218. value
  4219. } = nodeMap[i];
  4220. result[name] = value;
  4221. }
  4222. return result;
  4223. }
  4224. /**
  4225. * Given a DOM Element or Text node, returns an equivalent block node. Throws
  4226. * if passed any node type other than element or text.
  4227. *
  4228. * @throws {TypeError} If non-element/text node is passed.
  4229. *
  4230. * @param {Node} domNode DOM node to convert.
  4231. *
  4232. * @return {WPBlockNode} Block node equivalent to DOM node.
  4233. */
  4234. function fromDOM(domNode) {
  4235. if (domNode.nodeType === domNode.TEXT_NODE) {
  4236. return domNode.nodeValue;
  4237. }
  4238. if (domNode.nodeType !== domNode.ELEMENT_NODE) {
  4239. throw new TypeError('A block node can only be created from a node of type text or ' + 'element.');
  4240. }
  4241. return {
  4242. type: domNode.nodeName.toLowerCase(),
  4243. props: { ...getNamedNodeMapAsObject(domNode.attributes),
  4244. children: children_fromDOM(domNode.childNodes)
  4245. }
  4246. };
  4247. }
  4248. /**
  4249. * Given a block node, returns its HTML string representation.
  4250. *
  4251. * @param {WPBlockNode} node Block node to convert to string.
  4252. *
  4253. * @return {string} String HTML representation of block node.
  4254. */
  4255. function toHTML(node) {
  4256. return children_toHTML([node]);
  4257. }
  4258. /**
  4259. * Given a selector, returns an hpq matcher generating a WPBlockNode value
  4260. * matching the selector result.
  4261. *
  4262. * @param {string} selector DOM selector.
  4263. *
  4264. * @return {Function} hpq matcher.
  4265. */
  4266. function node_matcher(selector) {
  4267. return domNode => {
  4268. let match = domNode;
  4269. if (selector) {
  4270. match = domNode.querySelector(selector);
  4271. }
  4272. try {
  4273. return fromDOM(match);
  4274. } catch (error) {
  4275. return null;
  4276. }
  4277. };
  4278. }
  4279. /**
  4280. * Object of utility functions used in managing block attribute values of
  4281. * source `node`.
  4282. *
  4283. * @see https://github.com/WordPress/gutenberg/pull/10439
  4284. *
  4285. * @deprecated since 4.0. The `node` source should not be used, and can be
  4286. * replaced by the `html` source.
  4287. *
  4288. * @private
  4289. */
  4290. /* harmony default export */ var api_node = ({
  4291. isNodeOfType,
  4292. fromDOM,
  4293. toHTML,
  4294. matcher: node_matcher
  4295. });
  4296. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/children.js
  4297. /**
  4298. * External dependencies
  4299. */
  4300. /**
  4301. * WordPress dependencies
  4302. */
  4303. /**
  4304. * Internal dependencies
  4305. */
  4306. /**
  4307. * A representation of a block's rich text value.
  4308. *
  4309. * @typedef {WPBlockNode[]} WPBlockChildren
  4310. */
  4311. /**
  4312. * Given block children, returns a serialize-capable WordPress element.
  4313. *
  4314. * @param {WPBlockChildren} children Block children object to convert.
  4315. *
  4316. * @return {WPElement} A serialize-capable element.
  4317. */
  4318. function getSerializeCapableElement(children) {
  4319. // The fact that block children are compatible with the element serializer is
  4320. // merely an implementation detail that currently serves to be true, but
  4321. // should not be mistaken as being a guarantee on the external API. The
  4322. // public API only offers guarantees to work with strings (toHTML) and DOM
  4323. // elements (fromDOM), and should provide utilities to manipulate the value
  4324. // rather than expect consumers to inspect or construct its shape (concat).
  4325. return children;
  4326. }
  4327. /**
  4328. * Given block children, returns an array of block nodes.
  4329. *
  4330. * @param {WPBlockChildren} children Block children object to convert.
  4331. *
  4332. * @return {Array<WPBlockNode>} An array of individual block nodes.
  4333. */
  4334. function getChildrenArray(children) {
  4335. // The fact that block children are compatible with the element serializer
  4336. // is merely an implementation detail that currently serves to be true, but
  4337. // should not be mistaken as being a guarantee on the external API.
  4338. return children;
  4339. }
  4340. /**
  4341. * Given two or more block nodes, returns a new block node representing a
  4342. * concatenation of its values.
  4343. *
  4344. * @param {...WPBlockChildren} blockNodes Block nodes to concatenate.
  4345. *
  4346. * @return {WPBlockChildren} Concatenated block node.
  4347. */
  4348. function concat(...blockNodes) {
  4349. const result = [];
  4350. for (let i = 0; i < blockNodes.length; i++) {
  4351. const blockNode = Object(external_lodash_["castArray"])(blockNodes[i]);
  4352. for (let j = 0; j < blockNode.length; j++) {
  4353. const child = blockNode[j];
  4354. const canConcatToPreviousString = typeof child === 'string' && typeof result[result.length - 1] === 'string';
  4355. if (canConcatToPreviousString) {
  4356. result[result.length - 1] += child;
  4357. } else {
  4358. result.push(child);
  4359. }
  4360. }
  4361. }
  4362. return result;
  4363. }
  4364. /**
  4365. * Given an iterable set of DOM nodes, returns equivalent block children.
  4366. * Ignores any non-element/text nodes included in set.
  4367. *
  4368. * @param {Iterable.<Node>} domNodes Iterable set of DOM nodes to convert.
  4369. *
  4370. * @return {WPBlockChildren} Block children equivalent to DOM nodes.
  4371. */
  4372. function children_fromDOM(domNodes) {
  4373. const result = [];
  4374. for (let i = 0; i < domNodes.length; i++) {
  4375. try {
  4376. result.push(fromDOM(domNodes[i]));
  4377. } catch (error) {// Simply ignore if DOM node could not be converted.
  4378. }
  4379. }
  4380. return result;
  4381. }
  4382. /**
  4383. * Given a block node, returns its HTML string representation.
  4384. *
  4385. * @param {WPBlockChildren} children Block node(s) to convert to string.
  4386. *
  4387. * @return {string} String HTML representation of block node.
  4388. */
  4389. function children_toHTML(children) {
  4390. const element = getSerializeCapableElement(children);
  4391. return Object(external_wp_element_["renderToString"])(element);
  4392. }
  4393. /**
  4394. * Given a selector, returns an hpq matcher generating a WPBlockChildren value
  4395. * matching the selector result.
  4396. *
  4397. * @param {string} selector DOM selector.
  4398. *
  4399. * @return {Function} hpq matcher.
  4400. */
  4401. function children_matcher(selector) {
  4402. return domNode => {
  4403. let match = domNode;
  4404. if (selector) {
  4405. match = domNode.querySelector(selector);
  4406. }
  4407. if (match) {
  4408. return children_fromDOM(match.childNodes);
  4409. }
  4410. return [];
  4411. };
  4412. }
  4413. /**
  4414. * Object of utility functions used in managing block attribute values of
  4415. * source `children`.
  4416. *
  4417. * @see https://github.com/WordPress/gutenberg/pull/10439
  4418. *
  4419. * @deprecated since 4.0. The `children` source should not be used, and can be
  4420. * replaced by the `html` source.
  4421. *
  4422. * @private
  4423. */
  4424. /* harmony default export */ var api_children = ({
  4425. concat,
  4426. getChildrenArray,
  4427. fromDOM: children_fromDOM,
  4428. toHTML: children_toHTML,
  4429. matcher: children_matcher
  4430. });
  4431. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser.js
  4432. /**
  4433. * External dependencies
  4434. */
  4435. /**
  4436. * WordPress dependencies
  4437. */
  4438. /**
  4439. * Internal dependencies
  4440. */
  4441. /**
  4442. * Sources which are guaranteed to return a string value.
  4443. *
  4444. * @type {Set}
  4445. */
  4446. const STRING_SOURCES = new Set(['attribute', 'html', 'text', 'tag']);
  4447. /**
  4448. * Higher-order hpq matcher which enhances an attribute matcher to return true
  4449. * or false depending on whether the original matcher returns undefined. This
  4450. * is useful for boolean attributes (e.g. disabled) whose attribute values may
  4451. * be technically falsey (empty string), though their mere presence should be
  4452. * enough to infer as true.
  4453. *
  4454. * @param {Function} matcher Original hpq matcher.
  4455. *
  4456. * @return {Function} Enhanced hpq matcher.
  4457. */
  4458. const toBooleanAttributeMatcher = matcher => Object(external_lodash_["flow"])([matcher, // Expected values from `attr( 'disabled' )`:
  4459. //
  4460. // <input>
  4461. // - Value: `undefined`
  4462. // - Transformed: `false`
  4463. //
  4464. // <input disabled>
  4465. // - Value: `''`
  4466. // - Transformed: `true`
  4467. //
  4468. // <input disabled="disabled">
  4469. // - Value: `'disabled'`
  4470. // - Transformed: `true`
  4471. value => value !== undefined]);
  4472. /**
  4473. * Returns true if value is of the given JSON schema type, or false otherwise.
  4474. *
  4475. * @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25
  4476. *
  4477. * @param {*} value Value to test.
  4478. * @param {string} type Type to test.
  4479. *
  4480. * @return {boolean} Whether value is of type.
  4481. */
  4482. function isOfType(value, type) {
  4483. switch (type) {
  4484. case 'string':
  4485. return typeof value === 'string';
  4486. case 'boolean':
  4487. return typeof value === 'boolean';
  4488. case 'object':
  4489. return !!value && value.constructor === Object;
  4490. case 'null':
  4491. return value === null;
  4492. case 'array':
  4493. return Array.isArray(value);
  4494. case 'integer':
  4495. case 'number':
  4496. return typeof value === 'number';
  4497. }
  4498. return true;
  4499. }
  4500. /**
  4501. * Returns true if value is of an array of given JSON schema types, or false
  4502. * otherwise.
  4503. *
  4504. * @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25
  4505. *
  4506. * @param {*} value Value to test.
  4507. * @param {string[]} types Types to test.
  4508. *
  4509. * @return {boolean} Whether value is of types.
  4510. */
  4511. function isOfTypes(value, types) {
  4512. return types.some(type => isOfType(value, type));
  4513. }
  4514. /**
  4515. * Returns true if value is valid per the given block attribute schema type
  4516. * definition, or false otherwise.
  4517. *
  4518. * @see https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.1
  4519. *
  4520. * @param {*} value Value to test.
  4521. * @param {?(Array<string>|string)} type Block attribute schema type.
  4522. *
  4523. * @return {boolean} Whether value is valid.
  4524. */
  4525. function isValidByType(value, type) {
  4526. return type === undefined || isOfTypes(value, Object(external_lodash_["castArray"])(type));
  4527. }
  4528. /**
  4529. * Returns true if value is valid per the given block attribute schema enum
  4530. * definition, or false otherwise.
  4531. *
  4532. * @see https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.2
  4533. *
  4534. * @param {*} value Value to test.
  4535. * @param {?Array} enumSet Block attribute schema enum.
  4536. *
  4537. * @return {boolean} Whether value is valid.
  4538. */
  4539. function isValidByEnum(value, enumSet) {
  4540. return !Array.isArray(enumSet) || enumSet.includes(value);
  4541. }
  4542. /**
  4543. * Returns true if the given attribute schema describes a value which may be
  4544. * an ambiguous string.
  4545. *
  4546. * Some sources are ambiguously serialized as strings, for which value casting
  4547. * is enabled. This is only possible when a singular type is assigned to the
  4548. * attribute schema, since the string ambiguity makes it impossible to know the
  4549. * correct type of multiple to which to cast.
  4550. *
  4551. * @param {Object} attributeSchema Attribute's schema.
  4552. *
  4553. * @return {boolean} Whether attribute schema defines an ambiguous string
  4554. * source.
  4555. */
  4556. function isAmbiguousStringSource(attributeSchema) {
  4557. const {
  4558. source,
  4559. type
  4560. } = attributeSchema;
  4561. const isStringSource = STRING_SOURCES.has(source);
  4562. const isSingleType = typeof type === 'string';
  4563. return isStringSource && isSingleType;
  4564. }
  4565. /**
  4566. * Returns an hpq matcher given a source object.
  4567. *
  4568. * @param {Object} sourceConfig Attribute Source object.
  4569. *
  4570. * @return {Function} A hpq Matcher.
  4571. */
  4572. function matcherFromSource(sourceConfig) {
  4573. switch (sourceConfig.source) {
  4574. case 'attribute':
  4575. let matcher = attr(sourceConfig.selector, sourceConfig.attribute);
  4576. if (sourceConfig.type === 'boolean') {
  4577. matcher = toBooleanAttributeMatcher(matcher);
  4578. }
  4579. return matcher;
  4580. case 'html':
  4581. return matchers_html(sourceConfig.selector, sourceConfig.multiline);
  4582. case 'text':
  4583. return es_text(sourceConfig.selector);
  4584. case 'children':
  4585. return children_matcher(sourceConfig.selector);
  4586. case 'node':
  4587. return node_matcher(sourceConfig.selector);
  4588. case 'query':
  4589. const subMatchers = Object(external_lodash_["mapValues"])(sourceConfig.query, matcherFromSource);
  4590. return query(sourceConfig.selector, subMatchers);
  4591. case 'tag':
  4592. return Object(external_lodash_["flow"])([prop(sourceConfig.selector, 'nodeName'), nodeName => nodeName ? nodeName.toLowerCase() : undefined]);
  4593. default:
  4594. // eslint-disable-next-line no-console
  4595. console.error(`Unknown source type "${sourceConfig.source}"`);
  4596. }
  4597. }
  4598. /**
  4599. * Given a block's raw content and an attribute's schema returns the attribute's
  4600. * value depending on its source.
  4601. *
  4602. * @param {string} innerHTML Block's raw content.
  4603. * @param {Object} attributeSchema Attribute's schema.
  4604. *
  4605. * @return {*} Attribute value.
  4606. */
  4607. function parseWithAttributeSchema(innerHTML, attributeSchema) {
  4608. return parse(innerHTML, matcherFromSource(attributeSchema));
  4609. }
  4610. /**
  4611. * Given an attribute key, an attribute's schema, a block's raw content and the
  4612. * commentAttributes returns the attribute value depending on its source
  4613. * definition of the given attribute key.
  4614. *
  4615. * @param {string} attributeKey Attribute key.
  4616. * @param {Object} attributeSchema Attribute's schema.
  4617. * @param {string} innerHTML Block's raw content.
  4618. * @param {Object} commentAttributes Block's comment attributes.
  4619. *
  4620. * @return {*} Attribute value.
  4621. */
  4622. function getBlockAttribute(attributeKey, attributeSchema, innerHTML, commentAttributes) {
  4623. const {
  4624. type,
  4625. enum: enumSet
  4626. } = attributeSchema;
  4627. let value;
  4628. switch (attributeSchema.source) {
  4629. // An undefined source means that it's an attribute serialized to the
  4630. // block's "comment".
  4631. case undefined:
  4632. value = commentAttributes ? commentAttributes[attributeKey] : undefined;
  4633. break;
  4634. case 'attribute':
  4635. case 'property':
  4636. case 'html':
  4637. case 'text':
  4638. case 'children':
  4639. case 'node':
  4640. case 'query':
  4641. case 'tag':
  4642. value = parseWithAttributeSchema(innerHTML, attributeSchema);
  4643. break;
  4644. }
  4645. if (!isValidByType(value, type) || !isValidByEnum(value, enumSet)) {
  4646. // Reject the value if it is not valid. Reverting to the undefined
  4647. // value ensures the default is respected, if applicable.
  4648. value = undefined;
  4649. }
  4650. if (value === undefined) {
  4651. return attributeSchema.default;
  4652. }
  4653. return value;
  4654. }
  4655. /**
  4656. * Returns the block attributes of a registered block node given its type.
  4657. *
  4658. * @param {string|Object} blockTypeOrName Block type or name.
  4659. * @param {string} innerHTML Raw block content.
  4660. * @param {?Object} attributes Known block attributes (from delimiters).
  4661. *
  4662. * @return {Object} All block attributes.
  4663. */
  4664. function getBlockAttributes(blockTypeOrName, innerHTML, attributes = {}) {
  4665. const blockType = normalizeBlockType(blockTypeOrName);
  4666. const blockAttributes = Object(external_lodash_["mapValues"])(blockType.attributes, (attributeSchema, attributeKey) => {
  4667. return getBlockAttribute(attributeKey, attributeSchema, innerHTML, attributes);
  4668. });
  4669. return Object(external_wp_hooks_["applyFilters"])('blocks.getBlockAttributes', blockAttributes, blockType, innerHTML, attributes);
  4670. }
  4671. /**
  4672. * Given a block object, returns a new copy of the block with any applicable
  4673. * deprecated migrations applied, or the original block if it was both valid
  4674. * and no eligible migrations exist.
  4675. *
  4676. * @param {WPBlock} block Original block object.
  4677. * @param {Object} parsedAttributes Attributes as parsed from the initial
  4678. * block markup.
  4679. *
  4680. * @return {WPBlock} Migrated block object.
  4681. */
  4682. function getMigratedBlock(block, parsedAttributes) {
  4683. const blockType = registration_getBlockType(block.name);
  4684. const {
  4685. deprecated: deprecatedDefinitions
  4686. } = blockType; // Bail early if there are no registered deprecations to be handled.
  4687. if (!deprecatedDefinitions || !deprecatedDefinitions.length) {
  4688. return block;
  4689. }
  4690. const {
  4691. originalContent,
  4692. innerBlocks
  4693. } = block; // By design, blocks lack any sort of version tracking. Instead, to process
  4694. // outdated content the system operates a queue out of all the defined
  4695. // attribute shapes and tries each definition until the input produces a
  4696. // valid result. This mechanism seeks to avoid polluting the user-space with
  4697. // machine-specific code. An invalid block is thus a block that could not be
  4698. // matched successfully with any of the registered deprecation definitions.
  4699. for (let i = 0; i < deprecatedDefinitions.length; i++) {
  4700. // A block can opt into a migration even if the block is valid by
  4701. // defining `isEligible` on its deprecation. If the block is both valid
  4702. // and does not opt to migrate, skip.
  4703. const {
  4704. isEligible = external_lodash_["stubFalse"]
  4705. } = deprecatedDefinitions[i];
  4706. if (block.isValid && !isEligible(parsedAttributes, innerBlocks)) {
  4707. continue;
  4708. } // Block type properties which could impact either serialization or
  4709. // parsing are not considered in the deprecated block type by default,
  4710. // and must be explicitly provided.
  4711. const deprecatedBlockType = Object.assign(Object(external_lodash_["omit"])(blockType, DEPRECATED_ENTRY_KEYS), deprecatedDefinitions[i]);
  4712. let migratedAttributes = getBlockAttributes(deprecatedBlockType, originalContent, parsedAttributes); // Ignore the deprecation if it produces a block which is not valid.
  4713. const {
  4714. isValid,
  4715. validationIssues
  4716. } = getBlockContentValidationResult(deprecatedBlockType, migratedAttributes, originalContent); // An invalid block does not imply incorrect HTML but the fact block
  4717. // source information could be lost on reserialization.
  4718. if (!isValid) {
  4719. block = { ...block,
  4720. validationIssues: [...Object(external_lodash_["get"])(block, 'validationIssues', []), ...validationIssues]
  4721. };
  4722. continue;
  4723. }
  4724. let migratedInnerBlocks = innerBlocks; // A block may provide custom behavior to assign new attributes and/or
  4725. // inner blocks.
  4726. const {
  4727. migrate
  4728. } = deprecatedBlockType;
  4729. if (migrate) {
  4730. [migratedAttributes = parsedAttributes, migratedInnerBlocks = innerBlocks] = Object(external_lodash_["castArray"])(migrate(migratedAttributes, innerBlocks));
  4731. }
  4732. block = { ...block,
  4733. attributes: migratedAttributes,
  4734. innerBlocks: migratedInnerBlocks,
  4735. isValid: true
  4736. };
  4737. }
  4738. return block;
  4739. }
  4740. /**
  4741. * Convert legacy blocks to their canonical form. This function is used
  4742. * both in the parser level for previous content and to convert such blocks
  4743. * used in Custom Post Types templates.
  4744. *
  4745. * @param {string} name The block's name
  4746. * @param {Object} attributes The block's attributes
  4747. *
  4748. * @return {Object} The block's name and attributes, changed accordingly if a match was found
  4749. */
  4750. function convertLegacyBlocks(name, attributes) {
  4751. const newAttributes = { ...attributes
  4752. }; // Convert 'core/cover-image' block in existing content to 'core/cover'.
  4753. if ('core/cover-image' === name) {
  4754. name = 'core/cover';
  4755. } // Convert 'core/text' blocks in existing content to 'core/paragraph'.
  4756. if ('core/text' === name || 'core/cover-text' === name) {
  4757. name = 'core/paragraph';
  4758. } // Convert derivative blocks such as 'core/social-link-wordpress' to the
  4759. // canonical form 'core/social-link'.
  4760. if (name && name.indexOf('core/social-link-') === 0) {
  4761. // Capture `social-link-wordpress` into `{"service":"wordpress"}`
  4762. newAttributes.service = name.substring(17);
  4763. name = 'core/social-link';
  4764. } // Convert derivative blocks such as 'core-embed/instagram' to the
  4765. // canonical form 'core/embed'.
  4766. if (name && name.indexOf('core-embed/') === 0) {
  4767. // Capture `core-embed/instagram` into `{"providerNameSlug":"instagram"}`
  4768. const providerSlug = name.substring(11);
  4769. const deprecated = {
  4770. speaker: 'speaker-deck',
  4771. polldaddy: 'crowdsignal'
  4772. };
  4773. newAttributes.providerNameSlug = providerSlug in deprecated ? deprecated[providerSlug] : providerSlug; // this is needed as the `responsive` attribute was passed
  4774. // in a different way before the refactoring to block variations
  4775. if (!['amazon-kindle', 'wordpress'].includes(providerSlug)) {
  4776. newAttributes.responsive = true;
  4777. }
  4778. name = 'core/embed';
  4779. } // Convert 'core/query-loop' blocks in existing content to 'core/post-template'.
  4780. // TODO: Remove this check when WordPress 5.9 is released.
  4781. if (name === 'core/query-loop') {
  4782. name = 'core/post-template';
  4783. }
  4784. return {
  4785. name,
  4786. attributes: newAttributes
  4787. };
  4788. }
  4789. /**
  4790. * Creates a block with fallback to the unknown type handler.
  4791. *
  4792. * @param {Object} blockNode Parsed block node.
  4793. *
  4794. * @return {?Object} An initialized block object (if possible).
  4795. */
  4796. function createBlockWithFallback(blockNode) {
  4797. const {
  4798. blockName: originalName
  4799. } = blockNode; // The fundamental structure of a blocktype includes its attributes, inner
  4800. // blocks, and inner HTML. It is important to distinguish inner blocks from
  4801. // the HTML content of the block as only the latter is relevant for block
  4802. // validation and edit operations.
  4803. let {
  4804. attrs: attributes,
  4805. innerBlocks = [],
  4806. innerHTML
  4807. } = blockNode;
  4808. const {
  4809. innerContent
  4810. } = blockNode; // Blocks that don't have a registered handler are considered freeform.
  4811. const freeformContentFallbackBlock = getFreeformContentHandlerName();
  4812. const unregisteredFallbackBlock = getUnregisteredTypeHandlerName() || freeformContentFallbackBlock;
  4813. attributes = attributes || {}; // Trim content to avoid creation of intermediary freeform segments.
  4814. innerHTML = innerHTML.trim(); // Use type from block content if available. Otherwise, default to the
  4815. // freeform content fallback.
  4816. let name = originalName || freeformContentFallbackBlock;
  4817. ({
  4818. name,
  4819. attributes
  4820. } = convertLegacyBlocks(name, attributes)); // Fallback content may be upgraded from classic content expecting implicit
  4821. // automatic paragraphs, so preserve them. Assumes wpautop is idempotent,
  4822. // meaning there are no negative consequences to repeated autop calls.
  4823. if (name === freeformContentFallbackBlock) {
  4824. innerHTML = Object(external_wp_autop_["autop"])(innerHTML).trim();
  4825. } // Try finding the type for known block name, else fall back again.
  4826. let blockType = registration_getBlockType(name);
  4827. if (!blockType) {
  4828. // Since the constituents of the block node are extracted at the start
  4829. // of the present function, construct a new object rather than reuse
  4830. // `blockNode`.
  4831. const reconstitutedBlockNode = {
  4832. attrs: attributes,
  4833. blockName: originalName,
  4834. innerBlocks,
  4835. innerContent
  4836. }; // Preserve undelimited content for use by the unregistered type
  4837. // handler. A block node's `innerHTML` isn't enough, as that field only
  4838. // carries the block's own HTML and not its nested blocks.
  4839. const originalUndelimitedContent = serializeBlockNode(reconstitutedBlockNode, {
  4840. isCommentDelimited: false
  4841. }); // Preserve full block content for use by the unregistered type
  4842. // handler, block boundaries included.
  4843. const originalContent = serializeBlockNode(reconstitutedBlockNode, {
  4844. isCommentDelimited: true
  4845. }); // If detected as a block which is not registered, preserve comment
  4846. // delimiters in content of unregistered type handler.
  4847. if (name) {
  4848. innerHTML = originalContent;
  4849. }
  4850. name = unregisteredFallbackBlock;
  4851. attributes = {
  4852. originalName,
  4853. originalContent,
  4854. originalUndelimitedContent
  4855. };
  4856. blockType = registration_getBlockType(name);
  4857. } // Coerce inner blocks from parsed form to canonical form.
  4858. innerBlocks = innerBlocks.map(createBlockWithFallback); // Remove `undefined` innerBlocks.
  4859. //
  4860. // This is a temporary fix to prevent unrecoverable TypeErrors when handling unexpectedly
  4861. // empty freeform block nodes. See https://github.com/WordPress/gutenberg/pull/17164.
  4862. innerBlocks = innerBlocks.filter(innerBlock => innerBlock);
  4863. const isFallbackBlock = name === freeformContentFallbackBlock || name === unregisteredFallbackBlock; // Include in set only if type was determined.
  4864. if (!blockType || !innerHTML && isFallbackBlock) {
  4865. return;
  4866. }
  4867. let block = createBlock(name, getBlockAttributes(blockType, innerHTML, attributes), innerBlocks); // Block validation assumes an idempotent operation from source block to serialized block
  4868. // provided there are no changes in attributes. The validation procedure thus compares the
  4869. // provided source value with the serialized output before there are any modifications to
  4870. // the block. When both match, the block is marked as valid.
  4871. if (!isFallbackBlock) {
  4872. const {
  4873. isValid,
  4874. validationIssues
  4875. } = getBlockContentValidationResult(blockType, block.attributes, innerHTML);
  4876. block.isValid = isValid;
  4877. block.validationIssues = validationIssues;
  4878. } // Preserve original content for future use in case the block is parsed
  4879. // as invalid, or future serialization attempt results in an error.
  4880. block.originalContent = block.originalContent || innerHTML; // Ensure all necessary migrations are applied to the block.
  4881. block = getMigratedBlock(block, attributes);
  4882. if (block.validationIssues && block.validationIssues.length > 0) {
  4883. if (block.isValid) {
  4884. // eslint-disable-next-line no-console
  4885. console.info('Block successfully updated for `%s` (%o).\n\nNew content generated by `save` function:\n\n%s\n\nContent retrieved from post body:\n\n%s', blockType.name, blockType, getSaveContent(blockType, block.attributes), block.originalContent);
  4886. } else {
  4887. block.validationIssues.forEach(({
  4888. log,
  4889. args
  4890. }) => log(...args));
  4891. }
  4892. }
  4893. return block;
  4894. }
  4895. /**
  4896. * Serializes a block node into the native HTML-comment-powered block format.
  4897. * CAVEAT: This function is intended for reserializing blocks as parsed by
  4898. * valid parsers and skips any validation steps. This is NOT a generic
  4899. * serialization function for in-memory blocks. For most purposes, see the
  4900. * following functions available in the `@wordpress/blocks` package:
  4901. *
  4902. * @see serializeBlock
  4903. * @see serialize
  4904. *
  4905. * For more on the format of block nodes as returned by valid parsers:
  4906. *
  4907. * @see `@wordpress/block-serialization-default-parser` package
  4908. * @see `@wordpress/block-serialization-spec-parser` package
  4909. *
  4910. * @param {Object} blockNode A block node as returned by a valid parser.
  4911. * @param {?Object} options Serialization options.
  4912. * @param {?boolean} options.isCommentDelimited Whether to output HTML comments around blocks.
  4913. *
  4914. * @return {string} An HTML string representing a block.
  4915. */
  4916. function serializeBlockNode(blockNode, options = {}) {
  4917. const {
  4918. isCommentDelimited = true
  4919. } = options;
  4920. const {
  4921. blockName,
  4922. attrs = {},
  4923. innerBlocks = [],
  4924. innerContent = []
  4925. } = blockNode;
  4926. let childIndex = 0;
  4927. const content = innerContent.map(item => // `null` denotes a nested block, otherwise we have an HTML fragment.
  4928. item !== null ? item : serializeBlockNode(innerBlocks[childIndex++], options)).join('\n').replace(/\n+/g, '\n').trim();
  4929. return isCommentDelimited ? getCommentDelimitedContent(blockName, attrs, content) : content;
  4930. }
  4931. /**
  4932. * Creates a parse implementation for the post content which returns a list of blocks.
  4933. *
  4934. * @param {Function} parseImplementation Parse implementation.
  4935. *
  4936. * @return {Function} An implementation which parses the post content.
  4937. */
  4938. const createParse = parseImplementation => content => parseImplementation(content).reduce((accumulator, blockNode) => {
  4939. const block = createBlockWithFallback(blockNode);
  4940. if (block) {
  4941. accumulator.push(block);
  4942. }
  4943. return accumulator;
  4944. }, []);
  4945. /**
  4946. * Utilizes an optimized token-driven parser based on the Gutenberg grammar spec
  4947. * defined through a parsing expression grammar to take advantage of the regular
  4948. * cadence provided by block delimiters -- composed syntactically through HTML
  4949. * comments -- which, given a general HTML document as an input, returns a block
  4950. * list array representation.
  4951. *
  4952. * This is a recursive-descent parser that scans linearly once through the input
  4953. * document. Instead of directly recursing it utilizes a trampoline mechanism to
  4954. * prevent stack overflow. This initial pass is mainly interested in separating
  4955. * and isolating the blocks serialized in the document and manifestly not in the
  4956. * content within the blocks.
  4957. *
  4958. * @see
  4959. * https://developer.wordpress.org/block-editor/packages/packages-block-serialization-default-parser/
  4960. *
  4961. * @param {string} content The post content.
  4962. *
  4963. * @return {Array} Block list.
  4964. */
  4965. const parseWithGrammar = createParse(external_wp_blockSerializationDefaultParser_["parse"]);
  4966. /* harmony default export */ var parser = (parseWithGrammar);
  4967. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/get-raw-transforms.js
  4968. /**
  4969. * External dependencies
  4970. */
  4971. /**
  4972. * Internal dependencies
  4973. */
  4974. function getRawTransforms() {
  4975. return Object(external_lodash_["filter"])(getBlockTransforms('from'), {
  4976. type: 'raw'
  4977. }).map(transform => {
  4978. return transform.isMatch ? transform : { ...transform,
  4979. isMatch: node => transform.selector && node.matches(transform.selector)
  4980. };
  4981. });
  4982. }
  4983. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/html-to-blocks.js
  4984. /**
  4985. * Internal dependencies
  4986. */
  4987. /**
  4988. * Converts HTML directly to blocks. Looks for a matching transform for each
  4989. * top-level tag. The HTML should be filtered to not have any text between
  4990. * top-level tags and formatted in a way that blocks can handle the HTML.
  4991. *
  4992. * @param {string} html HTML to convert.
  4993. *
  4994. * @return {Array} An array of blocks.
  4995. */
  4996. function htmlToBlocks(html) {
  4997. const doc = document.implementation.createHTMLDocument('');
  4998. doc.body.innerHTML = html;
  4999. return Array.from(doc.body.children).flatMap(node => {
  5000. const rawTransform = findTransform(getRawTransforms(), ({
  5001. isMatch
  5002. }) => isMatch(node));
  5003. if (!rawTransform) {
  5004. return createBlock( // Should not be hardcoded.
  5005. 'core/html', getBlockAttributes('core/html', node.outerHTML));
  5006. }
  5007. const {
  5008. transform,
  5009. blockName
  5010. } = rawTransform;
  5011. if (transform) {
  5012. return transform(node);
  5013. }
  5014. return createBlock(blockName, getBlockAttributes(blockName, node.outerHTML));
  5015. });
  5016. }
  5017. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/normalise-blocks.js
  5018. /**
  5019. * WordPress dependencies
  5020. */
  5021. function normaliseBlocks(HTML) {
  5022. const decuDoc = document.implementation.createHTMLDocument('');
  5023. const accuDoc = document.implementation.createHTMLDocument('');
  5024. const decu = decuDoc.body;
  5025. const accu = accuDoc.body;
  5026. decu.innerHTML = HTML;
  5027. while (decu.firstChild) {
  5028. const node = decu.firstChild; // Text nodes: wrap in a paragraph, or append to previous.
  5029. if (node.nodeType === node.TEXT_NODE) {
  5030. if (Object(external_wp_dom_["isEmpty"])(node)) {
  5031. decu.removeChild(node);
  5032. } else {
  5033. if (!accu.lastChild || accu.lastChild.nodeName !== 'P') {
  5034. accu.appendChild(accuDoc.createElement('P'));
  5035. }
  5036. accu.lastChild.appendChild(node);
  5037. } // Element nodes.
  5038. } else if (node.nodeType === node.ELEMENT_NODE) {
  5039. // BR nodes: create a new paragraph on double, or append to previous.
  5040. if (node.nodeName === 'BR') {
  5041. if (node.nextSibling && node.nextSibling.nodeName === 'BR') {
  5042. accu.appendChild(accuDoc.createElement('P'));
  5043. decu.removeChild(node.nextSibling);
  5044. } // Don't append to an empty paragraph.
  5045. if (accu.lastChild && accu.lastChild.nodeName === 'P' && accu.lastChild.hasChildNodes()) {
  5046. accu.lastChild.appendChild(node);
  5047. } else {
  5048. decu.removeChild(node);
  5049. }
  5050. } else if (node.nodeName === 'P') {
  5051. // Only append non-empty paragraph nodes.
  5052. if (Object(external_wp_dom_["isEmpty"])(node)) {
  5053. decu.removeChild(node);
  5054. } else {
  5055. accu.appendChild(node);
  5056. }
  5057. } else if (Object(external_wp_dom_["isPhrasingContent"])(node)) {
  5058. if (!accu.lastChild || accu.lastChild.nodeName !== 'P') {
  5059. accu.appendChild(accuDoc.createElement('P'));
  5060. }
  5061. accu.lastChild.appendChild(node);
  5062. } else {
  5063. accu.appendChild(node);
  5064. }
  5065. } else {
  5066. decu.removeChild(node);
  5067. }
  5068. }
  5069. return accu.innerHTML;
  5070. }
  5071. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/special-comment-converter.js
  5072. /**
  5073. * WordPress dependencies
  5074. */
  5075. /**
  5076. * Looks for `<!--nextpage-->` and `<!--more-->` comments, as well as the
  5077. * `<!--more Some text-->` variant and its `<!--noteaser-->` companion,
  5078. * and replaces them with a custom element representing a future block.
  5079. *
  5080. * The custom element is a way to bypass the rest of the `raw-handling`
  5081. * transforms, which would eliminate other kinds of node with which to carry
  5082. * `<!--more-->`'s data: nodes with `data` attributes, empty paragraphs, etc.
  5083. *
  5084. * The custom element is then expected to be recognized by any registered
  5085. * block's `raw` transform.
  5086. *
  5087. * @param {Node} node The node to be processed.
  5088. * @param {Document} doc The document of the node.
  5089. * @return {void}
  5090. */
  5091. function specialCommentConverter(node, doc) {
  5092. if (node.nodeType !== node.COMMENT_NODE) {
  5093. return;
  5094. }
  5095. if (node.nodeValue === 'nextpage') {
  5096. Object(external_wp_dom_["replace"])(node, createNextpage(doc));
  5097. return;
  5098. }
  5099. if (node.nodeValue.indexOf('more') === 0) {
  5100. // Grab any custom text in the comment.
  5101. const customText = node.nodeValue.slice(4).trim();
  5102. /*
  5103. * When a `<!--more-->` comment is found, we need to look for any
  5104. * `<!--noteaser-->` sibling, but it may not be a direct sibling
  5105. * (whitespace typically lies in between)
  5106. */
  5107. let sibling = node;
  5108. let noTeaser = false;
  5109. while (sibling = sibling.nextSibling) {
  5110. if (sibling.nodeType === sibling.COMMENT_NODE && sibling.nodeValue === 'noteaser') {
  5111. noTeaser = true;
  5112. Object(external_wp_dom_["remove"])(sibling);
  5113. break;
  5114. }
  5115. }
  5116. Object(external_wp_dom_["replace"])(node, createMore(customText, noTeaser, doc));
  5117. }
  5118. }
  5119. function createMore(customText, noTeaser, doc) {
  5120. const node = doc.createElement('wp-block');
  5121. node.dataset.block = 'core/more';
  5122. if (customText) {
  5123. node.dataset.customText = customText;
  5124. }
  5125. if (noTeaser) {
  5126. // "Boolean" data attribute
  5127. node.dataset.noTeaser = '';
  5128. }
  5129. return node;
  5130. }
  5131. function createNextpage(doc) {
  5132. const node = doc.createElement('wp-block');
  5133. node.dataset.block = 'core/nextpage';
  5134. return node;
  5135. }
  5136. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/comment-remover.js
  5137. /**
  5138. * WordPress dependencies
  5139. */
  5140. /**
  5141. * Looks for comments, and removes them.
  5142. *
  5143. * @param {Node} node The node to be processed.
  5144. * @return {void}
  5145. */
  5146. function commentRemover(node) {
  5147. if (node.nodeType === node.COMMENT_NODE) {
  5148. Object(external_wp_dom_["remove"])(node);
  5149. }
  5150. }
  5151. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/is-inline-content.js
  5152. /**
  5153. * External dependencies
  5154. */
  5155. /**
  5156. * WordPress dependencies
  5157. */
  5158. /**
  5159. * Checks if the given node should be considered inline content, optionally
  5160. * depending on a context tag.
  5161. *
  5162. * @param {Node} node Node name.
  5163. * @param {string} contextTag Tag name.
  5164. *
  5165. * @return {boolean} True if the node is inline content, false if nohe.
  5166. */
  5167. function isInline(node, contextTag) {
  5168. if (Object(external_wp_dom_["isTextContent"])(node)) {
  5169. return true;
  5170. }
  5171. if (!contextTag) {
  5172. return false;
  5173. }
  5174. const tag = node.nodeName.toLowerCase();
  5175. const inlineAllowedTagGroups = [['ul', 'li', 'ol'], ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']];
  5176. return inlineAllowedTagGroups.some(tagGroup => Object(external_lodash_["difference"])([tag, contextTag], tagGroup).length === 0);
  5177. }
  5178. function deepCheck(nodes, contextTag) {
  5179. return nodes.every(node => isInline(node, contextTag) && deepCheck(Array.from(node.children), contextTag));
  5180. }
  5181. function isDoubleBR(node) {
  5182. return node.nodeName === 'BR' && node.previousSibling && node.previousSibling.nodeName === 'BR';
  5183. }
  5184. function isInlineContent(HTML, contextTag) {
  5185. const doc = document.implementation.createHTMLDocument('');
  5186. doc.body.innerHTML = HTML;
  5187. const nodes = Array.from(doc.body.children);
  5188. return !nodes.some(isDoubleBR) && deepCheck(nodes, contextTag);
  5189. }
  5190. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/phrasing-content-reducer.js
  5191. /**
  5192. * External dependencies
  5193. */
  5194. /**
  5195. * WordPress dependencies
  5196. */
  5197. function phrasingContentReducer(node, doc) {
  5198. // In jsdom-jscore, 'node.style' can be null.
  5199. // TODO: Explore fixing this by patching jsdom-jscore.
  5200. if (node.nodeName === 'SPAN' && node.style) {
  5201. const {
  5202. fontWeight,
  5203. fontStyle,
  5204. textDecorationLine,
  5205. textDecoration,
  5206. verticalAlign
  5207. } = node.style;
  5208. if (fontWeight === 'bold' || fontWeight === '700') {
  5209. Object(external_wp_dom_["wrap"])(doc.createElement('strong'), node);
  5210. }
  5211. if (fontStyle === 'italic') {
  5212. Object(external_wp_dom_["wrap"])(doc.createElement('em'), node);
  5213. } // Some DOM implementations (Safari, JSDom) don't support
  5214. // style.textDecorationLine, so we check style.textDecoration as a
  5215. // fallback.
  5216. if (textDecorationLine === 'line-through' || Object(external_lodash_["includes"])(textDecoration, 'line-through')) {
  5217. Object(external_wp_dom_["wrap"])(doc.createElement('s'), node);
  5218. }
  5219. if (verticalAlign === 'super') {
  5220. Object(external_wp_dom_["wrap"])(doc.createElement('sup'), node);
  5221. } else if (verticalAlign === 'sub') {
  5222. Object(external_wp_dom_["wrap"])(doc.createElement('sub'), node);
  5223. }
  5224. } else if (node.nodeName === 'B') {
  5225. node = Object(external_wp_dom_["replaceTag"])(node, 'strong');
  5226. } else if (node.nodeName === 'I') {
  5227. node = Object(external_wp_dom_["replaceTag"])(node, 'em');
  5228. } else if (node.nodeName === 'A') {
  5229. // In jsdom-jscore, 'node.target' can be null.
  5230. // TODO: Explore fixing this by patching jsdom-jscore.
  5231. if (node.target && node.target.toLowerCase() === '_blank') {
  5232. node.rel = 'noreferrer noopener';
  5233. } else {
  5234. node.removeAttribute('target');
  5235. node.removeAttribute('rel');
  5236. }
  5237. }
  5238. }
  5239. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/head-remover.js
  5240. function headRemover(node) {
  5241. if (node.nodeName !== 'SCRIPT' && node.nodeName !== 'NOSCRIPT' && node.nodeName !== 'TEMPLATE' && node.nodeName !== 'STYLE') {
  5242. return;
  5243. }
  5244. node.parentNode.removeChild(node);
  5245. }
  5246. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/ms-list-converter.js
  5247. /**
  5248. * Browser dependencies
  5249. */
  5250. const {
  5251. parseInt: ms_list_converter_parseInt
  5252. } = window;
  5253. function isList(node) {
  5254. return node.nodeName === 'OL' || node.nodeName === 'UL';
  5255. }
  5256. function msListConverter(node, doc) {
  5257. if (node.nodeName !== 'P') {
  5258. return;
  5259. }
  5260. const style = node.getAttribute('style');
  5261. if (!style) {
  5262. return;
  5263. } // Quick check.
  5264. if (style.indexOf('mso-list') === -1) {
  5265. return;
  5266. }
  5267. const matches = /mso-list\s*:[^;]+level([0-9]+)/i.exec(style);
  5268. if (!matches) {
  5269. return;
  5270. }
  5271. let level = ms_list_converter_parseInt(matches[1], 10) - 1 || 0;
  5272. const prevNode = node.previousElementSibling; // Add new list if no previous.
  5273. if (!prevNode || !isList(prevNode)) {
  5274. // See https://html.spec.whatwg.org/multipage/grouping-content.html#attr-ol-type.
  5275. const type = node.textContent.trim().slice(0, 1);
  5276. const isNumeric = /[1iIaA]/.test(type);
  5277. const newListNode = doc.createElement(isNumeric ? 'ol' : 'ul');
  5278. if (isNumeric) {
  5279. newListNode.setAttribute('type', type);
  5280. }
  5281. node.parentNode.insertBefore(newListNode, node);
  5282. }
  5283. const listNode = node.previousElementSibling;
  5284. const listType = listNode.nodeName;
  5285. const listItem = doc.createElement('li');
  5286. let receivingNode = listNode; // Remove the first span with list info.
  5287. node.removeChild(node.firstElementChild); // Add content.
  5288. while (node.firstChild) {
  5289. listItem.appendChild(node.firstChild);
  5290. } // Change pointer depending on indentation level.
  5291. while (level--) {
  5292. receivingNode = receivingNode.lastElementChild || receivingNode; // If it's a list, move pointer to the last item.
  5293. if (isList(receivingNode)) {
  5294. receivingNode = receivingNode.lastElementChild || receivingNode;
  5295. }
  5296. } // Make sure we append to a list.
  5297. if (!isList(receivingNode)) {
  5298. receivingNode = receivingNode.appendChild(doc.createElement(listType));
  5299. } // Append the list item to the list.
  5300. receivingNode.appendChild(listItem); // Remove the wrapper paragraph.
  5301. node.parentNode.removeChild(node);
  5302. }
  5303. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/list-reducer.js
  5304. /**
  5305. * WordPress dependencies
  5306. */
  5307. function list_reducer_isList(node) {
  5308. return node.nodeName === 'OL' || node.nodeName === 'UL';
  5309. }
  5310. function shallowTextContent(element) {
  5311. return Array.from(element.childNodes).map(({
  5312. nodeValue = ''
  5313. }) => nodeValue).join('');
  5314. }
  5315. function listReducer(node) {
  5316. if (!list_reducer_isList(node)) {
  5317. return;
  5318. }
  5319. const list = node;
  5320. const prevElement = node.previousElementSibling; // Merge with previous list if:
  5321. // * There is a previous list of the same type.
  5322. // * There is only one list item.
  5323. if (prevElement && prevElement.nodeName === node.nodeName && list.children.length === 1) {
  5324. // Move all child nodes, including any text nodes, if any.
  5325. while (list.firstChild) {
  5326. prevElement.appendChild(list.firstChild);
  5327. }
  5328. list.parentNode.removeChild(list);
  5329. }
  5330. const parentElement = node.parentNode; // Nested list with empty parent item.
  5331. if (parentElement && parentElement.nodeName === 'LI' && parentElement.children.length === 1 && !/\S/.test(shallowTextContent(parentElement))) {
  5332. const parentListItem = parentElement;
  5333. const prevListItem = parentListItem.previousElementSibling;
  5334. const parentList = parentListItem.parentNode;
  5335. if (prevListItem) {
  5336. prevListItem.appendChild(list);
  5337. parentList.removeChild(parentListItem);
  5338. } else {
  5339. parentList.parentNode.insertBefore(list, parentList);
  5340. parentList.parentNode.removeChild(parentList);
  5341. }
  5342. } // Invalid: OL/UL > OL/UL.
  5343. if (parentElement && list_reducer_isList(parentElement)) {
  5344. const prevListItem = node.previousElementSibling;
  5345. if (prevListItem) {
  5346. prevListItem.appendChild(node);
  5347. } else {
  5348. Object(external_wp_dom_["unwrap"])(node);
  5349. }
  5350. }
  5351. }
  5352. // EXTERNAL MODULE: external ["wp","blob"]
  5353. var external_wp_blob_ = __webpack_require__("xTGt");
  5354. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/image-corrector.js
  5355. /**
  5356. * WordPress dependencies
  5357. */
  5358. /**
  5359. * Browser dependencies
  5360. */
  5361. const {
  5362. atob,
  5363. File
  5364. } = window;
  5365. function imageCorrector(node) {
  5366. if (node.nodeName !== 'IMG') {
  5367. return;
  5368. }
  5369. if (node.src.indexOf('file:') === 0) {
  5370. node.src = '';
  5371. } // This piece cannot be tested outside a browser env.
  5372. if (node.src.indexOf('data:') === 0) {
  5373. const [properties, data] = node.src.split(',');
  5374. const [type] = properties.slice(5).split(';');
  5375. if (!data || !type) {
  5376. node.src = '';
  5377. return;
  5378. }
  5379. let decoded; // Can throw DOMException!
  5380. try {
  5381. decoded = atob(data);
  5382. } catch (e) {
  5383. node.src = '';
  5384. return;
  5385. }
  5386. const uint8Array = new Uint8Array(decoded.length);
  5387. for (let i = 0; i < uint8Array.length; i++) {
  5388. uint8Array[i] = decoded.charCodeAt(i);
  5389. }
  5390. const name = type.replace('/', '.');
  5391. const file = new File([uint8Array], name, {
  5392. type
  5393. });
  5394. node.src = Object(external_wp_blob_["createBlobURL"])(file);
  5395. } // Remove trackers and hardly visible images.
  5396. if (node.height === 1 || node.width === 1) {
  5397. node.parentNode.removeChild(node);
  5398. }
  5399. }
  5400. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/blockquote-normaliser.js
  5401. /**
  5402. * Internal dependencies
  5403. */
  5404. function blockquoteNormaliser(node) {
  5405. if (node.nodeName !== 'BLOCKQUOTE') {
  5406. return;
  5407. }
  5408. node.innerHTML = normaliseBlocks(node.innerHTML);
  5409. }
  5410. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/figure-content-reducer.js
  5411. /**
  5412. * External dependencies
  5413. */
  5414. /**
  5415. * WordPress dependencies
  5416. */
  5417. /**
  5418. * Whether or not the given node is figure content.
  5419. *
  5420. * @param {Node} node The node to check.
  5421. * @param {Object} schema The schema to use.
  5422. *
  5423. * @return {boolean} True if figure content, false if not.
  5424. */
  5425. function isFigureContent(node, schema) {
  5426. const tag = node.nodeName.toLowerCase(); // We are looking for tags that can be a child of the figure tag, excluding
  5427. // `figcaption` and any phrasing content.
  5428. if (tag === 'figcaption' || Object(external_wp_dom_["isTextContent"])(node)) {
  5429. return false;
  5430. }
  5431. return Object(external_lodash_["has"])(schema, ['figure', 'children', tag]);
  5432. }
  5433. /**
  5434. * Whether or not the given node can have an anchor.
  5435. *
  5436. * @param {Node} node The node to check.
  5437. * @param {Object} schema The schema to use.
  5438. *
  5439. * @return {boolean} True if it can, false if not.
  5440. */
  5441. function canHaveAnchor(node, schema) {
  5442. const tag = node.nodeName.toLowerCase();
  5443. return Object(external_lodash_["has"])(schema, ['figure', 'children', 'a', 'children', tag]);
  5444. }
  5445. /**
  5446. * Wraps the given element in a figure element.
  5447. *
  5448. * @param {Element} element The element to wrap.
  5449. * @param {Element} beforeElement The element before which to place the figure.
  5450. */
  5451. function wrapFigureContent(element, beforeElement = element) {
  5452. const figure = element.ownerDocument.createElement('figure');
  5453. beforeElement.parentNode.insertBefore(figure, beforeElement);
  5454. figure.appendChild(element);
  5455. }
  5456. /**
  5457. * This filter takes figure content out of paragraphs, wraps it in a figure
  5458. * element, and moves any anchors with it if needed.
  5459. *
  5460. * @param {Node} node The node to filter.
  5461. * @param {Document} doc The document of the node.
  5462. * @param {Object} schema The schema to use.
  5463. *
  5464. * @return {void}
  5465. */
  5466. function figureContentReducer(node, doc, schema) {
  5467. if (!isFigureContent(node, schema)) {
  5468. return;
  5469. }
  5470. let nodeToInsert = node;
  5471. const parentNode = node.parentNode; // If the figure content can have an anchor and its parent is an anchor with
  5472. // only the figure content, take the anchor out instead of just the content.
  5473. if (canHaveAnchor(node, schema) && parentNode.nodeName === 'A' && parentNode.childNodes.length === 1) {
  5474. nodeToInsert = node.parentNode;
  5475. }
  5476. const wrapper = nodeToInsert.closest('p,div'); // If wrapped in a paragraph or div, only extract if it's aligned or if
  5477. // there is no text content.
  5478. // Otherwise, if directly at the root, wrap in a figure element.
  5479. if (wrapper) {
  5480. // In jsdom-jscore, 'node.classList' can be undefined.
  5481. // In this case, default to extract as it offers a better UI experience on mobile.
  5482. if (!node.classList) {
  5483. wrapFigureContent(nodeToInsert, wrapper);
  5484. } else if (node.classList.contains('alignright') || node.classList.contains('alignleft') || node.classList.contains('aligncenter') || !wrapper.textContent.trim()) {
  5485. wrapFigureContent(nodeToInsert, wrapper);
  5486. }
  5487. } else if (nodeToInsert.parentNode.nodeName === 'BODY') {
  5488. wrapFigureContent(nodeToInsert);
  5489. }
  5490. }
  5491. // EXTERNAL MODULE: external ["wp","shortcode"]
  5492. var external_wp_shortcode_ = __webpack_require__("SVSp");
  5493. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/shortcode-converter.js
  5494. /**
  5495. * External dependencies
  5496. */
  5497. /**
  5498. * WordPress dependencies
  5499. */
  5500. /**
  5501. * Internal dependencies
  5502. */
  5503. function segmentHTMLToShortcodeBlock(HTML, lastIndex = 0, excludedBlockNames = []) {
  5504. // Get all matches.
  5505. const transformsFrom = getBlockTransforms('from');
  5506. const transformation = findTransform(transformsFrom, transform => excludedBlockNames.indexOf(transform.blockName) === -1 && transform.type === 'shortcode' && Object(external_lodash_["some"])(Object(external_lodash_["castArray"])(transform.tag), tag => Object(external_wp_shortcode_["regexp"])(tag).test(HTML)));
  5507. if (!transformation) {
  5508. return [HTML];
  5509. }
  5510. const transformTags = Object(external_lodash_["castArray"])(transformation.tag);
  5511. const transformTag = Object(external_lodash_["find"])(transformTags, tag => Object(external_wp_shortcode_["regexp"])(tag).test(HTML));
  5512. let match;
  5513. const previousIndex = lastIndex;
  5514. if (match = Object(external_wp_shortcode_["next"])(transformTag, HTML, lastIndex)) {
  5515. lastIndex = match.index + match.content.length;
  5516. const beforeHTML = HTML.substr(0, match.index);
  5517. const afterHTML = HTML.substr(lastIndex); // If the shortcode content does not contain HTML and the shortcode is
  5518. // not on a new line (or in paragraph from Markdown converter),
  5519. // consider the shortcode as inline text, and thus skip conversion for
  5520. // this segment.
  5521. if (!Object(external_lodash_["includes"])(match.shortcode.content || '', '<') && !(/(\n|<p>)\s*$/.test(beforeHTML) && /^\s*(\n|<\/p>)/.test(afterHTML))) {
  5522. return segmentHTMLToShortcodeBlock(HTML, lastIndex);
  5523. } // If a transformation's `isMatch` predicate fails for the inbound
  5524. // shortcode, try again by excluding the current block type.
  5525. //
  5526. // This is the only call to `segmentHTMLToShortcodeBlock` that should
  5527. // ever carry over `excludedBlockNames`. Other calls in the module
  5528. // should skip that argument as a way to reset the exclusion state, so
  5529. // that one `isMatch` fail in an HTML fragment doesn't prevent any
  5530. // valid matches in subsequent fragments.
  5531. if (transformation.isMatch && !transformation.isMatch(match.shortcode.attrs)) {
  5532. return segmentHTMLToShortcodeBlock(HTML, previousIndex, [...excludedBlockNames, transformation.blockName]);
  5533. }
  5534. const attributes = Object(external_lodash_["mapValues"])(Object(external_lodash_["pickBy"])(transformation.attributes, schema => schema.shortcode), // Passing all of `match` as second argument is intentionally broad
  5535. // but shouldn't be too relied upon.
  5536. //
  5537. // See: https://github.com/WordPress/gutenberg/pull/3610#discussion_r152546926
  5538. schema => schema.shortcode(match.shortcode.attrs, match));
  5539. const block = createBlock(transformation.blockName, getBlockAttributes({ ...registration_getBlockType(transformation.blockName),
  5540. attributes: transformation.attributes
  5541. }, match.shortcode.content, attributes));
  5542. return [...segmentHTMLToShortcodeBlock(beforeHTML), block, ...segmentHTMLToShortcodeBlock(afterHTML)];
  5543. }
  5544. return [HTML];
  5545. }
  5546. /* harmony default export */ var shortcode_converter = (segmentHTMLToShortcodeBlock);
  5547. // EXTERNAL MODULE: ./node_modules/showdown/dist/showdown.js
  5548. var showdown = __webpack_require__("M55E");
  5549. var showdown_default = /*#__PURE__*/__webpack_require__.n(showdown);
  5550. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/markdown-converter.js
  5551. /**
  5552. * External dependencies
  5553. */
  5554. // Reuse the same showdown converter.
  5555. const converter = new showdown_default.a.Converter({
  5556. noHeaderId: true,
  5557. tables: true,
  5558. literalMidWordUnderscores: true,
  5559. omitExtraWLInCodeBlocks: true,
  5560. simpleLineBreaks: true,
  5561. strikethrough: true
  5562. });
  5563. /**
  5564. * Corrects the Slack Markdown variant of the code block.
  5565. * If uncorrected, it will be converted to inline code.
  5566. *
  5567. * @see https://get.slack.help/hc/en-us/articles/202288908-how-can-i-add-formatting-to-my-messages-#code-blocks
  5568. *
  5569. * @param {string} text The potential Markdown text to correct.
  5570. *
  5571. * @return {string} The corrected Markdown.
  5572. */
  5573. function slackMarkdownVariantCorrector(text) {
  5574. return text.replace(/((?:^|\n)```)([^\n`]+)(```(?:$|\n))/, (match, p1, p2, p3) => `${p1}\n${p2}\n${p3}`);
  5575. }
  5576. /**
  5577. * Converts a piece of text into HTML based on any Markdown present.
  5578. * Also decodes any encoded HTML.
  5579. *
  5580. * @param {string} text The plain text to convert.
  5581. *
  5582. * @return {string} HTML.
  5583. */
  5584. function markdownConverter(text) {
  5585. return converter.makeHtml(slackMarkdownVariantCorrector(text));
  5586. }
  5587. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/iframe-remover.js
  5588. /**
  5589. * Removes iframes.
  5590. *
  5591. * @param {Node} node The node to check.
  5592. *
  5593. * @return {void}
  5594. */
  5595. function iframeRemover(node) {
  5596. if (node.nodeName === 'IFRAME') {
  5597. const text = node.ownerDocument.createTextNode(node.src);
  5598. node.parentNode.replaceChild(text, node);
  5599. }
  5600. }
  5601. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/google-docs-uid-remover.js
  5602. /**
  5603. * WordPress dependencies
  5604. */
  5605. function googleDocsUIdRemover(node) {
  5606. if (!node.id || node.id.indexOf('docs-internal-guid-') !== 0) {
  5607. return;
  5608. }
  5609. Object(external_wp_dom_["unwrap"])(node);
  5610. }
  5611. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/utils.js
  5612. /**
  5613. * External dependencies
  5614. */
  5615. /**
  5616. * WordPress dependencies
  5617. */
  5618. /**
  5619. * Internal dependencies
  5620. */
  5621. function getBlockContentSchemaFromTransforms(transforms, context) {
  5622. const phrasingContentSchema = Object(external_wp_dom_["getPhrasingContentSchema"])(context);
  5623. const schemaArgs = {
  5624. phrasingContentSchema,
  5625. isPaste: context === 'paste'
  5626. };
  5627. const schemas = transforms.map(({
  5628. isMatch,
  5629. blockName,
  5630. schema
  5631. }) => {
  5632. const hasAnchorSupport = registration_hasBlockSupport(blockName, 'anchor');
  5633. schema = Object(external_lodash_["isFunction"])(schema) ? schema(schemaArgs) : schema; // If the block does not has anchor support and the transform does not
  5634. // provides an isMatch we can return the schema right away.
  5635. if (!hasAnchorSupport && !isMatch) {
  5636. return schema;
  5637. }
  5638. return Object(external_lodash_["mapValues"])(schema, value => {
  5639. let attributes = value.attributes || []; // If the block supports the "anchor" functionality, it needs to keep its ID attribute.
  5640. if (hasAnchorSupport) {
  5641. attributes = [...attributes, 'id'];
  5642. }
  5643. return { ...value,
  5644. attributes,
  5645. isMatch: isMatch ? isMatch : undefined
  5646. };
  5647. });
  5648. });
  5649. return Object(external_lodash_["mergeWith"])({}, ...schemas, (objValue, srcValue, key) => {
  5650. switch (key) {
  5651. case 'children':
  5652. {
  5653. if (objValue === '*' || srcValue === '*') {
  5654. return '*';
  5655. }
  5656. return { ...objValue,
  5657. ...srcValue
  5658. };
  5659. }
  5660. case 'attributes':
  5661. case 'require':
  5662. {
  5663. return [...(objValue || []), ...(srcValue || [])];
  5664. }
  5665. case 'isMatch':
  5666. {
  5667. // If one of the values being merge is undefined (matches everything),
  5668. // the result of the merge will be undefined.
  5669. if (!objValue || !srcValue) {
  5670. return undefined;
  5671. } // When merging two isMatch functions, the result is a new function
  5672. // that returns if one of the source functions returns true.
  5673. return (...args) => {
  5674. return objValue(...args) || srcValue(...args);
  5675. };
  5676. }
  5677. }
  5678. });
  5679. }
  5680. /**
  5681. * Gets the block content schema, which is extracted and merged from all
  5682. * registered blocks with raw transfroms.
  5683. *
  5684. * @param {string} context Set to "paste" when in paste context, where the
  5685. * schema is more strict.
  5686. *
  5687. * @return {Object} A complete block content schema.
  5688. */
  5689. function getBlockContentSchema(context) {
  5690. return getBlockContentSchemaFromTransforms(getRawTransforms(), context);
  5691. }
  5692. /**
  5693. * Checks whether HTML can be considered plain text. That is, it does not contain
  5694. * any elements that are not line breaks.
  5695. *
  5696. * @param {string} HTML The HTML to check.
  5697. *
  5698. * @return {boolean} Whether the HTML can be considered plain text.
  5699. */
  5700. function isPlain(HTML) {
  5701. return !/<(?!br[ />])/i.test(HTML);
  5702. }
  5703. /**
  5704. * Given node filters, deeply filters and mutates a NodeList.
  5705. *
  5706. * @param {NodeList} nodeList The nodeList to filter.
  5707. * @param {Array} filters An array of functions that can mutate with the provided node.
  5708. * @param {Document} doc The document of the nodeList.
  5709. * @param {Object} schema The schema to use.
  5710. */
  5711. function deepFilterNodeList(nodeList, filters, doc, schema) {
  5712. Array.from(nodeList).forEach(node => {
  5713. deepFilterNodeList(node.childNodes, filters, doc, schema);
  5714. filters.forEach(item => {
  5715. // Make sure the node is still attached to the document.
  5716. if (!doc.contains(node)) {
  5717. return;
  5718. }
  5719. item(node, doc, schema);
  5720. });
  5721. });
  5722. }
  5723. /**
  5724. * Given node filters, deeply filters HTML tags.
  5725. * Filters from the deepest nodes to the top.
  5726. *
  5727. * @param {string} HTML The HTML to filter.
  5728. * @param {Array} filters An array of functions that can mutate with the provided node.
  5729. * @param {Object} schema The schema to use.
  5730. *
  5731. * @return {string} The filtered HTML.
  5732. */
  5733. function deepFilterHTML(HTML, filters = [], schema) {
  5734. const doc = document.implementation.createHTMLDocument('');
  5735. doc.body.innerHTML = HTML;
  5736. deepFilterNodeList(doc.body.childNodes, filters, doc, schema);
  5737. return doc.body.innerHTML;
  5738. }
  5739. /**
  5740. * Gets a sibling within text-level context.
  5741. *
  5742. * @param {Element} node The subject node.
  5743. * @param {string} which "next" or "previous".
  5744. */
  5745. function getSibling(node, which) {
  5746. const sibling = node[`${which}Sibling`];
  5747. if (sibling && Object(external_wp_dom_["isPhrasingContent"])(sibling)) {
  5748. return sibling;
  5749. }
  5750. const {
  5751. parentNode
  5752. } = node;
  5753. if (!parentNode || !Object(external_wp_dom_["isPhrasingContent"])(parentNode)) {
  5754. return;
  5755. }
  5756. return getSibling(parentNode, which);
  5757. }
  5758. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/html-formatting-remover.js
  5759. /**
  5760. * Internal dependencies
  5761. */
  5762. function isFormattingSpace(character) {
  5763. return character === ' ' || character === '\r' || character === '\n' || character === '\t';
  5764. }
  5765. /**
  5766. * Removes spacing that formats HTML.
  5767. *
  5768. * @see https://www.w3.org/TR/css-text-3/#white-space-processing
  5769. *
  5770. * @param {Node} node The node to be processed.
  5771. * @return {void}
  5772. */
  5773. function htmlFormattingRemover(node) {
  5774. if (node.nodeType !== node.TEXT_NODE) {
  5775. return;
  5776. } // Ignore pre content. Note that this does not use Element#closest due to
  5777. // a combination of (a) node may not be Element and (b) node.parentElement
  5778. // does not have full support in all browsers (Internet Exporer).
  5779. //
  5780. // See: https://developer.mozilla.org/en-US/docs/Web/API/Node/parentElement#Browser_compatibility
  5781. /** @type {Node?} */
  5782. let parent = node;
  5783. while (parent = parent.parentNode) {
  5784. if (parent.nodeType === parent.ELEMENT_NODE && parent.nodeName === 'PRE') {
  5785. return;
  5786. }
  5787. } // First, replace any sequence of HTML formatting space with a single space.
  5788. let newData = node.data.replace(/[ \r\n\t]+/g, ' '); // Remove the leading space if the text element is at the start of a block,
  5789. // is preceded by a line break element, or has a space in the previous
  5790. // node.
  5791. if (newData[0] === ' ') {
  5792. const previousSibling = getSibling(node, 'previous');
  5793. if (!previousSibling || previousSibling.nodeName === 'BR' || previousSibling.textContent.slice(-1) === ' ') {
  5794. newData = newData.slice(1);
  5795. }
  5796. } // Remove the trailing space if the text element is at the end of a block,
  5797. // is succeded by a line break element, or has a space in the next text
  5798. // node.
  5799. if (newData[newData.length - 1] === ' ') {
  5800. const nextSibling = getSibling(node, 'next');
  5801. if (!nextSibling || nextSibling.nodeName === 'BR' || nextSibling.nodeType === nextSibling.TEXT_NODE && isFormattingSpace(nextSibling.textContent[0])) {
  5802. newData = newData.slice(0, -1);
  5803. }
  5804. } // If there's no data left, remove the node, so `previousSibling` stays
  5805. // accurate. Otherwise, update the node data.
  5806. if (!newData) {
  5807. node.parentNode.removeChild(node);
  5808. } else {
  5809. node.data = newData;
  5810. }
  5811. }
  5812. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/br-remover.js
  5813. /**
  5814. * Internal dependencies
  5815. */
  5816. /**
  5817. * Removes trailing br elements from text-level content.
  5818. *
  5819. * @param {Element} node Node to check.
  5820. */
  5821. function brRemover(node) {
  5822. if (node.nodeName !== 'BR') {
  5823. return;
  5824. }
  5825. if (getSibling(node, 'next')) {
  5826. return;
  5827. }
  5828. node.parentNode.removeChild(node);
  5829. }
  5830. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/empty-paragraph-remover.js
  5831. /**
  5832. * Removes empty paragraph elements.
  5833. *
  5834. * @param {Element} node Node to check.
  5835. */
  5836. function emptyParagraphRemover(node) {
  5837. if (node.nodeName !== 'P') {
  5838. return;
  5839. }
  5840. if (node.hasChildNodes()) {
  5841. return;
  5842. }
  5843. node.parentNode.removeChild(node);
  5844. }
  5845. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/paste-handler.js
  5846. /**
  5847. * External dependencies
  5848. */
  5849. /**
  5850. * WordPress dependencies
  5851. */
  5852. /**
  5853. * Internal dependencies
  5854. */
  5855. /**
  5856. * Browser dependencies
  5857. */
  5858. const {
  5859. console: paste_handler_console
  5860. } = window;
  5861. /**
  5862. * Filters HTML to only contain phrasing content.
  5863. *
  5864. * @param {string} HTML The HTML to filter.
  5865. * @param {boolean} preserveWhiteSpace Whether or not to preserve consequent white space.
  5866. *
  5867. * @return {string} HTML only containing phrasing content.
  5868. */
  5869. function filterInlineHTML(HTML, preserveWhiteSpace) {
  5870. HTML = deepFilterHTML(HTML, [googleDocsUIdRemover, phrasingContentReducer, commentRemover]);
  5871. HTML = Object(external_wp_dom_["removeInvalidHTML"])(HTML, Object(external_wp_dom_["getPhrasingContentSchema"])('paste'), {
  5872. inline: true
  5873. });
  5874. if (!preserveWhiteSpace) {
  5875. HTML = deepFilterHTML(HTML, [htmlFormattingRemover, brRemover]);
  5876. } // Allows us to ask for this information when we get a report.
  5877. paste_handler_console.log('Processed inline HTML:\n\n', HTML);
  5878. return HTML;
  5879. }
  5880. /**
  5881. * Converts an HTML string to known blocks. Strips everything else.
  5882. *
  5883. * @param {Object} options
  5884. * @param {string} [options.HTML] The HTML to convert.
  5885. * @param {string} [options.plainText] Plain text version.
  5886. * @param {string} [options.mode] Handle content as blocks or inline content.
  5887. * * 'AUTO': Decide based on the content passed.
  5888. * * 'INLINE': Always handle as inline content, and return string.
  5889. * * 'BLOCKS': Always handle as blocks, and return array of blocks.
  5890. * @param {Array} [options.tagName] The tag into which content will be inserted.
  5891. * @param {boolean} [options.preserveWhiteSpace] Whether or not to preserve consequent white space.
  5892. *
  5893. * @return {Array|string} A list of blocks or a string, depending on `handlerMode`.
  5894. */
  5895. function pasteHandler({
  5896. HTML = '',
  5897. plainText = '',
  5898. mode = 'AUTO',
  5899. tagName,
  5900. preserveWhiteSpace
  5901. }) {
  5902. // First of all, strip any meta tags.
  5903. HTML = HTML.replace(/<meta[^>]+>/g, ''); // Strip Windows markers.
  5904. HTML = HTML.replace(/^\s*<html[^>]*>\s*<body[^>]*>(?:\s*<!--\s*StartFragment\s*-->)?/i, '');
  5905. HTML = HTML.replace(/(?:<!--\s*EndFragment\s*-->\s*)?<\/body>\s*<\/html>\s*$/i, ''); // If we detect block delimiters in HTML, parse entirely as blocks.
  5906. if (mode !== 'INLINE') {
  5907. // Check plain text if there is no HTML.
  5908. const content = HTML ? HTML : plainText;
  5909. if (content.indexOf('<!-- wp:') !== -1) {
  5910. return parseWithGrammar(content);
  5911. }
  5912. } // Normalize unicode to use composed characters.
  5913. // This is unsupported in IE 11 but it's a nice-to-have feature, not mandatory.
  5914. // Not normalizing the content will only affect older browsers and won't
  5915. // entirely break the app.
  5916. // See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
  5917. // See: https://core.trac.wordpress.org/ticket/30130
  5918. // See: https://github.com/WordPress/gutenberg/pull/6983#pullrequestreview-125151075
  5919. if (String.prototype.normalize) {
  5920. HTML = HTML.normalize();
  5921. } // Parse Markdown (and encoded HTML) if:
  5922. // * There is a plain text version.
  5923. // * There is no HTML version, or it has no formatting.
  5924. if (plainText && (!HTML || isPlain(HTML))) {
  5925. HTML = plainText; // The markdown converter (Showdown) trims whitespace.
  5926. if (!/^\s+$/.test(plainText)) {
  5927. HTML = markdownConverter(HTML);
  5928. } // Switch to inline mode if:
  5929. // * The current mode is AUTO.
  5930. // * The original plain text had no line breaks.
  5931. // * The original plain text was not an HTML paragraph.
  5932. // * The converted text is just a paragraph.
  5933. if (mode === 'AUTO' && plainText.indexOf('\n') === -1 && plainText.indexOf('<p>') !== 0 && HTML.indexOf('<p>') === 0) {
  5934. mode = 'INLINE';
  5935. }
  5936. }
  5937. if (mode === 'INLINE') {
  5938. return filterInlineHTML(HTML, preserveWhiteSpace);
  5939. } // An array of HTML strings and block objects. The blocks replace matched
  5940. // shortcodes.
  5941. const pieces = shortcode_converter(HTML); // The call to shortcodeConverter will always return more than one element
  5942. // if shortcodes are matched. The reason is when shortcodes are matched
  5943. // empty HTML strings are included.
  5944. const hasShortcodes = pieces.length > 1;
  5945. if (mode === 'AUTO' && !hasShortcodes && isInlineContent(HTML, tagName)) {
  5946. return filterInlineHTML(HTML, preserveWhiteSpace);
  5947. }
  5948. const phrasingContentSchema = Object(external_wp_dom_["getPhrasingContentSchema"])('paste');
  5949. const blockContentSchema = getBlockContentSchema('paste');
  5950. const blocks = Object(external_lodash_["compact"])(Object(external_lodash_["flatMap"])(pieces, piece => {
  5951. // Already a block from shortcode.
  5952. if (typeof piece !== 'string') {
  5953. return piece;
  5954. }
  5955. const filters = [googleDocsUIdRemover, msListConverter, headRemover, listReducer, imageCorrector, phrasingContentReducer, specialCommentConverter, commentRemover, iframeRemover, figureContentReducer, blockquoteNormaliser];
  5956. const schema = { ...blockContentSchema,
  5957. // Keep top-level phrasing content, normalised by `normaliseBlocks`.
  5958. ...phrasingContentSchema
  5959. };
  5960. piece = deepFilterHTML(piece, filters, blockContentSchema);
  5961. piece = Object(external_wp_dom_["removeInvalidHTML"])(piece, schema);
  5962. piece = normaliseBlocks(piece);
  5963. piece = deepFilterHTML(piece, [htmlFormattingRemover, brRemover, emptyParagraphRemover], blockContentSchema); // Allows us to ask for this information when we get a report.
  5964. paste_handler_console.log('Processed HTML piece:\n\n', piece);
  5965. return htmlToBlocks(piece);
  5966. })); // If we're allowed to return inline content, and there is only one
  5967. // inlineable block, and the original plain text content does not have any
  5968. // line breaks, then treat it as inline paste.
  5969. if (mode === 'AUTO' && blocks.length === 1 && registration_hasBlockSupport(blocks[0].name, '__unstablePasteTextInline', false)) {
  5970. // Don't catch line breaks at the start or end.
  5971. const trimmedPlainText = plainText.replace(/^[\n]+|[\n]+$/g, '');
  5972. if (trimmedPlainText !== '' && trimmedPlainText.indexOf('\n') === -1) {
  5973. return Object(external_wp_dom_["removeInvalidHTML"])(getBlockInnerHTML(blocks[0]), phrasingContentSchema);
  5974. }
  5975. }
  5976. return blocks;
  5977. }
  5978. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/index.js
  5979. /**
  5980. * External dependencies
  5981. */
  5982. /**
  5983. * WordPress dependencies
  5984. */
  5985. /**
  5986. * Internal dependencies
  5987. */
  5988. function deprecatedGetPhrasingContentSchema(context) {
  5989. external_wp_deprecated_default()('wp.blocks.getPhrasingContentSchema', {
  5990. since: '5.6',
  5991. alternative: 'wp.dom.getPhrasingContentSchema'
  5992. });
  5993. return Object(external_wp_dom_["getPhrasingContentSchema"])(context);
  5994. }
  5995. /**
  5996. * Converts an HTML string to known blocks.
  5997. *
  5998. * @param {Object} $1
  5999. * @param {string} $1.HTML The HTML to convert.
  6000. *
  6001. * @return {Array} A list of blocks.
  6002. */
  6003. function rawHandler({
  6004. HTML = ''
  6005. }) {
  6006. // If we detect block delimiters, parse entirely as blocks.
  6007. if (HTML.indexOf('<!-- wp:') !== -1) {
  6008. return parseWithGrammar(HTML);
  6009. } // An array of HTML strings and block objects. The blocks replace matched
  6010. // shortcodes.
  6011. const pieces = shortcode_converter(HTML);
  6012. const blockContentSchema = getBlockContentSchema();
  6013. return Object(external_lodash_["compact"])(Object(external_lodash_["flatMap"])(pieces, piece => {
  6014. // Already a block from shortcode.
  6015. if (typeof piece !== 'string') {
  6016. return piece;
  6017. } // These filters are essential for some blocks to be able to transform
  6018. // from raw HTML. These filters move around some content or add
  6019. // additional tags, they do not remove any content.
  6020. const filters = [// Needed to adjust invalid lists.
  6021. listReducer, // Needed to create more and nextpage blocks.
  6022. specialCommentConverter, // Needed to create media blocks.
  6023. figureContentReducer, // Needed to create the quote block, which cannot handle text
  6024. // without wrapper paragraphs.
  6025. blockquoteNormaliser];
  6026. piece = deepFilterHTML(piece, filters, blockContentSchema);
  6027. piece = normaliseBlocks(piece);
  6028. return htmlToBlocks(piece);
  6029. }));
  6030. }
  6031. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/categories.js
  6032. /**
  6033. * WordPress dependencies
  6034. */
  6035. /**
  6036. * Internal dependencies
  6037. */
  6038. /** @typedef {import('../store/reducer').WPBlockCategory} WPBlockCategory */
  6039. /**
  6040. * Returns all the block categories.
  6041. *
  6042. * @return {WPBlockCategory[]} Block categories.
  6043. */
  6044. function categories_getCategories() {
  6045. return Object(external_wp_data_["select"])(store).getCategories();
  6046. }
  6047. /**
  6048. * Sets the block categories.
  6049. *
  6050. * @param {WPBlockCategory[]} categories Block categories.
  6051. */
  6052. function categories_setCategories(categories) {
  6053. Object(external_wp_data_["dispatch"])(store).setCategories(categories);
  6054. }
  6055. /**
  6056. * Updates a category.
  6057. *
  6058. * @param {string} slug Block category slug.
  6059. * @param {WPBlockCategory} category Object containing the category properties
  6060. * that should be updated.
  6061. */
  6062. function categories_updateCategory(slug, category) {
  6063. Object(external_wp_data_["dispatch"])(store).updateCategory(slug, category);
  6064. }
  6065. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/templates.js
  6066. /**
  6067. * External dependencies
  6068. */
  6069. /**
  6070. * WordPress dependencies
  6071. */
  6072. /**
  6073. * Internal dependencies
  6074. */
  6075. /**
  6076. * Checks whether a list of blocks matches a template by comparing the block names.
  6077. *
  6078. * @param {Array} blocks Block list.
  6079. * @param {Array} template Block template.
  6080. *
  6081. * @return {boolean} Whether the list of blocks matches a templates
  6082. */
  6083. function doBlocksMatchTemplate(blocks = [], template = []) {
  6084. return blocks.length === template.length && Object(external_lodash_["every"])(template, ([name,, innerBlocksTemplate], index) => {
  6085. const block = blocks[index];
  6086. return name === block.name && doBlocksMatchTemplate(block.innerBlocks, innerBlocksTemplate);
  6087. });
  6088. }
  6089. /**
  6090. * Synchronize a block list with a block template.
  6091. *
  6092. * Synchronizing a block list with a block template means that we loop over the blocks
  6093. * keep the block as is if it matches the block at the same position in the template
  6094. * (If it has the same name) and if doesn't match, we create a new block based on the template.
  6095. * Extra blocks not present in the template are removed.
  6096. *
  6097. * @param {Array} blocks Block list.
  6098. * @param {Array} template Block template.
  6099. *
  6100. * @return {Array} Updated Block list.
  6101. */
  6102. function synchronizeBlocksWithTemplate(blocks = [], template) {
  6103. // If no template is provided, return blocks unmodified.
  6104. if (!template) {
  6105. return blocks;
  6106. }
  6107. return Object(external_lodash_["map"])(template, ([name, attributes, innerBlocksTemplate], index) => {
  6108. const block = blocks[index];
  6109. if (block && block.name === name) {
  6110. const innerBlocks = synchronizeBlocksWithTemplate(block.innerBlocks, innerBlocksTemplate);
  6111. return { ...block,
  6112. innerBlocks
  6113. };
  6114. } // To support old templates that were using the "children" format
  6115. // for the attributes using "html" strings now, we normalize the template attributes
  6116. // before creating the blocks.
  6117. const blockType = registration_getBlockType(name);
  6118. const isHTMLAttribute = attributeDefinition => Object(external_lodash_["get"])(attributeDefinition, ['source']) === 'html';
  6119. const isQueryAttribute = attributeDefinition => Object(external_lodash_["get"])(attributeDefinition, ['source']) === 'query';
  6120. const normalizeAttributes = (schema, values) => {
  6121. return Object(external_lodash_["mapValues"])(values, (value, key) => {
  6122. return normalizeAttribute(schema[key], value);
  6123. });
  6124. };
  6125. const normalizeAttribute = (definition, value) => {
  6126. if (isHTMLAttribute(definition) && Object(external_lodash_["isArray"])(value)) {
  6127. // Introduce a deprecated call at this point
  6128. // When we're confident that "children" format should be removed from the templates.
  6129. return Object(external_wp_element_["renderToString"])(value);
  6130. }
  6131. if (isQueryAttribute(definition) && value) {
  6132. return value.map(subValues => {
  6133. return normalizeAttributes(definition.query, subValues);
  6134. });
  6135. }
  6136. return value;
  6137. };
  6138. const normalizedAttributes = normalizeAttributes(Object(external_lodash_["get"])(blockType, ['attributes'], {}), attributes);
  6139. const {
  6140. name: blockName,
  6141. attributes: blockAttributes
  6142. } = convertLegacyBlocks(name, normalizedAttributes);
  6143. return createBlock(blockName, blockAttributes, synchronizeBlocksWithTemplate([], innerBlocksTemplate));
  6144. });
  6145. }
  6146. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/index.js
  6147. // The blocktype is the most important concept within the block API. It defines
  6148. // all aspects of the block configuration and its interfaces, including `edit`
  6149. // and `save`. The transforms specification allows converting one blocktype to
  6150. // another through formulas defined by either the source or the destination.
  6151. // Switching a blocktype is to be considered a one-way operation implying a
  6152. // transformation in the opposite way has to be handled explicitly.
  6153. // The block tree is composed of a collection of block nodes. Blocks contained
  6154. // within other blocks are called inner blocks. An important design
  6155. // consideration is that inner blocks are -- conceptually -- not part of the
  6156. // territory established by the parent block that contains them.
  6157. //
  6158. // This has multiple practical implications: when parsing, we can safely dispose
  6159. // of any block boundary found within a block from the innerHTML property when
  6160. // transfering to state. Not doing so would have a compounding effect on memory
  6161. // and uncertainty over the source of truth. This can be illustrated in how,
  6162. // given a tree of `n` nested blocks, the entry node would have to contain the
  6163. // actual content of each block while each subsequent block node in the state
  6164. // tree would replicate the entire chain `n-1`, meaning the extreme end node
  6165. // would have been replicated `n` times as the tree is traversed and would
  6166. // generate uncertainty as to which one is to hold the current value of the
  6167. // block. For composition, it also means inner blocks can effectively be child
  6168. // components whose mechanisms can be shielded from the `edit` implementation
  6169. // and just passed along.
  6170. // While block transformations account for a specific surface of the API, there
  6171. // are also raw transformations which handle arbitrary sources not made out of
  6172. // blocks but producing block basaed on various heursitics. This includes
  6173. // pasting rich text or HTML data.
  6174. // The process of serialization aims to deflate the internal memory of the block
  6175. // editor and its state representation back into an HTML valid string. This
  6176. // process restores the document integrity and inserts invisible delimiters
  6177. // around each block with HTML comment boundaries which can contain any extra
  6178. // attributes needed to operate with the block later on.
  6179. // Validation is the process of comparing a block source with its output before
  6180. // there is any user input or interaction with a block. When this operation
  6181. // fails -- for whatever reason -- the block is to be considered invalid. As
  6182. // part of validating a block the system will attempt to run the source against
  6183. // any provided deprecation definitions.
  6184. //
  6185. // Worth emphasizing that validation is not a case of whether the markup is
  6186. // merely HTML spec-compliant but about how the editor knows to create such
  6187. // markup and that its inability to create an identical result can be a strong
  6188. // indicator of potential data loss (the invalidation is then a protective
  6189. // measure).
  6190. //
  6191. // The invalidation process can also be deconstructed in phases: 1) validate the
  6192. // block exists; 2) validate the source matches the output; 3) validate the
  6193. // source matches deprecated outputs; 4) work through the significance of
  6194. // differences. These are stacked in a way that favors performance and optimizes
  6195. // for the majority of cases. That is to say, the evaluation logic can become
  6196. // more sophisticated the further down it goes in the process as the cost is
  6197. // accounted for. The first logic checks have to be extremely efficient since
  6198. // they will be run for all valid and invalid blocks alike. However, once a
  6199. // block is detected as invalid -- failing the three first steps -- it is
  6200. // adequate to spend more time determining validity before throwing a conflict.
  6201. // Blocks are inherently indifferent about where the data they operate with ends
  6202. // up being saved. For example, all blocks can have a static and dynamic aspect
  6203. // to them depending on the needs. The static nature of a block is the `save()`
  6204. // definition that is meant to be serialized into HTML and which can be left
  6205. // void. Any block can also register a `render_callback` on the server, which
  6206. // makes its output dynamic either in part or in its totality.
  6207. //
  6208. // Child blocks are defined as a relationship that builds on top of the inner
  6209. // blocks mechanism. A child block is a block node of a particular type that can
  6210. // only exist within the inner block boundaries of a specific parent type. This
  6211. // allows block authors to compose specific blocks that are not meant to be used
  6212. // outside of a specified parent block context. Thus, child blocks extend the
  6213. // concept of inner blocks to support a more direct relationship between sets of
  6214. // blocks. The addition of parent–child would be a subset of the inner block
  6215. // functionality under the premise that certain blocks only make sense as
  6216. // children of another block.
  6217. // Templates are, in a general sense, a basic collection of block nodes with any
  6218. // given set of predefined attributes that are supplied as the initial state of
  6219. // an inner blocks group. These nodes can, in turn, contain any number of nested
  6220. // blocks within their definition. Templates allow both to specify a default
  6221. // state for an editor session or a default set of blocks for any inner block
  6222. // implementation within a specific block.
  6223. // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/index.js
  6224. // A "block" is the abstract term used to describe units of markup that,
  6225. // when composed together, form the content or layout of a page.
  6226. // The API for blocks is exposed via `wp.blocks`.
  6227. //
  6228. // Supported blocks are registered by calling `registerBlockType`. Once registered,
  6229. // the block is made available as an option to the editor interface.
  6230. //
  6231. // Blocks are inferred from the HTML source of a post through a parsing mechanism
  6232. // and then stored as objects in state, from which it is then rendered for editing.
  6233. /***/ }),
  6234. /***/ "1CF3":
  6235. /***/ (function(module, exports) {
  6236. (function() { module.exports = window["wp"]["dom"]; }());
  6237. /***/ }),
  6238. /***/ "1ZqX":
  6239. /***/ (function(module, exports) {
  6240. (function() { module.exports = window["wp"]["data"]; }());
  6241. /***/ }),
  6242. /***/ "7Cbv":
  6243. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6244. "use strict";
  6245. // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js
  6246. // Unique ID creation requires a high quality random # generator. In the browser we therefore
  6247. // require the crypto API and do not support built-in fallback to lower quality random number
  6248. // generators (like Math.random()).
  6249. var getRandomValues;
  6250. var rnds8 = new Uint8Array(16);
  6251. function rng() {
  6252. // lazy load so that environments that need to polyfill have a chance to do so
  6253. if (!getRandomValues) {
  6254. // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
  6255. // find the complete implementation of crypto (msCrypto) on IE11.
  6256. getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
  6257. if (!getRandomValues) {
  6258. throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
  6259. }
  6260. }
  6261. return getRandomValues(rnds8);
  6262. }
  6263. // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/regex.js
  6264. /* harmony default export */ var regex = (/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i);
  6265. // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/validate.js
  6266. function validate(uuid) {
  6267. return typeof uuid === 'string' && regex.test(uuid);
  6268. }
  6269. /* harmony default export */ var esm_browser_validate = (validate);
  6270. // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js
  6271. /**
  6272. * Convert array of 16 byte values to UUID string format of the form:
  6273. * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
  6274. */
  6275. var byteToHex = [];
  6276. for (var stringify_i = 0; stringify_i < 256; ++stringify_i) {
  6277. byteToHex.push((stringify_i + 0x100).toString(16).substr(1));
  6278. }
  6279. function stringify(arr) {
  6280. var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  6281. // Note: Be careful editing this code! It's been tuned for performance
  6282. // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
  6283. var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
  6284. // of the following:
  6285. // - One or more input array values don't map to a hex octet (leading to
  6286. // "undefined" in the uuid)
  6287. // - Invalid input values for the RFC `version` or `variant` fields
  6288. if (!esm_browser_validate(uuid)) {
  6289. throw TypeError('Stringified UUID is invalid');
  6290. }
  6291. return uuid;
  6292. }
  6293. /* harmony default export */ var esm_browser_stringify = (stringify);
  6294. // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js
  6295. function v4(options, buf, offset) {
  6296. options = options || {};
  6297. var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
  6298. rnds[6] = rnds[6] & 0x0f | 0x40;
  6299. rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
  6300. if (buf) {
  6301. offset = offset || 0;
  6302. for (var i = 0; i < 16; ++i) {
  6303. buf[offset + i] = rnds[i];
  6304. }
  6305. return buf;
  6306. }
  6307. return esm_browser_stringify(rnds);
  6308. }
  6309. /* harmony default export */ var esm_browser_v4 = __webpack_exports__["a"] = (v4);
  6310. /***/ }),
  6311. /***/ "GRId":
  6312. /***/ (function(module, exports) {
  6313. (function() { module.exports = window["wp"]["element"]; }());
  6314. /***/ }),
  6315. /***/ "K9lf":
  6316. /***/ (function(module, exports) {
  6317. (function() { module.exports = window["wp"]["compose"]; }());
  6318. /***/ }),
  6319. /***/ "M55E":
  6320. /***/ (function(module, exports, __webpack_require__) {
  6321. var __WEBPACK_AMD_DEFINE_RESULT__;;/*! showdown v 1.9.1 - 02-11-2019 */
  6322. (function(){
  6323. /**
  6324. * Created by Tivie on 13-07-2015.
  6325. */
  6326. function getDefaultOpts (simple) {
  6327. 'use strict';
  6328. var defaultOptions = {
  6329. omitExtraWLInCodeBlocks: {
  6330. defaultValue: false,
  6331. describe: 'Omit the default extra whiteline added to code blocks',
  6332. type: 'boolean'
  6333. },
  6334. noHeaderId: {
  6335. defaultValue: false,
  6336. describe: 'Turn on/off generated header id',
  6337. type: 'boolean'
  6338. },
  6339. prefixHeaderId: {
  6340. defaultValue: false,
  6341. describe: 'Add a prefix to the generated header ids. Passing a string will prefix that string to the header id. Setting to true will add a generic \'section-\' prefix',
  6342. type: 'string'
  6343. },
  6344. rawPrefixHeaderId: {
  6345. defaultValue: false,
  6346. describe: 'Setting this option to true will prevent showdown from modifying the prefix. This might result in malformed IDs (if, for instance, the " char is used in the prefix)',
  6347. type: 'boolean'
  6348. },
  6349. ghCompatibleHeaderId: {
  6350. defaultValue: false,
  6351. describe: 'Generate header ids compatible with github style (spaces are replaced with dashes, a bunch of non alphanumeric chars are removed)',
  6352. type: 'boolean'
  6353. },
  6354. rawHeaderId: {
  6355. defaultValue: false,
  6356. describe: 'Remove only spaces, \' and " from generated header ids (including prefixes), replacing them with dashes (-). WARNING: This might result in malformed ids',
  6357. type: 'boolean'
  6358. },
  6359. headerLevelStart: {
  6360. defaultValue: false,
  6361. describe: 'The header blocks level start',
  6362. type: 'integer'
  6363. },
  6364. parseImgDimensions: {
  6365. defaultValue: false,
  6366. describe: 'Turn on/off image dimension parsing',
  6367. type: 'boolean'
  6368. },
  6369. simplifiedAutoLink: {
  6370. defaultValue: false,
  6371. describe: 'Turn on/off GFM autolink style',
  6372. type: 'boolean'
  6373. },
  6374. excludeTrailingPunctuationFromURLs: {
  6375. defaultValue: false,
  6376. describe: 'Excludes trailing punctuation from links generated with autoLinking',
  6377. type: 'boolean'
  6378. },
  6379. literalMidWordUnderscores: {
  6380. defaultValue: false,
  6381. describe: 'Parse midword underscores as literal underscores',
  6382. type: 'boolean'
  6383. },
  6384. literalMidWordAsterisks: {
  6385. defaultValue: false,
  6386. describe: 'Parse midword asterisks as literal asterisks',
  6387. type: 'boolean'
  6388. },
  6389. strikethrough: {
  6390. defaultValue: false,
  6391. describe: 'Turn on/off strikethrough support',
  6392. type: 'boolean'
  6393. },
  6394. tables: {
  6395. defaultValue: false,
  6396. describe: 'Turn on/off tables support',
  6397. type: 'boolean'
  6398. },
  6399. tablesHeaderId: {
  6400. defaultValue: false,
  6401. describe: 'Add an id to table headers',
  6402. type: 'boolean'
  6403. },
  6404. ghCodeBlocks: {
  6405. defaultValue: true,
  6406. describe: 'Turn on/off GFM fenced code blocks support',
  6407. type: 'boolean'
  6408. },
  6409. tasklists: {
  6410. defaultValue: false,
  6411. describe: 'Turn on/off GFM tasklist support',
  6412. type: 'boolean'
  6413. },
  6414. smoothLivePreview: {
  6415. defaultValue: false,
  6416. describe: 'Prevents weird effects in live previews due to incomplete input',
  6417. type: 'boolean'
  6418. },
  6419. smartIndentationFix: {
  6420. defaultValue: false,
  6421. description: 'Tries to smartly fix indentation in es6 strings',
  6422. type: 'boolean'
  6423. },
  6424. disableForced4SpacesIndentedSublists: {
  6425. defaultValue: false,
  6426. description: 'Disables the requirement of indenting nested sublists by 4 spaces',
  6427. type: 'boolean'
  6428. },
  6429. simpleLineBreaks: {
  6430. defaultValue: false,
  6431. description: 'Parses simple line breaks as <br> (GFM Style)',
  6432. type: 'boolean'
  6433. },
  6434. requireSpaceBeforeHeadingText: {
  6435. defaultValue: false,
  6436. description: 'Makes adding a space between `#` and the header text mandatory (GFM Style)',
  6437. type: 'boolean'
  6438. },
  6439. ghMentions: {
  6440. defaultValue: false,
  6441. description: 'Enables github @mentions',
  6442. type: 'boolean'
  6443. },
  6444. ghMentionsLink: {
  6445. defaultValue: 'https://github.com/{u}',
  6446. description: 'Changes the link generated by @mentions. Only applies if ghMentions option is enabled.',
  6447. type: 'string'
  6448. },
  6449. encodeEmails: {
  6450. defaultValue: true,
  6451. description: 'Encode e-mail addresses through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities',
  6452. type: 'boolean'
  6453. },
  6454. openLinksInNewWindow: {
  6455. defaultValue: false,
  6456. description: 'Open all links in new windows',
  6457. type: 'boolean'
  6458. },
  6459. backslashEscapesHTMLTags: {
  6460. defaultValue: false,
  6461. description: 'Support for HTML Tag escaping. ex: \<div>foo\</div>',
  6462. type: 'boolean'
  6463. },
  6464. emoji: {
  6465. defaultValue: false,
  6466. description: 'Enable emoji support. Ex: `this is a :smile: emoji`',
  6467. type: 'boolean'
  6468. },
  6469. underline: {
  6470. defaultValue: false,
  6471. description: 'Enable support for underline. Syntax is double or triple underscores: `__underline word__`. With this option enabled, underscores no longer parses into `<em>` and `<strong>`',
  6472. type: 'boolean'
  6473. },
  6474. completeHTMLDocument: {
  6475. defaultValue: false,
  6476. description: 'Outputs a complete html document, including `<html>`, `<head>` and `<body>` tags',
  6477. type: 'boolean'
  6478. },
  6479. metadata: {
  6480. defaultValue: false,
  6481. description: 'Enable support for document metadata (defined at the top of the document between `«««` and `»»»` or between `---` and `---`).',
  6482. type: 'boolean'
  6483. },
  6484. splitAdjacentBlockquotes: {
  6485. defaultValue: false,
  6486. description: 'Split adjacent blockquote blocks',
  6487. type: 'boolean'
  6488. }
  6489. };
  6490. if (simple === false) {
  6491. return JSON.parse(JSON.stringify(defaultOptions));
  6492. }
  6493. var ret = {};
  6494. for (var opt in defaultOptions) {
  6495. if (defaultOptions.hasOwnProperty(opt)) {
  6496. ret[opt] = defaultOptions[opt].defaultValue;
  6497. }
  6498. }
  6499. return ret;
  6500. }
  6501. function allOptionsOn () {
  6502. 'use strict';
  6503. var options = getDefaultOpts(true),
  6504. ret = {};
  6505. for (var opt in options) {
  6506. if (options.hasOwnProperty(opt)) {
  6507. ret[opt] = true;
  6508. }
  6509. }
  6510. return ret;
  6511. }
  6512. /**
  6513. * Created by Tivie on 06-01-2015.
  6514. */
  6515. // Private properties
  6516. var showdown = {},
  6517. parsers = {},
  6518. extensions = {},
  6519. globalOptions = getDefaultOpts(true),
  6520. setFlavor = 'vanilla',
  6521. flavor = {
  6522. github: {
  6523. omitExtraWLInCodeBlocks: true,
  6524. simplifiedAutoLink: true,
  6525. excludeTrailingPunctuationFromURLs: true,
  6526. literalMidWordUnderscores: true,
  6527. strikethrough: true,
  6528. tables: true,
  6529. tablesHeaderId: true,
  6530. ghCodeBlocks: true,
  6531. tasklists: true,
  6532. disableForced4SpacesIndentedSublists: true,
  6533. simpleLineBreaks: true,
  6534. requireSpaceBeforeHeadingText: true,
  6535. ghCompatibleHeaderId: true,
  6536. ghMentions: true,
  6537. backslashEscapesHTMLTags: true,
  6538. emoji: true,
  6539. splitAdjacentBlockquotes: true
  6540. },
  6541. original: {
  6542. noHeaderId: true,
  6543. ghCodeBlocks: false
  6544. },
  6545. ghost: {
  6546. omitExtraWLInCodeBlocks: true,
  6547. parseImgDimensions: true,
  6548. simplifiedAutoLink: true,
  6549. excludeTrailingPunctuationFromURLs: true,
  6550. literalMidWordUnderscores: true,
  6551. strikethrough: true,
  6552. tables: true,
  6553. tablesHeaderId: true,
  6554. ghCodeBlocks: true,
  6555. tasklists: true,
  6556. smoothLivePreview: true,
  6557. simpleLineBreaks: true,
  6558. requireSpaceBeforeHeadingText: true,
  6559. ghMentions: false,
  6560. encodeEmails: true
  6561. },
  6562. vanilla: getDefaultOpts(true),
  6563. allOn: allOptionsOn()
  6564. };
  6565. /**
  6566. * helper namespace
  6567. * @type {{}}
  6568. */
  6569. showdown.helper = {};
  6570. /**
  6571. * TODO LEGACY SUPPORT CODE
  6572. * @type {{}}
  6573. */
  6574. showdown.extensions = {};
  6575. /**
  6576. * Set a global option
  6577. * @static
  6578. * @param {string} key
  6579. * @param {*} value
  6580. * @returns {showdown}
  6581. */
  6582. showdown.setOption = function (key, value) {
  6583. 'use strict';
  6584. globalOptions[key] = value;
  6585. return this;
  6586. };
  6587. /**
  6588. * Get a global option
  6589. * @static
  6590. * @param {string} key
  6591. * @returns {*}
  6592. */
  6593. showdown.getOption = function (key) {
  6594. 'use strict';
  6595. return globalOptions[key];
  6596. };
  6597. /**
  6598. * Get the global options
  6599. * @static
  6600. * @returns {{}}
  6601. */
  6602. showdown.getOptions = function () {
  6603. 'use strict';
  6604. return globalOptions;
  6605. };
  6606. /**
  6607. * Reset global options to the default values
  6608. * @static
  6609. */
  6610. showdown.resetOptions = function () {
  6611. 'use strict';
  6612. globalOptions = getDefaultOpts(true);
  6613. };
  6614. /**
  6615. * Set the flavor showdown should use as default
  6616. * @param {string} name
  6617. */
  6618. showdown.setFlavor = function (name) {
  6619. 'use strict';
  6620. if (!flavor.hasOwnProperty(name)) {
  6621. throw Error(name + ' flavor was not found');
  6622. }
  6623. showdown.resetOptions();
  6624. var preset = flavor[name];
  6625. setFlavor = name;
  6626. for (var option in preset) {
  6627. if (preset.hasOwnProperty(option)) {
  6628. globalOptions[option] = preset[option];
  6629. }
  6630. }
  6631. };
  6632. /**
  6633. * Get the currently set flavor
  6634. * @returns {string}
  6635. */
  6636. showdown.getFlavor = function () {
  6637. 'use strict';
  6638. return setFlavor;
  6639. };
  6640. /**
  6641. * Get the options of a specified flavor. Returns undefined if the flavor was not found
  6642. * @param {string} name Name of the flavor
  6643. * @returns {{}|undefined}
  6644. */
  6645. showdown.getFlavorOptions = function (name) {
  6646. 'use strict';
  6647. if (flavor.hasOwnProperty(name)) {
  6648. return flavor[name];
  6649. }
  6650. };
  6651. /**
  6652. * Get the default options
  6653. * @static
  6654. * @param {boolean} [simple=true]
  6655. * @returns {{}}
  6656. */
  6657. showdown.getDefaultOptions = function (simple) {
  6658. 'use strict';
  6659. return getDefaultOpts(simple);
  6660. };
  6661. /**
  6662. * Get or set a subParser
  6663. *
  6664. * subParser(name) - Get a registered subParser
  6665. * subParser(name, func) - Register a subParser
  6666. * @static
  6667. * @param {string} name
  6668. * @param {function} [func]
  6669. * @returns {*}
  6670. */
  6671. showdown.subParser = function (name, func) {
  6672. 'use strict';
  6673. if (showdown.helper.isString(name)) {
  6674. if (typeof func !== 'undefined') {
  6675. parsers[name] = func;
  6676. } else {
  6677. if (parsers.hasOwnProperty(name)) {
  6678. return parsers[name];
  6679. } else {
  6680. throw Error('SubParser named ' + name + ' not registered!');
  6681. }
  6682. }
  6683. }
  6684. };
  6685. /**
  6686. * Gets or registers an extension
  6687. * @static
  6688. * @param {string} name
  6689. * @param {object|function=} ext
  6690. * @returns {*}
  6691. */
  6692. showdown.extension = function (name, ext) {
  6693. 'use strict';
  6694. if (!showdown.helper.isString(name)) {
  6695. throw Error('Extension \'name\' must be a string');
  6696. }
  6697. name = showdown.helper.stdExtName(name);
  6698. // Getter
  6699. if (showdown.helper.isUndefined(ext)) {
  6700. if (!extensions.hasOwnProperty(name)) {
  6701. throw Error('Extension named ' + name + ' is not registered!');
  6702. }
  6703. return extensions[name];
  6704. // Setter
  6705. } else {
  6706. // Expand extension if it's wrapped in a function
  6707. if (typeof ext === 'function') {
  6708. ext = ext();
  6709. }
  6710. // Ensure extension is an array
  6711. if (!showdown.helper.isArray(ext)) {
  6712. ext = [ext];
  6713. }
  6714. var validExtension = validate(ext, name);
  6715. if (validExtension.valid) {
  6716. extensions[name] = ext;
  6717. } else {
  6718. throw Error(validExtension.error);
  6719. }
  6720. }
  6721. };
  6722. /**
  6723. * Gets all extensions registered
  6724. * @returns {{}}
  6725. */
  6726. showdown.getAllExtensions = function () {
  6727. 'use strict';
  6728. return extensions;
  6729. };
  6730. /**
  6731. * Remove an extension
  6732. * @param {string} name
  6733. */
  6734. showdown.removeExtension = function (name) {
  6735. 'use strict';
  6736. delete extensions[name];
  6737. };
  6738. /**
  6739. * Removes all extensions
  6740. */
  6741. showdown.resetExtensions = function () {
  6742. 'use strict';
  6743. extensions = {};
  6744. };
  6745. /**
  6746. * Validate extension
  6747. * @param {array} extension
  6748. * @param {string} name
  6749. * @returns {{valid: boolean, error: string}}
  6750. */
  6751. function validate (extension, name) {
  6752. 'use strict';
  6753. var errMsg = (name) ? 'Error in ' + name + ' extension->' : 'Error in unnamed extension',
  6754. ret = {
  6755. valid: true,
  6756. error: ''
  6757. };
  6758. if (!showdown.helper.isArray(extension)) {
  6759. extension = [extension];
  6760. }
  6761. for (var i = 0; i < extension.length; ++i) {
  6762. var baseMsg = errMsg + ' sub-extension ' + i + ': ',
  6763. ext = extension[i];
  6764. if (typeof ext !== 'object') {
  6765. ret.valid = false;
  6766. ret.error = baseMsg + 'must be an object, but ' + typeof ext + ' given';
  6767. return ret;
  6768. }
  6769. if (!showdown.helper.isString(ext.type)) {
  6770. ret.valid = false;
  6771. ret.error = baseMsg + 'property "type" must be a string, but ' + typeof ext.type + ' given';
  6772. return ret;
  6773. }
  6774. var type = ext.type = ext.type.toLowerCase();
  6775. // normalize extension type
  6776. if (type === 'language') {
  6777. type = ext.type = 'lang';
  6778. }
  6779. if (type === 'html') {
  6780. type = ext.type = 'output';
  6781. }
  6782. if (type !== 'lang' && type !== 'output' && type !== 'listener') {
  6783. ret.valid = false;
  6784. ret.error = baseMsg + 'type ' + type + ' is not recognized. Valid values: "lang/language", "output/html" or "listener"';
  6785. return ret;
  6786. }
  6787. if (type === 'listener') {
  6788. if (showdown.helper.isUndefined(ext.listeners)) {
  6789. ret.valid = false;
  6790. ret.error = baseMsg + '. Extensions of type "listener" must have a property called "listeners"';
  6791. return ret;
  6792. }
  6793. } else {
  6794. if (showdown.helper.isUndefined(ext.filter) && showdown.helper.isUndefined(ext.regex)) {
  6795. ret.valid = false;
  6796. ret.error = baseMsg + type + ' extensions must define either a "regex" property or a "filter" method';
  6797. return ret;
  6798. }
  6799. }
  6800. if (ext.listeners) {
  6801. if (typeof ext.listeners !== 'object') {
  6802. ret.valid = false;
  6803. ret.error = baseMsg + '"listeners" property must be an object but ' + typeof ext.listeners + ' given';
  6804. return ret;
  6805. }
  6806. for (var ln in ext.listeners) {
  6807. if (ext.listeners.hasOwnProperty(ln)) {
  6808. if (typeof ext.listeners[ln] !== 'function') {
  6809. ret.valid = false;
  6810. ret.error = baseMsg + '"listeners" property must be an hash of [event name]: [callback]. listeners.' + ln +
  6811. ' must be a function but ' + typeof ext.listeners[ln] + ' given';
  6812. return ret;
  6813. }
  6814. }
  6815. }
  6816. }
  6817. if (ext.filter) {
  6818. if (typeof ext.filter !== 'function') {
  6819. ret.valid = false;
  6820. ret.error = baseMsg + '"filter" must be a function, but ' + typeof ext.filter + ' given';
  6821. return ret;
  6822. }
  6823. } else if (ext.regex) {
  6824. if (showdown.helper.isString(ext.regex)) {
  6825. ext.regex = new RegExp(ext.regex, 'g');
  6826. }
  6827. if (!(ext.regex instanceof RegExp)) {
  6828. ret.valid = false;
  6829. ret.error = baseMsg + '"regex" property must either be a string or a RegExp object, but ' + typeof ext.regex + ' given';
  6830. return ret;
  6831. }
  6832. if (showdown.helper.isUndefined(ext.replace)) {
  6833. ret.valid = false;
  6834. ret.error = baseMsg + '"regex" extensions must implement a replace string or function';
  6835. return ret;
  6836. }
  6837. }
  6838. }
  6839. return ret;
  6840. }
  6841. /**
  6842. * Validate extension
  6843. * @param {object} ext
  6844. * @returns {boolean}
  6845. */
  6846. showdown.validateExtension = function (ext) {
  6847. 'use strict';
  6848. var validateExtension = validate(ext, null);
  6849. if (!validateExtension.valid) {
  6850. console.warn(validateExtension.error);
  6851. return false;
  6852. }
  6853. return true;
  6854. };
  6855. /**
  6856. * showdownjs helper functions
  6857. */
  6858. if (!showdown.hasOwnProperty('helper')) {
  6859. showdown.helper = {};
  6860. }
  6861. /**
  6862. * Check if var is string
  6863. * @static
  6864. * @param {string} a
  6865. * @returns {boolean}
  6866. */
  6867. showdown.helper.isString = function (a) {
  6868. 'use strict';
  6869. return (typeof a === 'string' || a instanceof String);
  6870. };
  6871. /**
  6872. * Check if var is a function
  6873. * @static
  6874. * @param {*} a
  6875. * @returns {boolean}
  6876. */
  6877. showdown.helper.isFunction = function (a) {
  6878. 'use strict';
  6879. var getType = {};
  6880. return a && getType.toString.call(a) === '[object Function]';
  6881. };
  6882. /**
  6883. * isArray helper function
  6884. * @static
  6885. * @param {*} a
  6886. * @returns {boolean}
  6887. */
  6888. showdown.helper.isArray = function (a) {
  6889. 'use strict';
  6890. return Array.isArray(a);
  6891. };
  6892. /**
  6893. * Check if value is undefined
  6894. * @static
  6895. * @param {*} value The value to check.
  6896. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  6897. */
  6898. showdown.helper.isUndefined = function (value) {
  6899. 'use strict';
  6900. return typeof value === 'undefined';
  6901. };
  6902. /**
  6903. * ForEach helper function
  6904. * Iterates over Arrays and Objects (own properties only)
  6905. * @static
  6906. * @param {*} obj
  6907. * @param {function} callback Accepts 3 params: 1. value, 2. key, 3. the original array/object
  6908. */
  6909. showdown.helper.forEach = function (obj, callback) {
  6910. 'use strict';
  6911. // check if obj is defined
  6912. if (showdown.helper.isUndefined(obj)) {
  6913. throw new Error('obj param is required');
  6914. }
  6915. if (showdown.helper.isUndefined(callback)) {
  6916. throw new Error('callback param is required');
  6917. }
  6918. if (!showdown.helper.isFunction(callback)) {
  6919. throw new Error('callback param must be a function/closure');
  6920. }
  6921. if (typeof obj.forEach === 'function') {
  6922. obj.forEach(callback);
  6923. } else if (showdown.helper.isArray(obj)) {
  6924. for (var i = 0; i < obj.length; i++) {
  6925. callback(obj[i], i, obj);
  6926. }
  6927. } else if (typeof (obj) === 'object') {
  6928. for (var prop in obj) {
  6929. if (obj.hasOwnProperty(prop)) {
  6930. callback(obj[prop], prop, obj);
  6931. }
  6932. }
  6933. } else {
  6934. throw new Error('obj does not seem to be an array or an iterable object');
  6935. }
  6936. };
  6937. /**
  6938. * Standardidize extension name
  6939. * @static
  6940. * @param {string} s extension name
  6941. * @returns {string}
  6942. */
  6943. showdown.helper.stdExtName = function (s) {
  6944. 'use strict';
  6945. return s.replace(/[_?*+\/\\.^-]/g, '').replace(/\s/g, '').toLowerCase();
  6946. };
  6947. function escapeCharactersCallback (wholeMatch, m1) {
  6948. 'use strict';
  6949. var charCodeToEscape = m1.charCodeAt(0);
  6950. return '¨E' + charCodeToEscape + 'E';
  6951. }
  6952. /**
  6953. * Callback used to escape characters when passing through String.replace
  6954. * @static
  6955. * @param {string} wholeMatch
  6956. * @param {string} m1
  6957. * @returns {string}
  6958. */
  6959. showdown.helper.escapeCharactersCallback = escapeCharactersCallback;
  6960. /**
  6961. * Escape characters in a string
  6962. * @static
  6963. * @param {string} text
  6964. * @param {string} charsToEscape
  6965. * @param {boolean} afterBackslash
  6966. * @returns {XML|string|void|*}
  6967. */
  6968. showdown.helper.escapeCharacters = function (text, charsToEscape, afterBackslash) {
  6969. 'use strict';
  6970. // First we have to escape the escape characters so that
  6971. // we can build a character class out of them
  6972. var regexString = '([' + charsToEscape.replace(/([\[\]\\])/g, '\\$1') + '])';
  6973. if (afterBackslash) {
  6974. regexString = '\\\\' + regexString;
  6975. }
  6976. var regex = new RegExp(regexString, 'g');
  6977. text = text.replace(regex, escapeCharactersCallback);
  6978. return text;
  6979. };
  6980. /**
  6981. * Unescape HTML entities
  6982. * @param txt
  6983. * @returns {string}
  6984. */
  6985. showdown.helper.unescapeHTMLEntities = function (txt) {
  6986. 'use strict';
  6987. return txt
  6988. .replace(/&quot;/g, '"')
  6989. .replace(/&lt;/g, '<')
  6990. .replace(/&gt;/g, '>')
  6991. .replace(/&amp;/g, '&');
  6992. };
  6993. var rgxFindMatchPos = function (str, left, right, flags) {
  6994. 'use strict';
  6995. var f = flags || '',
  6996. g = f.indexOf('g') > -1,
  6997. x = new RegExp(left + '|' + right, 'g' + f.replace(/g/g, '')),
  6998. l = new RegExp(left, f.replace(/g/g, '')),
  6999. pos = [],
  7000. t, s, m, start, end;
  7001. do {
  7002. t = 0;
  7003. while ((m = x.exec(str))) {
  7004. if (l.test(m[0])) {
  7005. if (!(t++)) {
  7006. s = x.lastIndex;
  7007. start = s - m[0].length;
  7008. }
  7009. } else if (t) {
  7010. if (!--t) {
  7011. end = m.index + m[0].length;
  7012. var obj = {
  7013. left: {start: start, end: s},
  7014. match: {start: s, end: m.index},
  7015. right: {start: m.index, end: end},
  7016. wholeMatch: {start: start, end: end}
  7017. };
  7018. pos.push(obj);
  7019. if (!g) {
  7020. return pos;
  7021. }
  7022. }
  7023. }
  7024. }
  7025. } while (t && (x.lastIndex = s));
  7026. return pos;
  7027. };
  7028. /**
  7029. * matchRecursiveRegExp
  7030. *
  7031. * (c) 2007 Steven Levithan <stevenlevithan.com>
  7032. * MIT License
  7033. *
  7034. * Accepts a string to search, a left and right format delimiter
  7035. * as regex patterns, and optional regex flags. Returns an array
  7036. * of matches, allowing nested instances of left/right delimiters.
  7037. * Use the "g" flag to return all matches, otherwise only the
  7038. * first is returned. Be careful to ensure that the left and
  7039. * right format delimiters produce mutually exclusive matches.
  7040. * Backreferences are not supported within the right delimiter
  7041. * due to how it is internally combined with the left delimiter.
  7042. * When matching strings whose format delimiters are unbalanced
  7043. * to the left or right, the output is intentionally as a
  7044. * conventional regex library with recursion support would
  7045. * produce, e.g. "<<x>" and "<x>>" both produce ["x"] when using
  7046. * "<" and ">" as the delimiters (both strings contain a single,
  7047. * balanced instance of "<x>").
  7048. *
  7049. * examples:
  7050. * matchRecursiveRegExp("test", "\\(", "\\)")
  7051. * returns: []
  7052. * matchRecursiveRegExp("<t<<e>><s>>t<>", "<", ">", "g")
  7053. * returns: ["t<<e>><s>", ""]
  7054. * matchRecursiveRegExp("<div id=\"x\">test</div>", "<div\\b[^>]*>", "</div>", "gi")
  7055. * returns: ["test"]
  7056. */
  7057. showdown.helper.matchRecursiveRegExp = function (str, left, right, flags) {
  7058. 'use strict';
  7059. var matchPos = rgxFindMatchPos (str, left, right, flags),
  7060. results = [];
  7061. for (var i = 0; i < matchPos.length; ++i) {
  7062. results.push([
  7063. str.slice(matchPos[i].wholeMatch.start, matchPos[i].wholeMatch.end),
  7064. str.slice(matchPos[i].match.start, matchPos[i].match.end),
  7065. str.slice(matchPos[i].left.start, matchPos[i].left.end),
  7066. str.slice(matchPos[i].right.start, matchPos[i].right.end)
  7067. ]);
  7068. }
  7069. return results;
  7070. };
  7071. /**
  7072. *
  7073. * @param {string} str
  7074. * @param {string|function} replacement
  7075. * @param {string} left
  7076. * @param {string} right
  7077. * @param {string} flags
  7078. * @returns {string}
  7079. */
  7080. showdown.helper.replaceRecursiveRegExp = function (str, replacement, left, right, flags) {
  7081. 'use strict';
  7082. if (!showdown.helper.isFunction(replacement)) {
  7083. var repStr = replacement;
  7084. replacement = function () {
  7085. return repStr;
  7086. };
  7087. }
  7088. var matchPos = rgxFindMatchPos(str, left, right, flags),
  7089. finalStr = str,
  7090. lng = matchPos.length;
  7091. if (lng > 0) {
  7092. var bits = [];
  7093. if (matchPos[0].wholeMatch.start !== 0) {
  7094. bits.push(str.slice(0, matchPos[0].wholeMatch.start));
  7095. }
  7096. for (var i = 0; i < lng; ++i) {
  7097. bits.push(
  7098. replacement(
  7099. str.slice(matchPos[i].wholeMatch.start, matchPos[i].wholeMatch.end),
  7100. str.slice(matchPos[i].match.start, matchPos[i].match.end),
  7101. str.slice(matchPos[i].left.start, matchPos[i].left.end),
  7102. str.slice(matchPos[i].right.start, matchPos[i].right.end)
  7103. )
  7104. );
  7105. if (i < lng - 1) {
  7106. bits.push(str.slice(matchPos[i].wholeMatch.end, matchPos[i + 1].wholeMatch.start));
  7107. }
  7108. }
  7109. if (matchPos[lng - 1].wholeMatch.end < str.length) {
  7110. bits.push(str.slice(matchPos[lng - 1].wholeMatch.end));
  7111. }
  7112. finalStr = bits.join('');
  7113. }
  7114. return finalStr;
  7115. };
  7116. /**
  7117. * Returns the index within the passed String object of the first occurrence of the specified regex,
  7118. * starting the search at fromIndex. Returns -1 if the value is not found.
  7119. *
  7120. * @param {string} str string to search
  7121. * @param {RegExp} regex Regular expression to search
  7122. * @param {int} [fromIndex = 0] Index to start the search
  7123. * @returns {Number}
  7124. * @throws InvalidArgumentError
  7125. */
  7126. showdown.helper.regexIndexOf = function (str, regex, fromIndex) {
  7127. 'use strict';
  7128. if (!showdown.helper.isString(str)) {
  7129. throw 'InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string';
  7130. }
  7131. if (regex instanceof RegExp === false) {
  7132. throw 'InvalidArgumentError: second parameter of showdown.helper.regexIndexOf function must be an instance of RegExp';
  7133. }
  7134. var indexOf = str.substring(fromIndex || 0).search(regex);
  7135. return (indexOf >= 0) ? (indexOf + (fromIndex || 0)) : indexOf;
  7136. };
  7137. /**
  7138. * Splits the passed string object at the defined index, and returns an array composed of the two substrings
  7139. * @param {string} str string to split
  7140. * @param {int} index index to split string at
  7141. * @returns {[string,string]}
  7142. * @throws InvalidArgumentError
  7143. */
  7144. showdown.helper.splitAtIndex = function (str, index) {
  7145. 'use strict';
  7146. if (!showdown.helper.isString(str)) {
  7147. throw 'InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string';
  7148. }
  7149. return [str.substring(0, index), str.substring(index)];
  7150. };
  7151. /**
  7152. * Obfuscate an e-mail address through the use of Character Entities,
  7153. * transforming ASCII characters into their equivalent decimal or hex entities.
  7154. *
  7155. * Since it has a random component, subsequent calls to this function produce different results
  7156. *
  7157. * @param {string} mail
  7158. * @returns {string}
  7159. */
  7160. showdown.helper.encodeEmailAddress = function (mail) {
  7161. 'use strict';
  7162. var encode = [
  7163. function (ch) {
  7164. return '&#' + ch.charCodeAt(0) + ';';
  7165. },
  7166. function (ch) {
  7167. return '&#x' + ch.charCodeAt(0).toString(16) + ';';
  7168. },
  7169. function (ch) {
  7170. return ch;
  7171. }
  7172. ];
  7173. mail = mail.replace(/./g, function (ch) {
  7174. if (ch === '@') {
  7175. // this *must* be encoded. I insist.
  7176. ch = encode[Math.floor(Math.random() * 2)](ch);
  7177. } else {
  7178. var r = Math.random();
  7179. // roughly 10% raw, 45% hex, 45% dec
  7180. ch = (
  7181. r > 0.9 ? encode[2](ch) : r > 0.45 ? encode[1](ch) : encode[0](ch)
  7182. );
  7183. }
  7184. return ch;
  7185. });
  7186. return mail;
  7187. };
  7188. /**
  7189. *
  7190. * @param str
  7191. * @param targetLength
  7192. * @param padString
  7193. * @returns {string}
  7194. */
  7195. showdown.helper.padEnd = function padEnd (str, targetLength, padString) {
  7196. 'use strict';
  7197. /*jshint bitwise: false*/
  7198. // eslint-disable-next-line space-infix-ops
  7199. targetLength = targetLength>>0; //floor if number or convert non-number to 0;
  7200. /*jshint bitwise: true*/
  7201. padString = String(padString || ' ');
  7202. if (str.length > targetLength) {
  7203. return String(str);
  7204. } else {
  7205. targetLength = targetLength - str.length;
  7206. if (targetLength > padString.length) {
  7207. padString += padString.repeat(targetLength / padString.length); //append to original to ensure we are longer than needed
  7208. }
  7209. return String(str) + padString.slice(0,targetLength);
  7210. }
  7211. };
  7212. /**
  7213. * POLYFILLS
  7214. */
  7215. // use this instead of builtin is undefined for IE8 compatibility
  7216. if (typeof console === 'undefined') {
  7217. console = {
  7218. warn: function (msg) {
  7219. 'use strict';
  7220. alert(msg);
  7221. },
  7222. log: function (msg) {
  7223. 'use strict';
  7224. alert(msg);
  7225. },
  7226. error: function (msg) {
  7227. 'use strict';
  7228. throw msg;
  7229. }
  7230. };
  7231. }
  7232. /**
  7233. * Common regexes.
  7234. * We declare some common regexes to improve performance
  7235. */
  7236. showdown.helper.regexes = {
  7237. asteriskDashAndColon: /([*_:~])/g
  7238. };
  7239. /**
  7240. * EMOJIS LIST
  7241. */
  7242. showdown.helper.emojis = {
  7243. '+1':'\ud83d\udc4d',
  7244. '-1':'\ud83d\udc4e',
  7245. '100':'\ud83d\udcaf',
  7246. '1234':'\ud83d\udd22',
  7247. '1st_place_medal':'\ud83e\udd47',
  7248. '2nd_place_medal':'\ud83e\udd48',
  7249. '3rd_place_medal':'\ud83e\udd49',
  7250. '8ball':'\ud83c\udfb1',
  7251. 'a':'\ud83c\udd70\ufe0f',
  7252. 'ab':'\ud83c\udd8e',
  7253. 'abc':'\ud83d\udd24',
  7254. 'abcd':'\ud83d\udd21',
  7255. 'accept':'\ud83c\ude51',
  7256. 'aerial_tramway':'\ud83d\udea1',
  7257. 'airplane':'\u2708\ufe0f',
  7258. 'alarm_clock':'\u23f0',
  7259. 'alembic':'\u2697\ufe0f',
  7260. 'alien':'\ud83d\udc7d',
  7261. 'ambulance':'\ud83d\ude91',
  7262. 'amphora':'\ud83c\udffa',
  7263. 'anchor':'\u2693\ufe0f',
  7264. 'angel':'\ud83d\udc7c',
  7265. 'anger':'\ud83d\udca2',
  7266. 'angry':'\ud83d\ude20',
  7267. 'anguished':'\ud83d\ude27',
  7268. 'ant':'\ud83d\udc1c',
  7269. 'apple':'\ud83c\udf4e',
  7270. 'aquarius':'\u2652\ufe0f',
  7271. 'aries':'\u2648\ufe0f',
  7272. 'arrow_backward':'\u25c0\ufe0f',
  7273. 'arrow_double_down':'\u23ec',
  7274. 'arrow_double_up':'\u23eb',
  7275. 'arrow_down':'\u2b07\ufe0f',
  7276. 'arrow_down_small':'\ud83d\udd3d',
  7277. 'arrow_forward':'\u25b6\ufe0f',
  7278. 'arrow_heading_down':'\u2935\ufe0f',
  7279. 'arrow_heading_up':'\u2934\ufe0f',
  7280. 'arrow_left':'\u2b05\ufe0f',
  7281. 'arrow_lower_left':'\u2199\ufe0f',
  7282. 'arrow_lower_right':'\u2198\ufe0f',
  7283. 'arrow_right':'\u27a1\ufe0f',
  7284. 'arrow_right_hook':'\u21aa\ufe0f',
  7285. 'arrow_up':'\u2b06\ufe0f',
  7286. 'arrow_up_down':'\u2195\ufe0f',
  7287. 'arrow_up_small':'\ud83d\udd3c',
  7288. 'arrow_upper_left':'\u2196\ufe0f',
  7289. 'arrow_upper_right':'\u2197\ufe0f',
  7290. 'arrows_clockwise':'\ud83d\udd03',
  7291. 'arrows_counterclockwise':'\ud83d\udd04',
  7292. 'art':'\ud83c\udfa8',
  7293. 'articulated_lorry':'\ud83d\ude9b',
  7294. 'artificial_satellite':'\ud83d\udef0',
  7295. 'astonished':'\ud83d\ude32',
  7296. 'athletic_shoe':'\ud83d\udc5f',
  7297. 'atm':'\ud83c\udfe7',
  7298. 'atom_symbol':'\u269b\ufe0f',
  7299. 'avocado':'\ud83e\udd51',
  7300. 'b':'\ud83c\udd71\ufe0f',
  7301. 'baby':'\ud83d\udc76',
  7302. 'baby_bottle':'\ud83c\udf7c',
  7303. 'baby_chick':'\ud83d\udc24',
  7304. 'baby_symbol':'\ud83d\udebc',
  7305. 'back':'\ud83d\udd19',
  7306. 'bacon':'\ud83e\udd53',
  7307. 'badminton':'\ud83c\udff8',
  7308. 'baggage_claim':'\ud83d\udec4',
  7309. 'baguette_bread':'\ud83e\udd56',
  7310. 'balance_scale':'\u2696\ufe0f',
  7311. 'balloon':'\ud83c\udf88',
  7312. 'ballot_box':'\ud83d\uddf3',
  7313. 'ballot_box_with_check':'\u2611\ufe0f',
  7314. 'bamboo':'\ud83c\udf8d',
  7315. 'banana':'\ud83c\udf4c',
  7316. 'bangbang':'\u203c\ufe0f',
  7317. 'bank':'\ud83c\udfe6',
  7318. 'bar_chart':'\ud83d\udcca',
  7319. 'barber':'\ud83d\udc88',
  7320. 'baseball':'\u26be\ufe0f',
  7321. 'basketball':'\ud83c\udfc0',
  7322. 'basketball_man':'\u26f9\ufe0f',
  7323. 'basketball_woman':'\u26f9\ufe0f&zwj;\u2640\ufe0f',
  7324. 'bat':'\ud83e\udd87',
  7325. 'bath':'\ud83d\udec0',
  7326. 'bathtub':'\ud83d\udec1',
  7327. 'battery':'\ud83d\udd0b',
  7328. 'beach_umbrella':'\ud83c\udfd6',
  7329. 'bear':'\ud83d\udc3b',
  7330. 'bed':'\ud83d\udecf',
  7331. 'bee':'\ud83d\udc1d',
  7332. 'beer':'\ud83c\udf7a',
  7333. 'beers':'\ud83c\udf7b',
  7334. 'beetle':'\ud83d\udc1e',
  7335. 'beginner':'\ud83d\udd30',
  7336. 'bell':'\ud83d\udd14',
  7337. 'bellhop_bell':'\ud83d\udece',
  7338. 'bento':'\ud83c\udf71',
  7339. 'biking_man':'\ud83d\udeb4',
  7340. 'bike':'\ud83d\udeb2',
  7341. 'biking_woman':'\ud83d\udeb4&zwj;\u2640\ufe0f',
  7342. 'bikini':'\ud83d\udc59',
  7343. 'biohazard':'\u2623\ufe0f',
  7344. 'bird':'\ud83d\udc26',
  7345. 'birthday':'\ud83c\udf82',
  7346. 'black_circle':'\u26ab\ufe0f',
  7347. 'black_flag':'\ud83c\udff4',
  7348. 'black_heart':'\ud83d\udda4',
  7349. 'black_joker':'\ud83c\udccf',
  7350. 'black_large_square':'\u2b1b\ufe0f',
  7351. 'black_medium_small_square':'\u25fe\ufe0f',
  7352. 'black_medium_square':'\u25fc\ufe0f',
  7353. 'black_nib':'\u2712\ufe0f',
  7354. 'black_small_square':'\u25aa\ufe0f',
  7355. 'black_square_button':'\ud83d\udd32',
  7356. 'blonde_man':'\ud83d\udc71',
  7357. 'blonde_woman':'\ud83d\udc71&zwj;\u2640\ufe0f',
  7358. 'blossom':'\ud83c\udf3c',
  7359. 'blowfish':'\ud83d\udc21',
  7360. 'blue_book':'\ud83d\udcd8',
  7361. 'blue_car':'\ud83d\ude99',
  7362. 'blue_heart':'\ud83d\udc99',
  7363. 'blush':'\ud83d\ude0a',
  7364. 'boar':'\ud83d\udc17',
  7365. 'boat':'\u26f5\ufe0f',
  7366. 'bomb':'\ud83d\udca3',
  7367. 'book':'\ud83d\udcd6',
  7368. 'bookmark':'\ud83d\udd16',
  7369. 'bookmark_tabs':'\ud83d\udcd1',
  7370. 'books':'\ud83d\udcda',
  7371. 'boom':'\ud83d\udca5',
  7372. 'boot':'\ud83d\udc62',
  7373. 'bouquet':'\ud83d\udc90',
  7374. 'bowing_man':'\ud83d\ude47',
  7375. 'bow_and_arrow':'\ud83c\udff9',
  7376. 'bowing_woman':'\ud83d\ude47&zwj;\u2640\ufe0f',
  7377. 'bowling':'\ud83c\udfb3',
  7378. 'boxing_glove':'\ud83e\udd4a',
  7379. 'boy':'\ud83d\udc66',
  7380. 'bread':'\ud83c\udf5e',
  7381. 'bride_with_veil':'\ud83d\udc70',
  7382. 'bridge_at_night':'\ud83c\udf09',
  7383. 'briefcase':'\ud83d\udcbc',
  7384. 'broken_heart':'\ud83d\udc94',
  7385. 'bug':'\ud83d\udc1b',
  7386. 'building_construction':'\ud83c\udfd7',
  7387. 'bulb':'\ud83d\udca1',
  7388. 'bullettrain_front':'\ud83d\ude85',
  7389. 'bullettrain_side':'\ud83d\ude84',
  7390. 'burrito':'\ud83c\udf2f',
  7391. 'bus':'\ud83d\ude8c',
  7392. 'business_suit_levitating':'\ud83d\udd74',
  7393. 'busstop':'\ud83d\ude8f',
  7394. 'bust_in_silhouette':'\ud83d\udc64',
  7395. 'busts_in_silhouette':'\ud83d\udc65',
  7396. 'butterfly':'\ud83e\udd8b',
  7397. 'cactus':'\ud83c\udf35',
  7398. 'cake':'\ud83c\udf70',
  7399. 'calendar':'\ud83d\udcc6',
  7400. 'call_me_hand':'\ud83e\udd19',
  7401. 'calling':'\ud83d\udcf2',
  7402. 'camel':'\ud83d\udc2b',
  7403. 'camera':'\ud83d\udcf7',
  7404. 'camera_flash':'\ud83d\udcf8',
  7405. 'camping':'\ud83c\udfd5',
  7406. 'cancer':'\u264b\ufe0f',
  7407. 'candle':'\ud83d\udd6f',
  7408. 'candy':'\ud83c\udf6c',
  7409. 'canoe':'\ud83d\udef6',
  7410. 'capital_abcd':'\ud83d\udd20',
  7411. 'capricorn':'\u2651\ufe0f',
  7412. 'car':'\ud83d\ude97',
  7413. 'card_file_box':'\ud83d\uddc3',
  7414. 'card_index':'\ud83d\udcc7',
  7415. 'card_index_dividers':'\ud83d\uddc2',
  7416. 'carousel_horse':'\ud83c\udfa0',
  7417. 'carrot':'\ud83e\udd55',
  7418. 'cat':'\ud83d\udc31',
  7419. 'cat2':'\ud83d\udc08',
  7420. 'cd':'\ud83d\udcbf',
  7421. 'chains':'\u26d3',
  7422. 'champagne':'\ud83c\udf7e',
  7423. 'chart':'\ud83d\udcb9',
  7424. 'chart_with_downwards_trend':'\ud83d\udcc9',
  7425. 'chart_with_upwards_trend':'\ud83d\udcc8',
  7426. 'checkered_flag':'\ud83c\udfc1',
  7427. 'cheese':'\ud83e\uddc0',
  7428. 'cherries':'\ud83c\udf52',
  7429. 'cherry_blossom':'\ud83c\udf38',
  7430. 'chestnut':'\ud83c\udf30',
  7431. 'chicken':'\ud83d\udc14',
  7432. 'children_crossing':'\ud83d\udeb8',
  7433. 'chipmunk':'\ud83d\udc3f',
  7434. 'chocolate_bar':'\ud83c\udf6b',
  7435. 'christmas_tree':'\ud83c\udf84',
  7436. 'church':'\u26ea\ufe0f',
  7437. 'cinema':'\ud83c\udfa6',
  7438. 'circus_tent':'\ud83c\udfaa',
  7439. 'city_sunrise':'\ud83c\udf07',
  7440. 'city_sunset':'\ud83c\udf06',
  7441. 'cityscape':'\ud83c\udfd9',
  7442. 'cl':'\ud83c\udd91',
  7443. 'clamp':'\ud83d\udddc',
  7444. 'clap':'\ud83d\udc4f',
  7445. 'clapper':'\ud83c\udfac',
  7446. 'classical_building':'\ud83c\udfdb',
  7447. 'clinking_glasses':'\ud83e\udd42',
  7448. 'clipboard':'\ud83d\udccb',
  7449. 'clock1':'\ud83d\udd50',
  7450. 'clock10':'\ud83d\udd59',
  7451. 'clock1030':'\ud83d\udd65',
  7452. 'clock11':'\ud83d\udd5a',
  7453. 'clock1130':'\ud83d\udd66',
  7454. 'clock12':'\ud83d\udd5b',
  7455. 'clock1230':'\ud83d\udd67',
  7456. 'clock130':'\ud83d\udd5c',
  7457. 'clock2':'\ud83d\udd51',
  7458. 'clock230':'\ud83d\udd5d',
  7459. 'clock3':'\ud83d\udd52',
  7460. 'clock330':'\ud83d\udd5e',
  7461. 'clock4':'\ud83d\udd53',
  7462. 'clock430':'\ud83d\udd5f',
  7463. 'clock5':'\ud83d\udd54',
  7464. 'clock530':'\ud83d\udd60',
  7465. 'clock6':'\ud83d\udd55',
  7466. 'clock630':'\ud83d\udd61',
  7467. 'clock7':'\ud83d\udd56',
  7468. 'clock730':'\ud83d\udd62',
  7469. 'clock8':'\ud83d\udd57',
  7470. 'clock830':'\ud83d\udd63',
  7471. 'clock9':'\ud83d\udd58',
  7472. 'clock930':'\ud83d\udd64',
  7473. 'closed_book':'\ud83d\udcd5',
  7474. 'closed_lock_with_key':'\ud83d\udd10',
  7475. 'closed_umbrella':'\ud83c\udf02',
  7476. 'cloud':'\u2601\ufe0f',
  7477. 'cloud_with_lightning':'\ud83c\udf29',
  7478. 'cloud_with_lightning_and_rain':'\u26c8',
  7479. 'cloud_with_rain':'\ud83c\udf27',
  7480. 'cloud_with_snow':'\ud83c\udf28',
  7481. 'clown_face':'\ud83e\udd21',
  7482. 'clubs':'\u2663\ufe0f',
  7483. 'cocktail':'\ud83c\udf78',
  7484. 'coffee':'\u2615\ufe0f',
  7485. 'coffin':'\u26b0\ufe0f',
  7486. 'cold_sweat':'\ud83d\ude30',
  7487. 'comet':'\u2604\ufe0f',
  7488. 'computer':'\ud83d\udcbb',
  7489. 'computer_mouse':'\ud83d\uddb1',
  7490. 'confetti_ball':'\ud83c\udf8a',
  7491. 'confounded':'\ud83d\ude16',
  7492. 'confused':'\ud83d\ude15',
  7493. 'congratulations':'\u3297\ufe0f',
  7494. 'construction':'\ud83d\udea7',
  7495. 'construction_worker_man':'\ud83d\udc77',
  7496. 'construction_worker_woman':'\ud83d\udc77&zwj;\u2640\ufe0f',
  7497. 'control_knobs':'\ud83c\udf9b',
  7498. 'convenience_store':'\ud83c\udfea',
  7499. 'cookie':'\ud83c\udf6a',
  7500. 'cool':'\ud83c\udd92',
  7501. 'policeman':'\ud83d\udc6e',
  7502. 'copyright':'\u00a9\ufe0f',
  7503. 'corn':'\ud83c\udf3d',
  7504. 'couch_and_lamp':'\ud83d\udecb',
  7505. 'couple':'\ud83d\udc6b',
  7506. 'couple_with_heart_woman_man':'\ud83d\udc91',
  7507. 'couple_with_heart_man_man':'\ud83d\udc68&zwj;\u2764\ufe0f&zwj;\ud83d\udc68',
  7508. 'couple_with_heart_woman_woman':'\ud83d\udc69&zwj;\u2764\ufe0f&zwj;\ud83d\udc69',
  7509. 'couplekiss_man_man':'\ud83d\udc68&zwj;\u2764\ufe0f&zwj;\ud83d\udc8b&zwj;\ud83d\udc68',
  7510. 'couplekiss_man_woman':'\ud83d\udc8f',
  7511. 'couplekiss_woman_woman':'\ud83d\udc69&zwj;\u2764\ufe0f&zwj;\ud83d\udc8b&zwj;\ud83d\udc69',
  7512. 'cow':'\ud83d\udc2e',
  7513. 'cow2':'\ud83d\udc04',
  7514. 'cowboy_hat_face':'\ud83e\udd20',
  7515. 'crab':'\ud83e\udd80',
  7516. 'crayon':'\ud83d\udd8d',
  7517. 'credit_card':'\ud83d\udcb3',
  7518. 'crescent_moon':'\ud83c\udf19',
  7519. 'cricket':'\ud83c\udfcf',
  7520. 'crocodile':'\ud83d\udc0a',
  7521. 'croissant':'\ud83e\udd50',
  7522. 'crossed_fingers':'\ud83e\udd1e',
  7523. 'crossed_flags':'\ud83c\udf8c',
  7524. 'crossed_swords':'\u2694\ufe0f',
  7525. 'crown':'\ud83d\udc51',
  7526. 'cry':'\ud83d\ude22',
  7527. 'crying_cat_face':'\ud83d\ude3f',
  7528. 'crystal_ball':'\ud83d\udd2e',
  7529. 'cucumber':'\ud83e\udd52',
  7530. 'cupid':'\ud83d\udc98',
  7531. 'curly_loop':'\u27b0',
  7532. 'currency_exchange':'\ud83d\udcb1',
  7533. 'curry':'\ud83c\udf5b',
  7534. 'custard':'\ud83c\udf6e',
  7535. 'customs':'\ud83d\udec3',
  7536. 'cyclone':'\ud83c\udf00',
  7537. 'dagger':'\ud83d\udde1',
  7538. 'dancer':'\ud83d\udc83',
  7539. 'dancing_women':'\ud83d\udc6f',
  7540. 'dancing_men':'\ud83d\udc6f&zwj;\u2642\ufe0f',
  7541. 'dango':'\ud83c\udf61',
  7542. 'dark_sunglasses':'\ud83d\udd76',
  7543. 'dart':'\ud83c\udfaf',
  7544. 'dash':'\ud83d\udca8',
  7545. 'date':'\ud83d\udcc5',
  7546. 'deciduous_tree':'\ud83c\udf33',
  7547. 'deer':'\ud83e\udd8c',
  7548. 'department_store':'\ud83c\udfec',
  7549. 'derelict_house':'\ud83c\udfda',
  7550. 'desert':'\ud83c\udfdc',
  7551. 'desert_island':'\ud83c\udfdd',
  7552. 'desktop_computer':'\ud83d\udda5',
  7553. 'male_detective':'\ud83d\udd75\ufe0f',
  7554. 'diamond_shape_with_a_dot_inside':'\ud83d\udca0',
  7555. 'diamonds':'\u2666\ufe0f',
  7556. 'disappointed':'\ud83d\ude1e',
  7557. 'disappointed_relieved':'\ud83d\ude25',
  7558. 'dizzy':'\ud83d\udcab',
  7559. 'dizzy_face':'\ud83d\ude35',
  7560. 'do_not_litter':'\ud83d\udeaf',
  7561. 'dog':'\ud83d\udc36',
  7562. 'dog2':'\ud83d\udc15',
  7563. 'dollar':'\ud83d\udcb5',
  7564. 'dolls':'\ud83c\udf8e',
  7565. 'dolphin':'\ud83d\udc2c',
  7566. 'door':'\ud83d\udeaa',
  7567. 'doughnut':'\ud83c\udf69',
  7568. 'dove':'\ud83d\udd4a',
  7569. 'dragon':'\ud83d\udc09',
  7570. 'dragon_face':'\ud83d\udc32',
  7571. 'dress':'\ud83d\udc57',
  7572. 'dromedary_camel':'\ud83d\udc2a',
  7573. 'drooling_face':'\ud83e\udd24',
  7574. 'droplet':'\ud83d\udca7',
  7575. 'drum':'\ud83e\udd41',
  7576. 'duck':'\ud83e\udd86',
  7577. 'dvd':'\ud83d\udcc0',
  7578. 'e-mail':'\ud83d\udce7',
  7579. 'eagle':'\ud83e\udd85',
  7580. 'ear':'\ud83d\udc42',
  7581. 'ear_of_rice':'\ud83c\udf3e',
  7582. 'earth_africa':'\ud83c\udf0d',
  7583. 'earth_americas':'\ud83c\udf0e',
  7584. 'earth_asia':'\ud83c\udf0f',
  7585. 'egg':'\ud83e\udd5a',
  7586. 'eggplant':'\ud83c\udf46',
  7587. 'eight_pointed_black_star':'\u2734\ufe0f',
  7588. 'eight_spoked_asterisk':'\u2733\ufe0f',
  7589. 'electric_plug':'\ud83d\udd0c',
  7590. 'elephant':'\ud83d\udc18',
  7591. 'email':'\u2709\ufe0f',
  7592. 'end':'\ud83d\udd1a',
  7593. 'envelope_with_arrow':'\ud83d\udce9',
  7594. 'euro':'\ud83d\udcb6',
  7595. 'european_castle':'\ud83c\udff0',
  7596. 'european_post_office':'\ud83c\udfe4',
  7597. 'evergreen_tree':'\ud83c\udf32',
  7598. 'exclamation':'\u2757\ufe0f',
  7599. 'expressionless':'\ud83d\ude11',
  7600. 'eye':'\ud83d\udc41',
  7601. 'eye_speech_bubble':'\ud83d\udc41&zwj;\ud83d\udde8',
  7602. 'eyeglasses':'\ud83d\udc53',
  7603. 'eyes':'\ud83d\udc40',
  7604. 'face_with_head_bandage':'\ud83e\udd15',
  7605. 'face_with_thermometer':'\ud83e\udd12',
  7606. 'fist_oncoming':'\ud83d\udc4a',
  7607. 'factory':'\ud83c\udfed',
  7608. 'fallen_leaf':'\ud83c\udf42',
  7609. 'family_man_woman_boy':'\ud83d\udc6a',
  7610. 'family_man_boy':'\ud83d\udc68&zwj;\ud83d\udc66',
  7611. 'family_man_boy_boy':'\ud83d\udc68&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  7612. 'family_man_girl':'\ud83d\udc68&zwj;\ud83d\udc67',
  7613. 'family_man_girl_boy':'\ud83d\udc68&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  7614. 'family_man_girl_girl':'\ud83d\udc68&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  7615. 'family_man_man_boy':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc66',
  7616. 'family_man_man_boy_boy':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  7617. 'family_man_man_girl':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc67',
  7618. 'family_man_man_girl_boy':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  7619. 'family_man_man_girl_girl':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  7620. 'family_man_woman_boy_boy':'\ud83d\udc68&zwj;\ud83d\udc69&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  7621. 'family_man_woman_girl':'\ud83d\udc68&zwj;\ud83d\udc69&zwj;\ud83d\udc67',
  7622. 'family_man_woman_girl_boy':'\ud83d\udc68&zwj;\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  7623. 'family_man_woman_girl_girl':'\ud83d\udc68&zwj;\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  7624. 'family_woman_boy':'\ud83d\udc69&zwj;\ud83d\udc66',
  7625. 'family_woman_boy_boy':'\ud83d\udc69&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  7626. 'family_woman_girl':'\ud83d\udc69&zwj;\ud83d\udc67',
  7627. 'family_woman_girl_boy':'\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  7628. 'family_woman_girl_girl':'\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  7629. 'family_woman_woman_boy':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc66',
  7630. 'family_woman_woman_boy_boy':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  7631. 'family_woman_woman_girl':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc67',
  7632. 'family_woman_woman_girl_boy':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  7633. 'family_woman_woman_girl_girl':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  7634. 'fast_forward':'\u23e9',
  7635. 'fax':'\ud83d\udce0',
  7636. 'fearful':'\ud83d\ude28',
  7637. 'feet':'\ud83d\udc3e',
  7638. 'female_detective':'\ud83d\udd75\ufe0f&zwj;\u2640\ufe0f',
  7639. 'ferris_wheel':'\ud83c\udfa1',
  7640. 'ferry':'\u26f4',
  7641. 'field_hockey':'\ud83c\udfd1',
  7642. 'file_cabinet':'\ud83d\uddc4',
  7643. 'file_folder':'\ud83d\udcc1',
  7644. 'film_projector':'\ud83d\udcfd',
  7645. 'film_strip':'\ud83c\udf9e',
  7646. 'fire':'\ud83d\udd25',
  7647. 'fire_engine':'\ud83d\ude92',
  7648. 'fireworks':'\ud83c\udf86',
  7649. 'first_quarter_moon':'\ud83c\udf13',
  7650. 'first_quarter_moon_with_face':'\ud83c\udf1b',
  7651. 'fish':'\ud83d\udc1f',
  7652. 'fish_cake':'\ud83c\udf65',
  7653. 'fishing_pole_and_fish':'\ud83c\udfa3',
  7654. 'fist_raised':'\u270a',
  7655. 'fist_left':'\ud83e\udd1b',
  7656. 'fist_right':'\ud83e\udd1c',
  7657. 'flags':'\ud83c\udf8f',
  7658. 'flashlight':'\ud83d\udd26',
  7659. 'fleur_de_lis':'\u269c\ufe0f',
  7660. 'flight_arrival':'\ud83d\udeec',
  7661. 'flight_departure':'\ud83d\udeeb',
  7662. 'floppy_disk':'\ud83d\udcbe',
  7663. 'flower_playing_cards':'\ud83c\udfb4',
  7664. 'flushed':'\ud83d\ude33',
  7665. 'fog':'\ud83c\udf2b',
  7666. 'foggy':'\ud83c\udf01',
  7667. 'football':'\ud83c\udfc8',
  7668. 'footprints':'\ud83d\udc63',
  7669. 'fork_and_knife':'\ud83c\udf74',
  7670. 'fountain':'\u26f2\ufe0f',
  7671. 'fountain_pen':'\ud83d\udd8b',
  7672. 'four_leaf_clover':'\ud83c\udf40',
  7673. 'fox_face':'\ud83e\udd8a',
  7674. 'framed_picture':'\ud83d\uddbc',
  7675. 'free':'\ud83c\udd93',
  7676. 'fried_egg':'\ud83c\udf73',
  7677. 'fried_shrimp':'\ud83c\udf64',
  7678. 'fries':'\ud83c\udf5f',
  7679. 'frog':'\ud83d\udc38',
  7680. 'frowning':'\ud83d\ude26',
  7681. 'frowning_face':'\u2639\ufe0f',
  7682. 'frowning_man':'\ud83d\ude4d&zwj;\u2642\ufe0f',
  7683. 'frowning_woman':'\ud83d\ude4d',
  7684. 'middle_finger':'\ud83d\udd95',
  7685. 'fuelpump':'\u26fd\ufe0f',
  7686. 'full_moon':'\ud83c\udf15',
  7687. 'full_moon_with_face':'\ud83c\udf1d',
  7688. 'funeral_urn':'\u26b1\ufe0f',
  7689. 'game_die':'\ud83c\udfb2',
  7690. 'gear':'\u2699\ufe0f',
  7691. 'gem':'\ud83d\udc8e',
  7692. 'gemini':'\u264a\ufe0f',
  7693. 'ghost':'\ud83d\udc7b',
  7694. 'gift':'\ud83c\udf81',
  7695. 'gift_heart':'\ud83d\udc9d',
  7696. 'girl':'\ud83d\udc67',
  7697. 'globe_with_meridians':'\ud83c\udf10',
  7698. 'goal_net':'\ud83e\udd45',
  7699. 'goat':'\ud83d\udc10',
  7700. 'golf':'\u26f3\ufe0f',
  7701. 'golfing_man':'\ud83c\udfcc\ufe0f',
  7702. 'golfing_woman':'\ud83c\udfcc\ufe0f&zwj;\u2640\ufe0f',
  7703. 'gorilla':'\ud83e\udd8d',
  7704. 'grapes':'\ud83c\udf47',
  7705. 'green_apple':'\ud83c\udf4f',
  7706. 'green_book':'\ud83d\udcd7',
  7707. 'green_heart':'\ud83d\udc9a',
  7708. 'green_salad':'\ud83e\udd57',
  7709. 'grey_exclamation':'\u2755',
  7710. 'grey_question':'\u2754',
  7711. 'grimacing':'\ud83d\ude2c',
  7712. 'grin':'\ud83d\ude01',
  7713. 'grinning':'\ud83d\ude00',
  7714. 'guardsman':'\ud83d\udc82',
  7715. 'guardswoman':'\ud83d\udc82&zwj;\u2640\ufe0f',
  7716. 'guitar':'\ud83c\udfb8',
  7717. 'gun':'\ud83d\udd2b',
  7718. 'haircut_woman':'\ud83d\udc87',
  7719. 'haircut_man':'\ud83d\udc87&zwj;\u2642\ufe0f',
  7720. 'hamburger':'\ud83c\udf54',
  7721. 'hammer':'\ud83d\udd28',
  7722. 'hammer_and_pick':'\u2692',
  7723. 'hammer_and_wrench':'\ud83d\udee0',
  7724. 'hamster':'\ud83d\udc39',
  7725. 'hand':'\u270b',
  7726. 'handbag':'\ud83d\udc5c',
  7727. 'handshake':'\ud83e\udd1d',
  7728. 'hankey':'\ud83d\udca9',
  7729. 'hatched_chick':'\ud83d\udc25',
  7730. 'hatching_chick':'\ud83d\udc23',
  7731. 'headphones':'\ud83c\udfa7',
  7732. 'hear_no_evil':'\ud83d\ude49',
  7733. 'heart':'\u2764\ufe0f',
  7734. 'heart_decoration':'\ud83d\udc9f',
  7735. 'heart_eyes':'\ud83d\ude0d',
  7736. 'heart_eyes_cat':'\ud83d\ude3b',
  7737. 'heartbeat':'\ud83d\udc93',
  7738. 'heartpulse':'\ud83d\udc97',
  7739. 'hearts':'\u2665\ufe0f',
  7740. 'heavy_check_mark':'\u2714\ufe0f',
  7741. 'heavy_division_sign':'\u2797',
  7742. 'heavy_dollar_sign':'\ud83d\udcb2',
  7743. 'heavy_heart_exclamation':'\u2763\ufe0f',
  7744. 'heavy_minus_sign':'\u2796',
  7745. 'heavy_multiplication_x':'\u2716\ufe0f',
  7746. 'heavy_plus_sign':'\u2795',
  7747. 'helicopter':'\ud83d\ude81',
  7748. 'herb':'\ud83c\udf3f',
  7749. 'hibiscus':'\ud83c\udf3a',
  7750. 'high_brightness':'\ud83d\udd06',
  7751. 'high_heel':'\ud83d\udc60',
  7752. 'hocho':'\ud83d\udd2a',
  7753. 'hole':'\ud83d\udd73',
  7754. 'honey_pot':'\ud83c\udf6f',
  7755. 'horse':'\ud83d\udc34',
  7756. 'horse_racing':'\ud83c\udfc7',
  7757. 'hospital':'\ud83c\udfe5',
  7758. 'hot_pepper':'\ud83c\udf36',
  7759. 'hotdog':'\ud83c\udf2d',
  7760. 'hotel':'\ud83c\udfe8',
  7761. 'hotsprings':'\u2668\ufe0f',
  7762. 'hourglass':'\u231b\ufe0f',
  7763. 'hourglass_flowing_sand':'\u23f3',
  7764. 'house':'\ud83c\udfe0',
  7765. 'house_with_garden':'\ud83c\udfe1',
  7766. 'houses':'\ud83c\udfd8',
  7767. 'hugs':'\ud83e\udd17',
  7768. 'hushed':'\ud83d\ude2f',
  7769. 'ice_cream':'\ud83c\udf68',
  7770. 'ice_hockey':'\ud83c\udfd2',
  7771. 'ice_skate':'\u26f8',
  7772. 'icecream':'\ud83c\udf66',
  7773. 'id':'\ud83c\udd94',
  7774. 'ideograph_advantage':'\ud83c\ude50',
  7775. 'imp':'\ud83d\udc7f',
  7776. 'inbox_tray':'\ud83d\udce5',
  7777. 'incoming_envelope':'\ud83d\udce8',
  7778. 'tipping_hand_woman':'\ud83d\udc81',
  7779. 'information_source':'\u2139\ufe0f',
  7780. 'innocent':'\ud83d\ude07',
  7781. 'interrobang':'\u2049\ufe0f',
  7782. 'iphone':'\ud83d\udcf1',
  7783. 'izakaya_lantern':'\ud83c\udfee',
  7784. 'jack_o_lantern':'\ud83c\udf83',
  7785. 'japan':'\ud83d\uddfe',
  7786. 'japanese_castle':'\ud83c\udfef',
  7787. 'japanese_goblin':'\ud83d\udc7a',
  7788. 'japanese_ogre':'\ud83d\udc79',
  7789. 'jeans':'\ud83d\udc56',
  7790. 'joy':'\ud83d\ude02',
  7791. 'joy_cat':'\ud83d\ude39',
  7792. 'joystick':'\ud83d\udd79',
  7793. 'kaaba':'\ud83d\udd4b',
  7794. 'key':'\ud83d\udd11',
  7795. 'keyboard':'\u2328\ufe0f',
  7796. 'keycap_ten':'\ud83d\udd1f',
  7797. 'kick_scooter':'\ud83d\udef4',
  7798. 'kimono':'\ud83d\udc58',
  7799. 'kiss':'\ud83d\udc8b',
  7800. 'kissing':'\ud83d\ude17',
  7801. 'kissing_cat':'\ud83d\ude3d',
  7802. 'kissing_closed_eyes':'\ud83d\ude1a',
  7803. 'kissing_heart':'\ud83d\ude18',
  7804. 'kissing_smiling_eyes':'\ud83d\ude19',
  7805. 'kiwi_fruit':'\ud83e\udd5d',
  7806. 'koala':'\ud83d\udc28',
  7807. 'koko':'\ud83c\ude01',
  7808. 'label':'\ud83c\udff7',
  7809. 'large_blue_circle':'\ud83d\udd35',
  7810. 'large_blue_diamond':'\ud83d\udd37',
  7811. 'large_orange_diamond':'\ud83d\udd36',
  7812. 'last_quarter_moon':'\ud83c\udf17',
  7813. 'last_quarter_moon_with_face':'\ud83c\udf1c',
  7814. 'latin_cross':'\u271d\ufe0f',
  7815. 'laughing':'\ud83d\ude06',
  7816. 'leaves':'\ud83c\udf43',
  7817. 'ledger':'\ud83d\udcd2',
  7818. 'left_luggage':'\ud83d\udec5',
  7819. 'left_right_arrow':'\u2194\ufe0f',
  7820. 'leftwards_arrow_with_hook':'\u21a9\ufe0f',
  7821. 'lemon':'\ud83c\udf4b',
  7822. 'leo':'\u264c\ufe0f',
  7823. 'leopard':'\ud83d\udc06',
  7824. 'level_slider':'\ud83c\udf9a',
  7825. 'libra':'\u264e\ufe0f',
  7826. 'light_rail':'\ud83d\ude88',
  7827. 'link':'\ud83d\udd17',
  7828. 'lion':'\ud83e\udd81',
  7829. 'lips':'\ud83d\udc44',
  7830. 'lipstick':'\ud83d\udc84',
  7831. 'lizard':'\ud83e\udd8e',
  7832. 'lock':'\ud83d\udd12',
  7833. 'lock_with_ink_pen':'\ud83d\udd0f',
  7834. 'lollipop':'\ud83c\udf6d',
  7835. 'loop':'\u27bf',
  7836. 'loud_sound':'\ud83d\udd0a',
  7837. 'loudspeaker':'\ud83d\udce2',
  7838. 'love_hotel':'\ud83c\udfe9',
  7839. 'love_letter':'\ud83d\udc8c',
  7840. 'low_brightness':'\ud83d\udd05',
  7841. 'lying_face':'\ud83e\udd25',
  7842. 'm':'\u24c2\ufe0f',
  7843. 'mag':'\ud83d\udd0d',
  7844. 'mag_right':'\ud83d\udd0e',
  7845. 'mahjong':'\ud83c\udc04\ufe0f',
  7846. 'mailbox':'\ud83d\udceb',
  7847. 'mailbox_closed':'\ud83d\udcea',
  7848. 'mailbox_with_mail':'\ud83d\udcec',
  7849. 'mailbox_with_no_mail':'\ud83d\udced',
  7850. 'man':'\ud83d\udc68',
  7851. 'man_artist':'\ud83d\udc68&zwj;\ud83c\udfa8',
  7852. 'man_astronaut':'\ud83d\udc68&zwj;\ud83d\ude80',
  7853. 'man_cartwheeling':'\ud83e\udd38&zwj;\u2642\ufe0f',
  7854. 'man_cook':'\ud83d\udc68&zwj;\ud83c\udf73',
  7855. 'man_dancing':'\ud83d\udd7a',
  7856. 'man_facepalming':'\ud83e\udd26&zwj;\u2642\ufe0f',
  7857. 'man_factory_worker':'\ud83d\udc68&zwj;\ud83c\udfed',
  7858. 'man_farmer':'\ud83d\udc68&zwj;\ud83c\udf3e',
  7859. 'man_firefighter':'\ud83d\udc68&zwj;\ud83d\ude92',
  7860. 'man_health_worker':'\ud83d\udc68&zwj;\u2695\ufe0f',
  7861. 'man_in_tuxedo':'\ud83e\udd35',
  7862. 'man_judge':'\ud83d\udc68&zwj;\u2696\ufe0f',
  7863. 'man_juggling':'\ud83e\udd39&zwj;\u2642\ufe0f',
  7864. 'man_mechanic':'\ud83d\udc68&zwj;\ud83d\udd27',
  7865. 'man_office_worker':'\ud83d\udc68&zwj;\ud83d\udcbc',
  7866. 'man_pilot':'\ud83d\udc68&zwj;\u2708\ufe0f',
  7867. 'man_playing_handball':'\ud83e\udd3e&zwj;\u2642\ufe0f',
  7868. 'man_playing_water_polo':'\ud83e\udd3d&zwj;\u2642\ufe0f',
  7869. 'man_scientist':'\ud83d\udc68&zwj;\ud83d\udd2c',
  7870. 'man_shrugging':'\ud83e\udd37&zwj;\u2642\ufe0f',
  7871. 'man_singer':'\ud83d\udc68&zwj;\ud83c\udfa4',
  7872. 'man_student':'\ud83d\udc68&zwj;\ud83c\udf93',
  7873. 'man_teacher':'\ud83d\udc68&zwj;\ud83c\udfeb',
  7874. 'man_technologist':'\ud83d\udc68&zwj;\ud83d\udcbb',
  7875. 'man_with_gua_pi_mao':'\ud83d\udc72',
  7876. 'man_with_turban':'\ud83d\udc73',
  7877. 'tangerine':'\ud83c\udf4a',
  7878. 'mans_shoe':'\ud83d\udc5e',
  7879. 'mantelpiece_clock':'\ud83d\udd70',
  7880. 'maple_leaf':'\ud83c\udf41',
  7881. 'martial_arts_uniform':'\ud83e\udd4b',
  7882. 'mask':'\ud83d\ude37',
  7883. 'massage_woman':'\ud83d\udc86',
  7884. 'massage_man':'\ud83d\udc86&zwj;\u2642\ufe0f',
  7885. 'meat_on_bone':'\ud83c\udf56',
  7886. 'medal_military':'\ud83c\udf96',
  7887. 'medal_sports':'\ud83c\udfc5',
  7888. 'mega':'\ud83d\udce3',
  7889. 'melon':'\ud83c\udf48',
  7890. 'memo':'\ud83d\udcdd',
  7891. 'men_wrestling':'\ud83e\udd3c&zwj;\u2642\ufe0f',
  7892. 'menorah':'\ud83d\udd4e',
  7893. 'mens':'\ud83d\udeb9',
  7894. 'metal':'\ud83e\udd18',
  7895. 'metro':'\ud83d\ude87',
  7896. 'microphone':'\ud83c\udfa4',
  7897. 'microscope':'\ud83d\udd2c',
  7898. 'milk_glass':'\ud83e\udd5b',
  7899. 'milky_way':'\ud83c\udf0c',
  7900. 'minibus':'\ud83d\ude90',
  7901. 'minidisc':'\ud83d\udcbd',
  7902. 'mobile_phone_off':'\ud83d\udcf4',
  7903. 'money_mouth_face':'\ud83e\udd11',
  7904. 'money_with_wings':'\ud83d\udcb8',
  7905. 'moneybag':'\ud83d\udcb0',
  7906. 'monkey':'\ud83d\udc12',
  7907. 'monkey_face':'\ud83d\udc35',
  7908. 'monorail':'\ud83d\ude9d',
  7909. 'moon':'\ud83c\udf14',
  7910. 'mortar_board':'\ud83c\udf93',
  7911. 'mosque':'\ud83d\udd4c',
  7912. 'motor_boat':'\ud83d\udee5',
  7913. 'motor_scooter':'\ud83d\udef5',
  7914. 'motorcycle':'\ud83c\udfcd',
  7915. 'motorway':'\ud83d\udee3',
  7916. 'mount_fuji':'\ud83d\uddfb',
  7917. 'mountain':'\u26f0',
  7918. 'mountain_biking_man':'\ud83d\udeb5',
  7919. 'mountain_biking_woman':'\ud83d\udeb5&zwj;\u2640\ufe0f',
  7920. 'mountain_cableway':'\ud83d\udea0',
  7921. 'mountain_railway':'\ud83d\ude9e',
  7922. 'mountain_snow':'\ud83c\udfd4',
  7923. 'mouse':'\ud83d\udc2d',
  7924. 'mouse2':'\ud83d\udc01',
  7925. 'movie_camera':'\ud83c\udfa5',
  7926. 'moyai':'\ud83d\uddff',
  7927. 'mrs_claus':'\ud83e\udd36',
  7928. 'muscle':'\ud83d\udcaa',
  7929. 'mushroom':'\ud83c\udf44',
  7930. 'musical_keyboard':'\ud83c\udfb9',
  7931. 'musical_note':'\ud83c\udfb5',
  7932. 'musical_score':'\ud83c\udfbc',
  7933. 'mute':'\ud83d\udd07',
  7934. 'nail_care':'\ud83d\udc85',
  7935. 'name_badge':'\ud83d\udcdb',
  7936. 'national_park':'\ud83c\udfde',
  7937. 'nauseated_face':'\ud83e\udd22',
  7938. 'necktie':'\ud83d\udc54',
  7939. 'negative_squared_cross_mark':'\u274e',
  7940. 'nerd_face':'\ud83e\udd13',
  7941. 'neutral_face':'\ud83d\ude10',
  7942. 'new':'\ud83c\udd95',
  7943. 'new_moon':'\ud83c\udf11',
  7944. 'new_moon_with_face':'\ud83c\udf1a',
  7945. 'newspaper':'\ud83d\udcf0',
  7946. 'newspaper_roll':'\ud83d\uddde',
  7947. 'next_track_button':'\u23ed',
  7948. 'ng':'\ud83c\udd96',
  7949. 'no_good_man':'\ud83d\ude45&zwj;\u2642\ufe0f',
  7950. 'no_good_woman':'\ud83d\ude45',
  7951. 'night_with_stars':'\ud83c\udf03',
  7952. 'no_bell':'\ud83d\udd15',
  7953. 'no_bicycles':'\ud83d\udeb3',
  7954. 'no_entry':'\u26d4\ufe0f',
  7955. 'no_entry_sign':'\ud83d\udeab',
  7956. 'no_mobile_phones':'\ud83d\udcf5',
  7957. 'no_mouth':'\ud83d\ude36',
  7958. 'no_pedestrians':'\ud83d\udeb7',
  7959. 'no_smoking':'\ud83d\udead',
  7960. 'non-potable_water':'\ud83d\udeb1',
  7961. 'nose':'\ud83d\udc43',
  7962. 'notebook':'\ud83d\udcd3',
  7963. 'notebook_with_decorative_cover':'\ud83d\udcd4',
  7964. 'notes':'\ud83c\udfb6',
  7965. 'nut_and_bolt':'\ud83d\udd29',
  7966. 'o':'\u2b55\ufe0f',
  7967. 'o2':'\ud83c\udd7e\ufe0f',
  7968. 'ocean':'\ud83c\udf0a',
  7969. 'octopus':'\ud83d\udc19',
  7970. 'oden':'\ud83c\udf62',
  7971. 'office':'\ud83c\udfe2',
  7972. 'oil_drum':'\ud83d\udee2',
  7973. 'ok':'\ud83c\udd97',
  7974. 'ok_hand':'\ud83d\udc4c',
  7975. 'ok_man':'\ud83d\ude46&zwj;\u2642\ufe0f',
  7976. 'ok_woman':'\ud83d\ude46',
  7977. 'old_key':'\ud83d\udddd',
  7978. 'older_man':'\ud83d\udc74',
  7979. 'older_woman':'\ud83d\udc75',
  7980. 'om':'\ud83d\udd49',
  7981. 'on':'\ud83d\udd1b',
  7982. 'oncoming_automobile':'\ud83d\ude98',
  7983. 'oncoming_bus':'\ud83d\ude8d',
  7984. 'oncoming_police_car':'\ud83d\ude94',
  7985. 'oncoming_taxi':'\ud83d\ude96',
  7986. 'open_file_folder':'\ud83d\udcc2',
  7987. 'open_hands':'\ud83d\udc50',
  7988. 'open_mouth':'\ud83d\ude2e',
  7989. 'open_umbrella':'\u2602\ufe0f',
  7990. 'ophiuchus':'\u26ce',
  7991. 'orange_book':'\ud83d\udcd9',
  7992. 'orthodox_cross':'\u2626\ufe0f',
  7993. 'outbox_tray':'\ud83d\udce4',
  7994. 'owl':'\ud83e\udd89',
  7995. 'ox':'\ud83d\udc02',
  7996. 'package':'\ud83d\udce6',
  7997. 'page_facing_up':'\ud83d\udcc4',
  7998. 'page_with_curl':'\ud83d\udcc3',
  7999. 'pager':'\ud83d\udcdf',
  8000. 'paintbrush':'\ud83d\udd8c',
  8001. 'palm_tree':'\ud83c\udf34',
  8002. 'pancakes':'\ud83e\udd5e',
  8003. 'panda_face':'\ud83d\udc3c',
  8004. 'paperclip':'\ud83d\udcce',
  8005. 'paperclips':'\ud83d\udd87',
  8006. 'parasol_on_ground':'\u26f1',
  8007. 'parking':'\ud83c\udd7f\ufe0f',
  8008. 'part_alternation_mark':'\u303d\ufe0f',
  8009. 'partly_sunny':'\u26c5\ufe0f',
  8010. 'passenger_ship':'\ud83d\udef3',
  8011. 'passport_control':'\ud83d\udec2',
  8012. 'pause_button':'\u23f8',
  8013. 'peace_symbol':'\u262e\ufe0f',
  8014. 'peach':'\ud83c\udf51',
  8015. 'peanuts':'\ud83e\udd5c',
  8016. 'pear':'\ud83c\udf50',
  8017. 'pen':'\ud83d\udd8a',
  8018. 'pencil2':'\u270f\ufe0f',
  8019. 'penguin':'\ud83d\udc27',
  8020. 'pensive':'\ud83d\ude14',
  8021. 'performing_arts':'\ud83c\udfad',
  8022. 'persevere':'\ud83d\ude23',
  8023. 'person_fencing':'\ud83e\udd3a',
  8024. 'pouting_woman':'\ud83d\ude4e',
  8025. 'phone':'\u260e\ufe0f',
  8026. 'pick':'\u26cf',
  8027. 'pig':'\ud83d\udc37',
  8028. 'pig2':'\ud83d\udc16',
  8029. 'pig_nose':'\ud83d\udc3d',
  8030. 'pill':'\ud83d\udc8a',
  8031. 'pineapple':'\ud83c\udf4d',
  8032. 'ping_pong':'\ud83c\udfd3',
  8033. 'pisces':'\u2653\ufe0f',
  8034. 'pizza':'\ud83c\udf55',
  8035. 'place_of_worship':'\ud83d\uded0',
  8036. 'plate_with_cutlery':'\ud83c\udf7d',
  8037. 'play_or_pause_button':'\u23ef',
  8038. 'point_down':'\ud83d\udc47',
  8039. 'point_left':'\ud83d\udc48',
  8040. 'point_right':'\ud83d\udc49',
  8041. 'point_up':'\u261d\ufe0f',
  8042. 'point_up_2':'\ud83d\udc46',
  8043. 'police_car':'\ud83d\ude93',
  8044. 'policewoman':'\ud83d\udc6e&zwj;\u2640\ufe0f',
  8045. 'poodle':'\ud83d\udc29',
  8046. 'popcorn':'\ud83c\udf7f',
  8047. 'post_office':'\ud83c\udfe3',
  8048. 'postal_horn':'\ud83d\udcef',
  8049. 'postbox':'\ud83d\udcee',
  8050. 'potable_water':'\ud83d\udeb0',
  8051. 'potato':'\ud83e\udd54',
  8052. 'pouch':'\ud83d\udc5d',
  8053. 'poultry_leg':'\ud83c\udf57',
  8054. 'pound':'\ud83d\udcb7',
  8055. 'rage':'\ud83d\ude21',
  8056. 'pouting_cat':'\ud83d\ude3e',
  8057. 'pouting_man':'\ud83d\ude4e&zwj;\u2642\ufe0f',
  8058. 'pray':'\ud83d\ude4f',
  8059. 'prayer_beads':'\ud83d\udcff',
  8060. 'pregnant_woman':'\ud83e\udd30',
  8061. 'previous_track_button':'\u23ee',
  8062. 'prince':'\ud83e\udd34',
  8063. 'princess':'\ud83d\udc78',
  8064. 'printer':'\ud83d\udda8',
  8065. 'purple_heart':'\ud83d\udc9c',
  8066. 'purse':'\ud83d\udc5b',
  8067. 'pushpin':'\ud83d\udccc',
  8068. 'put_litter_in_its_place':'\ud83d\udeae',
  8069. 'question':'\u2753',
  8070. 'rabbit':'\ud83d\udc30',
  8071. 'rabbit2':'\ud83d\udc07',
  8072. 'racehorse':'\ud83d\udc0e',
  8073. 'racing_car':'\ud83c\udfce',
  8074. 'radio':'\ud83d\udcfb',
  8075. 'radio_button':'\ud83d\udd18',
  8076. 'radioactive':'\u2622\ufe0f',
  8077. 'railway_car':'\ud83d\ude83',
  8078. 'railway_track':'\ud83d\udee4',
  8079. 'rainbow':'\ud83c\udf08',
  8080. 'rainbow_flag':'\ud83c\udff3\ufe0f&zwj;\ud83c\udf08',
  8081. 'raised_back_of_hand':'\ud83e\udd1a',
  8082. 'raised_hand_with_fingers_splayed':'\ud83d\udd90',
  8083. 'raised_hands':'\ud83d\ude4c',
  8084. 'raising_hand_woman':'\ud83d\ude4b',
  8085. 'raising_hand_man':'\ud83d\ude4b&zwj;\u2642\ufe0f',
  8086. 'ram':'\ud83d\udc0f',
  8087. 'ramen':'\ud83c\udf5c',
  8088. 'rat':'\ud83d\udc00',
  8089. 'record_button':'\u23fa',
  8090. 'recycle':'\u267b\ufe0f',
  8091. 'red_circle':'\ud83d\udd34',
  8092. 'registered':'\u00ae\ufe0f',
  8093. 'relaxed':'\u263a\ufe0f',
  8094. 'relieved':'\ud83d\ude0c',
  8095. 'reminder_ribbon':'\ud83c\udf97',
  8096. 'repeat':'\ud83d\udd01',
  8097. 'repeat_one':'\ud83d\udd02',
  8098. 'rescue_worker_helmet':'\u26d1',
  8099. 'restroom':'\ud83d\udebb',
  8100. 'revolving_hearts':'\ud83d\udc9e',
  8101. 'rewind':'\u23ea',
  8102. 'rhinoceros':'\ud83e\udd8f',
  8103. 'ribbon':'\ud83c\udf80',
  8104. 'rice':'\ud83c\udf5a',
  8105. 'rice_ball':'\ud83c\udf59',
  8106. 'rice_cracker':'\ud83c\udf58',
  8107. 'rice_scene':'\ud83c\udf91',
  8108. 'right_anger_bubble':'\ud83d\uddef',
  8109. 'ring':'\ud83d\udc8d',
  8110. 'robot':'\ud83e\udd16',
  8111. 'rocket':'\ud83d\ude80',
  8112. 'rofl':'\ud83e\udd23',
  8113. 'roll_eyes':'\ud83d\ude44',
  8114. 'roller_coaster':'\ud83c\udfa2',
  8115. 'rooster':'\ud83d\udc13',
  8116. 'rose':'\ud83c\udf39',
  8117. 'rosette':'\ud83c\udff5',
  8118. 'rotating_light':'\ud83d\udea8',
  8119. 'round_pushpin':'\ud83d\udccd',
  8120. 'rowing_man':'\ud83d\udea3',
  8121. 'rowing_woman':'\ud83d\udea3&zwj;\u2640\ufe0f',
  8122. 'rugby_football':'\ud83c\udfc9',
  8123. 'running_man':'\ud83c\udfc3',
  8124. 'running_shirt_with_sash':'\ud83c\udfbd',
  8125. 'running_woman':'\ud83c\udfc3&zwj;\u2640\ufe0f',
  8126. 'sa':'\ud83c\ude02\ufe0f',
  8127. 'sagittarius':'\u2650\ufe0f',
  8128. 'sake':'\ud83c\udf76',
  8129. 'sandal':'\ud83d\udc61',
  8130. 'santa':'\ud83c\udf85',
  8131. 'satellite':'\ud83d\udce1',
  8132. 'saxophone':'\ud83c\udfb7',
  8133. 'school':'\ud83c\udfeb',
  8134. 'school_satchel':'\ud83c\udf92',
  8135. 'scissors':'\u2702\ufe0f',
  8136. 'scorpion':'\ud83e\udd82',
  8137. 'scorpius':'\u264f\ufe0f',
  8138. 'scream':'\ud83d\ude31',
  8139. 'scream_cat':'\ud83d\ude40',
  8140. 'scroll':'\ud83d\udcdc',
  8141. 'seat':'\ud83d\udcba',
  8142. 'secret':'\u3299\ufe0f',
  8143. 'see_no_evil':'\ud83d\ude48',
  8144. 'seedling':'\ud83c\udf31',
  8145. 'selfie':'\ud83e\udd33',
  8146. 'shallow_pan_of_food':'\ud83e\udd58',
  8147. 'shamrock':'\u2618\ufe0f',
  8148. 'shark':'\ud83e\udd88',
  8149. 'shaved_ice':'\ud83c\udf67',
  8150. 'sheep':'\ud83d\udc11',
  8151. 'shell':'\ud83d\udc1a',
  8152. 'shield':'\ud83d\udee1',
  8153. 'shinto_shrine':'\u26e9',
  8154. 'ship':'\ud83d\udea2',
  8155. 'shirt':'\ud83d\udc55',
  8156. 'shopping':'\ud83d\udecd',
  8157. 'shopping_cart':'\ud83d\uded2',
  8158. 'shower':'\ud83d\udebf',
  8159. 'shrimp':'\ud83e\udd90',
  8160. 'signal_strength':'\ud83d\udcf6',
  8161. 'six_pointed_star':'\ud83d\udd2f',
  8162. 'ski':'\ud83c\udfbf',
  8163. 'skier':'\u26f7',
  8164. 'skull':'\ud83d\udc80',
  8165. 'skull_and_crossbones':'\u2620\ufe0f',
  8166. 'sleeping':'\ud83d\ude34',
  8167. 'sleeping_bed':'\ud83d\udecc',
  8168. 'sleepy':'\ud83d\ude2a',
  8169. 'slightly_frowning_face':'\ud83d\ude41',
  8170. 'slightly_smiling_face':'\ud83d\ude42',
  8171. 'slot_machine':'\ud83c\udfb0',
  8172. 'small_airplane':'\ud83d\udee9',
  8173. 'small_blue_diamond':'\ud83d\udd39',
  8174. 'small_orange_diamond':'\ud83d\udd38',
  8175. 'small_red_triangle':'\ud83d\udd3a',
  8176. 'small_red_triangle_down':'\ud83d\udd3b',
  8177. 'smile':'\ud83d\ude04',
  8178. 'smile_cat':'\ud83d\ude38',
  8179. 'smiley':'\ud83d\ude03',
  8180. 'smiley_cat':'\ud83d\ude3a',
  8181. 'smiling_imp':'\ud83d\ude08',
  8182. 'smirk':'\ud83d\ude0f',
  8183. 'smirk_cat':'\ud83d\ude3c',
  8184. 'smoking':'\ud83d\udeac',
  8185. 'snail':'\ud83d\udc0c',
  8186. 'snake':'\ud83d\udc0d',
  8187. 'sneezing_face':'\ud83e\udd27',
  8188. 'snowboarder':'\ud83c\udfc2',
  8189. 'snowflake':'\u2744\ufe0f',
  8190. 'snowman':'\u26c4\ufe0f',
  8191. 'snowman_with_snow':'\u2603\ufe0f',
  8192. 'sob':'\ud83d\ude2d',
  8193. 'soccer':'\u26bd\ufe0f',
  8194. 'soon':'\ud83d\udd1c',
  8195. 'sos':'\ud83c\udd98',
  8196. 'sound':'\ud83d\udd09',
  8197. 'space_invader':'\ud83d\udc7e',
  8198. 'spades':'\u2660\ufe0f',
  8199. 'spaghetti':'\ud83c\udf5d',
  8200. 'sparkle':'\u2747\ufe0f',
  8201. 'sparkler':'\ud83c\udf87',
  8202. 'sparkles':'\u2728',
  8203. 'sparkling_heart':'\ud83d\udc96',
  8204. 'speak_no_evil':'\ud83d\ude4a',
  8205. 'speaker':'\ud83d\udd08',
  8206. 'speaking_head':'\ud83d\udde3',
  8207. 'speech_balloon':'\ud83d\udcac',
  8208. 'speedboat':'\ud83d\udea4',
  8209. 'spider':'\ud83d\udd77',
  8210. 'spider_web':'\ud83d\udd78',
  8211. 'spiral_calendar':'\ud83d\uddd3',
  8212. 'spiral_notepad':'\ud83d\uddd2',
  8213. 'spoon':'\ud83e\udd44',
  8214. 'squid':'\ud83e\udd91',
  8215. 'stadium':'\ud83c\udfdf',
  8216. 'star':'\u2b50\ufe0f',
  8217. 'star2':'\ud83c\udf1f',
  8218. 'star_and_crescent':'\u262a\ufe0f',
  8219. 'star_of_david':'\u2721\ufe0f',
  8220. 'stars':'\ud83c\udf20',
  8221. 'station':'\ud83d\ude89',
  8222. 'statue_of_liberty':'\ud83d\uddfd',
  8223. 'steam_locomotive':'\ud83d\ude82',
  8224. 'stew':'\ud83c\udf72',
  8225. 'stop_button':'\u23f9',
  8226. 'stop_sign':'\ud83d\uded1',
  8227. 'stopwatch':'\u23f1',
  8228. 'straight_ruler':'\ud83d\udccf',
  8229. 'strawberry':'\ud83c\udf53',
  8230. 'stuck_out_tongue':'\ud83d\ude1b',
  8231. 'stuck_out_tongue_closed_eyes':'\ud83d\ude1d',
  8232. 'stuck_out_tongue_winking_eye':'\ud83d\ude1c',
  8233. 'studio_microphone':'\ud83c\udf99',
  8234. 'stuffed_flatbread':'\ud83e\udd59',
  8235. 'sun_behind_large_cloud':'\ud83c\udf25',
  8236. 'sun_behind_rain_cloud':'\ud83c\udf26',
  8237. 'sun_behind_small_cloud':'\ud83c\udf24',
  8238. 'sun_with_face':'\ud83c\udf1e',
  8239. 'sunflower':'\ud83c\udf3b',
  8240. 'sunglasses':'\ud83d\ude0e',
  8241. 'sunny':'\u2600\ufe0f',
  8242. 'sunrise':'\ud83c\udf05',
  8243. 'sunrise_over_mountains':'\ud83c\udf04',
  8244. 'surfing_man':'\ud83c\udfc4',
  8245. 'surfing_woman':'\ud83c\udfc4&zwj;\u2640\ufe0f',
  8246. 'sushi':'\ud83c\udf63',
  8247. 'suspension_railway':'\ud83d\ude9f',
  8248. 'sweat':'\ud83d\ude13',
  8249. 'sweat_drops':'\ud83d\udca6',
  8250. 'sweat_smile':'\ud83d\ude05',
  8251. 'sweet_potato':'\ud83c\udf60',
  8252. 'swimming_man':'\ud83c\udfca',
  8253. 'swimming_woman':'\ud83c\udfca&zwj;\u2640\ufe0f',
  8254. 'symbols':'\ud83d\udd23',
  8255. 'synagogue':'\ud83d\udd4d',
  8256. 'syringe':'\ud83d\udc89',
  8257. 'taco':'\ud83c\udf2e',
  8258. 'tada':'\ud83c\udf89',
  8259. 'tanabata_tree':'\ud83c\udf8b',
  8260. 'taurus':'\u2649\ufe0f',
  8261. 'taxi':'\ud83d\ude95',
  8262. 'tea':'\ud83c\udf75',
  8263. 'telephone_receiver':'\ud83d\udcde',
  8264. 'telescope':'\ud83d\udd2d',
  8265. 'tennis':'\ud83c\udfbe',
  8266. 'tent':'\u26fa\ufe0f',
  8267. 'thermometer':'\ud83c\udf21',
  8268. 'thinking':'\ud83e\udd14',
  8269. 'thought_balloon':'\ud83d\udcad',
  8270. 'ticket':'\ud83c\udfab',
  8271. 'tickets':'\ud83c\udf9f',
  8272. 'tiger':'\ud83d\udc2f',
  8273. 'tiger2':'\ud83d\udc05',
  8274. 'timer_clock':'\u23f2',
  8275. 'tipping_hand_man':'\ud83d\udc81&zwj;\u2642\ufe0f',
  8276. 'tired_face':'\ud83d\ude2b',
  8277. 'tm':'\u2122\ufe0f',
  8278. 'toilet':'\ud83d\udebd',
  8279. 'tokyo_tower':'\ud83d\uddfc',
  8280. 'tomato':'\ud83c\udf45',
  8281. 'tongue':'\ud83d\udc45',
  8282. 'top':'\ud83d\udd1d',
  8283. 'tophat':'\ud83c\udfa9',
  8284. 'tornado':'\ud83c\udf2a',
  8285. 'trackball':'\ud83d\uddb2',
  8286. 'tractor':'\ud83d\ude9c',
  8287. 'traffic_light':'\ud83d\udea5',
  8288. 'train':'\ud83d\ude8b',
  8289. 'train2':'\ud83d\ude86',
  8290. 'tram':'\ud83d\ude8a',
  8291. 'triangular_flag_on_post':'\ud83d\udea9',
  8292. 'triangular_ruler':'\ud83d\udcd0',
  8293. 'trident':'\ud83d\udd31',
  8294. 'triumph':'\ud83d\ude24',
  8295. 'trolleybus':'\ud83d\ude8e',
  8296. 'trophy':'\ud83c\udfc6',
  8297. 'tropical_drink':'\ud83c\udf79',
  8298. 'tropical_fish':'\ud83d\udc20',
  8299. 'truck':'\ud83d\ude9a',
  8300. 'trumpet':'\ud83c\udfba',
  8301. 'tulip':'\ud83c\udf37',
  8302. 'tumbler_glass':'\ud83e\udd43',
  8303. 'turkey':'\ud83e\udd83',
  8304. 'turtle':'\ud83d\udc22',
  8305. 'tv':'\ud83d\udcfa',
  8306. 'twisted_rightwards_arrows':'\ud83d\udd00',
  8307. 'two_hearts':'\ud83d\udc95',
  8308. 'two_men_holding_hands':'\ud83d\udc6c',
  8309. 'two_women_holding_hands':'\ud83d\udc6d',
  8310. 'u5272':'\ud83c\ude39',
  8311. 'u5408':'\ud83c\ude34',
  8312. 'u55b6':'\ud83c\ude3a',
  8313. 'u6307':'\ud83c\ude2f\ufe0f',
  8314. 'u6708':'\ud83c\ude37\ufe0f',
  8315. 'u6709':'\ud83c\ude36',
  8316. 'u6e80':'\ud83c\ude35',
  8317. 'u7121':'\ud83c\ude1a\ufe0f',
  8318. 'u7533':'\ud83c\ude38',
  8319. 'u7981':'\ud83c\ude32',
  8320. 'u7a7a':'\ud83c\ude33',
  8321. 'umbrella':'\u2614\ufe0f',
  8322. 'unamused':'\ud83d\ude12',
  8323. 'underage':'\ud83d\udd1e',
  8324. 'unicorn':'\ud83e\udd84',
  8325. 'unlock':'\ud83d\udd13',
  8326. 'up':'\ud83c\udd99',
  8327. 'upside_down_face':'\ud83d\ude43',
  8328. 'v':'\u270c\ufe0f',
  8329. 'vertical_traffic_light':'\ud83d\udea6',
  8330. 'vhs':'\ud83d\udcfc',
  8331. 'vibration_mode':'\ud83d\udcf3',
  8332. 'video_camera':'\ud83d\udcf9',
  8333. 'video_game':'\ud83c\udfae',
  8334. 'violin':'\ud83c\udfbb',
  8335. 'virgo':'\u264d\ufe0f',
  8336. 'volcano':'\ud83c\udf0b',
  8337. 'volleyball':'\ud83c\udfd0',
  8338. 'vs':'\ud83c\udd9a',
  8339. 'vulcan_salute':'\ud83d\udd96',
  8340. 'walking_man':'\ud83d\udeb6',
  8341. 'walking_woman':'\ud83d\udeb6&zwj;\u2640\ufe0f',
  8342. 'waning_crescent_moon':'\ud83c\udf18',
  8343. 'waning_gibbous_moon':'\ud83c\udf16',
  8344. 'warning':'\u26a0\ufe0f',
  8345. 'wastebasket':'\ud83d\uddd1',
  8346. 'watch':'\u231a\ufe0f',
  8347. 'water_buffalo':'\ud83d\udc03',
  8348. 'watermelon':'\ud83c\udf49',
  8349. 'wave':'\ud83d\udc4b',
  8350. 'wavy_dash':'\u3030\ufe0f',
  8351. 'waxing_crescent_moon':'\ud83c\udf12',
  8352. 'wc':'\ud83d\udebe',
  8353. 'weary':'\ud83d\ude29',
  8354. 'wedding':'\ud83d\udc92',
  8355. 'weight_lifting_man':'\ud83c\udfcb\ufe0f',
  8356. 'weight_lifting_woman':'\ud83c\udfcb\ufe0f&zwj;\u2640\ufe0f',
  8357. 'whale':'\ud83d\udc33',
  8358. 'whale2':'\ud83d\udc0b',
  8359. 'wheel_of_dharma':'\u2638\ufe0f',
  8360. 'wheelchair':'\u267f\ufe0f',
  8361. 'white_check_mark':'\u2705',
  8362. 'white_circle':'\u26aa\ufe0f',
  8363. 'white_flag':'\ud83c\udff3\ufe0f',
  8364. 'white_flower':'\ud83d\udcae',
  8365. 'white_large_square':'\u2b1c\ufe0f',
  8366. 'white_medium_small_square':'\u25fd\ufe0f',
  8367. 'white_medium_square':'\u25fb\ufe0f',
  8368. 'white_small_square':'\u25ab\ufe0f',
  8369. 'white_square_button':'\ud83d\udd33',
  8370. 'wilted_flower':'\ud83e\udd40',
  8371. 'wind_chime':'\ud83c\udf90',
  8372. 'wind_face':'\ud83c\udf2c',
  8373. 'wine_glass':'\ud83c\udf77',
  8374. 'wink':'\ud83d\ude09',
  8375. 'wolf':'\ud83d\udc3a',
  8376. 'woman':'\ud83d\udc69',
  8377. 'woman_artist':'\ud83d\udc69&zwj;\ud83c\udfa8',
  8378. 'woman_astronaut':'\ud83d\udc69&zwj;\ud83d\ude80',
  8379. 'woman_cartwheeling':'\ud83e\udd38&zwj;\u2640\ufe0f',
  8380. 'woman_cook':'\ud83d\udc69&zwj;\ud83c\udf73',
  8381. 'woman_facepalming':'\ud83e\udd26&zwj;\u2640\ufe0f',
  8382. 'woman_factory_worker':'\ud83d\udc69&zwj;\ud83c\udfed',
  8383. 'woman_farmer':'\ud83d\udc69&zwj;\ud83c\udf3e',
  8384. 'woman_firefighter':'\ud83d\udc69&zwj;\ud83d\ude92',
  8385. 'woman_health_worker':'\ud83d\udc69&zwj;\u2695\ufe0f',
  8386. 'woman_judge':'\ud83d\udc69&zwj;\u2696\ufe0f',
  8387. 'woman_juggling':'\ud83e\udd39&zwj;\u2640\ufe0f',
  8388. 'woman_mechanic':'\ud83d\udc69&zwj;\ud83d\udd27',
  8389. 'woman_office_worker':'\ud83d\udc69&zwj;\ud83d\udcbc',
  8390. 'woman_pilot':'\ud83d\udc69&zwj;\u2708\ufe0f',
  8391. 'woman_playing_handball':'\ud83e\udd3e&zwj;\u2640\ufe0f',
  8392. 'woman_playing_water_polo':'\ud83e\udd3d&zwj;\u2640\ufe0f',
  8393. 'woman_scientist':'\ud83d\udc69&zwj;\ud83d\udd2c',
  8394. 'woman_shrugging':'\ud83e\udd37&zwj;\u2640\ufe0f',
  8395. 'woman_singer':'\ud83d\udc69&zwj;\ud83c\udfa4',
  8396. 'woman_student':'\ud83d\udc69&zwj;\ud83c\udf93',
  8397. 'woman_teacher':'\ud83d\udc69&zwj;\ud83c\udfeb',
  8398. 'woman_technologist':'\ud83d\udc69&zwj;\ud83d\udcbb',
  8399. 'woman_with_turban':'\ud83d\udc73&zwj;\u2640\ufe0f',
  8400. 'womans_clothes':'\ud83d\udc5a',
  8401. 'womans_hat':'\ud83d\udc52',
  8402. 'women_wrestling':'\ud83e\udd3c&zwj;\u2640\ufe0f',
  8403. 'womens':'\ud83d\udeba',
  8404. 'world_map':'\ud83d\uddfa',
  8405. 'worried':'\ud83d\ude1f',
  8406. 'wrench':'\ud83d\udd27',
  8407. 'writing_hand':'\u270d\ufe0f',
  8408. 'x':'\u274c',
  8409. 'yellow_heart':'\ud83d\udc9b',
  8410. 'yen':'\ud83d\udcb4',
  8411. 'yin_yang':'\u262f\ufe0f',
  8412. 'yum':'\ud83d\ude0b',
  8413. 'zap':'\u26a1\ufe0f',
  8414. 'zipper_mouth_face':'\ud83e\udd10',
  8415. 'zzz':'\ud83d\udca4',
  8416. /* special emojis :P */
  8417. 'octocat': '<img alt=":octocat:" height="20" width="20" align="absmiddle" src="https://assets-cdn.github.com/images/icons/emoji/octocat.png">',
  8418. 'showdown': '<span style="font-family: \'Anonymous Pro\', monospace; text-decoration: underline; text-decoration-style: dashed; text-decoration-color: #3e8b8a;text-underline-position: under;">S</span>'
  8419. };
  8420. /**
  8421. * Created by Estevao on 31-05-2015.
  8422. */
  8423. /**
  8424. * Showdown Converter class
  8425. * @class
  8426. * @param {object} [converterOptions]
  8427. * @returns {Converter}
  8428. */
  8429. showdown.Converter = function (converterOptions) {
  8430. 'use strict';
  8431. var
  8432. /**
  8433. * Options used by this converter
  8434. * @private
  8435. * @type {{}}
  8436. */
  8437. options = {},
  8438. /**
  8439. * Language extensions used by this converter
  8440. * @private
  8441. * @type {Array}
  8442. */
  8443. langExtensions = [],
  8444. /**
  8445. * Output modifiers extensions used by this converter
  8446. * @private
  8447. * @type {Array}
  8448. */
  8449. outputModifiers = [],
  8450. /**
  8451. * Event listeners
  8452. * @private
  8453. * @type {{}}
  8454. */
  8455. listeners = {},
  8456. /**
  8457. * The flavor set in this converter
  8458. */
  8459. setConvFlavor = setFlavor,
  8460. /**
  8461. * Metadata of the document
  8462. * @type {{parsed: {}, raw: string, format: string}}
  8463. */
  8464. metadata = {
  8465. parsed: {},
  8466. raw: '',
  8467. format: ''
  8468. };
  8469. _constructor();
  8470. /**
  8471. * Converter constructor
  8472. * @private
  8473. */
  8474. function _constructor () {
  8475. converterOptions = converterOptions || {};
  8476. for (var gOpt in globalOptions) {
  8477. if (globalOptions.hasOwnProperty(gOpt)) {
  8478. options[gOpt] = globalOptions[gOpt];
  8479. }
  8480. }
  8481. // Merge options
  8482. if (typeof converterOptions === 'object') {
  8483. for (var opt in converterOptions) {
  8484. if (converterOptions.hasOwnProperty(opt)) {
  8485. options[opt] = converterOptions[opt];
  8486. }
  8487. }
  8488. } else {
  8489. throw Error('Converter expects the passed parameter to be an object, but ' + typeof converterOptions +
  8490. ' was passed instead.');
  8491. }
  8492. if (options.extensions) {
  8493. showdown.helper.forEach(options.extensions, _parseExtension);
  8494. }
  8495. }
  8496. /**
  8497. * Parse extension
  8498. * @param {*} ext
  8499. * @param {string} [name='']
  8500. * @private
  8501. */
  8502. function _parseExtension (ext, name) {
  8503. name = name || null;
  8504. // If it's a string, the extension was previously loaded
  8505. if (showdown.helper.isString(ext)) {
  8506. ext = showdown.helper.stdExtName(ext);
  8507. name = ext;
  8508. // LEGACY_SUPPORT CODE
  8509. if (showdown.extensions[ext]) {
  8510. console.warn('DEPRECATION WARNING: ' + ext + ' is an old extension that uses a deprecated loading method.' +
  8511. 'Please inform the developer that the extension should be updated!');
  8512. legacyExtensionLoading(showdown.extensions[ext], ext);
  8513. return;
  8514. // END LEGACY SUPPORT CODE
  8515. } else if (!showdown.helper.isUndefined(extensions[ext])) {
  8516. ext = extensions[ext];
  8517. } else {
  8518. throw Error('Extension "' + ext + '" could not be loaded. It was either not found or is not a valid extension.');
  8519. }
  8520. }
  8521. if (typeof ext === 'function') {
  8522. ext = ext();
  8523. }
  8524. if (!showdown.helper.isArray(ext)) {
  8525. ext = [ext];
  8526. }
  8527. var validExt = validate(ext, name);
  8528. if (!validExt.valid) {
  8529. throw Error(validExt.error);
  8530. }
  8531. for (var i = 0; i < ext.length; ++i) {
  8532. switch (ext[i].type) {
  8533. case 'lang':
  8534. langExtensions.push(ext[i]);
  8535. break;
  8536. case 'output':
  8537. outputModifiers.push(ext[i]);
  8538. break;
  8539. }
  8540. if (ext[i].hasOwnProperty('listeners')) {
  8541. for (var ln in ext[i].listeners) {
  8542. if (ext[i].listeners.hasOwnProperty(ln)) {
  8543. listen(ln, ext[i].listeners[ln]);
  8544. }
  8545. }
  8546. }
  8547. }
  8548. }
  8549. /**
  8550. * LEGACY_SUPPORT
  8551. * @param {*} ext
  8552. * @param {string} name
  8553. */
  8554. function legacyExtensionLoading (ext, name) {
  8555. if (typeof ext === 'function') {
  8556. ext = ext(new showdown.Converter());
  8557. }
  8558. if (!showdown.helper.isArray(ext)) {
  8559. ext = [ext];
  8560. }
  8561. var valid = validate(ext, name);
  8562. if (!valid.valid) {
  8563. throw Error(valid.error);
  8564. }
  8565. for (var i = 0; i < ext.length; ++i) {
  8566. switch (ext[i].type) {
  8567. case 'lang':
  8568. langExtensions.push(ext[i]);
  8569. break;
  8570. case 'output':
  8571. outputModifiers.push(ext[i]);
  8572. break;
  8573. default:// should never reach here
  8574. throw Error('Extension loader error: Type unrecognized!!!');
  8575. }
  8576. }
  8577. }
  8578. /**
  8579. * Listen to an event
  8580. * @param {string} name
  8581. * @param {function} callback
  8582. */
  8583. function listen (name, callback) {
  8584. if (!showdown.helper.isString(name)) {
  8585. throw Error('Invalid argument in converter.listen() method: name must be a string, but ' + typeof name + ' given');
  8586. }
  8587. if (typeof callback !== 'function') {
  8588. throw Error('Invalid argument in converter.listen() method: callback must be a function, but ' + typeof callback + ' given');
  8589. }
  8590. if (!listeners.hasOwnProperty(name)) {
  8591. listeners[name] = [];
  8592. }
  8593. listeners[name].push(callback);
  8594. }
  8595. function rTrimInputText (text) {
  8596. var rsp = text.match(/^\s*/)[0].length,
  8597. rgx = new RegExp('^\\s{0,' + rsp + '}', 'gm');
  8598. return text.replace(rgx, '');
  8599. }
  8600. /**
  8601. * Dispatch an event
  8602. * @private
  8603. * @param {string} evtName Event name
  8604. * @param {string} text Text
  8605. * @param {{}} options Converter Options
  8606. * @param {{}} globals
  8607. * @returns {string}
  8608. */
  8609. this._dispatch = function dispatch (evtName, text, options, globals) {
  8610. if (listeners.hasOwnProperty(evtName)) {
  8611. for (var ei = 0; ei < listeners[evtName].length; ++ei) {
  8612. var nText = listeners[evtName][ei](evtName, text, this, options, globals);
  8613. if (nText && typeof nText !== 'undefined') {
  8614. text = nText;
  8615. }
  8616. }
  8617. }
  8618. return text;
  8619. };
  8620. /**
  8621. * Listen to an event
  8622. * @param {string} name
  8623. * @param {function} callback
  8624. * @returns {showdown.Converter}
  8625. */
  8626. this.listen = function (name, callback) {
  8627. listen(name, callback);
  8628. return this;
  8629. };
  8630. /**
  8631. * Converts a markdown string into HTML
  8632. * @param {string} text
  8633. * @returns {*}
  8634. */
  8635. this.makeHtml = function (text) {
  8636. //check if text is not falsy
  8637. if (!text) {
  8638. return text;
  8639. }
  8640. var globals = {
  8641. gHtmlBlocks: [],
  8642. gHtmlMdBlocks: [],
  8643. gHtmlSpans: [],
  8644. gUrls: {},
  8645. gTitles: {},
  8646. gDimensions: {},
  8647. gListLevel: 0,
  8648. hashLinkCounts: {},
  8649. langExtensions: langExtensions,
  8650. outputModifiers: outputModifiers,
  8651. converter: this,
  8652. ghCodeBlocks: [],
  8653. metadata: {
  8654. parsed: {},
  8655. raw: '',
  8656. format: ''
  8657. }
  8658. };
  8659. // This lets us use ¨ trema as an escape char to avoid md5 hashes
  8660. // The choice of character is arbitrary; anything that isn't
  8661. // magic in Markdown will work.
  8662. text = text.replace(/¨/g, '¨T');
  8663. // Replace $ with ¨D
  8664. // RegExp interprets $ as a special character
  8665. // when it's in a replacement string
  8666. text = text.replace(/\$/g, '¨D');
  8667. // Standardize line endings
  8668. text = text.replace(/\r\n/g, '\n'); // DOS to Unix
  8669. text = text.replace(/\r/g, '\n'); // Mac to Unix
  8670. // Stardardize line spaces
  8671. text = text.replace(/\u00A0/g, '&nbsp;');
  8672. if (options.smartIndentationFix) {
  8673. text = rTrimInputText(text);
  8674. }
  8675. // Make sure text begins and ends with a couple of newlines:
  8676. text = '\n\n' + text + '\n\n';
  8677. // detab
  8678. text = showdown.subParser('detab')(text, options, globals);
  8679. /**
  8680. * Strip any lines consisting only of spaces and tabs.
  8681. * This makes subsequent regexs easier to write, because we can
  8682. * match consecutive blank lines with /\n+/ instead of something
  8683. * contorted like /[ \t]*\n+/
  8684. */
  8685. text = text.replace(/^[ \t]+$/mg, '');
  8686. //run languageExtensions
  8687. showdown.helper.forEach(langExtensions, function (ext) {
  8688. text = showdown.subParser('runExtension')(ext, text, options, globals);
  8689. });
  8690. // run the sub parsers
  8691. text = showdown.subParser('metadata')(text, options, globals);
  8692. text = showdown.subParser('hashPreCodeTags')(text, options, globals);
  8693. text = showdown.subParser('githubCodeBlocks')(text, options, globals);
  8694. text = showdown.subParser('hashHTMLBlocks')(text, options, globals);
  8695. text = showdown.subParser('hashCodeTags')(text, options, globals);
  8696. text = showdown.subParser('stripLinkDefinitions')(text, options, globals);
  8697. text = showdown.subParser('blockGamut')(text, options, globals);
  8698. text = showdown.subParser('unhashHTMLSpans')(text, options, globals);
  8699. text = showdown.subParser('unescapeSpecialChars')(text, options, globals);
  8700. // attacklab: Restore dollar signs
  8701. text = text.replace(/¨D/g, '$$');
  8702. // attacklab: Restore tremas
  8703. text = text.replace(/¨T/g, '¨');
  8704. // render a complete html document instead of a partial if the option is enabled
  8705. text = showdown.subParser('completeHTMLDocument')(text, options, globals);
  8706. // Run output modifiers
  8707. showdown.helper.forEach(outputModifiers, function (ext) {
  8708. text = showdown.subParser('runExtension')(ext, text, options, globals);
  8709. });
  8710. // update metadata
  8711. metadata = globals.metadata;
  8712. return text;
  8713. };
  8714. /**
  8715. * Converts an HTML string into a markdown string
  8716. * @param src
  8717. * @param [HTMLParser] A WHATWG DOM and HTML parser, such as JSDOM. If none is supplied, window.document will be used.
  8718. * @returns {string}
  8719. */
  8720. this.makeMarkdown = this.makeMd = function (src, HTMLParser) {
  8721. // replace \r\n with \n
  8722. src = src.replace(/\r\n/g, '\n');
  8723. src = src.replace(/\r/g, '\n'); // old macs
  8724. // due to an edge case, we need to find this: > <
  8725. // to prevent removing of non silent white spaces
  8726. // ex: <em>this is</em> <strong>sparta</strong>
  8727. src = src.replace(/>[ \t]+</, '>¨NBSP;<');
  8728. if (!HTMLParser) {
  8729. if (window && window.document) {
  8730. HTMLParser = window.document;
  8731. } else {
  8732. throw new Error('HTMLParser is undefined. If in a webworker or nodejs environment, you need to provide a WHATWG DOM and HTML such as JSDOM');
  8733. }
  8734. }
  8735. var doc = HTMLParser.createElement('div');
  8736. doc.innerHTML = src;
  8737. var globals = {
  8738. preList: substitutePreCodeTags(doc)
  8739. };
  8740. // remove all newlines and collapse spaces
  8741. clean(doc);
  8742. // some stuff, like accidental reference links must now be escaped
  8743. // TODO
  8744. // doc.innerHTML = doc.innerHTML.replace(/\[[\S\t ]]/);
  8745. var nodes = doc.childNodes,
  8746. mdDoc = '';
  8747. for (var i = 0; i < nodes.length; i++) {
  8748. mdDoc += showdown.subParser('makeMarkdown.node')(nodes[i], globals);
  8749. }
  8750. function clean (node) {
  8751. for (var n = 0; n < node.childNodes.length; ++n) {
  8752. var child = node.childNodes[n];
  8753. if (child.nodeType === 3) {
  8754. if (!/\S/.test(child.nodeValue)) {
  8755. node.removeChild(child);
  8756. --n;
  8757. } else {
  8758. child.nodeValue = child.nodeValue.split('\n').join(' ');
  8759. child.nodeValue = child.nodeValue.replace(/(\s)+/g, '$1');
  8760. }
  8761. } else if (child.nodeType === 1) {
  8762. clean(child);
  8763. }
  8764. }
  8765. }
  8766. // find all pre tags and replace contents with placeholder
  8767. // we need this so that we can remove all indentation from html
  8768. // to ease up parsing
  8769. function substitutePreCodeTags (doc) {
  8770. var pres = doc.querySelectorAll('pre'),
  8771. presPH = [];
  8772. for (var i = 0; i < pres.length; ++i) {
  8773. if (pres[i].childElementCount === 1 && pres[i].firstChild.tagName.toLowerCase() === 'code') {
  8774. var content = pres[i].firstChild.innerHTML.trim(),
  8775. language = pres[i].firstChild.getAttribute('data-language') || '';
  8776. // if data-language attribute is not defined, then we look for class language-*
  8777. if (language === '') {
  8778. var classes = pres[i].firstChild.className.split(' ');
  8779. for (var c = 0; c < classes.length; ++c) {
  8780. var matches = classes[c].match(/^language-(.+)$/);
  8781. if (matches !== null) {
  8782. language = matches[1];
  8783. break;
  8784. }
  8785. }
  8786. }
  8787. // unescape html entities in content
  8788. content = showdown.helper.unescapeHTMLEntities(content);
  8789. presPH.push(content);
  8790. pres[i].outerHTML = '<precode language="' + language + '" precodenum="' + i.toString() + '"></precode>';
  8791. } else {
  8792. presPH.push(pres[i].innerHTML);
  8793. pres[i].innerHTML = '';
  8794. pres[i].setAttribute('prenum', i.toString());
  8795. }
  8796. }
  8797. return presPH;
  8798. }
  8799. return mdDoc;
  8800. };
  8801. /**
  8802. * Set an option of this Converter instance
  8803. * @param {string} key
  8804. * @param {*} value
  8805. */
  8806. this.setOption = function (key, value) {
  8807. options[key] = value;
  8808. };
  8809. /**
  8810. * Get the option of this Converter instance
  8811. * @param {string} key
  8812. * @returns {*}
  8813. */
  8814. this.getOption = function (key) {
  8815. return options[key];
  8816. };
  8817. /**
  8818. * Get the options of this Converter instance
  8819. * @returns {{}}
  8820. */
  8821. this.getOptions = function () {
  8822. return options;
  8823. };
  8824. /**
  8825. * Add extension to THIS converter
  8826. * @param {{}} extension
  8827. * @param {string} [name=null]
  8828. */
  8829. this.addExtension = function (extension, name) {
  8830. name = name || null;
  8831. _parseExtension(extension, name);
  8832. };
  8833. /**
  8834. * Use a global registered extension with THIS converter
  8835. * @param {string} extensionName Name of the previously registered extension
  8836. */
  8837. this.useExtension = function (extensionName) {
  8838. _parseExtension(extensionName);
  8839. };
  8840. /**
  8841. * Set the flavor THIS converter should use
  8842. * @param {string} name
  8843. */
  8844. this.setFlavor = function (name) {
  8845. if (!flavor.hasOwnProperty(name)) {
  8846. throw Error(name + ' flavor was not found');
  8847. }
  8848. var preset = flavor[name];
  8849. setConvFlavor = name;
  8850. for (var option in preset) {
  8851. if (preset.hasOwnProperty(option)) {
  8852. options[option] = preset[option];
  8853. }
  8854. }
  8855. };
  8856. /**
  8857. * Get the currently set flavor of this converter
  8858. * @returns {string}
  8859. */
  8860. this.getFlavor = function () {
  8861. return setConvFlavor;
  8862. };
  8863. /**
  8864. * Remove an extension from THIS converter.
  8865. * Note: This is a costly operation. It's better to initialize a new converter
  8866. * and specify the extensions you wish to use
  8867. * @param {Array} extension
  8868. */
  8869. this.removeExtension = function (extension) {
  8870. if (!showdown.helper.isArray(extension)) {
  8871. extension = [extension];
  8872. }
  8873. for (var a = 0; a < extension.length; ++a) {
  8874. var ext = extension[a];
  8875. for (var i = 0; i < langExtensions.length; ++i) {
  8876. if (langExtensions[i] === ext) {
  8877. langExtensions[i].splice(i, 1);
  8878. }
  8879. }
  8880. for (var ii = 0; ii < outputModifiers.length; ++i) {
  8881. if (outputModifiers[ii] === ext) {
  8882. outputModifiers[ii].splice(i, 1);
  8883. }
  8884. }
  8885. }
  8886. };
  8887. /**
  8888. * Get all extension of THIS converter
  8889. * @returns {{language: Array, output: Array}}
  8890. */
  8891. this.getAllExtensions = function () {
  8892. return {
  8893. language: langExtensions,
  8894. output: outputModifiers
  8895. };
  8896. };
  8897. /**
  8898. * Get the metadata of the previously parsed document
  8899. * @param raw
  8900. * @returns {string|{}}
  8901. */
  8902. this.getMetadata = function (raw) {
  8903. if (raw) {
  8904. return metadata.raw;
  8905. } else {
  8906. return metadata.parsed;
  8907. }
  8908. };
  8909. /**
  8910. * Get the metadata format of the previously parsed document
  8911. * @returns {string}
  8912. */
  8913. this.getMetadataFormat = function () {
  8914. return metadata.format;
  8915. };
  8916. /**
  8917. * Private: set a single key, value metadata pair
  8918. * @param {string} key
  8919. * @param {string} value
  8920. */
  8921. this._setMetadataPair = function (key, value) {
  8922. metadata.parsed[key] = value;
  8923. };
  8924. /**
  8925. * Private: set metadata format
  8926. * @param {string} format
  8927. */
  8928. this._setMetadataFormat = function (format) {
  8929. metadata.format = format;
  8930. };
  8931. /**
  8932. * Private: set metadata raw text
  8933. * @param {string} raw
  8934. */
  8935. this._setMetadataRaw = function (raw) {
  8936. metadata.raw = raw;
  8937. };
  8938. };
  8939. /**
  8940. * Turn Markdown link shortcuts into XHTML <a> tags.
  8941. */
  8942. showdown.subParser('anchors', function (text, options, globals) {
  8943. 'use strict';
  8944. text = globals.converter._dispatch('anchors.before', text, options, globals);
  8945. var writeAnchorTag = function (wholeMatch, linkText, linkId, url, m5, m6, title) {
  8946. if (showdown.helper.isUndefined(title)) {
  8947. title = '';
  8948. }
  8949. linkId = linkId.toLowerCase();
  8950. // Special case for explicit empty url
  8951. if (wholeMatch.search(/\(<?\s*>? ?(['"].*['"])?\)$/m) > -1) {
  8952. url = '';
  8953. } else if (!url) {
  8954. if (!linkId) {
  8955. // lower-case and turn embedded newlines into spaces
  8956. linkId = linkText.toLowerCase().replace(/ ?\n/g, ' ');
  8957. }
  8958. url = '#' + linkId;
  8959. if (!showdown.helper.isUndefined(globals.gUrls[linkId])) {
  8960. url = globals.gUrls[linkId];
  8961. if (!showdown.helper.isUndefined(globals.gTitles[linkId])) {
  8962. title = globals.gTitles[linkId];
  8963. }
  8964. } else {
  8965. return wholeMatch;
  8966. }
  8967. }
  8968. //url = showdown.helper.escapeCharacters(url, '*_', false); // replaced line to improve performance
  8969. url = url.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  8970. var result = '<a href="' + url + '"';
  8971. if (title !== '' && title !== null) {
  8972. title = title.replace(/"/g, '&quot;');
  8973. //title = showdown.helper.escapeCharacters(title, '*_', false); // replaced line to improve performance
  8974. title = title.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  8975. result += ' title="' + title + '"';
  8976. }
  8977. // optionLinksInNewWindow only applies
  8978. // to external links. Hash links (#) open in same page
  8979. if (options.openLinksInNewWindow && !/^#/.test(url)) {
  8980. // escaped _
  8981. result += ' rel="noopener noreferrer" target="¨E95Eblank"';
  8982. }
  8983. result += '>' + linkText + '</a>';
  8984. return result;
  8985. };
  8986. // First, handle reference-style links: [link text] [id]
  8987. text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)] ?(?:\n *)?\[(.*?)]()()()()/g, writeAnchorTag);
  8988. // Next, inline-style links: [link text](url "optional title")
  8989. // cases with crazy urls like ./image/cat1).png
  8990. text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)]()[ \t]*\([ \t]?<([^>]*)>(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g,
  8991. writeAnchorTag);
  8992. // normal cases
  8993. text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)]()[ \t]*\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g,
  8994. writeAnchorTag);
  8995. // handle reference-style shortcuts: [link text]
  8996. // These must come last in case you've also got [link test][1]
  8997. // or [link test](/foo)
  8998. text = text.replace(/\[([^\[\]]+)]()()()()()/g, writeAnchorTag);
  8999. // Lastly handle GithubMentions if option is enabled
  9000. if (options.ghMentions) {
  9001. text = text.replace(/(^|\s)(\\)?(@([a-z\d]+(?:[a-z\d.-]+?[a-z\d]+)*))/gmi, function (wm, st, escape, mentions, username) {
  9002. if (escape === '\\') {
  9003. return st + mentions;
  9004. }
  9005. //check if options.ghMentionsLink is a string
  9006. if (!showdown.helper.isString(options.ghMentionsLink)) {
  9007. throw new Error('ghMentionsLink option must be a string');
  9008. }
  9009. var lnk = options.ghMentionsLink.replace(/\{u}/g, username),
  9010. target = '';
  9011. if (options.openLinksInNewWindow) {
  9012. target = ' rel="noopener noreferrer" target="¨E95Eblank"';
  9013. }
  9014. return st + '<a href="' + lnk + '"' + target + '>' + mentions + '</a>';
  9015. });
  9016. }
  9017. text = globals.converter._dispatch('anchors.after', text, options, globals);
  9018. return text;
  9019. });
  9020. // url allowed chars [a-z\d_.~:/?#[]@!$&'()*+,;=-]
  9021. var simpleURLRegex = /([*~_]+|\b)(((https?|ftp|dict):\/\/|www\.)[^'">\s]+?\.[^'">\s]+?)()(\1)?(?=\s|$)(?!["<>])/gi,
  9022. simpleURLRegex2 = /([*~_]+|\b)(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+?)([.!?,()\[\]])?(\1)?(?=\s|$)(?!["<>])/gi,
  9023. delimUrlRegex = /()<(((https?|ftp|dict):\/\/|www\.)[^'">\s]+)()>()/gi,
  9024. simpleMailRegex = /(^|\s)(?:mailto:)?([A-Za-z0-9!#$%&'*+-/=?^_`{|}~.]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(?=$|\s)/gmi,
  9025. delimMailRegex = /<()(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,
  9026. replaceLink = function (options) {
  9027. 'use strict';
  9028. return function (wm, leadingMagicChars, link, m2, m3, trailingPunctuation, trailingMagicChars) {
  9029. link = link.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  9030. var lnkTxt = link,
  9031. append = '',
  9032. target = '',
  9033. lmc = leadingMagicChars || '',
  9034. tmc = trailingMagicChars || '';
  9035. if (/^www\./i.test(link)) {
  9036. link = link.replace(/^www\./i, 'http://www.');
  9037. }
  9038. if (options.excludeTrailingPunctuationFromURLs && trailingPunctuation) {
  9039. append = trailingPunctuation;
  9040. }
  9041. if (options.openLinksInNewWindow) {
  9042. target = ' rel="noopener noreferrer" target="¨E95Eblank"';
  9043. }
  9044. return lmc + '<a href="' + link + '"' + target + '>' + lnkTxt + '</a>' + append + tmc;
  9045. };
  9046. },
  9047. replaceMail = function (options, globals) {
  9048. 'use strict';
  9049. return function (wholeMatch, b, mail) {
  9050. var href = 'mailto:';
  9051. b = b || '';
  9052. mail = showdown.subParser('unescapeSpecialChars')(mail, options, globals);
  9053. if (options.encodeEmails) {
  9054. href = showdown.helper.encodeEmailAddress(href + mail);
  9055. mail = showdown.helper.encodeEmailAddress(mail);
  9056. } else {
  9057. href = href + mail;
  9058. }
  9059. return b + '<a href="' + href + '">' + mail + '</a>';
  9060. };
  9061. };
  9062. showdown.subParser('autoLinks', function (text, options, globals) {
  9063. 'use strict';
  9064. text = globals.converter._dispatch('autoLinks.before', text, options, globals);
  9065. text = text.replace(delimUrlRegex, replaceLink(options));
  9066. text = text.replace(delimMailRegex, replaceMail(options, globals));
  9067. text = globals.converter._dispatch('autoLinks.after', text, options, globals);
  9068. return text;
  9069. });
  9070. showdown.subParser('simplifiedAutoLinks', function (text, options, globals) {
  9071. 'use strict';
  9072. if (!options.simplifiedAutoLink) {
  9073. return text;
  9074. }
  9075. text = globals.converter._dispatch('simplifiedAutoLinks.before', text, options, globals);
  9076. if (options.excludeTrailingPunctuationFromURLs) {
  9077. text = text.replace(simpleURLRegex2, replaceLink(options));
  9078. } else {
  9079. text = text.replace(simpleURLRegex, replaceLink(options));
  9080. }
  9081. text = text.replace(simpleMailRegex, replaceMail(options, globals));
  9082. text = globals.converter._dispatch('simplifiedAutoLinks.after', text, options, globals);
  9083. return text;
  9084. });
  9085. /**
  9086. * These are all the transformations that form block-level
  9087. * tags like paragraphs, headers, and list items.
  9088. */
  9089. showdown.subParser('blockGamut', function (text, options, globals) {
  9090. 'use strict';
  9091. text = globals.converter._dispatch('blockGamut.before', text, options, globals);
  9092. // we parse blockquotes first so that we can have headings and hrs
  9093. // inside blockquotes
  9094. text = showdown.subParser('blockQuotes')(text, options, globals);
  9095. text = showdown.subParser('headers')(text, options, globals);
  9096. // Do Horizontal Rules:
  9097. text = showdown.subParser('horizontalRule')(text, options, globals);
  9098. text = showdown.subParser('lists')(text, options, globals);
  9099. text = showdown.subParser('codeBlocks')(text, options, globals);
  9100. text = showdown.subParser('tables')(text, options, globals);
  9101. // We already ran _HashHTMLBlocks() before, in Markdown(), but that
  9102. // was to escape raw HTML in the original Markdown source. This time,
  9103. // we're escaping the markup we've just created, so that we don't wrap
  9104. // <p> tags around block-level tags.
  9105. text = showdown.subParser('hashHTMLBlocks')(text, options, globals);
  9106. text = showdown.subParser('paragraphs')(text, options, globals);
  9107. text = globals.converter._dispatch('blockGamut.after', text, options, globals);
  9108. return text;
  9109. });
  9110. showdown.subParser('blockQuotes', function (text, options, globals) {
  9111. 'use strict';
  9112. text = globals.converter._dispatch('blockQuotes.before', text, options, globals);
  9113. // add a couple extra lines after the text and endtext mark
  9114. text = text + '\n\n';
  9115. var rgx = /(^ {0,3}>[ \t]?.+\n(.+\n)*\n*)+/gm;
  9116. if (options.splitAdjacentBlockquotes) {
  9117. rgx = /^ {0,3}>[\s\S]*?(?:\n\n)/gm;
  9118. }
  9119. text = text.replace(rgx, function (bq) {
  9120. // attacklab: hack around Konqueror 3.5.4 bug:
  9121. // "----------bug".replace(/^-/g,"") == "bug"
  9122. bq = bq.replace(/^[ \t]*>[ \t]?/gm, ''); // trim one level of quoting
  9123. // attacklab: clean up hack
  9124. bq = bq.replace(/¨0/g, '');
  9125. bq = bq.replace(/^[ \t]+$/gm, ''); // trim whitespace-only lines
  9126. bq = showdown.subParser('githubCodeBlocks')(bq, options, globals);
  9127. bq = showdown.subParser('blockGamut')(bq, options, globals); // recurse
  9128. bq = bq.replace(/(^|\n)/g, '$1 ');
  9129. // These leading spaces screw with <pre> content, so we need to fix that:
  9130. bq = bq.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm, function (wholeMatch, m1) {
  9131. var pre = m1;
  9132. // attacklab: hack around Konqueror 3.5.4 bug:
  9133. pre = pre.replace(/^ /mg, '¨0');
  9134. pre = pre.replace(/¨0/g, '');
  9135. return pre;
  9136. });
  9137. return showdown.subParser('hashBlock')('<blockquote>\n' + bq + '\n</blockquote>', options, globals);
  9138. });
  9139. text = globals.converter._dispatch('blockQuotes.after', text, options, globals);
  9140. return text;
  9141. });
  9142. /**
  9143. * Process Markdown `<pre><code>` blocks.
  9144. */
  9145. showdown.subParser('codeBlocks', function (text, options, globals) {
  9146. 'use strict';
  9147. text = globals.converter._dispatch('codeBlocks.before', text, options, globals);
  9148. // sentinel workarounds for lack of \A and \Z, safari\khtml bug
  9149. text += '¨0';
  9150. var pattern = /(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=¨0))/g;
  9151. text = text.replace(pattern, function (wholeMatch, m1, m2) {
  9152. var codeblock = m1,
  9153. nextChar = m2,
  9154. end = '\n';
  9155. codeblock = showdown.subParser('outdent')(codeblock, options, globals);
  9156. codeblock = showdown.subParser('encodeCode')(codeblock, options, globals);
  9157. codeblock = showdown.subParser('detab')(codeblock, options, globals);
  9158. codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
  9159. codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing newlines
  9160. if (options.omitExtraWLInCodeBlocks) {
  9161. end = '';
  9162. }
  9163. codeblock = '<pre><code>' + codeblock + end + '</code></pre>';
  9164. return showdown.subParser('hashBlock')(codeblock, options, globals) + nextChar;
  9165. });
  9166. // strip sentinel
  9167. text = text.replace(/¨0/, '');
  9168. text = globals.converter._dispatch('codeBlocks.after', text, options, globals);
  9169. return text;
  9170. });
  9171. /**
  9172. *
  9173. * * Backtick quotes are used for <code></code> spans.
  9174. *
  9175. * * You can use multiple backticks as the delimiters if you want to
  9176. * include literal backticks in the code span. So, this input:
  9177. *
  9178. * Just type ``foo `bar` baz`` at the prompt.
  9179. *
  9180. * Will translate to:
  9181. *
  9182. * <p>Just type <code>foo `bar` baz</code> at the prompt.</p>
  9183. *
  9184. * There's no arbitrary limit to the number of backticks you
  9185. * can use as delimters. If you need three consecutive backticks
  9186. * in your code, use four for delimiters, etc.
  9187. *
  9188. * * You can use spaces to get literal backticks at the edges:
  9189. *
  9190. * ... type `` `bar` `` ...
  9191. *
  9192. * Turns to:
  9193. *
  9194. * ... type <code>`bar`</code> ...
  9195. */
  9196. showdown.subParser('codeSpans', function (text, options, globals) {
  9197. 'use strict';
  9198. text = globals.converter._dispatch('codeSpans.before', text, options, globals);
  9199. if (typeof text === 'undefined') {
  9200. text = '';
  9201. }
  9202. text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
  9203. function (wholeMatch, m1, m2, m3) {
  9204. var c = m3;
  9205. c = c.replace(/^([ \t]*)/g, ''); // leading whitespace
  9206. c = c.replace(/[ \t]*$/g, ''); // trailing whitespace
  9207. c = showdown.subParser('encodeCode')(c, options, globals);
  9208. c = m1 + '<code>' + c + '</code>';
  9209. c = showdown.subParser('hashHTMLSpans')(c, options, globals);
  9210. return c;
  9211. }
  9212. );
  9213. text = globals.converter._dispatch('codeSpans.after', text, options, globals);
  9214. return text;
  9215. });
  9216. /**
  9217. * Create a full HTML document from the processed markdown
  9218. */
  9219. showdown.subParser('completeHTMLDocument', function (text, options, globals) {
  9220. 'use strict';
  9221. if (!options.completeHTMLDocument) {
  9222. return text;
  9223. }
  9224. text = globals.converter._dispatch('completeHTMLDocument.before', text, options, globals);
  9225. var doctype = 'html',
  9226. doctypeParsed = '<!DOCTYPE HTML>\n',
  9227. title = '',
  9228. charset = '<meta charset="utf-8">\n',
  9229. lang = '',
  9230. metadata = '';
  9231. if (typeof globals.metadata.parsed.doctype !== 'undefined') {
  9232. doctypeParsed = '<!DOCTYPE ' + globals.metadata.parsed.doctype + '>\n';
  9233. doctype = globals.metadata.parsed.doctype.toString().toLowerCase();
  9234. if (doctype === 'html' || doctype === 'html5') {
  9235. charset = '<meta charset="utf-8">';
  9236. }
  9237. }
  9238. for (var meta in globals.metadata.parsed) {
  9239. if (globals.metadata.parsed.hasOwnProperty(meta)) {
  9240. switch (meta.toLowerCase()) {
  9241. case 'doctype':
  9242. break;
  9243. case 'title':
  9244. title = '<title>' + globals.metadata.parsed.title + '</title>\n';
  9245. break;
  9246. case 'charset':
  9247. if (doctype === 'html' || doctype === 'html5') {
  9248. charset = '<meta charset="' + globals.metadata.parsed.charset + '">\n';
  9249. } else {
  9250. charset = '<meta name="charset" content="' + globals.metadata.parsed.charset + '">\n';
  9251. }
  9252. break;
  9253. case 'language':
  9254. case 'lang':
  9255. lang = ' lang="' + globals.metadata.parsed[meta] + '"';
  9256. metadata += '<meta name="' + meta + '" content="' + globals.metadata.parsed[meta] + '">\n';
  9257. break;
  9258. default:
  9259. metadata += '<meta name="' + meta + '" content="' + globals.metadata.parsed[meta] + '">\n';
  9260. }
  9261. }
  9262. }
  9263. text = doctypeParsed + '<html' + lang + '>\n<head>\n' + title + charset + metadata + '</head>\n<body>\n' + text.trim() + '\n</body>\n</html>';
  9264. text = globals.converter._dispatch('completeHTMLDocument.after', text, options, globals);
  9265. return text;
  9266. });
  9267. /**
  9268. * Convert all tabs to spaces
  9269. */
  9270. showdown.subParser('detab', function (text, options, globals) {
  9271. 'use strict';
  9272. text = globals.converter._dispatch('detab.before', text, options, globals);
  9273. // expand first n-1 tabs
  9274. text = text.replace(/\t(?=\t)/g, ' '); // g_tab_width
  9275. // replace the nth with two sentinels
  9276. text = text.replace(/\t/g, '¨A¨B');
  9277. // use the sentinel to anchor our regex so it doesn't explode
  9278. text = text.replace(/¨B(.+?)¨A/g, function (wholeMatch, m1) {
  9279. var leadingText = m1,
  9280. numSpaces = 4 - leadingText.length % 4; // g_tab_width
  9281. // there *must* be a better way to do this:
  9282. for (var i = 0; i < numSpaces; i++) {
  9283. leadingText += ' ';
  9284. }
  9285. return leadingText;
  9286. });
  9287. // clean up sentinels
  9288. text = text.replace(/¨A/g, ' '); // g_tab_width
  9289. text = text.replace(/¨B/g, '');
  9290. text = globals.converter._dispatch('detab.after', text, options, globals);
  9291. return text;
  9292. });
  9293. showdown.subParser('ellipsis', function (text, options, globals) {
  9294. 'use strict';
  9295. text = globals.converter._dispatch('ellipsis.before', text, options, globals);
  9296. text = text.replace(/\.\.\./g, '…');
  9297. text = globals.converter._dispatch('ellipsis.after', text, options, globals);
  9298. return text;
  9299. });
  9300. /**
  9301. * Turn emoji codes into emojis
  9302. *
  9303. * List of supported emojis: https://github.com/showdownjs/showdown/wiki/Emojis
  9304. */
  9305. showdown.subParser('emoji', function (text, options, globals) {
  9306. 'use strict';
  9307. if (!options.emoji) {
  9308. return text;
  9309. }
  9310. text = globals.converter._dispatch('emoji.before', text, options, globals);
  9311. var emojiRgx = /:([\S]+?):/g;
  9312. text = text.replace(emojiRgx, function (wm, emojiCode) {
  9313. if (showdown.helper.emojis.hasOwnProperty(emojiCode)) {
  9314. return showdown.helper.emojis[emojiCode];
  9315. }
  9316. return wm;
  9317. });
  9318. text = globals.converter._dispatch('emoji.after', text, options, globals);
  9319. return text;
  9320. });
  9321. /**
  9322. * Smart processing for ampersands and angle brackets that need to be encoded.
  9323. */
  9324. showdown.subParser('encodeAmpsAndAngles', function (text, options, globals) {
  9325. 'use strict';
  9326. text = globals.converter._dispatch('encodeAmpsAndAngles.before', text, options, globals);
  9327. // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
  9328. // http://bumppo.net/projects/amputator/
  9329. text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, '&amp;');
  9330. // Encode naked <'s
  9331. text = text.replace(/<(?![a-z\/?$!])/gi, '&lt;');
  9332. // Encode <
  9333. text = text.replace(/</g, '&lt;');
  9334. // Encode >
  9335. text = text.replace(/>/g, '&gt;');
  9336. text = globals.converter._dispatch('encodeAmpsAndAngles.after', text, options, globals);
  9337. return text;
  9338. });
  9339. /**
  9340. * Returns the string, with after processing the following backslash escape sequences.
  9341. *
  9342. * attacklab: The polite way to do this is with the new escapeCharacters() function:
  9343. *
  9344. * text = escapeCharacters(text,"\\",true);
  9345. * text = escapeCharacters(text,"`*_{}[]()>#+-.!",true);
  9346. *
  9347. * ...but we're sidestepping its use of the (slow) RegExp constructor
  9348. * as an optimization for Firefox. This function gets called a LOT.
  9349. */
  9350. showdown.subParser('encodeBackslashEscapes', function (text, options, globals) {
  9351. 'use strict';
  9352. text = globals.converter._dispatch('encodeBackslashEscapes.before', text, options, globals);
  9353. text = text.replace(/\\(\\)/g, showdown.helper.escapeCharactersCallback);
  9354. text = text.replace(/\\([`*_{}\[\]()>#+.!~=|-])/g, showdown.helper.escapeCharactersCallback);
  9355. text = globals.converter._dispatch('encodeBackslashEscapes.after', text, options, globals);
  9356. return text;
  9357. });
  9358. /**
  9359. * Encode/escape certain characters inside Markdown code runs.
  9360. * The point is that in code, these characters are literals,
  9361. * and lose their special Markdown meanings.
  9362. */
  9363. showdown.subParser('encodeCode', function (text, options, globals) {
  9364. 'use strict';
  9365. text = globals.converter._dispatch('encodeCode.before', text, options, globals);
  9366. // Encode all ampersands; HTML entities are not
  9367. // entities within a Markdown code span.
  9368. text = text
  9369. .replace(/&/g, '&amp;')
  9370. // Do the angle bracket song and dance:
  9371. .replace(/</g, '&lt;')
  9372. .replace(/>/g, '&gt;')
  9373. // Now, escape characters that are magic in Markdown:
  9374. .replace(/([*_{}\[\]\\=~-])/g, showdown.helper.escapeCharactersCallback);
  9375. text = globals.converter._dispatch('encodeCode.after', text, options, globals);
  9376. return text;
  9377. });
  9378. /**
  9379. * Within tags -- meaning between < and > -- encode [\ ` * _ ~ =] so they
  9380. * don't conflict with their use in Markdown for code, italics and strong.
  9381. */
  9382. showdown.subParser('escapeSpecialCharsWithinTagAttributes', function (text, options, globals) {
  9383. 'use strict';
  9384. text = globals.converter._dispatch('escapeSpecialCharsWithinTagAttributes.before', text, options, globals);
  9385. // Build a regex to find HTML tags.
  9386. var tags = /<\/?[a-z\d_:-]+(?:[\s]+[\s\S]+?)?>/gi,
  9387. comments = /<!(--(?:(?:[^>-]|-[^>])(?:[^-]|-[^-])*)--)>/gi;
  9388. text = text.replace(tags, function (wholeMatch) {
  9389. return wholeMatch
  9390. .replace(/(.)<\/?code>(?=.)/g, '$1`')
  9391. .replace(/([\\`*_~=|])/g, showdown.helper.escapeCharactersCallback);
  9392. });
  9393. text = text.replace(comments, function (wholeMatch) {
  9394. return wholeMatch
  9395. .replace(/([\\`*_~=|])/g, showdown.helper.escapeCharactersCallback);
  9396. });
  9397. text = globals.converter._dispatch('escapeSpecialCharsWithinTagAttributes.after', text, options, globals);
  9398. return text;
  9399. });
  9400. /**
  9401. * Handle github codeblocks prior to running HashHTML so that
  9402. * HTML contained within the codeblock gets escaped properly
  9403. * Example:
  9404. * ```ruby
  9405. * def hello_world(x)
  9406. * puts "Hello, #{x}"
  9407. * end
  9408. * ```
  9409. */
  9410. showdown.subParser('githubCodeBlocks', function (text, options, globals) {
  9411. 'use strict';
  9412. // early exit if option is not enabled
  9413. if (!options.ghCodeBlocks) {
  9414. return text;
  9415. }
  9416. text = globals.converter._dispatch('githubCodeBlocks.before', text, options, globals);
  9417. text += '¨0';
  9418. text = text.replace(/(?:^|\n)(?: {0,3})(```+|~~~+)(?: *)([^\s`~]*)\n([\s\S]*?)\n(?: {0,3})\1/g, function (wholeMatch, delim, language, codeblock) {
  9419. var end = (options.omitExtraWLInCodeBlocks) ? '' : '\n';
  9420. // First parse the github code block
  9421. codeblock = showdown.subParser('encodeCode')(codeblock, options, globals);
  9422. codeblock = showdown.subParser('detab')(codeblock, options, globals);
  9423. codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
  9424. codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing whitespace
  9425. codeblock = '<pre><code' + (language ? ' class="' + language + ' language-' + language + '"' : '') + '>' + codeblock + end + '</code></pre>';
  9426. codeblock = showdown.subParser('hashBlock')(codeblock, options, globals);
  9427. // Since GHCodeblocks can be false positives, we need to
  9428. // store the primitive text and the parsed text in a global var,
  9429. // and then return a token
  9430. return '\n\n¨G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n';
  9431. });
  9432. // attacklab: strip sentinel
  9433. text = text.replace(/¨0/, '');
  9434. return globals.converter._dispatch('githubCodeBlocks.after', text, options, globals);
  9435. });
  9436. showdown.subParser('hashBlock', function (text, options, globals) {
  9437. 'use strict';
  9438. text = globals.converter._dispatch('hashBlock.before', text, options, globals);
  9439. text = text.replace(/(^\n+|\n+$)/g, '');
  9440. text = '\n\n¨K' + (globals.gHtmlBlocks.push(text) - 1) + 'K\n\n';
  9441. text = globals.converter._dispatch('hashBlock.after', text, options, globals);
  9442. return text;
  9443. });
  9444. /**
  9445. * Hash and escape <code> elements that should not be parsed as markdown
  9446. */
  9447. showdown.subParser('hashCodeTags', function (text, options, globals) {
  9448. 'use strict';
  9449. text = globals.converter._dispatch('hashCodeTags.before', text, options, globals);
  9450. var repFunc = function (wholeMatch, match, left, right) {
  9451. var codeblock = left + showdown.subParser('encodeCode')(match, options, globals) + right;
  9452. return '¨C' + (globals.gHtmlSpans.push(codeblock) - 1) + 'C';
  9453. };
  9454. // Hash naked <code>
  9455. text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '<code\\b[^>]*>', '</code>', 'gim');
  9456. text = globals.converter._dispatch('hashCodeTags.after', text, options, globals);
  9457. return text;
  9458. });
  9459. showdown.subParser('hashElement', function (text, options, globals) {
  9460. 'use strict';
  9461. return function (wholeMatch, m1) {
  9462. var blockText = m1;
  9463. // Undo double lines
  9464. blockText = blockText.replace(/\n\n/g, '\n');
  9465. blockText = blockText.replace(/^\n/, '');
  9466. // strip trailing blank lines
  9467. blockText = blockText.replace(/\n+$/g, '');
  9468. // Replace the element text with a marker ("¨KxK" where x is its key)
  9469. blockText = '\n\n¨K' + (globals.gHtmlBlocks.push(blockText) - 1) + 'K\n\n';
  9470. return blockText;
  9471. };
  9472. });
  9473. showdown.subParser('hashHTMLBlocks', function (text, options, globals) {
  9474. 'use strict';
  9475. text = globals.converter._dispatch('hashHTMLBlocks.before', text, options, globals);
  9476. var blockTags = [
  9477. 'pre',
  9478. 'div',
  9479. 'h1',
  9480. 'h2',
  9481. 'h3',
  9482. 'h4',
  9483. 'h5',
  9484. 'h6',
  9485. 'blockquote',
  9486. 'table',
  9487. 'dl',
  9488. 'ol',
  9489. 'ul',
  9490. 'script',
  9491. 'noscript',
  9492. 'form',
  9493. 'fieldset',
  9494. 'iframe',
  9495. 'math',
  9496. 'style',
  9497. 'section',
  9498. 'header',
  9499. 'footer',
  9500. 'nav',
  9501. 'article',
  9502. 'aside',
  9503. 'address',
  9504. 'audio',
  9505. 'canvas',
  9506. 'figure',
  9507. 'hgroup',
  9508. 'output',
  9509. 'video',
  9510. 'p'
  9511. ],
  9512. repFunc = function (wholeMatch, match, left, right) {
  9513. var txt = wholeMatch;
  9514. // check if this html element is marked as markdown
  9515. // if so, it's contents should be parsed as markdown
  9516. if (left.search(/\bmarkdown\b/) !== -1) {
  9517. txt = left + globals.converter.makeHtml(match) + right;
  9518. }
  9519. return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n';
  9520. };
  9521. if (options.backslashEscapesHTMLTags) {
  9522. // encode backslash escaped HTML tags
  9523. text = text.replace(/\\<(\/?[^>]+?)>/g, function (wm, inside) {
  9524. return '&lt;' + inside + '&gt;';
  9525. });
  9526. }
  9527. // hash HTML Blocks
  9528. for (var i = 0; i < blockTags.length; ++i) {
  9529. var opTagPos,
  9530. rgx1 = new RegExp('^ {0,3}(<' + blockTags[i] + '\\b[^>]*>)', 'im'),
  9531. patLeft = '<' + blockTags[i] + '\\b[^>]*>',
  9532. patRight = '</' + blockTags[i] + '>';
  9533. // 1. Look for the first position of the first opening HTML tag in the text
  9534. while ((opTagPos = showdown.helper.regexIndexOf(text, rgx1)) !== -1) {
  9535. // if the HTML tag is \ escaped, we need to escape it and break
  9536. //2. Split the text in that position
  9537. var subTexts = showdown.helper.splitAtIndex(text, opTagPos),
  9538. //3. Match recursively
  9539. newSubText1 = showdown.helper.replaceRecursiveRegExp(subTexts[1], repFunc, patLeft, patRight, 'im');
  9540. // prevent an infinite loop
  9541. if (newSubText1 === subTexts[1]) {
  9542. break;
  9543. }
  9544. text = subTexts[0].concat(newSubText1);
  9545. }
  9546. }
  9547. // HR SPECIAL CASE
  9548. text = text.replace(/(\n {0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,
  9549. showdown.subParser('hashElement')(text, options, globals));
  9550. // Special case for standalone HTML comments
  9551. text = showdown.helper.replaceRecursiveRegExp(text, function (txt) {
  9552. return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n';
  9553. }, '^ {0,3}<!--', '-->', 'gm');
  9554. // PHP and ASP-style processor instructions (<?...?> and <%...%>)
  9555. text = text.replace(/(?:\n\n)( {0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,
  9556. showdown.subParser('hashElement')(text, options, globals));
  9557. text = globals.converter._dispatch('hashHTMLBlocks.after', text, options, globals);
  9558. return text;
  9559. });
  9560. /**
  9561. * Hash span elements that should not be parsed as markdown
  9562. */
  9563. showdown.subParser('hashHTMLSpans', function (text, options, globals) {
  9564. 'use strict';
  9565. text = globals.converter._dispatch('hashHTMLSpans.before', text, options, globals);
  9566. function hashHTMLSpan (html) {
  9567. return '¨C' + (globals.gHtmlSpans.push(html) - 1) + 'C';
  9568. }
  9569. // Hash Self Closing tags
  9570. text = text.replace(/<[^>]+?\/>/gi, function (wm) {
  9571. return hashHTMLSpan(wm);
  9572. });
  9573. // Hash tags without properties
  9574. text = text.replace(/<([^>]+?)>[\s\S]*?<\/\1>/g, function (wm) {
  9575. return hashHTMLSpan(wm);
  9576. });
  9577. // Hash tags with properties
  9578. text = text.replace(/<([^>]+?)\s[^>]+?>[\s\S]*?<\/\1>/g, function (wm) {
  9579. return hashHTMLSpan(wm);
  9580. });
  9581. // Hash self closing tags without />
  9582. text = text.replace(/<[^>]+?>/gi, function (wm) {
  9583. return hashHTMLSpan(wm);
  9584. });
  9585. /*showdown.helper.matchRecursiveRegExp(text, '<code\\b[^>]*>', '</code>', 'gi');*/
  9586. text = globals.converter._dispatch('hashHTMLSpans.after', text, options, globals);
  9587. return text;
  9588. });
  9589. /**
  9590. * Unhash HTML spans
  9591. */
  9592. showdown.subParser('unhashHTMLSpans', function (text, options, globals) {
  9593. 'use strict';
  9594. text = globals.converter._dispatch('unhashHTMLSpans.before', text, options, globals);
  9595. for (var i = 0; i < globals.gHtmlSpans.length; ++i) {
  9596. var repText = globals.gHtmlSpans[i],
  9597. // limiter to prevent infinite loop (assume 10 as limit for recurse)
  9598. limit = 0;
  9599. while (/¨C(\d+)C/.test(repText)) {
  9600. var num = RegExp.$1;
  9601. repText = repText.replace('¨C' + num + 'C', globals.gHtmlSpans[num]);
  9602. if (limit === 10) {
  9603. console.error('maximum nesting of 10 spans reached!!!');
  9604. break;
  9605. }
  9606. ++limit;
  9607. }
  9608. text = text.replace('¨C' + i + 'C', repText);
  9609. }
  9610. text = globals.converter._dispatch('unhashHTMLSpans.after', text, options, globals);
  9611. return text;
  9612. });
  9613. /**
  9614. * Hash and escape <pre><code> elements that should not be parsed as markdown
  9615. */
  9616. showdown.subParser('hashPreCodeTags', function (text, options, globals) {
  9617. 'use strict';
  9618. text = globals.converter._dispatch('hashPreCodeTags.before', text, options, globals);
  9619. var repFunc = function (wholeMatch, match, left, right) {
  9620. // encode html entities
  9621. var codeblock = left + showdown.subParser('encodeCode')(match, options, globals) + right;
  9622. return '\n\n¨G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n';
  9623. };
  9624. // Hash <pre><code>
  9625. text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '^ {0,3}<pre\\b[^>]*>\\s*<code\\b[^>]*>', '^ {0,3}</code>\\s*</pre>', 'gim');
  9626. text = globals.converter._dispatch('hashPreCodeTags.after', text, options, globals);
  9627. return text;
  9628. });
  9629. showdown.subParser('headers', function (text, options, globals) {
  9630. 'use strict';
  9631. text = globals.converter._dispatch('headers.before', text, options, globals);
  9632. var headerLevelStart = (isNaN(parseInt(options.headerLevelStart))) ? 1 : parseInt(options.headerLevelStart),
  9633. // Set text-style headers:
  9634. // Header 1
  9635. // ========
  9636. //
  9637. // Header 2
  9638. // --------
  9639. //
  9640. setextRegexH1 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n={2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n=+[ \t]*\n+/gm,
  9641. setextRegexH2 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n-{2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n-+[ \t]*\n+/gm;
  9642. text = text.replace(setextRegexH1, function (wholeMatch, m1) {
  9643. var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
  9644. hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
  9645. hLevel = headerLevelStart,
  9646. hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>';
  9647. return showdown.subParser('hashBlock')(hashBlock, options, globals);
  9648. });
  9649. text = text.replace(setextRegexH2, function (matchFound, m1) {
  9650. var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
  9651. hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
  9652. hLevel = headerLevelStart + 1,
  9653. hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>';
  9654. return showdown.subParser('hashBlock')(hashBlock, options, globals);
  9655. });
  9656. // atx-style headers:
  9657. // # Header 1
  9658. // ## Header 2
  9659. // ## Header 2 with closing hashes ##
  9660. // ...
  9661. // ###### Header 6
  9662. //
  9663. var atxStyle = (options.requireSpaceBeforeHeadingText) ? /^(#{1,6})[ \t]+(.+?)[ \t]*#*\n+/gm : /^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm;
  9664. text = text.replace(atxStyle, function (wholeMatch, m1, m2) {
  9665. var hText = m2;
  9666. if (options.customizedHeaderId) {
  9667. hText = m2.replace(/\s?\{([^{]+?)}\s*$/, '');
  9668. }
  9669. var span = showdown.subParser('spanGamut')(hText, options, globals),
  9670. hID = (options.noHeaderId) ? '' : ' id="' + headerId(m2) + '"',
  9671. hLevel = headerLevelStart - 1 + m1.length,
  9672. header = '<h' + hLevel + hID + '>' + span + '</h' + hLevel + '>';
  9673. return showdown.subParser('hashBlock')(header, options, globals);
  9674. });
  9675. function headerId (m) {
  9676. var title,
  9677. prefix;
  9678. // It is separate from other options to allow combining prefix and customized
  9679. if (options.customizedHeaderId) {
  9680. var match = m.match(/\{([^{]+?)}\s*$/);
  9681. if (match && match[1]) {
  9682. m = match[1];
  9683. }
  9684. }
  9685. title = m;
  9686. // Prefix id to prevent causing inadvertent pre-existing style matches.
  9687. if (showdown.helper.isString(options.prefixHeaderId)) {
  9688. prefix = options.prefixHeaderId;
  9689. } else if (options.prefixHeaderId === true) {
  9690. prefix = 'section-';
  9691. } else {
  9692. prefix = '';
  9693. }
  9694. if (!options.rawPrefixHeaderId) {
  9695. title = prefix + title;
  9696. }
  9697. if (options.ghCompatibleHeaderId) {
  9698. title = title
  9699. .replace(/ /g, '-')
  9700. // replace previously escaped chars (&, ¨ and $)
  9701. .replace(/&amp;/g, '')
  9702. .replace(/¨T/g, '')
  9703. .replace(/¨D/g, '')
  9704. // replace rest of the chars (&~$ are repeated as they might have been escaped)
  9705. // borrowed from github's redcarpet (some they should produce similar results)
  9706. .replace(/[&+$,\/:;=?@"#{}|^¨~\[\]`\\*)(%.!'<>]/g, '')
  9707. .toLowerCase();
  9708. } else if (options.rawHeaderId) {
  9709. title = title
  9710. .replace(/ /g, '-')
  9711. // replace previously escaped chars (&, ¨ and $)
  9712. .replace(/&amp;/g, '&')
  9713. .replace(/¨T/g, '¨')
  9714. .replace(/¨D/g, '$')
  9715. // replace " and '
  9716. .replace(/["']/g, '-')
  9717. .toLowerCase();
  9718. } else {
  9719. title = title
  9720. .replace(/[^\w]/g, '')
  9721. .toLowerCase();
  9722. }
  9723. if (options.rawPrefixHeaderId) {
  9724. title = prefix + title;
  9725. }
  9726. if (globals.hashLinkCounts[title]) {
  9727. title = title + '-' + (globals.hashLinkCounts[title]++);
  9728. } else {
  9729. globals.hashLinkCounts[title] = 1;
  9730. }
  9731. return title;
  9732. }
  9733. text = globals.converter._dispatch('headers.after', text, options, globals);
  9734. return text;
  9735. });
  9736. /**
  9737. * Turn Markdown link shortcuts into XHTML <a> tags.
  9738. */
  9739. showdown.subParser('horizontalRule', function (text, options, globals) {
  9740. 'use strict';
  9741. text = globals.converter._dispatch('horizontalRule.before', text, options, globals);
  9742. var key = showdown.subParser('hashBlock')('<hr />', options, globals);
  9743. text = text.replace(/^ {0,2}( ?-){3,}[ \t]*$/gm, key);
  9744. text = text.replace(/^ {0,2}( ?\*){3,}[ \t]*$/gm, key);
  9745. text = text.replace(/^ {0,2}( ?_){3,}[ \t]*$/gm, key);
  9746. text = globals.converter._dispatch('horizontalRule.after', text, options, globals);
  9747. return text;
  9748. });
  9749. /**
  9750. * Turn Markdown image shortcuts into <img> tags.
  9751. */
  9752. showdown.subParser('images', function (text, options, globals) {
  9753. 'use strict';
  9754. text = globals.converter._dispatch('images.before', text, options, globals);
  9755. var inlineRegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g,
  9756. crazyRegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<([^>]*)>(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(?:(["'])([^"]*?)\6))?[ \t]?\)/g,
  9757. base64RegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<?(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g,
  9758. referenceRegExp = /!\[([^\]]*?)] ?(?:\n *)?\[([\s\S]*?)]()()()()()/g,
  9759. refShortcutRegExp = /!\[([^\[\]]+)]()()()()()/g;
  9760. function writeImageTagBase64 (wholeMatch, altText, linkId, url, width, height, m5, title) {
  9761. url = url.replace(/\s/g, '');
  9762. return writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title);
  9763. }
  9764. function writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title) {
  9765. var gUrls = globals.gUrls,
  9766. gTitles = globals.gTitles,
  9767. gDims = globals.gDimensions;
  9768. linkId = linkId.toLowerCase();
  9769. if (!title) {
  9770. title = '';
  9771. }
  9772. // Special case for explicit empty url
  9773. if (wholeMatch.search(/\(<?\s*>? ?(['"].*['"])?\)$/m) > -1) {
  9774. url = '';
  9775. } else if (url === '' || url === null) {
  9776. if (linkId === '' || linkId === null) {
  9777. // lower-case and turn embedded newlines into spaces
  9778. linkId = altText.toLowerCase().replace(/ ?\n/g, ' ');
  9779. }
  9780. url = '#' + linkId;
  9781. if (!showdown.helper.isUndefined(gUrls[linkId])) {
  9782. url = gUrls[linkId];
  9783. if (!showdown.helper.isUndefined(gTitles[linkId])) {
  9784. title = gTitles[linkId];
  9785. }
  9786. if (!showdown.helper.isUndefined(gDims[linkId])) {
  9787. width = gDims[linkId].width;
  9788. height = gDims[linkId].height;
  9789. }
  9790. } else {
  9791. return wholeMatch;
  9792. }
  9793. }
  9794. altText = altText
  9795. .replace(/"/g, '&quot;')
  9796. //altText = showdown.helper.escapeCharacters(altText, '*_', false);
  9797. .replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  9798. //url = showdown.helper.escapeCharacters(url, '*_', false);
  9799. url = url.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  9800. var result = '<img src="' + url + '" alt="' + altText + '"';
  9801. if (title && showdown.helper.isString(title)) {
  9802. title = title
  9803. .replace(/"/g, '&quot;')
  9804. //title = showdown.helper.escapeCharacters(title, '*_', false);
  9805. .replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  9806. result += ' title="' + title + '"';
  9807. }
  9808. if (width && height) {
  9809. width = (width === '*') ? 'auto' : width;
  9810. height = (height === '*') ? 'auto' : height;
  9811. result += ' width="' + width + '"';
  9812. result += ' height="' + height + '"';
  9813. }
  9814. result += ' />';
  9815. return result;
  9816. }
  9817. // First, handle reference-style labeled images: ![alt text][id]
  9818. text = text.replace(referenceRegExp, writeImageTag);
  9819. // Next, handle inline images: ![alt text](url =<width>x<height> "optional title")
  9820. // base64 encoded images
  9821. text = text.replace(base64RegExp, writeImageTagBase64);
  9822. // cases with crazy urls like ./image/cat1).png
  9823. text = text.replace(crazyRegExp, writeImageTag);
  9824. // normal cases
  9825. text = text.replace(inlineRegExp, writeImageTag);
  9826. // handle reference-style shortcuts: ![img text]
  9827. text = text.replace(refShortcutRegExp, writeImageTag);
  9828. text = globals.converter._dispatch('images.after', text, options, globals);
  9829. return text;
  9830. });
  9831. showdown.subParser('italicsAndBold', function (text, options, globals) {
  9832. 'use strict';
  9833. text = globals.converter._dispatch('italicsAndBold.before', text, options, globals);
  9834. // it's faster to have 3 separate regexes for each case than have just one
  9835. // because of backtracing, in some cases, it could lead to an exponential effect
  9836. // called "catastrophic backtrace". Ominous!
  9837. function parseInside (txt, left, right) {
  9838. /*
  9839. if (options.simplifiedAutoLink) {
  9840. txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals);
  9841. }
  9842. */
  9843. return left + txt + right;
  9844. }
  9845. // Parse underscores
  9846. if (options.literalMidWordUnderscores) {
  9847. text = text.replace(/\b___(\S[\s\S]*?)___\b/g, function (wm, txt) {
  9848. return parseInside (txt, '<strong><em>', '</em></strong>');
  9849. });
  9850. text = text.replace(/\b__(\S[\s\S]*?)__\b/g, function (wm, txt) {
  9851. return parseInside (txt, '<strong>', '</strong>');
  9852. });
  9853. text = text.replace(/\b_(\S[\s\S]*?)_\b/g, function (wm, txt) {
  9854. return parseInside (txt, '<em>', '</em>');
  9855. });
  9856. } else {
  9857. text = text.replace(/___(\S[\s\S]*?)___/g, function (wm, m) {
  9858. return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm;
  9859. });
  9860. text = text.replace(/__(\S[\s\S]*?)__/g, function (wm, m) {
  9861. return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : wm;
  9862. });
  9863. text = text.replace(/_([^\s_][\s\S]*?)_/g, function (wm, m) {
  9864. // !/^_[^_]/.test(m) - test if it doesn't start with __ (since it seems redundant, we removed it)
  9865. return (/\S$/.test(m)) ? parseInside (m, '<em>', '</em>') : wm;
  9866. });
  9867. }
  9868. // Now parse asterisks
  9869. if (options.literalMidWordAsterisks) {
  9870. text = text.replace(/([^*]|^)\B\*\*\*(\S[\s\S]*?)\*\*\*\B(?!\*)/g, function (wm, lead, txt) {
  9871. return parseInside (txt, lead + '<strong><em>', '</em></strong>');
  9872. });
  9873. text = text.replace(/([^*]|^)\B\*\*(\S[\s\S]*?)\*\*\B(?!\*)/g, function (wm, lead, txt) {
  9874. return parseInside (txt, lead + '<strong>', '</strong>');
  9875. });
  9876. text = text.replace(/([^*]|^)\B\*(\S[\s\S]*?)\*\B(?!\*)/g, function (wm, lead, txt) {
  9877. return parseInside (txt, lead + '<em>', '</em>');
  9878. });
  9879. } else {
  9880. text = text.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function (wm, m) {
  9881. return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm;
  9882. });
  9883. text = text.replace(/\*\*(\S[\s\S]*?)\*\*/g, function (wm, m) {
  9884. return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : wm;
  9885. });
  9886. text = text.replace(/\*([^\s*][\s\S]*?)\*/g, function (wm, m) {
  9887. // !/^\*[^*]/.test(m) - test if it doesn't start with ** (since it seems redundant, we removed it)
  9888. return (/\S$/.test(m)) ? parseInside (m, '<em>', '</em>') : wm;
  9889. });
  9890. }
  9891. text = globals.converter._dispatch('italicsAndBold.after', text, options, globals);
  9892. return text;
  9893. });
  9894. /**
  9895. * Form HTML ordered (numbered) and unordered (bulleted) lists.
  9896. */
  9897. showdown.subParser('lists', function (text, options, globals) {
  9898. 'use strict';
  9899. /**
  9900. * Process the contents of a single ordered or unordered list, splitting it
  9901. * into individual list items.
  9902. * @param {string} listStr
  9903. * @param {boolean} trimTrailing
  9904. * @returns {string}
  9905. */
  9906. function processListItems (listStr, trimTrailing) {
  9907. // The $g_list_level global keeps track of when we're inside a list.
  9908. // Each time we enter a list, we increment it; when we leave a list,
  9909. // we decrement. If it's zero, we're not in a list anymore.
  9910. //
  9911. // We do this because when we're not inside a list, we want to treat
  9912. // something like this:
  9913. //
  9914. // I recommend upgrading to version
  9915. // 8. Oops, now this line is treated
  9916. // as a sub-list.
  9917. //
  9918. // As a single paragraph, despite the fact that the second line starts
  9919. // with a digit-period-space sequence.
  9920. //
  9921. // Whereas when we're inside a list (or sub-list), that line will be
  9922. // treated as the start of a sub-list. What a kludge, huh? This is
  9923. // an aspect of Markdown's syntax that's hard to parse perfectly
  9924. // without resorting to mind-reading. Perhaps the solution is to
  9925. // change the syntax rules such that sub-lists must start with a
  9926. // starting cardinal number; e.g. "1." or "a.".
  9927. globals.gListLevel++;
  9928. // trim trailing blank lines:
  9929. listStr = listStr.replace(/\n{2,}$/, '\n');
  9930. // attacklab: add sentinel to emulate \z
  9931. listStr += '¨0';
  9932. var rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0| {0,3}([*+-]|\d+[.])[ \t]+))/gm,
  9933. isParagraphed = (/\n[ \t]*\n(?!¨0)/.test(listStr));
  9934. // Since version 1.5, nesting sublists requires 4 spaces (or 1 tab) indentation,
  9935. // which is a syntax breaking change
  9936. // activating this option reverts to old behavior
  9937. if (options.disableForced4SpacesIndentedSublists) {
  9938. rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0|\2([*+-]|\d+[.])[ \t]+))/gm;
  9939. }
  9940. listStr = listStr.replace(rgx, function (wholeMatch, m1, m2, m3, m4, taskbtn, checked) {
  9941. checked = (checked && checked.trim() !== '');
  9942. var item = showdown.subParser('outdent')(m4, options, globals),
  9943. bulletStyle = '';
  9944. // Support for github tasklists
  9945. if (taskbtn && options.tasklists) {
  9946. bulletStyle = ' class="task-list-item" style="list-style-type: none;"';
  9947. item = item.replace(/^[ \t]*\[(x|X| )?]/m, function () {
  9948. var otp = '<input type="checkbox" disabled style="margin: 0px 0.35em 0.25em -1.6em; vertical-align: middle;"';
  9949. if (checked) {
  9950. otp += ' checked';
  9951. }
  9952. otp += '>';
  9953. return otp;
  9954. });
  9955. }
  9956. // ISSUE #312
  9957. // This input: - - - a
  9958. // causes trouble to the parser, since it interprets it as:
  9959. // <ul><li><li><li>a</li></li></li></ul>
  9960. // instead of:
  9961. // <ul><li>- - a</li></ul>
  9962. // So, to prevent it, we will put a marker (¨A)in the beginning of the line
  9963. // Kind of hackish/monkey patching, but seems more effective than overcomplicating the list parser
  9964. item = item.replace(/^([-*+]|\d\.)[ \t]+[\S\n ]*/g, function (wm2) {
  9965. return '¨A' + wm2;
  9966. });
  9967. // m1 - Leading line or
  9968. // Has a double return (multi paragraph) or
  9969. // Has sublist
  9970. if (m1 || (item.search(/\n{2,}/) > -1)) {
  9971. item = showdown.subParser('githubCodeBlocks')(item, options, globals);
  9972. item = showdown.subParser('blockGamut')(item, options, globals);
  9973. } else {
  9974. // Recursion for sub-lists:
  9975. item = showdown.subParser('lists')(item, options, globals);
  9976. item = item.replace(/\n$/, ''); // chomp(item)
  9977. item = showdown.subParser('hashHTMLBlocks')(item, options, globals);
  9978. // Colapse double linebreaks
  9979. item = item.replace(/\n\n+/g, '\n\n');
  9980. if (isParagraphed) {
  9981. item = showdown.subParser('paragraphs')(item, options, globals);
  9982. } else {
  9983. item = showdown.subParser('spanGamut')(item, options, globals);
  9984. }
  9985. }
  9986. // now we need to remove the marker (¨A)
  9987. item = item.replace('¨A', '');
  9988. // we can finally wrap the line in list item tags
  9989. item = '<li' + bulletStyle + '>' + item + '</li>\n';
  9990. return item;
  9991. });
  9992. // attacklab: strip sentinel
  9993. listStr = listStr.replace(/¨0/g, '');
  9994. globals.gListLevel--;
  9995. if (trimTrailing) {
  9996. listStr = listStr.replace(/\s+$/, '');
  9997. }
  9998. return listStr;
  9999. }
  10000. function styleStartNumber (list, listType) {
  10001. // check if ol and starts by a number different than 1
  10002. if (listType === 'ol') {
  10003. var res = list.match(/^ *(\d+)\./);
  10004. if (res && res[1] !== '1') {
  10005. return ' start="' + res[1] + '"';
  10006. }
  10007. }
  10008. return '';
  10009. }
  10010. /**
  10011. * Check and parse consecutive lists (better fix for issue #142)
  10012. * @param {string} list
  10013. * @param {string} listType
  10014. * @param {boolean} trimTrailing
  10015. * @returns {string}
  10016. */
  10017. function parseConsecutiveLists (list, listType, trimTrailing) {
  10018. // check if we caught 2 or more consecutive lists by mistake
  10019. // we use the counterRgx, meaning if listType is UL we look for OL and vice versa
  10020. var olRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?\d+\.[ \t]/gm : /^ {0,3}\d+\.[ \t]/gm,
  10021. ulRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?[*+-][ \t]/gm : /^ {0,3}[*+-][ \t]/gm,
  10022. counterRxg = (listType === 'ul') ? olRgx : ulRgx,
  10023. result = '';
  10024. if (list.search(counterRxg) !== -1) {
  10025. (function parseCL (txt) {
  10026. var pos = txt.search(counterRxg),
  10027. style = styleStartNumber(list, listType);
  10028. if (pos !== -1) {
  10029. // slice
  10030. result += '\n\n<' + listType + style + '>\n' + processListItems(txt.slice(0, pos), !!trimTrailing) + '</' + listType + '>\n';
  10031. // invert counterType and listType
  10032. listType = (listType === 'ul') ? 'ol' : 'ul';
  10033. counterRxg = (listType === 'ul') ? olRgx : ulRgx;
  10034. //recurse
  10035. parseCL(txt.slice(pos));
  10036. } else {
  10037. result += '\n\n<' + listType + style + '>\n' + processListItems(txt, !!trimTrailing) + '</' + listType + '>\n';
  10038. }
  10039. })(list);
  10040. } else {
  10041. var style = styleStartNumber(list, listType);
  10042. result = '\n\n<' + listType + style + '>\n' + processListItems(list, !!trimTrailing) + '</' + listType + '>\n';
  10043. }
  10044. return result;
  10045. }
  10046. /** Start of list parsing **/
  10047. text = globals.converter._dispatch('lists.before', text, options, globals);
  10048. // add sentinel to hack around khtml/safari bug:
  10049. // http://bugs.webkit.org/show_bug.cgi?id=11231
  10050. text += '¨0';
  10051. if (globals.gListLevel) {
  10052. text = text.replace(/^(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm,
  10053. function (wholeMatch, list, m2) {
  10054. var listType = (m2.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
  10055. return parseConsecutiveLists(list, listType, true);
  10056. }
  10057. );
  10058. } else {
  10059. text = text.replace(/(\n\n|^\n?)(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm,
  10060. function (wholeMatch, m1, list, m3) {
  10061. var listType = (m3.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
  10062. return parseConsecutiveLists(list, listType, false);
  10063. }
  10064. );
  10065. }
  10066. // strip sentinel
  10067. text = text.replace(/¨0/, '');
  10068. text = globals.converter._dispatch('lists.after', text, options, globals);
  10069. return text;
  10070. });
  10071. /**
  10072. * Parse metadata at the top of the document
  10073. */
  10074. showdown.subParser('metadata', function (text, options, globals) {
  10075. 'use strict';
  10076. if (!options.metadata) {
  10077. return text;
  10078. }
  10079. text = globals.converter._dispatch('metadata.before', text, options, globals);
  10080. function parseMetadataContents (content) {
  10081. // raw is raw so it's not changed in any way
  10082. globals.metadata.raw = content;
  10083. // escape chars forbidden in html attributes
  10084. // double quotes
  10085. content = content
  10086. // ampersand first
  10087. .replace(/&/g, '&amp;')
  10088. // double quotes
  10089. .replace(/"/g, '&quot;');
  10090. content = content.replace(/\n {4}/g, ' ');
  10091. content.replace(/^([\S ]+): +([\s\S]+?)$/gm, function (wm, key, value) {
  10092. globals.metadata.parsed[key] = value;
  10093. return '';
  10094. });
  10095. }
  10096. text = text.replace(/^\s*«««+(\S*?)\n([\s\S]+?)\n»»»+\n/, function (wholematch, format, content) {
  10097. parseMetadataContents(content);
  10098. return '¨M';
  10099. });
  10100. text = text.replace(/^\s*---+(\S*?)\n([\s\S]+?)\n---+\n/, function (wholematch, format, content) {
  10101. if (format) {
  10102. globals.metadata.format = format;
  10103. }
  10104. parseMetadataContents(content);
  10105. return '¨M';
  10106. });
  10107. text = text.replace(/¨M/g, '');
  10108. text = globals.converter._dispatch('metadata.after', text, options, globals);
  10109. return text;
  10110. });
  10111. /**
  10112. * Remove one level of line-leading tabs or spaces
  10113. */
  10114. showdown.subParser('outdent', function (text, options, globals) {
  10115. 'use strict';
  10116. text = globals.converter._dispatch('outdent.before', text, options, globals);
  10117. // attacklab: hack around Konqueror 3.5.4 bug:
  10118. // "----------bug".replace(/^-/g,"") == "bug"
  10119. text = text.replace(/^(\t|[ ]{1,4})/gm, '¨0'); // attacklab: g_tab_width
  10120. // attacklab: clean up hack
  10121. text = text.replace(/¨0/g, '');
  10122. text = globals.converter._dispatch('outdent.after', text, options, globals);
  10123. return text;
  10124. });
  10125. /**
  10126. *
  10127. */
  10128. showdown.subParser('paragraphs', function (text, options, globals) {
  10129. 'use strict';
  10130. text = globals.converter._dispatch('paragraphs.before', text, options, globals);
  10131. // Strip leading and trailing lines:
  10132. text = text.replace(/^\n+/g, '');
  10133. text = text.replace(/\n+$/g, '');
  10134. var grafs = text.split(/\n{2,}/g),
  10135. grafsOut = [],
  10136. end = grafs.length; // Wrap <p> tags
  10137. for (var i = 0; i < end; i++) {
  10138. var str = grafs[i];
  10139. // if this is an HTML marker, copy it
  10140. if (str.search(/¨(K|G)(\d+)\1/g) >= 0) {
  10141. grafsOut.push(str);
  10142. // test for presence of characters to prevent empty lines being parsed
  10143. // as paragraphs (resulting in undesired extra empty paragraphs)
  10144. } else if (str.search(/\S/) >= 0) {
  10145. str = showdown.subParser('spanGamut')(str, options, globals);
  10146. str = str.replace(/^([ \t]*)/g, '<p>');
  10147. str += '</p>';
  10148. grafsOut.push(str);
  10149. }
  10150. }
  10151. /** Unhashify HTML blocks */
  10152. end = grafsOut.length;
  10153. for (i = 0; i < end; i++) {
  10154. var blockText = '',
  10155. grafsOutIt = grafsOut[i],
  10156. codeFlag = false;
  10157. // if this is a marker for an html block...
  10158. // use RegExp.test instead of string.search because of QML bug
  10159. while (/¨(K|G)(\d+)\1/.test(grafsOutIt)) {
  10160. var delim = RegExp.$1,
  10161. num = RegExp.$2;
  10162. if (delim === 'K') {
  10163. blockText = globals.gHtmlBlocks[num];
  10164. } else {
  10165. // we need to check if ghBlock is a false positive
  10166. if (codeFlag) {
  10167. // use encoded version of all text
  10168. blockText = showdown.subParser('encodeCode')(globals.ghCodeBlocks[num].text, options, globals);
  10169. } else {
  10170. blockText = globals.ghCodeBlocks[num].codeblock;
  10171. }
  10172. }
  10173. blockText = blockText.replace(/\$/g, '$$$$'); // Escape any dollar signs
  10174. grafsOutIt = grafsOutIt.replace(/(\n\n)?¨(K|G)\d+\2(\n\n)?/, blockText);
  10175. // Check if grafsOutIt is a pre->code
  10176. if (/^<pre\b[^>]*>\s*<code\b[^>]*>/.test(grafsOutIt)) {
  10177. codeFlag = true;
  10178. }
  10179. }
  10180. grafsOut[i] = grafsOutIt;
  10181. }
  10182. text = grafsOut.join('\n');
  10183. // Strip leading and trailing lines:
  10184. text = text.replace(/^\n+/g, '');
  10185. text = text.replace(/\n+$/g, '');
  10186. return globals.converter._dispatch('paragraphs.after', text, options, globals);
  10187. });
  10188. /**
  10189. * Run extension
  10190. */
  10191. showdown.subParser('runExtension', function (ext, text, options, globals) {
  10192. 'use strict';
  10193. if (ext.filter) {
  10194. text = ext.filter(text, globals.converter, options);
  10195. } else if (ext.regex) {
  10196. // TODO remove this when old extension loading mechanism is deprecated
  10197. var re = ext.regex;
  10198. if (!(re instanceof RegExp)) {
  10199. re = new RegExp(re, 'g');
  10200. }
  10201. text = text.replace(re, ext.replace);
  10202. }
  10203. return text;
  10204. });
  10205. /**
  10206. * These are all the transformations that occur *within* block-level
  10207. * tags like paragraphs, headers, and list items.
  10208. */
  10209. showdown.subParser('spanGamut', function (text, options, globals) {
  10210. 'use strict';
  10211. text = globals.converter._dispatch('spanGamut.before', text, options, globals);
  10212. text = showdown.subParser('codeSpans')(text, options, globals);
  10213. text = showdown.subParser('escapeSpecialCharsWithinTagAttributes')(text, options, globals);
  10214. text = showdown.subParser('encodeBackslashEscapes')(text, options, globals);
  10215. // Process anchor and image tags. Images must come first,
  10216. // because ![foo][f] looks like an anchor.
  10217. text = showdown.subParser('images')(text, options, globals);
  10218. text = showdown.subParser('anchors')(text, options, globals);
  10219. // Make links out of things like `<http://example.com/>`
  10220. // Must come after anchors, because you can use < and >
  10221. // delimiters in inline links like [this](<url>).
  10222. text = showdown.subParser('autoLinks')(text, options, globals);
  10223. text = showdown.subParser('simplifiedAutoLinks')(text, options, globals);
  10224. text = showdown.subParser('emoji')(text, options, globals);
  10225. text = showdown.subParser('underline')(text, options, globals);
  10226. text = showdown.subParser('italicsAndBold')(text, options, globals);
  10227. text = showdown.subParser('strikethrough')(text, options, globals);
  10228. text = showdown.subParser('ellipsis')(text, options, globals);
  10229. // we need to hash HTML tags inside spans
  10230. text = showdown.subParser('hashHTMLSpans')(text, options, globals);
  10231. // now we encode amps and angles
  10232. text = showdown.subParser('encodeAmpsAndAngles')(text, options, globals);
  10233. // Do hard breaks
  10234. if (options.simpleLineBreaks) {
  10235. // GFM style hard breaks
  10236. // only add line breaks if the text does not contain a block (special case for lists)
  10237. if (!/\n\n¨K/.test(text)) {
  10238. text = text.replace(/\n+/g, '<br />\n');
  10239. }
  10240. } else {
  10241. // Vanilla hard breaks
  10242. text = text.replace(/ +\n/g, '<br />\n');
  10243. }
  10244. text = globals.converter._dispatch('spanGamut.after', text, options, globals);
  10245. return text;
  10246. });
  10247. showdown.subParser('strikethrough', function (text, options, globals) {
  10248. 'use strict';
  10249. function parseInside (txt) {
  10250. if (options.simplifiedAutoLink) {
  10251. txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals);
  10252. }
  10253. return '<del>' + txt + '</del>';
  10254. }
  10255. if (options.strikethrough) {
  10256. text = globals.converter._dispatch('strikethrough.before', text, options, globals);
  10257. text = text.replace(/(?:~){2}([\s\S]+?)(?:~){2}/g, function (wm, txt) { return parseInside(txt); });
  10258. text = globals.converter._dispatch('strikethrough.after', text, options, globals);
  10259. }
  10260. return text;
  10261. });
  10262. /**
  10263. * Strips link definitions from text, stores the URLs and titles in
  10264. * hash references.
  10265. * Link defs are in the form: ^[id]: url "optional title"
  10266. */
  10267. showdown.subParser('stripLinkDefinitions', function (text, options, globals) {
  10268. 'use strict';
  10269. var regex = /^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*<?([^>\s]+)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=¨0))/gm,
  10270. base64Regex = /^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*<?(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n\n|(?=¨0)|(?=\n\[))/gm;
  10271. // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
  10272. text += '¨0';
  10273. var replaceFunc = function (wholeMatch, linkId, url, width, height, blankLines, title) {
  10274. linkId = linkId.toLowerCase();
  10275. if (url.match(/^data:.+?\/.+?;base64,/)) {
  10276. // remove newlines
  10277. globals.gUrls[linkId] = url.replace(/\s/g, '');
  10278. } else {
  10279. globals.gUrls[linkId] = showdown.subParser('encodeAmpsAndAngles')(url, options, globals); // Link IDs are case-insensitive
  10280. }
  10281. if (blankLines) {
  10282. // Oops, found blank lines, so it's not a title.
  10283. // Put back the parenthetical statement we stole.
  10284. return blankLines + title;
  10285. } else {
  10286. if (title) {
  10287. globals.gTitles[linkId] = title.replace(/"|'/g, '&quot;');
  10288. }
  10289. if (options.parseImgDimensions && width && height) {
  10290. globals.gDimensions[linkId] = {
  10291. width: width,
  10292. height: height
  10293. };
  10294. }
  10295. }
  10296. // Completely remove the definition from the text
  10297. return '';
  10298. };
  10299. // first we try to find base64 link references
  10300. text = text.replace(base64Regex, replaceFunc);
  10301. text = text.replace(regex, replaceFunc);
  10302. // attacklab: strip sentinel
  10303. text = text.replace(/¨0/, '');
  10304. return text;
  10305. });
  10306. showdown.subParser('tables', function (text, options, globals) {
  10307. 'use strict';
  10308. if (!options.tables) {
  10309. return text;
  10310. }
  10311. var tableRgx = /^ {0,3}\|?.+\|.+\n {0,3}\|?[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:[-=]){2,}[\s\S]+?(?:\n\n|¨0)/gm,
  10312. //singeColTblRgx = /^ {0,3}\|.+\|\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n(?: {0,3}\|.+\|\n)+(?:\n\n|¨0)/gm;
  10313. singeColTblRgx = /^ {0,3}\|.+\|[ \t]*\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n( {0,3}\|.+\|[ \t]*\n)*(?:\n|¨0)/gm;
  10314. function parseStyles (sLine) {
  10315. if (/^:[ \t]*--*$/.test(sLine)) {
  10316. return ' style="text-align:left;"';
  10317. } else if (/^--*[ \t]*:[ \t]*$/.test(sLine)) {
  10318. return ' style="text-align:right;"';
  10319. } else if (/^:[ \t]*--*[ \t]*:$/.test(sLine)) {
  10320. return ' style="text-align:center;"';
  10321. } else {
  10322. return '';
  10323. }
  10324. }
  10325. function parseHeaders (header, style) {
  10326. var id = '';
  10327. header = header.trim();
  10328. // support both tablesHeaderId and tableHeaderId due to error in documentation so we don't break backwards compatibility
  10329. if (options.tablesHeaderId || options.tableHeaderId) {
  10330. id = ' id="' + header.replace(/ /g, '_').toLowerCase() + '"';
  10331. }
  10332. header = showdown.subParser('spanGamut')(header, options, globals);
  10333. return '<th' + id + style + '>' + header + '</th>\n';
  10334. }
  10335. function parseCells (cell, style) {
  10336. var subText = showdown.subParser('spanGamut')(cell, options, globals);
  10337. return '<td' + style + '>' + subText + '</td>\n';
  10338. }
  10339. function buildTable (headers, cells) {
  10340. var tb = '<table>\n<thead>\n<tr>\n',
  10341. tblLgn = headers.length;
  10342. for (var i = 0; i < tblLgn; ++i) {
  10343. tb += headers[i];
  10344. }
  10345. tb += '</tr>\n</thead>\n<tbody>\n';
  10346. for (i = 0; i < cells.length; ++i) {
  10347. tb += '<tr>\n';
  10348. for (var ii = 0; ii < tblLgn; ++ii) {
  10349. tb += cells[i][ii];
  10350. }
  10351. tb += '</tr>\n';
  10352. }
  10353. tb += '</tbody>\n</table>\n';
  10354. return tb;
  10355. }
  10356. function parseTable (rawTable) {
  10357. var i, tableLines = rawTable.split('\n');
  10358. for (i = 0; i < tableLines.length; ++i) {
  10359. // strip wrong first and last column if wrapped tables are used
  10360. if (/^ {0,3}\|/.test(tableLines[i])) {
  10361. tableLines[i] = tableLines[i].replace(/^ {0,3}\|/, '');
  10362. }
  10363. if (/\|[ \t]*$/.test(tableLines[i])) {
  10364. tableLines[i] = tableLines[i].replace(/\|[ \t]*$/, '');
  10365. }
  10366. // parse code spans first, but we only support one line code spans
  10367. tableLines[i] = showdown.subParser('codeSpans')(tableLines[i], options, globals);
  10368. }
  10369. var rawHeaders = tableLines[0].split('|').map(function (s) { return s.trim();}),
  10370. rawStyles = tableLines[1].split('|').map(function (s) { return s.trim();}),
  10371. rawCells = [],
  10372. headers = [],
  10373. styles = [],
  10374. cells = [];
  10375. tableLines.shift();
  10376. tableLines.shift();
  10377. for (i = 0; i < tableLines.length; ++i) {
  10378. if (tableLines[i].trim() === '') {
  10379. continue;
  10380. }
  10381. rawCells.push(
  10382. tableLines[i]
  10383. .split('|')
  10384. .map(function (s) {
  10385. return s.trim();
  10386. })
  10387. );
  10388. }
  10389. if (rawHeaders.length < rawStyles.length) {
  10390. return rawTable;
  10391. }
  10392. for (i = 0; i < rawStyles.length; ++i) {
  10393. styles.push(parseStyles(rawStyles[i]));
  10394. }
  10395. for (i = 0; i < rawHeaders.length; ++i) {
  10396. if (showdown.helper.isUndefined(styles[i])) {
  10397. styles[i] = '';
  10398. }
  10399. headers.push(parseHeaders(rawHeaders[i], styles[i]));
  10400. }
  10401. for (i = 0; i < rawCells.length; ++i) {
  10402. var row = [];
  10403. for (var ii = 0; ii < headers.length; ++ii) {
  10404. if (showdown.helper.isUndefined(rawCells[i][ii])) {
  10405. }
  10406. row.push(parseCells(rawCells[i][ii], styles[ii]));
  10407. }
  10408. cells.push(row);
  10409. }
  10410. return buildTable(headers, cells);
  10411. }
  10412. text = globals.converter._dispatch('tables.before', text, options, globals);
  10413. // find escaped pipe characters
  10414. text = text.replace(/\\(\|)/g, showdown.helper.escapeCharactersCallback);
  10415. // parse multi column tables
  10416. text = text.replace(tableRgx, parseTable);
  10417. // parse one column tables
  10418. text = text.replace(singeColTblRgx, parseTable);
  10419. text = globals.converter._dispatch('tables.after', text, options, globals);
  10420. return text;
  10421. });
  10422. showdown.subParser('underline', function (text, options, globals) {
  10423. 'use strict';
  10424. if (!options.underline) {
  10425. return text;
  10426. }
  10427. text = globals.converter._dispatch('underline.before', text, options, globals);
  10428. if (options.literalMidWordUnderscores) {
  10429. text = text.replace(/\b___(\S[\s\S]*?)___\b/g, function (wm, txt) {
  10430. return '<u>' + txt + '</u>';
  10431. });
  10432. text = text.replace(/\b__(\S[\s\S]*?)__\b/g, function (wm, txt) {
  10433. return '<u>' + txt + '</u>';
  10434. });
  10435. } else {
  10436. text = text.replace(/___(\S[\s\S]*?)___/g, function (wm, m) {
  10437. return (/\S$/.test(m)) ? '<u>' + m + '</u>' : wm;
  10438. });
  10439. text = text.replace(/__(\S[\s\S]*?)__/g, function (wm, m) {
  10440. return (/\S$/.test(m)) ? '<u>' + m + '</u>' : wm;
  10441. });
  10442. }
  10443. // escape remaining underscores to prevent them being parsed by italic and bold
  10444. text = text.replace(/(_)/g, showdown.helper.escapeCharactersCallback);
  10445. text = globals.converter._dispatch('underline.after', text, options, globals);
  10446. return text;
  10447. });
  10448. /**
  10449. * Swap back in all the special characters we've hidden.
  10450. */
  10451. showdown.subParser('unescapeSpecialChars', function (text, options, globals) {
  10452. 'use strict';
  10453. text = globals.converter._dispatch('unescapeSpecialChars.before', text, options, globals);
  10454. text = text.replace(/¨E(\d+)E/g, function (wholeMatch, m1) {
  10455. var charCodeToReplace = parseInt(m1);
  10456. return String.fromCharCode(charCodeToReplace);
  10457. });
  10458. text = globals.converter._dispatch('unescapeSpecialChars.after', text, options, globals);
  10459. return text;
  10460. });
  10461. showdown.subParser('makeMarkdown.blockquote', function (node, globals) {
  10462. 'use strict';
  10463. var txt = '';
  10464. if (node.hasChildNodes()) {
  10465. var children = node.childNodes,
  10466. childrenLength = children.length;
  10467. for (var i = 0; i < childrenLength; ++i) {
  10468. var innerTxt = showdown.subParser('makeMarkdown.node')(children[i], globals);
  10469. if (innerTxt === '') {
  10470. continue;
  10471. }
  10472. txt += innerTxt;
  10473. }
  10474. }
  10475. // cleanup
  10476. txt = txt.trim();
  10477. txt = '> ' + txt.split('\n').join('\n> ');
  10478. return txt;
  10479. });
  10480. showdown.subParser('makeMarkdown.codeBlock', function (node, globals) {
  10481. 'use strict';
  10482. var lang = node.getAttribute('language'),
  10483. num = node.getAttribute('precodenum');
  10484. return '```' + lang + '\n' + globals.preList[num] + '\n```';
  10485. });
  10486. showdown.subParser('makeMarkdown.codeSpan', function (node) {
  10487. 'use strict';
  10488. return '`' + node.innerHTML + '`';
  10489. });
  10490. showdown.subParser('makeMarkdown.emphasis', function (node, globals) {
  10491. 'use strict';
  10492. var txt = '';
  10493. if (node.hasChildNodes()) {
  10494. txt += '*';
  10495. var children = node.childNodes,
  10496. childrenLength = children.length;
  10497. for (var i = 0; i < childrenLength; ++i) {
  10498. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  10499. }
  10500. txt += '*';
  10501. }
  10502. return txt;
  10503. });
  10504. showdown.subParser('makeMarkdown.header', function (node, globals, headerLevel) {
  10505. 'use strict';
  10506. var headerMark = new Array(headerLevel + 1).join('#'),
  10507. txt = '';
  10508. if (node.hasChildNodes()) {
  10509. txt = headerMark + ' ';
  10510. var children = node.childNodes,
  10511. childrenLength = children.length;
  10512. for (var i = 0; i < childrenLength; ++i) {
  10513. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  10514. }
  10515. }
  10516. return txt;
  10517. });
  10518. showdown.subParser('makeMarkdown.hr', function () {
  10519. 'use strict';
  10520. return '---';
  10521. });
  10522. showdown.subParser('makeMarkdown.image', function (node) {
  10523. 'use strict';
  10524. var txt = '';
  10525. if (node.hasAttribute('src')) {
  10526. txt += '![' + node.getAttribute('alt') + '](';
  10527. txt += '<' + node.getAttribute('src') + '>';
  10528. if (node.hasAttribute('width') && node.hasAttribute('height')) {
  10529. txt += ' =' + node.getAttribute('width') + 'x' + node.getAttribute('height');
  10530. }
  10531. if (node.hasAttribute('title')) {
  10532. txt += ' "' + node.getAttribute('title') + '"';
  10533. }
  10534. txt += ')';
  10535. }
  10536. return txt;
  10537. });
  10538. showdown.subParser('makeMarkdown.links', function (node, globals) {
  10539. 'use strict';
  10540. var txt = '';
  10541. if (node.hasChildNodes() && node.hasAttribute('href')) {
  10542. var children = node.childNodes,
  10543. childrenLength = children.length;
  10544. txt = '[';
  10545. for (var i = 0; i < childrenLength; ++i) {
  10546. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  10547. }
  10548. txt += '](';
  10549. txt += '<' + node.getAttribute('href') + '>';
  10550. if (node.hasAttribute('title')) {
  10551. txt += ' "' + node.getAttribute('title') + '"';
  10552. }
  10553. txt += ')';
  10554. }
  10555. return txt;
  10556. });
  10557. showdown.subParser('makeMarkdown.list', function (node, globals, type) {
  10558. 'use strict';
  10559. var txt = '';
  10560. if (!node.hasChildNodes()) {
  10561. return '';
  10562. }
  10563. var listItems = node.childNodes,
  10564. listItemsLenght = listItems.length,
  10565. listNum = node.getAttribute('start') || 1;
  10566. for (var i = 0; i < listItemsLenght; ++i) {
  10567. if (typeof listItems[i].tagName === 'undefined' || listItems[i].tagName.toLowerCase() !== 'li') {
  10568. continue;
  10569. }
  10570. // define the bullet to use in list
  10571. var bullet = '';
  10572. if (type === 'ol') {
  10573. bullet = listNum.toString() + '. ';
  10574. } else {
  10575. bullet = '- ';
  10576. }
  10577. // parse list item
  10578. txt += bullet + showdown.subParser('makeMarkdown.listItem')(listItems[i], globals);
  10579. ++listNum;
  10580. }
  10581. // add comment at the end to prevent consecutive lists to be parsed as one
  10582. txt += '\n<!-- -->\n';
  10583. return txt.trim();
  10584. });
  10585. showdown.subParser('makeMarkdown.listItem', function (node, globals) {
  10586. 'use strict';
  10587. var listItemTxt = '';
  10588. var children = node.childNodes,
  10589. childrenLenght = children.length;
  10590. for (var i = 0; i < childrenLenght; ++i) {
  10591. listItemTxt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  10592. }
  10593. // if it's only one liner, we need to add a newline at the end
  10594. if (!/\n$/.test(listItemTxt)) {
  10595. listItemTxt += '\n';
  10596. } else {
  10597. // it's multiparagraph, so we need to indent
  10598. listItemTxt = listItemTxt
  10599. .split('\n')
  10600. .join('\n ')
  10601. .replace(/^ {4}$/gm, '')
  10602. .replace(/\n\n+/g, '\n\n');
  10603. }
  10604. return listItemTxt;
  10605. });
  10606. showdown.subParser('makeMarkdown.node', function (node, globals, spansOnly) {
  10607. 'use strict';
  10608. spansOnly = spansOnly || false;
  10609. var txt = '';
  10610. // edge case of text without wrapper paragraph
  10611. if (node.nodeType === 3) {
  10612. return showdown.subParser('makeMarkdown.txt')(node, globals);
  10613. }
  10614. // HTML comment
  10615. if (node.nodeType === 8) {
  10616. return '<!--' + node.data + '-->\n\n';
  10617. }
  10618. // process only node elements
  10619. if (node.nodeType !== 1) {
  10620. return '';
  10621. }
  10622. var tagName = node.tagName.toLowerCase();
  10623. switch (tagName) {
  10624. //
  10625. // BLOCKS
  10626. //
  10627. case 'h1':
  10628. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 1) + '\n\n'; }
  10629. break;
  10630. case 'h2':
  10631. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 2) + '\n\n'; }
  10632. break;
  10633. case 'h3':
  10634. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 3) + '\n\n'; }
  10635. break;
  10636. case 'h4':
  10637. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 4) + '\n\n'; }
  10638. break;
  10639. case 'h5':
  10640. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 5) + '\n\n'; }
  10641. break;
  10642. case 'h6':
  10643. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 6) + '\n\n'; }
  10644. break;
  10645. case 'p':
  10646. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.paragraph')(node, globals) + '\n\n'; }
  10647. break;
  10648. case 'blockquote':
  10649. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.blockquote')(node, globals) + '\n\n'; }
  10650. break;
  10651. case 'hr':
  10652. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.hr')(node, globals) + '\n\n'; }
  10653. break;
  10654. case 'ol':
  10655. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.list')(node, globals, 'ol') + '\n\n'; }
  10656. break;
  10657. case 'ul':
  10658. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.list')(node, globals, 'ul') + '\n\n'; }
  10659. break;
  10660. case 'precode':
  10661. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.codeBlock')(node, globals) + '\n\n'; }
  10662. break;
  10663. case 'pre':
  10664. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.pre')(node, globals) + '\n\n'; }
  10665. break;
  10666. case 'table':
  10667. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.table')(node, globals) + '\n\n'; }
  10668. break;
  10669. //
  10670. // SPANS
  10671. //
  10672. case 'code':
  10673. txt = showdown.subParser('makeMarkdown.codeSpan')(node, globals);
  10674. break;
  10675. case 'em':
  10676. case 'i':
  10677. txt = showdown.subParser('makeMarkdown.emphasis')(node, globals);
  10678. break;
  10679. case 'strong':
  10680. case 'b':
  10681. txt = showdown.subParser('makeMarkdown.strong')(node, globals);
  10682. break;
  10683. case 'del':
  10684. txt = showdown.subParser('makeMarkdown.strikethrough')(node, globals);
  10685. break;
  10686. case 'a':
  10687. txt = showdown.subParser('makeMarkdown.links')(node, globals);
  10688. break;
  10689. case 'img':
  10690. txt = showdown.subParser('makeMarkdown.image')(node, globals);
  10691. break;
  10692. default:
  10693. txt = node.outerHTML + '\n\n';
  10694. }
  10695. // common normalization
  10696. // TODO eventually
  10697. return txt;
  10698. });
  10699. showdown.subParser('makeMarkdown.paragraph', function (node, globals) {
  10700. 'use strict';
  10701. var txt = '';
  10702. if (node.hasChildNodes()) {
  10703. var children = node.childNodes,
  10704. childrenLength = children.length;
  10705. for (var i = 0; i < childrenLength; ++i) {
  10706. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  10707. }
  10708. }
  10709. // some text normalization
  10710. txt = txt.trim();
  10711. return txt;
  10712. });
  10713. showdown.subParser('makeMarkdown.pre', function (node, globals) {
  10714. 'use strict';
  10715. var num = node.getAttribute('prenum');
  10716. return '<pre>' + globals.preList[num] + '</pre>';
  10717. });
  10718. showdown.subParser('makeMarkdown.strikethrough', function (node, globals) {
  10719. 'use strict';
  10720. var txt = '';
  10721. if (node.hasChildNodes()) {
  10722. txt += '~~';
  10723. var children = node.childNodes,
  10724. childrenLength = children.length;
  10725. for (var i = 0; i < childrenLength; ++i) {
  10726. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  10727. }
  10728. txt += '~~';
  10729. }
  10730. return txt;
  10731. });
  10732. showdown.subParser('makeMarkdown.strong', function (node, globals) {
  10733. 'use strict';
  10734. var txt = '';
  10735. if (node.hasChildNodes()) {
  10736. txt += '**';
  10737. var children = node.childNodes,
  10738. childrenLength = children.length;
  10739. for (var i = 0; i < childrenLength; ++i) {
  10740. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  10741. }
  10742. txt += '**';
  10743. }
  10744. return txt;
  10745. });
  10746. showdown.subParser('makeMarkdown.table', function (node, globals) {
  10747. 'use strict';
  10748. var txt = '',
  10749. tableArray = [[], []],
  10750. headings = node.querySelectorAll('thead>tr>th'),
  10751. rows = node.querySelectorAll('tbody>tr'),
  10752. i, ii;
  10753. for (i = 0; i < headings.length; ++i) {
  10754. var headContent = showdown.subParser('makeMarkdown.tableCell')(headings[i], globals),
  10755. allign = '---';
  10756. if (headings[i].hasAttribute('style')) {
  10757. var style = headings[i].getAttribute('style').toLowerCase().replace(/\s/g, '');
  10758. switch (style) {
  10759. case 'text-align:left;':
  10760. allign = ':---';
  10761. break;
  10762. case 'text-align:right;':
  10763. allign = '---:';
  10764. break;
  10765. case 'text-align:center;':
  10766. allign = ':---:';
  10767. break;
  10768. }
  10769. }
  10770. tableArray[0][i] = headContent.trim();
  10771. tableArray[1][i] = allign;
  10772. }
  10773. for (i = 0; i < rows.length; ++i) {
  10774. var r = tableArray.push([]) - 1,
  10775. cols = rows[i].getElementsByTagName('td');
  10776. for (ii = 0; ii < headings.length; ++ii) {
  10777. var cellContent = ' ';
  10778. if (typeof cols[ii] !== 'undefined') {
  10779. cellContent = showdown.subParser('makeMarkdown.tableCell')(cols[ii], globals);
  10780. }
  10781. tableArray[r].push(cellContent);
  10782. }
  10783. }
  10784. var cellSpacesCount = 3;
  10785. for (i = 0; i < tableArray.length; ++i) {
  10786. for (ii = 0; ii < tableArray[i].length; ++ii) {
  10787. var strLen = tableArray[i][ii].length;
  10788. if (strLen > cellSpacesCount) {
  10789. cellSpacesCount = strLen;
  10790. }
  10791. }
  10792. }
  10793. for (i = 0; i < tableArray.length; ++i) {
  10794. for (ii = 0; ii < tableArray[i].length; ++ii) {
  10795. if (i === 1) {
  10796. if (tableArray[i][ii].slice(-1) === ':') {
  10797. tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii].slice(-1), cellSpacesCount - 1, '-') + ':';
  10798. } else {
  10799. tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii], cellSpacesCount, '-');
  10800. }
  10801. } else {
  10802. tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii], cellSpacesCount);
  10803. }
  10804. }
  10805. txt += '| ' + tableArray[i].join(' | ') + ' |\n';
  10806. }
  10807. return txt.trim();
  10808. });
  10809. showdown.subParser('makeMarkdown.tableCell', function (node, globals) {
  10810. 'use strict';
  10811. var txt = '';
  10812. if (!node.hasChildNodes()) {
  10813. return '';
  10814. }
  10815. var children = node.childNodes,
  10816. childrenLength = children.length;
  10817. for (var i = 0; i < childrenLength; ++i) {
  10818. txt += showdown.subParser('makeMarkdown.node')(children[i], globals, true);
  10819. }
  10820. return txt.trim();
  10821. });
  10822. showdown.subParser('makeMarkdown.txt', function (node) {
  10823. 'use strict';
  10824. var txt = node.nodeValue;
  10825. // multiple spaces are collapsed
  10826. txt = txt.replace(/ +/g, ' ');
  10827. // replace the custom ¨NBSP; with a space
  10828. txt = txt.replace(/¨NBSP;/g, ' ');
  10829. // ", <, > and & should replace escaped html entities
  10830. txt = showdown.helper.unescapeHTMLEntities(txt);
  10831. // escape markdown magic characters
  10832. // emphasis, strong and strikethrough - can appear everywhere
  10833. // we also escape pipe (|) because of tables
  10834. // and escape ` because of code blocks and spans
  10835. txt = txt.replace(/([*_~|`])/g, '\\$1');
  10836. // escape > because of blockquotes
  10837. txt = txt.replace(/^(\s*)>/g, '\\$1>');
  10838. // hash character, only troublesome at the beginning of a line because of headers
  10839. txt = txt.replace(/^#/gm, '\\#');
  10840. // horizontal rules
  10841. txt = txt.replace(/^(\s*)([-=]{3,})(\s*)$/, '$1\\$2$3');
  10842. // dot, because of ordered lists, only troublesome at the beginning of a line when preceded by an integer
  10843. txt = txt.replace(/^( {0,3}\d+)\./gm, '$1\\.');
  10844. // +, * and -, at the beginning of a line becomes a list, so we need to escape them also (asterisk was already escaped)
  10845. txt = txt.replace(/^( {0,3})([+-])/gm, '$1\\$2');
  10846. // images and links, ] followed by ( is problematic, so we escape it
  10847. txt = txt.replace(/]([\s]*)\(/g, '\\]$1\\(');
  10848. // reference URIs must also be escaped
  10849. txt = txt.replace(/^ {0,3}\[([\S \t]*?)]:/gm, '\\[$1]:');
  10850. return txt;
  10851. });
  10852. var root = this;
  10853. // AMD Loader
  10854. if (true) {
  10855. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {
  10856. 'use strict';
  10857. return showdown;
  10858. }).call(exports, __webpack_require__, exports, module),
  10859. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  10860. // CommonJS/nodeJS Loader
  10861. } else {}
  10862. }).call(this);
  10863. /***/ }),
  10864. /***/ "NMb1":
  10865. /***/ (function(module, exports) {
  10866. (function() { module.exports = window["wp"]["deprecated"]; }());
  10867. /***/ }),
  10868. /***/ "SVSp":
  10869. /***/ (function(module, exports) {
  10870. (function() { module.exports = window["wp"]["shortcode"]; }());
  10871. /***/ }),
  10872. /***/ "Tqx9":
  10873. /***/ (function(module, exports) {
  10874. (function() { module.exports = window["wp"]["primitives"]; }());
  10875. /***/ }),
  10876. /***/ "UuzZ":
  10877. /***/ (function(module, exports) {
  10878. (function() { module.exports = window["wp"]["autop"]; }());
  10879. /***/ }),
  10880. /***/ "YLtl":
  10881. /***/ (function(module, exports) {
  10882. (function() { module.exports = window["lodash"]; }());
  10883. /***/ }),
  10884. /***/ "Zss7":
  10885. /***/ (function(module, exports, __webpack_require__) {
  10886. var __WEBPACK_AMD_DEFINE_RESULT__;// TinyColor v1.4.2
  10887. // https://github.com/bgrins/TinyColor
  10888. // Brian Grinstead, MIT License
  10889. (function(Math) {
  10890. var trimLeft = /^\s+/,
  10891. trimRight = /\s+$/,
  10892. tinyCounter = 0,
  10893. mathRound = Math.round,
  10894. mathMin = Math.min,
  10895. mathMax = Math.max,
  10896. mathRandom = Math.random;
  10897. function tinycolor (color, opts) {
  10898. color = (color) ? color : '';
  10899. opts = opts || { };
  10900. // If input is already a tinycolor, return itself
  10901. if (color instanceof tinycolor) {
  10902. return color;
  10903. }
  10904. // If we are called as a function, call using new instead
  10905. if (!(this instanceof tinycolor)) {
  10906. return new tinycolor(color, opts);
  10907. }
  10908. var rgb = inputToRGB(color);
  10909. this._originalInput = color,
  10910. this._r = rgb.r,
  10911. this._g = rgb.g,
  10912. this._b = rgb.b,
  10913. this._a = rgb.a,
  10914. this._roundA = mathRound(100*this._a) / 100,
  10915. this._format = opts.format || rgb.format;
  10916. this._gradientType = opts.gradientType;
  10917. // Don't let the range of [0,255] come back in [0,1].
  10918. // Potentially lose a little bit of precision here, but will fix issues where
  10919. // .5 gets interpreted as half of the total, instead of half of 1
  10920. // If it was supposed to be 128, this was already taken care of by `inputToRgb`
  10921. if (this._r < 1) { this._r = mathRound(this._r); }
  10922. if (this._g < 1) { this._g = mathRound(this._g); }
  10923. if (this._b < 1) { this._b = mathRound(this._b); }
  10924. this._ok = rgb.ok;
  10925. this._tc_id = tinyCounter++;
  10926. }
  10927. tinycolor.prototype = {
  10928. isDark: function() {
  10929. return this.getBrightness() < 128;
  10930. },
  10931. isLight: function() {
  10932. return !this.isDark();
  10933. },
  10934. isValid: function() {
  10935. return this._ok;
  10936. },
  10937. getOriginalInput: function() {
  10938. return this._originalInput;
  10939. },
  10940. getFormat: function() {
  10941. return this._format;
  10942. },
  10943. getAlpha: function() {
  10944. return this._a;
  10945. },
  10946. getBrightness: function() {
  10947. //http://www.w3.org/TR/AERT#color-contrast
  10948. var rgb = this.toRgb();
  10949. return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
  10950. },
  10951. getLuminance: function() {
  10952. //http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
  10953. var rgb = this.toRgb();
  10954. var RsRGB, GsRGB, BsRGB, R, G, B;
  10955. RsRGB = rgb.r/255;
  10956. GsRGB = rgb.g/255;
  10957. BsRGB = rgb.b/255;
  10958. if (RsRGB <= 0.03928) {R = RsRGB / 12.92;} else {R = Math.pow(((RsRGB + 0.055) / 1.055), 2.4);}
  10959. if (GsRGB <= 0.03928) {G = GsRGB / 12.92;} else {G = Math.pow(((GsRGB + 0.055) / 1.055), 2.4);}
  10960. if (BsRGB <= 0.03928) {B = BsRGB / 12.92;} else {B = Math.pow(((BsRGB + 0.055) / 1.055), 2.4);}
  10961. return (0.2126 * R) + (0.7152 * G) + (0.0722 * B);
  10962. },
  10963. setAlpha: function(value) {
  10964. this._a = boundAlpha(value);
  10965. this._roundA = mathRound(100*this._a) / 100;
  10966. return this;
  10967. },
  10968. toHsv: function() {
  10969. var hsv = rgbToHsv(this._r, this._g, this._b);
  10970. return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a };
  10971. },
  10972. toHsvString: function() {
  10973. var hsv = rgbToHsv(this._r, this._g, this._b);
  10974. var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100);
  10975. return (this._a == 1) ?
  10976. "hsv(" + h + ", " + s + "%, " + v + "%)" :
  10977. "hsva(" + h + ", " + s + "%, " + v + "%, "+ this._roundA + ")";
  10978. },
  10979. toHsl: function() {
  10980. var hsl = rgbToHsl(this._r, this._g, this._b);
  10981. return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a };
  10982. },
  10983. toHslString: function() {
  10984. var hsl = rgbToHsl(this._r, this._g, this._b);
  10985. var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100);
  10986. return (this._a == 1) ?
  10987. "hsl(" + h + ", " + s + "%, " + l + "%)" :
  10988. "hsla(" + h + ", " + s + "%, " + l + "%, "+ this._roundA + ")";
  10989. },
  10990. toHex: function(allow3Char) {
  10991. return rgbToHex(this._r, this._g, this._b, allow3Char);
  10992. },
  10993. toHexString: function(allow3Char) {
  10994. return '#' + this.toHex(allow3Char);
  10995. },
  10996. toHex8: function(allow4Char) {
  10997. return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char);
  10998. },
  10999. toHex8String: function(allow4Char) {
  11000. return '#' + this.toHex8(allow4Char);
  11001. },
  11002. toRgb: function() {
  11003. return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a };
  11004. },
  11005. toRgbString: function() {
  11006. return (this._a == 1) ?
  11007. "rgb(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ")" :
  11008. "rgba(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ", " + this._roundA + ")";
  11009. },
  11010. toPercentageRgb: function() {
  11011. return { r: mathRound(bound01(this._r, 255) * 100) + "%", g: mathRound(bound01(this._g, 255) * 100) + "%", b: mathRound(bound01(this._b, 255) * 100) + "%", a: this._a };
  11012. },
  11013. toPercentageRgbString: function() {
  11014. return (this._a == 1) ?
  11015. "rgb(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%)" :
  11016. "rgba(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")";
  11017. },
  11018. toName: function() {
  11019. if (this._a === 0) {
  11020. return "transparent";
  11021. }
  11022. if (this._a < 1) {
  11023. return false;
  11024. }
  11025. return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
  11026. },
  11027. toFilter: function(secondColor) {
  11028. var hex8String = '#' + rgbaToArgbHex(this._r, this._g, this._b, this._a);
  11029. var secondHex8String = hex8String;
  11030. var gradientType = this._gradientType ? "GradientType = 1, " : "";
  11031. if (secondColor) {
  11032. var s = tinycolor(secondColor);
  11033. secondHex8String = '#' + rgbaToArgbHex(s._r, s._g, s._b, s._a);
  11034. }
  11035. return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")";
  11036. },
  11037. toString: function(format) {
  11038. var formatSet = !!format;
  11039. format = format || this._format;
  11040. var formattedString = false;
  11041. var hasAlpha = this._a < 1 && this._a >= 0;
  11042. var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name");
  11043. if (needsAlphaFormat) {
  11044. // Special case for "transparent", all other non-alpha formats
  11045. // will return rgba when there is transparency.
  11046. if (format === "name" && this._a === 0) {
  11047. return this.toName();
  11048. }
  11049. return this.toRgbString();
  11050. }
  11051. if (format === "rgb") {
  11052. formattedString = this.toRgbString();
  11053. }
  11054. if (format === "prgb") {
  11055. formattedString = this.toPercentageRgbString();
  11056. }
  11057. if (format === "hex" || format === "hex6") {
  11058. formattedString = this.toHexString();
  11059. }
  11060. if (format === "hex3") {
  11061. formattedString = this.toHexString(true);
  11062. }
  11063. if (format === "hex4") {
  11064. formattedString = this.toHex8String(true);
  11065. }
  11066. if (format === "hex8") {
  11067. formattedString = this.toHex8String();
  11068. }
  11069. if (format === "name") {
  11070. formattedString = this.toName();
  11071. }
  11072. if (format === "hsl") {
  11073. formattedString = this.toHslString();
  11074. }
  11075. if (format === "hsv") {
  11076. formattedString = this.toHsvString();
  11077. }
  11078. return formattedString || this.toHexString();
  11079. },
  11080. clone: function() {
  11081. return tinycolor(this.toString());
  11082. },
  11083. _applyModification: function(fn, args) {
  11084. var color = fn.apply(null, [this].concat([].slice.call(args)));
  11085. this._r = color._r;
  11086. this._g = color._g;
  11087. this._b = color._b;
  11088. this.setAlpha(color._a);
  11089. return this;
  11090. },
  11091. lighten: function() {
  11092. return this._applyModification(lighten, arguments);
  11093. },
  11094. brighten: function() {
  11095. return this._applyModification(brighten, arguments);
  11096. },
  11097. darken: function() {
  11098. return this._applyModification(darken, arguments);
  11099. },
  11100. desaturate: function() {
  11101. return this._applyModification(desaturate, arguments);
  11102. },
  11103. saturate: function() {
  11104. return this._applyModification(saturate, arguments);
  11105. },
  11106. greyscale: function() {
  11107. return this._applyModification(greyscale, arguments);
  11108. },
  11109. spin: function() {
  11110. return this._applyModification(spin, arguments);
  11111. },
  11112. _applyCombination: function(fn, args) {
  11113. return fn.apply(null, [this].concat([].slice.call(args)));
  11114. },
  11115. analogous: function() {
  11116. return this._applyCombination(analogous, arguments);
  11117. },
  11118. complement: function() {
  11119. return this._applyCombination(complement, arguments);
  11120. },
  11121. monochromatic: function() {
  11122. return this._applyCombination(monochromatic, arguments);
  11123. },
  11124. splitcomplement: function() {
  11125. return this._applyCombination(splitcomplement, arguments);
  11126. },
  11127. triad: function() {
  11128. return this._applyCombination(triad, arguments);
  11129. },
  11130. tetrad: function() {
  11131. return this._applyCombination(tetrad, arguments);
  11132. }
  11133. };
  11134. // If input is an object, force 1 into "1.0" to handle ratios properly
  11135. // String input requires "1.0" as input, so 1 will be treated as 1
  11136. tinycolor.fromRatio = function(color, opts) {
  11137. if (typeof color == "object") {
  11138. var newColor = {};
  11139. for (var i in color) {
  11140. if (color.hasOwnProperty(i)) {
  11141. if (i === "a") {
  11142. newColor[i] = color[i];
  11143. }
  11144. else {
  11145. newColor[i] = convertToPercentage(color[i]);
  11146. }
  11147. }
  11148. }
  11149. color = newColor;
  11150. }
  11151. return tinycolor(color, opts);
  11152. };
  11153. // Given a string or object, convert that input to RGB
  11154. // Possible string inputs:
  11155. //
  11156. // "red"
  11157. // "#f00" or "f00"
  11158. // "#ff0000" or "ff0000"
  11159. // "#ff000000" or "ff000000"
  11160. // "rgb 255 0 0" or "rgb (255, 0, 0)"
  11161. // "rgb 1.0 0 0" or "rgb (1, 0, 0)"
  11162. // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
  11163. // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
  11164. // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
  11165. // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
  11166. // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
  11167. //
  11168. function inputToRGB(color) {
  11169. var rgb = { r: 0, g: 0, b: 0 };
  11170. var a = 1;
  11171. var s = null;
  11172. var v = null;
  11173. var l = null;
  11174. var ok = false;
  11175. var format = false;
  11176. if (typeof color == "string") {
  11177. color = stringInputToObject(color);
  11178. }
  11179. if (typeof color == "object") {
  11180. if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
  11181. rgb = rgbToRgb(color.r, color.g, color.b);
  11182. ok = true;
  11183. format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
  11184. }
  11185. else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
  11186. s = convertToPercentage(color.s);
  11187. v = convertToPercentage(color.v);
  11188. rgb = hsvToRgb(color.h, s, v);
  11189. ok = true;
  11190. format = "hsv";
  11191. }
  11192. else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
  11193. s = convertToPercentage(color.s);
  11194. l = convertToPercentage(color.l);
  11195. rgb = hslToRgb(color.h, s, l);
  11196. ok = true;
  11197. format = "hsl";
  11198. }
  11199. if (color.hasOwnProperty("a")) {
  11200. a = color.a;
  11201. }
  11202. }
  11203. a = boundAlpha(a);
  11204. return {
  11205. ok: ok,
  11206. format: color.format || format,
  11207. r: mathMin(255, mathMax(rgb.r, 0)),
  11208. g: mathMin(255, mathMax(rgb.g, 0)),
  11209. b: mathMin(255, mathMax(rgb.b, 0)),
  11210. a: a
  11211. };
  11212. }
  11213. // Conversion Functions
  11214. // --------------------
  11215. // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
  11216. // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
  11217. // `rgbToRgb`
  11218. // Handle bounds / percentage checking to conform to CSS color spec
  11219. // <http://www.w3.org/TR/css3-color/>
  11220. // *Assumes:* r, g, b in [0, 255] or [0, 1]
  11221. // *Returns:* { r, g, b } in [0, 255]
  11222. function rgbToRgb(r, g, b){
  11223. return {
  11224. r: bound01(r, 255) * 255,
  11225. g: bound01(g, 255) * 255,
  11226. b: bound01(b, 255) * 255
  11227. };
  11228. }
  11229. // `rgbToHsl`
  11230. // Converts an RGB color value to HSL.
  11231. // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
  11232. // *Returns:* { h, s, l } in [0,1]
  11233. function rgbToHsl(r, g, b) {
  11234. r = bound01(r, 255);
  11235. g = bound01(g, 255);
  11236. b = bound01(b, 255);
  11237. var max = mathMax(r, g, b), min = mathMin(r, g, b);
  11238. var h, s, l = (max + min) / 2;
  11239. if(max == min) {
  11240. h = s = 0; // achromatic
  11241. }
  11242. else {
  11243. var d = max - min;
  11244. s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
  11245. switch(max) {
  11246. case r: h = (g - b) / d + (g < b ? 6 : 0); break;
  11247. case g: h = (b - r) / d + 2; break;
  11248. case b: h = (r - g) / d + 4; break;
  11249. }
  11250. h /= 6;
  11251. }
  11252. return { h: h, s: s, l: l };
  11253. }
  11254. // `hslToRgb`
  11255. // Converts an HSL color value to RGB.
  11256. // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
  11257. // *Returns:* { r, g, b } in the set [0, 255]
  11258. function hslToRgb(h, s, l) {
  11259. var r, g, b;
  11260. h = bound01(h, 360);
  11261. s = bound01(s, 100);
  11262. l = bound01(l, 100);
  11263. function hue2rgb(p, q, t) {
  11264. if(t < 0) t += 1;
  11265. if(t > 1) t -= 1;
  11266. if(t < 1/6) return p + (q - p) * 6 * t;
  11267. if(t < 1/2) return q;
  11268. if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
  11269. return p;
  11270. }
  11271. if(s === 0) {
  11272. r = g = b = l; // achromatic
  11273. }
  11274. else {
  11275. var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
  11276. var p = 2 * l - q;
  11277. r = hue2rgb(p, q, h + 1/3);
  11278. g = hue2rgb(p, q, h);
  11279. b = hue2rgb(p, q, h - 1/3);
  11280. }
  11281. return { r: r * 255, g: g * 255, b: b * 255 };
  11282. }
  11283. // `rgbToHsv`
  11284. // Converts an RGB color value to HSV
  11285. // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
  11286. // *Returns:* { h, s, v } in [0,1]
  11287. function rgbToHsv(r, g, b) {
  11288. r = bound01(r, 255);
  11289. g = bound01(g, 255);
  11290. b = bound01(b, 255);
  11291. var max = mathMax(r, g, b), min = mathMin(r, g, b);
  11292. var h, s, v = max;
  11293. var d = max - min;
  11294. s = max === 0 ? 0 : d / max;
  11295. if(max == min) {
  11296. h = 0; // achromatic
  11297. }
  11298. else {
  11299. switch(max) {
  11300. case r: h = (g - b) / d + (g < b ? 6 : 0); break;
  11301. case g: h = (b - r) / d + 2; break;
  11302. case b: h = (r - g) / d + 4; break;
  11303. }
  11304. h /= 6;
  11305. }
  11306. return { h: h, s: s, v: v };
  11307. }
  11308. // `hsvToRgb`
  11309. // Converts an HSV color value to RGB.
  11310. // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
  11311. // *Returns:* { r, g, b } in the set [0, 255]
  11312. function hsvToRgb(h, s, v) {
  11313. h = bound01(h, 360) * 6;
  11314. s = bound01(s, 100);
  11315. v = bound01(v, 100);
  11316. var i = Math.floor(h),
  11317. f = h - i,
  11318. p = v * (1 - s),
  11319. q = v * (1 - f * s),
  11320. t = v * (1 - (1 - f) * s),
  11321. mod = i % 6,
  11322. r = [v, q, p, p, t, v][mod],
  11323. g = [t, v, v, q, p, p][mod],
  11324. b = [p, p, t, v, v, q][mod];
  11325. return { r: r * 255, g: g * 255, b: b * 255 };
  11326. }
  11327. // `rgbToHex`
  11328. // Converts an RGB color to hex
  11329. // Assumes r, g, and b are contained in the set [0, 255]
  11330. // Returns a 3 or 6 character hex
  11331. function rgbToHex(r, g, b, allow3Char) {
  11332. var hex = [
  11333. pad2(mathRound(r).toString(16)),
  11334. pad2(mathRound(g).toString(16)),
  11335. pad2(mathRound(b).toString(16))
  11336. ];
  11337. // Return a 3 character hex if possible
  11338. if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
  11339. return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
  11340. }
  11341. return hex.join("");
  11342. }
  11343. // `rgbaToHex`
  11344. // Converts an RGBA color plus alpha transparency to hex
  11345. // Assumes r, g, b are contained in the set [0, 255] and
  11346. // a in [0, 1]. Returns a 4 or 8 character rgba hex
  11347. function rgbaToHex(r, g, b, a, allow4Char) {
  11348. var hex = [
  11349. pad2(mathRound(r).toString(16)),
  11350. pad2(mathRound(g).toString(16)),
  11351. pad2(mathRound(b).toString(16)),
  11352. pad2(convertDecimalToHex(a))
  11353. ];
  11354. // Return a 4 character hex if possible
  11355. if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) {
  11356. return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
  11357. }
  11358. return hex.join("");
  11359. }
  11360. // `rgbaToArgbHex`
  11361. // Converts an RGBA color to an ARGB Hex8 string
  11362. // Rarely used, but required for "toFilter()"
  11363. function rgbaToArgbHex(r, g, b, a) {
  11364. var hex = [
  11365. pad2(convertDecimalToHex(a)),
  11366. pad2(mathRound(r).toString(16)),
  11367. pad2(mathRound(g).toString(16)),
  11368. pad2(mathRound(b).toString(16))
  11369. ];
  11370. return hex.join("");
  11371. }
  11372. // `equals`
  11373. // Can be called with any tinycolor input
  11374. tinycolor.equals = function (color1, color2) {
  11375. if (!color1 || !color2) { return false; }
  11376. return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
  11377. };
  11378. tinycolor.random = function() {
  11379. return tinycolor.fromRatio({
  11380. r: mathRandom(),
  11381. g: mathRandom(),
  11382. b: mathRandom()
  11383. });
  11384. };
  11385. // Modification Functions
  11386. // ----------------------
  11387. // Thanks to less.js for some of the basics here
  11388. // <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>
  11389. function desaturate(color, amount) {
  11390. amount = (amount === 0) ? 0 : (amount || 10);
  11391. var hsl = tinycolor(color).toHsl();
  11392. hsl.s -= amount / 100;
  11393. hsl.s = clamp01(hsl.s);
  11394. return tinycolor(hsl);
  11395. }
  11396. function saturate(color, amount) {
  11397. amount = (amount === 0) ? 0 : (amount || 10);
  11398. var hsl = tinycolor(color).toHsl();
  11399. hsl.s += amount / 100;
  11400. hsl.s = clamp01(hsl.s);
  11401. return tinycolor(hsl);
  11402. }
  11403. function greyscale(color) {
  11404. return tinycolor(color).desaturate(100);
  11405. }
  11406. function lighten (color, amount) {
  11407. amount = (amount === 0) ? 0 : (amount || 10);
  11408. var hsl = tinycolor(color).toHsl();
  11409. hsl.l += amount / 100;
  11410. hsl.l = clamp01(hsl.l);
  11411. return tinycolor(hsl);
  11412. }
  11413. function brighten(color, amount) {
  11414. amount = (amount === 0) ? 0 : (amount || 10);
  11415. var rgb = tinycolor(color).toRgb();
  11416. rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100))));
  11417. rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100))));
  11418. rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100))));
  11419. return tinycolor(rgb);
  11420. }
  11421. function darken (color, amount) {
  11422. amount = (amount === 0) ? 0 : (amount || 10);
  11423. var hsl = tinycolor(color).toHsl();
  11424. hsl.l -= amount / 100;
  11425. hsl.l = clamp01(hsl.l);
  11426. return tinycolor(hsl);
  11427. }
  11428. // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
  11429. // Values outside of this range will be wrapped into this range.
  11430. function spin(color, amount) {
  11431. var hsl = tinycolor(color).toHsl();
  11432. var hue = (hsl.h + amount) % 360;
  11433. hsl.h = hue < 0 ? 360 + hue : hue;
  11434. return tinycolor(hsl);
  11435. }
  11436. // Combination Functions
  11437. // ---------------------
  11438. // Thanks to jQuery xColor for some of the ideas behind these
  11439. // <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>
  11440. function complement(color) {
  11441. var hsl = tinycolor(color).toHsl();
  11442. hsl.h = (hsl.h + 180) % 360;
  11443. return tinycolor(hsl);
  11444. }
  11445. function triad(color) {
  11446. var hsl = tinycolor(color).toHsl();
  11447. var h = hsl.h;
  11448. return [
  11449. tinycolor(color),
  11450. tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }),
  11451. tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l })
  11452. ];
  11453. }
  11454. function tetrad(color) {
  11455. var hsl = tinycolor(color).toHsl();
  11456. var h = hsl.h;
  11457. return [
  11458. tinycolor(color),
  11459. tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }),
  11460. tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }),
  11461. tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l })
  11462. ];
  11463. }
  11464. function splitcomplement(color) {
  11465. var hsl = tinycolor(color).toHsl();
  11466. var h = hsl.h;
  11467. return [
  11468. tinycolor(color),
  11469. tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}),
  11470. tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l})
  11471. ];
  11472. }
  11473. function analogous(color, results, slices) {
  11474. results = results || 6;
  11475. slices = slices || 30;
  11476. var hsl = tinycolor(color).toHsl();
  11477. var part = 360 / slices;
  11478. var ret = [tinycolor(color)];
  11479. for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) {
  11480. hsl.h = (hsl.h + part) % 360;
  11481. ret.push(tinycolor(hsl));
  11482. }
  11483. return ret;
  11484. }
  11485. function monochromatic(color, results) {
  11486. results = results || 6;
  11487. var hsv = tinycolor(color).toHsv();
  11488. var h = hsv.h, s = hsv.s, v = hsv.v;
  11489. var ret = [];
  11490. var modification = 1 / results;
  11491. while (results--) {
  11492. ret.push(tinycolor({ h: h, s: s, v: v}));
  11493. v = (v + modification) % 1;
  11494. }
  11495. return ret;
  11496. }
  11497. // Utility Functions
  11498. // ---------------------
  11499. tinycolor.mix = function(color1, color2, amount) {
  11500. amount = (amount === 0) ? 0 : (amount || 50);
  11501. var rgb1 = tinycolor(color1).toRgb();
  11502. var rgb2 = tinycolor(color2).toRgb();
  11503. var p = amount / 100;
  11504. var rgba = {
  11505. r: ((rgb2.r - rgb1.r) * p) + rgb1.r,
  11506. g: ((rgb2.g - rgb1.g) * p) + rgb1.g,
  11507. b: ((rgb2.b - rgb1.b) * p) + rgb1.b,
  11508. a: ((rgb2.a - rgb1.a) * p) + rgb1.a
  11509. };
  11510. return tinycolor(rgba);
  11511. };
  11512. // Readability Functions
  11513. // ---------------------
  11514. // <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
  11515. // `contrast`
  11516. // Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
  11517. tinycolor.readability = function(color1, color2) {
  11518. var c1 = tinycolor(color1);
  11519. var c2 = tinycolor(color2);
  11520. return (Math.max(c1.getLuminance(),c2.getLuminance())+0.05) / (Math.min(c1.getLuminance(),c2.getLuminance())+0.05);
  11521. };
  11522. // `isReadable`
  11523. // Ensure that foreground and background color combinations meet WCAG2 guidelines.
  11524. // The third argument is an optional Object.
  11525. // the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';
  11526. // the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.
  11527. // If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
  11528. // *Example*
  11529. // tinycolor.isReadable("#000", "#111") => false
  11530. // tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false
  11531. tinycolor.isReadable = function(color1, color2, wcag2) {
  11532. var readability = tinycolor.readability(color1, color2);
  11533. var wcag2Parms, out;
  11534. out = false;
  11535. wcag2Parms = validateWCAG2Parms(wcag2);
  11536. switch (wcag2Parms.level + wcag2Parms.size) {
  11537. case "AAsmall":
  11538. case "AAAlarge":
  11539. out = readability >= 4.5;
  11540. break;
  11541. case "AAlarge":
  11542. out = readability >= 3;
  11543. break;
  11544. case "AAAsmall":
  11545. out = readability >= 7;
  11546. break;
  11547. }
  11548. return out;
  11549. };
  11550. // `mostReadable`
  11551. // Given a base color and a list of possible foreground or background
  11552. // colors for that base, returns the most readable color.
  11553. // Optionally returns Black or White if the most readable color is unreadable.
  11554. // *Example*
  11555. // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255"
  11556. // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff"
  11557. // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3"
  11558. // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff"
  11559. tinycolor.mostReadable = function(baseColor, colorList, args) {
  11560. var bestColor = null;
  11561. var bestScore = 0;
  11562. var readability;
  11563. var includeFallbackColors, level, size ;
  11564. args = args || {};
  11565. includeFallbackColors = args.includeFallbackColors ;
  11566. level = args.level;
  11567. size = args.size;
  11568. for (var i= 0; i < colorList.length ; i++) {
  11569. readability = tinycolor.readability(baseColor, colorList[i]);
  11570. if (readability > bestScore) {
  11571. bestScore = readability;
  11572. bestColor = tinycolor(colorList[i]);
  11573. }
  11574. }
  11575. if (tinycolor.isReadable(baseColor, bestColor, {"level":level,"size":size}) || !includeFallbackColors) {
  11576. return bestColor;
  11577. }
  11578. else {
  11579. args.includeFallbackColors=false;
  11580. return tinycolor.mostReadable(baseColor,["#fff", "#000"],args);
  11581. }
  11582. };
  11583. // Big List of Colors
  11584. // ------------------
  11585. // <http://www.w3.org/TR/css3-color/#svg-color>
  11586. var names = tinycolor.names = {
  11587. aliceblue: "f0f8ff",
  11588. antiquewhite: "faebd7",
  11589. aqua: "0ff",
  11590. aquamarine: "7fffd4",
  11591. azure: "f0ffff",
  11592. beige: "f5f5dc",
  11593. bisque: "ffe4c4",
  11594. black: "000",
  11595. blanchedalmond: "ffebcd",
  11596. blue: "00f",
  11597. blueviolet: "8a2be2",
  11598. brown: "a52a2a",
  11599. burlywood: "deb887",
  11600. burntsienna: "ea7e5d",
  11601. cadetblue: "5f9ea0",
  11602. chartreuse: "7fff00",
  11603. chocolate: "d2691e",
  11604. coral: "ff7f50",
  11605. cornflowerblue: "6495ed",
  11606. cornsilk: "fff8dc",
  11607. crimson: "dc143c",
  11608. cyan: "0ff",
  11609. darkblue: "00008b",
  11610. darkcyan: "008b8b",
  11611. darkgoldenrod: "b8860b",
  11612. darkgray: "a9a9a9",
  11613. darkgreen: "006400",
  11614. darkgrey: "a9a9a9",
  11615. darkkhaki: "bdb76b",
  11616. darkmagenta: "8b008b",
  11617. darkolivegreen: "556b2f",
  11618. darkorange: "ff8c00",
  11619. darkorchid: "9932cc",
  11620. darkred: "8b0000",
  11621. darksalmon: "e9967a",
  11622. darkseagreen: "8fbc8f",
  11623. darkslateblue: "483d8b",
  11624. darkslategray: "2f4f4f",
  11625. darkslategrey: "2f4f4f",
  11626. darkturquoise: "00ced1",
  11627. darkviolet: "9400d3",
  11628. deeppink: "ff1493",
  11629. deepskyblue: "00bfff",
  11630. dimgray: "696969",
  11631. dimgrey: "696969",
  11632. dodgerblue: "1e90ff",
  11633. firebrick: "b22222",
  11634. floralwhite: "fffaf0",
  11635. forestgreen: "228b22",
  11636. fuchsia: "f0f",
  11637. gainsboro: "dcdcdc",
  11638. ghostwhite: "f8f8ff",
  11639. gold: "ffd700",
  11640. goldenrod: "daa520",
  11641. gray: "808080",
  11642. green: "008000",
  11643. greenyellow: "adff2f",
  11644. grey: "808080",
  11645. honeydew: "f0fff0",
  11646. hotpink: "ff69b4",
  11647. indianred: "cd5c5c",
  11648. indigo: "4b0082",
  11649. ivory: "fffff0",
  11650. khaki: "f0e68c",
  11651. lavender: "e6e6fa",
  11652. lavenderblush: "fff0f5",
  11653. lawngreen: "7cfc00",
  11654. lemonchiffon: "fffacd",
  11655. lightblue: "add8e6",
  11656. lightcoral: "f08080",
  11657. lightcyan: "e0ffff",
  11658. lightgoldenrodyellow: "fafad2",
  11659. lightgray: "d3d3d3",
  11660. lightgreen: "90ee90",
  11661. lightgrey: "d3d3d3",
  11662. lightpink: "ffb6c1",
  11663. lightsalmon: "ffa07a",
  11664. lightseagreen: "20b2aa",
  11665. lightskyblue: "87cefa",
  11666. lightslategray: "789",
  11667. lightslategrey: "789",
  11668. lightsteelblue: "b0c4de",
  11669. lightyellow: "ffffe0",
  11670. lime: "0f0",
  11671. limegreen: "32cd32",
  11672. linen: "faf0e6",
  11673. magenta: "f0f",
  11674. maroon: "800000",
  11675. mediumaquamarine: "66cdaa",
  11676. mediumblue: "0000cd",
  11677. mediumorchid: "ba55d3",
  11678. mediumpurple: "9370db",
  11679. mediumseagreen: "3cb371",
  11680. mediumslateblue: "7b68ee",
  11681. mediumspringgreen: "00fa9a",
  11682. mediumturquoise: "48d1cc",
  11683. mediumvioletred: "c71585",
  11684. midnightblue: "191970",
  11685. mintcream: "f5fffa",
  11686. mistyrose: "ffe4e1",
  11687. moccasin: "ffe4b5",
  11688. navajowhite: "ffdead",
  11689. navy: "000080",
  11690. oldlace: "fdf5e6",
  11691. olive: "808000",
  11692. olivedrab: "6b8e23",
  11693. orange: "ffa500",
  11694. orangered: "ff4500",
  11695. orchid: "da70d6",
  11696. palegoldenrod: "eee8aa",
  11697. palegreen: "98fb98",
  11698. paleturquoise: "afeeee",
  11699. palevioletred: "db7093",
  11700. papayawhip: "ffefd5",
  11701. peachpuff: "ffdab9",
  11702. peru: "cd853f",
  11703. pink: "ffc0cb",
  11704. plum: "dda0dd",
  11705. powderblue: "b0e0e6",
  11706. purple: "800080",
  11707. rebeccapurple: "663399",
  11708. red: "f00",
  11709. rosybrown: "bc8f8f",
  11710. royalblue: "4169e1",
  11711. saddlebrown: "8b4513",
  11712. salmon: "fa8072",
  11713. sandybrown: "f4a460",
  11714. seagreen: "2e8b57",
  11715. seashell: "fff5ee",
  11716. sienna: "a0522d",
  11717. silver: "c0c0c0",
  11718. skyblue: "87ceeb",
  11719. slateblue: "6a5acd",
  11720. slategray: "708090",
  11721. slategrey: "708090",
  11722. snow: "fffafa",
  11723. springgreen: "00ff7f",
  11724. steelblue: "4682b4",
  11725. tan: "d2b48c",
  11726. teal: "008080",
  11727. thistle: "d8bfd8",
  11728. tomato: "ff6347",
  11729. turquoise: "40e0d0",
  11730. violet: "ee82ee",
  11731. wheat: "f5deb3",
  11732. white: "fff",
  11733. whitesmoke: "f5f5f5",
  11734. yellow: "ff0",
  11735. yellowgreen: "9acd32"
  11736. };
  11737. // Make it easy to access colors via `hexNames[hex]`
  11738. var hexNames = tinycolor.hexNames = flip(names);
  11739. // Utilities
  11740. // ---------
  11741. // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
  11742. function flip(o) {
  11743. var flipped = { };
  11744. for (var i in o) {
  11745. if (o.hasOwnProperty(i)) {
  11746. flipped[o[i]] = i;
  11747. }
  11748. }
  11749. return flipped;
  11750. }
  11751. // Return a valid alpha value [0,1] with all invalid values being set to 1
  11752. function boundAlpha(a) {
  11753. a = parseFloat(a);
  11754. if (isNaN(a) || a < 0 || a > 1) {
  11755. a = 1;
  11756. }
  11757. return a;
  11758. }
  11759. // Take input from [0, n] and return it as [0, 1]
  11760. function bound01(n, max) {
  11761. if (isOnePointZero(n)) { n = "100%"; }
  11762. var processPercent = isPercentage(n);
  11763. n = mathMin(max, mathMax(0, parseFloat(n)));
  11764. // Automatically convert percentage into number
  11765. if (processPercent) {
  11766. n = parseInt(n * max, 10) / 100;
  11767. }
  11768. // Handle floating point rounding errors
  11769. if ((Math.abs(n - max) < 0.000001)) {
  11770. return 1;
  11771. }
  11772. // Convert into [0, 1] range if it isn't already
  11773. return (n % max) / parseFloat(max);
  11774. }
  11775. // Force a number between 0 and 1
  11776. function clamp01(val) {
  11777. return mathMin(1, mathMax(0, val));
  11778. }
  11779. // Parse a base-16 hex value into a base-10 integer
  11780. function parseIntFromHex(val) {
  11781. return parseInt(val, 16);
  11782. }
  11783. // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
  11784. // <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
  11785. function isOnePointZero(n) {
  11786. return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1;
  11787. }
  11788. // Check to see if string passed in is a percentage
  11789. function isPercentage(n) {
  11790. return typeof n === "string" && n.indexOf('%') != -1;
  11791. }
  11792. // Force a hex value to have 2 characters
  11793. function pad2(c) {
  11794. return c.length == 1 ? '0' + c : '' + c;
  11795. }
  11796. // Replace a decimal with it's percentage value
  11797. function convertToPercentage(n) {
  11798. if (n <= 1) {
  11799. n = (n * 100) + "%";
  11800. }
  11801. return n;
  11802. }
  11803. // Converts a decimal to a hex value
  11804. function convertDecimalToHex(d) {
  11805. return Math.round(parseFloat(d) * 255).toString(16);
  11806. }
  11807. // Converts a hex value to a decimal
  11808. function convertHexToDecimal(h) {
  11809. return (parseIntFromHex(h) / 255);
  11810. }
  11811. var matchers = (function() {
  11812. // <http://www.w3.org/TR/css3-values/#integers>
  11813. var CSS_INTEGER = "[-\\+]?\\d+%?";
  11814. // <http://www.w3.org/TR/css3-values/#number-value>
  11815. var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
  11816. // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
  11817. var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
  11818. // Actual matching.
  11819. // Parentheses and commas are optional, but not required.
  11820. // Whitespace can take the place of commas or opening paren
  11821. var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
  11822. var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
  11823. return {
  11824. CSS_UNIT: new RegExp(CSS_UNIT),
  11825. rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
  11826. rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
  11827. hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
  11828. hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
  11829. hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
  11830. hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
  11831. hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
  11832. hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
  11833. hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
  11834. hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
  11835. };
  11836. })();
  11837. // `isValidCSSUnit`
  11838. // Take in a single string / number and check to see if it looks like a CSS unit
  11839. // (see `matchers` above for definition).
  11840. function isValidCSSUnit(color) {
  11841. return !!matchers.CSS_UNIT.exec(color);
  11842. }
  11843. // `stringInputToObject`
  11844. // Permissive string parsing. Take in a number of formats, and output an object
  11845. // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
  11846. function stringInputToObject(color) {
  11847. color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase();
  11848. var named = false;
  11849. if (names[color]) {
  11850. color = names[color];
  11851. named = true;
  11852. }
  11853. else if (color == 'transparent') {
  11854. return { r: 0, g: 0, b: 0, a: 0, format: "name" };
  11855. }
  11856. // Try to match string input using regular expressions.
  11857. // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
  11858. // Just return an object and let the conversion functions handle that.
  11859. // This way the result will be the same whether the tinycolor is initialized with string or object.
  11860. var match;
  11861. if ((match = matchers.rgb.exec(color))) {
  11862. return { r: match[1], g: match[2], b: match[3] };
  11863. }
  11864. if ((match = matchers.rgba.exec(color))) {
  11865. return { r: match[1], g: match[2], b: match[3], a: match[4] };
  11866. }
  11867. if ((match = matchers.hsl.exec(color))) {
  11868. return { h: match[1], s: match[2], l: match[3] };
  11869. }
  11870. if ((match = matchers.hsla.exec(color))) {
  11871. return { h: match[1], s: match[2], l: match[3], a: match[4] };
  11872. }
  11873. if ((match = matchers.hsv.exec(color))) {
  11874. return { h: match[1], s: match[2], v: match[3] };
  11875. }
  11876. if ((match = matchers.hsva.exec(color))) {
  11877. return { h: match[1], s: match[2], v: match[3], a: match[4] };
  11878. }
  11879. if ((match = matchers.hex8.exec(color))) {
  11880. return {
  11881. r: parseIntFromHex(match[1]),
  11882. g: parseIntFromHex(match[2]),
  11883. b: parseIntFromHex(match[3]),
  11884. a: convertHexToDecimal(match[4]),
  11885. format: named ? "name" : "hex8"
  11886. };
  11887. }
  11888. if ((match = matchers.hex6.exec(color))) {
  11889. return {
  11890. r: parseIntFromHex(match[1]),
  11891. g: parseIntFromHex(match[2]),
  11892. b: parseIntFromHex(match[3]),
  11893. format: named ? "name" : "hex"
  11894. };
  11895. }
  11896. if ((match = matchers.hex4.exec(color))) {
  11897. return {
  11898. r: parseIntFromHex(match[1] + '' + match[1]),
  11899. g: parseIntFromHex(match[2] + '' + match[2]),
  11900. b: parseIntFromHex(match[3] + '' + match[3]),
  11901. a: convertHexToDecimal(match[4] + '' + match[4]),
  11902. format: named ? "name" : "hex8"
  11903. };
  11904. }
  11905. if ((match = matchers.hex3.exec(color))) {
  11906. return {
  11907. r: parseIntFromHex(match[1] + '' + match[1]),
  11908. g: parseIntFromHex(match[2] + '' + match[2]),
  11909. b: parseIntFromHex(match[3] + '' + match[3]),
  11910. format: named ? "name" : "hex"
  11911. };
  11912. }
  11913. return false;
  11914. }
  11915. function validateWCAG2Parms(parms) {
  11916. // return valid WCAG2 parms for isReadable.
  11917. // If input parms are invalid, return {"level":"AA", "size":"small"}
  11918. var level, size;
  11919. parms = parms || {"level":"AA", "size":"small"};
  11920. level = (parms.level || "AA").toUpperCase();
  11921. size = (parms.size || "small").toLowerCase();
  11922. if (level !== "AA" && level !== "AAA") {
  11923. level = "AA";
  11924. }
  11925. if (size !== "small" && size !== "large") {
  11926. size = "small";
  11927. }
  11928. return {"level":level, "size":size};
  11929. }
  11930. // Node: Export function
  11931. if ( true && module.exports) {
  11932. module.exports = tinycolor;
  11933. }
  11934. // AMD/requirejs: Define the module
  11935. else if (true) {
  11936. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {return tinycolor;}).call(exports, __webpack_require__, exports, module),
  11937. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  11938. }
  11939. // Browser: Expose to window
  11940. else {}
  11941. })(Math);
  11942. /***/ }),
  11943. /***/ "g56x":
  11944. /***/ (function(module, exports) {
  11945. (function() { module.exports = window["wp"]["hooks"]; }());
  11946. /***/ }),
  11947. /***/ "l3Sj":
  11948. /***/ (function(module, exports) {
  11949. (function() { module.exports = window["wp"]["i18n"]; }());
  11950. /***/ }),
  11951. /***/ "ouCq":
  11952. /***/ (function(module, exports) {
  11953. (function() { module.exports = window["wp"]["blockSerializationDefaultParser"]; }());
  11954. /***/ }),
  11955. /***/ "pPDe":
  11956. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11957. "use strict";
  11958. var LEAF_KEY, hasWeakMap;
  11959. /**
  11960. * Arbitrary value used as key for referencing cache object in WeakMap tree.
  11961. *
  11962. * @type {Object}
  11963. */
  11964. LEAF_KEY = {};
  11965. /**
  11966. * Whether environment supports WeakMap.
  11967. *
  11968. * @type {boolean}
  11969. */
  11970. hasWeakMap = typeof WeakMap !== 'undefined';
  11971. /**
  11972. * Returns the first argument as the sole entry in an array.
  11973. *
  11974. * @param {*} value Value to return.
  11975. *
  11976. * @return {Array} Value returned as entry in array.
  11977. */
  11978. function arrayOf( value ) {
  11979. return [ value ];
  11980. }
  11981. /**
  11982. * Returns true if the value passed is object-like, or false otherwise. A value
  11983. * is object-like if it can support property assignment, e.g. object or array.
  11984. *
  11985. * @param {*} value Value to test.
  11986. *
  11987. * @return {boolean} Whether value is object-like.
  11988. */
  11989. function isObjectLike( value ) {
  11990. return !! value && 'object' === typeof value;
  11991. }
  11992. /**
  11993. * Creates and returns a new cache object.
  11994. *
  11995. * @return {Object} Cache object.
  11996. */
  11997. function createCache() {
  11998. var cache = {
  11999. clear: function() {
  12000. cache.head = null;
  12001. },
  12002. };
  12003. return cache;
  12004. }
  12005. /**
  12006. * Returns true if entries within the two arrays are strictly equal by
  12007. * reference from a starting index.
  12008. *
  12009. * @param {Array} a First array.
  12010. * @param {Array} b Second array.
  12011. * @param {number} fromIndex Index from which to start comparison.
  12012. *
  12013. * @return {boolean} Whether arrays are shallowly equal.
  12014. */
  12015. function isShallowEqual( a, b, fromIndex ) {
  12016. var i;
  12017. if ( a.length !== b.length ) {
  12018. return false;
  12019. }
  12020. for ( i = fromIndex; i < a.length; i++ ) {
  12021. if ( a[ i ] !== b[ i ] ) {
  12022. return false;
  12023. }
  12024. }
  12025. return true;
  12026. }
  12027. /**
  12028. * Returns a memoized selector function. The getDependants function argument is
  12029. * called before the memoized selector and is expected to return an immutable
  12030. * reference or array of references on which the selector depends for computing
  12031. * its own return value. The memoize cache is preserved only as long as those
  12032. * dependant references remain the same. If getDependants returns a different
  12033. * reference(s), the cache is cleared and the selector value regenerated.
  12034. *
  12035. * @param {Function} selector Selector function.
  12036. * @param {Function} getDependants Dependant getter returning an immutable
  12037. * reference or array of reference used in
  12038. * cache bust consideration.
  12039. *
  12040. * @return {Function} Memoized selector.
  12041. */
  12042. /* harmony default export */ __webpack_exports__["a"] = (function( selector, getDependants ) {
  12043. var rootCache, getCache;
  12044. // Use object source as dependant if getter not provided
  12045. if ( ! getDependants ) {
  12046. getDependants = arrayOf;
  12047. }
  12048. /**
  12049. * Returns the root cache. If WeakMap is supported, this is assigned to the
  12050. * root WeakMap cache set, otherwise it is a shared instance of the default
  12051. * cache object.
  12052. *
  12053. * @return {(WeakMap|Object)} Root cache object.
  12054. */
  12055. function getRootCache() {
  12056. return rootCache;
  12057. }
  12058. /**
  12059. * Returns the cache for a given dependants array. When possible, a WeakMap
  12060. * will be used to create a unique cache for each set of dependants. This
  12061. * is feasible due to the nature of WeakMap in allowing garbage collection
  12062. * to occur on entries where the key object is no longer referenced. Since
  12063. * WeakMap requires the key to be an object, this is only possible when the
  12064. * dependant is object-like. The root cache is created as a hierarchy where
  12065. * each top-level key is the first entry in a dependants set, the value a
  12066. * WeakMap where each key is the next dependant, and so on. This continues
  12067. * so long as the dependants are object-like. If no dependants are object-
  12068. * like, then the cache is shared across all invocations.
  12069. *
  12070. * @see isObjectLike
  12071. *
  12072. * @param {Array} dependants Selector dependants.
  12073. *
  12074. * @return {Object} Cache object.
  12075. */
  12076. function getWeakMapCache( dependants ) {
  12077. var caches = rootCache,
  12078. isUniqueByDependants = true,
  12079. i, dependant, map, cache;
  12080. for ( i = 0; i < dependants.length; i++ ) {
  12081. dependant = dependants[ i ];
  12082. // Can only compose WeakMap from object-like key.
  12083. if ( ! isObjectLike( dependant ) ) {
  12084. isUniqueByDependants = false;
  12085. break;
  12086. }
  12087. // Does current segment of cache already have a WeakMap?
  12088. if ( caches.has( dependant ) ) {
  12089. // Traverse into nested WeakMap.
  12090. caches = caches.get( dependant );
  12091. } else {
  12092. // Create, set, and traverse into a new one.
  12093. map = new WeakMap();
  12094. caches.set( dependant, map );
  12095. caches = map;
  12096. }
  12097. }
  12098. // We use an arbitrary (but consistent) object as key for the last item
  12099. // in the WeakMap to serve as our running cache.
  12100. if ( ! caches.has( LEAF_KEY ) ) {
  12101. cache = createCache();
  12102. cache.isUniqueByDependants = isUniqueByDependants;
  12103. caches.set( LEAF_KEY, cache );
  12104. }
  12105. return caches.get( LEAF_KEY );
  12106. }
  12107. // Assign cache handler by availability of WeakMap
  12108. getCache = hasWeakMap ? getWeakMapCache : getRootCache;
  12109. /**
  12110. * Resets root memoization cache.
  12111. */
  12112. function clear() {
  12113. rootCache = hasWeakMap ? new WeakMap() : createCache();
  12114. }
  12115. // eslint-disable-next-line jsdoc/check-param-names
  12116. /**
  12117. * The augmented selector call, considering first whether dependants have
  12118. * changed before passing it to underlying memoize function.
  12119. *
  12120. * @param {Object} source Source object for derivation.
  12121. * @param {...*} extraArgs Additional arguments to pass to selector.
  12122. *
  12123. * @return {*} Selector result.
  12124. */
  12125. function callSelector( /* source, ...extraArgs */ ) {
  12126. var len = arguments.length,
  12127. cache, node, i, args, dependants;
  12128. // Create copy of arguments (avoid leaking deoptimization).
  12129. args = new Array( len );
  12130. for ( i = 0; i < len; i++ ) {
  12131. args[ i ] = arguments[ i ];
  12132. }
  12133. dependants = getDependants.apply( null, args );
  12134. cache = getCache( dependants );
  12135. // If not guaranteed uniqueness by dependants (primitive type or lack
  12136. // of WeakMap support), shallow compare against last dependants and, if
  12137. // references have changed, destroy cache to recalculate result.
  12138. if ( ! cache.isUniqueByDependants ) {
  12139. if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) {
  12140. cache.clear();
  12141. }
  12142. cache.lastDependants = dependants;
  12143. }
  12144. node = cache.head;
  12145. while ( node ) {
  12146. // Check whether node arguments match arguments
  12147. if ( ! isShallowEqual( node.args, args, 1 ) ) {
  12148. node = node.next;
  12149. continue;
  12150. }
  12151. // At this point we can assume we've found a match
  12152. // Surface matched node to head if not already
  12153. if ( node !== cache.head ) {
  12154. // Adjust siblings to point to each other.
  12155. node.prev.next = node.next;
  12156. if ( node.next ) {
  12157. node.next.prev = node.prev;
  12158. }
  12159. node.next = cache.head;
  12160. node.prev = null;
  12161. cache.head.prev = node;
  12162. cache.head = node;
  12163. }
  12164. // Return immediately
  12165. return node.val;
  12166. }
  12167. // No cached value found. Continue to insertion phase:
  12168. node = {
  12169. // Generate the result from original function
  12170. val: selector.apply( null, args ),
  12171. };
  12172. // Avoid including the source object in the cache.
  12173. args[ 0 ] = null;
  12174. node.args = args;
  12175. // Don't need to check whether node is already head, since it would
  12176. // have been returned above already if it was
  12177. // Shift existing head down list
  12178. if ( cache.head ) {
  12179. cache.head.prev = node;
  12180. node.next = cache.head;
  12181. }
  12182. cache.head = node;
  12183. return node.val;
  12184. }
  12185. callSelector.getDependants = getDependants;
  12186. callSelector.clear = clear;
  12187. clear();
  12188. return callSelector;
  12189. });
  12190. /***/ }),
  12191. /***/ "rl8x":
  12192. /***/ (function(module, exports) {
  12193. (function() { module.exports = window["wp"]["isShallowEqual"]; }());
  12194. /***/ }),
  12195. /***/ "rmEH":
  12196. /***/ (function(module, exports) {
  12197. (function() { module.exports = window["wp"]["htmlEntities"]; }());
  12198. /***/ }),
  12199. /***/ "wx14":
  12200. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12201. "use strict";
  12202. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; });
  12203. function _extends() {
  12204. _extends = Object.assign || function (target) {
  12205. for (var i = 1; i < arguments.length; i++) {
  12206. var source = arguments[i];
  12207. for (var key in source) {
  12208. if (Object.prototype.hasOwnProperty.call(source, key)) {
  12209. target[key] = source[key];
  12210. }
  12211. }
  12212. }
  12213. return target;
  12214. };
  12215. return _extends.apply(this, arguments);
  12216. }
  12217. /***/ }),
  12218. /***/ "xTGt":
  12219. /***/ (function(module, exports) {
  12220. (function() { module.exports = window["wp"]["blob"]; }());
  12221. /***/ })
  12222. /******/ });