blocks.js 525 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321
  1. /******/ (function() { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ 9756:
  4. /***/ (function(module) {
  5. /**
  6. * Memize options object.
  7. *
  8. * @typedef MemizeOptions
  9. *
  10. * @property {number} [maxSize] Maximum size of the cache.
  11. */
  12. /**
  13. * Internal cache entry.
  14. *
  15. * @typedef MemizeCacheNode
  16. *
  17. * @property {?MemizeCacheNode|undefined} [prev] Previous node.
  18. * @property {?MemizeCacheNode|undefined} [next] Next node.
  19. * @property {Array<*>} args Function arguments for cache
  20. * entry.
  21. * @property {*} val Function result.
  22. */
  23. /**
  24. * Properties of the enhanced function for controlling cache.
  25. *
  26. * @typedef MemizeMemoizedFunction
  27. *
  28. * @property {()=>void} clear Clear the cache.
  29. */
  30. /**
  31. * Accepts a function to be memoized, and returns a new memoized function, with
  32. * optional options.
  33. *
  34. * @template {Function} F
  35. *
  36. * @param {F} fn Function to memoize.
  37. * @param {MemizeOptions} [options] Options object.
  38. *
  39. * @return {F & MemizeMemoizedFunction} Memoized function.
  40. */
  41. function memize( fn, options ) {
  42. var size = 0;
  43. /** @type {?MemizeCacheNode|undefined} */
  44. var head;
  45. /** @type {?MemizeCacheNode|undefined} */
  46. var tail;
  47. options = options || {};
  48. function memoized( /* ...args */ ) {
  49. var node = head,
  50. len = arguments.length,
  51. args, i;
  52. searchCache: while ( node ) {
  53. // Perform a shallow equality test to confirm that whether the node
  54. // under test is a candidate for the arguments passed. Two arrays
  55. // are shallowly equal if their length matches and each entry is
  56. // strictly equal between the two sets. Avoid abstracting to a
  57. // function which could incur an arguments leaking deoptimization.
  58. // Check whether node arguments match arguments length
  59. if ( node.args.length !== arguments.length ) {
  60. node = node.next;
  61. continue;
  62. }
  63. // Check whether node arguments match arguments values
  64. for ( i = 0; i < len; i++ ) {
  65. if ( node.args[ i ] !== arguments[ i ] ) {
  66. node = node.next;
  67. continue searchCache;
  68. }
  69. }
  70. // At this point we can assume we've found a match
  71. // Surface matched node to head if not already
  72. if ( node !== head ) {
  73. // As tail, shift to previous. Must only shift if not also
  74. // head, since if both head and tail, there is no previous.
  75. if ( node === tail ) {
  76. tail = node.prev;
  77. }
  78. // Adjust siblings to point to each other. If node was tail,
  79. // this also handles new tail's empty `next` assignment.
  80. /** @type {MemizeCacheNode} */ ( node.prev ).next = node.next;
  81. if ( node.next ) {
  82. node.next.prev = node.prev;
  83. }
  84. node.next = head;
  85. node.prev = null;
  86. /** @type {MemizeCacheNode} */ ( head ).prev = node;
  87. head = node;
  88. }
  89. // Return immediately
  90. return node.val;
  91. }
  92. // No cached value found. Continue to insertion phase:
  93. // Create a copy of arguments (avoid leaking deoptimization)
  94. args = new Array( len );
  95. for ( i = 0; i < len; i++ ) {
  96. args[ i ] = arguments[ i ];
  97. }
  98. node = {
  99. args: args,
  100. // Generate the result from original function
  101. val: fn.apply( null, args ),
  102. };
  103. // Don't need to check whether node is already head, since it would
  104. // have been returned above already if it was
  105. // Shift existing head down list
  106. if ( head ) {
  107. head.prev = node;
  108. node.next = head;
  109. } else {
  110. // If no head, follows that there's no tail (at initial or reset)
  111. tail = node;
  112. }
  113. // Trim tail if we're reached max size and are pending cache insertion
  114. if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) {
  115. tail = /** @type {MemizeCacheNode} */ ( tail ).prev;
  116. /** @type {MemizeCacheNode} */ ( tail ).next = null;
  117. } else {
  118. size++;
  119. }
  120. head = node;
  121. return node.val;
  122. }
  123. memoized.clear = function() {
  124. head = null;
  125. tail = null;
  126. size = 0;
  127. };
  128. if ( false ) {}
  129. // Ignore reason: There's not a clear solution to create an intersection of
  130. // the function with additional properties, where the goal is to retain the
  131. // function signature of the incoming argument and add control properties
  132. // on the return value.
  133. // @ts-ignore
  134. return memoized;
  135. }
  136. module.exports = memize;
  137. /***/ }),
  138. /***/ 4793:
  139. /***/ (function(module) {
  140. var characterMap = {
  141. "À": "A",
  142. "Á": "A",
  143. "Â": "A",
  144. "Ã": "A",
  145. "Ä": "A",
  146. "Å": "A",
  147. "Ấ": "A",
  148. "Ắ": "A",
  149. "Ẳ": "A",
  150. "Ẵ": "A",
  151. "Ặ": "A",
  152. "Æ": "AE",
  153. "Ầ": "A",
  154. "Ằ": "A",
  155. "Ȃ": "A",
  156. "Ç": "C",
  157. "Ḉ": "C",
  158. "È": "E",
  159. "É": "E",
  160. "Ê": "E",
  161. "Ë": "E",
  162. "Ế": "E",
  163. "Ḗ": "E",
  164. "Ề": "E",
  165. "Ḕ": "E",
  166. "Ḝ": "E",
  167. "Ȇ": "E",
  168. "Ì": "I",
  169. "Í": "I",
  170. "Î": "I",
  171. "Ï": "I",
  172. "Ḯ": "I",
  173. "Ȋ": "I",
  174. "Ð": "D",
  175. "Ñ": "N",
  176. "Ò": "O",
  177. "Ó": "O",
  178. "Ô": "O",
  179. "Õ": "O",
  180. "Ö": "O",
  181. "Ø": "O",
  182. "Ố": "O",
  183. "Ṍ": "O",
  184. "Ṓ": "O",
  185. "Ȏ": "O",
  186. "Ù": "U",
  187. "Ú": "U",
  188. "Û": "U",
  189. "Ü": "U",
  190. "Ý": "Y",
  191. "à": "a",
  192. "á": "a",
  193. "â": "a",
  194. "ã": "a",
  195. "ä": "a",
  196. "å": "a",
  197. "ấ": "a",
  198. "ắ": "a",
  199. "ẳ": "a",
  200. "ẵ": "a",
  201. "ặ": "a",
  202. "æ": "ae",
  203. "ầ": "a",
  204. "ằ": "a",
  205. "ȃ": "a",
  206. "ç": "c",
  207. "ḉ": "c",
  208. "è": "e",
  209. "é": "e",
  210. "ê": "e",
  211. "ë": "e",
  212. "ế": "e",
  213. "ḗ": "e",
  214. "ề": "e",
  215. "ḕ": "e",
  216. "ḝ": "e",
  217. "ȇ": "e",
  218. "ì": "i",
  219. "í": "i",
  220. "î": "i",
  221. "ï": "i",
  222. "ḯ": "i",
  223. "ȋ": "i",
  224. "ð": "d",
  225. "ñ": "n",
  226. "ò": "o",
  227. "ó": "o",
  228. "ô": "o",
  229. "õ": "o",
  230. "ö": "o",
  231. "ø": "o",
  232. "ố": "o",
  233. "ṍ": "o",
  234. "ṓ": "o",
  235. "ȏ": "o",
  236. "ù": "u",
  237. "ú": "u",
  238. "û": "u",
  239. "ü": "u",
  240. "ý": "y",
  241. "ÿ": "y",
  242. "Ā": "A",
  243. "ā": "a",
  244. "Ă": "A",
  245. "ă": "a",
  246. "Ą": "A",
  247. "ą": "a",
  248. "Ć": "C",
  249. "ć": "c",
  250. "Ĉ": "C",
  251. "ĉ": "c",
  252. "Ċ": "C",
  253. "ċ": "c",
  254. "Č": "C",
  255. "č": "c",
  256. "C̆": "C",
  257. "c̆": "c",
  258. "Ď": "D",
  259. "ď": "d",
  260. "Đ": "D",
  261. "đ": "d",
  262. "Ē": "E",
  263. "ē": "e",
  264. "Ĕ": "E",
  265. "ĕ": "e",
  266. "Ė": "E",
  267. "ė": "e",
  268. "Ę": "E",
  269. "ę": "e",
  270. "Ě": "E",
  271. "ě": "e",
  272. "Ĝ": "G",
  273. "Ǵ": "G",
  274. "ĝ": "g",
  275. "ǵ": "g",
  276. "Ğ": "G",
  277. "ğ": "g",
  278. "Ġ": "G",
  279. "ġ": "g",
  280. "Ģ": "G",
  281. "ģ": "g",
  282. "Ĥ": "H",
  283. "ĥ": "h",
  284. "Ħ": "H",
  285. "ħ": "h",
  286. "Ḫ": "H",
  287. "ḫ": "h",
  288. "Ĩ": "I",
  289. "ĩ": "i",
  290. "Ī": "I",
  291. "ī": "i",
  292. "Ĭ": "I",
  293. "ĭ": "i",
  294. "Į": "I",
  295. "į": "i",
  296. "İ": "I",
  297. "ı": "i",
  298. "IJ": "IJ",
  299. "ij": "ij",
  300. "Ĵ": "J",
  301. "ĵ": "j",
  302. "Ķ": "K",
  303. "ķ": "k",
  304. "Ḱ": "K",
  305. "ḱ": "k",
  306. "K̆": "K",
  307. "k̆": "k",
  308. "Ĺ": "L",
  309. "ĺ": "l",
  310. "Ļ": "L",
  311. "ļ": "l",
  312. "Ľ": "L",
  313. "ľ": "l",
  314. "Ŀ": "L",
  315. "ŀ": "l",
  316. "Ł": "l",
  317. "ł": "l",
  318. "Ḿ": "M",
  319. "ḿ": "m",
  320. "M̆": "M",
  321. "m̆": "m",
  322. "Ń": "N",
  323. "ń": "n",
  324. "Ņ": "N",
  325. "ņ": "n",
  326. "Ň": "N",
  327. "ň": "n",
  328. "ʼn": "n",
  329. "N̆": "N",
  330. "n̆": "n",
  331. "Ō": "O",
  332. "ō": "o",
  333. "Ŏ": "O",
  334. "ŏ": "o",
  335. "Ő": "O",
  336. "ő": "o",
  337. "Œ": "OE",
  338. "œ": "oe",
  339. "P̆": "P",
  340. "p̆": "p",
  341. "Ŕ": "R",
  342. "ŕ": "r",
  343. "Ŗ": "R",
  344. "ŗ": "r",
  345. "Ř": "R",
  346. "ř": "r",
  347. "R̆": "R",
  348. "r̆": "r",
  349. "Ȓ": "R",
  350. "ȓ": "r",
  351. "Ś": "S",
  352. "ś": "s",
  353. "Ŝ": "S",
  354. "ŝ": "s",
  355. "Ş": "S",
  356. "Ș": "S",
  357. "ș": "s",
  358. "ş": "s",
  359. "Š": "S",
  360. "š": "s",
  361. "Ţ": "T",
  362. "ţ": "t",
  363. "ț": "t",
  364. "Ț": "T",
  365. "Ť": "T",
  366. "ť": "t",
  367. "Ŧ": "T",
  368. "ŧ": "t",
  369. "T̆": "T",
  370. "t̆": "t",
  371. "Ũ": "U",
  372. "ũ": "u",
  373. "Ū": "U",
  374. "ū": "u",
  375. "Ŭ": "U",
  376. "ŭ": "u",
  377. "Ů": "U",
  378. "ů": "u",
  379. "Ű": "U",
  380. "ű": "u",
  381. "Ų": "U",
  382. "ų": "u",
  383. "Ȗ": "U",
  384. "ȗ": "u",
  385. "V̆": "V",
  386. "v̆": "v",
  387. "Ŵ": "W",
  388. "ŵ": "w",
  389. "Ẃ": "W",
  390. "ẃ": "w",
  391. "X̆": "X",
  392. "x̆": "x",
  393. "Ŷ": "Y",
  394. "ŷ": "y",
  395. "Ÿ": "Y",
  396. "Y̆": "Y",
  397. "y̆": "y",
  398. "Ź": "Z",
  399. "ź": "z",
  400. "Ż": "Z",
  401. "ż": "z",
  402. "Ž": "Z",
  403. "ž": "z",
  404. "ſ": "s",
  405. "ƒ": "f",
  406. "Ơ": "O",
  407. "ơ": "o",
  408. "Ư": "U",
  409. "ư": "u",
  410. "Ǎ": "A",
  411. "ǎ": "a",
  412. "Ǐ": "I",
  413. "ǐ": "i",
  414. "Ǒ": "O",
  415. "ǒ": "o",
  416. "Ǔ": "U",
  417. "ǔ": "u",
  418. "Ǖ": "U",
  419. "ǖ": "u",
  420. "Ǘ": "U",
  421. "ǘ": "u",
  422. "Ǚ": "U",
  423. "ǚ": "u",
  424. "Ǜ": "U",
  425. "ǜ": "u",
  426. "Ứ": "U",
  427. "ứ": "u",
  428. "Ṹ": "U",
  429. "ṹ": "u",
  430. "Ǻ": "A",
  431. "ǻ": "a",
  432. "Ǽ": "AE",
  433. "ǽ": "ae",
  434. "Ǿ": "O",
  435. "ǿ": "o",
  436. "Þ": "TH",
  437. "þ": "th",
  438. "Ṕ": "P",
  439. "ṕ": "p",
  440. "Ṥ": "S",
  441. "ṥ": "s",
  442. "X́": "X",
  443. "x́": "x",
  444. "Ѓ": "Г",
  445. "ѓ": "г",
  446. "Ќ": "К",
  447. "ќ": "к",
  448. "A̋": "A",
  449. "a̋": "a",
  450. "E̋": "E",
  451. "e̋": "e",
  452. "I̋": "I",
  453. "i̋": "i",
  454. "Ǹ": "N",
  455. "ǹ": "n",
  456. "Ồ": "O",
  457. "ồ": "o",
  458. "Ṑ": "O",
  459. "ṑ": "o",
  460. "Ừ": "U",
  461. "ừ": "u",
  462. "Ẁ": "W",
  463. "ẁ": "w",
  464. "Ỳ": "Y",
  465. "ỳ": "y",
  466. "Ȁ": "A",
  467. "ȁ": "a",
  468. "Ȅ": "E",
  469. "ȅ": "e",
  470. "Ȉ": "I",
  471. "ȉ": "i",
  472. "Ȍ": "O",
  473. "ȍ": "o",
  474. "Ȑ": "R",
  475. "ȑ": "r",
  476. "Ȕ": "U",
  477. "ȕ": "u",
  478. "B̌": "B",
  479. "b̌": "b",
  480. "Č̣": "C",
  481. "č̣": "c",
  482. "Ê̌": "E",
  483. "ê̌": "e",
  484. "F̌": "F",
  485. "f̌": "f",
  486. "Ǧ": "G",
  487. "ǧ": "g",
  488. "Ȟ": "H",
  489. "ȟ": "h",
  490. "J̌": "J",
  491. "ǰ": "j",
  492. "Ǩ": "K",
  493. "ǩ": "k",
  494. "M̌": "M",
  495. "m̌": "m",
  496. "P̌": "P",
  497. "p̌": "p",
  498. "Q̌": "Q",
  499. "q̌": "q",
  500. "Ř̩": "R",
  501. "ř̩": "r",
  502. "Ṧ": "S",
  503. "ṧ": "s",
  504. "V̌": "V",
  505. "v̌": "v",
  506. "W̌": "W",
  507. "w̌": "w",
  508. "X̌": "X",
  509. "x̌": "x",
  510. "Y̌": "Y",
  511. "y̌": "y",
  512. "A̧": "A",
  513. "a̧": "a",
  514. "B̧": "B",
  515. "b̧": "b",
  516. "Ḑ": "D",
  517. "ḑ": "d",
  518. "Ȩ": "E",
  519. "ȩ": "e",
  520. "Ɛ̧": "E",
  521. "ɛ̧": "e",
  522. "Ḩ": "H",
  523. "ḩ": "h",
  524. "I̧": "I",
  525. "i̧": "i",
  526. "Ɨ̧": "I",
  527. "ɨ̧": "i",
  528. "M̧": "M",
  529. "m̧": "m",
  530. "O̧": "O",
  531. "o̧": "o",
  532. "Q̧": "Q",
  533. "q̧": "q",
  534. "U̧": "U",
  535. "u̧": "u",
  536. "X̧": "X",
  537. "x̧": "x",
  538. "Z̧": "Z",
  539. "z̧": "z",
  540. };
  541. var chars = Object.keys(characterMap).join('|');
  542. var allAccents = new RegExp(chars, 'g');
  543. var firstAccent = new RegExp(chars, '');
  544. function matcher(match) {
  545. return characterMap[match];
  546. }
  547. var removeAccents = function(string) {
  548. return string.replace(allAccents, matcher);
  549. };
  550. var hasAccents = function(string) {
  551. return !!string.match(firstAccent);
  552. };
  553. module.exports = removeAccents;
  554. module.exports.has = hasAccents;
  555. module.exports.remove = removeAccents;
  556. /***/ }),
  557. /***/ 7308:
  558. /***/ (function(module, exports, __webpack_require__) {
  559. var __WEBPACK_AMD_DEFINE_RESULT__;;/*! showdown v 1.9.1 - 02-11-2019 */
  560. (function(){
  561. /**
  562. * Created by Tivie on 13-07-2015.
  563. */
  564. function getDefaultOpts (simple) {
  565. 'use strict';
  566. var defaultOptions = {
  567. omitExtraWLInCodeBlocks: {
  568. defaultValue: false,
  569. describe: 'Omit the default extra whiteline added to code blocks',
  570. type: 'boolean'
  571. },
  572. noHeaderId: {
  573. defaultValue: false,
  574. describe: 'Turn on/off generated header id',
  575. type: 'boolean'
  576. },
  577. prefixHeaderId: {
  578. defaultValue: false,
  579. 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',
  580. type: 'string'
  581. },
  582. rawPrefixHeaderId: {
  583. defaultValue: false,
  584. 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)',
  585. type: 'boolean'
  586. },
  587. ghCompatibleHeaderId: {
  588. defaultValue: false,
  589. describe: 'Generate header ids compatible with github style (spaces are replaced with dashes, a bunch of non alphanumeric chars are removed)',
  590. type: 'boolean'
  591. },
  592. rawHeaderId: {
  593. defaultValue: false,
  594. describe: 'Remove only spaces, \' and " from generated header ids (including prefixes), replacing them with dashes (-). WARNING: This might result in malformed ids',
  595. type: 'boolean'
  596. },
  597. headerLevelStart: {
  598. defaultValue: false,
  599. describe: 'The header blocks level start',
  600. type: 'integer'
  601. },
  602. parseImgDimensions: {
  603. defaultValue: false,
  604. describe: 'Turn on/off image dimension parsing',
  605. type: 'boolean'
  606. },
  607. simplifiedAutoLink: {
  608. defaultValue: false,
  609. describe: 'Turn on/off GFM autolink style',
  610. type: 'boolean'
  611. },
  612. excludeTrailingPunctuationFromURLs: {
  613. defaultValue: false,
  614. describe: 'Excludes trailing punctuation from links generated with autoLinking',
  615. type: 'boolean'
  616. },
  617. literalMidWordUnderscores: {
  618. defaultValue: false,
  619. describe: 'Parse midword underscores as literal underscores',
  620. type: 'boolean'
  621. },
  622. literalMidWordAsterisks: {
  623. defaultValue: false,
  624. describe: 'Parse midword asterisks as literal asterisks',
  625. type: 'boolean'
  626. },
  627. strikethrough: {
  628. defaultValue: false,
  629. describe: 'Turn on/off strikethrough support',
  630. type: 'boolean'
  631. },
  632. tables: {
  633. defaultValue: false,
  634. describe: 'Turn on/off tables support',
  635. type: 'boolean'
  636. },
  637. tablesHeaderId: {
  638. defaultValue: false,
  639. describe: 'Add an id to table headers',
  640. type: 'boolean'
  641. },
  642. ghCodeBlocks: {
  643. defaultValue: true,
  644. describe: 'Turn on/off GFM fenced code blocks support',
  645. type: 'boolean'
  646. },
  647. tasklists: {
  648. defaultValue: false,
  649. describe: 'Turn on/off GFM tasklist support',
  650. type: 'boolean'
  651. },
  652. smoothLivePreview: {
  653. defaultValue: false,
  654. describe: 'Prevents weird effects in live previews due to incomplete input',
  655. type: 'boolean'
  656. },
  657. smartIndentationFix: {
  658. defaultValue: false,
  659. description: 'Tries to smartly fix indentation in es6 strings',
  660. type: 'boolean'
  661. },
  662. disableForced4SpacesIndentedSublists: {
  663. defaultValue: false,
  664. description: 'Disables the requirement of indenting nested sublists by 4 spaces',
  665. type: 'boolean'
  666. },
  667. simpleLineBreaks: {
  668. defaultValue: false,
  669. description: 'Parses simple line breaks as <br> (GFM Style)',
  670. type: 'boolean'
  671. },
  672. requireSpaceBeforeHeadingText: {
  673. defaultValue: false,
  674. description: 'Makes adding a space between `#` and the header text mandatory (GFM Style)',
  675. type: 'boolean'
  676. },
  677. ghMentions: {
  678. defaultValue: false,
  679. description: 'Enables github @mentions',
  680. type: 'boolean'
  681. },
  682. ghMentionsLink: {
  683. defaultValue: 'https://github.com/{u}',
  684. description: 'Changes the link generated by @mentions. Only applies if ghMentions option is enabled.',
  685. type: 'string'
  686. },
  687. encodeEmails: {
  688. defaultValue: true,
  689. description: 'Encode e-mail addresses through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities',
  690. type: 'boolean'
  691. },
  692. openLinksInNewWindow: {
  693. defaultValue: false,
  694. description: 'Open all links in new windows',
  695. type: 'boolean'
  696. },
  697. backslashEscapesHTMLTags: {
  698. defaultValue: false,
  699. description: 'Support for HTML Tag escaping. ex: \<div>foo\</div>',
  700. type: 'boolean'
  701. },
  702. emoji: {
  703. defaultValue: false,
  704. description: 'Enable emoji support. Ex: `this is a :smile: emoji`',
  705. type: 'boolean'
  706. },
  707. underline: {
  708. defaultValue: false,
  709. 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>`',
  710. type: 'boolean'
  711. },
  712. completeHTMLDocument: {
  713. defaultValue: false,
  714. description: 'Outputs a complete html document, including `<html>`, `<head>` and `<body>` tags',
  715. type: 'boolean'
  716. },
  717. metadata: {
  718. defaultValue: false,
  719. description: 'Enable support for document metadata (defined at the top of the document between `«««` and `»»»` or between `---` and `---`).',
  720. type: 'boolean'
  721. },
  722. splitAdjacentBlockquotes: {
  723. defaultValue: false,
  724. description: 'Split adjacent blockquote blocks',
  725. type: 'boolean'
  726. }
  727. };
  728. if (simple === false) {
  729. return JSON.parse(JSON.stringify(defaultOptions));
  730. }
  731. var ret = {};
  732. for (var opt in defaultOptions) {
  733. if (defaultOptions.hasOwnProperty(opt)) {
  734. ret[opt] = defaultOptions[opt].defaultValue;
  735. }
  736. }
  737. return ret;
  738. }
  739. function allOptionsOn () {
  740. 'use strict';
  741. var options = getDefaultOpts(true),
  742. ret = {};
  743. for (var opt in options) {
  744. if (options.hasOwnProperty(opt)) {
  745. ret[opt] = true;
  746. }
  747. }
  748. return ret;
  749. }
  750. /**
  751. * Created by Tivie on 06-01-2015.
  752. */
  753. // Private properties
  754. var showdown = {},
  755. parsers = {},
  756. extensions = {},
  757. globalOptions = getDefaultOpts(true),
  758. setFlavor = 'vanilla',
  759. flavor = {
  760. github: {
  761. omitExtraWLInCodeBlocks: true,
  762. simplifiedAutoLink: true,
  763. excludeTrailingPunctuationFromURLs: true,
  764. literalMidWordUnderscores: true,
  765. strikethrough: true,
  766. tables: true,
  767. tablesHeaderId: true,
  768. ghCodeBlocks: true,
  769. tasklists: true,
  770. disableForced4SpacesIndentedSublists: true,
  771. simpleLineBreaks: true,
  772. requireSpaceBeforeHeadingText: true,
  773. ghCompatibleHeaderId: true,
  774. ghMentions: true,
  775. backslashEscapesHTMLTags: true,
  776. emoji: true,
  777. splitAdjacentBlockquotes: true
  778. },
  779. original: {
  780. noHeaderId: true,
  781. ghCodeBlocks: false
  782. },
  783. ghost: {
  784. omitExtraWLInCodeBlocks: true,
  785. parseImgDimensions: true,
  786. simplifiedAutoLink: true,
  787. excludeTrailingPunctuationFromURLs: true,
  788. literalMidWordUnderscores: true,
  789. strikethrough: true,
  790. tables: true,
  791. tablesHeaderId: true,
  792. ghCodeBlocks: true,
  793. tasklists: true,
  794. smoothLivePreview: true,
  795. simpleLineBreaks: true,
  796. requireSpaceBeforeHeadingText: true,
  797. ghMentions: false,
  798. encodeEmails: true
  799. },
  800. vanilla: getDefaultOpts(true),
  801. allOn: allOptionsOn()
  802. };
  803. /**
  804. * helper namespace
  805. * @type {{}}
  806. */
  807. showdown.helper = {};
  808. /**
  809. * TODO LEGACY SUPPORT CODE
  810. * @type {{}}
  811. */
  812. showdown.extensions = {};
  813. /**
  814. * Set a global option
  815. * @static
  816. * @param {string} key
  817. * @param {*} value
  818. * @returns {showdown}
  819. */
  820. showdown.setOption = function (key, value) {
  821. 'use strict';
  822. globalOptions[key] = value;
  823. return this;
  824. };
  825. /**
  826. * Get a global option
  827. * @static
  828. * @param {string} key
  829. * @returns {*}
  830. */
  831. showdown.getOption = function (key) {
  832. 'use strict';
  833. return globalOptions[key];
  834. };
  835. /**
  836. * Get the global options
  837. * @static
  838. * @returns {{}}
  839. */
  840. showdown.getOptions = function () {
  841. 'use strict';
  842. return globalOptions;
  843. };
  844. /**
  845. * Reset global options to the default values
  846. * @static
  847. */
  848. showdown.resetOptions = function () {
  849. 'use strict';
  850. globalOptions = getDefaultOpts(true);
  851. };
  852. /**
  853. * Set the flavor showdown should use as default
  854. * @param {string} name
  855. */
  856. showdown.setFlavor = function (name) {
  857. 'use strict';
  858. if (!flavor.hasOwnProperty(name)) {
  859. throw Error(name + ' flavor was not found');
  860. }
  861. showdown.resetOptions();
  862. var preset = flavor[name];
  863. setFlavor = name;
  864. for (var option in preset) {
  865. if (preset.hasOwnProperty(option)) {
  866. globalOptions[option] = preset[option];
  867. }
  868. }
  869. };
  870. /**
  871. * Get the currently set flavor
  872. * @returns {string}
  873. */
  874. showdown.getFlavor = function () {
  875. 'use strict';
  876. return setFlavor;
  877. };
  878. /**
  879. * Get the options of a specified flavor. Returns undefined if the flavor was not found
  880. * @param {string} name Name of the flavor
  881. * @returns {{}|undefined}
  882. */
  883. showdown.getFlavorOptions = function (name) {
  884. 'use strict';
  885. if (flavor.hasOwnProperty(name)) {
  886. return flavor[name];
  887. }
  888. };
  889. /**
  890. * Get the default options
  891. * @static
  892. * @param {boolean} [simple=true]
  893. * @returns {{}}
  894. */
  895. showdown.getDefaultOptions = function (simple) {
  896. 'use strict';
  897. return getDefaultOpts(simple);
  898. };
  899. /**
  900. * Get or set a subParser
  901. *
  902. * subParser(name) - Get a registered subParser
  903. * subParser(name, func) - Register a subParser
  904. * @static
  905. * @param {string} name
  906. * @param {function} [func]
  907. * @returns {*}
  908. */
  909. showdown.subParser = function (name, func) {
  910. 'use strict';
  911. if (showdown.helper.isString(name)) {
  912. if (typeof func !== 'undefined') {
  913. parsers[name] = func;
  914. } else {
  915. if (parsers.hasOwnProperty(name)) {
  916. return parsers[name];
  917. } else {
  918. throw Error('SubParser named ' + name + ' not registered!');
  919. }
  920. }
  921. }
  922. };
  923. /**
  924. * Gets or registers an extension
  925. * @static
  926. * @param {string} name
  927. * @param {object|function=} ext
  928. * @returns {*}
  929. */
  930. showdown.extension = function (name, ext) {
  931. 'use strict';
  932. if (!showdown.helper.isString(name)) {
  933. throw Error('Extension \'name\' must be a string');
  934. }
  935. name = showdown.helper.stdExtName(name);
  936. // Getter
  937. if (showdown.helper.isUndefined(ext)) {
  938. if (!extensions.hasOwnProperty(name)) {
  939. throw Error('Extension named ' + name + ' is not registered!');
  940. }
  941. return extensions[name];
  942. // Setter
  943. } else {
  944. // Expand extension if it's wrapped in a function
  945. if (typeof ext === 'function') {
  946. ext = ext();
  947. }
  948. // Ensure extension is an array
  949. if (!showdown.helper.isArray(ext)) {
  950. ext = [ext];
  951. }
  952. var validExtension = validate(ext, name);
  953. if (validExtension.valid) {
  954. extensions[name] = ext;
  955. } else {
  956. throw Error(validExtension.error);
  957. }
  958. }
  959. };
  960. /**
  961. * Gets all extensions registered
  962. * @returns {{}}
  963. */
  964. showdown.getAllExtensions = function () {
  965. 'use strict';
  966. return extensions;
  967. };
  968. /**
  969. * Remove an extension
  970. * @param {string} name
  971. */
  972. showdown.removeExtension = function (name) {
  973. 'use strict';
  974. delete extensions[name];
  975. };
  976. /**
  977. * Removes all extensions
  978. */
  979. showdown.resetExtensions = function () {
  980. 'use strict';
  981. extensions = {};
  982. };
  983. /**
  984. * Validate extension
  985. * @param {array} extension
  986. * @param {string} name
  987. * @returns {{valid: boolean, error: string}}
  988. */
  989. function validate (extension, name) {
  990. 'use strict';
  991. var errMsg = (name) ? 'Error in ' + name + ' extension->' : 'Error in unnamed extension',
  992. ret = {
  993. valid: true,
  994. error: ''
  995. };
  996. if (!showdown.helper.isArray(extension)) {
  997. extension = [extension];
  998. }
  999. for (var i = 0; i < extension.length; ++i) {
  1000. var baseMsg = errMsg + ' sub-extension ' + i + ': ',
  1001. ext = extension[i];
  1002. if (typeof ext !== 'object') {
  1003. ret.valid = false;
  1004. ret.error = baseMsg + 'must be an object, but ' + typeof ext + ' given';
  1005. return ret;
  1006. }
  1007. if (!showdown.helper.isString(ext.type)) {
  1008. ret.valid = false;
  1009. ret.error = baseMsg + 'property "type" must be a string, but ' + typeof ext.type + ' given';
  1010. return ret;
  1011. }
  1012. var type = ext.type = ext.type.toLowerCase();
  1013. // normalize extension type
  1014. if (type === 'language') {
  1015. type = ext.type = 'lang';
  1016. }
  1017. if (type === 'html') {
  1018. type = ext.type = 'output';
  1019. }
  1020. if (type !== 'lang' && type !== 'output' && type !== 'listener') {
  1021. ret.valid = false;
  1022. ret.error = baseMsg + 'type ' + type + ' is not recognized. Valid values: "lang/language", "output/html" or "listener"';
  1023. return ret;
  1024. }
  1025. if (type === 'listener') {
  1026. if (showdown.helper.isUndefined(ext.listeners)) {
  1027. ret.valid = false;
  1028. ret.error = baseMsg + '. Extensions of type "listener" must have a property called "listeners"';
  1029. return ret;
  1030. }
  1031. } else {
  1032. if (showdown.helper.isUndefined(ext.filter) && showdown.helper.isUndefined(ext.regex)) {
  1033. ret.valid = false;
  1034. ret.error = baseMsg + type + ' extensions must define either a "regex" property or a "filter" method';
  1035. return ret;
  1036. }
  1037. }
  1038. if (ext.listeners) {
  1039. if (typeof ext.listeners !== 'object') {
  1040. ret.valid = false;
  1041. ret.error = baseMsg + '"listeners" property must be an object but ' + typeof ext.listeners + ' given';
  1042. return ret;
  1043. }
  1044. for (var ln in ext.listeners) {
  1045. if (ext.listeners.hasOwnProperty(ln)) {
  1046. if (typeof ext.listeners[ln] !== 'function') {
  1047. ret.valid = false;
  1048. ret.error = baseMsg + '"listeners" property must be an hash of [event name]: [callback]. listeners.' + ln +
  1049. ' must be a function but ' + typeof ext.listeners[ln] + ' given';
  1050. return ret;
  1051. }
  1052. }
  1053. }
  1054. }
  1055. if (ext.filter) {
  1056. if (typeof ext.filter !== 'function') {
  1057. ret.valid = false;
  1058. ret.error = baseMsg + '"filter" must be a function, but ' + typeof ext.filter + ' given';
  1059. return ret;
  1060. }
  1061. } else if (ext.regex) {
  1062. if (showdown.helper.isString(ext.regex)) {
  1063. ext.regex = new RegExp(ext.regex, 'g');
  1064. }
  1065. if (!(ext.regex instanceof RegExp)) {
  1066. ret.valid = false;
  1067. ret.error = baseMsg + '"regex" property must either be a string or a RegExp object, but ' + typeof ext.regex + ' given';
  1068. return ret;
  1069. }
  1070. if (showdown.helper.isUndefined(ext.replace)) {
  1071. ret.valid = false;
  1072. ret.error = baseMsg + '"regex" extensions must implement a replace string or function';
  1073. return ret;
  1074. }
  1075. }
  1076. }
  1077. return ret;
  1078. }
  1079. /**
  1080. * Validate extension
  1081. * @param {object} ext
  1082. * @returns {boolean}
  1083. */
  1084. showdown.validateExtension = function (ext) {
  1085. 'use strict';
  1086. var validateExtension = validate(ext, null);
  1087. if (!validateExtension.valid) {
  1088. console.warn(validateExtension.error);
  1089. return false;
  1090. }
  1091. return true;
  1092. };
  1093. /**
  1094. * showdownjs helper functions
  1095. */
  1096. if (!showdown.hasOwnProperty('helper')) {
  1097. showdown.helper = {};
  1098. }
  1099. /**
  1100. * Check if var is string
  1101. * @static
  1102. * @param {string} a
  1103. * @returns {boolean}
  1104. */
  1105. showdown.helper.isString = function (a) {
  1106. 'use strict';
  1107. return (typeof a === 'string' || a instanceof String);
  1108. };
  1109. /**
  1110. * Check if var is a function
  1111. * @static
  1112. * @param {*} a
  1113. * @returns {boolean}
  1114. */
  1115. showdown.helper.isFunction = function (a) {
  1116. 'use strict';
  1117. var getType = {};
  1118. return a && getType.toString.call(a) === '[object Function]';
  1119. };
  1120. /**
  1121. * isArray helper function
  1122. * @static
  1123. * @param {*} a
  1124. * @returns {boolean}
  1125. */
  1126. showdown.helper.isArray = function (a) {
  1127. 'use strict';
  1128. return Array.isArray(a);
  1129. };
  1130. /**
  1131. * Check if value is undefined
  1132. * @static
  1133. * @param {*} value The value to check.
  1134. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  1135. */
  1136. showdown.helper.isUndefined = function (value) {
  1137. 'use strict';
  1138. return typeof value === 'undefined';
  1139. };
  1140. /**
  1141. * ForEach helper function
  1142. * Iterates over Arrays and Objects (own properties only)
  1143. * @static
  1144. * @param {*} obj
  1145. * @param {function} callback Accepts 3 params: 1. value, 2. key, 3. the original array/object
  1146. */
  1147. showdown.helper.forEach = function (obj, callback) {
  1148. 'use strict';
  1149. // check if obj is defined
  1150. if (showdown.helper.isUndefined(obj)) {
  1151. throw new Error('obj param is required');
  1152. }
  1153. if (showdown.helper.isUndefined(callback)) {
  1154. throw new Error('callback param is required');
  1155. }
  1156. if (!showdown.helper.isFunction(callback)) {
  1157. throw new Error('callback param must be a function/closure');
  1158. }
  1159. if (typeof obj.forEach === 'function') {
  1160. obj.forEach(callback);
  1161. } else if (showdown.helper.isArray(obj)) {
  1162. for (var i = 0; i < obj.length; i++) {
  1163. callback(obj[i], i, obj);
  1164. }
  1165. } else if (typeof (obj) === 'object') {
  1166. for (var prop in obj) {
  1167. if (obj.hasOwnProperty(prop)) {
  1168. callback(obj[prop], prop, obj);
  1169. }
  1170. }
  1171. } else {
  1172. throw new Error('obj does not seem to be an array or an iterable object');
  1173. }
  1174. };
  1175. /**
  1176. * Standardidize extension name
  1177. * @static
  1178. * @param {string} s extension name
  1179. * @returns {string}
  1180. */
  1181. showdown.helper.stdExtName = function (s) {
  1182. 'use strict';
  1183. return s.replace(/[_?*+\/\\.^-]/g, '').replace(/\s/g, '').toLowerCase();
  1184. };
  1185. function escapeCharactersCallback (wholeMatch, m1) {
  1186. 'use strict';
  1187. var charCodeToEscape = m1.charCodeAt(0);
  1188. return '¨E' + charCodeToEscape + 'E';
  1189. }
  1190. /**
  1191. * Callback used to escape characters when passing through String.replace
  1192. * @static
  1193. * @param {string} wholeMatch
  1194. * @param {string} m1
  1195. * @returns {string}
  1196. */
  1197. showdown.helper.escapeCharactersCallback = escapeCharactersCallback;
  1198. /**
  1199. * Escape characters in a string
  1200. * @static
  1201. * @param {string} text
  1202. * @param {string} charsToEscape
  1203. * @param {boolean} afterBackslash
  1204. * @returns {XML|string|void|*}
  1205. */
  1206. showdown.helper.escapeCharacters = function (text, charsToEscape, afterBackslash) {
  1207. 'use strict';
  1208. // First we have to escape the escape characters so that
  1209. // we can build a character class out of them
  1210. var regexString = '([' + charsToEscape.replace(/([\[\]\\])/g, '\\$1') + '])';
  1211. if (afterBackslash) {
  1212. regexString = '\\\\' + regexString;
  1213. }
  1214. var regex = new RegExp(regexString, 'g');
  1215. text = text.replace(regex, escapeCharactersCallback);
  1216. return text;
  1217. };
  1218. /**
  1219. * Unescape HTML entities
  1220. * @param txt
  1221. * @returns {string}
  1222. */
  1223. showdown.helper.unescapeHTMLEntities = function (txt) {
  1224. 'use strict';
  1225. return txt
  1226. .replace(/&quot;/g, '"')
  1227. .replace(/&lt;/g, '<')
  1228. .replace(/&gt;/g, '>')
  1229. .replace(/&amp;/g, '&');
  1230. };
  1231. var rgxFindMatchPos = function (str, left, right, flags) {
  1232. 'use strict';
  1233. var f = flags || '',
  1234. g = f.indexOf('g') > -1,
  1235. x = new RegExp(left + '|' + right, 'g' + f.replace(/g/g, '')),
  1236. l = new RegExp(left, f.replace(/g/g, '')),
  1237. pos = [],
  1238. t, s, m, start, end;
  1239. do {
  1240. t = 0;
  1241. while ((m = x.exec(str))) {
  1242. if (l.test(m[0])) {
  1243. if (!(t++)) {
  1244. s = x.lastIndex;
  1245. start = s - m[0].length;
  1246. }
  1247. } else if (t) {
  1248. if (!--t) {
  1249. end = m.index + m[0].length;
  1250. var obj = {
  1251. left: {start: start, end: s},
  1252. match: {start: s, end: m.index},
  1253. right: {start: m.index, end: end},
  1254. wholeMatch: {start: start, end: end}
  1255. };
  1256. pos.push(obj);
  1257. if (!g) {
  1258. return pos;
  1259. }
  1260. }
  1261. }
  1262. }
  1263. } while (t && (x.lastIndex = s));
  1264. return pos;
  1265. };
  1266. /**
  1267. * matchRecursiveRegExp
  1268. *
  1269. * (c) 2007 Steven Levithan <stevenlevithan.com>
  1270. * MIT License
  1271. *
  1272. * Accepts a string to search, a left and right format delimiter
  1273. * as regex patterns, and optional regex flags. Returns an array
  1274. * of matches, allowing nested instances of left/right delimiters.
  1275. * Use the "g" flag to return all matches, otherwise only the
  1276. * first is returned. Be careful to ensure that the left and
  1277. * right format delimiters produce mutually exclusive matches.
  1278. * Backreferences are not supported within the right delimiter
  1279. * due to how it is internally combined with the left delimiter.
  1280. * When matching strings whose format delimiters are unbalanced
  1281. * to the left or right, the output is intentionally as a
  1282. * conventional regex library with recursion support would
  1283. * produce, e.g. "<<x>" and "<x>>" both produce ["x"] when using
  1284. * "<" and ">" as the delimiters (both strings contain a single,
  1285. * balanced instance of "<x>").
  1286. *
  1287. * examples:
  1288. * matchRecursiveRegExp("test", "\\(", "\\)")
  1289. * returns: []
  1290. * matchRecursiveRegExp("<t<<e>><s>>t<>", "<", ">", "g")
  1291. * returns: ["t<<e>><s>", ""]
  1292. * matchRecursiveRegExp("<div id=\"x\">test</div>", "<div\\b[^>]*>", "</div>", "gi")
  1293. * returns: ["test"]
  1294. */
  1295. showdown.helper.matchRecursiveRegExp = function (str, left, right, flags) {
  1296. 'use strict';
  1297. var matchPos = rgxFindMatchPos (str, left, right, flags),
  1298. results = [];
  1299. for (var i = 0; i < matchPos.length; ++i) {
  1300. results.push([
  1301. str.slice(matchPos[i].wholeMatch.start, matchPos[i].wholeMatch.end),
  1302. str.slice(matchPos[i].match.start, matchPos[i].match.end),
  1303. str.slice(matchPos[i].left.start, matchPos[i].left.end),
  1304. str.slice(matchPos[i].right.start, matchPos[i].right.end)
  1305. ]);
  1306. }
  1307. return results;
  1308. };
  1309. /**
  1310. *
  1311. * @param {string} str
  1312. * @param {string|function} replacement
  1313. * @param {string} left
  1314. * @param {string} right
  1315. * @param {string} flags
  1316. * @returns {string}
  1317. */
  1318. showdown.helper.replaceRecursiveRegExp = function (str, replacement, left, right, flags) {
  1319. 'use strict';
  1320. if (!showdown.helper.isFunction(replacement)) {
  1321. var repStr = replacement;
  1322. replacement = function () {
  1323. return repStr;
  1324. };
  1325. }
  1326. var matchPos = rgxFindMatchPos(str, left, right, flags),
  1327. finalStr = str,
  1328. lng = matchPos.length;
  1329. if (lng > 0) {
  1330. var bits = [];
  1331. if (matchPos[0].wholeMatch.start !== 0) {
  1332. bits.push(str.slice(0, matchPos[0].wholeMatch.start));
  1333. }
  1334. for (var i = 0; i < lng; ++i) {
  1335. bits.push(
  1336. replacement(
  1337. str.slice(matchPos[i].wholeMatch.start, matchPos[i].wholeMatch.end),
  1338. str.slice(matchPos[i].match.start, matchPos[i].match.end),
  1339. str.slice(matchPos[i].left.start, matchPos[i].left.end),
  1340. str.slice(matchPos[i].right.start, matchPos[i].right.end)
  1341. )
  1342. );
  1343. if (i < lng - 1) {
  1344. bits.push(str.slice(matchPos[i].wholeMatch.end, matchPos[i + 1].wholeMatch.start));
  1345. }
  1346. }
  1347. if (matchPos[lng - 1].wholeMatch.end < str.length) {
  1348. bits.push(str.slice(matchPos[lng - 1].wholeMatch.end));
  1349. }
  1350. finalStr = bits.join('');
  1351. }
  1352. return finalStr;
  1353. };
  1354. /**
  1355. * Returns the index within the passed String object of the first occurrence of the specified regex,
  1356. * starting the search at fromIndex. Returns -1 if the value is not found.
  1357. *
  1358. * @param {string} str string to search
  1359. * @param {RegExp} regex Regular expression to search
  1360. * @param {int} [fromIndex = 0] Index to start the search
  1361. * @returns {Number}
  1362. * @throws InvalidArgumentError
  1363. */
  1364. showdown.helper.regexIndexOf = function (str, regex, fromIndex) {
  1365. 'use strict';
  1366. if (!showdown.helper.isString(str)) {
  1367. throw 'InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string';
  1368. }
  1369. if (regex instanceof RegExp === false) {
  1370. throw 'InvalidArgumentError: second parameter of showdown.helper.regexIndexOf function must be an instance of RegExp';
  1371. }
  1372. var indexOf = str.substring(fromIndex || 0).search(regex);
  1373. return (indexOf >= 0) ? (indexOf + (fromIndex || 0)) : indexOf;
  1374. };
  1375. /**
  1376. * Splits the passed string object at the defined index, and returns an array composed of the two substrings
  1377. * @param {string} str string to split
  1378. * @param {int} index index to split string at
  1379. * @returns {[string,string]}
  1380. * @throws InvalidArgumentError
  1381. */
  1382. showdown.helper.splitAtIndex = function (str, index) {
  1383. 'use strict';
  1384. if (!showdown.helper.isString(str)) {
  1385. throw 'InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string';
  1386. }
  1387. return [str.substring(0, index), str.substring(index)];
  1388. };
  1389. /**
  1390. * Obfuscate an e-mail address through the use of Character Entities,
  1391. * transforming ASCII characters into their equivalent decimal or hex entities.
  1392. *
  1393. * Since it has a random component, subsequent calls to this function produce different results
  1394. *
  1395. * @param {string} mail
  1396. * @returns {string}
  1397. */
  1398. showdown.helper.encodeEmailAddress = function (mail) {
  1399. 'use strict';
  1400. var encode = [
  1401. function (ch) {
  1402. return '&#' + ch.charCodeAt(0) + ';';
  1403. },
  1404. function (ch) {
  1405. return '&#x' + ch.charCodeAt(0).toString(16) + ';';
  1406. },
  1407. function (ch) {
  1408. return ch;
  1409. }
  1410. ];
  1411. mail = mail.replace(/./g, function (ch) {
  1412. if (ch === '@') {
  1413. // this *must* be encoded. I insist.
  1414. ch = encode[Math.floor(Math.random() * 2)](ch);
  1415. } else {
  1416. var r = Math.random();
  1417. // roughly 10% raw, 45% hex, 45% dec
  1418. ch = (
  1419. r > 0.9 ? encode[2](ch) : r > 0.45 ? encode[1](ch) : encode[0](ch)
  1420. );
  1421. }
  1422. return ch;
  1423. });
  1424. return mail;
  1425. };
  1426. /**
  1427. *
  1428. * @param str
  1429. * @param targetLength
  1430. * @param padString
  1431. * @returns {string}
  1432. */
  1433. showdown.helper.padEnd = function padEnd (str, targetLength, padString) {
  1434. 'use strict';
  1435. /*jshint bitwise: false*/
  1436. // eslint-disable-next-line space-infix-ops
  1437. targetLength = targetLength>>0; //floor if number or convert non-number to 0;
  1438. /*jshint bitwise: true*/
  1439. padString = String(padString || ' ');
  1440. if (str.length > targetLength) {
  1441. return String(str);
  1442. } else {
  1443. targetLength = targetLength - str.length;
  1444. if (targetLength > padString.length) {
  1445. padString += padString.repeat(targetLength / padString.length); //append to original to ensure we are longer than needed
  1446. }
  1447. return String(str) + padString.slice(0,targetLength);
  1448. }
  1449. };
  1450. /**
  1451. * POLYFILLS
  1452. */
  1453. // use this instead of builtin is undefined for IE8 compatibility
  1454. if (typeof console === 'undefined') {
  1455. console = {
  1456. warn: function (msg) {
  1457. 'use strict';
  1458. alert(msg);
  1459. },
  1460. log: function (msg) {
  1461. 'use strict';
  1462. alert(msg);
  1463. },
  1464. error: function (msg) {
  1465. 'use strict';
  1466. throw msg;
  1467. }
  1468. };
  1469. }
  1470. /**
  1471. * Common regexes.
  1472. * We declare some common regexes to improve performance
  1473. */
  1474. showdown.helper.regexes = {
  1475. asteriskDashAndColon: /([*_:~])/g
  1476. };
  1477. /**
  1478. * EMOJIS LIST
  1479. */
  1480. showdown.helper.emojis = {
  1481. '+1':'\ud83d\udc4d',
  1482. '-1':'\ud83d\udc4e',
  1483. '100':'\ud83d\udcaf',
  1484. '1234':'\ud83d\udd22',
  1485. '1st_place_medal':'\ud83e\udd47',
  1486. '2nd_place_medal':'\ud83e\udd48',
  1487. '3rd_place_medal':'\ud83e\udd49',
  1488. '8ball':'\ud83c\udfb1',
  1489. 'a':'\ud83c\udd70\ufe0f',
  1490. 'ab':'\ud83c\udd8e',
  1491. 'abc':'\ud83d\udd24',
  1492. 'abcd':'\ud83d\udd21',
  1493. 'accept':'\ud83c\ude51',
  1494. 'aerial_tramway':'\ud83d\udea1',
  1495. 'airplane':'\u2708\ufe0f',
  1496. 'alarm_clock':'\u23f0',
  1497. 'alembic':'\u2697\ufe0f',
  1498. 'alien':'\ud83d\udc7d',
  1499. 'ambulance':'\ud83d\ude91',
  1500. 'amphora':'\ud83c\udffa',
  1501. 'anchor':'\u2693\ufe0f',
  1502. 'angel':'\ud83d\udc7c',
  1503. 'anger':'\ud83d\udca2',
  1504. 'angry':'\ud83d\ude20',
  1505. 'anguished':'\ud83d\ude27',
  1506. 'ant':'\ud83d\udc1c',
  1507. 'apple':'\ud83c\udf4e',
  1508. 'aquarius':'\u2652\ufe0f',
  1509. 'aries':'\u2648\ufe0f',
  1510. 'arrow_backward':'\u25c0\ufe0f',
  1511. 'arrow_double_down':'\u23ec',
  1512. 'arrow_double_up':'\u23eb',
  1513. 'arrow_down':'\u2b07\ufe0f',
  1514. 'arrow_down_small':'\ud83d\udd3d',
  1515. 'arrow_forward':'\u25b6\ufe0f',
  1516. 'arrow_heading_down':'\u2935\ufe0f',
  1517. 'arrow_heading_up':'\u2934\ufe0f',
  1518. 'arrow_left':'\u2b05\ufe0f',
  1519. 'arrow_lower_left':'\u2199\ufe0f',
  1520. 'arrow_lower_right':'\u2198\ufe0f',
  1521. 'arrow_right':'\u27a1\ufe0f',
  1522. 'arrow_right_hook':'\u21aa\ufe0f',
  1523. 'arrow_up':'\u2b06\ufe0f',
  1524. 'arrow_up_down':'\u2195\ufe0f',
  1525. 'arrow_up_small':'\ud83d\udd3c',
  1526. 'arrow_upper_left':'\u2196\ufe0f',
  1527. 'arrow_upper_right':'\u2197\ufe0f',
  1528. 'arrows_clockwise':'\ud83d\udd03',
  1529. 'arrows_counterclockwise':'\ud83d\udd04',
  1530. 'art':'\ud83c\udfa8',
  1531. 'articulated_lorry':'\ud83d\ude9b',
  1532. 'artificial_satellite':'\ud83d\udef0',
  1533. 'astonished':'\ud83d\ude32',
  1534. 'athletic_shoe':'\ud83d\udc5f',
  1535. 'atm':'\ud83c\udfe7',
  1536. 'atom_symbol':'\u269b\ufe0f',
  1537. 'avocado':'\ud83e\udd51',
  1538. 'b':'\ud83c\udd71\ufe0f',
  1539. 'baby':'\ud83d\udc76',
  1540. 'baby_bottle':'\ud83c\udf7c',
  1541. 'baby_chick':'\ud83d\udc24',
  1542. 'baby_symbol':'\ud83d\udebc',
  1543. 'back':'\ud83d\udd19',
  1544. 'bacon':'\ud83e\udd53',
  1545. 'badminton':'\ud83c\udff8',
  1546. 'baggage_claim':'\ud83d\udec4',
  1547. 'baguette_bread':'\ud83e\udd56',
  1548. 'balance_scale':'\u2696\ufe0f',
  1549. 'balloon':'\ud83c\udf88',
  1550. 'ballot_box':'\ud83d\uddf3',
  1551. 'ballot_box_with_check':'\u2611\ufe0f',
  1552. 'bamboo':'\ud83c\udf8d',
  1553. 'banana':'\ud83c\udf4c',
  1554. 'bangbang':'\u203c\ufe0f',
  1555. 'bank':'\ud83c\udfe6',
  1556. 'bar_chart':'\ud83d\udcca',
  1557. 'barber':'\ud83d\udc88',
  1558. 'baseball':'\u26be\ufe0f',
  1559. 'basketball':'\ud83c\udfc0',
  1560. 'basketball_man':'\u26f9\ufe0f',
  1561. 'basketball_woman':'\u26f9\ufe0f&zwj;\u2640\ufe0f',
  1562. 'bat':'\ud83e\udd87',
  1563. 'bath':'\ud83d\udec0',
  1564. 'bathtub':'\ud83d\udec1',
  1565. 'battery':'\ud83d\udd0b',
  1566. 'beach_umbrella':'\ud83c\udfd6',
  1567. 'bear':'\ud83d\udc3b',
  1568. 'bed':'\ud83d\udecf',
  1569. 'bee':'\ud83d\udc1d',
  1570. 'beer':'\ud83c\udf7a',
  1571. 'beers':'\ud83c\udf7b',
  1572. 'beetle':'\ud83d\udc1e',
  1573. 'beginner':'\ud83d\udd30',
  1574. 'bell':'\ud83d\udd14',
  1575. 'bellhop_bell':'\ud83d\udece',
  1576. 'bento':'\ud83c\udf71',
  1577. 'biking_man':'\ud83d\udeb4',
  1578. 'bike':'\ud83d\udeb2',
  1579. 'biking_woman':'\ud83d\udeb4&zwj;\u2640\ufe0f',
  1580. 'bikini':'\ud83d\udc59',
  1581. 'biohazard':'\u2623\ufe0f',
  1582. 'bird':'\ud83d\udc26',
  1583. 'birthday':'\ud83c\udf82',
  1584. 'black_circle':'\u26ab\ufe0f',
  1585. 'black_flag':'\ud83c\udff4',
  1586. 'black_heart':'\ud83d\udda4',
  1587. 'black_joker':'\ud83c\udccf',
  1588. 'black_large_square':'\u2b1b\ufe0f',
  1589. 'black_medium_small_square':'\u25fe\ufe0f',
  1590. 'black_medium_square':'\u25fc\ufe0f',
  1591. 'black_nib':'\u2712\ufe0f',
  1592. 'black_small_square':'\u25aa\ufe0f',
  1593. 'black_square_button':'\ud83d\udd32',
  1594. 'blonde_man':'\ud83d\udc71',
  1595. 'blonde_woman':'\ud83d\udc71&zwj;\u2640\ufe0f',
  1596. 'blossom':'\ud83c\udf3c',
  1597. 'blowfish':'\ud83d\udc21',
  1598. 'blue_book':'\ud83d\udcd8',
  1599. 'blue_car':'\ud83d\ude99',
  1600. 'blue_heart':'\ud83d\udc99',
  1601. 'blush':'\ud83d\ude0a',
  1602. 'boar':'\ud83d\udc17',
  1603. 'boat':'\u26f5\ufe0f',
  1604. 'bomb':'\ud83d\udca3',
  1605. 'book':'\ud83d\udcd6',
  1606. 'bookmark':'\ud83d\udd16',
  1607. 'bookmark_tabs':'\ud83d\udcd1',
  1608. 'books':'\ud83d\udcda',
  1609. 'boom':'\ud83d\udca5',
  1610. 'boot':'\ud83d\udc62',
  1611. 'bouquet':'\ud83d\udc90',
  1612. 'bowing_man':'\ud83d\ude47',
  1613. 'bow_and_arrow':'\ud83c\udff9',
  1614. 'bowing_woman':'\ud83d\ude47&zwj;\u2640\ufe0f',
  1615. 'bowling':'\ud83c\udfb3',
  1616. 'boxing_glove':'\ud83e\udd4a',
  1617. 'boy':'\ud83d\udc66',
  1618. 'bread':'\ud83c\udf5e',
  1619. 'bride_with_veil':'\ud83d\udc70',
  1620. 'bridge_at_night':'\ud83c\udf09',
  1621. 'briefcase':'\ud83d\udcbc',
  1622. 'broken_heart':'\ud83d\udc94',
  1623. 'bug':'\ud83d\udc1b',
  1624. 'building_construction':'\ud83c\udfd7',
  1625. 'bulb':'\ud83d\udca1',
  1626. 'bullettrain_front':'\ud83d\ude85',
  1627. 'bullettrain_side':'\ud83d\ude84',
  1628. 'burrito':'\ud83c\udf2f',
  1629. 'bus':'\ud83d\ude8c',
  1630. 'business_suit_levitating':'\ud83d\udd74',
  1631. 'busstop':'\ud83d\ude8f',
  1632. 'bust_in_silhouette':'\ud83d\udc64',
  1633. 'busts_in_silhouette':'\ud83d\udc65',
  1634. 'butterfly':'\ud83e\udd8b',
  1635. 'cactus':'\ud83c\udf35',
  1636. 'cake':'\ud83c\udf70',
  1637. 'calendar':'\ud83d\udcc6',
  1638. 'call_me_hand':'\ud83e\udd19',
  1639. 'calling':'\ud83d\udcf2',
  1640. 'camel':'\ud83d\udc2b',
  1641. 'camera':'\ud83d\udcf7',
  1642. 'camera_flash':'\ud83d\udcf8',
  1643. 'camping':'\ud83c\udfd5',
  1644. 'cancer':'\u264b\ufe0f',
  1645. 'candle':'\ud83d\udd6f',
  1646. 'candy':'\ud83c\udf6c',
  1647. 'canoe':'\ud83d\udef6',
  1648. 'capital_abcd':'\ud83d\udd20',
  1649. 'capricorn':'\u2651\ufe0f',
  1650. 'car':'\ud83d\ude97',
  1651. 'card_file_box':'\ud83d\uddc3',
  1652. 'card_index':'\ud83d\udcc7',
  1653. 'card_index_dividers':'\ud83d\uddc2',
  1654. 'carousel_horse':'\ud83c\udfa0',
  1655. 'carrot':'\ud83e\udd55',
  1656. 'cat':'\ud83d\udc31',
  1657. 'cat2':'\ud83d\udc08',
  1658. 'cd':'\ud83d\udcbf',
  1659. 'chains':'\u26d3',
  1660. 'champagne':'\ud83c\udf7e',
  1661. 'chart':'\ud83d\udcb9',
  1662. 'chart_with_downwards_trend':'\ud83d\udcc9',
  1663. 'chart_with_upwards_trend':'\ud83d\udcc8',
  1664. 'checkered_flag':'\ud83c\udfc1',
  1665. 'cheese':'\ud83e\uddc0',
  1666. 'cherries':'\ud83c\udf52',
  1667. 'cherry_blossom':'\ud83c\udf38',
  1668. 'chestnut':'\ud83c\udf30',
  1669. 'chicken':'\ud83d\udc14',
  1670. 'children_crossing':'\ud83d\udeb8',
  1671. 'chipmunk':'\ud83d\udc3f',
  1672. 'chocolate_bar':'\ud83c\udf6b',
  1673. 'christmas_tree':'\ud83c\udf84',
  1674. 'church':'\u26ea\ufe0f',
  1675. 'cinema':'\ud83c\udfa6',
  1676. 'circus_tent':'\ud83c\udfaa',
  1677. 'city_sunrise':'\ud83c\udf07',
  1678. 'city_sunset':'\ud83c\udf06',
  1679. 'cityscape':'\ud83c\udfd9',
  1680. 'cl':'\ud83c\udd91',
  1681. 'clamp':'\ud83d\udddc',
  1682. 'clap':'\ud83d\udc4f',
  1683. 'clapper':'\ud83c\udfac',
  1684. 'classical_building':'\ud83c\udfdb',
  1685. 'clinking_glasses':'\ud83e\udd42',
  1686. 'clipboard':'\ud83d\udccb',
  1687. 'clock1':'\ud83d\udd50',
  1688. 'clock10':'\ud83d\udd59',
  1689. 'clock1030':'\ud83d\udd65',
  1690. 'clock11':'\ud83d\udd5a',
  1691. 'clock1130':'\ud83d\udd66',
  1692. 'clock12':'\ud83d\udd5b',
  1693. 'clock1230':'\ud83d\udd67',
  1694. 'clock130':'\ud83d\udd5c',
  1695. 'clock2':'\ud83d\udd51',
  1696. 'clock230':'\ud83d\udd5d',
  1697. 'clock3':'\ud83d\udd52',
  1698. 'clock330':'\ud83d\udd5e',
  1699. 'clock4':'\ud83d\udd53',
  1700. 'clock430':'\ud83d\udd5f',
  1701. 'clock5':'\ud83d\udd54',
  1702. 'clock530':'\ud83d\udd60',
  1703. 'clock6':'\ud83d\udd55',
  1704. 'clock630':'\ud83d\udd61',
  1705. 'clock7':'\ud83d\udd56',
  1706. 'clock730':'\ud83d\udd62',
  1707. 'clock8':'\ud83d\udd57',
  1708. 'clock830':'\ud83d\udd63',
  1709. 'clock9':'\ud83d\udd58',
  1710. 'clock930':'\ud83d\udd64',
  1711. 'closed_book':'\ud83d\udcd5',
  1712. 'closed_lock_with_key':'\ud83d\udd10',
  1713. 'closed_umbrella':'\ud83c\udf02',
  1714. 'cloud':'\u2601\ufe0f',
  1715. 'cloud_with_lightning':'\ud83c\udf29',
  1716. 'cloud_with_lightning_and_rain':'\u26c8',
  1717. 'cloud_with_rain':'\ud83c\udf27',
  1718. 'cloud_with_snow':'\ud83c\udf28',
  1719. 'clown_face':'\ud83e\udd21',
  1720. 'clubs':'\u2663\ufe0f',
  1721. 'cocktail':'\ud83c\udf78',
  1722. 'coffee':'\u2615\ufe0f',
  1723. 'coffin':'\u26b0\ufe0f',
  1724. 'cold_sweat':'\ud83d\ude30',
  1725. 'comet':'\u2604\ufe0f',
  1726. 'computer':'\ud83d\udcbb',
  1727. 'computer_mouse':'\ud83d\uddb1',
  1728. 'confetti_ball':'\ud83c\udf8a',
  1729. 'confounded':'\ud83d\ude16',
  1730. 'confused':'\ud83d\ude15',
  1731. 'congratulations':'\u3297\ufe0f',
  1732. 'construction':'\ud83d\udea7',
  1733. 'construction_worker_man':'\ud83d\udc77',
  1734. 'construction_worker_woman':'\ud83d\udc77&zwj;\u2640\ufe0f',
  1735. 'control_knobs':'\ud83c\udf9b',
  1736. 'convenience_store':'\ud83c\udfea',
  1737. 'cookie':'\ud83c\udf6a',
  1738. 'cool':'\ud83c\udd92',
  1739. 'policeman':'\ud83d\udc6e',
  1740. 'copyright':'\u00a9\ufe0f',
  1741. 'corn':'\ud83c\udf3d',
  1742. 'couch_and_lamp':'\ud83d\udecb',
  1743. 'couple':'\ud83d\udc6b',
  1744. 'couple_with_heart_woman_man':'\ud83d\udc91',
  1745. 'couple_with_heart_man_man':'\ud83d\udc68&zwj;\u2764\ufe0f&zwj;\ud83d\udc68',
  1746. 'couple_with_heart_woman_woman':'\ud83d\udc69&zwj;\u2764\ufe0f&zwj;\ud83d\udc69',
  1747. 'couplekiss_man_man':'\ud83d\udc68&zwj;\u2764\ufe0f&zwj;\ud83d\udc8b&zwj;\ud83d\udc68',
  1748. 'couplekiss_man_woman':'\ud83d\udc8f',
  1749. 'couplekiss_woman_woman':'\ud83d\udc69&zwj;\u2764\ufe0f&zwj;\ud83d\udc8b&zwj;\ud83d\udc69',
  1750. 'cow':'\ud83d\udc2e',
  1751. 'cow2':'\ud83d\udc04',
  1752. 'cowboy_hat_face':'\ud83e\udd20',
  1753. 'crab':'\ud83e\udd80',
  1754. 'crayon':'\ud83d\udd8d',
  1755. 'credit_card':'\ud83d\udcb3',
  1756. 'crescent_moon':'\ud83c\udf19',
  1757. 'cricket':'\ud83c\udfcf',
  1758. 'crocodile':'\ud83d\udc0a',
  1759. 'croissant':'\ud83e\udd50',
  1760. 'crossed_fingers':'\ud83e\udd1e',
  1761. 'crossed_flags':'\ud83c\udf8c',
  1762. 'crossed_swords':'\u2694\ufe0f',
  1763. 'crown':'\ud83d\udc51',
  1764. 'cry':'\ud83d\ude22',
  1765. 'crying_cat_face':'\ud83d\ude3f',
  1766. 'crystal_ball':'\ud83d\udd2e',
  1767. 'cucumber':'\ud83e\udd52',
  1768. 'cupid':'\ud83d\udc98',
  1769. 'curly_loop':'\u27b0',
  1770. 'currency_exchange':'\ud83d\udcb1',
  1771. 'curry':'\ud83c\udf5b',
  1772. 'custard':'\ud83c\udf6e',
  1773. 'customs':'\ud83d\udec3',
  1774. 'cyclone':'\ud83c\udf00',
  1775. 'dagger':'\ud83d\udde1',
  1776. 'dancer':'\ud83d\udc83',
  1777. 'dancing_women':'\ud83d\udc6f',
  1778. 'dancing_men':'\ud83d\udc6f&zwj;\u2642\ufe0f',
  1779. 'dango':'\ud83c\udf61',
  1780. 'dark_sunglasses':'\ud83d\udd76',
  1781. 'dart':'\ud83c\udfaf',
  1782. 'dash':'\ud83d\udca8',
  1783. 'date':'\ud83d\udcc5',
  1784. 'deciduous_tree':'\ud83c\udf33',
  1785. 'deer':'\ud83e\udd8c',
  1786. 'department_store':'\ud83c\udfec',
  1787. 'derelict_house':'\ud83c\udfda',
  1788. 'desert':'\ud83c\udfdc',
  1789. 'desert_island':'\ud83c\udfdd',
  1790. 'desktop_computer':'\ud83d\udda5',
  1791. 'male_detective':'\ud83d\udd75\ufe0f',
  1792. 'diamond_shape_with_a_dot_inside':'\ud83d\udca0',
  1793. 'diamonds':'\u2666\ufe0f',
  1794. 'disappointed':'\ud83d\ude1e',
  1795. 'disappointed_relieved':'\ud83d\ude25',
  1796. 'dizzy':'\ud83d\udcab',
  1797. 'dizzy_face':'\ud83d\ude35',
  1798. 'do_not_litter':'\ud83d\udeaf',
  1799. 'dog':'\ud83d\udc36',
  1800. 'dog2':'\ud83d\udc15',
  1801. 'dollar':'\ud83d\udcb5',
  1802. 'dolls':'\ud83c\udf8e',
  1803. 'dolphin':'\ud83d\udc2c',
  1804. 'door':'\ud83d\udeaa',
  1805. 'doughnut':'\ud83c\udf69',
  1806. 'dove':'\ud83d\udd4a',
  1807. 'dragon':'\ud83d\udc09',
  1808. 'dragon_face':'\ud83d\udc32',
  1809. 'dress':'\ud83d\udc57',
  1810. 'dromedary_camel':'\ud83d\udc2a',
  1811. 'drooling_face':'\ud83e\udd24',
  1812. 'droplet':'\ud83d\udca7',
  1813. 'drum':'\ud83e\udd41',
  1814. 'duck':'\ud83e\udd86',
  1815. 'dvd':'\ud83d\udcc0',
  1816. 'e-mail':'\ud83d\udce7',
  1817. 'eagle':'\ud83e\udd85',
  1818. 'ear':'\ud83d\udc42',
  1819. 'ear_of_rice':'\ud83c\udf3e',
  1820. 'earth_africa':'\ud83c\udf0d',
  1821. 'earth_americas':'\ud83c\udf0e',
  1822. 'earth_asia':'\ud83c\udf0f',
  1823. 'egg':'\ud83e\udd5a',
  1824. 'eggplant':'\ud83c\udf46',
  1825. 'eight_pointed_black_star':'\u2734\ufe0f',
  1826. 'eight_spoked_asterisk':'\u2733\ufe0f',
  1827. 'electric_plug':'\ud83d\udd0c',
  1828. 'elephant':'\ud83d\udc18',
  1829. 'email':'\u2709\ufe0f',
  1830. 'end':'\ud83d\udd1a',
  1831. 'envelope_with_arrow':'\ud83d\udce9',
  1832. 'euro':'\ud83d\udcb6',
  1833. 'european_castle':'\ud83c\udff0',
  1834. 'european_post_office':'\ud83c\udfe4',
  1835. 'evergreen_tree':'\ud83c\udf32',
  1836. 'exclamation':'\u2757\ufe0f',
  1837. 'expressionless':'\ud83d\ude11',
  1838. 'eye':'\ud83d\udc41',
  1839. 'eye_speech_bubble':'\ud83d\udc41&zwj;\ud83d\udde8',
  1840. 'eyeglasses':'\ud83d\udc53',
  1841. 'eyes':'\ud83d\udc40',
  1842. 'face_with_head_bandage':'\ud83e\udd15',
  1843. 'face_with_thermometer':'\ud83e\udd12',
  1844. 'fist_oncoming':'\ud83d\udc4a',
  1845. 'factory':'\ud83c\udfed',
  1846. 'fallen_leaf':'\ud83c\udf42',
  1847. 'family_man_woman_boy':'\ud83d\udc6a',
  1848. 'family_man_boy':'\ud83d\udc68&zwj;\ud83d\udc66',
  1849. 'family_man_boy_boy':'\ud83d\udc68&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  1850. 'family_man_girl':'\ud83d\udc68&zwj;\ud83d\udc67',
  1851. 'family_man_girl_boy':'\ud83d\udc68&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  1852. 'family_man_girl_girl':'\ud83d\udc68&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  1853. 'family_man_man_boy':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc66',
  1854. 'family_man_man_boy_boy':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  1855. 'family_man_man_girl':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc67',
  1856. 'family_man_man_girl_boy':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  1857. 'family_man_man_girl_girl':'\ud83d\udc68&zwj;\ud83d\udc68&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  1858. 'family_man_woman_boy_boy':'\ud83d\udc68&zwj;\ud83d\udc69&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  1859. 'family_man_woman_girl':'\ud83d\udc68&zwj;\ud83d\udc69&zwj;\ud83d\udc67',
  1860. 'family_man_woman_girl_boy':'\ud83d\udc68&zwj;\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  1861. 'family_man_woman_girl_girl':'\ud83d\udc68&zwj;\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  1862. 'family_woman_boy':'\ud83d\udc69&zwj;\ud83d\udc66',
  1863. 'family_woman_boy_boy':'\ud83d\udc69&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  1864. 'family_woman_girl':'\ud83d\udc69&zwj;\ud83d\udc67',
  1865. 'family_woman_girl_boy':'\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  1866. 'family_woman_girl_girl':'\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  1867. 'family_woman_woman_boy':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc66',
  1868. 'family_woman_woman_boy_boy':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc66&zwj;\ud83d\udc66',
  1869. 'family_woman_woman_girl':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc67',
  1870. 'family_woman_woman_girl_boy':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc66',
  1871. 'family_woman_woman_girl_girl':'\ud83d\udc69&zwj;\ud83d\udc69&zwj;\ud83d\udc67&zwj;\ud83d\udc67',
  1872. 'fast_forward':'\u23e9',
  1873. 'fax':'\ud83d\udce0',
  1874. 'fearful':'\ud83d\ude28',
  1875. 'feet':'\ud83d\udc3e',
  1876. 'female_detective':'\ud83d\udd75\ufe0f&zwj;\u2640\ufe0f',
  1877. 'ferris_wheel':'\ud83c\udfa1',
  1878. 'ferry':'\u26f4',
  1879. 'field_hockey':'\ud83c\udfd1',
  1880. 'file_cabinet':'\ud83d\uddc4',
  1881. 'file_folder':'\ud83d\udcc1',
  1882. 'film_projector':'\ud83d\udcfd',
  1883. 'film_strip':'\ud83c\udf9e',
  1884. 'fire':'\ud83d\udd25',
  1885. 'fire_engine':'\ud83d\ude92',
  1886. 'fireworks':'\ud83c\udf86',
  1887. 'first_quarter_moon':'\ud83c\udf13',
  1888. 'first_quarter_moon_with_face':'\ud83c\udf1b',
  1889. 'fish':'\ud83d\udc1f',
  1890. 'fish_cake':'\ud83c\udf65',
  1891. 'fishing_pole_and_fish':'\ud83c\udfa3',
  1892. 'fist_raised':'\u270a',
  1893. 'fist_left':'\ud83e\udd1b',
  1894. 'fist_right':'\ud83e\udd1c',
  1895. 'flags':'\ud83c\udf8f',
  1896. 'flashlight':'\ud83d\udd26',
  1897. 'fleur_de_lis':'\u269c\ufe0f',
  1898. 'flight_arrival':'\ud83d\udeec',
  1899. 'flight_departure':'\ud83d\udeeb',
  1900. 'floppy_disk':'\ud83d\udcbe',
  1901. 'flower_playing_cards':'\ud83c\udfb4',
  1902. 'flushed':'\ud83d\ude33',
  1903. 'fog':'\ud83c\udf2b',
  1904. 'foggy':'\ud83c\udf01',
  1905. 'football':'\ud83c\udfc8',
  1906. 'footprints':'\ud83d\udc63',
  1907. 'fork_and_knife':'\ud83c\udf74',
  1908. 'fountain':'\u26f2\ufe0f',
  1909. 'fountain_pen':'\ud83d\udd8b',
  1910. 'four_leaf_clover':'\ud83c\udf40',
  1911. 'fox_face':'\ud83e\udd8a',
  1912. 'framed_picture':'\ud83d\uddbc',
  1913. 'free':'\ud83c\udd93',
  1914. 'fried_egg':'\ud83c\udf73',
  1915. 'fried_shrimp':'\ud83c\udf64',
  1916. 'fries':'\ud83c\udf5f',
  1917. 'frog':'\ud83d\udc38',
  1918. 'frowning':'\ud83d\ude26',
  1919. 'frowning_face':'\u2639\ufe0f',
  1920. 'frowning_man':'\ud83d\ude4d&zwj;\u2642\ufe0f',
  1921. 'frowning_woman':'\ud83d\ude4d',
  1922. 'middle_finger':'\ud83d\udd95',
  1923. 'fuelpump':'\u26fd\ufe0f',
  1924. 'full_moon':'\ud83c\udf15',
  1925. 'full_moon_with_face':'\ud83c\udf1d',
  1926. 'funeral_urn':'\u26b1\ufe0f',
  1927. 'game_die':'\ud83c\udfb2',
  1928. 'gear':'\u2699\ufe0f',
  1929. 'gem':'\ud83d\udc8e',
  1930. 'gemini':'\u264a\ufe0f',
  1931. 'ghost':'\ud83d\udc7b',
  1932. 'gift':'\ud83c\udf81',
  1933. 'gift_heart':'\ud83d\udc9d',
  1934. 'girl':'\ud83d\udc67',
  1935. 'globe_with_meridians':'\ud83c\udf10',
  1936. 'goal_net':'\ud83e\udd45',
  1937. 'goat':'\ud83d\udc10',
  1938. 'golf':'\u26f3\ufe0f',
  1939. 'golfing_man':'\ud83c\udfcc\ufe0f',
  1940. 'golfing_woman':'\ud83c\udfcc\ufe0f&zwj;\u2640\ufe0f',
  1941. 'gorilla':'\ud83e\udd8d',
  1942. 'grapes':'\ud83c\udf47',
  1943. 'green_apple':'\ud83c\udf4f',
  1944. 'green_book':'\ud83d\udcd7',
  1945. 'green_heart':'\ud83d\udc9a',
  1946. 'green_salad':'\ud83e\udd57',
  1947. 'grey_exclamation':'\u2755',
  1948. 'grey_question':'\u2754',
  1949. 'grimacing':'\ud83d\ude2c',
  1950. 'grin':'\ud83d\ude01',
  1951. 'grinning':'\ud83d\ude00',
  1952. 'guardsman':'\ud83d\udc82',
  1953. 'guardswoman':'\ud83d\udc82&zwj;\u2640\ufe0f',
  1954. 'guitar':'\ud83c\udfb8',
  1955. 'gun':'\ud83d\udd2b',
  1956. 'haircut_woman':'\ud83d\udc87',
  1957. 'haircut_man':'\ud83d\udc87&zwj;\u2642\ufe0f',
  1958. 'hamburger':'\ud83c\udf54',
  1959. 'hammer':'\ud83d\udd28',
  1960. 'hammer_and_pick':'\u2692',
  1961. 'hammer_and_wrench':'\ud83d\udee0',
  1962. 'hamster':'\ud83d\udc39',
  1963. 'hand':'\u270b',
  1964. 'handbag':'\ud83d\udc5c',
  1965. 'handshake':'\ud83e\udd1d',
  1966. 'hankey':'\ud83d\udca9',
  1967. 'hatched_chick':'\ud83d\udc25',
  1968. 'hatching_chick':'\ud83d\udc23',
  1969. 'headphones':'\ud83c\udfa7',
  1970. 'hear_no_evil':'\ud83d\ude49',
  1971. 'heart':'\u2764\ufe0f',
  1972. 'heart_decoration':'\ud83d\udc9f',
  1973. 'heart_eyes':'\ud83d\ude0d',
  1974. 'heart_eyes_cat':'\ud83d\ude3b',
  1975. 'heartbeat':'\ud83d\udc93',
  1976. 'heartpulse':'\ud83d\udc97',
  1977. 'hearts':'\u2665\ufe0f',
  1978. 'heavy_check_mark':'\u2714\ufe0f',
  1979. 'heavy_division_sign':'\u2797',
  1980. 'heavy_dollar_sign':'\ud83d\udcb2',
  1981. 'heavy_heart_exclamation':'\u2763\ufe0f',
  1982. 'heavy_minus_sign':'\u2796',
  1983. 'heavy_multiplication_x':'\u2716\ufe0f',
  1984. 'heavy_plus_sign':'\u2795',
  1985. 'helicopter':'\ud83d\ude81',
  1986. 'herb':'\ud83c\udf3f',
  1987. 'hibiscus':'\ud83c\udf3a',
  1988. 'high_brightness':'\ud83d\udd06',
  1989. 'high_heel':'\ud83d\udc60',
  1990. 'hocho':'\ud83d\udd2a',
  1991. 'hole':'\ud83d\udd73',
  1992. 'honey_pot':'\ud83c\udf6f',
  1993. 'horse':'\ud83d\udc34',
  1994. 'horse_racing':'\ud83c\udfc7',
  1995. 'hospital':'\ud83c\udfe5',
  1996. 'hot_pepper':'\ud83c\udf36',
  1997. 'hotdog':'\ud83c\udf2d',
  1998. 'hotel':'\ud83c\udfe8',
  1999. 'hotsprings':'\u2668\ufe0f',
  2000. 'hourglass':'\u231b\ufe0f',
  2001. 'hourglass_flowing_sand':'\u23f3',
  2002. 'house':'\ud83c\udfe0',
  2003. 'house_with_garden':'\ud83c\udfe1',
  2004. 'houses':'\ud83c\udfd8',
  2005. 'hugs':'\ud83e\udd17',
  2006. 'hushed':'\ud83d\ude2f',
  2007. 'ice_cream':'\ud83c\udf68',
  2008. 'ice_hockey':'\ud83c\udfd2',
  2009. 'ice_skate':'\u26f8',
  2010. 'icecream':'\ud83c\udf66',
  2011. 'id':'\ud83c\udd94',
  2012. 'ideograph_advantage':'\ud83c\ude50',
  2013. 'imp':'\ud83d\udc7f',
  2014. 'inbox_tray':'\ud83d\udce5',
  2015. 'incoming_envelope':'\ud83d\udce8',
  2016. 'tipping_hand_woman':'\ud83d\udc81',
  2017. 'information_source':'\u2139\ufe0f',
  2018. 'innocent':'\ud83d\ude07',
  2019. 'interrobang':'\u2049\ufe0f',
  2020. 'iphone':'\ud83d\udcf1',
  2021. 'izakaya_lantern':'\ud83c\udfee',
  2022. 'jack_o_lantern':'\ud83c\udf83',
  2023. 'japan':'\ud83d\uddfe',
  2024. 'japanese_castle':'\ud83c\udfef',
  2025. 'japanese_goblin':'\ud83d\udc7a',
  2026. 'japanese_ogre':'\ud83d\udc79',
  2027. 'jeans':'\ud83d\udc56',
  2028. 'joy':'\ud83d\ude02',
  2029. 'joy_cat':'\ud83d\ude39',
  2030. 'joystick':'\ud83d\udd79',
  2031. 'kaaba':'\ud83d\udd4b',
  2032. 'key':'\ud83d\udd11',
  2033. 'keyboard':'\u2328\ufe0f',
  2034. 'keycap_ten':'\ud83d\udd1f',
  2035. 'kick_scooter':'\ud83d\udef4',
  2036. 'kimono':'\ud83d\udc58',
  2037. 'kiss':'\ud83d\udc8b',
  2038. 'kissing':'\ud83d\ude17',
  2039. 'kissing_cat':'\ud83d\ude3d',
  2040. 'kissing_closed_eyes':'\ud83d\ude1a',
  2041. 'kissing_heart':'\ud83d\ude18',
  2042. 'kissing_smiling_eyes':'\ud83d\ude19',
  2043. 'kiwi_fruit':'\ud83e\udd5d',
  2044. 'koala':'\ud83d\udc28',
  2045. 'koko':'\ud83c\ude01',
  2046. 'label':'\ud83c\udff7',
  2047. 'large_blue_circle':'\ud83d\udd35',
  2048. 'large_blue_diamond':'\ud83d\udd37',
  2049. 'large_orange_diamond':'\ud83d\udd36',
  2050. 'last_quarter_moon':'\ud83c\udf17',
  2051. 'last_quarter_moon_with_face':'\ud83c\udf1c',
  2052. 'latin_cross':'\u271d\ufe0f',
  2053. 'laughing':'\ud83d\ude06',
  2054. 'leaves':'\ud83c\udf43',
  2055. 'ledger':'\ud83d\udcd2',
  2056. 'left_luggage':'\ud83d\udec5',
  2057. 'left_right_arrow':'\u2194\ufe0f',
  2058. 'leftwards_arrow_with_hook':'\u21a9\ufe0f',
  2059. 'lemon':'\ud83c\udf4b',
  2060. 'leo':'\u264c\ufe0f',
  2061. 'leopard':'\ud83d\udc06',
  2062. 'level_slider':'\ud83c\udf9a',
  2063. 'libra':'\u264e\ufe0f',
  2064. 'light_rail':'\ud83d\ude88',
  2065. 'link':'\ud83d\udd17',
  2066. 'lion':'\ud83e\udd81',
  2067. 'lips':'\ud83d\udc44',
  2068. 'lipstick':'\ud83d\udc84',
  2069. 'lizard':'\ud83e\udd8e',
  2070. 'lock':'\ud83d\udd12',
  2071. 'lock_with_ink_pen':'\ud83d\udd0f',
  2072. 'lollipop':'\ud83c\udf6d',
  2073. 'loop':'\u27bf',
  2074. 'loud_sound':'\ud83d\udd0a',
  2075. 'loudspeaker':'\ud83d\udce2',
  2076. 'love_hotel':'\ud83c\udfe9',
  2077. 'love_letter':'\ud83d\udc8c',
  2078. 'low_brightness':'\ud83d\udd05',
  2079. 'lying_face':'\ud83e\udd25',
  2080. 'm':'\u24c2\ufe0f',
  2081. 'mag':'\ud83d\udd0d',
  2082. 'mag_right':'\ud83d\udd0e',
  2083. 'mahjong':'\ud83c\udc04\ufe0f',
  2084. 'mailbox':'\ud83d\udceb',
  2085. 'mailbox_closed':'\ud83d\udcea',
  2086. 'mailbox_with_mail':'\ud83d\udcec',
  2087. 'mailbox_with_no_mail':'\ud83d\udced',
  2088. 'man':'\ud83d\udc68',
  2089. 'man_artist':'\ud83d\udc68&zwj;\ud83c\udfa8',
  2090. 'man_astronaut':'\ud83d\udc68&zwj;\ud83d\ude80',
  2091. 'man_cartwheeling':'\ud83e\udd38&zwj;\u2642\ufe0f',
  2092. 'man_cook':'\ud83d\udc68&zwj;\ud83c\udf73',
  2093. 'man_dancing':'\ud83d\udd7a',
  2094. 'man_facepalming':'\ud83e\udd26&zwj;\u2642\ufe0f',
  2095. 'man_factory_worker':'\ud83d\udc68&zwj;\ud83c\udfed',
  2096. 'man_farmer':'\ud83d\udc68&zwj;\ud83c\udf3e',
  2097. 'man_firefighter':'\ud83d\udc68&zwj;\ud83d\ude92',
  2098. 'man_health_worker':'\ud83d\udc68&zwj;\u2695\ufe0f',
  2099. 'man_in_tuxedo':'\ud83e\udd35',
  2100. 'man_judge':'\ud83d\udc68&zwj;\u2696\ufe0f',
  2101. 'man_juggling':'\ud83e\udd39&zwj;\u2642\ufe0f',
  2102. 'man_mechanic':'\ud83d\udc68&zwj;\ud83d\udd27',
  2103. 'man_office_worker':'\ud83d\udc68&zwj;\ud83d\udcbc',
  2104. 'man_pilot':'\ud83d\udc68&zwj;\u2708\ufe0f',
  2105. 'man_playing_handball':'\ud83e\udd3e&zwj;\u2642\ufe0f',
  2106. 'man_playing_water_polo':'\ud83e\udd3d&zwj;\u2642\ufe0f',
  2107. 'man_scientist':'\ud83d\udc68&zwj;\ud83d\udd2c',
  2108. 'man_shrugging':'\ud83e\udd37&zwj;\u2642\ufe0f',
  2109. 'man_singer':'\ud83d\udc68&zwj;\ud83c\udfa4',
  2110. 'man_student':'\ud83d\udc68&zwj;\ud83c\udf93',
  2111. 'man_teacher':'\ud83d\udc68&zwj;\ud83c\udfeb',
  2112. 'man_technologist':'\ud83d\udc68&zwj;\ud83d\udcbb',
  2113. 'man_with_gua_pi_mao':'\ud83d\udc72',
  2114. 'man_with_turban':'\ud83d\udc73',
  2115. 'tangerine':'\ud83c\udf4a',
  2116. 'mans_shoe':'\ud83d\udc5e',
  2117. 'mantelpiece_clock':'\ud83d\udd70',
  2118. 'maple_leaf':'\ud83c\udf41',
  2119. 'martial_arts_uniform':'\ud83e\udd4b',
  2120. 'mask':'\ud83d\ude37',
  2121. 'massage_woman':'\ud83d\udc86',
  2122. 'massage_man':'\ud83d\udc86&zwj;\u2642\ufe0f',
  2123. 'meat_on_bone':'\ud83c\udf56',
  2124. 'medal_military':'\ud83c\udf96',
  2125. 'medal_sports':'\ud83c\udfc5',
  2126. 'mega':'\ud83d\udce3',
  2127. 'melon':'\ud83c\udf48',
  2128. 'memo':'\ud83d\udcdd',
  2129. 'men_wrestling':'\ud83e\udd3c&zwj;\u2642\ufe0f',
  2130. 'menorah':'\ud83d\udd4e',
  2131. 'mens':'\ud83d\udeb9',
  2132. 'metal':'\ud83e\udd18',
  2133. 'metro':'\ud83d\ude87',
  2134. 'microphone':'\ud83c\udfa4',
  2135. 'microscope':'\ud83d\udd2c',
  2136. 'milk_glass':'\ud83e\udd5b',
  2137. 'milky_way':'\ud83c\udf0c',
  2138. 'minibus':'\ud83d\ude90',
  2139. 'minidisc':'\ud83d\udcbd',
  2140. 'mobile_phone_off':'\ud83d\udcf4',
  2141. 'money_mouth_face':'\ud83e\udd11',
  2142. 'money_with_wings':'\ud83d\udcb8',
  2143. 'moneybag':'\ud83d\udcb0',
  2144. 'monkey':'\ud83d\udc12',
  2145. 'monkey_face':'\ud83d\udc35',
  2146. 'monorail':'\ud83d\ude9d',
  2147. 'moon':'\ud83c\udf14',
  2148. 'mortar_board':'\ud83c\udf93',
  2149. 'mosque':'\ud83d\udd4c',
  2150. 'motor_boat':'\ud83d\udee5',
  2151. 'motor_scooter':'\ud83d\udef5',
  2152. 'motorcycle':'\ud83c\udfcd',
  2153. 'motorway':'\ud83d\udee3',
  2154. 'mount_fuji':'\ud83d\uddfb',
  2155. 'mountain':'\u26f0',
  2156. 'mountain_biking_man':'\ud83d\udeb5',
  2157. 'mountain_biking_woman':'\ud83d\udeb5&zwj;\u2640\ufe0f',
  2158. 'mountain_cableway':'\ud83d\udea0',
  2159. 'mountain_railway':'\ud83d\ude9e',
  2160. 'mountain_snow':'\ud83c\udfd4',
  2161. 'mouse':'\ud83d\udc2d',
  2162. 'mouse2':'\ud83d\udc01',
  2163. 'movie_camera':'\ud83c\udfa5',
  2164. 'moyai':'\ud83d\uddff',
  2165. 'mrs_claus':'\ud83e\udd36',
  2166. 'muscle':'\ud83d\udcaa',
  2167. 'mushroom':'\ud83c\udf44',
  2168. 'musical_keyboard':'\ud83c\udfb9',
  2169. 'musical_note':'\ud83c\udfb5',
  2170. 'musical_score':'\ud83c\udfbc',
  2171. 'mute':'\ud83d\udd07',
  2172. 'nail_care':'\ud83d\udc85',
  2173. 'name_badge':'\ud83d\udcdb',
  2174. 'national_park':'\ud83c\udfde',
  2175. 'nauseated_face':'\ud83e\udd22',
  2176. 'necktie':'\ud83d\udc54',
  2177. 'negative_squared_cross_mark':'\u274e',
  2178. 'nerd_face':'\ud83e\udd13',
  2179. 'neutral_face':'\ud83d\ude10',
  2180. 'new':'\ud83c\udd95',
  2181. 'new_moon':'\ud83c\udf11',
  2182. 'new_moon_with_face':'\ud83c\udf1a',
  2183. 'newspaper':'\ud83d\udcf0',
  2184. 'newspaper_roll':'\ud83d\uddde',
  2185. 'next_track_button':'\u23ed',
  2186. 'ng':'\ud83c\udd96',
  2187. 'no_good_man':'\ud83d\ude45&zwj;\u2642\ufe0f',
  2188. 'no_good_woman':'\ud83d\ude45',
  2189. 'night_with_stars':'\ud83c\udf03',
  2190. 'no_bell':'\ud83d\udd15',
  2191. 'no_bicycles':'\ud83d\udeb3',
  2192. 'no_entry':'\u26d4\ufe0f',
  2193. 'no_entry_sign':'\ud83d\udeab',
  2194. 'no_mobile_phones':'\ud83d\udcf5',
  2195. 'no_mouth':'\ud83d\ude36',
  2196. 'no_pedestrians':'\ud83d\udeb7',
  2197. 'no_smoking':'\ud83d\udead',
  2198. 'non-potable_water':'\ud83d\udeb1',
  2199. 'nose':'\ud83d\udc43',
  2200. 'notebook':'\ud83d\udcd3',
  2201. 'notebook_with_decorative_cover':'\ud83d\udcd4',
  2202. 'notes':'\ud83c\udfb6',
  2203. 'nut_and_bolt':'\ud83d\udd29',
  2204. 'o':'\u2b55\ufe0f',
  2205. 'o2':'\ud83c\udd7e\ufe0f',
  2206. 'ocean':'\ud83c\udf0a',
  2207. 'octopus':'\ud83d\udc19',
  2208. 'oden':'\ud83c\udf62',
  2209. 'office':'\ud83c\udfe2',
  2210. 'oil_drum':'\ud83d\udee2',
  2211. 'ok':'\ud83c\udd97',
  2212. 'ok_hand':'\ud83d\udc4c',
  2213. 'ok_man':'\ud83d\ude46&zwj;\u2642\ufe0f',
  2214. 'ok_woman':'\ud83d\ude46',
  2215. 'old_key':'\ud83d\udddd',
  2216. 'older_man':'\ud83d\udc74',
  2217. 'older_woman':'\ud83d\udc75',
  2218. 'om':'\ud83d\udd49',
  2219. 'on':'\ud83d\udd1b',
  2220. 'oncoming_automobile':'\ud83d\ude98',
  2221. 'oncoming_bus':'\ud83d\ude8d',
  2222. 'oncoming_police_car':'\ud83d\ude94',
  2223. 'oncoming_taxi':'\ud83d\ude96',
  2224. 'open_file_folder':'\ud83d\udcc2',
  2225. 'open_hands':'\ud83d\udc50',
  2226. 'open_mouth':'\ud83d\ude2e',
  2227. 'open_umbrella':'\u2602\ufe0f',
  2228. 'ophiuchus':'\u26ce',
  2229. 'orange_book':'\ud83d\udcd9',
  2230. 'orthodox_cross':'\u2626\ufe0f',
  2231. 'outbox_tray':'\ud83d\udce4',
  2232. 'owl':'\ud83e\udd89',
  2233. 'ox':'\ud83d\udc02',
  2234. 'package':'\ud83d\udce6',
  2235. 'page_facing_up':'\ud83d\udcc4',
  2236. 'page_with_curl':'\ud83d\udcc3',
  2237. 'pager':'\ud83d\udcdf',
  2238. 'paintbrush':'\ud83d\udd8c',
  2239. 'palm_tree':'\ud83c\udf34',
  2240. 'pancakes':'\ud83e\udd5e',
  2241. 'panda_face':'\ud83d\udc3c',
  2242. 'paperclip':'\ud83d\udcce',
  2243. 'paperclips':'\ud83d\udd87',
  2244. 'parasol_on_ground':'\u26f1',
  2245. 'parking':'\ud83c\udd7f\ufe0f',
  2246. 'part_alternation_mark':'\u303d\ufe0f',
  2247. 'partly_sunny':'\u26c5\ufe0f',
  2248. 'passenger_ship':'\ud83d\udef3',
  2249. 'passport_control':'\ud83d\udec2',
  2250. 'pause_button':'\u23f8',
  2251. 'peace_symbol':'\u262e\ufe0f',
  2252. 'peach':'\ud83c\udf51',
  2253. 'peanuts':'\ud83e\udd5c',
  2254. 'pear':'\ud83c\udf50',
  2255. 'pen':'\ud83d\udd8a',
  2256. 'pencil2':'\u270f\ufe0f',
  2257. 'penguin':'\ud83d\udc27',
  2258. 'pensive':'\ud83d\ude14',
  2259. 'performing_arts':'\ud83c\udfad',
  2260. 'persevere':'\ud83d\ude23',
  2261. 'person_fencing':'\ud83e\udd3a',
  2262. 'pouting_woman':'\ud83d\ude4e',
  2263. 'phone':'\u260e\ufe0f',
  2264. 'pick':'\u26cf',
  2265. 'pig':'\ud83d\udc37',
  2266. 'pig2':'\ud83d\udc16',
  2267. 'pig_nose':'\ud83d\udc3d',
  2268. 'pill':'\ud83d\udc8a',
  2269. 'pineapple':'\ud83c\udf4d',
  2270. 'ping_pong':'\ud83c\udfd3',
  2271. 'pisces':'\u2653\ufe0f',
  2272. 'pizza':'\ud83c\udf55',
  2273. 'place_of_worship':'\ud83d\uded0',
  2274. 'plate_with_cutlery':'\ud83c\udf7d',
  2275. 'play_or_pause_button':'\u23ef',
  2276. 'point_down':'\ud83d\udc47',
  2277. 'point_left':'\ud83d\udc48',
  2278. 'point_right':'\ud83d\udc49',
  2279. 'point_up':'\u261d\ufe0f',
  2280. 'point_up_2':'\ud83d\udc46',
  2281. 'police_car':'\ud83d\ude93',
  2282. 'policewoman':'\ud83d\udc6e&zwj;\u2640\ufe0f',
  2283. 'poodle':'\ud83d\udc29',
  2284. 'popcorn':'\ud83c\udf7f',
  2285. 'post_office':'\ud83c\udfe3',
  2286. 'postal_horn':'\ud83d\udcef',
  2287. 'postbox':'\ud83d\udcee',
  2288. 'potable_water':'\ud83d\udeb0',
  2289. 'potato':'\ud83e\udd54',
  2290. 'pouch':'\ud83d\udc5d',
  2291. 'poultry_leg':'\ud83c\udf57',
  2292. 'pound':'\ud83d\udcb7',
  2293. 'rage':'\ud83d\ude21',
  2294. 'pouting_cat':'\ud83d\ude3e',
  2295. 'pouting_man':'\ud83d\ude4e&zwj;\u2642\ufe0f',
  2296. 'pray':'\ud83d\ude4f',
  2297. 'prayer_beads':'\ud83d\udcff',
  2298. 'pregnant_woman':'\ud83e\udd30',
  2299. 'previous_track_button':'\u23ee',
  2300. 'prince':'\ud83e\udd34',
  2301. 'princess':'\ud83d\udc78',
  2302. 'printer':'\ud83d\udda8',
  2303. 'purple_heart':'\ud83d\udc9c',
  2304. 'purse':'\ud83d\udc5b',
  2305. 'pushpin':'\ud83d\udccc',
  2306. 'put_litter_in_its_place':'\ud83d\udeae',
  2307. 'question':'\u2753',
  2308. 'rabbit':'\ud83d\udc30',
  2309. 'rabbit2':'\ud83d\udc07',
  2310. 'racehorse':'\ud83d\udc0e',
  2311. 'racing_car':'\ud83c\udfce',
  2312. 'radio':'\ud83d\udcfb',
  2313. 'radio_button':'\ud83d\udd18',
  2314. 'radioactive':'\u2622\ufe0f',
  2315. 'railway_car':'\ud83d\ude83',
  2316. 'railway_track':'\ud83d\udee4',
  2317. 'rainbow':'\ud83c\udf08',
  2318. 'rainbow_flag':'\ud83c\udff3\ufe0f&zwj;\ud83c\udf08',
  2319. 'raised_back_of_hand':'\ud83e\udd1a',
  2320. 'raised_hand_with_fingers_splayed':'\ud83d\udd90',
  2321. 'raised_hands':'\ud83d\ude4c',
  2322. 'raising_hand_woman':'\ud83d\ude4b',
  2323. 'raising_hand_man':'\ud83d\ude4b&zwj;\u2642\ufe0f',
  2324. 'ram':'\ud83d\udc0f',
  2325. 'ramen':'\ud83c\udf5c',
  2326. 'rat':'\ud83d\udc00',
  2327. 'record_button':'\u23fa',
  2328. 'recycle':'\u267b\ufe0f',
  2329. 'red_circle':'\ud83d\udd34',
  2330. 'registered':'\u00ae\ufe0f',
  2331. 'relaxed':'\u263a\ufe0f',
  2332. 'relieved':'\ud83d\ude0c',
  2333. 'reminder_ribbon':'\ud83c\udf97',
  2334. 'repeat':'\ud83d\udd01',
  2335. 'repeat_one':'\ud83d\udd02',
  2336. 'rescue_worker_helmet':'\u26d1',
  2337. 'restroom':'\ud83d\udebb',
  2338. 'revolving_hearts':'\ud83d\udc9e',
  2339. 'rewind':'\u23ea',
  2340. 'rhinoceros':'\ud83e\udd8f',
  2341. 'ribbon':'\ud83c\udf80',
  2342. 'rice':'\ud83c\udf5a',
  2343. 'rice_ball':'\ud83c\udf59',
  2344. 'rice_cracker':'\ud83c\udf58',
  2345. 'rice_scene':'\ud83c\udf91',
  2346. 'right_anger_bubble':'\ud83d\uddef',
  2347. 'ring':'\ud83d\udc8d',
  2348. 'robot':'\ud83e\udd16',
  2349. 'rocket':'\ud83d\ude80',
  2350. 'rofl':'\ud83e\udd23',
  2351. 'roll_eyes':'\ud83d\ude44',
  2352. 'roller_coaster':'\ud83c\udfa2',
  2353. 'rooster':'\ud83d\udc13',
  2354. 'rose':'\ud83c\udf39',
  2355. 'rosette':'\ud83c\udff5',
  2356. 'rotating_light':'\ud83d\udea8',
  2357. 'round_pushpin':'\ud83d\udccd',
  2358. 'rowing_man':'\ud83d\udea3',
  2359. 'rowing_woman':'\ud83d\udea3&zwj;\u2640\ufe0f',
  2360. 'rugby_football':'\ud83c\udfc9',
  2361. 'running_man':'\ud83c\udfc3',
  2362. 'running_shirt_with_sash':'\ud83c\udfbd',
  2363. 'running_woman':'\ud83c\udfc3&zwj;\u2640\ufe0f',
  2364. 'sa':'\ud83c\ude02\ufe0f',
  2365. 'sagittarius':'\u2650\ufe0f',
  2366. 'sake':'\ud83c\udf76',
  2367. 'sandal':'\ud83d\udc61',
  2368. 'santa':'\ud83c\udf85',
  2369. 'satellite':'\ud83d\udce1',
  2370. 'saxophone':'\ud83c\udfb7',
  2371. 'school':'\ud83c\udfeb',
  2372. 'school_satchel':'\ud83c\udf92',
  2373. 'scissors':'\u2702\ufe0f',
  2374. 'scorpion':'\ud83e\udd82',
  2375. 'scorpius':'\u264f\ufe0f',
  2376. 'scream':'\ud83d\ude31',
  2377. 'scream_cat':'\ud83d\ude40',
  2378. 'scroll':'\ud83d\udcdc',
  2379. 'seat':'\ud83d\udcba',
  2380. 'secret':'\u3299\ufe0f',
  2381. 'see_no_evil':'\ud83d\ude48',
  2382. 'seedling':'\ud83c\udf31',
  2383. 'selfie':'\ud83e\udd33',
  2384. 'shallow_pan_of_food':'\ud83e\udd58',
  2385. 'shamrock':'\u2618\ufe0f',
  2386. 'shark':'\ud83e\udd88',
  2387. 'shaved_ice':'\ud83c\udf67',
  2388. 'sheep':'\ud83d\udc11',
  2389. 'shell':'\ud83d\udc1a',
  2390. 'shield':'\ud83d\udee1',
  2391. 'shinto_shrine':'\u26e9',
  2392. 'ship':'\ud83d\udea2',
  2393. 'shirt':'\ud83d\udc55',
  2394. 'shopping':'\ud83d\udecd',
  2395. 'shopping_cart':'\ud83d\uded2',
  2396. 'shower':'\ud83d\udebf',
  2397. 'shrimp':'\ud83e\udd90',
  2398. 'signal_strength':'\ud83d\udcf6',
  2399. 'six_pointed_star':'\ud83d\udd2f',
  2400. 'ski':'\ud83c\udfbf',
  2401. 'skier':'\u26f7',
  2402. 'skull':'\ud83d\udc80',
  2403. 'skull_and_crossbones':'\u2620\ufe0f',
  2404. 'sleeping':'\ud83d\ude34',
  2405. 'sleeping_bed':'\ud83d\udecc',
  2406. 'sleepy':'\ud83d\ude2a',
  2407. 'slightly_frowning_face':'\ud83d\ude41',
  2408. 'slightly_smiling_face':'\ud83d\ude42',
  2409. 'slot_machine':'\ud83c\udfb0',
  2410. 'small_airplane':'\ud83d\udee9',
  2411. 'small_blue_diamond':'\ud83d\udd39',
  2412. 'small_orange_diamond':'\ud83d\udd38',
  2413. 'small_red_triangle':'\ud83d\udd3a',
  2414. 'small_red_triangle_down':'\ud83d\udd3b',
  2415. 'smile':'\ud83d\ude04',
  2416. 'smile_cat':'\ud83d\ude38',
  2417. 'smiley':'\ud83d\ude03',
  2418. 'smiley_cat':'\ud83d\ude3a',
  2419. 'smiling_imp':'\ud83d\ude08',
  2420. 'smirk':'\ud83d\ude0f',
  2421. 'smirk_cat':'\ud83d\ude3c',
  2422. 'smoking':'\ud83d\udeac',
  2423. 'snail':'\ud83d\udc0c',
  2424. 'snake':'\ud83d\udc0d',
  2425. 'sneezing_face':'\ud83e\udd27',
  2426. 'snowboarder':'\ud83c\udfc2',
  2427. 'snowflake':'\u2744\ufe0f',
  2428. 'snowman':'\u26c4\ufe0f',
  2429. 'snowman_with_snow':'\u2603\ufe0f',
  2430. 'sob':'\ud83d\ude2d',
  2431. 'soccer':'\u26bd\ufe0f',
  2432. 'soon':'\ud83d\udd1c',
  2433. 'sos':'\ud83c\udd98',
  2434. 'sound':'\ud83d\udd09',
  2435. 'space_invader':'\ud83d\udc7e',
  2436. 'spades':'\u2660\ufe0f',
  2437. 'spaghetti':'\ud83c\udf5d',
  2438. 'sparkle':'\u2747\ufe0f',
  2439. 'sparkler':'\ud83c\udf87',
  2440. 'sparkles':'\u2728',
  2441. 'sparkling_heart':'\ud83d\udc96',
  2442. 'speak_no_evil':'\ud83d\ude4a',
  2443. 'speaker':'\ud83d\udd08',
  2444. 'speaking_head':'\ud83d\udde3',
  2445. 'speech_balloon':'\ud83d\udcac',
  2446. 'speedboat':'\ud83d\udea4',
  2447. 'spider':'\ud83d\udd77',
  2448. 'spider_web':'\ud83d\udd78',
  2449. 'spiral_calendar':'\ud83d\uddd3',
  2450. 'spiral_notepad':'\ud83d\uddd2',
  2451. 'spoon':'\ud83e\udd44',
  2452. 'squid':'\ud83e\udd91',
  2453. 'stadium':'\ud83c\udfdf',
  2454. 'star':'\u2b50\ufe0f',
  2455. 'star2':'\ud83c\udf1f',
  2456. 'star_and_crescent':'\u262a\ufe0f',
  2457. 'star_of_david':'\u2721\ufe0f',
  2458. 'stars':'\ud83c\udf20',
  2459. 'station':'\ud83d\ude89',
  2460. 'statue_of_liberty':'\ud83d\uddfd',
  2461. 'steam_locomotive':'\ud83d\ude82',
  2462. 'stew':'\ud83c\udf72',
  2463. 'stop_button':'\u23f9',
  2464. 'stop_sign':'\ud83d\uded1',
  2465. 'stopwatch':'\u23f1',
  2466. 'straight_ruler':'\ud83d\udccf',
  2467. 'strawberry':'\ud83c\udf53',
  2468. 'stuck_out_tongue':'\ud83d\ude1b',
  2469. 'stuck_out_tongue_closed_eyes':'\ud83d\ude1d',
  2470. 'stuck_out_tongue_winking_eye':'\ud83d\ude1c',
  2471. 'studio_microphone':'\ud83c\udf99',
  2472. 'stuffed_flatbread':'\ud83e\udd59',
  2473. 'sun_behind_large_cloud':'\ud83c\udf25',
  2474. 'sun_behind_rain_cloud':'\ud83c\udf26',
  2475. 'sun_behind_small_cloud':'\ud83c\udf24',
  2476. 'sun_with_face':'\ud83c\udf1e',
  2477. 'sunflower':'\ud83c\udf3b',
  2478. 'sunglasses':'\ud83d\ude0e',
  2479. 'sunny':'\u2600\ufe0f',
  2480. 'sunrise':'\ud83c\udf05',
  2481. 'sunrise_over_mountains':'\ud83c\udf04',
  2482. 'surfing_man':'\ud83c\udfc4',
  2483. 'surfing_woman':'\ud83c\udfc4&zwj;\u2640\ufe0f',
  2484. 'sushi':'\ud83c\udf63',
  2485. 'suspension_railway':'\ud83d\ude9f',
  2486. 'sweat':'\ud83d\ude13',
  2487. 'sweat_drops':'\ud83d\udca6',
  2488. 'sweat_smile':'\ud83d\ude05',
  2489. 'sweet_potato':'\ud83c\udf60',
  2490. 'swimming_man':'\ud83c\udfca',
  2491. 'swimming_woman':'\ud83c\udfca&zwj;\u2640\ufe0f',
  2492. 'symbols':'\ud83d\udd23',
  2493. 'synagogue':'\ud83d\udd4d',
  2494. 'syringe':'\ud83d\udc89',
  2495. 'taco':'\ud83c\udf2e',
  2496. 'tada':'\ud83c\udf89',
  2497. 'tanabata_tree':'\ud83c\udf8b',
  2498. 'taurus':'\u2649\ufe0f',
  2499. 'taxi':'\ud83d\ude95',
  2500. 'tea':'\ud83c\udf75',
  2501. 'telephone_receiver':'\ud83d\udcde',
  2502. 'telescope':'\ud83d\udd2d',
  2503. 'tennis':'\ud83c\udfbe',
  2504. 'tent':'\u26fa\ufe0f',
  2505. 'thermometer':'\ud83c\udf21',
  2506. 'thinking':'\ud83e\udd14',
  2507. 'thought_balloon':'\ud83d\udcad',
  2508. 'ticket':'\ud83c\udfab',
  2509. 'tickets':'\ud83c\udf9f',
  2510. 'tiger':'\ud83d\udc2f',
  2511. 'tiger2':'\ud83d\udc05',
  2512. 'timer_clock':'\u23f2',
  2513. 'tipping_hand_man':'\ud83d\udc81&zwj;\u2642\ufe0f',
  2514. 'tired_face':'\ud83d\ude2b',
  2515. 'tm':'\u2122\ufe0f',
  2516. 'toilet':'\ud83d\udebd',
  2517. 'tokyo_tower':'\ud83d\uddfc',
  2518. 'tomato':'\ud83c\udf45',
  2519. 'tongue':'\ud83d\udc45',
  2520. 'top':'\ud83d\udd1d',
  2521. 'tophat':'\ud83c\udfa9',
  2522. 'tornado':'\ud83c\udf2a',
  2523. 'trackball':'\ud83d\uddb2',
  2524. 'tractor':'\ud83d\ude9c',
  2525. 'traffic_light':'\ud83d\udea5',
  2526. 'train':'\ud83d\ude8b',
  2527. 'train2':'\ud83d\ude86',
  2528. 'tram':'\ud83d\ude8a',
  2529. 'triangular_flag_on_post':'\ud83d\udea9',
  2530. 'triangular_ruler':'\ud83d\udcd0',
  2531. 'trident':'\ud83d\udd31',
  2532. 'triumph':'\ud83d\ude24',
  2533. 'trolleybus':'\ud83d\ude8e',
  2534. 'trophy':'\ud83c\udfc6',
  2535. 'tropical_drink':'\ud83c\udf79',
  2536. 'tropical_fish':'\ud83d\udc20',
  2537. 'truck':'\ud83d\ude9a',
  2538. 'trumpet':'\ud83c\udfba',
  2539. 'tulip':'\ud83c\udf37',
  2540. 'tumbler_glass':'\ud83e\udd43',
  2541. 'turkey':'\ud83e\udd83',
  2542. 'turtle':'\ud83d\udc22',
  2543. 'tv':'\ud83d\udcfa',
  2544. 'twisted_rightwards_arrows':'\ud83d\udd00',
  2545. 'two_hearts':'\ud83d\udc95',
  2546. 'two_men_holding_hands':'\ud83d\udc6c',
  2547. 'two_women_holding_hands':'\ud83d\udc6d',
  2548. 'u5272':'\ud83c\ude39',
  2549. 'u5408':'\ud83c\ude34',
  2550. 'u55b6':'\ud83c\ude3a',
  2551. 'u6307':'\ud83c\ude2f\ufe0f',
  2552. 'u6708':'\ud83c\ude37\ufe0f',
  2553. 'u6709':'\ud83c\ude36',
  2554. 'u6e80':'\ud83c\ude35',
  2555. 'u7121':'\ud83c\ude1a\ufe0f',
  2556. 'u7533':'\ud83c\ude38',
  2557. 'u7981':'\ud83c\ude32',
  2558. 'u7a7a':'\ud83c\ude33',
  2559. 'umbrella':'\u2614\ufe0f',
  2560. 'unamused':'\ud83d\ude12',
  2561. 'underage':'\ud83d\udd1e',
  2562. 'unicorn':'\ud83e\udd84',
  2563. 'unlock':'\ud83d\udd13',
  2564. 'up':'\ud83c\udd99',
  2565. 'upside_down_face':'\ud83d\ude43',
  2566. 'v':'\u270c\ufe0f',
  2567. 'vertical_traffic_light':'\ud83d\udea6',
  2568. 'vhs':'\ud83d\udcfc',
  2569. 'vibration_mode':'\ud83d\udcf3',
  2570. 'video_camera':'\ud83d\udcf9',
  2571. 'video_game':'\ud83c\udfae',
  2572. 'violin':'\ud83c\udfbb',
  2573. 'virgo':'\u264d\ufe0f',
  2574. 'volcano':'\ud83c\udf0b',
  2575. 'volleyball':'\ud83c\udfd0',
  2576. 'vs':'\ud83c\udd9a',
  2577. 'vulcan_salute':'\ud83d\udd96',
  2578. 'walking_man':'\ud83d\udeb6',
  2579. 'walking_woman':'\ud83d\udeb6&zwj;\u2640\ufe0f',
  2580. 'waning_crescent_moon':'\ud83c\udf18',
  2581. 'waning_gibbous_moon':'\ud83c\udf16',
  2582. 'warning':'\u26a0\ufe0f',
  2583. 'wastebasket':'\ud83d\uddd1',
  2584. 'watch':'\u231a\ufe0f',
  2585. 'water_buffalo':'\ud83d\udc03',
  2586. 'watermelon':'\ud83c\udf49',
  2587. 'wave':'\ud83d\udc4b',
  2588. 'wavy_dash':'\u3030\ufe0f',
  2589. 'waxing_crescent_moon':'\ud83c\udf12',
  2590. 'wc':'\ud83d\udebe',
  2591. 'weary':'\ud83d\ude29',
  2592. 'wedding':'\ud83d\udc92',
  2593. 'weight_lifting_man':'\ud83c\udfcb\ufe0f',
  2594. 'weight_lifting_woman':'\ud83c\udfcb\ufe0f&zwj;\u2640\ufe0f',
  2595. 'whale':'\ud83d\udc33',
  2596. 'whale2':'\ud83d\udc0b',
  2597. 'wheel_of_dharma':'\u2638\ufe0f',
  2598. 'wheelchair':'\u267f\ufe0f',
  2599. 'white_check_mark':'\u2705',
  2600. 'white_circle':'\u26aa\ufe0f',
  2601. 'white_flag':'\ud83c\udff3\ufe0f',
  2602. 'white_flower':'\ud83d\udcae',
  2603. 'white_large_square':'\u2b1c\ufe0f',
  2604. 'white_medium_small_square':'\u25fd\ufe0f',
  2605. 'white_medium_square':'\u25fb\ufe0f',
  2606. 'white_small_square':'\u25ab\ufe0f',
  2607. 'white_square_button':'\ud83d\udd33',
  2608. 'wilted_flower':'\ud83e\udd40',
  2609. 'wind_chime':'\ud83c\udf90',
  2610. 'wind_face':'\ud83c\udf2c',
  2611. 'wine_glass':'\ud83c\udf77',
  2612. 'wink':'\ud83d\ude09',
  2613. 'wolf':'\ud83d\udc3a',
  2614. 'woman':'\ud83d\udc69',
  2615. 'woman_artist':'\ud83d\udc69&zwj;\ud83c\udfa8',
  2616. 'woman_astronaut':'\ud83d\udc69&zwj;\ud83d\ude80',
  2617. 'woman_cartwheeling':'\ud83e\udd38&zwj;\u2640\ufe0f',
  2618. 'woman_cook':'\ud83d\udc69&zwj;\ud83c\udf73',
  2619. 'woman_facepalming':'\ud83e\udd26&zwj;\u2640\ufe0f',
  2620. 'woman_factory_worker':'\ud83d\udc69&zwj;\ud83c\udfed',
  2621. 'woman_farmer':'\ud83d\udc69&zwj;\ud83c\udf3e',
  2622. 'woman_firefighter':'\ud83d\udc69&zwj;\ud83d\ude92',
  2623. 'woman_health_worker':'\ud83d\udc69&zwj;\u2695\ufe0f',
  2624. 'woman_judge':'\ud83d\udc69&zwj;\u2696\ufe0f',
  2625. 'woman_juggling':'\ud83e\udd39&zwj;\u2640\ufe0f',
  2626. 'woman_mechanic':'\ud83d\udc69&zwj;\ud83d\udd27',
  2627. 'woman_office_worker':'\ud83d\udc69&zwj;\ud83d\udcbc',
  2628. 'woman_pilot':'\ud83d\udc69&zwj;\u2708\ufe0f',
  2629. 'woman_playing_handball':'\ud83e\udd3e&zwj;\u2640\ufe0f',
  2630. 'woman_playing_water_polo':'\ud83e\udd3d&zwj;\u2640\ufe0f',
  2631. 'woman_scientist':'\ud83d\udc69&zwj;\ud83d\udd2c',
  2632. 'woman_shrugging':'\ud83e\udd37&zwj;\u2640\ufe0f',
  2633. 'woman_singer':'\ud83d\udc69&zwj;\ud83c\udfa4',
  2634. 'woman_student':'\ud83d\udc69&zwj;\ud83c\udf93',
  2635. 'woman_teacher':'\ud83d\udc69&zwj;\ud83c\udfeb',
  2636. 'woman_technologist':'\ud83d\udc69&zwj;\ud83d\udcbb',
  2637. 'woman_with_turban':'\ud83d\udc73&zwj;\u2640\ufe0f',
  2638. 'womans_clothes':'\ud83d\udc5a',
  2639. 'womans_hat':'\ud83d\udc52',
  2640. 'women_wrestling':'\ud83e\udd3c&zwj;\u2640\ufe0f',
  2641. 'womens':'\ud83d\udeba',
  2642. 'world_map':'\ud83d\uddfa',
  2643. 'worried':'\ud83d\ude1f',
  2644. 'wrench':'\ud83d\udd27',
  2645. 'writing_hand':'\u270d\ufe0f',
  2646. 'x':'\u274c',
  2647. 'yellow_heart':'\ud83d\udc9b',
  2648. 'yen':'\ud83d\udcb4',
  2649. 'yin_yang':'\u262f\ufe0f',
  2650. 'yum':'\ud83d\ude0b',
  2651. 'zap':'\u26a1\ufe0f',
  2652. 'zipper_mouth_face':'\ud83e\udd10',
  2653. 'zzz':'\ud83d\udca4',
  2654. /* special emojis :P */
  2655. 'octocat': '<img alt=":octocat:" height="20" width="20" align="absmiddle" src="https://assets-cdn.github.com/images/icons/emoji/octocat.png">',
  2656. '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>'
  2657. };
  2658. /**
  2659. * Created by Estevao on 31-05-2015.
  2660. */
  2661. /**
  2662. * Showdown Converter class
  2663. * @class
  2664. * @param {object} [converterOptions]
  2665. * @returns {Converter}
  2666. */
  2667. showdown.Converter = function (converterOptions) {
  2668. 'use strict';
  2669. var
  2670. /**
  2671. * Options used by this converter
  2672. * @private
  2673. * @type {{}}
  2674. */
  2675. options = {},
  2676. /**
  2677. * Language extensions used by this converter
  2678. * @private
  2679. * @type {Array}
  2680. */
  2681. langExtensions = [],
  2682. /**
  2683. * Output modifiers extensions used by this converter
  2684. * @private
  2685. * @type {Array}
  2686. */
  2687. outputModifiers = [],
  2688. /**
  2689. * Event listeners
  2690. * @private
  2691. * @type {{}}
  2692. */
  2693. listeners = {},
  2694. /**
  2695. * The flavor set in this converter
  2696. */
  2697. setConvFlavor = setFlavor,
  2698. /**
  2699. * Metadata of the document
  2700. * @type {{parsed: {}, raw: string, format: string}}
  2701. */
  2702. metadata = {
  2703. parsed: {},
  2704. raw: '',
  2705. format: ''
  2706. };
  2707. _constructor();
  2708. /**
  2709. * Converter constructor
  2710. * @private
  2711. */
  2712. function _constructor () {
  2713. converterOptions = converterOptions || {};
  2714. for (var gOpt in globalOptions) {
  2715. if (globalOptions.hasOwnProperty(gOpt)) {
  2716. options[gOpt] = globalOptions[gOpt];
  2717. }
  2718. }
  2719. // Merge options
  2720. if (typeof converterOptions === 'object') {
  2721. for (var opt in converterOptions) {
  2722. if (converterOptions.hasOwnProperty(opt)) {
  2723. options[opt] = converterOptions[opt];
  2724. }
  2725. }
  2726. } else {
  2727. throw Error('Converter expects the passed parameter to be an object, but ' + typeof converterOptions +
  2728. ' was passed instead.');
  2729. }
  2730. if (options.extensions) {
  2731. showdown.helper.forEach(options.extensions, _parseExtension);
  2732. }
  2733. }
  2734. /**
  2735. * Parse extension
  2736. * @param {*} ext
  2737. * @param {string} [name='']
  2738. * @private
  2739. */
  2740. function _parseExtension (ext, name) {
  2741. name = name || null;
  2742. // If it's a string, the extension was previously loaded
  2743. if (showdown.helper.isString(ext)) {
  2744. ext = showdown.helper.stdExtName(ext);
  2745. name = ext;
  2746. // LEGACY_SUPPORT CODE
  2747. if (showdown.extensions[ext]) {
  2748. console.warn('DEPRECATION WARNING: ' + ext + ' is an old extension that uses a deprecated loading method.' +
  2749. 'Please inform the developer that the extension should be updated!');
  2750. legacyExtensionLoading(showdown.extensions[ext], ext);
  2751. return;
  2752. // END LEGACY SUPPORT CODE
  2753. } else if (!showdown.helper.isUndefined(extensions[ext])) {
  2754. ext = extensions[ext];
  2755. } else {
  2756. throw Error('Extension "' + ext + '" could not be loaded. It was either not found or is not a valid extension.');
  2757. }
  2758. }
  2759. if (typeof ext === 'function') {
  2760. ext = ext();
  2761. }
  2762. if (!showdown.helper.isArray(ext)) {
  2763. ext = [ext];
  2764. }
  2765. var validExt = validate(ext, name);
  2766. if (!validExt.valid) {
  2767. throw Error(validExt.error);
  2768. }
  2769. for (var i = 0; i < ext.length; ++i) {
  2770. switch (ext[i].type) {
  2771. case 'lang':
  2772. langExtensions.push(ext[i]);
  2773. break;
  2774. case 'output':
  2775. outputModifiers.push(ext[i]);
  2776. break;
  2777. }
  2778. if (ext[i].hasOwnProperty('listeners')) {
  2779. for (var ln in ext[i].listeners) {
  2780. if (ext[i].listeners.hasOwnProperty(ln)) {
  2781. listen(ln, ext[i].listeners[ln]);
  2782. }
  2783. }
  2784. }
  2785. }
  2786. }
  2787. /**
  2788. * LEGACY_SUPPORT
  2789. * @param {*} ext
  2790. * @param {string} name
  2791. */
  2792. function legacyExtensionLoading (ext, name) {
  2793. if (typeof ext === 'function') {
  2794. ext = ext(new showdown.Converter());
  2795. }
  2796. if (!showdown.helper.isArray(ext)) {
  2797. ext = [ext];
  2798. }
  2799. var valid = validate(ext, name);
  2800. if (!valid.valid) {
  2801. throw Error(valid.error);
  2802. }
  2803. for (var i = 0; i < ext.length; ++i) {
  2804. switch (ext[i].type) {
  2805. case 'lang':
  2806. langExtensions.push(ext[i]);
  2807. break;
  2808. case 'output':
  2809. outputModifiers.push(ext[i]);
  2810. break;
  2811. default:// should never reach here
  2812. throw Error('Extension loader error: Type unrecognized!!!');
  2813. }
  2814. }
  2815. }
  2816. /**
  2817. * Listen to an event
  2818. * @param {string} name
  2819. * @param {function} callback
  2820. */
  2821. function listen (name, callback) {
  2822. if (!showdown.helper.isString(name)) {
  2823. throw Error('Invalid argument in converter.listen() method: name must be a string, but ' + typeof name + ' given');
  2824. }
  2825. if (typeof callback !== 'function') {
  2826. throw Error('Invalid argument in converter.listen() method: callback must be a function, but ' + typeof callback + ' given');
  2827. }
  2828. if (!listeners.hasOwnProperty(name)) {
  2829. listeners[name] = [];
  2830. }
  2831. listeners[name].push(callback);
  2832. }
  2833. function rTrimInputText (text) {
  2834. var rsp = text.match(/^\s*/)[0].length,
  2835. rgx = new RegExp('^\\s{0,' + rsp + '}', 'gm');
  2836. return text.replace(rgx, '');
  2837. }
  2838. /**
  2839. * Dispatch an event
  2840. * @private
  2841. * @param {string} evtName Event name
  2842. * @param {string} text Text
  2843. * @param {{}} options Converter Options
  2844. * @param {{}} globals
  2845. * @returns {string}
  2846. */
  2847. this._dispatch = function dispatch (evtName, text, options, globals) {
  2848. if (listeners.hasOwnProperty(evtName)) {
  2849. for (var ei = 0; ei < listeners[evtName].length; ++ei) {
  2850. var nText = listeners[evtName][ei](evtName, text, this, options, globals);
  2851. if (nText && typeof nText !== 'undefined') {
  2852. text = nText;
  2853. }
  2854. }
  2855. }
  2856. return text;
  2857. };
  2858. /**
  2859. * Listen to an event
  2860. * @param {string} name
  2861. * @param {function} callback
  2862. * @returns {showdown.Converter}
  2863. */
  2864. this.listen = function (name, callback) {
  2865. listen(name, callback);
  2866. return this;
  2867. };
  2868. /**
  2869. * Converts a markdown string into HTML
  2870. * @param {string} text
  2871. * @returns {*}
  2872. */
  2873. this.makeHtml = function (text) {
  2874. //check if text is not falsy
  2875. if (!text) {
  2876. return text;
  2877. }
  2878. var globals = {
  2879. gHtmlBlocks: [],
  2880. gHtmlMdBlocks: [],
  2881. gHtmlSpans: [],
  2882. gUrls: {},
  2883. gTitles: {},
  2884. gDimensions: {},
  2885. gListLevel: 0,
  2886. hashLinkCounts: {},
  2887. langExtensions: langExtensions,
  2888. outputModifiers: outputModifiers,
  2889. converter: this,
  2890. ghCodeBlocks: [],
  2891. metadata: {
  2892. parsed: {},
  2893. raw: '',
  2894. format: ''
  2895. }
  2896. };
  2897. // This lets us use ¨ trema as an escape char to avoid md5 hashes
  2898. // The choice of character is arbitrary; anything that isn't
  2899. // magic in Markdown will work.
  2900. text = text.replace(/¨/g, '¨T');
  2901. // Replace $ with ¨D
  2902. // RegExp interprets $ as a special character
  2903. // when it's in a replacement string
  2904. text = text.replace(/\$/g, '¨D');
  2905. // Standardize line endings
  2906. text = text.replace(/\r\n/g, '\n'); // DOS to Unix
  2907. text = text.replace(/\r/g, '\n'); // Mac to Unix
  2908. // Stardardize line spaces
  2909. text = text.replace(/\u00A0/g, '&nbsp;');
  2910. if (options.smartIndentationFix) {
  2911. text = rTrimInputText(text);
  2912. }
  2913. // Make sure text begins and ends with a couple of newlines:
  2914. text = '\n\n' + text + '\n\n';
  2915. // detab
  2916. text = showdown.subParser('detab')(text, options, globals);
  2917. /**
  2918. * Strip any lines consisting only of spaces and tabs.
  2919. * This makes subsequent regexs easier to write, because we can
  2920. * match consecutive blank lines with /\n+/ instead of something
  2921. * contorted like /[ \t]*\n+/
  2922. */
  2923. text = text.replace(/^[ \t]+$/mg, '');
  2924. //run languageExtensions
  2925. showdown.helper.forEach(langExtensions, function (ext) {
  2926. text = showdown.subParser('runExtension')(ext, text, options, globals);
  2927. });
  2928. // run the sub parsers
  2929. text = showdown.subParser('metadata')(text, options, globals);
  2930. text = showdown.subParser('hashPreCodeTags')(text, options, globals);
  2931. text = showdown.subParser('githubCodeBlocks')(text, options, globals);
  2932. text = showdown.subParser('hashHTMLBlocks')(text, options, globals);
  2933. text = showdown.subParser('hashCodeTags')(text, options, globals);
  2934. text = showdown.subParser('stripLinkDefinitions')(text, options, globals);
  2935. text = showdown.subParser('blockGamut')(text, options, globals);
  2936. text = showdown.subParser('unhashHTMLSpans')(text, options, globals);
  2937. text = showdown.subParser('unescapeSpecialChars')(text, options, globals);
  2938. // attacklab: Restore dollar signs
  2939. text = text.replace(/¨D/g, '$$');
  2940. // attacklab: Restore tremas
  2941. text = text.replace(/¨T/g, '¨');
  2942. // render a complete html document instead of a partial if the option is enabled
  2943. text = showdown.subParser('completeHTMLDocument')(text, options, globals);
  2944. // Run output modifiers
  2945. showdown.helper.forEach(outputModifiers, function (ext) {
  2946. text = showdown.subParser('runExtension')(ext, text, options, globals);
  2947. });
  2948. // update metadata
  2949. metadata = globals.metadata;
  2950. return text;
  2951. };
  2952. /**
  2953. * Converts an HTML string into a markdown string
  2954. * @param src
  2955. * @param [HTMLParser] A WHATWG DOM and HTML parser, such as JSDOM. If none is supplied, window.document will be used.
  2956. * @returns {string}
  2957. */
  2958. this.makeMarkdown = this.makeMd = function (src, HTMLParser) {
  2959. // replace \r\n with \n
  2960. src = src.replace(/\r\n/g, '\n');
  2961. src = src.replace(/\r/g, '\n'); // old macs
  2962. // due to an edge case, we need to find this: > <
  2963. // to prevent removing of non silent white spaces
  2964. // ex: <em>this is</em> <strong>sparta</strong>
  2965. src = src.replace(/>[ \t]+</, '>¨NBSP;<');
  2966. if (!HTMLParser) {
  2967. if (window && window.document) {
  2968. HTMLParser = window.document;
  2969. } else {
  2970. 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');
  2971. }
  2972. }
  2973. var doc = HTMLParser.createElement('div');
  2974. doc.innerHTML = src;
  2975. var globals = {
  2976. preList: substitutePreCodeTags(doc)
  2977. };
  2978. // remove all newlines and collapse spaces
  2979. clean(doc);
  2980. // some stuff, like accidental reference links must now be escaped
  2981. // TODO
  2982. // doc.innerHTML = doc.innerHTML.replace(/\[[\S\t ]]/);
  2983. var nodes = doc.childNodes,
  2984. mdDoc = '';
  2985. for (var i = 0; i < nodes.length; i++) {
  2986. mdDoc += showdown.subParser('makeMarkdown.node')(nodes[i], globals);
  2987. }
  2988. function clean (node) {
  2989. for (var n = 0; n < node.childNodes.length; ++n) {
  2990. var child = node.childNodes[n];
  2991. if (child.nodeType === 3) {
  2992. if (!/\S/.test(child.nodeValue)) {
  2993. node.removeChild(child);
  2994. --n;
  2995. } else {
  2996. child.nodeValue = child.nodeValue.split('\n').join(' ');
  2997. child.nodeValue = child.nodeValue.replace(/(\s)+/g, '$1');
  2998. }
  2999. } else if (child.nodeType === 1) {
  3000. clean(child);
  3001. }
  3002. }
  3003. }
  3004. // find all pre tags and replace contents with placeholder
  3005. // we need this so that we can remove all indentation from html
  3006. // to ease up parsing
  3007. function substitutePreCodeTags (doc) {
  3008. var pres = doc.querySelectorAll('pre'),
  3009. presPH = [];
  3010. for (var i = 0; i < pres.length; ++i) {
  3011. if (pres[i].childElementCount === 1 && pres[i].firstChild.tagName.toLowerCase() === 'code') {
  3012. var content = pres[i].firstChild.innerHTML.trim(),
  3013. language = pres[i].firstChild.getAttribute('data-language') || '';
  3014. // if data-language attribute is not defined, then we look for class language-*
  3015. if (language === '') {
  3016. var classes = pres[i].firstChild.className.split(' ');
  3017. for (var c = 0; c < classes.length; ++c) {
  3018. var matches = classes[c].match(/^language-(.+)$/);
  3019. if (matches !== null) {
  3020. language = matches[1];
  3021. break;
  3022. }
  3023. }
  3024. }
  3025. // unescape html entities in content
  3026. content = showdown.helper.unescapeHTMLEntities(content);
  3027. presPH.push(content);
  3028. pres[i].outerHTML = '<precode language="' + language + '" precodenum="' + i.toString() + '"></precode>';
  3029. } else {
  3030. presPH.push(pres[i].innerHTML);
  3031. pres[i].innerHTML = '';
  3032. pres[i].setAttribute('prenum', i.toString());
  3033. }
  3034. }
  3035. return presPH;
  3036. }
  3037. return mdDoc;
  3038. };
  3039. /**
  3040. * Set an option of this Converter instance
  3041. * @param {string} key
  3042. * @param {*} value
  3043. */
  3044. this.setOption = function (key, value) {
  3045. options[key] = value;
  3046. };
  3047. /**
  3048. * Get the option of this Converter instance
  3049. * @param {string} key
  3050. * @returns {*}
  3051. */
  3052. this.getOption = function (key) {
  3053. return options[key];
  3054. };
  3055. /**
  3056. * Get the options of this Converter instance
  3057. * @returns {{}}
  3058. */
  3059. this.getOptions = function () {
  3060. return options;
  3061. };
  3062. /**
  3063. * Add extension to THIS converter
  3064. * @param {{}} extension
  3065. * @param {string} [name=null]
  3066. */
  3067. this.addExtension = function (extension, name) {
  3068. name = name || null;
  3069. _parseExtension(extension, name);
  3070. };
  3071. /**
  3072. * Use a global registered extension with THIS converter
  3073. * @param {string} extensionName Name of the previously registered extension
  3074. */
  3075. this.useExtension = function (extensionName) {
  3076. _parseExtension(extensionName);
  3077. };
  3078. /**
  3079. * Set the flavor THIS converter should use
  3080. * @param {string} name
  3081. */
  3082. this.setFlavor = function (name) {
  3083. if (!flavor.hasOwnProperty(name)) {
  3084. throw Error(name + ' flavor was not found');
  3085. }
  3086. var preset = flavor[name];
  3087. setConvFlavor = name;
  3088. for (var option in preset) {
  3089. if (preset.hasOwnProperty(option)) {
  3090. options[option] = preset[option];
  3091. }
  3092. }
  3093. };
  3094. /**
  3095. * Get the currently set flavor of this converter
  3096. * @returns {string}
  3097. */
  3098. this.getFlavor = function () {
  3099. return setConvFlavor;
  3100. };
  3101. /**
  3102. * Remove an extension from THIS converter.
  3103. * Note: This is a costly operation. It's better to initialize a new converter
  3104. * and specify the extensions you wish to use
  3105. * @param {Array} extension
  3106. */
  3107. this.removeExtension = function (extension) {
  3108. if (!showdown.helper.isArray(extension)) {
  3109. extension = [extension];
  3110. }
  3111. for (var a = 0; a < extension.length; ++a) {
  3112. var ext = extension[a];
  3113. for (var i = 0; i < langExtensions.length; ++i) {
  3114. if (langExtensions[i] === ext) {
  3115. langExtensions[i].splice(i, 1);
  3116. }
  3117. }
  3118. for (var ii = 0; ii < outputModifiers.length; ++i) {
  3119. if (outputModifiers[ii] === ext) {
  3120. outputModifiers[ii].splice(i, 1);
  3121. }
  3122. }
  3123. }
  3124. };
  3125. /**
  3126. * Get all extension of THIS converter
  3127. * @returns {{language: Array, output: Array}}
  3128. */
  3129. this.getAllExtensions = function () {
  3130. return {
  3131. language: langExtensions,
  3132. output: outputModifiers
  3133. };
  3134. };
  3135. /**
  3136. * Get the metadata of the previously parsed document
  3137. * @param raw
  3138. * @returns {string|{}}
  3139. */
  3140. this.getMetadata = function (raw) {
  3141. if (raw) {
  3142. return metadata.raw;
  3143. } else {
  3144. return metadata.parsed;
  3145. }
  3146. };
  3147. /**
  3148. * Get the metadata format of the previously parsed document
  3149. * @returns {string}
  3150. */
  3151. this.getMetadataFormat = function () {
  3152. return metadata.format;
  3153. };
  3154. /**
  3155. * Private: set a single key, value metadata pair
  3156. * @param {string} key
  3157. * @param {string} value
  3158. */
  3159. this._setMetadataPair = function (key, value) {
  3160. metadata.parsed[key] = value;
  3161. };
  3162. /**
  3163. * Private: set metadata format
  3164. * @param {string} format
  3165. */
  3166. this._setMetadataFormat = function (format) {
  3167. metadata.format = format;
  3168. };
  3169. /**
  3170. * Private: set metadata raw text
  3171. * @param {string} raw
  3172. */
  3173. this._setMetadataRaw = function (raw) {
  3174. metadata.raw = raw;
  3175. };
  3176. };
  3177. /**
  3178. * Turn Markdown link shortcuts into XHTML <a> tags.
  3179. */
  3180. showdown.subParser('anchors', function (text, options, globals) {
  3181. 'use strict';
  3182. text = globals.converter._dispatch('anchors.before', text, options, globals);
  3183. var writeAnchorTag = function (wholeMatch, linkText, linkId, url, m5, m6, title) {
  3184. if (showdown.helper.isUndefined(title)) {
  3185. title = '';
  3186. }
  3187. linkId = linkId.toLowerCase();
  3188. // Special case for explicit empty url
  3189. if (wholeMatch.search(/\(<?\s*>? ?(['"].*['"])?\)$/m) > -1) {
  3190. url = '';
  3191. } else if (!url) {
  3192. if (!linkId) {
  3193. // lower-case and turn embedded newlines into spaces
  3194. linkId = linkText.toLowerCase().replace(/ ?\n/g, ' ');
  3195. }
  3196. url = '#' + linkId;
  3197. if (!showdown.helper.isUndefined(globals.gUrls[linkId])) {
  3198. url = globals.gUrls[linkId];
  3199. if (!showdown.helper.isUndefined(globals.gTitles[linkId])) {
  3200. title = globals.gTitles[linkId];
  3201. }
  3202. } else {
  3203. return wholeMatch;
  3204. }
  3205. }
  3206. //url = showdown.helper.escapeCharacters(url, '*_', false); // replaced line to improve performance
  3207. url = url.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  3208. var result = '<a href="' + url + '"';
  3209. if (title !== '' && title !== null) {
  3210. title = title.replace(/"/g, '&quot;');
  3211. //title = showdown.helper.escapeCharacters(title, '*_', false); // replaced line to improve performance
  3212. title = title.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  3213. result += ' title="' + title + '"';
  3214. }
  3215. // optionLinksInNewWindow only applies
  3216. // to external links. Hash links (#) open in same page
  3217. if (options.openLinksInNewWindow && !/^#/.test(url)) {
  3218. // escaped _
  3219. result += ' rel="noopener noreferrer" target="¨E95Eblank"';
  3220. }
  3221. result += '>' + linkText + '</a>';
  3222. return result;
  3223. };
  3224. // First, handle reference-style links: [link text] [id]
  3225. text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)] ?(?:\n *)?\[(.*?)]()()()()/g, writeAnchorTag);
  3226. // Next, inline-style links: [link text](url "optional title")
  3227. // cases with crazy urls like ./image/cat1).png
  3228. text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)]()[ \t]*\([ \t]?<([^>]*)>(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g,
  3229. writeAnchorTag);
  3230. // normal cases
  3231. text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)]()[ \t]*\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g,
  3232. writeAnchorTag);
  3233. // handle reference-style shortcuts: [link text]
  3234. // These must come last in case you've also got [link test][1]
  3235. // or [link test](/foo)
  3236. text = text.replace(/\[([^\[\]]+)]()()()()()/g, writeAnchorTag);
  3237. // Lastly handle GithubMentions if option is enabled
  3238. if (options.ghMentions) {
  3239. text = text.replace(/(^|\s)(\\)?(@([a-z\d]+(?:[a-z\d.-]+?[a-z\d]+)*))/gmi, function (wm, st, escape, mentions, username) {
  3240. if (escape === '\\') {
  3241. return st + mentions;
  3242. }
  3243. //check if options.ghMentionsLink is a string
  3244. if (!showdown.helper.isString(options.ghMentionsLink)) {
  3245. throw new Error('ghMentionsLink option must be a string');
  3246. }
  3247. var lnk = options.ghMentionsLink.replace(/\{u}/g, username),
  3248. target = '';
  3249. if (options.openLinksInNewWindow) {
  3250. target = ' rel="noopener noreferrer" target="¨E95Eblank"';
  3251. }
  3252. return st + '<a href="' + lnk + '"' + target + '>' + mentions + '</a>';
  3253. });
  3254. }
  3255. text = globals.converter._dispatch('anchors.after', text, options, globals);
  3256. return text;
  3257. });
  3258. // url allowed chars [a-z\d_.~:/?#[]@!$&'()*+,;=-]
  3259. var simpleURLRegex = /([*~_]+|\b)(((https?|ftp|dict):\/\/|www\.)[^'">\s]+?\.[^'">\s]+?)()(\1)?(?=\s|$)(?!["<>])/gi,
  3260. simpleURLRegex2 = /([*~_]+|\b)(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+?)([.!?,()\[\]])?(\1)?(?=\s|$)(?!["<>])/gi,
  3261. delimUrlRegex = /()<(((https?|ftp|dict):\/\/|www\.)[^'">\s]+)()>()/gi,
  3262. simpleMailRegex = /(^|\s)(?:mailto:)?([A-Za-z0-9!#$%&'*+-/=?^_`{|}~.]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(?=$|\s)/gmi,
  3263. delimMailRegex = /<()(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,
  3264. replaceLink = function (options) {
  3265. 'use strict';
  3266. return function (wm, leadingMagicChars, link, m2, m3, trailingPunctuation, trailingMagicChars) {
  3267. link = link.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  3268. var lnkTxt = link,
  3269. append = '',
  3270. target = '',
  3271. lmc = leadingMagicChars || '',
  3272. tmc = trailingMagicChars || '';
  3273. if (/^www\./i.test(link)) {
  3274. link = link.replace(/^www\./i, 'http://www.');
  3275. }
  3276. if (options.excludeTrailingPunctuationFromURLs && trailingPunctuation) {
  3277. append = trailingPunctuation;
  3278. }
  3279. if (options.openLinksInNewWindow) {
  3280. target = ' rel="noopener noreferrer" target="¨E95Eblank"';
  3281. }
  3282. return lmc + '<a href="' + link + '"' + target + '>' + lnkTxt + '</a>' + append + tmc;
  3283. };
  3284. },
  3285. replaceMail = function (options, globals) {
  3286. 'use strict';
  3287. return function (wholeMatch, b, mail) {
  3288. var href = 'mailto:';
  3289. b = b || '';
  3290. mail = showdown.subParser('unescapeSpecialChars')(mail, options, globals);
  3291. if (options.encodeEmails) {
  3292. href = showdown.helper.encodeEmailAddress(href + mail);
  3293. mail = showdown.helper.encodeEmailAddress(mail);
  3294. } else {
  3295. href = href + mail;
  3296. }
  3297. return b + '<a href="' + href + '">' + mail + '</a>';
  3298. };
  3299. };
  3300. showdown.subParser('autoLinks', function (text, options, globals) {
  3301. 'use strict';
  3302. text = globals.converter._dispatch('autoLinks.before', text, options, globals);
  3303. text = text.replace(delimUrlRegex, replaceLink(options));
  3304. text = text.replace(delimMailRegex, replaceMail(options, globals));
  3305. text = globals.converter._dispatch('autoLinks.after', text, options, globals);
  3306. return text;
  3307. });
  3308. showdown.subParser('simplifiedAutoLinks', function (text, options, globals) {
  3309. 'use strict';
  3310. if (!options.simplifiedAutoLink) {
  3311. return text;
  3312. }
  3313. text = globals.converter._dispatch('simplifiedAutoLinks.before', text, options, globals);
  3314. if (options.excludeTrailingPunctuationFromURLs) {
  3315. text = text.replace(simpleURLRegex2, replaceLink(options));
  3316. } else {
  3317. text = text.replace(simpleURLRegex, replaceLink(options));
  3318. }
  3319. text = text.replace(simpleMailRegex, replaceMail(options, globals));
  3320. text = globals.converter._dispatch('simplifiedAutoLinks.after', text, options, globals);
  3321. return text;
  3322. });
  3323. /**
  3324. * These are all the transformations that form block-level
  3325. * tags like paragraphs, headers, and list items.
  3326. */
  3327. showdown.subParser('blockGamut', function (text, options, globals) {
  3328. 'use strict';
  3329. text = globals.converter._dispatch('blockGamut.before', text, options, globals);
  3330. // we parse blockquotes first so that we can have headings and hrs
  3331. // inside blockquotes
  3332. text = showdown.subParser('blockQuotes')(text, options, globals);
  3333. text = showdown.subParser('headers')(text, options, globals);
  3334. // Do Horizontal Rules:
  3335. text = showdown.subParser('horizontalRule')(text, options, globals);
  3336. text = showdown.subParser('lists')(text, options, globals);
  3337. text = showdown.subParser('codeBlocks')(text, options, globals);
  3338. text = showdown.subParser('tables')(text, options, globals);
  3339. // We already ran _HashHTMLBlocks() before, in Markdown(), but that
  3340. // was to escape raw HTML in the original Markdown source. This time,
  3341. // we're escaping the markup we've just created, so that we don't wrap
  3342. // <p> tags around block-level tags.
  3343. text = showdown.subParser('hashHTMLBlocks')(text, options, globals);
  3344. text = showdown.subParser('paragraphs')(text, options, globals);
  3345. text = globals.converter._dispatch('blockGamut.after', text, options, globals);
  3346. return text;
  3347. });
  3348. showdown.subParser('blockQuotes', function (text, options, globals) {
  3349. 'use strict';
  3350. text = globals.converter._dispatch('blockQuotes.before', text, options, globals);
  3351. // add a couple extra lines after the text and endtext mark
  3352. text = text + '\n\n';
  3353. var rgx = /(^ {0,3}>[ \t]?.+\n(.+\n)*\n*)+/gm;
  3354. if (options.splitAdjacentBlockquotes) {
  3355. rgx = /^ {0,3}>[\s\S]*?(?:\n\n)/gm;
  3356. }
  3357. text = text.replace(rgx, function (bq) {
  3358. // attacklab: hack around Konqueror 3.5.4 bug:
  3359. // "----------bug".replace(/^-/g,"") == "bug"
  3360. bq = bq.replace(/^[ \t]*>[ \t]?/gm, ''); // trim one level of quoting
  3361. // attacklab: clean up hack
  3362. bq = bq.replace(/¨0/g, '');
  3363. bq = bq.replace(/^[ \t]+$/gm, ''); // trim whitespace-only lines
  3364. bq = showdown.subParser('githubCodeBlocks')(bq, options, globals);
  3365. bq = showdown.subParser('blockGamut')(bq, options, globals); // recurse
  3366. bq = bq.replace(/(^|\n)/g, '$1 ');
  3367. // These leading spaces screw with <pre> content, so we need to fix that:
  3368. bq = bq.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm, function (wholeMatch, m1) {
  3369. var pre = m1;
  3370. // attacklab: hack around Konqueror 3.5.4 bug:
  3371. pre = pre.replace(/^ /mg, '¨0');
  3372. pre = pre.replace(/¨0/g, '');
  3373. return pre;
  3374. });
  3375. return showdown.subParser('hashBlock')('<blockquote>\n' + bq + '\n</blockquote>', options, globals);
  3376. });
  3377. text = globals.converter._dispatch('blockQuotes.after', text, options, globals);
  3378. return text;
  3379. });
  3380. /**
  3381. * Process Markdown `<pre><code>` blocks.
  3382. */
  3383. showdown.subParser('codeBlocks', function (text, options, globals) {
  3384. 'use strict';
  3385. text = globals.converter._dispatch('codeBlocks.before', text, options, globals);
  3386. // sentinel workarounds for lack of \A and \Z, safari\khtml bug
  3387. text += '¨0';
  3388. var pattern = /(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=¨0))/g;
  3389. text = text.replace(pattern, function (wholeMatch, m1, m2) {
  3390. var codeblock = m1,
  3391. nextChar = m2,
  3392. end = '\n';
  3393. codeblock = showdown.subParser('outdent')(codeblock, options, globals);
  3394. codeblock = showdown.subParser('encodeCode')(codeblock, options, globals);
  3395. codeblock = showdown.subParser('detab')(codeblock, options, globals);
  3396. codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
  3397. codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing newlines
  3398. if (options.omitExtraWLInCodeBlocks) {
  3399. end = '';
  3400. }
  3401. codeblock = '<pre><code>' + codeblock + end + '</code></pre>';
  3402. return showdown.subParser('hashBlock')(codeblock, options, globals) + nextChar;
  3403. });
  3404. // strip sentinel
  3405. text = text.replace(/¨0/, '');
  3406. text = globals.converter._dispatch('codeBlocks.after', text, options, globals);
  3407. return text;
  3408. });
  3409. /**
  3410. *
  3411. * * Backtick quotes are used for <code></code> spans.
  3412. *
  3413. * * You can use multiple backticks as the delimiters if you want to
  3414. * include literal backticks in the code span. So, this input:
  3415. *
  3416. * Just type ``foo `bar` baz`` at the prompt.
  3417. *
  3418. * Will translate to:
  3419. *
  3420. * <p>Just type <code>foo `bar` baz</code> at the prompt.</p>
  3421. *
  3422. * There's no arbitrary limit to the number of backticks you
  3423. * can use as delimters. If you need three consecutive backticks
  3424. * in your code, use four for delimiters, etc.
  3425. *
  3426. * * You can use spaces to get literal backticks at the edges:
  3427. *
  3428. * ... type `` `bar` `` ...
  3429. *
  3430. * Turns to:
  3431. *
  3432. * ... type <code>`bar`</code> ...
  3433. */
  3434. showdown.subParser('codeSpans', function (text, options, globals) {
  3435. 'use strict';
  3436. text = globals.converter._dispatch('codeSpans.before', text, options, globals);
  3437. if (typeof text === 'undefined') {
  3438. text = '';
  3439. }
  3440. text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
  3441. function (wholeMatch, m1, m2, m3) {
  3442. var c = m3;
  3443. c = c.replace(/^([ \t]*)/g, ''); // leading whitespace
  3444. c = c.replace(/[ \t]*$/g, ''); // trailing whitespace
  3445. c = showdown.subParser('encodeCode')(c, options, globals);
  3446. c = m1 + '<code>' + c + '</code>';
  3447. c = showdown.subParser('hashHTMLSpans')(c, options, globals);
  3448. return c;
  3449. }
  3450. );
  3451. text = globals.converter._dispatch('codeSpans.after', text, options, globals);
  3452. return text;
  3453. });
  3454. /**
  3455. * Create a full HTML document from the processed markdown
  3456. */
  3457. showdown.subParser('completeHTMLDocument', function (text, options, globals) {
  3458. 'use strict';
  3459. if (!options.completeHTMLDocument) {
  3460. return text;
  3461. }
  3462. text = globals.converter._dispatch('completeHTMLDocument.before', text, options, globals);
  3463. var doctype = 'html',
  3464. doctypeParsed = '<!DOCTYPE HTML>\n',
  3465. title = '',
  3466. charset = '<meta charset="utf-8">\n',
  3467. lang = '',
  3468. metadata = '';
  3469. if (typeof globals.metadata.parsed.doctype !== 'undefined') {
  3470. doctypeParsed = '<!DOCTYPE ' + globals.metadata.parsed.doctype + '>\n';
  3471. doctype = globals.metadata.parsed.doctype.toString().toLowerCase();
  3472. if (doctype === 'html' || doctype === 'html5') {
  3473. charset = '<meta charset="utf-8">';
  3474. }
  3475. }
  3476. for (var meta in globals.metadata.parsed) {
  3477. if (globals.metadata.parsed.hasOwnProperty(meta)) {
  3478. switch (meta.toLowerCase()) {
  3479. case 'doctype':
  3480. break;
  3481. case 'title':
  3482. title = '<title>' + globals.metadata.parsed.title + '</title>\n';
  3483. break;
  3484. case 'charset':
  3485. if (doctype === 'html' || doctype === 'html5') {
  3486. charset = '<meta charset="' + globals.metadata.parsed.charset + '">\n';
  3487. } else {
  3488. charset = '<meta name="charset" content="' + globals.metadata.parsed.charset + '">\n';
  3489. }
  3490. break;
  3491. case 'language':
  3492. case 'lang':
  3493. lang = ' lang="' + globals.metadata.parsed[meta] + '"';
  3494. metadata += '<meta name="' + meta + '" content="' + globals.metadata.parsed[meta] + '">\n';
  3495. break;
  3496. default:
  3497. metadata += '<meta name="' + meta + '" content="' + globals.metadata.parsed[meta] + '">\n';
  3498. }
  3499. }
  3500. }
  3501. text = doctypeParsed + '<html' + lang + '>\n<head>\n' + title + charset + metadata + '</head>\n<body>\n' + text.trim() + '\n</body>\n</html>';
  3502. text = globals.converter._dispatch('completeHTMLDocument.after', text, options, globals);
  3503. return text;
  3504. });
  3505. /**
  3506. * Convert all tabs to spaces
  3507. */
  3508. showdown.subParser('detab', function (text, options, globals) {
  3509. 'use strict';
  3510. text = globals.converter._dispatch('detab.before', text, options, globals);
  3511. // expand first n-1 tabs
  3512. text = text.replace(/\t(?=\t)/g, ' '); // g_tab_width
  3513. // replace the nth with two sentinels
  3514. text = text.replace(/\t/g, '¨A¨B');
  3515. // use the sentinel to anchor our regex so it doesn't explode
  3516. text = text.replace(/¨B(.+?)¨A/g, function (wholeMatch, m1) {
  3517. var leadingText = m1,
  3518. numSpaces = 4 - leadingText.length % 4; // g_tab_width
  3519. // there *must* be a better way to do this:
  3520. for (var i = 0; i < numSpaces; i++) {
  3521. leadingText += ' ';
  3522. }
  3523. return leadingText;
  3524. });
  3525. // clean up sentinels
  3526. text = text.replace(/¨A/g, ' '); // g_tab_width
  3527. text = text.replace(/¨B/g, '');
  3528. text = globals.converter._dispatch('detab.after', text, options, globals);
  3529. return text;
  3530. });
  3531. showdown.subParser('ellipsis', function (text, options, globals) {
  3532. 'use strict';
  3533. text = globals.converter._dispatch('ellipsis.before', text, options, globals);
  3534. text = text.replace(/\.\.\./g, '…');
  3535. text = globals.converter._dispatch('ellipsis.after', text, options, globals);
  3536. return text;
  3537. });
  3538. /**
  3539. * Turn emoji codes into emojis
  3540. *
  3541. * List of supported emojis: https://github.com/showdownjs/showdown/wiki/Emojis
  3542. */
  3543. showdown.subParser('emoji', function (text, options, globals) {
  3544. 'use strict';
  3545. if (!options.emoji) {
  3546. return text;
  3547. }
  3548. text = globals.converter._dispatch('emoji.before', text, options, globals);
  3549. var emojiRgx = /:([\S]+?):/g;
  3550. text = text.replace(emojiRgx, function (wm, emojiCode) {
  3551. if (showdown.helper.emojis.hasOwnProperty(emojiCode)) {
  3552. return showdown.helper.emojis[emojiCode];
  3553. }
  3554. return wm;
  3555. });
  3556. text = globals.converter._dispatch('emoji.after', text, options, globals);
  3557. return text;
  3558. });
  3559. /**
  3560. * Smart processing for ampersands and angle brackets that need to be encoded.
  3561. */
  3562. showdown.subParser('encodeAmpsAndAngles', function (text, options, globals) {
  3563. 'use strict';
  3564. text = globals.converter._dispatch('encodeAmpsAndAngles.before', text, options, globals);
  3565. // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
  3566. // http://bumppo.net/projects/amputator/
  3567. text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, '&amp;');
  3568. // Encode naked <'s
  3569. text = text.replace(/<(?![a-z\/?$!])/gi, '&lt;');
  3570. // Encode <
  3571. text = text.replace(/</g, '&lt;');
  3572. // Encode >
  3573. text = text.replace(/>/g, '&gt;');
  3574. text = globals.converter._dispatch('encodeAmpsAndAngles.after', text, options, globals);
  3575. return text;
  3576. });
  3577. /**
  3578. * Returns the string, with after processing the following backslash escape sequences.
  3579. *
  3580. * attacklab: The polite way to do this is with the new escapeCharacters() function:
  3581. *
  3582. * text = escapeCharacters(text,"\\",true);
  3583. * text = escapeCharacters(text,"`*_{}[]()>#+-.!",true);
  3584. *
  3585. * ...but we're sidestepping its use of the (slow) RegExp constructor
  3586. * as an optimization for Firefox. This function gets called a LOT.
  3587. */
  3588. showdown.subParser('encodeBackslashEscapes', function (text, options, globals) {
  3589. 'use strict';
  3590. text = globals.converter._dispatch('encodeBackslashEscapes.before', text, options, globals);
  3591. text = text.replace(/\\(\\)/g, showdown.helper.escapeCharactersCallback);
  3592. text = text.replace(/\\([`*_{}\[\]()>#+.!~=|-])/g, showdown.helper.escapeCharactersCallback);
  3593. text = globals.converter._dispatch('encodeBackslashEscapes.after', text, options, globals);
  3594. return text;
  3595. });
  3596. /**
  3597. * Encode/escape certain characters inside Markdown code runs.
  3598. * The point is that in code, these characters are literals,
  3599. * and lose their special Markdown meanings.
  3600. */
  3601. showdown.subParser('encodeCode', function (text, options, globals) {
  3602. 'use strict';
  3603. text = globals.converter._dispatch('encodeCode.before', text, options, globals);
  3604. // Encode all ampersands; HTML entities are not
  3605. // entities within a Markdown code span.
  3606. text = text
  3607. .replace(/&/g, '&amp;')
  3608. // Do the angle bracket song and dance:
  3609. .replace(/</g, '&lt;')
  3610. .replace(/>/g, '&gt;')
  3611. // Now, escape characters that are magic in Markdown:
  3612. .replace(/([*_{}\[\]\\=~-])/g, showdown.helper.escapeCharactersCallback);
  3613. text = globals.converter._dispatch('encodeCode.after', text, options, globals);
  3614. return text;
  3615. });
  3616. /**
  3617. * Within tags -- meaning between < and > -- encode [\ ` * _ ~ =] so they
  3618. * don't conflict with their use in Markdown for code, italics and strong.
  3619. */
  3620. showdown.subParser('escapeSpecialCharsWithinTagAttributes', function (text, options, globals) {
  3621. 'use strict';
  3622. text = globals.converter._dispatch('escapeSpecialCharsWithinTagAttributes.before', text, options, globals);
  3623. // Build a regex to find HTML tags.
  3624. var tags = /<\/?[a-z\d_:-]+(?:[\s]+[\s\S]+?)?>/gi,
  3625. comments = /<!(--(?:(?:[^>-]|-[^>])(?:[^-]|-[^-])*)--)>/gi;
  3626. text = text.replace(tags, function (wholeMatch) {
  3627. return wholeMatch
  3628. .replace(/(.)<\/?code>(?=.)/g, '$1`')
  3629. .replace(/([\\`*_~=|])/g, showdown.helper.escapeCharactersCallback);
  3630. });
  3631. text = text.replace(comments, function (wholeMatch) {
  3632. return wholeMatch
  3633. .replace(/([\\`*_~=|])/g, showdown.helper.escapeCharactersCallback);
  3634. });
  3635. text = globals.converter._dispatch('escapeSpecialCharsWithinTagAttributes.after', text, options, globals);
  3636. return text;
  3637. });
  3638. /**
  3639. * Handle github codeblocks prior to running HashHTML so that
  3640. * HTML contained within the codeblock gets escaped properly
  3641. * Example:
  3642. * ```ruby
  3643. * def hello_world(x)
  3644. * puts "Hello, #{x}"
  3645. * end
  3646. * ```
  3647. */
  3648. showdown.subParser('githubCodeBlocks', function (text, options, globals) {
  3649. 'use strict';
  3650. // early exit if option is not enabled
  3651. if (!options.ghCodeBlocks) {
  3652. return text;
  3653. }
  3654. text = globals.converter._dispatch('githubCodeBlocks.before', text, options, globals);
  3655. text += '¨0';
  3656. text = text.replace(/(?:^|\n)(?: {0,3})(```+|~~~+)(?: *)([^\s`~]*)\n([\s\S]*?)\n(?: {0,3})\1/g, function (wholeMatch, delim, language, codeblock) {
  3657. var end = (options.omitExtraWLInCodeBlocks) ? '' : '\n';
  3658. // First parse the github code block
  3659. codeblock = showdown.subParser('encodeCode')(codeblock, options, globals);
  3660. codeblock = showdown.subParser('detab')(codeblock, options, globals);
  3661. codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
  3662. codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing whitespace
  3663. codeblock = '<pre><code' + (language ? ' class="' + language + ' language-' + language + '"' : '') + '>' + codeblock + end + '</code></pre>';
  3664. codeblock = showdown.subParser('hashBlock')(codeblock, options, globals);
  3665. // Since GHCodeblocks can be false positives, we need to
  3666. // store the primitive text and the parsed text in a global var,
  3667. // and then return a token
  3668. return '\n\n¨G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n';
  3669. });
  3670. // attacklab: strip sentinel
  3671. text = text.replace(/¨0/, '');
  3672. return globals.converter._dispatch('githubCodeBlocks.after', text, options, globals);
  3673. });
  3674. showdown.subParser('hashBlock', function (text, options, globals) {
  3675. 'use strict';
  3676. text = globals.converter._dispatch('hashBlock.before', text, options, globals);
  3677. text = text.replace(/(^\n+|\n+$)/g, '');
  3678. text = '\n\n¨K' + (globals.gHtmlBlocks.push(text) - 1) + 'K\n\n';
  3679. text = globals.converter._dispatch('hashBlock.after', text, options, globals);
  3680. return text;
  3681. });
  3682. /**
  3683. * Hash and escape <code> elements that should not be parsed as markdown
  3684. */
  3685. showdown.subParser('hashCodeTags', function (text, options, globals) {
  3686. 'use strict';
  3687. text = globals.converter._dispatch('hashCodeTags.before', text, options, globals);
  3688. var repFunc = function (wholeMatch, match, left, right) {
  3689. var codeblock = left + showdown.subParser('encodeCode')(match, options, globals) + right;
  3690. return '¨C' + (globals.gHtmlSpans.push(codeblock) - 1) + 'C';
  3691. };
  3692. // Hash naked <code>
  3693. text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '<code\\b[^>]*>', '</code>', 'gim');
  3694. text = globals.converter._dispatch('hashCodeTags.after', text, options, globals);
  3695. return text;
  3696. });
  3697. showdown.subParser('hashElement', function (text, options, globals) {
  3698. 'use strict';
  3699. return function (wholeMatch, m1) {
  3700. var blockText = m1;
  3701. // Undo double lines
  3702. blockText = blockText.replace(/\n\n/g, '\n');
  3703. blockText = blockText.replace(/^\n/, '');
  3704. // strip trailing blank lines
  3705. blockText = blockText.replace(/\n+$/g, '');
  3706. // Replace the element text with a marker ("¨KxK" where x is its key)
  3707. blockText = '\n\n¨K' + (globals.gHtmlBlocks.push(blockText) - 1) + 'K\n\n';
  3708. return blockText;
  3709. };
  3710. });
  3711. showdown.subParser('hashHTMLBlocks', function (text, options, globals) {
  3712. 'use strict';
  3713. text = globals.converter._dispatch('hashHTMLBlocks.before', text, options, globals);
  3714. var blockTags = [
  3715. 'pre',
  3716. 'div',
  3717. 'h1',
  3718. 'h2',
  3719. 'h3',
  3720. 'h4',
  3721. 'h5',
  3722. 'h6',
  3723. 'blockquote',
  3724. 'table',
  3725. 'dl',
  3726. 'ol',
  3727. 'ul',
  3728. 'script',
  3729. 'noscript',
  3730. 'form',
  3731. 'fieldset',
  3732. 'iframe',
  3733. 'math',
  3734. 'style',
  3735. 'section',
  3736. 'header',
  3737. 'footer',
  3738. 'nav',
  3739. 'article',
  3740. 'aside',
  3741. 'address',
  3742. 'audio',
  3743. 'canvas',
  3744. 'figure',
  3745. 'hgroup',
  3746. 'output',
  3747. 'video',
  3748. 'p'
  3749. ],
  3750. repFunc = function (wholeMatch, match, left, right) {
  3751. var txt = wholeMatch;
  3752. // check if this html element is marked as markdown
  3753. // if so, it's contents should be parsed as markdown
  3754. if (left.search(/\bmarkdown\b/) !== -1) {
  3755. txt = left + globals.converter.makeHtml(match) + right;
  3756. }
  3757. return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n';
  3758. };
  3759. if (options.backslashEscapesHTMLTags) {
  3760. // encode backslash escaped HTML tags
  3761. text = text.replace(/\\<(\/?[^>]+?)>/g, function (wm, inside) {
  3762. return '&lt;' + inside + '&gt;';
  3763. });
  3764. }
  3765. // hash HTML Blocks
  3766. for (var i = 0; i < blockTags.length; ++i) {
  3767. var opTagPos,
  3768. rgx1 = new RegExp('^ {0,3}(<' + blockTags[i] + '\\b[^>]*>)', 'im'),
  3769. patLeft = '<' + blockTags[i] + '\\b[^>]*>',
  3770. patRight = '</' + blockTags[i] + '>';
  3771. // 1. Look for the first position of the first opening HTML tag in the text
  3772. while ((opTagPos = showdown.helper.regexIndexOf(text, rgx1)) !== -1) {
  3773. // if the HTML tag is \ escaped, we need to escape it and break
  3774. //2. Split the text in that position
  3775. var subTexts = showdown.helper.splitAtIndex(text, opTagPos),
  3776. //3. Match recursively
  3777. newSubText1 = showdown.helper.replaceRecursiveRegExp(subTexts[1], repFunc, patLeft, patRight, 'im');
  3778. // prevent an infinite loop
  3779. if (newSubText1 === subTexts[1]) {
  3780. break;
  3781. }
  3782. text = subTexts[0].concat(newSubText1);
  3783. }
  3784. }
  3785. // HR SPECIAL CASE
  3786. text = text.replace(/(\n {0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,
  3787. showdown.subParser('hashElement')(text, options, globals));
  3788. // Special case for standalone HTML comments
  3789. text = showdown.helper.replaceRecursiveRegExp(text, function (txt) {
  3790. return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n';
  3791. }, '^ {0,3}<!--', '-->', 'gm');
  3792. // PHP and ASP-style processor instructions (<?...?> and <%...%>)
  3793. text = text.replace(/(?:\n\n)( {0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,
  3794. showdown.subParser('hashElement')(text, options, globals));
  3795. text = globals.converter._dispatch('hashHTMLBlocks.after', text, options, globals);
  3796. return text;
  3797. });
  3798. /**
  3799. * Hash span elements that should not be parsed as markdown
  3800. */
  3801. showdown.subParser('hashHTMLSpans', function (text, options, globals) {
  3802. 'use strict';
  3803. text = globals.converter._dispatch('hashHTMLSpans.before', text, options, globals);
  3804. function hashHTMLSpan (html) {
  3805. return '¨C' + (globals.gHtmlSpans.push(html) - 1) + 'C';
  3806. }
  3807. // Hash Self Closing tags
  3808. text = text.replace(/<[^>]+?\/>/gi, function (wm) {
  3809. return hashHTMLSpan(wm);
  3810. });
  3811. // Hash tags without properties
  3812. text = text.replace(/<([^>]+?)>[\s\S]*?<\/\1>/g, function (wm) {
  3813. return hashHTMLSpan(wm);
  3814. });
  3815. // Hash tags with properties
  3816. text = text.replace(/<([^>]+?)\s[^>]+?>[\s\S]*?<\/\1>/g, function (wm) {
  3817. return hashHTMLSpan(wm);
  3818. });
  3819. // Hash self closing tags without />
  3820. text = text.replace(/<[^>]+?>/gi, function (wm) {
  3821. return hashHTMLSpan(wm);
  3822. });
  3823. /*showdown.helper.matchRecursiveRegExp(text, '<code\\b[^>]*>', '</code>', 'gi');*/
  3824. text = globals.converter._dispatch('hashHTMLSpans.after', text, options, globals);
  3825. return text;
  3826. });
  3827. /**
  3828. * Unhash HTML spans
  3829. */
  3830. showdown.subParser('unhashHTMLSpans', function (text, options, globals) {
  3831. 'use strict';
  3832. text = globals.converter._dispatch('unhashHTMLSpans.before', text, options, globals);
  3833. for (var i = 0; i < globals.gHtmlSpans.length; ++i) {
  3834. var repText = globals.gHtmlSpans[i],
  3835. // limiter to prevent infinite loop (assume 10 as limit for recurse)
  3836. limit = 0;
  3837. while (/¨C(\d+)C/.test(repText)) {
  3838. var num = RegExp.$1;
  3839. repText = repText.replace('¨C' + num + 'C', globals.gHtmlSpans[num]);
  3840. if (limit === 10) {
  3841. console.error('maximum nesting of 10 spans reached!!!');
  3842. break;
  3843. }
  3844. ++limit;
  3845. }
  3846. text = text.replace('¨C' + i + 'C', repText);
  3847. }
  3848. text = globals.converter._dispatch('unhashHTMLSpans.after', text, options, globals);
  3849. return text;
  3850. });
  3851. /**
  3852. * Hash and escape <pre><code> elements that should not be parsed as markdown
  3853. */
  3854. showdown.subParser('hashPreCodeTags', function (text, options, globals) {
  3855. 'use strict';
  3856. text = globals.converter._dispatch('hashPreCodeTags.before', text, options, globals);
  3857. var repFunc = function (wholeMatch, match, left, right) {
  3858. // encode html entities
  3859. var codeblock = left + showdown.subParser('encodeCode')(match, options, globals) + right;
  3860. return '\n\n¨G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n';
  3861. };
  3862. // Hash <pre><code>
  3863. text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '^ {0,3}<pre\\b[^>]*>\\s*<code\\b[^>]*>', '^ {0,3}</code>\\s*</pre>', 'gim');
  3864. text = globals.converter._dispatch('hashPreCodeTags.after', text, options, globals);
  3865. return text;
  3866. });
  3867. showdown.subParser('headers', function (text, options, globals) {
  3868. 'use strict';
  3869. text = globals.converter._dispatch('headers.before', text, options, globals);
  3870. var headerLevelStart = (isNaN(parseInt(options.headerLevelStart))) ? 1 : parseInt(options.headerLevelStart),
  3871. // Set text-style headers:
  3872. // Header 1
  3873. // ========
  3874. //
  3875. // Header 2
  3876. // --------
  3877. //
  3878. setextRegexH1 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n={2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n=+[ \t]*\n+/gm,
  3879. setextRegexH2 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n-{2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n-+[ \t]*\n+/gm;
  3880. text = text.replace(setextRegexH1, function (wholeMatch, m1) {
  3881. var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
  3882. hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
  3883. hLevel = headerLevelStart,
  3884. hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>';
  3885. return showdown.subParser('hashBlock')(hashBlock, options, globals);
  3886. });
  3887. text = text.replace(setextRegexH2, function (matchFound, m1) {
  3888. var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
  3889. hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
  3890. hLevel = headerLevelStart + 1,
  3891. hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>';
  3892. return showdown.subParser('hashBlock')(hashBlock, options, globals);
  3893. });
  3894. // atx-style headers:
  3895. // # Header 1
  3896. // ## Header 2
  3897. // ## Header 2 with closing hashes ##
  3898. // ...
  3899. // ###### Header 6
  3900. //
  3901. var atxStyle = (options.requireSpaceBeforeHeadingText) ? /^(#{1,6})[ \t]+(.+?)[ \t]*#*\n+/gm : /^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm;
  3902. text = text.replace(atxStyle, function (wholeMatch, m1, m2) {
  3903. var hText = m2;
  3904. if (options.customizedHeaderId) {
  3905. hText = m2.replace(/\s?\{([^{]+?)}\s*$/, '');
  3906. }
  3907. var span = showdown.subParser('spanGamut')(hText, options, globals),
  3908. hID = (options.noHeaderId) ? '' : ' id="' + headerId(m2) + '"',
  3909. hLevel = headerLevelStart - 1 + m1.length,
  3910. header = '<h' + hLevel + hID + '>' + span + '</h' + hLevel + '>';
  3911. return showdown.subParser('hashBlock')(header, options, globals);
  3912. });
  3913. function headerId (m) {
  3914. var title,
  3915. prefix;
  3916. // It is separate from other options to allow combining prefix and customized
  3917. if (options.customizedHeaderId) {
  3918. var match = m.match(/\{([^{]+?)}\s*$/);
  3919. if (match && match[1]) {
  3920. m = match[1];
  3921. }
  3922. }
  3923. title = m;
  3924. // Prefix id to prevent causing inadvertent pre-existing style matches.
  3925. if (showdown.helper.isString(options.prefixHeaderId)) {
  3926. prefix = options.prefixHeaderId;
  3927. } else if (options.prefixHeaderId === true) {
  3928. prefix = 'section-';
  3929. } else {
  3930. prefix = '';
  3931. }
  3932. if (!options.rawPrefixHeaderId) {
  3933. title = prefix + title;
  3934. }
  3935. if (options.ghCompatibleHeaderId) {
  3936. title = title
  3937. .replace(/ /g, '-')
  3938. // replace previously escaped chars (&, ¨ and $)
  3939. .replace(/&amp;/g, '')
  3940. .replace(/¨T/g, '')
  3941. .replace(/¨D/g, '')
  3942. // replace rest of the chars (&~$ are repeated as they might have been escaped)
  3943. // borrowed from github's redcarpet (some they should produce similar results)
  3944. .replace(/[&+$,\/:;=?@"#{}|^¨~\[\]`\\*)(%.!'<>]/g, '')
  3945. .toLowerCase();
  3946. } else if (options.rawHeaderId) {
  3947. title = title
  3948. .replace(/ /g, '-')
  3949. // replace previously escaped chars (&, ¨ and $)
  3950. .replace(/&amp;/g, '&')
  3951. .replace(/¨T/g, '¨')
  3952. .replace(/¨D/g, '$')
  3953. // replace " and '
  3954. .replace(/["']/g, '-')
  3955. .toLowerCase();
  3956. } else {
  3957. title = title
  3958. .replace(/[^\w]/g, '')
  3959. .toLowerCase();
  3960. }
  3961. if (options.rawPrefixHeaderId) {
  3962. title = prefix + title;
  3963. }
  3964. if (globals.hashLinkCounts[title]) {
  3965. title = title + '-' + (globals.hashLinkCounts[title]++);
  3966. } else {
  3967. globals.hashLinkCounts[title] = 1;
  3968. }
  3969. return title;
  3970. }
  3971. text = globals.converter._dispatch('headers.after', text, options, globals);
  3972. return text;
  3973. });
  3974. /**
  3975. * Turn Markdown link shortcuts into XHTML <a> tags.
  3976. */
  3977. showdown.subParser('horizontalRule', function (text, options, globals) {
  3978. 'use strict';
  3979. text = globals.converter._dispatch('horizontalRule.before', text, options, globals);
  3980. var key = showdown.subParser('hashBlock')('<hr />', options, globals);
  3981. text = text.replace(/^ {0,2}( ?-){3,}[ \t]*$/gm, key);
  3982. text = text.replace(/^ {0,2}( ?\*){3,}[ \t]*$/gm, key);
  3983. text = text.replace(/^ {0,2}( ?_){3,}[ \t]*$/gm, key);
  3984. text = globals.converter._dispatch('horizontalRule.after', text, options, globals);
  3985. return text;
  3986. });
  3987. /**
  3988. * Turn Markdown image shortcuts into <img> tags.
  3989. */
  3990. showdown.subParser('images', function (text, options, globals) {
  3991. 'use strict';
  3992. text = globals.converter._dispatch('images.before', text, options, globals);
  3993. var inlineRegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g,
  3994. crazyRegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<([^>]*)>(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(?:(["'])([^"]*?)\6))?[ \t]?\)/g,
  3995. 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,
  3996. referenceRegExp = /!\[([^\]]*?)] ?(?:\n *)?\[([\s\S]*?)]()()()()()/g,
  3997. refShortcutRegExp = /!\[([^\[\]]+)]()()()()()/g;
  3998. function writeImageTagBase64 (wholeMatch, altText, linkId, url, width, height, m5, title) {
  3999. url = url.replace(/\s/g, '');
  4000. return writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title);
  4001. }
  4002. function writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title) {
  4003. var gUrls = globals.gUrls,
  4004. gTitles = globals.gTitles,
  4005. gDims = globals.gDimensions;
  4006. linkId = linkId.toLowerCase();
  4007. if (!title) {
  4008. title = '';
  4009. }
  4010. // Special case for explicit empty url
  4011. if (wholeMatch.search(/\(<?\s*>? ?(['"].*['"])?\)$/m) > -1) {
  4012. url = '';
  4013. } else if (url === '' || url === null) {
  4014. if (linkId === '' || linkId === null) {
  4015. // lower-case and turn embedded newlines into spaces
  4016. linkId = altText.toLowerCase().replace(/ ?\n/g, ' ');
  4017. }
  4018. url = '#' + linkId;
  4019. if (!showdown.helper.isUndefined(gUrls[linkId])) {
  4020. url = gUrls[linkId];
  4021. if (!showdown.helper.isUndefined(gTitles[linkId])) {
  4022. title = gTitles[linkId];
  4023. }
  4024. if (!showdown.helper.isUndefined(gDims[linkId])) {
  4025. width = gDims[linkId].width;
  4026. height = gDims[linkId].height;
  4027. }
  4028. } else {
  4029. return wholeMatch;
  4030. }
  4031. }
  4032. altText = altText
  4033. .replace(/"/g, '&quot;')
  4034. //altText = showdown.helper.escapeCharacters(altText, '*_', false);
  4035. .replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  4036. //url = showdown.helper.escapeCharacters(url, '*_', false);
  4037. url = url.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  4038. var result = '<img src="' + url + '" alt="' + altText + '"';
  4039. if (title && showdown.helper.isString(title)) {
  4040. title = title
  4041. .replace(/"/g, '&quot;')
  4042. //title = showdown.helper.escapeCharacters(title, '*_', false);
  4043. .replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
  4044. result += ' title="' + title + '"';
  4045. }
  4046. if (width && height) {
  4047. width = (width === '*') ? 'auto' : width;
  4048. height = (height === '*') ? 'auto' : height;
  4049. result += ' width="' + width + '"';
  4050. result += ' height="' + height + '"';
  4051. }
  4052. result += ' />';
  4053. return result;
  4054. }
  4055. // First, handle reference-style labeled images: ![alt text][id]
  4056. text = text.replace(referenceRegExp, writeImageTag);
  4057. // Next, handle inline images: ![alt text](url =<width>x<height> "optional title")
  4058. // base64 encoded images
  4059. text = text.replace(base64RegExp, writeImageTagBase64);
  4060. // cases with crazy urls like ./image/cat1).png
  4061. text = text.replace(crazyRegExp, writeImageTag);
  4062. // normal cases
  4063. text = text.replace(inlineRegExp, writeImageTag);
  4064. // handle reference-style shortcuts: ![img text]
  4065. text = text.replace(refShortcutRegExp, writeImageTag);
  4066. text = globals.converter._dispatch('images.after', text, options, globals);
  4067. return text;
  4068. });
  4069. showdown.subParser('italicsAndBold', function (text, options, globals) {
  4070. 'use strict';
  4071. text = globals.converter._dispatch('italicsAndBold.before', text, options, globals);
  4072. // it's faster to have 3 separate regexes for each case than have just one
  4073. // because of backtracing, in some cases, it could lead to an exponential effect
  4074. // called "catastrophic backtrace". Ominous!
  4075. function parseInside (txt, left, right) {
  4076. /*
  4077. if (options.simplifiedAutoLink) {
  4078. txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals);
  4079. }
  4080. */
  4081. return left + txt + right;
  4082. }
  4083. // Parse underscores
  4084. if (options.literalMidWordUnderscores) {
  4085. text = text.replace(/\b___(\S[\s\S]*?)___\b/g, function (wm, txt) {
  4086. return parseInside (txt, '<strong><em>', '</em></strong>');
  4087. });
  4088. text = text.replace(/\b__(\S[\s\S]*?)__\b/g, function (wm, txt) {
  4089. return parseInside (txt, '<strong>', '</strong>');
  4090. });
  4091. text = text.replace(/\b_(\S[\s\S]*?)_\b/g, function (wm, txt) {
  4092. return parseInside (txt, '<em>', '</em>');
  4093. });
  4094. } else {
  4095. text = text.replace(/___(\S[\s\S]*?)___/g, function (wm, m) {
  4096. return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm;
  4097. });
  4098. text = text.replace(/__(\S[\s\S]*?)__/g, function (wm, m) {
  4099. return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : wm;
  4100. });
  4101. text = text.replace(/_([^\s_][\s\S]*?)_/g, function (wm, m) {
  4102. // !/^_[^_]/.test(m) - test if it doesn't start with __ (since it seems redundant, we removed it)
  4103. return (/\S$/.test(m)) ? parseInside (m, '<em>', '</em>') : wm;
  4104. });
  4105. }
  4106. // Now parse asterisks
  4107. if (options.literalMidWordAsterisks) {
  4108. text = text.replace(/([^*]|^)\B\*\*\*(\S[\s\S]*?)\*\*\*\B(?!\*)/g, function (wm, lead, txt) {
  4109. return parseInside (txt, lead + '<strong><em>', '</em></strong>');
  4110. });
  4111. text = text.replace(/([^*]|^)\B\*\*(\S[\s\S]*?)\*\*\B(?!\*)/g, function (wm, lead, txt) {
  4112. return parseInside (txt, lead + '<strong>', '</strong>');
  4113. });
  4114. text = text.replace(/([^*]|^)\B\*(\S[\s\S]*?)\*\B(?!\*)/g, function (wm, lead, txt) {
  4115. return parseInside (txt, lead + '<em>', '</em>');
  4116. });
  4117. } else {
  4118. text = text.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function (wm, m) {
  4119. return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm;
  4120. });
  4121. text = text.replace(/\*\*(\S[\s\S]*?)\*\*/g, function (wm, m) {
  4122. return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : wm;
  4123. });
  4124. text = text.replace(/\*([^\s*][\s\S]*?)\*/g, function (wm, m) {
  4125. // !/^\*[^*]/.test(m) - test if it doesn't start with ** (since it seems redundant, we removed it)
  4126. return (/\S$/.test(m)) ? parseInside (m, '<em>', '</em>') : wm;
  4127. });
  4128. }
  4129. text = globals.converter._dispatch('italicsAndBold.after', text, options, globals);
  4130. return text;
  4131. });
  4132. /**
  4133. * Form HTML ordered (numbered) and unordered (bulleted) lists.
  4134. */
  4135. showdown.subParser('lists', function (text, options, globals) {
  4136. 'use strict';
  4137. /**
  4138. * Process the contents of a single ordered or unordered list, splitting it
  4139. * into individual list items.
  4140. * @param {string} listStr
  4141. * @param {boolean} trimTrailing
  4142. * @returns {string}
  4143. */
  4144. function processListItems (listStr, trimTrailing) {
  4145. // The $g_list_level global keeps track of when we're inside a list.
  4146. // Each time we enter a list, we increment it; when we leave a list,
  4147. // we decrement. If it's zero, we're not in a list anymore.
  4148. //
  4149. // We do this because when we're not inside a list, we want to treat
  4150. // something like this:
  4151. //
  4152. // I recommend upgrading to version
  4153. // 8. Oops, now this line is treated
  4154. // as a sub-list.
  4155. //
  4156. // As a single paragraph, despite the fact that the second line starts
  4157. // with a digit-period-space sequence.
  4158. //
  4159. // Whereas when we're inside a list (or sub-list), that line will be
  4160. // treated as the start of a sub-list. What a kludge, huh? This is
  4161. // an aspect of Markdown's syntax that's hard to parse perfectly
  4162. // without resorting to mind-reading. Perhaps the solution is to
  4163. // change the syntax rules such that sub-lists must start with a
  4164. // starting cardinal number; e.g. "1." or "a.".
  4165. globals.gListLevel++;
  4166. // trim trailing blank lines:
  4167. listStr = listStr.replace(/\n{2,}$/, '\n');
  4168. // attacklab: add sentinel to emulate \z
  4169. listStr += '¨0';
  4170. var rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0| {0,3}([*+-]|\d+[.])[ \t]+))/gm,
  4171. isParagraphed = (/\n[ \t]*\n(?!¨0)/.test(listStr));
  4172. // Since version 1.5, nesting sublists requires 4 spaces (or 1 tab) indentation,
  4173. // which is a syntax breaking change
  4174. // activating this option reverts to old behavior
  4175. if (options.disableForced4SpacesIndentedSublists) {
  4176. rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0|\2([*+-]|\d+[.])[ \t]+))/gm;
  4177. }
  4178. listStr = listStr.replace(rgx, function (wholeMatch, m1, m2, m3, m4, taskbtn, checked) {
  4179. checked = (checked && checked.trim() !== '');
  4180. var item = showdown.subParser('outdent')(m4, options, globals),
  4181. bulletStyle = '';
  4182. // Support for github tasklists
  4183. if (taskbtn && options.tasklists) {
  4184. bulletStyle = ' class="task-list-item" style="list-style-type: none;"';
  4185. item = item.replace(/^[ \t]*\[(x|X| )?]/m, function () {
  4186. var otp = '<input type="checkbox" disabled style="margin: 0px 0.35em 0.25em -1.6em; vertical-align: middle;"';
  4187. if (checked) {
  4188. otp += ' checked';
  4189. }
  4190. otp += '>';
  4191. return otp;
  4192. });
  4193. }
  4194. // ISSUE #312
  4195. // This input: - - - a
  4196. // causes trouble to the parser, since it interprets it as:
  4197. // <ul><li><li><li>a</li></li></li></ul>
  4198. // instead of:
  4199. // <ul><li>- - a</li></ul>
  4200. // So, to prevent it, we will put a marker (¨A)in the beginning of the line
  4201. // Kind of hackish/monkey patching, but seems more effective than overcomplicating the list parser
  4202. item = item.replace(/^([-*+]|\d\.)[ \t]+[\S\n ]*/g, function (wm2) {
  4203. return '¨A' + wm2;
  4204. });
  4205. // m1 - Leading line or
  4206. // Has a double return (multi paragraph) or
  4207. // Has sublist
  4208. if (m1 || (item.search(/\n{2,}/) > -1)) {
  4209. item = showdown.subParser('githubCodeBlocks')(item, options, globals);
  4210. item = showdown.subParser('blockGamut')(item, options, globals);
  4211. } else {
  4212. // Recursion for sub-lists:
  4213. item = showdown.subParser('lists')(item, options, globals);
  4214. item = item.replace(/\n$/, ''); // chomp(item)
  4215. item = showdown.subParser('hashHTMLBlocks')(item, options, globals);
  4216. // Colapse double linebreaks
  4217. item = item.replace(/\n\n+/g, '\n\n');
  4218. if (isParagraphed) {
  4219. item = showdown.subParser('paragraphs')(item, options, globals);
  4220. } else {
  4221. item = showdown.subParser('spanGamut')(item, options, globals);
  4222. }
  4223. }
  4224. // now we need to remove the marker (¨A)
  4225. item = item.replace('¨A', '');
  4226. // we can finally wrap the line in list item tags
  4227. item = '<li' + bulletStyle + '>' + item + '</li>\n';
  4228. return item;
  4229. });
  4230. // attacklab: strip sentinel
  4231. listStr = listStr.replace(/¨0/g, '');
  4232. globals.gListLevel--;
  4233. if (trimTrailing) {
  4234. listStr = listStr.replace(/\s+$/, '');
  4235. }
  4236. return listStr;
  4237. }
  4238. function styleStartNumber (list, listType) {
  4239. // check if ol and starts by a number different than 1
  4240. if (listType === 'ol') {
  4241. var res = list.match(/^ *(\d+)\./);
  4242. if (res && res[1] !== '1') {
  4243. return ' start="' + res[1] + '"';
  4244. }
  4245. }
  4246. return '';
  4247. }
  4248. /**
  4249. * Check and parse consecutive lists (better fix for issue #142)
  4250. * @param {string} list
  4251. * @param {string} listType
  4252. * @param {boolean} trimTrailing
  4253. * @returns {string}
  4254. */
  4255. function parseConsecutiveLists (list, listType, trimTrailing) {
  4256. // check if we caught 2 or more consecutive lists by mistake
  4257. // we use the counterRgx, meaning if listType is UL we look for OL and vice versa
  4258. var olRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?\d+\.[ \t]/gm : /^ {0,3}\d+\.[ \t]/gm,
  4259. ulRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?[*+-][ \t]/gm : /^ {0,3}[*+-][ \t]/gm,
  4260. counterRxg = (listType === 'ul') ? olRgx : ulRgx,
  4261. result = '';
  4262. if (list.search(counterRxg) !== -1) {
  4263. (function parseCL (txt) {
  4264. var pos = txt.search(counterRxg),
  4265. style = styleStartNumber(list, listType);
  4266. if (pos !== -1) {
  4267. // slice
  4268. result += '\n\n<' + listType + style + '>\n' + processListItems(txt.slice(0, pos), !!trimTrailing) + '</' + listType + '>\n';
  4269. // invert counterType and listType
  4270. listType = (listType === 'ul') ? 'ol' : 'ul';
  4271. counterRxg = (listType === 'ul') ? olRgx : ulRgx;
  4272. //recurse
  4273. parseCL(txt.slice(pos));
  4274. } else {
  4275. result += '\n\n<' + listType + style + '>\n' + processListItems(txt, !!trimTrailing) + '</' + listType + '>\n';
  4276. }
  4277. })(list);
  4278. } else {
  4279. var style = styleStartNumber(list, listType);
  4280. result = '\n\n<' + listType + style + '>\n' + processListItems(list, !!trimTrailing) + '</' + listType + '>\n';
  4281. }
  4282. return result;
  4283. }
  4284. /** Start of list parsing **/
  4285. text = globals.converter._dispatch('lists.before', text, options, globals);
  4286. // add sentinel to hack around khtml/safari bug:
  4287. // http://bugs.webkit.org/show_bug.cgi?id=11231
  4288. text += '¨0';
  4289. if (globals.gListLevel) {
  4290. text = text.replace(/^(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm,
  4291. function (wholeMatch, list, m2) {
  4292. var listType = (m2.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
  4293. return parseConsecutiveLists(list, listType, true);
  4294. }
  4295. );
  4296. } else {
  4297. text = text.replace(/(\n\n|^\n?)(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm,
  4298. function (wholeMatch, m1, list, m3) {
  4299. var listType = (m3.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
  4300. return parseConsecutiveLists(list, listType, false);
  4301. }
  4302. );
  4303. }
  4304. // strip sentinel
  4305. text = text.replace(/¨0/, '');
  4306. text = globals.converter._dispatch('lists.after', text, options, globals);
  4307. return text;
  4308. });
  4309. /**
  4310. * Parse metadata at the top of the document
  4311. */
  4312. showdown.subParser('metadata', function (text, options, globals) {
  4313. 'use strict';
  4314. if (!options.metadata) {
  4315. return text;
  4316. }
  4317. text = globals.converter._dispatch('metadata.before', text, options, globals);
  4318. function parseMetadataContents (content) {
  4319. // raw is raw so it's not changed in any way
  4320. globals.metadata.raw = content;
  4321. // escape chars forbidden in html attributes
  4322. // double quotes
  4323. content = content
  4324. // ampersand first
  4325. .replace(/&/g, '&amp;')
  4326. // double quotes
  4327. .replace(/"/g, '&quot;');
  4328. content = content.replace(/\n {4}/g, ' ');
  4329. content.replace(/^([\S ]+): +([\s\S]+?)$/gm, function (wm, key, value) {
  4330. globals.metadata.parsed[key] = value;
  4331. return '';
  4332. });
  4333. }
  4334. text = text.replace(/^\s*«««+(\S*?)\n([\s\S]+?)\n»»»+\n/, function (wholematch, format, content) {
  4335. parseMetadataContents(content);
  4336. return '¨M';
  4337. });
  4338. text = text.replace(/^\s*---+(\S*?)\n([\s\S]+?)\n---+\n/, function (wholematch, format, content) {
  4339. if (format) {
  4340. globals.metadata.format = format;
  4341. }
  4342. parseMetadataContents(content);
  4343. return '¨M';
  4344. });
  4345. text = text.replace(/¨M/g, '');
  4346. text = globals.converter._dispatch('metadata.after', text, options, globals);
  4347. return text;
  4348. });
  4349. /**
  4350. * Remove one level of line-leading tabs or spaces
  4351. */
  4352. showdown.subParser('outdent', function (text, options, globals) {
  4353. 'use strict';
  4354. text = globals.converter._dispatch('outdent.before', text, options, globals);
  4355. // attacklab: hack around Konqueror 3.5.4 bug:
  4356. // "----------bug".replace(/^-/g,"") == "bug"
  4357. text = text.replace(/^(\t|[ ]{1,4})/gm, '¨0'); // attacklab: g_tab_width
  4358. // attacklab: clean up hack
  4359. text = text.replace(/¨0/g, '');
  4360. text = globals.converter._dispatch('outdent.after', text, options, globals);
  4361. return text;
  4362. });
  4363. /**
  4364. *
  4365. */
  4366. showdown.subParser('paragraphs', function (text, options, globals) {
  4367. 'use strict';
  4368. text = globals.converter._dispatch('paragraphs.before', text, options, globals);
  4369. // Strip leading and trailing lines:
  4370. text = text.replace(/^\n+/g, '');
  4371. text = text.replace(/\n+$/g, '');
  4372. var grafs = text.split(/\n{2,}/g),
  4373. grafsOut = [],
  4374. end = grafs.length; // Wrap <p> tags
  4375. for (var i = 0; i < end; i++) {
  4376. var str = grafs[i];
  4377. // if this is an HTML marker, copy it
  4378. if (str.search(/¨(K|G)(\d+)\1/g) >= 0) {
  4379. grafsOut.push(str);
  4380. // test for presence of characters to prevent empty lines being parsed
  4381. // as paragraphs (resulting in undesired extra empty paragraphs)
  4382. } else if (str.search(/\S/) >= 0) {
  4383. str = showdown.subParser('spanGamut')(str, options, globals);
  4384. str = str.replace(/^([ \t]*)/g, '<p>');
  4385. str += '</p>';
  4386. grafsOut.push(str);
  4387. }
  4388. }
  4389. /** Unhashify HTML blocks */
  4390. end = grafsOut.length;
  4391. for (i = 0; i < end; i++) {
  4392. var blockText = '',
  4393. grafsOutIt = grafsOut[i],
  4394. codeFlag = false;
  4395. // if this is a marker for an html block...
  4396. // use RegExp.test instead of string.search because of QML bug
  4397. while (/¨(K|G)(\d+)\1/.test(grafsOutIt)) {
  4398. var delim = RegExp.$1,
  4399. num = RegExp.$2;
  4400. if (delim === 'K') {
  4401. blockText = globals.gHtmlBlocks[num];
  4402. } else {
  4403. // we need to check if ghBlock is a false positive
  4404. if (codeFlag) {
  4405. // use encoded version of all text
  4406. blockText = showdown.subParser('encodeCode')(globals.ghCodeBlocks[num].text, options, globals);
  4407. } else {
  4408. blockText = globals.ghCodeBlocks[num].codeblock;
  4409. }
  4410. }
  4411. blockText = blockText.replace(/\$/g, '$$$$'); // Escape any dollar signs
  4412. grafsOutIt = grafsOutIt.replace(/(\n\n)?¨(K|G)\d+\2(\n\n)?/, blockText);
  4413. // Check if grafsOutIt is a pre->code
  4414. if (/^<pre\b[^>]*>\s*<code\b[^>]*>/.test(grafsOutIt)) {
  4415. codeFlag = true;
  4416. }
  4417. }
  4418. grafsOut[i] = grafsOutIt;
  4419. }
  4420. text = grafsOut.join('\n');
  4421. // Strip leading and trailing lines:
  4422. text = text.replace(/^\n+/g, '');
  4423. text = text.replace(/\n+$/g, '');
  4424. return globals.converter._dispatch('paragraphs.after', text, options, globals);
  4425. });
  4426. /**
  4427. * Run extension
  4428. */
  4429. showdown.subParser('runExtension', function (ext, text, options, globals) {
  4430. 'use strict';
  4431. if (ext.filter) {
  4432. text = ext.filter(text, globals.converter, options);
  4433. } else if (ext.regex) {
  4434. // TODO remove this when old extension loading mechanism is deprecated
  4435. var re = ext.regex;
  4436. if (!(re instanceof RegExp)) {
  4437. re = new RegExp(re, 'g');
  4438. }
  4439. text = text.replace(re, ext.replace);
  4440. }
  4441. return text;
  4442. });
  4443. /**
  4444. * These are all the transformations that occur *within* block-level
  4445. * tags like paragraphs, headers, and list items.
  4446. */
  4447. showdown.subParser('spanGamut', function (text, options, globals) {
  4448. 'use strict';
  4449. text = globals.converter._dispatch('spanGamut.before', text, options, globals);
  4450. text = showdown.subParser('codeSpans')(text, options, globals);
  4451. text = showdown.subParser('escapeSpecialCharsWithinTagAttributes')(text, options, globals);
  4452. text = showdown.subParser('encodeBackslashEscapes')(text, options, globals);
  4453. // Process anchor and image tags. Images must come first,
  4454. // because ![foo][f] looks like an anchor.
  4455. text = showdown.subParser('images')(text, options, globals);
  4456. text = showdown.subParser('anchors')(text, options, globals);
  4457. // Make links out of things like `<http://example.com/>`
  4458. // Must come after anchors, because you can use < and >
  4459. // delimiters in inline links like [this](<url>).
  4460. text = showdown.subParser('autoLinks')(text, options, globals);
  4461. text = showdown.subParser('simplifiedAutoLinks')(text, options, globals);
  4462. text = showdown.subParser('emoji')(text, options, globals);
  4463. text = showdown.subParser('underline')(text, options, globals);
  4464. text = showdown.subParser('italicsAndBold')(text, options, globals);
  4465. text = showdown.subParser('strikethrough')(text, options, globals);
  4466. text = showdown.subParser('ellipsis')(text, options, globals);
  4467. // we need to hash HTML tags inside spans
  4468. text = showdown.subParser('hashHTMLSpans')(text, options, globals);
  4469. // now we encode amps and angles
  4470. text = showdown.subParser('encodeAmpsAndAngles')(text, options, globals);
  4471. // Do hard breaks
  4472. if (options.simpleLineBreaks) {
  4473. // GFM style hard breaks
  4474. // only add line breaks if the text does not contain a block (special case for lists)
  4475. if (!/\n\n¨K/.test(text)) {
  4476. text = text.replace(/\n+/g, '<br />\n');
  4477. }
  4478. } else {
  4479. // Vanilla hard breaks
  4480. text = text.replace(/ +\n/g, '<br />\n');
  4481. }
  4482. text = globals.converter._dispatch('spanGamut.after', text, options, globals);
  4483. return text;
  4484. });
  4485. showdown.subParser('strikethrough', function (text, options, globals) {
  4486. 'use strict';
  4487. function parseInside (txt) {
  4488. if (options.simplifiedAutoLink) {
  4489. txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals);
  4490. }
  4491. return '<del>' + txt + '</del>';
  4492. }
  4493. if (options.strikethrough) {
  4494. text = globals.converter._dispatch('strikethrough.before', text, options, globals);
  4495. text = text.replace(/(?:~){2}([\s\S]+?)(?:~){2}/g, function (wm, txt) { return parseInside(txt); });
  4496. text = globals.converter._dispatch('strikethrough.after', text, options, globals);
  4497. }
  4498. return text;
  4499. });
  4500. /**
  4501. * Strips link definitions from text, stores the URLs and titles in
  4502. * hash references.
  4503. * Link defs are in the form: ^[id]: url "optional title"
  4504. */
  4505. showdown.subParser('stripLinkDefinitions', function (text, options, globals) {
  4506. 'use strict';
  4507. 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,
  4508. 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;
  4509. // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
  4510. text += '¨0';
  4511. var replaceFunc = function (wholeMatch, linkId, url, width, height, blankLines, title) {
  4512. linkId = linkId.toLowerCase();
  4513. if (url.match(/^data:.+?\/.+?;base64,/)) {
  4514. // remove newlines
  4515. globals.gUrls[linkId] = url.replace(/\s/g, '');
  4516. } else {
  4517. globals.gUrls[linkId] = showdown.subParser('encodeAmpsAndAngles')(url, options, globals); // Link IDs are case-insensitive
  4518. }
  4519. if (blankLines) {
  4520. // Oops, found blank lines, so it's not a title.
  4521. // Put back the parenthetical statement we stole.
  4522. return blankLines + title;
  4523. } else {
  4524. if (title) {
  4525. globals.gTitles[linkId] = title.replace(/"|'/g, '&quot;');
  4526. }
  4527. if (options.parseImgDimensions && width && height) {
  4528. globals.gDimensions[linkId] = {
  4529. width: width,
  4530. height: height
  4531. };
  4532. }
  4533. }
  4534. // Completely remove the definition from the text
  4535. return '';
  4536. };
  4537. // first we try to find base64 link references
  4538. text = text.replace(base64Regex, replaceFunc);
  4539. text = text.replace(regex, replaceFunc);
  4540. // attacklab: strip sentinel
  4541. text = text.replace(/¨0/, '');
  4542. return text;
  4543. });
  4544. showdown.subParser('tables', function (text, options, globals) {
  4545. 'use strict';
  4546. if (!options.tables) {
  4547. return text;
  4548. }
  4549. var tableRgx = /^ {0,3}\|?.+\|.+\n {0,3}\|?[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:[-=]){2,}[\s\S]+?(?:\n\n|¨0)/gm,
  4550. //singeColTblRgx = /^ {0,3}\|.+\|\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n(?: {0,3}\|.+\|\n)+(?:\n\n|¨0)/gm;
  4551. singeColTblRgx = /^ {0,3}\|.+\|[ \t]*\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n( {0,3}\|.+\|[ \t]*\n)*(?:\n|¨0)/gm;
  4552. function parseStyles (sLine) {
  4553. if (/^:[ \t]*--*$/.test(sLine)) {
  4554. return ' style="text-align:left;"';
  4555. } else if (/^--*[ \t]*:[ \t]*$/.test(sLine)) {
  4556. return ' style="text-align:right;"';
  4557. } else if (/^:[ \t]*--*[ \t]*:$/.test(sLine)) {
  4558. return ' style="text-align:center;"';
  4559. } else {
  4560. return '';
  4561. }
  4562. }
  4563. function parseHeaders (header, style) {
  4564. var id = '';
  4565. header = header.trim();
  4566. // support both tablesHeaderId and tableHeaderId due to error in documentation so we don't break backwards compatibility
  4567. if (options.tablesHeaderId || options.tableHeaderId) {
  4568. id = ' id="' + header.replace(/ /g, '_').toLowerCase() + '"';
  4569. }
  4570. header = showdown.subParser('spanGamut')(header, options, globals);
  4571. return '<th' + id + style + '>' + header + '</th>\n';
  4572. }
  4573. function parseCells (cell, style) {
  4574. var subText = showdown.subParser('spanGamut')(cell, options, globals);
  4575. return '<td' + style + '>' + subText + '</td>\n';
  4576. }
  4577. function buildTable (headers, cells) {
  4578. var tb = '<table>\n<thead>\n<tr>\n',
  4579. tblLgn = headers.length;
  4580. for (var i = 0; i < tblLgn; ++i) {
  4581. tb += headers[i];
  4582. }
  4583. tb += '</tr>\n</thead>\n<tbody>\n';
  4584. for (i = 0; i < cells.length; ++i) {
  4585. tb += '<tr>\n';
  4586. for (var ii = 0; ii < tblLgn; ++ii) {
  4587. tb += cells[i][ii];
  4588. }
  4589. tb += '</tr>\n';
  4590. }
  4591. tb += '</tbody>\n</table>\n';
  4592. return tb;
  4593. }
  4594. function parseTable (rawTable) {
  4595. var i, tableLines = rawTable.split('\n');
  4596. for (i = 0; i < tableLines.length; ++i) {
  4597. // strip wrong first and last column if wrapped tables are used
  4598. if (/^ {0,3}\|/.test(tableLines[i])) {
  4599. tableLines[i] = tableLines[i].replace(/^ {0,3}\|/, '');
  4600. }
  4601. if (/\|[ \t]*$/.test(tableLines[i])) {
  4602. tableLines[i] = tableLines[i].replace(/\|[ \t]*$/, '');
  4603. }
  4604. // parse code spans first, but we only support one line code spans
  4605. tableLines[i] = showdown.subParser('codeSpans')(tableLines[i], options, globals);
  4606. }
  4607. var rawHeaders = tableLines[0].split('|').map(function (s) { return s.trim();}),
  4608. rawStyles = tableLines[1].split('|').map(function (s) { return s.trim();}),
  4609. rawCells = [],
  4610. headers = [],
  4611. styles = [],
  4612. cells = [];
  4613. tableLines.shift();
  4614. tableLines.shift();
  4615. for (i = 0; i < tableLines.length; ++i) {
  4616. if (tableLines[i].trim() === '') {
  4617. continue;
  4618. }
  4619. rawCells.push(
  4620. tableLines[i]
  4621. .split('|')
  4622. .map(function (s) {
  4623. return s.trim();
  4624. })
  4625. );
  4626. }
  4627. if (rawHeaders.length < rawStyles.length) {
  4628. return rawTable;
  4629. }
  4630. for (i = 0; i < rawStyles.length; ++i) {
  4631. styles.push(parseStyles(rawStyles[i]));
  4632. }
  4633. for (i = 0; i < rawHeaders.length; ++i) {
  4634. if (showdown.helper.isUndefined(styles[i])) {
  4635. styles[i] = '';
  4636. }
  4637. headers.push(parseHeaders(rawHeaders[i], styles[i]));
  4638. }
  4639. for (i = 0; i < rawCells.length; ++i) {
  4640. var row = [];
  4641. for (var ii = 0; ii < headers.length; ++ii) {
  4642. if (showdown.helper.isUndefined(rawCells[i][ii])) {
  4643. }
  4644. row.push(parseCells(rawCells[i][ii], styles[ii]));
  4645. }
  4646. cells.push(row);
  4647. }
  4648. return buildTable(headers, cells);
  4649. }
  4650. text = globals.converter._dispatch('tables.before', text, options, globals);
  4651. // find escaped pipe characters
  4652. text = text.replace(/\\(\|)/g, showdown.helper.escapeCharactersCallback);
  4653. // parse multi column tables
  4654. text = text.replace(tableRgx, parseTable);
  4655. // parse one column tables
  4656. text = text.replace(singeColTblRgx, parseTable);
  4657. text = globals.converter._dispatch('tables.after', text, options, globals);
  4658. return text;
  4659. });
  4660. showdown.subParser('underline', function (text, options, globals) {
  4661. 'use strict';
  4662. if (!options.underline) {
  4663. return text;
  4664. }
  4665. text = globals.converter._dispatch('underline.before', text, options, globals);
  4666. if (options.literalMidWordUnderscores) {
  4667. text = text.replace(/\b___(\S[\s\S]*?)___\b/g, function (wm, txt) {
  4668. return '<u>' + txt + '</u>';
  4669. });
  4670. text = text.replace(/\b__(\S[\s\S]*?)__\b/g, function (wm, txt) {
  4671. return '<u>' + txt + '</u>';
  4672. });
  4673. } else {
  4674. text = text.replace(/___(\S[\s\S]*?)___/g, function (wm, m) {
  4675. return (/\S$/.test(m)) ? '<u>' + m + '</u>' : wm;
  4676. });
  4677. text = text.replace(/__(\S[\s\S]*?)__/g, function (wm, m) {
  4678. return (/\S$/.test(m)) ? '<u>' + m + '</u>' : wm;
  4679. });
  4680. }
  4681. // escape remaining underscores to prevent them being parsed by italic and bold
  4682. text = text.replace(/(_)/g, showdown.helper.escapeCharactersCallback);
  4683. text = globals.converter._dispatch('underline.after', text, options, globals);
  4684. return text;
  4685. });
  4686. /**
  4687. * Swap back in all the special characters we've hidden.
  4688. */
  4689. showdown.subParser('unescapeSpecialChars', function (text, options, globals) {
  4690. 'use strict';
  4691. text = globals.converter._dispatch('unescapeSpecialChars.before', text, options, globals);
  4692. text = text.replace(/¨E(\d+)E/g, function (wholeMatch, m1) {
  4693. var charCodeToReplace = parseInt(m1);
  4694. return String.fromCharCode(charCodeToReplace);
  4695. });
  4696. text = globals.converter._dispatch('unescapeSpecialChars.after', text, options, globals);
  4697. return text;
  4698. });
  4699. showdown.subParser('makeMarkdown.blockquote', function (node, globals) {
  4700. 'use strict';
  4701. var txt = '';
  4702. if (node.hasChildNodes()) {
  4703. var children = node.childNodes,
  4704. childrenLength = children.length;
  4705. for (var i = 0; i < childrenLength; ++i) {
  4706. var innerTxt = showdown.subParser('makeMarkdown.node')(children[i], globals);
  4707. if (innerTxt === '') {
  4708. continue;
  4709. }
  4710. txt += innerTxt;
  4711. }
  4712. }
  4713. // cleanup
  4714. txt = txt.trim();
  4715. txt = '> ' + txt.split('\n').join('\n> ');
  4716. return txt;
  4717. });
  4718. showdown.subParser('makeMarkdown.codeBlock', function (node, globals) {
  4719. 'use strict';
  4720. var lang = node.getAttribute('language'),
  4721. num = node.getAttribute('precodenum');
  4722. return '```' + lang + '\n' + globals.preList[num] + '\n```';
  4723. });
  4724. showdown.subParser('makeMarkdown.codeSpan', function (node) {
  4725. 'use strict';
  4726. return '`' + node.innerHTML + '`';
  4727. });
  4728. showdown.subParser('makeMarkdown.emphasis', function (node, globals) {
  4729. 'use strict';
  4730. var txt = '';
  4731. if (node.hasChildNodes()) {
  4732. txt += '*';
  4733. var children = node.childNodes,
  4734. childrenLength = children.length;
  4735. for (var i = 0; i < childrenLength; ++i) {
  4736. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4737. }
  4738. txt += '*';
  4739. }
  4740. return txt;
  4741. });
  4742. showdown.subParser('makeMarkdown.header', function (node, globals, headerLevel) {
  4743. 'use strict';
  4744. var headerMark = new Array(headerLevel + 1).join('#'),
  4745. txt = '';
  4746. if (node.hasChildNodes()) {
  4747. txt = headerMark + ' ';
  4748. var children = node.childNodes,
  4749. childrenLength = children.length;
  4750. for (var i = 0; i < childrenLength; ++i) {
  4751. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4752. }
  4753. }
  4754. return txt;
  4755. });
  4756. showdown.subParser('makeMarkdown.hr', function () {
  4757. 'use strict';
  4758. return '---';
  4759. });
  4760. showdown.subParser('makeMarkdown.image', function (node) {
  4761. 'use strict';
  4762. var txt = '';
  4763. if (node.hasAttribute('src')) {
  4764. txt += '![' + node.getAttribute('alt') + '](';
  4765. txt += '<' + node.getAttribute('src') + '>';
  4766. if (node.hasAttribute('width') && node.hasAttribute('height')) {
  4767. txt += ' =' + node.getAttribute('width') + 'x' + node.getAttribute('height');
  4768. }
  4769. if (node.hasAttribute('title')) {
  4770. txt += ' "' + node.getAttribute('title') + '"';
  4771. }
  4772. txt += ')';
  4773. }
  4774. return txt;
  4775. });
  4776. showdown.subParser('makeMarkdown.links', function (node, globals) {
  4777. 'use strict';
  4778. var txt = '';
  4779. if (node.hasChildNodes() && node.hasAttribute('href')) {
  4780. var children = node.childNodes,
  4781. childrenLength = children.length;
  4782. txt = '[';
  4783. for (var i = 0; i < childrenLength; ++i) {
  4784. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4785. }
  4786. txt += '](';
  4787. txt += '<' + node.getAttribute('href') + '>';
  4788. if (node.hasAttribute('title')) {
  4789. txt += ' "' + node.getAttribute('title') + '"';
  4790. }
  4791. txt += ')';
  4792. }
  4793. return txt;
  4794. });
  4795. showdown.subParser('makeMarkdown.list', function (node, globals, type) {
  4796. 'use strict';
  4797. var txt = '';
  4798. if (!node.hasChildNodes()) {
  4799. return '';
  4800. }
  4801. var listItems = node.childNodes,
  4802. listItemsLenght = listItems.length,
  4803. listNum = node.getAttribute('start') || 1;
  4804. for (var i = 0; i < listItemsLenght; ++i) {
  4805. if (typeof listItems[i].tagName === 'undefined' || listItems[i].tagName.toLowerCase() !== 'li') {
  4806. continue;
  4807. }
  4808. // define the bullet to use in list
  4809. var bullet = '';
  4810. if (type === 'ol') {
  4811. bullet = listNum.toString() + '. ';
  4812. } else {
  4813. bullet = '- ';
  4814. }
  4815. // parse list item
  4816. txt += bullet + showdown.subParser('makeMarkdown.listItem')(listItems[i], globals);
  4817. ++listNum;
  4818. }
  4819. // add comment at the end to prevent consecutive lists to be parsed as one
  4820. txt += '\n<!-- -->\n';
  4821. return txt.trim();
  4822. });
  4823. showdown.subParser('makeMarkdown.listItem', function (node, globals) {
  4824. 'use strict';
  4825. var listItemTxt = '';
  4826. var children = node.childNodes,
  4827. childrenLenght = children.length;
  4828. for (var i = 0; i < childrenLenght; ++i) {
  4829. listItemTxt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4830. }
  4831. // if it's only one liner, we need to add a newline at the end
  4832. if (!/\n$/.test(listItemTxt)) {
  4833. listItemTxt += '\n';
  4834. } else {
  4835. // it's multiparagraph, so we need to indent
  4836. listItemTxt = listItemTxt
  4837. .split('\n')
  4838. .join('\n ')
  4839. .replace(/^ {4}$/gm, '')
  4840. .replace(/\n\n+/g, '\n\n');
  4841. }
  4842. return listItemTxt;
  4843. });
  4844. showdown.subParser('makeMarkdown.node', function (node, globals, spansOnly) {
  4845. 'use strict';
  4846. spansOnly = spansOnly || false;
  4847. var txt = '';
  4848. // edge case of text without wrapper paragraph
  4849. if (node.nodeType === 3) {
  4850. return showdown.subParser('makeMarkdown.txt')(node, globals);
  4851. }
  4852. // HTML comment
  4853. if (node.nodeType === 8) {
  4854. return '<!--' + node.data + '-->\n\n';
  4855. }
  4856. // process only node elements
  4857. if (node.nodeType !== 1) {
  4858. return '';
  4859. }
  4860. var tagName = node.tagName.toLowerCase();
  4861. switch (tagName) {
  4862. //
  4863. // BLOCKS
  4864. //
  4865. case 'h1':
  4866. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 1) + '\n\n'; }
  4867. break;
  4868. case 'h2':
  4869. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 2) + '\n\n'; }
  4870. break;
  4871. case 'h3':
  4872. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 3) + '\n\n'; }
  4873. break;
  4874. case 'h4':
  4875. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 4) + '\n\n'; }
  4876. break;
  4877. case 'h5':
  4878. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 5) + '\n\n'; }
  4879. break;
  4880. case 'h6':
  4881. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 6) + '\n\n'; }
  4882. break;
  4883. case 'p':
  4884. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.paragraph')(node, globals) + '\n\n'; }
  4885. break;
  4886. case 'blockquote':
  4887. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.blockquote')(node, globals) + '\n\n'; }
  4888. break;
  4889. case 'hr':
  4890. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.hr')(node, globals) + '\n\n'; }
  4891. break;
  4892. case 'ol':
  4893. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.list')(node, globals, 'ol') + '\n\n'; }
  4894. break;
  4895. case 'ul':
  4896. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.list')(node, globals, 'ul') + '\n\n'; }
  4897. break;
  4898. case 'precode':
  4899. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.codeBlock')(node, globals) + '\n\n'; }
  4900. break;
  4901. case 'pre':
  4902. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.pre')(node, globals) + '\n\n'; }
  4903. break;
  4904. case 'table':
  4905. if (!spansOnly) { txt = showdown.subParser('makeMarkdown.table')(node, globals) + '\n\n'; }
  4906. break;
  4907. //
  4908. // SPANS
  4909. //
  4910. case 'code':
  4911. txt = showdown.subParser('makeMarkdown.codeSpan')(node, globals);
  4912. break;
  4913. case 'em':
  4914. case 'i':
  4915. txt = showdown.subParser('makeMarkdown.emphasis')(node, globals);
  4916. break;
  4917. case 'strong':
  4918. case 'b':
  4919. txt = showdown.subParser('makeMarkdown.strong')(node, globals);
  4920. break;
  4921. case 'del':
  4922. txt = showdown.subParser('makeMarkdown.strikethrough')(node, globals);
  4923. break;
  4924. case 'a':
  4925. txt = showdown.subParser('makeMarkdown.links')(node, globals);
  4926. break;
  4927. case 'img':
  4928. txt = showdown.subParser('makeMarkdown.image')(node, globals);
  4929. break;
  4930. default:
  4931. txt = node.outerHTML + '\n\n';
  4932. }
  4933. // common normalization
  4934. // TODO eventually
  4935. return txt;
  4936. });
  4937. showdown.subParser('makeMarkdown.paragraph', function (node, globals) {
  4938. 'use strict';
  4939. var txt = '';
  4940. if (node.hasChildNodes()) {
  4941. var children = node.childNodes,
  4942. childrenLength = children.length;
  4943. for (var i = 0; i < childrenLength; ++i) {
  4944. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4945. }
  4946. }
  4947. // some text normalization
  4948. txt = txt.trim();
  4949. return txt;
  4950. });
  4951. showdown.subParser('makeMarkdown.pre', function (node, globals) {
  4952. 'use strict';
  4953. var num = node.getAttribute('prenum');
  4954. return '<pre>' + globals.preList[num] + '</pre>';
  4955. });
  4956. showdown.subParser('makeMarkdown.strikethrough', function (node, globals) {
  4957. 'use strict';
  4958. var txt = '';
  4959. if (node.hasChildNodes()) {
  4960. txt += '~~';
  4961. var children = node.childNodes,
  4962. childrenLength = children.length;
  4963. for (var i = 0; i < childrenLength; ++i) {
  4964. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4965. }
  4966. txt += '~~';
  4967. }
  4968. return txt;
  4969. });
  4970. showdown.subParser('makeMarkdown.strong', function (node, globals) {
  4971. 'use strict';
  4972. var txt = '';
  4973. if (node.hasChildNodes()) {
  4974. txt += '**';
  4975. var children = node.childNodes,
  4976. childrenLength = children.length;
  4977. for (var i = 0; i < childrenLength; ++i) {
  4978. txt += showdown.subParser('makeMarkdown.node')(children[i], globals);
  4979. }
  4980. txt += '**';
  4981. }
  4982. return txt;
  4983. });
  4984. showdown.subParser('makeMarkdown.table', function (node, globals) {
  4985. 'use strict';
  4986. var txt = '',
  4987. tableArray = [[], []],
  4988. headings = node.querySelectorAll('thead>tr>th'),
  4989. rows = node.querySelectorAll('tbody>tr'),
  4990. i, ii;
  4991. for (i = 0; i < headings.length; ++i) {
  4992. var headContent = showdown.subParser('makeMarkdown.tableCell')(headings[i], globals),
  4993. allign = '---';
  4994. if (headings[i].hasAttribute('style')) {
  4995. var style = headings[i].getAttribute('style').toLowerCase().replace(/\s/g, '');
  4996. switch (style) {
  4997. case 'text-align:left;':
  4998. allign = ':---';
  4999. break;
  5000. case 'text-align:right;':
  5001. allign = '---:';
  5002. break;
  5003. case 'text-align:center;':
  5004. allign = ':---:';
  5005. break;
  5006. }
  5007. }
  5008. tableArray[0][i] = headContent.trim();
  5009. tableArray[1][i] = allign;
  5010. }
  5011. for (i = 0; i < rows.length; ++i) {
  5012. var r = tableArray.push([]) - 1,
  5013. cols = rows[i].getElementsByTagName('td');
  5014. for (ii = 0; ii < headings.length; ++ii) {
  5015. var cellContent = ' ';
  5016. if (typeof cols[ii] !== 'undefined') {
  5017. cellContent = showdown.subParser('makeMarkdown.tableCell')(cols[ii], globals);
  5018. }
  5019. tableArray[r].push(cellContent);
  5020. }
  5021. }
  5022. var cellSpacesCount = 3;
  5023. for (i = 0; i < tableArray.length; ++i) {
  5024. for (ii = 0; ii < tableArray[i].length; ++ii) {
  5025. var strLen = tableArray[i][ii].length;
  5026. if (strLen > cellSpacesCount) {
  5027. cellSpacesCount = strLen;
  5028. }
  5029. }
  5030. }
  5031. for (i = 0; i < tableArray.length; ++i) {
  5032. for (ii = 0; ii < tableArray[i].length; ++ii) {
  5033. if (i === 1) {
  5034. if (tableArray[i][ii].slice(-1) === ':') {
  5035. tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii].slice(-1), cellSpacesCount - 1, '-') + ':';
  5036. } else {
  5037. tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii], cellSpacesCount, '-');
  5038. }
  5039. } else {
  5040. tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii], cellSpacesCount);
  5041. }
  5042. }
  5043. txt += '| ' + tableArray[i].join(' | ') + ' |\n';
  5044. }
  5045. return txt.trim();
  5046. });
  5047. showdown.subParser('makeMarkdown.tableCell', function (node, globals) {
  5048. 'use strict';
  5049. var txt = '';
  5050. if (!node.hasChildNodes()) {
  5051. return '';
  5052. }
  5053. var children = node.childNodes,
  5054. childrenLength = children.length;
  5055. for (var i = 0; i < childrenLength; ++i) {
  5056. txt += showdown.subParser('makeMarkdown.node')(children[i], globals, true);
  5057. }
  5058. return txt.trim();
  5059. });
  5060. showdown.subParser('makeMarkdown.txt', function (node) {
  5061. 'use strict';
  5062. var txt = node.nodeValue;
  5063. // multiple spaces are collapsed
  5064. txt = txt.replace(/ +/g, ' ');
  5065. // replace the custom ¨NBSP; with a space
  5066. txt = txt.replace(/¨NBSP;/g, ' ');
  5067. // ", <, > and & should replace escaped html entities
  5068. txt = showdown.helper.unescapeHTMLEntities(txt);
  5069. // escape markdown magic characters
  5070. // emphasis, strong and strikethrough - can appear everywhere
  5071. // we also escape pipe (|) because of tables
  5072. // and escape ` because of code blocks and spans
  5073. txt = txt.replace(/([*_~|`])/g, '\\$1');
  5074. // escape > because of blockquotes
  5075. txt = txt.replace(/^(\s*)>/g, '\\$1>');
  5076. // hash character, only troublesome at the beginning of a line because of headers
  5077. txt = txt.replace(/^#/gm, '\\#');
  5078. // horizontal rules
  5079. txt = txt.replace(/^(\s*)([-=]{3,})(\s*)$/, '$1\\$2$3');
  5080. // dot, because of ordered lists, only troublesome at the beginning of a line when preceded by an integer
  5081. txt = txt.replace(/^( {0,3}\d+)\./gm, '$1\\.');
  5082. // +, * and -, at the beginning of a line becomes a list, so we need to escape them also (asterisk was already escaped)
  5083. txt = txt.replace(/^( {0,3})([+-])/gm, '$1\\$2');
  5084. // images and links, ] followed by ( is problematic, so we escape it
  5085. txt = txt.replace(/]([\s]*)\(/g, '\\]$1\\(');
  5086. // reference URIs must also be escaped
  5087. txt = txt.replace(/^ {0,3}\[([\S \t]*?)]:/gm, '\\[$1]:');
  5088. return txt;
  5089. });
  5090. var root = this;
  5091. // AMD Loader
  5092. if (true) {
  5093. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {
  5094. 'use strict';
  5095. return showdown;
  5096. }).call(exports, __webpack_require__, exports, module),
  5097. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  5098. // CommonJS/nodeJS Loader
  5099. } else {}
  5100. }).call(this);
  5101. /***/ })
  5102. /******/ });
  5103. /************************************************************************/
  5104. /******/ // The module cache
  5105. /******/ var __webpack_module_cache__ = {};
  5106. /******/
  5107. /******/ // The require function
  5108. /******/ function __webpack_require__(moduleId) {
  5109. /******/ // Check if module is in cache
  5110. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  5111. /******/ if (cachedModule !== undefined) {
  5112. /******/ return cachedModule.exports;
  5113. /******/ }
  5114. /******/ // Create a new module (and put it into the cache)
  5115. /******/ var module = __webpack_module_cache__[moduleId] = {
  5116. /******/ // no module.id needed
  5117. /******/ // no module.loaded needed
  5118. /******/ exports: {}
  5119. /******/ };
  5120. /******/
  5121. /******/ // Execute the module function
  5122. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  5123. /******/
  5124. /******/ // Return the exports of the module
  5125. /******/ return module.exports;
  5126. /******/ }
  5127. /******/
  5128. /************************************************************************/
  5129. /******/ /* webpack/runtime/compat get default export */
  5130. /******/ !function() {
  5131. /******/ // getDefaultExport function for compatibility with non-harmony modules
  5132. /******/ __webpack_require__.n = function(module) {
  5133. /******/ var getter = module && module.__esModule ?
  5134. /******/ function() { return module['default']; } :
  5135. /******/ function() { return module; };
  5136. /******/ __webpack_require__.d(getter, { a: getter });
  5137. /******/ return getter;
  5138. /******/ };
  5139. /******/ }();
  5140. /******/
  5141. /******/ /* webpack/runtime/define property getters */
  5142. /******/ !function() {
  5143. /******/ // define getter functions for harmony exports
  5144. /******/ __webpack_require__.d = function(exports, definition) {
  5145. /******/ for(var key in definition) {
  5146. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  5147. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  5148. /******/ }
  5149. /******/ }
  5150. /******/ };
  5151. /******/ }();
  5152. /******/
  5153. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  5154. /******/ !function() {
  5155. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  5156. /******/ }();
  5157. /******/
  5158. /******/ /* webpack/runtime/make namespace object */
  5159. /******/ !function() {
  5160. /******/ // define __esModule on exports
  5161. /******/ __webpack_require__.r = function(exports) {
  5162. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  5163. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  5164. /******/ }
  5165. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  5166. /******/ };
  5167. /******/ }();
  5168. /******/
  5169. /************************************************************************/
  5170. var __webpack_exports__ = {};
  5171. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  5172. !function() {
  5173. "use strict";
  5174. // ESM COMPAT FLAG
  5175. __webpack_require__.r(__webpack_exports__);
  5176. // EXPORTS
  5177. __webpack_require__.d(__webpack_exports__, {
  5178. "__EXPERIMENTAL_ELEMENTS": function() { return /* reexport */ __EXPERIMENTAL_ELEMENTS; },
  5179. "__EXPERIMENTAL_PATHS_WITH_MERGE": function() { return /* reexport */ __EXPERIMENTAL_PATHS_WITH_MERGE; },
  5180. "__EXPERIMENTAL_STYLE_PROPERTY": function() { return /* reexport */ __EXPERIMENTAL_STYLE_PROPERTY; },
  5181. "__experimentalCloneSanitizedBlock": function() { return /* reexport */ __experimentalCloneSanitizedBlock; },
  5182. "__experimentalGetAccessibleBlockLabel": function() { return /* reexport */ getAccessibleBlockLabel; },
  5183. "__experimentalGetBlockAttributesNamesByRole": function() { return /* reexport */ __experimentalGetBlockAttributesNamesByRole; },
  5184. "__experimentalGetBlockLabel": function() { return /* reexport */ getBlockLabel; },
  5185. "__experimentalSanitizeBlockAttributes": function() { return /* reexport */ __experimentalSanitizeBlockAttributes; },
  5186. "__unstableGetBlockProps": function() { return /* reexport */ getBlockProps; },
  5187. "__unstableGetInnerBlocksProps": function() { return /* reexport */ getInnerBlocksProps; },
  5188. "__unstableSerializeAndClean": function() { return /* reexport */ __unstableSerializeAndClean; },
  5189. "children": function() { return /* reexport */ children; },
  5190. "cloneBlock": function() { return /* reexport */ cloneBlock; },
  5191. "createBlock": function() { return /* reexport */ createBlock; },
  5192. "createBlocksFromInnerBlocksTemplate": function() { return /* reexport */ createBlocksFromInnerBlocksTemplate; },
  5193. "doBlocksMatchTemplate": function() { return /* reexport */ doBlocksMatchTemplate; },
  5194. "findTransform": function() { return /* reexport */ findTransform; },
  5195. "getBlockAttributes": function() { return /* reexport */ getBlockAttributes; },
  5196. "getBlockContent": function() { return /* reexport */ getBlockInnerHTML; },
  5197. "getBlockDefaultClassName": function() { return /* reexport */ getBlockDefaultClassName; },
  5198. "getBlockFromExample": function() { return /* reexport */ getBlockFromExample; },
  5199. "getBlockMenuDefaultClassName": function() { return /* reexport */ getBlockMenuDefaultClassName; },
  5200. "getBlockSupport": function() { return /* reexport */ getBlockSupport; },
  5201. "getBlockTransforms": function() { return /* reexport */ getBlockTransforms; },
  5202. "getBlockType": function() { return /* reexport */ getBlockType; },
  5203. "getBlockTypes": function() { return /* reexport */ getBlockTypes; },
  5204. "getBlockVariations": function() { return /* reexport */ getBlockVariations; },
  5205. "getCategories": function() { return /* reexport */ categories_getCategories; },
  5206. "getChildBlockNames": function() { return /* reexport */ getChildBlockNames; },
  5207. "getDefaultBlockName": function() { return /* reexport */ getDefaultBlockName; },
  5208. "getFreeformContentHandlerName": function() { return /* reexport */ getFreeformContentHandlerName; },
  5209. "getGroupingBlockName": function() { return /* reexport */ getGroupingBlockName; },
  5210. "getPhrasingContentSchema": function() { return /* reexport */ deprecatedGetPhrasingContentSchema; },
  5211. "getPossibleBlockTransformations": function() { return /* reexport */ getPossibleBlockTransformations; },
  5212. "getSaveContent": function() { return /* reexport */ getSaveContent; },
  5213. "getSaveElement": function() { return /* reexport */ getSaveElement; },
  5214. "getUnregisteredTypeHandlerName": function() { return /* reexport */ getUnregisteredTypeHandlerName; },
  5215. "hasBlockSupport": function() { return /* reexport */ hasBlockSupport; },
  5216. "hasChildBlocks": function() { return /* reexport */ hasChildBlocks; },
  5217. "hasChildBlocksWithInserterSupport": function() { return /* reexport */ hasChildBlocksWithInserterSupport; },
  5218. "isReusableBlock": function() { return /* reexport */ isReusableBlock; },
  5219. "isTemplatePart": function() { return /* reexport */ isTemplatePart; },
  5220. "isUnmodifiedDefaultBlock": function() { return /* reexport */ isUnmodifiedDefaultBlock; },
  5221. "isValidBlockContent": function() { return /* reexport */ isValidBlockContent; },
  5222. "isValidIcon": function() { return /* reexport */ isValidIcon; },
  5223. "node": function() { return /* reexport */ node; },
  5224. "normalizeIconObject": function() { return /* reexport */ normalizeIconObject; },
  5225. "parse": function() { return /* reexport */ parser_parse; },
  5226. "parseWithAttributeSchema": function() { return /* reexport */ parseWithAttributeSchema; },
  5227. "pasteHandler": function() { return /* reexport */ pasteHandler; },
  5228. "rawHandler": function() { return /* reexport */ rawHandler; },
  5229. "registerBlockCollection": function() { return /* reexport */ registerBlockCollection; },
  5230. "registerBlockStyle": function() { return /* reexport */ registerBlockStyle; },
  5231. "registerBlockType": function() { return /* reexport */ registerBlockType; },
  5232. "registerBlockVariation": function() { return /* reexport */ registerBlockVariation; },
  5233. "serialize": function() { return /* reexport */ serialize; },
  5234. "serializeRawBlock": function() { return /* reexport */ serializeRawBlock; },
  5235. "setCategories": function() { return /* reexport */ categories_setCategories; },
  5236. "setDefaultBlockName": function() { return /* reexport */ setDefaultBlockName; },
  5237. "setFreeformContentHandlerName": function() { return /* reexport */ setFreeformContentHandlerName; },
  5238. "setGroupingBlockName": function() { return /* reexport */ setGroupingBlockName; },
  5239. "setUnregisteredTypeHandlerName": function() { return /* reexport */ setUnregisteredTypeHandlerName; },
  5240. "store": function() { return /* reexport */ store; },
  5241. "switchToBlockType": function() { return /* reexport */ switchToBlockType; },
  5242. "synchronizeBlocksWithTemplate": function() { return /* reexport */ synchronizeBlocksWithTemplate; },
  5243. "unregisterBlockStyle": function() { return /* reexport */ unregisterBlockStyle; },
  5244. "unregisterBlockType": function() { return /* reexport */ unregisterBlockType; },
  5245. "unregisterBlockVariation": function() { return /* reexport */ unregisterBlockVariation; },
  5246. "unstable__bootstrapServerSideBlockDefinitions": function() { return /* reexport */ unstable__bootstrapServerSideBlockDefinitions; },
  5247. "updateCategory": function() { return /* reexport */ categories_updateCategory; },
  5248. "validateBlock": function() { return /* reexport */ validateBlock; },
  5249. "withBlockContentContext": function() { return /* reexport */ withBlockContentContext; }
  5250. });
  5251. // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/selectors.js
  5252. var selectors_namespaceObject = {};
  5253. __webpack_require__.r(selectors_namespaceObject);
  5254. __webpack_require__.d(selectors_namespaceObject, {
  5255. "__experimentalGetUnprocessedBlockTypes": function() { return __experimentalGetUnprocessedBlockTypes; },
  5256. "__experimentalHasContentRoleAttribute": function() { return __experimentalHasContentRoleAttribute; },
  5257. "getActiveBlockVariation": function() { return getActiveBlockVariation; },
  5258. "getBlockStyles": function() { return getBlockStyles; },
  5259. "getBlockSupport": function() { return selectors_getBlockSupport; },
  5260. "getBlockType": function() { return selectors_getBlockType; },
  5261. "getBlockTypes": function() { return selectors_getBlockTypes; },
  5262. "getBlockVariations": function() { return selectors_getBlockVariations; },
  5263. "getCategories": function() { return getCategories; },
  5264. "getChildBlockNames": function() { return selectors_getChildBlockNames; },
  5265. "getCollections": function() { return getCollections; },
  5266. "getDefaultBlockName": function() { return selectors_getDefaultBlockName; },
  5267. "getDefaultBlockVariation": function() { return getDefaultBlockVariation; },
  5268. "getFreeformFallbackBlockName": function() { return getFreeformFallbackBlockName; },
  5269. "getGroupingBlockName": function() { return selectors_getGroupingBlockName; },
  5270. "getUnregisteredFallbackBlockName": function() { return getUnregisteredFallbackBlockName; },
  5271. "hasBlockSupport": function() { return selectors_hasBlockSupport; },
  5272. "hasChildBlocks": function() { return selectors_hasChildBlocks; },
  5273. "hasChildBlocksWithInserterSupport": function() { return selectors_hasChildBlocksWithInserterSupport; },
  5274. "isMatchingSearchTerm": function() { return isMatchingSearchTerm; }
  5275. });
  5276. // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/actions.js
  5277. var actions_namespaceObject = {};
  5278. __webpack_require__.r(actions_namespaceObject);
  5279. __webpack_require__.d(actions_namespaceObject, {
  5280. "__experimentalReapplyBlockTypeFilters": function() { return __experimentalReapplyBlockTypeFilters; },
  5281. "__experimentalRegisterBlockType": function() { return __experimentalRegisterBlockType; },
  5282. "addBlockCollection": function() { return addBlockCollection; },
  5283. "addBlockStyles": function() { return addBlockStyles; },
  5284. "addBlockTypes": function() { return addBlockTypes; },
  5285. "addBlockVariations": function() { return addBlockVariations; },
  5286. "removeBlockCollection": function() { return removeBlockCollection; },
  5287. "removeBlockStyles": function() { return removeBlockStyles; },
  5288. "removeBlockTypes": function() { return removeBlockTypes; },
  5289. "removeBlockVariations": function() { return removeBlockVariations; },
  5290. "setCategories": function() { return setCategories; },
  5291. "setDefaultBlockName": function() { return actions_setDefaultBlockName; },
  5292. "setFreeformFallbackBlockName": function() { return setFreeformFallbackBlockName; },
  5293. "setGroupingBlockName": function() { return actions_setGroupingBlockName; },
  5294. "setUnregisteredFallbackBlockName": function() { return setUnregisteredFallbackBlockName; },
  5295. "updateCategory": function() { return updateCategory; }
  5296. });
  5297. ;// CONCATENATED MODULE: external ["wp","data"]
  5298. var external_wp_data_namespaceObject = window["wp"]["data"];
  5299. ;// CONCATENATED MODULE: external "lodash"
  5300. var external_lodash_namespaceObject = window["lodash"];
  5301. ;// CONCATENATED MODULE: external ["wp","i18n"]
  5302. var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
  5303. ;// CONCATENATED MODULE: ./node_modules/colord/index.mjs
  5304. var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n+0},e=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},u=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},a=function(r){return{r:e(r.r,0,255),g:e(r.g,0,255),b:e(r.b,0,255),a:e(r.a)}},o=function(r){return{r:n(r.r),g:n(r.g),b:n(r.b),a:n(r.a,3)}},i=/^#([0-9a-f]{3,8})$/i,s=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},h=function(r){var t=r.r,n=r.g,e=r.b,u=r.a,a=Math.max(t,n,e),o=a-Math.min(t,n,e),i=o?a===t?(n-e)/o:a===n?2+(e-t)/o:4+(t-n)/o:0;return{h:60*(i<0?i+6:i),s:a?o/a*100:0,v:a/255*100,a:u}},b=function(r){var t=r.h,n=r.s,e=r.v,u=r.a;t=t/360*6,n/=100,e/=100;var a=Math.floor(t),o=e*(1-n),i=e*(1-(t-a)*n),s=e*(1-(1-t+a)*n),h=a%6;return{r:255*[e,i,o,o,s,e][h],g:255*[s,e,e,i,o,o][h],b:255*[o,o,s,e,e,i][h],a:u}},g=function(r){return{h:u(r.h),s:e(r.s,0,100),l:e(r.l,0,100),a:e(r.a)}},d=function(r){return{h:n(r.h),s:n(r.s),l:n(r.l),a:n(r.a,3)}},f=function(r){return b((n=(t=r).s,{h:t.h,s:(n*=((e=t.l)<50?e:100-e)/100)>0?2*n/(e+n)*100:0,v:e+n,a:t.a}));var t,n,e},c=function(r){return{h:(t=h(r)).h,s:(u=(200-(n=t.s))*(e=t.v)/100)>0&&u<200?n*e/100/(u<=100?u:200-u)*100:0,l:u/2,a:t.a};var t,n,e,u},l=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,p=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,v=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,m=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y={string:[[function(r){var t=i.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:4===r.length?n(parseInt(r[3]+r[3],16)/255,2):1}:6===r.length||8===r.length?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:8===r.length?n(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=v.exec(r)||m.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:a({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:void 0===t[7]?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(t){var n=l.exec(t)||p.exec(t);if(!n)return null;var e,u,a=g({h:(e=n[1],u=n[2],void 0===u&&(u="deg"),Number(e)*(r[u]||1)),s:Number(n[3]),l:Number(n[4]),a:void 0===n[5]?1:Number(n[5])/(n[6]?100:1)});return f(a)},"hsl"]],object:[[function(r){var n=r.r,e=r.g,u=r.b,o=r.a,i=void 0===o?1:o;return t(n)&&t(e)&&t(u)?a({r:Number(n),g:Number(e),b:Number(u),a:Number(i)}):null},"rgb"],[function(r){var n=r.h,e=r.s,u=r.l,a=r.a,o=void 0===a?1:a;if(!t(n)||!t(e)||!t(u))return null;var i=g({h:Number(n),s:Number(e),l:Number(u),a:Number(o)});return f(i)},"hsl"],[function(r){var n=r.h,a=r.s,o=r.v,i=r.a,s=void 0===i?1:i;if(!t(n)||!t(a)||!t(o))return null;var h=function(r){return{h:u(r.h),s:e(r.s,0,100),v:e(r.v,0,100),a:e(r.a)}}({h:Number(n),s:Number(a),v:Number(o),a:Number(s)});return b(h)},"hsv"]]},N=function(r,t){for(var n=0;n<t.length;n++){var e=t[n][0](r);if(e)return[e,t[n][1]]}return[null,void 0]},x=function(r){return"string"==typeof r?N(r.trim(),y.string):"object"==typeof r&&null!==r?N(r,y.object):[null,void 0]},I=function(r){return x(r)[1]},M=function(r,t){var n=c(r);return{h:n.h,s:e(n.s+100*t,0,100),l:n.l,a:n.a}},H=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},$=function(r,t){var n=c(r);return{h:n.h,s:n.s,l:e(n.l+100*t,0,100),a:n.a}},j=function(){function r(r){this.parsed=x(r)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return n(H(this.rgba),2)},r.prototype.isDark=function(){return H(this.rgba)<.5},r.prototype.isLight=function(){return H(this.rgba)>=.5},r.prototype.toHex=function(){return r=o(this.rgba),t=r.r,e=r.g,u=r.b,i=(a=r.a)<1?s(n(255*a)):"","#"+s(t)+s(e)+s(u)+i;var r,t,e,u,a,i},r.prototype.toRgb=function(){return o(this.rgba)},r.prototype.toRgbString=function(){return r=o(this.rgba),t=r.r,n=r.g,e=r.b,(u=r.a)<1?"rgba("+t+", "+n+", "+e+", "+u+")":"rgb("+t+", "+n+", "+e+")";var r,t,n,e,u},r.prototype.toHsl=function(){return d(c(this.rgba))},r.prototype.toHslString=function(){return r=d(c(this.rgba)),t=r.h,n=r.s,e=r.l,(u=r.a)<1?"hsla("+t+", "+n+"%, "+e+"%, "+u+")":"hsl("+t+", "+n+"%, "+e+"%)";var r,t,n,e,u},r.prototype.toHsv=function(){return r=h(this.rgba),{h:n(r.h),s:n(r.s),v:n(r.v),a:n(r.a,3)};var r},r.prototype.invert=function(){return w({r:255-(r=this.rgba).r,g:255-r.g,b:255-r.b,a:r.a});var r},r.prototype.saturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,-r))},r.prototype.grayscale=function(){return w(M(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),w($(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),w($(this.rgba,-r))},r.prototype.rotate=function(r){return void 0===r&&(r=15),this.hue(this.hue()+r)},r.prototype.alpha=function(r){return"number"==typeof r?w({r:(t=this.rgba).r,g:t.g,b:t.b,a:r}):n(this.rgba.a,3);var t},r.prototype.hue=function(r){var t=c(this.rgba);return"number"==typeof r?w({h:r,s:t.s,l:t.l,a:t.a}):n(t.h)},r.prototype.isEqual=function(r){return this.toHex()===w(r).toHex()},r}(),w=function(r){return r instanceof j?r:new j(r)},S=[],k=function(r){r.forEach(function(r){S.indexOf(r)<0&&(r(j,y),S.push(r))})},E=function(){return new j({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};
  5305. ;// CONCATENATED MODULE: ./node_modules/colord/plugins/names.mjs
  5306. /* harmony default export */ function names(e,f){var a={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var d in a)r[a[d]]=d;var l={};e.prototype.toName=function(f){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var d,i,n=r[this.toHex()];if(n)return n;if(null==f?void 0:f.closest){var o=this.toRgb(),t=1/0,b="black";if(!l.length)for(var c in a)l[c]=new e(a[c]).toRgb();for(var g in a){var u=(d=o,i=l[g],Math.pow(d.r-i.r,2)+Math.pow(d.g-i.g,2)+Math.pow(d.b-i.b,2));u<t&&(t=u,b=g)}return b}};f.string.push([function(f){var r=f.toLowerCase(),d="transparent"===r?"#0000":a[r];return d?new e(d).toRgb():null},"name"])}
  5307. ;// CONCATENATED MODULE: ./node_modules/colord/plugins/a11y.mjs
  5308. var a11y_o=function(o){var t=o/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},a11y_t=function(t){return.2126*a11y_o(t.r)+.7152*a11y_o(t.g)+.0722*a11y_o(t.b)};/* harmony default export */ function a11y(o){o.prototype.luminance=function(){return o=a11y_t(this.rgba),void 0===(r=2)&&(r=0),void 0===n&&(n=Math.pow(10,r)),Math.round(n*o)/n+0;var o,r,n},o.prototype.contrast=function(r){void 0===r&&(r="#FFF");var n,a,i,e,v,u,d,c=r instanceof o?r:new o(r);return e=this.rgba,v=c.toRgb(),u=a11y_t(e),d=a11y_t(v),n=u>d?(u+.05)/(d+.05):(d+.05)/(u+.05),void 0===(a=2)&&(a=0),void 0===i&&(i=Math.pow(10,a)),Math.floor(i*n)/i+0},o.prototype.isReadable=function(o,t){return void 0===o&&(o="#FFF"),void 0===t&&(t={}),this.contrast(o)>=(e=void 0===(i=(r=t).size)?"normal":i,"AAA"===(a=void 0===(n=r.level)?"AA":n)&&"normal"===e?7:"AA"===a&&"large"===e?3:4.5);var r,n,a,i,e}}
  5309. ;// CONCATENATED MODULE: external ["wp","element"]
  5310. var external_wp_element_namespaceObject = window["wp"]["element"];
  5311. ;// CONCATENATED MODULE: external ["wp","dom"]
  5312. var external_wp_dom_namespaceObject = window["wp"]["dom"];
  5313. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/constants.js
  5314. const BLOCK_ICON_DEFAULT = 'block-default';
  5315. /**
  5316. * Array of valid keys in a block type settings deprecation object.
  5317. *
  5318. * @type {string[]}
  5319. */
  5320. const DEPRECATED_ENTRY_KEYS = ['attributes', 'supports', 'save', 'migrate', 'isEligible', 'apiVersion'];
  5321. const __EXPERIMENTAL_STYLE_PROPERTY = {
  5322. // Kept for back-compatibility purposes.
  5323. '--wp--style--color--link': {
  5324. value: ['color', 'link'],
  5325. support: ['color', 'link']
  5326. },
  5327. background: {
  5328. value: ['color', 'gradient'],
  5329. support: ['color', 'gradients'],
  5330. useEngine: true
  5331. },
  5332. backgroundColor: {
  5333. value: ['color', 'background'],
  5334. support: ['color', 'background'],
  5335. requiresOptOut: true,
  5336. useEngine: true
  5337. },
  5338. borderColor: {
  5339. value: ['border', 'color'],
  5340. support: ['__experimentalBorder', 'color'],
  5341. useEngine: true
  5342. },
  5343. borderRadius: {
  5344. value: ['border', 'radius'],
  5345. support: ['__experimentalBorder', 'radius'],
  5346. properties: {
  5347. borderTopLeftRadius: 'topLeft',
  5348. borderTopRightRadius: 'topRight',
  5349. borderBottomLeftRadius: 'bottomLeft',
  5350. borderBottomRightRadius: 'bottomRight'
  5351. },
  5352. useEngine: true
  5353. },
  5354. borderStyle: {
  5355. value: ['border', 'style'],
  5356. support: ['__experimentalBorder', 'style'],
  5357. useEngine: true
  5358. },
  5359. borderWidth: {
  5360. value: ['border', 'width'],
  5361. support: ['__experimentalBorder', 'width'],
  5362. useEngine: true
  5363. },
  5364. borderTopColor: {
  5365. value: ['border', 'top', 'color'],
  5366. support: ['__experimentalBorder', 'color'],
  5367. useEngine: true
  5368. },
  5369. borderTopStyle: {
  5370. value: ['border', 'top', 'style'],
  5371. support: ['__experimentalBorder', 'style'],
  5372. useEngine: true
  5373. },
  5374. borderTopWidth: {
  5375. value: ['border', 'top', 'width'],
  5376. support: ['__experimentalBorder', 'width'],
  5377. useEngine: true
  5378. },
  5379. borderRightColor: {
  5380. value: ['border', 'right', 'color'],
  5381. support: ['__experimentalBorder', 'color'],
  5382. useEngine: true
  5383. },
  5384. borderRightStyle: {
  5385. value: ['border', 'right', 'style'],
  5386. support: ['__experimentalBorder', 'style'],
  5387. useEngine: true
  5388. },
  5389. borderRightWidth: {
  5390. value: ['border', 'right', 'width'],
  5391. support: ['__experimentalBorder', 'width'],
  5392. useEngine: true
  5393. },
  5394. borderBottomColor: {
  5395. value: ['border', 'bottom', 'color'],
  5396. support: ['__experimentalBorder', 'color'],
  5397. useEngine: true
  5398. },
  5399. borderBottomStyle: {
  5400. value: ['border', 'bottom', 'style'],
  5401. support: ['__experimentalBorder', 'style'],
  5402. useEngine: true
  5403. },
  5404. borderBottomWidth: {
  5405. value: ['border', 'bottom', 'width'],
  5406. support: ['__experimentalBorder', 'width'],
  5407. useEngine: true
  5408. },
  5409. borderLeftColor: {
  5410. value: ['border', 'left', 'color'],
  5411. support: ['__experimentalBorder', 'color'],
  5412. useEngine: true
  5413. },
  5414. borderLeftStyle: {
  5415. value: ['border', 'left', 'style'],
  5416. support: ['__experimentalBorder', 'style'],
  5417. useEngine: true
  5418. },
  5419. borderLeftWidth: {
  5420. value: ['border', 'left', 'width'],
  5421. support: ['__experimentalBorder', 'width'],
  5422. useEngine: true
  5423. },
  5424. color: {
  5425. value: ['color', 'text'],
  5426. support: ['color', 'text'],
  5427. requiresOptOut: true,
  5428. useEngine: true
  5429. },
  5430. filter: {
  5431. value: ['filter', 'duotone'],
  5432. support: ['color', '__experimentalDuotone']
  5433. },
  5434. linkColor: {
  5435. value: ['elements', 'link', 'color', 'text'],
  5436. support: ['color', 'link']
  5437. },
  5438. buttonColor: {
  5439. value: ['elements', 'button', 'color', 'text'],
  5440. support: ['color', 'button']
  5441. },
  5442. buttonBackgroundColor: {
  5443. value: ['elements', 'button', 'color', 'background'],
  5444. support: ['color', 'button']
  5445. },
  5446. fontFamily: {
  5447. value: ['typography', 'fontFamily'],
  5448. support: ['typography', '__experimentalFontFamily'],
  5449. useEngine: true
  5450. },
  5451. fontSize: {
  5452. value: ['typography', 'fontSize'],
  5453. support: ['typography', 'fontSize'],
  5454. useEngine: true
  5455. },
  5456. fontStyle: {
  5457. value: ['typography', 'fontStyle'],
  5458. support: ['typography', '__experimentalFontStyle'],
  5459. useEngine: true
  5460. },
  5461. fontWeight: {
  5462. value: ['typography', 'fontWeight'],
  5463. support: ['typography', '__experimentalFontWeight'],
  5464. useEngine: true
  5465. },
  5466. lineHeight: {
  5467. value: ['typography', 'lineHeight'],
  5468. support: ['typography', 'lineHeight'],
  5469. useEngine: true
  5470. },
  5471. margin: {
  5472. value: ['spacing', 'margin'],
  5473. support: ['spacing', 'margin'],
  5474. properties: {
  5475. marginTop: 'top',
  5476. marginRight: 'right',
  5477. marginBottom: 'bottom',
  5478. marginLeft: 'left'
  5479. },
  5480. useEngine: true
  5481. },
  5482. padding: {
  5483. value: ['spacing', 'padding'],
  5484. support: ['spacing', 'padding'],
  5485. properties: {
  5486. paddingTop: 'top',
  5487. paddingRight: 'right',
  5488. paddingBottom: 'bottom',
  5489. paddingLeft: 'left'
  5490. },
  5491. useEngine: true
  5492. },
  5493. textDecoration: {
  5494. value: ['typography', 'textDecoration'],
  5495. support: ['typography', '__experimentalTextDecoration'],
  5496. useEngine: true
  5497. },
  5498. textTransform: {
  5499. value: ['typography', 'textTransform'],
  5500. support: ['typography', '__experimentalTextTransform'],
  5501. useEngine: true
  5502. },
  5503. letterSpacing: {
  5504. value: ['typography', 'letterSpacing'],
  5505. support: ['typography', '__experimentalLetterSpacing'],
  5506. useEngine: true
  5507. },
  5508. '--wp--style--root--padding': {
  5509. value: ['spacing', 'padding'],
  5510. support: ['spacing', 'padding'],
  5511. properties: {
  5512. '--wp--style--root--padding-top': 'top',
  5513. '--wp--style--root--padding-right': 'right',
  5514. '--wp--style--root--padding-bottom': 'bottom',
  5515. '--wp--style--root--padding-left': 'left'
  5516. },
  5517. rootOnly: true
  5518. }
  5519. };
  5520. const __EXPERIMENTAL_ELEMENTS = {
  5521. link: 'a',
  5522. heading: 'h1, h2, h3, h4, h5, h6',
  5523. h1: 'h1',
  5524. h2: 'h2',
  5525. h3: 'h3',
  5526. h4: 'h4',
  5527. h5: 'h5',
  5528. h6: 'h6',
  5529. button: '.wp-element-button, .wp-block-button__link',
  5530. caption: '.wp-element-caption, .wp-block-audio figcaption, .wp-block-embed figcaption, .wp-block-gallery figcaption, .wp-block-image figcaption, .wp-block-table figcaption, .wp-block-video figcaption',
  5531. cite: 'cite'
  5532. };
  5533. const __EXPERIMENTAL_PATHS_WITH_MERGE = {
  5534. 'color.duotone': true,
  5535. 'color.gradients': true,
  5536. 'color.palette': true,
  5537. 'typography.fontFamilies': true,
  5538. 'typography.fontSizes': true,
  5539. 'spacing.spacingSizes': true
  5540. };
  5541. ;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.js
  5542. /*! *****************************************************************************
  5543. Copyright (c) Microsoft Corporation.
  5544. Permission to use, copy, modify, and/or distribute this software for any
  5545. purpose with or without fee is hereby granted.
  5546. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  5547. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  5548. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  5549. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  5550. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  5551. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  5552. PERFORMANCE OF THIS SOFTWARE.
  5553. ***************************************************************************** */
  5554. /* global Reflect, Promise */
  5555. var extendStatics = function(d, b) {
  5556. extendStatics = Object.setPrototypeOf ||
  5557. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5558. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  5559. return extendStatics(d, b);
  5560. };
  5561. function __extends(d, b) {
  5562. if (typeof b !== "function" && b !== null)
  5563. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  5564. extendStatics(d, b);
  5565. function __() { this.constructor = d; }
  5566. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5567. }
  5568. var __assign = function() {
  5569. __assign = Object.assign || function __assign(t) {
  5570. for (var s, i = 1, n = arguments.length; i < n; i++) {
  5571. s = arguments[i];
  5572. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  5573. }
  5574. return t;
  5575. }
  5576. return __assign.apply(this, arguments);
  5577. }
  5578. function __rest(s, e) {
  5579. var t = {};
  5580. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  5581. t[p] = s[p];
  5582. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  5583. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  5584. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  5585. t[p[i]] = s[p[i]];
  5586. }
  5587. return t;
  5588. }
  5589. function __decorate(decorators, target, key, desc) {
  5590. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  5591. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  5592. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  5593. return c > 3 && r && Object.defineProperty(target, key, r), r;
  5594. }
  5595. function __param(paramIndex, decorator) {
  5596. return function (target, key) { decorator(target, key, paramIndex); }
  5597. }
  5598. function __metadata(metadataKey, metadataValue) {
  5599. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  5600. }
  5601. function __awaiter(thisArg, _arguments, P, generator) {
  5602. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  5603. return new (P || (P = Promise))(function (resolve, reject) {
  5604. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  5605. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  5606. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  5607. step((generator = generator.apply(thisArg, _arguments || [])).next());
  5608. });
  5609. }
  5610. function __generator(thisArg, body) {
  5611. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  5612. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  5613. function verb(n) { return function (v) { return step([n, v]); }; }
  5614. function step(op) {
  5615. if (f) throw new TypeError("Generator is already executing.");
  5616. while (_) try {
  5617. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  5618. if (y = 0, t) op = [op[0] & 2, t.value];
  5619. switch (op[0]) {
  5620. case 0: case 1: t = op; break;
  5621. case 4: _.label++; return { value: op[1], done: false };
  5622. case 5: _.label++; y = op[1]; op = [0]; continue;
  5623. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  5624. default:
  5625. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  5626. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  5627. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  5628. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  5629. if (t[2]) _.ops.pop();
  5630. _.trys.pop(); continue;
  5631. }
  5632. op = body.call(thisArg, _);
  5633. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  5634. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  5635. }
  5636. }
  5637. var __createBinding = Object.create ? (function(o, m, k, k2) {
  5638. if (k2 === undefined) k2 = k;
  5639. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  5640. }) : (function(o, m, k, k2) {
  5641. if (k2 === undefined) k2 = k;
  5642. o[k2] = m[k];
  5643. });
  5644. function __exportStar(m, o) {
  5645. for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
  5646. }
  5647. function __values(o) {
  5648. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  5649. if (m) return m.call(o);
  5650. if (o && typeof o.length === "number") return {
  5651. next: function () {
  5652. if (o && i >= o.length) o = void 0;
  5653. return { value: o && o[i++], done: !o };
  5654. }
  5655. };
  5656. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  5657. }
  5658. function __read(o, n) {
  5659. var m = typeof Symbol === "function" && o[Symbol.iterator];
  5660. if (!m) return o;
  5661. var i = m.call(o), r, ar = [], e;
  5662. try {
  5663. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  5664. }
  5665. catch (error) { e = { error: error }; }
  5666. finally {
  5667. try {
  5668. if (r && !r.done && (m = i["return"])) m.call(i);
  5669. }
  5670. finally { if (e) throw e.error; }
  5671. }
  5672. return ar;
  5673. }
  5674. /** @deprecated */
  5675. function __spread() {
  5676. for (var ar = [], i = 0; i < arguments.length; i++)
  5677. ar = ar.concat(__read(arguments[i]));
  5678. return ar;
  5679. }
  5680. /** @deprecated */
  5681. function __spreadArrays() {
  5682. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  5683. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  5684. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  5685. r[k] = a[j];
  5686. return r;
  5687. }
  5688. function __spreadArray(to, from, pack) {
  5689. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  5690. if (ar || !(i in from)) {
  5691. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  5692. ar[i] = from[i];
  5693. }
  5694. }
  5695. return to.concat(ar || Array.prototype.slice.call(from));
  5696. }
  5697. function __await(v) {
  5698. return this instanceof __await ? (this.v = v, this) : new __await(v);
  5699. }
  5700. function __asyncGenerator(thisArg, _arguments, generator) {
  5701. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  5702. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  5703. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  5704. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  5705. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  5706. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  5707. function fulfill(value) { resume("next", value); }
  5708. function reject(value) { resume("throw", value); }
  5709. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  5710. }
  5711. function __asyncDelegator(o) {
  5712. var i, p;
  5713. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  5714. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  5715. }
  5716. function __asyncValues(o) {
  5717. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  5718. var m = o[Symbol.asyncIterator], i;
  5719. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  5720. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  5721. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  5722. }
  5723. function __makeTemplateObject(cooked, raw) {
  5724. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  5725. return cooked;
  5726. };
  5727. var __setModuleDefault = Object.create ? (function(o, v) {
  5728. Object.defineProperty(o, "default", { enumerable: true, value: v });
  5729. }) : function(o, v) {
  5730. o["default"] = v;
  5731. };
  5732. function __importStar(mod) {
  5733. if (mod && mod.__esModule) return mod;
  5734. var result = {};
  5735. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  5736. __setModuleDefault(result, mod);
  5737. return result;
  5738. }
  5739. function __importDefault(mod) {
  5740. return (mod && mod.__esModule) ? mod : { default: mod };
  5741. }
  5742. function __classPrivateFieldGet(receiver, state, kind, f) {
  5743. if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
  5744. if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
  5745. return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
  5746. }
  5747. function __classPrivateFieldSet(receiver, state, value, kind, f) {
  5748. if (kind === "m") throw new TypeError("Private method is not writable");
  5749. if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
  5750. if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
  5751. return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
  5752. }
  5753. ;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js
  5754. /**
  5755. * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
  5756. */
  5757. var SUPPORTED_LOCALE = {
  5758. tr: {
  5759. regexp: /\u0130|\u0049|\u0049\u0307/g,
  5760. map: {
  5761. İ: "\u0069",
  5762. I: "\u0131",
  5763. İ: "\u0069",
  5764. },
  5765. },
  5766. az: {
  5767. regexp: /\u0130/g,
  5768. map: {
  5769. İ: "\u0069",
  5770. I: "\u0131",
  5771. İ: "\u0069",
  5772. },
  5773. },
  5774. lt: {
  5775. regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
  5776. map: {
  5777. I: "\u0069\u0307",
  5778. J: "\u006A\u0307",
  5779. Į: "\u012F\u0307",
  5780. Ì: "\u0069\u0307\u0300",
  5781. Í: "\u0069\u0307\u0301",
  5782. Ĩ: "\u0069\u0307\u0303",
  5783. },
  5784. },
  5785. };
  5786. /**
  5787. * Localized lower case.
  5788. */
  5789. function localeLowerCase(str, locale) {
  5790. var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
  5791. if (lang)
  5792. return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
  5793. return lowerCase(str);
  5794. }
  5795. /**
  5796. * Lower case as a function.
  5797. */
  5798. function lowerCase(str) {
  5799. return str.toLowerCase();
  5800. }
  5801. ;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js
  5802. // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
  5803. var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
  5804. // Remove all non-word characters.
  5805. var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
  5806. /**
  5807. * Normalize the string into something other libraries can manipulate easier.
  5808. */
  5809. function noCase(input, options) {
  5810. if (options === void 0) { options = {}; }
  5811. var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
  5812. var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
  5813. var start = 0;
  5814. var end = result.length;
  5815. // Trim the delimiter from around the output string.
  5816. while (result.charAt(start) === "\0")
  5817. start++;
  5818. while (result.charAt(end - 1) === "\0")
  5819. end--;
  5820. // Transform each token independently.
  5821. return result.slice(start, end).split("\0").map(transform).join(delimiter);
  5822. }
  5823. /**
  5824. * Replace `re` in the input string with the replacement value.
  5825. */
  5826. function replace(input, re, value) {
  5827. if (re instanceof RegExp)
  5828. return input.replace(re, value);
  5829. return re.reduce(function (input, re) { return input.replace(re, value); }, input);
  5830. }
  5831. ;// CONCATENATED MODULE: ./node_modules/pascal-case/dist.es2015/index.js
  5832. function pascalCaseTransform(input, index) {
  5833. var firstChar = input.charAt(0);
  5834. var lowerChars = input.substr(1).toLowerCase();
  5835. if (index > 0 && firstChar >= "0" && firstChar <= "9") {
  5836. return "_" + firstChar + lowerChars;
  5837. }
  5838. return "" + firstChar.toUpperCase() + lowerChars;
  5839. }
  5840. function dist_es2015_pascalCaseTransformMerge(input) {
  5841. return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase();
  5842. }
  5843. function pascalCase(input, options) {
  5844. if (options === void 0) { options = {}; }
  5845. return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options));
  5846. }
  5847. ;// CONCATENATED MODULE: ./node_modules/camel-case/dist.es2015/index.js
  5848. function camelCaseTransform(input, index) {
  5849. if (index === 0)
  5850. return input.toLowerCase();
  5851. return pascalCaseTransform(input, index);
  5852. }
  5853. function camelCaseTransformMerge(input, index) {
  5854. if (index === 0)
  5855. return input.toLowerCase();
  5856. return pascalCaseTransformMerge(input);
  5857. }
  5858. function camelCase(input, options) {
  5859. if (options === void 0) { options = {}; }
  5860. return pascalCase(input, __assign({ transform: camelCaseTransform }, options));
  5861. }
  5862. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/registration.js
  5863. /* eslint no-console: [ 'error', { allow: [ 'error', 'warn' ] } ] */
  5864. /**
  5865. * External dependencies
  5866. */
  5867. /**
  5868. * WordPress dependencies
  5869. */
  5870. /**
  5871. * Internal dependencies
  5872. */
  5873. const i18nBlockSchema = {
  5874. title: "block title",
  5875. description: "block description",
  5876. keywords: ["block keyword"],
  5877. styles: [{
  5878. label: "block style label"
  5879. }],
  5880. variations: [{
  5881. title: "block variation title",
  5882. description: "block variation description",
  5883. keywords: ["block variation keyword"]
  5884. }]
  5885. };
  5886. /**
  5887. * An icon type definition. One of a Dashicon slug, an element,
  5888. * or a component.
  5889. *
  5890. * @typedef {(string|WPElement|WPComponent)} WPIcon
  5891. *
  5892. * @see https://developer.wordpress.org/resource/dashicons/
  5893. */
  5894. /**
  5895. * Render behavior of a block type icon; one of a Dashicon slug, an element,
  5896. * or a component.
  5897. *
  5898. * @typedef {WPIcon} WPBlockTypeIconRender
  5899. */
  5900. /**
  5901. * An object describing a normalized block type icon.
  5902. *
  5903. * @typedef {Object} WPBlockTypeIconDescriptor
  5904. *
  5905. * @property {WPBlockTypeIconRender} src Render behavior of the icon,
  5906. * one of a Dashicon slug, an
  5907. * element, or a component.
  5908. * @property {string} background Optimal background hex string
  5909. * color when displaying icon.
  5910. * @property {string} foreground Optimal foreground hex string
  5911. * color when displaying icon.
  5912. * @property {string} shadowColor Optimal shadow hex string
  5913. * color when displaying icon.
  5914. */
  5915. /**
  5916. * Value to use to render the icon for a block type in an editor interface,
  5917. * either a Dashicon slug, an element, a component, or an object describing
  5918. * the icon.
  5919. *
  5920. * @typedef {(WPBlockTypeIconDescriptor|WPBlockTypeIconRender)} WPBlockTypeIcon
  5921. */
  5922. /**
  5923. * Named block variation scopes.
  5924. *
  5925. * @typedef {'block'|'inserter'|'transform'} WPBlockVariationScope
  5926. */
  5927. /**
  5928. * An object describing a variation defined for the block type.
  5929. *
  5930. * @typedef {Object} WPBlockVariation
  5931. *
  5932. * @property {string} name The unique and machine-readable name.
  5933. * @property {string} title A human-readable variation title.
  5934. * @property {string} [description] A detailed variation description.
  5935. * @property {string} [category] Block type category classification,
  5936. * used in search interfaces to arrange
  5937. * block types by category.
  5938. * @property {WPIcon} [icon] An icon helping to visualize the variation.
  5939. * @property {boolean} [isDefault] Indicates whether the current variation is
  5940. * the default one. Defaults to `false`.
  5941. * @property {Object} [attributes] Values which override block attributes.
  5942. * @property {Array[]} [innerBlocks] Initial configuration of nested blocks.
  5943. * @property {Object} [example] Example provides structured data for
  5944. * the block preview. You can set to
  5945. * `undefined` to disable the preview shown
  5946. * for the block type.
  5947. * @property {WPBlockVariationScope[]} [scope] The list of scopes where the variation
  5948. * is applicable. When not provided, it
  5949. * assumes all available scopes.
  5950. * @property {string[]} [keywords] An array of terms (which can be translated)
  5951. * that help users discover the variation
  5952. * while searching.
  5953. * @property {Function|string[]} [isActive] This can be a function or an array of block attributes.
  5954. * Function that accepts a block's attributes and the
  5955. * variation's attributes and determines if a variation is active.
  5956. * This function doesn't try to find a match dynamically based
  5957. * on all block's attributes, as in many cases some attributes are irrelevant.
  5958. * An example would be for `embed` block where we only care
  5959. * about `providerNameSlug` attribute's value.
  5960. * We can also use a `string[]` to tell which attributes
  5961. * should be compared as a shorthand. Each attributes will
  5962. * be matched and the variation will be active if all of them are matching.
  5963. */
  5964. /**
  5965. * Defined behavior of a block type.
  5966. *
  5967. * @typedef {Object} WPBlockType
  5968. *
  5969. * @property {string} name Block type's namespaced name.
  5970. * @property {string} title Human-readable block type label.
  5971. * @property {string} [description] A detailed block type description.
  5972. * @property {string} [category] Block type category classification,
  5973. * used in search interfaces to arrange
  5974. * block types by category.
  5975. * @property {WPBlockTypeIcon} [icon] Block type icon.
  5976. * @property {string[]} [keywords] Additional keywords to produce block
  5977. * type as result in search interfaces.
  5978. * @property {Object} [attributes] Block type attributes.
  5979. * @property {WPComponent} [save] Optional component describing
  5980. * serialized markup structure of a
  5981. * block type.
  5982. * @property {WPComponent} edit Component rendering an element to
  5983. * manipulate the attributes of a block
  5984. * in the context of an editor.
  5985. * @property {WPBlockVariation[]} [variations] The list of block variations.
  5986. * @property {Object} [example] Example provides structured data for
  5987. * the block preview. When not defined
  5988. * then no preview is shown.
  5989. */
  5990. const serverSideBlockDefinitions = {};
  5991. function isObject(object) {
  5992. return object !== null && typeof object === 'object';
  5993. }
  5994. /**
  5995. * Sets the server side block definition of blocks.
  5996. *
  5997. * @param {Object} definitions Server-side block definitions
  5998. */
  5999. // eslint-disable-next-line camelcase
  6000. function unstable__bootstrapServerSideBlockDefinitions(definitions) {
  6001. for (const blockName of Object.keys(definitions)) {
  6002. // Don't overwrite if already set. It covers the case when metadata
  6003. // was initialized from the server.
  6004. if (serverSideBlockDefinitions[blockName]) {
  6005. // We still need to polyfill `apiVersion` for WordPress version
  6006. // lower than 5.7. If it isn't present in the definition shared
  6007. // from the server, we try to fallback to the definition passed.
  6008. // @see https://github.com/WordPress/gutenberg/pull/29279
  6009. if (serverSideBlockDefinitions[blockName].apiVersion === undefined && definitions[blockName].apiVersion) {
  6010. serverSideBlockDefinitions[blockName].apiVersion = definitions[blockName].apiVersion;
  6011. } // The `ancestor` prop is not included in the definitions shared
  6012. // from the server yet, so it needs to be polyfilled as well.
  6013. // @see https://github.com/WordPress/gutenberg/pull/39894
  6014. if (serverSideBlockDefinitions[blockName].ancestor === undefined && definitions[blockName].ancestor) {
  6015. serverSideBlockDefinitions[blockName].ancestor = definitions[blockName].ancestor;
  6016. }
  6017. continue;
  6018. }
  6019. serverSideBlockDefinitions[blockName] = Object.fromEntries(Object.entries(definitions[blockName]).filter(_ref => {
  6020. let [, value] = _ref;
  6021. return value !== null && value !== undefined;
  6022. }).map(_ref2 => {
  6023. let [key, value] = _ref2;
  6024. return [camelCase(key), value];
  6025. }));
  6026. }
  6027. }
  6028. /**
  6029. * Gets block settings from metadata loaded from `block.json` file.
  6030. *
  6031. * @param {Object} metadata Block metadata loaded from `block.json`.
  6032. * @param {string} metadata.textdomain Textdomain to use with translations.
  6033. *
  6034. * @return {Object} Block settings.
  6035. */
  6036. function getBlockSettingsFromMetadata(_ref3) {
  6037. let {
  6038. textdomain,
  6039. ...metadata
  6040. } = _ref3;
  6041. const allowedFields = ['apiVersion', 'title', 'category', 'parent', 'ancestor', 'icon', 'description', 'keywords', 'attributes', 'providesContext', 'usesContext', 'supports', 'styles', 'example', 'variations'];
  6042. const settings = Object.fromEntries(Object.entries(metadata).filter(_ref4 => {
  6043. let [key] = _ref4;
  6044. return allowedFields.includes(key);
  6045. }));
  6046. if (textdomain) {
  6047. Object.keys(i18nBlockSchema).forEach(key => {
  6048. if (!settings[key]) {
  6049. return;
  6050. }
  6051. settings[key] = translateBlockSettingUsingI18nSchema(i18nBlockSchema[key], settings[key], textdomain);
  6052. });
  6053. }
  6054. return settings;
  6055. }
  6056. /**
  6057. * Registers a new block provided a unique name and an object defining its
  6058. * behavior. Once registered, the block is made available as an option to any
  6059. * editor interface where blocks are implemented.
  6060. *
  6061. * For more in-depth information on registering a custom block see the [Create a block tutorial](docs/how-to-guides/block-tutorial/README.md)
  6062. *
  6063. * @param {string|Object} blockNameOrMetadata Block type name or its metadata.
  6064. * @param {Object} settings Block settings.
  6065. *
  6066. * @example
  6067. * ```js
  6068. * import { __ } from '@wordpress/i18n';
  6069. * import { registerBlockType } from '@wordpress/blocks'
  6070. *
  6071. * registerBlockType( 'namespace/block-name', {
  6072. * title: __( 'My First Block' ),
  6073. * edit: () => <div>{ __( 'Hello from the editor!' ) }</div>,
  6074. * save: () => <div>Hello from the saved content!</div>,
  6075. * } );
  6076. * ```
  6077. *
  6078. * @return {?WPBlockType} The block, if it has been successfully registered;
  6079. * otherwise `undefined`.
  6080. */
  6081. function registerBlockType(blockNameOrMetadata, settings) {
  6082. const name = isObject(blockNameOrMetadata) ? blockNameOrMetadata.name : blockNameOrMetadata;
  6083. if (typeof name !== 'string') {
  6084. console.error('Block names must be strings.');
  6085. return;
  6086. }
  6087. if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(name)) {
  6088. 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');
  6089. return;
  6090. }
  6091. if ((0,external_wp_data_namespaceObject.select)(store).getBlockType(name)) {
  6092. console.error('Block "' + name + '" is already registered.');
  6093. return;
  6094. }
  6095. if (isObject(blockNameOrMetadata)) {
  6096. unstable__bootstrapServerSideBlockDefinitions({
  6097. [name]: getBlockSettingsFromMetadata(blockNameOrMetadata)
  6098. });
  6099. }
  6100. const blockType = {
  6101. name,
  6102. icon: BLOCK_ICON_DEFAULT,
  6103. keywords: [],
  6104. attributes: {},
  6105. providesContext: {},
  6106. usesContext: [],
  6107. supports: {},
  6108. styles: [],
  6109. variations: [],
  6110. save: () => null,
  6111. ...(serverSideBlockDefinitions === null || serverSideBlockDefinitions === void 0 ? void 0 : serverSideBlockDefinitions[name]),
  6112. ...settings
  6113. };
  6114. (0,external_wp_data_namespaceObject.dispatch)(store).__experimentalRegisterBlockType(blockType);
  6115. return (0,external_wp_data_namespaceObject.select)(store).getBlockType(name);
  6116. }
  6117. /**
  6118. * Translates block settings provided with metadata using the i18n schema.
  6119. *
  6120. * @param {string|string[]|Object[]} i18nSchema I18n schema for the block setting.
  6121. * @param {string|string[]|Object[]} settingValue Value for the block setting.
  6122. * @param {string} textdomain Textdomain to use with translations.
  6123. *
  6124. * @return {string|string[]|Object[]} Translated setting.
  6125. */
  6126. function translateBlockSettingUsingI18nSchema(i18nSchema, settingValue, textdomain) {
  6127. if (typeof i18nSchema === 'string' && typeof settingValue === 'string') {
  6128. // eslint-disable-next-line @wordpress/i18n-no-variables, @wordpress/i18n-text-domain
  6129. return (0,external_wp_i18n_namespaceObject._x)(settingValue, i18nSchema, textdomain);
  6130. }
  6131. if (Array.isArray(i18nSchema) && i18nSchema.length && Array.isArray(settingValue)) {
  6132. return settingValue.map(value => translateBlockSettingUsingI18nSchema(i18nSchema[0], value, textdomain));
  6133. }
  6134. if (isObject(i18nSchema) && Object.entries(i18nSchema).length && isObject(settingValue)) {
  6135. return Object.keys(settingValue).reduce((accumulator, key) => {
  6136. if (!i18nSchema[key]) {
  6137. accumulator[key] = settingValue[key];
  6138. return accumulator;
  6139. }
  6140. accumulator[key] = translateBlockSettingUsingI18nSchema(i18nSchema[key], settingValue[key], textdomain);
  6141. return accumulator;
  6142. }, {});
  6143. }
  6144. return settingValue;
  6145. }
  6146. /**
  6147. * Registers a new block collection to group blocks in the same namespace in the inserter.
  6148. *
  6149. * @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace.
  6150. * @param {Object} settings The block collection settings.
  6151. * @param {string} settings.title The title to display in the block inserter.
  6152. * @param {Object} [settings.icon] The icon to display in the block inserter.
  6153. *
  6154. * @example
  6155. * ```js
  6156. * import { __ } from '@wordpress/i18n';
  6157. * import { registerBlockCollection, registerBlockType } from '@wordpress/blocks';
  6158. *
  6159. * // Register the collection.
  6160. * registerBlockCollection( 'my-collection', {
  6161. * title: __( 'Custom Collection' ),
  6162. * } );
  6163. *
  6164. * // Register a block in the same namespace to add it to the collection.
  6165. * registerBlockType( 'my-collection/block-name', {
  6166. * title: __( 'My First Block' ),
  6167. * edit: () => <div>{ __( 'Hello from the editor!' ) }</div>,
  6168. * save: () => <div>'Hello from the saved content!</div>,
  6169. * } );
  6170. * ```
  6171. */
  6172. function registerBlockCollection(namespace, _ref5) {
  6173. let {
  6174. title,
  6175. icon
  6176. } = _ref5;
  6177. (0,external_wp_data_namespaceObject.dispatch)(store).addBlockCollection(namespace, title, icon);
  6178. }
  6179. /**
  6180. * Unregisters a block collection
  6181. *
  6182. * @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace
  6183. *
  6184. * @example
  6185. * ```js
  6186. * import { unregisterBlockCollection } from '@wordpress/blocks';
  6187. *
  6188. * unregisterBlockCollection( 'my-collection' );
  6189. * ```
  6190. */
  6191. function unregisterBlockCollection(namespace) {
  6192. dispatch(blocksStore).removeBlockCollection(namespace);
  6193. }
  6194. /**
  6195. * Unregisters a block.
  6196. *
  6197. * @param {string} name Block name.
  6198. *
  6199. * @example
  6200. * ```js
  6201. * import { __ } from '@wordpress/i18n';
  6202. * import { unregisterBlockType } from '@wordpress/blocks';
  6203. *
  6204. * const ExampleComponent = () => {
  6205. * return (
  6206. * <Button
  6207. * onClick={ () =>
  6208. * unregisterBlockType( 'my-collection/block-name' )
  6209. * }
  6210. * >
  6211. * { __( 'Unregister my custom block.' ) }
  6212. * </Button>
  6213. * );
  6214. * };
  6215. * ```
  6216. *
  6217. * @return {?WPBlockType} The previous block value, if it has been successfully
  6218. * unregistered; otherwise `undefined`.
  6219. */
  6220. function unregisterBlockType(name) {
  6221. const oldBlock = (0,external_wp_data_namespaceObject.select)(store).getBlockType(name);
  6222. if (!oldBlock) {
  6223. console.error('Block "' + name + '" is not registered.');
  6224. return;
  6225. }
  6226. (0,external_wp_data_namespaceObject.dispatch)(store).removeBlockTypes(name);
  6227. return oldBlock;
  6228. }
  6229. /**
  6230. * Assigns name of block for handling non-block content.
  6231. *
  6232. * @param {string} blockName Block name.
  6233. */
  6234. function setFreeformContentHandlerName(blockName) {
  6235. (0,external_wp_data_namespaceObject.dispatch)(store).setFreeformFallbackBlockName(blockName);
  6236. }
  6237. /**
  6238. * Retrieves name of block handling non-block content, or undefined if no
  6239. * handler has been defined.
  6240. *
  6241. * @return {?string} Block name.
  6242. */
  6243. function getFreeformContentHandlerName() {
  6244. return (0,external_wp_data_namespaceObject.select)(store).getFreeformFallbackBlockName();
  6245. }
  6246. /**
  6247. * Retrieves name of block used for handling grouping interactions.
  6248. *
  6249. * @return {?string} Block name.
  6250. */
  6251. function getGroupingBlockName() {
  6252. return (0,external_wp_data_namespaceObject.select)(store).getGroupingBlockName();
  6253. }
  6254. /**
  6255. * Assigns name of block handling unregistered block types.
  6256. *
  6257. * @param {string} blockName Block name.
  6258. */
  6259. function setUnregisteredTypeHandlerName(blockName) {
  6260. (0,external_wp_data_namespaceObject.dispatch)(store).setUnregisteredFallbackBlockName(blockName);
  6261. }
  6262. /**
  6263. * Retrieves name of block handling unregistered block types, or undefined if no
  6264. * handler has been defined.
  6265. *
  6266. * @return {?string} Block name.
  6267. */
  6268. function getUnregisteredTypeHandlerName() {
  6269. return (0,external_wp_data_namespaceObject.select)(store).getUnregisteredFallbackBlockName();
  6270. }
  6271. /**
  6272. * Assigns the default block name.
  6273. *
  6274. * @param {string} name Block name.
  6275. *
  6276. * @example
  6277. * ```js
  6278. * import { setDefaultBlockName } from '@wordpress/blocks';
  6279. *
  6280. * const ExampleComponent = () => {
  6281. *
  6282. * return (
  6283. * <Button onClick={ () => setDefaultBlockName( 'core/heading' ) }>
  6284. * { __( 'Set the default block to Heading' ) }
  6285. * </Button>
  6286. * );
  6287. * };
  6288. * ```
  6289. */
  6290. function setDefaultBlockName(name) {
  6291. (0,external_wp_data_namespaceObject.dispatch)(store).setDefaultBlockName(name);
  6292. }
  6293. /**
  6294. * Assigns name of block for handling block grouping interactions.
  6295. *
  6296. * @param {string} name Block name.
  6297. *
  6298. * @example
  6299. * ```js
  6300. * import { setGroupingBlockName } from '@wordpress/blocks';
  6301. *
  6302. * const ExampleComponent = () => {
  6303. *
  6304. * return (
  6305. * <Button onClick={ () => setGroupingBlockName( 'core/columns' ) }>
  6306. * { __( 'Set the default block to Heading' ) }
  6307. * </Button>
  6308. * );
  6309. * };
  6310. * ```
  6311. */
  6312. function setGroupingBlockName(name) {
  6313. (0,external_wp_data_namespaceObject.dispatch)(store).setGroupingBlockName(name);
  6314. }
  6315. /**
  6316. * Retrieves the default block name.
  6317. *
  6318. * @return {?string} Block name.
  6319. */
  6320. function getDefaultBlockName() {
  6321. return (0,external_wp_data_namespaceObject.select)(store).getDefaultBlockName();
  6322. }
  6323. /**
  6324. * Returns a registered block type.
  6325. *
  6326. * @param {string} name Block name.
  6327. *
  6328. * @return {?Object} Block type.
  6329. */
  6330. function getBlockType(name) {
  6331. var _select;
  6332. return (_select = (0,external_wp_data_namespaceObject.select)(store)) === null || _select === void 0 ? void 0 : _select.getBlockType(name);
  6333. }
  6334. /**
  6335. * Returns all registered blocks.
  6336. *
  6337. * @return {Array} Block settings.
  6338. */
  6339. function getBlockTypes() {
  6340. return (0,external_wp_data_namespaceObject.select)(store).getBlockTypes();
  6341. }
  6342. /**
  6343. * Returns the block support value for a feature, if defined.
  6344. *
  6345. * @param {(string|Object)} nameOrType Block name or type object
  6346. * @param {string} feature Feature to retrieve
  6347. * @param {*} defaultSupports Default value to return if not
  6348. * explicitly defined
  6349. *
  6350. * @return {?*} Block support value
  6351. */
  6352. function getBlockSupport(nameOrType, feature, defaultSupports) {
  6353. return (0,external_wp_data_namespaceObject.select)(store).getBlockSupport(nameOrType, feature, defaultSupports);
  6354. }
  6355. /**
  6356. * Returns true if the block defines support for a feature, or false otherwise.
  6357. *
  6358. * @param {(string|Object)} nameOrType Block name or type object.
  6359. * @param {string} feature Feature to test.
  6360. * @param {boolean} defaultSupports Whether feature is supported by
  6361. * default if not explicitly defined.
  6362. *
  6363. * @return {boolean} Whether block supports feature.
  6364. */
  6365. function hasBlockSupport(nameOrType, feature, defaultSupports) {
  6366. return (0,external_wp_data_namespaceObject.select)(store).hasBlockSupport(nameOrType, feature, defaultSupports);
  6367. }
  6368. /**
  6369. * Determines whether or not the given block is a reusable block. This is a
  6370. * special block type that is used to point to a global block stored via the
  6371. * API.
  6372. *
  6373. * @param {Object} blockOrType Block or Block Type to test.
  6374. *
  6375. * @return {boolean} Whether the given block is a reusable block.
  6376. */
  6377. function isReusableBlock(blockOrType) {
  6378. return (blockOrType === null || blockOrType === void 0 ? void 0 : blockOrType.name) === 'core/block';
  6379. }
  6380. /**
  6381. * Determines whether or not the given block is a template part. This is a
  6382. * special block type that allows composing a page template out of reusable
  6383. * design elements.
  6384. *
  6385. * @param {Object} blockOrType Block or Block Type to test.
  6386. *
  6387. * @return {boolean} Whether the given block is a template part.
  6388. */
  6389. function isTemplatePart(blockOrType) {
  6390. return blockOrType.name === 'core/template-part';
  6391. }
  6392. /**
  6393. * Returns an array with the child blocks of a given block.
  6394. *
  6395. * @param {string} blockName Name of block (example: “latest-posts”).
  6396. *
  6397. * @return {Array} Array of child block names.
  6398. */
  6399. const getChildBlockNames = blockName => {
  6400. return (0,external_wp_data_namespaceObject.select)(store).getChildBlockNames(blockName);
  6401. };
  6402. /**
  6403. * Returns a boolean indicating if a block has child blocks or not.
  6404. *
  6405. * @param {string} blockName Name of block (example: “latest-posts”).
  6406. *
  6407. * @return {boolean} True if a block contains child blocks and false otherwise.
  6408. */
  6409. const hasChildBlocks = blockName => {
  6410. return (0,external_wp_data_namespaceObject.select)(store).hasChildBlocks(blockName);
  6411. };
  6412. /**
  6413. * Returns a boolean indicating if a block has at least one child block with inserter support.
  6414. *
  6415. * @param {string} blockName Block type name.
  6416. *
  6417. * @return {boolean} True if a block contains at least one child blocks with inserter support
  6418. * and false otherwise.
  6419. */
  6420. const hasChildBlocksWithInserterSupport = blockName => {
  6421. return (0,external_wp_data_namespaceObject.select)(store).hasChildBlocksWithInserterSupport(blockName);
  6422. };
  6423. /**
  6424. * Registers a new block style variation for the given block.
  6425. *
  6426. * For more information on connecting the styles with CSS [the official documentation](/docs/reference-guides/block-api/block-styles.md#styles)
  6427. *
  6428. * @param {string} blockName Name of block (example: “core/latest-posts”).
  6429. * @param {Object} styleVariation Object containing `name` which is the class name applied to the block and `label` which identifies the variation to the user.
  6430. *
  6431. * @example
  6432. * ```js
  6433. * import { __ } from '@wordpress/i18n';
  6434. * import { registerBlockStyle } from '@wordpress/blocks';
  6435. * import { Button } from '@wordpress/components';
  6436. *
  6437. *
  6438. * const ExampleComponent = () => {
  6439. * return (
  6440. * <Button
  6441. * onClick={ () => {
  6442. * registerBlockStyle( 'core/quote', {
  6443. * name: 'fancy-quote',
  6444. * label: __( 'Fancy Quote' ),
  6445. * } );
  6446. * } }
  6447. * >
  6448. * { __( 'Add a new block style for core/quote' ) }
  6449. * </Button>
  6450. * );
  6451. * };
  6452. * ```
  6453. */
  6454. const registerBlockStyle = (blockName, styleVariation) => {
  6455. (0,external_wp_data_namespaceObject.dispatch)(store).addBlockStyles(blockName, styleVariation);
  6456. };
  6457. /**
  6458. * Unregisters a block style variation for the given block.
  6459. *
  6460. * @param {string} blockName Name of block (example: “core/latest-posts”).
  6461. * @param {string} styleVariationName Name of class applied to the block.
  6462. *
  6463. * @example
  6464. * ```js
  6465. * import { __ } from '@wordpress/i18n';
  6466. * import { unregisterBlockStyle } from '@wordpress/blocks';
  6467. * import { Button } from '@wordpress/components';
  6468. *
  6469. * const ExampleComponent = () => {
  6470. * return (
  6471. * <Button
  6472. * onClick={ () => {
  6473. * unregisterBlockStyle( 'core/quote', 'plain' );
  6474. * } }
  6475. * >
  6476. * { __( 'Remove the "Plain" block style for core/quote' ) }
  6477. * </Button>
  6478. * );
  6479. * };
  6480. * ```
  6481. */
  6482. const unregisterBlockStyle = (blockName, styleVariationName) => {
  6483. (0,external_wp_data_namespaceObject.dispatch)(store).removeBlockStyles(blockName, styleVariationName);
  6484. };
  6485. /**
  6486. * Returns an array with the variations of a given block type.
  6487. * Ignored from documentation as the recommended usage is via useSelect from @wordpress/data.
  6488. *
  6489. * @ignore
  6490. *
  6491. * @param {string} blockName Name of block (example: “core/columns”).
  6492. * @param {WPBlockVariationScope} [scope] Block variation scope name.
  6493. *
  6494. * @return {(WPBlockVariation[]|void)} Block variations.
  6495. */
  6496. const getBlockVariations = (blockName, scope) => {
  6497. return (0,external_wp_data_namespaceObject.select)(store).getBlockVariations(blockName, scope);
  6498. };
  6499. /**
  6500. * Registers a new block variation for the given block type.
  6501. *
  6502. * For more information on block variations see [the official documentation ](/docs/reference-guides/block-api/block-variations.md)
  6503. *
  6504. * @param {string} blockName Name of the block (example: “core/columns”).
  6505. * @param {WPBlockVariation} variation Object describing a block variation.
  6506. *
  6507. * @example
  6508. * ```js
  6509. * import { __ } from '@wordpress/i18n';
  6510. * import { registerBlockVariation } from '@wordpress/blocks';
  6511. * import { Button } from '@wordpress/components';
  6512. *
  6513. * const ExampleComponent = () => {
  6514. * return (
  6515. * <Button
  6516. * onClick={ () => {
  6517. * registerBlockVariation( 'core/embed', {
  6518. * name: 'custom',
  6519. * title: __( 'My Custom Embed' ),
  6520. * attributes: { providerNameSlug: 'custom' },
  6521. * } );
  6522. * } }
  6523. * >
  6524. * __( 'Add a custom variation for core/embed' ) }
  6525. * </Button>
  6526. * );
  6527. * };
  6528. * ```
  6529. */
  6530. const registerBlockVariation = (blockName, variation) => {
  6531. (0,external_wp_data_namespaceObject.dispatch)(store).addBlockVariations(blockName, variation);
  6532. };
  6533. /**
  6534. * Unregisters a block variation defined for the given block type.
  6535. *
  6536. * @param {string} blockName Name of the block (example: “core/columns”).
  6537. * @param {string} variationName Name of the variation defined for the block.
  6538. *
  6539. * @example
  6540. * ```js
  6541. * import { __ } from '@wordpress/i18n';
  6542. * import { unregisterBlockVariation } from '@wordpress/blocks';
  6543. * import { Button } from '@wordpress/components';
  6544. *
  6545. * const ExampleComponent = () => {
  6546. * return (
  6547. * <Button
  6548. * onClick={ () => {
  6549. * unregisterBlockVariation( 'core/embed', 'youtube' );
  6550. * } }
  6551. * >
  6552. * { __( 'Remove the YouTube variation from core/embed' ) }
  6553. * </Button>
  6554. * );
  6555. * };
  6556. * ```
  6557. */
  6558. const unregisterBlockVariation = (blockName, variationName) => {
  6559. (0,external_wp_data_namespaceObject.dispatch)(store).removeBlockVariations(blockName, variationName);
  6560. };
  6561. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/node_modules/uuid/dist/esm-browser/rng.js
  6562. // Unique ID creation requires a high quality random # generator. In the browser we therefore
  6563. // require the crypto API and do not support built-in fallback to lower quality random number
  6564. // generators (like Math.random()).
  6565. var getRandomValues;
  6566. var rnds8 = new Uint8Array(16);
  6567. function rng() {
  6568. // lazy load so that environments that need to polyfill have a chance to do so
  6569. if (!getRandomValues) {
  6570. // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
  6571. // find the complete implementation of crypto (msCrypto) on IE11.
  6572. getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
  6573. if (!getRandomValues) {
  6574. throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
  6575. }
  6576. }
  6577. return getRandomValues(rnds8);
  6578. }
  6579. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/node_modules/uuid/dist/esm-browser/regex.js
  6580. /* 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);
  6581. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/node_modules/uuid/dist/esm-browser/validate.js
  6582. function validate(uuid) {
  6583. return typeof uuid === 'string' && regex.test(uuid);
  6584. }
  6585. /* harmony default export */ var esm_browser_validate = (validate);
  6586. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/node_modules/uuid/dist/esm-browser/stringify.js
  6587. /**
  6588. * Convert array of 16 byte values to UUID string format of the form:
  6589. * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
  6590. */
  6591. var byteToHex = [];
  6592. for (var stringify_i = 0; stringify_i < 256; ++stringify_i) {
  6593. byteToHex.push((stringify_i + 0x100).toString(16).substr(1));
  6594. }
  6595. function stringify(arr) {
  6596. var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  6597. // Note: Be careful editing this code! It's been tuned for performance
  6598. // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
  6599. 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
  6600. // of the following:
  6601. // - One or more input array values don't map to a hex octet (leading to
  6602. // "undefined" in the uuid)
  6603. // - Invalid input values for the RFC `version` or `variant` fields
  6604. if (!esm_browser_validate(uuid)) {
  6605. throw TypeError('Stringified UUID is invalid');
  6606. }
  6607. return uuid;
  6608. }
  6609. /* harmony default export */ var esm_browser_stringify = (stringify);
  6610. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/node_modules/uuid/dist/esm-browser/v4.js
  6611. function v4(options, buf, offset) {
  6612. options = options || {};
  6613. var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
  6614. rnds[6] = rnds[6] & 0x0f | 0x40;
  6615. rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
  6616. if (buf) {
  6617. offset = offset || 0;
  6618. for (var i = 0; i < 16; ++i) {
  6619. buf[offset + i] = rnds[i];
  6620. }
  6621. return buf;
  6622. }
  6623. return esm_browser_stringify(rnds);
  6624. }
  6625. /* harmony default export */ var esm_browser_v4 = (v4);
  6626. ;// CONCATENATED MODULE: external ["wp","hooks"]
  6627. var external_wp_hooks_namespaceObject = window["wp"]["hooks"];
  6628. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/factory.js
  6629. /**
  6630. * External dependencies
  6631. */
  6632. /**
  6633. * WordPress dependencies
  6634. */
  6635. /**
  6636. * Internal dependencies
  6637. */
  6638. /**
  6639. * Returns a block object given its type and attributes.
  6640. *
  6641. * @param {string} name Block name.
  6642. * @param {Object} attributes Block attributes.
  6643. * @param {?Array} innerBlocks Nested blocks.
  6644. *
  6645. * @return {Object} Block object.
  6646. */
  6647. function createBlock(name) {
  6648. let attributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  6649. let innerBlocks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
  6650. const sanitizedAttributes = __experimentalSanitizeBlockAttributes(name, attributes);
  6651. const clientId = esm_browser_v4(); // Blocks are stored with a unique ID, the assigned type name, the block
  6652. // attributes, and their inner blocks.
  6653. return {
  6654. clientId,
  6655. name,
  6656. isValid: true,
  6657. attributes: sanitizedAttributes,
  6658. innerBlocks
  6659. };
  6660. }
  6661. /**
  6662. * Given an array of InnerBlocks templates or Block Objects,
  6663. * returns an array of created Blocks from them.
  6664. * It handles the case of having InnerBlocks as Blocks by
  6665. * converting them to the proper format to continue recursively.
  6666. *
  6667. * @param {Array} innerBlocksOrTemplate Nested blocks or InnerBlocks templates.
  6668. *
  6669. * @return {Object[]} Array of Block objects.
  6670. */
  6671. function createBlocksFromInnerBlocksTemplate() {
  6672. let innerBlocksOrTemplate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  6673. return innerBlocksOrTemplate.map(innerBlock => {
  6674. const innerBlockTemplate = Array.isArray(innerBlock) ? innerBlock : [innerBlock.name, innerBlock.attributes, innerBlock.innerBlocks];
  6675. const [name, attributes, innerBlocks = []] = innerBlockTemplate;
  6676. return createBlock(name, attributes, createBlocksFromInnerBlocksTemplate(innerBlocks));
  6677. });
  6678. }
  6679. /**
  6680. * Given a block object, returns a copy of the block object while sanitizing its attributes,
  6681. * optionally merging new attributes and/or replacing its inner blocks.
  6682. *
  6683. * @param {Object} block Block instance.
  6684. * @param {Object} mergeAttributes Block attributes.
  6685. * @param {?Array} newInnerBlocks Nested blocks.
  6686. *
  6687. * @return {Object} A cloned block.
  6688. */
  6689. function __experimentalCloneSanitizedBlock(block) {
  6690. let mergeAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  6691. let newInnerBlocks = arguments.length > 2 ? arguments[2] : undefined;
  6692. const clientId = esm_browser_v4();
  6693. const sanitizedAttributes = __experimentalSanitizeBlockAttributes(block.name, { ...block.attributes,
  6694. ...mergeAttributes
  6695. });
  6696. return { ...block,
  6697. clientId,
  6698. attributes: sanitizedAttributes,
  6699. innerBlocks: newInnerBlocks || block.innerBlocks.map(innerBlock => __experimentalCloneSanitizedBlock(innerBlock))
  6700. };
  6701. }
  6702. /**
  6703. * Given a block object, returns a copy of the block object,
  6704. * optionally merging new attributes and/or replacing its inner blocks.
  6705. *
  6706. * @param {Object} block Block instance.
  6707. * @param {Object} mergeAttributes Block attributes.
  6708. * @param {?Array} newInnerBlocks Nested blocks.
  6709. *
  6710. * @return {Object} A cloned block.
  6711. */
  6712. function cloneBlock(block) {
  6713. let mergeAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  6714. let newInnerBlocks = arguments.length > 2 ? arguments[2] : undefined;
  6715. const clientId = esm_browser_v4();
  6716. return { ...block,
  6717. clientId,
  6718. attributes: { ...block.attributes,
  6719. ...mergeAttributes
  6720. },
  6721. innerBlocks: newInnerBlocks || block.innerBlocks.map(innerBlock => cloneBlock(innerBlock))
  6722. };
  6723. }
  6724. /**
  6725. * Returns a boolean indicating whether a transform is possible based on
  6726. * various bits of context.
  6727. *
  6728. * @param {Object} transform The transform object to validate.
  6729. * @param {string} direction Is this a 'from' or 'to' transform.
  6730. * @param {Array} blocks The blocks to transform from.
  6731. *
  6732. * @return {boolean} Is the transform possible?
  6733. */
  6734. const isPossibleTransformForSource = (transform, direction, blocks) => {
  6735. if (!blocks.length) {
  6736. return false;
  6737. } // If multiple blocks are selected, only multi block transforms
  6738. // or wildcard transforms are allowed.
  6739. const isMultiBlock = blocks.length > 1;
  6740. const firstBlockName = blocks[0].name;
  6741. const isValidForMultiBlocks = isWildcardBlockTransform(transform) || !isMultiBlock || transform.isMultiBlock;
  6742. if (!isValidForMultiBlocks) {
  6743. return false;
  6744. } // Check non-wildcard transforms to ensure that transform is valid
  6745. // for a block selection of multiple blocks of different types.
  6746. if (!isWildcardBlockTransform(transform) && !blocks.every(block => block.name === firstBlockName)) {
  6747. return false;
  6748. } // Only consider 'block' type transforms as valid.
  6749. const isBlockType = transform.type === 'block';
  6750. if (!isBlockType) {
  6751. return false;
  6752. } // Check if the transform's block name matches the source block (or is a wildcard)
  6753. // only if this is a transform 'from'.
  6754. const sourceBlock = blocks[0];
  6755. const hasMatchingName = direction !== 'from' || transform.blocks.indexOf(sourceBlock.name) !== -1 || isWildcardBlockTransform(transform);
  6756. if (!hasMatchingName) {
  6757. return false;
  6758. } // Don't allow single Grouping blocks to be transformed into
  6759. // a Grouping block.
  6760. if (!isMultiBlock && direction === 'from' && isContainerGroupBlock(sourceBlock.name) && isContainerGroupBlock(transform.blockName)) {
  6761. return false;
  6762. } // If the transform has a `isMatch` function specified, check that it returns true.
  6763. if (!maybeCheckTransformIsMatch(transform, blocks)) {
  6764. return false;
  6765. }
  6766. if (transform.usingMobileTransformations && isWildcardBlockTransform(transform) && !isContainerGroupBlock(sourceBlock.name)) {
  6767. return false;
  6768. }
  6769. return true;
  6770. };
  6771. /**
  6772. * Returns block types that the 'blocks' can be transformed into, based on
  6773. * 'from' transforms on other blocks.
  6774. *
  6775. * @param {Array} blocks The blocks to transform from.
  6776. *
  6777. * @return {Array} Block types that the blocks can be transformed into.
  6778. */
  6779. const getBlockTypesForPossibleFromTransforms = blocks => {
  6780. if (!blocks.length) {
  6781. return [];
  6782. }
  6783. const allBlockTypes = getBlockTypes(); // filter all blocks to find those with a 'from' transform.
  6784. const blockTypesWithPossibleFromTransforms = allBlockTypes.filter(blockType => {
  6785. const fromTransforms = getBlockTransforms('from', blockType.name);
  6786. return !!findTransform(fromTransforms, transform => {
  6787. return isPossibleTransformForSource(transform, 'from', blocks);
  6788. });
  6789. });
  6790. return blockTypesWithPossibleFromTransforms;
  6791. };
  6792. /**
  6793. * Returns block types that the 'blocks' can be transformed into, based on
  6794. * the source block's own 'to' transforms.
  6795. *
  6796. * @param {Array} blocks The blocks to transform from.
  6797. *
  6798. * @return {Array} Block types that the source can be transformed into.
  6799. */
  6800. const getBlockTypesForPossibleToTransforms = blocks => {
  6801. if (!blocks.length) {
  6802. return [];
  6803. }
  6804. const sourceBlock = blocks[0];
  6805. const blockType = getBlockType(sourceBlock.name);
  6806. const transformsTo = blockType ? getBlockTransforms('to', blockType.name) : []; // filter all 'to' transforms to find those that are possible.
  6807. const possibleTransforms = transformsTo.filter(transform => {
  6808. return transform && isPossibleTransformForSource(transform, 'to', blocks);
  6809. }); // Build a list of block names using the possible 'to' transforms.
  6810. const blockNames = possibleTransforms.map(transformation => transformation.blocks).flat(); // Map block names to block types.
  6811. return blockNames.map(name => name === '*' ? name : getBlockType(name));
  6812. };
  6813. /**
  6814. * Determines whether transform is a "block" type
  6815. * and if so whether it is a "wildcard" transform
  6816. * ie: targets "any" block type
  6817. *
  6818. * @param {Object} t the Block transform object
  6819. *
  6820. * @return {boolean} whether transform is a wildcard transform
  6821. */
  6822. const isWildcardBlockTransform = t => t && t.type === 'block' && Array.isArray(t.blocks) && t.blocks.includes('*');
  6823. /**
  6824. * Determines whether the given Block is the core Block which
  6825. * acts as a container Block for other Blocks as part of the
  6826. * Grouping mechanics
  6827. *
  6828. * @param {string} name the name of the Block to test against
  6829. *
  6830. * @return {boolean} whether or not the Block is the container Block type
  6831. */
  6832. const isContainerGroupBlock = name => name === getGroupingBlockName();
  6833. /**
  6834. * Returns an array of block types that the set of blocks received as argument
  6835. * can be transformed into.
  6836. *
  6837. * @param {Array} blocks Blocks array.
  6838. *
  6839. * @return {Array} Block types that the blocks argument can be transformed to.
  6840. */
  6841. function getPossibleBlockTransformations(blocks) {
  6842. if (!blocks.length) {
  6843. return [];
  6844. }
  6845. const blockTypesForFromTransforms = getBlockTypesForPossibleFromTransforms(blocks);
  6846. const blockTypesForToTransforms = getBlockTypesForPossibleToTransforms(blocks);
  6847. return [...new Set([...blockTypesForFromTransforms, ...blockTypesForToTransforms])];
  6848. }
  6849. /**
  6850. * Given an array of transforms, returns the highest-priority transform where
  6851. * the predicate function returns a truthy value. A higher-priority transform
  6852. * is one with a lower priority value (i.e. first in priority order). Returns
  6853. * null if the transforms set is empty or the predicate function returns a
  6854. * falsey value for all entries.
  6855. *
  6856. * @param {Object[]} transforms Transforms to search.
  6857. * @param {Function} predicate Function returning true on matching transform.
  6858. *
  6859. * @return {?Object} Highest-priority transform candidate.
  6860. */
  6861. function findTransform(transforms, predicate) {
  6862. // The hooks library already has built-in mechanisms for managing priority
  6863. // queue, so leverage via locally-defined instance.
  6864. const hooks = (0,external_wp_hooks_namespaceObject.createHooks)();
  6865. for (let i = 0; i < transforms.length; i++) {
  6866. const candidate = transforms[i];
  6867. if (predicate(candidate)) {
  6868. hooks.addFilter('transform', 'transform/' + i.toString(), result => result ? result : candidate, candidate.priority);
  6869. }
  6870. } // Filter name is arbitrarily chosen but consistent with above aggregation.
  6871. return hooks.applyFilters('transform', null);
  6872. }
  6873. /**
  6874. * Returns normal block transforms for a given transform direction, optionally
  6875. * for a specific block by name, or an empty array if there are no transforms.
  6876. * If no block name is provided, returns transforms for all blocks. A normal
  6877. * transform object includes `blockName` as a property.
  6878. *
  6879. * @param {string} direction Transform direction ("to", "from").
  6880. * @param {string|Object} blockTypeOrName Block type or name.
  6881. *
  6882. * @return {Array} Block transforms for direction.
  6883. */
  6884. function getBlockTransforms(direction, blockTypeOrName) {
  6885. // When retrieving transforms for all block types, recurse into self.
  6886. if (blockTypeOrName === undefined) {
  6887. return getBlockTypes().map(_ref => {
  6888. let {
  6889. name
  6890. } = _ref;
  6891. return getBlockTransforms(direction, name);
  6892. }).flat();
  6893. } // Validate that block type exists and has array of direction.
  6894. const blockType = normalizeBlockType(blockTypeOrName);
  6895. const {
  6896. name: blockName,
  6897. transforms
  6898. } = blockType || {};
  6899. if (!transforms || !Array.isArray(transforms[direction])) {
  6900. return [];
  6901. }
  6902. const usingMobileTransformations = transforms.supportedMobileTransforms && Array.isArray(transforms.supportedMobileTransforms);
  6903. const filteredTransforms = usingMobileTransformations ? transforms[direction].filter(t => {
  6904. if (t.type === 'raw') {
  6905. return true;
  6906. }
  6907. if (!t.blocks || !t.blocks.length) {
  6908. return false;
  6909. }
  6910. if (isWildcardBlockTransform(t)) {
  6911. return true;
  6912. }
  6913. return t.blocks.every(transformBlockName => transforms.supportedMobileTransforms.includes(transformBlockName));
  6914. }) : transforms[direction]; // Map transforms to normal form.
  6915. return filteredTransforms.map(transform => ({ ...transform,
  6916. blockName,
  6917. usingMobileTransformations
  6918. }));
  6919. }
  6920. /**
  6921. * Checks that a given transforms isMatch method passes for given source blocks.
  6922. *
  6923. * @param {Object} transform A transform object.
  6924. * @param {Array} blocks Blocks array.
  6925. *
  6926. * @return {boolean} True if given blocks are a match for the transform.
  6927. */
  6928. function maybeCheckTransformIsMatch(transform, blocks) {
  6929. if (typeof transform.isMatch !== 'function') {
  6930. return true;
  6931. }
  6932. const sourceBlock = blocks[0];
  6933. const attributes = transform.isMultiBlock ? blocks.map(block => block.attributes) : sourceBlock.attributes;
  6934. const block = transform.isMultiBlock ? blocks : sourceBlock;
  6935. return transform.isMatch(attributes, block);
  6936. }
  6937. /**
  6938. * Switch one or more blocks into one or more blocks of the new block type.
  6939. *
  6940. * @param {Array|Object} blocks Blocks array or block object.
  6941. * @param {string} name Block name.
  6942. *
  6943. * @return {?Array} Array of blocks or null.
  6944. */
  6945. function switchToBlockType(blocks, name) {
  6946. const blocksArray = Array.isArray(blocks) ? blocks : [blocks];
  6947. const isMultiBlock = blocksArray.length > 1;
  6948. const firstBlock = blocksArray[0];
  6949. const sourceName = firstBlock.name; // Find the right transformation by giving priority to the "to"
  6950. // transformation.
  6951. const transformationsFrom = getBlockTransforms('from', name);
  6952. const transformationsTo = getBlockTransforms('to', sourceName);
  6953. const transformation = findTransform(transformationsTo, t => t.type === 'block' && t.blocks.indexOf(name) !== -1 && (!isMultiBlock || t.isMultiBlock) && maybeCheckTransformIsMatch(t, blocksArray)) || findTransform(transformationsFrom, t => t.type === 'block' && (isWildcardBlockTransform(t) || t.blocks.indexOf(sourceName) !== -1) && (!isMultiBlock || t.isMultiBlock) && maybeCheckTransformIsMatch(t, blocksArray)); // Stop if there is no valid transformation.
  6954. if (!transformation) {
  6955. return null;
  6956. }
  6957. let transformationResults;
  6958. if (transformation.isMultiBlock) {
  6959. if ('__experimentalConvert' in transformation) {
  6960. transformationResults = transformation.__experimentalConvert(blocksArray);
  6961. } else {
  6962. transformationResults = transformation.transform(blocksArray.map(currentBlock => currentBlock.attributes), blocksArray.map(currentBlock => currentBlock.innerBlocks));
  6963. }
  6964. } else if ('__experimentalConvert' in transformation) {
  6965. transformationResults = transformation.__experimentalConvert(firstBlock);
  6966. } else {
  6967. transformationResults = transformation.transform(firstBlock.attributes, firstBlock.innerBlocks);
  6968. } // Ensure that the transformation function returned an object or an array
  6969. // of objects.
  6970. if (transformationResults === null || typeof transformationResults !== 'object') {
  6971. return null;
  6972. } // If the transformation function returned a single object, we want to work
  6973. // with an array instead.
  6974. transformationResults = Array.isArray(transformationResults) ? transformationResults : [transformationResults]; // Ensure that every block object returned by the transformation has a
  6975. // valid block type.
  6976. if (transformationResults.some(result => !getBlockType(result.name))) {
  6977. return null;
  6978. } // When unwrapping blocks (`switchToBlockType( wrapperblocks, '*' )`), do
  6979. // not run filters on the unwrapped blocks. They shoud remain as they are.
  6980. if (name === '*') {
  6981. return transformationResults;
  6982. }
  6983. const hasSwitchedBlock = transformationResults.some(result => result.name === name); // Ensure that at least one block object returned by the transformation has
  6984. // the expected "destination" block type.
  6985. if (!hasSwitchedBlock) {
  6986. return null;
  6987. }
  6988. const ret = transformationResults.map((result, index, results) => {
  6989. /**
  6990. * Filters an individual transform result from block transformation.
  6991. * All of the original blocks are passed, since transformations are
  6992. * many-to-many, not one-to-one.
  6993. *
  6994. * @param {Object} transformedBlock The transformed block.
  6995. * @param {Object[]} blocks Original blocks transformed.
  6996. * @param {Object[]} index Index of the transformed block on the array of results.
  6997. * @param {Object[]} results An array all the blocks that resulted from the transformation.
  6998. */
  6999. return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.switchToBlockType.transformedBlock', result, blocks, index, results);
  7000. });
  7001. return ret;
  7002. }
  7003. /**
  7004. * Create a block object from the example API.
  7005. *
  7006. * @param {string} name
  7007. * @param {Object} example
  7008. *
  7009. * @return {Object} block.
  7010. */
  7011. const getBlockFromExample = (name, example) => {
  7012. var _example$innerBlocks;
  7013. return createBlock(name, example.attributes, ((_example$innerBlocks = example.innerBlocks) !== null && _example$innerBlocks !== void 0 ? _example$innerBlocks : []).map(innerBlock => getBlockFromExample(innerBlock.name, innerBlock)));
  7014. };
  7015. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/utils.js
  7016. /**
  7017. * External dependencies
  7018. */
  7019. /**
  7020. * WordPress dependencies
  7021. */
  7022. /**
  7023. * Internal dependencies
  7024. */
  7025. k([names, a11y]);
  7026. /**
  7027. * Array of icon colors containing a color to be used if the icon color
  7028. * was not explicitly set but the icon background color was.
  7029. *
  7030. * @type {Object}
  7031. */
  7032. const ICON_COLORS = ['#191e23', '#f8f9f9'];
  7033. /**
  7034. * Determines whether the block is a default block
  7035. * and its attributes are equal to the default attributes
  7036. * which means the block is unmodified.
  7037. *
  7038. * @param {WPBlock} block Block Object
  7039. *
  7040. * @return {boolean} Whether the block is an unmodified default block
  7041. */
  7042. function isUnmodifiedDefaultBlock(block) {
  7043. const defaultBlockName = getDefaultBlockName();
  7044. if (block.name !== defaultBlockName) {
  7045. return false;
  7046. } // Cache a created default block if no cache exists or the default block
  7047. // name changed.
  7048. if (!isUnmodifiedDefaultBlock.block || isUnmodifiedDefaultBlock.block.name !== defaultBlockName) {
  7049. isUnmodifiedDefaultBlock.block = createBlock(defaultBlockName);
  7050. }
  7051. const newDefaultBlock = isUnmodifiedDefaultBlock.block;
  7052. const blockType = getBlockType(defaultBlockName);
  7053. return (0,external_lodash_namespaceObject.every)(blockType === null || blockType === void 0 ? void 0 : blockType.attributes, (value, key) => newDefaultBlock.attributes[key] === block.attributes[key]);
  7054. }
  7055. /**
  7056. * Function that checks if the parameter is a valid icon.
  7057. *
  7058. * @param {*} icon Parameter to be checked.
  7059. *
  7060. * @return {boolean} True if the parameter is a valid icon and false otherwise.
  7061. */
  7062. function isValidIcon(icon) {
  7063. return !!icon && (typeof icon === 'string' || (0,external_wp_element_namespaceObject.isValidElement)(icon) || typeof icon === 'function' || icon instanceof external_wp_element_namespaceObject.Component);
  7064. }
  7065. /**
  7066. * Function that receives an icon as set by the blocks during the registration
  7067. * and returns a new icon object that is normalized so we can rely on just on possible icon structure
  7068. * in the codebase.
  7069. *
  7070. * @param {WPBlockTypeIconRender} icon Render behavior of a block type icon;
  7071. * one of a Dashicon slug, an element, or a
  7072. * component.
  7073. *
  7074. * @return {WPBlockTypeIconDescriptor} Object describing the icon.
  7075. */
  7076. function normalizeIconObject(icon) {
  7077. icon = icon || BLOCK_ICON_DEFAULT;
  7078. if (isValidIcon(icon)) {
  7079. return {
  7080. src: icon
  7081. };
  7082. }
  7083. if ('background' in icon) {
  7084. const colordBgColor = w(icon.background);
  7085. const getColorContrast = iconColor => colordBgColor.contrast(iconColor);
  7086. const maxContrast = Math.max(...ICON_COLORS.map(getColorContrast));
  7087. return { ...icon,
  7088. foreground: icon.foreground ? icon.foreground : ICON_COLORS.find(iconColor => getColorContrast(iconColor) === maxContrast),
  7089. shadowColor: colordBgColor.alpha(0.3).toRgbString()
  7090. };
  7091. }
  7092. return icon;
  7093. }
  7094. /**
  7095. * Normalizes block type passed as param. When string is passed then
  7096. * it converts it to the matching block type object.
  7097. * It passes the original object otherwise.
  7098. *
  7099. * @param {string|Object} blockTypeOrName Block type or name.
  7100. *
  7101. * @return {?Object} Block type.
  7102. */
  7103. function normalizeBlockType(blockTypeOrName) {
  7104. if (typeof blockTypeOrName === 'string') {
  7105. return getBlockType(blockTypeOrName);
  7106. }
  7107. return blockTypeOrName;
  7108. }
  7109. /**
  7110. * Get the label for the block, usually this is either the block title,
  7111. * or the value of the block's `label` function when that's specified.
  7112. *
  7113. * @param {Object} blockType The block type.
  7114. * @param {Object} attributes The values of the block's attributes.
  7115. * @param {Object} context The intended use for the label.
  7116. *
  7117. * @return {string} The block label.
  7118. */
  7119. function getBlockLabel(blockType, attributes) {
  7120. let context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'visual';
  7121. const {
  7122. __experimentalLabel: getLabel,
  7123. title
  7124. } = blockType;
  7125. const label = getLabel && getLabel(attributes, {
  7126. context
  7127. });
  7128. if (!label) {
  7129. return title;
  7130. } // Strip any HTML (i.e. RichText formatting) before returning.
  7131. return (0,external_wp_dom_namespaceObject.__unstableStripHTML)(label);
  7132. }
  7133. /**
  7134. * Get a label for the block for use by screenreaders, this is more descriptive
  7135. * than the visual label and includes the block title and the value of the
  7136. * `getLabel` function if it's specified.
  7137. *
  7138. * @param {?Object} blockType The block type.
  7139. * @param {Object} attributes The values of the block's attributes.
  7140. * @param {?number} position The position of the block in the block list.
  7141. * @param {string} [direction='vertical'] The direction of the block layout.
  7142. *
  7143. * @return {string} The block label.
  7144. */
  7145. function getAccessibleBlockLabel(blockType, attributes, position) {
  7146. let direction = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'vertical';
  7147. // `title` is already localized, `label` is a user-supplied value.
  7148. const title = blockType === null || blockType === void 0 ? void 0 : blockType.title;
  7149. const label = blockType ? getBlockLabel(blockType, attributes, 'accessibility') : '';
  7150. const hasPosition = position !== undefined; // getBlockLabel returns the block title as a fallback when there's no label,
  7151. // if it did return the title, this function needs to avoid adding the
  7152. // title twice within the accessible label. Use this `hasLabel` boolean to
  7153. // handle that.
  7154. const hasLabel = label && label !== title;
  7155. if (hasPosition && direction === 'vertical') {
  7156. if (hasLabel) {
  7157. return (0,external_wp_i18n_namespaceObject.sprintf)(
  7158. /* translators: accessibility text. 1: The block title. 2: The block row number. 3: The block label.. */
  7159. (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Row %2$d. %3$s'), title, position, label);
  7160. }
  7161. return (0,external_wp_i18n_namespaceObject.sprintf)(
  7162. /* translators: accessibility text. 1: The block title. 2: The block row number. */
  7163. (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Row %2$d'), title, position);
  7164. } else if (hasPosition && direction === 'horizontal') {
  7165. if (hasLabel) {
  7166. return (0,external_wp_i18n_namespaceObject.sprintf)(
  7167. /* translators: accessibility text. 1: The block title. 2: The block column number. 3: The block label.. */
  7168. (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Column %2$d. %3$s'), title, position, label);
  7169. }
  7170. return (0,external_wp_i18n_namespaceObject.sprintf)(
  7171. /* translators: accessibility text. 1: The block title. 2: The block column number. */
  7172. (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Column %2$d'), title, position);
  7173. }
  7174. if (hasLabel) {
  7175. return (0,external_wp_i18n_namespaceObject.sprintf)(
  7176. /* translators: accessibility text. %1: The block title. %2: The block label. */
  7177. (0,external_wp_i18n_namespaceObject.__)('%1$s Block. %2$s'), title, label);
  7178. }
  7179. return (0,external_wp_i18n_namespaceObject.sprintf)(
  7180. /* translators: accessibility text. %s: The block title. */
  7181. (0,external_wp_i18n_namespaceObject.__)('%s Block'), title);
  7182. }
  7183. /**
  7184. * Ensure attributes contains only values defined by block type, and merge
  7185. * default values for missing attributes.
  7186. *
  7187. * @param {string} name The block's name.
  7188. * @param {Object} attributes The block's attributes.
  7189. * @return {Object} The sanitized attributes.
  7190. */
  7191. function __experimentalSanitizeBlockAttributes(name, attributes) {
  7192. // Get the type definition associated with a registered block.
  7193. const blockType = getBlockType(name);
  7194. if (undefined === blockType) {
  7195. throw new Error(`Block type '${name}' is not registered.`);
  7196. }
  7197. return (0,external_lodash_namespaceObject.reduce)(blockType.attributes, (accumulator, schema, key) => {
  7198. const value = attributes[key];
  7199. if (undefined !== value) {
  7200. accumulator[key] = value;
  7201. } else if (schema.hasOwnProperty('default')) {
  7202. accumulator[key] = schema.default;
  7203. }
  7204. if (['node', 'children'].indexOf(schema.source) !== -1) {
  7205. // Ensure value passed is always an array, which we're expecting in
  7206. // the RichText component to handle the deprecated value.
  7207. if (typeof accumulator[key] === 'string') {
  7208. accumulator[key] = [accumulator[key]];
  7209. } else if (!Array.isArray(accumulator[key])) {
  7210. accumulator[key] = [];
  7211. }
  7212. }
  7213. return accumulator;
  7214. }, {});
  7215. }
  7216. /**
  7217. * Filter block attributes by `role` and return their names.
  7218. *
  7219. * @param {string} name Block attribute's name.
  7220. * @param {string} role The role of a block attribute.
  7221. *
  7222. * @return {string[]} The attribute names that have the provided role.
  7223. */
  7224. function __experimentalGetBlockAttributesNamesByRole(name, role) {
  7225. var _getBlockType;
  7226. const attributes = (_getBlockType = getBlockType(name)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.attributes;
  7227. if (!attributes) return [];
  7228. const attributesNames = Object.keys(attributes);
  7229. if (!role) return attributesNames;
  7230. return attributesNames.filter(attributeName => {
  7231. var _attributes$attribute;
  7232. return ((_attributes$attribute = attributes[attributeName]) === null || _attributes$attribute === void 0 ? void 0 : _attributes$attribute.__experimentalRole) === role;
  7233. });
  7234. }
  7235. /**
  7236. * Return a new object with the specified keys omitted.
  7237. *
  7238. * @param {Object} object Original object.
  7239. * @param {Array} keys Keys to be omitted.
  7240. *
  7241. * @return {Object} Object with omitted keys.
  7242. */
  7243. function omit(object, keys) {
  7244. return Object.fromEntries(Object.entries(object).filter(_ref => {
  7245. let [key] = _ref;
  7246. return !keys.includes(key);
  7247. }));
  7248. }
  7249. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/reducer.js
  7250. /**
  7251. * External dependencies
  7252. */
  7253. /**
  7254. * WordPress dependencies
  7255. */
  7256. /**
  7257. * Internal dependencies
  7258. */
  7259. /**
  7260. * @typedef {Object} WPBlockCategory
  7261. *
  7262. * @property {string} slug Unique category slug.
  7263. * @property {string} title Category label, for display in user interface.
  7264. */
  7265. /**
  7266. * Default set of categories.
  7267. *
  7268. * @type {WPBlockCategory[]}
  7269. */
  7270. const DEFAULT_CATEGORIES = [{
  7271. slug: 'text',
  7272. title: (0,external_wp_i18n_namespaceObject.__)('Text')
  7273. }, {
  7274. slug: 'media',
  7275. title: (0,external_wp_i18n_namespaceObject.__)('Media')
  7276. }, {
  7277. slug: 'design',
  7278. title: (0,external_wp_i18n_namespaceObject.__)('Design')
  7279. }, {
  7280. slug: 'widgets',
  7281. title: (0,external_wp_i18n_namespaceObject.__)('Widgets')
  7282. }, {
  7283. slug: 'theme',
  7284. title: (0,external_wp_i18n_namespaceObject.__)('Theme')
  7285. }, {
  7286. slug: 'embed',
  7287. title: (0,external_wp_i18n_namespaceObject.__)('Embeds')
  7288. }, {
  7289. slug: 'reusable',
  7290. title: (0,external_wp_i18n_namespaceObject.__)('Reusable blocks')
  7291. }]; // Key block types by their name.
  7292. function keyBlockTypesByName(types) {
  7293. return types.reduce((newBlockTypes, block) => ({ ...newBlockTypes,
  7294. [block.name]: block
  7295. }), {});
  7296. } // Filter items to ensure they're unique by their name.
  7297. function getUniqueItemsByName(items) {
  7298. return items.reduce((acc, currentItem) => {
  7299. if (!acc.some(item => item.name === currentItem.name)) {
  7300. acc.push(currentItem);
  7301. }
  7302. return acc;
  7303. }, []);
  7304. }
  7305. /**
  7306. * Reducer managing the unprocessed block types in a form passed when registering the by block.
  7307. * It's for internal use only. It allows recomputing the processed block types on-demand after block type filters
  7308. * get added or removed.
  7309. *
  7310. * @param {Object} state Current state.
  7311. * @param {Object} action Dispatched action.
  7312. *
  7313. * @return {Object} Updated state.
  7314. */
  7315. function unprocessedBlockTypes() {
  7316. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7317. let action = arguments.length > 1 ? arguments[1] : undefined;
  7318. switch (action.type) {
  7319. case 'ADD_UNPROCESSED_BLOCK_TYPE':
  7320. return { ...state,
  7321. [action.blockType.name]: action.blockType
  7322. };
  7323. case 'REMOVE_BLOCK_TYPES':
  7324. return omit(state, action.names);
  7325. }
  7326. return state;
  7327. }
  7328. /**
  7329. * Reducer managing the processed block types with all filters applied.
  7330. * The state is derived from the `unprocessedBlockTypes` reducer.
  7331. *
  7332. * @param {Object} state Current state.
  7333. * @param {Object} action Dispatched action.
  7334. *
  7335. * @return {Object} Updated state.
  7336. */
  7337. function blockTypes() {
  7338. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7339. let action = arguments.length > 1 ? arguments[1] : undefined;
  7340. switch (action.type) {
  7341. case 'ADD_BLOCK_TYPES':
  7342. return { ...state,
  7343. ...keyBlockTypesByName(action.blockTypes)
  7344. };
  7345. case 'REMOVE_BLOCK_TYPES':
  7346. return omit(state, action.names);
  7347. }
  7348. return state;
  7349. }
  7350. /**
  7351. * Reducer managing the block style variations.
  7352. *
  7353. * @param {Object} state Current state.
  7354. * @param {Object} action Dispatched action.
  7355. *
  7356. * @return {Object} Updated state.
  7357. */
  7358. function blockStyles() {
  7359. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7360. let action = arguments.length > 1 ? arguments[1] : undefined;
  7361. switch (action.type) {
  7362. case 'ADD_BLOCK_TYPES':
  7363. return { ...state,
  7364. ...(0,external_lodash_namespaceObject.mapValues)(keyBlockTypesByName(action.blockTypes), blockType => getUniqueItemsByName([...(0,external_lodash_namespaceObject.get)(blockType, ['styles'], []).map(style => ({ ...style,
  7365. source: 'block'
  7366. })), ...(0,external_lodash_namespaceObject.get)(state, [blockType.name], []).filter(_ref => {
  7367. let {
  7368. source
  7369. } = _ref;
  7370. return 'block' !== source;
  7371. })]))
  7372. };
  7373. case 'ADD_BLOCK_STYLES':
  7374. return { ...state,
  7375. [action.blockName]: getUniqueItemsByName([...(0,external_lodash_namespaceObject.get)(state, [action.blockName], []), ...action.styles])
  7376. };
  7377. case 'REMOVE_BLOCK_STYLES':
  7378. return { ...state,
  7379. [action.blockName]: (0,external_lodash_namespaceObject.filter)((0,external_lodash_namespaceObject.get)(state, [action.blockName], []), style => action.styleNames.indexOf(style.name) === -1)
  7380. };
  7381. }
  7382. return state;
  7383. }
  7384. /**
  7385. * Reducer managing the block variations.
  7386. *
  7387. * @param {Object} state Current state.
  7388. * @param {Object} action Dispatched action.
  7389. *
  7390. * @return {Object} Updated state.
  7391. */
  7392. function blockVariations() {
  7393. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7394. let action = arguments.length > 1 ? arguments[1] : undefined;
  7395. switch (action.type) {
  7396. case 'ADD_BLOCK_TYPES':
  7397. return { ...state,
  7398. ...(0,external_lodash_namespaceObject.mapValues)(keyBlockTypesByName(action.blockTypes), blockType => {
  7399. return getUniqueItemsByName([...(0,external_lodash_namespaceObject.get)(blockType, ['variations'], []).map(variation => ({ ...variation,
  7400. source: 'block'
  7401. })), ...(0,external_lodash_namespaceObject.get)(state, [blockType.name], []).filter(_ref2 => {
  7402. let {
  7403. source
  7404. } = _ref2;
  7405. return 'block' !== source;
  7406. })]);
  7407. })
  7408. };
  7409. case 'ADD_BLOCK_VARIATIONS':
  7410. return { ...state,
  7411. [action.blockName]: getUniqueItemsByName([...(0,external_lodash_namespaceObject.get)(state, [action.blockName], []), ...action.variations])
  7412. };
  7413. case 'REMOVE_BLOCK_VARIATIONS':
  7414. return { ...state,
  7415. [action.blockName]: (0,external_lodash_namespaceObject.filter)((0,external_lodash_namespaceObject.get)(state, [action.blockName], []), variation => action.variationNames.indexOf(variation.name) === -1)
  7416. };
  7417. }
  7418. return state;
  7419. }
  7420. /**
  7421. * Higher-order Reducer creating a reducer keeping track of given block name.
  7422. *
  7423. * @param {string} setActionType Action type.
  7424. *
  7425. * @return {Function} Reducer.
  7426. */
  7427. function createBlockNameSetterReducer(setActionType) {
  7428. return function () {
  7429. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  7430. let action = arguments.length > 1 ? arguments[1] : undefined;
  7431. switch (action.type) {
  7432. case 'REMOVE_BLOCK_TYPES':
  7433. if (action.names.indexOf(state) !== -1) {
  7434. return null;
  7435. }
  7436. return state;
  7437. case setActionType:
  7438. return action.name || null;
  7439. }
  7440. return state;
  7441. };
  7442. }
  7443. const defaultBlockName = createBlockNameSetterReducer('SET_DEFAULT_BLOCK_NAME');
  7444. const freeformFallbackBlockName = createBlockNameSetterReducer('SET_FREEFORM_FALLBACK_BLOCK_NAME');
  7445. const unregisteredFallbackBlockName = createBlockNameSetterReducer('SET_UNREGISTERED_FALLBACK_BLOCK_NAME');
  7446. const groupingBlockName = createBlockNameSetterReducer('SET_GROUPING_BLOCK_NAME');
  7447. /**
  7448. * Reducer managing the categories
  7449. *
  7450. * @param {WPBlockCategory[]} state Current state.
  7451. * @param {Object} action Dispatched action.
  7452. *
  7453. * @return {WPBlockCategory[]} Updated state.
  7454. */
  7455. function categories() {
  7456. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_CATEGORIES;
  7457. let action = arguments.length > 1 ? arguments[1] : undefined;
  7458. switch (action.type) {
  7459. case 'SET_CATEGORIES':
  7460. return action.categories || [];
  7461. case 'UPDATE_CATEGORY':
  7462. {
  7463. if (!action.category || (0,external_lodash_namespaceObject.isEmpty)(action.category)) {
  7464. return state;
  7465. }
  7466. const categoryToChange = (0,external_lodash_namespaceObject.find)(state, ['slug', action.slug]);
  7467. if (categoryToChange) {
  7468. return (0,external_lodash_namespaceObject.map)(state, category => {
  7469. if (category.slug === action.slug) {
  7470. return { ...category,
  7471. ...action.category
  7472. };
  7473. }
  7474. return category;
  7475. });
  7476. }
  7477. }
  7478. }
  7479. return state;
  7480. }
  7481. function collections() {
  7482. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7483. let action = arguments.length > 1 ? arguments[1] : undefined;
  7484. switch (action.type) {
  7485. case 'ADD_BLOCK_COLLECTION':
  7486. return { ...state,
  7487. [action.namespace]: {
  7488. title: action.title,
  7489. icon: action.icon
  7490. }
  7491. };
  7492. case 'REMOVE_BLOCK_COLLECTION':
  7493. return omit(state, action.namespace);
  7494. }
  7495. return state;
  7496. }
  7497. /* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
  7498. unprocessedBlockTypes,
  7499. blockTypes,
  7500. blockStyles,
  7501. blockVariations,
  7502. defaultBlockName,
  7503. freeformFallbackBlockName,
  7504. unregisteredFallbackBlockName,
  7505. groupingBlockName,
  7506. categories,
  7507. collections
  7508. }));
  7509. ;// CONCATENATED MODULE: ./node_modules/rememo/rememo.js
  7510. /** @typedef {(...args: any[]) => *[]} GetDependants */
  7511. /** @typedef {() => void} Clear */
  7512. /**
  7513. * @typedef {{
  7514. * getDependants: GetDependants,
  7515. * clear: Clear
  7516. * }} EnhancedSelector
  7517. */
  7518. /**
  7519. * Internal cache entry.
  7520. *
  7521. * @typedef CacheNode
  7522. *
  7523. * @property {?CacheNode|undefined} [prev] Previous node.
  7524. * @property {?CacheNode|undefined} [next] Next node.
  7525. * @property {*[]} args Function arguments for cache entry.
  7526. * @property {*} val Function result.
  7527. */
  7528. /**
  7529. * @typedef Cache
  7530. *
  7531. * @property {Clear} clear Function to clear cache.
  7532. * @property {boolean} [isUniqueByDependants] Whether dependants are valid in
  7533. * considering cache uniqueness. A cache is unique if dependents are all arrays
  7534. * or objects.
  7535. * @property {CacheNode?} [head] Cache head.
  7536. * @property {*[]} [lastDependants] Dependants from previous invocation.
  7537. */
  7538. /**
  7539. * Arbitrary value used as key for referencing cache object in WeakMap tree.
  7540. *
  7541. * @type {{}}
  7542. */
  7543. var LEAF_KEY = {};
  7544. /**
  7545. * Returns the first argument as the sole entry in an array.
  7546. *
  7547. * @template T
  7548. *
  7549. * @param {T} value Value to return.
  7550. *
  7551. * @return {[T]} Value returned as entry in array.
  7552. */
  7553. function arrayOf(value) {
  7554. return [value];
  7555. }
  7556. /**
  7557. * Returns true if the value passed is object-like, or false otherwise. A value
  7558. * is object-like if it can support property assignment, e.g. object or array.
  7559. *
  7560. * @param {*} value Value to test.
  7561. *
  7562. * @return {boolean} Whether value is object-like.
  7563. */
  7564. function isObjectLike(value) {
  7565. return !!value && 'object' === typeof value;
  7566. }
  7567. /**
  7568. * Creates and returns a new cache object.
  7569. *
  7570. * @return {Cache} Cache object.
  7571. */
  7572. function createCache() {
  7573. /** @type {Cache} */
  7574. var cache = {
  7575. clear: function () {
  7576. cache.head = null;
  7577. },
  7578. };
  7579. return cache;
  7580. }
  7581. /**
  7582. * Returns true if entries within the two arrays are strictly equal by
  7583. * reference from a starting index.
  7584. *
  7585. * @param {*[]} a First array.
  7586. * @param {*[]} b Second array.
  7587. * @param {number} fromIndex Index from which to start comparison.
  7588. *
  7589. * @return {boolean} Whether arrays are shallowly equal.
  7590. */
  7591. function isShallowEqual(a, b, fromIndex) {
  7592. var i;
  7593. if (a.length !== b.length) {
  7594. return false;
  7595. }
  7596. for (i = fromIndex; i < a.length; i++) {
  7597. if (a[i] !== b[i]) {
  7598. return false;
  7599. }
  7600. }
  7601. return true;
  7602. }
  7603. /**
  7604. * Returns a memoized selector function. The getDependants function argument is
  7605. * called before the memoized selector and is expected to return an immutable
  7606. * reference or array of references on which the selector depends for computing
  7607. * its own return value. The memoize cache is preserved only as long as those
  7608. * dependant references remain the same. If getDependants returns a different
  7609. * reference(s), the cache is cleared and the selector value regenerated.
  7610. *
  7611. * @template {(...args: *[]) => *} S
  7612. *
  7613. * @param {S} selector Selector function.
  7614. * @param {GetDependants=} getDependants Dependant getter returning an array of
  7615. * references used in cache bust consideration.
  7616. */
  7617. /* harmony default export */ function rememo(selector, getDependants) {
  7618. /** @type {WeakMap<*,*>} */
  7619. var rootCache;
  7620. /** @type {GetDependants} */
  7621. var normalizedGetDependants = getDependants ? getDependants : arrayOf;
  7622. /**
  7623. * Returns the cache for a given dependants array. When possible, a WeakMap
  7624. * will be used to create a unique cache for each set of dependants. This
  7625. * is feasible due to the nature of WeakMap in allowing garbage collection
  7626. * to occur on entries where the key object is no longer referenced. Since
  7627. * WeakMap requires the key to be an object, this is only possible when the
  7628. * dependant is object-like. The root cache is created as a hierarchy where
  7629. * each top-level key is the first entry in a dependants set, the value a
  7630. * WeakMap where each key is the next dependant, and so on. This continues
  7631. * so long as the dependants are object-like. If no dependants are object-
  7632. * like, then the cache is shared across all invocations.
  7633. *
  7634. * @see isObjectLike
  7635. *
  7636. * @param {*[]} dependants Selector dependants.
  7637. *
  7638. * @return {Cache} Cache object.
  7639. */
  7640. function getCache(dependants) {
  7641. var caches = rootCache,
  7642. isUniqueByDependants = true,
  7643. i,
  7644. dependant,
  7645. map,
  7646. cache;
  7647. for (i = 0; i < dependants.length; i++) {
  7648. dependant = dependants[i];
  7649. // Can only compose WeakMap from object-like key.
  7650. if (!isObjectLike(dependant)) {
  7651. isUniqueByDependants = false;
  7652. break;
  7653. }
  7654. // Does current segment of cache already have a WeakMap?
  7655. if (caches.has(dependant)) {
  7656. // Traverse into nested WeakMap.
  7657. caches = caches.get(dependant);
  7658. } else {
  7659. // Create, set, and traverse into a new one.
  7660. map = new WeakMap();
  7661. caches.set(dependant, map);
  7662. caches = map;
  7663. }
  7664. }
  7665. // We use an arbitrary (but consistent) object as key for the last item
  7666. // in the WeakMap to serve as our running cache.
  7667. if (!caches.has(LEAF_KEY)) {
  7668. cache = createCache();
  7669. cache.isUniqueByDependants = isUniqueByDependants;
  7670. caches.set(LEAF_KEY, cache);
  7671. }
  7672. return caches.get(LEAF_KEY);
  7673. }
  7674. /**
  7675. * Resets root memoization cache.
  7676. */
  7677. function clear() {
  7678. rootCache = new WeakMap();
  7679. }
  7680. /* eslint-disable jsdoc/check-param-names */
  7681. /**
  7682. * The augmented selector call, considering first whether dependants have
  7683. * changed before passing it to underlying memoize function.
  7684. *
  7685. * @param {*} source Source object for derivation.
  7686. * @param {...*} extraArgs Additional arguments to pass to selector.
  7687. *
  7688. * @return {*} Selector result.
  7689. */
  7690. /* eslint-enable jsdoc/check-param-names */
  7691. function callSelector(/* source, ...extraArgs */) {
  7692. var len = arguments.length,
  7693. cache,
  7694. node,
  7695. i,
  7696. args,
  7697. dependants;
  7698. // Create copy of arguments (avoid leaking deoptimization).
  7699. args = new Array(len);
  7700. for (i = 0; i < len; i++) {
  7701. args[i] = arguments[i];
  7702. }
  7703. dependants = normalizedGetDependants.apply(null, args);
  7704. cache = getCache(dependants);
  7705. // If not guaranteed uniqueness by dependants (primitive type), shallow
  7706. // compare against last dependants and, if references have changed,
  7707. // destroy cache to recalculate result.
  7708. if (!cache.isUniqueByDependants) {
  7709. if (
  7710. cache.lastDependants &&
  7711. !isShallowEqual(dependants, cache.lastDependants, 0)
  7712. ) {
  7713. cache.clear();
  7714. }
  7715. cache.lastDependants = dependants;
  7716. }
  7717. node = cache.head;
  7718. while (node) {
  7719. // Check whether node arguments match arguments
  7720. if (!isShallowEqual(node.args, args, 1)) {
  7721. node = node.next;
  7722. continue;
  7723. }
  7724. // At this point we can assume we've found a match
  7725. // Surface matched node to head if not already
  7726. if (node !== cache.head) {
  7727. // Adjust siblings to point to each other.
  7728. /** @type {CacheNode} */ (node.prev).next = node.next;
  7729. if (node.next) {
  7730. node.next.prev = node.prev;
  7731. }
  7732. node.next = cache.head;
  7733. node.prev = null;
  7734. /** @type {CacheNode} */ (cache.head).prev = node;
  7735. cache.head = node;
  7736. }
  7737. // Return immediately
  7738. return node.val;
  7739. }
  7740. // No cached value found. Continue to insertion phase:
  7741. node = /** @type {CacheNode} */ ({
  7742. // Generate the result from original function
  7743. val: selector.apply(null, args),
  7744. });
  7745. // Avoid including the source object in the cache.
  7746. args[0] = null;
  7747. node.args = args;
  7748. // Don't need to check whether node is already head, since it would
  7749. // have been returned above already if it was
  7750. // Shift existing head down list
  7751. if (cache.head) {
  7752. cache.head.prev = node;
  7753. node.next = cache.head;
  7754. }
  7755. cache.head = node;
  7756. return node.val;
  7757. }
  7758. callSelector.getDependants = normalizedGetDependants;
  7759. callSelector.clear = clear;
  7760. clear();
  7761. return /** @type {S & EnhancedSelector} */ (callSelector);
  7762. }
  7763. // EXTERNAL MODULE: ./node_modules/remove-accents/index.js
  7764. var remove_accents = __webpack_require__(4793);
  7765. var remove_accents_default = /*#__PURE__*/__webpack_require__.n(remove_accents);
  7766. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/selectors.js
  7767. /**
  7768. * External dependencies
  7769. */
  7770. /** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */
  7771. /** @typedef {import('../api/registration').WPBlockVariationScope} WPBlockVariationScope */
  7772. /** @typedef {import('./reducer').WPBlockCategory} WPBlockCategory */
  7773. /**
  7774. * Given a block name or block type object, returns the corresponding
  7775. * normalized block type object.
  7776. *
  7777. * @param {Object} state Blocks state.
  7778. * @param {(string|Object)} nameOrType Block name or type object
  7779. *
  7780. * @return {Object} Block type object.
  7781. */
  7782. const getNormalizedBlockType = (state, nameOrType) => 'string' === typeof nameOrType ? selectors_getBlockType(state, nameOrType) : nameOrType;
  7783. /**
  7784. * Returns all the unprocessed block types as passed during the registration.
  7785. *
  7786. * @param {Object} state Data state.
  7787. *
  7788. * @return {Array} Unprocessed block types.
  7789. */
  7790. function __experimentalGetUnprocessedBlockTypes(state) {
  7791. return state.unprocessedBlockTypes;
  7792. }
  7793. /**
  7794. * Returns all the available block types.
  7795. *
  7796. * @param {Object} state Data state.
  7797. *
  7798. * @example
  7799. * ```js
  7800. * import { store as blocksStore } from '@wordpress/blocks';
  7801. * import { useSelect } from '@wordpress/data';
  7802. *
  7803. * const ExampleComponent = () => {
  7804. * const blockTypes = useSelect(
  7805. * ( select ) => select( blocksStore ).getBlockTypes(),
  7806. * []
  7807. * );
  7808. *
  7809. * return (
  7810. * <ul>
  7811. * { blockTypes.map( ( block ) => (
  7812. * <li key={ block.name }>{ block.title }</li>
  7813. * ) ) }
  7814. * </ul>
  7815. * );
  7816. * };
  7817. * ```
  7818. *
  7819. * @return {Array} Block Types.
  7820. */
  7821. const selectors_getBlockTypes = rememo(state => Object.values(state.blockTypes), state => [state.blockTypes]);
  7822. /**
  7823. * Returns a block type by name.
  7824. *
  7825. * @param {Object} state Data state.
  7826. * @param {string} name Block type name.
  7827. *
  7828. * @example
  7829. * ```js
  7830. * import { store as blocksStore } from '@wordpress/blocks';
  7831. * import { useSelect } from '@wordpress/data';
  7832. *
  7833. * const ExampleComponent = () => {
  7834. * const paragraphBlock = useSelect( ( select ) =>
  7835. * ( select ) => select( blocksStore ).getBlockType( 'core/paragraph' ),
  7836. * []
  7837. * );
  7838. *
  7839. * return (
  7840. * <ul>
  7841. * { paragraphBlock &&
  7842. * Object.entries( paragraphBlock.supports ).map(
  7843. * ( blockSupportsEntry ) => {
  7844. * const [ propertyName, value ] = blockSupportsEntry;
  7845. * return (
  7846. * <li
  7847. * key={ propertyName }
  7848. * >{ `${ propertyName } : ${ value }` }</li>
  7849. * );
  7850. * }
  7851. * ) }
  7852. * </ul>
  7853. * );
  7854. * };
  7855. * ```
  7856. *
  7857. * @return {Object?} Block Type.
  7858. */
  7859. function selectors_getBlockType(state, name) {
  7860. return state.blockTypes[name];
  7861. }
  7862. /**
  7863. * Returns block styles by block name.
  7864. *
  7865. * @param {Object} state Data state.
  7866. * @param {string} name Block type name.
  7867. *
  7868. * @example
  7869. * ```js
  7870. * import { store as blocksStore } from '@wordpress/blocks';
  7871. * import { useSelect } from '@wordpress/data';
  7872. *
  7873. * const ExampleComponent = () => {
  7874. * const buttonBlockStyles = useSelect( ( select ) =>
  7875. * select( blocksStore ).getBlockStyles( 'core/button' ),
  7876. * []
  7877. * );
  7878. *
  7879. * return (
  7880. * <ul>
  7881. * { buttonBlockStyles &&
  7882. * buttonBlockStyles.map( ( style ) => (
  7883. * <li key={ style.name }>{ style.label }</li>
  7884. * ) ) }
  7885. * </ul>
  7886. * );
  7887. * };
  7888. * ```
  7889. *
  7890. * @return {Array?} Block Styles.
  7891. */
  7892. function getBlockStyles(state, name) {
  7893. return state.blockStyles[name];
  7894. }
  7895. /**
  7896. * Returns block variations by block name.
  7897. *
  7898. * @param {Object} state Data state.
  7899. * @param {string} blockName Block type name.
  7900. * @param {WPBlockVariationScope} [scope] Block variation scope name.
  7901. *
  7902. * @example
  7903. * ```js
  7904. * import { store as blocksStore } from '@wordpress/blocks';
  7905. * import { useSelect } from '@wordpress/data';
  7906. *
  7907. * const ExampleComponent = () => {
  7908. * const socialLinkVariations = useSelect( ( select ) =>
  7909. * select( blocksStore ).getBlockVariations( 'core/social-link' ),
  7910. * []
  7911. * );
  7912. *
  7913. * return (
  7914. * <ul>
  7915. * { socialLinkVariations &&
  7916. * socialLinkVariations.map( ( variation ) => (
  7917. * <li key={ variation.name }>{ variation.title }</li>
  7918. * ) ) }
  7919. * </ul>
  7920. * );
  7921. * };
  7922. * ```
  7923. *
  7924. * @return {(WPBlockVariation[]|void)} Block variations.
  7925. */
  7926. const selectors_getBlockVariations = rememo((state, blockName, scope) => {
  7927. const variations = state.blockVariations[blockName];
  7928. if (!variations || !scope) {
  7929. return variations;
  7930. }
  7931. return variations.filter(variation => {
  7932. // For backward compatibility reasons, variation's scope defaults to
  7933. // `block` and `inserter` when not set.
  7934. return (variation.scope || ['block', 'inserter']).includes(scope);
  7935. });
  7936. }, (state, blockName) => [state.blockVariations[blockName]]);
  7937. /**
  7938. * Returns the active block variation for a given block based on its attributes.
  7939. * Variations are determined by their `isActive` property.
  7940. * Which is either an array of block attribute keys or a function.
  7941. *
  7942. * In case of an array of block attribute keys, the `attributes` are compared
  7943. * to the variation's attributes using strict equality check.
  7944. *
  7945. * In case of function type, the function should accept a block's attributes
  7946. * and the variation's attributes and determines if a variation is active.
  7947. * A function that accepts a block's attributes and the variation's attributes and determines if a variation is active.
  7948. *
  7949. * @param {Object} state Data state.
  7950. * @param {string} blockName Name of block (example: “core/columns”).
  7951. * @param {Object} attributes Block attributes used to determine active variation.
  7952. * @param {WPBlockVariationScope} [scope] Block variation scope name.
  7953. *
  7954. * @example
  7955. * ```js
  7956. * import { __ } from '@wordpress/i18n';
  7957. * import { store as blocksStore } from '@wordpress/blocks';
  7958. * import { store as blockEditorStore } from '@wordpress/block-editor';
  7959. * import { useSelect } from '@wordpress/data';
  7960. *
  7961. * const ExampleComponent = () => {
  7962. * // This example assumes that a core/embed block is the first block in the Block Editor.
  7963. * const activeBlockVariation = useSelect( ( select ) => {
  7964. * // Retrieve the list of blocks.
  7965. * const [ firstBlock ] = select( blockEditorStore ).getBlocks()
  7966. *
  7967. * // Return the active block variation for the first block.
  7968. * return select( blocksStore ).getActiveBlockVariation(
  7969. * firstBlock.name,
  7970. * firstBlock.attributes
  7971. * );
  7972. * }, [] );
  7973. *
  7974. * return activeBlockVariation && activeBlockVariation.name === 'spotify' ? (
  7975. * <p>{ __( 'Spotify variation' ) }</p>
  7976. * ) : (
  7977. * <p>{ __( 'Other variation' ) }</p>
  7978. * );
  7979. * };
  7980. * ```
  7981. *
  7982. * @return {(WPBlockVariation|undefined)} Active block variation.
  7983. */
  7984. function getActiveBlockVariation(state, blockName, attributes, scope) {
  7985. const variations = selectors_getBlockVariations(state, blockName, scope);
  7986. const match = variations === null || variations === void 0 ? void 0 : variations.find(variation => {
  7987. var _variation$isActive;
  7988. if (Array.isArray(variation.isActive)) {
  7989. const blockType = selectors_getBlockType(state, blockName);
  7990. const attributeKeys = Object.keys((blockType === null || blockType === void 0 ? void 0 : blockType.attributes) || {});
  7991. const definedAttributes = variation.isActive.filter(attribute => attributeKeys.includes(attribute));
  7992. if (definedAttributes.length === 0) {
  7993. return false;
  7994. }
  7995. return definedAttributes.every(attribute => attributes[attribute] === variation.attributes[attribute]);
  7996. }
  7997. return (_variation$isActive = variation.isActive) === null || _variation$isActive === void 0 ? void 0 : _variation$isActive.call(variation, attributes, variation.attributes);
  7998. });
  7999. return match;
  8000. }
  8001. /**
  8002. * Returns the default block variation for the given block type.
  8003. * When there are multiple variations annotated as the default one,
  8004. * the last added item is picked. This simplifies registering overrides.
  8005. * When there is no default variation set, it returns the first item.
  8006. *
  8007. * @param {Object} state Data state.
  8008. * @param {string} blockName Block type name.
  8009. * @param {WPBlockVariationScope} [scope] Block variation scope name.
  8010. *
  8011. * @example
  8012. * ```js
  8013. * import { __, sprintf } from '@wordpress/i18n';
  8014. * import { store as blocksStore } from '@wordpress/blocks';
  8015. * import { useSelect } from '@wordpress/data';
  8016. *
  8017. * const ExampleComponent = () => {
  8018. * const defaultEmbedBlockVariation = useSelect( ( select ) =>
  8019. * select( blocksStore ).getDefaultBlockVariation( 'core/embed' ),
  8020. * []
  8021. * );
  8022. *
  8023. * return (
  8024. * defaultEmbedBlockVariation && (
  8025. * <p>
  8026. * { sprintf(
  8027. * __( 'core/embed default variation: %s' ),
  8028. * defaultEmbedBlockVariation.title
  8029. * ) }
  8030. * </p>
  8031. * )
  8032. * );
  8033. * };
  8034. * ```
  8035. *
  8036. * @return {?WPBlockVariation} The default block variation.
  8037. */
  8038. function getDefaultBlockVariation(state, blockName, scope) {
  8039. const variations = selectors_getBlockVariations(state, blockName, scope);
  8040. const defaultVariation = [...variations].reverse().find(_ref => {
  8041. let {
  8042. isDefault
  8043. } = _ref;
  8044. return !!isDefault;
  8045. });
  8046. return defaultVariation || variations[0];
  8047. }
  8048. /**
  8049. * Returns all the available block categories.
  8050. *
  8051. * @param {Object} state Data state.
  8052. *
  8053. * @example
  8054. * ```js
  8055. * import { store as blocksStore } from '@wordpress/blocks';
  8056. * import { useSelect, } from '@wordpress/data';
  8057. *
  8058. * const ExampleComponent = () => {
  8059. * const blockCategories = useSelect( ( select ) =>
  8060. * select( blocksStore ).getCategories(),
  8061. * []
  8062. * );
  8063. *
  8064. * return (
  8065. * <ul>
  8066. * { blockCategories.map( ( category ) => (
  8067. * <li key={ category.slug }>{ category.title }</li>
  8068. * ) ) }
  8069. * </ul>
  8070. * );
  8071. * };
  8072. * ```
  8073. *
  8074. * @return {WPBlockCategory[]} Categories list.
  8075. */
  8076. function getCategories(state) {
  8077. return state.categories;
  8078. }
  8079. /**
  8080. * Returns all the available collections.
  8081. *
  8082. * @param {Object} state Data state.
  8083. *
  8084. * @example
  8085. * ```js
  8086. * import { store as blocksStore } from '@wordpress/blocks';
  8087. * import { useSelect } from '@wordpress/data';
  8088. *
  8089. * const ExampleComponent = () => {
  8090. * const blockCollections = useSelect( ( select ) =>
  8091. * select( blocksStore ).getCollections(),
  8092. * []
  8093. * );
  8094. *
  8095. * return (
  8096. * <ul>
  8097. * { Object.values( blockCollections ).length > 0 &&
  8098. * Object.values( blockCollections ).map( ( collection ) => (
  8099. * <li key={ collection.title }>{ collection.title }</li>
  8100. * ) ) }
  8101. * </ul>
  8102. * );
  8103. * };
  8104. * ```
  8105. *
  8106. * @return {Object} Collections list.
  8107. */
  8108. function getCollections(state) {
  8109. return state.collections;
  8110. }
  8111. /**
  8112. * Returns the name of the default block name.
  8113. *
  8114. * @param {Object} state Data state.
  8115. *
  8116. * @example
  8117. * ```js
  8118. * import { __, sprintf } from '@wordpress/i18n';
  8119. * import { store as blocksStore } from '@wordpress/blocks';
  8120. * import { useSelect } from '@wordpress/data';
  8121. *
  8122. * const ExampleComponent = () => {
  8123. * const defaultBlockName = useSelect( ( select ) =>
  8124. * select( blocksStore ).getDefaultBlockName(),
  8125. * []
  8126. * );
  8127. *
  8128. * return (
  8129. * defaultBlockName && (
  8130. * <p>
  8131. * { sprintf( __( 'Default block name: %s' ), defaultBlockName ) }
  8132. * </p>
  8133. * )
  8134. * );
  8135. * };
  8136. * ```
  8137. *
  8138. * @return {string?} Default block name.
  8139. */
  8140. function selectors_getDefaultBlockName(state) {
  8141. return state.defaultBlockName;
  8142. }
  8143. /**
  8144. * Returns the name of the block for handling non-block content.
  8145. *
  8146. * @param {Object} state Data state.
  8147. *
  8148. * @example
  8149. * ```js
  8150. * import { __, sprintf } from '@wordpress/i18n';
  8151. * import { store as blocksStore } from '@wordpress/blocks';
  8152. * import { useSelect } from '@wordpress/data';
  8153. *
  8154. * const ExampleComponent = () => {
  8155. * const freeformFallbackBlockName = useSelect( ( select ) =>
  8156. * select( blocksStore ).getFreeformFallbackBlockName(),
  8157. * []
  8158. * );
  8159. *
  8160. * return (
  8161. * freeformFallbackBlockName && (
  8162. * <p>
  8163. * { sprintf( __(
  8164. * 'Freeform fallback block name: %s' ),
  8165. * freeformFallbackBlockName
  8166. * ) }
  8167. * </p>
  8168. * )
  8169. * );
  8170. * };
  8171. * ```
  8172. *
  8173. * @return {string?} Name of the block for handling non-block content.
  8174. */
  8175. function getFreeformFallbackBlockName(state) {
  8176. return state.freeformFallbackBlockName;
  8177. }
  8178. /**
  8179. * Returns the name of the block for handling unregistered blocks.
  8180. *
  8181. * @param {Object} state Data state.
  8182. *
  8183. * @example
  8184. * ```js
  8185. * import { __, sprintf } from '@wordpress/i18n';
  8186. * import { store as blocksStore } from '@wordpress/blocks';
  8187. * import { useSelect } from '@wordpress/data';
  8188. *
  8189. * const ExampleComponent = () => {
  8190. * const unregisteredFallbackBlockName = useSelect( ( select ) =>
  8191. * select( blocksStore ).getUnregisteredFallbackBlockName(),
  8192. * []
  8193. * );
  8194. *
  8195. * return (
  8196. * unregisteredFallbackBlockName && (
  8197. * <p>
  8198. * { sprintf( __(
  8199. * 'Unregistered fallback block name: %s' ),
  8200. * unregisteredFallbackBlockName
  8201. * ) }
  8202. * </p>
  8203. * )
  8204. * );
  8205. * };
  8206. * ```
  8207. *
  8208. * @return {string?} Name of the block for handling unregistered blocks.
  8209. */
  8210. function getUnregisteredFallbackBlockName(state) {
  8211. return state.unregisteredFallbackBlockName;
  8212. }
  8213. /**
  8214. * Returns the name of the block for handling the grouping of blocks.
  8215. *
  8216. * @param {Object} state Data state.
  8217. *
  8218. * @example
  8219. * ```js
  8220. * import { __, sprintf } from '@wordpress/i18n';
  8221. * import { store as blocksStore } from '@wordpress/blocks';
  8222. * import { useSelect } from '@wordpress/data';
  8223. *
  8224. * const ExampleComponent = () => {
  8225. * const groupingBlockName = useSelect( ( select ) =>
  8226. * select( blocksStore ).getGroupingBlockName(),
  8227. * []
  8228. * );
  8229. *
  8230. * return (
  8231. * groupingBlockName && (
  8232. * <p>
  8233. * { sprintf(
  8234. * __( 'Default grouping block name: %s' ),
  8235. * groupingBlockName
  8236. * ) }
  8237. * </p>
  8238. * )
  8239. * );
  8240. * };
  8241. * ```
  8242. *
  8243. * @return {string?} Name of the block for handling the grouping of blocks.
  8244. */
  8245. function selectors_getGroupingBlockName(state) {
  8246. return state.groupingBlockName;
  8247. }
  8248. /**
  8249. * Returns an array with the child blocks of a given block.
  8250. *
  8251. * @param {Object} state Data state.
  8252. * @param {string} blockName Block type name.
  8253. *
  8254. * @example
  8255. * ```js
  8256. * import { store as blocksStore } from '@wordpress/blocks';
  8257. * import { useSelect } from '@wordpress/data';
  8258. *
  8259. * const ExampleComponent = () => {
  8260. * const childBlockNames = useSelect( ( select ) =>
  8261. * select( blocksStore ).getChildBlockNames( 'core/navigation' ),
  8262. * []
  8263. * );
  8264. *
  8265. * return (
  8266. * <ul>
  8267. * { childBlockNames &&
  8268. * childBlockNames.map( ( child ) => (
  8269. * <li key={ child }>{ child }</li>
  8270. * ) ) }
  8271. * </ul>
  8272. * );
  8273. * };
  8274. * ```
  8275. *
  8276. * @return {Array} Array of child block names.
  8277. */
  8278. const selectors_getChildBlockNames = rememo((state, blockName) => {
  8279. return (0,external_lodash_namespaceObject.map)((0,external_lodash_namespaceObject.filter)(state.blockTypes, blockType => {
  8280. return (0,external_lodash_namespaceObject.includes)(blockType.parent, blockName);
  8281. }), _ref2 => {
  8282. let {
  8283. name
  8284. } = _ref2;
  8285. return name;
  8286. });
  8287. }, state => [state.blockTypes]);
  8288. /**
  8289. * Returns the block support value for a feature, if defined.
  8290. *
  8291. * @param {Object} state Data state.
  8292. * @param {(string|Object)} nameOrType Block name or type object
  8293. * @param {Array|string} feature Feature to retrieve
  8294. * @param {*} defaultSupports Default value to return if not
  8295. * explicitly defined
  8296. *
  8297. * @example
  8298. * ```js
  8299. * import { __, sprintf } from '@wordpress/i18n';
  8300. * import { store as blocksStore } from '@wordpress/blocks';
  8301. * import { useSelect } from '@wordpress/data';
  8302. *
  8303. * const ExampleComponent = () => {
  8304. * const paragraphBlockSupportValue = useSelect( ( select ) =>
  8305. * select( blocksStore ).getBlockSupport( 'core/paragraph', 'anchor' ),
  8306. * []
  8307. * );
  8308. *
  8309. * return (
  8310. * <p>
  8311. * { sprintf(
  8312. * __( 'core/paragraph supports.anchor value: %s' ),
  8313. * paragraphBlockSupportValue
  8314. * ) }
  8315. * </p>
  8316. * );
  8317. * };
  8318. * ```
  8319. *
  8320. * @return {?*} Block support value
  8321. */
  8322. const selectors_getBlockSupport = (state, nameOrType, feature, defaultSupports) => {
  8323. const blockType = getNormalizedBlockType(state, nameOrType);
  8324. if (!(blockType !== null && blockType !== void 0 && blockType.supports)) {
  8325. return defaultSupports;
  8326. }
  8327. return (0,external_lodash_namespaceObject.get)(blockType.supports, feature, defaultSupports);
  8328. };
  8329. /**
  8330. * Returns true if the block defines support for a feature, or false otherwise.
  8331. *
  8332. * @param {Object} state Data state.
  8333. * @param {(string|Object)} nameOrType Block name or type object.
  8334. * @param {string} feature Feature to test.
  8335. * @param {boolean} defaultSupports Whether feature is supported by
  8336. * default if not explicitly defined.
  8337. *
  8338. * @example
  8339. * ```js
  8340. * import { __, sprintf } from '@wordpress/i18n';
  8341. * import { store as blocksStore } from '@wordpress/blocks';
  8342. * import { useSelect } from '@wordpress/data';
  8343. *
  8344. * const ExampleComponent = () => {
  8345. * const paragraphBlockSupportClassName = useSelect( ( select ) =>
  8346. * select( blocksStore ).hasBlockSupport( 'core/paragraph', 'className' ),
  8347. * []
  8348. * );
  8349. *
  8350. * return (
  8351. * <p>
  8352. * { sprintf(
  8353. * __( 'core/paragraph supports custom class name?: %s' ),
  8354. * paragraphBlockSupportClassName
  8355. * ) }
  8356. * /p>
  8357. * );
  8358. * };
  8359. * ```
  8360. *
  8361. * @return {boolean} Whether block supports feature.
  8362. */
  8363. function selectors_hasBlockSupport(state, nameOrType, feature, defaultSupports) {
  8364. return !!selectors_getBlockSupport(state, nameOrType, feature, defaultSupports);
  8365. }
  8366. /**
  8367. * Returns true if the block type by the given name or object value matches a
  8368. * search term, or false otherwise.
  8369. *
  8370. * @param {Object} state Blocks state.
  8371. * @param {(string|Object)} nameOrType Block name or type object.
  8372. * @param {string} searchTerm Search term by which to filter.
  8373. *
  8374. * @example
  8375. * ```js
  8376. * import { __, sprintf } from '@wordpress/i18n';
  8377. * import { store as blocksStore } from '@wordpress/blocks';
  8378. * import { useSelect } from '@wordpress/data';
  8379. *
  8380. * const ExampleComponent = () => {
  8381. * const termFound = useSelect(
  8382. * ( select ) =>
  8383. * select( blocksStore ).isMatchingSearchTerm(
  8384. * 'core/navigation',
  8385. * 'theme'
  8386. * ),
  8387. * []
  8388. * );
  8389. *
  8390. * return (
  8391. * <p>
  8392. * { sprintf(
  8393. * __(
  8394. * 'Search term was found in the title, keywords, category or description in block.json: %s'
  8395. * ),
  8396. * termFound
  8397. * ) }
  8398. * </p>
  8399. * );
  8400. * };
  8401. * ```
  8402. *
  8403. * @return {Object[]} Whether block type matches search term.
  8404. */
  8405. function isMatchingSearchTerm(state, nameOrType, searchTerm) {
  8406. const blockType = getNormalizedBlockType(state, nameOrType);
  8407. const getNormalizedSearchTerm = (0,external_lodash_namespaceObject.flow)([// Disregard diacritics.
  8408. // Input: "média"
  8409. term => remove_accents_default()(term !== null && term !== void 0 ? term : ''), // Lowercase.
  8410. // Input: "MEDIA"
  8411. term => term.toLowerCase(), // Strip leading and trailing whitespace.
  8412. // Input: " media "
  8413. term => term.trim()]);
  8414. const normalizedSearchTerm = getNormalizedSearchTerm(searchTerm);
  8415. const isSearchMatch = (0,external_lodash_namespaceObject.flow)([getNormalizedSearchTerm, normalizedCandidate => (0,external_lodash_namespaceObject.includes)(normalizedCandidate, normalizedSearchTerm)]);
  8416. return isSearchMatch(blockType.title) || (0,external_lodash_namespaceObject.some)(blockType.keywords, isSearchMatch) || isSearchMatch(blockType.category) || typeof blockType.description === 'string' && isSearchMatch(blockType.description);
  8417. }
  8418. /**
  8419. * Returns a boolean indicating if a block has child blocks or not.
  8420. *
  8421. * @param {Object} state Data state.
  8422. * @param {string} blockName Block type name.
  8423. *
  8424. * @example
  8425. * ```js
  8426. * import { __, sprintf } from '@wordpress/i18n';
  8427. * import { store as blocksStore } from '@wordpress/blocks';
  8428. * import { useSelect } from '@wordpress/data';
  8429. *
  8430. * const ExampleComponent = () => {
  8431. * const navigationBlockHasChildBlocks = useSelect( ( select ) =>
  8432. * select( blocksStore ).hasChildBlocks( 'core/navigation' ),
  8433. * []
  8434. * );
  8435. *
  8436. * return (
  8437. * <p>
  8438. * { sprintf(
  8439. * __( 'core/navigation has child blocks: %s' ),
  8440. * navigationBlockHasChildBlocks
  8441. * ) }
  8442. * </p>
  8443. * );
  8444. * };
  8445. * ```
  8446. *
  8447. * @return {boolean} True if a block contains child blocks and false otherwise.
  8448. */
  8449. const selectors_hasChildBlocks = (state, blockName) => {
  8450. return selectors_getChildBlockNames(state, blockName).length > 0;
  8451. };
  8452. /**
  8453. * Returns a boolean indicating if a block has at least one child block with inserter support.
  8454. *
  8455. * @param {Object} state Data state.
  8456. * @param {string} blockName Block type name.
  8457. *
  8458. * @example
  8459. * ```js
  8460. * import { __, sprintf } from '@wordpress/i18n';
  8461. * import { store as blocksStore } from '@wordpress/blocks';
  8462. * import { useSelect } from '@wordpress/data';
  8463. *
  8464. * const ExampleComponent = () => {
  8465. * const navigationBlockHasChildBlocksWithInserterSupport = useSelect( ( select ) =>
  8466. * select( blocksStore ).hasChildBlocksWithInserterSupport(
  8467. * 'core/navigation'
  8468. * ),
  8469. * []
  8470. * );
  8471. *
  8472. * return (
  8473. * <p>
  8474. * { sprintf(
  8475. * __( 'core/navigation has child blocks with inserter support: %s' ),
  8476. * navigationBlockHasChildBlocksWithInserterSupport
  8477. * ) }
  8478. * </p>
  8479. * );
  8480. * };
  8481. * ```
  8482. *
  8483. * @return {boolean} True if a block contains at least one child blocks with inserter support
  8484. * and false otherwise.
  8485. */
  8486. const selectors_hasChildBlocksWithInserterSupport = (state, blockName) => {
  8487. return (0,external_lodash_namespaceObject.some)(selectors_getChildBlockNames(state, blockName), childBlockName => {
  8488. return selectors_hasBlockSupport(state, childBlockName, 'inserter', true);
  8489. });
  8490. };
  8491. const __experimentalHasContentRoleAttribute = rememo((state, blockTypeName) => {
  8492. const blockType = selectors_getBlockType(state, blockTypeName);
  8493. if (!blockType) {
  8494. return false;
  8495. }
  8496. return Object.entries(blockType.attributes).some(_ref3 => {
  8497. let [, {
  8498. __experimentalRole
  8499. }] = _ref3;
  8500. return __experimentalRole === 'content';
  8501. });
  8502. }, (state, blockTypeName) => {
  8503. var _state$blockTypes$blo;
  8504. return [(_state$blockTypes$blo = state.blockTypes[blockTypeName]) === null || _state$blockTypes$blo === void 0 ? void 0 : _state$blockTypes$blo.attributes];
  8505. });
  8506. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/node_modules/is-plain-object/dist/is-plain-object.mjs
  8507. /*!
  8508. * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
  8509. *
  8510. * Copyright (c) 2014-2017, Jon Schlinkert.
  8511. * Released under the MIT License.
  8512. */
  8513. function is_plain_object_isObject(o) {
  8514. return Object.prototype.toString.call(o) === '[object Object]';
  8515. }
  8516. function isPlainObject(o) {
  8517. var ctor,prot;
  8518. if (is_plain_object_isObject(o) === false) return false;
  8519. // If has modified constructor
  8520. ctor = o.constructor;
  8521. if (ctor === undefined) return true;
  8522. // If has modified prototype
  8523. prot = ctor.prototype;
  8524. if (is_plain_object_isObject(prot) === false) return false;
  8525. // If constructor does not have an Object-specific method
  8526. if (prot.hasOwnProperty('isPrototypeOf') === false) {
  8527. return false;
  8528. }
  8529. // Most likely a plain Object
  8530. return true;
  8531. }
  8532. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/actions.js
  8533. /**
  8534. * External dependencies
  8535. */
  8536. /**
  8537. * WordPress dependencies
  8538. */
  8539. /**
  8540. * Internal dependencies
  8541. */
  8542. /** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */
  8543. /** @typedef {import('../api/registration').WPBlockType} WPBlockType */
  8544. /** @typedef {import('./reducer').WPBlockCategory} WPBlockCategory */
  8545. const {
  8546. error,
  8547. warn
  8548. } = window.console;
  8549. /**
  8550. * Mapping of legacy category slugs to their latest normal values, used to
  8551. * accommodate updates of the default set of block categories.
  8552. *
  8553. * @type {Record<string,string>}
  8554. */
  8555. const LEGACY_CATEGORY_MAPPING = {
  8556. common: 'text',
  8557. formatting: 'text',
  8558. layout: 'design'
  8559. };
  8560. /**
  8561. * Whether the argument is a function.
  8562. *
  8563. * @param {*} maybeFunc The argument to check.
  8564. * @return {boolean} True if the argument is a function, false otherwise.
  8565. */
  8566. function isFunction(maybeFunc) {
  8567. return typeof maybeFunc === 'function';
  8568. }
  8569. /**
  8570. * Takes the unprocessed block type data and applies all the existing filters for the registered block type.
  8571. * Next, it validates all the settings and performs additional processing to the block type definition.
  8572. *
  8573. * @param {WPBlockType} blockType Unprocessed block type settings.
  8574. * @param {Object} thunkArgs Argument object for the thunk middleware.
  8575. * @param {Function} thunkArgs.select Function to select from the store.
  8576. *
  8577. * @return {?WPBlockType} The block, if it has been successfully registered; otherwise `undefined`.
  8578. */
  8579. const processBlockType = (blockType, _ref) => {
  8580. let {
  8581. select
  8582. } = _ref;
  8583. const {
  8584. name
  8585. } = blockType;
  8586. const settings = (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.registerBlockType', { ...blockType
  8587. }, name, null);
  8588. if (settings.deprecated) {
  8589. settings.deprecated = settings.deprecated.map(deprecation => (0,external_lodash_namespaceObject.pick)( // Only keep valid deprecation keys.
  8590. (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.registerBlockType', // Merge deprecation keys with pre-filter settings
  8591. // so that filters that depend on specific keys being
  8592. // present don't fail.
  8593. { // Omit deprecation keys here so that deprecations
  8594. // can opt out of specific keys like "supports".
  8595. ...omit(blockType, DEPRECATED_ENTRY_KEYS),
  8596. ...deprecation
  8597. }, name, deprecation), DEPRECATED_ENTRY_KEYS));
  8598. }
  8599. if (!isPlainObject(settings)) {
  8600. error('Block settings must be a valid object.');
  8601. return;
  8602. }
  8603. if (!isFunction(settings.save)) {
  8604. error('The "save" property must be a valid function.');
  8605. return;
  8606. }
  8607. if ('edit' in settings && !isFunction(settings.edit)) {
  8608. error('The "edit" property must be a valid function.');
  8609. return;
  8610. } // Canonicalize legacy categories to equivalent fallback.
  8611. if (LEGACY_CATEGORY_MAPPING.hasOwnProperty(settings.category)) {
  8612. settings.category = LEGACY_CATEGORY_MAPPING[settings.category];
  8613. }
  8614. if ('category' in settings && !(0,external_lodash_namespaceObject.some)(select.getCategories(), {
  8615. slug: settings.category
  8616. })) {
  8617. warn('The block "' + name + '" is registered with an invalid category "' + settings.category + '".');
  8618. delete settings.category;
  8619. }
  8620. if (!('title' in settings) || settings.title === '') {
  8621. error('The block "' + name + '" must have a title.');
  8622. return;
  8623. }
  8624. if (typeof settings.title !== 'string') {
  8625. error('Block titles must be strings.');
  8626. return;
  8627. }
  8628. settings.icon = normalizeIconObject(settings.icon);
  8629. if (!isValidIcon(settings.icon.src)) {
  8630. 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');
  8631. return;
  8632. }
  8633. return settings;
  8634. };
  8635. /**
  8636. * Returns an action object used in signalling that block types have been added.
  8637. * Ignored from documentation as the recommended usage for this action through registerBlockType from @wordpress/blocks.
  8638. *
  8639. * @ignore
  8640. *
  8641. * @param {WPBlockType|WPBlockType[]} blockTypes Object or array of objects representing blocks to added.
  8642. *
  8643. *
  8644. * @return {Object} Action object.
  8645. */
  8646. function addBlockTypes(blockTypes) {
  8647. return {
  8648. type: 'ADD_BLOCK_TYPES',
  8649. blockTypes: (0,external_lodash_namespaceObject.castArray)(blockTypes)
  8650. };
  8651. }
  8652. /**
  8653. * Signals that the passed block type's settings should be stored in the state.
  8654. *
  8655. * @param {WPBlockType} blockType Unprocessed block type settings.
  8656. */
  8657. const __experimentalRegisterBlockType = blockType => _ref2 => {
  8658. let {
  8659. dispatch,
  8660. select
  8661. } = _ref2;
  8662. dispatch({
  8663. type: 'ADD_UNPROCESSED_BLOCK_TYPE',
  8664. blockType
  8665. });
  8666. const processedBlockType = processBlockType(blockType, {
  8667. select
  8668. });
  8669. if (!processedBlockType) {
  8670. return;
  8671. }
  8672. dispatch.addBlockTypes(processedBlockType);
  8673. };
  8674. /**
  8675. * Signals that all block types should be computed again.
  8676. * It uses stored unprocessed block types and all the most recent list of registered filters.
  8677. *
  8678. * It addresses the issue where third party block filters get registered after third party blocks. A sample sequence:
  8679. * 1. Filter A.
  8680. * 2. Block B.
  8681. * 3. Block C.
  8682. * 4. Filter D.
  8683. * 5. Filter E.
  8684. * 6. Block F.
  8685. * 7. Filter G.
  8686. * In this scenario some filters would not get applied for all blocks because they are registered too late.
  8687. */
  8688. const __experimentalReapplyBlockTypeFilters = () => _ref3 => {
  8689. let {
  8690. dispatch,
  8691. select
  8692. } = _ref3;
  8693. const unprocessedBlockTypes = select.__experimentalGetUnprocessedBlockTypes();
  8694. const processedBlockTypes = Object.keys(unprocessedBlockTypes).reduce((accumulator, blockName) => {
  8695. const result = processBlockType(unprocessedBlockTypes[blockName], {
  8696. select
  8697. });
  8698. if (result) {
  8699. accumulator.push(result);
  8700. }
  8701. return accumulator;
  8702. }, []);
  8703. if (!processedBlockTypes.length) {
  8704. return;
  8705. }
  8706. dispatch.addBlockTypes(processedBlockTypes);
  8707. };
  8708. /**
  8709. * Returns an action object used to remove a registered block type.
  8710. * Ignored from documentation as the recommended usage for this action through unregisterBlockType from @wordpress/blocks.
  8711. *
  8712. * @ignore
  8713. *
  8714. * @param {string|string[]} names Block name or array of block names to be removed.
  8715. *
  8716. *
  8717. * @return {Object} Action object.
  8718. */
  8719. function removeBlockTypes(names) {
  8720. return {
  8721. type: 'REMOVE_BLOCK_TYPES',
  8722. names: (0,external_lodash_namespaceObject.castArray)(names)
  8723. };
  8724. }
  8725. /**
  8726. * Returns an action object used in signalling that new block styles have been added.
  8727. * Ignored from documentation as the recommended usage for this action through registerBlockStyle from @wordpress/blocks.
  8728. *
  8729. * @param {string} blockName Block name.
  8730. * @param {Array|Object} styles Block style object or array of block style objects.
  8731. *
  8732. * @ignore
  8733. *
  8734. * @return {Object} Action object.
  8735. */
  8736. function addBlockStyles(blockName, styles) {
  8737. return {
  8738. type: 'ADD_BLOCK_STYLES',
  8739. styles: (0,external_lodash_namespaceObject.castArray)(styles),
  8740. blockName
  8741. };
  8742. }
  8743. /**
  8744. * Returns an action object used in signalling that block styles have been removed.
  8745. * Ignored from documentation as the recommended usage for this action through unregisterBlockStyle from @wordpress/blocks.
  8746. *
  8747. * @ignore
  8748. *
  8749. * @param {string} blockName Block name.
  8750. * @param {Array|string} styleNames Block style names or array of block style names.
  8751. *
  8752. * @return {Object} Action object.
  8753. */
  8754. function removeBlockStyles(blockName, styleNames) {
  8755. return {
  8756. type: 'REMOVE_BLOCK_STYLES',
  8757. styleNames: (0,external_lodash_namespaceObject.castArray)(styleNames),
  8758. blockName
  8759. };
  8760. }
  8761. /**
  8762. * Returns an action object used in signalling that new block variations have been added.
  8763. * Ignored from documentation as the recommended usage for this action through registerBlockVariation from @wordpress/blocks.
  8764. *
  8765. * @ignore
  8766. *
  8767. * @param {string} blockName Block name.
  8768. * @param {WPBlockVariation|WPBlockVariation[]} variations Block variations.
  8769. *
  8770. * @return {Object} Action object.
  8771. */
  8772. function addBlockVariations(blockName, variations) {
  8773. return {
  8774. type: 'ADD_BLOCK_VARIATIONS',
  8775. variations: (0,external_lodash_namespaceObject.castArray)(variations),
  8776. blockName
  8777. };
  8778. }
  8779. /**
  8780. * Returns an action object used in signalling that block variations have been removed.
  8781. * Ignored from documentation as the recommended usage for this action through unregisterBlockVariation from @wordpress/blocks.
  8782. *
  8783. * @ignore
  8784. *
  8785. * @param {string} blockName Block name.
  8786. * @param {string|string[]} variationNames Block variation names.
  8787. *
  8788. * @return {Object} Action object.
  8789. */
  8790. function removeBlockVariations(blockName, variationNames) {
  8791. return {
  8792. type: 'REMOVE_BLOCK_VARIATIONS',
  8793. variationNames: (0,external_lodash_namespaceObject.castArray)(variationNames),
  8794. blockName
  8795. };
  8796. }
  8797. /**
  8798. * Returns an action object used to set the default block name.
  8799. * Ignored from documentation as the recommended usage for this action through setDefaultBlockName from @wordpress/blocks.
  8800. *
  8801. * @ignore
  8802. *
  8803. * @param {string} name Block name.
  8804. *
  8805. * @return {Object} Action object.
  8806. */
  8807. function actions_setDefaultBlockName(name) {
  8808. return {
  8809. type: 'SET_DEFAULT_BLOCK_NAME',
  8810. name
  8811. };
  8812. }
  8813. /**
  8814. * Returns an action object used to set the name of the block used as a fallback
  8815. * for non-block content.
  8816. * Ignored from documentation as the recommended usage for this action through setFreeformContentHandlerName from @wordpress/blocks.
  8817. *
  8818. * @ignore
  8819. *
  8820. * @param {string} name Block name.
  8821. *
  8822. * @return {Object} Action object.
  8823. */
  8824. function setFreeformFallbackBlockName(name) {
  8825. return {
  8826. type: 'SET_FREEFORM_FALLBACK_BLOCK_NAME',
  8827. name
  8828. };
  8829. }
  8830. /**
  8831. * Returns an action object used to set the name of the block used as a fallback
  8832. * for unregistered blocks.
  8833. * Ignored from documentation as the recommended usage for this action through setUnregisteredTypeHandlerName from @wordpress/blocks.
  8834. *
  8835. * @ignore
  8836. *
  8837. * @param {string} name Block name.
  8838. *
  8839. * @return {Object} Action object.
  8840. */
  8841. function setUnregisteredFallbackBlockName(name) {
  8842. return {
  8843. type: 'SET_UNREGISTERED_FALLBACK_BLOCK_NAME',
  8844. name
  8845. };
  8846. }
  8847. /**
  8848. * Returns an action object used to set the name of the block used
  8849. * when grouping other blocks
  8850. * eg: in "Group/Ungroup" interactions
  8851. * Ignored from documentation as the recommended usage for this action through setGroupingBlockName from @wordpress/blocks.
  8852. *
  8853. * @ignore
  8854. *
  8855. * @param {string} name Block name.
  8856. *
  8857. * @return {Object} Action object.
  8858. */
  8859. function actions_setGroupingBlockName(name) {
  8860. return {
  8861. type: 'SET_GROUPING_BLOCK_NAME',
  8862. name
  8863. };
  8864. }
  8865. /**
  8866. * Returns an action object used to set block categories.
  8867. * Ignored from documentation as the recommended usage for this action through setCategories from @wordpress/blocks.
  8868. *
  8869. * @ignore
  8870. *
  8871. * @param {WPBlockCategory[]} categories Block categories.
  8872. *
  8873. * @return {Object} Action object.
  8874. */
  8875. function setCategories(categories) {
  8876. return {
  8877. type: 'SET_CATEGORIES',
  8878. categories
  8879. };
  8880. }
  8881. /**
  8882. * Returns an action object used to update a category.
  8883. * Ignored from documentation as the recommended usage for this action through updateCategory from @wordpress/blocks.
  8884. *
  8885. * @ignore
  8886. *
  8887. * @param {string} slug Block category slug.
  8888. * @param {Object} category Object containing the category properties that should be updated.
  8889. *
  8890. * @return {Object} Action object.
  8891. */
  8892. function updateCategory(slug, category) {
  8893. return {
  8894. type: 'UPDATE_CATEGORY',
  8895. slug,
  8896. category
  8897. };
  8898. }
  8899. /**
  8900. * Returns an action object used to add block collections
  8901. * Ignored from documentation as the recommended usage for this action through registerBlockCollection from @wordpress/blocks.
  8902. *
  8903. * @ignore
  8904. *
  8905. * @param {string} namespace The namespace of the blocks to put in the collection
  8906. * @param {string} title The title to display in the block inserter
  8907. * @param {Object} icon (optional) The icon to display in the block inserter
  8908. *
  8909. * @return {Object} Action object.
  8910. */
  8911. function addBlockCollection(namespace, title, icon) {
  8912. return {
  8913. type: 'ADD_BLOCK_COLLECTION',
  8914. namespace,
  8915. title,
  8916. icon
  8917. };
  8918. }
  8919. /**
  8920. * Returns an action object used to remove block collections
  8921. * Ignored from documentation as the recommended usage for this action through unregisterBlockCollection from @wordpress/blocks.
  8922. *
  8923. * @ignore
  8924. *
  8925. * @param {string} namespace The namespace of the blocks to put in the collection
  8926. *
  8927. * @return {Object} Action object.
  8928. */
  8929. function removeBlockCollection(namespace) {
  8930. return {
  8931. type: 'REMOVE_BLOCK_COLLECTION',
  8932. namespace
  8933. };
  8934. }
  8935. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/constants.js
  8936. const STORE_NAME = 'core/blocks';
  8937. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/index.js
  8938. /**
  8939. * WordPress dependencies
  8940. */
  8941. /**
  8942. * Internal dependencies
  8943. */
  8944. /**
  8945. * Store definition for the blocks namespace.
  8946. *
  8947. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  8948. *
  8949. * @type {Object}
  8950. */
  8951. const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
  8952. reducer: reducer,
  8953. selectors: selectors_namespaceObject,
  8954. actions: actions_namespaceObject
  8955. });
  8956. (0,external_wp_data_namespaceObject.register)(store);
  8957. ;// CONCATENATED MODULE: external ["wp","blockSerializationDefaultParser"]
  8958. var external_wp_blockSerializationDefaultParser_namespaceObject = window["wp"]["blockSerializationDefaultParser"];
  8959. ;// CONCATENATED MODULE: external ["wp","autop"]
  8960. var external_wp_autop_namespaceObject = window["wp"]["autop"];
  8961. ;// CONCATENATED MODULE: external ["wp","isShallowEqual"]
  8962. var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"];
  8963. var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject);
  8964. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/serialize-raw-block.js
  8965. /**
  8966. * Internal dependencies
  8967. */
  8968. /**
  8969. * @typedef {Object} Options Serialization options.
  8970. * @property {boolean} [isCommentDelimited=true] Whether to output HTML comments around blocks.
  8971. */
  8972. /** @typedef {import("./").WPRawBlock} WPRawBlock */
  8973. /**
  8974. * Serializes a block node into the native HTML-comment-powered block format.
  8975. * CAVEAT: This function is intended for re-serializing blocks as parsed by
  8976. * valid parsers and skips any validation steps. This is NOT a generic
  8977. * serialization function for in-memory blocks. For most purposes, see the
  8978. * following functions available in the `@wordpress/blocks` package:
  8979. *
  8980. * @see serializeBlock
  8981. * @see serialize
  8982. *
  8983. * For more on the format of block nodes as returned by valid parsers:
  8984. *
  8985. * @see `@wordpress/block-serialization-default-parser` package
  8986. * @see `@wordpress/block-serialization-spec-parser` package
  8987. *
  8988. * @param {WPRawBlock} rawBlock A block node as returned by a valid parser.
  8989. * @param {Options} [options={}] Serialization options.
  8990. *
  8991. * @return {string} An HTML string representing a block.
  8992. */
  8993. function serializeRawBlock(rawBlock) {
  8994. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  8995. const {
  8996. isCommentDelimited = true
  8997. } = options;
  8998. const {
  8999. blockName,
  9000. attrs = {},
  9001. innerBlocks = [],
  9002. innerContent = []
  9003. } = rawBlock;
  9004. let childIndex = 0;
  9005. const content = innerContent.map(item => // `null` denotes a nested block, otherwise we have an HTML fragment.
  9006. item !== null ? item : serializeRawBlock(innerBlocks[childIndex++], options)).join('\n').replace(/\n+/g, '\n').trim();
  9007. return isCommentDelimited ? getCommentDelimitedContent(blockName, attrs, content) : content;
  9008. }
  9009. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/serializer.js
  9010. /**
  9011. * WordPress dependencies
  9012. */
  9013. /**
  9014. * Internal dependencies
  9015. */
  9016. /** @typedef {import('./parser').WPBlock} WPBlock */
  9017. /**
  9018. * @typedef {Object} WPBlockSerializationOptions Serialization Options.
  9019. *
  9020. * @property {boolean} isInnerBlocks Whether we are serializing inner blocks.
  9021. */
  9022. /**
  9023. * Returns the block's default classname from its name.
  9024. *
  9025. * @param {string} blockName The block name.
  9026. *
  9027. * @return {string} The block's default class.
  9028. */
  9029. function getBlockDefaultClassName(blockName) {
  9030. // Generated HTML classes for blocks follow the `wp-block-{name}` nomenclature.
  9031. // Blocks provided by WordPress drop the prefixes 'core/' or 'core-' (historically used in 'core-embed/').
  9032. const className = 'wp-block-' + blockName.replace(/\//, '-').replace(/^core-/, '');
  9033. return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getBlockDefaultClassName', className, blockName);
  9034. }
  9035. /**
  9036. * Returns the block's default menu item classname from its name.
  9037. *
  9038. * @param {string} blockName The block name.
  9039. *
  9040. * @return {string} The block's default menu item class.
  9041. */
  9042. function getBlockMenuDefaultClassName(blockName) {
  9043. // Generated HTML classes for blocks follow the `editor-block-list-item-{name}` nomenclature.
  9044. // Blocks provided by WordPress drop the prefixes 'core/' or 'core-' (historically used in 'core-embed/').
  9045. const className = 'editor-block-list-item-' + blockName.replace(/\//, '-').replace(/^core-/, '');
  9046. return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getBlockMenuDefaultClassName', className, blockName);
  9047. }
  9048. const blockPropsProvider = {};
  9049. const innerBlocksPropsProvider = {};
  9050. /**
  9051. * Call within a save function to get the props for the block wrapper.
  9052. *
  9053. * @param {Object} props Optional. Props to pass to the element.
  9054. */
  9055. function getBlockProps() {
  9056. let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  9057. const {
  9058. blockType,
  9059. attributes
  9060. } = blockPropsProvider;
  9061. return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getSaveContent.extraProps', { ...props
  9062. }, blockType, attributes);
  9063. }
  9064. /**
  9065. * Call within a save function to get the props for the inner blocks wrapper.
  9066. *
  9067. * @param {Object} props Optional. Props to pass to the element.
  9068. */
  9069. function getInnerBlocksProps() {
  9070. let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  9071. const {
  9072. innerBlocks
  9073. } = innerBlocksPropsProvider; // Value is an array of blocks, so defer to block serializer.
  9074. const html = serialize(innerBlocks, {
  9075. isInnerBlocks: true
  9076. }); // Use special-cased raw HTML tag to avoid default escaping.
  9077. const children = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, null, html);
  9078. return { ...props,
  9079. children
  9080. };
  9081. }
  9082. /**
  9083. * Given a block type containing a save render implementation and attributes, returns the
  9084. * enhanced element to be saved or string when raw HTML expected.
  9085. *
  9086. * @param {string|Object} blockTypeOrName Block type or name.
  9087. * @param {Object} attributes Block attributes.
  9088. * @param {?Array} innerBlocks Nested blocks.
  9089. *
  9090. * @return {Object|string} Save element or raw HTML string.
  9091. */
  9092. function getSaveElement(blockTypeOrName, attributes) {
  9093. let innerBlocks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
  9094. const blockType = normalizeBlockType(blockTypeOrName);
  9095. let {
  9096. save
  9097. } = blockType; // Component classes are unsupported for save since serialization must
  9098. // occur synchronously. For improved interoperability with higher-order
  9099. // components which often return component class, emulate basic support.
  9100. if (save.prototype instanceof external_wp_element_namespaceObject.Component) {
  9101. const instance = new save({
  9102. attributes
  9103. });
  9104. save = instance.render.bind(instance);
  9105. }
  9106. blockPropsProvider.blockType = blockType;
  9107. blockPropsProvider.attributes = attributes;
  9108. innerBlocksPropsProvider.innerBlocks = innerBlocks;
  9109. let element = save({
  9110. attributes,
  9111. innerBlocks
  9112. });
  9113. if (element !== null && typeof element === 'object' && (0,external_wp_hooks_namespaceObject.hasFilter)('blocks.getSaveContent.extraProps') && !(blockType.apiVersion > 1)) {
  9114. /**
  9115. * Filters the props applied to the block save result element.
  9116. *
  9117. * @param {Object} props Props applied to save element.
  9118. * @param {WPBlock} blockType Block type definition.
  9119. * @param {Object} attributes Block attributes.
  9120. */
  9121. const props = (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getSaveContent.extraProps', { ...element.props
  9122. }, blockType, attributes);
  9123. if (!external_wp_isShallowEqual_default()(props, element.props)) {
  9124. element = (0,external_wp_element_namespaceObject.cloneElement)(element, props);
  9125. }
  9126. }
  9127. /**
  9128. * Filters the save result of a block during serialization.
  9129. *
  9130. * @param {WPElement} element Block save result.
  9131. * @param {WPBlock} blockType Block type definition.
  9132. * @param {Object} attributes Block attributes.
  9133. */
  9134. return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getSaveElement', element, blockType, attributes);
  9135. }
  9136. /**
  9137. * Given a block type containing a save render implementation and attributes, returns the
  9138. * static markup to be saved.
  9139. *
  9140. * @param {string|Object} blockTypeOrName Block type or name.
  9141. * @param {Object} attributes Block attributes.
  9142. * @param {?Array} innerBlocks Nested blocks.
  9143. *
  9144. * @return {string} Save content.
  9145. */
  9146. function getSaveContent(blockTypeOrName, attributes, innerBlocks) {
  9147. const blockType = normalizeBlockType(blockTypeOrName);
  9148. return (0,external_wp_element_namespaceObject.renderToString)(getSaveElement(blockType, attributes, innerBlocks));
  9149. }
  9150. /**
  9151. * Returns attributes which are to be saved and serialized into the block
  9152. * comment delimiter.
  9153. *
  9154. * When a block exists in memory it contains as its attributes both those
  9155. * parsed the block comment delimiter _and_ those which matched from the
  9156. * contents of the block.
  9157. *
  9158. * This function returns only those attributes which are needed to persist and
  9159. * which cannot be matched from the block content.
  9160. *
  9161. * @param {Object<string,*>} blockType Block type.
  9162. * @param {Object<string,*>} attributes Attributes from in-memory block data.
  9163. *
  9164. * @return {Object<string,*>} Subset of attributes for comment serialization.
  9165. */
  9166. function getCommentAttributes(blockType, attributes) {
  9167. var _blockType$attributes;
  9168. return Object.entries((_blockType$attributes = blockType.attributes) !== null && _blockType$attributes !== void 0 ? _blockType$attributes : {}).reduce((accumulator, _ref) => {
  9169. let [key, attributeSchema] = _ref;
  9170. const value = attributes[key]; // Ignore undefined values.
  9171. if (undefined === value) {
  9172. return accumulator;
  9173. } // Ignore all attributes but the ones with an "undefined" source
  9174. // "undefined" source refers to attributes saved in the block comment.
  9175. if (attributeSchema.source !== undefined) {
  9176. return accumulator;
  9177. } // Ignore default value.
  9178. if ('default' in attributeSchema && attributeSchema.default === value) {
  9179. return accumulator;
  9180. } // Otherwise, include in comment set.
  9181. accumulator[key] = value;
  9182. return accumulator;
  9183. }, {});
  9184. }
  9185. /**
  9186. * Given an attributes object, returns a string in the serialized attributes
  9187. * format prepared for post content.
  9188. *
  9189. * @param {Object} attributes Attributes object.
  9190. *
  9191. * @return {string} Serialized attributes.
  9192. */
  9193. function serializeAttributes(attributes) {
  9194. return JSON.stringify(attributes) // Don't break HTML comments.
  9195. .replace(/--/g, '\\u002d\\u002d') // Don't break non-standard-compliant tools.
  9196. .replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/&/g, '\\u0026') // Bypass server stripslashes behavior which would unescape stringify's
  9197. // escaping of quotation mark.
  9198. //
  9199. // See: https://developer.wordpress.org/reference/functions/wp_kses_stripslashes/
  9200. .replace(/\\"/g, '\\u0022');
  9201. }
  9202. /**
  9203. * Given a block object, returns the Block's Inner HTML markup.
  9204. *
  9205. * @param {Object} block Block instance.
  9206. *
  9207. * @return {string} HTML.
  9208. */
  9209. function getBlockInnerHTML(block) {
  9210. // If block was parsed as invalid or encounters an error while generating
  9211. // save content, use original content instead to avoid content loss. If a
  9212. // block contains nested content, exempt it from this condition because we
  9213. // otherwise have no access to its original content and content loss would
  9214. // still occur.
  9215. let saveContent = block.originalContent;
  9216. if (block.isValid || block.innerBlocks.length) {
  9217. try {
  9218. saveContent = getSaveContent(block.name, block.attributes, block.innerBlocks);
  9219. } catch (error) {}
  9220. }
  9221. return saveContent;
  9222. }
  9223. /**
  9224. * Returns the content of a block, including comment delimiters.
  9225. *
  9226. * @param {string} rawBlockName Block name.
  9227. * @param {Object} attributes Block attributes.
  9228. * @param {string} content Block save content.
  9229. *
  9230. * @return {string} Comment-delimited block content.
  9231. */
  9232. function getCommentDelimitedContent(rawBlockName, attributes, content) {
  9233. const serializedAttributes = attributes && Object.entries(attributes).length ? serializeAttributes(attributes) + ' ' : ''; // Strip core blocks of their namespace prefix.
  9234. const blockName = rawBlockName !== null && rawBlockName !== void 0 && rawBlockName.startsWith('core/') ? rawBlockName.slice(5) : rawBlockName; // @todo make the `wp:` prefix potentially configurable.
  9235. if (!content) {
  9236. return `<!-- wp:${blockName} ${serializedAttributes}/-->`;
  9237. }
  9238. return `<!-- wp:${blockName} ${serializedAttributes}-->\n` + content + `\n<!-- /wp:${blockName} -->`;
  9239. }
  9240. /**
  9241. * Returns the content of a block, including comment delimiters, determining
  9242. * serialized attributes and content form from the current state of the block.
  9243. *
  9244. * @param {WPBlock} block Block instance.
  9245. * @param {WPBlockSerializationOptions} options Serialization options.
  9246. *
  9247. * @return {string} Serialized block.
  9248. */
  9249. function serializeBlock(block) {
  9250. let {
  9251. isInnerBlocks = false
  9252. } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  9253. if (!block.isValid && block.__unstableBlockSource) {
  9254. return serializeRawBlock(block.__unstableBlockSource);
  9255. }
  9256. const blockName = block.name;
  9257. const saveContent = getBlockInnerHTML(block);
  9258. if (blockName === getUnregisteredTypeHandlerName() || !isInnerBlocks && blockName === getFreeformContentHandlerName()) {
  9259. return saveContent;
  9260. }
  9261. const blockType = getBlockType(blockName);
  9262. if (!blockType) {
  9263. return saveContent;
  9264. }
  9265. const saveAttributes = getCommentAttributes(blockType, block.attributes);
  9266. return getCommentDelimitedContent(blockName, saveAttributes, saveContent);
  9267. }
  9268. function __unstableSerializeAndClean(blocks) {
  9269. // A single unmodified default block is assumed to
  9270. // be equivalent to an empty post.
  9271. if (blocks.length === 1 && isUnmodifiedDefaultBlock(blocks[0])) {
  9272. blocks = [];
  9273. }
  9274. let content = serialize(blocks); // For compatibility, treat a post consisting of a
  9275. // single freeform block as legacy content and apply
  9276. // pre-block-editor removep'd content formatting.
  9277. if (blocks.length === 1 && blocks[0].name === getFreeformContentHandlerName()) {
  9278. content = (0,external_wp_autop_namespaceObject.removep)(content);
  9279. }
  9280. return content;
  9281. }
  9282. /**
  9283. * Takes a block or set of blocks and returns the serialized post content.
  9284. *
  9285. * @param {Array} blocks Block(s) to serialize.
  9286. * @param {WPBlockSerializationOptions} options Serialization options.
  9287. *
  9288. * @return {string} The post content.
  9289. */
  9290. function serialize(blocks, options) {
  9291. const blocksArray = Array.isArray(blocks) ? blocks : [blocks];
  9292. return blocksArray.map(block => serializeBlock(block, options)).join('\n\n');
  9293. }
  9294. ;// CONCATENATED MODULE: ./node_modules/simple-html-tokenizer/dist/es6/index.js
  9295. /**
  9296. * generated from https://raw.githubusercontent.com/w3c/html/26b5126f96f736f796b9e29718138919dd513744/entities.json
  9297. * do not edit
  9298. */
  9299. var namedCharRefs = {
  9300. 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"
  9301. };
  9302. var HEXCHARCODE = /^#[xX]([A-Fa-f0-9]+)$/;
  9303. var CHARCODE = /^#([0-9]+)$/;
  9304. var NAMED = /^([A-Za-z0-9]+)$/;
  9305. var EntityParser = /** @class */ (function () {
  9306. function EntityParser(named) {
  9307. this.named = named;
  9308. }
  9309. EntityParser.prototype.parse = function (entity) {
  9310. if (!entity) {
  9311. return;
  9312. }
  9313. var matches = entity.match(HEXCHARCODE);
  9314. if (matches) {
  9315. return String.fromCharCode(parseInt(matches[1], 16));
  9316. }
  9317. matches = entity.match(CHARCODE);
  9318. if (matches) {
  9319. return String.fromCharCode(parseInt(matches[1], 10));
  9320. }
  9321. matches = entity.match(NAMED);
  9322. if (matches) {
  9323. return this.named[matches[1]];
  9324. }
  9325. };
  9326. return EntityParser;
  9327. }());
  9328. var WSP = /[\t\n\f ]/;
  9329. var ALPHA = /[A-Za-z]/;
  9330. var CRLF = /\r\n?/g;
  9331. function isSpace(char) {
  9332. return WSP.test(char);
  9333. }
  9334. function isAlpha(char) {
  9335. return ALPHA.test(char);
  9336. }
  9337. function preprocessInput(input) {
  9338. return input.replace(CRLF, '\n');
  9339. }
  9340. var EventedTokenizer = /** @class */ (function () {
  9341. function EventedTokenizer(delegate, entityParser, mode) {
  9342. if (mode === void 0) { mode = 'precompile'; }
  9343. this.delegate = delegate;
  9344. this.entityParser = entityParser;
  9345. this.mode = mode;
  9346. this.state = "beforeData" /* beforeData */;
  9347. this.line = -1;
  9348. this.column = -1;
  9349. this.input = '';
  9350. this.index = -1;
  9351. this.tagNameBuffer = '';
  9352. this.states = {
  9353. beforeData: function () {
  9354. var char = this.peek();
  9355. if (char === '<' && !this.isIgnoredEndTag()) {
  9356. this.transitionTo("tagOpen" /* tagOpen */);
  9357. this.markTagStart();
  9358. this.consume();
  9359. }
  9360. else {
  9361. if (this.mode === 'precompile' && char === '\n') {
  9362. var tag = this.tagNameBuffer.toLowerCase();
  9363. if (tag === 'pre' || tag === 'textarea') {
  9364. this.consume();
  9365. }
  9366. }
  9367. this.transitionTo("data" /* data */);
  9368. this.delegate.beginData();
  9369. }
  9370. },
  9371. data: function () {
  9372. var char = this.peek();
  9373. var tag = this.tagNameBuffer;
  9374. if (char === '<' && !this.isIgnoredEndTag()) {
  9375. this.delegate.finishData();
  9376. this.transitionTo("tagOpen" /* tagOpen */);
  9377. this.markTagStart();
  9378. this.consume();
  9379. }
  9380. else if (char === '&' && tag !== 'script' && tag !== 'style') {
  9381. this.consume();
  9382. this.delegate.appendToData(this.consumeCharRef() || '&');
  9383. }
  9384. else {
  9385. this.consume();
  9386. this.delegate.appendToData(char);
  9387. }
  9388. },
  9389. tagOpen: function () {
  9390. var char = this.consume();
  9391. if (char === '!') {
  9392. this.transitionTo("markupDeclarationOpen" /* markupDeclarationOpen */);
  9393. }
  9394. else if (char === '/') {
  9395. this.transitionTo("endTagOpen" /* endTagOpen */);
  9396. }
  9397. else if (char === '@' || char === ':' || isAlpha(char)) {
  9398. this.transitionTo("tagName" /* tagName */);
  9399. this.tagNameBuffer = '';
  9400. this.delegate.beginStartTag();
  9401. this.appendToTagName(char);
  9402. }
  9403. },
  9404. markupDeclarationOpen: function () {
  9405. var char = this.consume();
  9406. if (char === '-' && this.peek() === '-') {
  9407. this.consume();
  9408. this.transitionTo("commentStart" /* commentStart */);
  9409. this.delegate.beginComment();
  9410. }
  9411. else {
  9412. var maybeDoctype = char.toUpperCase() + this.input.substring(this.index, this.index + 6).toUpperCase();
  9413. if (maybeDoctype === 'DOCTYPE') {
  9414. this.consume();
  9415. this.consume();
  9416. this.consume();
  9417. this.consume();
  9418. this.consume();
  9419. this.consume();
  9420. this.transitionTo("doctype" /* doctype */);
  9421. if (this.delegate.beginDoctype)
  9422. this.delegate.beginDoctype();
  9423. }
  9424. }
  9425. },
  9426. doctype: function () {
  9427. var char = this.consume();
  9428. if (isSpace(char)) {
  9429. this.transitionTo("beforeDoctypeName" /* beforeDoctypeName */);
  9430. }
  9431. },
  9432. beforeDoctypeName: function () {
  9433. var char = this.consume();
  9434. if (isSpace(char)) {
  9435. return;
  9436. }
  9437. else {
  9438. this.transitionTo("doctypeName" /* doctypeName */);
  9439. if (this.delegate.appendToDoctypeName)
  9440. this.delegate.appendToDoctypeName(char.toLowerCase());
  9441. }
  9442. },
  9443. doctypeName: function () {
  9444. var char = this.consume();
  9445. if (isSpace(char)) {
  9446. this.transitionTo("afterDoctypeName" /* afterDoctypeName */);
  9447. }
  9448. else if (char === '>') {
  9449. if (this.delegate.endDoctype)
  9450. this.delegate.endDoctype();
  9451. this.transitionTo("beforeData" /* beforeData */);
  9452. }
  9453. else {
  9454. if (this.delegate.appendToDoctypeName)
  9455. this.delegate.appendToDoctypeName(char.toLowerCase());
  9456. }
  9457. },
  9458. afterDoctypeName: function () {
  9459. var char = this.consume();
  9460. if (isSpace(char)) {
  9461. return;
  9462. }
  9463. else if (char === '>') {
  9464. if (this.delegate.endDoctype)
  9465. this.delegate.endDoctype();
  9466. this.transitionTo("beforeData" /* beforeData */);
  9467. }
  9468. else {
  9469. var nextSixChars = char.toUpperCase() + this.input.substring(this.index, this.index + 5).toUpperCase();
  9470. var isPublic = nextSixChars.toUpperCase() === 'PUBLIC';
  9471. var isSystem = nextSixChars.toUpperCase() === 'SYSTEM';
  9472. if (isPublic || isSystem) {
  9473. this.consume();
  9474. this.consume();
  9475. this.consume();
  9476. this.consume();
  9477. this.consume();
  9478. this.consume();
  9479. }
  9480. if (isPublic) {
  9481. this.transitionTo("afterDoctypePublicKeyword" /* afterDoctypePublicKeyword */);
  9482. }
  9483. else if (isSystem) {
  9484. this.transitionTo("afterDoctypeSystemKeyword" /* afterDoctypeSystemKeyword */);
  9485. }
  9486. }
  9487. },
  9488. afterDoctypePublicKeyword: function () {
  9489. var char = this.peek();
  9490. if (isSpace(char)) {
  9491. this.transitionTo("beforeDoctypePublicIdentifier" /* beforeDoctypePublicIdentifier */);
  9492. this.consume();
  9493. }
  9494. else if (char === '"') {
  9495. this.transitionTo("doctypePublicIdentifierDoubleQuoted" /* doctypePublicIdentifierDoubleQuoted */);
  9496. this.consume();
  9497. }
  9498. else if (char === "'") {
  9499. this.transitionTo("doctypePublicIdentifierSingleQuoted" /* doctypePublicIdentifierSingleQuoted */);
  9500. this.consume();
  9501. }
  9502. else if (char === '>') {
  9503. this.consume();
  9504. if (this.delegate.endDoctype)
  9505. this.delegate.endDoctype();
  9506. this.transitionTo("beforeData" /* beforeData */);
  9507. }
  9508. },
  9509. doctypePublicIdentifierDoubleQuoted: function () {
  9510. var char = this.consume();
  9511. if (char === '"') {
  9512. this.transitionTo("afterDoctypePublicIdentifier" /* afterDoctypePublicIdentifier */);
  9513. }
  9514. else if (char === '>') {
  9515. if (this.delegate.endDoctype)
  9516. this.delegate.endDoctype();
  9517. this.transitionTo("beforeData" /* beforeData */);
  9518. }
  9519. else {
  9520. if (this.delegate.appendToDoctypePublicIdentifier)
  9521. this.delegate.appendToDoctypePublicIdentifier(char);
  9522. }
  9523. },
  9524. doctypePublicIdentifierSingleQuoted: function () {
  9525. var char = this.consume();
  9526. if (char === "'") {
  9527. this.transitionTo("afterDoctypePublicIdentifier" /* afterDoctypePublicIdentifier */);
  9528. }
  9529. else if (char === '>') {
  9530. if (this.delegate.endDoctype)
  9531. this.delegate.endDoctype();
  9532. this.transitionTo("beforeData" /* beforeData */);
  9533. }
  9534. else {
  9535. if (this.delegate.appendToDoctypePublicIdentifier)
  9536. this.delegate.appendToDoctypePublicIdentifier(char);
  9537. }
  9538. },
  9539. afterDoctypePublicIdentifier: function () {
  9540. var char = this.consume();
  9541. if (isSpace(char)) {
  9542. this.transitionTo("betweenDoctypePublicAndSystemIdentifiers" /* betweenDoctypePublicAndSystemIdentifiers */);
  9543. }
  9544. else if (char === '>') {
  9545. if (this.delegate.endDoctype)
  9546. this.delegate.endDoctype();
  9547. this.transitionTo("beforeData" /* beforeData */);
  9548. }
  9549. else if (char === '"') {
  9550. this.transitionTo("doctypeSystemIdentifierDoubleQuoted" /* doctypeSystemIdentifierDoubleQuoted */);
  9551. }
  9552. else if (char === "'") {
  9553. this.transitionTo("doctypeSystemIdentifierSingleQuoted" /* doctypeSystemIdentifierSingleQuoted */);
  9554. }
  9555. },
  9556. betweenDoctypePublicAndSystemIdentifiers: function () {
  9557. var char = this.consume();
  9558. if (isSpace(char)) {
  9559. return;
  9560. }
  9561. else if (char === '>') {
  9562. if (this.delegate.endDoctype)
  9563. this.delegate.endDoctype();
  9564. this.transitionTo("beforeData" /* beforeData */);
  9565. }
  9566. else if (char === '"') {
  9567. this.transitionTo("doctypeSystemIdentifierDoubleQuoted" /* doctypeSystemIdentifierDoubleQuoted */);
  9568. }
  9569. else if (char === "'") {
  9570. this.transitionTo("doctypeSystemIdentifierSingleQuoted" /* doctypeSystemIdentifierSingleQuoted */);
  9571. }
  9572. },
  9573. doctypeSystemIdentifierDoubleQuoted: function () {
  9574. var char = this.consume();
  9575. if (char === '"') {
  9576. this.transitionTo("afterDoctypeSystemIdentifier" /* afterDoctypeSystemIdentifier */);
  9577. }
  9578. else if (char === '>') {
  9579. if (this.delegate.endDoctype)
  9580. this.delegate.endDoctype();
  9581. this.transitionTo("beforeData" /* beforeData */);
  9582. }
  9583. else {
  9584. if (this.delegate.appendToDoctypeSystemIdentifier)
  9585. this.delegate.appendToDoctypeSystemIdentifier(char);
  9586. }
  9587. },
  9588. doctypeSystemIdentifierSingleQuoted: function () {
  9589. var char = this.consume();
  9590. if (char === "'") {
  9591. this.transitionTo("afterDoctypeSystemIdentifier" /* afterDoctypeSystemIdentifier */);
  9592. }
  9593. else if (char === '>') {
  9594. if (this.delegate.endDoctype)
  9595. this.delegate.endDoctype();
  9596. this.transitionTo("beforeData" /* beforeData */);
  9597. }
  9598. else {
  9599. if (this.delegate.appendToDoctypeSystemIdentifier)
  9600. this.delegate.appendToDoctypeSystemIdentifier(char);
  9601. }
  9602. },
  9603. afterDoctypeSystemIdentifier: function () {
  9604. var char = this.consume();
  9605. if (isSpace(char)) {
  9606. return;
  9607. }
  9608. else if (char === '>') {
  9609. if (this.delegate.endDoctype)
  9610. this.delegate.endDoctype();
  9611. this.transitionTo("beforeData" /* beforeData */);
  9612. }
  9613. },
  9614. commentStart: function () {
  9615. var char = this.consume();
  9616. if (char === '-') {
  9617. this.transitionTo("commentStartDash" /* commentStartDash */);
  9618. }
  9619. else if (char === '>') {
  9620. this.delegate.finishComment();
  9621. this.transitionTo("beforeData" /* beforeData */);
  9622. }
  9623. else {
  9624. this.delegate.appendToCommentData(char);
  9625. this.transitionTo("comment" /* comment */);
  9626. }
  9627. },
  9628. commentStartDash: function () {
  9629. var char = this.consume();
  9630. if (char === '-') {
  9631. this.transitionTo("commentEnd" /* commentEnd */);
  9632. }
  9633. else if (char === '>') {
  9634. this.delegate.finishComment();
  9635. this.transitionTo("beforeData" /* beforeData */);
  9636. }
  9637. else {
  9638. this.delegate.appendToCommentData('-');
  9639. this.transitionTo("comment" /* comment */);
  9640. }
  9641. },
  9642. comment: function () {
  9643. var char = this.consume();
  9644. if (char === '-') {
  9645. this.transitionTo("commentEndDash" /* commentEndDash */);
  9646. }
  9647. else {
  9648. this.delegate.appendToCommentData(char);
  9649. }
  9650. },
  9651. commentEndDash: function () {
  9652. var char = this.consume();
  9653. if (char === '-') {
  9654. this.transitionTo("commentEnd" /* commentEnd */);
  9655. }
  9656. else {
  9657. this.delegate.appendToCommentData('-' + char);
  9658. this.transitionTo("comment" /* comment */);
  9659. }
  9660. },
  9661. commentEnd: function () {
  9662. var char = this.consume();
  9663. if (char === '>') {
  9664. this.delegate.finishComment();
  9665. this.transitionTo("beforeData" /* beforeData */);
  9666. }
  9667. else {
  9668. this.delegate.appendToCommentData('--' + char);
  9669. this.transitionTo("comment" /* comment */);
  9670. }
  9671. },
  9672. tagName: function () {
  9673. var char = this.consume();
  9674. if (isSpace(char)) {
  9675. this.transitionTo("beforeAttributeName" /* beforeAttributeName */);
  9676. }
  9677. else if (char === '/') {
  9678. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  9679. }
  9680. else if (char === '>') {
  9681. this.delegate.finishTag();
  9682. this.transitionTo("beforeData" /* beforeData */);
  9683. }
  9684. else {
  9685. this.appendToTagName(char);
  9686. }
  9687. },
  9688. endTagName: function () {
  9689. var char = this.consume();
  9690. if (isSpace(char)) {
  9691. this.transitionTo("beforeAttributeName" /* beforeAttributeName */);
  9692. this.tagNameBuffer = '';
  9693. }
  9694. else if (char === '/') {
  9695. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  9696. this.tagNameBuffer = '';
  9697. }
  9698. else if (char === '>') {
  9699. this.delegate.finishTag();
  9700. this.transitionTo("beforeData" /* beforeData */);
  9701. this.tagNameBuffer = '';
  9702. }
  9703. else {
  9704. this.appendToTagName(char);
  9705. }
  9706. },
  9707. beforeAttributeName: function () {
  9708. var char = this.peek();
  9709. if (isSpace(char)) {
  9710. this.consume();
  9711. return;
  9712. }
  9713. else if (char === '/') {
  9714. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  9715. this.consume();
  9716. }
  9717. else if (char === '>') {
  9718. this.consume();
  9719. this.delegate.finishTag();
  9720. this.transitionTo("beforeData" /* beforeData */);
  9721. }
  9722. else if (char === '=') {
  9723. this.delegate.reportSyntaxError('attribute name cannot start with equals sign');
  9724. this.transitionTo("attributeName" /* attributeName */);
  9725. this.delegate.beginAttribute();
  9726. this.consume();
  9727. this.delegate.appendToAttributeName(char);
  9728. }
  9729. else {
  9730. this.transitionTo("attributeName" /* attributeName */);
  9731. this.delegate.beginAttribute();
  9732. }
  9733. },
  9734. attributeName: function () {
  9735. var char = this.peek();
  9736. if (isSpace(char)) {
  9737. this.transitionTo("afterAttributeName" /* afterAttributeName */);
  9738. this.consume();
  9739. }
  9740. else if (char === '/') {
  9741. this.delegate.beginAttributeValue(false);
  9742. this.delegate.finishAttributeValue();
  9743. this.consume();
  9744. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  9745. }
  9746. else if (char === '=') {
  9747. this.transitionTo("beforeAttributeValue" /* beforeAttributeValue */);
  9748. this.consume();
  9749. }
  9750. else if (char === '>') {
  9751. this.delegate.beginAttributeValue(false);
  9752. this.delegate.finishAttributeValue();
  9753. this.consume();
  9754. this.delegate.finishTag();
  9755. this.transitionTo("beforeData" /* beforeData */);
  9756. }
  9757. else if (char === '"' || char === "'" || char === '<') {
  9758. this.delegate.reportSyntaxError(char + ' is not a valid character within attribute names');
  9759. this.consume();
  9760. this.delegate.appendToAttributeName(char);
  9761. }
  9762. else {
  9763. this.consume();
  9764. this.delegate.appendToAttributeName(char);
  9765. }
  9766. },
  9767. afterAttributeName: function () {
  9768. var char = this.peek();
  9769. if (isSpace(char)) {
  9770. this.consume();
  9771. return;
  9772. }
  9773. else if (char === '/') {
  9774. this.delegate.beginAttributeValue(false);
  9775. this.delegate.finishAttributeValue();
  9776. this.consume();
  9777. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  9778. }
  9779. else if (char === '=') {
  9780. this.consume();
  9781. this.transitionTo("beforeAttributeValue" /* beforeAttributeValue */);
  9782. }
  9783. else if (char === '>') {
  9784. this.delegate.beginAttributeValue(false);
  9785. this.delegate.finishAttributeValue();
  9786. this.consume();
  9787. this.delegate.finishTag();
  9788. this.transitionTo("beforeData" /* beforeData */);
  9789. }
  9790. else {
  9791. this.delegate.beginAttributeValue(false);
  9792. this.delegate.finishAttributeValue();
  9793. this.transitionTo("attributeName" /* attributeName */);
  9794. this.delegate.beginAttribute();
  9795. this.consume();
  9796. this.delegate.appendToAttributeName(char);
  9797. }
  9798. },
  9799. beforeAttributeValue: function () {
  9800. var char = this.peek();
  9801. if (isSpace(char)) {
  9802. this.consume();
  9803. }
  9804. else if (char === '"') {
  9805. this.transitionTo("attributeValueDoubleQuoted" /* attributeValueDoubleQuoted */);
  9806. this.delegate.beginAttributeValue(true);
  9807. this.consume();
  9808. }
  9809. else if (char === "'") {
  9810. this.transitionTo("attributeValueSingleQuoted" /* attributeValueSingleQuoted */);
  9811. this.delegate.beginAttributeValue(true);
  9812. this.consume();
  9813. }
  9814. else if (char === '>') {
  9815. this.delegate.beginAttributeValue(false);
  9816. this.delegate.finishAttributeValue();
  9817. this.consume();
  9818. this.delegate.finishTag();
  9819. this.transitionTo("beforeData" /* beforeData */);
  9820. }
  9821. else {
  9822. this.transitionTo("attributeValueUnquoted" /* attributeValueUnquoted */);
  9823. this.delegate.beginAttributeValue(false);
  9824. this.consume();
  9825. this.delegate.appendToAttributeValue(char);
  9826. }
  9827. },
  9828. attributeValueDoubleQuoted: function () {
  9829. var char = this.consume();
  9830. if (char === '"') {
  9831. this.delegate.finishAttributeValue();
  9832. this.transitionTo("afterAttributeValueQuoted" /* afterAttributeValueQuoted */);
  9833. }
  9834. else if (char === '&') {
  9835. this.delegate.appendToAttributeValue(this.consumeCharRef() || '&');
  9836. }
  9837. else {
  9838. this.delegate.appendToAttributeValue(char);
  9839. }
  9840. },
  9841. attributeValueSingleQuoted: function () {
  9842. var char = this.consume();
  9843. if (char === "'") {
  9844. this.delegate.finishAttributeValue();
  9845. this.transitionTo("afterAttributeValueQuoted" /* afterAttributeValueQuoted */);
  9846. }
  9847. else if (char === '&') {
  9848. this.delegate.appendToAttributeValue(this.consumeCharRef() || '&');
  9849. }
  9850. else {
  9851. this.delegate.appendToAttributeValue(char);
  9852. }
  9853. },
  9854. attributeValueUnquoted: function () {
  9855. var char = this.peek();
  9856. if (isSpace(char)) {
  9857. this.delegate.finishAttributeValue();
  9858. this.consume();
  9859. this.transitionTo("beforeAttributeName" /* beforeAttributeName */);
  9860. }
  9861. else if (char === '/') {
  9862. this.delegate.finishAttributeValue();
  9863. this.consume();
  9864. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  9865. }
  9866. else if (char === '&') {
  9867. this.consume();
  9868. this.delegate.appendToAttributeValue(this.consumeCharRef() || '&');
  9869. }
  9870. else if (char === '>') {
  9871. this.delegate.finishAttributeValue();
  9872. this.consume();
  9873. this.delegate.finishTag();
  9874. this.transitionTo("beforeData" /* beforeData */);
  9875. }
  9876. else {
  9877. this.consume();
  9878. this.delegate.appendToAttributeValue(char);
  9879. }
  9880. },
  9881. afterAttributeValueQuoted: function () {
  9882. var char = this.peek();
  9883. if (isSpace(char)) {
  9884. this.consume();
  9885. this.transitionTo("beforeAttributeName" /* beforeAttributeName */);
  9886. }
  9887. else if (char === '/') {
  9888. this.consume();
  9889. this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */);
  9890. }
  9891. else if (char === '>') {
  9892. this.consume();
  9893. this.delegate.finishTag();
  9894. this.transitionTo("beforeData" /* beforeData */);
  9895. }
  9896. else {
  9897. this.transitionTo("beforeAttributeName" /* beforeAttributeName */);
  9898. }
  9899. },
  9900. selfClosingStartTag: function () {
  9901. var char = this.peek();
  9902. if (char === '>') {
  9903. this.consume();
  9904. this.delegate.markTagAsSelfClosing();
  9905. this.delegate.finishTag();
  9906. this.transitionTo("beforeData" /* beforeData */);
  9907. }
  9908. else {
  9909. this.transitionTo("beforeAttributeName" /* beforeAttributeName */);
  9910. }
  9911. },
  9912. endTagOpen: function () {
  9913. var char = this.consume();
  9914. if (char === '@' || char === ':' || isAlpha(char)) {
  9915. this.transitionTo("endTagName" /* endTagName */);
  9916. this.tagNameBuffer = '';
  9917. this.delegate.beginEndTag();
  9918. this.appendToTagName(char);
  9919. }
  9920. }
  9921. };
  9922. this.reset();
  9923. }
  9924. EventedTokenizer.prototype.reset = function () {
  9925. this.transitionTo("beforeData" /* beforeData */);
  9926. this.input = '';
  9927. this.tagNameBuffer = '';
  9928. this.index = 0;
  9929. this.line = 1;
  9930. this.column = 0;
  9931. this.delegate.reset();
  9932. };
  9933. EventedTokenizer.prototype.transitionTo = function (state) {
  9934. this.state = state;
  9935. };
  9936. EventedTokenizer.prototype.tokenize = function (input) {
  9937. this.reset();
  9938. this.tokenizePart(input);
  9939. this.tokenizeEOF();
  9940. };
  9941. EventedTokenizer.prototype.tokenizePart = function (input) {
  9942. this.input += preprocessInput(input);
  9943. while (this.index < this.input.length) {
  9944. var handler = this.states[this.state];
  9945. if (handler !== undefined) {
  9946. handler.call(this);
  9947. }
  9948. else {
  9949. throw new Error("unhandled state " + this.state);
  9950. }
  9951. }
  9952. };
  9953. EventedTokenizer.prototype.tokenizeEOF = function () {
  9954. this.flushData();
  9955. };
  9956. EventedTokenizer.prototype.flushData = function () {
  9957. if (this.state === 'data') {
  9958. this.delegate.finishData();
  9959. this.transitionTo("beforeData" /* beforeData */);
  9960. }
  9961. };
  9962. EventedTokenizer.prototype.peek = function () {
  9963. return this.input.charAt(this.index);
  9964. };
  9965. EventedTokenizer.prototype.consume = function () {
  9966. var char = this.peek();
  9967. this.index++;
  9968. if (char === '\n') {
  9969. this.line++;
  9970. this.column = 0;
  9971. }
  9972. else {
  9973. this.column++;
  9974. }
  9975. return char;
  9976. };
  9977. EventedTokenizer.prototype.consumeCharRef = function () {
  9978. var endIndex = this.input.indexOf(';', this.index);
  9979. if (endIndex === -1) {
  9980. return;
  9981. }
  9982. var entity = this.input.slice(this.index, endIndex);
  9983. var chars = this.entityParser.parse(entity);
  9984. if (chars) {
  9985. var count = entity.length;
  9986. // consume the entity chars
  9987. while (count) {
  9988. this.consume();
  9989. count--;
  9990. }
  9991. // consume the `;`
  9992. this.consume();
  9993. return chars;
  9994. }
  9995. };
  9996. EventedTokenizer.prototype.markTagStart = function () {
  9997. this.delegate.tagOpen();
  9998. };
  9999. EventedTokenizer.prototype.appendToTagName = function (char) {
  10000. this.tagNameBuffer += char;
  10001. this.delegate.appendToTagName(char);
  10002. };
  10003. EventedTokenizer.prototype.isIgnoredEndTag = function () {
  10004. var tag = this.tagNameBuffer;
  10005. return (tag === 'title' && this.input.substring(this.index, this.index + 8) !== '</title>') ||
  10006. (tag === 'style' && this.input.substring(this.index, this.index + 8) !== '</style>') ||
  10007. (tag === 'script' && this.input.substring(this.index, this.index + 9) !== '</script>');
  10008. };
  10009. return EventedTokenizer;
  10010. }());
  10011. var Tokenizer = /** @class */ (function () {
  10012. function Tokenizer(entityParser, options) {
  10013. if (options === void 0) { options = {}; }
  10014. this.options = options;
  10015. this.token = null;
  10016. this.startLine = 1;
  10017. this.startColumn = 0;
  10018. this.tokens = [];
  10019. this.tokenizer = new EventedTokenizer(this, entityParser, options.mode);
  10020. this._currentAttribute = undefined;
  10021. }
  10022. Tokenizer.prototype.tokenize = function (input) {
  10023. this.tokens = [];
  10024. this.tokenizer.tokenize(input);
  10025. return this.tokens;
  10026. };
  10027. Tokenizer.prototype.tokenizePart = function (input) {
  10028. this.tokens = [];
  10029. this.tokenizer.tokenizePart(input);
  10030. return this.tokens;
  10031. };
  10032. Tokenizer.prototype.tokenizeEOF = function () {
  10033. this.tokens = [];
  10034. this.tokenizer.tokenizeEOF();
  10035. return this.tokens[0];
  10036. };
  10037. Tokenizer.prototype.reset = function () {
  10038. this.token = null;
  10039. this.startLine = 1;
  10040. this.startColumn = 0;
  10041. };
  10042. Tokenizer.prototype.current = function () {
  10043. var token = this.token;
  10044. if (token === null) {
  10045. throw new Error('token was unexpectedly null');
  10046. }
  10047. if (arguments.length === 0) {
  10048. return token;
  10049. }
  10050. for (var i = 0; i < arguments.length; i++) {
  10051. if (token.type === arguments[i]) {
  10052. return token;
  10053. }
  10054. }
  10055. throw new Error("token type was unexpectedly " + token.type);
  10056. };
  10057. Tokenizer.prototype.push = function (token) {
  10058. this.token = token;
  10059. this.tokens.push(token);
  10060. };
  10061. Tokenizer.prototype.currentAttribute = function () {
  10062. return this._currentAttribute;
  10063. };
  10064. Tokenizer.prototype.addLocInfo = function () {
  10065. if (this.options.loc) {
  10066. this.current().loc = {
  10067. start: {
  10068. line: this.startLine,
  10069. column: this.startColumn
  10070. },
  10071. end: {
  10072. line: this.tokenizer.line,
  10073. column: this.tokenizer.column
  10074. }
  10075. };
  10076. }
  10077. this.startLine = this.tokenizer.line;
  10078. this.startColumn = this.tokenizer.column;
  10079. };
  10080. // Data
  10081. Tokenizer.prototype.beginDoctype = function () {
  10082. this.push({
  10083. type: "Doctype" /* Doctype */,
  10084. name: '',
  10085. });
  10086. };
  10087. Tokenizer.prototype.appendToDoctypeName = function (char) {
  10088. this.current("Doctype" /* Doctype */).name += char;
  10089. };
  10090. Tokenizer.prototype.appendToDoctypePublicIdentifier = function (char) {
  10091. var doctype = this.current("Doctype" /* Doctype */);
  10092. if (doctype.publicIdentifier === undefined) {
  10093. doctype.publicIdentifier = char;
  10094. }
  10095. else {
  10096. doctype.publicIdentifier += char;
  10097. }
  10098. };
  10099. Tokenizer.prototype.appendToDoctypeSystemIdentifier = function (char) {
  10100. var doctype = this.current("Doctype" /* Doctype */);
  10101. if (doctype.systemIdentifier === undefined) {
  10102. doctype.systemIdentifier = char;
  10103. }
  10104. else {
  10105. doctype.systemIdentifier += char;
  10106. }
  10107. };
  10108. Tokenizer.prototype.endDoctype = function () {
  10109. this.addLocInfo();
  10110. };
  10111. Tokenizer.prototype.beginData = function () {
  10112. this.push({
  10113. type: "Chars" /* Chars */,
  10114. chars: ''
  10115. });
  10116. };
  10117. Tokenizer.prototype.appendToData = function (char) {
  10118. this.current("Chars" /* Chars */).chars += char;
  10119. };
  10120. Tokenizer.prototype.finishData = function () {
  10121. this.addLocInfo();
  10122. };
  10123. // Comment
  10124. Tokenizer.prototype.beginComment = function () {
  10125. this.push({
  10126. type: "Comment" /* Comment */,
  10127. chars: ''
  10128. });
  10129. };
  10130. Tokenizer.prototype.appendToCommentData = function (char) {
  10131. this.current("Comment" /* Comment */).chars += char;
  10132. };
  10133. Tokenizer.prototype.finishComment = function () {
  10134. this.addLocInfo();
  10135. };
  10136. // Tags - basic
  10137. Tokenizer.prototype.tagOpen = function () { };
  10138. Tokenizer.prototype.beginStartTag = function () {
  10139. this.push({
  10140. type: "StartTag" /* StartTag */,
  10141. tagName: '',
  10142. attributes: [],
  10143. selfClosing: false
  10144. });
  10145. };
  10146. Tokenizer.prototype.beginEndTag = function () {
  10147. this.push({
  10148. type: "EndTag" /* EndTag */,
  10149. tagName: ''
  10150. });
  10151. };
  10152. Tokenizer.prototype.finishTag = function () {
  10153. this.addLocInfo();
  10154. };
  10155. Tokenizer.prototype.markTagAsSelfClosing = function () {
  10156. this.current("StartTag" /* StartTag */).selfClosing = true;
  10157. };
  10158. // Tags - name
  10159. Tokenizer.prototype.appendToTagName = function (char) {
  10160. this.current("StartTag" /* StartTag */, "EndTag" /* EndTag */).tagName += char;
  10161. };
  10162. // Tags - attributes
  10163. Tokenizer.prototype.beginAttribute = function () {
  10164. this._currentAttribute = ['', '', false];
  10165. };
  10166. Tokenizer.prototype.appendToAttributeName = function (char) {
  10167. this.currentAttribute()[0] += char;
  10168. };
  10169. Tokenizer.prototype.beginAttributeValue = function (isQuoted) {
  10170. this.currentAttribute()[2] = isQuoted;
  10171. };
  10172. Tokenizer.prototype.appendToAttributeValue = function (char) {
  10173. this.currentAttribute()[1] += char;
  10174. };
  10175. Tokenizer.prototype.finishAttributeValue = function () {
  10176. this.current("StartTag" /* StartTag */).attributes.push(this._currentAttribute);
  10177. };
  10178. Tokenizer.prototype.reportSyntaxError = function (message) {
  10179. this.current().syntaxError = message;
  10180. };
  10181. return Tokenizer;
  10182. }());
  10183. function tokenize(input, options) {
  10184. var tokenizer = new Tokenizer(new EntityParser(namedCharRefs), options);
  10185. return tokenizer.tokenize(input);
  10186. }
  10187. ;// CONCATENATED MODULE: external ["wp","deprecated"]
  10188. var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
  10189. var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
  10190. ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
  10191. var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
  10192. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/validation/logger.js
  10193. /**
  10194. * @typedef LoggerItem
  10195. * @property {Function} log Which logger recorded the message
  10196. * @property {Array<any>} args White arguments were supplied to the logger
  10197. */
  10198. function createLogger() {
  10199. /**
  10200. * Creates a log handler with block validation prefix.
  10201. *
  10202. * @param {Function} logger Original logger function.
  10203. *
  10204. * @return {Function} Augmented logger function.
  10205. */
  10206. function createLogHandler(logger) {
  10207. let log = function (message) {
  10208. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  10209. args[_key - 1] = arguments[_key];
  10210. }
  10211. return logger('Block validation: ' + message, ...args);
  10212. }; // In test environments, pre-process string substitutions to improve
  10213. // readability of error messages. We'd prefer to avoid pulling in this
  10214. // dependency in runtime environments, and it can be dropped by a combo
  10215. // of Webpack env substitution + UglifyJS dead code elimination.
  10216. if (false) {}
  10217. return log;
  10218. }
  10219. return {
  10220. // eslint-disable-next-line no-console
  10221. error: createLogHandler(console.error),
  10222. // eslint-disable-next-line no-console
  10223. warning: createLogHandler(console.warn),
  10224. getItems() {
  10225. return [];
  10226. }
  10227. };
  10228. }
  10229. function createQueuedLogger() {
  10230. /**
  10231. * The list of enqueued log actions to print.
  10232. *
  10233. * @type {Array<LoggerItem>}
  10234. */
  10235. const queue = [];
  10236. const logger = createLogger();
  10237. return {
  10238. error() {
  10239. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  10240. args[_key2] = arguments[_key2];
  10241. }
  10242. queue.push({
  10243. log: logger.error,
  10244. args
  10245. });
  10246. },
  10247. warning() {
  10248. for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  10249. args[_key3] = arguments[_key3];
  10250. }
  10251. queue.push({
  10252. log: logger.warning,
  10253. args
  10254. });
  10255. },
  10256. getItems() {
  10257. return queue;
  10258. }
  10259. };
  10260. }
  10261. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/validation/index.js
  10262. /**
  10263. * External dependencies
  10264. */
  10265. /**
  10266. * WordPress dependencies
  10267. */
  10268. /**
  10269. * Internal dependencies
  10270. */
  10271. /** @typedef {import('../parser').WPBlock} WPBlock */
  10272. /** @typedef {import('../registration').WPBlockType} WPBlockType */
  10273. /** @typedef {import('./logger').LoggerItem} LoggerItem */
  10274. const identity = x => x;
  10275. /**
  10276. * Globally matches any consecutive whitespace
  10277. *
  10278. * @type {RegExp}
  10279. */
  10280. const REGEXP_WHITESPACE = /[\t\n\r\v\f ]+/g;
  10281. /**
  10282. * Matches a string containing only whitespace
  10283. *
  10284. * @type {RegExp}
  10285. */
  10286. const REGEXP_ONLY_WHITESPACE = /^[\t\n\r\v\f ]*$/;
  10287. /**
  10288. * Matches a CSS URL type value
  10289. *
  10290. * @type {RegExp}
  10291. */
  10292. const REGEXP_STYLE_URL_TYPE = /^url\s*\(['"\s]*(.*?)['"\s]*\)$/;
  10293. /**
  10294. * Boolean attributes are attributes whose presence as being assigned is
  10295. * meaningful, even if only empty.
  10296. *
  10297. * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes
  10298. * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
  10299. *
  10300. * Object.keys( Array.from( document.querySelectorAll( '#attributes-1 > tbody > tr' ) )
  10301. * .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 )
  10302. * .reduce( ( result, tr ) => Object.assign( result, {
  10303. * [ tr.firstChild.textContent.trim() ]: true
  10304. * } ), {} ) ).sort();
  10305. *
  10306. * @type {Array}
  10307. */
  10308. 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'];
  10309. /**
  10310. * Enumerated attributes are attributes which must be of a specific value form.
  10311. * Like boolean attributes, these are meaningful if specified, even if not of a
  10312. * valid enumerated value.
  10313. *
  10314. * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute
  10315. * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
  10316. *
  10317. * Object.keys( Array.from( document.querySelectorAll( '#attributes-1 > tbody > tr' ) )
  10318. * .filter( ( tr ) => /^("(.+?)";?\s*)+/.test( tr.lastChild.textContent.trim() ) )
  10319. * .reduce( ( result, tr ) => Object.assign( result, {
  10320. * [ tr.firstChild.textContent.trim() ]: true
  10321. * } ), {} ) ).sort();
  10322. *
  10323. * @type {Array}
  10324. */
  10325. 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'];
  10326. /**
  10327. * Meaningful attributes are those who cannot be safely ignored when omitted in
  10328. * one HTML markup string and not another.
  10329. *
  10330. * @type {Array}
  10331. */
  10332. const MEANINGFUL_ATTRIBUTES = [...BOOLEAN_ATTRIBUTES, ...ENUMERATED_ATTRIBUTES];
  10333. /**
  10334. * Array of functions which receive a text string on which to apply normalizing
  10335. * behavior for consideration in text token equivalence, carefully ordered from
  10336. * least-to-most expensive operations.
  10337. *
  10338. * @type {Array}
  10339. */
  10340. const TEXT_NORMALIZATIONS = [identity, getTextWithCollapsedWhitespace];
  10341. /**
  10342. * Regular expression matching a named character reference. In lieu of bundling
  10343. * a full set of references, the pattern covers the minimal necessary to test
  10344. * positively against the full set.
  10345. *
  10346. * "The ampersand must be followed by one of the names given in the named
  10347. * character references section, using the same case."
  10348. *
  10349. * Tested aginst "12.5 Named character references":
  10350. *
  10351. * ```
  10352. * const references = Array.from( document.querySelectorAll(
  10353. * '#named-character-references-table tr[id^=entity-] td:first-child'
  10354. * ) ).map( ( code ) => code.textContent )
  10355. * references.every( ( reference ) => /^[\da-z]+$/i.test( reference ) )
  10356. * ```
  10357. *
  10358. * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references
  10359. * @see https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references
  10360. *
  10361. * @type {RegExp}
  10362. */
  10363. const REGEXP_NAMED_CHARACTER_REFERENCE = /^[\da-z]+$/i;
  10364. /**
  10365. * Regular expression matching a decimal character reference.
  10366. *
  10367. * "The ampersand must be followed by a U+0023 NUMBER SIGN character (#),
  10368. * followed by one or more ASCII digits, representing a base-ten integer"
  10369. *
  10370. * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references
  10371. *
  10372. * @type {RegExp}
  10373. */
  10374. const REGEXP_DECIMAL_CHARACTER_REFERENCE = /^#\d+$/;
  10375. /**
  10376. * Regular expression matching a hexadecimal character reference.
  10377. *
  10378. * "The ampersand must be followed by a U+0023 NUMBER SIGN character (#), which
  10379. * must be followed by either a U+0078 LATIN SMALL LETTER X character (x) or a
  10380. * U+0058 LATIN CAPITAL LETTER X character (X), which must then be followed by
  10381. * one or more ASCII hex digits, representing a hexadecimal integer"
  10382. *
  10383. * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references
  10384. *
  10385. * @type {RegExp}
  10386. */
  10387. const REGEXP_HEXADECIMAL_CHARACTER_REFERENCE = /^#x[\da-f]+$/i;
  10388. /**
  10389. * Returns true if the given string is a valid character reference segment, or
  10390. * false otherwise. The text should be stripped of `&` and `;` demarcations.
  10391. *
  10392. * @param {string} text Text to test.
  10393. *
  10394. * @return {boolean} Whether text is valid character reference.
  10395. */
  10396. function isValidCharacterReference(text) {
  10397. return REGEXP_NAMED_CHARACTER_REFERENCE.test(text) || REGEXP_DECIMAL_CHARACTER_REFERENCE.test(text) || REGEXP_HEXADECIMAL_CHARACTER_REFERENCE.test(text);
  10398. }
  10399. /**
  10400. * Subsitute EntityParser class for `simple-html-tokenizer` which uses the
  10401. * implementation of `decodeEntities` from `html-entities`, in order to avoid
  10402. * bundling a massive named character reference.
  10403. *
  10404. * @see https://github.com/tildeio/simple-html-tokenizer/tree/HEAD/src/entity-parser.ts
  10405. */
  10406. class DecodeEntityParser {
  10407. /**
  10408. * Returns a substitute string for an entity string sequence between `&`
  10409. * and `;`, or undefined if no substitution should occur.
  10410. *
  10411. * @param {string} entity Entity fragment discovered in HTML.
  10412. *
  10413. * @return {?string} Entity substitute value.
  10414. */
  10415. parse(entity) {
  10416. if (isValidCharacterReference(entity)) {
  10417. return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)('&' + entity + ';');
  10418. }
  10419. }
  10420. }
  10421. /**
  10422. * Given a specified string, returns an array of strings split by consecutive
  10423. * whitespace, ignoring leading or trailing whitespace.
  10424. *
  10425. * @param {string} text Original text.
  10426. *
  10427. * @return {string[]} Text pieces split on whitespace.
  10428. */
  10429. function getTextPiecesSplitOnWhitespace(text) {
  10430. return text.trim().split(REGEXP_WHITESPACE);
  10431. }
  10432. /**
  10433. * Given a specified string, returns a new trimmed string where all consecutive
  10434. * whitespace is collapsed to a single space.
  10435. *
  10436. * @param {string} text Original text.
  10437. *
  10438. * @return {string} Trimmed text with consecutive whitespace collapsed.
  10439. */
  10440. function getTextWithCollapsedWhitespace(text) {
  10441. // This is an overly simplified whitespace comparison. The specification is
  10442. // more prescriptive of whitespace behavior in inline and block contexts.
  10443. //
  10444. // See: https://medium.com/@patrickbrosset/when-does-white-space-matter-in-html-b90e8a7cdd33
  10445. return getTextPiecesSplitOnWhitespace(text).join(' ');
  10446. }
  10447. /**
  10448. * Returns attribute pairs of the given StartTag token, including only pairs
  10449. * where the value is non-empty or the attribute is a boolean attribute, an
  10450. * enumerated attribute, or a custom data- attribute.
  10451. *
  10452. * @see MEANINGFUL_ATTRIBUTES
  10453. *
  10454. * @param {Object} token StartTag token.
  10455. *
  10456. * @return {Array[]} Attribute pairs.
  10457. */
  10458. function getMeaningfulAttributePairs(token) {
  10459. return token.attributes.filter(pair => {
  10460. const [key, value] = pair;
  10461. return value || key.indexOf('data-') === 0 || (0,external_lodash_namespaceObject.includes)(MEANINGFUL_ATTRIBUTES, key);
  10462. });
  10463. }
  10464. /**
  10465. * Returns true if two text tokens (with `chars` property) are equivalent, or
  10466. * false otherwise.
  10467. *
  10468. * @param {Object} actual Actual token.
  10469. * @param {Object} expected Expected token.
  10470. * @param {Object} logger Validation logger object.
  10471. *
  10472. * @return {boolean} Whether two text tokens are equivalent.
  10473. */
  10474. function isEquivalentTextTokens(actual, expected) {
  10475. let logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger();
  10476. // This function is intentionally written as syntactically "ugly" as a hot
  10477. // path optimization. Text is progressively normalized in order from least-
  10478. // to-most operationally expensive, until the earliest point at which text
  10479. // can be confidently inferred as being equal.
  10480. let actualChars = actual.chars;
  10481. let expectedChars = expected.chars;
  10482. for (let i = 0; i < TEXT_NORMALIZATIONS.length; i++) {
  10483. const normalize = TEXT_NORMALIZATIONS[i];
  10484. actualChars = normalize(actualChars);
  10485. expectedChars = normalize(expectedChars);
  10486. if (actualChars === expectedChars) {
  10487. return true;
  10488. }
  10489. }
  10490. logger.warning('Expected text `%s`, saw `%s`.', expected.chars, actual.chars);
  10491. return false;
  10492. }
  10493. /**
  10494. * Given a CSS length value, returns a normalized CSS length value for strict equality
  10495. * comparison.
  10496. *
  10497. * @param {string} value CSS length value.
  10498. *
  10499. * @return {string} Normalized CSS length value.
  10500. */
  10501. function getNormalizedLength(value) {
  10502. if (0 === parseFloat(value)) {
  10503. return '0';
  10504. } // Normalize strings with floats to always include a leading zero.
  10505. if (value.indexOf('.') === 0) {
  10506. return '0' + value;
  10507. }
  10508. return value;
  10509. }
  10510. /**
  10511. * Given a style value, returns a normalized style value for strict equality
  10512. * comparison.
  10513. *
  10514. * @param {string} value Style value.
  10515. *
  10516. * @return {string} Normalized style value.
  10517. */
  10518. function getNormalizedStyleValue(value) {
  10519. const textPieces = getTextPiecesSplitOnWhitespace(value);
  10520. const normalizedPieces = textPieces.map(getNormalizedLength);
  10521. const result = normalizedPieces.join(' ');
  10522. return result // Normalize URL type to omit whitespace or quotes.
  10523. .replace(REGEXP_STYLE_URL_TYPE, 'url($1)');
  10524. }
  10525. /**
  10526. * Given a style attribute string, returns an object of style properties.
  10527. *
  10528. * @param {string} text Style attribute.
  10529. *
  10530. * @return {Object} Style properties.
  10531. */
  10532. function getStyleProperties(text) {
  10533. const pairs = text // Trim ending semicolon (avoid including in split)
  10534. .replace(/;?\s*$/, '') // Split on property assignment.
  10535. .split(';') // For each property assignment...
  10536. .map(style => {
  10537. // ...split further into key-value pairs.
  10538. const [key, ...valueParts] = style.split(':');
  10539. const value = valueParts.join(':');
  10540. return [key.trim(), getNormalizedStyleValue(value.trim())];
  10541. });
  10542. return Object.fromEntries(pairs);
  10543. }
  10544. /**
  10545. * Attribute-specific equality handlers
  10546. *
  10547. * @type {Object}
  10548. */
  10549. const isEqualAttributesOfName = {
  10550. class: (actual, expected) => {
  10551. // Class matches if members are the same, even if out of order or
  10552. // superfluous whitespace between.
  10553. const [actualPieces, expectedPieces] = [actual, expected].map(getTextPiecesSplitOnWhitespace);
  10554. const actualDiff = actualPieces.filter(c => !expectedPieces.includes(c));
  10555. const expectedDiff = expectedPieces.filter(c => !actualPieces.includes(c));
  10556. return actualDiff.length === 0 && expectedDiff.length === 0;
  10557. },
  10558. style: (actual, expected) => {
  10559. return (0,external_lodash_namespaceObject.isEqual)(...[actual, expected].map(getStyleProperties));
  10560. },
  10561. // For each boolean attribute, mere presence of attribute in both is enough
  10562. // to assume equivalence.
  10563. ...Object.fromEntries(BOOLEAN_ATTRIBUTES.map(attribute => [attribute, () => true]))
  10564. };
  10565. /**
  10566. * Given two sets of attribute tuples, returns true if the attribute sets are
  10567. * equivalent.
  10568. *
  10569. * @param {Array[]} actual Actual attributes tuples.
  10570. * @param {Array[]} expected Expected attributes tuples.
  10571. * @param {Object} logger Validation logger object.
  10572. *
  10573. * @return {boolean} Whether attributes are equivalent.
  10574. */
  10575. function isEqualTagAttributePairs(actual, expected) {
  10576. let logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger();
  10577. // Attributes is tokenized as tuples. Their lengths should match. This also
  10578. // avoids us needing to check both attributes sets, since if A has any keys
  10579. // which do not exist in B, we know the sets to be different.
  10580. if (actual.length !== expected.length) {
  10581. logger.warning('Expected attributes %o, instead saw %o.', expected, actual);
  10582. return false;
  10583. } // Attributes are not guaranteed to occur in the same order. For validating
  10584. // actual attributes, first convert the set of expected attribute values to
  10585. // an object, for lookup by key.
  10586. const expectedAttributes = {};
  10587. for (let i = 0; i < expected.length; i++) {
  10588. expectedAttributes[expected[i][0].toLowerCase()] = expected[i][1];
  10589. }
  10590. for (let i = 0; i < actual.length; i++) {
  10591. const [name, actualValue] = actual[i];
  10592. const nameLower = name.toLowerCase(); // As noted above, if missing member in B, assume different.
  10593. if (!expectedAttributes.hasOwnProperty(nameLower)) {
  10594. logger.warning('Encountered unexpected attribute `%s`.', name);
  10595. return false;
  10596. }
  10597. const expectedValue = expectedAttributes[nameLower];
  10598. const isEqualAttributes = isEqualAttributesOfName[nameLower];
  10599. if (isEqualAttributes) {
  10600. // Defer custom attribute equality handling.
  10601. if (!isEqualAttributes(actualValue, expectedValue)) {
  10602. logger.warning('Expected attribute `%s` of value `%s`, saw `%s`.', name, expectedValue, actualValue);
  10603. return false;
  10604. }
  10605. } else if (actualValue !== expectedValue) {
  10606. // Otherwise strict inequality should bail.
  10607. logger.warning('Expected attribute `%s` of value `%s`, saw `%s`.', name, expectedValue, actualValue);
  10608. return false;
  10609. }
  10610. }
  10611. return true;
  10612. }
  10613. /**
  10614. * Token-type-specific equality handlers
  10615. *
  10616. * @type {Object}
  10617. */
  10618. const isEqualTokensOfType = {
  10619. StartTag: function (actual, expected) {
  10620. let logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger();
  10621. if (actual.tagName !== expected.tagName && // Optimization: Use short-circuit evaluation to defer case-
  10622. // insensitive check on the assumption that the majority case will
  10623. // have exactly equal tag names.
  10624. actual.tagName.toLowerCase() !== expected.tagName.toLowerCase()) {
  10625. logger.warning('Expected tag name `%s`, instead saw `%s`.', expected.tagName, actual.tagName);
  10626. return false;
  10627. }
  10628. return isEqualTagAttributePairs(...[actual, expected].map(getMeaningfulAttributePairs), logger);
  10629. },
  10630. Chars: isEquivalentTextTokens,
  10631. Comment: isEquivalentTextTokens
  10632. };
  10633. /**
  10634. * Given an array of tokens, returns the first token which is not purely
  10635. * whitespace.
  10636. *
  10637. * Mutates the tokens array.
  10638. *
  10639. * @param {Object[]} tokens Set of tokens to search.
  10640. *
  10641. * @return {Object} Next non-whitespace token.
  10642. */
  10643. function getNextNonWhitespaceToken(tokens) {
  10644. let token;
  10645. while (token = tokens.shift()) {
  10646. if (token.type !== 'Chars') {
  10647. return token;
  10648. }
  10649. if (!REGEXP_ONLY_WHITESPACE.test(token.chars)) {
  10650. return token;
  10651. }
  10652. }
  10653. }
  10654. /**
  10655. * Tokenize an HTML string, gracefully handling any errors thrown during
  10656. * underlying tokenization.
  10657. *
  10658. * @param {string} html HTML string to tokenize.
  10659. * @param {Object} logger Validation logger object.
  10660. *
  10661. * @return {Object[]|null} Array of valid tokenized HTML elements, or null on error
  10662. */
  10663. function getHTMLTokens(html) {
  10664. let logger = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createLogger();
  10665. try {
  10666. return new Tokenizer(new DecodeEntityParser()).tokenize(html);
  10667. } catch (e) {
  10668. logger.warning('Malformed HTML detected: %s', html);
  10669. }
  10670. return null;
  10671. }
  10672. /**
  10673. * Returns true if the next HTML token closes the current token.
  10674. *
  10675. * @param {Object} currentToken Current token to compare with.
  10676. * @param {Object|undefined} nextToken Next token to compare against.
  10677. *
  10678. * @return {boolean} true if `nextToken` closes `currentToken`, false otherwise
  10679. */
  10680. function isClosedByToken(currentToken, nextToken) {
  10681. // Ensure this is a self closed token.
  10682. if (!currentToken.selfClosing) {
  10683. return false;
  10684. } // Check token names and determine if nextToken is the closing tag for currentToken.
  10685. if (nextToken && nextToken.tagName === currentToken.tagName && nextToken.type === 'EndTag') {
  10686. return true;
  10687. }
  10688. return false;
  10689. }
  10690. /**
  10691. * Returns true if the given HTML strings are effectively equivalent, or
  10692. * false otherwise. Invalid HTML is not considered equivalent, even if the
  10693. * strings directly match.
  10694. *
  10695. * @param {string} actual Actual HTML string.
  10696. * @param {string} expected Expected HTML string.
  10697. * @param {Object} logger Validation logger object.
  10698. *
  10699. * @return {boolean} Whether HTML strings are equivalent.
  10700. */
  10701. function isEquivalentHTML(actual, expected) {
  10702. let logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger();
  10703. // Short-circuit if markup is identical.
  10704. if (actual === expected) {
  10705. return true;
  10706. } // Tokenize input content and reserialized save content.
  10707. const [actualTokens, expectedTokens] = [actual, expected].map(html => getHTMLTokens(html, logger)); // If either is malformed then stop comparing - the strings are not equivalent.
  10708. if (!actualTokens || !expectedTokens) {
  10709. return false;
  10710. }
  10711. let actualToken, expectedToken;
  10712. while (actualToken = getNextNonWhitespaceToken(actualTokens)) {
  10713. expectedToken = getNextNonWhitespaceToken(expectedTokens); // Inequal if exhausted all expected tokens.
  10714. if (!expectedToken) {
  10715. logger.warning('Expected end of content, instead saw %o.', actualToken);
  10716. return false;
  10717. } // Inequal if next non-whitespace token of each set are not same type.
  10718. if (actualToken.type !== expectedToken.type) {
  10719. logger.warning('Expected token of type `%s` (%o), instead saw `%s` (%o).', expectedToken.type, expectedToken, actualToken.type, actualToken);
  10720. return false;
  10721. } // Defer custom token type equality handling, otherwise continue and
  10722. // assume as equal.
  10723. const isEqualTokens = isEqualTokensOfType[actualToken.type];
  10724. if (isEqualTokens && !isEqualTokens(actualToken, expectedToken, logger)) {
  10725. return false;
  10726. } // Peek at the next tokens (actual and expected) to see if they close
  10727. // a self-closing tag.
  10728. if (isClosedByToken(actualToken, expectedTokens[0])) {
  10729. // Consume the next expected token that closes the current actual
  10730. // self-closing token.
  10731. getNextNonWhitespaceToken(expectedTokens);
  10732. } else if (isClosedByToken(expectedToken, actualTokens[0])) {
  10733. // Consume the next actual token that closes the current expected
  10734. // self-closing token.
  10735. getNextNonWhitespaceToken(actualTokens);
  10736. }
  10737. }
  10738. if (expectedToken = getNextNonWhitespaceToken(expectedTokens)) {
  10739. // If any non-whitespace tokens remain in expected token set, this
  10740. // indicates inequality.
  10741. logger.warning('Expected %o, instead saw end of content.', expectedToken);
  10742. return false;
  10743. }
  10744. return true;
  10745. }
  10746. /**
  10747. * Returns an object with `isValid` property set to `true` if the parsed block
  10748. * is valid given the input content. A block is considered valid if, when serialized
  10749. * with assumed attributes, the content matches the original value. If block is
  10750. * invalid, this function returns all validations issues as well.
  10751. *
  10752. * @param {string|Object} blockTypeOrName Block type.
  10753. * @param {Object} attributes Parsed block attributes.
  10754. * @param {string} originalBlockContent Original block content.
  10755. * @param {Object} logger Validation logger object.
  10756. *
  10757. * @return {Object} Whether block is valid and contains validation messages.
  10758. */
  10759. /**
  10760. * Returns an object with `isValid` property set to `true` if the parsed block
  10761. * is valid given the input content. A block is considered valid if, when serialized
  10762. * with assumed attributes, the content matches the original value. If block is
  10763. * invalid, this function returns all validations issues as well.
  10764. *
  10765. * @param {WPBlock} block block object.
  10766. * @param {WPBlockType|string} [blockTypeOrName = block.name] Block type or name, inferred from block if not given.
  10767. *
  10768. * @return {[boolean,Array<LoggerItem>]} validation results.
  10769. */
  10770. function validateBlock(block) {
  10771. let blockTypeOrName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : block.name;
  10772. const isFallbackBlock = block.name === getFreeformContentHandlerName() || block.name === getUnregisteredTypeHandlerName(); // Shortcut to avoid costly validation.
  10773. if (isFallbackBlock) {
  10774. return [true, []];
  10775. }
  10776. const logger = createQueuedLogger();
  10777. const blockType = normalizeBlockType(blockTypeOrName);
  10778. let generatedBlockContent;
  10779. try {
  10780. generatedBlockContent = getSaveContent(blockType, block.attributes);
  10781. } catch (error) {
  10782. logger.error('Block validation failed because an error occurred while generating block content:\n\n%s', error.toString());
  10783. return [false, logger.getItems()];
  10784. }
  10785. const isValid = isEquivalentHTML(block.originalContent, generatedBlockContent, logger);
  10786. if (!isValid) {
  10787. 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, block.originalContent);
  10788. }
  10789. return [isValid, logger.getItems()];
  10790. }
  10791. /**
  10792. * Returns true if the parsed block is valid given the input content. A block
  10793. * is considered valid if, when serialized with assumed attributes, the content
  10794. * matches the original value.
  10795. *
  10796. * Logs to console in development environments when invalid.
  10797. *
  10798. * @deprecated Use validateBlock instead to avoid data loss.
  10799. *
  10800. * @param {string|Object} blockTypeOrName Block type.
  10801. * @param {Object} attributes Parsed block attributes.
  10802. * @param {string} originalBlockContent Original block content.
  10803. *
  10804. * @return {boolean} Whether block is valid.
  10805. */
  10806. function isValidBlockContent(blockTypeOrName, attributes, originalBlockContent) {
  10807. external_wp_deprecated_default()('isValidBlockContent introduces opportunity for data loss', {
  10808. since: '12.6',
  10809. plugin: 'Gutenberg',
  10810. alternative: 'validateBlock'
  10811. });
  10812. const blockType = normalizeBlockType(blockTypeOrName);
  10813. const block = {
  10814. name: blockType.name,
  10815. attributes,
  10816. innerBlocks: [],
  10817. originalContent: originalBlockContent
  10818. };
  10819. const [isValid] = validateBlock(block, blockType);
  10820. return isValid;
  10821. }
  10822. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/convert-legacy-block.js
  10823. /**
  10824. * Convert legacy blocks to their canonical form. This function is used
  10825. * both in the parser level for previous content and to convert such blocks
  10826. * used in Custom Post Types templates.
  10827. *
  10828. * @param {string} name The block's name
  10829. * @param {Object} attributes The block's attributes
  10830. *
  10831. * @return {[string, Object]} The block's name and attributes, changed accordingly if a match was found
  10832. */
  10833. function convertLegacyBlockNameAndAttributes(name, attributes) {
  10834. const newAttributes = { ...attributes
  10835. }; // Convert 'core/cover-image' block in existing content to 'core/cover'.
  10836. if ('core/cover-image' === name) {
  10837. name = 'core/cover';
  10838. } // Convert 'core/text' blocks in existing content to 'core/paragraph'.
  10839. if ('core/text' === name || 'core/cover-text' === name) {
  10840. name = 'core/paragraph';
  10841. } // Convert derivative blocks such as 'core/social-link-wordpress' to the
  10842. // canonical form 'core/social-link'.
  10843. if (name && name.indexOf('core/social-link-') === 0) {
  10844. // Capture `social-link-wordpress` into `{"service":"wordpress"}`
  10845. newAttributes.service = name.substring(17);
  10846. name = 'core/social-link';
  10847. } // Convert derivative blocks such as 'core-embed/instagram' to the
  10848. // canonical form 'core/embed'.
  10849. if (name && name.indexOf('core-embed/') === 0) {
  10850. // Capture `core-embed/instagram` into `{"providerNameSlug":"instagram"}`
  10851. const providerSlug = name.substring(11);
  10852. const deprecated = {
  10853. speaker: 'speaker-deck',
  10854. polldaddy: 'crowdsignal'
  10855. };
  10856. newAttributes.providerNameSlug = providerSlug in deprecated ? deprecated[providerSlug] : providerSlug; // This is needed as the `responsive` attribute was passed
  10857. // in a different way before the refactoring to block variations.
  10858. if (!['amazon-kindle', 'wordpress'].includes(providerSlug)) {
  10859. newAttributes.responsive = true;
  10860. }
  10861. name = 'core/embed';
  10862. } // Convert Post Comment blocks in existing content to Comment blocks.
  10863. // TODO: Remove these checks when WordPress 6.0 is released.
  10864. if (name === 'core/post-comment-author') {
  10865. name = 'core/comment-author-name';
  10866. }
  10867. if (name === 'core/post-comment-content') {
  10868. name = 'core/comment-content';
  10869. }
  10870. if (name === 'core/post-comment-date') {
  10871. name = 'core/comment-date';
  10872. }
  10873. if (name === 'core/comments-query-loop') {
  10874. name = 'core/comments';
  10875. const {
  10876. className = ''
  10877. } = newAttributes;
  10878. if (!className.includes('wp-block-comments-query-loop')) {
  10879. newAttributes.className = ['wp-block-comments-query-loop', className].join(' ');
  10880. } // Note that we also had to add a deprecation to the block in order
  10881. // for the ID change to work.
  10882. }
  10883. if (name === 'core/post-comments') {
  10884. name = 'core/comments';
  10885. newAttributes.legacy = true;
  10886. }
  10887. return [name, newAttributes];
  10888. }
  10889. ;// CONCATENATED MODULE: ./node_modules/hpq/es/get-path.js
  10890. /**
  10891. * Given object and string of dot-delimited path segments, returns value at
  10892. * path or undefined if path cannot be resolved.
  10893. *
  10894. * @param {Object} object Lookup object
  10895. * @param {string} path Path to resolve
  10896. * @return {?*} Resolved value
  10897. */
  10898. function getPath(object, path) {
  10899. var segments = path.split('.');
  10900. var segment;
  10901. while (segment = segments.shift()) {
  10902. if (!(segment in object)) {
  10903. return;
  10904. }
  10905. object = object[segment];
  10906. }
  10907. return object;
  10908. }
  10909. ;// CONCATENATED MODULE: ./node_modules/hpq/es/index.js
  10910. /**
  10911. * Internal dependencies
  10912. */
  10913. /**
  10914. * Function returning a DOM document created by `createHTMLDocument`. The same
  10915. * document is returned between invocations.
  10916. *
  10917. * @return {Document} DOM document.
  10918. */
  10919. var getDocument = function () {
  10920. var doc;
  10921. return function () {
  10922. if (!doc) {
  10923. doc = document.implementation.createHTMLDocument('');
  10924. }
  10925. return doc;
  10926. };
  10927. }();
  10928. /**
  10929. * Given a markup string or DOM element, creates an object aligning with the
  10930. * shape of the matchers object, or the value returned by the matcher.
  10931. *
  10932. * @param {(string|Element)} source Source content
  10933. * @param {(Object|Function)} matchers Matcher function or object of matchers
  10934. * @return {(Object|*)} Matched value(s), shaped by object
  10935. */
  10936. function parse(source, matchers) {
  10937. if (!matchers) {
  10938. return;
  10939. } // Coerce to element
  10940. if ('string' === typeof source) {
  10941. var doc = getDocument();
  10942. doc.body.innerHTML = source;
  10943. source = doc.body;
  10944. } // Return singular value
  10945. if ('function' === typeof matchers) {
  10946. return matchers(source);
  10947. } // Bail if we can't handle matchers
  10948. if (Object !== matchers.constructor) {
  10949. return;
  10950. } // Shape result by matcher object
  10951. return Object.keys(matchers).reduce(function (memo, key) {
  10952. memo[key] = parse(source, matchers[key]);
  10953. return memo;
  10954. }, {});
  10955. }
  10956. /**
  10957. * Generates a function which matches node of type selector, returning an
  10958. * attribute by property if the attribute exists. If no selector is passed,
  10959. * returns property of the query element.
  10960. *
  10961. * @param {?string} selector Optional selector
  10962. * @param {string} name Property name
  10963. * @return {*} Property value
  10964. */
  10965. function prop(selector, name) {
  10966. if (1 === arguments.length) {
  10967. name = selector;
  10968. selector = undefined;
  10969. }
  10970. return function (node) {
  10971. var match = node;
  10972. if (selector) {
  10973. match = node.querySelector(selector);
  10974. }
  10975. if (match) {
  10976. return getPath(match, name);
  10977. }
  10978. };
  10979. }
  10980. /**
  10981. * Generates a function which matches node of type selector, returning an
  10982. * attribute by name if the attribute exists. If no selector is passed,
  10983. * returns attribute of the query element.
  10984. *
  10985. * @param {?string} selector Optional selector
  10986. * @param {string} name Attribute name
  10987. * @return {?string} Attribute value
  10988. */
  10989. function attr(selector, name) {
  10990. if (1 === arguments.length) {
  10991. name = selector;
  10992. selector = undefined;
  10993. }
  10994. return function (node) {
  10995. var attributes = prop(selector, 'attributes')(node);
  10996. if (attributes && attributes.hasOwnProperty(name)) {
  10997. return attributes[name].value;
  10998. }
  10999. };
  11000. }
  11001. /**
  11002. * Convenience for `prop( selector, 'innerHTML' )`.
  11003. *
  11004. * @see prop()
  11005. *
  11006. * @param {?string} selector Optional selector
  11007. * @return {string} Inner HTML
  11008. */
  11009. function html(selector) {
  11010. return prop(selector, 'innerHTML');
  11011. }
  11012. /**
  11013. * Convenience for `prop( selector, 'textContent' )`.
  11014. *
  11015. * @see prop()
  11016. *
  11017. * @param {?string} selector Optional selector
  11018. * @return {string} Text content
  11019. */
  11020. function es_text(selector) {
  11021. return prop(selector, 'textContent');
  11022. }
  11023. /**
  11024. * Creates a new matching context by first finding elements matching selector
  11025. * using querySelectorAll before then running another `parse` on `matchers`
  11026. * scoped to the matched elements.
  11027. *
  11028. * @see parse()
  11029. *
  11030. * @param {string} selector Selector to match
  11031. * @param {(Object|Function)} matchers Matcher function or object of matchers
  11032. * @return {Array.<*,Object>} Array of matched value(s)
  11033. */
  11034. function query(selector, matchers) {
  11035. return function (node) {
  11036. var matches = node.querySelectorAll(selector);
  11037. return [].map.call(matches, function (match) {
  11038. return parse(match, matchers);
  11039. });
  11040. };
  11041. }
  11042. // EXTERNAL MODULE: ./node_modules/memize/index.js
  11043. var memize = __webpack_require__(9756);
  11044. var memize_default = /*#__PURE__*/__webpack_require__.n(memize);
  11045. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/matchers.js
  11046. /**
  11047. * External dependencies
  11048. */
  11049. /**
  11050. * Internal dependencies
  11051. */
  11052. function matchers_html(selector, multilineTag) {
  11053. return domNode => {
  11054. let match = domNode;
  11055. if (selector) {
  11056. match = domNode.querySelector(selector);
  11057. }
  11058. if (!match) {
  11059. return '';
  11060. }
  11061. if (multilineTag) {
  11062. let value = '';
  11063. const length = match.children.length;
  11064. for (let index = 0; index < length; index++) {
  11065. const child = match.children[index];
  11066. if (child.nodeName.toLowerCase() !== multilineTag) {
  11067. continue;
  11068. }
  11069. value += child.outerHTML;
  11070. }
  11071. return value;
  11072. }
  11073. return match.innerHTML;
  11074. };
  11075. }
  11076. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/node.js
  11077. /**
  11078. * WordPress dependencies
  11079. */
  11080. /**
  11081. * Internal dependencies
  11082. */
  11083. /**
  11084. * A representation of a single node within a block's rich text value. If
  11085. * representing a text node, the value is simply a string of the node value.
  11086. * As representing an element node, it is an object of:
  11087. *
  11088. * 1. `type` (string): Tag name.
  11089. * 2. `props` (object): Attributes and children array of WPBlockNode.
  11090. *
  11091. * @typedef {string|Object} WPBlockNode
  11092. */
  11093. /**
  11094. * Given a single node and a node type (e.g. `'br'`), returns true if the node
  11095. * corresponds to that type, false otherwise.
  11096. *
  11097. * @param {WPBlockNode} node Block node to test
  11098. * @param {string} type Node to type to test against.
  11099. *
  11100. * @return {boolean} Whether node is of intended type.
  11101. */
  11102. function isNodeOfType(node, type) {
  11103. external_wp_deprecated_default()('wp.blocks.node.isNodeOfType', {
  11104. since: '6.1',
  11105. version: '6.3',
  11106. link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
  11107. });
  11108. return node && node.type === type;
  11109. }
  11110. /**
  11111. * Given an object implementing the NamedNodeMap interface, returns a plain
  11112. * object equivalent value of name, value key-value pairs.
  11113. *
  11114. * @see https://dom.spec.whatwg.org/#interface-namednodemap
  11115. *
  11116. * @param {NamedNodeMap} nodeMap NamedNodeMap to convert to object.
  11117. *
  11118. * @return {Object} Object equivalent value of NamedNodeMap.
  11119. */
  11120. function getNamedNodeMapAsObject(nodeMap) {
  11121. const result = {};
  11122. for (let i = 0; i < nodeMap.length; i++) {
  11123. const {
  11124. name,
  11125. value
  11126. } = nodeMap[i];
  11127. result[name] = value;
  11128. }
  11129. return result;
  11130. }
  11131. /**
  11132. * Given a DOM Element or Text node, returns an equivalent block node. Throws
  11133. * if passed any node type other than element or text.
  11134. *
  11135. * @throws {TypeError} If non-element/text node is passed.
  11136. *
  11137. * @param {Node} domNode DOM node to convert.
  11138. *
  11139. * @return {WPBlockNode} Block node equivalent to DOM node.
  11140. */
  11141. function fromDOM(domNode) {
  11142. external_wp_deprecated_default()('wp.blocks.node.fromDOM', {
  11143. since: '6.1',
  11144. version: '6.3',
  11145. alternative: 'wp.richText.create',
  11146. link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
  11147. });
  11148. if (domNode.nodeType === domNode.TEXT_NODE) {
  11149. return domNode.nodeValue;
  11150. }
  11151. if (domNode.nodeType !== domNode.ELEMENT_NODE) {
  11152. throw new TypeError('A block node can only be created from a node of type text or ' + 'element.');
  11153. }
  11154. return {
  11155. type: domNode.nodeName.toLowerCase(),
  11156. props: { ...getNamedNodeMapAsObject(domNode.attributes),
  11157. children: children_fromDOM(domNode.childNodes)
  11158. }
  11159. };
  11160. }
  11161. /**
  11162. * Given a block node, returns its HTML string representation.
  11163. *
  11164. * @param {WPBlockNode} node Block node to convert to string.
  11165. *
  11166. * @return {string} String HTML representation of block node.
  11167. */
  11168. function toHTML(node) {
  11169. external_wp_deprecated_default()('wp.blocks.node.toHTML', {
  11170. since: '6.1',
  11171. version: '6.3',
  11172. alternative: 'wp.richText.toHTMLString',
  11173. link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
  11174. });
  11175. return children_toHTML([node]);
  11176. }
  11177. /**
  11178. * Given a selector, returns an hpq matcher generating a WPBlockNode value
  11179. * matching the selector result.
  11180. *
  11181. * @param {string} selector DOM selector.
  11182. *
  11183. * @return {Function} hpq matcher.
  11184. */
  11185. function node_matcher(selector) {
  11186. external_wp_deprecated_default()('wp.blocks.node.matcher', {
  11187. since: '6.1',
  11188. version: '6.3',
  11189. alternative: 'html source',
  11190. link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
  11191. });
  11192. return domNode => {
  11193. let match = domNode;
  11194. if (selector) {
  11195. match = domNode.querySelector(selector);
  11196. }
  11197. try {
  11198. return fromDOM(match);
  11199. } catch (error) {
  11200. return null;
  11201. }
  11202. };
  11203. }
  11204. /**
  11205. * Object of utility functions used in managing block attribute values of
  11206. * source `node`.
  11207. *
  11208. * @see https://github.com/WordPress/gutenberg/pull/10439
  11209. *
  11210. * @deprecated since 4.0. The `node` source should not be used, and can be
  11211. * replaced by the `html` source.
  11212. *
  11213. * @private
  11214. */
  11215. /* harmony default export */ var node = ({
  11216. isNodeOfType,
  11217. fromDOM,
  11218. toHTML,
  11219. matcher: node_matcher
  11220. });
  11221. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/children.js
  11222. /**
  11223. * External dependencies
  11224. */
  11225. /**
  11226. * WordPress dependencies
  11227. */
  11228. /**
  11229. * Internal dependencies
  11230. */
  11231. /**
  11232. * A representation of a block's rich text value.
  11233. *
  11234. * @typedef {WPBlockNode[]} WPBlockChildren
  11235. */
  11236. /**
  11237. * Given block children, returns a serialize-capable WordPress element.
  11238. *
  11239. * @param {WPBlockChildren} children Block children object to convert.
  11240. *
  11241. * @return {WPElement} A serialize-capable element.
  11242. */
  11243. function getSerializeCapableElement(children) {
  11244. // The fact that block children are compatible with the element serializer is
  11245. // merely an implementation detail that currently serves to be true, but
  11246. // should not be mistaken as being a guarantee on the external API. The
  11247. // public API only offers guarantees to work with strings (toHTML) and DOM
  11248. // elements (fromDOM), and should provide utilities to manipulate the value
  11249. // rather than expect consumers to inspect or construct its shape (concat).
  11250. return children;
  11251. }
  11252. /**
  11253. * Given block children, returns an array of block nodes.
  11254. *
  11255. * @param {WPBlockChildren} children Block children object to convert.
  11256. *
  11257. * @return {Array<WPBlockNode>} An array of individual block nodes.
  11258. */
  11259. function getChildrenArray(children) {
  11260. external_wp_deprecated_default()('wp.blocks.children.getChildrenArray', {
  11261. since: '6.1',
  11262. version: '6.3',
  11263. link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
  11264. }); // The fact that block children are compatible with the element serializer
  11265. // is merely an implementation detail that currently serves to be true, but
  11266. // should not be mistaken as being a guarantee on the external API.
  11267. return children;
  11268. }
  11269. /**
  11270. * Given two or more block nodes, returns a new block node representing a
  11271. * concatenation of its values.
  11272. *
  11273. * @param {...WPBlockChildren} blockNodes Block nodes to concatenate.
  11274. *
  11275. * @return {WPBlockChildren} Concatenated block node.
  11276. */
  11277. function concat() {
  11278. external_wp_deprecated_default()('wp.blocks.children.concat', {
  11279. since: '6.1',
  11280. version: '6.3',
  11281. alternative: 'wp.richText.concat',
  11282. link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
  11283. });
  11284. const result = [];
  11285. for (let i = 0; i < arguments.length; i++) {
  11286. const blockNode = (0,external_lodash_namespaceObject.castArray)(i < 0 || arguments.length <= i ? undefined : arguments[i]);
  11287. for (let j = 0; j < blockNode.length; j++) {
  11288. const child = blockNode[j];
  11289. const canConcatToPreviousString = typeof child === 'string' && typeof result[result.length - 1] === 'string';
  11290. if (canConcatToPreviousString) {
  11291. result[result.length - 1] += child;
  11292. } else {
  11293. result.push(child);
  11294. }
  11295. }
  11296. }
  11297. return result;
  11298. }
  11299. /**
  11300. * Given an iterable set of DOM nodes, returns equivalent block children.
  11301. * Ignores any non-element/text nodes included in set.
  11302. *
  11303. * @param {Iterable.<Node>} domNodes Iterable set of DOM nodes to convert.
  11304. *
  11305. * @return {WPBlockChildren} Block children equivalent to DOM nodes.
  11306. */
  11307. function children_fromDOM(domNodes) {
  11308. external_wp_deprecated_default()('wp.blocks.children.fromDOM', {
  11309. since: '6.1',
  11310. version: '6.3',
  11311. alternative: 'wp.richText.create',
  11312. link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
  11313. });
  11314. const result = [];
  11315. for (let i = 0; i < domNodes.length; i++) {
  11316. try {
  11317. result.push(fromDOM(domNodes[i]));
  11318. } catch (error) {// Simply ignore if DOM node could not be converted.
  11319. }
  11320. }
  11321. return result;
  11322. }
  11323. /**
  11324. * Given a block node, returns its HTML string representation.
  11325. *
  11326. * @param {WPBlockChildren} children Block node(s) to convert to string.
  11327. *
  11328. * @return {string} String HTML representation of block node.
  11329. */
  11330. function children_toHTML(children) {
  11331. external_wp_deprecated_default()('wp.blocks.children.toHTML', {
  11332. since: '6.1',
  11333. version: '6.3',
  11334. alternative: 'wp.richText.toHTMLString',
  11335. link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
  11336. });
  11337. const element = getSerializeCapableElement(children);
  11338. return (0,external_wp_element_namespaceObject.renderToString)(element);
  11339. }
  11340. /**
  11341. * Given a selector, returns an hpq matcher generating a WPBlockChildren value
  11342. * matching the selector result.
  11343. *
  11344. * @param {string} selector DOM selector.
  11345. *
  11346. * @return {Function} hpq matcher.
  11347. */
  11348. function children_matcher(selector) {
  11349. external_wp_deprecated_default()('wp.blocks.children.matcher', {
  11350. since: '6.1',
  11351. version: '6.3',
  11352. alternative: 'html source',
  11353. link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
  11354. });
  11355. return domNode => {
  11356. let match = domNode;
  11357. if (selector) {
  11358. match = domNode.querySelector(selector);
  11359. }
  11360. if (match) {
  11361. return children_fromDOM(match.childNodes);
  11362. }
  11363. return [];
  11364. };
  11365. }
  11366. /**
  11367. * Object of utility functions used in managing block attribute values of
  11368. * source `children`.
  11369. *
  11370. * @see https://github.com/WordPress/gutenberg/pull/10439
  11371. *
  11372. * @deprecated since 4.0. The `children` source should not be used, and can be
  11373. * replaced by the `html` source.
  11374. *
  11375. * @private
  11376. */
  11377. /* harmony default export */ var children = ({
  11378. concat,
  11379. getChildrenArray,
  11380. fromDOM: children_fromDOM,
  11381. toHTML: children_toHTML,
  11382. matcher: children_matcher
  11383. });
  11384. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/get-block-attributes.js
  11385. /**
  11386. * External dependencies
  11387. */
  11388. /**
  11389. * WordPress dependencies
  11390. */
  11391. /**
  11392. * Internal dependencies
  11393. */
  11394. /**
  11395. * Higher-order hpq matcher which enhances an attribute matcher to return true
  11396. * or false depending on whether the original matcher returns undefined. This
  11397. * is useful for boolean attributes (e.g. disabled) whose attribute values may
  11398. * be technically falsey (empty string), though their mere presence should be
  11399. * enough to infer as true.
  11400. *
  11401. * @param {Function} matcher Original hpq matcher.
  11402. *
  11403. * @return {Function} Enhanced hpq matcher.
  11404. */
  11405. const toBooleanAttributeMatcher = matcher => (0,external_lodash_namespaceObject.flow)([matcher, // Expected values from `attr( 'disabled' )`:
  11406. //
  11407. // <input>
  11408. // - Value: `undefined`
  11409. // - Transformed: `false`
  11410. //
  11411. // <input disabled>
  11412. // - Value: `''`
  11413. // - Transformed: `true`
  11414. //
  11415. // <input disabled="disabled">
  11416. // - Value: `'disabled'`
  11417. // - Transformed: `true`
  11418. value => value !== undefined]);
  11419. /**
  11420. * Returns true if value is of the given JSON schema type, or false otherwise.
  11421. *
  11422. * @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25
  11423. *
  11424. * @param {*} value Value to test.
  11425. * @param {string} type Type to test.
  11426. *
  11427. * @return {boolean} Whether value is of type.
  11428. */
  11429. function isOfType(value, type) {
  11430. switch (type) {
  11431. case 'string':
  11432. return typeof value === 'string';
  11433. case 'boolean':
  11434. return typeof value === 'boolean';
  11435. case 'object':
  11436. return !!value && value.constructor === Object;
  11437. case 'null':
  11438. return value === null;
  11439. case 'array':
  11440. return Array.isArray(value);
  11441. case 'integer':
  11442. case 'number':
  11443. return typeof value === 'number';
  11444. }
  11445. return true;
  11446. }
  11447. /**
  11448. * Returns true if value is of an array of given JSON schema types, or false
  11449. * otherwise.
  11450. *
  11451. * @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25
  11452. *
  11453. * @param {*} value Value to test.
  11454. * @param {string[]} types Types to test.
  11455. *
  11456. * @return {boolean} Whether value is of types.
  11457. */
  11458. function isOfTypes(value, types) {
  11459. return types.some(type => isOfType(value, type));
  11460. }
  11461. /**
  11462. * Given an attribute key, an attribute's schema, a block's raw content and the
  11463. * commentAttributes returns the attribute value depending on its source
  11464. * definition of the given attribute key.
  11465. *
  11466. * @param {string} attributeKey Attribute key.
  11467. * @param {Object} attributeSchema Attribute's schema.
  11468. * @param {string|Node} innerHTML Block's raw content.
  11469. * @param {Object} commentAttributes Block's comment attributes.
  11470. *
  11471. * @return {*} Attribute value.
  11472. */
  11473. function getBlockAttribute(attributeKey, attributeSchema, innerHTML, commentAttributes) {
  11474. let value;
  11475. switch (attributeSchema.source) {
  11476. // An undefined source means that it's an attribute serialized to the
  11477. // block's "comment".
  11478. case undefined:
  11479. value = commentAttributes ? commentAttributes[attributeKey] : undefined;
  11480. break;
  11481. case 'attribute':
  11482. case 'property':
  11483. case 'html':
  11484. case 'text':
  11485. case 'children':
  11486. case 'node':
  11487. case 'query':
  11488. case 'tag':
  11489. value = parseWithAttributeSchema(innerHTML, attributeSchema);
  11490. break;
  11491. }
  11492. if (!isValidByType(value, attributeSchema.type) || !isValidByEnum(value, attributeSchema.enum)) {
  11493. // Reject the value if it is not valid. Reverting to the undefined
  11494. // value ensures the default is respected, if applicable.
  11495. value = undefined;
  11496. }
  11497. if (value === undefined) {
  11498. value = attributeSchema.default;
  11499. }
  11500. return value;
  11501. }
  11502. /**
  11503. * Returns true if value is valid per the given block attribute schema type
  11504. * definition, or false otherwise.
  11505. *
  11506. * @see https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.1
  11507. *
  11508. * @param {*} value Value to test.
  11509. * @param {?(Array<string>|string)} type Block attribute schema type.
  11510. *
  11511. * @return {boolean} Whether value is valid.
  11512. */
  11513. function isValidByType(value, type) {
  11514. return type === undefined || isOfTypes(value, (0,external_lodash_namespaceObject.castArray)(type));
  11515. }
  11516. /**
  11517. * Returns true if value is valid per the given block attribute schema enum
  11518. * definition, or false otherwise.
  11519. *
  11520. * @see https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.2
  11521. *
  11522. * @param {*} value Value to test.
  11523. * @param {?Array} enumSet Block attribute schema enum.
  11524. *
  11525. * @return {boolean} Whether value is valid.
  11526. */
  11527. function isValidByEnum(value, enumSet) {
  11528. return !Array.isArray(enumSet) || enumSet.includes(value);
  11529. }
  11530. /**
  11531. * Returns an hpq matcher given a source object.
  11532. *
  11533. * @param {Object} sourceConfig Attribute Source object.
  11534. *
  11535. * @return {Function} A hpq Matcher.
  11536. */
  11537. const matcherFromSource = memize_default()(sourceConfig => {
  11538. switch (sourceConfig.source) {
  11539. case 'attribute':
  11540. let matcher = attr(sourceConfig.selector, sourceConfig.attribute);
  11541. if (sourceConfig.type === 'boolean') {
  11542. matcher = toBooleanAttributeMatcher(matcher);
  11543. }
  11544. return matcher;
  11545. case 'html':
  11546. return matchers_html(sourceConfig.selector, sourceConfig.multiline);
  11547. case 'text':
  11548. return es_text(sourceConfig.selector);
  11549. case 'children':
  11550. return children_matcher(sourceConfig.selector);
  11551. case 'node':
  11552. return node_matcher(sourceConfig.selector);
  11553. case 'query':
  11554. const subMatchers = (0,external_lodash_namespaceObject.mapValues)(sourceConfig.query, matcherFromSource);
  11555. return query(sourceConfig.selector, subMatchers);
  11556. case 'tag':
  11557. return (0,external_lodash_namespaceObject.flow)([prop(sourceConfig.selector, 'nodeName'), nodeName => nodeName ? nodeName.toLowerCase() : undefined]);
  11558. default:
  11559. // eslint-disable-next-line no-console
  11560. console.error(`Unknown source type "${sourceConfig.source}"`);
  11561. }
  11562. });
  11563. /**
  11564. * Parse a HTML string into DOM tree.
  11565. *
  11566. * @param {string|Node} innerHTML HTML string or already parsed DOM node.
  11567. *
  11568. * @return {Node} Parsed DOM node.
  11569. */
  11570. function parseHtml(innerHTML) {
  11571. return parse(innerHTML, h => h);
  11572. }
  11573. /**
  11574. * Given a block's raw content and an attribute's schema returns the attribute's
  11575. * value depending on its source.
  11576. *
  11577. * @param {string|Node} innerHTML Block's raw content.
  11578. * @param {Object} attributeSchema Attribute's schema.
  11579. *
  11580. * @return {*} Attribute value.
  11581. */
  11582. function parseWithAttributeSchema(innerHTML, attributeSchema) {
  11583. return matcherFromSource(attributeSchema)(parseHtml(innerHTML));
  11584. }
  11585. /**
  11586. * Returns the block attributes of a registered block node given its type.
  11587. *
  11588. * @param {string|Object} blockTypeOrName Block type or name.
  11589. * @param {string|Node} innerHTML Raw block content.
  11590. * @param {?Object} attributes Known block attributes (from delimiters).
  11591. *
  11592. * @return {Object} All block attributes.
  11593. */
  11594. function getBlockAttributes(blockTypeOrName, innerHTML) {
  11595. let attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  11596. const doc = parseHtml(innerHTML);
  11597. const blockType = normalizeBlockType(blockTypeOrName);
  11598. const blockAttributes = (0,external_lodash_namespaceObject.mapValues)(blockType.attributes, (schema, key) => getBlockAttribute(key, schema, doc, attributes));
  11599. return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getBlockAttributes', blockAttributes, blockType, innerHTML, attributes);
  11600. }
  11601. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/fix-custom-classname.js
  11602. /**
  11603. * Internal dependencies
  11604. */
  11605. const CLASS_ATTR_SCHEMA = {
  11606. type: 'string',
  11607. source: 'attribute',
  11608. selector: '[data-custom-class-name] > *',
  11609. attribute: 'class'
  11610. };
  11611. /**
  11612. * Given an HTML string, returns an array of class names assigned to the root
  11613. * element in the markup.
  11614. *
  11615. * @param {string} innerHTML Markup string from which to extract classes.
  11616. *
  11617. * @return {string[]} Array of class names assigned to the root element.
  11618. */
  11619. function getHTMLRootElementClasses(innerHTML) {
  11620. const parsed = parseWithAttributeSchema(`<div data-custom-class-name>${innerHTML}</div>`, CLASS_ATTR_SCHEMA);
  11621. return parsed ? parsed.trim().split(/\s+/) : [];
  11622. }
  11623. /**
  11624. * Given a parsed set of block attributes, if the block supports custom class
  11625. * names and an unknown class (per the block's serialization behavior) is
  11626. * found, the unknown classes are treated as custom classes. This prevents the
  11627. * block from being considered as invalid.
  11628. *
  11629. * @param {Object} blockAttributes Original block attributes.
  11630. * @param {Object} blockType Block type settings.
  11631. * @param {string} innerHTML Original block markup.
  11632. *
  11633. * @return {Object} Filtered block attributes.
  11634. */
  11635. function fixCustomClassname(blockAttributes, blockType, innerHTML) {
  11636. if (hasBlockSupport(blockType, 'customClassName', true)) {
  11637. // To determine difference, serialize block given the known set of
  11638. // attributes, with the exception of `className`. This will determine
  11639. // the default set of classes. From there, any difference in innerHTML
  11640. // can be considered as custom classes.
  11641. const {
  11642. className: omittedClassName,
  11643. ...attributesSansClassName
  11644. } = blockAttributes;
  11645. const serialized = getSaveContent(blockType, attributesSansClassName);
  11646. const defaultClasses = getHTMLRootElementClasses(serialized);
  11647. const actualClasses = getHTMLRootElementClasses(innerHTML);
  11648. const customClasses = actualClasses.filter(className => !defaultClasses.includes(className));
  11649. if (customClasses.length) {
  11650. blockAttributes.className = customClasses.join(' ');
  11651. } else if (serialized) {
  11652. delete blockAttributes.className;
  11653. }
  11654. }
  11655. return blockAttributes;
  11656. }
  11657. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/apply-built-in-validation-fixes.js
  11658. /**
  11659. * Internal dependencies
  11660. */
  11661. /**
  11662. * Attempts to fix block invalidation by applying build-in validation fixes
  11663. * like moving all extra classNames to the className attribute.
  11664. *
  11665. * @param {WPBlock} block block object.
  11666. * @param {import('../registration').WPBlockType} blockType Block type. This is normalize not necessary and
  11667. * can be inferred from the block name,
  11668. * but it's here for performance reasons.
  11669. *
  11670. * @return {WPBlock} Fixed block object
  11671. */
  11672. function applyBuiltInValidationFixes(block, blockType) {
  11673. const updatedBlockAttributes = fixCustomClassname(block.attributes, blockType, block.originalContent);
  11674. return { ...block,
  11675. attributes: updatedBlockAttributes
  11676. };
  11677. }
  11678. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/apply-block-deprecated-versions.js
  11679. /**
  11680. * External dependencies
  11681. */
  11682. /**
  11683. * Internal dependencies
  11684. */
  11685. /**
  11686. * Function that takes no arguments and always returns false.
  11687. *
  11688. * @return {boolean} Always returns false.
  11689. */
  11690. function stubFalse() {
  11691. return false;
  11692. }
  11693. /**
  11694. * Given a block object, returns a new copy of the block with any applicable
  11695. * deprecated migrations applied, or the original block if it was both valid
  11696. * and no eligible migrations exist.
  11697. *
  11698. * @param {import(".").WPBlock} block Parsed and invalid block object.
  11699. * @param {import(".").WPRawBlock} rawBlock Raw block object.
  11700. * @param {import('../registration').WPBlockType} blockType Block type. This is normalize not necessary and
  11701. * can be inferred from the block name,
  11702. * but it's here for performance reasons.
  11703. *
  11704. * @return {import(".").WPBlock} Migrated block object.
  11705. */
  11706. function applyBlockDeprecatedVersions(block, rawBlock, blockType) {
  11707. const parsedAttributes = rawBlock.attrs;
  11708. const {
  11709. deprecated: deprecatedDefinitions
  11710. } = blockType; // Bail early if there are no registered deprecations to be handled.
  11711. if (!deprecatedDefinitions || !deprecatedDefinitions.length) {
  11712. return block;
  11713. } // By design, blocks lack any sort of version tracking. Instead, to process
  11714. // outdated content the system operates a queue out of all the defined
  11715. // attribute shapes and tries each definition until the input produces a
  11716. // valid result. This mechanism seeks to avoid polluting the user-space with
  11717. // machine-specific code. An invalid block is thus a block that could not be
  11718. // matched successfully with any of the registered deprecation definitions.
  11719. for (let i = 0; i < deprecatedDefinitions.length; i++) {
  11720. // A block can opt into a migration even if the block is valid by
  11721. // defining `isEligible` on its deprecation. If the block is both valid
  11722. // and does not opt to migrate, skip.
  11723. const {
  11724. isEligible = stubFalse
  11725. } = deprecatedDefinitions[i];
  11726. if (block.isValid && !isEligible(parsedAttributes, block.innerBlocks)) {
  11727. continue;
  11728. } // Block type properties which could impact either serialization or
  11729. // parsing are not considered in the deprecated block type by default,
  11730. // and must be explicitly provided.
  11731. const deprecatedBlockType = Object.assign(omit(blockType, DEPRECATED_ENTRY_KEYS), deprecatedDefinitions[i]);
  11732. let migratedBlock = { ...block,
  11733. attributes: getBlockAttributes(deprecatedBlockType, block.originalContent, parsedAttributes)
  11734. }; // Ignore the deprecation if it produces a block which is not valid.
  11735. let [isValid] = validateBlock(migratedBlock, deprecatedBlockType); // If the migrated block is not valid initially, try the built-in fixes.
  11736. if (!isValid) {
  11737. migratedBlock = applyBuiltInValidationFixes(migratedBlock, deprecatedBlockType);
  11738. [isValid] = validateBlock(migratedBlock, deprecatedBlockType);
  11739. } // An invalid block does not imply incorrect HTML but the fact block
  11740. // source information could be lost on re-serialization.
  11741. if (!isValid) {
  11742. continue;
  11743. }
  11744. let migratedInnerBlocks = migratedBlock.innerBlocks;
  11745. let migratedAttributes = migratedBlock.attributes; // A block may provide custom behavior to assign new attributes and/or
  11746. // inner blocks.
  11747. const {
  11748. migrate
  11749. } = deprecatedBlockType;
  11750. if (migrate) {
  11751. [migratedAttributes = parsedAttributes, migratedInnerBlocks = block.innerBlocks] = (0,external_lodash_namespaceObject.castArray)(migrate(migratedAttributes, block.innerBlocks));
  11752. }
  11753. block = { ...block,
  11754. attributes: migratedAttributes,
  11755. innerBlocks: migratedInnerBlocks,
  11756. isValid: true,
  11757. validationIssues: []
  11758. };
  11759. }
  11760. return block;
  11761. }
  11762. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/index.js
  11763. /**
  11764. * WordPress dependencies
  11765. */
  11766. /**
  11767. * Internal dependencies
  11768. */
  11769. /**
  11770. * The raw structure of a block includes its attributes, inner
  11771. * blocks, and inner HTML. It is important to distinguish inner blocks from
  11772. * the HTML content of the block as only the latter is relevant for block
  11773. * validation and edit operations.
  11774. *
  11775. * @typedef WPRawBlock
  11776. *
  11777. * @property {string=} blockName Block name
  11778. * @property {Object=} attrs Block raw or comment attributes.
  11779. * @property {string} innerHTML HTML content of the block.
  11780. * @property {(string|null)[]} innerContent Content without inner blocks.
  11781. * @property {WPRawBlock[]} innerBlocks Inner Blocks.
  11782. */
  11783. /**
  11784. * Fully parsed block object.
  11785. *
  11786. * @typedef WPBlock
  11787. *
  11788. * @property {string} name Block name
  11789. * @property {Object} attributes Block raw or comment attributes.
  11790. * @property {WPBlock[]} innerBlocks Inner Blocks.
  11791. * @property {string} originalContent Original content of the block before validation fixes.
  11792. * @property {boolean} isValid Whether the block is valid.
  11793. * @property {Object[]} validationIssues Validation issues.
  11794. * @property {WPRawBlock} [__unstableBlockSource] Un-processed original copy of block if created through parser.
  11795. */
  11796. /**
  11797. * @typedef {Object} ParseOptions
  11798. * @property {boolean?} __unstableSkipMigrationLogs If a block is migrated from a deprecated version, skip logging the migration details.
  11799. * @property {boolean?} __unstableSkipAutop Whether to skip autop when processing freeform content.
  11800. */
  11801. /**
  11802. * Convert legacy blocks to their canonical form. This function is used
  11803. * both in the parser level for previous content and to convert such blocks
  11804. * used in Custom Post Types templates.
  11805. *
  11806. * @param {WPRawBlock} rawBlock
  11807. *
  11808. * @return {WPRawBlock} The block's name and attributes, changed accordingly if a match was found
  11809. */
  11810. function convertLegacyBlocks(rawBlock) {
  11811. const [correctName, correctedAttributes] = convertLegacyBlockNameAndAttributes(rawBlock.blockName, rawBlock.attrs);
  11812. return { ...rawBlock,
  11813. blockName: correctName,
  11814. attrs: correctedAttributes
  11815. };
  11816. }
  11817. /**
  11818. * Normalize the raw block by applying the fallback block name if none given,
  11819. * sanitize the parsed HTML...
  11820. *
  11821. * @param {WPRawBlock} rawBlock The raw block object.
  11822. * @param {ParseOptions?} options Extra options for handling block parsing.
  11823. *
  11824. * @return {WPRawBlock} The normalized block object.
  11825. */
  11826. function normalizeRawBlock(rawBlock, options) {
  11827. const fallbackBlockName = getFreeformContentHandlerName(); // If the grammar parsing don't produce any block name, use the freeform block.
  11828. const rawBlockName = rawBlock.blockName || getFreeformContentHandlerName();
  11829. const rawAttributes = rawBlock.attrs || {};
  11830. const rawInnerBlocks = rawBlock.innerBlocks || [];
  11831. let rawInnerHTML = rawBlock.innerHTML.trim(); // Fallback content may be upgraded from classic content expecting implicit
  11832. // automatic paragraphs, so preserve them. Assumes wpautop is idempotent,
  11833. // meaning there are no negative consequences to repeated autop calls.
  11834. if (rawBlockName === fallbackBlockName && !(options !== null && options !== void 0 && options.__unstableSkipAutop)) {
  11835. rawInnerHTML = (0,external_wp_autop_namespaceObject.autop)(rawInnerHTML).trim();
  11836. }
  11837. return { ...rawBlock,
  11838. blockName: rawBlockName,
  11839. attrs: rawAttributes,
  11840. innerHTML: rawInnerHTML,
  11841. innerBlocks: rawInnerBlocks
  11842. };
  11843. }
  11844. /**
  11845. * Uses the "unregistered blockType" to create a block object.
  11846. *
  11847. * @param {WPRawBlock} rawBlock block.
  11848. *
  11849. * @return {WPRawBlock} The unregistered block object.
  11850. */
  11851. function createMissingBlockType(rawBlock) {
  11852. const unregisteredFallbackBlock = getUnregisteredTypeHandlerName() || getFreeformContentHandlerName(); // Preserve undelimited content for use by the unregistered type
  11853. // handler. A block node's `innerHTML` isn't enough, as that field only
  11854. // carries the block's own HTML and not its nested blocks.
  11855. const originalUndelimitedContent = serializeRawBlock(rawBlock, {
  11856. isCommentDelimited: false
  11857. }); // Preserve full block content for use by the unregistered type
  11858. // handler, block boundaries included.
  11859. const originalContent = serializeRawBlock(rawBlock, {
  11860. isCommentDelimited: true
  11861. });
  11862. return {
  11863. blockName: unregisteredFallbackBlock,
  11864. attrs: {
  11865. originalName: rawBlock.blockName,
  11866. originalContent,
  11867. originalUndelimitedContent
  11868. },
  11869. innerHTML: rawBlock.blockName ? originalContent : rawBlock.innerHTML,
  11870. innerBlocks: rawBlock.innerBlocks,
  11871. innerContent: rawBlock.innerContent
  11872. };
  11873. }
  11874. /**
  11875. * Validates a block and wraps with validation meta.
  11876. *
  11877. * The name here is regrettable but `validateBlock` is already taken.
  11878. *
  11879. * @param {WPBlock} unvalidatedBlock
  11880. * @param {import('../registration').WPBlockType} blockType
  11881. * @return {WPBlock} validated block, with auto-fixes if initially invalid
  11882. */
  11883. function applyBlockValidation(unvalidatedBlock, blockType) {
  11884. // Attempt to validate the block.
  11885. const [isValid] = validateBlock(unvalidatedBlock, blockType);
  11886. if (isValid) {
  11887. return { ...unvalidatedBlock,
  11888. isValid,
  11889. validationIssues: []
  11890. };
  11891. } // If the block is invalid, attempt some built-in fixes
  11892. // like custom classNames handling.
  11893. const fixedBlock = applyBuiltInValidationFixes(unvalidatedBlock, blockType); // Attempt to validate the block once again after the built-in fixes.
  11894. const [isFixedValid, validationIssues] = validateBlock(unvalidatedBlock, blockType);
  11895. return { ...fixedBlock,
  11896. isValid: isFixedValid,
  11897. validationIssues
  11898. };
  11899. }
  11900. /**
  11901. * Given a raw block returned by grammar parsing, returns a fully parsed block.
  11902. *
  11903. * @param {WPRawBlock} rawBlock The raw block object.
  11904. * @param {ParseOptions} options Extra options for handling block parsing.
  11905. *
  11906. * @return {WPBlock} Fully parsed block.
  11907. */
  11908. function parseRawBlock(rawBlock, options) {
  11909. let normalizedBlock = normalizeRawBlock(rawBlock, options); // During the lifecycle of the project, we renamed some old blocks
  11910. // and transformed others to new blocks. To avoid breaking existing content,
  11911. // we added this function to properly parse the old content.
  11912. normalizedBlock = convertLegacyBlocks(normalizedBlock); // Try finding the type for known block name.
  11913. let blockType = getBlockType(normalizedBlock.blockName); // If not blockType is found for the specified name, fallback to the "unregistedBlockType".
  11914. if (!blockType) {
  11915. normalizedBlock = createMissingBlockType(normalizedBlock);
  11916. blockType = getBlockType(normalizedBlock.blockName);
  11917. } // If it's an empty freeform block or there's no blockType (no missing block handler)
  11918. // Then, just ignore the block.
  11919. // It might be a good idea to throw a warning here.
  11920. // TODO: I'm unsure about the unregisteredFallbackBlock check,
  11921. // it might ignore some dynamic unregistered third party blocks wrongly.
  11922. const isFallbackBlock = normalizedBlock.blockName === getFreeformContentHandlerName() || normalizedBlock.blockName === getUnregisteredTypeHandlerName();
  11923. if (!blockType || !normalizedBlock.innerHTML && isFallbackBlock) {
  11924. return;
  11925. } // Parse inner blocks recursively.
  11926. const parsedInnerBlocks = normalizedBlock.innerBlocks.map(innerBlock => parseRawBlock(innerBlock, options)) // See https://github.com/WordPress/gutenberg/pull/17164.
  11927. .filter(innerBlock => !!innerBlock); // Get the fully parsed block.
  11928. const parsedBlock = createBlock(normalizedBlock.blockName, getBlockAttributes(blockType, normalizedBlock.innerHTML, normalizedBlock.attrs), parsedInnerBlocks);
  11929. parsedBlock.originalContent = normalizedBlock.innerHTML;
  11930. const validatedBlock = applyBlockValidation(parsedBlock, blockType);
  11931. const {
  11932. validationIssues
  11933. } = validatedBlock; // Run the block deprecation and migrations.
  11934. // This is performed on both invalid and valid blocks because
  11935. // migration using the `migrate` functions should run even
  11936. // if the output is deemed valid.
  11937. const updatedBlock = applyBlockDeprecatedVersions(validatedBlock, normalizedBlock, blockType);
  11938. if (!updatedBlock.isValid) {
  11939. // Preserve the original unprocessed version of the block
  11940. // that we received (no fixes, no deprecations) so that
  11941. // we can save it as close to exactly the same way as
  11942. // we loaded it. This is important to avoid corruption
  11943. // and data loss caused by block implementations trying
  11944. // to process data that isn't fully recognized.
  11945. updatedBlock.__unstableBlockSource = rawBlock;
  11946. }
  11947. if (!validatedBlock.isValid && updatedBlock.isValid && !(options !== null && options !== void 0 && options.__unstableSkipMigrationLogs)) {
  11948. /* eslint-disable no-console */
  11949. console.groupCollapsed('Updated Block: %s', blockType.name);
  11950. 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, updatedBlock.attributes), updatedBlock.originalContent);
  11951. console.groupEnd();
  11952. /* eslint-enable no-console */
  11953. } else if (!validatedBlock.isValid && !updatedBlock.isValid) {
  11954. validationIssues.forEach(_ref => {
  11955. let {
  11956. log,
  11957. args
  11958. } = _ref;
  11959. return log(...args);
  11960. });
  11961. }
  11962. return updatedBlock;
  11963. }
  11964. /**
  11965. * Utilizes an optimized token-driven parser based on the Gutenberg grammar spec
  11966. * defined through a parsing expression grammar to take advantage of the regular
  11967. * cadence provided by block delimiters -- composed syntactically through HTML
  11968. * comments -- which, given a general HTML document as an input, returns a block
  11969. * list array representation.
  11970. *
  11971. * This is a recursive-descent parser that scans linearly once through the input
  11972. * document. Instead of directly recursing it utilizes a trampoline mechanism to
  11973. * prevent stack overflow. This initial pass is mainly interested in separating
  11974. * and isolating the blocks serialized in the document and manifestly not in the
  11975. * content within the blocks.
  11976. *
  11977. * @see
  11978. * https://developer.wordpress.org/block-editor/packages/packages-block-serialization-default-parser/
  11979. *
  11980. * @param {string} content The post content.
  11981. * @param {ParseOptions} options Extra options for handling block parsing.
  11982. *
  11983. * @return {Array} Block list.
  11984. */
  11985. function parser_parse(content, options) {
  11986. return (0,external_wp_blockSerializationDefaultParser_namespaceObject.parse)(content).reduce((accumulator, rawBlock) => {
  11987. const block = parseRawBlock(rawBlock, options);
  11988. if (block) {
  11989. accumulator.push(block);
  11990. }
  11991. return accumulator;
  11992. }, []);
  11993. }
  11994. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/get-raw-transforms.js
  11995. /**
  11996. * Internal dependencies
  11997. */
  11998. function getRawTransforms() {
  11999. return getBlockTransforms('from').filter(_ref => {
  12000. let {
  12001. type
  12002. } = _ref;
  12003. return type === 'raw';
  12004. }).map(transform => {
  12005. return transform.isMatch ? transform : { ...transform,
  12006. isMatch: node => transform.selector && node.matches(transform.selector)
  12007. };
  12008. });
  12009. }
  12010. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/html-to-blocks.js
  12011. /**
  12012. * Internal dependencies
  12013. */
  12014. /**
  12015. * Converts HTML directly to blocks. Looks for a matching transform for each
  12016. * top-level tag. The HTML should be filtered to not have any text between
  12017. * top-level tags and formatted in a way that blocks can handle the HTML.
  12018. *
  12019. * @param {string} html HTML to convert.
  12020. * @param {Function} handler The handler calling htmlToBlocks: either rawHandler
  12021. * or pasteHandler.
  12022. *
  12023. * @return {Array} An array of blocks.
  12024. */
  12025. function htmlToBlocks(html, handler) {
  12026. const doc = document.implementation.createHTMLDocument('');
  12027. doc.body.innerHTML = html;
  12028. return Array.from(doc.body.children).flatMap(node => {
  12029. const rawTransform = findTransform(getRawTransforms(), _ref => {
  12030. let {
  12031. isMatch
  12032. } = _ref;
  12033. return isMatch(node);
  12034. });
  12035. if (!rawTransform) {
  12036. return createBlock( // Should not be hardcoded.
  12037. 'core/html', getBlockAttributes('core/html', node.outerHTML));
  12038. }
  12039. const {
  12040. transform,
  12041. blockName
  12042. } = rawTransform;
  12043. if (transform) {
  12044. return transform(node, handler);
  12045. }
  12046. return createBlock(blockName, getBlockAttributes(blockName, node.outerHTML));
  12047. });
  12048. }
  12049. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/normalise-blocks.js
  12050. /**
  12051. * WordPress dependencies
  12052. */
  12053. function normaliseBlocks(HTML) {
  12054. const decuDoc = document.implementation.createHTMLDocument('');
  12055. const accuDoc = document.implementation.createHTMLDocument('');
  12056. const decu = decuDoc.body;
  12057. const accu = accuDoc.body;
  12058. decu.innerHTML = HTML;
  12059. while (decu.firstChild) {
  12060. const node = decu.firstChild; // Text nodes: wrap in a paragraph, or append to previous.
  12061. if (node.nodeType === node.TEXT_NODE) {
  12062. if ((0,external_wp_dom_namespaceObject.isEmpty)(node)) {
  12063. decu.removeChild(node);
  12064. } else {
  12065. if (!accu.lastChild || accu.lastChild.nodeName !== 'P') {
  12066. accu.appendChild(accuDoc.createElement('P'));
  12067. }
  12068. accu.lastChild.appendChild(node);
  12069. } // Element nodes.
  12070. } else if (node.nodeType === node.ELEMENT_NODE) {
  12071. // BR nodes: create a new paragraph on double, or append to previous.
  12072. if (node.nodeName === 'BR') {
  12073. if (node.nextSibling && node.nextSibling.nodeName === 'BR') {
  12074. accu.appendChild(accuDoc.createElement('P'));
  12075. decu.removeChild(node.nextSibling);
  12076. } // Don't append to an empty paragraph.
  12077. if (accu.lastChild && accu.lastChild.nodeName === 'P' && accu.lastChild.hasChildNodes()) {
  12078. accu.lastChild.appendChild(node);
  12079. } else {
  12080. decu.removeChild(node);
  12081. }
  12082. } else if (node.nodeName === 'P') {
  12083. // Only append non-empty paragraph nodes.
  12084. if ((0,external_wp_dom_namespaceObject.isEmpty)(node)) {
  12085. decu.removeChild(node);
  12086. } else {
  12087. accu.appendChild(node);
  12088. }
  12089. } else if ((0,external_wp_dom_namespaceObject.isPhrasingContent)(node)) {
  12090. if (!accu.lastChild || accu.lastChild.nodeName !== 'P') {
  12091. accu.appendChild(accuDoc.createElement('P'));
  12092. }
  12093. accu.lastChild.appendChild(node);
  12094. } else {
  12095. accu.appendChild(node);
  12096. }
  12097. } else {
  12098. decu.removeChild(node);
  12099. }
  12100. }
  12101. return accu.innerHTML;
  12102. }
  12103. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/special-comment-converter.js
  12104. /**
  12105. * WordPress dependencies
  12106. */
  12107. /**
  12108. * Looks for `<!--nextpage-->` and `<!--more-->` comments and
  12109. * replaces them with a custom element representing a future block.
  12110. *
  12111. * The custom element is a way to bypass the rest of the `raw-handling`
  12112. * transforms, which would eliminate other kinds of node with which to carry
  12113. * `<!--more-->`'s data: nodes with `data` attributes, empty paragraphs, etc.
  12114. *
  12115. * The custom element is then expected to be recognized by any registered
  12116. * block's `raw` transform.
  12117. *
  12118. * @param {Node} node The node to be processed.
  12119. * @param {Document} doc The document of the node.
  12120. * @return {void}
  12121. */
  12122. function specialCommentConverter(node, doc) {
  12123. if (node.nodeType !== node.COMMENT_NODE) {
  12124. return;
  12125. }
  12126. if (node.nodeValue === 'nextpage') {
  12127. (0,external_wp_dom_namespaceObject.replace)(node, createNextpage(doc));
  12128. return;
  12129. }
  12130. if (node.nodeValue.indexOf('more') === 0) {
  12131. moreCommentConverter(node, doc);
  12132. }
  12133. }
  12134. /**
  12135. * Convert `<!--more-->` as well as the `<!--more Some text-->` variant
  12136. * and its `<!--noteaser-->` companion into the custom element
  12137. * described in `specialCommentConverter()`.
  12138. *
  12139. * @param {Node} node The node to be processed.
  12140. * @param {Document} doc The document of the node.
  12141. * @return {void}
  12142. */
  12143. function moreCommentConverter(node, doc) {
  12144. // Grab any custom text in the comment.
  12145. const customText = node.nodeValue.slice(4).trim();
  12146. /*
  12147. * When a `<!--more-->` comment is found, we need to look for any
  12148. * `<!--noteaser-->` sibling, but it may not be a direct sibling
  12149. * (whitespace typically lies in between)
  12150. */
  12151. let sibling = node;
  12152. let noTeaser = false;
  12153. while (sibling = sibling.nextSibling) {
  12154. if (sibling.nodeType === sibling.COMMENT_NODE && sibling.nodeValue === 'noteaser') {
  12155. noTeaser = true;
  12156. (0,external_wp_dom_namespaceObject.remove)(sibling);
  12157. break;
  12158. }
  12159. }
  12160. const moreBlock = createMore(customText, noTeaser, doc); // If our `<!--more-->` comment is in the middle of a paragraph, we should
  12161. // split the paragraph in two and insert the more block in between. If not,
  12162. // the more block will eventually end up being inserted after the paragraph.
  12163. if (!node.parentNode || node.parentNode.nodeName !== 'P' || node.parentNode.childNodes.length === 1) {
  12164. (0,external_wp_dom_namespaceObject.replace)(node, moreBlock);
  12165. } else {
  12166. const childNodes = Array.from(node.parentNode.childNodes);
  12167. const nodeIndex = childNodes.indexOf(node);
  12168. const wrapperNode = node.parentNode.parentNode || doc.body;
  12169. const paragraphBuilder = (acc, child) => {
  12170. if (!acc) {
  12171. acc = doc.createElement('p');
  12172. }
  12173. acc.appendChild(child);
  12174. return acc;
  12175. }; // Split the original parent node and insert our more block
  12176. [childNodes.slice(0, nodeIndex).reduce(paragraphBuilder, null), moreBlock, childNodes.slice(nodeIndex + 1).reduce(paragraphBuilder, null)].forEach(element => element && wrapperNode.insertBefore(element, node.parentNode)); // Remove the old parent paragraph
  12177. (0,external_wp_dom_namespaceObject.remove)(node.parentNode);
  12178. }
  12179. }
  12180. function createMore(customText, noTeaser, doc) {
  12181. const node = doc.createElement('wp-block');
  12182. node.dataset.block = 'core/more';
  12183. if (customText) {
  12184. node.dataset.customText = customText;
  12185. }
  12186. if (noTeaser) {
  12187. // "Boolean" data attribute.
  12188. node.dataset.noTeaser = '';
  12189. }
  12190. return node;
  12191. }
  12192. function createNextpage(doc) {
  12193. const node = doc.createElement('wp-block');
  12194. node.dataset.block = 'core/nextpage';
  12195. return node;
  12196. }
  12197. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/list-reducer.js
  12198. /**
  12199. * WordPress dependencies
  12200. */
  12201. function isList(node) {
  12202. return node.nodeName === 'OL' || node.nodeName === 'UL';
  12203. }
  12204. function shallowTextContent(element) {
  12205. return Array.from(element.childNodes).map(_ref => {
  12206. let {
  12207. nodeValue = ''
  12208. } = _ref;
  12209. return nodeValue;
  12210. }).join('');
  12211. }
  12212. function listReducer(node) {
  12213. if (!isList(node)) {
  12214. return;
  12215. }
  12216. const list = node;
  12217. const prevElement = node.previousElementSibling; // Merge with previous list if:
  12218. // * There is a previous list of the same type.
  12219. // * There is only one list item.
  12220. if (prevElement && prevElement.nodeName === node.nodeName && list.children.length === 1) {
  12221. // Move all child nodes, including any text nodes, if any.
  12222. while (list.firstChild) {
  12223. prevElement.appendChild(list.firstChild);
  12224. }
  12225. list.parentNode.removeChild(list);
  12226. }
  12227. const parentElement = node.parentNode; // Nested list with empty parent item.
  12228. if (parentElement && parentElement.nodeName === 'LI' && parentElement.children.length === 1 && !/\S/.test(shallowTextContent(parentElement))) {
  12229. const parentListItem = parentElement;
  12230. const prevListItem = parentListItem.previousElementSibling;
  12231. const parentList = parentListItem.parentNode;
  12232. if (prevListItem) {
  12233. prevListItem.appendChild(list);
  12234. parentList.removeChild(parentListItem);
  12235. } else {
  12236. parentList.parentNode.insertBefore(list, parentList);
  12237. parentList.parentNode.removeChild(parentList);
  12238. }
  12239. } // Invalid: OL/UL > OL/UL.
  12240. if (parentElement && isList(parentElement)) {
  12241. const prevListItem = node.previousElementSibling;
  12242. if (prevListItem) {
  12243. prevListItem.appendChild(node);
  12244. } else {
  12245. (0,external_wp_dom_namespaceObject.unwrap)(node);
  12246. }
  12247. }
  12248. }
  12249. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/blockquote-normaliser.js
  12250. /**
  12251. * Internal dependencies
  12252. */
  12253. function blockquoteNormaliser(node) {
  12254. if (node.nodeName !== 'BLOCKQUOTE') {
  12255. return;
  12256. }
  12257. node.innerHTML = normaliseBlocks(node.innerHTML);
  12258. }
  12259. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/figure-content-reducer.js
  12260. /**
  12261. * WordPress dependencies
  12262. */
  12263. /**
  12264. * Whether or not the given node is figure content.
  12265. *
  12266. * @param {Node} node The node to check.
  12267. * @param {Object} schema The schema to use.
  12268. *
  12269. * @return {boolean} True if figure content, false if not.
  12270. */
  12271. function isFigureContent(node, schema) {
  12272. var _schema$figure$childr, _schema$figure;
  12273. const tag = node.nodeName.toLowerCase(); // We are looking for tags that can be a child of the figure tag, excluding
  12274. // `figcaption` and any phrasing content.
  12275. if (tag === 'figcaption' || (0,external_wp_dom_namespaceObject.isTextContent)(node)) {
  12276. return false;
  12277. }
  12278. return tag in ((_schema$figure$childr = schema === null || schema === void 0 ? void 0 : (_schema$figure = schema.figure) === null || _schema$figure === void 0 ? void 0 : _schema$figure.children) !== null && _schema$figure$childr !== void 0 ? _schema$figure$childr : {});
  12279. }
  12280. /**
  12281. * Whether or not the given node can have an anchor.
  12282. *
  12283. * @param {Node} node The node to check.
  12284. * @param {Object} schema The schema to use.
  12285. *
  12286. * @return {boolean} True if it can, false if not.
  12287. */
  12288. function canHaveAnchor(node, schema) {
  12289. var _schema$figure$childr2, _schema$figure2, _schema$figure2$child, _schema$figure2$child2;
  12290. const tag = node.nodeName.toLowerCase();
  12291. return tag in ((_schema$figure$childr2 = schema === null || schema === void 0 ? void 0 : (_schema$figure2 = schema.figure) === null || _schema$figure2 === void 0 ? void 0 : (_schema$figure2$child = _schema$figure2.children) === null || _schema$figure2$child === void 0 ? void 0 : (_schema$figure2$child2 = _schema$figure2$child.a) === null || _schema$figure2$child2 === void 0 ? void 0 : _schema$figure2$child2.children) !== null && _schema$figure$childr2 !== void 0 ? _schema$figure$childr2 : {});
  12292. }
  12293. /**
  12294. * Wraps the given element in a figure element.
  12295. *
  12296. * @param {Element} element The element to wrap.
  12297. * @param {Element} beforeElement The element before which to place the figure.
  12298. */
  12299. function wrapFigureContent(element) {
  12300. let beforeElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : element;
  12301. const figure = element.ownerDocument.createElement('figure');
  12302. beforeElement.parentNode.insertBefore(figure, beforeElement);
  12303. figure.appendChild(element);
  12304. }
  12305. /**
  12306. * This filter takes figure content out of paragraphs, wraps it in a figure
  12307. * element, and moves any anchors with it if needed.
  12308. *
  12309. * @param {Node} node The node to filter.
  12310. * @param {Document} doc The document of the node.
  12311. * @param {Object} schema The schema to use.
  12312. *
  12313. * @return {void}
  12314. */
  12315. function figureContentReducer(node, doc, schema) {
  12316. if (!isFigureContent(node, schema)) {
  12317. return;
  12318. }
  12319. let nodeToInsert = node;
  12320. const parentNode = node.parentNode; // If the figure content can have an anchor and its parent is an anchor with
  12321. // only the figure content, take the anchor out instead of just the content.
  12322. if (canHaveAnchor(node, schema) && parentNode.nodeName === 'A' && parentNode.childNodes.length === 1) {
  12323. nodeToInsert = node.parentNode;
  12324. }
  12325. const wrapper = nodeToInsert.closest('p,div'); // If wrapped in a paragraph or div, only extract if it's aligned or if
  12326. // there is no text content.
  12327. // Otherwise, if directly at the root, wrap in a figure element.
  12328. if (wrapper) {
  12329. // In jsdom-jscore, 'node.classList' can be undefined.
  12330. // In this case, default to extract as it offers a better UI experience on mobile.
  12331. if (!node.classList) {
  12332. wrapFigureContent(nodeToInsert, wrapper);
  12333. } else if (node.classList.contains('alignright') || node.classList.contains('alignleft') || node.classList.contains('aligncenter') || !wrapper.textContent.trim()) {
  12334. wrapFigureContent(nodeToInsert, wrapper);
  12335. }
  12336. } else if (nodeToInsert.parentNode.nodeName === 'BODY') {
  12337. wrapFigureContent(nodeToInsert);
  12338. }
  12339. }
  12340. ;// CONCATENATED MODULE: external ["wp","shortcode"]
  12341. var external_wp_shortcode_namespaceObject = window["wp"]["shortcode"];
  12342. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/shortcode-converter.js
  12343. /**
  12344. * WordPress dependencies
  12345. */
  12346. /**
  12347. * Internal dependencies
  12348. */
  12349. const castArray = maybeArray => Array.isArray(maybeArray) ? maybeArray : [maybeArray];
  12350. function segmentHTMLToShortcodeBlock(HTML) {
  12351. let lastIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  12352. let excludedBlockNames = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
  12353. // Get all matches.
  12354. const transformsFrom = getBlockTransforms('from');
  12355. const transformation = findTransform(transformsFrom, transform => excludedBlockNames.indexOf(transform.blockName) === -1 && transform.type === 'shortcode' && castArray(transform.tag).some(tag => (0,external_wp_shortcode_namespaceObject.regexp)(tag).test(HTML)));
  12356. if (!transformation) {
  12357. return [HTML];
  12358. }
  12359. const transformTags = castArray(transformation.tag);
  12360. const transformTag = transformTags.find(tag => (0,external_wp_shortcode_namespaceObject.regexp)(tag).test(HTML));
  12361. let match;
  12362. const previousIndex = lastIndex;
  12363. if (match = (0,external_wp_shortcode_namespaceObject.next)(transformTag, HTML, lastIndex)) {
  12364. var _match$shortcode$cont;
  12365. lastIndex = match.index + match.content.length;
  12366. const beforeHTML = HTML.substr(0, match.index);
  12367. const afterHTML = HTML.substr(lastIndex); // If the shortcode content does not contain HTML and the shortcode is
  12368. // not on a new line (or in paragraph from Markdown converter),
  12369. // consider the shortcode as inline text, and thus skip conversion for
  12370. // this segment.
  12371. if (!((_match$shortcode$cont = match.shortcode.content) !== null && _match$shortcode$cont !== void 0 && _match$shortcode$cont.includes('<')) && !(/(\n|<p>)\s*$/.test(beforeHTML) && /^\s*(\n|<\/p>)/.test(afterHTML))) {
  12372. return segmentHTMLToShortcodeBlock(HTML, lastIndex);
  12373. } // If a transformation's `isMatch` predicate fails for the inbound
  12374. // shortcode, try again by excluding the current block type.
  12375. //
  12376. // This is the only call to `segmentHTMLToShortcodeBlock` that should
  12377. // ever carry over `excludedBlockNames`. Other calls in the module
  12378. // should skip that argument as a way to reset the exclusion state, so
  12379. // that one `isMatch` fail in an HTML fragment doesn't prevent any
  12380. // valid matches in subsequent fragments.
  12381. if (transformation.isMatch && !transformation.isMatch(match.shortcode.attrs)) {
  12382. return segmentHTMLToShortcodeBlock(HTML, previousIndex, [...excludedBlockNames, transformation.blockName]);
  12383. }
  12384. let blocks = [];
  12385. if (typeof transformation.transform === 'function') {
  12386. // Passing all of `match` as second argument is intentionally broad
  12387. // but shouldn't be too relied upon.
  12388. //
  12389. // See: https://github.com/WordPress/gutenberg/pull/3610#discussion_r152546926
  12390. blocks = [].concat(transformation.transform(match.shortcode.attrs, match)); // Applying the built-in fixes can enhance the attributes with missing content like "className".
  12391. blocks = blocks.map(block => {
  12392. block.originalContent = match.shortcode.content;
  12393. return applyBuiltInValidationFixes(block, getBlockType(block.name));
  12394. });
  12395. } else {
  12396. const attributes = Object.fromEntries(Object.entries(transformation.attributes).filter(_ref => {
  12397. let [, schema] = _ref;
  12398. return schema.shortcode;
  12399. }) // Passing all of `match` as second argument is intentionally broad
  12400. // but shouldn't be too relied upon.
  12401. //
  12402. // See: https://github.com/WordPress/gutenberg/pull/3610#discussion_r152546926
  12403. .map(_ref2 => {
  12404. let [key, schema] = _ref2;
  12405. return [key, schema.shortcode(match.shortcode.attrs, match)];
  12406. }));
  12407. const blockType = getBlockType(transformation.blockName);
  12408. if (!blockType) {
  12409. return [HTML];
  12410. }
  12411. const transformationBlockType = { ...blockType,
  12412. attributes: transformation.attributes
  12413. };
  12414. let block = createBlock(transformation.blockName, getBlockAttributes(transformationBlockType, match.shortcode.content, attributes)); // Applying the built-in fixes can enhance the attributes with missing content like "className".
  12415. block.originalContent = match.shortcode.content;
  12416. block = applyBuiltInValidationFixes(block, transformationBlockType);
  12417. blocks = [block];
  12418. }
  12419. return [...segmentHTMLToShortcodeBlock(beforeHTML), ...blocks, ...segmentHTMLToShortcodeBlock(afterHTML)];
  12420. }
  12421. return [HTML];
  12422. }
  12423. /* harmony default export */ var shortcode_converter = (segmentHTMLToShortcodeBlock);
  12424. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/utils.js
  12425. /**
  12426. * External dependencies
  12427. */
  12428. /**
  12429. * WordPress dependencies
  12430. */
  12431. /**
  12432. * Internal dependencies
  12433. */
  12434. function getBlockContentSchemaFromTransforms(transforms, context) {
  12435. const phrasingContentSchema = (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)(context);
  12436. const schemaArgs = {
  12437. phrasingContentSchema,
  12438. isPaste: context === 'paste'
  12439. };
  12440. const schemas = transforms.map(_ref => {
  12441. let {
  12442. isMatch,
  12443. blockName,
  12444. schema
  12445. } = _ref;
  12446. const hasAnchorSupport = hasBlockSupport(blockName, 'anchor');
  12447. schema = typeof schema === 'function' ? schema(schemaArgs) : schema; // If the block does not has anchor support and the transform does not
  12448. // provides an isMatch we can return the schema right away.
  12449. if (!hasAnchorSupport && !isMatch) {
  12450. return schema;
  12451. }
  12452. return (0,external_lodash_namespaceObject.mapValues)(schema, value => {
  12453. let attributes = value.attributes || []; // If the block supports the "anchor" functionality, it needs to keep its ID attribute.
  12454. if (hasAnchorSupport) {
  12455. attributes = [...attributes, 'id'];
  12456. }
  12457. return { ...value,
  12458. attributes,
  12459. isMatch: isMatch ? isMatch : undefined
  12460. };
  12461. });
  12462. });
  12463. return (0,external_lodash_namespaceObject.mergeWith)({}, ...schemas, (objValue, srcValue, key) => {
  12464. switch (key) {
  12465. case 'children':
  12466. {
  12467. if (objValue === '*' || srcValue === '*') {
  12468. return '*';
  12469. }
  12470. return { ...objValue,
  12471. ...srcValue
  12472. };
  12473. }
  12474. case 'attributes':
  12475. case 'require':
  12476. {
  12477. return [...(objValue || []), ...(srcValue || [])];
  12478. }
  12479. case 'isMatch':
  12480. {
  12481. // If one of the values being merge is undefined (matches everything),
  12482. // the result of the merge will be undefined.
  12483. if (!objValue || !srcValue) {
  12484. return undefined;
  12485. } // When merging two isMatch functions, the result is a new function
  12486. // that returns if one of the source functions returns true.
  12487. return function () {
  12488. return objValue(...arguments) || srcValue(...arguments);
  12489. };
  12490. }
  12491. }
  12492. });
  12493. }
  12494. /**
  12495. * Gets the block content schema, which is extracted and merged from all
  12496. * registered blocks with raw transfroms.
  12497. *
  12498. * @param {string} context Set to "paste" when in paste context, where the
  12499. * schema is more strict.
  12500. *
  12501. * @return {Object} A complete block content schema.
  12502. */
  12503. function getBlockContentSchema(context) {
  12504. return getBlockContentSchemaFromTransforms(getRawTransforms(), context);
  12505. }
  12506. /**
  12507. * Checks whether HTML can be considered plain text. That is, it does not contain
  12508. * any elements that are not line breaks.
  12509. *
  12510. * @param {string} HTML The HTML to check.
  12511. *
  12512. * @return {boolean} Whether the HTML can be considered plain text.
  12513. */
  12514. function isPlain(HTML) {
  12515. return !/<(?!br[ />])/i.test(HTML);
  12516. }
  12517. /**
  12518. * Given node filters, deeply filters and mutates a NodeList.
  12519. *
  12520. * @param {NodeList} nodeList The nodeList to filter.
  12521. * @param {Array} filters An array of functions that can mutate with the provided node.
  12522. * @param {Document} doc The document of the nodeList.
  12523. * @param {Object} schema The schema to use.
  12524. */
  12525. function deepFilterNodeList(nodeList, filters, doc, schema) {
  12526. Array.from(nodeList).forEach(node => {
  12527. deepFilterNodeList(node.childNodes, filters, doc, schema);
  12528. filters.forEach(item => {
  12529. // Make sure the node is still attached to the document.
  12530. if (!doc.contains(node)) {
  12531. return;
  12532. }
  12533. item(node, doc, schema);
  12534. });
  12535. });
  12536. }
  12537. /**
  12538. * Given node filters, deeply filters HTML tags.
  12539. * Filters from the deepest nodes to the top.
  12540. *
  12541. * @param {string} HTML The HTML to filter.
  12542. * @param {Array} filters An array of functions that can mutate with the provided node.
  12543. * @param {Object} schema The schema to use.
  12544. *
  12545. * @return {string} The filtered HTML.
  12546. */
  12547. function deepFilterHTML(HTML) {
  12548. let filters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  12549. let schema = arguments.length > 2 ? arguments[2] : undefined;
  12550. const doc = document.implementation.createHTMLDocument('');
  12551. doc.body.innerHTML = HTML;
  12552. deepFilterNodeList(doc.body.childNodes, filters, doc, schema);
  12553. return doc.body.innerHTML;
  12554. }
  12555. /**
  12556. * Gets a sibling within text-level context.
  12557. *
  12558. * @param {Element} node The subject node.
  12559. * @param {string} which "next" or "previous".
  12560. */
  12561. function getSibling(node, which) {
  12562. const sibling = node[`${which}Sibling`];
  12563. if (sibling && (0,external_wp_dom_namespaceObject.isPhrasingContent)(sibling)) {
  12564. return sibling;
  12565. }
  12566. const {
  12567. parentNode
  12568. } = node;
  12569. if (!parentNode || !(0,external_wp_dom_namespaceObject.isPhrasingContent)(parentNode)) {
  12570. return;
  12571. }
  12572. return getSibling(parentNode, which);
  12573. }
  12574. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/index.js
  12575. /**
  12576. * WordPress dependencies
  12577. */
  12578. /**
  12579. * Internal dependencies
  12580. */
  12581. function deprecatedGetPhrasingContentSchema(context) {
  12582. external_wp_deprecated_default()('wp.blocks.getPhrasingContentSchema', {
  12583. since: '5.6',
  12584. alternative: 'wp.dom.getPhrasingContentSchema'
  12585. });
  12586. return (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)(context);
  12587. }
  12588. /**
  12589. * Converts an HTML string to known blocks.
  12590. *
  12591. * @param {Object} $1
  12592. * @param {string} $1.HTML The HTML to convert.
  12593. *
  12594. * @return {Array} A list of blocks.
  12595. */
  12596. function rawHandler(_ref) {
  12597. let {
  12598. HTML = ''
  12599. } = _ref;
  12600. // If we detect block delimiters, parse entirely as blocks.
  12601. if (HTML.indexOf('<!-- wp:') !== -1) {
  12602. return parser_parse(HTML);
  12603. } // An array of HTML strings and block objects. The blocks replace matched
  12604. // shortcodes.
  12605. const pieces = shortcode_converter(HTML);
  12606. const blockContentSchema = getBlockContentSchema();
  12607. return pieces.map(piece => {
  12608. // Already a block from shortcode.
  12609. if (typeof piece !== 'string') {
  12610. return piece;
  12611. } // These filters are essential for some blocks to be able to transform
  12612. // from raw HTML. These filters move around some content or add
  12613. // additional tags, they do not remove any content.
  12614. const filters = [// Needed to adjust invalid lists.
  12615. listReducer, // Needed to create more and nextpage blocks.
  12616. specialCommentConverter, // Needed to create media blocks.
  12617. figureContentReducer, // Needed to create the quote block, which cannot handle text
  12618. // without wrapper paragraphs.
  12619. blockquoteNormaliser];
  12620. piece = deepFilterHTML(piece, filters, blockContentSchema);
  12621. piece = normaliseBlocks(piece);
  12622. return htmlToBlocks(piece, rawHandler);
  12623. }).flat().filter(Boolean);
  12624. }
  12625. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/comment-remover.js
  12626. /**
  12627. * WordPress dependencies
  12628. */
  12629. /**
  12630. * Looks for comments, and removes them.
  12631. *
  12632. * @param {Node} node The node to be processed.
  12633. * @return {void}
  12634. */
  12635. function commentRemover(node) {
  12636. if (node.nodeType === node.COMMENT_NODE) {
  12637. (0,external_wp_dom_namespaceObject.remove)(node);
  12638. }
  12639. }
  12640. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/is-inline-content.js
  12641. /**
  12642. * WordPress dependencies
  12643. */
  12644. /**
  12645. * Checks if the given node should be considered inline content, optionally
  12646. * depending on a context tag.
  12647. *
  12648. * @param {Node} node Node name.
  12649. * @param {string} contextTag Tag name.
  12650. *
  12651. * @return {boolean} True if the node is inline content, false if nohe.
  12652. */
  12653. function isInline(node, contextTag) {
  12654. if ((0,external_wp_dom_namespaceObject.isTextContent)(node)) {
  12655. return true;
  12656. }
  12657. if (!contextTag) {
  12658. return false;
  12659. }
  12660. const tag = node.nodeName.toLowerCase();
  12661. const inlineAllowedTagGroups = [['ul', 'li', 'ol'], ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']];
  12662. return inlineAllowedTagGroups.some(tagGroup => [tag, contextTag].filter(t => !tagGroup.includes(t)).length === 0);
  12663. }
  12664. function deepCheck(nodes, contextTag) {
  12665. return nodes.every(node => isInline(node, contextTag) && deepCheck(Array.from(node.children), contextTag));
  12666. }
  12667. function isDoubleBR(node) {
  12668. return node.nodeName === 'BR' && node.previousSibling && node.previousSibling.nodeName === 'BR';
  12669. }
  12670. function isInlineContent(HTML, contextTag) {
  12671. const doc = document.implementation.createHTMLDocument('');
  12672. doc.body.innerHTML = HTML;
  12673. const nodes = Array.from(doc.body.children);
  12674. return !nodes.some(isDoubleBR) && deepCheck(nodes, contextTag);
  12675. }
  12676. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/phrasing-content-reducer.js
  12677. /**
  12678. * WordPress dependencies
  12679. */
  12680. function phrasingContentReducer(node, doc) {
  12681. // In jsdom-jscore, 'node.style' can be null.
  12682. // TODO: Explore fixing this by patching jsdom-jscore.
  12683. if (node.nodeName === 'SPAN' && node.style) {
  12684. const {
  12685. fontWeight,
  12686. fontStyle,
  12687. textDecorationLine,
  12688. textDecoration,
  12689. verticalAlign
  12690. } = node.style;
  12691. if (fontWeight === 'bold' || fontWeight === '700') {
  12692. (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('strong'), node);
  12693. }
  12694. if (fontStyle === 'italic') {
  12695. (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('em'), node);
  12696. } // Some DOM implementations (Safari, JSDom) don't support
  12697. // style.textDecorationLine, so we check style.textDecoration as a
  12698. // fallback.
  12699. if (textDecorationLine === 'line-through' || textDecoration.includes('line-through')) {
  12700. (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('s'), node);
  12701. }
  12702. if (verticalAlign === 'super') {
  12703. (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('sup'), node);
  12704. } else if (verticalAlign === 'sub') {
  12705. (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('sub'), node);
  12706. }
  12707. } else if (node.nodeName === 'B') {
  12708. node = (0,external_wp_dom_namespaceObject.replaceTag)(node, 'strong');
  12709. } else if (node.nodeName === 'I') {
  12710. node = (0,external_wp_dom_namespaceObject.replaceTag)(node, 'em');
  12711. } else if (node.nodeName === 'A') {
  12712. // In jsdom-jscore, 'node.target' can be null.
  12713. // TODO: Explore fixing this by patching jsdom-jscore.
  12714. if (node.target && node.target.toLowerCase() === '_blank') {
  12715. node.rel = 'noreferrer noopener';
  12716. } else {
  12717. node.removeAttribute('target');
  12718. node.removeAttribute('rel');
  12719. } // Saves anchor elements name attribute as id
  12720. if (node.name && !node.id) {
  12721. node.id = node.name;
  12722. } // Keeps id only if there is an internal link pointing to it
  12723. if (node.id && !node.ownerDocument.querySelector(`[href="#${node.id}"]`)) {
  12724. node.removeAttribute('id');
  12725. }
  12726. }
  12727. }
  12728. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/head-remover.js
  12729. function headRemover(node) {
  12730. if (node.nodeName !== 'SCRIPT' && node.nodeName !== 'NOSCRIPT' && node.nodeName !== 'TEMPLATE' && node.nodeName !== 'STYLE') {
  12731. return;
  12732. }
  12733. node.parentNode.removeChild(node);
  12734. }
  12735. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/ms-list-converter.js
  12736. /**
  12737. * Browser dependencies
  12738. */
  12739. const {
  12740. parseInt: ms_list_converter_parseInt
  12741. } = window;
  12742. function ms_list_converter_isList(node) {
  12743. return node.nodeName === 'OL' || node.nodeName === 'UL';
  12744. }
  12745. function msListConverter(node, doc) {
  12746. if (node.nodeName !== 'P') {
  12747. return;
  12748. }
  12749. const style = node.getAttribute('style');
  12750. if (!style) {
  12751. return;
  12752. } // Quick check.
  12753. if (style.indexOf('mso-list') === -1) {
  12754. return;
  12755. }
  12756. const matches = /mso-list\s*:[^;]+level([0-9]+)/i.exec(style);
  12757. if (!matches) {
  12758. return;
  12759. }
  12760. let level = ms_list_converter_parseInt(matches[1], 10) - 1 || 0;
  12761. const prevNode = node.previousElementSibling; // Add new list if no previous.
  12762. if (!prevNode || !ms_list_converter_isList(prevNode)) {
  12763. // See https://html.spec.whatwg.org/multipage/grouping-content.html#attr-ol-type.
  12764. const type = node.textContent.trim().slice(0, 1);
  12765. const isNumeric = /[1iIaA]/.test(type);
  12766. const newListNode = doc.createElement(isNumeric ? 'ol' : 'ul');
  12767. if (isNumeric) {
  12768. newListNode.setAttribute('type', type);
  12769. }
  12770. node.parentNode.insertBefore(newListNode, node);
  12771. }
  12772. const listNode = node.previousElementSibling;
  12773. const listType = listNode.nodeName;
  12774. const listItem = doc.createElement('li');
  12775. let receivingNode = listNode; // Remove the first span with list info.
  12776. node.removeChild(node.firstChild); // Add content.
  12777. while (node.firstChild) {
  12778. listItem.appendChild(node.firstChild);
  12779. } // Change pointer depending on indentation level.
  12780. while (level--) {
  12781. receivingNode = receivingNode.lastChild || receivingNode; // If it's a list, move pointer to the last item.
  12782. if (ms_list_converter_isList(receivingNode)) {
  12783. receivingNode = receivingNode.lastChild || receivingNode;
  12784. }
  12785. } // Make sure we append to a list.
  12786. if (!ms_list_converter_isList(receivingNode)) {
  12787. receivingNode = receivingNode.appendChild(doc.createElement(listType));
  12788. } // Append the list item to the list.
  12789. receivingNode.appendChild(listItem); // Remove the wrapper paragraph.
  12790. node.parentNode.removeChild(node);
  12791. }
  12792. ;// CONCATENATED MODULE: external ["wp","blob"]
  12793. var external_wp_blob_namespaceObject = window["wp"]["blob"];
  12794. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/image-corrector.js
  12795. /**
  12796. * WordPress dependencies
  12797. */
  12798. /**
  12799. * Browser dependencies
  12800. */
  12801. const {
  12802. atob,
  12803. File
  12804. } = window;
  12805. function imageCorrector(node) {
  12806. if (node.nodeName !== 'IMG') {
  12807. return;
  12808. }
  12809. if (node.src.indexOf('file:') === 0) {
  12810. node.src = '';
  12811. } // This piece cannot be tested outside a browser env.
  12812. if (node.src.indexOf('data:') === 0) {
  12813. const [properties, data] = node.src.split(',');
  12814. const [type] = properties.slice(5).split(';');
  12815. if (!data || !type) {
  12816. node.src = '';
  12817. return;
  12818. }
  12819. let decoded; // Can throw DOMException!
  12820. try {
  12821. decoded = atob(data);
  12822. } catch (e) {
  12823. node.src = '';
  12824. return;
  12825. }
  12826. const uint8Array = new Uint8Array(decoded.length);
  12827. for (let i = 0; i < uint8Array.length; i++) {
  12828. uint8Array[i] = decoded.charCodeAt(i);
  12829. }
  12830. const name = type.replace('/', '.');
  12831. const file = new File([uint8Array], name, {
  12832. type
  12833. });
  12834. node.src = (0,external_wp_blob_namespaceObject.createBlobURL)(file);
  12835. } // Remove trackers and hardly visible images.
  12836. if (node.height === 1 || node.width === 1) {
  12837. node.parentNode.removeChild(node);
  12838. }
  12839. }
  12840. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/div-normaliser.js
  12841. /**
  12842. * Internal dependencies
  12843. */
  12844. function divNormaliser(node) {
  12845. if (node.nodeName !== 'DIV') {
  12846. return;
  12847. }
  12848. node.innerHTML = normaliseBlocks(node.innerHTML);
  12849. }
  12850. // EXTERNAL MODULE: ./node_modules/showdown/dist/showdown.js
  12851. var showdown = __webpack_require__(7308);
  12852. var showdown_default = /*#__PURE__*/__webpack_require__.n(showdown);
  12853. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/markdown-converter.js
  12854. /**
  12855. * External dependencies
  12856. */
  12857. // Reuse the same showdown converter.
  12858. const converter = new (showdown_default()).Converter({
  12859. noHeaderId: true,
  12860. tables: true,
  12861. literalMidWordUnderscores: true,
  12862. omitExtraWLInCodeBlocks: true,
  12863. simpleLineBreaks: true,
  12864. strikethrough: true
  12865. });
  12866. /**
  12867. * Corrects the Slack Markdown variant of the code block.
  12868. * If uncorrected, it will be converted to inline code.
  12869. *
  12870. * @see https://get.slack.help/hc/en-us/articles/202288908-how-can-i-add-formatting-to-my-messages-#code-blocks
  12871. *
  12872. * @param {string} text The potential Markdown text to correct.
  12873. *
  12874. * @return {string} The corrected Markdown.
  12875. */
  12876. function slackMarkdownVariantCorrector(text) {
  12877. return text.replace(/((?:^|\n)```)([^\n`]+)(```(?:$|\n))/, (match, p1, p2, p3) => `${p1}\n${p2}\n${p3}`);
  12878. }
  12879. /**
  12880. * Converts a piece of text into HTML based on any Markdown present.
  12881. * Also decodes any encoded HTML.
  12882. *
  12883. * @param {string} text The plain text to convert.
  12884. *
  12885. * @return {string} HTML.
  12886. */
  12887. function markdownConverter(text) {
  12888. return converter.makeHtml(slackMarkdownVariantCorrector(text));
  12889. }
  12890. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/iframe-remover.js
  12891. /**
  12892. * Removes iframes.
  12893. *
  12894. * @param {Node} node The node to check.
  12895. *
  12896. * @return {void}
  12897. */
  12898. function iframeRemover(node) {
  12899. if (node.nodeName === 'IFRAME') {
  12900. const text = node.ownerDocument.createTextNode(node.src);
  12901. node.parentNode.replaceChild(text, node);
  12902. }
  12903. }
  12904. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/google-docs-uid-remover.js
  12905. /**
  12906. * WordPress dependencies
  12907. */
  12908. function googleDocsUIdRemover(node) {
  12909. if (!node.id || node.id.indexOf('docs-internal-guid-') !== 0) {
  12910. return;
  12911. }
  12912. (0,external_wp_dom_namespaceObject.unwrap)(node);
  12913. }
  12914. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/html-formatting-remover.js
  12915. /**
  12916. * Internal dependencies
  12917. */
  12918. function isFormattingSpace(character) {
  12919. return character === ' ' || character === '\r' || character === '\n' || character === '\t';
  12920. }
  12921. /**
  12922. * Removes spacing that formats HTML.
  12923. *
  12924. * @see https://www.w3.org/TR/css-text-3/#white-space-processing
  12925. *
  12926. * @param {Node} node The node to be processed.
  12927. * @return {void}
  12928. */
  12929. function htmlFormattingRemover(node) {
  12930. if (node.nodeType !== node.TEXT_NODE) {
  12931. return;
  12932. } // Ignore pre content. Note that this does not use Element#closest due to
  12933. // a combination of (a) node may not be Element and (b) node.parentElement
  12934. // does not have full support in all browsers (Internet Exporer).
  12935. //
  12936. // See: https://developer.mozilla.org/en-US/docs/Web/API/Node/parentElement#Browser_compatibility
  12937. /** @type {Node?} */
  12938. let parent = node;
  12939. while (parent = parent.parentNode) {
  12940. if (parent.nodeType === parent.ELEMENT_NODE && parent.nodeName === 'PRE') {
  12941. return;
  12942. }
  12943. } // First, replace any sequence of HTML formatting space with a single space.
  12944. let newData = node.data.replace(/[ \r\n\t]+/g, ' '); // Remove the leading space if the text element is at the start of a block,
  12945. // is preceded by a line break element, or has a space in the previous
  12946. // node.
  12947. if (newData[0] === ' ') {
  12948. const previousSibling = getSibling(node, 'previous');
  12949. if (!previousSibling || previousSibling.nodeName === 'BR' || previousSibling.textContent.slice(-1) === ' ') {
  12950. newData = newData.slice(1);
  12951. }
  12952. } // Remove the trailing space if the text element is at the end of a block,
  12953. // is succeded by a line break element, or has a space in the next text
  12954. // node.
  12955. if (newData[newData.length - 1] === ' ') {
  12956. const nextSibling = getSibling(node, 'next');
  12957. if (!nextSibling || nextSibling.nodeName === 'BR' || nextSibling.nodeType === nextSibling.TEXT_NODE && isFormattingSpace(nextSibling.textContent[0])) {
  12958. newData = newData.slice(0, -1);
  12959. }
  12960. } // If there's no data left, remove the node, so `previousSibling` stays
  12961. // accurate. Otherwise, update the node data.
  12962. if (!newData) {
  12963. node.parentNode.removeChild(node);
  12964. } else {
  12965. node.data = newData;
  12966. }
  12967. }
  12968. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/br-remover.js
  12969. /**
  12970. * Internal dependencies
  12971. */
  12972. /**
  12973. * Removes trailing br elements from text-level content.
  12974. *
  12975. * @param {Element} node Node to check.
  12976. */
  12977. function brRemover(node) {
  12978. if (node.nodeName !== 'BR') {
  12979. return;
  12980. }
  12981. if (getSibling(node, 'next')) {
  12982. return;
  12983. }
  12984. node.parentNode.removeChild(node);
  12985. }
  12986. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/empty-paragraph-remover.js
  12987. /**
  12988. * Removes empty paragraph elements.
  12989. *
  12990. * @param {Element} node Node to check.
  12991. */
  12992. function emptyParagraphRemover(node) {
  12993. if (node.nodeName !== 'P') {
  12994. return;
  12995. }
  12996. if (node.hasChildNodes()) {
  12997. return;
  12998. }
  12999. node.parentNode.removeChild(node);
  13000. }
  13001. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/slack-paragraph-corrector.js
  13002. /**
  13003. * Replaces Slack paragraph markup with a double line break (later converted to
  13004. * a proper paragraph).
  13005. *
  13006. * @param {Element} node Node to check.
  13007. */
  13008. function slackParagraphCorrector(node) {
  13009. if (node.nodeName !== 'SPAN') {
  13010. return;
  13011. }
  13012. if (node.getAttribute('data-stringify-type') !== 'paragraph-break') {
  13013. return;
  13014. }
  13015. const {
  13016. parentNode
  13017. } = node;
  13018. parentNode.insertBefore(node.ownerDocument.createElement('br'), node);
  13019. parentNode.insertBefore(node.ownerDocument.createElement('br'), node);
  13020. parentNode.removeChild(node);
  13021. }
  13022. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/paste-handler.js
  13023. /**
  13024. * WordPress dependencies
  13025. */
  13026. /**
  13027. * Internal dependencies
  13028. */
  13029. /**
  13030. * Browser dependencies
  13031. */
  13032. const {
  13033. console: paste_handler_console
  13034. } = window;
  13035. /**
  13036. * Filters HTML to only contain phrasing content.
  13037. *
  13038. * @param {string} HTML The HTML to filter.
  13039. * @param {boolean} preserveWhiteSpace Whether or not to preserve consequent white space.
  13040. *
  13041. * @return {string} HTML only containing phrasing content.
  13042. */
  13043. function filterInlineHTML(HTML, preserveWhiteSpace) {
  13044. HTML = deepFilterHTML(HTML, [googleDocsUIdRemover, phrasingContentReducer, commentRemover]);
  13045. HTML = (0,external_wp_dom_namespaceObject.removeInvalidHTML)(HTML, (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)('paste'), {
  13046. inline: true
  13047. });
  13048. if (!preserveWhiteSpace) {
  13049. HTML = deepFilterHTML(HTML, [htmlFormattingRemover, brRemover]);
  13050. } // Allows us to ask for this information when we get a report.
  13051. paste_handler_console.log('Processed inline HTML:\n\n', HTML);
  13052. return HTML;
  13053. }
  13054. /**
  13055. * Converts an HTML string to known blocks. Strips everything else.
  13056. *
  13057. * @param {Object} options
  13058. * @param {string} [options.HTML] The HTML to convert.
  13059. * @param {string} [options.plainText] Plain text version.
  13060. * @param {string} [options.mode] Handle content as blocks or inline content.
  13061. * * 'AUTO': Decide based on the content passed.
  13062. * * 'INLINE': Always handle as inline content, and return string.
  13063. * * 'BLOCKS': Always handle as blocks, and return array of blocks.
  13064. * @param {Array} [options.tagName] The tag into which content will be inserted.
  13065. * @param {boolean} [options.preserveWhiteSpace] Whether or not to preserve consequent white space.
  13066. *
  13067. * @return {Array|string} A list of blocks or a string, depending on `handlerMode`.
  13068. */
  13069. function pasteHandler(_ref) {
  13070. let {
  13071. HTML = '',
  13072. plainText = '',
  13073. mode = 'AUTO',
  13074. tagName,
  13075. preserveWhiteSpace
  13076. } = _ref;
  13077. // First of all, strip any meta tags.
  13078. HTML = HTML.replace(/<meta[^>]+>/g, ''); // Strip Windows markers.
  13079. HTML = HTML.replace(/^\s*<html[^>]*>\s*<body[^>]*>(?:\s*<!--\s*StartFragment\s*-->)?/i, '');
  13080. HTML = HTML.replace(/(?:<!--\s*EndFragment\s*-->\s*)?<\/body>\s*<\/html>\s*$/i, ''); // If we detect block delimiters in HTML, parse entirely as blocks.
  13081. if (mode !== 'INLINE') {
  13082. // Check plain text if there is no HTML.
  13083. const content = HTML ? HTML : plainText;
  13084. if (content.indexOf('<!-- wp:') !== -1) {
  13085. return parser_parse(content);
  13086. }
  13087. } // Normalize unicode to use composed characters.
  13088. // This is unsupported in IE 11 but it's a nice-to-have feature, not mandatory.
  13089. // Not normalizing the content will only affect older browsers and won't
  13090. // entirely break the app.
  13091. // See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
  13092. // See: https://core.trac.wordpress.org/ticket/30130
  13093. // See: https://github.com/WordPress/gutenberg/pull/6983#pullrequestreview-125151075
  13094. if (String.prototype.normalize) {
  13095. HTML = HTML.normalize();
  13096. } // Parse Markdown (and encoded HTML) if:
  13097. // * There is a plain text version.
  13098. // * There is no HTML version, or it has no formatting.
  13099. if (plainText && (!HTML || isPlain(HTML))) {
  13100. HTML = plainText; // The markdown converter (Showdown) trims whitespace.
  13101. if (!/^\s+$/.test(plainText)) {
  13102. HTML = markdownConverter(HTML);
  13103. } // Switch to inline mode if:
  13104. // * The current mode is AUTO.
  13105. // * The original plain text had no line breaks.
  13106. // * The original plain text was not an HTML paragraph.
  13107. // * The converted text is just a paragraph.
  13108. if (mode === 'AUTO' && plainText.indexOf('\n') === -1 && plainText.indexOf('<p>') !== 0 && HTML.indexOf('<p>') === 0) {
  13109. mode = 'INLINE';
  13110. }
  13111. }
  13112. if (mode === 'INLINE') {
  13113. return filterInlineHTML(HTML, preserveWhiteSpace);
  13114. } // Must be run before checking if it's inline content.
  13115. HTML = deepFilterHTML(HTML, [slackParagraphCorrector]); // An array of HTML strings and block objects. The blocks replace matched
  13116. // shortcodes.
  13117. const pieces = shortcode_converter(HTML); // The call to shortcodeConverter will always return more than one element
  13118. // if shortcodes are matched. The reason is when shortcodes are matched
  13119. // empty HTML strings are included.
  13120. const hasShortcodes = pieces.length > 1;
  13121. if (mode === 'AUTO' && !hasShortcodes && isInlineContent(HTML, tagName)) {
  13122. return filterInlineHTML(HTML, preserveWhiteSpace);
  13123. }
  13124. const phrasingContentSchema = (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)('paste');
  13125. const blockContentSchema = getBlockContentSchema('paste');
  13126. const blocks = pieces.map(piece => {
  13127. // Already a block from shortcode.
  13128. if (typeof piece !== 'string') {
  13129. return piece;
  13130. }
  13131. const filters = [googleDocsUIdRemover, msListConverter, headRemover, listReducer, imageCorrector, phrasingContentReducer, specialCommentConverter, commentRemover, iframeRemover, figureContentReducer, blockquoteNormaliser, divNormaliser];
  13132. const schema = { ...blockContentSchema,
  13133. // Keep top-level phrasing content, normalised by `normaliseBlocks`.
  13134. ...phrasingContentSchema
  13135. };
  13136. piece = deepFilterHTML(piece, filters, blockContentSchema);
  13137. piece = (0,external_wp_dom_namespaceObject.removeInvalidHTML)(piece, schema);
  13138. piece = normaliseBlocks(piece);
  13139. piece = deepFilterHTML(piece, [htmlFormattingRemover, brRemover, emptyParagraphRemover], blockContentSchema); // Allows us to ask for this information when we get a report.
  13140. paste_handler_console.log('Processed HTML piece:\n\n', piece);
  13141. return htmlToBlocks(piece, pasteHandler);
  13142. }).flat().filter(Boolean); // If we're allowed to return inline content, and there is only one
  13143. // inlineable block, and the original plain text content does not have any
  13144. // line breaks, then treat it as inline paste.
  13145. if (mode === 'AUTO' && blocks.length === 1 && hasBlockSupport(blocks[0].name, '__unstablePasteTextInline', false)) {
  13146. const trimRegex = /^[\n]+|[\n]+$/g; // Don't catch line breaks at the start or end.
  13147. const trimmedPlainText = plainText.replace(trimRegex, '');
  13148. if (trimmedPlainText !== '' && trimmedPlainText.indexOf('\n') === -1) {
  13149. return (0,external_wp_dom_namespaceObject.removeInvalidHTML)(getBlockInnerHTML(blocks[0]), phrasingContentSchema).replace(trimRegex, '');
  13150. }
  13151. }
  13152. return blocks;
  13153. }
  13154. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/categories.js
  13155. /**
  13156. * WordPress dependencies
  13157. */
  13158. /**
  13159. * Internal dependencies
  13160. */
  13161. /** @typedef {import('../store/reducer').WPBlockCategory} WPBlockCategory */
  13162. /**
  13163. * Returns all the block categories.
  13164. * Ignored from documentation as the recommended usage is via useSelect from @wordpress/data.
  13165. *
  13166. * @ignore
  13167. *
  13168. * @return {WPBlockCategory[]} Block categories.
  13169. */
  13170. function categories_getCategories() {
  13171. return (0,external_wp_data_namespaceObject.select)(store).getCategories();
  13172. }
  13173. /**
  13174. * Sets the block categories.
  13175. *
  13176. * @param {WPBlockCategory[]} categories Block categories.
  13177. *
  13178. * @example
  13179. * ```js
  13180. * import { __ } from '@wordpress/i18n';
  13181. * import { store as blocksStore, setCategories } from '@wordpress/blocks';
  13182. * import { useSelect } from '@wordpress/data';
  13183. * import { Button } from '@wordpress/components';
  13184. *
  13185. * const ExampleComponent = () => {
  13186. * // Retrieve the list of current categories.
  13187. * const blockCategories = useSelect(
  13188. * ( select ) => select( blocksStore ).getCategories(),
  13189. * []
  13190. * );
  13191. *
  13192. * return (
  13193. * <Button
  13194. * onClick={ () => {
  13195. * // Add a custom category to the existing list.
  13196. * setCategories( [
  13197. * ...blockCategories,
  13198. * { title: 'Custom Category', slug: 'custom-category' },
  13199. * ] );
  13200. * } }
  13201. * >
  13202. * { __( 'Add a new custom block category' ) }
  13203. * </Button>
  13204. * );
  13205. * };
  13206. * ```
  13207. */
  13208. function categories_setCategories(categories) {
  13209. (0,external_wp_data_namespaceObject.dispatch)(store).setCategories(categories);
  13210. }
  13211. /**
  13212. * Updates a category.
  13213. *
  13214. * @param {string} slug Block category slug.
  13215. * @param {WPBlockCategory} category Object containing the category properties
  13216. * that should be updated.
  13217. *
  13218. * @example
  13219. * ```js
  13220. * import { __ } from '@wordpress/i18n';
  13221. * import { updateCategory } from '@wordpress/blocks';
  13222. * import { Button } from '@wordpress/components';
  13223. *
  13224. * const ExampleComponent = () => {
  13225. * return (
  13226. * <Button
  13227. * onClick={ () => {
  13228. * updateCategory( 'text', { title: __( 'Written Word' ) } );
  13229. * } }
  13230. * >
  13231. * { __( 'Update Text category title' ) }
  13232. * </Button>
  13233. * ) ;
  13234. * };
  13235. * ```
  13236. */
  13237. function categories_updateCategory(slug, category) {
  13238. (0,external_wp_data_namespaceObject.dispatch)(store).updateCategory(slug, category);
  13239. }
  13240. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/templates.js
  13241. /**
  13242. * WordPress dependencies
  13243. */
  13244. /**
  13245. * Internal dependencies
  13246. */
  13247. /**
  13248. * Checks whether a list of blocks matches a template by comparing the block names.
  13249. *
  13250. * @param {Array} blocks Block list.
  13251. * @param {Array} template Block template.
  13252. *
  13253. * @return {boolean} Whether the list of blocks matches a templates.
  13254. */
  13255. function doBlocksMatchTemplate() {
  13256. let blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  13257. let template = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  13258. return blocks.length === template.length && template.every((_ref, index) => {
  13259. let [name,, innerBlocksTemplate] = _ref;
  13260. const block = blocks[index];
  13261. return name === block.name && doBlocksMatchTemplate(block.innerBlocks, innerBlocksTemplate);
  13262. });
  13263. }
  13264. /**
  13265. * Synchronize a block list with a block template.
  13266. *
  13267. * Synchronizing a block list with a block template means that we loop over the blocks
  13268. * keep the block as is if it matches the block at the same position in the template
  13269. * (If it has the same name) and if doesn't match, we create a new block based on the template.
  13270. * Extra blocks not present in the template are removed.
  13271. *
  13272. * @param {Array} blocks Block list.
  13273. * @param {Array} template Block template.
  13274. *
  13275. * @return {Array} Updated Block list.
  13276. */
  13277. function synchronizeBlocksWithTemplate() {
  13278. let blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  13279. let template = arguments.length > 1 ? arguments[1] : undefined;
  13280. // If no template is provided, return blocks unmodified.
  13281. if (!template) {
  13282. return blocks;
  13283. }
  13284. return template.map((_ref2, index) => {
  13285. var _blockType$attributes;
  13286. let [name, attributes, innerBlocksTemplate] = _ref2;
  13287. const block = blocks[index];
  13288. if (block && block.name === name) {
  13289. const innerBlocks = synchronizeBlocksWithTemplate(block.innerBlocks, innerBlocksTemplate);
  13290. return { ...block,
  13291. innerBlocks
  13292. };
  13293. } // To support old templates that were using the "children" format
  13294. // for the attributes using "html" strings now, we normalize the template attributes
  13295. // before creating the blocks.
  13296. const blockType = getBlockType(name);
  13297. const isHTMLAttribute = attributeDefinition => (attributeDefinition === null || attributeDefinition === void 0 ? void 0 : attributeDefinition.source) === 'html';
  13298. const isQueryAttribute = attributeDefinition => (attributeDefinition === null || attributeDefinition === void 0 ? void 0 : attributeDefinition.source) === 'query';
  13299. const normalizeAttributes = (schema, values) => {
  13300. if (!values) {
  13301. return {};
  13302. }
  13303. return Object.fromEntries(Object.entries(values).map(_ref3 => {
  13304. let [key, value] = _ref3;
  13305. return [key, normalizeAttribute(schema[key], value)];
  13306. }));
  13307. };
  13308. const normalizeAttribute = (definition, value) => {
  13309. if (isHTMLAttribute(definition) && Array.isArray(value)) {
  13310. // Introduce a deprecated call at this point
  13311. // When we're confident that "children" format should be removed from the templates.
  13312. return (0,external_wp_element_namespaceObject.renderToString)(value);
  13313. }
  13314. if (isQueryAttribute(definition) && value) {
  13315. return value.map(subValues => {
  13316. return normalizeAttributes(definition.query, subValues);
  13317. });
  13318. }
  13319. return value;
  13320. };
  13321. const normalizedAttributes = normalizeAttributes((_blockType$attributes = blockType === null || blockType === void 0 ? void 0 : blockType.attributes) !== null && _blockType$attributes !== void 0 ? _blockType$attributes : {}, attributes);
  13322. let [blockName, blockAttributes] = convertLegacyBlockNameAndAttributes(name, normalizedAttributes); // If a Block is undefined at this point, use the core/missing block as
  13323. // a placeholder for a better user experience.
  13324. if (undefined === getBlockType(blockName)) {
  13325. blockAttributes = {
  13326. originalName: name,
  13327. originalContent: '',
  13328. originalUndelimitedContent: ''
  13329. };
  13330. blockName = 'core/missing';
  13331. }
  13332. return createBlock(blockName, blockAttributes, synchronizeBlocksWithTemplate([], innerBlocksTemplate));
  13333. });
  13334. }
  13335. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/index.js
  13336. // The blocktype is the most important concept within the block API. It defines
  13337. // all aspects of the block configuration and its interfaces, including `edit`
  13338. // and `save`. The transforms specification allows converting one blocktype to
  13339. // another through formulas defined by either the source or the destination.
  13340. // Switching a blocktype is to be considered a one-way operation implying a
  13341. // transformation in the opposite way has to be handled explicitly.
  13342. // The block tree is composed of a collection of block nodes. Blocks contained
  13343. // within other blocks are called inner blocks. An important design
  13344. // consideration is that inner blocks are -- conceptually -- not part of the
  13345. // territory established by the parent block that contains them.
  13346. //
  13347. // This has multiple practical implications: when parsing, we can safely dispose
  13348. // of any block boundary found within a block from the innerHTML property when
  13349. // transfering to state. Not doing so would have a compounding effect on memory
  13350. // and uncertainty over the source of truth. This can be illustrated in how,
  13351. // given a tree of `n` nested blocks, the entry node would have to contain the
  13352. // actual content of each block while each subsequent block node in the state
  13353. // tree would replicate the entire chain `n-1`, meaning the extreme end node
  13354. // would have been replicated `n` times as the tree is traversed and would
  13355. // generate uncertainty as to which one is to hold the current value of the
  13356. // block. For composition, it also means inner blocks can effectively be child
  13357. // components whose mechanisms can be shielded from the `edit` implementation
  13358. // and just passed along.
  13359. // While block transformations account for a specific surface of the API, there
  13360. // are also raw transformations which handle arbitrary sources not made out of
  13361. // blocks but producing block basaed on various heursitics. This includes
  13362. // pasting rich text or HTML data.
  13363. // The process of serialization aims to deflate the internal memory of the block
  13364. // editor and its state representation back into an HTML valid string. This
  13365. // process restores the document integrity and inserts invisible delimiters
  13366. // around each block with HTML comment boundaries which can contain any extra
  13367. // attributes needed to operate with the block later on.
  13368. // Validation is the process of comparing a block source with its output before
  13369. // there is any user input or interaction with a block. When this operation
  13370. // fails -- for whatever reason -- the block is to be considered invalid. As
  13371. // part of validating a block the system will attempt to run the source against
  13372. // any provided deprecation definitions.
  13373. //
  13374. // Worth emphasizing that validation is not a case of whether the markup is
  13375. // merely HTML spec-compliant but about how the editor knows to create such
  13376. // markup and that its inability to create an identical result can be a strong
  13377. // indicator of potential data loss (the invalidation is then a protective
  13378. // measure).
  13379. //
  13380. // The invalidation process can also be deconstructed in phases: 1) validate the
  13381. // block exists; 2) validate the source matches the output; 3) validate the
  13382. // source matches deprecated outputs; 4) work through the significance of
  13383. // differences. These are stacked in a way that favors performance and optimizes
  13384. // for the majority of cases. That is to say, the evaluation logic can become
  13385. // more sophisticated the further down it goes in the process as the cost is
  13386. // accounted for. The first logic checks have to be extremely efficient since
  13387. // they will be run for all valid and invalid blocks alike. However, once a
  13388. // block is detected as invalid -- failing the three first steps -- it is
  13389. // adequate to spend more time determining validity before throwing a conflict.
  13390. // Blocks are inherently indifferent about where the data they operate with ends
  13391. // up being saved. For example, all blocks can have a static and dynamic aspect
  13392. // to them depending on the needs. The static nature of a block is the `save()`
  13393. // definition that is meant to be serialized into HTML and which can be left
  13394. // void. Any block can also register a `render_callback` on the server, which
  13395. // makes its output dynamic either in part or in its totality.
  13396. //
  13397. // Child blocks are defined as a relationship that builds on top of the inner
  13398. // blocks mechanism. A child block is a block node of a particular type that can
  13399. // only exist within the inner block boundaries of a specific parent type. This
  13400. // allows block authors to compose specific blocks that are not meant to be used
  13401. // outside of a specified parent block context. Thus, child blocks extend the
  13402. // concept of inner blocks to support a more direct relationship between sets of
  13403. // blocks. The addition of parent–child would be a subset of the inner block
  13404. // functionality under the premise that certain blocks only make sense as
  13405. // children of another block.
  13406. // Templates are, in a general sense, a basic collection of block nodes with any
  13407. // given set of predefined attributes that are supplied as the initial state of
  13408. // an inner blocks group. These nodes can, in turn, contain any number of nested
  13409. // blocks within their definition. Templates allow both to specify a default
  13410. // state for an editor session or a default set of blocks for any inner block
  13411. // implementation within a specific block.
  13412. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/deprecated.js
  13413. /**
  13414. * WordPress dependencies
  13415. */
  13416. /**
  13417. * A Higher Order Component used to inject BlockContent using context to the
  13418. * wrapped component.
  13419. *
  13420. * @deprecated
  13421. *
  13422. * @param {WPComponent} OriginalComponent The component to enhance.
  13423. * @return {WPComponent} The same component.
  13424. */
  13425. function withBlockContentContext(OriginalComponent) {
  13426. external_wp_deprecated_default()('wp.blocks.withBlockContentContext', {
  13427. since: '6.1'
  13428. });
  13429. return OriginalComponent;
  13430. }
  13431. ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/index.js
  13432. // A "block" is the abstract term used to describe units of markup that,
  13433. // when composed together, form the content or layout of a page.
  13434. // The API for blocks is exposed via `wp.blocks`.
  13435. //
  13436. // Supported blocks are registered by calling `registerBlockType`. Once registered,
  13437. // the block is made available as an option to the editor interface.
  13438. //
  13439. // Blocks are inferred from the HTML source of a post through a parsing mechanism
  13440. // and then stored as objects in state, from which it is then rendered for editing.
  13441. }();
  13442. (window.wp = window.wp || {}).blocks = __webpack_exports__;
  13443. /******/ })()
  13444. ;