Нет описания

block-editor.js 1.2MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085
  1. this["wp"] = this["wp"] || {}; this["wp"]["blockEditor"] =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41. /******/ }
  42. /******/ };
  43. /******/
  44. /******/ // define __esModule on exports
  45. /******/ __webpack_require__.r = function(exports) {
  46. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48. /******/ }
  49. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  50. /******/ };
  51. /******/
  52. /******/ // create a fake namespace object
  53. /******/ // mode & 1: value is a module id, require it
  54. /******/ // mode & 2: merge all properties of value into the ns
  55. /******/ // mode & 4: return value when already ns object
  56. /******/ // mode & 8|1: behave like require
  57. /******/ __webpack_require__.t = function(value, mode) {
  58. /******/ if(mode & 1) value = __webpack_require__(value);
  59. /******/ if(mode & 8) return value;
  60. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61. /******/ var ns = Object.create(null);
  62. /******/ __webpack_require__.r(ns);
  63. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65. /******/ return ns;
  66. /******/ };
  67. /******/
  68. /******/ // getDefaultExport function for compatibility with non-harmony modules
  69. /******/ __webpack_require__.n = function(module) {
  70. /******/ var getter = module && module.__esModule ?
  71. /******/ function getDefault() { return module['default']; } :
  72. /******/ function getModuleExports() { return module; };
  73. /******/ __webpack_require__.d(getter, 'a', getter);
  74. /******/ return getter;
  75. /******/ };
  76. /******/
  77. /******/ // Object.prototype.hasOwnProperty.call
  78. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79. /******/
  80. /******/ // __webpack_public_path__
  81. /******/ __webpack_require__.p = "";
  82. /******/
  83. /******/
  84. /******/ // Load entry module and return exports
  85. /******/ return __webpack_require__(__webpack_require__.s = "tr0p");
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ "//Lo":
  90. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91. "use strict";
  92. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  93. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  94. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  95. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  96. /**
  97. * WordPress dependencies
  98. */
  99. const blockDefault = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  100. xmlns: "http://www.w3.org/2000/svg",
  101. viewBox: "0 0 24 24"
  102. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  103. d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z"
  104. }));
  105. /* harmony default export */ __webpack_exports__["a"] = (blockDefault);
  106. /***/ }),
  107. /***/ "16Al":
  108. /***/ (function(module, exports, __webpack_require__) {
  109. "use strict";
  110. /**
  111. * Copyright (c) 2013-present, Facebook, Inc.
  112. *
  113. * This source code is licensed under the MIT license found in the
  114. * LICENSE file in the root directory of this source tree.
  115. */
  116. var ReactPropTypesSecret = __webpack_require__("WbBG");
  117. function emptyFunction() {}
  118. function emptyFunctionWithReset() {}
  119. emptyFunctionWithReset.resetWarningCache = emptyFunction;
  120. module.exports = function() {
  121. function shim(props, propName, componentName, location, propFullName, secret) {
  122. if (secret === ReactPropTypesSecret) {
  123. // It is still safe when called from React.
  124. return;
  125. }
  126. var err = new Error(
  127. 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
  128. 'Use PropTypes.checkPropTypes() to call them. ' +
  129. 'Read more at http://fb.me/use-check-prop-types'
  130. );
  131. err.name = 'Invariant Violation';
  132. throw err;
  133. };
  134. shim.isRequired = shim;
  135. function getShim() {
  136. return shim;
  137. };
  138. // Important!
  139. // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
  140. var ReactPropTypes = {
  141. array: shim,
  142. bool: shim,
  143. func: shim,
  144. number: shim,
  145. object: shim,
  146. string: shim,
  147. symbol: shim,
  148. any: shim,
  149. arrayOf: getShim,
  150. element: shim,
  151. elementType: shim,
  152. instanceOf: getShim,
  153. node: shim,
  154. objectOf: getShim,
  155. oneOf: getShim,
  156. oneOfType: getShim,
  157. shape: getShim,
  158. exact: getShim,
  159. checkPropTypes: emptyFunctionWithReset,
  160. resetWarningCache: emptyFunction
  161. };
  162. ReactPropTypes.PropTypes = ReactPropTypes;
  163. return ReactPropTypes;
  164. };
  165. /***/ }),
  166. /***/ "17x9":
  167. /***/ (function(module, exports, __webpack_require__) {
  168. /**
  169. * Copyright (c) 2013-present, Facebook, Inc.
  170. *
  171. * This source code is licensed under the MIT license found in the
  172. * LICENSE file in the root directory of this source tree.
  173. */
  174. if (false) { var throwOnDirectAccess, ReactIs; } else {
  175. // By explicitly using `prop-types` you are opting into new production behavior.
  176. // http://fb.me/prop-types-in-prod
  177. module.exports = __webpack_require__("16Al")();
  178. }
  179. /***/ }),
  180. /***/ "1CF3":
  181. /***/ (function(module, exports) {
  182. (function() { module.exports = window["wp"]["dom"]; }());
  183. /***/ }),
  184. /***/ "1ZqX":
  185. /***/ (function(module, exports) {
  186. (function() { module.exports = window["wp"]["data"]; }());
  187. /***/ }),
  188. /***/ "1iEr":
  189. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  190. "use strict";
  191. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  192. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  193. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  194. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  195. /**
  196. * WordPress dependencies
  197. */
  198. const chevronRight = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  199. xmlns: "http://www.w3.org/2000/svg",
  200. viewBox: "0 0 24 24"
  201. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  202. d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"
  203. }));
  204. /* harmony default export */ __webpack_exports__["a"] = (chevronRight);
  205. /***/ }),
  206. /***/ "2gm7":
  207. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  208. "use strict";
  209. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  210. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  211. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  212. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  213. /**
  214. * WordPress dependencies
  215. */
  216. const chevronLeft = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  217. xmlns: "http://www.w3.org/2000/svg",
  218. viewBox: "0 0 24 24"
  219. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  220. d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z"
  221. }));
  222. /* harmony default export */ __webpack_exports__["a"] = (chevronLeft);
  223. /***/ }),
  224. /***/ "4eJC":
  225. /***/ (function(module, exports, __webpack_require__) {
  226. /**
  227. * Memize options object.
  228. *
  229. * @typedef MemizeOptions
  230. *
  231. * @property {number} [maxSize] Maximum size of the cache.
  232. */
  233. /**
  234. * Internal cache entry.
  235. *
  236. * @typedef MemizeCacheNode
  237. *
  238. * @property {?MemizeCacheNode|undefined} [prev] Previous node.
  239. * @property {?MemizeCacheNode|undefined} [next] Next node.
  240. * @property {Array<*>} args Function arguments for cache
  241. * entry.
  242. * @property {*} val Function result.
  243. */
  244. /**
  245. * Properties of the enhanced function for controlling cache.
  246. *
  247. * @typedef MemizeMemoizedFunction
  248. *
  249. * @property {()=>void} clear Clear the cache.
  250. */
  251. /**
  252. * Accepts a function to be memoized, and returns a new memoized function, with
  253. * optional options.
  254. *
  255. * @template {Function} F
  256. *
  257. * @param {F} fn Function to memoize.
  258. * @param {MemizeOptions} [options] Options object.
  259. *
  260. * @return {F & MemizeMemoizedFunction} Memoized function.
  261. */
  262. function memize( fn, options ) {
  263. var size = 0;
  264. /** @type {?MemizeCacheNode|undefined} */
  265. var head;
  266. /** @type {?MemizeCacheNode|undefined} */
  267. var tail;
  268. options = options || {};
  269. function memoized( /* ...args */ ) {
  270. var node = head,
  271. len = arguments.length,
  272. args, i;
  273. searchCache: while ( node ) {
  274. // Perform a shallow equality test to confirm that whether the node
  275. // under test is a candidate for the arguments passed. Two arrays
  276. // are shallowly equal if their length matches and each entry is
  277. // strictly equal between the two sets. Avoid abstracting to a
  278. // function which could incur an arguments leaking deoptimization.
  279. // Check whether node arguments match arguments length
  280. if ( node.args.length !== arguments.length ) {
  281. node = node.next;
  282. continue;
  283. }
  284. // Check whether node arguments match arguments values
  285. for ( i = 0; i < len; i++ ) {
  286. if ( node.args[ i ] !== arguments[ i ] ) {
  287. node = node.next;
  288. continue searchCache;
  289. }
  290. }
  291. // At this point we can assume we've found a match
  292. // Surface matched node to head if not already
  293. if ( node !== head ) {
  294. // As tail, shift to previous. Must only shift if not also
  295. // head, since if both head and tail, there is no previous.
  296. if ( node === tail ) {
  297. tail = node.prev;
  298. }
  299. // Adjust siblings to point to each other. If node was tail,
  300. // this also handles new tail's empty `next` assignment.
  301. /** @type {MemizeCacheNode} */ ( node.prev ).next = node.next;
  302. if ( node.next ) {
  303. node.next.prev = node.prev;
  304. }
  305. node.next = head;
  306. node.prev = null;
  307. /** @type {MemizeCacheNode} */ ( head ).prev = node;
  308. head = node;
  309. }
  310. // Return immediately
  311. return node.val;
  312. }
  313. // No cached value found. Continue to insertion phase:
  314. // Create a copy of arguments (avoid leaking deoptimization)
  315. args = new Array( len );
  316. for ( i = 0; i < len; i++ ) {
  317. args[ i ] = arguments[ i ];
  318. }
  319. node = {
  320. args: args,
  321. // Generate the result from original function
  322. val: fn.apply( null, args ),
  323. };
  324. // Don't need to check whether node is already head, since it would
  325. // have been returned above already if it was
  326. // Shift existing head down list
  327. if ( head ) {
  328. head.prev = node;
  329. node.next = head;
  330. } else {
  331. // If no head, follows that there's no tail (at initial or reset)
  332. tail = node;
  333. }
  334. // Trim tail if we're reached max size and are pending cache insertion
  335. if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) {
  336. tail = /** @type {MemizeCacheNode} */ ( tail ).prev;
  337. /** @type {MemizeCacheNode} */ ( tail ).next = null;
  338. } else {
  339. size++;
  340. }
  341. head = node;
  342. return node.val;
  343. }
  344. memoized.clear = function() {
  345. head = null;
  346. tail = null;
  347. size = 0;
  348. };
  349. if ( false ) {}
  350. // Ignore reason: There's not a clear solution to create an intersection of
  351. // the function with additional properties, where the goal is to retain the
  352. // function signature of the incoming argument and add control properties
  353. // on the return value.
  354. // @ts-ignore
  355. return memoized;
  356. }
  357. module.exports = memize;
  358. /***/ }),
  359. /***/ "6fKw":
  360. /***/ (function(module, exports, __webpack_require__) {
  361. "use strict";
  362. /*
  363. Copyright (c) 2014, Yahoo! Inc. All rights reserved.
  364. Copyrights licensed under the New BSD License.
  365. See the accompanying LICENSE file for terms.
  366. */
  367. exports.match = matchQuery;
  368. exports.parse = parseQuery;
  369. // -----------------------------------------------------------------------------
  370. var RE_MEDIA_QUERY = /(?:(only|not)?\s*([^\s\(\)]+)(?:\s*and)?\s*)?(.+)?/i,
  371. RE_MQ_EXPRESSION = /\(\s*([^\s\:\)]+)\s*(?:\:\s*([^\s\)]+))?\s*\)/,
  372. RE_MQ_FEATURE = /^(?:(min|max)-)?(.+)/,
  373. RE_LENGTH_UNIT = /(em|rem|px|cm|mm|in|pt|pc)?$/,
  374. RE_RESOLUTION_UNIT = /(dpi|dpcm|dppx)?$/;
  375. function matchQuery(mediaQuery, values) {
  376. return parseQuery(mediaQuery).some(function (query) {
  377. var inverse = query.inverse;
  378. // Either the parsed or specified `type` is "all", or the types must be
  379. // equal for a match.
  380. var typeMatch = query.type === 'all' || values.type === query.type;
  381. // Quit early when `type` doesn't match, but take "not" into account.
  382. if ((typeMatch && inverse) || !(typeMatch || inverse)) {
  383. return false;
  384. }
  385. var expressionsMatch = query.expressions.every(function (expression) {
  386. var feature = expression.feature,
  387. modifier = expression.modifier,
  388. expValue = expression.value,
  389. value = values[feature];
  390. // Missing or falsy values don't match.
  391. if (!value) { return false; }
  392. switch (feature) {
  393. case 'orientation':
  394. case 'scan':
  395. return value.toLowerCase() === expValue.toLowerCase();
  396. case 'width':
  397. case 'height':
  398. case 'device-width':
  399. case 'device-height':
  400. expValue = toPx(expValue);
  401. value = toPx(value);
  402. break;
  403. case 'resolution':
  404. expValue = toDpi(expValue);
  405. value = toDpi(value);
  406. break;
  407. case 'aspect-ratio':
  408. case 'device-aspect-ratio':
  409. case /* Deprecated */ 'device-pixel-ratio':
  410. expValue = toDecimal(expValue);
  411. value = toDecimal(value);
  412. break;
  413. case 'grid':
  414. case 'color':
  415. case 'color-index':
  416. case 'monochrome':
  417. expValue = parseInt(expValue, 10) || 1;
  418. value = parseInt(value, 10) || 0;
  419. break;
  420. }
  421. switch (modifier) {
  422. case 'min': return value >= expValue;
  423. case 'max': return value <= expValue;
  424. default : return value === expValue;
  425. }
  426. });
  427. return (expressionsMatch && !inverse) || (!expressionsMatch && inverse);
  428. });
  429. }
  430. function parseQuery(mediaQuery) {
  431. return mediaQuery.split(',').map(function (query) {
  432. query = query.trim();
  433. var captures = query.match(RE_MEDIA_QUERY),
  434. modifier = captures[1],
  435. type = captures[2],
  436. expressions = captures[3] || '',
  437. parsed = {};
  438. parsed.inverse = !!modifier && modifier.toLowerCase() === 'not';
  439. parsed.type = type ? type.toLowerCase() : 'all';
  440. // Split expressions into a list.
  441. expressions = expressions.match(/\([^\)]+\)/g) || [];
  442. parsed.expressions = expressions.map(function (expression) {
  443. var captures = expression.match(RE_MQ_EXPRESSION),
  444. feature = captures[1].toLowerCase().match(RE_MQ_FEATURE);
  445. return {
  446. modifier: feature[1],
  447. feature : feature[2],
  448. value : captures[2]
  449. };
  450. });
  451. return parsed;
  452. });
  453. }
  454. // -- Utilities ----------------------------------------------------------------
  455. function toDecimal(ratio) {
  456. var decimal = Number(ratio),
  457. numbers;
  458. if (!decimal) {
  459. numbers = ratio.match(/^(\d+)\s*\/\s*(\d+)$/);
  460. decimal = numbers[1] / numbers[2];
  461. }
  462. return decimal;
  463. }
  464. function toDpi(resolution) {
  465. var value = parseFloat(resolution),
  466. units = String(resolution).match(RE_RESOLUTION_UNIT)[1];
  467. switch (units) {
  468. case 'dpcm': return value / 2.54;
  469. case 'dppx': return value * 96;
  470. default : return value;
  471. }
  472. }
  473. function toPx(length) {
  474. var value = parseFloat(length),
  475. units = String(length).match(RE_LENGTH_UNIT)[1];
  476. switch (units) {
  477. case 'em' : return value * 16;
  478. case 'rem': return value * 16;
  479. case 'cm' : return value * 96 / 2.54;
  480. case 'mm' : return value * 96 / 2.54 / 10;
  481. case 'in' : return value * 96;
  482. case 'pt' : return value * 72;
  483. case 'pc' : return value * 72 / 12;
  484. default : return value;
  485. }
  486. }
  487. /***/ }),
  488. /***/ "7fqt":
  489. /***/ (function(module, exports) {
  490. (function() { module.exports = window["wp"]["wordcount"]; }());
  491. /***/ }),
  492. /***/ "8OQS":
  493. /***/ (function(module, exports) {
  494. function _objectWithoutPropertiesLoose(source, excluded) {
  495. if (source == null) return {};
  496. var target = {};
  497. var sourceKeys = Object.keys(source);
  498. var key, i;
  499. for (i = 0; i < sourceKeys.length; i++) {
  500. key = sourceKeys[i];
  501. if (excluded.indexOf(key) >= 0) continue;
  502. target[key] = source[key];
  503. }
  504. return target;
  505. }
  506. module.exports = _objectWithoutPropertiesLoose;
  507. module.exports["default"] = module.exports, module.exports.__esModule = true;
  508. /***/ }),
  509. /***/ "9Do8":
  510. /***/ (function(module, exports, __webpack_require__) {
  511. "use strict";
  512. module.exports = __webpack_require__("zt9T");
  513. /***/ }),
  514. /***/ "B9Az":
  515. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  516. "use strict";
  517. // EXTERNAL MODULE: external ["wp","element"]
  518. var external_wp_element_ = __webpack_require__("GRId");
  519. // EXTERNAL MODULE: external ["wp","primitives"]
  520. var external_wp_primitives_ = __webpack_require__("Tqx9");
  521. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/pencil.js
  522. /**
  523. * WordPress dependencies
  524. */
  525. const pencil = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
  526. xmlns: "http://www.w3.org/2000/svg",
  527. viewBox: "0 0 24 24"
  528. }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
  529. d: "M20.1 5.1L16.9 2 6.2 12.7l-1.3 4.4 4.5-1.3L20.1 5.1zM4 20.8h8v-1.5H4v1.5z"
  530. }));
  531. /* harmony default export */ var library_pencil = (pencil);
  532. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/edit.js
  533. /**
  534. * Internal dependencies
  535. */
  536. /* harmony default export */ var edit = __webpack_exports__["a"] = (library_pencil);
  537. /***/ }),
  538. /***/ "BLeD":
  539. /***/ (function(module, exports) {
  540. (function() { module.exports = window["wp"]["tokenList"]; }());
  541. /***/ }),
  542. /***/ "Bpkj":
  543. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  544. "use strict";
  545. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  546. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  547. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  548. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  549. /**
  550. * WordPress dependencies
  551. */
  552. const link = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  553. xmlns: "http://www.w3.org/2000/svg",
  554. viewBox: "0 0 24 24"
  555. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  556. d: "M15.6 7.2H14v1.5h1.6c2 0 3.7 1.7 3.7 3.7s-1.7 3.7-3.7 3.7H14v1.5h1.6c2.8 0 5.2-2.3 5.2-5.2 0-2.9-2.3-5.2-5.2-5.2zM4.7 12.4c0-2 1.7-3.7 3.7-3.7H10V7.2H8.4c-2.9 0-5.2 2.3-5.2 5.2 0 2.9 2.3 5.2 5.2 5.2H10v-1.5H8.4c-2 0-3.7-1.7-3.7-3.7zm4.6.9h5.3v-1.5H9.3v1.5z"
  557. }));
  558. /* harmony default export */ __webpack_exports__["a"] = (link);
  559. /***/ }),
  560. /***/ "CNgt":
  561. /***/ (function(module, exports, __webpack_require__) {
  562. "use strict";
  563. var __extends = (this && this.__extends) || (function () {
  564. var extendStatics = Object.setPrototypeOf ||
  565. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  566. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  567. return function (d, b) {
  568. extendStatics(d, b);
  569. function __() { this.constructor = d; }
  570. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  571. };
  572. })();
  573. var __assign = (this && this.__assign) || Object.assign || function(t) {
  574. for (var s, i = 1, n = arguments.length; i < n; i++) {
  575. s = arguments[i];
  576. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  577. t[p] = s[p];
  578. }
  579. return t;
  580. };
  581. var __rest = (this && this.__rest) || function (s, e) {
  582. var t = {};
  583. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  584. t[p] = s[p];
  585. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  586. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  587. t[p[i]] = s[p[i]];
  588. return t;
  589. };
  590. exports.__esModule = true;
  591. var React = __webpack_require__("cDcd");
  592. var PropTypes = __webpack_require__("17x9");
  593. var autosize = __webpack_require__("GemG");
  594. var _getLineHeight = __webpack_require__("Rk8H");
  595. var getLineHeight = _getLineHeight;
  596. var RESIZED = "autosize:resized";
  597. /**
  598. * A light replacement for built-in textarea component
  599. * which automaticaly adjusts its height to match the content
  600. */
  601. var TextareaAutosizeClass = /** @class */ (function (_super) {
  602. __extends(TextareaAutosizeClass, _super);
  603. function TextareaAutosizeClass() {
  604. var _this = _super !== null && _super.apply(this, arguments) || this;
  605. _this.state = {
  606. lineHeight: null
  607. };
  608. _this.textarea = null;
  609. _this.onResize = function (e) {
  610. if (_this.props.onResize) {
  611. _this.props.onResize(e);
  612. }
  613. };
  614. _this.updateLineHeight = function () {
  615. if (_this.textarea) {
  616. _this.setState({
  617. lineHeight: getLineHeight(_this.textarea)
  618. });
  619. }
  620. };
  621. _this.onChange = function (e) {
  622. var onChange = _this.props.onChange;
  623. _this.currentValue = e.currentTarget.value;
  624. onChange && onChange(e);
  625. };
  626. return _this;
  627. }
  628. TextareaAutosizeClass.prototype.componentDidMount = function () {
  629. var _this = this;
  630. var _a = this.props, maxRows = _a.maxRows, async = _a.async;
  631. if (typeof maxRows === "number") {
  632. this.updateLineHeight();
  633. }
  634. if (typeof maxRows === "number" || async) {
  635. /*
  636. the defer is needed to:
  637. - force "autosize" to activate the scrollbar when this.props.maxRows is passed
  638. - support StyledComponents (see #71)
  639. */
  640. setTimeout(function () { return _this.textarea && autosize(_this.textarea); });
  641. }
  642. else {
  643. this.textarea && autosize(this.textarea);
  644. }
  645. if (this.textarea) {
  646. this.textarea.addEventListener(RESIZED, this.onResize);
  647. }
  648. };
  649. TextareaAutosizeClass.prototype.componentWillUnmount = function () {
  650. if (this.textarea) {
  651. this.textarea.removeEventListener(RESIZED, this.onResize);
  652. autosize.destroy(this.textarea);
  653. }
  654. };
  655. TextareaAutosizeClass.prototype.render = function () {
  656. var _this = this;
  657. var _a = this, _b = _a.props, onResize = _b.onResize, maxRows = _b.maxRows, onChange = _b.onChange, style = _b.style, innerRef = _b.innerRef, children = _b.children, props = __rest(_b, ["onResize", "maxRows", "onChange", "style", "innerRef", "children"]), lineHeight = _a.state.lineHeight;
  658. var maxHeight = maxRows && lineHeight ? lineHeight * maxRows : null;
  659. return (React.createElement("textarea", __assign({}, props, { onChange: this.onChange, style: maxHeight ? __assign({}, style, { maxHeight: maxHeight }) : style, ref: function (element) {
  660. _this.textarea = element;
  661. if (typeof _this.props.innerRef === 'function') {
  662. _this.props.innerRef(element);
  663. }
  664. else if (_this.props.innerRef) {
  665. _this.props.innerRef.current = element;
  666. }
  667. } }), children));
  668. };
  669. TextareaAutosizeClass.prototype.componentDidUpdate = function () {
  670. this.textarea && autosize.update(this.textarea);
  671. };
  672. TextareaAutosizeClass.defaultProps = {
  673. rows: 1,
  674. async: false
  675. };
  676. TextareaAutosizeClass.propTypes = {
  677. rows: PropTypes.number,
  678. maxRows: PropTypes.number,
  679. onResize: PropTypes.func,
  680. innerRef: PropTypes.any,
  681. async: PropTypes.bool
  682. };
  683. return TextareaAutosizeClass;
  684. }(React.Component));
  685. exports.TextareaAutosize = React.forwardRef(function (props, ref) {
  686. return React.createElement(TextareaAutosizeClass, __assign({}, props, { innerRef: ref }));
  687. });
  688. /***/ }),
  689. /***/ "Civd":
  690. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  691. "use strict";
  692. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  693. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  694. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  695. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  696. /**
  697. * WordPress dependencies
  698. */
  699. const layout = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  700. xmlns: "http://www.w3.org/2000/svg",
  701. viewBox: "0 0 24 24"
  702. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  703. d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
  704. }));
  705. /* harmony default export */ __webpack_exports__["a"] = (layout);
  706. /***/ }),
  707. /***/ "Crq9":
  708. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  709. "use strict";
  710. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  711. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  712. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  713. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  714. /**
  715. * WordPress dependencies
  716. */
  717. const formatStrikethrough = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  718. xmlns: "http://www.w3.org/2000/svg",
  719. viewBox: "0 0 24 24"
  720. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  721. d: "M9.1 9v-.5c0-.6.2-1.1.7-1.4.5-.3 1.2-.5 2-.5.7 0 1.4.1 2.1.3.7.2 1.4.5 2.1.9l.2-1.9c-.6-.3-1.2-.5-1.9-.7-.8-.1-1.6-.2-2.4-.2-1.5 0-2.7.3-3.6 1-.8.7-1.2 1.5-1.2 2.6V9h2zM20 12H4v1h8.3c.3.1.6.2.8.3.5.2.9.5 1.1.8.3.3.4.7.4 1.2 0 .7-.2 1.1-.8 1.5-.5.3-1.2.5-2.1.5-.8 0-1.6-.1-2.4-.3-.8-.2-1.5-.5-2.2-.8L7 18.1c.5.2 1.2.4 2 .6.8.2 1.6.3 2.4.3 1.7 0 3-.3 3.9-1 .9-.7 1.3-1.6 1.3-2.8 0-.9-.2-1.7-.7-2.2H20v-1z"
  722. }));
  723. /* harmony default export */ __webpack_exports__["a"] = (formatStrikethrough);
  724. /***/ }),
  725. /***/ "GRId":
  726. /***/ (function(module, exports) {
  727. (function() { module.exports = window["wp"]["element"]; }());
  728. /***/ }),
  729. /***/ "GemG":
  730. /***/ (function(module, exports, __webpack_require__) {
  731. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  732. autosize 4.0.4
  733. license: MIT
  734. http://www.jacklmoore.com/autosize
  735. */
  736. (function (global, factory) {
  737. if (true) {
  738. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
  739. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  740. (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
  741. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  742. } else { var mod; }
  743. })(this, function (module, exports) {
  744. 'use strict';
  745. var map = typeof Map === "function" ? new Map() : function () {
  746. var keys = [];
  747. var values = [];
  748. return {
  749. has: function has(key) {
  750. return keys.indexOf(key) > -1;
  751. },
  752. get: function get(key) {
  753. return values[keys.indexOf(key)];
  754. },
  755. set: function set(key, value) {
  756. if (keys.indexOf(key) === -1) {
  757. keys.push(key);
  758. values.push(value);
  759. }
  760. },
  761. delete: function _delete(key) {
  762. var index = keys.indexOf(key);
  763. if (index > -1) {
  764. keys.splice(index, 1);
  765. values.splice(index, 1);
  766. }
  767. }
  768. };
  769. }();
  770. var createEvent = function createEvent(name) {
  771. return new Event(name, { bubbles: true });
  772. };
  773. try {
  774. new Event('test');
  775. } catch (e) {
  776. // IE does not support `new Event()`
  777. createEvent = function createEvent(name) {
  778. var evt = document.createEvent('Event');
  779. evt.initEvent(name, true, false);
  780. return evt;
  781. };
  782. }
  783. function assign(ta) {
  784. if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || map.has(ta)) return;
  785. var heightOffset = null;
  786. var clientWidth = null;
  787. var cachedHeight = null;
  788. function init() {
  789. var style = window.getComputedStyle(ta, null);
  790. if (style.resize === 'vertical') {
  791. ta.style.resize = 'none';
  792. } else if (style.resize === 'both') {
  793. ta.style.resize = 'horizontal';
  794. }
  795. if (style.boxSizing === 'content-box') {
  796. heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom));
  797. } else {
  798. heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
  799. }
  800. // Fix when a textarea is not on document body and heightOffset is Not a Number
  801. if (isNaN(heightOffset)) {
  802. heightOffset = 0;
  803. }
  804. update();
  805. }
  806. function changeOverflow(value) {
  807. {
  808. // Chrome/Safari-specific fix:
  809. // When the textarea y-overflow is hidden, Chrome/Safari do not reflow the text to account for the space
  810. // made available by removing the scrollbar. The following forces the necessary text reflow.
  811. var width = ta.style.width;
  812. ta.style.width = '0px';
  813. // Force reflow:
  814. /* jshint ignore:start */
  815. ta.offsetWidth;
  816. /* jshint ignore:end */
  817. ta.style.width = width;
  818. }
  819. ta.style.overflowY = value;
  820. }
  821. function getParentOverflows(el) {
  822. var arr = [];
  823. while (el && el.parentNode && el.parentNode instanceof Element) {
  824. if (el.parentNode.scrollTop) {
  825. arr.push({
  826. node: el.parentNode,
  827. scrollTop: el.parentNode.scrollTop
  828. });
  829. }
  830. el = el.parentNode;
  831. }
  832. return arr;
  833. }
  834. function resize() {
  835. if (ta.scrollHeight === 0) {
  836. // If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM.
  837. return;
  838. }
  839. var overflows = getParentOverflows(ta);
  840. var docTop = document.documentElement && document.documentElement.scrollTop; // Needed for Mobile IE (ticket #240)
  841. ta.style.height = '';
  842. ta.style.height = ta.scrollHeight + heightOffset + 'px';
  843. // used to check if an update is actually necessary on window.resize
  844. clientWidth = ta.clientWidth;
  845. // prevents scroll-position jumping
  846. overflows.forEach(function (el) {
  847. el.node.scrollTop = el.scrollTop;
  848. });
  849. if (docTop) {
  850. document.documentElement.scrollTop = docTop;
  851. }
  852. }
  853. function update() {
  854. resize();
  855. var styleHeight = Math.round(parseFloat(ta.style.height));
  856. var computed = window.getComputedStyle(ta, null);
  857. // Using offsetHeight as a replacement for computed.height in IE, because IE does not account use of border-box
  858. var actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(computed.height)) : ta.offsetHeight;
  859. // The actual height not matching the style height (set via the resize method) indicates that
  860. // the max-height has been exceeded, in which case the overflow should be allowed.
  861. if (actualHeight < styleHeight) {
  862. if (computed.overflowY === 'hidden') {
  863. changeOverflow('scroll');
  864. resize();
  865. actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
  866. }
  867. } else {
  868. // Normally keep overflow set to hidden, to avoid flash of scrollbar as the textarea expands.
  869. if (computed.overflowY !== 'hidden') {
  870. changeOverflow('hidden');
  871. resize();
  872. actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
  873. }
  874. }
  875. if (cachedHeight !== actualHeight) {
  876. cachedHeight = actualHeight;
  877. var evt = createEvent('autosize:resized');
  878. try {
  879. ta.dispatchEvent(evt);
  880. } catch (err) {
  881. // Firefox will throw an error on dispatchEvent for a detached element
  882. // https://bugzilla.mozilla.org/show_bug.cgi?id=889376
  883. }
  884. }
  885. }
  886. var pageResize = function pageResize() {
  887. if (ta.clientWidth !== clientWidth) {
  888. update();
  889. }
  890. };
  891. var destroy = function (style) {
  892. window.removeEventListener('resize', pageResize, false);
  893. ta.removeEventListener('input', update, false);
  894. ta.removeEventListener('keyup', update, false);
  895. ta.removeEventListener('autosize:destroy', destroy, false);
  896. ta.removeEventListener('autosize:update', update, false);
  897. Object.keys(style).forEach(function (key) {
  898. ta.style[key] = style[key];
  899. });
  900. map.delete(ta);
  901. }.bind(ta, {
  902. height: ta.style.height,
  903. resize: ta.style.resize,
  904. overflowY: ta.style.overflowY,
  905. overflowX: ta.style.overflowX,
  906. wordWrap: ta.style.wordWrap
  907. });
  908. ta.addEventListener('autosize:destroy', destroy, false);
  909. // IE9 does not fire onpropertychange or oninput for deletions,
  910. // so binding to onkeyup to catch most of those events.
  911. // There is no way that I know of to detect something like 'cut' in IE9.
  912. if ('onpropertychange' in ta && 'oninput' in ta) {
  913. ta.addEventListener('keyup', update, false);
  914. }
  915. window.addEventListener('resize', pageResize, false);
  916. ta.addEventListener('input', update, false);
  917. ta.addEventListener('autosize:update', update, false);
  918. ta.style.overflowX = 'hidden';
  919. ta.style.wordWrap = 'break-word';
  920. map.set(ta, {
  921. destroy: destroy,
  922. update: update
  923. });
  924. init();
  925. }
  926. function destroy(ta) {
  927. var methods = map.get(ta);
  928. if (methods) {
  929. methods.destroy();
  930. }
  931. }
  932. function update(ta) {
  933. var methods = map.get(ta);
  934. if (methods) {
  935. methods.update();
  936. }
  937. }
  938. var autosize = null;
  939. // Do nothing in Node.js environment and IE8 (or lower)
  940. if (typeof window === 'undefined' || typeof window.getComputedStyle !== 'function') {
  941. autosize = function autosize(el) {
  942. return el;
  943. };
  944. autosize.destroy = function (el) {
  945. return el;
  946. };
  947. autosize.update = function (el) {
  948. return el;
  949. };
  950. } else {
  951. autosize = function autosize(el, options) {
  952. if (el) {
  953. Array.prototype.forEach.call(el.length ? el : [el], function (x) {
  954. return assign(x, options);
  955. });
  956. }
  957. return el;
  958. };
  959. autosize.destroy = function (el) {
  960. if (el) {
  961. Array.prototype.forEach.call(el.length ? el : [el], destroy);
  962. }
  963. return el;
  964. };
  965. autosize.update = function (el) {
  966. if (el) {
  967. Array.prototype.forEach.call(el.length ? el : [el], update);
  968. }
  969. return el;
  970. };
  971. }
  972. exports.default = autosize;
  973. module.exports = exports['default'];
  974. });
  975. /***/ }),
  976. /***/ "HSyU":
  977. /***/ (function(module, exports) {
  978. (function() { module.exports = window["wp"]["blocks"]; }());
  979. /***/ }),
  980. /***/ "K9lf":
  981. /***/ (function(module, exports) {
  982. (function() { module.exports = window["wp"]["compose"]; }());
  983. /***/ }),
  984. /***/ "Mmq9":
  985. /***/ (function(module, exports) {
  986. (function() { module.exports = window["wp"]["url"]; }());
  987. /***/ }),
  988. /***/ "NMb1":
  989. /***/ (function(module, exports) {
  990. (function() { module.exports = window["wp"]["deprecated"]; }());
  991. /***/ }),
  992. /***/ "NTP4":
  993. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  994. "use strict";
  995. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  996. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  997. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  998. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  999. /**
  1000. * WordPress dependencies
  1001. */
  1002. const upload = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  1003. xmlns: "http://www.w3.org/2000/svg",
  1004. viewBox: "0 0 24 24"
  1005. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  1006. d: "M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z"
  1007. }));
  1008. /* harmony default export */ __webpack_exports__["a"] = (upload);
  1009. /***/ }),
  1010. /***/ "NWDH":
  1011. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1012. "use strict";
  1013. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  1014. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  1015. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  1016. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  1017. /**
  1018. * WordPress dependencies
  1019. */
  1020. const chevronDown = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  1021. viewBox: "0 0 24 24",
  1022. xmlns: "http://www.w3.org/2000/svg"
  1023. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  1024. d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"
  1025. }));
  1026. /* harmony default export */ __webpack_exports__["a"] = (chevronDown);
  1027. /***/ }),
  1028. /***/ "O6Fj":
  1029. /***/ (function(module, exports, __webpack_require__) {
  1030. "use strict";
  1031. exports.__esModule = true;
  1032. var TextareaAutosize_1 = __webpack_require__("CNgt");
  1033. exports["default"] = TextareaAutosize_1.TextareaAutosize;
  1034. /***/ }),
  1035. /***/ "OzlF":
  1036. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1037. "use strict";
  1038. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  1039. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  1040. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  1041. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  1042. /**
  1043. * WordPress dependencies
  1044. */
  1045. const listView = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  1046. viewBox: "0 0 24 24",
  1047. xmlns: "http://www.w3.org/2000/svg"
  1048. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  1049. d: "M13.8 5.2H3v1.5h10.8V5.2zm-3.6 12v1.5H21v-1.5H10.2zm7.2-6H6.6v1.5h10.8v-1.5z"
  1050. }));
  1051. /* harmony default export */ __webpack_exports__["a"] = (listView);
  1052. /***/ }),
  1053. /***/ "P7XM":
  1054. /***/ (function(module, exports) {
  1055. if (typeof Object.create === 'function') {
  1056. // implementation from standard node.js 'util' module
  1057. module.exports = function inherits(ctor, superCtor) {
  1058. if (superCtor) {
  1059. ctor.super_ = superCtor
  1060. ctor.prototype = Object.create(superCtor.prototype, {
  1061. constructor: {
  1062. value: ctor,
  1063. enumerable: false,
  1064. writable: true,
  1065. configurable: true
  1066. }
  1067. })
  1068. }
  1069. };
  1070. } else {
  1071. // old school shim for old browsers
  1072. module.exports = function inherits(ctor, superCtor) {
  1073. if (superCtor) {
  1074. ctor.super_ = superCtor
  1075. var TempCtor = function () {}
  1076. TempCtor.prototype = superCtor.prototype
  1077. ctor.prototype = new TempCtor()
  1078. ctor.prototype.constructor = ctor
  1079. }
  1080. }
  1081. }
  1082. /***/ }),
  1083. /***/ "PJYZ":
  1084. /***/ (function(module, exports) {
  1085. function _assertThisInitialized(self) {
  1086. if (self === void 0) {
  1087. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  1088. }
  1089. return self;
  1090. }
  1091. module.exports = _assertThisInitialized;
  1092. module.exports["default"] = module.exports, module.exports.__esModule = true;
  1093. /***/ }),
  1094. /***/ "Q4Sy":
  1095. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1096. "use strict";
  1097. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  1098. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  1099. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  1100. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  1101. /**
  1102. * WordPress dependencies
  1103. */
  1104. const plus = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  1105. xmlns: "http://www.w3.org/2000/svg",
  1106. viewBox: "0 0 24 24"
  1107. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  1108. d: "M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"
  1109. }));
  1110. /* harmony default export */ __webpack_exports__["a"] = (plus);
  1111. /***/ }),
  1112. /***/ "RMJe":
  1113. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1114. "use strict";
  1115. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  1116. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  1117. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  1118. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  1119. /**
  1120. * WordPress dependencies
  1121. */
  1122. const check = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  1123. xmlns: "http://www.w3.org/2000/svg",
  1124. viewBox: "0 0 24 24"
  1125. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  1126. d: "M18.3 5.6L9.9 16.9l-4.6-3.4-.9 1.2 5.8 4.3 9.3-12.6z"
  1127. }));
  1128. /* harmony default export */ __webpack_exports__["a"] = (check);
  1129. /***/ }),
  1130. /***/ "Rk8H":
  1131. /***/ (function(module, exports, __webpack_require__) {
  1132. // Load in dependencies
  1133. var computedStyle = __webpack_require__("jTPX");
  1134. /**
  1135. * Calculate the `line-height` of a given node
  1136. * @param {HTMLElement} node Element to calculate line height of. Must be in the DOM.
  1137. * @returns {Number} `line-height` of the element in pixels
  1138. */
  1139. function lineHeight(node) {
  1140. // Grab the line-height via style
  1141. var lnHeightStr = computedStyle(node, 'line-height');
  1142. var lnHeight = parseFloat(lnHeightStr, 10);
  1143. // If the lineHeight did not contain a unit (i.e. it was numeric), convert it to ems (e.g. '2.3' === '2.3em')
  1144. if (lnHeightStr === lnHeight + '') {
  1145. // Save the old lineHeight style and update the em unit to the element
  1146. var _lnHeightStyle = node.style.lineHeight;
  1147. node.style.lineHeight = lnHeightStr + 'em';
  1148. // Calculate the em based height
  1149. lnHeightStr = computedStyle(node, 'line-height');
  1150. lnHeight = parseFloat(lnHeightStr, 10);
  1151. // Revert the lineHeight style
  1152. if (_lnHeightStyle) {
  1153. node.style.lineHeight = _lnHeightStyle;
  1154. } else {
  1155. delete node.style.lineHeight;
  1156. }
  1157. }
  1158. // If the lineHeight is in `pt`, convert it to pixels (4px for 3pt)
  1159. // DEV: `em` units are converted to `pt` in IE6
  1160. // Conversion ratio from https://developer.mozilla.org/en-US/docs/Web/CSS/length
  1161. if (lnHeightStr.indexOf('pt') !== -1) {
  1162. lnHeight *= 4;
  1163. lnHeight /= 3;
  1164. // Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm)
  1165. } else if (lnHeightStr.indexOf('mm') !== -1) {
  1166. lnHeight *= 96;
  1167. lnHeight /= 25.4;
  1168. // Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm)
  1169. } else if (lnHeightStr.indexOf('cm') !== -1) {
  1170. lnHeight *= 96;
  1171. lnHeight /= 2.54;
  1172. // Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in)
  1173. } else if (lnHeightStr.indexOf('in') !== -1) {
  1174. lnHeight *= 96;
  1175. // Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc)
  1176. } else if (lnHeightStr.indexOf('pc') !== -1) {
  1177. lnHeight *= 16;
  1178. }
  1179. // Continue our computation
  1180. lnHeight = Math.round(lnHeight);
  1181. // If the line-height is "normal", calculate by font-size
  1182. if (lnHeightStr === 'normal') {
  1183. // Create a temporary node
  1184. var nodeName = node.nodeName;
  1185. var _node = document.createElement(nodeName);
  1186. _node.innerHTML = '&nbsp;';
  1187. // If we have a text area, reset it to only 1 row
  1188. // https://github.com/twolfson/line-height/issues/4
  1189. if (nodeName.toUpperCase() === 'TEXTAREA') {
  1190. _node.setAttribute('rows', '1');
  1191. }
  1192. // Set the font-size of the element
  1193. var fontSizeStr = computedStyle(node, 'font-size');
  1194. _node.style.fontSize = fontSizeStr;
  1195. // Remove default padding/border which can affect offset height
  1196. // https://github.com/twolfson/line-height/issues/4
  1197. // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight
  1198. _node.style.padding = '0px';
  1199. _node.style.border = '0px';
  1200. // Append it to the body
  1201. var body = document.body;
  1202. body.appendChild(_node);
  1203. // Assume the line height of the element is the height
  1204. var height = _node.offsetHeight;
  1205. lnHeight = height;
  1206. // Remove our child from the DOM
  1207. body.removeChild(_node);
  1208. }
  1209. // Return the calculated height
  1210. return lnHeight;
  1211. }
  1212. // Export lineHeight
  1213. module.exports = lineHeight;
  1214. /***/ }),
  1215. /***/ "RxS6":
  1216. /***/ (function(module, exports) {
  1217. (function() { module.exports = window["wp"]["keycodes"]; }());
  1218. /***/ }),
  1219. /***/ "SVSp":
  1220. /***/ (function(module, exports) {
  1221. (function() { module.exports = window["wp"]["shortcode"]; }());
  1222. /***/ }),
  1223. /***/ "SksO":
  1224. /***/ (function(module, exports) {
  1225. function _setPrototypeOf(o, p) {
  1226. module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  1227. o.__proto__ = p;
  1228. return o;
  1229. };
  1230. module.exports["default"] = module.exports, module.exports.__esModule = true;
  1231. return _setPrototypeOf(o, p);
  1232. }
  1233. module.exports = _setPrototypeOf;
  1234. module.exports["default"] = module.exports, module.exports.__esModule = true;
  1235. /***/ }),
  1236. /***/ "TSYQ":
  1237. /***/ (function(module, exports, __webpack_require__) {
  1238. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  1239. Copyright (c) 2018 Jed Watson.
  1240. Licensed under the MIT License (MIT), see
  1241. http://jedwatson.github.io/classnames
  1242. */
  1243. /* global define */
  1244. (function () {
  1245. 'use strict';
  1246. var hasOwn = {}.hasOwnProperty;
  1247. function classNames() {
  1248. var classes = [];
  1249. for (var i = 0; i < arguments.length; i++) {
  1250. var arg = arguments[i];
  1251. if (!arg) continue;
  1252. var argType = typeof arg;
  1253. if (argType === 'string' || argType === 'number') {
  1254. classes.push(arg);
  1255. } else if (Array.isArray(arg)) {
  1256. if (arg.length) {
  1257. var inner = classNames.apply(null, arg);
  1258. if (inner) {
  1259. classes.push(inner);
  1260. }
  1261. }
  1262. } else if (argType === 'object') {
  1263. if (arg.toString === Object.prototype.toString) {
  1264. for (var key in arg) {
  1265. if (hasOwn.call(arg, key) && arg[key]) {
  1266. classes.push(key);
  1267. }
  1268. }
  1269. } else {
  1270. classes.push(arg.toString());
  1271. }
  1272. }
  1273. }
  1274. return classes.join(' ');
  1275. }
  1276. if ( true && module.exports) {
  1277. classNames.default = classNames;
  1278. module.exports = classNames;
  1279. } else if (true) {
  1280. // register as 'classnames', consistent with npm package name
  1281. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
  1282. return classNames;
  1283. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  1284. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  1285. } else {}
  1286. }());
  1287. /***/ }),
  1288. /***/ "Tqx9":
  1289. /***/ (function(module, exports) {
  1290. (function() { module.exports = window["wp"]["primitives"]; }());
  1291. /***/ }),
  1292. /***/ "VKE3":
  1293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1294. "use strict";
  1295. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  1296. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  1297. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  1298. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  1299. /**
  1300. * WordPress dependencies
  1301. */
  1302. const moreVertical = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  1303. xmlns: "http://www.w3.org/2000/svg",
  1304. viewBox: "0 0 24 24"
  1305. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  1306. d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"
  1307. }));
  1308. /* harmony default export */ __webpack_exports__["a"] = (moreVertical);
  1309. /***/ }),
  1310. /***/ "VbXa":
  1311. /***/ (function(module, exports, __webpack_require__) {
  1312. var setPrototypeOf = __webpack_require__("SksO");
  1313. function _inheritsLoose(subClass, superClass) {
  1314. subClass.prototype = Object.create(superClass.prototype);
  1315. subClass.prototype.constructor = subClass;
  1316. setPrototypeOf(subClass, superClass);
  1317. }
  1318. module.exports = _inheritsLoose;
  1319. module.exports["default"] = module.exports, module.exports.__esModule = true;
  1320. /***/ }),
  1321. /***/ "WbBG":
  1322. /***/ (function(module, exports, __webpack_require__) {
  1323. "use strict";
  1324. /**
  1325. * Copyright (c) 2013-present, Facebook, Inc.
  1326. *
  1327. * This source code is licensed under the MIT license found in the
  1328. * LICENSE file in the root directory of this source tree.
  1329. */
  1330. var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  1331. module.exports = ReactPropTypesSecret;
  1332. /***/ }),
  1333. /***/ "XgzB":
  1334. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1335. "use strict";
  1336. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  1337. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  1338. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  1339. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  1340. /**
  1341. * WordPress dependencies
  1342. */
  1343. const chevronUp = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  1344. viewBox: "0 0 24 24",
  1345. xmlns: "http://www.w3.org/2000/svg"
  1346. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  1347. d: "M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"
  1348. }));
  1349. /* harmony default export */ __webpack_exports__["a"] = (chevronUp);
  1350. /***/ }),
  1351. /***/ "YLtl":
  1352. /***/ (function(module, exports) {
  1353. (function() { module.exports = window["lodash"]; }());
  1354. /***/ }),
  1355. /***/ "ZO3Q":
  1356. /***/ (function(module, exports, __webpack_require__) {
  1357. "use strict";
  1358. Object.defineProperty(exports, '__esModule', { value: true });
  1359. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  1360. var _extends = _interopDefault(__webpack_require__("pVnL"));
  1361. var _objectWithoutPropertiesLoose = _interopDefault(__webpack_require__("8OQS"));
  1362. var React = __webpack_require__("cDcd");
  1363. var React__default = _interopDefault(React);
  1364. var _inheritsLoose = _interopDefault(__webpack_require__("VbXa"));
  1365. var _assertThisInitialized = _interopDefault(__webpack_require__("PJYZ"));
  1366. var is = {
  1367. arr: Array.isArray,
  1368. obj: function obj(a) {
  1369. return Object.prototype.toString.call(a) === '[object Object]';
  1370. },
  1371. fun: function fun(a) {
  1372. return typeof a === 'function';
  1373. },
  1374. str: function str(a) {
  1375. return typeof a === 'string';
  1376. },
  1377. num: function num(a) {
  1378. return typeof a === 'number';
  1379. },
  1380. und: function und(a) {
  1381. return a === void 0;
  1382. },
  1383. nul: function nul(a) {
  1384. return a === null;
  1385. },
  1386. set: function set(a) {
  1387. return a instanceof Set;
  1388. },
  1389. map: function map(a) {
  1390. return a instanceof Map;
  1391. },
  1392. equ: function equ(a, b) {
  1393. if (typeof a !== typeof b) return false;
  1394. if (is.str(a) || is.num(a)) return a === b;
  1395. if (is.obj(a) && is.obj(b) && Object.keys(a).length + Object.keys(b).length === 0) return true;
  1396. var i;
  1397. for (i in a) {
  1398. if (!(i in b)) return false;
  1399. }
  1400. for (i in b) {
  1401. if (a[i] !== b[i]) return false;
  1402. }
  1403. return is.und(i) ? a === b : true;
  1404. }
  1405. };
  1406. function merge(target, lowercase) {
  1407. if (lowercase === void 0) {
  1408. lowercase = true;
  1409. }
  1410. return function (object) {
  1411. return (is.arr(object) ? object : Object.keys(object)).reduce(function (acc, element) {
  1412. var key = lowercase ? element[0].toLowerCase() + element.substring(1) : element;
  1413. acc[key] = target(key);
  1414. return acc;
  1415. }, target);
  1416. };
  1417. }
  1418. function useForceUpdate() {
  1419. var _useState = React.useState(false),
  1420. f = _useState[1];
  1421. var forceUpdate = React.useCallback(function () {
  1422. return f(function (v) {
  1423. return !v;
  1424. });
  1425. }, []);
  1426. return forceUpdate;
  1427. }
  1428. function withDefault(value, defaultValue) {
  1429. return is.und(value) || is.nul(value) ? defaultValue : value;
  1430. }
  1431. function toArray(a) {
  1432. return !is.und(a) ? is.arr(a) ? a : [a] : [];
  1433. }
  1434. function callProp(obj) {
  1435. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1436. args[_key - 1] = arguments[_key];
  1437. }
  1438. return is.fun(obj) ? obj.apply(void 0, args) : obj;
  1439. }
  1440. function getForwardProps(props) {
  1441. var to = props.to,
  1442. from = props.from,
  1443. config = props.config,
  1444. onStart = props.onStart,
  1445. onRest = props.onRest,
  1446. onFrame = props.onFrame,
  1447. children = props.children,
  1448. reset = props.reset,
  1449. reverse = props.reverse,
  1450. force = props.force,
  1451. immediate = props.immediate,
  1452. delay = props.delay,
  1453. attach = props.attach,
  1454. destroyed = props.destroyed,
  1455. interpolateTo = props.interpolateTo,
  1456. ref = props.ref,
  1457. lazy = props.lazy,
  1458. forward = _objectWithoutPropertiesLoose(props, ["to", "from", "config", "onStart", "onRest", "onFrame", "children", "reset", "reverse", "force", "immediate", "delay", "attach", "destroyed", "interpolateTo", "ref", "lazy"]);
  1459. return forward;
  1460. }
  1461. function interpolateTo(props) {
  1462. var forward = getForwardProps(props);
  1463. if (is.und(forward)) return _extends({
  1464. to: forward
  1465. }, props);
  1466. var rest = Object.keys(props).reduce(function (a, k) {
  1467. var _extends2;
  1468. return !is.und(forward[k]) ? a : _extends({}, a, (_extends2 = {}, _extends2[k] = props[k], _extends2));
  1469. }, {});
  1470. return _extends({
  1471. to: forward
  1472. }, rest);
  1473. }
  1474. function handleRef(ref, forward) {
  1475. if (forward) {
  1476. // If it's a function, assume it's a ref callback
  1477. if (is.fun(forward)) forward(ref);else if (is.obj(forward)) {
  1478. forward.current = ref;
  1479. }
  1480. }
  1481. return ref;
  1482. }
  1483. var Animated =
  1484. /*#__PURE__*/
  1485. function () {
  1486. function Animated() {
  1487. this.payload = void 0;
  1488. this.children = [];
  1489. }
  1490. var _proto = Animated.prototype;
  1491. _proto.getAnimatedValue = function getAnimatedValue() {
  1492. return this.getValue();
  1493. };
  1494. _proto.getPayload = function getPayload() {
  1495. return this.payload || this;
  1496. };
  1497. _proto.attach = function attach() {};
  1498. _proto.detach = function detach() {};
  1499. _proto.getChildren = function getChildren() {
  1500. return this.children;
  1501. };
  1502. _proto.addChild = function addChild(child) {
  1503. if (this.children.length === 0) this.attach();
  1504. this.children.push(child);
  1505. };
  1506. _proto.removeChild = function removeChild(child) {
  1507. var index = this.children.indexOf(child);
  1508. this.children.splice(index, 1);
  1509. if (this.children.length === 0) this.detach();
  1510. };
  1511. return Animated;
  1512. }();
  1513. var AnimatedArray =
  1514. /*#__PURE__*/
  1515. function (_Animated) {
  1516. _inheritsLoose(AnimatedArray, _Animated);
  1517. function AnimatedArray() {
  1518. var _this;
  1519. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  1520. args[_key] = arguments[_key];
  1521. }
  1522. _this = _Animated.call.apply(_Animated, [this].concat(args)) || this;
  1523. _this.payload = [];
  1524. _this.attach = function () {
  1525. return _this.payload.forEach(function (p) {
  1526. return p instanceof Animated && p.addChild(_assertThisInitialized(_this));
  1527. });
  1528. };
  1529. _this.detach = function () {
  1530. return _this.payload.forEach(function (p) {
  1531. return p instanceof Animated && p.removeChild(_assertThisInitialized(_this));
  1532. });
  1533. };
  1534. return _this;
  1535. }
  1536. return AnimatedArray;
  1537. }(Animated);
  1538. var AnimatedObject =
  1539. /*#__PURE__*/
  1540. function (_Animated2) {
  1541. _inheritsLoose(AnimatedObject, _Animated2);
  1542. function AnimatedObject() {
  1543. var _this2;
  1544. for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  1545. args[_key3] = arguments[_key3];
  1546. }
  1547. _this2 = _Animated2.call.apply(_Animated2, [this].concat(args)) || this;
  1548. _this2.payload = {};
  1549. _this2.attach = function () {
  1550. return Object.values(_this2.payload).forEach(function (s) {
  1551. return s instanceof Animated && s.addChild(_assertThisInitialized(_this2));
  1552. });
  1553. };
  1554. _this2.detach = function () {
  1555. return Object.values(_this2.payload).forEach(function (s) {
  1556. return s instanceof Animated && s.removeChild(_assertThisInitialized(_this2));
  1557. });
  1558. };
  1559. return _this2;
  1560. }
  1561. var _proto2 = AnimatedObject.prototype;
  1562. _proto2.getValue = function getValue(animated) {
  1563. if (animated === void 0) {
  1564. animated = false;
  1565. }
  1566. var payload = {};
  1567. for (var _key4 in this.payload) {
  1568. var value = this.payload[_key4];
  1569. if (animated && !(value instanceof Animated)) continue;
  1570. payload[_key4] = value instanceof Animated ? value[animated ? 'getAnimatedValue' : 'getValue']() : value;
  1571. }
  1572. return payload;
  1573. };
  1574. _proto2.getAnimatedValue = function getAnimatedValue() {
  1575. return this.getValue(true);
  1576. };
  1577. return AnimatedObject;
  1578. }(Animated);
  1579. var applyAnimatedValues;
  1580. function injectApplyAnimatedValues(fn, transform) {
  1581. applyAnimatedValues = {
  1582. fn: fn,
  1583. transform: transform
  1584. };
  1585. }
  1586. var colorNames;
  1587. function injectColorNames(names) {
  1588. colorNames = names;
  1589. }
  1590. var requestFrame = function requestFrame(cb) {
  1591. return typeof window !== 'undefined' ? window.requestAnimationFrame(cb) : -1;
  1592. };
  1593. var cancelFrame = function cancelFrame(id) {
  1594. typeof window !== 'undefined' && window.cancelAnimationFrame(id);
  1595. };
  1596. function injectFrame(raf, caf) {
  1597. requestFrame = raf;
  1598. cancelFrame = caf;
  1599. }
  1600. var interpolation;
  1601. function injectStringInterpolator(fn) {
  1602. interpolation = fn;
  1603. }
  1604. var now = function now() {
  1605. return Date.now();
  1606. };
  1607. function injectNow(nowFn) {
  1608. now = nowFn;
  1609. }
  1610. var defaultElement;
  1611. function injectDefaultElement(el) {
  1612. defaultElement = el;
  1613. }
  1614. var animatedApi = function animatedApi(node) {
  1615. return node.current;
  1616. };
  1617. function injectAnimatedApi(fn) {
  1618. animatedApi = fn;
  1619. }
  1620. var createAnimatedStyle;
  1621. function injectCreateAnimatedStyle(factory) {
  1622. createAnimatedStyle = factory;
  1623. }
  1624. var manualFrameloop;
  1625. function injectManualFrameloop(callback) {
  1626. manualFrameloop = callback;
  1627. }
  1628. var Globals = /*#__PURE__*/Object.freeze({
  1629. get applyAnimatedValues () { return applyAnimatedValues; },
  1630. injectApplyAnimatedValues: injectApplyAnimatedValues,
  1631. get colorNames () { return colorNames; },
  1632. injectColorNames: injectColorNames,
  1633. get requestFrame () { return requestFrame; },
  1634. get cancelFrame () { return cancelFrame; },
  1635. injectFrame: injectFrame,
  1636. get interpolation () { return interpolation; },
  1637. injectStringInterpolator: injectStringInterpolator,
  1638. get now () { return now; },
  1639. injectNow: injectNow,
  1640. get defaultElement () { return defaultElement; },
  1641. injectDefaultElement: injectDefaultElement,
  1642. get animatedApi () { return animatedApi; },
  1643. injectAnimatedApi: injectAnimatedApi,
  1644. get createAnimatedStyle () { return createAnimatedStyle; },
  1645. injectCreateAnimatedStyle: injectCreateAnimatedStyle,
  1646. get manualFrameloop () { return manualFrameloop; },
  1647. injectManualFrameloop: injectManualFrameloop
  1648. });
  1649. /**
  1650. * Wraps the `style` property with `AnimatedStyle`.
  1651. */
  1652. var AnimatedProps =
  1653. /*#__PURE__*/
  1654. function (_AnimatedObject) {
  1655. _inheritsLoose(AnimatedProps, _AnimatedObject);
  1656. function AnimatedProps(props, callback) {
  1657. var _this;
  1658. _this = _AnimatedObject.call(this) || this;
  1659. _this.update = void 0;
  1660. _this.payload = !props.style ? props : _extends({}, props, {
  1661. style: createAnimatedStyle(props.style)
  1662. });
  1663. _this.update = callback;
  1664. _this.attach();
  1665. return _this;
  1666. }
  1667. return AnimatedProps;
  1668. }(AnimatedObject);
  1669. var isFunctionComponent = function isFunctionComponent(val) {
  1670. return is.fun(val) && !(val.prototype instanceof React__default.Component);
  1671. };
  1672. var createAnimatedComponent = function createAnimatedComponent(Component) {
  1673. var AnimatedComponent = React.forwardRef(function (props, ref) {
  1674. var forceUpdate = useForceUpdate();
  1675. var mounted = React.useRef(true);
  1676. var propsAnimated = React.useRef(null);
  1677. var node = React.useRef(null);
  1678. var attachProps = React.useCallback(function (props) {
  1679. var oldPropsAnimated = propsAnimated.current;
  1680. var callback = function callback() {
  1681. var didUpdate = false;
  1682. if (node.current) {
  1683. didUpdate = applyAnimatedValues.fn(node.current, propsAnimated.current.getAnimatedValue());
  1684. }
  1685. if (!node.current || didUpdate === false) {
  1686. // If no referenced node has been found, or the update target didn't have a
  1687. // native-responder, then forceUpdate the animation ...
  1688. forceUpdate();
  1689. }
  1690. };
  1691. propsAnimated.current = new AnimatedProps(props, callback);
  1692. oldPropsAnimated && oldPropsAnimated.detach();
  1693. }, []);
  1694. React.useEffect(function () {
  1695. return function () {
  1696. mounted.current = false;
  1697. propsAnimated.current && propsAnimated.current.detach();
  1698. };
  1699. }, []);
  1700. React.useImperativeHandle(ref, function () {
  1701. return animatedApi(node, mounted, forceUpdate);
  1702. });
  1703. attachProps(props);
  1704. var _getValue = propsAnimated.current.getValue(),
  1705. scrollTop = _getValue.scrollTop,
  1706. scrollLeft = _getValue.scrollLeft,
  1707. animatedProps = _objectWithoutPropertiesLoose(_getValue, ["scrollTop", "scrollLeft"]); // Functions cannot have refs, see:
  1708. // See: https://github.com/react-spring/react-spring/issues/569
  1709. var refFn = isFunctionComponent(Component) ? undefined : function (childRef) {
  1710. return node.current = handleRef(childRef, ref);
  1711. };
  1712. return React__default.createElement(Component, _extends({}, animatedProps, {
  1713. ref: refFn
  1714. }));
  1715. });
  1716. return AnimatedComponent;
  1717. };
  1718. var active = false;
  1719. var controllers = new Set();
  1720. var update = function update() {
  1721. if (!active) return false;
  1722. var time = now();
  1723. for (var _iterator = controllers, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
  1724. var _ref;
  1725. if (_isArray) {
  1726. if (_i >= _iterator.length) break;
  1727. _ref = _iterator[_i++];
  1728. } else {
  1729. _i = _iterator.next();
  1730. if (_i.done) break;
  1731. _ref = _i.value;
  1732. }
  1733. var controller = _ref;
  1734. var isActive = false;
  1735. for (var configIdx = 0; configIdx < controller.configs.length; configIdx++) {
  1736. var config = controller.configs[configIdx];
  1737. var endOfAnimation = void 0,
  1738. lastTime = void 0;
  1739. for (var valIdx = 0; valIdx < config.animatedValues.length; valIdx++) {
  1740. var animation = config.animatedValues[valIdx]; // If an animation is done, skip, until all of them conclude
  1741. if (animation.done) continue;
  1742. var from = config.fromValues[valIdx];
  1743. var to = config.toValues[valIdx];
  1744. var position = animation.lastPosition;
  1745. var isAnimated = to instanceof Animated;
  1746. var velocity = Array.isArray(config.initialVelocity) ? config.initialVelocity[valIdx] : config.initialVelocity;
  1747. if (isAnimated) to = to.getValue(); // Conclude animation if it's either immediate, or from-values match end-state
  1748. if (config.immediate) {
  1749. animation.setValue(to);
  1750. animation.done = true;
  1751. continue;
  1752. } // Break animation when string values are involved
  1753. if (typeof from === 'string' || typeof to === 'string') {
  1754. animation.setValue(to);
  1755. animation.done = true;
  1756. continue;
  1757. }
  1758. if (config.duration !== void 0) {
  1759. /** Duration easing */
  1760. position = from + config.easing((time - animation.startTime) / config.duration) * (to - from);
  1761. endOfAnimation = time >= animation.startTime + config.duration;
  1762. } else if (config.decay) {
  1763. /** Decay easing */
  1764. position = from + velocity / (1 - 0.998) * (1 - Math.exp(-(1 - 0.998) * (time - animation.startTime)));
  1765. endOfAnimation = Math.abs(animation.lastPosition - position) < 0.1;
  1766. if (endOfAnimation) to = position;
  1767. } else {
  1768. /** Spring easing */
  1769. lastTime = animation.lastTime !== void 0 ? animation.lastTime : time;
  1770. velocity = animation.lastVelocity !== void 0 ? animation.lastVelocity : config.initialVelocity; // If we lost a lot of frames just jump to the end.
  1771. if (time > lastTime + 64) lastTime = time; // http://gafferongames.com/game-physics/fix-your-timestep/
  1772. var numSteps = Math.floor(time - lastTime);
  1773. for (var i = 0; i < numSteps; ++i) {
  1774. var force = -config.tension * (position - to);
  1775. var damping = -config.friction * velocity;
  1776. var acceleration = (force + damping) / config.mass;
  1777. velocity = velocity + acceleration * 1 / 1000;
  1778. position = position + velocity * 1 / 1000;
  1779. } // Conditions for stopping the spring animation
  1780. var isOvershooting = config.clamp && config.tension !== 0 ? from < to ? position > to : position < to : false;
  1781. var isVelocity = Math.abs(velocity) <= config.precision;
  1782. var isDisplacement = config.tension !== 0 ? Math.abs(to - position) <= config.precision : true;
  1783. endOfAnimation = isOvershooting || isVelocity && isDisplacement;
  1784. animation.lastVelocity = velocity;
  1785. animation.lastTime = time;
  1786. } // Trails aren't done until their parents conclude
  1787. if (isAnimated && !config.toValues[valIdx].done) endOfAnimation = false;
  1788. if (endOfAnimation) {
  1789. // Ensure that we end up with a round value
  1790. if (animation.value !== to) position = to;
  1791. animation.done = true;
  1792. } else isActive = true;
  1793. animation.setValue(position);
  1794. animation.lastPosition = position;
  1795. } // Keep track of updated values only when necessary
  1796. if (controller.props.onFrame) controller.values[config.name] = config.interpolation.getValue();
  1797. } // Update callbacks in the end of the frame
  1798. if (controller.props.onFrame) controller.props.onFrame(controller.values); // Either call onEnd or next frame
  1799. if (!isActive) {
  1800. controllers.delete(controller);
  1801. controller.stop(true);
  1802. }
  1803. } // Loop over as long as there are controllers ...
  1804. if (controllers.size) {
  1805. if (manualFrameloop) manualFrameloop();else requestFrame(update);
  1806. } else {
  1807. active = false;
  1808. }
  1809. return active;
  1810. };
  1811. var start = function start(controller) {
  1812. if (!controllers.has(controller)) controllers.add(controller);
  1813. if (!active) {
  1814. active = true;
  1815. if (manualFrameloop) requestFrame(manualFrameloop);else requestFrame(update);
  1816. }
  1817. };
  1818. var stop = function stop(controller) {
  1819. if (controllers.has(controller)) controllers.delete(controller);
  1820. };
  1821. function createInterpolator(range, output, extrapolate) {
  1822. if (typeof range === 'function') {
  1823. return range;
  1824. }
  1825. if (Array.isArray(range)) {
  1826. return createInterpolator({
  1827. range: range,
  1828. output: output,
  1829. extrapolate: extrapolate
  1830. });
  1831. }
  1832. if (interpolation && typeof range.output[0] === 'string') {
  1833. return interpolation(range);
  1834. }
  1835. var config = range;
  1836. var outputRange = config.output;
  1837. var inputRange = config.range || [0, 1];
  1838. var extrapolateLeft = config.extrapolateLeft || config.extrapolate || 'extend';
  1839. var extrapolateRight = config.extrapolateRight || config.extrapolate || 'extend';
  1840. var easing = config.easing || function (t) {
  1841. return t;
  1842. };
  1843. return function (input) {
  1844. var range = findRange(input, inputRange);
  1845. return interpolate(input, inputRange[range], inputRange[range + 1], outputRange[range], outputRange[range + 1], easing, extrapolateLeft, extrapolateRight, config.map);
  1846. };
  1847. }
  1848. function interpolate(input, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight, map) {
  1849. var result = map ? map(input) : input; // Extrapolate
  1850. if (result < inputMin) {
  1851. if (extrapolateLeft === 'identity') return result;else if (extrapolateLeft === 'clamp') result = inputMin;
  1852. }
  1853. if (result > inputMax) {
  1854. if (extrapolateRight === 'identity') return result;else if (extrapolateRight === 'clamp') result = inputMax;
  1855. }
  1856. if (outputMin === outputMax) return outputMin;
  1857. if (inputMin === inputMax) return input <= inputMin ? outputMin : outputMax; // Input Range
  1858. if (inputMin === -Infinity) result = -result;else if (inputMax === Infinity) result = result - inputMin;else result = (result - inputMin) / (inputMax - inputMin); // Easing
  1859. result = easing(result); // Output Range
  1860. if (outputMin === -Infinity) result = -result;else if (outputMax === Infinity) result = result + outputMin;else result = result * (outputMax - outputMin) + outputMin;
  1861. return result;
  1862. }
  1863. function findRange(input, inputRange) {
  1864. for (var i = 1; i < inputRange.length - 1; ++i) {
  1865. if (inputRange[i] >= input) break;
  1866. }
  1867. return i - 1;
  1868. }
  1869. var AnimatedInterpolation =
  1870. /*#__PURE__*/
  1871. function (_AnimatedArray) {
  1872. _inheritsLoose(AnimatedInterpolation, _AnimatedArray);
  1873. function AnimatedInterpolation(parents, range, output, extrapolate) {
  1874. var _this;
  1875. _this = _AnimatedArray.call(this) || this;
  1876. _this.calc = void 0;
  1877. _this.payload = parents instanceof AnimatedArray && !(parents instanceof AnimatedInterpolation) ? parents.getPayload() : Array.isArray(parents) ? parents : [parents];
  1878. _this.calc = createInterpolator(range, output, extrapolate);
  1879. return _this;
  1880. }
  1881. var _proto = AnimatedInterpolation.prototype;
  1882. _proto.getValue = function getValue() {
  1883. return this.calc.apply(this, this.payload.map(function (value) {
  1884. return value.getValue();
  1885. }));
  1886. };
  1887. _proto.updateConfig = function updateConfig(range, output, extrapolate) {
  1888. this.calc = createInterpolator(range, output, extrapolate);
  1889. };
  1890. _proto.interpolate = function interpolate(range, output, extrapolate) {
  1891. return new AnimatedInterpolation(this, range, output, extrapolate);
  1892. };
  1893. return AnimatedInterpolation;
  1894. }(AnimatedArray);
  1895. var interpolate$1 = function interpolate(parents, range, output) {
  1896. return parents && new AnimatedInterpolation(parents, range, output);
  1897. };
  1898. var config = {
  1899. default: {
  1900. tension: 170,
  1901. friction: 26
  1902. },
  1903. gentle: {
  1904. tension: 120,
  1905. friction: 14
  1906. },
  1907. wobbly: {
  1908. tension: 180,
  1909. friction: 12
  1910. },
  1911. stiff: {
  1912. tension: 210,
  1913. friction: 20
  1914. },
  1915. slow: {
  1916. tension: 280,
  1917. friction: 60
  1918. },
  1919. molasses: {
  1920. tension: 280,
  1921. friction: 120
  1922. }
  1923. };
  1924. /** API
  1925. * useChain(references, timeSteps, timeFrame)
  1926. */
  1927. function useChain(refs, timeSteps, timeFrame) {
  1928. if (timeFrame === void 0) {
  1929. timeFrame = 1000;
  1930. }
  1931. var previous = React.useRef();
  1932. React.useEffect(function () {
  1933. if (is.equ(refs, previous.current)) refs.forEach(function (_ref) {
  1934. var current = _ref.current;
  1935. return current && current.start();
  1936. });else if (timeSteps) {
  1937. refs.forEach(function (_ref2, index) {
  1938. var current = _ref2.current;
  1939. if (current) {
  1940. var ctrls = current.controllers;
  1941. if (ctrls.length) {
  1942. var t = timeFrame * timeSteps[index];
  1943. ctrls.forEach(function (ctrl) {
  1944. ctrl.queue = ctrl.queue.map(function (e) {
  1945. return _extends({}, e, {
  1946. delay: e.delay + t
  1947. });
  1948. });
  1949. ctrl.start();
  1950. });
  1951. }
  1952. }
  1953. });
  1954. } else refs.reduce(function (q, _ref3, rI) {
  1955. var current = _ref3.current;
  1956. return q = q.then(function () {
  1957. return current.start();
  1958. });
  1959. }, Promise.resolve());
  1960. previous.current = refs;
  1961. });
  1962. }
  1963. /**
  1964. * Animated works by building a directed acyclic graph of dependencies
  1965. * transparently when you render your Animated components.
  1966. *
  1967. * new Animated.Value(0)
  1968. * .interpolate() .interpolate() new Animated.Value(1)
  1969. * opacity translateY scale
  1970. * style transform
  1971. * View#234 style
  1972. * View#123
  1973. *
  1974. * A) Top Down phase
  1975. * When an AnimatedValue is updated, we recursively go down through this
  1976. * graph in order to find leaf nodes: the views that we flag as needing
  1977. * an update.
  1978. *
  1979. * B) Bottom Up phase
  1980. * When a view is flagged as needing an update, we recursively go back up
  1981. * in order to build the new value that it needs. The reason why we need
  1982. * this two-phases process is to deal with composite props such as
  1983. * transform which can receive values from multiple parents.
  1984. */
  1985. function addAnimatedStyles(node, styles) {
  1986. if ('update' in node) {
  1987. styles.add(node);
  1988. } else {
  1989. node.getChildren().forEach(function (child) {
  1990. return addAnimatedStyles(child, styles);
  1991. });
  1992. }
  1993. }
  1994. var AnimatedValue =
  1995. /*#__PURE__*/
  1996. function (_Animated) {
  1997. _inheritsLoose(AnimatedValue, _Animated);
  1998. function AnimatedValue(_value) {
  1999. var _this;
  2000. _this = _Animated.call(this) || this;
  2001. _this.animatedStyles = new Set();
  2002. _this.value = void 0;
  2003. _this.startPosition = void 0;
  2004. _this.lastPosition = void 0;
  2005. _this.lastVelocity = void 0;
  2006. _this.startTime = void 0;
  2007. _this.lastTime = void 0;
  2008. _this.done = false;
  2009. _this.setValue = function (value, flush) {
  2010. if (flush === void 0) {
  2011. flush = true;
  2012. }
  2013. _this.value = value;
  2014. if (flush) _this.flush();
  2015. };
  2016. _this.value = _value;
  2017. _this.startPosition = _value;
  2018. _this.lastPosition = _value;
  2019. return _this;
  2020. }
  2021. var _proto = AnimatedValue.prototype;
  2022. _proto.flush = function flush() {
  2023. if (this.animatedStyles.size === 0) {
  2024. addAnimatedStyles(this, this.animatedStyles);
  2025. }
  2026. this.animatedStyles.forEach(function (animatedStyle) {
  2027. return animatedStyle.update();
  2028. });
  2029. };
  2030. _proto.clearStyles = function clearStyles() {
  2031. this.animatedStyles.clear();
  2032. };
  2033. _proto.getValue = function getValue() {
  2034. return this.value;
  2035. };
  2036. _proto.interpolate = function interpolate(range, output, extrapolate) {
  2037. return new AnimatedInterpolation(this, range, output, extrapolate);
  2038. };
  2039. return AnimatedValue;
  2040. }(Animated);
  2041. var AnimatedValueArray =
  2042. /*#__PURE__*/
  2043. function (_AnimatedArray) {
  2044. _inheritsLoose(AnimatedValueArray, _AnimatedArray);
  2045. function AnimatedValueArray(values) {
  2046. var _this;
  2047. _this = _AnimatedArray.call(this) || this;
  2048. _this.payload = values.map(function (n) {
  2049. return new AnimatedValue(n);
  2050. });
  2051. return _this;
  2052. }
  2053. var _proto = AnimatedValueArray.prototype;
  2054. _proto.setValue = function setValue(value, flush) {
  2055. var _this2 = this;
  2056. if (flush === void 0) {
  2057. flush = true;
  2058. }
  2059. if (Array.isArray(value)) {
  2060. if (value.length === this.payload.length) {
  2061. value.forEach(function (v, i) {
  2062. return _this2.payload[i].setValue(v, flush);
  2063. });
  2064. }
  2065. } else {
  2066. this.payload.forEach(function (p) {
  2067. return p.setValue(value, flush);
  2068. });
  2069. }
  2070. };
  2071. _proto.getValue = function getValue() {
  2072. return this.payload.map(function (v) {
  2073. return v.getValue();
  2074. });
  2075. };
  2076. _proto.interpolate = function interpolate(range, output) {
  2077. return new AnimatedInterpolation(this, range, output);
  2078. };
  2079. return AnimatedValueArray;
  2080. }(AnimatedArray);
  2081. var G = 0;
  2082. var Controller =
  2083. /*#__PURE__*/
  2084. function () {
  2085. function Controller() {
  2086. var _this = this;
  2087. this.id = void 0;
  2088. this.idle = true;
  2089. this.hasChanged = false;
  2090. this.guid = 0;
  2091. this.local = 0;
  2092. this.props = {};
  2093. this.merged = {};
  2094. this.animations = {};
  2095. this.interpolations = {};
  2096. this.values = {};
  2097. this.configs = [];
  2098. this.listeners = [];
  2099. this.queue = [];
  2100. this.localQueue = void 0;
  2101. this.getValues = function () {
  2102. return _this.interpolations;
  2103. };
  2104. this.id = G++;
  2105. }
  2106. /** update(props)
  2107. * This function filters input props and creates an array of tasks which are executed in .start()
  2108. * Each task is allowed to carry a delay, which means it can execute asnychroneously */
  2109. var _proto = Controller.prototype;
  2110. _proto.update = function update$$1(args) {
  2111. //this._id = n + this.id
  2112. if (!args) return this; // Extract delay and the to-prop from props
  2113. var _ref = interpolateTo(args),
  2114. _ref$delay = _ref.delay,
  2115. delay = _ref$delay === void 0 ? 0 : _ref$delay,
  2116. to = _ref.to,
  2117. props = _objectWithoutPropertiesLoose(_ref, ["delay", "to"]);
  2118. if (is.arr(to) || is.fun(to)) {
  2119. // If config is either a function or an array queue it up as is
  2120. this.queue.push(_extends({}, props, {
  2121. delay: delay,
  2122. to: to
  2123. }));
  2124. } else if (to) {
  2125. // Otherwise go through each key since it could be delayed individually
  2126. var ops = {};
  2127. Object.entries(to).forEach(function (_ref2) {
  2128. var _to;
  2129. var k = _ref2[0],
  2130. v = _ref2[1];
  2131. // Fetch delay and create an entry, consisting of the to-props, the delay, and basic props
  2132. var entry = _extends({
  2133. to: (_to = {}, _to[k] = v, _to),
  2134. delay: callProp(delay, k)
  2135. }, props);
  2136. var previous = ops[entry.delay] && ops[entry.delay].to;
  2137. ops[entry.delay] = _extends({}, ops[entry.delay], entry, {
  2138. to: _extends({}, previous, entry.to)
  2139. });
  2140. });
  2141. this.queue = Object.values(ops);
  2142. } // Sort queue, so that async calls go last
  2143. this.queue = this.queue.sort(function (a, b) {
  2144. return a.delay - b.delay;
  2145. }); // Diff the reduced props immediately (they'll contain the from-prop and some config)
  2146. this.diff(props);
  2147. return this;
  2148. }
  2149. /** start(onEnd)
  2150. * This function either executes a queue, if present, or starts the frameloop, which animates */
  2151. ;
  2152. _proto.start = function start$$1(onEnd) {
  2153. var _this2 = this;
  2154. // If a queue is present we must excecute it
  2155. if (this.queue.length) {
  2156. this.idle = false; // Updates can interrupt trailing queues, in that case we just merge values
  2157. if (this.localQueue) {
  2158. this.localQueue.forEach(function (_ref3) {
  2159. var _ref3$from = _ref3.from,
  2160. from = _ref3$from === void 0 ? {} : _ref3$from,
  2161. _ref3$to = _ref3.to,
  2162. to = _ref3$to === void 0 ? {} : _ref3$to;
  2163. if (is.obj(from)) _this2.merged = _extends({}, from, _this2.merged);
  2164. if (is.obj(to)) _this2.merged = _extends({}, _this2.merged, to);
  2165. });
  2166. } // The guid helps us tracking frames, a new queue over an old one means an override
  2167. // We discard async calls in that caseÍ
  2168. var local = this.local = ++this.guid;
  2169. var queue = this.localQueue = this.queue;
  2170. this.queue = []; // Go through each entry and execute it
  2171. queue.forEach(function (_ref4, index) {
  2172. var delay = _ref4.delay,
  2173. props = _objectWithoutPropertiesLoose(_ref4, ["delay"]);
  2174. var cb = function cb(finished) {
  2175. if (index === queue.length - 1 && local === _this2.guid && finished) {
  2176. _this2.idle = true;
  2177. if (_this2.props.onRest) _this2.props.onRest(_this2.merged);
  2178. }
  2179. if (onEnd) onEnd();
  2180. }; // Entries can be delayed, ansyc or immediate
  2181. var async = is.arr(props.to) || is.fun(props.to);
  2182. if (delay) {
  2183. setTimeout(function () {
  2184. if (local === _this2.guid) {
  2185. if (async) _this2.runAsync(props, cb);else _this2.diff(props).start(cb);
  2186. }
  2187. }, delay);
  2188. } else if (async) _this2.runAsync(props, cb);else _this2.diff(props).start(cb);
  2189. });
  2190. } // Otherwise we kick of the frameloop
  2191. else {
  2192. if (is.fun(onEnd)) this.listeners.push(onEnd);
  2193. if (this.props.onStart) this.props.onStart();
  2194. start(this);
  2195. }
  2196. return this;
  2197. };
  2198. _proto.stop = function stop$$1(finished) {
  2199. this.listeners.forEach(function (onEnd) {
  2200. return onEnd(finished);
  2201. });
  2202. this.listeners = [];
  2203. return this;
  2204. }
  2205. /** Pause sets onEnd listeners free, but also removes the controller from the frameloop */
  2206. ;
  2207. _proto.pause = function pause(finished) {
  2208. this.stop(true);
  2209. if (finished) stop(this);
  2210. return this;
  2211. };
  2212. _proto.runAsync = function runAsync(_ref5, onEnd) {
  2213. var _this3 = this;
  2214. var delay = _ref5.delay,
  2215. props = _objectWithoutPropertiesLoose(_ref5, ["delay"]);
  2216. var local = this.local; // If "to" is either a function or an array it will be processed async, therefor "to" should be empty right now
  2217. // If the view relies on certain values "from" has to be present
  2218. var queue = Promise.resolve(undefined);
  2219. if (is.arr(props.to)) {
  2220. var _loop = function _loop(i) {
  2221. var index = i;
  2222. var fresh = _extends({}, props, interpolateTo(props.to[index]));
  2223. if (is.arr(fresh.config)) fresh.config = fresh.config[index];
  2224. queue = queue.then(function () {
  2225. //this.stop()
  2226. if (local === _this3.guid) return new Promise(function (r) {
  2227. return _this3.diff(fresh).start(r);
  2228. });
  2229. });
  2230. };
  2231. for (var i = 0; i < props.to.length; i++) {
  2232. _loop(i);
  2233. }
  2234. } else if (is.fun(props.to)) {
  2235. var index = 0;
  2236. var last;
  2237. queue = queue.then(function () {
  2238. return props.to( // next(props)
  2239. function (p) {
  2240. var fresh = _extends({}, props, interpolateTo(p));
  2241. if (is.arr(fresh.config)) fresh.config = fresh.config[index];
  2242. index++; //this.stop()
  2243. if (local === _this3.guid) return last = new Promise(function (r) {
  2244. return _this3.diff(fresh).start(r);
  2245. });
  2246. return;
  2247. }, // cancel()
  2248. function (finished) {
  2249. if (finished === void 0) {
  2250. finished = true;
  2251. }
  2252. return _this3.stop(finished);
  2253. }).then(function () {
  2254. return last;
  2255. });
  2256. });
  2257. }
  2258. queue.then(onEnd);
  2259. };
  2260. _proto.diff = function diff(props) {
  2261. var _this4 = this;
  2262. this.props = _extends({}, this.props, props);
  2263. var _this$props = this.props,
  2264. _this$props$from = _this$props.from,
  2265. from = _this$props$from === void 0 ? {} : _this$props$from,
  2266. _this$props$to = _this$props.to,
  2267. to = _this$props$to === void 0 ? {} : _this$props$to,
  2268. _this$props$config = _this$props.config,
  2269. config = _this$props$config === void 0 ? {} : _this$props$config,
  2270. reverse = _this$props.reverse,
  2271. attach = _this$props.attach,
  2272. reset = _this$props.reset,
  2273. immediate = _this$props.immediate; // Reverse values when requested
  2274. if (reverse) {
  2275. var _ref6 = [to, from];
  2276. from = _ref6[0];
  2277. to = _ref6[1];
  2278. } // This will collect all props that were ever set, reset merged props when necessary
  2279. this.merged = _extends({}, from, this.merged, to);
  2280. this.hasChanged = false; // Attachment handling, trailed springs can "attach" themselves to a previous spring
  2281. var target = attach && attach(this); // Reduces input { name: value } pairs into animated values
  2282. this.animations = Object.entries(this.merged).reduce(function (acc, _ref7) {
  2283. var name = _ref7[0],
  2284. value = _ref7[1];
  2285. // Issue cached entries, except on reset
  2286. var entry = acc[name] || {}; // Figure out what the value is supposed to be
  2287. var isNumber = is.num(value);
  2288. var isString = is.str(value) && !value.startsWith('#') && !/\d/.test(value) && !colorNames[value];
  2289. var isArray = is.arr(value);
  2290. var isInterpolation = !isNumber && !isArray && !isString;
  2291. var fromValue = !is.und(from[name]) ? from[name] : value;
  2292. var toValue = isNumber || isArray ? value : isString ? value : 1;
  2293. var toConfig = callProp(config, name);
  2294. if (target) toValue = target.animations[name].parent;
  2295. var parent = entry.parent,
  2296. interpolation$$1 = entry.interpolation,
  2297. toValues = toArray(target ? toValue.getPayload() : toValue),
  2298. animatedValues;
  2299. var newValue = value;
  2300. if (isInterpolation) newValue = interpolation({
  2301. range: [0, 1],
  2302. output: [value, value]
  2303. })(1);
  2304. var currentValue = interpolation$$1 && interpolation$$1.getValue(); // Change detection flags
  2305. var isFirst = is.und(parent);
  2306. var isActive = !isFirst && entry.animatedValues.some(function (v) {
  2307. return !v.done;
  2308. });
  2309. var currentValueDiffersFromGoal = !is.equ(newValue, currentValue);
  2310. var hasNewGoal = !is.equ(newValue, entry.previous);
  2311. var hasNewConfig = !is.equ(toConfig, entry.config); // Change animation props when props indicate a new goal (new value differs from previous one)
  2312. // and current values differ from it. Config changes trigger a new update as well (though probably shouldn't?)
  2313. if (reset || hasNewGoal && currentValueDiffersFromGoal || hasNewConfig) {
  2314. var _extends2;
  2315. // Convert regular values into animated values, ALWAYS re-use if possible
  2316. if (isNumber || isString) parent = interpolation$$1 = entry.parent || new AnimatedValue(fromValue);else if (isArray) parent = interpolation$$1 = entry.parent || new AnimatedValueArray(fromValue);else if (isInterpolation) {
  2317. var prev = entry.interpolation && entry.interpolation.calc(entry.parent.value);
  2318. prev = prev !== void 0 && !reset ? prev : fromValue;
  2319. if (entry.parent) {
  2320. parent = entry.parent;
  2321. parent.setValue(0, false);
  2322. } else parent = new AnimatedValue(0);
  2323. var range = {
  2324. output: [prev, value]
  2325. };
  2326. if (entry.interpolation) {
  2327. interpolation$$1 = entry.interpolation;
  2328. entry.interpolation.updateConfig(range);
  2329. } else interpolation$$1 = parent.interpolate(range);
  2330. }
  2331. toValues = toArray(target ? toValue.getPayload() : toValue);
  2332. animatedValues = toArray(parent.getPayload());
  2333. if (reset && !isInterpolation) parent.setValue(fromValue, false);
  2334. _this4.hasChanged = true; // Reset animated values
  2335. animatedValues.forEach(function (value) {
  2336. value.startPosition = value.value;
  2337. value.lastPosition = value.value;
  2338. value.lastVelocity = isActive ? value.lastVelocity : undefined;
  2339. value.lastTime = isActive ? value.lastTime : undefined;
  2340. value.startTime = now();
  2341. value.done = false;
  2342. value.animatedStyles.clear();
  2343. }); // Set immediate values
  2344. if (callProp(immediate, name)) {
  2345. parent.setValue(isInterpolation ? toValue : value, false);
  2346. }
  2347. return _extends({}, acc, (_extends2 = {}, _extends2[name] = _extends({}, entry, {
  2348. name: name,
  2349. parent: parent,
  2350. interpolation: interpolation$$1,
  2351. animatedValues: animatedValues,
  2352. toValues: toValues,
  2353. previous: newValue,
  2354. config: toConfig,
  2355. fromValues: toArray(parent.getValue()),
  2356. immediate: callProp(immediate, name),
  2357. initialVelocity: withDefault(toConfig.velocity, 0),
  2358. clamp: withDefault(toConfig.clamp, false),
  2359. precision: withDefault(toConfig.precision, 0.01),
  2360. tension: withDefault(toConfig.tension, 170),
  2361. friction: withDefault(toConfig.friction, 26),
  2362. mass: withDefault(toConfig.mass, 1),
  2363. duration: toConfig.duration,
  2364. easing: withDefault(toConfig.easing, function (t) {
  2365. return t;
  2366. }),
  2367. decay: toConfig.decay
  2368. }), _extends2));
  2369. } else {
  2370. if (!currentValueDiffersFromGoal) {
  2371. var _extends3;
  2372. // So ... the current target value (newValue) appears to be different from the previous value,
  2373. // which normally constitutes an update, but the actual value (currentValue) matches the target!
  2374. // In order to resolve this without causing an animation update we silently flag the animation as done,
  2375. // which it technically is. Interpolations also needs a config update with their target set to 1.
  2376. if (isInterpolation) {
  2377. parent.setValue(1, false);
  2378. interpolation$$1.updateConfig({
  2379. output: [newValue, newValue]
  2380. });
  2381. }
  2382. parent.done = true;
  2383. _this4.hasChanged = true;
  2384. return _extends({}, acc, (_extends3 = {}, _extends3[name] = _extends({}, acc[name], {
  2385. previous: newValue
  2386. }), _extends3));
  2387. }
  2388. return acc;
  2389. }
  2390. }, this.animations);
  2391. if (this.hasChanged) {
  2392. // Make animations available to frameloop
  2393. this.configs = Object.values(this.animations);
  2394. this.values = {};
  2395. this.interpolations = {};
  2396. for (var key in this.animations) {
  2397. this.interpolations[key] = this.animations[key].interpolation;
  2398. this.values[key] = this.animations[key].interpolation.getValue();
  2399. }
  2400. }
  2401. return this;
  2402. };
  2403. _proto.destroy = function destroy() {
  2404. this.stop();
  2405. this.props = {};
  2406. this.merged = {};
  2407. this.animations = {};
  2408. this.interpolations = {};
  2409. this.values = {};
  2410. this.configs = [];
  2411. this.local = 0;
  2412. };
  2413. return Controller;
  2414. }();
  2415. /** API
  2416. * const props = useSprings(number, [{ ... }, { ... }, ...])
  2417. * const [props, set] = useSprings(number, (i, controller) => ({ ... }))
  2418. */
  2419. var useSprings = function useSprings(length, props) {
  2420. var mounted = React.useRef(false);
  2421. var ctrl = React.useRef();
  2422. var isFn = is.fun(props); // The controller maintains the animation values, starts and stops animations
  2423. var _useMemo = React.useMemo(function () {
  2424. // Remove old controllers
  2425. if (ctrl.current) {
  2426. ctrl.current.map(function (c) {
  2427. return c.destroy();
  2428. });
  2429. ctrl.current = undefined;
  2430. }
  2431. var ref;
  2432. return [new Array(length).fill().map(function (_, i) {
  2433. var ctrl = new Controller();
  2434. var newProps = isFn ? callProp(props, i, ctrl) : props[i];
  2435. if (i === 0) ref = newProps.ref;
  2436. ctrl.update(newProps);
  2437. if (!ref) ctrl.start();
  2438. return ctrl;
  2439. }), ref];
  2440. }, [length]),
  2441. controllers = _useMemo[0],
  2442. ref = _useMemo[1];
  2443. ctrl.current = controllers; // The hooks reference api gets defined here ...
  2444. var api = React.useImperativeHandle(ref, function () {
  2445. return {
  2446. start: function start() {
  2447. return Promise.all(ctrl.current.map(function (c) {
  2448. return new Promise(function (r) {
  2449. return c.start(r);
  2450. });
  2451. }));
  2452. },
  2453. stop: function stop(finished) {
  2454. return ctrl.current.forEach(function (c) {
  2455. return c.stop(finished);
  2456. });
  2457. },
  2458. get controllers() {
  2459. return ctrl.current;
  2460. }
  2461. };
  2462. }); // This function updates the controllers
  2463. var updateCtrl = React.useMemo(function () {
  2464. return function (updateProps) {
  2465. return ctrl.current.map(function (c, i) {
  2466. c.update(isFn ? callProp(updateProps, i, c) : updateProps[i]);
  2467. if (!ref) c.start();
  2468. });
  2469. };
  2470. }, [length]); // Update controller if props aren't functional
  2471. React.useEffect(function () {
  2472. if (mounted.current) {
  2473. if (!isFn) updateCtrl(props);
  2474. } else if (!ref) ctrl.current.forEach(function (c) {
  2475. return c.start();
  2476. });
  2477. }); // Update mounted flag and destroy controller on unmount
  2478. React.useEffect(function () {
  2479. return mounted.current = true, function () {
  2480. return ctrl.current.forEach(function (c) {
  2481. return c.destroy();
  2482. });
  2483. };
  2484. }, []); // Return animated props, or, anim-props + the update-setter above
  2485. var propValues = ctrl.current.map(function (c) {
  2486. return c.getValues();
  2487. });
  2488. return isFn ? [propValues, updateCtrl, function (finished) {
  2489. return ctrl.current.forEach(function (c) {
  2490. return c.pause(finished);
  2491. });
  2492. }] : propValues;
  2493. };
  2494. /** API
  2495. * const props = useSpring({ ... })
  2496. * const [props, set] = useSpring(() => ({ ... }))
  2497. */
  2498. var useSpring = function useSpring(props) {
  2499. var isFn = is.fun(props);
  2500. var _useSprings = useSprings(1, isFn ? props : [props]),
  2501. result = _useSprings[0],
  2502. set = _useSprings[1],
  2503. pause = _useSprings[2];
  2504. return isFn ? [result[0], set, pause] : result;
  2505. };
  2506. /** API
  2507. * const trails = useTrail(number, { ... })
  2508. * const [trails, set] = useTrail(number, () => ({ ... }))
  2509. */
  2510. var useTrail = function useTrail(length, props) {
  2511. var mounted = React.useRef(false);
  2512. var isFn = is.fun(props);
  2513. var updateProps = callProp(props);
  2514. var instances = React.useRef();
  2515. var _useSprings = useSprings(length, function (i, ctrl) {
  2516. if (i === 0) instances.current = [];
  2517. instances.current.push(ctrl);
  2518. return _extends({}, updateProps, {
  2519. config: callProp(updateProps.config, i),
  2520. attach: i > 0 && function () {
  2521. return instances.current[i - 1];
  2522. }
  2523. });
  2524. }),
  2525. result = _useSprings[0],
  2526. set = _useSprings[1],
  2527. pause = _useSprings[2]; // Set up function to update controller
  2528. var updateCtrl = React.useMemo(function () {
  2529. return function (props) {
  2530. return set(function (i, ctrl) {
  2531. var last = props.reverse ? i === 0 : length - 1 === i;
  2532. var attachIdx = props.reverse ? i + 1 : i - 1;
  2533. var attachController = instances.current[attachIdx];
  2534. return _extends({}, props, {
  2535. config: callProp(props.config || updateProps.config, i),
  2536. attach: attachController && function () {
  2537. return attachController;
  2538. }
  2539. });
  2540. });
  2541. };
  2542. }, [length, updateProps.reverse]); // Update controller if props aren't functional
  2543. React.useEffect(function () {
  2544. return void (mounted.current && !isFn && updateCtrl(props));
  2545. }); // Update mounted flag and destroy controller on unmount
  2546. React.useEffect(function () {
  2547. return void (mounted.current = true);
  2548. }, []);
  2549. return isFn ? [result, updateCtrl, pause] : result;
  2550. };
  2551. /** API
  2552. * const transitions = useTransition(items, itemKeys, { ... })
  2553. * const [transitions, update] = useTransition(items, itemKeys, () => ({ ... }))
  2554. */
  2555. var guid = 0;
  2556. var ENTER = 'enter';
  2557. var LEAVE = 'leave';
  2558. var UPDATE = 'update';
  2559. var mapKeys = function mapKeys(items, keys) {
  2560. return (typeof keys === 'function' ? items.map(keys) : toArray(keys)).map(String);
  2561. };
  2562. var get = function get(props) {
  2563. var items = props.items,
  2564. _props$keys = props.keys,
  2565. keys = _props$keys === void 0 ? function (item) {
  2566. return item;
  2567. } : _props$keys,
  2568. rest = _objectWithoutPropertiesLoose(props, ["items", "keys"]);
  2569. items = toArray(items !== void 0 ? items : null);
  2570. return _extends({
  2571. items: items,
  2572. keys: mapKeys(items, keys)
  2573. }, rest);
  2574. };
  2575. function useTransition(input, keyTransform, config) {
  2576. var props = _extends({
  2577. items: input,
  2578. keys: keyTransform || function (i) {
  2579. return i;
  2580. }
  2581. }, config);
  2582. var _get = get(props),
  2583. _get$lazy = _get.lazy,
  2584. lazy = _get$lazy === void 0 ? false : _get$lazy,
  2585. _get$unique = _get.unique,
  2586. _get$reset = _get.reset,
  2587. reset = _get$reset === void 0 ? false : _get$reset,
  2588. enter = _get.enter,
  2589. leave = _get.leave,
  2590. update = _get.update,
  2591. onDestroyed = _get.onDestroyed,
  2592. keys = _get.keys,
  2593. items = _get.items,
  2594. onFrame = _get.onFrame,
  2595. _onRest = _get.onRest,
  2596. onStart = _get.onStart,
  2597. ref = _get.ref,
  2598. extra = _objectWithoutPropertiesLoose(_get, ["lazy", "unique", "reset", "enter", "leave", "update", "onDestroyed", "keys", "items", "onFrame", "onRest", "onStart", "ref"]);
  2599. var forceUpdate = useForceUpdate();
  2600. var mounted = React.useRef(false);
  2601. var state = React.useRef({
  2602. mounted: false,
  2603. first: true,
  2604. deleted: [],
  2605. current: {},
  2606. transitions: [],
  2607. prevProps: {},
  2608. paused: !!props.ref,
  2609. instances: !mounted.current && new Map(),
  2610. forceUpdate: forceUpdate
  2611. });
  2612. React.useImperativeHandle(props.ref, function () {
  2613. return {
  2614. start: function start() {
  2615. return Promise.all(Array.from(state.current.instances).map(function (_ref) {
  2616. var c = _ref[1];
  2617. return new Promise(function (r) {
  2618. return c.start(r);
  2619. });
  2620. }));
  2621. },
  2622. stop: function stop(finished) {
  2623. return Array.from(state.current.instances).forEach(function (_ref2) {
  2624. var c = _ref2[1];
  2625. return c.stop(finished);
  2626. });
  2627. },
  2628. get controllers() {
  2629. return Array.from(state.current.instances).map(function (_ref3) {
  2630. var c = _ref3[1];
  2631. return c;
  2632. });
  2633. }
  2634. };
  2635. }); // Update state
  2636. state.current = diffItems(state.current, props);
  2637. if (state.current.changed) {
  2638. // Update state
  2639. state.current.transitions.forEach(function (transition) {
  2640. var slot = transition.slot,
  2641. from = transition.from,
  2642. to = transition.to,
  2643. config = transition.config,
  2644. trail = transition.trail,
  2645. key = transition.key,
  2646. item = transition.item;
  2647. if (!state.current.instances.has(key)) state.current.instances.set(key, new Controller()); // update the map object
  2648. var ctrl = state.current.instances.get(key);
  2649. var newProps = _extends({}, extra, {
  2650. to: to,
  2651. from: from,
  2652. config: config,
  2653. ref: ref,
  2654. onRest: function onRest(values) {
  2655. if (state.current.mounted) {
  2656. if (transition.destroyed) {
  2657. // If no ref is given delete destroyed items immediately
  2658. if (!ref && !lazy) cleanUp(state, key);
  2659. if (onDestroyed) onDestroyed(item);
  2660. } // A transition comes to rest once all its springs conclude
  2661. var curInstances = Array.from(state.current.instances);
  2662. var active = curInstances.some(function (_ref4) {
  2663. var c = _ref4[1];
  2664. return !c.idle;
  2665. });
  2666. if (!active && (ref || lazy) && state.current.deleted.length > 0) cleanUp(state);
  2667. if (_onRest) _onRest(item, slot, values);
  2668. }
  2669. },
  2670. onStart: onStart && function () {
  2671. return onStart(item, slot);
  2672. },
  2673. onFrame: onFrame && function (values) {
  2674. return onFrame(item, slot, values);
  2675. },
  2676. delay: trail,
  2677. reset: reset && slot === ENTER // Update controller
  2678. });
  2679. ctrl.update(newProps);
  2680. if (!state.current.paused) ctrl.start();
  2681. });
  2682. }
  2683. React.useEffect(function () {
  2684. state.current.mounted = mounted.current = true;
  2685. return function () {
  2686. state.current.mounted = mounted.current = false;
  2687. Array.from(state.current.instances).map(function (_ref5) {
  2688. var c = _ref5[1];
  2689. return c.destroy();
  2690. });
  2691. state.current.instances.clear();
  2692. };
  2693. }, []);
  2694. return state.current.transitions.map(function (_ref6) {
  2695. var item = _ref6.item,
  2696. slot = _ref6.slot,
  2697. key = _ref6.key;
  2698. return {
  2699. item: item,
  2700. key: key,
  2701. state: slot,
  2702. props: state.current.instances.get(key).getValues()
  2703. };
  2704. });
  2705. }
  2706. function cleanUp(state, filterKey) {
  2707. var deleted = state.current.deleted;
  2708. var _loop = function _loop() {
  2709. if (_isArray) {
  2710. if (_i >= _iterator.length) return "break";
  2711. _ref8 = _iterator[_i++];
  2712. } else {
  2713. _i = _iterator.next();
  2714. if (_i.done) return "break";
  2715. _ref8 = _i.value;
  2716. }
  2717. var _ref7 = _ref8;
  2718. var key = _ref7.key;
  2719. var filter = function filter(t) {
  2720. return t.key !== key;
  2721. };
  2722. if (is.und(filterKey) || filterKey === key) {
  2723. state.current.instances.delete(key);
  2724. state.current.transitions = state.current.transitions.filter(filter);
  2725. state.current.deleted = state.current.deleted.filter(filter);
  2726. }
  2727. };
  2728. for (var _iterator = deleted, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
  2729. var _ref8;
  2730. var _ret = _loop();
  2731. if (_ret === "break") break;
  2732. }
  2733. state.current.forceUpdate();
  2734. }
  2735. function diffItems(_ref9, props) {
  2736. var first = _ref9.first,
  2737. prevProps = _ref9.prevProps,
  2738. state = _objectWithoutPropertiesLoose(_ref9, ["first", "prevProps"]);
  2739. var _get2 = get(props),
  2740. items = _get2.items,
  2741. keys = _get2.keys,
  2742. initial = _get2.initial,
  2743. from = _get2.from,
  2744. enter = _get2.enter,
  2745. leave = _get2.leave,
  2746. update = _get2.update,
  2747. _get2$trail = _get2.trail,
  2748. trail = _get2$trail === void 0 ? 0 : _get2$trail,
  2749. unique = _get2.unique,
  2750. config = _get2.config,
  2751. _get2$order = _get2.order,
  2752. order = _get2$order === void 0 ? [ENTER, LEAVE, UPDATE] : _get2$order;
  2753. var _get3 = get(prevProps),
  2754. _keys = _get3.keys,
  2755. _items = _get3.items;
  2756. var current = _extends({}, state.current);
  2757. var deleted = [].concat(state.deleted); // Compare next keys with current keys
  2758. var currentKeys = Object.keys(current);
  2759. var currentSet = new Set(currentKeys);
  2760. var nextSet = new Set(keys);
  2761. var added = keys.filter(function (item) {
  2762. return !currentSet.has(item);
  2763. });
  2764. var removed = state.transitions.filter(function (item) {
  2765. return !item.destroyed && !nextSet.has(item.originalKey);
  2766. }).map(function (i) {
  2767. return i.originalKey;
  2768. });
  2769. var updated = keys.filter(function (item) {
  2770. return currentSet.has(item);
  2771. });
  2772. var delay = -trail;
  2773. while (order.length) {
  2774. var changeType = order.shift();
  2775. switch (changeType) {
  2776. case ENTER:
  2777. {
  2778. added.forEach(function (key, index) {
  2779. // In unique mode, remove fading out transitions if their key comes in again
  2780. if (unique && deleted.find(function (d) {
  2781. return d.originalKey === key;
  2782. })) deleted = deleted.filter(function (t) {
  2783. return t.originalKey !== key;
  2784. });
  2785. var keyIndex = keys.indexOf(key);
  2786. var item = items[keyIndex];
  2787. var slot = first && initial !== void 0 ? 'initial' : ENTER;
  2788. current[key] = {
  2789. slot: slot,
  2790. originalKey: key,
  2791. key: unique ? String(key) : guid++,
  2792. item: item,
  2793. trail: delay = delay + trail,
  2794. config: callProp(config, item, slot),
  2795. from: callProp(first ? initial !== void 0 ? initial || {} : from : from, item),
  2796. to: callProp(enter, item)
  2797. };
  2798. });
  2799. break;
  2800. }
  2801. case LEAVE:
  2802. {
  2803. removed.forEach(function (key) {
  2804. var keyIndex = _keys.indexOf(key);
  2805. var item = _items[keyIndex];
  2806. var slot = LEAVE;
  2807. deleted.unshift(_extends({}, current[key], {
  2808. slot: slot,
  2809. destroyed: true,
  2810. left: _keys[Math.max(0, keyIndex - 1)],
  2811. right: _keys[Math.min(_keys.length, keyIndex + 1)],
  2812. trail: delay = delay + trail,
  2813. config: callProp(config, item, slot),
  2814. to: callProp(leave, item)
  2815. }));
  2816. delete current[key];
  2817. });
  2818. break;
  2819. }
  2820. case UPDATE:
  2821. {
  2822. updated.forEach(function (key) {
  2823. var keyIndex = keys.indexOf(key);
  2824. var item = items[keyIndex];
  2825. var slot = UPDATE;
  2826. current[key] = _extends({}, current[key], {
  2827. item: item,
  2828. slot: slot,
  2829. trail: delay = delay + trail,
  2830. config: callProp(config, item, slot),
  2831. to: callProp(update, item)
  2832. });
  2833. });
  2834. break;
  2835. }
  2836. }
  2837. }
  2838. var out = keys.map(function (key) {
  2839. return current[key];
  2840. }); // This tries to restore order for deleted items by finding their last known siblings
  2841. // only using the left sibling to keep order placement consistent for all deleted items
  2842. deleted.forEach(function (_ref10) {
  2843. var left = _ref10.left,
  2844. right = _ref10.right,
  2845. item = _objectWithoutPropertiesLoose(_ref10, ["left", "right"]);
  2846. var pos; // Was it the element on the left, if yes, move there ...
  2847. if ((pos = out.findIndex(function (t) {
  2848. return t.originalKey === left;
  2849. })) !== -1) pos += 1; // And if nothing else helps, move it to the start ¯\_(ツ)_/¯
  2850. pos = Math.max(0, pos);
  2851. out = [].concat(out.slice(0, pos), [item], out.slice(pos));
  2852. });
  2853. return _extends({}, state, {
  2854. changed: added.length || removed.length || updated.length,
  2855. first: first && added.length === 0,
  2856. transitions: out,
  2857. current: current,
  2858. deleted: deleted,
  2859. prevProps: props
  2860. });
  2861. }
  2862. var AnimatedStyle =
  2863. /*#__PURE__*/
  2864. function (_AnimatedObject) {
  2865. _inheritsLoose(AnimatedStyle, _AnimatedObject);
  2866. function AnimatedStyle(style) {
  2867. var _this;
  2868. if (style === void 0) {
  2869. style = {};
  2870. }
  2871. _this = _AnimatedObject.call(this) || this;
  2872. if (style.transform && !(style.transform instanceof Animated)) {
  2873. style = applyAnimatedValues.transform(style);
  2874. }
  2875. _this.payload = style;
  2876. return _this;
  2877. }
  2878. return AnimatedStyle;
  2879. }(AnimatedObject);
  2880. // http://www.w3.org/TR/css3-color/#svg-color
  2881. var colors = {
  2882. transparent: 0x00000000,
  2883. aliceblue: 0xf0f8ffff,
  2884. antiquewhite: 0xfaebd7ff,
  2885. aqua: 0x00ffffff,
  2886. aquamarine: 0x7fffd4ff,
  2887. azure: 0xf0ffffff,
  2888. beige: 0xf5f5dcff,
  2889. bisque: 0xffe4c4ff,
  2890. black: 0x000000ff,
  2891. blanchedalmond: 0xffebcdff,
  2892. blue: 0x0000ffff,
  2893. blueviolet: 0x8a2be2ff,
  2894. brown: 0xa52a2aff,
  2895. burlywood: 0xdeb887ff,
  2896. burntsienna: 0xea7e5dff,
  2897. cadetblue: 0x5f9ea0ff,
  2898. chartreuse: 0x7fff00ff,
  2899. chocolate: 0xd2691eff,
  2900. coral: 0xff7f50ff,
  2901. cornflowerblue: 0x6495edff,
  2902. cornsilk: 0xfff8dcff,
  2903. crimson: 0xdc143cff,
  2904. cyan: 0x00ffffff,
  2905. darkblue: 0x00008bff,
  2906. darkcyan: 0x008b8bff,
  2907. darkgoldenrod: 0xb8860bff,
  2908. darkgray: 0xa9a9a9ff,
  2909. darkgreen: 0x006400ff,
  2910. darkgrey: 0xa9a9a9ff,
  2911. darkkhaki: 0xbdb76bff,
  2912. darkmagenta: 0x8b008bff,
  2913. darkolivegreen: 0x556b2fff,
  2914. darkorange: 0xff8c00ff,
  2915. darkorchid: 0x9932ccff,
  2916. darkred: 0x8b0000ff,
  2917. darksalmon: 0xe9967aff,
  2918. darkseagreen: 0x8fbc8fff,
  2919. darkslateblue: 0x483d8bff,
  2920. darkslategray: 0x2f4f4fff,
  2921. darkslategrey: 0x2f4f4fff,
  2922. darkturquoise: 0x00ced1ff,
  2923. darkviolet: 0x9400d3ff,
  2924. deeppink: 0xff1493ff,
  2925. deepskyblue: 0x00bfffff,
  2926. dimgray: 0x696969ff,
  2927. dimgrey: 0x696969ff,
  2928. dodgerblue: 0x1e90ffff,
  2929. firebrick: 0xb22222ff,
  2930. floralwhite: 0xfffaf0ff,
  2931. forestgreen: 0x228b22ff,
  2932. fuchsia: 0xff00ffff,
  2933. gainsboro: 0xdcdcdcff,
  2934. ghostwhite: 0xf8f8ffff,
  2935. gold: 0xffd700ff,
  2936. goldenrod: 0xdaa520ff,
  2937. gray: 0x808080ff,
  2938. green: 0x008000ff,
  2939. greenyellow: 0xadff2fff,
  2940. grey: 0x808080ff,
  2941. honeydew: 0xf0fff0ff,
  2942. hotpink: 0xff69b4ff,
  2943. indianred: 0xcd5c5cff,
  2944. indigo: 0x4b0082ff,
  2945. ivory: 0xfffff0ff,
  2946. khaki: 0xf0e68cff,
  2947. lavender: 0xe6e6faff,
  2948. lavenderblush: 0xfff0f5ff,
  2949. lawngreen: 0x7cfc00ff,
  2950. lemonchiffon: 0xfffacdff,
  2951. lightblue: 0xadd8e6ff,
  2952. lightcoral: 0xf08080ff,
  2953. lightcyan: 0xe0ffffff,
  2954. lightgoldenrodyellow: 0xfafad2ff,
  2955. lightgray: 0xd3d3d3ff,
  2956. lightgreen: 0x90ee90ff,
  2957. lightgrey: 0xd3d3d3ff,
  2958. lightpink: 0xffb6c1ff,
  2959. lightsalmon: 0xffa07aff,
  2960. lightseagreen: 0x20b2aaff,
  2961. lightskyblue: 0x87cefaff,
  2962. lightslategray: 0x778899ff,
  2963. lightslategrey: 0x778899ff,
  2964. lightsteelblue: 0xb0c4deff,
  2965. lightyellow: 0xffffe0ff,
  2966. lime: 0x00ff00ff,
  2967. limegreen: 0x32cd32ff,
  2968. linen: 0xfaf0e6ff,
  2969. magenta: 0xff00ffff,
  2970. maroon: 0x800000ff,
  2971. mediumaquamarine: 0x66cdaaff,
  2972. mediumblue: 0x0000cdff,
  2973. mediumorchid: 0xba55d3ff,
  2974. mediumpurple: 0x9370dbff,
  2975. mediumseagreen: 0x3cb371ff,
  2976. mediumslateblue: 0x7b68eeff,
  2977. mediumspringgreen: 0x00fa9aff,
  2978. mediumturquoise: 0x48d1ccff,
  2979. mediumvioletred: 0xc71585ff,
  2980. midnightblue: 0x191970ff,
  2981. mintcream: 0xf5fffaff,
  2982. mistyrose: 0xffe4e1ff,
  2983. moccasin: 0xffe4b5ff,
  2984. navajowhite: 0xffdeadff,
  2985. navy: 0x000080ff,
  2986. oldlace: 0xfdf5e6ff,
  2987. olive: 0x808000ff,
  2988. olivedrab: 0x6b8e23ff,
  2989. orange: 0xffa500ff,
  2990. orangered: 0xff4500ff,
  2991. orchid: 0xda70d6ff,
  2992. palegoldenrod: 0xeee8aaff,
  2993. palegreen: 0x98fb98ff,
  2994. paleturquoise: 0xafeeeeff,
  2995. palevioletred: 0xdb7093ff,
  2996. papayawhip: 0xffefd5ff,
  2997. peachpuff: 0xffdab9ff,
  2998. peru: 0xcd853fff,
  2999. pink: 0xffc0cbff,
  3000. plum: 0xdda0ddff,
  3001. powderblue: 0xb0e0e6ff,
  3002. purple: 0x800080ff,
  3003. rebeccapurple: 0x663399ff,
  3004. red: 0xff0000ff,
  3005. rosybrown: 0xbc8f8fff,
  3006. royalblue: 0x4169e1ff,
  3007. saddlebrown: 0x8b4513ff,
  3008. salmon: 0xfa8072ff,
  3009. sandybrown: 0xf4a460ff,
  3010. seagreen: 0x2e8b57ff,
  3011. seashell: 0xfff5eeff,
  3012. sienna: 0xa0522dff,
  3013. silver: 0xc0c0c0ff,
  3014. skyblue: 0x87ceebff,
  3015. slateblue: 0x6a5acdff,
  3016. slategray: 0x708090ff,
  3017. slategrey: 0x708090ff,
  3018. snow: 0xfffafaff,
  3019. springgreen: 0x00ff7fff,
  3020. steelblue: 0x4682b4ff,
  3021. tan: 0xd2b48cff,
  3022. teal: 0x008080ff,
  3023. thistle: 0xd8bfd8ff,
  3024. tomato: 0xff6347ff,
  3025. turquoise: 0x40e0d0ff,
  3026. violet: 0xee82eeff,
  3027. wheat: 0xf5deb3ff,
  3028. white: 0xffffffff,
  3029. whitesmoke: 0xf5f5f5ff,
  3030. yellow: 0xffff00ff,
  3031. yellowgreen: 0x9acd32ff
  3032. };
  3033. // const INTEGER = '[-+]?\\d+';
  3034. var NUMBER = '[-+]?\\d*\\.?\\d+';
  3035. var PERCENTAGE = NUMBER + '%';
  3036. function call() {
  3037. for (var _len = arguments.length, parts = new Array(_len), _key = 0; _key < _len; _key++) {
  3038. parts[_key] = arguments[_key];
  3039. }
  3040. return '\\(\\s*(' + parts.join(')\\s*,\\s*(') + ')\\s*\\)';
  3041. }
  3042. var rgb = new RegExp('rgb' + call(NUMBER, NUMBER, NUMBER));
  3043. var rgba = new RegExp('rgba' + call(NUMBER, NUMBER, NUMBER, NUMBER));
  3044. var hsl = new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE));
  3045. var hsla = new RegExp('hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
  3046. var hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
  3047. var hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
  3048. var hex6 = /^#([0-9a-fA-F]{6})$/;
  3049. var hex8 = /^#([0-9a-fA-F]{8})$/;
  3050. /*
  3051. https://github.com/react-community/normalize-css-color
  3052. BSD 3-Clause License
  3053. Copyright (c) 2016, React Community
  3054. All rights reserved.
  3055. Redistribution and use in source and binary forms, with or without
  3056. modification, are permitted provided that the following conditions are met:
  3057. * Redistributions of source code must retain the above copyright notice, this
  3058. list of conditions and the following disclaimer.
  3059. * Redistributions in binary form must reproduce the above copyright notice,
  3060. this list of conditions and the following disclaimer in the documentation
  3061. and/or other materials provided with the distribution.
  3062. * Neither the name of the copyright holder nor the names of its
  3063. contributors may be used to endorse or promote products derived from
  3064. this software without specific prior written permission.
  3065. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  3066. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  3067. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  3068. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  3069. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  3070. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  3071. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  3072. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  3073. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  3074. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3075. */
  3076. function normalizeColor(color) {
  3077. var match;
  3078. if (typeof color === 'number') {
  3079. return color >>> 0 === color && color >= 0 && color <= 0xffffffff ? color : null;
  3080. } // Ordered based on occurrences on Facebook codebase
  3081. if (match = hex6.exec(color)) return parseInt(match[1] + 'ff', 16) >>> 0;
  3082. if (colors.hasOwnProperty(color)) return colors[color];
  3083. if (match = rgb.exec(color)) {
  3084. return (parse255(match[1]) << 24 | // r
  3085. parse255(match[2]) << 16 | // g
  3086. parse255(match[3]) << 8 | // b
  3087. 0x000000ff) >>> // a
  3088. 0;
  3089. }
  3090. if (match = rgba.exec(color)) {
  3091. return (parse255(match[1]) << 24 | // r
  3092. parse255(match[2]) << 16 | // g
  3093. parse255(match[3]) << 8 | // b
  3094. parse1(match[4])) >>> // a
  3095. 0;
  3096. }
  3097. if (match = hex3.exec(color)) {
  3098. return parseInt(match[1] + match[1] + // r
  3099. match[2] + match[2] + // g
  3100. match[3] + match[3] + // b
  3101. 'ff', // a
  3102. 16) >>> 0;
  3103. } // https://drafts.csswg.org/css-color-4/#hex-notation
  3104. if (match = hex8.exec(color)) return parseInt(match[1], 16) >>> 0;
  3105. if (match = hex4.exec(color)) {
  3106. return parseInt(match[1] + match[1] + // r
  3107. match[2] + match[2] + // g
  3108. match[3] + match[3] + // b
  3109. match[4] + match[4], // a
  3110. 16) >>> 0;
  3111. }
  3112. if (match = hsl.exec(color)) {
  3113. return (hslToRgb(parse360(match[1]), // h
  3114. parsePercentage(match[2]), // s
  3115. parsePercentage(match[3]) // l
  3116. ) | 0x000000ff) >>> // a
  3117. 0;
  3118. }
  3119. if (match = hsla.exec(color)) {
  3120. return (hslToRgb(parse360(match[1]), // h
  3121. parsePercentage(match[2]), // s
  3122. parsePercentage(match[3]) // l
  3123. ) | parse1(match[4])) >>> // a
  3124. 0;
  3125. }
  3126. return null;
  3127. }
  3128. function hue2rgb(p, q, t) {
  3129. if (t < 0) t += 1;
  3130. if (t > 1) t -= 1;
  3131. if (t < 1 / 6) return p + (q - p) * 6 * t;
  3132. if (t < 1 / 2) return q;
  3133. if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
  3134. return p;
  3135. }
  3136. function hslToRgb(h, s, l) {
  3137. var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
  3138. var p = 2 * l - q;
  3139. var r = hue2rgb(p, q, h + 1 / 3);
  3140. var g = hue2rgb(p, q, h);
  3141. var b = hue2rgb(p, q, h - 1 / 3);
  3142. return Math.round(r * 255) << 24 | Math.round(g * 255) << 16 | Math.round(b * 255) << 8;
  3143. }
  3144. function parse255(str) {
  3145. var int = parseInt(str, 10);
  3146. if (int < 0) return 0;
  3147. if (int > 255) return 255;
  3148. return int;
  3149. }
  3150. function parse360(str) {
  3151. var int = parseFloat(str);
  3152. return (int % 360 + 360) % 360 / 360;
  3153. }
  3154. function parse1(str) {
  3155. var num = parseFloat(str);
  3156. if (num < 0) return 0;
  3157. if (num > 1) return 255;
  3158. return Math.round(num * 255);
  3159. }
  3160. function parsePercentage(str) {
  3161. // parseFloat conveniently ignores the final %
  3162. var int = parseFloat(str);
  3163. if (int < 0) return 0;
  3164. if (int > 100) return 1;
  3165. return int / 100;
  3166. }
  3167. function colorToRgba(input) {
  3168. var int32Color = normalizeColor(input);
  3169. if (int32Color === null) return input;
  3170. int32Color = int32Color || 0;
  3171. var r = (int32Color & 0xff000000) >>> 24;
  3172. var g = (int32Color & 0x00ff0000) >>> 16;
  3173. var b = (int32Color & 0x0000ff00) >>> 8;
  3174. var a = (int32Color & 0x000000ff) / 255;
  3175. return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
  3176. } // Problem: https://github.com/animatedjs/animated/pull/102
  3177. // Solution: https://stackoverflow.com/questions/638565/parsing-scientific-notation-sensibly/658662
  3178. var stringShapeRegex = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g; // Covers rgb, rgba, hsl, hsla
  3179. // Taken from https://gist.github.com/olmokramer/82ccce673f86db7cda5e
  3180. var colorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi; // Covers color names (transparent, blue, etc.)
  3181. var colorNamesRegex = new RegExp("(" + Object.keys(colors).join('|') + ")", 'g');
  3182. /**
  3183. * Supports string shapes by extracting numbers so new values can be computed,
  3184. * and recombines those values into new strings of the same shape. Supports
  3185. * things like:
  3186. *
  3187. * rgba(123, 42, 99, 0.36) // colors
  3188. * -45deg // values with units
  3189. * 0 2px 2px 0px rgba(0, 0, 0, 0.12) // box shadows
  3190. */
  3191. var createStringInterpolator = function createStringInterpolator(config) {
  3192. // Replace colors with rgba
  3193. var outputRange = config.output.map(function (rangeValue) {
  3194. return rangeValue.replace(colorRegex, colorToRgba);
  3195. }).map(function (rangeValue) {
  3196. return rangeValue.replace(colorNamesRegex, colorToRgba);
  3197. });
  3198. var outputRanges = outputRange[0].match(stringShapeRegex).map(function () {
  3199. return [];
  3200. });
  3201. outputRange.forEach(function (value) {
  3202. value.match(stringShapeRegex).forEach(function (number, i) {
  3203. return outputRanges[i].push(+number);
  3204. });
  3205. });
  3206. var interpolations = outputRange[0].match(stringShapeRegex).map(function (_value, i) {
  3207. return createInterpolator(_extends({}, config, {
  3208. output: outputRanges[i]
  3209. }));
  3210. });
  3211. return function (input) {
  3212. var i = 0;
  3213. return outputRange[0] // 'rgba(0, 100, 200, 0)'
  3214. // ->
  3215. // 'rgba(${interpolations[0](input)}, ${interpolations[1](input)}, ...'
  3216. .replace(stringShapeRegex, function () {
  3217. return interpolations[i++](input);
  3218. }) // rgba requires that the r,g,b are integers.... so we want to round them, but we *dont* want to
  3219. // round the opacity (4th column).
  3220. .replace(/rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi, function (_, p1, p2, p3, p4) {
  3221. return "rgba(" + Math.round(p1) + ", " + Math.round(p2) + ", " + Math.round(p3) + ", " + p4 + ")";
  3222. });
  3223. };
  3224. };
  3225. var isUnitlessNumber = {
  3226. animationIterationCount: true,
  3227. borderImageOutset: true,
  3228. borderImageSlice: true,
  3229. borderImageWidth: true,
  3230. boxFlex: true,
  3231. boxFlexGroup: true,
  3232. boxOrdinalGroup: true,
  3233. columnCount: true,
  3234. columns: true,
  3235. flex: true,
  3236. flexGrow: true,
  3237. flexPositive: true,
  3238. flexShrink: true,
  3239. flexNegative: true,
  3240. flexOrder: true,
  3241. gridRow: true,
  3242. gridRowEnd: true,
  3243. gridRowSpan: true,
  3244. gridRowStart: true,
  3245. gridColumn: true,
  3246. gridColumnEnd: true,
  3247. gridColumnSpan: true,
  3248. gridColumnStart: true,
  3249. fontWeight: true,
  3250. lineClamp: true,
  3251. lineHeight: true,
  3252. opacity: true,
  3253. order: true,
  3254. orphans: true,
  3255. tabSize: true,
  3256. widows: true,
  3257. zIndex: true,
  3258. zoom: true,
  3259. // SVG-related properties
  3260. fillOpacity: true,
  3261. floodOpacity: true,
  3262. stopOpacity: true,
  3263. strokeDasharray: true,
  3264. strokeDashoffset: true,
  3265. strokeMiterlimit: true,
  3266. strokeOpacity: true,
  3267. strokeWidth: true
  3268. };
  3269. var prefixKey = function prefixKey(prefix, key) {
  3270. return prefix + key.charAt(0).toUpperCase() + key.substring(1);
  3271. };
  3272. var prefixes = ['Webkit', 'Ms', 'Moz', 'O'];
  3273. isUnitlessNumber = Object.keys(isUnitlessNumber).reduce(function (acc, prop) {
  3274. prefixes.forEach(function (prefix) {
  3275. return acc[prefixKey(prefix, prop)] = acc[prop];
  3276. });
  3277. return acc;
  3278. }, isUnitlessNumber);
  3279. function dangerousStyleValue(name, value, isCustomProperty) {
  3280. if (value == null || typeof value === 'boolean' || value === '') return '';
  3281. if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers
  3282. return ('' + value).trim();
  3283. }
  3284. var attributeCache = {};
  3285. injectCreateAnimatedStyle(function (style) {
  3286. return new AnimatedStyle(style);
  3287. });
  3288. injectDefaultElement('div');
  3289. injectStringInterpolator(createStringInterpolator);
  3290. injectColorNames(colors);
  3291. injectApplyAnimatedValues(function (instance, props) {
  3292. if (instance.nodeType && instance.setAttribute !== undefined) {
  3293. var style = props.style,
  3294. children = props.children,
  3295. scrollTop = props.scrollTop,
  3296. scrollLeft = props.scrollLeft,
  3297. attributes = _objectWithoutPropertiesLoose(props, ["style", "children", "scrollTop", "scrollLeft"]);
  3298. var filter = instance.nodeName === 'filter' || instance.parentNode && instance.parentNode.nodeName === 'filter';
  3299. if (scrollTop !== void 0) instance.scrollTop = scrollTop;
  3300. if (scrollLeft !== void 0) instance.scrollLeft = scrollLeft; // Set textContent, if children is an animatable value
  3301. if (children !== void 0) instance.textContent = children; // Set styles ...
  3302. for (var styleName in style) {
  3303. if (!style.hasOwnProperty(styleName)) continue;
  3304. var isCustomProperty = styleName.indexOf('--') === 0;
  3305. var styleValue = dangerousStyleValue(styleName, style[styleName], isCustomProperty);
  3306. if (styleName === 'float') styleName = 'cssFloat';
  3307. if (isCustomProperty) instance.style.setProperty(styleName, styleValue);else instance.style[styleName] = styleValue;
  3308. } // Set attributes ...
  3309. for (var name in attributes) {
  3310. // Attributes are written in dash case
  3311. var dashCase = filter ? name : attributeCache[name] || (attributeCache[name] = name.replace(/([A-Z])/g, function (n) {
  3312. return '-' + n.toLowerCase();
  3313. }));
  3314. if (typeof instance.getAttribute(dashCase) !== 'undefined') instance.setAttribute(dashCase, attributes[name]);
  3315. }
  3316. return;
  3317. } else return false;
  3318. }, function (style) {
  3319. return style;
  3320. });
  3321. var domElements = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr', // SVG
  3322. 'circle', 'clipPath', 'defs', 'ellipse', 'foreignObject', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'svg', 'text', 'tspan'];
  3323. // Extend animated with all the available THREE elements
  3324. var apply = merge(createAnimatedComponent, false);
  3325. var extendedAnimated = apply(domElements);
  3326. exports.apply = apply;
  3327. exports.config = config;
  3328. exports.update = update;
  3329. exports.animated = extendedAnimated;
  3330. exports.a = extendedAnimated;
  3331. exports.interpolate = interpolate$1;
  3332. exports.Globals = Globals;
  3333. exports.useSpring = useSpring;
  3334. exports.useTrail = useTrail;
  3335. exports.useTransition = useTransition;
  3336. exports.useChain = useChain;
  3337. exports.useSprings = useSprings;
  3338. /***/ }),
  3339. /***/ "Zss7":
  3340. /***/ (function(module, exports, __webpack_require__) {
  3341. var __WEBPACK_AMD_DEFINE_RESULT__;// TinyColor v1.4.2
  3342. // https://github.com/bgrins/TinyColor
  3343. // Brian Grinstead, MIT License
  3344. (function(Math) {
  3345. var trimLeft = /^\s+/,
  3346. trimRight = /\s+$/,
  3347. tinyCounter = 0,
  3348. mathRound = Math.round,
  3349. mathMin = Math.min,
  3350. mathMax = Math.max,
  3351. mathRandom = Math.random;
  3352. function tinycolor (color, opts) {
  3353. color = (color) ? color : '';
  3354. opts = opts || { };
  3355. // If input is already a tinycolor, return itself
  3356. if (color instanceof tinycolor) {
  3357. return color;
  3358. }
  3359. // If we are called as a function, call using new instead
  3360. if (!(this instanceof tinycolor)) {
  3361. return new tinycolor(color, opts);
  3362. }
  3363. var rgb = inputToRGB(color);
  3364. this._originalInput = color,
  3365. this._r = rgb.r,
  3366. this._g = rgb.g,
  3367. this._b = rgb.b,
  3368. this._a = rgb.a,
  3369. this._roundA = mathRound(100*this._a) / 100,
  3370. this._format = opts.format || rgb.format;
  3371. this._gradientType = opts.gradientType;
  3372. // Don't let the range of [0,255] come back in [0,1].
  3373. // Potentially lose a little bit of precision here, but will fix issues where
  3374. // .5 gets interpreted as half of the total, instead of half of 1
  3375. // If it was supposed to be 128, this was already taken care of by `inputToRgb`
  3376. if (this._r < 1) { this._r = mathRound(this._r); }
  3377. if (this._g < 1) { this._g = mathRound(this._g); }
  3378. if (this._b < 1) { this._b = mathRound(this._b); }
  3379. this._ok = rgb.ok;
  3380. this._tc_id = tinyCounter++;
  3381. }
  3382. tinycolor.prototype = {
  3383. isDark: function() {
  3384. return this.getBrightness() < 128;
  3385. },
  3386. isLight: function() {
  3387. return !this.isDark();
  3388. },
  3389. isValid: function() {
  3390. return this._ok;
  3391. },
  3392. getOriginalInput: function() {
  3393. return this._originalInput;
  3394. },
  3395. getFormat: function() {
  3396. return this._format;
  3397. },
  3398. getAlpha: function() {
  3399. return this._a;
  3400. },
  3401. getBrightness: function() {
  3402. //http://www.w3.org/TR/AERT#color-contrast
  3403. var rgb = this.toRgb();
  3404. return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
  3405. },
  3406. getLuminance: function() {
  3407. //http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
  3408. var rgb = this.toRgb();
  3409. var RsRGB, GsRGB, BsRGB, R, G, B;
  3410. RsRGB = rgb.r/255;
  3411. GsRGB = rgb.g/255;
  3412. BsRGB = rgb.b/255;
  3413. if (RsRGB <= 0.03928) {R = RsRGB / 12.92;} else {R = Math.pow(((RsRGB + 0.055) / 1.055), 2.4);}
  3414. if (GsRGB <= 0.03928) {G = GsRGB / 12.92;} else {G = Math.pow(((GsRGB + 0.055) / 1.055), 2.4);}
  3415. if (BsRGB <= 0.03928) {B = BsRGB / 12.92;} else {B = Math.pow(((BsRGB + 0.055) / 1.055), 2.4);}
  3416. return (0.2126 * R) + (0.7152 * G) + (0.0722 * B);
  3417. },
  3418. setAlpha: function(value) {
  3419. this._a = boundAlpha(value);
  3420. this._roundA = mathRound(100*this._a) / 100;
  3421. return this;
  3422. },
  3423. toHsv: function() {
  3424. var hsv = rgbToHsv(this._r, this._g, this._b);
  3425. return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a };
  3426. },
  3427. toHsvString: function() {
  3428. var hsv = rgbToHsv(this._r, this._g, this._b);
  3429. var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100);
  3430. return (this._a == 1) ?
  3431. "hsv(" + h + ", " + s + "%, " + v + "%)" :
  3432. "hsva(" + h + ", " + s + "%, " + v + "%, "+ this._roundA + ")";
  3433. },
  3434. toHsl: function() {
  3435. var hsl = rgbToHsl(this._r, this._g, this._b);
  3436. return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a };
  3437. },
  3438. toHslString: function() {
  3439. var hsl = rgbToHsl(this._r, this._g, this._b);
  3440. var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100);
  3441. return (this._a == 1) ?
  3442. "hsl(" + h + ", " + s + "%, " + l + "%)" :
  3443. "hsla(" + h + ", " + s + "%, " + l + "%, "+ this._roundA + ")";
  3444. },
  3445. toHex: function(allow3Char) {
  3446. return rgbToHex(this._r, this._g, this._b, allow3Char);
  3447. },
  3448. toHexString: function(allow3Char) {
  3449. return '#' + this.toHex(allow3Char);
  3450. },
  3451. toHex8: function(allow4Char) {
  3452. return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char);
  3453. },
  3454. toHex8String: function(allow4Char) {
  3455. return '#' + this.toHex8(allow4Char);
  3456. },
  3457. toRgb: function() {
  3458. return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a };
  3459. },
  3460. toRgbString: function() {
  3461. return (this._a == 1) ?
  3462. "rgb(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ")" :
  3463. "rgba(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ", " + this._roundA + ")";
  3464. },
  3465. toPercentageRgb: function() {
  3466. return { r: mathRound(bound01(this._r, 255) * 100) + "%", g: mathRound(bound01(this._g, 255) * 100) + "%", b: mathRound(bound01(this._b, 255) * 100) + "%", a: this._a };
  3467. },
  3468. toPercentageRgbString: function() {
  3469. return (this._a == 1) ?
  3470. "rgb(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%)" :
  3471. "rgba(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")";
  3472. },
  3473. toName: function() {
  3474. if (this._a === 0) {
  3475. return "transparent";
  3476. }
  3477. if (this._a < 1) {
  3478. return false;
  3479. }
  3480. return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
  3481. },
  3482. toFilter: function(secondColor) {
  3483. var hex8String = '#' + rgbaToArgbHex(this._r, this._g, this._b, this._a);
  3484. var secondHex8String = hex8String;
  3485. var gradientType = this._gradientType ? "GradientType = 1, " : "";
  3486. if (secondColor) {
  3487. var s = tinycolor(secondColor);
  3488. secondHex8String = '#' + rgbaToArgbHex(s._r, s._g, s._b, s._a);
  3489. }
  3490. return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")";
  3491. },
  3492. toString: function(format) {
  3493. var formatSet = !!format;
  3494. format = format || this._format;
  3495. var formattedString = false;
  3496. var hasAlpha = this._a < 1 && this._a >= 0;
  3497. var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name");
  3498. if (needsAlphaFormat) {
  3499. // Special case for "transparent", all other non-alpha formats
  3500. // will return rgba when there is transparency.
  3501. if (format === "name" && this._a === 0) {
  3502. return this.toName();
  3503. }
  3504. return this.toRgbString();
  3505. }
  3506. if (format === "rgb") {
  3507. formattedString = this.toRgbString();
  3508. }
  3509. if (format === "prgb") {
  3510. formattedString = this.toPercentageRgbString();
  3511. }
  3512. if (format === "hex" || format === "hex6") {
  3513. formattedString = this.toHexString();
  3514. }
  3515. if (format === "hex3") {
  3516. formattedString = this.toHexString(true);
  3517. }
  3518. if (format === "hex4") {
  3519. formattedString = this.toHex8String(true);
  3520. }
  3521. if (format === "hex8") {
  3522. formattedString = this.toHex8String();
  3523. }
  3524. if (format === "name") {
  3525. formattedString = this.toName();
  3526. }
  3527. if (format === "hsl") {
  3528. formattedString = this.toHslString();
  3529. }
  3530. if (format === "hsv") {
  3531. formattedString = this.toHsvString();
  3532. }
  3533. return formattedString || this.toHexString();
  3534. },
  3535. clone: function() {
  3536. return tinycolor(this.toString());
  3537. },
  3538. _applyModification: function(fn, args) {
  3539. var color = fn.apply(null, [this].concat([].slice.call(args)));
  3540. this._r = color._r;
  3541. this._g = color._g;
  3542. this._b = color._b;
  3543. this.setAlpha(color._a);
  3544. return this;
  3545. },
  3546. lighten: function() {
  3547. return this._applyModification(lighten, arguments);
  3548. },
  3549. brighten: function() {
  3550. return this._applyModification(brighten, arguments);
  3551. },
  3552. darken: function() {
  3553. return this._applyModification(darken, arguments);
  3554. },
  3555. desaturate: function() {
  3556. return this._applyModification(desaturate, arguments);
  3557. },
  3558. saturate: function() {
  3559. return this._applyModification(saturate, arguments);
  3560. },
  3561. greyscale: function() {
  3562. return this._applyModification(greyscale, arguments);
  3563. },
  3564. spin: function() {
  3565. return this._applyModification(spin, arguments);
  3566. },
  3567. _applyCombination: function(fn, args) {
  3568. return fn.apply(null, [this].concat([].slice.call(args)));
  3569. },
  3570. analogous: function() {
  3571. return this._applyCombination(analogous, arguments);
  3572. },
  3573. complement: function() {
  3574. return this._applyCombination(complement, arguments);
  3575. },
  3576. monochromatic: function() {
  3577. return this._applyCombination(monochromatic, arguments);
  3578. },
  3579. splitcomplement: function() {
  3580. return this._applyCombination(splitcomplement, arguments);
  3581. },
  3582. triad: function() {
  3583. return this._applyCombination(triad, arguments);
  3584. },
  3585. tetrad: function() {
  3586. return this._applyCombination(tetrad, arguments);
  3587. }
  3588. };
  3589. // If input is an object, force 1 into "1.0" to handle ratios properly
  3590. // String input requires "1.0" as input, so 1 will be treated as 1
  3591. tinycolor.fromRatio = function(color, opts) {
  3592. if (typeof color == "object") {
  3593. var newColor = {};
  3594. for (var i in color) {
  3595. if (color.hasOwnProperty(i)) {
  3596. if (i === "a") {
  3597. newColor[i] = color[i];
  3598. }
  3599. else {
  3600. newColor[i] = convertToPercentage(color[i]);
  3601. }
  3602. }
  3603. }
  3604. color = newColor;
  3605. }
  3606. return tinycolor(color, opts);
  3607. };
  3608. // Given a string or object, convert that input to RGB
  3609. // Possible string inputs:
  3610. //
  3611. // "red"
  3612. // "#f00" or "f00"
  3613. // "#ff0000" or "ff0000"
  3614. // "#ff000000" or "ff000000"
  3615. // "rgb 255 0 0" or "rgb (255, 0, 0)"
  3616. // "rgb 1.0 0 0" or "rgb (1, 0, 0)"
  3617. // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
  3618. // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
  3619. // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
  3620. // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
  3621. // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
  3622. //
  3623. function inputToRGB(color) {
  3624. var rgb = { r: 0, g: 0, b: 0 };
  3625. var a = 1;
  3626. var s = null;
  3627. var v = null;
  3628. var l = null;
  3629. var ok = false;
  3630. var format = false;
  3631. if (typeof color == "string") {
  3632. color = stringInputToObject(color);
  3633. }
  3634. if (typeof color == "object") {
  3635. if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
  3636. rgb = rgbToRgb(color.r, color.g, color.b);
  3637. ok = true;
  3638. format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
  3639. }
  3640. else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
  3641. s = convertToPercentage(color.s);
  3642. v = convertToPercentage(color.v);
  3643. rgb = hsvToRgb(color.h, s, v);
  3644. ok = true;
  3645. format = "hsv";
  3646. }
  3647. else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
  3648. s = convertToPercentage(color.s);
  3649. l = convertToPercentage(color.l);
  3650. rgb = hslToRgb(color.h, s, l);
  3651. ok = true;
  3652. format = "hsl";
  3653. }
  3654. if (color.hasOwnProperty("a")) {
  3655. a = color.a;
  3656. }
  3657. }
  3658. a = boundAlpha(a);
  3659. return {
  3660. ok: ok,
  3661. format: color.format || format,
  3662. r: mathMin(255, mathMax(rgb.r, 0)),
  3663. g: mathMin(255, mathMax(rgb.g, 0)),
  3664. b: mathMin(255, mathMax(rgb.b, 0)),
  3665. a: a
  3666. };
  3667. }
  3668. // Conversion Functions
  3669. // --------------------
  3670. // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
  3671. // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
  3672. // `rgbToRgb`
  3673. // Handle bounds / percentage checking to conform to CSS color spec
  3674. // <http://www.w3.org/TR/css3-color/>
  3675. // *Assumes:* r, g, b in [0, 255] or [0, 1]
  3676. // *Returns:* { r, g, b } in [0, 255]
  3677. function rgbToRgb(r, g, b){
  3678. return {
  3679. r: bound01(r, 255) * 255,
  3680. g: bound01(g, 255) * 255,
  3681. b: bound01(b, 255) * 255
  3682. };
  3683. }
  3684. // `rgbToHsl`
  3685. // Converts an RGB color value to HSL.
  3686. // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
  3687. // *Returns:* { h, s, l } in [0,1]
  3688. function rgbToHsl(r, g, b) {
  3689. r = bound01(r, 255);
  3690. g = bound01(g, 255);
  3691. b = bound01(b, 255);
  3692. var max = mathMax(r, g, b), min = mathMin(r, g, b);
  3693. var h, s, l = (max + min) / 2;
  3694. if(max == min) {
  3695. h = s = 0; // achromatic
  3696. }
  3697. else {
  3698. var d = max - min;
  3699. s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
  3700. switch(max) {
  3701. case r: h = (g - b) / d + (g < b ? 6 : 0); break;
  3702. case g: h = (b - r) / d + 2; break;
  3703. case b: h = (r - g) / d + 4; break;
  3704. }
  3705. h /= 6;
  3706. }
  3707. return { h: h, s: s, l: l };
  3708. }
  3709. // `hslToRgb`
  3710. // Converts an HSL color value to RGB.
  3711. // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
  3712. // *Returns:* { r, g, b } in the set [0, 255]
  3713. function hslToRgb(h, s, l) {
  3714. var r, g, b;
  3715. h = bound01(h, 360);
  3716. s = bound01(s, 100);
  3717. l = bound01(l, 100);
  3718. function hue2rgb(p, q, t) {
  3719. if(t < 0) t += 1;
  3720. if(t > 1) t -= 1;
  3721. if(t < 1/6) return p + (q - p) * 6 * t;
  3722. if(t < 1/2) return q;
  3723. if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
  3724. return p;
  3725. }
  3726. if(s === 0) {
  3727. r = g = b = l; // achromatic
  3728. }
  3729. else {
  3730. var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
  3731. var p = 2 * l - q;
  3732. r = hue2rgb(p, q, h + 1/3);
  3733. g = hue2rgb(p, q, h);
  3734. b = hue2rgb(p, q, h - 1/3);
  3735. }
  3736. return { r: r * 255, g: g * 255, b: b * 255 };
  3737. }
  3738. // `rgbToHsv`
  3739. // Converts an RGB color value to HSV
  3740. // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
  3741. // *Returns:* { h, s, v } in [0,1]
  3742. function rgbToHsv(r, g, b) {
  3743. r = bound01(r, 255);
  3744. g = bound01(g, 255);
  3745. b = bound01(b, 255);
  3746. var max = mathMax(r, g, b), min = mathMin(r, g, b);
  3747. var h, s, v = max;
  3748. var d = max - min;
  3749. s = max === 0 ? 0 : d / max;
  3750. if(max == min) {
  3751. h = 0; // achromatic
  3752. }
  3753. else {
  3754. switch(max) {
  3755. case r: h = (g - b) / d + (g < b ? 6 : 0); break;
  3756. case g: h = (b - r) / d + 2; break;
  3757. case b: h = (r - g) / d + 4; break;
  3758. }
  3759. h /= 6;
  3760. }
  3761. return { h: h, s: s, v: v };
  3762. }
  3763. // `hsvToRgb`
  3764. // Converts an HSV color value to RGB.
  3765. // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
  3766. // *Returns:* { r, g, b } in the set [0, 255]
  3767. function hsvToRgb(h, s, v) {
  3768. h = bound01(h, 360) * 6;
  3769. s = bound01(s, 100);
  3770. v = bound01(v, 100);
  3771. var i = Math.floor(h),
  3772. f = h - i,
  3773. p = v * (1 - s),
  3774. q = v * (1 - f * s),
  3775. t = v * (1 - (1 - f) * s),
  3776. mod = i % 6,
  3777. r = [v, q, p, p, t, v][mod],
  3778. g = [t, v, v, q, p, p][mod],
  3779. b = [p, p, t, v, v, q][mod];
  3780. return { r: r * 255, g: g * 255, b: b * 255 };
  3781. }
  3782. // `rgbToHex`
  3783. // Converts an RGB color to hex
  3784. // Assumes r, g, and b are contained in the set [0, 255]
  3785. // Returns a 3 or 6 character hex
  3786. function rgbToHex(r, g, b, allow3Char) {
  3787. var hex = [
  3788. pad2(mathRound(r).toString(16)),
  3789. pad2(mathRound(g).toString(16)),
  3790. pad2(mathRound(b).toString(16))
  3791. ];
  3792. // Return a 3 character hex if possible
  3793. if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
  3794. return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
  3795. }
  3796. return hex.join("");
  3797. }
  3798. // `rgbaToHex`
  3799. // Converts an RGBA color plus alpha transparency to hex
  3800. // Assumes r, g, b are contained in the set [0, 255] and
  3801. // a in [0, 1]. Returns a 4 or 8 character rgba hex
  3802. function rgbaToHex(r, g, b, a, allow4Char) {
  3803. var hex = [
  3804. pad2(mathRound(r).toString(16)),
  3805. pad2(mathRound(g).toString(16)),
  3806. pad2(mathRound(b).toString(16)),
  3807. pad2(convertDecimalToHex(a))
  3808. ];
  3809. // Return a 4 character hex if possible
  3810. if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) {
  3811. return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
  3812. }
  3813. return hex.join("");
  3814. }
  3815. // `rgbaToArgbHex`
  3816. // Converts an RGBA color to an ARGB Hex8 string
  3817. // Rarely used, but required for "toFilter()"
  3818. function rgbaToArgbHex(r, g, b, a) {
  3819. var hex = [
  3820. pad2(convertDecimalToHex(a)),
  3821. pad2(mathRound(r).toString(16)),
  3822. pad2(mathRound(g).toString(16)),
  3823. pad2(mathRound(b).toString(16))
  3824. ];
  3825. return hex.join("");
  3826. }
  3827. // `equals`
  3828. // Can be called with any tinycolor input
  3829. tinycolor.equals = function (color1, color2) {
  3830. if (!color1 || !color2) { return false; }
  3831. return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
  3832. };
  3833. tinycolor.random = function() {
  3834. return tinycolor.fromRatio({
  3835. r: mathRandom(),
  3836. g: mathRandom(),
  3837. b: mathRandom()
  3838. });
  3839. };
  3840. // Modification Functions
  3841. // ----------------------
  3842. // Thanks to less.js for some of the basics here
  3843. // <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>
  3844. function desaturate(color, amount) {
  3845. amount = (amount === 0) ? 0 : (amount || 10);
  3846. var hsl = tinycolor(color).toHsl();
  3847. hsl.s -= amount / 100;
  3848. hsl.s = clamp01(hsl.s);
  3849. return tinycolor(hsl);
  3850. }
  3851. function saturate(color, amount) {
  3852. amount = (amount === 0) ? 0 : (amount || 10);
  3853. var hsl = tinycolor(color).toHsl();
  3854. hsl.s += amount / 100;
  3855. hsl.s = clamp01(hsl.s);
  3856. return tinycolor(hsl);
  3857. }
  3858. function greyscale(color) {
  3859. return tinycolor(color).desaturate(100);
  3860. }
  3861. function lighten (color, amount) {
  3862. amount = (amount === 0) ? 0 : (amount || 10);
  3863. var hsl = tinycolor(color).toHsl();
  3864. hsl.l += amount / 100;
  3865. hsl.l = clamp01(hsl.l);
  3866. return tinycolor(hsl);
  3867. }
  3868. function brighten(color, amount) {
  3869. amount = (amount === 0) ? 0 : (amount || 10);
  3870. var rgb = tinycolor(color).toRgb();
  3871. rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100))));
  3872. rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100))));
  3873. rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100))));
  3874. return tinycolor(rgb);
  3875. }
  3876. function darken (color, amount) {
  3877. amount = (amount === 0) ? 0 : (amount || 10);
  3878. var hsl = tinycolor(color).toHsl();
  3879. hsl.l -= amount / 100;
  3880. hsl.l = clamp01(hsl.l);
  3881. return tinycolor(hsl);
  3882. }
  3883. // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
  3884. // Values outside of this range will be wrapped into this range.
  3885. function spin(color, amount) {
  3886. var hsl = tinycolor(color).toHsl();
  3887. var hue = (hsl.h + amount) % 360;
  3888. hsl.h = hue < 0 ? 360 + hue : hue;
  3889. return tinycolor(hsl);
  3890. }
  3891. // Combination Functions
  3892. // ---------------------
  3893. // Thanks to jQuery xColor for some of the ideas behind these
  3894. // <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>
  3895. function complement(color) {
  3896. var hsl = tinycolor(color).toHsl();
  3897. hsl.h = (hsl.h + 180) % 360;
  3898. return tinycolor(hsl);
  3899. }
  3900. function triad(color) {
  3901. var hsl = tinycolor(color).toHsl();
  3902. var h = hsl.h;
  3903. return [
  3904. tinycolor(color),
  3905. tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }),
  3906. tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l })
  3907. ];
  3908. }
  3909. function tetrad(color) {
  3910. var hsl = tinycolor(color).toHsl();
  3911. var h = hsl.h;
  3912. return [
  3913. tinycolor(color),
  3914. tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }),
  3915. tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }),
  3916. tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l })
  3917. ];
  3918. }
  3919. function splitcomplement(color) {
  3920. var hsl = tinycolor(color).toHsl();
  3921. var h = hsl.h;
  3922. return [
  3923. tinycolor(color),
  3924. tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}),
  3925. tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l})
  3926. ];
  3927. }
  3928. function analogous(color, results, slices) {
  3929. results = results || 6;
  3930. slices = slices || 30;
  3931. var hsl = tinycolor(color).toHsl();
  3932. var part = 360 / slices;
  3933. var ret = [tinycolor(color)];
  3934. for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) {
  3935. hsl.h = (hsl.h + part) % 360;
  3936. ret.push(tinycolor(hsl));
  3937. }
  3938. return ret;
  3939. }
  3940. function monochromatic(color, results) {
  3941. results = results || 6;
  3942. var hsv = tinycolor(color).toHsv();
  3943. var h = hsv.h, s = hsv.s, v = hsv.v;
  3944. var ret = [];
  3945. var modification = 1 / results;
  3946. while (results--) {
  3947. ret.push(tinycolor({ h: h, s: s, v: v}));
  3948. v = (v + modification) % 1;
  3949. }
  3950. return ret;
  3951. }
  3952. // Utility Functions
  3953. // ---------------------
  3954. tinycolor.mix = function(color1, color2, amount) {
  3955. amount = (amount === 0) ? 0 : (amount || 50);
  3956. var rgb1 = tinycolor(color1).toRgb();
  3957. var rgb2 = tinycolor(color2).toRgb();
  3958. var p = amount / 100;
  3959. var rgba = {
  3960. r: ((rgb2.r - rgb1.r) * p) + rgb1.r,
  3961. g: ((rgb2.g - rgb1.g) * p) + rgb1.g,
  3962. b: ((rgb2.b - rgb1.b) * p) + rgb1.b,
  3963. a: ((rgb2.a - rgb1.a) * p) + rgb1.a
  3964. };
  3965. return tinycolor(rgba);
  3966. };
  3967. // Readability Functions
  3968. // ---------------------
  3969. // <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
  3970. // `contrast`
  3971. // Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
  3972. tinycolor.readability = function(color1, color2) {
  3973. var c1 = tinycolor(color1);
  3974. var c2 = tinycolor(color2);
  3975. return (Math.max(c1.getLuminance(),c2.getLuminance())+0.05) / (Math.min(c1.getLuminance(),c2.getLuminance())+0.05);
  3976. };
  3977. // `isReadable`
  3978. // Ensure that foreground and background color combinations meet WCAG2 guidelines.
  3979. // The third argument is an optional Object.
  3980. // the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';
  3981. // the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.
  3982. // If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
  3983. // *Example*
  3984. // tinycolor.isReadable("#000", "#111") => false
  3985. // tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false
  3986. tinycolor.isReadable = function(color1, color2, wcag2) {
  3987. var readability = tinycolor.readability(color1, color2);
  3988. var wcag2Parms, out;
  3989. out = false;
  3990. wcag2Parms = validateWCAG2Parms(wcag2);
  3991. switch (wcag2Parms.level + wcag2Parms.size) {
  3992. case "AAsmall":
  3993. case "AAAlarge":
  3994. out = readability >= 4.5;
  3995. break;
  3996. case "AAlarge":
  3997. out = readability >= 3;
  3998. break;
  3999. case "AAAsmall":
  4000. out = readability >= 7;
  4001. break;
  4002. }
  4003. return out;
  4004. };
  4005. // `mostReadable`
  4006. // Given a base color and a list of possible foreground or background
  4007. // colors for that base, returns the most readable color.
  4008. // Optionally returns Black or White if the most readable color is unreadable.
  4009. // *Example*
  4010. // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255"
  4011. // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff"
  4012. // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3"
  4013. // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff"
  4014. tinycolor.mostReadable = function(baseColor, colorList, args) {
  4015. var bestColor = null;
  4016. var bestScore = 0;
  4017. var readability;
  4018. var includeFallbackColors, level, size ;
  4019. args = args || {};
  4020. includeFallbackColors = args.includeFallbackColors ;
  4021. level = args.level;
  4022. size = args.size;
  4023. for (var i= 0; i < colorList.length ; i++) {
  4024. readability = tinycolor.readability(baseColor, colorList[i]);
  4025. if (readability > bestScore) {
  4026. bestScore = readability;
  4027. bestColor = tinycolor(colorList[i]);
  4028. }
  4029. }
  4030. if (tinycolor.isReadable(baseColor, bestColor, {"level":level,"size":size}) || !includeFallbackColors) {
  4031. return bestColor;
  4032. }
  4033. else {
  4034. args.includeFallbackColors=false;
  4035. return tinycolor.mostReadable(baseColor,["#fff", "#000"],args);
  4036. }
  4037. };
  4038. // Big List of Colors
  4039. // ------------------
  4040. // <http://www.w3.org/TR/css3-color/#svg-color>
  4041. var names = tinycolor.names = {
  4042. aliceblue: "f0f8ff",
  4043. antiquewhite: "faebd7",
  4044. aqua: "0ff",
  4045. aquamarine: "7fffd4",
  4046. azure: "f0ffff",
  4047. beige: "f5f5dc",
  4048. bisque: "ffe4c4",
  4049. black: "000",
  4050. blanchedalmond: "ffebcd",
  4051. blue: "00f",
  4052. blueviolet: "8a2be2",
  4053. brown: "a52a2a",
  4054. burlywood: "deb887",
  4055. burntsienna: "ea7e5d",
  4056. cadetblue: "5f9ea0",
  4057. chartreuse: "7fff00",
  4058. chocolate: "d2691e",
  4059. coral: "ff7f50",
  4060. cornflowerblue: "6495ed",
  4061. cornsilk: "fff8dc",
  4062. crimson: "dc143c",
  4063. cyan: "0ff",
  4064. darkblue: "00008b",
  4065. darkcyan: "008b8b",
  4066. darkgoldenrod: "b8860b",
  4067. darkgray: "a9a9a9",
  4068. darkgreen: "006400",
  4069. darkgrey: "a9a9a9",
  4070. darkkhaki: "bdb76b",
  4071. darkmagenta: "8b008b",
  4072. darkolivegreen: "556b2f",
  4073. darkorange: "ff8c00",
  4074. darkorchid: "9932cc",
  4075. darkred: "8b0000",
  4076. darksalmon: "e9967a",
  4077. darkseagreen: "8fbc8f",
  4078. darkslateblue: "483d8b",
  4079. darkslategray: "2f4f4f",
  4080. darkslategrey: "2f4f4f",
  4081. darkturquoise: "00ced1",
  4082. darkviolet: "9400d3",
  4083. deeppink: "ff1493",
  4084. deepskyblue: "00bfff",
  4085. dimgray: "696969",
  4086. dimgrey: "696969",
  4087. dodgerblue: "1e90ff",
  4088. firebrick: "b22222",
  4089. floralwhite: "fffaf0",
  4090. forestgreen: "228b22",
  4091. fuchsia: "f0f",
  4092. gainsboro: "dcdcdc",
  4093. ghostwhite: "f8f8ff",
  4094. gold: "ffd700",
  4095. goldenrod: "daa520",
  4096. gray: "808080",
  4097. green: "008000",
  4098. greenyellow: "adff2f",
  4099. grey: "808080",
  4100. honeydew: "f0fff0",
  4101. hotpink: "ff69b4",
  4102. indianred: "cd5c5c",
  4103. indigo: "4b0082",
  4104. ivory: "fffff0",
  4105. khaki: "f0e68c",
  4106. lavender: "e6e6fa",
  4107. lavenderblush: "fff0f5",
  4108. lawngreen: "7cfc00",
  4109. lemonchiffon: "fffacd",
  4110. lightblue: "add8e6",
  4111. lightcoral: "f08080",
  4112. lightcyan: "e0ffff",
  4113. lightgoldenrodyellow: "fafad2",
  4114. lightgray: "d3d3d3",
  4115. lightgreen: "90ee90",
  4116. lightgrey: "d3d3d3",
  4117. lightpink: "ffb6c1",
  4118. lightsalmon: "ffa07a",
  4119. lightseagreen: "20b2aa",
  4120. lightskyblue: "87cefa",
  4121. lightslategray: "789",
  4122. lightslategrey: "789",
  4123. lightsteelblue: "b0c4de",
  4124. lightyellow: "ffffe0",
  4125. lime: "0f0",
  4126. limegreen: "32cd32",
  4127. linen: "faf0e6",
  4128. magenta: "f0f",
  4129. maroon: "800000",
  4130. mediumaquamarine: "66cdaa",
  4131. mediumblue: "0000cd",
  4132. mediumorchid: "ba55d3",
  4133. mediumpurple: "9370db",
  4134. mediumseagreen: "3cb371",
  4135. mediumslateblue: "7b68ee",
  4136. mediumspringgreen: "00fa9a",
  4137. mediumturquoise: "48d1cc",
  4138. mediumvioletred: "c71585",
  4139. midnightblue: "191970",
  4140. mintcream: "f5fffa",
  4141. mistyrose: "ffe4e1",
  4142. moccasin: "ffe4b5",
  4143. navajowhite: "ffdead",
  4144. navy: "000080",
  4145. oldlace: "fdf5e6",
  4146. olive: "808000",
  4147. olivedrab: "6b8e23",
  4148. orange: "ffa500",
  4149. orangered: "ff4500",
  4150. orchid: "da70d6",
  4151. palegoldenrod: "eee8aa",
  4152. palegreen: "98fb98",
  4153. paleturquoise: "afeeee",
  4154. palevioletred: "db7093",
  4155. papayawhip: "ffefd5",
  4156. peachpuff: "ffdab9",
  4157. peru: "cd853f",
  4158. pink: "ffc0cb",
  4159. plum: "dda0dd",
  4160. powderblue: "b0e0e6",
  4161. purple: "800080",
  4162. rebeccapurple: "663399",
  4163. red: "f00",
  4164. rosybrown: "bc8f8f",
  4165. royalblue: "4169e1",
  4166. saddlebrown: "8b4513",
  4167. salmon: "fa8072",
  4168. sandybrown: "f4a460",
  4169. seagreen: "2e8b57",
  4170. seashell: "fff5ee",
  4171. sienna: "a0522d",
  4172. silver: "c0c0c0",
  4173. skyblue: "87ceeb",
  4174. slateblue: "6a5acd",
  4175. slategray: "708090",
  4176. slategrey: "708090",
  4177. snow: "fffafa",
  4178. springgreen: "00ff7f",
  4179. steelblue: "4682b4",
  4180. tan: "d2b48c",
  4181. teal: "008080",
  4182. thistle: "d8bfd8",
  4183. tomato: "ff6347",
  4184. turquoise: "40e0d0",
  4185. violet: "ee82ee",
  4186. wheat: "f5deb3",
  4187. white: "fff",
  4188. whitesmoke: "f5f5f5",
  4189. yellow: "ff0",
  4190. yellowgreen: "9acd32"
  4191. };
  4192. // Make it easy to access colors via `hexNames[hex]`
  4193. var hexNames = tinycolor.hexNames = flip(names);
  4194. // Utilities
  4195. // ---------
  4196. // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
  4197. function flip(o) {
  4198. var flipped = { };
  4199. for (var i in o) {
  4200. if (o.hasOwnProperty(i)) {
  4201. flipped[o[i]] = i;
  4202. }
  4203. }
  4204. return flipped;
  4205. }
  4206. // Return a valid alpha value [0,1] with all invalid values being set to 1
  4207. function boundAlpha(a) {
  4208. a = parseFloat(a);
  4209. if (isNaN(a) || a < 0 || a > 1) {
  4210. a = 1;
  4211. }
  4212. return a;
  4213. }
  4214. // Take input from [0, n] and return it as [0, 1]
  4215. function bound01(n, max) {
  4216. if (isOnePointZero(n)) { n = "100%"; }
  4217. var processPercent = isPercentage(n);
  4218. n = mathMin(max, mathMax(0, parseFloat(n)));
  4219. // Automatically convert percentage into number
  4220. if (processPercent) {
  4221. n = parseInt(n * max, 10) / 100;
  4222. }
  4223. // Handle floating point rounding errors
  4224. if ((Math.abs(n - max) < 0.000001)) {
  4225. return 1;
  4226. }
  4227. // Convert into [0, 1] range if it isn't already
  4228. return (n % max) / parseFloat(max);
  4229. }
  4230. // Force a number between 0 and 1
  4231. function clamp01(val) {
  4232. return mathMin(1, mathMax(0, val));
  4233. }
  4234. // Parse a base-16 hex value into a base-10 integer
  4235. function parseIntFromHex(val) {
  4236. return parseInt(val, 16);
  4237. }
  4238. // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
  4239. // <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
  4240. function isOnePointZero(n) {
  4241. return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1;
  4242. }
  4243. // Check to see if string passed in is a percentage
  4244. function isPercentage(n) {
  4245. return typeof n === "string" && n.indexOf('%') != -1;
  4246. }
  4247. // Force a hex value to have 2 characters
  4248. function pad2(c) {
  4249. return c.length == 1 ? '0' + c : '' + c;
  4250. }
  4251. // Replace a decimal with it's percentage value
  4252. function convertToPercentage(n) {
  4253. if (n <= 1) {
  4254. n = (n * 100) + "%";
  4255. }
  4256. return n;
  4257. }
  4258. // Converts a decimal to a hex value
  4259. function convertDecimalToHex(d) {
  4260. return Math.round(parseFloat(d) * 255).toString(16);
  4261. }
  4262. // Converts a hex value to a decimal
  4263. function convertHexToDecimal(h) {
  4264. return (parseIntFromHex(h) / 255);
  4265. }
  4266. var matchers = (function() {
  4267. // <http://www.w3.org/TR/css3-values/#integers>
  4268. var CSS_INTEGER = "[-\\+]?\\d+%?";
  4269. // <http://www.w3.org/TR/css3-values/#number-value>
  4270. var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
  4271. // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
  4272. var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
  4273. // Actual matching.
  4274. // Parentheses and commas are optional, but not required.
  4275. // Whitespace can take the place of commas or opening paren
  4276. var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
  4277. var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
  4278. return {
  4279. CSS_UNIT: new RegExp(CSS_UNIT),
  4280. rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
  4281. rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
  4282. hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
  4283. hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
  4284. hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
  4285. hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
  4286. hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
  4287. hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
  4288. hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
  4289. hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
  4290. };
  4291. })();
  4292. // `isValidCSSUnit`
  4293. // Take in a single string / number and check to see if it looks like a CSS unit
  4294. // (see `matchers` above for definition).
  4295. function isValidCSSUnit(color) {
  4296. return !!matchers.CSS_UNIT.exec(color);
  4297. }
  4298. // `stringInputToObject`
  4299. // Permissive string parsing. Take in a number of formats, and output an object
  4300. // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
  4301. function stringInputToObject(color) {
  4302. color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase();
  4303. var named = false;
  4304. if (names[color]) {
  4305. color = names[color];
  4306. named = true;
  4307. }
  4308. else if (color == 'transparent') {
  4309. return { r: 0, g: 0, b: 0, a: 0, format: "name" };
  4310. }
  4311. // Try to match string input using regular expressions.
  4312. // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
  4313. // Just return an object and let the conversion functions handle that.
  4314. // This way the result will be the same whether the tinycolor is initialized with string or object.
  4315. var match;
  4316. if ((match = matchers.rgb.exec(color))) {
  4317. return { r: match[1], g: match[2], b: match[3] };
  4318. }
  4319. if ((match = matchers.rgba.exec(color))) {
  4320. return { r: match[1], g: match[2], b: match[3], a: match[4] };
  4321. }
  4322. if ((match = matchers.hsl.exec(color))) {
  4323. return { h: match[1], s: match[2], l: match[3] };
  4324. }
  4325. if ((match = matchers.hsla.exec(color))) {
  4326. return { h: match[1], s: match[2], l: match[3], a: match[4] };
  4327. }
  4328. if ((match = matchers.hsv.exec(color))) {
  4329. return { h: match[1], s: match[2], v: match[3] };
  4330. }
  4331. if ((match = matchers.hsva.exec(color))) {
  4332. return { h: match[1], s: match[2], v: match[3], a: match[4] };
  4333. }
  4334. if ((match = matchers.hex8.exec(color))) {
  4335. return {
  4336. r: parseIntFromHex(match[1]),
  4337. g: parseIntFromHex(match[2]),
  4338. b: parseIntFromHex(match[3]),
  4339. a: convertHexToDecimal(match[4]),
  4340. format: named ? "name" : "hex8"
  4341. };
  4342. }
  4343. if ((match = matchers.hex6.exec(color))) {
  4344. return {
  4345. r: parseIntFromHex(match[1]),
  4346. g: parseIntFromHex(match[2]),
  4347. b: parseIntFromHex(match[3]),
  4348. format: named ? "name" : "hex"
  4349. };
  4350. }
  4351. if ((match = matchers.hex4.exec(color))) {
  4352. return {
  4353. r: parseIntFromHex(match[1] + '' + match[1]),
  4354. g: parseIntFromHex(match[2] + '' + match[2]),
  4355. b: parseIntFromHex(match[3] + '' + match[3]),
  4356. a: convertHexToDecimal(match[4] + '' + match[4]),
  4357. format: named ? "name" : "hex8"
  4358. };
  4359. }
  4360. if ((match = matchers.hex3.exec(color))) {
  4361. return {
  4362. r: parseIntFromHex(match[1] + '' + match[1]),
  4363. g: parseIntFromHex(match[2] + '' + match[2]),
  4364. b: parseIntFromHex(match[3] + '' + match[3]),
  4365. format: named ? "name" : "hex"
  4366. };
  4367. }
  4368. return false;
  4369. }
  4370. function validateWCAG2Parms(parms) {
  4371. // return valid WCAG2 parms for isReadable.
  4372. // If input parms are invalid, return {"level":"AA", "size":"small"}
  4373. var level, size;
  4374. parms = parms || {"level":"AA", "size":"small"};
  4375. level = (parms.level || "AA").toUpperCase();
  4376. size = (parms.size || "small").toLowerCase();
  4377. if (level !== "AA" && level !== "AAA") {
  4378. level = "AA";
  4379. }
  4380. if (size !== "small" && size !== "large") {
  4381. size = "small";
  4382. }
  4383. return {"level":level, "size":size};
  4384. }
  4385. // Node: Export function
  4386. if ( true && module.exports) {
  4387. module.exports = tinycolor;
  4388. }
  4389. // AMD/requirejs: Define the module
  4390. else if (true) {
  4391. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {return tinycolor;}).call(exports, __webpack_require__, exports, module),
  4392. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  4393. }
  4394. // Browser: Expose to window
  4395. else {}
  4396. })(Math);
  4397. /***/ }),
  4398. /***/ "b2RC":
  4399. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4400. "use strict";
  4401. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  4402. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  4403. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  4404. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  4405. /**
  4406. * WordPress dependencies
  4407. */
  4408. const grid = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  4409. xmlns: "http://www.w3.org/2000/svg",
  4410. viewBox: "0 0 24 24"
  4411. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  4412. d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7.8 16.5H5c-.3 0-.5-.2-.5-.5v-6.2h6.8v6.7zm0-8.3H4.5V5c0-.3.2-.5.5-.5h6.2v6.7zm8.3 7.8c0 .3-.2.5-.5.5h-6.2v-6.8h6.8V19zm0-7.8h-6.8V4.5H19c.3 0 .5.2.5.5v6.2z",
  4413. fillRule: "evenodd",
  4414. clipRule: "evenodd"
  4415. }));
  4416. /* harmony default export */ __webpack_exports__["a"] = (grid);
  4417. /***/ }),
  4418. /***/ "bWcr":
  4419. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4420. "use strict";
  4421. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  4422. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  4423. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  4424. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  4425. /**
  4426. * WordPress dependencies
  4427. */
  4428. const closeSmall = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  4429. xmlns: "http://www.w3.org/2000/svg",
  4430. viewBox: "0 0 24 24"
  4431. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  4432. d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"
  4433. }));
  4434. /* harmony default export */ __webpack_exports__["a"] = (closeSmall);
  4435. /***/ }),
  4436. /***/ "btIw":
  4437. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4438. "use strict";
  4439. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  4440. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  4441. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  4442. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  4443. /**
  4444. * WordPress dependencies
  4445. */
  4446. const keyboardReturn = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  4447. xmlns: "http://www.w3.org/2000/svg",
  4448. viewBox: "-2 -2 24 24"
  4449. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  4450. d: "M6.734 16.106l2.176-2.38-1.093-1.028-3.846 4.158 3.846 4.157 1.093-1.027-2.176-2.38h2.811c1.125 0 2.25.03 3.374 0 1.428-.001 3.362-.25 4.963-1.277 1.66-1.065 2.868-2.906 2.868-5.859 0-2.479-1.327-4.896-3.65-5.93-1.82-.813-3.044-.8-4.806-.788l-.567.002v1.5c.184 0 .368 0 .553-.002 1.82-.007 2.704-.014 4.21.657 1.854.827 2.76 2.657 2.76 4.561 0 2.472-.973 3.824-2.178 4.596-1.258.807-2.864 1.04-4.163 1.04h-.02c-1.115.03-2.229 0-3.344 0H6.734z"
  4451. }));
  4452. /* harmony default export */ __webpack_exports__["a"] = (keyboardReturn);
  4453. /***/ }),
  4454. /***/ "cDcd":
  4455. /***/ (function(module, exports) {
  4456. (function() { module.exports = window["React"]; }());
  4457. /***/ }),
  4458. /***/ "cGtP":
  4459. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4460. "use strict";
  4461. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  4462. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  4463. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  4464. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  4465. /**
  4466. * WordPress dependencies
  4467. */
  4468. const search = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  4469. xmlns: "http://www.w3.org/2000/svg",
  4470. viewBox: "0 0 24 24"
  4471. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  4472. d: "M13.5 6C10.5 6 8 8.5 8 11.5c0 1.1.3 2.1.9 3l-3.4 3 1 1.1 3.4-2.9c1 .9 2.2 1.4 3.6 1.4 3 0 5.5-2.5 5.5-5.5C19 8.5 16.5 6 13.5 6zm0 9.5c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4-1.8 4-4 4z"
  4473. }));
  4474. /* harmony default export */ __webpack_exports__["a"] = (search);
  4475. /***/ }),
  4476. /***/ "cjQ8":
  4477. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4478. "use strict";
  4479. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  4480. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  4481. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  4482. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  4483. /**
  4484. * WordPress dependencies
  4485. */
  4486. const arrowLeft = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  4487. xmlns: "http://www.w3.org/2000/svg",
  4488. viewBox: "0 0 24 24"
  4489. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  4490. d: "M20 10.8H6.7l4.1-4.5-1.1-1.1-5.8 6.3 5.8 5.8 1.1-1.1-4-3.9H20z"
  4491. }));
  4492. /* harmony default export */ __webpack_exports__["a"] = (arrowLeft);
  4493. /***/ }),
  4494. /***/ "eGrx":
  4495. /***/ (function(module, exports) {
  4496. var traverse = module.exports = function (obj) {
  4497. return new Traverse(obj);
  4498. };
  4499. function Traverse (obj) {
  4500. this.value = obj;
  4501. }
  4502. Traverse.prototype.get = function (ps) {
  4503. var node = this.value;
  4504. for (var i = 0; i < ps.length; i ++) {
  4505. var key = ps[i];
  4506. if (!node || !hasOwnProperty.call(node, key)) {
  4507. node = undefined;
  4508. break;
  4509. }
  4510. node = node[key];
  4511. }
  4512. return node;
  4513. };
  4514. Traverse.prototype.has = function (ps) {
  4515. var node = this.value;
  4516. for (var i = 0; i < ps.length; i ++) {
  4517. var key = ps[i];
  4518. if (!node || !hasOwnProperty.call(node, key)) {
  4519. return false;
  4520. }
  4521. node = node[key];
  4522. }
  4523. return true;
  4524. };
  4525. Traverse.prototype.set = function (ps, value) {
  4526. var node = this.value;
  4527. for (var i = 0; i < ps.length - 1; i ++) {
  4528. var key = ps[i];
  4529. if (!hasOwnProperty.call(node, key)) node[key] = {};
  4530. node = node[key];
  4531. }
  4532. node[ps[i]] = value;
  4533. return value;
  4534. };
  4535. Traverse.prototype.map = function (cb) {
  4536. return walk(this.value, cb, true);
  4537. };
  4538. Traverse.prototype.forEach = function (cb) {
  4539. this.value = walk(this.value, cb, false);
  4540. return this.value;
  4541. };
  4542. Traverse.prototype.reduce = function (cb, init) {
  4543. var skip = arguments.length === 1;
  4544. var acc = skip ? this.value : init;
  4545. this.forEach(function (x) {
  4546. if (!this.isRoot || !skip) {
  4547. acc = cb.call(this, acc, x);
  4548. }
  4549. });
  4550. return acc;
  4551. };
  4552. Traverse.prototype.paths = function () {
  4553. var acc = [];
  4554. this.forEach(function (x) {
  4555. acc.push(this.path);
  4556. });
  4557. return acc;
  4558. };
  4559. Traverse.prototype.nodes = function () {
  4560. var acc = [];
  4561. this.forEach(function (x) {
  4562. acc.push(this.node);
  4563. });
  4564. return acc;
  4565. };
  4566. Traverse.prototype.clone = function () {
  4567. var parents = [], nodes = [];
  4568. return (function clone (src) {
  4569. for (var i = 0; i < parents.length; i++) {
  4570. if (parents[i] === src) {
  4571. return nodes[i];
  4572. }
  4573. }
  4574. if (typeof src === 'object' && src !== null) {
  4575. var dst = copy(src);
  4576. parents.push(src);
  4577. nodes.push(dst);
  4578. forEach(objectKeys(src), function (key) {
  4579. dst[key] = clone(src[key]);
  4580. });
  4581. parents.pop();
  4582. nodes.pop();
  4583. return dst;
  4584. }
  4585. else {
  4586. return src;
  4587. }
  4588. })(this.value);
  4589. };
  4590. function walk (root, cb, immutable) {
  4591. var path = [];
  4592. var parents = [];
  4593. var alive = true;
  4594. return (function walker (node_) {
  4595. var node = immutable ? copy(node_) : node_;
  4596. var modifiers = {};
  4597. var keepGoing = true;
  4598. var state = {
  4599. node : node,
  4600. node_ : node_,
  4601. path : [].concat(path),
  4602. parent : parents[parents.length - 1],
  4603. parents : parents,
  4604. key : path.slice(-1)[0],
  4605. isRoot : path.length === 0,
  4606. level : path.length,
  4607. circular : null,
  4608. update : function (x, stopHere) {
  4609. if (!state.isRoot) {
  4610. state.parent.node[state.key] = x;
  4611. }
  4612. state.node = x;
  4613. if (stopHere) keepGoing = false;
  4614. },
  4615. 'delete' : function (stopHere) {
  4616. delete state.parent.node[state.key];
  4617. if (stopHere) keepGoing = false;
  4618. },
  4619. remove : function (stopHere) {
  4620. if (isArray(state.parent.node)) {
  4621. state.parent.node.splice(state.key, 1);
  4622. }
  4623. else {
  4624. delete state.parent.node[state.key];
  4625. }
  4626. if (stopHere) keepGoing = false;
  4627. },
  4628. keys : null,
  4629. before : function (f) { modifiers.before = f },
  4630. after : function (f) { modifiers.after = f },
  4631. pre : function (f) { modifiers.pre = f },
  4632. post : function (f) { modifiers.post = f },
  4633. stop : function () { alive = false },
  4634. block : function () { keepGoing = false }
  4635. };
  4636. if (!alive) return state;
  4637. function updateState() {
  4638. if (typeof state.node === 'object' && state.node !== null) {
  4639. if (!state.keys || state.node_ !== state.node) {
  4640. state.keys = objectKeys(state.node)
  4641. }
  4642. state.isLeaf = state.keys.length == 0;
  4643. for (var i = 0; i < parents.length; i++) {
  4644. if (parents[i].node_ === node_) {
  4645. state.circular = parents[i];
  4646. break;
  4647. }
  4648. }
  4649. }
  4650. else {
  4651. state.isLeaf = true;
  4652. state.keys = null;
  4653. }
  4654. state.notLeaf = !state.isLeaf;
  4655. state.notRoot = !state.isRoot;
  4656. }
  4657. updateState();
  4658. // use return values to update if defined
  4659. var ret = cb.call(state, state.node);
  4660. if (ret !== undefined && state.update) state.update(ret);
  4661. if (modifiers.before) modifiers.before.call(state, state.node);
  4662. if (!keepGoing) return state;
  4663. if (typeof state.node == 'object'
  4664. && state.node !== null && !state.circular) {
  4665. parents.push(state);
  4666. updateState();
  4667. forEach(state.keys, function (key, i) {
  4668. path.push(key);
  4669. if (modifiers.pre) modifiers.pre.call(state, state.node[key], key);
  4670. var child = walker(state.node[key]);
  4671. if (immutable && hasOwnProperty.call(state.node, key)) {
  4672. state.node[key] = child.node;
  4673. }
  4674. child.isLast = i == state.keys.length - 1;
  4675. child.isFirst = i == 0;
  4676. if (modifiers.post) modifiers.post.call(state, child);
  4677. path.pop();
  4678. });
  4679. parents.pop();
  4680. }
  4681. if (modifiers.after) modifiers.after.call(state, state.node);
  4682. return state;
  4683. })(root).node;
  4684. }
  4685. function copy (src) {
  4686. if (typeof src === 'object' && src !== null) {
  4687. var dst;
  4688. if (isArray(src)) {
  4689. dst = [];
  4690. }
  4691. else if (isDate(src)) {
  4692. dst = new Date(src.getTime ? src.getTime() : src);
  4693. }
  4694. else if (isRegExp(src)) {
  4695. dst = new RegExp(src);
  4696. }
  4697. else if (isError(src)) {
  4698. dst = { message: src.message };
  4699. }
  4700. else if (isBoolean(src)) {
  4701. dst = new Boolean(src);
  4702. }
  4703. else if (isNumber(src)) {
  4704. dst = new Number(src);
  4705. }
  4706. else if (isString(src)) {
  4707. dst = new String(src);
  4708. }
  4709. else if (Object.create && Object.getPrototypeOf) {
  4710. dst = Object.create(Object.getPrototypeOf(src));
  4711. }
  4712. else if (src.constructor === Object) {
  4713. dst = {};
  4714. }
  4715. else {
  4716. var proto =
  4717. (src.constructor && src.constructor.prototype)
  4718. || src.__proto__
  4719. || {}
  4720. ;
  4721. var T = function () {};
  4722. T.prototype = proto;
  4723. dst = new T;
  4724. }
  4725. forEach(objectKeys(src), function (key) {
  4726. dst[key] = src[key];
  4727. });
  4728. return dst;
  4729. }
  4730. else return src;
  4731. }
  4732. var objectKeys = Object.keys || function keys (obj) {
  4733. var res = [];
  4734. for (var key in obj) res.push(key)
  4735. return res;
  4736. };
  4737. function toS (obj) { return Object.prototype.toString.call(obj) }
  4738. function isDate (obj) { return toS(obj) === '[object Date]' }
  4739. function isRegExp (obj) { return toS(obj) === '[object RegExp]' }
  4740. function isError (obj) { return toS(obj) === '[object Error]' }
  4741. function isBoolean (obj) { return toS(obj) === '[object Boolean]' }
  4742. function isNumber (obj) { return toS(obj) === '[object Number]' }
  4743. function isString (obj) { return toS(obj) === '[object String]' }
  4744. var isArray = Array.isArray || function isArray (xs) {
  4745. return Object.prototype.toString.call(xs) === '[object Array]';
  4746. };
  4747. var forEach = function (xs, fn) {
  4748. if (xs.forEach) return xs.forEach(fn)
  4749. else for (var i = 0; i < xs.length; i++) {
  4750. fn(xs[i], i, xs);
  4751. }
  4752. };
  4753. forEach(objectKeys(Traverse.prototype), function (key) {
  4754. traverse[key] = function (obj) {
  4755. var args = [].slice.call(arguments, 1);
  4756. var t = new Traverse(obj);
  4757. return t[key].apply(t, args);
  4758. };
  4759. });
  4760. var hasOwnProperty = Object.hasOwnProperty || function (obj, key) {
  4761. return key in obj;
  4762. };
  4763. /***/ }),
  4764. /***/ "fPbg":
  4765. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4766. "use strict";
  4767. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  4768. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  4769. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  4770. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  4771. /**
  4772. * WordPress dependencies
  4773. */
  4774. const alignLeft = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  4775. xmlns: "http://www.w3.org/2000/svg",
  4776. viewBox: "0 0 24 24"
  4777. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  4778. d: "M4 19.8h8.9v-1.5H4v1.5zm8.9-15.6H4v1.5h8.9V4.2zm-8.9 7v1.5h16v-1.5H4z"
  4779. }));
  4780. /* harmony default export */ __webpack_exports__["a"] = (alignLeft);
  4781. /***/ }),
  4782. /***/ "g56x":
  4783. /***/ (function(module, exports) {
  4784. (function() { module.exports = window["wp"]["hooks"]; }());
  4785. /***/ }),
  4786. /***/ "gdqT":
  4787. /***/ (function(module, exports) {
  4788. (function() { module.exports = window["wp"]["a11y"]; }());
  4789. /***/ }),
  4790. /***/ "hF7m":
  4791. /***/ (function(module, exports) {
  4792. (function() { module.exports = window["wp"]["keyboardShortcuts"]; }());
  4793. /***/ }),
  4794. /***/ "iA5R":
  4795. /***/ (function(module, exports, __webpack_require__) {
  4796. "use strict";
  4797. /*istanbul ignore start*/
  4798. Object.defineProperty(exports, "__esModule", {
  4799. value: true
  4800. });
  4801. exports.diffChars = diffChars;
  4802. exports.characterDiff = void 0;
  4803. /*istanbul ignore end*/
  4804. var
  4805. /*istanbul ignore start*/
  4806. _base = _interopRequireDefault(__webpack_require__("smQA"))
  4807. /*istanbul ignore end*/
  4808. ;
  4809. /*istanbul ignore start*/ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4810. /*istanbul ignore end*/
  4811. var characterDiff = new
  4812. /*istanbul ignore start*/
  4813. _base
  4814. /*istanbul ignore end*/
  4815. .
  4816. /*istanbul ignore start*/
  4817. default
  4818. /*istanbul ignore end*/
  4819. ();
  4820. /*istanbul ignore start*/
  4821. exports.characterDiff = characterDiff;
  4822. /*istanbul ignore end*/
  4823. function diffChars(oldStr, newStr, options) {
  4824. return characterDiff.diff(oldStr, newStr, options);
  4825. }
  4826. /***/ }),
  4827. /***/ "iClF":
  4828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4829. "use strict";
  4830. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  4831. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  4832. /**
  4833. * WordPress dependencies
  4834. */
  4835. /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */
  4836. /**
  4837. * Return an SVG icon.
  4838. *
  4839. * @param {IconProps} props icon is the SVG component to render
  4840. * size is a number specifiying the icon size in pixels
  4841. * Other props will be passed to wrapped SVG component
  4842. *
  4843. * @return {JSX.Element} Icon component
  4844. */
  4845. function Icon({
  4846. icon,
  4847. size = 24,
  4848. ...props
  4849. }) {
  4850. return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["cloneElement"])(icon, {
  4851. width: size,
  4852. height: size,
  4853. ...props
  4854. });
  4855. }
  4856. /* harmony default export */ __webpack_exports__["a"] = (Icon);
  4857. /***/ }),
  4858. /***/ "jB5C":
  4859. /***/ (function(module, exports, __webpack_require__) {
  4860. "use strict";
  4861. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  4862. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
  4863. var RE_NUM = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source;
  4864. function getClientPosition(elem) {
  4865. var box = undefined;
  4866. var x = undefined;
  4867. var y = undefined;
  4868. var doc = elem.ownerDocument;
  4869. var body = doc.body;
  4870. var docElem = doc && doc.documentElement;
  4871. // 根据 GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect 方法,不用再考虑传统的实现方式
  4872. box = elem.getBoundingClientRect();
  4873. // 注:jQuery 还考虑减去 docElem.clientLeft/clientTop
  4874. // 但测试发现,这样反而会导致当 html 和 body 有边距/边框样式时,获取的值不正确
  4875. // 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin
  4876. x = box.left;
  4877. y = box.top;
  4878. // In IE, most of the time, 2 extra pixels are added to the top and left
  4879. // due to the implicit 2-pixel inset border. In IE6/7 quirks mode and
  4880. // IE6 standards mode, this border can be overridden by setting the
  4881. // document element's border to zero -- thus, we cannot rely on the
  4882. // offset always being 2 pixels.
  4883. // In quirks mode, the offset can be determined by querying the body's
  4884. // clientLeft/clientTop, but in standards mode, it is found by querying
  4885. // the document element's clientLeft/clientTop. Since we already called
  4886. // getClientBoundingRect we have already forced a reflow, so it is not
  4887. // too expensive just to query them all.
  4888. // ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的
  4889. // 窗口边框标准是设 documentElement ,quirks 时设置 body
  4890. // 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去
  4891. // 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置
  4892. // 标准 ie 下 docElem.clientTop 就是 border-top
  4893. // ie7 html 即窗口边框改变不了。永远为 2
  4894. // 但标准 firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0
  4895. x -= docElem.clientLeft || body.clientLeft || 0;
  4896. y -= docElem.clientTop || body.clientTop || 0;
  4897. return {
  4898. left: x,
  4899. top: y
  4900. };
  4901. }
  4902. function getScroll(w, top) {
  4903. var ret = w['page' + (top ? 'Y' : 'X') + 'Offset'];
  4904. var method = 'scroll' + (top ? 'Top' : 'Left');
  4905. if (typeof ret !== 'number') {
  4906. var d = w.document;
  4907. // ie6,7,8 standard mode
  4908. ret = d.documentElement[method];
  4909. if (typeof ret !== 'number') {
  4910. // quirks mode
  4911. ret = d.body[method];
  4912. }
  4913. }
  4914. return ret;
  4915. }
  4916. function getScrollLeft(w) {
  4917. return getScroll(w);
  4918. }
  4919. function getScrollTop(w) {
  4920. return getScroll(w, true);
  4921. }
  4922. function getOffset(el) {
  4923. var pos = getClientPosition(el);
  4924. var doc = el.ownerDocument;
  4925. var w = doc.defaultView || doc.parentWindow;
  4926. pos.left += getScrollLeft(w);
  4927. pos.top += getScrollTop(w);
  4928. return pos;
  4929. }
  4930. function _getComputedStyle(elem, name, computedStyle_) {
  4931. var val = '';
  4932. var d = elem.ownerDocument;
  4933. var computedStyle = computedStyle_ || d.defaultView.getComputedStyle(elem, null);
  4934. // https://github.com/kissyteam/kissy/issues/61
  4935. if (computedStyle) {
  4936. val = computedStyle.getPropertyValue(name) || computedStyle[name];
  4937. }
  4938. return val;
  4939. }
  4940. var _RE_NUM_NO_PX = new RegExp('^(' + RE_NUM + ')(?!px)[a-z%]+$', 'i');
  4941. var RE_POS = /^(top|right|bottom|left)$/;
  4942. var CURRENT_STYLE = 'currentStyle';
  4943. var RUNTIME_STYLE = 'runtimeStyle';
  4944. var LEFT = 'left';
  4945. var PX = 'px';
  4946. function _getComputedStyleIE(elem, name) {
  4947. // currentStyle maybe null
  4948. // http://msdn.microsoft.com/en-us/library/ms535231.aspx
  4949. var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name];
  4950. // 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值
  4951. // 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19
  4952. // 在 ie 下不对,需要直接用 offset 方式
  4953. // borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了
  4954. // From the awesome hack by Dean Edwards
  4955. // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
  4956. // If we're not dealing with a regular pixel number
  4957. // but a number that has a weird ending, we need to convert it to pixels
  4958. // exclude left right for relativity
  4959. if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) {
  4960. // Remember the original values
  4961. var style = elem.style;
  4962. var left = style[LEFT];
  4963. var rsLeft = elem[RUNTIME_STYLE][LEFT];
  4964. // prevent flashing of content
  4965. elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT];
  4966. // Put in the new values to get a computed value out
  4967. style[LEFT] = name === 'fontSize' ? '1em' : ret || 0;
  4968. ret = style.pixelLeft + PX;
  4969. // Revert the changed values
  4970. style[LEFT] = left;
  4971. elem[RUNTIME_STYLE][LEFT] = rsLeft;
  4972. }
  4973. return ret === '' ? 'auto' : ret;
  4974. }
  4975. var getComputedStyleX = undefined;
  4976. if (typeof window !== 'undefined') {
  4977. getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE;
  4978. }
  4979. function each(arr, fn) {
  4980. for (var i = 0; i < arr.length; i++) {
  4981. fn(arr[i]);
  4982. }
  4983. }
  4984. function isBorderBoxFn(elem) {
  4985. return getComputedStyleX(elem, 'boxSizing') === 'border-box';
  4986. }
  4987. var BOX_MODELS = ['margin', 'border', 'padding'];
  4988. var CONTENT_INDEX = -1;
  4989. var PADDING_INDEX = 2;
  4990. var BORDER_INDEX = 1;
  4991. var MARGIN_INDEX = 0;
  4992. function swap(elem, options, callback) {
  4993. var old = {};
  4994. var style = elem.style;
  4995. var name = undefined;
  4996. // Remember the old values, and insert the new ones
  4997. for (name in options) {
  4998. if (options.hasOwnProperty(name)) {
  4999. old[name] = style[name];
  5000. style[name] = options[name];
  5001. }
  5002. }
  5003. callback.call(elem);
  5004. // Revert the old values
  5005. for (name in options) {
  5006. if (options.hasOwnProperty(name)) {
  5007. style[name] = old[name];
  5008. }
  5009. }
  5010. }
  5011. function getPBMWidth(elem, props, which) {
  5012. var value = 0;
  5013. var prop = undefined;
  5014. var j = undefined;
  5015. var i = undefined;
  5016. for (j = 0; j < props.length; j++) {
  5017. prop = props[j];
  5018. if (prop) {
  5019. for (i = 0; i < which.length; i++) {
  5020. var cssProp = undefined;
  5021. if (prop === 'border') {
  5022. cssProp = prop + which[i] + 'Width';
  5023. } else {
  5024. cssProp = prop + which[i];
  5025. }
  5026. value += parseFloat(getComputedStyleX(elem, cssProp)) || 0;
  5027. }
  5028. }
  5029. }
  5030. return value;
  5031. }
  5032. /**
  5033. * A crude way of determining if an object is a window
  5034. * @member util
  5035. */
  5036. function isWindow(obj) {
  5037. // must use == for ie8
  5038. /* eslint eqeqeq:0 */
  5039. return obj != null && obj == obj.window;
  5040. }
  5041. var domUtils = {};
  5042. each(['Width', 'Height'], function (name) {
  5043. domUtils['doc' + name] = function (refWin) {
  5044. var d = refWin.document;
  5045. return Math.max(
  5046. // firefox chrome documentElement.scrollHeight< body.scrollHeight
  5047. // ie standard mode : documentElement.scrollHeight> body.scrollHeight
  5048. d.documentElement['scroll' + name],
  5049. // quirks : documentElement.scrollHeight 最大等于可视窗口多一点?
  5050. d.body['scroll' + name], domUtils['viewport' + name](d));
  5051. };
  5052. domUtils['viewport' + name] = function (win) {
  5053. // pc browser includes scrollbar in window.innerWidth
  5054. var prop = 'client' + name;
  5055. var doc = win.document;
  5056. var body = doc.body;
  5057. var documentElement = doc.documentElement;
  5058. var documentElementProp = documentElement[prop];
  5059. // 标准模式取 documentElement
  5060. // backcompat 取 body
  5061. return doc.compatMode === 'CSS1Compat' && documentElementProp || body && body[prop] || documentElementProp;
  5062. };
  5063. });
  5064. /*
  5065. 得到元素的大小信息
  5066. @param elem
  5067. @param name
  5068. @param {String} [extra] 'padding' : (css width) + padding
  5069. 'border' : (css width) + padding + border
  5070. 'margin' : (css width) + padding + border + margin
  5071. */
  5072. function getWH(elem, name, extra) {
  5073. if (isWindow(elem)) {
  5074. return name === 'width' ? domUtils.viewportWidth(elem) : domUtils.viewportHeight(elem);
  5075. } else if (elem.nodeType === 9) {
  5076. return name === 'width' ? domUtils.docWidth(elem) : domUtils.docHeight(elem);
  5077. }
  5078. var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'];
  5079. var borderBoxValue = name === 'width' ? elem.offsetWidth : elem.offsetHeight;
  5080. var computedStyle = getComputedStyleX(elem);
  5081. var isBorderBox = isBorderBoxFn(elem, computedStyle);
  5082. var cssBoxValue = 0;
  5083. if (borderBoxValue == null || borderBoxValue <= 0) {
  5084. borderBoxValue = undefined;
  5085. // Fall back to computed then un computed css if necessary
  5086. cssBoxValue = getComputedStyleX(elem, name);
  5087. if (cssBoxValue == null || Number(cssBoxValue) < 0) {
  5088. cssBoxValue = elem.style[name] || 0;
  5089. }
  5090. // Normalize '', auto, and prepare for extra
  5091. cssBoxValue = parseFloat(cssBoxValue) || 0;
  5092. }
  5093. if (extra === undefined) {
  5094. extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX;
  5095. }
  5096. var borderBoxValueOrIsBorderBox = borderBoxValue !== undefined || isBorderBox;
  5097. var val = borderBoxValue || cssBoxValue;
  5098. if (extra === CONTENT_INDEX) {
  5099. if (borderBoxValueOrIsBorderBox) {
  5100. return val - getPBMWidth(elem, ['border', 'padding'], which, computedStyle);
  5101. }
  5102. return cssBoxValue;
  5103. }
  5104. if (borderBoxValueOrIsBorderBox) {
  5105. var padding = extra === PADDING_INDEX ? -getPBMWidth(elem, ['border'], which, computedStyle) : getPBMWidth(elem, ['margin'], which, computedStyle);
  5106. return val + (extra === BORDER_INDEX ? 0 : padding);
  5107. }
  5108. return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra), which, computedStyle);
  5109. }
  5110. var cssShow = {
  5111. position: 'absolute',
  5112. visibility: 'hidden',
  5113. display: 'block'
  5114. };
  5115. // fix #119 : https://github.com/kissyteam/kissy/issues/119
  5116. function getWHIgnoreDisplay(elem) {
  5117. var val = undefined;
  5118. var args = arguments;
  5119. // in case elem is window
  5120. // elem.offsetWidth === undefined
  5121. if (elem.offsetWidth !== 0) {
  5122. val = getWH.apply(undefined, args);
  5123. } else {
  5124. swap(elem, cssShow, function () {
  5125. val = getWH.apply(undefined, args);
  5126. });
  5127. }
  5128. return val;
  5129. }
  5130. function css(el, name, v) {
  5131. var value = v;
  5132. if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') {
  5133. for (var i in name) {
  5134. if (name.hasOwnProperty(i)) {
  5135. css(el, i, name[i]);
  5136. }
  5137. }
  5138. return undefined;
  5139. }
  5140. if (typeof value !== 'undefined') {
  5141. if (typeof value === 'number') {
  5142. value += 'px';
  5143. }
  5144. el.style[name] = value;
  5145. return undefined;
  5146. }
  5147. return getComputedStyleX(el, name);
  5148. }
  5149. each(['width', 'height'], function (name) {
  5150. var first = name.charAt(0).toUpperCase() + name.slice(1);
  5151. domUtils['outer' + first] = function (el, includeMargin) {
  5152. return el && getWHIgnoreDisplay(el, name, includeMargin ? MARGIN_INDEX : BORDER_INDEX);
  5153. };
  5154. var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'];
  5155. domUtils[name] = function (elem, val) {
  5156. if (val !== undefined) {
  5157. if (elem) {
  5158. var computedStyle = getComputedStyleX(elem);
  5159. var isBorderBox = isBorderBoxFn(elem);
  5160. if (isBorderBox) {
  5161. val += getPBMWidth(elem, ['padding', 'border'], which, computedStyle);
  5162. }
  5163. return css(elem, name, val);
  5164. }
  5165. return undefined;
  5166. }
  5167. return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX);
  5168. };
  5169. });
  5170. // 设置 elem 相对 elem.ownerDocument 的坐标
  5171. function setOffset(elem, offset) {
  5172. // set position first, in-case top/left are set even on static elem
  5173. if (css(elem, 'position') === 'static') {
  5174. elem.style.position = 'relative';
  5175. }
  5176. var old = getOffset(elem);
  5177. var ret = {};
  5178. var current = undefined;
  5179. var key = undefined;
  5180. for (key in offset) {
  5181. if (offset.hasOwnProperty(key)) {
  5182. current = parseFloat(css(elem, key)) || 0;
  5183. ret[key] = current + offset[key] - old[key];
  5184. }
  5185. }
  5186. css(elem, ret);
  5187. }
  5188. module.exports = _extends({
  5189. getWindow: function getWindow(node) {
  5190. var doc = node.ownerDocument || node;
  5191. return doc.defaultView || doc.parentWindow;
  5192. },
  5193. offset: function offset(el, value) {
  5194. if (typeof value !== 'undefined') {
  5195. setOffset(el, value);
  5196. } else {
  5197. return getOffset(el);
  5198. }
  5199. },
  5200. isWindow: isWindow,
  5201. each: each,
  5202. css: css,
  5203. clone: function clone(obj) {
  5204. var ret = {};
  5205. for (var i in obj) {
  5206. if (obj.hasOwnProperty(i)) {
  5207. ret[i] = obj[i];
  5208. }
  5209. }
  5210. var overflow = obj.overflow;
  5211. if (overflow) {
  5212. for (var i in obj) {
  5213. if (obj.hasOwnProperty(i)) {
  5214. ret.overflow[i] = obj.overflow[i];
  5215. }
  5216. }
  5217. }
  5218. return ret;
  5219. },
  5220. scrollLeft: function scrollLeft(w, v) {
  5221. if (isWindow(w)) {
  5222. if (v === undefined) {
  5223. return getScrollLeft(w);
  5224. }
  5225. window.scrollTo(v, getScrollTop(w));
  5226. } else {
  5227. if (v === undefined) {
  5228. return w.scrollLeft;
  5229. }
  5230. w.scrollLeft = v;
  5231. }
  5232. },
  5233. scrollTop: function scrollTop(w, v) {
  5234. if (isWindow(w)) {
  5235. if (v === undefined) {
  5236. return getScrollTop(w);
  5237. }
  5238. window.scrollTo(getScrollLeft(w), v);
  5239. } else {
  5240. if (v === undefined) {
  5241. return w.scrollTop;
  5242. }
  5243. w.scrollTop = v;
  5244. }
  5245. },
  5246. viewportWidth: 0,
  5247. viewportHeight: 0
  5248. }, domUtils);
  5249. /***/ }),
  5250. /***/ "jTPX":
  5251. /***/ (function(module, exports) {
  5252. // This code has been refactored for 140 bytes
  5253. // You can see the original here: https://github.com/twolfson/computedStyle/blob/04cd1da2e30fa45844f95f5cb1ac898e9b9ef050/lib/computedStyle.js
  5254. var computedStyle = function (el, prop, getComputedStyle) {
  5255. getComputedStyle = window.getComputedStyle;
  5256. // In one fell swoop
  5257. return (
  5258. // If we have getComputedStyle
  5259. getComputedStyle ?
  5260. // Query it
  5261. // TODO: From CSS-Query notes, we might need (node, null) for FF
  5262. getComputedStyle(el) :
  5263. // Otherwise, we are in IE and use currentStyle
  5264. el.currentStyle
  5265. )[
  5266. // Switch to camelCase for CSSOM
  5267. // DEV: Grabbed from jQuery
  5268. // https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194
  5269. // https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597
  5270. prop.replace(/-(\w)/gi, function (word, letter) {
  5271. return letter.toUpperCase();
  5272. })
  5273. ];
  5274. };
  5275. module.exports = computedStyle;
  5276. /***/ }),
  5277. /***/ "l3Sj":
  5278. /***/ (function(module, exports) {
  5279. (function() { module.exports = window["wp"]["i18n"]; }());
  5280. /***/ }),
  5281. /***/ "onLe":
  5282. /***/ (function(module, exports) {
  5283. (function() { module.exports = window["wp"]["notices"]; }());
  5284. /***/ }),
  5285. /***/ "pPDe":
  5286. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5287. "use strict";
  5288. var LEAF_KEY, hasWeakMap;
  5289. /**
  5290. * Arbitrary value used as key for referencing cache object in WeakMap tree.
  5291. *
  5292. * @type {Object}
  5293. */
  5294. LEAF_KEY = {};
  5295. /**
  5296. * Whether environment supports WeakMap.
  5297. *
  5298. * @type {boolean}
  5299. */
  5300. hasWeakMap = typeof WeakMap !== 'undefined';
  5301. /**
  5302. * Returns the first argument as the sole entry in an array.
  5303. *
  5304. * @param {*} value Value to return.
  5305. *
  5306. * @return {Array} Value returned as entry in array.
  5307. */
  5308. function arrayOf( value ) {
  5309. return [ value ];
  5310. }
  5311. /**
  5312. * Returns true if the value passed is object-like, or false otherwise. A value
  5313. * is object-like if it can support property assignment, e.g. object or array.
  5314. *
  5315. * @param {*} value Value to test.
  5316. *
  5317. * @return {boolean} Whether value is object-like.
  5318. */
  5319. function isObjectLike( value ) {
  5320. return !! value && 'object' === typeof value;
  5321. }
  5322. /**
  5323. * Creates and returns a new cache object.
  5324. *
  5325. * @return {Object} Cache object.
  5326. */
  5327. function createCache() {
  5328. var cache = {
  5329. clear: function() {
  5330. cache.head = null;
  5331. },
  5332. };
  5333. return cache;
  5334. }
  5335. /**
  5336. * Returns true if entries within the two arrays are strictly equal by
  5337. * reference from a starting index.
  5338. *
  5339. * @param {Array} a First array.
  5340. * @param {Array} b Second array.
  5341. * @param {number} fromIndex Index from which to start comparison.
  5342. *
  5343. * @return {boolean} Whether arrays are shallowly equal.
  5344. */
  5345. function isShallowEqual( a, b, fromIndex ) {
  5346. var i;
  5347. if ( a.length !== b.length ) {
  5348. return false;
  5349. }
  5350. for ( i = fromIndex; i < a.length; i++ ) {
  5351. if ( a[ i ] !== b[ i ] ) {
  5352. return false;
  5353. }
  5354. }
  5355. return true;
  5356. }
  5357. /**
  5358. * Returns a memoized selector function. The getDependants function argument is
  5359. * called before the memoized selector and is expected to return an immutable
  5360. * reference or array of references on which the selector depends for computing
  5361. * its own return value. The memoize cache is preserved only as long as those
  5362. * dependant references remain the same. If getDependants returns a different
  5363. * reference(s), the cache is cleared and the selector value regenerated.
  5364. *
  5365. * @param {Function} selector Selector function.
  5366. * @param {Function} getDependants Dependant getter returning an immutable
  5367. * reference or array of reference used in
  5368. * cache bust consideration.
  5369. *
  5370. * @return {Function} Memoized selector.
  5371. */
  5372. /* harmony default export */ __webpack_exports__["a"] = (function( selector, getDependants ) {
  5373. var rootCache, getCache;
  5374. // Use object source as dependant if getter not provided
  5375. if ( ! getDependants ) {
  5376. getDependants = arrayOf;
  5377. }
  5378. /**
  5379. * Returns the root cache. If WeakMap is supported, this is assigned to the
  5380. * root WeakMap cache set, otherwise it is a shared instance of the default
  5381. * cache object.
  5382. *
  5383. * @return {(WeakMap|Object)} Root cache object.
  5384. */
  5385. function getRootCache() {
  5386. return rootCache;
  5387. }
  5388. /**
  5389. * Returns the cache for a given dependants array. When possible, a WeakMap
  5390. * will be used to create a unique cache for each set of dependants. This
  5391. * is feasible due to the nature of WeakMap in allowing garbage collection
  5392. * to occur on entries where the key object is no longer referenced. Since
  5393. * WeakMap requires the key to be an object, this is only possible when the
  5394. * dependant is object-like. The root cache is created as a hierarchy where
  5395. * each top-level key is the first entry in a dependants set, the value a
  5396. * WeakMap where each key is the next dependant, and so on. This continues
  5397. * so long as the dependants are object-like. If no dependants are object-
  5398. * like, then the cache is shared across all invocations.
  5399. *
  5400. * @see isObjectLike
  5401. *
  5402. * @param {Array} dependants Selector dependants.
  5403. *
  5404. * @return {Object} Cache object.
  5405. */
  5406. function getWeakMapCache( dependants ) {
  5407. var caches = rootCache,
  5408. isUniqueByDependants = true,
  5409. i, dependant, map, cache;
  5410. for ( i = 0; i < dependants.length; i++ ) {
  5411. dependant = dependants[ i ];
  5412. // Can only compose WeakMap from object-like key.
  5413. if ( ! isObjectLike( dependant ) ) {
  5414. isUniqueByDependants = false;
  5415. break;
  5416. }
  5417. // Does current segment of cache already have a WeakMap?
  5418. if ( caches.has( dependant ) ) {
  5419. // Traverse into nested WeakMap.
  5420. caches = caches.get( dependant );
  5421. } else {
  5422. // Create, set, and traverse into a new one.
  5423. map = new WeakMap();
  5424. caches.set( dependant, map );
  5425. caches = map;
  5426. }
  5427. }
  5428. // We use an arbitrary (but consistent) object as key for the last item
  5429. // in the WeakMap to serve as our running cache.
  5430. if ( ! caches.has( LEAF_KEY ) ) {
  5431. cache = createCache();
  5432. cache.isUniqueByDependants = isUniqueByDependants;
  5433. caches.set( LEAF_KEY, cache );
  5434. }
  5435. return caches.get( LEAF_KEY );
  5436. }
  5437. // Assign cache handler by availability of WeakMap
  5438. getCache = hasWeakMap ? getWeakMapCache : getRootCache;
  5439. /**
  5440. * Resets root memoization cache.
  5441. */
  5442. function clear() {
  5443. rootCache = hasWeakMap ? new WeakMap() : createCache();
  5444. }
  5445. // eslint-disable-next-line jsdoc/check-param-names
  5446. /**
  5447. * The augmented selector call, considering first whether dependants have
  5448. * changed before passing it to underlying memoize function.
  5449. *
  5450. * @param {Object} source Source object for derivation.
  5451. * @param {...*} extraArgs Additional arguments to pass to selector.
  5452. *
  5453. * @return {*} Selector result.
  5454. */
  5455. function callSelector( /* source, ...extraArgs */ ) {
  5456. var len = arguments.length,
  5457. cache, node, i, args, dependants;
  5458. // Create copy of arguments (avoid leaking deoptimization).
  5459. args = new Array( len );
  5460. for ( i = 0; i < len; i++ ) {
  5461. args[ i ] = arguments[ i ];
  5462. }
  5463. dependants = getDependants.apply( null, args );
  5464. cache = getCache( dependants );
  5465. // If not guaranteed uniqueness by dependants (primitive type or lack
  5466. // of WeakMap support), shallow compare against last dependants and, if
  5467. // references have changed, destroy cache to recalculate result.
  5468. if ( ! cache.isUniqueByDependants ) {
  5469. if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) {
  5470. cache.clear();
  5471. }
  5472. cache.lastDependants = dependants;
  5473. }
  5474. node = cache.head;
  5475. while ( node ) {
  5476. // Check whether node arguments match arguments
  5477. if ( ! isShallowEqual( node.args, args, 1 ) ) {
  5478. node = node.next;
  5479. continue;
  5480. }
  5481. // At this point we can assume we've found a match
  5482. // Surface matched node to head if not already
  5483. if ( node !== cache.head ) {
  5484. // Adjust siblings to point to each other.
  5485. node.prev.next = node.next;
  5486. if ( node.next ) {
  5487. node.next.prev = node.prev;
  5488. }
  5489. node.next = cache.head;
  5490. node.prev = null;
  5491. cache.head.prev = node;
  5492. cache.head = node;
  5493. }
  5494. // Return immediately
  5495. return node.val;
  5496. }
  5497. // No cached value found. Continue to insertion phase:
  5498. node = {
  5499. // Generate the result from original function
  5500. val: selector.apply( null, args ),
  5501. };
  5502. // Avoid including the source object in the cache.
  5503. args[ 0 ] = null;
  5504. node.args = args;
  5505. // Don't need to check whether node is already head, since it would
  5506. // have been returned above already if it was
  5507. // Shift existing head down list
  5508. if ( cache.head ) {
  5509. cache.head.prev = node;
  5510. node.next = cache.head;
  5511. }
  5512. cache.head = node;
  5513. return node.val;
  5514. }
  5515. callSelector.getDependants = getDependants;
  5516. callSelector.clear = clear;
  5517. clear();
  5518. return callSelector;
  5519. });
  5520. /***/ }),
  5521. /***/ "pVnL":
  5522. /***/ (function(module, exports) {
  5523. function _extends() {
  5524. module.exports = _extends = Object.assign || function (target) {
  5525. for (var i = 1; i < arguments.length; i++) {
  5526. var source = arguments[i];
  5527. for (var key in source) {
  5528. if (Object.prototype.hasOwnProperty.call(source, key)) {
  5529. target[key] = source[key];
  5530. }
  5531. }
  5532. }
  5533. return target;
  5534. };
  5535. module.exports["default"] = module.exports, module.exports.__esModule = true;
  5536. return _extends.apply(this, arguments);
  5537. }
  5538. module.exports = _extends;
  5539. module.exports["default"] = module.exports, module.exports.__esModule = true;
  5540. /***/ }),
  5541. /***/ "plpT":
  5542. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5543. "use strict";
  5544. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  5545. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  5546. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  5547. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  5548. /**
  5549. * WordPress dependencies
  5550. */
  5551. const alignCenter = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  5552. xmlns: "http://www.w3.org/2000/svg",
  5553. viewBox: "0 0 24 24"
  5554. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  5555. d: "M16.4 4.2H7.6v1.5h8.9V4.2zM4 11.2v1.5h16v-1.5H4zm3.6 8.6h8.9v-1.5H7.6v1.5z"
  5556. }));
  5557. /* harmony default export */ __webpack_exports__["a"] = (alignCenter);
  5558. /***/ }),
  5559. /***/ "qRz9":
  5560. /***/ (function(module, exports) {
  5561. (function() { module.exports = window["wp"]["richText"]; }());
  5562. /***/ }),
  5563. /***/ "rH4q":
  5564. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5565. "use strict";
  5566. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  5567. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  5568. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  5569. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  5570. /**
  5571. * WordPress dependencies
  5572. */
  5573. const media = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  5574. xmlns: "http://www.w3.org/2000/svg",
  5575. viewBox: "0 0 24 24"
  5576. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  5577. d: "M18.7 3H5.3C4 3 3 4 3 5.3v13.4C3 20 4 21 5.3 21h13.4c1.3 0 2.3-1 2.3-2.3V5.3C21 4 20 3 18.7 3zm.8 15.7c0 .4-.4.8-.8.8H5.3c-.4 0-.8-.4-.8-.8V5.3c0-.4.4-.8.8-.8h13.4c.4 0 .8.4.8.8v13.4zM10 15l5-3-5-3v6z"
  5578. }));
  5579. /* harmony default export */ __webpack_exports__["a"] = (media);
  5580. /***/ }),
  5581. /***/ "rl8x":
  5582. /***/ (function(module, exports) {
  5583. (function() { module.exports = window["wp"]["isShallowEqual"]; }());
  5584. /***/ }),
  5585. /***/ "rmEH":
  5586. /***/ (function(module, exports) {
  5587. (function() { module.exports = window["wp"]["htmlEntities"]; }());
  5588. /***/ }),
  5589. /***/ "smQA":
  5590. /***/ (function(module, exports, __webpack_require__) {
  5591. "use strict";
  5592. /*istanbul ignore start*/
  5593. Object.defineProperty(exports, "__esModule", {
  5594. value: true
  5595. });
  5596. exports.default = Diff;
  5597. /*istanbul ignore end*/
  5598. function Diff() {}
  5599. Diff.prototype = {
  5600. /*istanbul ignore start*/
  5601. /*istanbul ignore end*/
  5602. diff: function diff(oldString, newString) {
  5603. /*istanbul ignore start*/
  5604. var
  5605. /*istanbul ignore end*/
  5606. options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  5607. var callback = options.callback;
  5608. if (typeof options === 'function') {
  5609. callback = options;
  5610. options = {};
  5611. }
  5612. this.options = options;
  5613. var self = this;
  5614. function done(value) {
  5615. if (callback) {
  5616. setTimeout(function () {
  5617. callback(undefined, value);
  5618. }, 0);
  5619. return true;
  5620. } else {
  5621. return value;
  5622. }
  5623. } // Allow subclasses to massage the input prior to running
  5624. oldString = this.castInput(oldString);
  5625. newString = this.castInput(newString);
  5626. oldString = this.removeEmpty(this.tokenize(oldString));
  5627. newString = this.removeEmpty(this.tokenize(newString));
  5628. var newLen = newString.length,
  5629. oldLen = oldString.length;
  5630. var editLength = 1;
  5631. var maxEditLength = newLen + oldLen;
  5632. var bestPath = [{
  5633. newPos: -1,
  5634. components: []
  5635. }]; // Seed editLength = 0, i.e. the content starts with the same values
  5636. var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
  5637. if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
  5638. // Identity per the equality and tokenizer
  5639. return done([{
  5640. value: this.join(newString),
  5641. count: newString.length
  5642. }]);
  5643. } // Main worker method. checks all permutations of a given edit length for acceptance.
  5644. function execEditLength() {
  5645. for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
  5646. var basePath =
  5647. /*istanbul ignore start*/
  5648. void 0
  5649. /*istanbul ignore end*/
  5650. ;
  5651. var addPath = bestPath[diagonalPath - 1],
  5652. removePath = bestPath[diagonalPath + 1],
  5653. _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
  5654. if (addPath) {
  5655. // No one else is going to attempt to use this value, clear it
  5656. bestPath[diagonalPath - 1] = undefined;
  5657. }
  5658. var canAdd = addPath && addPath.newPos + 1 < newLen,
  5659. canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
  5660. if (!canAdd && !canRemove) {
  5661. // If this path is a terminal then prune
  5662. bestPath[diagonalPath] = undefined;
  5663. continue;
  5664. } // Select the diagonal that we want to branch from. We select the prior
  5665. // path whose position in the new string is the farthest from the origin
  5666. // and does not pass the bounds of the diff graph
  5667. if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
  5668. basePath = clonePath(removePath);
  5669. self.pushComponent(basePath.components, undefined, true);
  5670. } else {
  5671. basePath = addPath; // No need to clone, we've pulled it from the list
  5672. basePath.newPos++;
  5673. self.pushComponent(basePath.components, true, undefined);
  5674. }
  5675. _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done
  5676. if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
  5677. return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
  5678. } else {
  5679. // Otherwise track this path as a potential candidate and continue.
  5680. bestPath[diagonalPath] = basePath;
  5681. }
  5682. }
  5683. editLength++;
  5684. } // Performs the length of edit iteration. Is a bit fugly as this has to support the
  5685. // sync and async mode which is never fun. Loops over execEditLength until a value
  5686. // is produced.
  5687. if (callback) {
  5688. (function exec() {
  5689. setTimeout(function () {
  5690. // This should not happen, but we want to be safe.
  5691. /* istanbul ignore next */
  5692. if (editLength > maxEditLength) {
  5693. return callback();
  5694. }
  5695. if (!execEditLength()) {
  5696. exec();
  5697. }
  5698. }, 0);
  5699. })();
  5700. } else {
  5701. while (editLength <= maxEditLength) {
  5702. var ret = execEditLength();
  5703. if (ret) {
  5704. return ret;
  5705. }
  5706. }
  5707. }
  5708. },
  5709. /*istanbul ignore start*/
  5710. /*istanbul ignore end*/
  5711. pushComponent: function pushComponent(components, added, removed) {
  5712. var last = components[components.length - 1];
  5713. if (last && last.added === added && last.removed === removed) {
  5714. // We need to clone here as the component clone operation is just
  5715. // as shallow array clone
  5716. components[components.length - 1] = {
  5717. count: last.count + 1,
  5718. added: added,
  5719. removed: removed
  5720. };
  5721. } else {
  5722. components.push({
  5723. count: 1,
  5724. added: added,
  5725. removed: removed
  5726. });
  5727. }
  5728. },
  5729. /*istanbul ignore start*/
  5730. /*istanbul ignore end*/
  5731. extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
  5732. var newLen = newString.length,
  5733. oldLen = oldString.length,
  5734. newPos = basePath.newPos,
  5735. oldPos = newPos - diagonalPath,
  5736. commonCount = 0;
  5737. while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
  5738. newPos++;
  5739. oldPos++;
  5740. commonCount++;
  5741. }
  5742. if (commonCount) {
  5743. basePath.components.push({
  5744. count: commonCount
  5745. });
  5746. }
  5747. basePath.newPos = newPos;
  5748. return oldPos;
  5749. },
  5750. /*istanbul ignore start*/
  5751. /*istanbul ignore end*/
  5752. equals: function equals(left, right) {
  5753. if (this.options.comparator) {
  5754. return this.options.comparator(left, right);
  5755. } else {
  5756. return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
  5757. }
  5758. },
  5759. /*istanbul ignore start*/
  5760. /*istanbul ignore end*/
  5761. removeEmpty: function removeEmpty(array) {
  5762. var ret = [];
  5763. for (var i = 0; i < array.length; i++) {
  5764. if (array[i]) {
  5765. ret.push(array[i]);
  5766. }
  5767. }
  5768. return ret;
  5769. },
  5770. /*istanbul ignore start*/
  5771. /*istanbul ignore end*/
  5772. castInput: function castInput(value) {
  5773. return value;
  5774. },
  5775. /*istanbul ignore start*/
  5776. /*istanbul ignore end*/
  5777. tokenize: function tokenize(value) {
  5778. return value.split('');
  5779. },
  5780. /*istanbul ignore start*/
  5781. /*istanbul ignore end*/
  5782. join: function join(chars) {
  5783. return chars.join('');
  5784. }
  5785. };
  5786. function buildValues(diff, components, newString, oldString, useLongestToken) {
  5787. var componentPos = 0,
  5788. componentLen = components.length,
  5789. newPos = 0,
  5790. oldPos = 0;
  5791. for (; componentPos < componentLen; componentPos++) {
  5792. var component = components[componentPos];
  5793. if (!component.removed) {
  5794. if (!component.added && useLongestToken) {
  5795. var value = newString.slice(newPos, newPos + component.count);
  5796. value = value.map(function (value, i) {
  5797. var oldValue = oldString[oldPos + i];
  5798. return oldValue.length > value.length ? oldValue : value;
  5799. });
  5800. component.value = diff.join(value);
  5801. } else {
  5802. component.value = diff.join(newString.slice(newPos, newPos + component.count));
  5803. }
  5804. newPos += component.count; // Common case
  5805. if (!component.added) {
  5806. oldPos += component.count;
  5807. }
  5808. } else {
  5809. component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
  5810. oldPos += component.count; // Reverse add and remove so removes are output first to match common convention
  5811. // The diffing algorithm is tied to add then remove output and this is the simplest
  5812. // route to get the desired output with minimal overhead.
  5813. if (componentPos && components[componentPos - 1].added) {
  5814. var tmp = components[componentPos - 1];
  5815. components[componentPos - 1] = components[componentPos];
  5816. components[componentPos] = tmp;
  5817. }
  5818. }
  5819. } // Special case handle for when one terminal is ignored (i.e. whitespace).
  5820. // For this case we merge the terminal into the prior string and drop the change.
  5821. // This is only available for string mode.
  5822. var lastComponent = components[componentLen - 1];
  5823. if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
  5824. components[componentLen - 2].value += lastComponent.value;
  5825. components.pop();
  5826. }
  5827. return components;
  5828. }
  5829. function clonePath(path) {
  5830. return {
  5831. newPos: path.newPos,
  5832. components: path.components.slice(0)
  5833. };
  5834. }
  5835. /***/ }),
  5836. /***/ "tI+e":
  5837. /***/ (function(module, exports) {
  5838. (function() { module.exports = window["wp"]["components"]; }());
  5839. /***/ }),
  5840. /***/ "tr0p":
  5841. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5842. "use strict";
  5843. // ESM COMPAT FLAG
  5844. __webpack_require__.r(__webpack_exports__);
  5845. // EXPORTS
  5846. __webpack_require__.d(__webpack_exports__, "__experimentalGetBorderClassesAndStyles", function() { return /* reexport */ getBorderClassesAndStyles; });
  5847. __webpack_require__.d(__webpack_exports__, "__experimentalUseBorderProps", function() { return /* reexport */ useBorderProps; });
  5848. __webpack_require__.d(__webpack_exports__, "__experimentalGetColorClassesAndStyles", function() { return /* reexport */ getColorClassesAndStyles; });
  5849. __webpack_require__.d(__webpack_exports__, "__experimentalUseColorProps", function() { return /* reexport */ useColorProps; });
  5850. __webpack_require__.d(__webpack_exports__, "__experimentalUseCustomSides", function() { return /* reexport */ useCustomSides; });
  5851. __webpack_require__.d(__webpack_exports__, "getColorClassName", function() { return /* reexport */ getColorClassName; });
  5852. __webpack_require__.d(__webpack_exports__, "getColorObjectByAttributeValues", function() { return /* reexport */ getColorObjectByAttributeValues; });
  5853. __webpack_require__.d(__webpack_exports__, "getColorObjectByColorValue", function() { return /* reexport */ getColorObjectByColorValue; });
  5854. __webpack_require__.d(__webpack_exports__, "createCustomColorsHOC", function() { return /* reexport */ createCustomColorsHOC; });
  5855. __webpack_require__.d(__webpack_exports__, "withColors", function() { return /* reexport */ withColors; });
  5856. __webpack_require__.d(__webpack_exports__, "__experimentalUseColors", function() { return /* reexport */ __experimentalUseColors; });
  5857. __webpack_require__.d(__webpack_exports__, "__experimentalGetGradientClass", function() { return /* reexport */ __experimentalGetGradientClass; });
  5858. __webpack_require__.d(__webpack_exports__, "getGradientValueBySlug", function() { return /* reexport */ getGradientValueBySlug; });
  5859. __webpack_require__.d(__webpack_exports__, "__experimentalGetGradientObjectByGradientValue", function() { return /* reexport */ __experimentalGetGradientObjectByGradientValue; });
  5860. __webpack_require__.d(__webpack_exports__, "getGradientSlugByValue", function() { return /* reexport */ getGradientSlugByValue; });
  5861. __webpack_require__.d(__webpack_exports__, "__experimentalUseGradient", function() { return /* reexport */ __experimentalUseGradient; });
  5862. __webpack_require__.d(__webpack_exports__, "getFontSize", function() { return /* reexport */ getFontSize; });
  5863. __webpack_require__.d(__webpack_exports__, "getFontSizeClass", function() { return /* reexport */ getFontSizeClass; });
  5864. __webpack_require__.d(__webpack_exports__, "getFontSizeObjectByValue", function() { return /* reexport */ getFontSizeObjectByValue; });
  5865. __webpack_require__.d(__webpack_exports__, "FontSizePicker", function() { return /* reexport */ font_size_picker; });
  5866. __webpack_require__.d(__webpack_exports__, "withFontSizes", function() { return /* reexport */ with_font_sizes; });
  5867. __webpack_require__.d(__webpack_exports__, "AlignmentControl", function() { return /* reexport */ AlignmentControl; });
  5868. __webpack_require__.d(__webpack_exports__, "AlignmentToolbar", function() { return /* reexport */ AlignmentToolbar; });
  5869. __webpack_require__.d(__webpack_exports__, "Autocomplete", function() { return /* reexport */ autocomplete; });
  5870. __webpack_require__.d(__webpack_exports__, "BlockAlignmentControl", function() { return /* reexport */ BlockAlignmentControl; });
  5871. __webpack_require__.d(__webpack_exports__, "BlockAlignmentToolbar", function() { return /* reexport */ BlockAlignmentToolbar; });
  5872. __webpack_require__.d(__webpack_exports__, "__experimentalBlockFullHeightAligmentControl", function() { return /* reexport */ block_full_height_alignment_control; });
  5873. __webpack_require__.d(__webpack_exports__, "__experimentalBlockAlignmentMatrixControl", function() { return /* reexport */ block_alignment_matrix_control; });
  5874. __webpack_require__.d(__webpack_exports__, "BlockBreadcrumb", function() { return /* reexport */ block_breadcrumb; });
  5875. __webpack_require__.d(__webpack_exports__, "BlockContextProvider", function() { return /* reexport */ BlockContextProvider; });
  5876. __webpack_require__.d(__webpack_exports__, "BlockControls", function() { return /* reexport */ block_controls; });
  5877. __webpack_require__.d(__webpack_exports__, "BlockFormatControls", function() { return /* reexport */ BlockFormatControls; });
  5878. __webpack_require__.d(__webpack_exports__, "BlockColorsStyleSelector", function() { return /* reexport */ color_style_selector; });
  5879. __webpack_require__.d(__webpack_exports__, "BlockEdit", function() { return /* reexport */ block_edit_BlockEdit; });
  5880. __webpack_require__.d(__webpack_exports__, "useBlockEditContext", function() { return /* reexport */ useBlockEditContext; });
  5881. __webpack_require__.d(__webpack_exports__, "BlockIcon", function() { return /* reexport */ BlockIcon; });
  5882. __webpack_require__.d(__webpack_exports__, "BlockNavigationDropdown", function() { return /* reexport */ dropdown; });
  5883. __webpack_require__.d(__webpack_exports__, "__experimentalBlockNavigationBlockFill", function() { return /* reexport */ BlockNavigationBlockFill; });
  5884. __webpack_require__.d(__webpack_exports__, "__experimentalBlockNavigationEditor", function() { return /* reexport */ BlockNavigationEditor; });
  5885. __webpack_require__.d(__webpack_exports__, "__experimentalBlockNavigationTree", function() { return /* reexport */ BlockNavigationTree; });
  5886. __webpack_require__.d(__webpack_exports__, "__experimentalBlockVariationPicker", function() { return /* reexport */ block_variation_picker; });
  5887. __webpack_require__.d(__webpack_exports__, "__experimentalBlockPatternSetup", function() { return /* reexport */ block_pattern_setup; });
  5888. __webpack_require__.d(__webpack_exports__, "__experimentalBlockVariationTransforms", function() { return /* reexport */ block_variation_transforms; });
  5889. __webpack_require__.d(__webpack_exports__, "BlockVerticalAlignmentToolbar", function() { return /* reexport */ BlockVerticalAlignmentToolbar; });
  5890. __webpack_require__.d(__webpack_exports__, "BlockVerticalAlignmentControl", function() { return /* reexport */ BlockVerticalAlignmentControl; });
  5891. __webpack_require__.d(__webpack_exports__, "__experimentalBorderStyleControl", function() { return /* reexport */ BorderStyleControl; });
  5892. __webpack_require__.d(__webpack_exports__, "ButtonBlockerAppender", function() { return /* reexport */ ButtonBlockerAppender; });
  5893. __webpack_require__.d(__webpack_exports__, "ButtonBlockAppender", function() { return /* reexport */ button_block_appender; });
  5894. __webpack_require__.d(__webpack_exports__, "ColorPalette", function() { return /* reexport */ color_palette; });
  5895. __webpack_require__.d(__webpack_exports__, "ColorPaletteControl", function() { return /* reexport */ ColorPaletteControl; });
  5896. __webpack_require__.d(__webpack_exports__, "ContrastChecker", function() { return /* reexport */ contrast_checker; });
  5897. __webpack_require__.d(__webpack_exports__, "__experimentalDuotoneControl", function() { return /* reexport */ duotone_control; });
  5898. __webpack_require__.d(__webpack_exports__, "__experimentalGradientPicker", function() { return /* reexport */ gradient_picker; });
  5899. __webpack_require__.d(__webpack_exports__, "__experimentalGradientPickerControl", function() { return /* reexport */ GradientPickerControl; });
  5900. __webpack_require__.d(__webpack_exports__, "__experimentalGradientPickerPanel", function() { return /* reexport */ GradientPanel; });
  5901. __webpack_require__.d(__webpack_exports__, "__experimentalFontAppearanceControl", function() { return /* reexport */ FontAppearanceControl; });
  5902. __webpack_require__.d(__webpack_exports__, "__experimentalFontFamilyControl", function() { return /* reexport */ FontFamilyControl; });
  5903. __webpack_require__.d(__webpack_exports__, "__experimentalColorGradientControl", function() { return /* reexport */ control; });
  5904. __webpack_require__.d(__webpack_exports__, "__experimentalPanelColorGradientSettings", function() { return /* reexport */ panel_color_gradient_settings; });
  5905. __webpack_require__.d(__webpack_exports__, "__experimentalImageSizeControl", function() { return /* reexport */ ImageSizeControl; });
  5906. __webpack_require__.d(__webpack_exports__, "InnerBlocks", function() { return /* reexport */ inner_blocks; });
  5907. __webpack_require__.d(__webpack_exports__, "__experimentalUseInnerBlocksProps", function() { return /* reexport */ useInnerBlocksProps; });
  5908. __webpack_require__.d(__webpack_exports__, "InspectorAdvancedControls", function() { return /* reexport */ inspector_advanced_controls; });
  5909. __webpack_require__.d(__webpack_exports__, "InspectorControls", function() { return /* reexport */ inspector_controls; });
  5910. __webpack_require__.d(__webpack_exports__, "JustifyToolbar", function() { return /* reexport */ JustifyToolbar; });
  5911. __webpack_require__.d(__webpack_exports__, "JustifyContentControl", function() { return /* reexport */ JustifyContentControl; });
  5912. __webpack_require__.d(__webpack_exports__, "__experimentalLinkControl", function() { return /* reexport */ link_control; });
  5913. __webpack_require__.d(__webpack_exports__, "__experimentalLinkControlSearchInput", function() { return /* reexport */ search_input; });
  5914. __webpack_require__.d(__webpack_exports__, "__experimentalLinkControlSearchResults", function() { return /* reexport */ LinkControlSearchResults; });
  5915. __webpack_require__.d(__webpack_exports__, "__experimentalLinkControlSearchItem", function() { return /* reexport */ search_item; });
  5916. __webpack_require__.d(__webpack_exports__, "LineHeightControl", function() { return /* reexport */ LineHeightControl; });
  5917. __webpack_require__.d(__webpack_exports__, "MediaReplaceFlow", function() { return /* reexport */ media_replace_flow; });
  5918. __webpack_require__.d(__webpack_exports__, "MediaPlaceholder", function() { return /* reexport */ media_placeholder; });
  5919. __webpack_require__.d(__webpack_exports__, "MediaUpload", function() { return /* reexport */ media_upload; });
  5920. __webpack_require__.d(__webpack_exports__, "MediaUploadCheck", function() { return /* reexport */ check; });
  5921. __webpack_require__.d(__webpack_exports__, "PanelColorSettings", function() { return /* reexport */ panel_color_settings; });
  5922. __webpack_require__.d(__webpack_exports__, "PlainText", function() { return /* reexport */ plain_text; });
  5923. __webpack_require__.d(__webpack_exports__, "__experimentalResponsiveBlockControl", function() { return /* reexport */ responsive_block_control; });
  5924. __webpack_require__.d(__webpack_exports__, "RichText", function() { return /* reexport */ rich_text; });
  5925. __webpack_require__.d(__webpack_exports__, "RichTextShortcut", function() { return /* reexport */ RichTextShortcut; });
  5926. __webpack_require__.d(__webpack_exports__, "RichTextToolbarButton", function() { return /* reexport */ RichTextToolbarButton; });
  5927. __webpack_require__.d(__webpack_exports__, "__unstableRichTextInputEvent", function() { return /* reexport */ input_event_unstableRichTextInputEvent; });
  5928. __webpack_require__.d(__webpack_exports__, "ToolSelector", function() { return /* reexport */ tool_selector; });
  5929. __webpack_require__.d(__webpack_exports__, "__experimentalUnitControl", function() { return /* reexport */ UnitControl; });
  5930. __webpack_require__.d(__webpack_exports__, "URLInput", function() { return /* reexport */ url_input; });
  5931. __webpack_require__.d(__webpack_exports__, "URLInputButton", function() { return /* reexport */ url_input_button; });
  5932. __webpack_require__.d(__webpack_exports__, "URLPopover", function() { return /* reexport */ url_popover; });
  5933. __webpack_require__.d(__webpack_exports__, "__experimentalImageURLInputUI", function() { return /* reexport */ ImageURLInputUI; });
  5934. __webpack_require__.d(__webpack_exports__, "withColorContext", function() { return /* reexport */ with_color_context; });
  5935. __webpack_require__.d(__webpack_exports__, "__unstableBlockSettingsMenuFirstItem", function() { return /* reexport */ block_settings_menu_first_item; });
  5936. __webpack_require__.d(__webpack_exports__, "__unstableInserterMenuExtension", function() { return /* reexport */ inserter_menu_extension; });
  5937. __webpack_require__.d(__webpack_exports__, "__experimentalPreviewOptions", function() { return /* reexport */ PreviewOptions; });
  5938. __webpack_require__.d(__webpack_exports__, "__experimentalUseResizeCanvas", function() { return /* reexport */ useResizeCanvas; });
  5939. __webpack_require__.d(__webpack_exports__, "BlockInspector", function() { return /* reexport */ block_inspector; });
  5940. __webpack_require__.d(__webpack_exports__, "BlockList", function() { return /* reexport */ BlockList; });
  5941. __webpack_require__.d(__webpack_exports__, "useBlockProps", function() { return /* reexport */ useBlockProps; });
  5942. __webpack_require__.d(__webpack_exports__, "__experimentalLayoutStyle", function() { return /* reexport */ LayoutStyle; });
  5943. __webpack_require__.d(__webpack_exports__, "BlockMover", function() { return /* reexport */ block_mover; });
  5944. __webpack_require__.d(__webpack_exports__, "BlockPreview", function() { return /* reexport */ block_preview; });
  5945. __webpack_require__.d(__webpack_exports__, "BlockSelectionClearer", function() { return /* reexport */ BlockSelectionClearer; });
  5946. __webpack_require__.d(__webpack_exports__, "__unstableUseBlockSelectionClearer", function() { return /* reexport */ useBlockSelectionClearer; });
  5947. __webpack_require__.d(__webpack_exports__, "BlockSettingsMenu", function() { return /* reexport */ block_settings_menu; });
  5948. __webpack_require__.d(__webpack_exports__, "BlockSettingsMenuControls", function() { return /* reexport */ block_settings_menu_controls; });
  5949. __webpack_require__.d(__webpack_exports__, "BlockTitle", function() { return /* reexport */ BlockTitle; });
  5950. __webpack_require__.d(__webpack_exports__, "BlockToolbar", function() { return /* reexport */ BlockToolbar; });
  5951. __webpack_require__.d(__webpack_exports__, "BlockTools", function() { return /* reexport */ BlockTools; });
  5952. __webpack_require__.d(__webpack_exports__, "CopyHandler", function() { return /* reexport */ copy_handler; });
  5953. __webpack_require__.d(__webpack_exports__, "__unstableUseClipboardHandler", function() { return /* reexport */ useClipboardHandler; });
  5954. __webpack_require__.d(__webpack_exports__, "DefaultBlockAppender", function() { return /* reexport */ default_block_appender; });
  5955. __webpack_require__.d(__webpack_exports__, "__unstableEditorStyles", function() { return /* reexport */ EditorStyles; });
  5956. __webpack_require__.d(__webpack_exports__, "Inserter", function() { return /* reexport */ inserter; });
  5957. __webpack_require__.d(__webpack_exports__, "__experimentalLibrary", function() { return /* reexport */ library; });
  5958. __webpack_require__.d(__webpack_exports__, "__experimentalSearchForm", function() { return /* reexport */ search_form; });
  5959. __webpack_require__.d(__webpack_exports__, "BlockEditorKeyboardShortcuts", function() { return /* reexport */ keyboard_shortcuts; });
  5960. __webpack_require__.d(__webpack_exports__, "MultiSelectScrollIntoView", function() { return /* reexport */ MultiSelectScrollIntoView; });
  5961. __webpack_require__.d(__webpack_exports__, "NavigableToolbar", function() { return /* reexport */ navigable_toolbar; });
  5962. __webpack_require__.d(__webpack_exports__, "ObserveTyping", function() { return /* reexport */ observe_typing; });
  5963. __webpack_require__.d(__webpack_exports__, "__unstableUseTypingObserver", function() { return /* reexport */ useTypingObserver; });
  5964. __webpack_require__.d(__webpack_exports__, "__unstableUseMouseMoveTypingReset", function() { return /* reexport */ useMouseMoveTypingReset; });
  5965. __webpack_require__.d(__webpack_exports__, "PreserveScrollInReorder", function() { return /* reexport */ PreserveScrollInReorder; });
  5966. __webpack_require__.d(__webpack_exports__, "SkipToSelectedBlock", function() { return /* reexport */ skip_to_selected_block; });
  5967. __webpack_require__.d(__webpack_exports__, "Typewriter", function() { return /* reexport */ typewriter; });
  5968. __webpack_require__.d(__webpack_exports__, "__unstableUseTypewriter", function() { return /* reexport */ useTypewriter; });
  5969. __webpack_require__.d(__webpack_exports__, "Warning", function() { return /* reexport */ warning; });
  5970. __webpack_require__.d(__webpack_exports__, "WritingFlow", function() { return /* reexport */ writing_flow; });
  5971. __webpack_require__.d(__webpack_exports__, "__unstableUseCanvasClickRedirect", function() { return /* reexport */ useCanvasClickRedirect; });
  5972. __webpack_require__.d(__webpack_exports__, "useBlockDisplayInformation", function() { return /* reexport */ useBlockDisplayInformation; });
  5973. __webpack_require__.d(__webpack_exports__, "__unstableIframe", function() { return /* reexport */ iframe; });
  5974. __webpack_require__.d(__webpack_exports__, "__experimentalUseNoRecursiveRenders", function() { return /* reexport */ useNoRecursiveRenders; });
  5975. __webpack_require__.d(__webpack_exports__, "BlockEditorProvider", function() { return /* reexport */ provider; });
  5976. __webpack_require__.d(__webpack_exports__, "__experimentalUseSimulatedMediaQuery", function() { return /* reexport */ useSimulatedMediaQuery; });
  5977. __webpack_require__.d(__webpack_exports__, "useSetting", function() { return /* reexport */ useSetting; });
  5978. __webpack_require__.d(__webpack_exports__, "transformStyles", function() { return /* reexport */ transform_styles; });
  5979. __webpack_require__.d(__webpack_exports__, "validateThemeColors", function() { return /* reexport */ validateThemeColors; });
  5980. __webpack_require__.d(__webpack_exports__, "validateThemeGradients", function() { return /* reexport */ validateThemeGradients; });
  5981. __webpack_require__.d(__webpack_exports__, "__experimentalGetMatchingVariation", function() { return /* reexport */ __experimentalGetMatchingVariation; });
  5982. __webpack_require__.d(__webpack_exports__, "storeConfig", function() { return /* reexport */ storeConfig; });
  5983. __webpack_require__.d(__webpack_exports__, "store", function() { return /* reexport */ store; });
  5984. __webpack_require__.d(__webpack_exports__, "SETTINGS_DEFAULTS", function() { return /* reexport */ SETTINGS_DEFAULTS; });
  5985. // NAMESPACE OBJECT: ./node_modules/@wordpress/block-editor/build-module/store/selectors.js
  5986. var selectors_namespaceObject = {};
  5987. __webpack_require__.r(selectors_namespaceObject);
  5988. __webpack_require__.d(selectors_namespaceObject, "getBlockName", function() { return selectors_getBlockName; });
  5989. __webpack_require__.d(selectors_namespaceObject, "isBlockValid", function() { return selectors_isBlockValid; });
  5990. __webpack_require__.d(selectors_namespaceObject, "getBlockAttributes", function() { return selectors_getBlockAttributes; });
  5991. __webpack_require__.d(selectors_namespaceObject, "getBlock", function() { return selectors_getBlock; });
  5992. __webpack_require__.d(selectors_namespaceObject, "__unstableGetBlockWithoutInnerBlocks", function() { return selectors_unstableGetBlockWithoutInnerBlocks; });
  5993. __webpack_require__.d(selectors_namespaceObject, "getBlocks", function() { return selectors_getBlocks; });
  5994. __webpack_require__.d(selectors_namespaceObject, "__unstableGetBlockWithBlockTree", function() { return __unstableGetBlockWithBlockTree; });
  5995. __webpack_require__.d(selectors_namespaceObject, "__unstableGetBlockTree", function() { return __unstableGetBlockTree; });
  5996. __webpack_require__.d(selectors_namespaceObject, "__unstableGetClientIdWithClientIdsTree", function() { return selectors_unstableGetClientIdWithClientIdsTree; });
  5997. __webpack_require__.d(selectors_namespaceObject, "__unstableGetClientIdsTree", function() { return selectors_unstableGetClientIdsTree; });
  5998. __webpack_require__.d(selectors_namespaceObject, "getClientIdsOfDescendants", function() { return selectors_getClientIdsOfDescendants; });
  5999. __webpack_require__.d(selectors_namespaceObject, "getClientIdsWithDescendants", function() { return getClientIdsWithDescendants; });
  6000. __webpack_require__.d(selectors_namespaceObject, "getGlobalBlockCount", function() { return selectors_getGlobalBlockCount; });
  6001. __webpack_require__.d(selectors_namespaceObject, "getBlocksByClientId", function() { return selectors_getBlocksByClientId; });
  6002. __webpack_require__.d(selectors_namespaceObject, "getBlockCount", function() { return selectors_getBlockCount; });
  6003. __webpack_require__.d(selectors_namespaceObject, "getSelectionStart", function() { return selectors_getSelectionStart; });
  6004. __webpack_require__.d(selectors_namespaceObject, "getSelectionEnd", function() { return selectors_getSelectionEnd; });
  6005. __webpack_require__.d(selectors_namespaceObject, "getBlockSelectionStart", function() { return selectors_getBlockSelectionStart; });
  6006. __webpack_require__.d(selectors_namespaceObject, "getBlockSelectionEnd", function() { return selectors_getBlockSelectionEnd; });
  6007. __webpack_require__.d(selectors_namespaceObject, "getSelectedBlockCount", function() { return selectors_getSelectedBlockCount; });
  6008. __webpack_require__.d(selectors_namespaceObject, "hasSelectedBlock", function() { return selectors_hasSelectedBlock; });
  6009. __webpack_require__.d(selectors_namespaceObject, "getSelectedBlockClientId", function() { return selectors_getSelectedBlockClientId; });
  6010. __webpack_require__.d(selectors_namespaceObject, "getSelectedBlock", function() { return selectors_getSelectedBlock; });
  6011. __webpack_require__.d(selectors_namespaceObject, "getBlockRootClientId", function() { return selectors_getBlockRootClientId; });
  6012. __webpack_require__.d(selectors_namespaceObject, "getBlockParents", function() { return selectors_getBlockParents; });
  6013. __webpack_require__.d(selectors_namespaceObject, "getBlockParentsByBlockName", function() { return getBlockParentsByBlockName; });
  6014. __webpack_require__.d(selectors_namespaceObject, "getBlockHierarchyRootClientId", function() { return selectors_getBlockHierarchyRootClientId; });
  6015. __webpack_require__.d(selectors_namespaceObject, "getLowestCommonAncestorWithSelectedBlock", function() { return getLowestCommonAncestorWithSelectedBlock; });
  6016. __webpack_require__.d(selectors_namespaceObject, "getAdjacentBlockClientId", function() { return getAdjacentBlockClientId; });
  6017. __webpack_require__.d(selectors_namespaceObject, "getPreviousBlockClientId", function() { return selectors_getPreviousBlockClientId; });
  6018. __webpack_require__.d(selectors_namespaceObject, "getNextBlockClientId", function() { return selectors_getNextBlockClientId; });
  6019. __webpack_require__.d(selectors_namespaceObject, "getSelectedBlocksInitialCaretPosition", function() { return selectors_getSelectedBlocksInitialCaretPosition; });
  6020. __webpack_require__.d(selectors_namespaceObject, "getSelectedBlockClientIds", function() { return selectors_getSelectedBlockClientIds; });
  6021. __webpack_require__.d(selectors_namespaceObject, "getMultiSelectedBlockClientIds", function() { return selectors_getMultiSelectedBlockClientIds; });
  6022. __webpack_require__.d(selectors_namespaceObject, "getMultiSelectedBlocks", function() { return selectors_getMultiSelectedBlocks; });
  6023. __webpack_require__.d(selectors_namespaceObject, "getFirstMultiSelectedBlockClientId", function() { return selectors_getFirstMultiSelectedBlockClientId; });
  6024. __webpack_require__.d(selectors_namespaceObject, "getLastMultiSelectedBlockClientId", function() { return selectors_getLastMultiSelectedBlockClientId; });
  6025. __webpack_require__.d(selectors_namespaceObject, "isFirstMultiSelectedBlock", function() { return selectors_isFirstMultiSelectedBlock; });
  6026. __webpack_require__.d(selectors_namespaceObject, "isBlockMultiSelected", function() { return selectors_isBlockMultiSelected; });
  6027. __webpack_require__.d(selectors_namespaceObject, "isAncestorMultiSelected", function() { return selectors_isAncestorMultiSelected; });
  6028. __webpack_require__.d(selectors_namespaceObject, "getMultiSelectedBlocksStartClientId", function() { return selectors_getMultiSelectedBlocksStartClientId; });
  6029. __webpack_require__.d(selectors_namespaceObject, "getMultiSelectedBlocksEndClientId", function() { return selectors_getMultiSelectedBlocksEndClientId; });
  6030. __webpack_require__.d(selectors_namespaceObject, "getBlockOrder", function() { return selectors_getBlockOrder; });
  6031. __webpack_require__.d(selectors_namespaceObject, "getBlockIndex", function() { return selectors_getBlockIndex; });
  6032. __webpack_require__.d(selectors_namespaceObject, "isBlockSelected", function() { return selectors_isBlockSelected; });
  6033. __webpack_require__.d(selectors_namespaceObject, "hasSelectedInnerBlock", function() { return selectors_hasSelectedInnerBlock; });
  6034. __webpack_require__.d(selectors_namespaceObject, "isBlockWithinSelection", function() { return isBlockWithinSelection; });
  6035. __webpack_require__.d(selectors_namespaceObject, "hasMultiSelection", function() { return selectors_hasMultiSelection; });
  6036. __webpack_require__.d(selectors_namespaceObject, "isMultiSelecting", function() { return selectors_isMultiSelecting; });
  6037. __webpack_require__.d(selectors_namespaceObject, "isSelectionEnabled", function() { return selectors_isSelectionEnabled; });
  6038. __webpack_require__.d(selectors_namespaceObject, "getBlockMode", function() { return selectors_getBlockMode; });
  6039. __webpack_require__.d(selectors_namespaceObject, "isTyping", function() { return selectors_isTyping; });
  6040. __webpack_require__.d(selectors_namespaceObject, "isDraggingBlocks", function() { return isDraggingBlocks; });
  6041. __webpack_require__.d(selectors_namespaceObject, "getDraggedBlockClientIds", function() { return selectors_getDraggedBlockClientIds; });
  6042. __webpack_require__.d(selectors_namespaceObject, "isBlockBeingDragged", function() { return selectors_isBlockBeingDragged; });
  6043. __webpack_require__.d(selectors_namespaceObject, "isAncestorBeingDragged", function() { return selectors_isAncestorBeingDragged; });
  6044. __webpack_require__.d(selectors_namespaceObject, "isCaretWithinFormattedText", function() { return selectors_isCaretWithinFormattedText; });
  6045. __webpack_require__.d(selectors_namespaceObject, "getBlockInsertionPoint", function() { return selectors_getBlockInsertionPoint; });
  6046. __webpack_require__.d(selectors_namespaceObject, "isBlockInsertionPointVisible", function() { return selectors_isBlockInsertionPointVisible; });
  6047. __webpack_require__.d(selectors_namespaceObject, "isValidTemplate", function() { return selectors_isValidTemplate; });
  6048. __webpack_require__.d(selectors_namespaceObject, "getTemplate", function() { return getTemplate; });
  6049. __webpack_require__.d(selectors_namespaceObject, "getTemplateLock", function() { return selectors_getTemplateLock; });
  6050. __webpack_require__.d(selectors_namespaceObject, "canInsertBlockType", function() { return selectors_canInsertBlockType; });
  6051. __webpack_require__.d(selectors_namespaceObject, "canInsertBlocks", function() { return selectors_canInsertBlocks; });
  6052. __webpack_require__.d(selectors_namespaceObject, "getInserterItems", function() { return selectors_getInserterItems; });
  6053. __webpack_require__.d(selectors_namespaceObject, "getBlockTransformItems", function() { return selectors_getBlockTransformItems; });
  6054. __webpack_require__.d(selectors_namespaceObject, "hasInserterItems", function() { return selectors_hasInserterItems; });
  6055. __webpack_require__.d(selectors_namespaceObject, "__experimentalGetAllowedBlocks", function() { return selectors_experimentalGetAllowedBlocks; });
  6056. __webpack_require__.d(selectors_namespaceObject, "__experimentalGetParsedPattern", function() { return __experimentalGetParsedPattern; });
  6057. __webpack_require__.d(selectors_namespaceObject, "__experimentalGetAllowedPatterns", function() { return selectors_experimentalGetAllowedPatterns; });
  6058. __webpack_require__.d(selectors_namespaceObject, "__experimentalGetPatternsByBlockTypes", function() { return selectors_experimentalGetPatternsByBlockTypes; });
  6059. __webpack_require__.d(selectors_namespaceObject, "__experimentalGetPatternTransformItems", function() { return selectors_experimentalGetPatternTransformItems; });
  6060. __webpack_require__.d(selectors_namespaceObject, "getBlockListSettings", function() { return selectors_getBlockListSettings; });
  6061. __webpack_require__.d(selectors_namespaceObject, "getSettings", function() { return selectors_getSettings; });
  6062. __webpack_require__.d(selectors_namespaceObject, "isLastBlockChangePersistent", function() { return selectors_isLastBlockChangePersistent; });
  6063. __webpack_require__.d(selectors_namespaceObject, "__experimentalGetBlockListSettingsForBlocks", function() { return selectors_experimentalGetBlockListSettingsForBlocks; });
  6064. __webpack_require__.d(selectors_namespaceObject, "__experimentalGetParsedReusableBlock", function() { return __experimentalGetParsedReusableBlock; });
  6065. __webpack_require__.d(selectors_namespaceObject, "__experimentalGetReusableBlockTitle", function() { return selectors_experimentalGetReusableBlockTitle; });
  6066. __webpack_require__.d(selectors_namespaceObject, "__unstableIsLastBlockChangeIgnored", function() { return selectors_unstableIsLastBlockChangeIgnored; });
  6067. __webpack_require__.d(selectors_namespaceObject, "__experimentalGetLastBlockAttributeChanges", function() { return __experimentalGetLastBlockAttributeChanges; });
  6068. __webpack_require__.d(selectors_namespaceObject, "isNavigationMode", function() { return selectors_isNavigationMode; });
  6069. __webpack_require__.d(selectors_namespaceObject, "hasBlockMovingClientId", function() { return selectors_hasBlockMovingClientId; });
  6070. __webpack_require__.d(selectors_namespaceObject, "didAutomaticChange", function() { return selectors_didAutomaticChange; });
  6071. __webpack_require__.d(selectors_namespaceObject, "isBlockHighlighted", function() { return selectors_isBlockHighlighted; });
  6072. __webpack_require__.d(selectors_namespaceObject, "areInnerBlocksControlled", function() { return areInnerBlocksControlled; });
  6073. __webpack_require__.d(selectors_namespaceObject, "__experimentalGetActiveBlockIdByBlockNames", function() { return __experimentalGetActiveBlockIdByBlockNames; });
  6074. __webpack_require__.d(selectors_namespaceObject, "wasBlockJustInserted", function() { return wasBlockJustInserted; });
  6075. // NAMESPACE OBJECT: ./node_modules/@wordpress/block-editor/build-module/store/actions.js
  6076. var actions_namespaceObject = {};
  6077. __webpack_require__.r(actions_namespaceObject);
  6078. __webpack_require__.d(actions_namespaceObject, "resetBlocks", function() { return actions_resetBlocks; });
  6079. __webpack_require__.d(actions_namespaceObject, "validateBlocksToTemplate", function() { return validateBlocksToTemplate; });
  6080. __webpack_require__.d(actions_namespaceObject, "resetSelection", function() { return actions_resetSelection; });
  6081. __webpack_require__.d(actions_namespaceObject, "receiveBlocks", function() { return receiveBlocks; });
  6082. __webpack_require__.d(actions_namespaceObject, "updateBlockAttributes", function() { return actions_updateBlockAttributes; });
  6083. __webpack_require__.d(actions_namespaceObject, "updateBlock", function() { return actions_updateBlock; });
  6084. __webpack_require__.d(actions_namespaceObject, "selectBlock", function() { return actions_selectBlock; });
  6085. __webpack_require__.d(actions_namespaceObject, "selectPreviousBlock", function() { return selectPreviousBlock; });
  6086. __webpack_require__.d(actions_namespaceObject, "selectNextBlock", function() { return selectNextBlock; });
  6087. __webpack_require__.d(actions_namespaceObject, "startMultiSelect", function() { return actions_startMultiSelect; });
  6088. __webpack_require__.d(actions_namespaceObject, "stopMultiSelect", function() { return actions_stopMultiSelect; });
  6089. __webpack_require__.d(actions_namespaceObject, "multiSelect", function() { return actions_multiSelect; });
  6090. __webpack_require__.d(actions_namespaceObject, "clearSelectedBlock", function() { return actions_clearSelectedBlock; });
  6091. __webpack_require__.d(actions_namespaceObject, "toggleSelection", function() { return actions_toggleSelection; });
  6092. __webpack_require__.d(actions_namespaceObject, "replaceBlocks", function() { return actions_replaceBlocks; });
  6093. __webpack_require__.d(actions_namespaceObject, "replaceBlock", function() { return actions_replaceBlock; });
  6094. __webpack_require__.d(actions_namespaceObject, "moveBlocksDown", function() { return actions_moveBlocksDown; });
  6095. __webpack_require__.d(actions_namespaceObject, "moveBlocksUp", function() { return actions_moveBlocksUp; });
  6096. __webpack_require__.d(actions_namespaceObject, "moveBlocksToPosition", function() { return actions_moveBlocksToPosition; });
  6097. __webpack_require__.d(actions_namespaceObject, "moveBlockToPosition", function() { return actions_moveBlockToPosition; });
  6098. __webpack_require__.d(actions_namespaceObject, "insertBlock", function() { return actions_insertBlock; });
  6099. __webpack_require__.d(actions_namespaceObject, "insertBlocks", function() { return actions_insertBlocks; });
  6100. __webpack_require__.d(actions_namespaceObject, "showInsertionPoint", function() { return actions_showInsertionPoint; });
  6101. __webpack_require__.d(actions_namespaceObject, "hideInsertionPoint", function() { return actions_hideInsertionPoint; });
  6102. __webpack_require__.d(actions_namespaceObject, "setTemplateValidity", function() { return setTemplateValidity; });
  6103. __webpack_require__.d(actions_namespaceObject, "synchronizeTemplate", function() { return synchronizeTemplate; });
  6104. __webpack_require__.d(actions_namespaceObject, "mergeBlocks", function() { return actions_mergeBlocks; });
  6105. __webpack_require__.d(actions_namespaceObject, "removeBlocks", function() { return actions_removeBlocks; });
  6106. __webpack_require__.d(actions_namespaceObject, "removeBlock", function() { return actions_removeBlock; });
  6107. __webpack_require__.d(actions_namespaceObject, "replaceInnerBlocks", function() { return actions_replaceInnerBlocks; });
  6108. __webpack_require__.d(actions_namespaceObject, "toggleBlockMode", function() { return toggleBlockMode; });
  6109. __webpack_require__.d(actions_namespaceObject, "startTyping", function() { return actions_startTyping; });
  6110. __webpack_require__.d(actions_namespaceObject, "stopTyping", function() { return actions_stopTyping; });
  6111. __webpack_require__.d(actions_namespaceObject, "startDraggingBlocks", function() { return actions_startDraggingBlocks; });
  6112. __webpack_require__.d(actions_namespaceObject, "stopDraggingBlocks", function() { return actions_stopDraggingBlocks; });
  6113. __webpack_require__.d(actions_namespaceObject, "enterFormattedText", function() { return actions_enterFormattedText; });
  6114. __webpack_require__.d(actions_namespaceObject, "exitFormattedText", function() { return actions_exitFormattedText; });
  6115. __webpack_require__.d(actions_namespaceObject, "selectionChange", function() { return actions_selectionChange; });
  6116. __webpack_require__.d(actions_namespaceObject, "insertDefaultBlock", function() { return actions_insertDefaultBlock; });
  6117. __webpack_require__.d(actions_namespaceObject, "updateBlockListSettings", function() { return actions_updateBlockListSettings; });
  6118. __webpack_require__.d(actions_namespaceObject, "updateSettings", function() { return actions_updateSettings; });
  6119. __webpack_require__.d(actions_namespaceObject, "__unstableSaveReusableBlock", function() { return __unstableSaveReusableBlock; });
  6120. __webpack_require__.d(actions_namespaceObject, "__unstableMarkLastChangeAsPersistent", function() { return actions_unstableMarkLastChangeAsPersistent; });
  6121. __webpack_require__.d(actions_namespaceObject, "__unstableMarkNextChangeAsNotPersistent", function() { return actions_unstableMarkNextChangeAsNotPersistent; });
  6122. __webpack_require__.d(actions_namespaceObject, "__unstableMarkAutomaticChange", function() { return actions_unstableMarkAutomaticChange; });
  6123. __webpack_require__.d(actions_namespaceObject, "__unstableMarkAutomaticChangeFinal", function() { return __unstableMarkAutomaticChangeFinal; });
  6124. __webpack_require__.d(actions_namespaceObject, "setNavigationMode", function() { return actions_setNavigationMode; });
  6125. __webpack_require__.d(actions_namespaceObject, "setBlockMovingClientId", function() { return actions_setBlockMovingClientId; });
  6126. __webpack_require__.d(actions_namespaceObject, "duplicateBlocks", function() { return actions_duplicateBlocks; });
  6127. __webpack_require__.d(actions_namespaceObject, "insertBeforeBlock", function() { return actions_insertBeforeBlock; });
  6128. __webpack_require__.d(actions_namespaceObject, "insertAfterBlock", function() { return actions_insertAfterBlock; });
  6129. __webpack_require__.d(actions_namespaceObject, "toggleBlockHighlight", function() { return actions_toggleBlockHighlight; });
  6130. __webpack_require__.d(actions_namespaceObject, "flashBlock", function() { return actions_flashBlock; });
  6131. __webpack_require__.d(actions_namespaceObject, "setHasControlledInnerBlocks", function() { return actions_setHasControlledInnerBlocks; });
  6132. // EXTERNAL MODULE: external ["wp","richText"]
  6133. var external_wp_richText_ = __webpack_require__("qRz9");
  6134. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
  6135. var esm_extends = __webpack_require__("wx14");
  6136. // EXTERNAL MODULE: external ["wp","element"]
  6137. var external_wp_element_ = __webpack_require__("GRId");
  6138. // EXTERNAL MODULE: ./node_modules/classnames/index.js
  6139. var classnames = __webpack_require__("TSYQ");
  6140. var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
  6141. // EXTERNAL MODULE: external "lodash"
  6142. var external_lodash_ = __webpack_require__("YLtl");
  6143. // EXTERNAL MODULE: external ["wp","compose"]
  6144. var external_wp_compose_ = __webpack_require__("K9lf");
  6145. // EXTERNAL MODULE: external ["wp","hooks"]
  6146. var external_wp_hooks_ = __webpack_require__("g56x");
  6147. // EXTERNAL MODULE: external ["wp","blocks"]
  6148. var external_wp_blocks_ = __webpack_require__("HSyU");
  6149. // EXTERNAL MODULE: external ["wp","components"]
  6150. var external_wp_components_ = __webpack_require__("tI+e");
  6151. // EXTERNAL MODULE: external ["wp","data"]
  6152. var external_wp_data_ = __webpack_require__("1ZqX");
  6153. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-edit/context.js
  6154. /**
  6155. * WordPress dependencies
  6156. */
  6157. const Context = Object(external_wp_element_["createContext"])({
  6158. name: '',
  6159. isSelected: false,
  6160. clientId: null
  6161. });
  6162. const {
  6163. Provider: context_Provider
  6164. } = Context;
  6165. /**
  6166. * A hook that returns the block edit context.
  6167. *
  6168. * @return {Object} Block edit context
  6169. */
  6170. function useBlockEditContext() {
  6171. return Object(external_wp_element_["useContext"])(Context);
  6172. }
  6173. // EXTERNAL MODULE: external ["wp","i18n"]
  6174. var external_wp_i18n_ = __webpack_require__("l3Sj");
  6175. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/defaults.js
  6176. /**
  6177. * WordPress dependencies
  6178. */
  6179. const PREFERENCES_DEFAULTS = {
  6180. insertUsage: {}
  6181. };
  6182. /**
  6183. * The default editor settings
  6184. *
  6185. * @typedef {Object} SETTINGS_DEFAULT
  6186. * @property {boolean} alignWide Enable/Disable Wide/Full Alignments
  6187. * @property {boolean} supportsLayout Enable/disable layouts support in container blocks.
  6188. * @property {boolean} imageEditing Image Editing settings set to false to disable.
  6189. * @property {Array} imageSizes Available image sizes
  6190. * @property {number} maxWidth Max width to constraint resizing
  6191. * @property {boolean|Array} allowedBlockTypes Allowed block types
  6192. * @property {boolean} hasFixedToolbar Whether or not the editor toolbar is fixed
  6193. * @property {boolean} focusMode Whether the focus mode is enabled or not
  6194. * @property {Array} styles Editor Styles
  6195. * @property {boolean} keepCaretInsideBlock Whether caret should move between blocks in edit mode
  6196. * @property {string} bodyPlaceholder Empty post placeholder
  6197. * @property {string} titlePlaceholder Empty title placeholder
  6198. * @property {boolean} codeEditingEnabled Whether or not the user can switch to the code editor
  6199. * @property {boolean} __experimentalCanUserUseUnfilteredHTML Whether the user should be able to use unfiltered HTML or the HTML should be filtered e.g., to remove elements considered insecure like iframes.
  6200. * @property {boolean} __experimentalBlockDirectory Whether the user has enabled the Block Directory
  6201. * @property {Array} __experimentalBlockPatterns Array of objects representing the block patterns
  6202. * @property {Array} __experimentalBlockPatternCategories Array of objects representing the block pattern categories
  6203. */
  6204. const SETTINGS_DEFAULTS = {
  6205. alignWide: false,
  6206. supportsLayout: true,
  6207. // colors setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults.
  6208. // The setting is only kept for backward compatibility purposes.
  6209. colors: [{
  6210. name: Object(external_wp_i18n_["__"])('Black'),
  6211. slug: 'black',
  6212. color: '#000000'
  6213. }, {
  6214. name: Object(external_wp_i18n_["__"])('Cyan bluish gray'),
  6215. slug: 'cyan-bluish-gray',
  6216. color: '#abb8c3'
  6217. }, {
  6218. name: Object(external_wp_i18n_["__"])('White'),
  6219. slug: 'white',
  6220. color: '#ffffff'
  6221. }, {
  6222. name: Object(external_wp_i18n_["__"])('Pale pink'),
  6223. slug: 'pale-pink',
  6224. color: '#f78da7'
  6225. }, {
  6226. name: Object(external_wp_i18n_["__"])('Vivid red'),
  6227. slug: 'vivid-red',
  6228. color: '#cf2e2e'
  6229. }, {
  6230. name: Object(external_wp_i18n_["__"])('Luminous vivid orange'),
  6231. slug: 'luminous-vivid-orange',
  6232. color: '#ff6900'
  6233. }, {
  6234. name: Object(external_wp_i18n_["__"])('Luminous vivid amber'),
  6235. slug: 'luminous-vivid-amber',
  6236. color: '#fcb900'
  6237. }, {
  6238. name: Object(external_wp_i18n_["__"])('Light green cyan'),
  6239. slug: 'light-green-cyan',
  6240. color: '#7bdcb5'
  6241. }, {
  6242. name: Object(external_wp_i18n_["__"])('Vivid green cyan'),
  6243. slug: 'vivid-green-cyan',
  6244. color: '#00d084'
  6245. }, {
  6246. name: Object(external_wp_i18n_["__"])('Pale cyan blue'),
  6247. slug: 'pale-cyan-blue',
  6248. color: '#8ed1fc'
  6249. }, {
  6250. name: Object(external_wp_i18n_["__"])('Vivid cyan blue'),
  6251. slug: 'vivid-cyan-blue',
  6252. color: '#0693e3'
  6253. }, {
  6254. name: Object(external_wp_i18n_["__"])('Vivid purple'),
  6255. slug: 'vivid-purple',
  6256. color: '#9b51e0'
  6257. }],
  6258. // fontSizes setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults.
  6259. // The setting is only kept for backward compatibility purposes.
  6260. fontSizes: [{
  6261. name: Object(external_wp_i18n_["_x"])('Small', 'font size name'),
  6262. size: 13,
  6263. slug: 'small'
  6264. }, {
  6265. name: Object(external_wp_i18n_["_x"])('Normal', 'font size name'),
  6266. size: 16,
  6267. slug: 'normal'
  6268. }, {
  6269. name: Object(external_wp_i18n_["_x"])('Medium', 'font size name'),
  6270. size: 20,
  6271. slug: 'medium'
  6272. }, {
  6273. name: Object(external_wp_i18n_["_x"])('Large', 'font size name'),
  6274. size: 36,
  6275. slug: 'large'
  6276. }, {
  6277. name: Object(external_wp_i18n_["_x"])('Huge', 'font size name'),
  6278. size: 42,
  6279. slug: 'huge'
  6280. }],
  6281. // Image default size slug.
  6282. imageDefaultSize: 'large',
  6283. imageSizes: [{
  6284. slug: 'thumbnail',
  6285. name: Object(external_wp_i18n_["__"])('Thumbnail')
  6286. }, {
  6287. slug: 'medium',
  6288. name: Object(external_wp_i18n_["__"])('Medium')
  6289. }, {
  6290. slug: 'large',
  6291. name: Object(external_wp_i18n_["__"])('Large')
  6292. }, {
  6293. slug: 'full',
  6294. name: Object(external_wp_i18n_["__"])('Full Size')
  6295. }],
  6296. // Allow plugin to disable Image Editor if need be
  6297. imageEditing: true,
  6298. // This is current max width of the block inner area
  6299. // It's used to constraint image resizing and this value could be overridden later by themes
  6300. maxWidth: 580,
  6301. // Allowed block types for the editor, defaulting to true (all supported).
  6302. allowedBlockTypes: true,
  6303. // Maximum upload size in bytes allowed for the site.
  6304. maxUploadFileSize: 0,
  6305. // List of allowed mime types and file extensions.
  6306. allowedMimeTypes: null,
  6307. __experimentalCanUserUseUnfilteredHTML: false,
  6308. __experimentalBlockDirectory: false,
  6309. __mobileEnablePageTemplates: false,
  6310. __experimentalBlockPatterns: [],
  6311. __experimentalBlockPatternCategories: [],
  6312. __experimentalSpotlightEntityBlocks: [],
  6313. // gradients setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults.
  6314. // The setting is only kept for backward compatibility purposes.
  6315. gradients: [{
  6316. name: Object(external_wp_i18n_["__"])('Vivid cyan blue to vivid purple'),
  6317. gradient: 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)',
  6318. slug: 'vivid-cyan-blue-to-vivid-purple'
  6319. }, {
  6320. name: Object(external_wp_i18n_["__"])('Light green cyan to vivid green cyan'),
  6321. gradient: 'linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)',
  6322. slug: 'light-green-cyan-to-vivid-green-cyan'
  6323. }, {
  6324. name: Object(external_wp_i18n_["__"])('Luminous vivid amber to luminous vivid orange'),
  6325. gradient: 'linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%)',
  6326. slug: 'luminous-vivid-amber-to-luminous-vivid-orange'
  6327. }, {
  6328. name: Object(external_wp_i18n_["__"])('Luminous vivid orange to vivid red'),
  6329. gradient: 'linear-gradient(135deg,rgba(255,105,0,1) 0%,rgb(207,46,46) 100%)',
  6330. slug: 'luminous-vivid-orange-to-vivid-red'
  6331. }, {
  6332. name: Object(external_wp_i18n_["__"])('Very light gray to cyan bluish gray'),
  6333. gradient: 'linear-gradient(135deg,rgb(238,238,238) 0%,rgb(169,184,195) 100%)',
  6334. slug: 'very-light-gray-to-cyan-bluish-gray'
  6335. }, {
  6336. name: Object(external_wp_i18n_["__"])('Cool to warm spectrum'),
  6337. gradient: 'linear-gradient(135deg,rgb(74,234,220) 0%,rgb(151,120,209) 20%,rgb(207,42,186) 40%,rgb(238,44,130) 60%,rgb(251,105,98) 80%,rgb(254,248,76) 100%)',
  6338. slug: 'cool-to-warm-spectrum'
  6339. }, {
  6340. name: Object(external_wp_i18n_["__"])('Blush light purple'),
  6341. gradient: 'linear-gradient(135deg,rgb(255,206,236) 0%,rgb(152,150,240) 100%)',
  6342. slug: 'blush-light-purple'
  6343. }, {
  6344. name: Object(external_wp_i18n_["__"])('Blush bordeaux'),
  6345. gradient: 'linear-gradient(135deg,rgb(254,205,165) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%)',
  6346. slug: 'blush-bordeaux'
  6347. }, {
  6348. name: Object(external_wp_i18n_["__"])('Luminous dusk'),
  6349. gradient: 'linear-gradient(135deg,rgb(255,203,112) 0%,rgb(199,81,192) 50%,rgb(65,88,208) 100%)',
  6350. slug: 'luminous-dusk'
  6351. }, {
  6352. name: Object(external_wp_i18n_["__"])('Pale ocean'),
  6353. gradient: 'linear-gradient(135deg,rgb(255,245,203) 0%,rgb(182,227,212) 50%,rgb(51,167,181) 100%)',
  6354. slug: 'pale-ocean'
  6355. }, {
  6356. name: Object(external_wp_i18n_["__"])('Electric grass'),
  6357. gradient: 'linear-gradient(135deg,rgb(202,248,128) 0%,rgb(113,206,126) 100%)',
  6358. slug: 'electric-grass'
  6359. }, {
  6360. name: Object(external_wp_i18n_["__"])('Midnight'),
  6361. gradient: 'linear-gradient(135deg,rgb(2,3,129) 0%,rgb(40,116,252) 100%)',
  6362. slug: 'midnight'
  6363. }]
  6364. };
  6365. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/array.js
  6366. /**
  6367. * External dependencies
  6368. */
  6369. /**
  6370. * Insert one or multiple elements into a given position of an array.
  6371. *
  6372. * @param {Array} array Source array.
  6373. * @param {*} elements Elements to insert.
  6374. * @param {number} index Insert Position.
  6375. *
  6376. * @return {Array} Result.
  6377. */
  6378. function insertAt(array, elements, index) {
  6379. return [...array.slice(0, index), ...Object(external_lodash_["castArray"])(elements), ...array.slice(index)];
  6380. }
  6381. /**
  6382. * Moves an element in an array.
  6383. *
  6384. * @param {Array} array Source array.
  6385. * @param {number} from Source index.
  6386. * @param {number} to Destination index.
  6387. * @param {number} count Number of elements to move.
  6388. *
  6389. * @return {Array} Result.
  6390. */
  6391. function moveTo(array, from, to, count = 1) {
  6392. const withoutMovedElements = [...array];
  6393. withoutMovedElements.splice(from, count);
  6394. return insertAt(withoutMovedElements, array.slice(from, from + count), to);
  6395. }
  6396. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/reducer.js
  6397. /**
  6398. * External dependencies
  6399. */
  6400. /**
  6401. * WordPress dependencies
  6402. */
  6403. /**
  6404. * Internal dependencies
  6405. */
  6406. /**
  6407. * Given an array of blocks, returns an object where each key is a nesting
  6408. * context, the value of which is an array of block client IDs existing within
  6409. * that nesting context.
  6410. *
  6411. * @param {Array} blocks Blocks to map.
  6412. * @param {?string} rootClientId Assumed root client ID.
  6413. *
  6414. * @return {Object} Block order map object.
  6415. */
  6416. function mapBlockOrder(blocks, rootClientId = '') {
  6417. const result = {
  6418. [rootClientId]: []
  6419. };
  6420. blocks.forEach(block => {
  6421. const {
  6422. clientId,
  6423. innerBlocks
  6424. } = block;
  6425. result[rootClientId].push(clientId);
  6426. Object.assign(result, mapBlockOrder(innerBlocks, clientId));
  6427. });
  6428. return result;
  6429. }
  6430. /**
  6431. * Given an array of blocks, returns an object where each key contains
  6432. * the clientId of the block and the value is the parent of the block.
  6433. *
  6434. * @param {Array} blocks Blocks to map.
  6435. * @param {?string} rootClientId Assumed root client ID.
  6436. *
  6437. * @return {Object} Block order map object.
  6438. */
  6439. function mapBlockParents(blocks, rootClientId = '') {
  6440. return blocks.reduce((result, block) => Object.assign(result, {
  6441. [block.clientId]: rootClientId
  6442. }, mapBlockParents(block.innerBlocks, block.clientId)), {});
  6443. }
  6444. /**
  6445. * Helper method to iterate through all blocks, recursing into inner blocks,
  6446. * applying a transformation function to each one.
  6447. * Returns a flattened object with the transformed blocks.
  6448. *
  6449. * @param {Array} blocks Blocks to flatten.
  6450. * @param {Function} transform Transforming function to be applied to each block.
  6451. *
  6452. * @return {Object} Flattened object.
  6453. */
  6454. function flattenBlocks(blocks, transform = external_lodash_["identity"]) {
  6455. const result = {};
  6456. const stack = [...blocks];
  6457. while (stack.length) {
  6458. const {
  6459. innerBlocks,
  6460. ...block
  6461. } = stack.shift();
  6462. stack.push(...innerBlocks);
  6463. result[block.clientId] = transform(block);
  6464. }
  6465. return result;
  6466. }
  6467. /**
  6468. * Given an array of blocks, returns an object containing all blocks, without
  6469. * attributes, recursing into inner blocks. Keys correspond to the block client
  6470. * ID, the value of which is the attributes object.
  6471. *
  6472. * @param {Array} blocks Blocks to flatten.
  6473. *
  6474. * @return {Object} Flattened block attributes object.
  6475. */
  6476. function getFlattenedBlocksWithoutAttributes(blocks) {
  6477. return flattenBlocks(blocks, block => Object(external_lodash_["omit"])(block, 'attributes'));
  6478. }
  6479. /**
  6480. * Given an array of blocks, returns an object containing all block attributes,
  6481. * recursing into inner blocks. Keys correspond to the block client ID, the
  6482. * value of which is the attributes object.
  6483. *
  6484. * @param {Array} blocks Blocks to flatten.
  6485. *
  6486. * @return {Object} Flattened block attributes object.
  6487. */
  6488. function getFlattenedBlockAttributes(blocks) {
  6489. return flattenBlocks(blocks, block => block.attributes);
  6490. }
  6491. /**
  6492. * Given a block order map object, returns *all* of the block client IDs that are
  6493. * a descendant of the given root client ID.
  6494. *
  6495. * Calling this with `rootClientId` set to `''` results in a list of client IDs
  6496. * that are in the post. That is, it excludes blocks like fetched reusable
  6497. * blocks which are stored into state but not visible. It also excludes
  6498. * InnerBlocks controllers, like template parts.
  6499. *
  6500. * It is important to exclude the full inner block controller and not just the
  6501. * inner blocks because in many cases, we need to persist the previous value of
  6502. * an inner block controller. To do so, it must be excluded from the list of
  6503. * client IDs which are considered to be part of the top-level entity.
  6504. *
  6505. * @param {Object} blocksOrder Object that maps block client IDs to a list of
  6506. * nested block client IDs.
  6507. * @param {?string} rootClientId The root client ID to search. Defaults to ''.
  6508. * @param {?Object} controlledInnerBlocks The InnerBlocks controller state.
  6509. *
  6510. * @return {Array} List of descendant client IDs.
  6511. */
  6512. function getNestedBlockClientIds(blocksOrder, rootClientId = '', controlledInnerBlocks = {}) {
  6513. return Object(external_lodash_["reduce"])(blocksOrder[rootClientId], (result, clientId) => {
  6514. if (!!controlledInnerBlocks[clientId]) {
  6515. return result;
  6516. }
  6517. return [...result, clientId, ...getNestedBlockClientIds(blocksOrder, clientId)];
  6518. }, []);
  6519. }
  6520. /**
  6521. * Returns an object against which it is safe to perform mutating operations,
  6522. * given the original object and its current working copy.
  6523. *
  6524. * @param {Object} original Original object.
  6525. * @param {Object} working Working object.
  6526. *
  6527. * @return {Object} Mutation-safe object.
  6528. */
  6529. function getMutateSafeObject(original, working) {
  6530. if (original === working) {
  6531. return { ...original
  6532. };
  6533. }
  6534. return working;
  6535. }
  6536. /**
  6537. * Returns true if the two object arguments have the same keys, or false
  6538. * otherwise.
  6539. *
  6540. * @param {Object} a First object.
  6541. * @param {Object} b Second object.
  6542. *
  6543. * @return {boolean} Whether the two objects have the same keys.
  6544. */
  6545. function hasSameKeys(a, b) {
  6546. return Object(external_lodash_["isEqual"])(Object(external_lodash_["keys"])(a), Object(external_lodash_["keys"])(b));
  6547. }
  6548. /**
  6549. * Returns true if, given the currently dispatching action and the previously
  6550. * dispatched action, the two actions are updating the same block attribute, or
  6551. * false otherwise.
  6552. *
  6553. * @param {Object} action Currently dispatching action.
  6554. * @param {Object} lastAction Previously dispatched action.
  6555. *
  6556. * @return {boolean} Whether actions are updating the same block attribute.
  6557. */
  6558. function isUpdatingSameBlockAttribute(action, lastAction) {
  6559. return action.type === 'UPDATE_BLOCK_ATTRIBUTES' && lastAction !== undefined && lastAction.type === 'UPDATE_BLOCK_ATTRIBUTES' && Object(external_lodash_["isEqual"])(action.clientIds, lastAction.clientIds) && hasSameKeys(action.attributes, lastAction.attributes);
  6560. }
  6561. /**
  6562. * Utility returning an object with an empty object value for each key.
  6563. *
  6564. * @param {Array} objectKeys Keys to fill.
  6565. * @return {Object} Object filled with empty object as values for each clientId.
  6566. */
  6567. const fillKeysWithEmptyObject = objectKeys => {
  6568. return objectKeys.reduce((result, key) => {
  6569. result[key] = {};
  6570. return result;
  6571. }, {});
  6572. };
  6573. /**
  6574. * Higher-order reducer intended to compute a cache key for each block in the post.
  6575. * A new instance of the cache key (empty object) is created each time the block object
  6576. * needs to be refreshed (for any change in the block or its children).
  6577. *
  6578. * @param {Function} reducer Original reducer function.
  6579. *
  6580. * @return {Function} Enhanced reducer function.
  6581. */
  6582. const withBlockCache = reducer => (state = {}, action) => {
  6583. const newState = reducer(state, action);
  6584. if (newState === state) {
  6585. return state;
  6586. }
  6587. newState.cache = state.cache ? state.cache : {};
  6588. /**
  6589. * For each clientId provided, traverses up parents, adding the provided clientIds
  6590. * and each parent's clientId to the returned array.
  6591. *
  6592. * When calling this function consider that it uses the old state, so any state
  6593. * modifications made by the `reducer` will not be present.
  6594. *
  6595. * @param {Array} clientIds an Array of block clientIds.
  6596. *
  6597. * @return {Array} The provided clientIds and all of their parent clientIds.
  6598. */
  6599. const getBlocksWithParentsClientIds = clientIds => {
  6600. return clientIds.reduce((result, clientId) => {
  6601. let current = clientId;
  6602. do {
  6603. result.push(current);
  6604. current = state.parents[current];
  6605. } while (current && !state.controlledInnerBlocks[current]);
  6606. return result;
  6607. }, []);
  6608. };
  6609. switch (action.type) {
  6610. case 'RESET_BLOCKS':
  6611. newState.cache = Object(external_lodash_["mapValues"])(flattenBlocks(action.blocks), () => ({}));
  6612. break;
  6613. case 'RECEIVE_BLOCKS':
  6614. case 'INSERT_BLOCKS':
  6615. {
  6616. const updatedBlockUids = Object(external_lodash_["keys"])(flattenBlocks(action.blocks));
  6617. if (action.rootClientId && !state.controlledInnerBlocks[action.rootClientId]) {
  6618. updatedBlockUids.push(action.rootClientId);
  6619. }
  6620. newState.cache = { ...newState.cache,
  6621. ...fillKeysWithEmptyObject(getBlocksWithParentsClientIds(updatedBlockUids))
  6622. };
  6623. break;
  6624. }
  6625. case 'UPDATE_BLOCK':
  6626. newState.cache = { ...newState.cache,
  6627. ...fillKeysWithEmptyObject(getBlocksWithParentsClientIds([action.clientId]))
  6628. };
  6629. break;
  6630. case 'UPDATE_BLOCK_ATTRIBUTES':
  6631. newState.cache = { ...newState.cache,
  6632. ...fillKeysWithEmptyObject(getBlocksWithParentsClientIds(action.clientIds))
  6633. };
  6634. break;
  6635. case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  6636. const parentClientIds = fillKeysWithEmptyObject(getBlocksWithParentsClientIds(action.replacedClientIds));
  6637. newState.cache = { ...Object(external_lodash_["omit"])(newState.cache, action.replacedClientIds),
  6638. ...Object(external_lodash_["omit"])(parentClientIds, action.replacedClientIds),
  6639. ...fillKeysWithEmptyObject(Object(external_lodash_["keys"])(flattenBlocks(action.blocks)))
  6640. };
  6641. break;
  6642. case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  6643. newState.cache = { ...Object(external_lodash_["omit"])(newState.cache, action.removedClientIds),
  6644. ...fillKeysWithEmptyObject(Object(external_lodash_["difference"])(getBlocksWithParentsClientIds(action.clientIds), action.clientIds))
  6645. };
  6646. break;
  6647. case 'MOVE_BLOCKS_TO_POSITION':
  6648. {
  6649. const updatedBlockUids = [...action.clientIds];
  6650. if (action.fromRootClientId) {
  6651. updatedBlockUids.push(action.fromRootClientId);
  6652. }
  6653. if (action.toRootClientId) {
  6654. updatedBlockUids.push(action.toRootClientId);
  6655. }
  6656. newState.cache = { ...newState.cache,
  6657. ...fillKeysWithEmptyObject(getBlocksWithParentsClientIds(updatedBlockUids))
  6658. };
  6659. break;
  6660. }
  6661. case 'MOVE_BLOCKS_UP':
  6662. case 'MOVE_BLOCKS_DOWN':
  6663. {
  6664. const updatedBlockUids = [];
  6665. if (action.rootClientId) {
  6666. updatedBlockUids.push(action.rootClientId);
  6667. }
  6668. newState.cache = { ...newState.cache,
  6669. ...fillKeysWithEmptyObject(getBlocksWithParentsClientIds(updatedBlockUids))
  6670. };
  6671. break;
  6672. }
  6673. case 'SAVE_REUSABLE_BLOCK_SUCCESS':
  6674. {
  6675. const updatedBlockUids = Object(external_lodash_["keys"])(Object(external_lodash_["omitBy"])(newState.attributes, (attributes, clientId) => {
  6676. return newState.byClientId[clientId].name !== 'core/block' || attributes.ref !== action.updatedId;
  6677. }));
  6678. newState.cache = { ...newState.cache,
  6679. ...fillKeysWithEmptyObject(getBlocksWithParentsClientIds(updatedBlockUids))
  6680. };
  6681. }
  6682. }
  6683. return newState;
  6684. };
  6685. /**
  6686. * Higher-order reducer intended to augment the blocks reducer, assigning an
  6687. * `isPersistentChange` property value corresponding to whether a change in
  6688. * state can be considered as persistent. All changes are considered persistent
  6689. * except when updating the same block attribute as in the previous action.
  6690. *
  6691. * @param {Function} reducer Original reducer function.
  6692. *
  6693. * @return {Function} Enhanced reducer function.
  6694. */
  6695. function withPersistentBlockChange(reducer) {
  6696. let lastAction;
  6697. let markNextChangeAsNotPersistent = false;
  6698. return (state, action) => {
  6699. let nextState = reducer(state, action);
  6700. const isExplicitPersistentChange = action.type === 'MARK_LAST_CHANGE_AS_PERSISTENT' || markNextChangeAsNotPersistent; // Defer to previous state value (or default) unless changing or
  6701. // explicitly marking as persistent.
  6702. if (state === nextState && !isExplicitPersistentChange) {
  6703. var _state$isPersistentCh;
  6704. markNextChangeAsNotPersistent = action.type === 'MARK_NEXT_CHANGE_AS_NOT_PERSISTENT';
  6705. const nextIsPersistentChange = (_state$isPersistentCh = state === null || state === void 0 ? void 0 : state.isPersistentChange) !== null && _state$isPersistentCh !== void 0 ? _state$isPersistentCh : true;
  6706. if (state.isPersistentChange === nextIsPersistentChange) {
  6707. return state;
  6708. }
  6709. return { ...nextState,
  6710. isPersistentChange: nextIsPersistentChange
  6711. };
  6712. }
  6713. nextState = { ...nextState,
  6714. isPersistentChange: isExplicitPersistentChange ? !markNextChangeAsNotPersistent : !isUpdatingSameBlockAttribute(action, lastAction)
  6715. }; // In comparing against the previous action, consider only those which
  6716. // would have qualified as one which would have been ignored or not
  6717. // have resulted in a changed state.
  6718. lastAction = action;
  6719. markNextChangeAsNotPersistent = action.type === 'MARK_NEXT_CHANGE_AS_NOT_PERSISTENT';
  6720. return nextState;
  6721. };
  6722. }
  6723. /**
  6724. * Higher-order reducer intended to augment the blocks reducer, assigning an
  6725. * `isIgnoredChange` property value corresponding to whether a change in state
  6726. * can be considered as ignored. A change is considered ignored when the result
  6727. * of an action not incurred by direct user interaction.
  6728. *
  6729. * @param {Function} reducer Original reducer function.
  6730. *
  6731. * @return {Function} Enhanced reducer function.
  6732. */
  6733. function withIgnoredBlockChange(reducer) {
  6734. /**
  6735. * Set of action types for which a blocks state change should be ignored.
  6736. *
  6737. * @type {Set}
  6738. */
  6739. const IGNORED_ACTION_TYPES = new Set(['RECEIVE_BLOCKS']);
  6740. return (state, action) => {
  6741. const nextState = reducer(state, action);
  6742. if (nextState !== state) {
  6743. nextState.isIgnoredChange = IGNORED_ACTION_TYPES.has(action.type);
  6744. }
  6745. return nextState;
  6746. };
  6747. }
  6748. /**
  6749. * Higher-order reducer targeting the combined blocks reducer, augmenting
  6750. * block client IDs in remove action to include cascade of inner blocks.
  6751. *
  6752. * @param {Function} reducer Original reducer function.
  6753. *
  6754. * @return {Function} Enhanced reducer function.
  6755. */
  6756. const withInnerBlocksRemoveCascade = reducer => (state, action) => {
  6757. // Gets all children which need to be removed.
  6758. const getAllChildren = clientIds => {
  6759. let result = clientIds;
  6760. for (let i = 0; i < result.length; i++) {
  6761. if (!state.order[result[i]] || action.keepControlledInnerBlocks && action.keepControlledInnerBlocks[result[i]]) {
  6762. continue;
  6763. }
  6764. if (result === clientIds) {
  6765. result = [...result];
  6766. }
  6767. result.push(...state.order[result[i]]);
  6768. }
  6769. return result;
  6770. };
  6771. if (state) {
  6772. switch (action.type) {
  6773. case 'REMOVE_BLOCKS':
  6774. action = { ...action,
  6775. type: 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN',
  6776. removedClientIds: getAllChildren(action.clientIds)
  6777. };
  6778. break;
  6779. case 'REPLACE_BLOCKS':
  6780. action = { ...action,
  6781. type: 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN',
  6782. replacedClientIds: getAllChildren(action.clientIds)
  6783. };
  6784. break;
  6785. }
  6786. }
  6787. return reducer(state, action);
  6788. };
  6789. /**
  6790. * Higher-order reducer which targets the combined blocks reducer and handles
  6791. * the `RESET_BLOCKS` action. When dispatched, this action will replace all
  6792. * blocks that exist in the post, leaving blocks that exist only in state (e.g.
  6793. * reusable blocks and blocks controlled by inner blocks controllers) alone.
  6794. *
  6795. * @param {Function} reducer Original reducer function.
  6796. *
  6797. * @return {Function} Enhanced reducer function.
  6798. */
  6799. const withBlockReset = reducer => (state, action) => {
  6800. if (state && action.type === 'RESET_BLOCKS') {
  6801. /**
  6802. * A list of client IDs associated with the top level entity (like a
  6803. * post or template). It excludes the client IDs of blocks associated
  6804. * with other entities, like inner block controllers or reusable blocks.
  6805. */
  6806. const visibleClientIds = getNestedBlockClientIds(state.order, '', state.controlledInnerBlocks); // pickBy returns only the truthy values from controlledInnerBlocks
  6807. const controlledInnerBlocks = Object.keys(Object(external_lodash_["pickBy"])(state.controlledInnerBlocks));
  6808. /**
  6809. * Each update operation consists of a few parts:
  6810. * 1. First, the client IDs associated with the top level entity are
  6811. * removed from the existing state key, leaving in place controlled
  6812. * blocks (like reusable blocks and inner block controllers).
  6813. * 2. Second, the blocks from the reset action are used to calculate the
  6814. * individual state keys. This will re-populate the clientIDs which
  6815. * were removed in step 1.
  6816. * 3. In some cases, we remove the recalculated inner block controllers,
  6817. * letting their old values persist. We need to do this because the
  6818. * reset block action from a top-level entity is not aware of any
  6819. * inner blocks inside InnerBlock controllers. So if the new values
  6820. * were used, it would not take into account the existing InnerBlocks
  6821. * which already exist in the state for inner block controllers. For
  6822. * example, `attributes` uses the newly computed value for controllers
  6823. * since attributes are stored in the top-level entity. But `order`
  6824. * uses the previous value for the controllers since the new value
  6825. * does not include the order of controlled inner blocks. So if the
  6826. * new value was used, template parts would disappear from the editor
  6827. * whenever you try to undo a change in the top level entity.
  6828. */
  6829. return { ...state,
  6830. byClientId: { ...Object(external_lodash_["omit"])(state.byClientId, visibleClientIds),
  6831. ...getFlattenedBlocksWithoutAttributes(action.blocks)
  6832. },
  6833. attributes: { ...Object(external_lodash_["omit"])(state.attributes, visibleClientIds),
  6834. ...getFlattenedBlockAttributes(action.blocks)
  6835. },
  6836. order: { ...Object(external_lodash_["omit"])(state.order, visibleClientIds),
  6837. ...Object(external_lodash_["omit"])(mapBlockOrder(action.blocks), controlledInnerBlocks)
  6838. },
  6839. parents: { ...Object(external_lodash_["omit"])(state.parents, visibleClientIds),
  6840. ...mapBlockParents(action.blocks)
  6841. },
  6842. cache: { ...Object(external_lodash_["omit"])(state.cache, visibleClientIds),
  6843. ...Object(external_lodash_["omit"])(Object(external_lodash_["mapValues"])(flattenBlocks(action.blocks), () => ({})), controlledInnerBlocks)
  6844. }
  6845. };
  6846. }
  6847. return reducer(state, action);
  6848. };
  6849. /**
  6850. * Higher-order reducer which targets the combined blocks reducer and handles
  6851. * the `REPLACE_INNER_BLOCKS` action. When dispatched, this action the state
  6852. * should become equivalent to the execution of a `REMOVE_BLOCKS` action
  6853. * containing all the child's of the root block followed by the execution of
  6854. * `INSERT_BLOCKS` with the new blocks.
  6855. *
  6856. * @param {Function} reducer Original reducer function.
  6857. *
  6858. * @return {Function} Enhanced reducer function.
  6859. */
  6860. const withReplaceInnerBlocks = reducer => (state, action) => {
  6861. if (action.type !== 'REPLACE_INNER_BLOCKS') {
  6862. return reducer(state, action);
  6863. } // Finds every nested inner block controller. We must check the action blocks
  6864. // and not just the block parent state because some inner block controllers
  6865. // should be deleted if specified, whereas others should not be deleted. If
  6866. // a controlled should not be deleted, then we need to avoid deleting its
  6867. // inner blocks from the block state because its inner blocks will not be
  6868. // attached to the block in the action.
  6869. const nestedControllers = {};
  6870. if (Object.keys(state.controlledInnerBlocks).length) {
  6871. const stack = [...action.blocks];
  6872. while (stack.length) {
  6873. const {
  6874. innerBlocks,
  6875. ...block
  6876. } = stack.shift();
  6877. stack.push(...innerBlocks);
  6878. if (!!state.controlledInnerBlocks[block.clientId]) {
  6879. nestedControllers[block.clientId] = true;
  6880. }
  6881. }
  6882. } // The `keepControlledInnerBlocks` prop will keep the inner blocks of the
  6883. // marked block in the block state so that they can be reattached to the
  6884. // marked block when we re-insert everything a few lines below.
  6885. let stateAfterBlocksRemoval = state;
  6886. if (state.order[action.rootClientId]) {
  6887. stateAfterBlocksRemoval = reducer(stateAfterBlocksRemoval, {
  6888. type: 'REMOVE_BLOCKS',
  6889. keepControlledInnerBlocks: nestedControllers,
  6890. clientIds: state.order[action.rootClientId]
  6891. });
  6892. }
  6893. let stateAfterInsert = stateAfterBlocksRemoval;
  6894. if (action.blocks.length) {
  6895. stateAfterInsert = reducer(stateAfterInsert, { ...action,
  6896. type: 'INSERT_BLOCKS',
  6897. index: 0
  6898. }); // We need to re-attach the block order of the controlled inner blocks.
  6899. // Otherwise, an inner block controller's blocks will be deleted entirely
  6900. // from its entity..
  6901. stateAfterInsert.order = { ...stateAfterInsert.order,
  6902. ...Object(external_lodash_["reduce"])(nestedControllers, (result, value, key) => {
  6903. if (state.order[key]) {
  6904. result[key] = state.order[key];
  6905. }
  6906. return result;
  6907. }, {})
  6908. };
  6909. }
  6910. return stateAfterInsert;
  6911. };
  6912. /**
  6913. * Higher-order reducer which targets the combined blocks reducer and handles
  6914. * the `SAVE_REUSABLE_BLOCK_SUCCESS` action. This action can't be handled by
  6915. * regular reducers and needs a higher-order reducer since it needs access to
  6916. * both `byClientId` and `attributes` simultaneously.
  6917. *
  6918. * @param {Function} reducer Original reducer function.
  6919. *
  6920. * @return {Function} Enhanced reducer function.
  6921. */
  6922. const withSaveReusableBlock = reducer => (state, action) => {
  6923. if (state && action.type === 'SAVE_REUSABLE_BLOCK_SUCCESS') {
  6924. const {
  6925. id,
  6926. updatedId
  6927. } = action; // If a temporary reusable block is saved, we swap the temporary id with the final one
  6928. if (id === updatedId) {
  6929. return state;
  6930. }
  6931. state = { ...state
  6932. };
  6933. state.attributes = Object(external_lodash_["mapValues"])(state.attributes, (attributes, clientId) => {
  6934. const {
  6935. name
  6936. } = state.byClientId[clientId];
  6937. if (name === 'core/block' && attributes.ref === id) {
  6938. return { ...attributes,
  6939. ref: updatedId
  6940. };
  6941. }
  6942. return attributes;
  6943. });
  6944. }
  6945. return reducer(state, action);
  6946. };
  6947. /**
  6948. * Reducer returning the blocks state.
  6949. *
  6950. * @param {Object} state Current state.
  6951. * @param {Object} action Dispatched action.
  6952. *
  6953. * @return {Object} Updated state.
  6954. */
  6955. const reducer_blocks = Object(external_lodash_["flow"])(external_wp_data_["combineReducers"], withSaveReusableBlock, // needs to be before withBlockCache
  6956. withBlockCache, // needs to be before withInnerBlocksRemoveCascade
  6957. withInnerBlocksRemoveCascade, withReplaceInnerBlocks, // needs to be after withInnerBlocksRemoveCascade
  6958. withBlockReset, withPersistentBlockChange, withIgnoredBlockChange)({
  6959. byClientId(state = {}, action) {
  6960. switch (action.type) {
  6961. case 'RESET_BLOCKS':
  6962. return getFlattenedBlocksWithoutAttributes(action.blocks);
  6963. case 'RECEIVE_BLOCKS':
  6964. case 'INSERT_BLOCKS':
  6965. return { ...state,
  6966. ...getFlattenedBlocksWithoutAttributes(action.blocks)
  6967. };
  6968. case 'UPDATE_BLOCK':
  6969. // Ignore updates if block isn't known
  6970. if (!state[action.clientId]) {
  6971. return state;
  6972. } // Do nothing if only attributes change.
  6973. const changes = Object(external_lodash_["omit"])(action.updates, 'attributes');
  6974. if (Object(external_lodash_["isEmpty"])(changes)) {
  6975. return state;
  6976. }
  6977. return { ...state,
  6978. [action.clientId]: { ...state[action.clientId],
  6979. ...changes
  6980. }
  6981. };
  6982. case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  6983. if (!action.blocks) {
  6984. return state;
  6985. }
  6986. return { ...Object(external_lodash_["omit"])(state, action.replacedClientIds),
  6987. ...getFlattenedBlocksWithoutAttributes(action.blocks)
  6988. };
  6989. case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  6990. return Object(external_lodash_["omit"])(state, action.removedClientIds);
  6991. }
  6992. return state;
  6993. },
  6994. attributes(state = {}, action) {
  6995. switch (action.type) {
  6996. case 'RESET_BLOCKS':
  6997. return getFlattenedBlockAttributes(action.blocks);
  6998. case 'RECEIVE_BLOCKS':
  6999. case 'INSERT_BLOCKS':
  7000. return { ...state,
  7001. ...getFlattenedBlockAttributes(action.blocks)
  7002. };
  7003. case 'UPDATE_BLOCK':
  7004. // Ignore updates if block isn't known or there are no attribute changes.
  7005. if (!state[action.clientId] || !action.updates.attributes) {
  7006. return state;
  7007. }
  7008. return { ...state,
  7009. [action.clientId]: { ...state[action.clientId],
  7010. ...action.updates.attributes
  7011. }
  7012. };
  7013. case 'UPDATE_BLOCK_ATTRIBUTES':
  7014. {
  7015. // Avoid a state change if none of the block IDs are known.
  7016. if (action.clientIds.every(id => !state[id])) {
  7017. return state;
  7018. }
  7019. const next = action.clientIds.reduce((accumulator, id) => ({ ...accumulator,
  7020. [id]: Object(external_lodash_["reduce"])(action.uniqueByBlock ? action.attributes[id] : action.attributes, (result, value, key) => {
  7021. // Consider as updates only changed values.
  7022. if (value !== result[key]) {
  7023. result = getMutateSafeObject(state[id], result);
  7024. result[key] = value;
  7025. }
  7026. return result;
  7027. }, state[id])
  7028. }), {});
  7029. if (action.clientIds.every(id => next[id] === state[id])) {
  7030. return state;
  7031. }
  7032. return { ...state,
  7033. ...next
  7034. };
  7035. }
  7036. case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  7037. if (!action.blocks) {
  7038. return state;
  7039. }
  7040. return { ...Object(external_lodash_["omit"])(state, action.replacedClientIds),
  7041. ...getFlattenedBlockAttributes(action.blocks)
  7042. };
  7043. case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  7044. return Object(external_lodash_["omit"])(state, action.removedClientIds);
  7045. }
  7046. return state;
  7047. },
  7048. order(state = {}, action) {
  7049. switch (action.type) {
  7050. case 'RESET_BLOCKS':
  7051. return mapBlockOrder(action.blocks);
  7052. case 'RECEIVE_BLOCKS':
  7053. return { ...state,
  7054. ...Object(external_lodash_["omit"])(mapBlockOrder(action.blocks), '')
  7055. };
  7056. case 'INSERT_BLOCKS':
  7057. {
  7058. const {
  7059. rootClientId = ''
  7060. } = action;
  7061. const subState = state[rootClientId] || [];
  7062. const mappedBlocks = mapBlockOrder(action.blocks, rootClientId);
  7063. const {
  7064. index = subState.length
  7065. } = action;
  7066. return { ...state,
  7067. ...mappedBlocks,
  7068. [rootClientId]: insertAt(subState, mappedBlocks[rootClientId], index)
  7069. };
  7070. }
  7071. case 'MOVE_BLOCKS_TO_POSITION':
  7072. {
  7073. const {
  7074. fromRootClientId = '',
  7075. toRootClientId = '',
  7076. clientIds
  7077. } = action;
  7078. const {
  7079. index = state[toRootClientId].length
  7080. } = action; // Moving inside the same parent block
  7081. if (fromRootClientId === toRootClientId) {
  7082. const subState = state[toRootClientId];
  7083. const fromIndex = subState.indexOf(clientIds[0]);
  7084. return { ...state,
  7085. [toRootClientId]: moveTo(state[toRootClientId], fromIndex, index, clientIds.length)
  7086. };
  7087. } // Moving from a parent block to another
  7088. return { ...state,
  7089. [fromRootClientId]: Object(external_lodash_["without"])(state[fromRootClientId], ...clientIds),
  7090. [toRootClientId]: insertAt(state[toRootClientId], clientIds, index)
  7091. };
  7092. }
  7093. case 'MOVE_BLOCKS_UP':
  7094. {
  7095. const {
  7096. clientIds,
  7097. rootClientId = ''
  7098. } = action;
  7099. const firstClientId = Object(external_lodash_["first"])(clientIds);
  7100. const subState = state[rootClientId];
  7101. if (!subState.length || firstClientId === Object(external_lodash_["first"])(subState)) {
  7102. return state;
  7103. }
  7104. const firstIndex = subState.indexOf(firstClientId);
  7105. return { ...state,
  7106. [rootClientId]: moveTo(subState, firstIndex, firstIndex - 1, clientIds.length)
  7107. };
  7108. }
  7109. case 'MOVE_BLOCKS_DOWN':
  7110. {
  7111. const {
  7112. clientIds,
  7113. rootClientId = ''
  7114. } = action;
  7115. const firstClientId = Object(external_lodash_["first"])(clientIds);
  7116. const lastClientId = Object(external_lodash_["last"])(clientIds);
  7117. const subState = state[rootClientId];
  7118. if (!subState.length || lastClientId === Object(external_lodash_["last"])(subState)) {
  7119. return state;
  7120. }
  7121. const firstIndex = subState.indexOf(firstClientId);
  7122. return { ...state,
  7123. [rootClientId]: moveTo(subState, firstIndex, firstIndex + 1, clientIds.length)
  7124. };
  7125. }
  7126. case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  7127. {
  7128. const {
  7129. clientIds
  7130. } = action;
  7131. if (!action.blocks) {
  7132. return state;
  7133. }
  7134. const mappedBlocks = mapBlockOrder(action.blocks);
  7135. return Object(external_lodash_["flow"])([nextState => Object(external_lodash_["omit"])(nextState, action.replacedClientIds), nextState => ({ ...nextState,
  7136. ...Object(external_lodash_["omit"])(mappedBlocks, '')
  7137. }), nextState => Object(external_lodash_["mapValues"])(nextState, subState => Object(external_lodash_["reduce"])(subState, (result, clientId) => {
  7138. if (clientId === clientIds[0]) {
  7139. return [...result, ...mappedBlocks['']];
  7140. }
  7141. if (clientIds.indexOf(clientId) === -1) {
  7142. result.push(clientId);
  7143. }
  7144. return result;
  7145. }, []))])(state);
  7146. }
  7147. case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  7148. return Object(external_lodash_["flow"])([// Remove inner block ordering for removed blocks
  7149. nextState => Object(external_lodash_["omit"])(nextState, action.removedClientIds), // Remove deleted blocks from other blocks' orderings
  7150. nextState => Object(external_lodash_["mapValues"])(nextState, subState => Object(external_lodash_["without"])(subState, ...action.removedClientIds))])(state);
  7151. }
  7152. return state;
  7153. },
  7154. // While technically redundant data as the inverse of `order`, it serves as
  7155. // an optimization for the selectors which derive the ancestry of a block.
  7156. parents(state = {}, action) {
  7157. switch (action.type) {
  7158. case 'RESET_BLOCKS':
  7159. return mapBlockParents(action.blocks);
  7160. case 'RECEIVE_BLOCKS':
  7161. return { ...state,
  7162. ...mapBlockParents(action.blocks)
  7163. };
  7164. case 'INSERT_BLOCKS':
  7165. return { ...state,
  7166. ...mapBlockParents(action.blocks, action.rootClientId || '')
  7167. };
  7168. case 'MOVE_BLOCKS_TO_POSITION':
  7169. {
  7170. return { ...state,
  7171. ...action.clientIds.reduce((accumulator, id) => {
  7172. accumulator[id] = action.toRootClientId || '';
  7173. return accumulator;
  7174. }, {})
  7175. };
  7176. }
  7177. case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  7178. return { ...Object(external_lodash_["omit"])(state, action.replacedClientIds),
  7179. ...mapBlockParents(action.blocks, state[action.clientIds[0]])
  7180. };
  7181. case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
  7182. return Object(external_lodash_["omit"])(state, action.removedClientIds);
  7183. }
  7184. return state;
  7185. },
  7186. controlledInnerBlocks(state = {}, {
  7187. type,
  7188. clientId,
  7189. hasControlledInnerBlocks
  7190. }) {
  7191. if (type === 'SET_HAS_CONTROLLED_INNER_BLOCKS') {
  7192. return { ...state,
  7193. [clientId]: hasControlledInnerBlocks
  7194. };
  7195. }
  7196. return state;
  7197. }
  7198. });
  7199. /**
  7200. * Reducer returning typing state.
  7201. *
  7202. * @param {boolean} state Current state.
  7203. * @param {Object} action Dispatched action.
  7204. *
  7205. * @return {boolean} Updated state.
  7206. */
  7207. function reducer_isTyping(state = false, action) {
  7208. switch (action.type) {
  7209. case 'START_TYPING':
  7210. return true;
  7211. case 'STOP_TYPING':
  7212. return false;
  7213. }
  7214. return state;
  7215. }
  7216. /**
  7217. * Reducer returning dragged block client id.
  7218. *
  7219. * @param {string[]} state Current state.
  7220. * @param {Object} action Dispatched action.
  7221. *
  7222. * @return {string[]} Updated state.
  7223. */
  7224. function draggedBlocks(state = [], action) {
  7225. switch (action.type) {
  7226. case 'START_DRAGGING_BLOCKS':
  7227. return action.clientIds;
  7228. case 'STOP_DRAGGING_BLOCKS':
  7229. return [];
  7230. }
  7231. return state;
  7232. }
  7233. /**
  7234. * Reducer returning whether the caret is within formatted text.
  7235. *
  7236. * @param {boolean} state Current state.
  7237. * @param {Object} action Dispatched action.
  7238. *
  7239. * @return {boolean} Updated state.
  7240. */
  7241. function reducer_isCaretWithinFormattedText(state = false, action) {
  7242. switch (action.type) {
  7243. case 'ENTER_FORMATTED_TEXT':
  7244. return true;
  7245. case 'EXIT_FORMATTED_TEXT':
  7246. return false;
  7247. }
  7248. return state;
  7249. }
  7250. /**
  7251. * Internal helper reducer for selectionStart and selectionEnd. Can hold a block
  7252. * selection, represented by an object with property clientId.
  7253. *
  7254. * @param {Object} state Current state.
  7255. * @param {Object} action Dispatched action.
  7256. *
  7257. * @return {Object} Updated state.
  7258. */
  7259. function selectionHelper(state = {}, action) {
  7260. switch (action.type) {
  7261. case 'CLEAR_SELECTED_BLOCK':
  7262. {
  7263. if (state.clientId) {
  7264. return {};
  7265. }
  7266. return state;
  7267. }
  7268. case 'SELECT_BLOCK':
  7269. if (action.clientId === state.clientId) {
  7270. return state;
  7271. }
  7272. return {
  7273. clientId: action.clientId
  7274. };
  7275. case 'REPLACE_INNER_BLOCKS':
  7276. case 'INSERT_BLOCKS':
  7277. {
  7278. if (!action.updateSelection || !action.blocks.length) {
  7279. return state;
  7280. }
  7281. return {
  7282. clientId: action.blocks[0].clientId
  7283. };
  7284. }
  7285. case 'REMOVE_BLOCKS':
  7286. if (!action.clientIds || !action.clientIds.length || action.clientIds.indexOf(state.clientId) === -1) {
  7287. return state;
  7288. }
  7289. return {};
  7290. case 'REPLACE_BLOCKS':
  7291. {
  7292. if (action.clientIds.indexOf(state.clientId) === -1) {
  7293. return state;
  7294. }
  7295. const indexToSelect = action.indexToSelect || action.blocks.length - 1;
  7296. const blockToSelect = action.blocks[indexToSelect];
  7297. if (!blockToSelect) {
  7298. return {};
  7299. }
  7300. if (blockToSelect.clientId === state.clientId) {
  7301. return state;
  7302. }
  7303. return {
  7304. clientId: blockToSelect.clientId
  7305. };
  7306. }
  7307. }
  7308. return state;
  7309. }
  7310. /**
  7311. * Reducer returning the selection state.
  7312. *
  7313. * @param {boolean} state Current state.
  7314. * @param {Object} action Dispatched action.
  7315. *
  7316. * @return {boolean} Updated state.
  7317. */
  7318. function reducer_selection(state = {}, action) {
  7319. var _state$selectionStart, _state$selectionEnd;
  7320. switch (action.type) {
  7321. case 'SELECTION_CHANGE':
  7322. return {
  7323. selectionStart: {
  7324. clientId: action.clientId,
  7325. attributeKey: action.attributeKey,
  7326. offset: action.startOffset
  7327. },
  7328. selectionEnd: {
  7329. clientId: action.clientId,
  7330. attributeKey: action.attributeKey,
  7331. offset: action.endOffset
  7332. }
  7333. };
  7334. case 'RESET_SELECTION':
  7335. const {
  7336. selectionStart,
  7337. selectionEnd
  7338. } = action;
  7339. return {
  7340. selectionStart,
  7341. selectionEnd
  7342. };
  7343. case 'MULTI_SELECT':
  7344. const {
  7345. start,
  7346. end
  7347. } = action;
  7348. return {
  7349. selectionStart: {
  7350. clientId: start
  7351. },
  7352. selectionEnd: {
  7353. clientId: end
  7354. }
  7355. };
  7356. case 'RESET_BLOCKS':
  7357. const startClientId = state === null || state === void 0 ? void 0 : (_state$selectionStart = state.selectionStart) === null || _state$selectionStart === void 0 ? void 0 : _state$selectionStart.clientId;
  7358. const endClientId = state === null || state === void 0 ? void 0 : (_state$selectionEnd = state.selectionEnd) === null || _state$selectionEnd === void 0 ? void 0 : _state$selectionEnd.clientId; // Do nothing if there's no selected block.
  7359. if (!startClientId && !endClientId) {
  7360. return state;
  7361. } // If the start of the selection won't exist after reset, remove selection.
  7362. if (!action.blocks.some(block => block.clientId === startClientId)) {
  7363. return {
  7364. selectionStart: {},
  7365. selectionEnd: {}
  7366. };
  7367. } // If the end of the selection won't exist after reset, collapse selection.
  7368. if (!action.blocks.some(block => block.clientId === endClientId)) {
  7369. return { ...state,
  7370. selectionEnd: state.selectionStart
  7371. };
  7372. }
  7373. }
  7374. return {
  7375. selectionStart: selectionHelper(state.selectionStart, action),
  7376. selectionEnd: selectionHelper(state.selectionEnd, action)
  7377. };
  7378. }
  7379. /**
  7380. * Reducer returning whether the user is multi-selecting.
  7381. *
  7382. * @param {boolean} state Current state.
  7383. * @param {Object} action Dispatched action.
  7384. *
  7385. * @return {boolean} Updated state.
  7386. */
  7387. function reducer_isMultiSelecting(state = false, action) {
  7388. switch (action.type) {
  7389. case 'START_MULTI_SELECT':
  7390. return true;
  7391. case 'STOP_MULTI_SELECT':
  7392. return false;
  7393. }
  7394. return state;
  7395. }
  7396. /**
  7397. * Reducer returning whether selection is enabled.
  7398. *
  7399. * @param {boolean} state Current state.
  7400. * @param {Object} action Dispatched action.
  7401. *
  7402. * @return {boolean} Updated state.
  7403. */
  7404. function reducer_isSelectionEnabled(state = true, action) {
  7405. switch (action.type) {
  7406. case 'TOGGLE_SELECTION':
  7407. return action.isSelectionEnabled;
  7408. }
  7409. return state;
  7410. }
  7411. /**
  7412. * Reducer returning the intial block selection.
  7413. *
  7414. * Currently this in only used to restore the selection after block deletion and
  7415. * pasting new content.This reducer should eventually be removed in favour of setting
  7416. * selection directly.
  7417. *
  7418. * @param {boolean} state Current state.
  7419. * @param {Object} action Dispatched action.
  7420. *
  7421. * @return {number|null} Initial position: 0, -1 or null.
  7422. */
  7423. function reducer_initialPosition(state = null, action) {
  7424. if (action.type === 'REPLACE_BLOCKS' && action.initialPosition !== undefined) {
  7425. return action.initialPosition;
  7426. } else if (['SELECT_BLOCK', 'RESET_SELECTION', 'INSERT_BLOCKS', 'REPLACE_INNER_BLOCKS'].includes(action.type)) {
  7427. return action.initialPosition;
  7428. }
  7429. return state;
  7430. }
  7431. function blocksMode(state = {}, action) {
  7432. if (action.type === 'TOGGLE_BLOCK_MODE') {
  7433. const {
  7434. clientId
  7435. } = action;
  7436. return { ...state,
  7437. [clientId]: state[clientId] && state[clientId] === 'html' ? 'visual' : 'html'
  7438. };
  7439. }
  7440. return state;
  7441. }
  7442. /**
  7443. * Reducer returning the block insertion point visibility, either null if there
  7444. * is not an explicit insertion point assigned, or an object of its `index` and
  7445. * `rootClientId`.
  7446. *
  7447. * @param {Object} state Current state.
  7448. * @param {Object} action Dispatched action.
  7449. *
  7450. * @return {Object} Updated state.
  7451. */
  7452. function reducer_insertionPoint(state = null, action) {
  7453. switch (action.type) {
  7454. case 'SHOW_INSERTION_POINT':
  7455. const {
  7456. rootClientId,
  7457. index,
  7458. __unstableWithInserter
  7459. } = action;
  7460. return {
  7461. rootClientId,
  7462. index,
  7463. __unstableWithInserter
  7464. };
  7465. case 'HIDE_INSERTION_POINT':
  7466. return null;
  7467. }
  7468. return state;
  7469. }
  7470. /**
  7471. * Reducer returning whether the post blocks match the defined template or not.
  7472. *
  7473. * @param {Object} state Current state.
  7474. * @param {Object} action Dispatched action.
  7475. *
  7476. * @return {boolean} Updated state.
  7477. */
  7478. function reducer_template(state = {
  7479. isValid: true
  7480. }, action) {
  7481. switch (action.type) {
  7482. case 'SET_TEMPLATE_VALIDITY':
  7483. return { ...state,
  7484. isValid: action.isValid
  7485. };
  7486. }
  7487. return state;
  7488. }
  7489. /**
  7490. * Reducer returning the editor setting.
  7491. *
  7492. * @param {Object} state Current state.
  7493. * @param {Object} action Dispatched action.
  7494. *
  7495. * @return {Object} Updated state.
  7496. */
  7497. function reducer_settings(state = SETTINGS_DEFAULTS, action) {
  7498. switch (action.type) {
  7499. case 'UPDATE_SETTINGS':
  7500. return { ...state,
  7501. ...action.settings
  7502. };
  7503. }
  7504. return state;
  7505. }
  7506. /**
  7507. * Reducer returning the user preferences.
  7508. *
  7509. * @param {Object} state Current state.
  7510. * @param {Object} action Dispatched action.
  7511. *
  7512. * @return {string} Updated state.
  7513. */
  7514. function preferences(state = PREFERENCES_DEFAULTS, action) {
  7515. switch (action.type) {
  7516. case 'INSERT_BLOCKS':
  7517. case 'REPLACE_BLOCKS':
  7518. return action.blocks.reduce((prevState, block) => {
  7519. const {
  7520. attributes,
  7521. name: blockName
  7522. } = block;
  7523. const match = Object(external_wp_data_["select"])(external_wp_blocks_["store"]).getActiveBlockVariation(blockName, attributes); // If a block variation match is found change the name to be the same with the
  7524. // one that is used for block variations in the Inserter (`getItemFromVariation`).
  7525. let id = match !== null && match !== void 0 && match.name ? `${blockName}/${match.name}` : blockName;
  7526. const insert = {
  7527. name: id
  7528. };
  7529. if (blockName === 'core/block') {
  7530. insert.ref = attributes.ref;
  7531. id += '/' + attributes.ref;
  7532. }
  7533. return { ...prevState,
  7534. insertUsage: { ...prevState.insertUsage,
  7535. [id]: {
  7536. time: action.time,
  7537. count: prevState.insertUsage[id] ? prevState.insertUsage[id].count + 1 : 1,
  7538. insert
  7539. }
  7540. }
  7541. };
  7542. }, state);
  7543. }
  7544. return state;
  7545. }
  7546. /**
  7547. * Reducer returning an object where each key is a block client ID, its value
  7548. * representing the settings for its nested blocks.
  7549. *
  7550. * @param {Object} state Current state.
  7551. * @param {Object} action Dispatched action.
  7552. *
  7553. * @return {Object} Updated state.
  7554. */
  7555. const reducer_blockListSettings = (state = {}, action) => {
  7556. switch (action.type) {
  7557. // Even if the replaced blocks have the same client ID, our logic
  7558. // should correct the state.
  7559. case 'REPLACE_BLOCKS':
  7560. case 'REMOVE_BLOCKS':
  7561. {
  7562. return Object(external_lodash_["omit"])(state, action.clientIds);
  7563. }
  7564. case 'UPDATE_BLOCK_LIST_SETTINGS':
  7565. {
  7566. const {
  7567. clientId
  7568. } = action;
  7569. if (!action.settings) {
  7570. if (state.hasOwnProperty(clientId)) {
  7571. return Object(external_lodash_["omit"])(state, clientId);
  7572. }
  7573. return state;
  7574. }
  7575. if (Object(external_lodash_["isEqual"])(state[clientId], action.settings)) {
  7576. return state;
  7577. }
  7578. return { ...state,
  7579. [clientId]: action.settings
  7580. };
  7581. }
  7582. }
  7583. return state;
  7584. };
  7585. /**
  7586. * Reducer returning whether the navigation mode is enabled or not.
  7587. *
  7588. * @param {string} state Current state.
  7589. * @param {Object} action Dispatched action.
  7590. *
  7591. * @return {string} Updated state.
  7592. */
  7593. function reducer_isNavigationMode(state = false, action) {
  7594. // Let inserting block always trigger Edit mode.
  7595. if (action.type === 'INSERT_BLOCKS') {
  7596. return false;
  7597. }
  7598. if (action.type === 'SET_NAVIGATION_MODE') {
  7599. return action.isNavigationMode;
  7600. }
  7601. return state;
  7602. }
  7603. /**
  7604. * Reducer returning whether the block moving mode is enabled or not.
  7605. *
  7606. * @param {string|null} state Current state.
  7607. * @param {Object} action Dispatched action.
  7608. *
  7609. * @return {string|null} Updated state.
  7610. */
  7611. function reducer_hasBlockMovingClientId(state = null, action) {
  7612. // Let inserting block always trigger Edit mode.
  7613. if (action.type === 'SET_BLOCK_MOVING_MODE') {
  7614. return action.hasBlockMovingClientId;
  7615. }
  7616. if (action.type === 'SET_NAVIGATION_MODE') {
  7617. return null;
  7618. }
  7619. return state;
  7620. }
  7621. /**
  7622. * Reducer return an updated state representing the most recent block attribute
  7623. * update. The state is structured as an object where the keys represent the
  7624. * client IDs of blocks, the values a subset of attributes from the most recent
  7625. * block update. The state is always reset to null if the last action is
  7626. * anything other than an attributes update.
  7627. *
  7628. * @param {Object<string,Object>} state Current state.
  7629. * @param {Object} action Action object.
  7630. *
  7631. * @return {[string,Object]} Updated state.
  7632. */
  7633. function lastBlockAttributesChange(state, action) {
  7634. switch (action.type) {
  7635. case 'UPDATE_BLOCK':
  7636. if (!action.updates.attributes) {
  7637. break;
  7638. }
  7639. return {
  7640. [action.clientId]: action.updates.attributes
  7641. };
  7642. case 'UPDATE_BLOCK_ATTRIBUTES':
  7643. return action.clientIds.reduce((accumulator, id) => ({ ...accumulator,
  7644. [id]: action.uniqueByBlock ? action.attributes[id] : action.attributes
  7645. }), {});
  7646. }
  7647. return null;
  7648. }
  7649. /**
  7650. * Reducer returning automatic change state.
  7651. *
  7652. * @param {boolean} state Current state.
  7653. * @param {Object} action Dispatched action.
  7654. *
  7655. * @return {string} Updated state.
  7656. */
  7657. function automaticChangeStatus(state, action) {
  7658. switch (action.type) {
  7659. case 'MARK_AUTOMATIC_CHANGE':
  7660. return 'pending';
  7661. case 'MARK_AUTOMATIC_CHANGE_FINAL':
  7662. if (state === 'pending') {
  7663. return 'final';
  7664. }
  7665. return;
  7666. case 'SELECTION_CHANGE':
  7667. // As long as the state is not final, ignore any selection changes.
  7668. if (state !== 'final') {
  7669. return state;
  7670. }
  7671. return;
  7672. // Undoing an automatic change should still be possible after mouse
  7673. // move.
  7674. case 'START_TYPING':
  7675. case 'STOP_TYPING':
  7676. return state;
  7677. } // Reset the state by default (for any action not handled).
  7678. }
  7679. /**
  7680. * Reducer returning current highlighted block.
  7681. *
  7682. * @param {boolean} state Current highlighted block.
  7683. * @param {Object} action Dispatched action.
  7684. *
  7685. * @return {string} Updated state.
  7686. */
  7687. function highlightedBlock(state, action) {
  7688. switch (action.type) {
  7689. case 'TOGGLE_BLOCK_HIGHLIGHT':
  7690. const {
  7691. clientId,
  7692. isHighlighted
  7693. } = action;
  7694. if (isHighlighted) {
  7695. return clientId;
  7696. } else if (state === clientId) {
  7697. return null;
  7698. }
  7699. return state;
  7700. case 'SELECT_BLOCK':
  7701. if (action.clientId !== state) {
  7702. return null;
  7703. }
  7704. }
  7705. return state;
  7706. }
  7707. /**
  7708. * Reducer returning the block insertion event list state.
  7709. *
  7710. * @param {Object} state Current state.
  7711. * @param {Object} action Dispatched action.
  7712. *
  7713. * @return {Object} Updated state.
  7714. */
  7715. function lastBlockInserted(state = {}, action) {
  7716. var _action$meta;
  7717. switch (action.type) {
  7718. case 'INSERT_BLOCKS':
  7719. if (!action.blocks.length) {
  7720. return state;
  7721. }
  7722. const clientId = action.blocks[0].clientId;
  7723. const source = (_action$meta = action.meta) === null || _action$meta === void 0 ? void 0 : _action$meta.source;
  7724. return {
  7725. clientId,
  7726. source
  7727. };
  7728. case 'RESET_BLOCKS':
  7729. return {};
  7730. }
  7731. return state;
  7732. }
  7733. /* harmony default export */ var store_reducer = (Object(external_wp_data_["combineReducers"])({
  7734. blocks: reducer_blocks,
  7735. isTyping: reducer_isTyping,
  7736. draggedBlocks,
  7737. isCaretWithinFormattedText: reducer_isCaretWithinFormattedText,
  7738. selection: reducer_selection,
  7739. isMultiSelecting: reducer_isMultiSelecting,
  7740. isSelectionEnabled: reducer_isSelectionEnabled,
  7741. initialPosition: reducer_initialPosition,
  7742. blocksMode,
  7743. blockListSettings: reducer_blockListSettings,
  7744. insertionPoint: reducer_insertionPoint,
  7745. template: reducer_template,
  7746. settings: reducer_settings,
  7747. preferences,
  7748. lastBlockAttributesChange,
  7749. isNavigationMode: reducer_isNavigationMode,
  7750. hasBlockMovingClientId: reducer_hasBlockMovingClientId,
  7751. automaticChangeStatus,
  7752. highlightedBlock,
  7753. lastBlockInserted
  7754. }));
  7755. // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js
  7756. var rememo = __webpack_require__("pPDe");
  7757. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/selectors.js
  7758. /**
  7759. * External dependencies
  7760. */
  7761. /**
  7762. * WordPress dependencies
  7763. */
  7764. /**
  7765. * A block selection object.
  7766. *
  7767. * @typedef {Object} WPBlockSelection
  7768. *
  7769. * @property {string} clientId A block client ID.
  7770. * @property {string} attributeKey A block attribute key.
  7771. * @property {number} offset An attribute value offset, based on the rich
  7772. * text value. See `wp.richText.create`.
  7773. */
  7774. // Module constants
  7775. const MILLISECONDS_PER_HOUR = 3600 * 1000;
  7776. const MILLISECONDS_PER_DAY = 24 * 3600 * 1000;
  7777. const MILLISECONDS_PER_WEEK = 7 * 24 * 3600 * 1000;
  7778. const templateIcon = Object(external_wp_element_["createElement"])(external_wp_components_["SVG"], {
  7779. xmlns: "http://www.w3.org/2000/svg",
  7780. viewBox: "0 0 24 24"
  7781. }, Object(external_wp_element_["createElement"])(external_wp_components_["Rect"], {
  7782. x: "0",
  7783. fill: "none",
  7784. width: "24",
  7785. height: "24"
  7786. }), Object(external_wp_element_["createElement"])(external_wp_components_["G"], null, Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
  7787. d: "M19 3H5c-1.105 0-2 .895-2 2v14c0 1.105.895 2 2 2h14c1.105 0 2-.895 2-2V5c0-1.105-.895-2-2-2zM6 6h5v5H6V6zm4.5 13C9.12 19 8 17.88 8 16.5S9.12 14 10.5 14s2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5zm3-6l3-5 3 5h-6z"
  7788. })));
  7789. /**
  7790. * Shared reference to an empty array for cases where it is important to avoid
  7791. * returning a new array reference on every invocation, as in a connected or
  7792. * other pure component which performs `shouldComponentUpdate` check on props.
  7793. * This should be used as a last resort, since the normalized data should be
  7794. * maintained by the reducer result in state.
  7795. *
  7796. * @type {Array}
  7797. */
  7798. const EMPTY_ARRAY = [];
  7799. /**
  7800. * Returns a block's name given its client ID, or null if no block exists with
  7801. * the client ID.
  7802. *
  7803. * @param {Object} state Editor state.
  7804. * @param {string} clientId Block client ID.
  7805. *
  7806. * @return {string} Block name.
  7807. */
  7808. function selectors_getBlockName(state, clientId) {
  7809. const block = state.blocks.byClientId[clientId];
  7810. const socialLinkName = 'core/social-link';
  7811. if (external_wp_element_["Platform"].OS !== 'web' && (block === null || block === void 0 ? void 0 : block.name) === socialLinkName) {
  7812. const attributes = state.blocks.attributes[clientId];
  7813. const {
  7814. service
  7815. } = attributes;
  7816. return service ? `${socialLinkName}-${service}` : socialLinkName;
  7817. }
  7818. return block ? block.name : null;
  7819. }
  7820. /**
  7821. * Returns whether a block is valid or not.
  7822. *
  7823. * @param {Object} state Editor state.
  7824. * @param {string} clientId Block client ID.
  7825. *
  7826. * @return {boolean} Is Valid.
  7827. */
  7828. function selectors_isBlockValid(state, clientId) {
  7829. const block = state.blocks.byClientId[clientId];
  7830. return !!block && block.isValid;
  7831. }
  7832. /**
  7833. * Returns a block's attributes given its client ID, or null if no block exists with
  7834. * the client ID.
  7835. *
  7836. * @param {Object} state Editor state.
  7837. * @param {string} clientId Block client ID.
  7838. *
  7839. * @return {Object?} Block attributes.
  7840. */
  7841. function selectors_getBlockAttributes(state, clientId) {
  7842. const block = state.blocks.byClientId[clientId];
  7843. if (!block) {
  7844. return null;
  7845. }
  7846. return state.blocks.attributes[clientId];
  7847. }
  7848. /**
  7849. * Returns a block given its client ID. This is a parsed copy of the block,
  7850. * containing its `blockName`, `clientId`, and current `attributes` state. This
  7851. * is not the block's registration settings, which must be retrieved from the
  7852. * blocks module registration store.
  7853. *
  7854. * getBlock recurses through its inner blocks until all its children blocks have
  7855. * been retrieved. Note that getBlock will not return the child inner blocks of
  7856. * an inner block controller. This is because an inner block controller syncs
  7857. * itself with its own entity, and should therefore not be included with the
  7858. * blocks of a different entity. For example, say you call `getBlocks( TP )` to
  7859. * get the blocks of a template part. If another template part is a child of TP,
  7860. * then the nested template part's child blocks will not be returned. This way,
  7861. * the template block itself is considered part of the parent, but the children
  7862. * are not.
  7863. *
  7864. * @param {Object} state Editor state.
  7865. * @param {string} clientId Block client ID.
  7866. *
  7867. * @return {Object} Parsed block object.
  7868. */
  7869. const selectors_getBlock = Object(rememo["a" /* default */])((state, clientId) => {
  7870. const block = state.blocks.byClientId[clientId];
  7871. if (!block) {
  7872. return null;
  7873. }
  7874. return { ...block,
  7875. attributes: selectors_getBlockAttributes(state, clientId),
  7876. innerBlocks: areInnerBlocksControlled(state, clientId) ? EMPTY_ARRAY : selectors_getBlocks(state, clientId)
  7877. };
  7878. }, (state, clientId) => [// Normally, we'd have both `getBlockAttributes` dependencies and
  7879. // `getBlocks` (children) dependencies here but for performance reasons
  7880. // we use a denormalized cache key computed in the reducer that takes both
  7881. // the attributes and inner blocks into account. The value of the cache key
  7882. // is being changed whenever one of these dependencies is out of date.
  7883. state.blocks.cache[clientId]]);
  7884. const selectors_unstableGetBlockWithoutInnerBlocks = Object(rememo["a" /* default */])((state, clientId) => {
  7885. const block = state.blocks.byClientId[clientId];
  7886. if (!block) {
  7887. return null;
  7888. }
  7889. return { ...block,
  7890. attributes: selectors_getBlockAttributes(state, clientId)
  7891. };
  7892. }, (state, clientId) => [state.blocks.byClientId[clientId], state.blocks.attributes[clientId]]);
  7893. /**
  7894. * Returns all block objects for the current post being edited as an array in
  7895. * the order they appear in the post. Note that this will exclude child blocks
  7896. * of nested inner block controllers.
  7897. *
  7898. * Note: It's important to memoize this selector to avoid return a new instance
  7899. * on each call. We use the block cache state for each top-level block of the
  7900. * given clientID. This way, the selector only refreshes on changes to blocks
  7901. * associated with the given entity, and does not refresh when changes are made
  7902. * to blocks which are part of different inner block controllers.
  7903. *
  7904. * @param {Object} state Editor state.
  7905. * @param {?string} rootClientId Optional root client ID of block list.
  7906. *
  7907. * @return {Object[]} Post blocks.
  7908. */
  7909. const selectors_getBlocks = Object(rememo["a" /* default */])((state, rootClientId) => {
  7910. return Object(external_lodash_["map"])(selectors_getBlockOrder(state, rootClientId), clientId => selectors_getBlock(state, clientId));
  7911. }, (state, rootClientId) => Object(external_lodash_["map"])(state.blocks.order[rootClientId || ''], id => state.blocks.cache[id]));
  7912. /**
  7913. * Similar to getBlock, except it will include the entire nested block tree as
  7914. * inner blocks. The normal getBlock selector will exclude sections of the block
  7915. * tree which belong to different entities.
  7916. *
  7917. * @param {Object} state Editor state.
  7918. * @param {string} clientId Client ID of the block to get.
  7919. *
  7920. * @return {Object} The block with all
  7921. */
  7922. const __unstableGetBlockWithBlockTree = Object(rememo["a" /* default */])((state, clientId) => {
  7923. const block = state.blocks.byClientId[clientId];
  7924. if (!block) {
  7925. return null;
  7926. }
  7927. return { ...block,
  7928. attributes: selectors_getBlockAttributes(state, clientId),
  7929. innerBlocks: __unstableGetBlockTree(state, clientId)
  7930. };
  7931. }, state => [state.blocks.byClientId, state.blocks.order, state.blocks.attributes]);
  7932. /**
  7933. * Similar to getBlocks, except this selector returns the entire block tree
  7934. * represented in the block-editor store from the given root regardless of any
  7935. * inner block controllers.
  7936. *
  7937. * @param {Object} state Editor state.
  7938. * @param {?string} rootClientId Optional root client ID of block list.
  7939. *
  7940. * @return {Object[]} Post blocks.
  7941. */
  7942. const __unstableGetBlockTree = Object(rememo["a" /* default */])((state, rootClientId = '') => Object(external_lodash_["map"])(selectors_getBlockOrder(state, rootClientId), clientId => __unstableGetBlockWithBlockTree(state, clientId)), state => [state.blocks.byClientId, state.blocks.order, state.blocks.attributes]);
  7943. /**
  7944. * Returns a stripped down block object containing only its client ID,
  7945. * and its inner blocks' client IDs.
  7946. *
  7947. * @param {Object} state Editor state.
  7948. * @param {string} clientId Client ID of the block to get.
  7949. *
  7950. * @return {Object} Client IDs of the post blocks.
  7951. */
  7952. const selectors_unstableGetClientIdWithClientIdsTree = Object(rememo["a" /* default */])((state, clientId) => ({
  7953. clientId,
  7954. innerBlocks: selectors_unstableGetClientIdsTree(state, clientId)
  7955. }), state => [state.blocks.order]);
  7956. /**
  7957. * Returns the block tree represented in the block-editor store from the
  7958. * given root, consisting of stripped down block objects containing only
  7959. * their client IDs, and their inner blocks' client IDs.
  7960. *
  7961. * @param {Object} state Editor state.
  7962. * @param {?string} rootClientId Optional root client ID of block list.
  7963. *
  7964. * @return {Object[]} Client IDs of the post blocks.
  7965. */
  7966. const selectors_unstableGetClientIdsTree = Object(rememo["a" /* default */])((state, rootClientId = '') => Object(external_lodash_["map"])(selectors_getBlockOrder(state, rootClientId), clientId => selectors_unstableGetClientIdWithClientIdsTree(state, clientId)), state => [state.blocks.order]);
  7967. /**
  7968. * Returns an array containing the clientIds of all descendants
  7969. * of the blocks given.
  7970. *
  7971. * @param {Object} state Global application state.
  7972. * @param {Array} clientIds Array of blocks to inspect.
  7973. *
  7974. * @return {Array} ids of descendants.
  7975. */
  7976. const selectors_getClientIdsOfDescendants = (state, clientIds) => Object(external_lodash_["flatMap"])(clientIds, clientId => {
  7977. const descendants = selectors_getBlockOrder(state, clientId);
  7978. return [...descendants, ...selectors_getClientIdsOfDescendants(state, descendants)];
  7979. });
  7980. /**
  7981. * Returns an array containing the clientIds of the top-level blocks
  7982. * and their descendants of any depth (for nested blocks).
  7983. *
  7984. * @param {Object} state Global application state.
  7985. *
  7986. * @return {Array} ids of top-level and descendant blocks.
  7987. */
  7988. const getClientIdsWithDescendants = Object(rememo["a" /* default */])(state => {
  7989. const topLevelIds = selectors_getBlockOrder(state);
  7990. return [...topLevelIds, ...selectors_getClientIdsOfDescendants(state, topLevelIds)];
  7991. }, state => [state.blocks.order]);
  7992. /**
  7993. * Returns the total number of blocks, or the total number of blocks with a specific name in a post.
  7994. * The number returned includes nested blocks.
  7995. *
  7996. * @param {Object} state Global application state.
  7997. * @param {?string} blockName Optional block name, if specified only blocks of that type will be counted.
  7998. *
  7999. * @return {number} Number of blocks in the post, or number of blocks with name equal to blockName.
  8000. */
  8001. const selectors_getGlobalBlockCount = Object(rememo["a" /* default */])((state, blockName) => {
  8002. const clientIds = getClientIdsWithDescendants(state);
  8003. if (!blockName) {
  8004. return clientIds.length;
  8005. }
  8006. return Object(external_lodash_["reduce"])(clientIds, (accumulator, clientId) => {
  8007. const block = state.blocks.byClientId[clientId];
  8008. return block.name === blockName ? accumulator + 1 : accumulator;
  8009. }, 0);
  8010. }, state => [state.blocks.order, state.blocks.byClientId]);
  8011. /**
  8012. * Given an array of block client IDs, returns the corresponding array of block
  8013. * objects.
  8014. *
  8015. * @param {Object} state Editor state.
  8016. * @param {string[]} clientIds Client IDs for which blocks are to be returned.
  8017. *
  8018. * @return {WPBlock[]} Block objects.
  8019. */
  8020. const selectors_getBlocksByClientId = Object(rememo["a" /* default */])((state, clientIds) => Object(external_lodash_["map"])(Object(external_lodash_["castArray"])(clientIds), clientId => selectors_getBlock(state, clientId)), state => [state.blocks.byClientId, state.blocks.order, state.blocks.attributes]);
  8021. /**
  8022. * Returns the number of blocks currently present in the post.
  8023. *
  8024. * @param {Object} state Editor state.
  8025. * @param {?string} rootClientId Optional root client ID of block list.
  8026. *
  8027. * @return {number} Number of blocks in the post.
  8028. */
  8029. function selectors_getBlockCount(state, rootClientId) {
  8030. return selectors_getBlockOrder(state, rootClientId).length;
  8031. }
  8032. /**
  8033. * Returns the current selection start block client ID, attribute key and text
  8034. * offset.
  8035. *
  8036. * @param {Object} state Block editor state.
  8037. *
  8038. * @return {WPBlockSelection} Selection start information.
  8039. */
  8040. function selectors_getSelectionStart(state) {
  8041. return state.selection.selectionStart;
  8042. }
  8043. /**
  8044. * Returns the current selection end block client ID, attribute key and text
  8045. * offset.
  8046. *
  8047. * @param {Object} state Block editor state.
  8048. *
  8049. * @return {WPBlockSelection} Selection end information.
  8050. */
  8051. function selectors_getSelectionEnd(state) {
  8052. return state.selection.selectionEnd;
  8053. }
  8054. /**
  8055. * Returns the current block selection start. This value may be null, and it
  8056. * may represent either a singular block selection or multi-selection start.
  8057. * A selection is singular if its start and end match.
  8058. *
  8059. * @param {Object} state Global application state.
  8060. *
  8061. * @return {?string} Client ID of block selection start.
  8062. */
  8063. function selectors_getBlockSelectionStart(state) {
  8064. return state.selection.selectionStart.clientId;
  8065. }
  8066. /**
  8067. * Returns the current block selection end. This value may be null, and it
  8068. * may represent either a singular block selection or multi-selection end.
  8069. * A selection is singular if its start and end match.
  8070. *
  8071. * @param {Object} state Global application state.
  8072. *
  8073. * @return {?string} Client ID of block selection end.
  8074. */
  8075. function selectors_getBlockSelectionEnd(state) {
  8076. return state.selection.selectionEnd.clientId;
  8077. }
  8078. /**
  8079. * Returns the number of blocks currently selected in the post.
  8080. *
  8081. * @param {Object} state Global application state.
  8082. *
  8083. * @return {number} Number of blocks selected in the post.
  8084. */
  8085. function selectors_getSelectedBlockCount(state) {
  8086. const multiSelectedBlockCount = selectors_getMultiSelectedBlockClientIds(state).length;
  8087. if (multiSelectedBlockCount) {
  8088. return multiSelectedBlockCount;
  8089. }
  8090. return state.selection.selectionStart.clientId ? 1 : 0;
  8091. }
  8092. /**
  8093. * Returns true if there is a single selected block, or false otherwise.
  8094. *
  8095. * @param {Object} state Editor state.
  8096. *
  8097. * @return {boolean} Whether a single block is selected.
  8098. */
  8099. function selectors_hasSelectedBlock(state) {
  8100. const {
  8101. selectionStart,
  8102. selectionEnd
  8103. } = state.selection;
  8104. return !!selectionStart.clientId && selectionStart.clientId === selectionEnd.clientId;
  8105. }
  8106. /**
  8107. * Returns the currently selected block client ID, or null if there is no
  8108. * selected block.
  8109. *
  8110. * @param {Object} state Editor state.
  8111. *
  8112. * @return {?string} Selected block client ID.
  8113. */
  8114. function selectors_getSelectedBlockClientId(state) {
  8115. const {
  8116. selectionStart,
  8117. selectionEnd
  8118. } = state.selection;
  8119. const {
  8120. clientId
  8121. } = selectionStart;
  8122. if (!clientId || clientId !== selectionEnd.clientId) {
  8123. return null;
  8124. }
  8125. return clientId;
  8126. }
  8127. /**
  8128. * Returns the currently selected block, or null if there is no selected block.
  8129. *
  8130. * @param {Object} state Global application state.
  8131. *
  8132. * @return {?Object} Selected block.
  8133. */
  8134. function selectors_getSelectedBlock(state) {
  8135. const clientId = selectors_getSelectedBlockClientId(state);
  8136. return clientId ? selectors_getBlock(state, clientId) : null;
  8137. }
  8138. /**
  8139. * Given a block client ID, returns the root block from which the block is
  8140. * nested, an empty string for top-level blocks, or null if the block does not
  8141. * exist.
  8142. *
  8143. * @param {Object} state Editor state.
  8144. * @param {string} clientId Block from which to find root client ID.
  8145. *
  8146. * @return {?string} Root client ID, if exists
  8147. */
  8148. function selectors_getBlockRootClientId(state, clientId) {
  8149. return state.blocks.parents[clientId] !== undefined ? state.blocks.parents[clientId] : null;
  8150. }
  8151. /**
  8152. * Given a block client ID, returns the list of all its parents from top to bottom.
  8153. *
  8154. * @param {Object} state Editor state.
  8155. * @param {string} clientId Block from which to find root client ID.
  8156. * @param {boolean} ascending Order results from bottom to top (true) or top to bottom (false).
  8157. *
  8158. * @return {Array} ClientIDs of the parent blocks.
  8159. */
  8160. const selectors_getBlockParents = Object(rememo["a" /* default */])((state, clientId, ascending = false) => {
  8161. const parents = [];
  8162. let current = clientId;
  8163. while (!!state.blocks.parents[current]) {
  8164. current = state.blocks.parents[current];
  8165. parents.push(current);
  8166. }
  8167. return ascending ? parents : parents.reverse();
  8168. }, state => [state.blocks.parents]);
  8169. /**
  8170. * Given a block client ID and a block name, returns the list of all its parents
  8171. * from top to bottom, filtered by the given name(s). For example, if passed
  8172. * 'core/group' as the blockName, it will only return parents which are group
  8173. * blocks. If passed `[ 'core/group', 'core/cover']`, as the blockName, it will
  8174. * return parents which are group blocks and parents which are cover blocks.
  8175. *
  8176. * @param {Object} state Editor state.
  8177. * @param {string} clientId Block from which to find root client ID.
  8178. * @param {string|string[]} blockName Block name(s) to filter.
  8179. * @param {boolean} ascending Order results from bottom to top (true) or top to bottom (false).
  8180. *
  8181. * @return {Array} ClientIDs of the parent blocks.
  8182. */
  8183. const getBlockParentsByBlockName = Object(rememo["a" /* default */])((state, clientId, blockName, ascending = false) => {
  8184. const parents = selectors_getBlockParents(state, clientId, ascending);
  8185. return Object(external_lodash_["map"])(Object(external_lodash_["filter"])(Object(external_lodash_["map"])(parents, id => ({
  8186. id,
  8187. name: selectors_getBlockName(state, id)
  8188. })), ({
  8189. name
  8190. }) => {
  8191. if (Array.isArray(blockName)) {
  8192. return blockName.includes(name);
  8193. }
  8194. return name === blockName;
  8195. }), ({
  8196. id
  8197. }) => id);
  8198. }, state => [state.blocks.parents]);
  8199. /**
  8200. * Given a block client ID, returns the root of the hierarchy from which the block is nested, return the block itself for root level blocks.
  8201. *
  8202. * @param {Object} state Editor state.
  8203. * @param {string} clientId Block from which to find root client ID.
  8204. *
  8205. * @return {string} Root client ID
  8206. */
  8207. function selectors_getBlockHierarchyRootClientId(state, clientId) {
  8208. let current = clientId;
  8209. let parent;
  8210. do {
  8211. parent = current;
  8212. current = state.blocks.parents[current];
  8213. } while (current);
  8214. return parent;
  8215. }
  8216. /**
  8217. * Given a block client ID, returns the lowest common ancestor with selected client ID.
  8218. *
  8219. * @param {Object} state Editor state.
  8220. * @param {string} clientId Block from which to find common ancestor client ID.
  8221. *
  8222. * @return {string} Common ancestor client ID or undefined
  8223. */
  8224. function getLowestCommonAncestorWithSelectedBlock(state, clientId) {
  8225. const selectedId = selectors_getSelectedBlockClientId(state);
  8226. const clientParents = [...selectors_getBlockParents(state, clientId), clientId];
  8227. const selectedParents = [...selectors_getBlockParents(state, selectedId), selectedId];
  8228. let lowestCommonAncestor;
  8229. const maxDepth = Math.min(clientParents.length, selectedParents.length);
  8230. for (let index = 0; index < maxDepth; index++) {
  8231. if (clientParents[index] === selectedParents[index]) {
  8232. lowestCommonAncestor = clientParents[index];
  8233. } else {
  8234. break;
  8235. }
  8236. }
  8237. return lowestCommonAncestor;
  8238. }
  8239. /**
  8240. * Returns the client ID of the block adjacent one at the given reference
  8241. * startClientId and modifier directionality. Defaults start startClientId to
  8242. * the selected block, and direction as next block. Returns null if there is no
  8243. * adjacent block.
  8244. *
  8245. * @param {Object} state Editor state.
  8246. * @param {?string} startClientId Optional client ID of block from which to
  8247. * search.
  8248. * @param {?number} modifier Directionality multiplier (1 next, -1
  8249. * previous).
  8250. *
  8251. * @return {?string} Return the client ID of the block, or null if none exists.
  8252. */
  8253. function getAdjacentBlockClientId(state, startClientId, modifier = 1) {
  8254. // Default to selected block.
  8255. if (startClientId === undefined) {
  8256. startClientId = selectors_getSelectedBlockClientId(state);
  8257. } // Try multi-selection starting at extent based on modifier.
  8258. if (startClientId === undefined) {
  8259. if (modifier < 0) {
  8260. startClientId = selectors_getFirstMultiSelectedBlockClientId(state);
  8261. } else {
  8262. startClientId = selectors_getLastMultiSelectedBlockClientId(state);
  8263. }
  8264. } // Validate working start client ID.
  8265. if (!startClientId) {
  8266. return null;
  8267. } // Retrieve start block root client ID, being careful to allow the falsey
  8268. // empty string top-level root by explicitly testing against null.
  8269. const rootClientId = selectors_getBlockRootClientId(state, startClientId);
  8270. if (rootClientId === null) {
  8271. return null;
  8272. }
  8273. const {
  8274. order
  8275. } = state.blocks;
  8276. const orderSet = order[rootClientId];
  8277. const index = orderSet.indexOf(startClientId);
  8278. const nextIndex = index + 1 * modifier; // Block was first in set and we're attempting to get previous.
  8279. if (nextIndex < 0) {
  8280. return null;
  8281. } // Block was last in set and we're attempting to get next.
  8282. if (nextIndex === orderSet.length) {
  8283. return null;
  8284. } // Assume incremented index is within the set.
  8285. return orderSet[nextIndex];
  8286. }
  8287. /**
  8288. * Returns the previous block's client ID from the given reference start ID.
  8289. * Defaults start to the selected block. Returns null if there is no previous
  8290. * block.
  8291. *
  8292. * @param {Object} state Editor state.
  8293. * @param {?string} startClientId Optional client ID of block from which to
  8294. * search.
  8295. *
  8296. * @return {?string} Adjacent block's client ID, or null if none exists.
  8297. */
  8298. function selectors_getPreviousBlockClientId(state, startClientId) {
  8299. return getAdjacentBlockClientId(state, startClientId, -1);
  8300. }
  8301. /**
  8302. * Returns the next block's client ID from the given reference start ID.
  8303. * Defaults start to the selected block. Returns null if there is no next
  8304. * block.
  8305. *
  8306. * @param {Object} state Editor state.
  8307. * @param {?string} startClientId Optional client ID of block from which to
  8308. * search.
  8309. *
  8310. * @return {?string} Adjacent block's client ID, or null if none exists.
  8311. */
  8312. function selectors_getNextBlockClientId(state, startClientId) {
  8313. return getAdjacentBlockClientId(state, startClientId, 1);
  8314. }
  8315. /**
  8316. * Returns the initial caret position for the selected block.
  8317. * This position is to used to position the caret properly when the selected block changes.
  8318. * If the current block is not a RichText, having initial position set to 0 means "focus block"
  8319. *
  8320. * @param {Object} state Global application state.
  8321. *
  8322. * @return {0|-1|null} Initial position.
  8323. */
  8324. function selectors_getSelectedBlocksInitialCaretPosition(state) {
  8325. return state.initialPosition;
  8326. }
  8327. /**
  8328. * Returns the current selection set of block client IDs (multiselection or single selection).
  8329. *
  8330. * @param {Object} state Editor state.
  8331. *
  8332. * @return {Array} Multi-selected block client IDs.
  8333. */
  8334. const selectors_getSelectedBlockClientIds = Object(rememo["a" /* default */])(state => {
  8335. const {
  8336. selectionStart,
  8337. selectionEnd
  8338. } = state.selection;
  8339. if (selectionStart.clientId === undefined || selectionEnd.clientId === undefined) {
  8340. return EMPTY_ARRAY;
  8341. }
  8342. if (selectionStart.clientId === selectionEnd.clientId) {
  8343. return [selectionStart.clientId];
  8344. } // Retrieve root client ID to aid in retrieving relevant nested block
  8345. // order, being careful to allow the falsey empty string top-level root
  8346. // by explicitly testing against null.
  8347. const rootClientId = selectors_getBlockRootClientId(state, selectionStart.clientId);
  8348. if (rootClientId === null) {
  8349. return EMPTY_ARRAY;
  8350. }
  8351. const blockOrder = selectors_getBlockOrder(state, rootClientId);
  8352. const startIndex = blockOrder.indexOf(selectionStart.clientId);
  8353. const endIndex = blockOrder.indexOf(selectionEnd.clientId);
  8354. if (startIndex > endIndex) {
  8355. return blockOrder.slice(endIndex, startIndex + 1);
  8356. }
  8357. return blockOrder.slice(startIndex, endIndex + 1);
  8358. }, state => [state.blocks.order, state.selection.selectionStart.clientId, state.selection.selectionEnd.clientId]);
  8359. /**
  8360. * Returns the current multi-selection set of block client IDs, or an empty
  8361. * array if there is no multi-selection.
  8362. *
  8363. * @param {Object} state Editor state.
  8364. *
  8365. * @return {Array} Multi-selected block client IDs.
  8366. */
  8367. function selectors_getMultiSelectedBlockClientIds(state) {
  8368. const {
  8369. selectionStart,
  8370. selectionEnd
  8371. } = state.selection;
  8372. if (selectionStart.clientId === selectionEnd.clientId) {
  8373. return EMPTY_ARRAY;
  8374. }
  8375. return selectors_getSelectedBlockClientIds(state);
  8376. }
  8377. /**
  8378. * Returns the current multi-selection set of blocks, or an empty array if
  8379. * there is no multi-selection.
  8380. *
  8381. * @param {Object} state Editor state.
  8382. *
  8383. * @return {Array} Multi-selected block objects.
  8384. */
  8385. const selectors_getMultiSelectedBlocks = Object(rememo["a" /* default */])(state => {
  8386. const multiSelectedBlockClientIds = selectors_getMultiSelectedBlockClientIds(state);
  8387. if (!multiSelectedBlockClientIds.length) {
  8388. return EMPTY_ARRAY;
  8389. }
  8390. return multiSelectedBlockClientIds.map(clientId => selectors_getBlock(state, clientId));
  8391. }, state => [...selectors_getSelectedBlockClientIds.getDependants(state), state.blocks.byClientId, state.blocks.order, state.blocks.attributes]);
  8392. /**
  8393. * Returns the client ID of the first block in the multi-selection set, or null
  8394. * if there is no multi-selection.
  8395. *
  8396. * @param {Object} state Editor state.
  8397. *
  8398. * @return {?string} First block client ID in the multi-selection set.
  8399. */
  8400. function selectors_getFirstMultiSelectedBlockClientId(state) {
  8401. return Object(external_lodash_["first"])(selectors_getMultiSelectedBlockClientIds(state)) || null;
  8402. }
  8403. /**
  8404. * Returns the client ID of the last block in the multi-selection set, or null
  8405. * if there is no multi-selection.
  8406. *
  8407. * @param {Object} state Editor state.
  8408. *
  8409. * @return {?string} Last block client ID in the multi-selection set.
  8410. */
  8411. function selectors_getLastMultiSelectedBlockClientId(state) {
  8412. return Object(external_lodash_["last"])(selectors_getMultiSelectedBlockClientIds(state)) || null;
  8413. }
  8414. /**
  8415. * Returns true if a multi-selection exists, and the block corresponding to the
  8416. * specified client ID is the first block of the multi-selection set, or false
  8417. * otherwise.
  8418. *
  8419. * @param {Object} state Editor state.
  8420. * @param {string} clientId Block client ID.
  8421. *
  8422. * @return {boolean} Whether block is first in multi-selection.
  8423. */
  8424. function selectors_isFirstMultiSelectedBlock(state, clientId) {
  8425. return selectors_getFirstMultiSelectedBlockClientId(state) === clientId;
  8426. }
  8427. /**
  8428. * Returns true if the client ID occurs within the block multi-selection, or
  8429. * false otherwise.
  8430. *
  8431. * @param {Object} state Editor state.
  8432. * @param {string} clientId Block client ID.
  8433. *
  8434. * @return {boolean} Whether block is in multi-selection set.
  8435. */
  8436. function selectors_isBlockMultiSelected(state, clientId) {
  8437. return selectors_getMultiSelectedBlockClientIds(state).indexOf(clientId) !== -1;
  8438. }
  8439. /**
  8440. * Returns true if an ancestor of the block is multi-selected, or false
  8441. * otherwise.
  8442. *
  8443. * @param {Object} state Editor state.
  8444. * @param {string} clientId Block client ID.
  8445. *
  8446. * @return {boolean} Whether an ancestor of the block is in multi-selection
  8447. * set.
  8448. */
  8449. const selectors_isAncestorMultiSelected = Object(rememo["a" /* default */])((state, clientId) => {
  8450. let ancestorClientId = clientId;
  8451. let isMultiSelected = false;
  8452. while (ancestorClientId && !isMultiSelected) {
  8453. ancestorClientId = selectors_getBlockRootClientId(state, ancestorClientId);
  8454. isMultiSelected = selectors_isBlockMultiSelected(state, ancestorClientId);
  8455. }
  8456. return isMultiSelected;
  8457. }, state => [state.blocks.order, state.selection.selectionStart.clientId, state.selection.selectionEnd.clientId]);
  8458. /**
  8459. * Returns the client ID of the block which begins the multi-selection set, or
  8460. * null if there is no multi-selection.
  8461. *
  8462. * This is not necessarily the first client ID in the selection.
  8463. *
  8464. * @see getFirstMultiSelectedBlockClientId
  8465. *
  8466. * @param {Object} state Editor state.
  8467. *
  8468. * @return {?string} Client ID of block beginning multi-selection.
  8469. */
  8470. function selectors_getMultiSelectedBlocksStartClientId(state) {
  8471. const {
  8472. selectionStart,
  8473. selectionEnd
  8474. } = state.selection;
  8475. if (selectionStart.clientId === selectionEnd.clientId) {
  8476. return null;
  8477. }
  8478. return selectionStart.clientId || null;
  8479. }
  8480. /**
  8481. * Returns the client ID of the block which ends the multi-selection set, or
  8482. * null if there is no multi-selection.
  8483. *
  8484. * This is not necessarily the last client ID in the selection.
  8485. *
  8486. * @see getLastMultiSelectedBlockClientId
  8487. *
  8488. * @param {Object} state Editor state.
  8489. *
  8490. * @return {?string} Client ID of block ending multi-selection.
  8491. */
  8492. function selectors_getMultiSelectedBlocksEndClientId(state) {
  8493. const {
  8494. selectionStart,
  8495. selectionEnd
  8496. } = state.selection;
  8497. if (selectionStart.clientId === selectionEnd.clientId) {
  8498. return null;
  8499. }
  8500. return selectionEnd.clientId || null;
  8501. }
  8502. /**
  8503. * Returns an array containing all block client IDs in the editor in the order
  8504. * they appear. Optionally accepts a root client ID of the block list for which
  8505. * the order should be returned, defaulting to the top-level block order.
  8506. *
  8507. * @param {Object} state Editor state.
  8508. * @param {?string} rootClientId Optional root client ID of block list.
  8509. *
  8510. * @return {Array} Ordered client IDs of editor blocks.
  8511. */
  8512. function selectors_getBlockOrder(state, rootClientId) {
  8513. return state.blocks.order[rootClientId || ''] || EMPTY_ARRAY;
  8514. }
  8515. /**
  8516. * Returns the index at which the block corresponding to the specified client
  8517. * ID occurs within the block order, or `-1` if the block does not exist.
  8518. *
  8519. * @param {Object} state Editor state.
  8520. * @param {string} clientId Block client ID.
  8521. * @param {?string} rootClientId Optional root client ID of block list.
  8522. *
  8523. * @return {number} Index at which block exists in order.
  8524. */
  8525. function selectors_getBlockIndex(state, clientId, rootClientId) {
  8526. return selectors_getBlockOrder(state, rootClientId).indexOf(clientId);
  8527. }
  8528. /**
  8529. * Returns true if the block corresponding to the specified client ID is
  8530. * currently selected and no multi-selection exists, or false otherwise.
  8531. *
  8532. * @param {Object} state Editor state.
  8533. * @param {string} clientId Block client ID.
  8534. *
  8535. * @return {boolean} Whether block is selected and multi-selection exists.
  8536. */
  8537. function selectors_isBlockSelected(state, clientId) {
  8538. const {
  8539. selectionStart,
  8540. selectionEnd
  8541. } = state.selection;
  8542. if (selectionStart.clientId !== selectionEnd.clientId) {
  8543. return false;
  8544. }
  8545. return selectionStart.clientId === clientId;
  8546. }
  8547. /**
  8548. * Returns true if one of the block's inner blocks is selected.
  8549. *
  8550. * @param {Object} state Editor state.
  8551. * @param {string} clientId Block client ID.
  8552. * @param {boolean} deep Perform a deep check.
  8553. *
  8554. * @return {boolean} Whether the block as an inner block selected
  8555. */
  8556. function selectors_hasSelectedInnerBlock(state, clientId, deep = false) {
  8557. return Object(external_lodash_["some"])(selectors_getBlockOrder(state, clientId), innerClientId => selectors_isBlockSelected(state, innerClientId) || selectors_isBlockMultiSelected(state, innerClientId) || deep && selectors_hasSelectedInnerBlock(state, innerClientId, deep));
  8558. }
  8559. /**
  8560. * Returns true if the block corresponding to the specified client ID is
  8561. * currently selected but isn't the last of the selected blocks. Here "last"
  8562. * refers to the block sequence in the document, _not_ the sequence of
  8563. * multi-selection, which is why `state.selectionEnd` isn't used.
  8564. *
  8565. * @param {Object} state Editor state.
  8566. * @param {string} clientId Block client ID.
  8567. *
  8568. * @return {boolean} Whether block is selected and not the last in the
  8569. * selection.
  8570. */
  8571. function isBlockWithinSelection(state, clientId) {
  8572. if (!clientId) {
  8573. return false;
  8574. }
  8575. const clientIds = selectors_getMultiSelectedBlockClientIds(state);
  8576. const index = clientIds.indexOf(clientId);
  8577. return index > -1 && index < clientIds.length - 1;
  8578. }
  8579. /**
  8580. * Returns true if a multi-selection has been made, or false otherwise.
  8581. *
  8582. * @param {Object} state Editor state.
  8583. *
  8584. * @return {boolean} Whether multi-selection has been made.
  8585. */
  8586. function selectors_hasMultiSelection(state) {
  8587. const {
  8588. selectionStart,
  8589. selectionEnd
  8590. } = state.selection;
  8591. return selectionStart.clientId !== selectionEnd.clientId;
  8592. }
  8593. /**
  8594. * Whether in the process of multi-selecting or not. This flag is only true
  8595. * while the multi-selection is being selected (by mouse move), and is false
  8596. * once the multi-selection has been settled.
  8597. *
  8598. * @see hasMultiSelection
  8599. *
  8600. * @param {Object} state Global application state.
  8601. *
  8602. * @return {boolean} True if multi-selecting, false if not.
  8603. */
  8604. function selectors_isMultiSelecting(state) {
  8605. return state.isMultiSelecting;
  8606. }
  8607. /**
  8608. * Selector that returns if multi-selection is enabled or not.
  8609. *
  8610. * @param {Object} state Global application state.
  8611. *
  8612. * @return {boolean} True if it should be possible to multi-select blocks, false if multi-selection is disabled.
  8613. */
  8614. function selectors_isSelectionEnabled(state) {
  8615. return state.isSelectionEnabled;
  8616. }
  8617. /**
  8618. * Returns the block's editing mode, defaulting to "visual" if not explicitly
  8619. * assigned.
  8620. *
  8621. * @param {Object} state Editor state.
  8622. * @param {string} clientId Block client ID.
  8623. *
  8624. * @return {Object} Block editing mode.
  8625. */
  8626. function selectors_getBlockMode(state, clientId) {
  8627. return state.blocksMode[clientId] || 'visual';
  8628. }
  8629. /**
  8630. * Returns true if the user is typing, or false otherwise.
  8631. *
  8632. * @param {Object} state Global application state.
  8633. *
  8634. * @return {boolean} Whether user is typing.
  8635. */
  8636. function selectors_isTyping(state) {
  8637. return state.isTyping;
  8638. }
  8639. /**
  8640. * Returns true if the user is dragging blocks, or false otherwise.
  8641. *
  8642. * @param {Object} state Global application state.
  8643. *
  8644. * @return {boolean} Whether user is dragging blocks.
  8645. */
  8646. function isDraggingBlocks(state) {
  8647. return !!state.draggedBlocks.length;
  8648. }
  8649. /**
  8650. * Returns the client ids of any blocks being directly dragged.
  8651. *
  8652. * This does not include children of a parent being dragged.
  8653. *
  8654. * @param {Object} state Global application state.
  8655. *
  8656. * @return {string[]} Array of dragged block client ids.
  8657. */
  8658. function selectors_getDraggedBlockClientIds(state) {
  8659. return state.draggedBlocks;
  8660. }
  8661. /**
  8662. * Returns whether the block is being dragged.
  8663. *
  8664. * Only returns true if the block is being directly dragged,
  8665. * not if the block is a child of a parent being dragged.
  8666. * See `isAncestorBeingDragged` for child blocks.
  8667. *
  8668. * @param {Object} state Global application state.
  8669. * @param {string} clientId Client id for block to check.
  8670. *
  8671. * @return {boolean} Whether the block is being dragged.
  8672. */
  8673. function selectors_isBlockBeingDragged(state, clientId) {
  8674. return state.draggedBlocks.includes(clientId);
  8675. }
  8676. /**
  8677. * Returns whether a parent/ancestor of the block is being dragged.
  8678. *
  8679. * @param {Object} state Global application state.
  8680. * @param {string} clientId Client id for block to check.
  8681. *
  8682. * @return {boolean} Whether the block's ancestor is being dragged.
  8683. */
  8684. function selectors_isAncestorBeingDragged(state, clientId) {
  8685. // Return early if no blocks are being dragged rather than
  8686. // the more expensive check for parents.
  8687. if (!isDraggingBlocks(state)) {
  8688. return false;
  8689. }
  8690. const parents = selectors_getBlockParents(state, clientId);
  8691. return Object(external_lodash_["some"])(parents, parentClientId => selectors_isBlockBeingDragged(state, parentClientId));
  8692. }
  8693. /**
  8694. * Returns true if the caret is within formatted text, or false otherwise.
  8695. *
  8696. * @param {Object} state Global application state.
  8697. *
  8698. * @return {boolean} Whether the caret is within formatted text.
  8699. */
  8700. function selectors_isCaretWithinFormattedText(state) {
  8701. return state.isCaretWithinFormattedText;
  8702. }
  8703. /**
  8704. * Returns the insertion point, the index at which the new inserted block would
  8705. * be placed. Defaults to the last index.
  8706. *
  8707. * @param {Object} state Editor state.
  8708. *
  8709. * @return {Object} Insertion point object with `rootClientId`, `index`.
  8710. */
  8711. function selectors_getBlockInsertionPoint(state) {
  8712. let rootClientId, index;
  8713. const {
  8714. insertionPoint,
  8715. selection: {
  8716. selectionEnd
  8717. }
  8718. } = state;
  8719. if (insertionPoint !== null) {
  8720. return insertionPoint;
  8721. }
  8722. const {
  8723. clientId
  8724. } = selectionEnd;
  8725. if (clientId) {
  8726. rootClientId = selectors_getBlockRootClientId(state, clientId) || undefined;
  8727. index = selectors_getBlockIndex(state, selectionEnd.clientId, rootClientId) + 1;
  8728. } else {
  8729. index = selectors_getBlockOrder(state).length;
  8730. }
  8731. return {
  8732. rootClientId,
  8733. index
  8734. };
  8735. }
  8736. /**
  8737. * Returns true if we should show the block insertion point.
  8738. *
  8739. * @param {Object} state Global application state.
  8740. *
  8741. * @return {?boolean} Whether the insertion point is visible or not.
  8742. */
  8743. function selectors_isBlockInsertionPointVisible(state) {
  8744. return state.insertionPoint !== null;
  8745. }
  8746. /**
  8747. * Returns whether the blocks matches the template or not.
  8748. *
  8749. * @param {boolean} state
  8750. * @return {?boolean} Whether the template is valid or not.
  8751. */
  8752. function selectors_isValidTemplate(state) {
  8753. return state.template.isValid;
  8754. }
  8755. /**
  8756. * Returns the defined block template
  8757. *
  8758. * @param {boolean} state
  8759. * @return {?Array} Block Template
  8760. */
  8761. function getTemplate(state) {
  8762. return state.settings.template;
  8763. }
  8764. /**
  8765. * Returns the defined block template lock. Optionally accepts a root block
  8766. * client ID as context, otherwise defaulting to the global context.
  8767. *
  8768. * @param {Object} state Editor state.
  8769. * @param {?string} rootClientId Optional block root client ID.
  8770. *
  8771. * @return {?string} Block Template Lock
  8772. */
  8773. function selectors_getTemplateLock(state, rootClientId) {
  8774. if (!rootClientId) {
  8775. return state.settings.templateLock;
  8776. }
  8777. const blockListSettings = selectors_getBlockListSettings(state, rootClientId);
  8778. if (!blockListSettings) {
  8779. return null;
  8780. }
  8781. return blockListSettings.templateLock;
  8782. }
  8783. const checkAllowList = (list, item, defaultResult = null) => {
  8784. if (Object(external_lodash_["isBoolean"])(list)) {
  8785. return list;
  8786. }
  8787. if (Object(external_lodash_["isArray"])(list)) {
  8788. // TODO: when there is a canonical way to detect that we are editing a post
  8789. // the following check should be changed to something like:
  8790. // if ( list.includes( 'core/post-content' ) && getEditorMode() === 'post-content' && item === null )
  8791. if (list.includes('core/post-content') && item === null) {
  8792. return true;
  8793. }
  8794. return list.includes(item);
  8795. }
  8796. return defaultResult;
  8797. };
  8798. /**
  8799. * Determines if the given block type is allowed to be inserted into the block list.
  8800. * This function is not exported and not memoized because using a memoized selector
  8801. * inside another memoized selector is just a waste of time.
  8802. *
  8803. * @param {Object} state Editor state.
  8804. * @param {string|Object} blockName The block type object, e.g., the response
  8805. * from the block directory; or a string name of
  8806. * an installed block type, e.g.' core/paragraph'.
  8807. * @param {?string} rootClientId Optional root client ID of block list.
  8808. *
  8809. * @return {boolean} Whether the given block type is allowed to be inserted.
  8810. */
  8811. const canInsertBlockTypeUnmemoized = (state, blockName, rootClientId = null) => {
  8812. let blockType;
  8813. if (blockName && 'object' === typeof blockName) {
  8814. blockType = blockName;
  8815. blockName = blockType.name;
  8816. } else {
  8817. blockType = Object(external_wp_blocks_["getBlockType"])(blockName);
  8818. }
  8819. if (!blockType) {
  8820. return false;
  8821. }
  8822. const {
  8823. allowedBlockTypes
  8824. } = selectors_getSettings(state);
  8825. const isBlockAllowedInEditor = checkAllowList(allowedBlockTypes, blockName, true);
  8826. if (!isBlockAllowedInEditor) {
  8827. return false;
  8828. }
  8829. const isLocked = !!selectors_getTemplateLock(state, rootClientId);
  8830. if (isLocked) {
  8831. return false;
  8832. }
  8833. const parentBlockListSettings = selectors_getBlockListSettings(state, rootClientId); // The parent block doesn't have settings indicating it doesn't support
  8834. // inner blocks, return false.
  8835. if (rootClientId && parentBlockListSettings === undefined) {
  8836. return false;
  8837. }
  8838. const parentAllowedBlocks = parentBlockListSettings === null || parentBlockListSettings === void 0 ? void 0 : parentBlockListSettings.allowedBlocks;
  8839. const hasParentAllowedBlock = checkAllowList(parentAllowedBlocks, blockName);
  8840. const blockAllowedParentBlocks = blockType.parent;
  8841. const parentName = selectors_getBlockName(state, rootClientId);
  8842. const hasBlockAllowedParent = checkAllowList(blockAllowedParentBlocks, parentName);
  8843. if (hasParentAllowedBlock !== null && hasBlockAllowedParent !== null) {
  8844. return hasParentAllowedBlock || hasBlockAllowedParent;
  8845. } else if (hasParentAllowedBlock !== null) {
  8846. return hasParentAllowedBlock;
  8847. } else if (hasBlockAllowedParent !== null) {
  8848. return hasBlockAllowedParent;
  8849. }
  8850. return true;
  8851. };
  8852. /**
  8853. * Determines if the given block type is allowed to be inserted into the block list.
  8854. *
  8855. * @param {Object} state Editor state.
  8856. * @param {string} blockName The name of the block type, e.g.' core/paragraph'.
  8857. * @param {?string} rootClientId Optional root client ID of block list.
  8858. *
  8859. * @return {boolean} Whether the given block type is allowed to be inserted.
  8860. */
  8861. const selectors_canInsertBlockType = Object(rememo["a" /* default */])(canInsertBlockTypeUnmemoized, (state, blockName, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId[rootClientId], state.settings.allowedBlockTypes, state.settings.templateLock]);
  8862. /**
  8863. * Determines if the given blocks are allowed to be inserted into the block
  8864. * list.
  8865. *
  8866. * @param {Object} state Editor state.
  8867. * @param {string} clientIds The block client IDs to be inserted.
  8868. * @param {?string} rootClientId Optional root client ID of block list.
  8869. *
  8870. * @return {boolean} Whether the given blocks are allowed to be inserted.
  8871. */
  8872. function selectors_canInsertBlocks(state, clientIds, rootClientId = null) {
  8873. return clientIds.every(id => selectors_canInsertBlockType(state, selectors_getBlockName(state, id), rootClientId));
  8874. }
  8875. /**
  8876. * Returns information about how recently and frequently a block has been inserted.
  8877. *
  8878. * @param {Object} state Global application state.
  8879. * @param {string} id A string which identifies the insert, e.g. 'core/block/12'
  8880. *
  8881. * @return {?{ time: number, count: number }} An object containing `time` which is when the last
  8882. * insert occurred as a UNIX epoch, and `count` which is
  8883. * the number of inserts that have occurred.
  8884. */
  8885. function getInsertUsage(state, id) {
  8886. var _state$preferences$in, _state$preferences$in2;
  8887. return (_state$preferences$in = (_state$preferences$in2 = state.preferences.insertUsage) === null || _state$preferences$in2 === void 0 ? void 0 : _state$preferences$in2[id]) !== null && _state$preferences$in !== void 0 ? _state$preferences$in : null;
  8888. }
  8889. /**
  8890. * Returns whether we can show a block type in the inserter
  8891. *
  8892. * @param {Object} state Global State
  8893. * @param {Object} blockType BlockType
  8894. * @param {?string} rootClientId Optional root client ID of block list.
  8895. *
  8896. * @return {boolean} Whether the given block type is allowed to be shown in the inserter.
  8897. */
  8898. const canIncludeBlockTypeInInserter = (state, blockType, rootClientId) => {
  8899. if (!Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'inserter', true)) {
  8900. return false;
  8901. }
  8902. return canInsertBlockTypeUnmemoized(state, blockType.name, rootClientId);
  8903. };
  8904. /**
  8905. * Return a function to be used to tranform a block variation to an inserter item
  8906. *
  8907. * @param {Object} state Global State
  8908. * @param {Object} item Denormalized inserter item
  8909. * @return {Function} Function to transform a block variation to inserter item
  8910. */
  8911. const getItemFromVariation = (state, item) => variation => {
  8912. const variationId = `${item.id}/${variation.name}`;
  8913. const {
  8914. time,
  8915. count = 0
  8916. } = getInsertUsage(state, variationId) || {};
  8917. return { ...item,
  8918. id: variationId,
  8919. icon: variation.icon || item.icon,
  8920. title: variation.title || item.title,
  8921. description: variation.description || item.description,
  8922. category: variation.category || item.category,
  8923. // If `example` is explicitly undefined for the variation, the preview will not be shown.
  8924. example: variation.hasOwnProperty('example') ? variation.example : item.example,
  8925. initialAttributes: { ...item.initialAttributes,
  8926. ...variation.attributes
  8927. },
  8928. innerBlocks: variation.innerBlocks,
  8929. keywords: variation.keywords || item.keywords,
  8930. frecency: calculateFrecency(time, count)
  8931. };
  8932. };
  8933. /**
  8934. * Returns the calculated frecency.
  8935. *
  8936. * 'frecency' is a heuristic (https://en.wikipedia.org/wiki/Frecency)
  8937. * that combines block usage frequenty and recency.
  8938. *
  8939. * @param {number} time When the last insert occurred as a UNIX epoch
  8940. * @param {number} count The number of inserts that have occurred.
  8941. *
  8942. * @return {number} The calculated frecency.
  8943. */
  8944. const calculateFrecency = (time, count) => {
  8945. if (!time) {
  8946. return count;
  8947. } // The selector is cached, which means Date.now() is the last time that the
  8948. // relevant state changed. This suits our needs.
  8949. const duration = Date.now() - time;
  8950. switch (true) {
  8951. case duration < MILLISECONDS_PER_HOUR:
  8952. return count * 4;
  8953. case duration < MILLISECONDS_PER_DAY:
  8954. return count * 2;
  8955. case duration < MILLISECONDS_PER_WEEK:
  8956. return count / 2;
  8957. default:
  8958. return count / 4;
  8959. }
  8960. };
  8961. /**
  8962. * Returns a function that accepts a block type and builds an item to be shown
  8963. * in a specific context. It's used for building items for Inserter and available
  8964. * block Transfroms list.
  8965. *
  8966. * @param {Object} state Editor state.
  8967. * @param {Object} options Options object for handling the building of a block type.
  8968. * @param {string} options.buildScope The scope for which the item is going to be used.
  8969. * @return {Function} Function returns an item to be shown in a specific context (Inserter|Transforms list).
  8970. */
  8971. const buildBlockTypeItem = (state, {
  8972. buildScope = 'inserter'
  8973. }) => blockType => {
  8974. const id = blockType.name;
  8975. let isDisabled = false;
  8976. if (!Object(external_wp_blocks_["hasBlockSupport"])(blockType.name, 'multiple', true)) {
  8977. isDisabled = Object(external_lodash_["some"])(selectors_getBlocksByClientId(state, getClientIdsWithDescendants(state)), {
  8978. name: blockType.name
  8979. });
  8980. }
  8981. const {
  8982. time,
  8983. count = 0
  8984. } = getInsertUsage(state, id) || {};
  8985. const blockItemBase = {
  8986. id,
  8987. name: blockType.name,
  8988. title: blockType.title,
  8989. icon: blockType.icon,
  8990. isDisabled,
  8991. frecency: calculateFrecency(time, count)
  8992. };
  8993. if (buildScope === 'transform') return blockItemBase;
  8994. const inserterVariations = blockType.variations.filter(({
  8995. scope
  8996. }) => !scope || scope.includes('inserter'));
  8997. return { ...blockItemBase,
  8998. initialAttributes: {},
  8999. description: blockType.description,
  9000. category: blockType.category,
  9001. keywords: blockType.keywords,
  9002. variations: inserterVariations,
  9003. example: blockType.example,
  9004. utility: 1 // deprecated
  9005. };
  9006. };
  9007. /**
  9008. * Determines the items that appear in the inserter. Includes both static
  9009. * items (e.g. a regular block type) and dynamic items (e.g. a reusable block).
  9010. *
  9011. * Each item object contains what's necessary to display a button in the
  9012. * inserter and handle its selection.
  9013. *
  9014. * The 'frecency' property is a heuristic (https://en.wikipedia.org/wiki/Frecency)
  9015. * that combines block usage frequenty and recency.
  9016. *
  9017. * Items are returned ordered descendingly by their 'utility' and 'frecency'.
  9018. *
  9019. * @param {Object} state Editor state.
  9020. * @param {?string} rootClientId Optional root client ID of block list.
  9021. *
  9022. * @return {WPEditorInserterItem[]} Items that appear in inserter.
  9023. *
  9024. * @typedef {Object} WPEditorInserterItem
  9025. * @property {string} id Unique identifier for the item.
  9026. * @property {string} name The type of block to create.
  9027. * @property {Object} initialAttributes Attributes to pass to the newly created block.
  9028. * @property {string} title Title of the item, as it appears in the inserter.
  9029. * @property {string} icon Dashicon for the item, as it appears in the inserter.
  9030. * @property {string} category Block category that the item is associated with.
  9031. * @property {string[]} keywords Keywords that can be searched to find this item.
  9032. * @property {boolean} isDisabled Whether or not the user should be prevented from inserting
  9033. * this item.
  9034. * @property {number} frecency Heuristic that combines frequency and recency.
  9035. */
  9036. const selectors_getInserterItems = Object(rememo["a" /* default */])((state, rootClientId = null) => {
  9037. const buildBlockTypeInserterItem = buildBlockTypeItem(state, {
  9038. buildScope: 'inserter'
  9039. });
  9040. const buildReusableBlockInserterItem = reusableBlock => {
  9041. const id = `core/block/${reusableBlock.id}`;
  9042. const referencedBlocks = __experimentalGetParsedReusableBlock(state, reusableBlock.id);
  9043. let referencedBlockType;
  9044. if (referencedBlocks.length === 1) {
  9045. referencedBlockType = Object(external_wp_blocks_["getBlockType"])(referencedBlocks[0].name);
  9046. }
  9047. const {
  9048. time,
  9049. count = 0
  9050. } = getInsertUsage(state, id) || {};
  9051. const frecency = calculateFrecency(time, count);
  9052. return {
  9053. id,
  9054. name: 'core/block',
  9055. initialAttributes: {
  9056. ref: reusableBlock.id
  9057. },
  9058. title: reusableBlock.title.raw,
  9059. icon: referencedBlockType ? referencedBlockType.icon : templateIcon,
  9060. category: 'reusable',
  9061. keywords: [],
  9062. isDisabled: false,
  9063. utility: 1,
  9064. // deprecated
  9065. frecency
  9066. };
  9067. };
  9068. const blockTypeInserterItems = Object(external_wp_blocks_["getBlockTypes"])().filter(blockType => canIncludeBlockTypeInInserter(state, blockType, rootClientId)).map(buildBlockTypeInserterItem);
  9069. const reusableBlockInserterItems = canInsertBlockTypeUnmemoized(state, 'core/block', rootClientId) ? getReusableBlocks(state).map(buildReusableBlockInserterItem) : []; // Exclude any block type item that is to be replaced by a default
  9070. // variation.
  9071. const visibleBlockTypeInserterItems = blockTypeInserterItems.filter(({
  9072. variations = []
  9073. }) => !variations.some(({
  9074. isDefault
  9075. }) => isDefault));
  9076. const blockVariations = []; // Show all available blocks with variations
  9077. for (const item of blockTypeInserterItems) {
  9078. const {
  9079. variations = []
  9080. } = item;
  9081. if (variations.length) {
  9082. const variationMapper = getItemFromVariation(state, item);
  9083. blockVariations.push(...variations.map(variationMapper));
  9084. }
  9085. } // Prioritize core blocks's display in inserter.
  9086. const prioritizeCoreBlocks = (a, b) => {
  9087. const coreBlockNamePrefix = 'core/';
  9088. const firstIsCoreBlock = a.name.startsWith(coreBlockNamePrefix);
  9089. const secondIsCoreBlock = b.name.startsWith(coreBlockNamePrefix);
  9090. if (firstIsCoreBlock && secondIsCoreBlock) {
  9091. return 0;
  9092. }
  9093. return firstIsCoreBlock && !secondIsCoreBlock ? -1 : 1;
  9094. }; // Ensure core blocks are prioritized in the returned results,
  9095. // because third party blocks can be registered earlier than
  9096. // the core blocks (usually by using the `init` action),
  9097. // thus affecting the display order.
  9098. // We don't sort reusable blocks as they are handled differently.
  9099. const sortedBlockTypes = [...visibleBlockTypeInserterItems, ...blockVariations].sort(prioritizeCoreBlocks);
  9100. return [...sortedBlockTypes, ...reusableBlockInserterItems];
  9101. }, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId, state.blocks.order, state.preferences.insertUsage, state.settings.allowedBlockTypes, state.settings.templateLock, getReusableBlocks(state), Object(external_wp_blocks_["getBlockTypes"])()]);
  9102. /**
  9103. * Determines the items that appear in the available block transforms list.
  9104. *
  9105. * Each item object contains what's necessary to display a menu item in the
  9106. * transform list and handle its selection.
  9107. *
  9108. * The 'frecency' property is a heuristic (https://en.wikipedia.org/wiki/Frecency)
  9109. * that combines block usage frequenty and recency.
  9110. *
  9111. * Items are returned ordered descendingly by their 'frecency'.
  9112. *
  9113. * @param {Object} state Editor state.
  9114. * @param {?string} rootClientId Optional root client ID of block list.
  9115. *
  9116. * @return {WPEditorTransformItem[]} Items that appear in inserter.
  9117. *
  9118. * @typedef {Object} WPEditorTransformItem
  9119. * @property {string} id Unique identifier for the item.
  9120. * @property {string} name The type of block to create.
  9121. * @property {string} title Title of the item, as it appears in the inserter.
  9122. * @property {string} icon Dashicon for the item, as it appears in the inserter.
  9123. * @property {boolean} isDisabled Whether or not the user should be prevented from inserting
  9124. * this item.
  9125. * @property {number} frecency Heuristic that combines frequency and recency.
  9126. */
  9127. const selectors_getBlockTransformItems = Object(rememo["a" /* default */])((state, blocks, rootClientId = null) => {
  9128. const buildBlockTypeTransformItem = buildBlockTypeItem(state, {
  9129. buildScope: 'transform'
  9130. });
  9131. const blockTypeTransformItems = Object(external_wp_blocks_["getBlockTypes"])().filter(blockType => canIncludeBlockTypeInInserter(state, blockType, rootClientId)).map(buildBlockTypeTransformItem);
  9132. const itemsByName = Object(external_lodash_["mapKeys"])(blockTypeTransformItems, ({
  9133. name
  9134. }) => name);
  9135. const possibleTransforms = Object(external_wp_blocks_["getPossibleBlockTransformations"])(blocks).reduce((accumulator, block) => {
  9136. if (itemsByName[block === null || block === void 0 ? void 0 : block.name]) {
  9137. accumulator.push(itemsByName[block.name]);
  9138. }
  9139. return accumulator;
  9140. }, []);
  9141. const possibleBlockTransformations = Object(external_lodash_["orderBy"])(possibleTransforms, block => itemsByName[block.name].frecency, 'desc');
  9142. return possibleBlockTransformations;
  9143. }, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId, state.preferences.insertUsage, state.settings.allowedBlockTypes, state.settings.templateLock, Object(external_wp_blocks_["getBlockTypes"])()]);
  9144. /**
  9145. * Determines whether there are items to show in the inserter.
  9146. *
  9147. * @param {Object} state Editor state.
  9148. * @param {?string} rootClientId Optional root client ID of block list.
  9149. *
  9150. * @return {boolean} Items that appear in inserter.
  9151. */
  9152. const selectors_hasInserterItems = Object(rememo["a" /* default */])((state, rootClientId = null) => {
  9153. const hasBlockType = Object(external_lodash_["some"])(Object(external_wp_blocks_["getBlockTypes"])(), blockType => canIncludeBlockTypeInInserter(state, blockType, rootClientId));
  9154. if (hasBlockType) {
  9155. return true;
  9156. }
  9157. const hasReusableBlock = canInsertBlockTypeUnmemoized(state, 'core/block', rootClientId) && getReusableBlocks(state).length > 0;
  9158. return hasReusableBlock;
  9159. }, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId, state.settings.allowedBlockTypes, state.settings.templateLock, getReusableBlocks(state), Object(external_wp_blocks_["getBlockTypes"])()]);
  9160. /**
  9161. * Returns the list of allowed inserter blocks for inner blocks children
  9162. *
  9163. * @param {Object} state Editor state.
  9164. * @param {?string} rootClientId Optional root client ID of block list.
  9165. *
  9166. * @return {Array?} The list of allowed block types.
  9167. */
  9168. const selectors_experimentalGetAllowedBlocks = Object(rememo["a" /* default */])((state, rootClientId = null) => {
  9169. if (!rootClientId) {
  9170. return;
  9171. }
  9172. return Object(external_lodash_["filter"])(Object(external_wp_blocks_["getBlockTypes"])(), blockType => canIncludeBlockTypeInInserter(state, blockType, rootClientId));
  9173. }, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId, state.settings.allowedBlockTypes, state.settings.templateLock, Object(external_wp_blocks_["getBlockTypes"])()]);
  9174. const checkAllowListRecursive = (blocks, allowedBlockTypes) => {
  9175. if (Object(external_lodash_["isBoolean"])(allowedBlockTypes)) {
  9176. return allowedBlockTypes;
  9177. }
  9178. const blocksQueue = [...blocks];
  9179. while (blocksQueue.length > 0) {
  9180. var _block$innerBlocks;
  9181. const block = blocksQueue.shift();
  9182. const isAllowed = checkAllowList(allowedBlockTypes, block.name || block.blockName, true);
  9183. if (!isAllowed) {
  9184. return false;
  9185. }
  9186. (_block$innerBlocks = block.innerBlocks) === null || _block$innerBlocks === void 0 ? void 0 : _block$innerBlocks.forEach(innerBlock => {
  9187. blocksQueue.push(innerBlock);
  9188. });
  9189. }
  9190. return true;
  9191. };
  9192. const __experimentalGetParsedPattern = Object(rememo["a" /* default */])((state, patternName) => {
  9193. const patterns = state.settings.__experimentalBlockPatterns;
  9194. const pattern = patterns.find(({
  9195. name
  9196. }) => name === patternName);
  9197. if (!pattern) {
  9198. return null;
  9199. }
  9200. return { ...pattern,
  9201. blocks: Object(external_wp_blocks_["parse"])(pattern.content)
  9202. };
  9203. }, state => [state.settings.__experimentalBlockPatterns]);
  9204. const getAllAllowedPatterns = Object(rememo["a" /* default */])(state => {
  9205. const patterns = state.settings.__experimentalBlockPatterns;
  9206. const {
  9207. allowedBlockTypes
  9208. } = selectors_getSettings(state);
  9209. const parsedPatterns = patterns.map(({
  9210. name
  9211. }) => __experimentalGetParsedPattern(state, name));
  9212. const allowedPatterns = parsedPatterns.filter(({
  9213. blocks
  9214. }) => checkAllowListRecursive(blocks, allowedBlockTypes));
  9215. return allowedPatterns;
  9216. }, state => [state.settings.__experimentalBlockPatterns, state.settings.allowedBlockTypes]);
  9217. /**
  9218. * Returns the list of allowed patterns for inner blocks children.
  9219. *
  9220. * @param {Object} state Editor state.
  9221. * @param {?string} rootClientId Optional target root client ID.
  9222. *
  9223. * @return {Array?} The list of allowed patterns.
  9224. */
  9225. const selectors_experimentalGetAllowedPatterns = Object(rememo["a" /* default */])((state, rootClientId = null) => {
  9226. const availableParsedPatterns = getAllAllowedPatterns(state);
  9227. const patternsAllowed = Object(external_lodash_["filter"])(availableParsedPatterns, ({
  9228. blocks
  9229. }) => blocks.every(({
  9230. name
  9231. }) => selectors_canInsertBlockType(state, name, rootClientId)));
  9232. return patternsAllowed;
  9233. }, (state, rootClientId) => [state.settings.__experimentalBlockPatterns, state.settings.allowedBlockTypes, state.settings.templateLock, state.blockListSettings[rootClientId], state.blocks.byClientId[rootClientId]]);
  9234. /**
  9235. * Returns the list of patterns based on their declared `blockTypes`
  9236. * and a block's name.
  9237. * Patterns can use `blockTypes` to integrate in work flows like
  9238. * suggesting appropriate patterns in a Placeholder state(during insertion)
  9239. * or blocks transformations.
  9240. *
  9241. * @param {Object} state Editor state.
  9242. * @param {string|string[]} blockNames Block's name or array of block names to find matching pattens.
  9243. * @param {?string} rootClientId Optional target root client ID.
  9244. *
  9245. * @return {Array} The list of matched block patterns based on declared `blockTypes` and block name.
  9246. */
  9247. const selectors_experimentalGetPatternsByBlockTypes = Object(rememo["a" /* default */])((state, blockNames, rootClientId = null) => {
  9248. if (!blockNames) return EMPTY_ARRAY;
  9249. const patterns = selectors_experimentalGetAllowedPatterns(state, rootClientId);
  9250. const normalizedBlockNames = Array.isArray(blockNames) ? blockNames : [blockNames];
  9251. return patterns.filter(pattern => {
  9252. var _pattern$blockTypes, _pattern$blockTypes$s;
  9253. return pattern === null || pattern === void 0 ? void 0 : (_pattern$blockTypes = pattern.blockTypes) === null || _pattern$blockTypes === void 0 ? void 0 : (_pattern$blockTypes$s = _pattern$blockTypes.some) === null || _pattern$blockTypes$s === void 0 ? void 0 : _pattern$blockTypes$s.call(_pattern$blockTypes, blockName => normalizedBlockNames.includes(blockName));
  9254. });
  9255. }, (state, rootClientId) => [...selectors_experimentalGetAllowedPatterns.getDependants(state, rootClientId)]);
  9256. /**
  9257. * Determines the items that appear in the available pattern transforms list.
  9258. *
  9259. * For now we only handle blocks without InnerBlocks and take into account
  9260. * the `__experimentalRole` property of blocks' attributes for the transformation.
  9261. *
  9262. * We return the first set of possible eligible block patterns,
  9263. * by checking the `blockTypes` property. We still have to recurse through
  9264. * block pattern's blocks and try to find matches from the selected blocks.
  9265. * Now this happens in the consumer to avoid heavy operations in the selector.
  9266. *
  9267. * @param {Object} state Editor state.
  9268. * @param {Object[]} blocks The selected blocks.
  9269. * @param {?string} rootClientId Optional root client ID of block list.
  9270. *
  9271. * @return {WPBlockPattern[]} Items that are eligible for a pattern transformation.
  9272. */
  9273. const selectors_experimentalGetPatternTransformItems = Object(rememo["a" /* default */])((state, blocks, rootClientId = null) => {
  9274. if (!blocks) return EMPTY_ARRAY;
  9275. /**
  9276. * For now we only handle blocks without InnerBlocks and take into account
  9277. * the `__experimentalRole` property of blocks' attributes for the transformation.
  9278. * Note that the blocks have been retrieved through `getBlock`, which doesn't
  9279. * return the inner blocks of an inner block controller, so we still need
  9280. * to check for this case too.
  9281. */
  9282. if (blocks.some(({
  9283. clientId,
  9284. innerBlocks
  9285. }) => innerBlocks.length || areInnerBlocksControlled(state, clientId))) {
  9286. return EMPTY_ARRAY;
  9287. } // Create a Set of the selected block names that is used in patterns filtering.
  9288. const selectedBlockNames = Array.from(new Set(blocks.map(({
  9289. name
  9290. }) => name)));
  9291. /**
  9292. * Here we will return first set of possible eligible block patterns,
  9293. * by checking the `blockTypes` property. We still have to recurse through
  9294. * block pattern's blocks and try to find matches from the selected blocks.
  9295. * Now this happens in the consumer to avoid heavy operations in the selector.
  9296. */
  9297. return selectors_experimentalGetPatternsByBlockTypes(state, selectedBlockNames, rootClientId);
  9298. }, (state, rootClientId) => [...selectors_experimentalGetPatternsByBlockTypes.getDependants(state, rootClientId)]);
  9299. /**
  9300. * Returns the Block List settings of a block, if any exist.
  9301. *
  9302. * @param {Object} state Editor state.
  9303. * @param {?string} clientId Block client ID.
  9304. *
  9305. * @return {?Object} Block settings of the block if set.
  9306. */
  9307. function selectors_getBlockListSettings(state, clientId) {
  9308. return state.blockListSettings[clientId];
  9309. }
  9310. /**
  9311. * Returns the editor settings.
  9312. *
  9313. * @param {Object} state Editor state.
  9314. *
  9315. * @return {Object} The editor settings object.
  9316. */
  9317. function selectors_getSettings(state) {
  9318. return state.settings;
  9319. }
  9320. /**
  9321. * Returns true if the most recent block change is be considered persistent, or
  9322. * false otherwise. A persistent change is one committed by BlockEditorProvider
  9323. * via its `onChange` callback, in addition to `onInput`.
  9324. *
  9325. * @param {Object} state Block editor state.
  9326. *
  9327. * @return {boolean} Whether the most recent block change was persistent.
  9328. */
  9329. function selectors_isLastBlockChangePersistent(state) {
  9330. return state.blocks.isPersistentChange;
  9331. }
  9332. /**
  9333. * Returns the block list settings for an array of blocks, if any exist.
  9334. *
  9335. * @param {Object} state Editor state.
  9336. * @param {Array} clientIds Block client IDs.
  9337. *
  9338. * @return {Object} An object where the keys are client ids and the values are
  9339. * a block list setting object.
  9340. */
  9341. const selectors_experimentalGetBlockListSettingsForBlocks = Object(rememo["a" /* default */])((state, clientIds = []) => {
  9342. return clientIds.reduce((blockListSettingsForBlocks, clientId) => {
  9343. if (!state.blockListSettings[clientId]) {
  9344. return blockListSettingsForBlocks;
  9345. }
  9346. return { ...blockListSettingsForBlocks,
  9347. [clientId]: state.blockListSettings[clientId]
  9348. };
  9349. }, {});
  9350. }, state => [state.blockListSettings]);
  9351. /**
  9352. * Returns the parsed block saved as shared block with the given ID.
  9353. *
  9354. * @param {Object} state Global application state.
  9355. * @param {number|string} ref The shared block's ID.
  9356. *
  9357. * @return {Object} The parsed block.
  9358. */
  9359. const __experimentalGetParsedReusableBlock = Object(rememo["a" /* default */])((state, ref) => {
  9360. const reusableBlock = Object(external_lodash_["find"])(getReusableBlocks(state), block => block.id === ref);
  9361. if (!reusableBlock) {
  9362. return null;
  9363. } // Only reusableBlock.content.raw should be used here, `reusableBlock.content` is a
  9364. // workaround until #22127 is fixed.
  9365. return Object(external_wp_blocks_["parse"])(typeof reusableBlock.content.raw === 'string' ? reusableBlock.content.raw : reusableBlock.content);
  9366. }, state => [getReusableBlocks(state)]);
  9367. /**
  9368. * Returns the title of a given reusable block
  9369. *
  9370. * @param {Object} state Global application state.
  9371. * @param {number|string} ref The shared block's ID.
  9372. *
  9373. * @return {string} The reusable block saved title.
  9374. */
  9375. const selectors_experimentalGetReusableBlockTitle = Object(rememo["a" /* default */])((state, ref) => {
  9376. var _reusableBlock$title;
  9377. const reusableBlock = Object(external_lodash_["find"])(getReusableBlocks(state), block => block.id === ref);
  9378. if (!reusableBlock) {
  9379. return null;
  9380. }
  9381. return (_reusableBlock$title = reusableBlock.title) === null || _reusableBlock$title === void 0 ? void 0 : _reusableBlock$title.raw;
  9382. }, state => [getReusableBlocks(state)]);
  9383. /**
  9384. * Returns true if the most recent block change is be considered ignored, or
  9385. * false otherwise. An ignored change is one not to be committed by
  9386. * BlockEditorProvider, neither via `onChange` nor `onInput`.
  9387. *
  9388. * @param {Object} state Block editor state.
  9389. *
  9390. * @return {boolean} Whether the most recent block change was ignored.
  9391. */
  9392. function selectors_unstableIsLastBlockChangeIgnored(state) {
  9393. // TODO: Removal Plan: Changes incurred by RECEIVE_BLOCKS should not be
  9394. // ignored if in-fact they result in a change in blocks state. The current
  9395. // need to ignore changes not a result of user interaction should be
  9396. // accounted for in the refactoring of reusable blocks as occurring within
  9397. // their own separate block editor / state (#7119).
  9398. return state.blocks.isIgnoredChange;
  9399. }
  9400. /**
  9401. * Returns the block attributes changed as a result of the last dispatched
  9402. * action.
  9403. *
  9404. * @param {Object} state Block editor state.
  9405. *
  9406. * @return {Object<string,Object>} Subsets of block attributes changed, keyed
  9407. * by block client ID.
  9408. */
  9409. function __experimentalGetLastBlockAttributeChanges(state) {
  9410. return state.lastBlockAttributesChange;
  9411. }
  9412. /**
  9413. * Returns the available reusable blocks
  9414. *
  9415. * @param {Object} state Global application state.
  9416. *
  9417. * @return {Array} Reusable blocks
  9418. */
  9419. function getReusableBlocks(state) {
  9420. var _state$settings$__exp, _state$settings;
  9421. return (_state$settings$__exp = state === null || state === void 0 ? void 0 : (_state$settings = state.settings) === null || _state$settings === void 0 ? void 0 : _state$settings.__experimentalReusableBlocks) !== null && _state$settings$__exp !== void 0 ? _state$settings$__exp : EMPTY_ARRAY;
  9422. }
  9423. /**
  9424. * Returns whether the navigation mode is enabled.
  9425. *
  9426. * @param {Object} state Editor state.
  9427. *
  9428. * @return {boolean} Is navigation mode enabled.
  9429. */
  9430. function selectors_isNavigationMode(state) {
  9431. return state.isNavigationMode;
  9432. }
  9433. /**
  9434. * Returns whether block moving mode is enabled.
  9435. *
  9436. * @param {Object} state Editor state.
  9437. *
  9438. * @return {string} Client Id of moving block.
  9439. */
  9440. function selectors_hasBlockMovingClientId(state) {
  9441. return state.hasBlockMovingClientId;
  9442. }
  9443. /**
  9444. * Returns true if the last change was an automatic change, false otherwise.
  9445. *
  9446. * @param {Object} state Global application state.
  9447. *
  9448. * @return {boolean} Whether the last change was automatic.
  9449. */
  9450. function selectors_didAutomaticChange(state) {
  9451. return !!state.automaticChangeStatus;
  9452. }
  9453. /**
  9454. * Returns true if the current highlighted block matches the block clientId.
  9455. *
  9456. * @param {Object} state Global application state.
  9457. * @param {string} clientId The block to check.
  9458. *
  9459. * @return {boolean} Whether the block is currently highlighted.
  9460. */
  9461. function selectors_isBlockHighlighted(state, clientId) {
  9462. return state.highlightedBlock === clientId;
  9463. }
  9464. /**
  9465. * Checks if a given block has controlled inner blocks.
  9466. *
  9467. * @param {Object} state Global application state.
  9468. * @param {string} clientId The block to check.
  9469. *
  9470. * @return {boolean} True if the block has controlled inner blocks.
  9471. */
  9472. function areInnerBlocksControlled(state, clientId) {
  9473. return !!state.blocks.controlledInnerBlocks[clientId];
  9474. }
  9475. /**
  9476. * Returns the clientId for the first 'active' block of a given array of block names.
  9477. * A block is 'active' if it (or a child) is the selected block.
  9478. * Returns the first match moving up the DOM from the selected block.
  9479. *
  9480. * @param {Object} state Global application state.
  9481. * @param {string[]} validBlocksNames The names of block types to check for.
  9482. *
  9483. * @return {string} The matching block's clientId.
  9484. */
  9485. const __experimentalGetActiveBlockIdByBlockNames = Object(rememo["a" /* default */])((state, validBlockNames) => {
  9486. if (!validBlockNames.length) {
  9487. return null;
  9488. } // Check if selected block is a valid entity area.
  9489. const selectedBlockClientId = selectors_getSelectedBlockClientId(state);
  9490. if (validBlockNames.includes(selectors_getBlockName(state, selectedBlockClientId))) {
  9491. return selectedBlockClientId;
  9492. } // Check if first selected block is a child of a valid entity area.
  9493. const multiSelectedBlockClientIds = selectors_getMultiSelectedBlockClientIds(state);
  9494. const entityAreaParents = getBlockParentsByBlockName(state, selectedBlockClientId || multiSelectedBlockClientIds[0], validBlockNames);
  9495. if (entityAreaParents) {
  9496. // Last parent closest/most interior.
  9497. return Object(external_lodash_["last"])(entityAreaParents);
  9498. }
  9499. return null;
  9500. }, (state, validBlockNames) => [state.selection.selectionStart.clientId, state.selection.selectionEnd.clientId, validBlockNames]);
  9501. /**
  9502. * Tells if the block with the passed clientId was just inserted.
  9503. *
  9504. * @param {Object} state Global application state.
  9505. * @param {Object} clientId Client Id of the block.
  9506. * @param {?string} source Optional insertion source of the block.
  9507. * @return {boolean} True if the block matches the last block inserted from the specified source.
  9508. */
  9509. function wasBlockJustInserted(state, clientId, source) {
  9510. const {
  9511. lastBlockInserted
  9512. } = state;
  9513. return lastBlockInserted.clientId === clientId && lastBlockInserted.source === source;
  9514. }
  9515. // EXTERNAL MODULE: external ["wp","a11y"]
  9516. var external_wp_a11y_ = __webpack_require__("gdqT");
  9517. // EXTERNAL MODULE: external ["wp","deprecated"]
  9518. var external_wp_deprecated_ = __webpack_require__("NMb1");
  9519. var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_);
  9520. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/controls.js
  9521. /**
  9522. * WordPress dependencies
  9523. */
  9524. /**
  9525. * Internal dependencies
  9526. */
  9527. const __unstableMarkAutomaticChangeFinalControl = function () {
  9528. return {
  9529. type: 'MARK_AUTOMATIC_CHANGE_FINAL_CONTROL'
  9530. };
  9531. };
  9532. const controls_controls = {
  9533. SLEEP({
  9534. duration
  9535. }) {
  9536. return new Promise(resolve => {
  9537. setTimeout(resolve, duration);
  9538. });
  9539. },
  9540. MARK_AUTOMATIC_CHANGE_FINAL_CONTROL: Object(external_wp_data_["createRegistryControl"])(registry => () => {
  9541. const {
  9542. requestIdleCallback = callback => setTimeout(callback, 100)
  9543. } = window;
  9544. requestIdleCallback(() => registry.dispatch(store).__unstableMarkAutomaticChangeFinal());
  9545. })
  9546. };
  9547. /* harmony default export */ var store_controls = (controls_controls);
  9548. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/constants.js
  9549. const STORE_NAME = 'core/block-editor';
  9550. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/actions.js
  9551. /**
  9552. * External dependencies
  9553. */
  9554. /**
  9555. * WordPress dependencies
  9556. */
  9557. /**
  9558. * Internal dependencies
  9559. */
  9560. /**
  9561. * Generator which will yield a default block insert action if there
  9562. * are no other blocks at the root of the editor. This generator should be used
  9563. * in actions which may result in no blocks remaining in the editor (removal,
  9564. * replacement, etc).
  9565. */
  9566. function* ensureDefaultBlock() {
  9567. const count = yield external_wp_data_["controls"].select(STORE_NAME, 'getBlockCount'); // To avoid a focus loss when removing the last block, assure there is
  9568. // always a default block if the last of the blocks have been removed.
  9569. if (count === 0) {
  9570. const {
  9571. __unstableHasCustomAppender
  9572. } = yield external_wp_data_["controls"].select(STORE_NAME, 'getSettings'); // If there's an custom appender, don't insert default block.
  9573. // We have to remember to manually move the focus elsewhere to
  9574. // prevent it from being lost though.
  9575. if (__unstableHasCustomAppender) {
  9576. return;
  9577. }
  9578. return yield actions_insertDefaultBlock();
  9579. }
  9580. }
  9581. /**
  9582. * Returns an action object used in signalling that blocks state should be
  9583. * reset to the specified array of blocks, taking precedence over any other
  9584. * content reflected as an edit in state.
  9585. *
  9586. * @param {Array} blocks Array of blocks.
  9587. */
  9588. function* actions_resetBlocks(blocks) {
  9589. yield {
  9590. type: 'RESET_BLOCKS',
  9591. blocks
  9592. };
  9593. return yield* validateBlocksToTemplate(blocks);
  9594. }
  9595. /**
  9596. * Block validity is a function of blocks state (at the point of a
  9597. * reset) and the template setting. As a compromise to its placement
  9598. * across distinct parts of state, it is implemented here as a side-
  9599. * effect of the block reset action.
  9600. *
  9601. * @param {Array} blocks Array of blocks.
  9602. */
  9603. function* validateBlocksToTemplate(blocks) {
  9604. const template = yield external_wp_data_["controls"].select(STORE_NAME, 'getTemplate');
  9605. const templateLock = yield external_wp_data_["controls"].select(STORE_NAME, 'getTemplateLock'); // Unlocked templates are considered always valid because they act
  9606. // as default values only.
  9607. const isBlocksValidToTemplate = !template || templateLock !== 'all' || Object(external_wp_blocks_["doBlocksMatchTemplate"])(blocks, template); // Update if validity has changed.
  9608. const isValidTemplate = yield external_wp_data_["controls"].select(STORE_NAME, 'isValidTemplate');
  9609. if (isBlocksValidToTemplate !== isValidTemplate) {
  9610. yield setTemplateValidity(isBlocksValidToTemplate);
  9611. return isBlocksValidToTemplate;
  9612. }
  9613. }
  9614. /**
  9615. * A block selection object.
  9616. *
  9617. * @typedef {Object} WPBlockSelection
  9618. *
  9619. * @property {string} clientId A block client ID.
  9620. * @property {string} attributeKey A block attribute key.
  9621. * @property {number} offset An attribute value offset, based on the rich
  9622. * text value. See `wp.richText.create`.
  9623. */
  9624. /**
  9625. * Returns an action object used in signalling that selection state should be
  9626. * reset to the specified selection.
  9627. *
  9628. * @param {WPBlockSelection} selectionStart The selection start.
  9629. * @param {WPBlockSelection} selectionEnd The selection end.
  9630. * @param {0|-1|null} initialPosition Initial block position.
  9631. *
  9632. * @return {Object} Action object.
  9633. */
  9634. function actions_resetSelection(selectionStart, selectionEnd, initialPosition) {
  9635. return {
  9636. type: 'RESET_SELECTION',
  9637. selectionStart,
  9638. selectionEnd,
  9639. initialPosition
  9640. };
  9641. }
  9642. /**
  9643. * Returns an action object used in signalling that blocks have been received.
  9644. * Unlike resetBlocks, these should be appended to the existing known set, not
  9645. * replacing.
  9646. *
  9647. * @param {Object[]} blocks Array of block objects.
  9648. *
  9649. * @return {Object} Action object.
  9650. */
  9651. function receiveBlocks(blocks) {
  9652. return {
  9653. type: 'RECEIVE_BLOCKS',
  9654. blocks
  9655. };
  9656. }
  9657. /**
  9658. * Returns an action object used in signalling that the multiple blocks'
  9659. * attributes with the specified client IDs have been updated.
  9660. *
  9661. * @param {string|string[]} clientIds Block client IDs.
  9662. * @param {Object} attributes Block attributes to be merged. Should be keyed by clientIds if
  9663. * uniqueByBlock is true.
  9664. * @param {boolean} uniqueByBlock true if each block in clientIds array has a unique set of attributes
  9665. * @return {Object} Action object.
  9666. */
  9667. function actions_updateBlockAttributes(clientIds, attributes, uniqueByBlock = false) {
  9668. return {
  9669. type: 'UPDATE_BLOCK_ATTRIBUTES',
  9670. clientIds: Object(external_lodash_["castArray"])(clientIds),
  9671. attributes,
  9672. uniqueByBlock
  9673. };
  9674. }
  9675. /**
  9676. * Returns an action object used in signalling that the block with the
  9677. * specified client ID has been updated.
  9678. *
  9679. * @param {string} clientId Block client ID.
  9680. * @param {Object} updates Block attributes to be merged.
  9681. *
  9682. * @return {Object} Action object.
  9683. */
  9684. function actions_updateBlock(clientId, updates) {
  9685. return {
  9686. type: 'UPDATE_BLOCK',
  9687. clientId,
  9688. updates
  9689. };
  9690. }
  9691. /**
  9692. * Returns an action object used in signalling that the block with the
  9693. * specified client ID has been selected, optionally accepting a position
  9694. * value reflecting its selection directionality. An initialPosition of -1
  9695. * reflects a reverse selection.
  9696. *
  9697. * @param {string} clientId Block client ID.
  9698. * @param {0|-1|null} initialPosition Optional initial position. Pass as -1 to
  9699. * reflect reverse selection.
  9700. *
  9701. * @return {Object} Action object.
  9702. */
  9703. function actions_selectBlock(clientId, initialPosition = 0) {
  9704. return {
  9705. type: 'SELECT_BLOCK',
  9706. initialPosition,
  9707. clientId
  9708. };
  9709. }
  9710. /**
  9711. * Yields action objects used in signalling that the block preceding the given
  9712. * clientId should be selected.
  9713. *
  9714. * @param {string} clientId Block client ID.
  9715. */
  9716. function* selectPreviousBlock(clientId) {
  9717. const previousBlockClientId = yield external_wp_data_["controls"].select(STORE_NAME, 'getPreviousBlockClientId', clientId);
  9718. if (previousBlockClientId) {
  9719. yield actions_selectBlock(previousBlockClientId, -1);
  9720. return [previousBlockClientId];
  9721. }
  9722. }
  9723. /**
  9724. * Yields action objects used in signalling that the block following the given
  9725. * clientId should be selected.
  9726. *
  9727. * @param {string} clientId Block client ID.
  9728. */
  9729. function* selectNextBlock(clientId) {
  9730. const nextBlockClientId = yield external_wp_data_["controls"].select(STORE_NAME, 'getNextBlockClientId', clientId);
  9731. if (nextBlockClientId) {
  9732. yield actions_selectBlock(nextBlockClientId);
  9733. return [nextBlockClientId];
  9734. }
  9735. }
  9736. /**
  9737. * Returns an action object used in signalling that a block multi-selection has started.
  9738. *
  9739. * @return {Object} Action object.
  9740. */
  9741. function actions_startMultiSelect() {
  9742. return {
  9743. type: 'START_MULTI_SELECT'
  9744. };
  9745. }
  9746. /**
  9747. * Returns an action object used in signalling that block multi-selection stopped.
  9748. *
  9749. * @return {Object} Action object.
  9750. */
  9751. function actions_stopMultiSelect() {
  9752. return {
  9753. type: 'STOP_MULTI_SELECT'
  9754. };
  9755. }
  9756. /**
  9757. * Returns an action object used in signalling that block multi-selection changed.
  9758. *
  9759. * @param {string} start First block of the multi selection.
  9760. * @param {string} end Last block of the multiselection.
  9761. */
  9762. function* actions_multiSelect(start, end) {
  9763. const startBlockRootClientId = yield external_wp_data_["controls"].select(STORE_NAME, 'getBlockRootClientId', start);
  9764. const endBlockRootClientId = yield external_wp_data_["controls"].select(STORE_NAME, 'getBlockRootClientId', end); // Only allow block multi-selections at the same level.
  9765. if (startBlockRootClientId !== endBlockRootClientId) {
  9766. return;
  9767. }
  9768. yield {
  9769. type: 'MULTI_SELECT',
  9770. start,
  9771. end
  9772. };
  9773. const blockCount = yield external_wp_data_["controls"].select(STORE_NAME, 'getSelectedBlockCount');
  9774. Object(external_wp_a11y_["speak"])(Object(external_wp_i18n_["sprintf"])(
  9775. /* translators: %s: number of selected blocks */
  9776. Object(external_wp_i18n_["_n"])('%s block selected.', '%s blocks selected.', blockCount), blockCount), 'assertive');
  9777. }
  9778. /**
  9779. * Returns an action object used in signalling that the block selection is cleared.
  9780. *
  9781. * @return {Object} Action object.
  9782. */
  9783. function actions_clearSelectedBlock() {
  9784. return {
  9785. type: 'CLEAR_SELECTED_BLOCK'
  9786. };
  9787. }
  9788. /**
  9789. * Returns an action object that enables or disables block selection.
  9790. *
  9791. * @param {boolean} [isSelectionEnabled=true] Whether block selection should
  9792. * be enabled.
  9793. *
  9794. * @return {Object} Action object.
  9795. */
  9796. function actions_toggleSelection(isSelectionEnabled = true) {
  9797. return {
  9798. type: 'TOGGLE_SELECTION',
  9799. isSelectionEnabled
  9800. };
  9801. }
  9802. function getBlocksWithDefaultStylesApplied(blocks, blockEditorSettings) {
  9803. var _blockEditorSettings$, _blockEditorSettings$2;
  9804. const preferredStyleVariations = (_blockEditorSettings$ = blockEditorSettings === null || blockEditorSettings === void 0 ? void 0 : (_blockEditorSettings$2 = blockEditorSettings.__experimentalPreferredStyleVariations) === null || _blockEditorSettings$2 === void 0 ? void 0 : _blockEditorSettings$2.value) !== null && _blockEditorSettings$ !== void 0 ? _blockEditorSettings$ : {};
  9805. return blocks.map(block => {
  9806. var _block$attributes;
  9807. const blockName = block.name;
  9808. if (!Object(external_wp_blocks_["hasBlockSupport"])(blockName, 'defaultStylePicker', true)) {
  9809. return block;
  9810. }
  9811. if (!preferredStyleVariations[blockName]) {
  9812. return block;
  9813. }
  9814. const className = (_block$attributes = block.attributes) === null || _block$attributes === void 0 ? void 0 : _block$attributes.className;
  9815. if (className !== null && className !== void 0 && className.includes('is-style-')) {
  9816. return block;
  9817. }
  9818. const {
  9819. attributes = {}
  9820. } = block;
  9821. const blockStyle = preferredStyleVariations[blockName];
  9822. return { ...block,
  9823. attributes: { ...attributes,
  9824. className: `${className || ''} is-style-${blockStyle}`.trim()
  9825. }
  9826. };
  9827. });
  9828. }
  9829. /**
  9830. * Returns an action object signalling that a blocks should be replaced with
  9831. * one or more replacement blocks.
  9832. *
  9833. * @param {(string|string[])} clientIds Block client ID(s) to replace.
  9834. * @param {(Object|Object[])} blocks Replacement block(s).
  9835. * @param {number} indexToSelect Index of replacement block to select.
  9836. * @param {0|-1|null} initialPosition Index of caret after in the selected block after the operation.
  9837. * @param {?Object} meta Optional Meta values to be passed to the action object.
  9838. *
  9839. * @yield {Object} Action object.
  9840. */
  9841. function* actions_replaceBlocks(clientIds, blocks, indexToSelect, initialPosition = 0, meta) {
  9842. clientIds = Object(external_lodash_["castArray"])(clientIds);
  9843. blocks = getBlocksWithDefaultStylesApplied(Object(external_lodash_["castArray"])(blocks), yield external_wp_data_["controls"].select(STORE_NAME, 'getSettings'));
  9844. const rootClientId = yield external_wp_data_["controls"].select(STORE_NAME, 'getBlockRootClientId', Object(external_lodash_["first"])(clientIds)); // Replace is valid if the new blocks can be inserted in the root block.
  9845. for (let index = 0; index < blocks.length; index++) {
  9846. const block = blocks[index];
  9847. const canInsertBlock = yield external_wp_data_["controls"].select(STORE_NAME, 'canInsertBlockType', block.name, rootClientId);
  9848. if (!canInsertBlock) {
  9849. return;
  9850. }
  9851. }
  9852. yield {
  9853. type: 'REPLACE_BLOCKS',
  9854. clientIds,
  9855. blocks,
  9856. time: Date.now(),
  9857. indexToSelect,
  9858. initialPosition,
  9859. meta
  9860. };
  9861. yield* ensureDefaultBlock();
  9862. }
  9863. /**
  9864. * Returns an action object signalling that a single block should be replaced
  9865. * with one or more replacement blocks.
  9866. *
  9867. * @param {(string|string[])} clientId Block client ID to replace.
  9868. * @param {(Object|Object[])} block Replacement block(s).
  9869. *
  9870. * @return {Object} Action object.
  9871. */
  9872. function actions_replaceBlock(clientId, block) {
  9873. return actions_replaceBlocks(clientId, block);
  9874. }
  9875. /**
  9876. * Higher-order action creator which, given the action type to dispatch creates
  9877. * an action creator for managing block movement.
  9878. *
  9879. * @param {string} type Action type to dispatch.
  9880. *
  9881. * @return {Function} Action creator.
  9882. */
  9883. function createOnMove(type) {
  9884. return (clientIds, rootClientId) => {
  9885. return {
  9886. clientIds: Object(external_lodash_["castArray"])(clientIds),
  9887. type,
  9888. rootClientId
  9889. };
  9890. };
  9891. }
  9892. const actions_moveBlocksDown = createOnMove('MOVE_BLOCKS_DOWN');
  9893. const actions_moveBlocksUp = createOnMove('MOVE_BLOCKS_UP');
  9894. /**
  9895. * Returns an action object signalling that the given blocks should be moved to
  9896. * a new position.
  9897. *
  9898. * @param {?string} clientIds The client IDs of the blocks.
  9899. * @param {?string} fromRootClientId Root client ID source.
  9900. * @param {?string} toRootClientId Root client ID destination.
  9901. * @param {number} index The index to move the blocks to.
  9902. *
  9903. * @yield {Object} Action object.
  9904. */
  9905. function* actions_moveBlocksToPosition(clientIds, fromRootClientId = '', toRootClientId = '', index) {
  9906. const templateLock = yield external_wp_data_["controls"].select(STORE_NAME, 'getTemplateLock', fromRootClientId); // If locking is equal to all on the original clientId (fromRootClientId),
  9907. // it is not possible to move the block to any other position.
  9908. if (templateLock === 'all') {
  9909. return;
  9910. }
  9911. const action = {
  9912. type: 'MOVE_BLOCKS_TO_POSITION',
  9913. fromRootClientId,
  9914. toRootClientId,
  9915. clientIds,
  9916. index
  9917. }; // If moving inside the same root block the move is always possible.
  9918. if (fromRootClientId === toRootClientId) {
  9919. yield action;
  9920. return;
  9921. } // If templateLock is insert we can not remove the block from the parent.
  9922. // Given that here we know that we are moving the block to a different
  9923. // parent, the move should not be possible if the condition is true.
  9924. if (templateLock === 'insert') {
  9925. return;
  9926. }
  9927. const canInsertBlocks = yield external_wp_data_["controls"].select(STORE_NAME, 'canInsertBlocks', clientIds, toRootClientId); // If moving to other parent block, the move is possible if we can insert a block of the same type inside the new parent block.
  9928. if (canInsertBlocks) {
  9929. yield action;
  9930. }
  9931. }
  9932. /**
  9933. * Returns an action object signalling that the given block should be moved to a
  9934. * new position.
  9935. *
  9936. * @param {?string} clientId The client ID of the block.
  9937. * @param {?string} fromRootClientId Root client ID source.
  9938. * @param {?string} toRootClientId Root client ID destination.
  9939. * @param {number} index The index to move the block to.
  9940. *
  9941. * @yield {Object} Action object.
  9942. */
  9943. function* actions_moveBlockToPosition(clientId, fromRootClientId = '', toRootClientId = '', index) {
  9944. yield actions_moveBlocksToPosition([clientId], fromRootClientId, toRootClientId, index);
  9945. }
  9946. /**
  9947. * Returns an action object used in signalling that a single block should be
  9948. * inserted, optionally at a specific index respective a root block list.
  9949. *
  9950. * @param {Object} block Block object to insert.
  9951. * @param {?number} index Index at which block should be inserted.
  9952. * @param {?string} rootClientId Optional root client ID of block list on which to insert.
  9953. * @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to true.
  9954. * @param {?Object} meta Optional Meta values to be passed to the action object.
  9955. *
  9956. * @return {Object} Action object.
  9957. */
  9958. function actions_insertBlock(block, index, rootClientId, updateSelection = true, meta) {
  9959. return actions_insertBlocks([block], index, rootClientId, updateSelection, 0, meta);
  9960. }
  9961. /**
  9962. * Returns an action object used in signalling that an array of blocks should
  9963. * be inserted, optionally at a specific index respective a root block list.
  9964. *
  9965. * @param {Object[]} blocks Block objects to insert.
  9966. * @param {?number} index Index at which block should be inserted.
  9967. * @param {?string} rootClientId Optional root client ID of block list on which to insert.
  9968. * @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to true.
  9969. * @param {0|-1|null} initialPosition Initial focus position. Setting it to null prevent focusing the inserted block.
  9970. * @param {?Object} meta Optional Meta values to be passed to the action object.
  9971. * @return {Object} Action object.
  9972. */
  9973. function* actions_insertBlocks(blocks, index, rootClientId, updateSelection = true, initialPosition = 0, meta) {
  9974. if (Object(external_lodash_["isObject"])(initialPosition)) {
  9975. meta = initialPosition;
  9976. initialPosition = 0;
  9977. external_wp_deprecated_default()("meta argument in wp.data.dispatch('core/block-editor')", {
  9978. since: '10.1',
  9979. plugin: 'Gutenberg',
  9980. hint: 'The meta argument is now the 6th argument of the function'
  9981. });
  9982. }
  9983. blocks = getBlocksWithDefaultStylesApplied(Object(external_lodash_["castArray"])(blocks), yield external_wp_data_["controls"].select(STORE_NAME, 'getSettings'));
  9984. const allowedBlocks = [];
  9985. for (const block of blocks) {
  9986. const isValid = yield external_wp_data_["controls"].select(STORE_NAME, 'canInsertBlockType', block.name, rootClientId);
  9987. if (isValid) {
  9988. allowedBlocks.push(block);
  9989. }
  9990. }
  9991. if (allowedBlocks.length) {
  9992. return {
  9993. type: 'INSERT_BLOCKS',
  9994. blocks: allowedBlocks,
  9995. index,
  9996. rootClientId,
  9997. time: Date.now(),
  9998. updateSelection,
  9999. initialPosition: updateSelection ? initialPosition : null,
  10000. meta
  10001. };
  10002. }
  10003. }
  10004. /**
  10005. * Returns an action object used in signalling that the insertion point should
  10006. * be shown.
  10007. *
  10008. * @param {?string} rootClientId Optional root client ID of block list on
  10009. * which to insert.
  10010. * @param {?number} index Index at which block should be inserted.
  10011. * @param {Object} __unstableOptions Wether or not to show an inserter button.
  10012. *
  10013. * @return {Object} Action object.
  10014. */
  10015. function actions_showInsertionPoint(rootClientId, index, __unstableOptions = {}) {
  10016. const {
  10017. __unstableWithInserter
  10018. } = __unstableOptions;
  10019. return {
  10020. type: 'SHOW_INSERTION_POINT',
  10021. rootClientId,
  10022. index,
  10023. __unstableWithInserter
  10024. };
  10025. }
  10026. /**
  10027. * Returns an action object hiding the insertion point.
  10028. *
  10029. * @return {Object} Action object.
  10030. */
  10031. function actions_hideInsertionPoint() {
  10032. return {
  10033. type: 'HIDE_INSERTION_POINT'
  10034. };
  10035. }
  10036. /**
  10037. * Returns an action object resetting the template validity.
  10038. *
  10039. * @param {boolean} isValid template validity flag.
  10040. *
  10041. * @return {Object} Action object.
  10042. */
  10043. function setTemplateValidity(isValid) {
  10044. return {
  10045. type: 'SET_TEMPLATE_VALIDITY',
  10046. isValid
  10047. };
  10048. }
  10049. /**
  10050. * Returns an action object synchronize the template with the list of blocks
  10051. *
  10052. * @return {Object} Action object.
  10053. */
  10054. function* synchronizeTemplate() {
  10055. yield {
  10056. type: 'SYNCHRONIZE_TEMPLATE'
  10057. };
  10058. const blocks = yield external_wp_data_["controls"].select(STORE_NAME, 'getBlocks');
  10059. const template = yield external_wp_data_["controls"].select(STORE_NAME, 'getTemplate');
  10060. const updatedBlockList = Object(external_wp_blocks_["synchronizeBlocksWithTemplate"])(blocks, template);
  10061. return yield actions_resetBlocks(updatedBlockList);
  10062. }
  10063. /**
  10064. * Returns an action object used in signalling that two blocks should be merged
  10065. *
  10066. * @param {string} firstBlockClientId Client ID of the first block to merge.
  10067. * @param {string} secondBlockClientId Client ID of the second block to merge.
  10068. */
  10069. function* actions_mergeBlocks(firstBlockClientId, secondBlockClientId) {
  10070. const blocks = [firstBlockClientId, secondBlockClientId];
  10071. yield {
  10072. type: 'MERGE_BLOCKS',
  10073. blocks
  10074. };
  10075. const [clientIdA, clientIdB] = blocks;
  10076. const blockA = yield external_wp_data_["controls"].select(STORE_NAME, 'getBlock', clientIdA);
  10077. const blockAType = Object(external_wp_blocks_["getBlockType"])(blockA.name); // Only focus the previous block if it's not mergeable
  10078. if (!blockAType.merge) {
  10079. yield actions_selectBlock(blockA.clientId);
  10080. return;
  10081. }
  10082. const blockB = yield external_wp_data_["controls"].select(STORE_NAME, 'getBlock', clientIdB);
  10083. const blockBType = Object(external_wp_blocks_["getBlockType"])(blockB.name);
  10084. const {
  10085. clientId,
  10086. attributeKey,
  10087. offset
  10088. } = yield external_wp_data_["controls"].select(STORE_NAME, 'getSelectionStart');
  10089. const selectedBlockType = clientId === clientIdA ? blockAType : blockBType;
  10090. const attributeDefinition = selectedBlockType.attributes[attributeKey];
  10091. const canRestoreTextSelection = (clientId === clientIdA || clientId === clientIdB) && attributeKey !== undefined && offset !== undefined && // We cannot restore text selection if the RichText identifier
  10092. // is not a defined block attribute key. This can be the case if the
  10093. // fallback intance ID is used to store selection (and no RichText
  10094. // identifier is set), or when the identifier is wrong.
  10095. !!attributeDefinition;
  10096. if (!attributeDefinition) {
  10097. if (typeof attributeKey === 'number') {
  10098. window.console.error(`RichText needs an identifier prop that is the block attribute key of the attribute it controls. Its type is expected to be a string, but was ${typeof attributeKey}`);
  10099. } else {
  10100. window.console.error('The RichText identifier prop does not match any attributes defined by the block.');
  10101. }
  10102. } // A robust way to retain selection position through various transforms
  10103. // is to insert a special character at the position and then recover it.
  10104. const START_OF_SELECTED_AREA = '\u0086'; // Clone the blocks so we don't insert the character in a "live" block.
  10105. const cloneA = Object(external_wp_blocks_["cloneBlock"])(blockA);
  10106. const cloneB = Object(external_wp_blocks_["cloneBlock"])(blockB);
  10107. if (canRestoreTextSelection) {
  10108. const selectedBlock = clientId === clientIdA ? cloneA : cloneB;
  10109. const html = selectedBlock.attributes[attributeKey];
  10110. const {
  10111. multiline: multilineTag,
  10112. __unstableMultilineWrapperTags: multilineWrapperTags,
  10113. __unstablePreserveWhiteSpace: preserveWhiteSpace
  10114. } = attributeDefinition;
  10115. const value = Object(external_wp_richText_["insert"])(Object(external_wp_richText_["create"])({
  10116. html,
  10117. multilineTag,
  10118. multilineWrapperTags,
  10119. preserveWhiteSpace
  10120. }), START_OF_SELECTED_AREA, offset, offset);
  10121. selectedBlock.attributes[attributeKey] = Object(external_wp_richText_["toHTMLString"])({
  10122. value,
  10123. multilineTag,
  10124. preserveWhiteSpace
  10125. });
  10126. } // We can only merge blocks with similar types
  10127. // thus, we transform the block to merge first
  10128. const blocksWithTheSameType = blockA.name === blockB.name ? [cloneB] : Object(external_wp_blocks_["switchToBlockType"])(cloneB, blockA.name); // If the block types can not match, do nothing
  10129. if (!blocksWithTheSameType || !blocksWithTheSameType.length) {
  10130. return;
  10131. } // Calling the merge to update the attributes and remove the block to be merged
  10132. const updatedAttributes = blockAType.merge(cloneA.attributes, blocksWithTheSameType[0].attributes);
  10133. if (canRestoreTextSelection) {
  10134. const newAttributeKey = Object(external_lodash_["findKey"])(updatedAttributes, v => typeof v === 'string' && v.indexOf(START_OF_SELECTED_AREA) !== -1);
  10135. const convertedHtml = updatedAttributes[newAttributeKey];
  10136. const {
  10137. multiline: multilineTag,
  10138. __unstableMultilineWrapperTags: multilineWrapperTags,
  10139. __unstablePreserveWhiteSpace: preserveWhiteSpace
  10140. } = blockAType.attributes[newAttributeKey];
  10141. const convertedValue = Object(external_wp_richText_["create"])({
  10142. html: convertedHtml,
  10143. multilineTag,
  10144. multilineWrapperTags,
  10145. preserveWhiteSpace
  10146. });
  10147. const newOffset = convertedValue.text.indexOf(START_OF_SELECTED_AREA);
  10148. const newValue = Object(external_wp_richText_["remove"])(convertedValue, newOffset, newOffset + 1);
  10149. const newHtml = Object(external_wp_richText_["toHTMLString"])({
  10150. value: newValue,
  10151. multilineTag,
  10152. preserveWhiteSpace
  10153. });
  10154. updatedAttributes[newAttributeKey] = newHtml;
  10155. yield actions_selectionChange(blockA.clientId, newAttributeKey, newOffset, newOffset);
  10156. }
  10157. yield* actions_replaceBlocks([blockA.clientId, blockB.clientId], [{ ...blockA,
  10158. attributes: { ...blockA.attributes,
  10159. ...updatedAttributes
  10160. }
  10161. }, ...blocksWithTheSameType.slice(1)]);
  10162. }
  10163. /**
  10164. * Yields action objects used in signalling that the blocks corresponding to
  10165. * the set of specified client IDs are to be removed.
  10166. *
  10167. * @param {string|string[]} clientIds Client IDs of blocks to remove.
  10168. * @param {boolean} selectPrevious True if the previous block should be
  10169. * selected when a block is removed.
  10170. */
  10171. function* actions_removeBlocks(clientIds, selectPrevious = true) {
  10172. if (!clientIds || !clientIds.length) {
  10173. return;
  10174. }
  10175. clientIds = Object(external_lodash_["castArray"])(clientIds);
  10176. const rootClientId = yield external_wp_data_["controls"].select(STORE_NAME, 'getBlockRootClientId', clientIds[0]);
  10177. const isLocked = yield external_wp_data_["controls"].select(STORE_NAME, 'getTemplateLock', rootClientId);
  10178. if (isLocked) {
  10179. return;
  10180. }
  10181. let previousBlockId;
  10182. if (selectPrevious) {
  10183. previousBlockId = yield selectPreviousBlock(clientIds[0]);
  10184. } else {
  10185. previousBlockId = yield external_wp_data_["controls"].select(STORE_NAME, 'getPreviousBlockClientId', clientIds[0]);
  10186. }
  10187. yield {
  10188. type: 'REMOVE_BLOCKS',
  10189. clientIds
  10190. }; // To avoid a focus loss when removing the last block, assure there is
  10191. // always a default block if the last of the blocks have been removed.
  10192. const defaultBlockId = yield* ensureDefaultBlock();
  10193. return [previousBlockId || defaultBlockId];
  10194. }
  10195. /**
  10196. * Returns an action object used in signalling that the block with the
  10197. * specified client ID is to be removed.
  10198. *
  10199. * @param {string} clientId Client ID of block to remove.
  10200. * @param {boolean} selectPrevious True if the previous block should be
  10201. * selected when a block is removed.
  10202. *
  10203. * @return {Object} Action object.
  10204. */
  10205. function actions_removeBlock(clientId, selectPrevious) {
  10206. return actions_removeBlocks([clientId], selectPrevious);
  10207. }
  10208. /**
  10209. * Returns an action object used in signalling that the inner blocks with the
  10210. * specified client ID should be replaced.
  10211. *
  10212. * @param {string} rootClientId Client ID of the block whose InnerBlocks will re replaced.
  10213. * @param {Object[]} blocks Block objects to insert as new InnerBlocks
  10214. * @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to false.
  10215. * @param {0|-1|null} initialPosition Initial block position.
  10216. * @return {Object} Action object.
  10217. */
  10218. function actions_replaceInnerBlocks(rootClientId, blocks, updateSelection = false, initialPosition = 0) {
  10219. return {
  10220. type: 'REPLACE_INNER_BLOCKS',
  10221. rootClientId,
  10222. blocks,
  10223. updateSelection,
  10224. initialPosition: updateSelection ? initialPosition : null,
  10225. time: Date.now()
  10226. };
  10227. }
  10228. /**
  10229. * Returns an action object used to toggle the block editing mode between
  10230. * visual and HTML modes.
  10231. *
  10232. * @param {string} clientId Block client ID.
  10233. *
  10234. * @return {Object} Action object.
  10235. */
  10236. function toggleBlockMode(clientId) {
  10237. return {
  10238. type: 'TOGGLE_BLOCK_MODE',
  10239. clientId
  10240. };
  10241. }
  10242. /**
  10243. * Returns an action object used in signalling that the user has begun to type.
  10244. *
  10245. * @return {Object} Action object.
  10246. */
  10247. function actions_startTyping() {
  10248. return {
  10249. type: 'START_TYPING'
  10250. };
  10251. }
  10252. /**
  10253. * Returns an action object used in signalling that the user has stopped typing.
  10254. *
  10255. * @return {Object} Action object.
  10256. */
  10257. function actions_stopTyping() {
  10258. return {
  10259. type: 'STOP_TYPING'
  10260. };
  10261. }
  10262. /**
  10263. * Returns an action object used in signalling that the user has begun to drag blocks.
  10264. *
  10265. * @param {string[]} clientIds An array of client ids being dragged
  10266. *
  10267. * @return {Object} Action object.
  10268. */
  10269. function actions_startDraggingBlocks(clientIds = []) {
  10270. return {
  10271. type: 'START_DRAGGING_BLOCKS',
  10272. clientIds
  10273. };
  10274. }
  10275. /**
  10276. * Returns an action object used in signalling that the user has stopped dragging blocks.
  10277. *
  10278. * @return {Object} Action object.
  10279. */
  10280. function actions_stopDraggingBlocks() {
  10281. return {
  10282. type: 'STOP_DRAGGING_BLOCKS'
  10283. };
  10284. }
  10285. /**
  10286. * Returns an action object used in signalling that the caret has entered formatted text.
  10287. *
  10288. * @return {Object} Action object.
  10289. */
  10290. function actions_enterFormattedText() {
  10291. return {
  10292. type: 'ENTER_FORMATTED_TEXT'
  10293. };
  10294. }
  10295. /**
  10296. * Returns an action object used in signalling that the user caret has exited formatted text.
  10297. *
  10298. * @return {Object} Action object.
  10299. */
  10300. function actions_exitFormattedText() {
  10301. return {
  10302. type: 'EXIT_FORMATTED_TEXT'
  10303. };
  10304. }
  10305. /**
  10306. * Returns an action object used in signalling that the user caret has changed
  10307. * position.
  10308. *
  10309. * @param {string} clientId The selected block client ID.
  10310. * @param {string} attributeKey The selected block attribute key.
  10311. * @param {number} startOffset The start offset.
  10312. * @param {number} endOffset The end offset.
  10313. *
  10314. * @return {Object} Action object.
  10315. */
  10316. function actions_selectionChange(clientId, attributeKey, startOffset, endOffset) {
  10317. return {
  10318. type: 'SELECTION_CHANGE',
  10319. clientId,
  10320. attributeKey,
  10321. startOffset,
  10322. endOffset
  10323. };
  10324. }
  10325. /**
  10326. * Returns an action object used in signalling that a new block of the default
  10327. * type should be added to the block list.
  10328. *
  10329. * @param {?Object} attributes Optional attributes of the block to assign.
  10330. * @param {?string} rootClientId Optional root client ID of block list on which
  10331. * to append.
  10332. * @param {?number} index Optional index where to insert the default block
  10333. *
  10334. * @return {Object} Action object
  10335. */
  10336. function actions_insertDefaultBlock(attributes, rootClientId, index) {
  10337. // Abort if there is no default block type (if it has been unregistered).
  10338. const defaultBlockName = Object(external_wp_blocks_["getDefaultBlockName"])();
  10339. if (!defaultBlockName) {
  10340. return;
  10341. }
  10342. const block = Object(external_wp_blocks_["createBlock"])(defaultBlockName, attributes);
  10343. return actions_insertBlock(block, index, rootClientId);
  10344. }
  10345. /**
  10346. * Returns an action object that changes the nested settings of a given block.
  10347. *
  10348. * @param {string} clientId Client ID of the block whose nested setting are
  10349. * being received.
  10350. * @param {Object} settings Object with the new settings for the nested block.
  10351. *
  10352. * @return {Object} Action object
  10353. */
  10354. function actions_updateBlockListSettings(clientId, settings) {
  10355. return {
  10356. type: 'UPDATE_BLOCK_LIST_SETTINGS',
  10357. clientId,
  10358. settings
  10359. };
  10360. }
  10361. /**
  10362. * Returns an action object used in signalling that the block editor settings have been updated.
  10363. *
  10364. * @param {Object} settings Updated settings
  10365. *
  10366. * @return {Object} Action object
  10367. */
  10368. function actions_updateSettings(settings) {
  10369. return {
  10370. type: 'UPDATE_SETTINGS',
  10371. settings
  10372. };
  10373. }
  10374. /**
  10375. * Returns an action object used in signalling that a temporary reusable blocks have been saved
  10376. * in order to switch its temporary id with the real id.
  10377. *
  10378. * @param {string} id Reusable block's id.
  10379. * @param {string} updatedId Updated block's id.
  10380. *
  10381. * @return {Object} Action object.
  10382. */
  10383. function __unstableSaveReusableBlock(id, updatedId) {
  10384. return {
  10385. type: 'SAVE_REUSABLE_BLOCK_SUCCESS',
  10386. id,
  10387. updatedId
  10388. };
  10389. }
  10390. /**
  10391. * Returns an action object used in signalling that the last block change should be marked explicitly as persistent.
  10392. *
  10393. * @return {Object} Action object.
  10394. */
  10395. function actions_unstableMarkLastChangeAsPersistent() {
  10396. return {
  10397. type: 'MARK_LAST_CHANGE_AS_PERSISTENT'
  10398. };
  10399. }
  10400. /**
  10401. * Returns an action object used in signalling that the next block change should be marked explicitly as not persistent.
  10402. *
  10403. * @return {Object} Action object.
  10404. */
  10405. function actions_unstableMarkNextChangeAsNotPersistent() {
  10406. return {
  10407. type: 'MARK_NEXT_CHANGE_AS_NOT_PERSISTENT'
  10408. };
  10409. }
  10410. /**
  10411. * Returns an action object used in signalling that the last block change is
  10412. * an automatic change, meaning it was not performed by the user, and can be
  10413. * undone using the `Escape` and `Backspace` keys. This action must be called
  10414. * after the change was made, and any actions that are a consequence of it, so
  10415. * it is recommended to be called at the next idle period to ensure all
  10416. * selection changes have been recorded.
  10417. */
  10418. function* actions_unstableMarkAutomaticChange() {
  10419. yield {
  10420. type: 'MARK_AUTOMATIC_CHANGE'
  10421. };
  10422. yield __unstableMarkAutomaticChangeFinalControl();
  10423. }
  10424. function __unstableMarkAutomaticChangeFinal() {
  10425. return {
  10426. type: 'MARK_AUTOMATIC_CHANGE_FINAL'
  10427. };
  10428. }
  10429. /**
  10430. * Generators that triggers an action used to enable or disable the navigation mode.
  10431. *
  10432. * @param {string} isNavigationMode Enable/Disable navigation mode.
  10433. */
  10434. function* actions_setNavigationMode(isNavigationMode = true) {
  10435. yield {
  10436. type: 'SET_NAVIGATION_MODE',
  10437. isNavigationMode
  10438. };
  10439. if (isNavigationMode) {
  10440. Object(external_wp_a11y_["speak"])(Object(external_wp_i18n_["__"])('You are currently in navigation mode. Navigate blocks using the Tab key and Arrow keys. Use Left and Right Arrow keys to move between nesting levels. To exit navigation mode and edit the selected block, press Enter.'));
  10441. } else {
  10442. Object(external_wp_a11y_["speak"])(Object(external_wp_i18n_["__"])('You are currently in edit mode. To return to the navigation mode, press Escape.'));
  10443. }
  10444. }
  10445. /**
  10446. * Generator that triggers an action used to enable or disable the block moving mode.
  10447. *
  10448. * @param {string|null} hasBlockMovingClientId Enable/Disable block moving mode.
  10449. */
  10450. function* actions_setBlockMovingClientId(hasBlockMovingClientId = null) {
  10451. yield {
  10452. type: 'SET_BLOCK_MOVING_MODE',
  10453. hasBlockMovingClientId
  10454. };
  10455. if (hasBlockMovingClientId) {
  10456. Object(external_wp_a11y_["speak"])(Object(external_wp_i18n_["__"])('Use the Tab key and Arrow keys to choose new block location. Use Left and Right Arrow keys to move between nesting levels. Once location is selected press Enter or Space to move the block.'));
  10457. }
  10458. }
  10459. /**
  10460. * Generator that triggers an action used to duplicate a list of blocks.
  10461. *
  10462. * @param {string[]} clientIds
  10463. * @param {boolean} updateSelection
  10464. */
  10465. function* actions_duplicateBlocks(clientIds, updateSelection = true) {
  10466. if (!clientIds && !clientIds.length) {
  10467. return;
  10468. }
  10469. const blocks = yield external_wp_data_["controls"].select(STORE_NAME, 'getBlocksByClientId', clientIds);
  10470. const rootClientId = yield external_wp_data_["controls"].select(STORE_NAME, 'getBlockRootClientId', clientIds[0]); // Return early if blocks don't exist.
  10471. if (Object(external_lodash_["some"])(blocks, block => !block)) {
  10472. return;
  10473. }
  10474. const blockNames = blocks.map(block => block.name); // Return early if blocks don't support multiple usage.
  10475. if (Object(external_lodash_["some"])(blockNames, blockName => !Object(external_wp_blocks_["hasBlockSupport"])(blockName, 'multiple', true))) {
  10476. return;
  10477. }
  10478. const lastSelectedIndex = yield external_wp_data_["controls"].select(STORE_NAME, 'getBlockIndex', Object(external_lodash_["last"])(Object(external_lodash_["castArray"])(clientIds)), rootClientId);
  10479. const clonedBlocks = blocks.map(block => Object(external_wp_blocks_["__experimentalCloneSanitizedBlock"])(block));
  10480. yield actions_insertBlocks(clonedBlocks, lastSelectedIndex + 1, rootClientId, updateSelection);
  10481. if (clonedBlocks.length > 1 && updateSelection) {
  10482. yield actions_multiSelect(Object(external_lodash_["first"])(clonedBlocks).clientId, Object(external_lodash_["last"])(clonedBlocks).clientId);
  10483. }
  10484. return clonedBlocks.map(block => block.clientId);
  10485. }
  10486. /**
  10487. * Generator used to insert an empty block after a given block.
  10488. *
  10489. * @param {string} clientId
  10490. */
  10491. function* actions_insertBeforeBlock(clientId) {
  10492. if (!clientId) {
  10493. return;
  10494. }
  10495. const rootClientId = yield external_wp_data_["controls"].select(STORE_NAME, 'getBlockRootClientId', clientId);
  10496. const isLocked = yield external_wp_data_["controls"].select(STORE_NAME, 'getTemplateLock', rootClientId);
  10497. if (isLocked) {
  10498. return;
  10499. }
  10500. const firstSelectedIndex = yield external_wp_data_["controls"].select(STORE_NAME, 'getBlockIndex', clientId, rootClientId);
  10501. return yield actions_insertDefaultBlock({}, rootClientId, firstSelectedIndex);
  10502. }
  10503. /**
  10504. * Generator used to insert an empty block before a given block.
  10505. *
  10506. * @param {string} clientId
  10507. */
  10508. function* actions_insertAfterBlock(clientId) {
  10509. if (!clientId) {
  10510. return;
  10511. }
  10512. const rootClientId = yield external_wp_data_["controls"].select(STORE_NAME, 'getBlockRootClientId', clientId);
  10513. const isLocked = yield external_wp_data_["controls"].select(STORE_NAME, 'getTemplateLock', rootClientId);
  10514. if (isLocked) {
  10515. return;
  10516. }
  10517. const firstSelectedIndex = yield external_wp_data_["controls"].select(STORE_NAME, 'getBlockIndex', clientId, rootClientId);
  10518. return yield actions_insertDefaultBlock({}, rootClientId, firstSelectedIndex + 1);
  10519. }
  10520. /**
  10521. * Returns an action object that toggles the highlighted block state.
  10522. *
  10523. * @param {string} clientId The block's clientId.
  10524. * @param {boolean} isHighlighted The highlight state.
  10525. */
  10526. function actions_toggleBlockHighlight(clientId, isHighlighted) {
  10527. return {
  10528. type: 'TOGGLE_BLOCK_HIGHLIGHT',
  10529. clientId,
  10530. isHighlighted
  10531. };
  10532. }
  10533. /**
  10534. * Yields action objects used in signalling that the block corresponding to the
  10535. * given clientId should appear to "flash" by rhythmically highlighting it.
  10536. *
  10537. * @param {string} clientId Target block client ID.
  10538. */
  10539. function* actions_flashBlock(clientId) {
  10540. yield actions_toggleBlockHighlight(clientId, true);
  10541. yield {
  10542. type: 'SLEEP',
  10543. duration: 150
  10544. };
  10545. yield actions_toggleBlockHighlight(clientId, false);
  10546. }
  10547. /**
  10548. * Returns an action object that sets whether the block has controlled innerblocks.
  10549. *
  10550. * @param {string} clientId The block's clientId.
  10551. * @param {boolean} hasControlledInnerBlocks True if the block's inner blocks are controlled.
  10552. */
  10553. function actions_setHasControlledInnerBlocks(clientId, hasControlledInnerBlocks) {
  10554. return {
  10555. type: 'SET_HAS_CONTROLLED_INNER_BLOCKS',
  10556. hasControlledInnerBlocks,
  10557. clientId
  10558. };
  10559. }
  10560. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/index.js
  10561. /**
  10562. * WordPress dependencies
  10563. */
  10564. /**
  10565. * Internal dependencies
  10566. */
  10567. /**
  10568. * Block editor data store configuration.
  10569. *
  10570. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore
  10571. *
  10572. * @type {Object}
  10573. */
  10574. const storeConfig = {
  10575. reducer: store_reducer,
  10576. selectors: selectors_namespaceObject,
  10577. actions: actions_namespaceObject,
  10578. controls: store_controls
  10579. };
  10580. /**
  10581. * Store definition for the block editor namespace.
  10582. *
  10583. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  10584. *
  10585. * @type {Object}
  10586. */
  10587. const store = Object(external_wp_data_["createReduxStore"])(STORE_NAME, { ...storeConfig,
  10588. persist: ['preferences']
  10589. }); // Ideally we'd use register instead of register stores.
  10590. Object(external_wp_data_["registerStore"])(STORE_NAME, { ...storeConfig,
  10591. persist: ['preferences']
  10592. });
  10593. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-display-block-controls/index.js
  10594. /**
  10595. * WordPress dependencies
  10596. */
  10597. /**
  10598. * Internal dependencies
  10599. */
  10600. function useDisplayBlockControls() {
  10601. const {
  10602. isSelected,
  10603. clientId,
  10604. name
  10605. } = useBlockEditContext();
  10606. const isFirstAndSameTypeMultiSelected = Object(external_wp_data_["useSelect"])(select => {
  10607. // Don't bother checking, see OR statement below.
  10608. if (isSelected) {
  10609. return;
  10610. }
  10611. const {
  10612. getBlockName,
  10613. isFirstMultiSelectedBlock,
  10614. getMultiSelectedBlockClientIds
  10615. } = select(store);
  10616. if (!isFirstMultiSelectedBlock(clientId)) {
  10617. return false;
  10618. }
  10619. return getMultiSelectedBlockClientIds().every(id => getBlockName(id) === name);
  10620. }, [clientId, isSelected, name]);
  10621. return isSelected || isFirstAndSameTypeMultiSelected;
  10622. }
  10623. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/groups.js
  10624. /**
  10625. * WordPress dependencies
  10626. */
  10627. const BlockControlsDefault = Object(external_wp_components_["createSlotFill"])('BlockControls');
  10628. const BlockControlsBlock = Object(external_wp_components_["createSlotFill"])('BlockControlsBlock');
  10629. const BlockControlsInline = Object(external_wp_components_["createSlotFill"])('BlockFormatControls');
  10630. const BlockControlsOther = Object(external_wp_components_["createSlotFill"])('BlockControlsOther');
  10631. const groups = {
  10632. default: BlockControlsDefault,
  10633. block: BlockControlsBlock,
  10634. inline: BlockControlsInline,
  10635. other: BlockControlsOther
  10636. };
  10637. /* harmony default export */ var block_controls_groups = (groups);
  10638. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/fill.js
  10639. /**
  10640. * External dependencies
  10641. */
  10642. /**
  10643. * WordPress dependencies
  10644. */
  10645. /**
  10646. * Internal dependencies
  10647. */
  10648. function BlockControlsFill({
  10649. group = 'default',
  10650. controls,
  10651. children
  10652. }) {
  10653. if (!useDisplayBlockControls()) {
  10654. return null;
  10655. }
  10656. const Fill = block_controls_groups[group].Fill;
  10657. return Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalStyleProvider"], {
  10658. document: document
  10659. }, Object(external_wp_element_["createElement"])(Fill, null, fillProps => {
  10660. // Children passed to BlockControlsFill will not have access to any
  10661. // React Context whose Provider is part of the BlockControlsSlot tree.
  10662. // So we re-create the Provider in this subtree.
  10663. const value = !Object(external_lodash_["isEmpty"])(fillProps) ? fillProps : null;
  10664. return Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalToolbarContext"].Provider, {
  10665. value: value
  10666. }, group === 'default' && Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], {
  10667. controls: controls
  10668. }), children);
  10669. }));
  10670. }
  10671. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/slot.js
  10672. /**
  10673. * WordPress dependencies
  10674. */
  10675. /**
  10676. * Internal dependencies
  10677. */
  10678. function BlockControlsSlot({
  10679. group = 'default',
  10680. ...props
  10681. }) {
  10682. const accessibleToolbarState = Object(external_wp_element_["useContext"])(external_wp_components_["__experimentalToolbarContext"]);
  10683. const Slot = block_controls_groups[group].Slot;
  10684. const slot = Object(external_wp_components_["__experimentalUseSlot"])(Slot.__unstableName);
  10685. const hasFills = Boolean(slot.fills && slot.fills.length);
  10686. if (!hasFills) {
  10687. return null;
  10688. }
  10689. if (group === 'default') {
  10690. return Object(external_wp_element_["createElement"])(Slot, Object(esm_extends["a" /* default */])({}, props, {
  10691. bubblesVirtually: true,
  10692. fillProps: accessibleToolbarState
  10693. }));
  10694. }
  10695. return Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], null, Object(external_wp_element_["createElement"])(Slot, Object(esm_extends["a" /* default */])({}, props, {
  10696. bubblesVirtually: true,
  10697. fillProps: accessibleToolbarState
  10698. })));
  10699. }
  10700. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/index.js
  10701. /**
  10702. * Internal dependencies
  10703. */
  10704. const BlockControls = BlockControlsFill;
  10705. BlockControls.Slot = BlockControlsSlot; // This is just here for backward compatibility
  10706. const BlockFormatControls = props => {
  10707. return Object(external_wp_element_["createElement"])(BlockControlsFill, Object(esm_extends["a" /* default */])({
  10708. group: "inline"
  10709. }, props));
  10710. };
  10711. BlockFormatControls.Slot = props => {
  10712. return Object(external_wp_element_["createElement"])(BlockControlsSlot, Object(esm_extends["a" /* default */])({
  10713. group: "inline"
  10714. }, props));
  10715. };
  10716. /* harmony default export */ var block_controls = (BlockControls);
  10717. // EXTERNAL MODULE: external ["wp","primitives"]
  10718. var external_wp_primitives_ = __webpack_require__("Tqx9");
  10719. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/position-left.js
  10720. /**
  10721. * WordPress dependencies
  10722. */
  10723. const positionLeft = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
  10724. xmlns: "http://www.w3.org/2000/svg",
  10725. viewBox: "0 0 24 24"
  10726. }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
  10727. d: "M4 9v6h14V9H4zm8-4.8H4v1.5h8V4.2zM4 19.8h8v-1.5H4v1.5z"
  10728. }));
  10729. /* harmony default export */ var position_left = (positionLeft);
  10730. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/position-center.js
  10731. /**
  10732. * WordPress dependencies
  10733. */
  10734. const positionCenter = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
  10735. xmlns: "http://www.w3.org/2000/svg",
  10736. viewBox: "0 0 24 24"
  10737. }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
  10738. d: "M5 15h14V9H5v6zm0 4.8h14v-1.5H5v1.5zM5 4.2v1.5h14V4.2H5z"
  10739. }));
  10740. /* harmony default export */ var position_center = (positionCenter);
  10741. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/position-right.js
  10742. /**
  10743. * WordPress dependencies
  10744. */
  10745. const positionRight = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
  10746. xmlns: "http://www.w3.org/2000/svg",
  10747. viewBox: "0 0 24 24"
  10748. }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
  10749. d: "M6 15h14V9H6v6zm6-10.8v1.5h8V4.2h-8zm0 15.6h8v-1.5h-8v1.5z"
  10750. }));
  10751. /* harmony default export */ var position_right = (positionRight);
  10752. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/stretch-wide.js
  10753. /**
  10754. * WordPress dependencies
  10755. */
  10756. const stretchWide = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
  10757. xmlns: "http://www.w3.org/2000/svg",
  10758. viewBox: "0 0 24 24"
  10759. }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
  10760. d: "M5 9v6h14V9H5zm11-4.8H8v1.5h8V4.2zM8 19.8h8v-1.5H8v1.5z"
  10761. }));
  10762. /* harmony default export */ var stretch_wide = (stretchWide);
  10763. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/stretch-full-width.js
  10764. /**
  10765. * WordPress dependencies
  10766. */
  10767. const stretchFullWidth = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
  10768. xmlns: "http://www.w3.org/2000/svg",
  10769. viewBox: "0 0 24 24"
  10770. }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
  10771. d: "M5 4v11h14V4H5zm3 15.8h8v-1.5H8v1.5z"
  10772. }));
  10773. /* harmony default export */ var stretch_full_width = (stretchFullWidth);
  10774. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/layout.js
  10775. /**
  10776. * WordPress dependencies
  10777. */
  10778. const layout_defaultLayout = {
  10779. type: 'default'
  10780. };
  10781. const Layout = Object(external_wp_element_["createContext"])(layout_defaultLayout);
  10782. function appendSelectors(selectors, append) {
  10783. // Ideally we shouldn't need the `.editor-styles-wrapper` increased specificity here
  10784. // The problem though is that we have a `.editor-styles-wrapper p { margin: reset; }` style
  10785. // it's used to reset the default margin added by wp-admin to paragraphs
  10786. // so we need this to be higher speficity otherwise, it won't be applied to paragraphs inside containers
  10787. // When the post editor is fully iframed, this extra classname could be removed.
  10788. return selectors.split(',').map(subselector => `.editor-styles-wrapper ${subselector} ${append}`).join(',');
  10789. }
  10790. /**
  10791. * Allows to define the layout.
  10792. */
  10793. const LayoutProvider = Layout.Provider;
  10794. /**
  10795. * React hook used to retrieve the layout config.
  10796. */
  10797. function useLayout() {
  10798. return Object(external_wp_element_["useContext"])(Layout);
  10799. }
  10800. function LayoutStyle({
  10801. selector,
  10802. layout = {}
  10803. }) {
  10804. const {
  10805. contentSize,
  10806. wideSize
  10807. } = layout;
  10808. let style = !!contentSize || !!wideSize ? `
  10809. ${appendSelectors(selector, '> *')} {
  10810. max-width: ${contentSize !== null && contentSize !== void 0 ? contentSize : wideSize};
  10811. margin-left: auto !important;
  10812. margin-right: auto !important;
  10813. }
  10814. ${appendSelectors(selector, '> [data-align="wide"]')} {
  10815. max-width: ${wideSize !== null && wideSize !== void 0 ? wideSize : contentSize};
  10816. }
  10817. ${appendSelectors(selector, '> [data-align="full"]')} {
  10818. max-width: none;
  10819. }
  10820. ` : '';
  10821. style += `
  10822. ${appendSelectors(selector, '> [data-align="left"]')} {
  10823. float: left;
  10824. margin-right: 2em;
  10825. }
  10826. ${appendSelectors(selector, '> [data-align="right"]')} {
  10827. float: right;
  10828. margin-left: 2em;
  10829. }
  10830. `;
  10831. return Object(external_wp_element_["createElement"])("style", null, style);
  10832. }
  10833. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-alignment-control/use-available-alignments.js
  10834. /**
  10835. * WordPress dependencies
  10836. */
  10837. /**
  10838. * Internal dependencies
  10839. */
  10840. const DEFAULT_CONTROLS = ['left', 'center', 'right', 'wide', 'full'];
  10841. const WIDE_CONTROLS = ['wide', 'full'];
  10842. function useAvailableAlignments(controls = DEFAULT_CONTROLS) {
  10843. const {
  10844. wideControlsEnabled = false
  10845. } = Object(external_wp_data_["useSelect"])(select => {
  10846. const {
  10847. getSettings
  10848. } = select(store);
  10849. const settings = getSettings();
  10850. return {
  10851. wideControlsEnabled: settings.alignWide
  10852. };
  10853. }, []);
  10854. const layout = useLayout();
  10855. const supportsAlignments = layout.type === 'default';
  10856. if (!supportsAlignments) {
  10857. return [];
  10858. }
  10859. const {
  10860. alignments: availableAlignments = DEFAULT_CONTROLS
  10861. } = layout;
  10862. const enabledControls = controls.filter(control => (layout.alignments || // Ignore the global wideAlignment check if the layout explicitely defines alignments.
  10863. wideControlsEnabled || !WIDE_CONTROLS.includes(control)) && availableAlignments.includes(control));
  10864. return enabledControls;
  10865. }
  10866. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-alignment-control/ui.js
  10867. /**
  10868. * WordPress dependencies
  10869. */
  10870. /**
  10871. * Internal dependencies
  10872. */
  10873. const BLOCK_ALIGNMENTS_CONTROLS = {
  10874. left: {
  10875. icon: position_left,
  10876. title: Object(external_wp_i18n_["__"])('Align left')
  10877. },
  10878. center: {
  10879. icon: position_center,
  10880. title: Object(external_wp_i18n_["__"])('Align center')
  10881. },
  10882. right: {
  10883. icon: position_right,
  10884. title: Object(external_wp_i18n_["__"])('Align right')
  10885. },
  10886. wide: {
  10887. icon: stretch_wide,
  10888. title: Object(external_wp_i18n_["__"])('Wide width')
  10889. },
  10890. full: {
  10891. icon: stretch_full_width,
  10892. title: Object(external_wp_i18n_["__"])('Full width')
  10893. }
  10894. };
  10895. const DEFAULT_CONTROL = 'center';
  10896. const ui_POPOVER_PROPS = {
  10897. isAlternate: true
  10898. };
  10899. function BlockAlignmentUI({
  10900. value,
  10901. onChange,
  10902. controls,
  10903. isToolbar,
  10904. isCollapsed = true
  10905. }) {
  10906. const enabledControls = useAvailableAlignments(controls);
  10907. if (enabledControls.length === 0) {
  10908. return null;
  10909. }
  10910. function applyOrUnset(align) {
  10911. return () => onChange(value === align ? undefined : align);
  10912. }
  10913. const activeAlignmentControl = BLOCK_ALIGNMENTS_CONTROLS[value];
  10914. const defaultAlignmentControl = BLOCK_ALIGNMENTS_CONTROLS[DEFAULT_CONTROL];
  10915. const UIComponent = isToolbar ? external_wp_components_["ToolbarGroup"] : external_wp_components_["ToolbarDropdownMenu"];
  10916. const extraProps = isToolbar ? {
  10917. isCollapsed
  10918. } : {};
  10919. return Object(external_wp_element_["createElement"])(UIComponent, Object(esm_extends["a" /* default */])({
  10920. popoverProps: ui_POPOVER_PROPS,
  10921. icon: activeAlignmentControl ? activeAlignmentControl.icon : defaultAlignmentControl.icon,
  10922. label: Object(external_wp_i18n_["__"])('Align'),
  10923. toggleProps: {
  10924. describedBy: Object(external_wp_i18n_["__"])('Change alignment')
  10925. },
  10926. controls: enabledControls.map(control => {
  10927. return { ...BLOCK_ALIGNMENTS_CONTROLS[control],
  10928. isActive: value === control,
  10929. role: isCollapsed ? 'menuitemradio' : undefined,
  10930. onClick: applyOrUnset(control)
  10931. };
  10932. })
  10933. }, extraProps));
  10934. }
  10935. /* harmony default export */ var ui = (BlockAlignmentUI);
  10936. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-alignment-control/index.js
  10937. /**
  10938. * Internal dependencies
  10939. */
  10940. function BlockAlignmentControl(props) {
  10941. return Object(external_wp_element_["createElement"])(ui, Object(esm_extends["a" /* default */])({}, props, {
  10942. isToolbar: false
  10943. }));
  10944. }
  10945. function BlockAlignmentToolbar(props) {
  10946. return Object(external_wp_element_["createElement"])(ui, Object(esm_extends["a" /* default */])({}, props, {
  10947. isToolbar: true
  10948. }));
  10949. }
  10950. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/align.js
  10951. /**
  10952. * External dependencies
  10953. */
  10954. /**
  10955. * WordPress dependencies
  10956. */
  10957. /**
  10958. * Internal dependencies
  10959. */
  10960. /**
  10961. * An array which includes all possible valid alignments,
  10962. * used to validate if an alignment is valid or not.
  10963. *
  10964. * @constant
  10965. * @type {string[]}
  10966. */
  10967. const ALL_ALIGNMENTS = ['left', 'center', 'right', 'wide', 'full'];
  10968. /**
  10969. * An array which includes all wide alignments.
  10970. * In order for this alignments to be valid they need to be supported by the block,
  10971. * and by the theme.
  10972. *
  10973. * @constant
  10974. * @type {string[]}
  10975. */
  10976. const WIDE_ALIGNMENTS = ['wide', 'full'];
  10977. /**
  10978. * Returns the valid alignments.
  10979. * Takes into consideration the aligns supported by a block, if the block supports wide controls or not and if theme supports wide controls or not.
  10980. * Exported just for testing purposes, not exported outside the module.
  10981. *
  10982. * @param {?boolean|string[]} blockAlign Aligns supported by the block.
  10983. * @param {?boolean} hasWideBlockSupport True if block supports wide alignments. And False otherwise.
  10984. * @param {?boolean} hasWideEnabled True if theme supports wide alignments. And False otherwise.
  10985. *
  10986. * @return {string[]} Valid alignments.
  10987. */
  10988. function getValidAlignments(blockAlign, hasWideBlockSupport = true, hasWideEnabled = true) {
  10989. let validAlignments;
  10990. if (Array.isArray(blockAlign)) {
  10991. validAlignments = ALL_ALIGNMENTS.filter(value => blockAlign.includes(value));
  10992. } else if (blockAlign === true) {
  10993. // `true` includes all alignments...
  10994. validAlignments = ALL_ALIGNMENTS;
  10995. } else {
  10996. validAlignments = [];
  10997. }
  10998. if (!hasWideEnabled || blockAlign === true && !hasWideBlockSupport) {
  10999. return Object(external_lodash_["without"])(validAlignments, ...WIDE_ALIGNMENTS);
  11000. }
  11001. return validAlignments;
  11002. }
  11003. /**
  11004. * Filters registered block settings, extending attributes to include `align`.
  11005. *
  11006. * @param {Object} settings Original block settings
  11007. * @return {Object} Filtered block settings
  11008. */
  11009. function addAttribute(settings) {
  11010. // allow blocks to specify their own attribute definition with default values if needed.
  11011. if (Object(external_lodash_["has"])(settings.attributes, ['align', 'type'])) {
  11012. return settings;
  11013. }
  11014. if (Object(external_wp_blocks_["hasBlockSupport"])(settings, 'align')) {
  11015. // Gracefully handle if settings.attributes is undefined.
  11016. settings.attributes = { ...settings.attributes,
  11017. align: {
  11018. type: 'string',
  11019. // Allow for '' since it is used by updateAlignment function
  11020. // in withToolbarControls for special cases with defined default values.
  11021. enum: [...ALL_ALIGNMENTS, '']
  11022. }
  11023. };
  11024. }
  11025. return settings;
  11026. }
  11027. /**
  11028. * Override the default edit UI to include new toolbar controls for block
  11029. * alignment, if block defines support.
  11030. *
  11031. * @param {Function} BlockEdit Original component
  11032. * @return {Function} Wrapped component
  11033. */
  11034. const withToolbarControls = Object(external_wp_compose_["createHigherOrderComponent"])(BlockEdit => props => {
  11035. const {
  11036. name: blockName
  11037. } = props; // Compute the block allowed alignments without taking into account,
  11038. // if the theme supports wide alignments or not
  11039. // and without checking the layout for availble alignments.
  11040. // BlockAlignmentToolbar takes both of these into account.
  11041. const blockAllowedAlignments = getValidAlignments(Object(external_wp_blocks_["getBlockSupport"])(blockName, 'align'), Object(external_wp_blocks_["hasBlockSupport"])(blockName, 'alignWide', true));
  11042. const validAlignments = useAvailableAlignments(blockAllowedAlignments);
  11043. const updateAlignment = nextAlign => {
  11044. if (!nextAlign) {
  11045. var _blockType$attributes, _blockType$attributes2;
  11046. const blockType = Object(external_wp_blocks_["getBlockType"])(props.name);
  11047. const blockDefaultAlign = (_blockType$attributes = blockType.attributes) === null || _blockType$attributes === void 0 ? void 0 : (_blockType$attributes2 = _blockType$attributes.align) === null || _blockType$attributes2 === void 0 ? void 0 : _blockType$attributes2.default;
  11048. if (blockDefaultAlign) {
  11049. nextAlign = '';
  11050. }
  11051. }
  11052. props.setAttributes({
  11053. align: nextAlign
  11054. });
  11055. };
  11056. return [validAlignments.length > 0 && props.isSelected && Object(external_wp_element_["createElement"])(block_controls, {
  11057. key: "align-controls",
  11058. group: "block"
  11059. }, Object(external_wp_element_["createElement"])(BlockAlignmentControl, {
  11060. value: props.attributes.align,
  11061. onChange: updateAlignment,
  11062. controls: validAlignments
  11063. })), Object(external_wp_element_["createElement"])(BlockEdit, Object(esm_extends["a" /* default */])({
  11064. key: "edit"
  11065. }, props))];
  11066. }, 'withToolbarControls');
  11067. /**
  11068. * Override the default block element to add alignment wrapper props.
  11069. *
  11070. * @param {Function} BlockListBlock Original component
  11071. * @return {Function} Wrapped component
  11072. */
  11073. const withDataAlign = Object(external_wp_compose_["createHigherOrderComponent"])(BlockListBlock => props => {
  11074. const {
  11075. name,
  11076. attributes
  11077. } = props;
  11078. const {
  11079. align
  11080. } = attributes;
  11081. const blockAllowedAlignments = getValidAlignments(Object(external_wp_blocks_["getBlockSupport"])(name, 'align'), Object(external_wp_blocks_["hasBlockSupport"])(name, 'alignWide', true));
  11082. const validAlignments = useAvailableAlignments(blockAllowedAlignments); // If an alignment is not assigned, there's no need to go through the
  11083. // effort to validate or assign its value.
  11084. if (align === undefined) {
  11085. return Object(external_wp_element_["createElement"])(BlockListBlock, props);
  11086. }
  11087. let wrapperProps = props.wrapperProps;
  11088. if (validAlignments.includes(align)) {
  11089. wrapperProps = { ...wrapperProps,
  11090. 'data-align': align
  11091. };
  11092. }
  11093. return Object(external_wp_element_["createElement"])(BlockListBlock, Object(esm_extends["a" /* default */])({}, props, {
  11094. wrapperProps: wrapperProps
  11095. }));
  11096. });
  11097. /**
  11098. * Override props assigned to save component to inject alignment class name if
  11099. * block supports it.
  11100. *
  11101. * @param {Object} props Additional props applied to save element
  11102. * @param {Object} blockType Block type
  11103. * @param {Object} attributes Block attributes
  11104. * @return {Object} Filtered props applied to save element
  11105. */
  11106. function addAssignedAlign(props, blockType, attributes) {
  11107. const {
  11108. align
  11109. } = attributes;
  11110. const blockAlign = Object(external_wp_blocks_["getBlockSupport"])(blockType, 'align');
  11111. const hasWideBlockSupport = Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'alignWide', true); // Compute valid alignments without taking into account if
  11112. // the theme supports wide alignments or not.
  11113. // This way changing themes does not impact the block save.
  11114. const isAlignValid = getValidAlignments(blockAlign, hasWideBlockSupport).includes(align);
  11115. if (isAlignValid) {
  11116. props.className = classnames_default()(`align${align}`, props.className);
  11117. }
  11118. return props;
  11119. }
  11120. Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/align/addAttribute', addAttribute);
  11121. Object(external_wp_hooks_["addFilter"])('editor.BlockListBlock', 'core/editor/align/with-data-align', withDataAlign);
  11122. Object(external_wp_hooks_["addFilter"])('editor.BlockEdit', 'core/editor/align/with-toolbar-controls', withToolbarControls);
  11123. Object(external_wp_hooks_["addFilter"])('blocks.getSaveContent.extraProps', 'core/align/addAssignedAlign', addAssignedAlign);
  11124. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-advanced-controls/index.js
  11125. /**
  11126. * WordPress dependencies
  11127. */
  11128. /**
  11129. * Internal dependencies
  11130. */
  11131. const inspector_advanced_controls_name = 'InspectorAdvancedControls';
  11132. const {
  11133. Fill: inspector_advanced_controls_Fill,
  11134. Slot: inspector_advanced_controls_Slot
  11135. } = Object(external_wp_components_["createSlotFill"])(inspector_advanced_controls_name);
  11136. function InspectorAdvancedControls({
  11137. children
  11138. }) {
  11139. const {
  11140. isSelected
  11141. } = useBlockEditContext();
  11142. return isSelected ? Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalStyleProvider"], {
  11143. document: document
  11144. }, Object(external_wp_element_["createElement"])(inspector_advanced_controls_Fill, null, children)) : null;
  11145. }
  11146. InspectorAdvancedControls.slotName = inspector_advanced_controls_name;
  11147. InspectorAdvancedControls.Slot = inspector_advanced_controls_Slot;
  11148. /**
  11149. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inspector-advanced-controls/README.md
  11150. */
  11151. /* harmony default export */ var inspector_advanced_controls = (InspectorAdvancedControls);
  11152. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/index.js
  11153. /**
  11154. * WordPress dependencies
  11155. */
  11156. /**
  11157. * Internal dependencies
  11158. */
  11159. const {
  11160. Fill: inspector_controls_Fill,
  11161. Slot: inspector_controls_Slot
  11162. } = Object(external_wp_components_["createSlotFill"])('InspectorControls');
  11163. function InspectorControls({
  11164. children
  11165. }) {
  11166. return useDisplayBlockControls() ? Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalStyleProvider"], {
  11167. document: document
  11168. }, Object(external_wp_element_["createElement"])(inspector_controls_Fill, null, children)) : null;
  11169. }
  11170. InspectorControls.Slot = inspector_controls_Slot;
  11171. /**
  11172. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inspector-controls/README.md
  11173. */
  11174. /* harmony default export */ var inspector_controls = (InspectorControls);
  11175. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/anchor.js
  11176. /**
  11177. * External dependencies
  11178. */
  11179. /**
  11180. * WordPress dependencies
  11181. */
  11182. /**
  11183. * Internal dependencies
  11184. */
  11185. /**
  11186. * Regular expression matching invalid anchor characters for replacement.
  11187. *
  11188. * @type {RegExp}
  11189. */
  11190. const ANCHOR_REGEX = /[\s#]/g;
  11191. /**
  11192. * Filters registered block settings, extending attributes with anchor using ID
  11193. * of the first node.
  11194. *
  11195. * @param {Object} settings Original block settings.
  11196. *
  11197. * @return {Object} Filtered block settings.
  11198. */
  11199. function anchor_addAttribute(settings) {
  11200. // allow blocks to specify their own attribute definition with default values if needed.
  11201. if (Object(external_lodash_["has"])(settings.attributes, ['anchor', 'type'])) {
  11202. return settings;
  11203. }
  11204. if (Object(external_wp_blocks_["hasBlockSupport"])(settings, 'anchor')) {
  11205. // Gracefully handle if settings.attributes is undefined.
  11206. settings.attributes = { ...settings.attributes,
  11207. anchor: {
  11208. type: 'string',
  11209. source: 'attribute',
  11210. attribute: 'id',
  11211. selector: '*'
  11212. }
  11213. };
  11214. }
  11215. return settings;
  11216. }
  11217. /**
  11218. * Override the default edit UI to include a new block inspector control for
  11219. * assigning the anchor ID, if block supports anchor.
  11220. *
  11221. * @param {WPComponent} BlockEdit Original component.
  11222. *
  11223. * @return {WPComponent} Wrapped component.
  11224. */
  11225. const withInspectorControl = Object(external_wp_compose_["createHigherOrderComponent"])(BlockEdit => {
  11226. return props => {
  11227. const hasAnchor = Object(external_wp_blocks_["hasBlockSupport"])(props.name, 'anchor');
  11228. if (hasAnchor && props.isSelected) {
  11229. const isWeb = external_wp_element_["Platform"].OS === 'web';
  11230. const textControl = Object(external_wp_element_["createElement"])(external_wp_components_["TextControl"], {
  11231. className: "html-anchor-control",
  11232. label: Object(external_wp_i18n_["__"])('HTML anchor'),
  11233. help: Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_i18n_["__"])('Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'), Object(external_wp_element_["createElement"])(external_wp_components_["ExternalLink"], {
  11234. href: 'https://wordpress.org/support/article/page-jumps/'
  11235. }, Object(external_wp_i18n_["__"])('Learn more about anchors'))),
  11236. value: props.attributes.anchor || '',
  11237. placeholder: !isWeb ? Object(external_wp_i18n_["__"])('Add an anchor') : null,
  11238. onChange: nextValue => {
  11239. nextValue = nextValue.replace(ANCHOR_REGEX, '-');
  11240. props.setAttributes({
  11241. anchor: nextValue
  11242. });
  11243. },
  11244. autoCapitalize: "none",
  11245. autoComplete: "off"
  11246. });
  11247. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(BlockEdit, props), isWeb && Object(external_wp_element_["createElement"])(inspector_advanced_controls, null, textControl), !isWeb && props.name === 'core/heading' && Object(external_wp_element_["createElement"])(inspector_controls, null, Object(external_wp_element_["createElement"])(external_wp_components_["PanelBody"], {
  11248. title: Object(external_wp_i18n_["__"])('Heading settings')
  11249. }, textControl)));
  11250. }
  11251. return Object(external_wp_element_["createElement"])(BlockEdit, props);
  11252. };
  11253. }, 'withInspectorControl');
  11254. /**
  11255. * Override props assigned to save component to inject anchor ID, if block
  11256. * supports anchor. This is only applied if the block's save result is an
  11257. * element and not a markup string.
  11258. *
  11259. * @param {Object} extraProps Additional props applied to save element.
  11260. * @param {Object} blockType Block type.
  11261. * @param {Object} attributes Current block attributes.
  11262. *
  11263. * @return {Object} Filtered props applied to save element.
  11264. */
  11265. function addSaveProps(extraProps, blockType, attributes) {
  11266. if (Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'anchor')) {
  11267. extraProps.id = attributes.anchor === '' ? null : attributes.anchor;
  11268. }
  11269. return extraProps;
  11270. }
  11271. Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/anchor/attribute', anchor_addAttribute);
  11272. Object(external_wp_hooks_["addFilter"])('editor.BlockEdit', 'core/editor/anchor/with-inspector-control', withInspectorControl);
  11273. Object(external_wp_hooks_["addFilter"])('blocks.getSaveContent.extraProps', 'core/anchor/save-props', addSaveProps);
  11274. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/custom-class-name.js
  11275. /**
  11276. * External dependencies
  11277. */
  11278. /**
  11279. * WordPress dependencies
  11280. */
  11281. /**
  11282. * Internal dependencies
  11283. */
  11284. /**
  11285. * Filters registered block settings, extending attributes with anchor using ID
  11286. * of the first node.
  11287. *
  11288. * @param {Object} settings Original block settings.
  11289. *
  11290. * @return {Object} Filtered block settings.
  11291. */
  11292. function custom_class_name_addAttribute(settings) {
  11293. if (Object(external_wp_blocks_["hasBlockSupport"])(settings, 'customClassName', true)) {
  11294. // Gracefully handle if settings.attributes is undefined.
  11295. settings.attributes = { ...settings.attributes,
  11296. className: {
  11297. type: 'string'
  11298. }
  11299. };
  11300. }
  11301. return settings;
  11302. }
  11303. /**
  11304. * Override the default edit UI to include a new block inspector control for
  11305. * assigning the custom class name, if block supports custom class name.
  11306. *
  11307. * @param {WPComponent} BlockEdit Original component.
  11308. *
  11309. * @return {WPComponent} Wrapped component.
  11310. */
  11311. const custom_class_name_withInspectorControl = Object(external_wp_compose_["createHigherOrderComponent"])(BlockEdit => {
  11312. return props => {
  11313. const hasCustomClassName = Object(external_wp_blocks_["hasBlockSupport"])(props.name, 'customClassName', true);
  11314. if (hasCustomClassName && props.isSelected) {
  11315. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(BlockEdit, props), Object(external_wp_element_["createElement"])(inspector_advanced_controls, null, Object(external_wp_element_["createElement"])(external_wp_components_["TextControl"], {
  11316. autoComplete: "off",
  11317. label: Object(external_wp_i18n_["__"])('Additional CSS class(es)'),
  11318. value: props.attributes.className || '',
  11319. onChange: nextValue => {
  11320. props.setAttributes({
  11321. className: nextValue !== '' ? nextValue : undefined
  11322. });
  11323. },
  11324. help: Object(external_wp_i18n_["__"])('Separate multiple classes with spaces.')
  11325. })));
  11326. }
  11327. return Object(external_wp_element_["createElement"])(BlockEdit, props);
  11328. };
  11329. }, 'withInspectorControl');
  11330. /**
  11331. * Override props assigned to save component to inject anchor ID, if block
  11332. * supports anchor. This is only applied if the block's save result is an
  11333. * element and not a markup string.
  11334. *
  11335. * @param {Object} extraProps Additional props applied to save element.
  11336. * @param {Object} blockType Block type.
  11337. * @param {Object} attributes Current block attributes.
  11338. *
  11339. * @return {Object} Filtered props applied to save element.
  11340. */
  11341. function custom_class_name_addSaveProps(extraProps, blockType, attributes) {
  11342. if (Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'customClassName', true) && attributes.className) {
  11343. extraProps.className = classnames_default()(extraProps.className, attributes.className);
  11344. }
  11345. return extraProps;
  11346. }
  11347. /**
  11348. * Given an HTML string, returns an array of class names assigned to the root
  11349. * element in the markup.
  11350. *
  11351. * @param {string} innerHTML Markup string from which to extract classes.
  11352. *
  11353. * @return {string[]} Array of class names assigned to the root element.
  11354. */
  11355. function getHTMLRootElementClasses(innerHTML) {
  11356. innerHTML = `<div data-custom-class-name>${innerHTML}</div>`;
  11357. const parsed = Object(external_wp_blocks_["parseWithAttributeSchema"])(innerHTML, {
  11358. type: 'string',
  11359. source: 'attribute',
  11360. selector: '[data-custom-class-name] > *',
  11361. attribute: 'class'
  11362. });
  11363. return parsed ? parsed.trim().split(/\s+/) : [];
  11364. }
  11365. /**
  11366. * Given a parsed set of block attributes, if the block supports custom class
  11367. * names and an unknown class (per the block's serialization behavior) is
  11368. * found, the unknown classes are treated as custom classes. This prevents the
  11369. * block from being considered as invalid.
  11370. *
  11371. * @param {Object} blockAttributes Original block attributes.
  11372. * @param {Object} blockType Block type settings.
  11373. * @param {string} innerHTML Original block markup.
  11374. *
  11375. * @return {Object} Filtered block attributes.
  11376. */
  11377. function addParsedDifference(blockAttributes, blockType, innerHTML) {
  11378. if (Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'customClassName', true)) {
  11379. // To determine difference, serialize block given the known set of
  11380. // attributes, with the exception of `className`. This will determine
  11381. // the default set of classes. From there, any difference in innerHTML
  11382. // can be considered as custom classes.
  11383. const attributesSansClassName = Object(external_lodash_["omit"])(blockAttributes, ['className']);
  11384. const serialized = Object(external_wp_blocks_["getSaveContent"])(blockType, attributesSansClassName);
  11385. const defaultClasses = getHTMLRootElementClasses(serialized);
  11386. const actualClasses = getHTMLRootElementClasses(innerHTML);
  11387. const customClasses = Object(external_lodash_["difference"])(actualClasses, defaultClasses);
  11388. if (customClasses.length) {
  11389. blockAttributes.className = customClasses.join(' ');
  11390. } else if (serialized) {
  11391. delete blockAttributes.className;
  11392. }
  11393. }
  11394. return blockAttributes;
  11395. }
  11396. Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/custom-class-name/attribute', custom_class_name_addAttribute);
  11397. Object(external_wp_hooks_["addFilter"])('editor.BlockEdit', 'core/editor/custom-class-name/with-inspector-control', custom_class_name_withInspectorControl);
  11398. Object(external_wp_hooks_["addFilter"])('blocks.getSaveContent.extraProps', 'core/custom-class-name/save-props', custom_class_name_addSaveProps);
  11399. Object(external_wp_hooks_["addFilter"])('blocks.getBlockAttributes', 'core/custom-class-name/addParsedDifference', addParsedDifference);
  11400. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/generated-class-name.js
  11401. /**
  11402. * External dependencies
  11403. */
  11404. /**
  11405. * WordPress dependencies
  11406. */
  11407. /**
  11408. * Override props assigned to save component to inject generated className if
  11409. * block supports it. This is only applied if the block's save result is an
  11410. * element and not a markup string.
  11411. *
  11412. * @param {Object} extraProps Additional props applied to save element.
  11413. * @param {Object} blockType Block type.
  11414. *
  11415. * @return {Object} Filtered props applied to save element.
  11416. */
  11417. function addGeneratedClassName(extraProps, blockType) {
  11418. // Adding the generated className
  11419. if (Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'className', true)) {
  11420. if (typeof extraProps.className === 'string') {
  11421. // We have some extra classes and want to add the default classname
  11422. // We use uniq to prevent duplicate classnames
  11423. extraProps.className = Object(external_lodash_["uniq"])([Object(external_wp_blocks_["getBlockDefaultClassName"])(blockType.name), ...extraProps.className.split(' ')]).join(' ').trim();
  11424. } else {
  11425. // There is no string in the className variable,
  11426. // so we just dump the default name in there
  11427. extraProps.className = Object(external_wp_blocks_["getBlockDefaultClassName"])(blockType.name);
  11428. }
  11429. }
  11430. return extraProps;
  11431. }
  11432. Object(external_wp_hooks_["addFilter"])('blocks.getSaveContent.extraProps', 'core/generated-class-name/save-props', addGeneratedClassName);
  11433. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-setting/index.js
  11434. /**
  11435. * External dependencies
  11436. */
  11437. /**
  11438. * WordPress dependencies
  11439. */
  11440. /**
  11441. * Internal dependencies
  11442. */
  11443. const deprecatedFlags = {
  11444. 'color.palette': settings => settings.colors === undefined ? undefined : settings.colors,
  11445. 'color.gradients': settings => settings.gradients === undefined ? undefined : settings.gradients,
  11446. 'color.custom': settings => settings.disableCustomColors === undefined ? undefined : !settings.disableCustomColors,
  11447. 'color.customGradient': settings => settings.disableCustomGradients === undefined ? undefined : !settings.disableCustomGradients,
  11448. 'typography.fontSizes': settings => settings.fontSizes === undefined ? undefined : settings.fontSizes,
  11449. 'typography.customFontSize': settings => settings.disableCustomFontSizes === undefined ? undefined : !settings.disableCustomFontSizes,
  11450. 'typography.customLineHeight': settings => settings.enableCustomLineHeight,
  11451. 'spacing.units': settings => {
  11452. if (settings.enableCustomUnits === undefined) {
  11453. return;
  11454. }
  11455. if (settings.enableCustomUnits === true) {
  11456. return ['px', 'em', 'rem', 'vh', 'vw', '%'];
  11457. }
  11458. return settings.enableCustomUnits;
  11459. },
  11460. 'spacing.customPadding': settings => settings.enableCustomSpacing
  11461. };
  11462. const PATHS_WITH_MERGE = {
  11463. 'color.gradients': true,
  11464. 'color.palette': true,
  11465. 'typography.fontFamilies': true,
  11466. 'typography.fontSizes': true
  11467. };
  11468. /**
  11469. * Hook that retrieves the editor setting.
  11470. * It works with nested objects using by finding the value at path.
  11471. *
  11472. * @param {string} path The path to the setting.
  11473. *
  11474. * @return {any} Returns the value defined for the setting.
  11475. *
  11476. * @example
  11477. * ```js
  11478. * const isEnabled = useSetting( 'typography.dropCap' );
  11479. * ```
  11480. */
  11481. function useSetting(path) {
  11482. const {
  11483. name: blockName
  11484. } = useBlockEditContext();
  11485. const setting = Object(external_wp_data_["useSelect"])(select => {
  11486. var _get;
  11487. const settings = select(store).getSettings(); // 1 - Use __experimental features, if available.
  11488. // We cascade to the all value if the block one is not available.
  11489. const defaultsPath = `__experimentalFeatures.${path}`;
  11490. const blockPath = `__experimentalFeatures.blocks.${blockName}.${path}`;
  11491. const experimentalFeaturesResult = (_get = Object(external_lodash_["get"])(settings, blockPath)) !== null && _get !== void 0 ? _get : Object(external_lodash_["get"])(settings, defaultsPath);
  11492. if (experimentalFeaturesResult !== undefined) {
  11493. if (PATHS_WITH_MERGE[path]) {
  11494. var _ref, _experimentalFeatures;
  11495. return (_ref = (_experimentalFeatures = experimentalFeaturesResult.user) !== null && _experimentalFeatures !== void 0 ? _experimentalFeatures : experimentalFeaturesResult.theme) !== null && _ref !== void 0 ? _ref : experimentalFeaturesResult.core;
  11496. }
  11497. return experimentalFeaturesResult;
  11498. } // 2 - Use deprecated settings, otherwise.
  11499. const deprecatedSettingsValue = deprecatedFlags[path] ? deprecatedFlags[path](settings) : undefined;
  11500. if (deprecatedSettingsValue !== undefined) {
  11501. return deprecatedSettingsValue;
  11502. } // 3 - Fall back for typography.dropCap:
  11503. // This is only necessary to support typography.dropCap.
  11504. // when __experimentalFeatures are not present (core without plugin).
  11505. // To remove when __experimentalFeatures are ported to core.
  11506. return path === 'typography.dropCap' ? true : undefined;
  11507. }, [blockName, path]);
  11508. return setting;
  11509. }
  11510. // EXTERNAL MODULE: ./node_modules/tinycolor2/tinycolor.js
  11511. var tinycolor = __webpack_require__("Zss7");
  11512. var tinycolor_default = /*#__PURE__*/__webpack_require__.n(tinycolor);
  11513. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/utils.js
  11514. /**
  11515. * External dependencies
  11516. */
  11517. /**
  11518. * Provided an array of color objects as set by the theme or by the editor defaults,
  11519. * and the values of the defined color or custom color returns a color object describing the color.
  11520. *
  11521. * @param {Array} colors Array of color objects as set by the theme or by the editor defaults.
  11522. * @param {?string} definedColor A string containing the color slug.
  11523. * @param {?string} customColor A string containing the customColor value.
  11524. *
  11525. * @return {?Object} If definedColor is passed and the name is found in colors,
  11526. * the color object exactly as set by the theme or editor defaults is returned.
  11527. * Otherwise, an object that just sets the color is defined.
  11528. */
  11529. const getColorObjectByAttributeValues = (colors, definedColor, customColor) => {
  11530. if (definedColor) {
  11531. const colorObj = Object(external_lodash_["find"])(colors, {
  11532. slug: definedColor
  11533. });
  11534. if (colorObj) {
  11535. return colorObj;
  11536. }
  11537. }
  11538. return {
  11539. color: customColor
  11540. };
  11541. };
  11542. /**
  11543. * Provided an array of color objects as set by the theme or by the editor defaults, and a color value returns the color object matching that value or undefined.
  11544. *
  11545. * @param {Array} colors Array of color objects as set by the theme or by the editor defaults.
  11546. * @param {?string} colorValue A string containing the color value.
  11547. *
  11548. * @return {?Object} Color object included in the colors array whose color property equals colorValue.
  11549. * Returns undefined if no color object matches this requirement.
  11550. */
  11551. const getColorObjectByColorValue = (colors, colorValue) => {
  11552. return Object(external_lodash_["find"])(colors, {
  11553. color: colorValue
  11554. });
  11555. };
  11556. /**
  11557. * Returns a class based on the context a color is being used and its slug.
  11558. *
  11559. * @param {string} colorContextName Context/place where color is being used e.g: background, text etc...
  11560. * @param {string} colorSlug Slug of the color.
  11561. *
  11562. * @return {?string} String with the class corresponding to the color in the provided context.
  11563. * Returns undefined if either colorContextName or colorSlug are not provided.
  11564. */
  11565. function getColorClassName(colorContextName, colorSlug) {
  11566. if (!colorContextName || !colorSlug) {
  11567. return undefined;
  11568. }
  11569. return `has-${Object(external_lodash_["kebabCase"])(colorSlug)}-${colorContextName}`;
  11570. }
  11571. /**
  11572. * Given an array of color objects and a color value returns the color value of the most readable color in the array.
  11573. *
  11574. * @param {Array} colors Array of color objects as set by the theme or by the editor defaults.
  11575. * @param {?string} colorValue A string containing the color value.
  11576. *
  11577. * @return {string} String with the color value of the most readable color.
  11578. */
  11579. function getMostReadableColor(colors, colorValue) {
  11580. return tinycolor_default.a.mostReadable(colorValue, Object(external_lodash_["map"])(colors, 'color')).toHexString();
  11581. }
  11582. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/gradients/use-gradient.js
  11583. /**
  11584. * External dependencies
  11585. */
  11586. /**
  11587. * WordPress dependencies
  11588. */
  11589. /**
  11590. * Internal dependencies
  11591. */
  11592. const use_gradient_EMPTY_ARRAY = [];
  11593. function __experimentalGetGradientClass(gradientSlug) {
  11594. if (!gradientSlug) {
  11595. return undefined;
  11596. }
  11597. return `has-${gradientSlug}-gradient-background`;
  11598. }
  11599. /**
  11600. * Retrieves the gradient value per slug.
  11601. *
  11602. * @param {Array} gradients Gradient Palette
  11603. * @param {string} slug Gradient slug
  11604. *
  11605. * @return {string} Gradient value.
  11606. */
  11607. function getGradientValueBySlug(gradients, slug) {
  11608. const gradient = Object(external_lodash_["find"])(gradients, ['slug', slug]);
  11609. return gradient && gradient.gradient;
  11610. }
  11611. function __experimentalGetGradientObjectByGradientValue(gradients, value) {
  11612. const gradient = Object(external_lodash_["find"])(gradients, ['gradient', value]);
  11613. return gradient;
  11614. }
  11615. /**
  11616. * Retrieves the gradient slug per slug.
  11617. *
  11618. * @param {Array} gradients Gradient Palette
  11619. * @param {string} value Gradient value
  11620. * @return {string} Gradient slug.
  11621. */
  11622. function getGradientSlugByValue(gradients, value) {
  11623. const gradient = __experimentalGetGradientObjectByGradientValue(gradients, value);
  11624. return gradient && gradient.slug;
  11625. }
  11626. function __experimentalUseGradient({
  11627. gradientAttribute = 'gradient',
  11628. customGradientAttribute = 'customGradient'
  11629. } = {}) {
  11630. const {
  11631. clientId
  11632. } = useBlockEditContext();
  11633. const gradients = useSetting('color.gradients') || use_gradient_EMPTY_ARRAY;
  11634. const {
  11635. gradient,
  11636. customGradient
  11637. } = Object(external_wp_data_["useSelect"])(select => {
  11638. const {
  11639. getBlockAttributes
  11640. } = select(store);
  11641. const attributes = getBlockAttributes(clientId) || {};
  11642. return {
  11643. customGradient: attributes[customGradientAttribute],
  11644. gradient: attributes[gradientAttribute]
  11645. };
  11646. }, [clientId, gradientAttribute, customGradientAttribute]);
  11647. const {
  11648. updateBlockAttributes
  11649. } = Object(external_wp_data_["useDispatch"])(store);
  11650. const setGradient = Object(external_wp_element_["useCallback"])(newGradientValue => {
  11651. const slug = getGradientSlugByValue(gradients, newGradientValue);
  11652. if (slug) {
  11653. updateBlockAttributes(clientId, {
  11654. [gradientAttribute]: slug,
  11655. [customGradientAttribute]: undefined
  11656. });
  11657. return;
  11658. }
  11659. updateBlockAttributes(clientId, {
  11660. [gradientAttribute]: undefined,
  11661. [customGradientAttribute]: newGradientValue
  11662. });
  11663. }, [gradients, clientId, updateBlockAttributes]);
  11664. const gradientClass = __experimentalGetGradientClass(gradient);
  11665. let gradientValue;
  11666. if (gradient) {
  11667. gradientValue = getGradientValueBySlug(gradients, gradient);
  11668. } else {
  11669. gradientValue = customGradient;
  11670. }
  11671. return {
  11672. gradientClass,
  11673. gradientValue,
  11674. setGradient
  11675. };
  11676. }
  11677. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/control.js
  11678. /**
  11679. * External dependencies
  11680. */
  11681. /**
  11682. * WordPress dependencies
  11683. */
  11684. /**
  11685. * Internal dependencies
  11686. */
  11687. // translators: first %s: the color name or value (e.g. red or #ff0000)
  11688. const colorIndicatorAriaLabel = Object(external_wp_i18n_["__"])('(Color: %s)'); // translators: first %s: the gradient name or value (e.g. red to green or linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)
  11689. const gradientIndicatorAriaLabel = Object(external_wp_i18n_["__"])('(Gradient: %s)');
  11690. const colorsAndGradientKeys = ['colors', 'disableCustomColors', 'gradients', 'disableCustomGradients'];
  11691. function VisualLabel({
  11692. colors,
  11693. gradients,
  11694. label,
  11695. currentTab,
  11696. colorValue,
  11697. gradientValue
  11698. }) {
  11699. let value, ariaLabel;
  11700. if (currentTab === 'color') {
  11701. if (colorValue) {
  11702. value = colorValue;
  11703. const colorObject = getColorObjectByColorValue(colors, value);
  11704. const colorName = colorObject && colorObject.name;
  11705. ariaLabel = Object(external_wp_i18n_["sprintf"])(colorIndicatorAriaLabel, colorName || value);
  11706. }
  11707. } else if (currentTab === 'gradient' && gradientValue) {
  11708. value = gradientValue;
  11709. const gradientObject = __experimentalGetGradientObjectByGradientValue(gradients, value);
  11710. const gradientName = gradientObject && gradientObject.name;
  11711. ariaLabel = Object(external_wp_i18n_["sprintf"])(gradientIndicatorAriaLabel, gradientName || value);
  11712. }
  11713. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, label, !!value && Object(external_wp_element_["createElement"])(external_wp_components_["ColorIndicator"], {
  11714. colorValue: value,
  11715. "aria-label": ariaLabel
  11716. }));
  11717. }
  11718. function ColorGradientControlInner({
  11719. colors,
  11720. gradients,
  11721. disableCustomColors,
  11722. disableCustomGradients,
  11723. className,
  11724. label,
  11725. onColorChange,
  11726. onGradientChange,
  11727. colorValue,
  11728. gradientValue,
  11729. clearable
  11730. }) {
  11731. const canChooseAColor = onColorChange && (!Object(external_lodash_["isEmpty"])(colors) || !disableCustomColors);
  11732. const canChooseAGradient = onGradientChange && (!Object(external_lodash_["isEmpty"])(gradients) || !disableCustomGradients);
  11733. const [currentTab, setCurrentTab] = Object(external_wp_element_["useState"])(gradientValue ? 'gradient' : !!canChooseAColor && 'color');
  11734. if (!canChooseAColor && !canChooseAGradient) {
  11735. return null;
  11736. }
  11737. return Object(external_wp_element_["createElement"])(external_wp_components_["BaseControl"], {
  11738. className: classnames_default()('block-editor-color-gradient-control', className)
  11739. }, Object(external_wp_element_["createElement"])("fieldset", null, Object(external_wp_element_["createElement"])("legend", null, Object(external_wp_element_["createElement"])("div", {
  11740. className: "block-editor-color-gradient-control__color-indicator"
  11741. }, Object(external_wp_element_["createElement"])(external_wp_components_["BaseControl"].VisualLabel, null, Object(external_wp_element_["createElement"])(VisualLabel, {
  11742. currentTab: currentTab,
  11743. label: label,
  11744. colorValue: colorValue,
  11745. gradientValue: gradientValue
  11746. })))), canChooseAColor && canChooseAGradient && Object(external_wp_element_["createElement"])(external_wp_components_["ButtonGroup"], {
  11747. className: "block-editor-color-gradient-control__button-tabs"
  11748. }, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  11749. isSmall: true,
  11750. isPressed: currentTab === 'color',
  11751. onClick: () => setCurrentTab('color')
  11752. }, Object(external_wp_i18n_["__"])('Solid')), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  11753. isSmall: true,
  11754. isPressed: currentTab === 'gradient',
  11755. onClick: () => setCurrentTab('gradient')
  11756. }, Object(external_wp_i18n_["__"])('Gradient'))), (currentTab === 'color' || !canChooseAGradient) && Object(external_wp_element_["createElement"])(external_wp_components_["ColorPalette"], {
  11757. value: colorValue,
  11758. onChange: canChooseAGradient ? newColor => {
  11759. onColorChange(newColor);
  11760. onGradientChange();
  11761. } : onColorChange,
  11762. colors,
  11763. disableCustomColors,
  11764. clearable: clearable
  11765. }), (currentTab === 'gradient' || !canChooseAColor) && Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalGradientPicker"], {
  11766. value: gradientValue,
  11767. onChange: canChooseAColor ? newGradient => {
  11768. onGradientChange(newGradient);
  11769. onColorChange();
  11770. } : onGradientChange,
  11771. gradients,
  11772. disableCustomGradients,
  11773. clearable: clearable
  11774. })));
  11775. }
  11776. function ColorGradientControlSelect(props) {
  11777. const colorGradientSettings = {};
  11778. colorGradientSettings.colors = useSetting('color.palette');
  11779. colorGradientSettings.gradients = useSetting('color.gradients');
  11780. colorGradientSettings.disableCustomColors = !useSetting('color.custom');
  11781. colorGradientSettings.disableCustomGradients = !useSetting('color.customGradient');
  11782. return Object(external_wp_element_["createElement"])(ColorGradientControlInner, Object(esm_extends["a" /* default */])({}, colorGradientSettings, props));
  11783. }
  11784. function ColorGradientControl(props) {
  11785. if (Object(external_lodash_["every"])(colorsAndGradientKeys, key => props.hasOwnProperty(key))) {
  11786. return Object(external_wp_element_["createElement"])(ColorGradientControlInner, props);
  11787. }
  11788. return Object(external_wp_element_["createElement"])(ColorGradientControlSelect, props);
  11789. }
  11790. /* harmony default export */ var control = (ColorGradientControl);
  11791. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/utils.js
  11792. /**
  11793. * External dependencies
  11794. */
  11795. /**
  11796. * Removed falsy values from nested object.
  11797. *
  11798. * @param {*} object
  11799. * @return {*} Object cleaned from falsy values
  11800. */
  11801. const cleanEmptyObject = object => {
  11802. if (!Object(external_lodash_["isObject"])(object) || Array.isArray(object)) {
  11803. return object;
  11804. }
  11805. const cleanedNestedObjects = Object(external_lodash_["pickBy"])(Object(external_lodash_["mapValues"])(object, cleanEmptyObject), external_lodash_["identity"]);
  11806. return Object(external_lodash_["isEmpty"])(cleanedNestedObjects) ? undefined : cleanedNestedObjects;
  11807. };
  11808. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/border-color.js
  11809. /**
  11810. * External dependencies
  11811. */
  11812. /**
  11813. * WordPress dependencies
  11814. */
  11815. /**
  11816. * Internal dependencies
  11817. */
  11818. // Defining empty array here instead of inline avoids unnecessary re-renders of
  11819. // color control.
  11820. const border_color_EMPTY_ARRAY = [];
  11821. /**
  11822. * Inspector control panel containing the border color related configuration.
  11823. *
  11824. * There is deliberate overlap between the colors and borders block supports
  11825. * relating to border color. It can be argued the border color controls could
  11826. * be included within either, or both, the colors and borders panels in the
  11827. * inspector controls. If they share the same block attributes it should not
  11828. * matter.
  11829. *
  11830. * @param {Object} props Block properties.
  11831. * @return {WPElement} Border color edit element.
  11832. */
  11833. function BorderColorEdit(props) {
  11834. var _style$border;
  11835. const {
  11836. attributes: {
  11837. borderColor,
  11838. style
  11839. },
  11840. setAttributes
  11841. } = props;
  11842. const colors = useSetting('color.palette') || border_color_EMPTY_ARRAY;
  11843. const disableCustomColors = !useSetting('color.custom');
  11844. const disableCustomGradients = !useSetting('color.customGradient');
  11845. const onChangeColor = value => {
  11846. const colorObject = getColorObjectByColorValue(colors, value);
  11847. const newStyle = { ...style,
  11848. border: { ...(style === null || style === void 0 ? void 0 : style.border),
  11849. color: colorObject !== null && colorObject !== void 0 && colorObject.slug ? undefined : value
  11850. }
  11851. }; // If empty slug, ensure undefined to remove attribute.
  11852. const newNamedColor = colorObject !== null && colorObject !== void 0 && colorObject.slug ? colorObject.slug : undefined;
  11853. setAttributes({
  11854. style: cleanEmptyObject(newStyle),
  11855. borderColor: newNamedColor
  11856. });
  11857. };
  11858. return Object(external_wp_element_["createElement"])(control, {
  11859. label: Object(external_wp_i18n_["__"])('Border color'),
  11860. value: borderColor || (style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.color),
  11861. colors: colors,
  11862. gradients: undefined,
  11863. disableCustomColors: disableCustomColors,
  11864. disableCustomGradients: disableCustomGradients,
  11865. onColorChange: onChangeColor
  11866. });
  11867. }
  11868. /**
  11869. * Filters registered block settings, extending attributes to include
  11870. * `borderColor` if needed.
  11871. *
  11872. * @param {Object} settings Original block settings.
  11873. * @return {Object} Updated block settings.
  11874. */
  11875. function addAttributes(settings) {
  11876. if (!hasBorderSupport(settings, 'color')) {
  11877. return settings;
  11878. } // Allow blocks to specify default value if needed.
  11879. if (settings.attributes.borderColor) {
  11880. return settings;
  11881. } // Add new borderColor attribute to block settings.
  11882. return { ...settings,
  11883. attributes: { ...settings.attributes,
  11884. borderColor: {
  11885. type: 'string'
  11886. }
  11887. }
  11888. };
  11889. }
  11890. /**
  11891. * Override props assigned to save component to inject border color.
  11892. *
  11893. * @param {Object} props Additional props applied to save element.
  11894. * @param {Object} blockType Block type definition.
  11895. * @param {Object} attributes Block's attributes
  11896. * @return {Object} Filtered props to apply to save element.
  11897. */
  11898. function border_color_addSaveProps(props, blockType, attributes) {
  11899. var _style$border2;
  11900. if (!hasBorderSupport(blockType, 'color') || shouldSkipSerialization(blockType)) {
  11901. return props;
  11902. }
  11903. const {
  11904. borderColor,
  11905. style
  11906. } = attributes;
  11907. const borderColorClass = getColorClassName('border-color', borderColor);
  11908. const newClassName = classnames_default()(props.className, {
  11909. 'has-border-color': borderColor || (style === null || style === void 0 ? void 0 : (_style$border2 = style.border) === null || _style$border2 === void 0 ? void 0 : _style$border2.color),
  11910. [borderColorClass]: !!borderColorClass
  11911. }); // If we are clearing the last of the previous classes in `className`
  11912. // set it to `undefined` to avoid rendering empty DOM attributes.
  11913. props.className = newClassName ? newClassName : undefined;
  11914. return props;
  11915. }
  11916. /**
  11917. * Filters the registered block settings to apply border color styles and
  11918. * classnames to the block edit wrapper.
  11919. *
  11920. * @param {Object} settings Original block settings.
  11921. * @return {Object} Filtered block settings.
  11922. */
  11923. function addEditProps(settings) {
  11924. if (!hasBorderSupport(settings, 'color') || shouldSkipSerialization(settings)) {
  11925. return settings;
  11926. }
  11927. const existingGetEditWrapperProps = settings.getEditWrapperProps;
  11928. settings.getEditWrapperProps = attributes => {
  11929. let props = {};
  11930. if (existingGetEditWrapperProps) {
  11931. props = existingGetEditWrapperProps(attributes);
  11932. }
  11933. return border_color_addSaveProps(props, settings, attributes);
  11934. };
  11935. return settings;
  11936. }
  11937. /**
  11938. * This adds inline styles for color palette colors.
  11939. * Ideally, this is not needed and themes should load their palettes on the editor.
  11940. *
  11941. * @param {Function} BlockListBlock Original component
  11942. * @return {Function} Wrapped component
  11943. */
  11944. const withBorderColorPaletteStyles = Object(external_wp_compose_["createHigherOrderComponent"])(BlockListBlock => props => {
  11945. var _getColorObjectByAttr, _props$wrapperProps;
  11946. const {
  11947. name,
  11948. attributes
  11949. } = props;
  11950. const {
  11951. borderColor
  11952. } = attributes;
  11953. const colors = useSetting('color.palette') || border_color_EMPTY_ARRAY;
  11954. if (!hasBorderSupport(name, 'color') || shouldSkipSerialization(name)) {
  11955. return Object(external_wp_element_["createElement"])(BlockListBlock, props);
  11956. }
  11957. const extraStyles = {
  11958. borderColor: borderColor ? (_getColorObjectByAttr = getColorObjectByAttributeValues(colors, borderColor)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color : undefined
  11959. };
  11960. let wrapperProps = props.wrapperProps;
  11961. wrapperProps = { ...props.wrapperProps,
  11962. style: { ...extraStyles,
  11963. ...((_props$wrapperProps = props.wrapperProps) === null || _props$wrapperProps === void 0 ? void 0 : _props$wrapperProps.style)
  11964. }
  11965. };
  11966. return Object(external_wp_element_["createElement"])(BlockListBlock, Object(esm_extends["a" /* default */])({}, props, {
  11967. wrapperProps: wrapperProps
  11968. }));
  11969. });
  11970. Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/border/addAttributes', addAttributes);
  11971. Object(external_wp_hooks_["addFilter"])('blocks.getSaveContent.extraProps', 'core/border/addSaveProps', border_color_addSaveProps);
  11972. Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/border/addEditProps', addEditProps);
  11973. Object(external_wp_hooks_["addFilter"])('editor.BlockListBlock', 'core/border/with-border-color-palette-styles', withBorderColorPaletteStyles);
  11974. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/border-radius.js
  11975. /**
  11976. * WordPress dependencies
  11977. */
  11978. /**
  11979. * Internal dependencies
  11980. */
  11981. const MIN_BORDER_RADIUS_VALUE = 0;
  11982. const MAX_BORDER_RADIUS_VALUE = 50;
  11983. /**
  11984. * Inspector control panel containing the border radius related configuration.
  11985. *
  11986. * @param {Object} props Block properties.
  11987. * @return {WPElement} Border radius edit element.
  11988. */
  11989. function BorderRadiusEdit(props) {
  11990. var _style$border;
  11991. const {
  11992. attributes: {
  11993. style
  11994. },
  11995. setAttributes
  11996. } = props;
  11997. const onChange = newRadius => {
  11998. let newStyle = { ...style,
  11999. border: { ...(style === null || style === void 0 ? void 0 : style.border),
  12000. radius: newRadius
  12001. }
  12002. };
  12003. if (newRadius === undefined) {
  12004. newStyle = cleanEmptyObject(newStyle);
  12005. }
  12006. setAttributes({
  12007. style: newStyle
  12008. });
  12009. };
  12010. return Object(external_wp_element_["createElement"])(external_wp_components_["RangeControl"], {
  12011. value: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.radius,
  12012. label: Object(external_wp_i18n_["__"])('Border radius'),
  12013. min: MIN_BORDER_RADIUS_VALUE,
  12014. max: MAX_BORDER_RADIUS_VALUE,
  12015. initialPosition: 0,
  12016. allowReset: true,
  12017. onChange: onChange
  12018. });
  12019. }
  12020. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/border-style-control/index.js
  12021. /**
  12022. * WordPress dependencies
  12023. */
  12024. const DEFAULT_STYLE = {
  12025. key: 'default',
  12026. name: Object(external_wp_i18n_["__"])('Default'),
  12027. style: {
  12028. borderStyle: undefined
  12029. }
  12030. };
  12031. const BORDER_STYLES = [DEFAULT_STYLE, {
  12032. key: 'none',
  12033. name: Object(external_wp_i18n_["__"])('None'),
  12034. style: {
  12035. borderStyle: 'none'
  12036. }
  12037. }, {
  12038. key: 'solid',
  12039. name: Object(external_wp_i18n_["__"])('Solid'),
  12040. style: {
  12041. borderStyle: 'solid'
  12042. }
  12043. }, {
  12044. key: 'dashed',
  12045. name: Object(external_wp_i18n_["__"])('Dashed'),
  12046. style: {
  12047. borderStyle: 'dashed'
  12048. }
  12049. }, {
  12050. key: 'dotted',
  12051. name: Object(external_wp_i18n_["__"])('Dotted'),
  12052. style: {
  12053. borderStyle: 'dotted'
  12054. }
  12055. }];
  12056. /**
  12057. * Control to display border style options.
  12058. *
  12059. * @param {Object} props Component props.
  12060. * @param {Object} props.onChange Handler for changing border style selection.
  12061. * @param {Object} props.value Currently selected border style value.
  12062. *
  12063. * @return {WPElement} Custom border style select control.
  12064. */
  12065. function BorderStyleControl({
  12066. onChange,
  12067. value
  12068. }) {
  12069. const style = BORDER_STYLES.find(option => option.key === value);
  12070. return Object(external_wp_element_["createElement"])("fieldset", {
  12071. className: "components-border-style-control"
  12072. }, Object(external_wp_element_["createElement"])(external_wp_components_["CustomSelectControl"], {
  12073. className: "components-border-style-control__select",
  12074. label: Object(external_wp_i18n_["__"])('Border style'),
  12075. options: BORDER_STYLES,
  12076. value: style || DEFAULT_STYLE,
  12077. onChange: ({
  12078. selectedItem
  12079. }) => selectedItem.key === 'default' ? onChange(undefined) : onChange(selectedItem.key)
  12080. }));
  12081. }
  12082. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/border-style.js
  12083. /**
  12084. * Internal dependencies
  12085. */
  12086. /**
  12087. * Inspector control for configuring border style property.
  12088. *
  12089. * @param {Object} props Block properties.
  12090. * @return {WPElement} Border style edit element.
  12091. */
  12092. const BorderStyleEdit = props => {
  12093. var _style$border;
  12094. const {
  12095. attributes: {
  12096. style
  12097. },
  12098. setAttributes
  12099. } = props;
  12100. const onChange = newBorderStyle => {
  12101. const newStyleAttributes = { ...style,
  12102. border: { ...(style === null || style === void 0 ? void 0 : style.border),
  12103. style: newBorderStyle
  12104. }
  12105. };
  12106. setAttributes({
  12107. style: cleanEmptyObject(newStyleAttributes)
  12108. });
  12109. };
  12110. return Object(external_wp_element_["createElement"])(BorderStyleControl, {
  12111. value: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.style,
  12112. onChange: onChange
  12113. });
  12114. };
  12115. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/border-width.js
  12116. /**
  12117. * WordPress dependencies
  12118. */
  12119. /**
  12120. * Internal dependencies
  12121. */
  12122. const MIN_BORDER_WIDTH = 0;
  12123. const MAX_BORDER_WIDTH = 50;
  12124. /**
  12125. * Inspector control for configuring border width property.
  12126. *
  12127. * @param {Object} props Block properties.
  12128. * @return {WPElement} Border width edit element.
  12129. */
  12130. const BorderWidthEdit = props => {
  12131. var _style$border;
  12132. const {
  12133. attributes: {
  12134. style
  12135. },
  12136. setAttributes
  12137. } = props;
  12138. const onChange = newWidth => {
  12139. const newStyle = { ...style,
  12140. border: { ...(style === null || style === void 0 ? void 0 : style.border),
  12141. width: newWidth
  12142. }
  12143. };
  12144. setAttributes({
  12145. style: cleanEmptyObject(newStyle)
  12146. });
  12147. };
  12148. return Object(external_wp_element_["createElement"])(external_wp_components_["RangeControl"], {
  12149. value: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.width,
  12150. label: Object(external_wp_i18n_["__"])('Border width'),
  12151. min: MIN_BORDER_WIDTH,
  12152. max: MAX_BORDER_WIDTH,
  12153. initialPosition: 0,
  12154. allowReset: true,
  12155. onChange: onChange
  12156. });
  12157. };
  12158. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/border.js
  12159. /**
  12160. * WordPress dependencies
  12161. */
  12162. /**
  12163. * Internal dependencies
  12164. */
  12165. const BORDER_SUPPORT_KEY = '__experimentalBorder';
  12166. function BorderPanel(props) {
  12167. const isDisabled = useIsBorderDisabled(props);
  12168. const isSupported = hasBorderSupport(props.name);
  12169. const isColorSupported = useSetting('border.customColor') && hasBorderSupport(props.name, 'color');
  12170. const isRadiusSupported = useSetting('border.customRadius') && hasBorderSupport(props.name, 'radius');
  12171. const isStyleSupported = useSetting('border.customStyle') && hasBorderSupport(props.name, 'style');
  12172. const isWidthSupported = useSetting('border.customWidth') && hasBorderSupport(props.name, 'width');
  12173. if (isDisabled || !isSupported) {
  12174. return null;
  12175. }
  12176. return Object(external_wp_element_["createElement"])(inspector_controls, null, Object(external_wp_element_["createElement"])(external_wp_components_["PanelBody"], {
  12177. title: Object(external_wp_i18n_["__"])('Border settings'),
  12178. initialOpen: false
  12179. }, isStyleSupported && Object(external_wp_element_["createElement"])(BorderStyleEdit, props), isWidthSupported && Object(external_wp_element_["createElement"])(BorderWidthEdit, props), isRadiusSupported && Object(external_wp_element_["createElement"])(BorderRadiusEdit, props), isColorSupported && Object(external_wp_element_["createElement"])(BorderColorEdit, props)));
  12180. }
  12181. /**
  12182. * Determine whether there is block support for border properties.
  12183. *
  12184. * @param {string} blockName Block name.
  12185. * @param {string} feature Border feature to check support for.
  12186. * @return {boolean} Whether there is support.
  12187. */
  12188. function hasBorderSupport(blockName, feature = 'any') {
  12189. if (external_wp_element_["Platform"].OS !== 'web') {
  12190. return false;
  12191. }
  12192. const support = Object(external_wp_blocks_["getBlockSupport"])(blockName, BORDER_SUPPORT_KEY);
  12193. if (support === true) {
  12194. return true;
  12195. }
  12196. if (feature === 'any') {
  12197. return !!(support !== null && support !== void 0 && support.color || support !== null && support !== void 0 && support.radius || support !== null && support !== void 0 && support.width || support !== null && support !== void 0 && support.style);
  12198. }
  12199. return !!(support !== null && support !== void 0 && support[feature]);
  12200. }
  12201. /**
  12202. * Check whether serialization of border classes and styles should be skipped.
  12203. *
  12204. * @param {string|Object} blockType Block name or block type object.
  12205. * @return {boolean} Whether serialization of border properties should occur.
  12206. */
  12207. function shouldSkipSerialization(blockType) {
  12208. const support = Object(external_wp_blocks_["getBlockSupport"])(blockType, BORDER_SUPPORT_KEY);
  12209. return support === null || support === void 0 ? void 0 : support.__experimentalSkipSerialization;
  12210. }
  12211. /**
  12212. * Determines if all border support features have been disabled.
  12213. *
  12214. * @return {boolean} If border support is completely disabled.
  12215. */
  12216. const useIsBorderDisabled = () => {
  12217. const configs = [!useSetting('border.customColor'), !useSetting('border.customRadius'), !useSetting('border.customStyle'), !useSetting('border.customWidth')];
  12218. return configs.every(Boolean);
  12219. };
  12220. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/panel-color-gradient-settings.js
  12221. /**
  12222. * External dependencies
  12223. */
  12224. /**
  12225. * WordPress dependencies
  12226. */
  12227. /**
  12228. * Internal dependencies
  12229. */
  12230. // translators: first %s: The type of color or gradient (e.g. background, overlay...), second %s: the color name or value (e.g. red or #ff0000)
  12231. const panel_color_gradient_settings_colorIndicatorAriaLabel = Object(external_wp_i18n_["__"])('(%s: color %s)'); // translators: first %s: The type of color or gradient (e.g. background, overlay...), second %s: the color name or value (e.g. red or #ff0000)
  12232. const panel_color_gradient_settings_gradientIndicatorAriaLabel = Object(external_wp_i18n_["__"])('(%s: gradient %s)');
  12233. const panel_color_gradient_settings_colorsAndGradientKeys = ['colors', 'disableCustomColors', 'gradients', 'disableCustomGradients'];
  12234. const Indicators = ({
  12235. colors,
  12236. gradients,
  12237. settings
  12238. }) => {
  12239. return settings.map(({
  12240. colorValue,
  12241. gradientValue,
  12242. label,
  12243. colors: availableColors,
  12244. gradients: availableGradients
  12245. }, index) => {
  12246. if (!colorValue && !gradientValue) {
  12247. return null;
  12248. }
  12249. let ariaLabel;
  12250. if (colorValue) {
  12251. const colorObject = getColorObjectByColorValue(availableColors || colors, colorValue);
  12252. ariaLabel = Object(external_wp_i18n_["sprintf"])(panel_color_gradient_settings_colorIndicatorAriaLabel, label.toLowerCase(), colorObject && colorObject.name || colorValue);
  12253. } else {
  12254. const gradientObject = __experimentalGetGradientObjectByGradientValue(availableGradients || gradients, colorValue);
  12255. ariaLabel = Object(external_wp_i18n_["sprintf"])(panel_color_gradient_settings_gradientIndicatorAriaLabel, label.toLowerCase(), gradientObject && gradientObject.name || gradientValue);
  12256. }
  12257. return Object(external_wp_element_["createElement"])(external_wp_components_["ColorIndicator"], {
  12258. key: index,
  12259. colorValue: colorValue || gradientValue,
  12260. "aria-label": ariaLabel
  12261. });
  12262. });
  12263. };
  12264. const PanelColorGradientSettingsInner = ({
  12265. className,
  12266. colors,
  12267. gradients,
  12268. disableCustomColors,
  12269. disableCustomGradients,
  12270. children,
  12271. settings,
  12272. title,
  12273. ...props
  12274. }) => {
  12275. if (Object(external_lodash_["isEmpty"])(colors) && Object(external_lodash_["isEmpty"])(gradients) && disableCustomColors && disableCustomGradients && Object(external_lodash_["every"])(settings, setting => Object(external_lodash_["isEmpty"])(setting.colors) && Object(external_lodash_["isEmpty"])(setting.gradients) && (setting.disableCustomColors === undefined || setting.disableCustomColors) && (setting.disableCustomGradients === undefined || setting.disableCustomGradients))) {
  12276. return null;
  12277. }
  12278. const titleElement = Object(external_wp_element_["createElement"])("span", {
  12279. className: "block-editor-panel-color-gradient-settings__panel-title"
  12280. }, title, Object(external_wp_element_["createElement"])(Indicators, {
  12281. colors: colors,
  12282. gradients: gradients,
  12283. settings: settings
  12284. }));
  12285. return Object(external_wp_element_["createElement"])(external_wp_components_["PanelBody"], Object(esm_extends["a" /* default */])({
  12286. className: classnames_default()('block-editor-panel-color-gradient-settings', className),
  12287. title: titleElement
  12288. }, props), settings.map((setting, index) => Object(external_wp_element_["createElement"])(control, Object(esm_extends["a" /* default */])({
  12289. key: index,
  12290. colors,
  12291. gradients,
  12292. disableCustomColors,
  12293. disableCustomGradients
  12294. }, setting))), children);
  12295. };
  12296. const PanelColorGradientSettingsSelect = props => {
  12297. const colorGradientSettings = {};
  12298. colorGradientSettings.colors = useSetting('color.palette');
  12299. colorGradientSettings.gradients = useSetting('color.gradients');
  12300. colorGradientSettings.disableCustomColors = !useSetting('color.custom');
  12301. colorGradientSettings.disableCustomGradients = !useSetting('color.customGradient');
  12302. return Object(external_wp_element_["createElement"])(PanelColorGradientSettingsInner, Object(esm_extends["a" /* default */])({}, colorGradientSettings, props));
  12303. };
  12304. const PanelColorGradientSettings = props => {
  12305. if (Object(external_lodash_["every"])(panel_color_gradient_settings_colorsAndGradientKeys, key => props.hasOwnProperty(key))) {
  12306. return Object(external_wp_element_["createElement"])(PanelColorGradientSettingsInner, props);
  12307. }
  12308. return Object(external_wp_element_["createElement"])(PanelColorGradientSettingsSelect, props);
  12309. };
  12310. /* harmony default export */ var panel_color_gradient_settings = (PanelColorGradientSettings);
  12311. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/contrast-checker/index.js
  12312. /**
  12313. * External dependencies
  12314. */
  12315. /**
  12316. * WordPress dependencies
  12317. */
  12318. function ContrastCheckerMessage({
  12319. tinyBackgroundColor,
  12320. tinyTextColor,
  12321. backgroundColor,
  12322. textColor
  12323. }) {
  12324. const msg = tinyBackgroundColor.getBrightness() < tinyTextColor.getBrightness() ? Object(external_wp_i18n_["__"])('This color combination may be hard for people to read. Try using a darker background color and/or a brighter text color.') : Object(external_wp_i18n_["__"])('This color combination may be hard for people to read. Try using a brighter background color and/or a darker text color.'); // Note: The `Notice` component can speak messages via its `spokenMessage`
  12325. // prop, but the contrast checker requires granular control over when the
  12326. // announcements are made. Notably, the message will be re-announced if a
  12327. // new color combination is selected and the contrast is still insufficient.
  12328. Object(external_wp_element_["useEffect"])(() => {
  12329. Object(external_wp_a11y_["speak"])(Object(external_wp_i18n_["__"])('This color combination may be hard for people to read.'));
  12330. }, [backgroundColor, textColor]);
  12331. return Object(external_wp_element_["createElement"])("div", {
  12332. className: "block-editor-contrast-checker"
  12333. }, Object(external_wp_element_["createElement"])(external_wp_components_["Notice"], {
  12334. spokenMessage: null,
  12335. status: "warning",
  12336. isDismissible: false
  12337. }, msg));
  12338. }
  12339. function ContrastChecker({
  12340. backgroundColor,
  12341. fallbackBackgroundColor,
  12342. fallbackTextColor,
  12343. fontSize,
  12344. // font size value in pixels
  12345. isLargeText,
  12346. textColor
  12347. }) {
  12348. if (!(backgroundColor || fallbackBackgroundColor) || !(textColor || fallbackTextColor)) {
  12349. return null;
  12350. }
  12351. const tinyBackgroundColor = tinycolor_default()(backgroundColor || fallbackBackgroundColor);
  12352. const tinyTextColor = tinycolor_default()(textColor || fallbackTextColor);
  12353. const hasTransparency = tinyBackgroundColor.getAlpha() !== 1 || tinyTextColor.getAlpha() !== 1;
  12354. if (hasTransparency || tinycolor_default.a.isReadable(tinyBackgroundColor, tinyTextColor, {
  12355. level: 'AA',
  12356. size: isLargeText || isLargeText !== false && fontSize >= 24 ? 'large' : 'small'
  12357. })) {
  12358. return null;
  12359. }
  12360. return Object(external_wp_element_["createElement"])(ContrastCheckerMessage, {
  12361. backgroundColor: backgroundColor,
  12362. textColor: textColor,
  12363. tinyBackgroundColor: tinyBackgroundColor,
  12364. tinyTextColor: tinyTextColor
  12365. });
  12366. }
  12367. /* harmony default export */ var contrast_checker = (ContrastChecker);
  12368. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/provider/block-refs-provider.js
  12369. /**
  12370. * WordPress dependencies
  12371. */
  12372. const BlockRefs = Object(external_wp_element_["createContext"])();
  12373. function BlockRefsProvider({
  12374. children
  12375. }) {
  12376. const value = Object(external_wp_element_["useMemo"])(() => ({
  12377. refs: new Map(),
  12378. callbacks: new Map()
  12379. }), []);
  12380. return Object(external_wp_element_["createElement"])(BlockRefs.Provider, {
  12381. value: value
  12382. }, children);
  12383. }
  12384. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-refs.js
  12385. /**
  12386. * WordPress dependencies
  12387. */
  12388. /**
  12389. * Internal dependencies
  12390. */
  12391. /** @typedef {import('@wordpress/element').RefCallback} RefCallback */
  12392. /** @typedef {import('@wordpress/element').RefObject} RefObject */
  12393. /**
  12394. * Provides a ref to the BlockRefs context.
  12395. *
  12396. * @param {string} clientId The client ID of the element ref.
  12397. *
  12398. * @return {RefCallback} Ref callback.
  12399. */
  12400. function useBlockRefProvider(clientId) {
  12401. const {
  12402. refs,
  12403. callbacks
  12404. } = Object(external_wp_element_["useContext"])(BlockRefs);
  12405. const ref = Object(external_wp_element_["useRef"])();
  12406. Object(external_wp_element_["useLayoutEffect"])(() => {
  12407. refs.set(ref, clientId);
  12408. return () => {
  12409. refs.delete(ref);
  12410. };
  12411. }, [clientId]);
  12412. return Object(external_wp_compose_["useRefEffect"])(element => {
  12413. // Update the ref in the provider.
  12414. ref.current = element; // Call any update functions.
  12415. callbacks.forEach((id, setElement) => {
  12416. if (clientId === id) {
  12417. setElement(element);
  12418. }
  12419. });
  12420. }, [clientId]);
  12421. }
  12422. /**
  12423. * Gets a ref pointing to the current block element. Continues to return a
  12424. * stable ref even if the block client ID changes.
  12425. *
  12426. * @param {string} clientId The client ID to get a ref for.
  12427. *
  12428. * @return {RefObject} A ref containing the element.
  12429. */
  12430. function useBlockRef(clientId) {
  12431. const {
  12432. refs
  12433. } = Object(external_wp_element_["useContext"])(BlockRefs);
  12434. const freshClientId = Object(external_wp_element_["useRef"])();
  12435. freshClientId.current = clientId; // Always return an object, even if no ref exists for a given client ID, so
  12436. // that `current` works at a later point.
  12437. return Object(external_wp_element_["useMemo"])(() => ({
  12438. get current() {
  12439. let element = null; // Multiple refs may be created for a single block. Find the
  12440. // first that has an element set.
  12441. for (const [ref, id] of refs.entries()) {
  12442. if (id === freshClientId.current && ref.current) {
  12443. element = ref.current;
  12444. }
  12445. }
  12446. return element;
  12447. }
  12448. }), []);
  12449. }
  12450. /**
  12451. * Return the element for a given client ID. Updates whenever the element
  12452. * changes, becomes available, or disappears.
  12453. *
  12454. * @param {string} clientId The client ID to an element for.
  12455. *
  12456. * @return {Element|null} The block's wrapper element.
  12457. */
  12458. function useBlockElement(clientId) {
  12459. const {
  12460. callbacks
  12461. } = Object(external_wp_element_["useContext"])(BlockRefs);
  12462. const ref = useBlockRef(clientId);
  12463. const [element, setElement] = Object(external_wp_element_["useState"])(null);
  12464. Object(external_wp_element_["useLayoutEffect"])(() => {
  12465. if (!clientId) {
  12466. return;
  12467. }
  12468. callbacks.set(setElement, clientId);
  12469. return () => {
  12470. callbacks.delete(setElement);
  12471. };
  12472. }, [clientId]);
  12473. return ref.current || element;
  12474. }
  12475. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/color-panel.js
  12476. /**
  12477. * WordPress dependencies
  12478. */
  12479. /**
  12480. * Internal dependencies
  12481. */
  12482. function getComputedStyle(node) {
  12483. return node.ownerDocument.defaultView.getComputedStyle(node);
  12484. }
  12485. function ColorPanel({
  12486. settings,
  12487. clientId,
  12488. enableContrastChecking = true
  12489. }) {
  12490. const [detectedBackgroundColor, setDetectedBackgroundColor] = Object(external_wp_element_["useState"])();
  12491. const [detectedColor, setDetectedColor] = Object(external_wp_element_["useState"])();
  12492. const ref = useBlockRef(clientId);
  12493. Object(external_wp_element_["useEffect"])(() => {
  12494. if (!enableContrastChecking) {
  12495. return;
  12496. }
  12497. if (!ref.current) {
  12498. return;
  12499. }
  12500. setDetectedColor(getComputedStyle(ref.current).color);
  12501. let backgroundColorNode = ref.current;
  12502. let backgroundColor = getComputedStyle(backgroundColorNode).backgroundColor;
  12503. while (backgroundColor === 'rgba(0, 0, 0, 0)' && backgroundColorNode.parentNode && backgroundColorNode.parentNode.nodeType === backgroundColorNode.parentNode.ELEMENT_NODE) {
  12504. backgroundColorNode = backgroundColorNode.parentNode;
  12505. backgroundColor = getComputedStyle(backgroundColorNode).backgroundColor;
  12506. }
  12507. setDetectedBackgroundColor(backgroundColor);
  12508. });
  12509. return Object(external_wp_element_["createElement"])(inspector_controls, null, Object(external_wp_element_["createElement"])(panel_color_gradient_settings, {
  12510. title: Object(external_wp_i18n_["__"])('Color'),
  12511. initialOpen: false,
  12512. settings: settings
  12513. }, enableContrastChecking && Object(external_wp_element_["createElement"])(contrast_checker, {
  12514. backgroundColor: detectedBackgroundColor,
  12515. textColor: detectedColor
  12516. })));
  12517. }
  12518. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/color.js
  12519. /**
  12520. * External dependencies
  12521. */
  12522. /**
  12523. * WordPress dependencies
  12524. */
  12525. /**
  12526. * Internal dependencies
  12527. */
  12528. const COLOR_SUPPORT_KEY = 'color';
  12529. const color_EMPTY_ARRAY = [];
  12530. const hasColorSupport = blockType => {
  12531. const colorSupport = Object(external_wp_blocks_["getBlockSupport"])(blockType, COLOR_SUPPORT_KEY);
  12532. return colorSupport && (colorSupport.link === true || colorSupport.gradient === true || colorSupport.background !== false || colorSupport.text !== false);
  12533. };
  12534. const color_shouldSkipSerialization = blockType => {
  12535. const colorSupport = Object(external_wp_blocks_["getBlockSupport"])(blockType, COLOR_SUPPORT_KEY);
  12536. return colorSupport === null || colorSupport === void 0 ? void 0 : colorSupport.__experimentalSkipSerialization;
  12537. };
  12538. const hasLinkColorSupport = blockType => {
  12539. if (external_wp_element_["Platform"].OS !== 'web') {
  12540. return false;
  12541. }
  12542. const colorSupport = Object(external_wp_blocks_["getBlockSupport"])(blockType, COLOR_SUPPORT_KEY);
  12543. return Object(external_lodash_["isObject"])(colorSupport) && !!colorSupport.link;
  12544. };
  12545. const hasGradientSupport = blockType => {
  12546. if (external_wp_element_["Platform"].OS !== 'web') {
  12547. return false;
  12548. }
  12549. const colorSupport = Object(external_wp_blocks_["getBlockSupport"])(blockType, COLOR_SUPPORT_KEY);
  12550. return Object(external_lodash_["isObject"])(colorSupport) && !!colorSupport.gradients;
  12551. };
  12552. const hasBackgroundColorSupport = blockType => {
  12553. const colorSupport = Object(external_wp_blocks_["getBlockSupport"])(blockType, COLOR_SUPPORT_KEY);
  12554. return colorSupport && colorSupport.background !== false;
  12555. };
  12556. const hasTextColorSupport = blockType => {
  12557. const colorSupport = Object(external_wp_blocks_["getBlockSupport"])(blockType, COLOR_SUPPORT_KEY);
  12558. return colorSupport && colorSupport.text !== false;
  12559. };
  12560. /**
  12561. * Filters registered block settings, extending attributes to include
  12562. * `backgroundColor` and `textColor` attribute.
  12563. *
  12564. * @param {Object} settings Original block settings
  12565. * @return {Object} Filtered block settings
  12566. */
  12567. function color_addAttributes(settings) {
  12568. if (!hasColorSupport(settings)) {
  12569. return settings;
  12570. } // allow blocks to specify their own attribute definition with default values if needed.
  12571. if (!settings.attributes.backgroundColor) {
  12572. Object.assign(settings.attributes, {
  12573. backgroundColor: {
  12574. type: 'string'
  12575. }
  12576. });
  12577. }
  12578. if (!settings.attributes.textColor) {
  12579. Object.assign(settings.attributes, {
  12580. textColor: {
  12581. type: 'string'
  12582. }
  12583. });
  12584. }
  12585. if (hasGradientSupport(settings) && !settings.attributes.gradient) {
  12586. Object.assign(settings.attributes, {
  12587. gradient: {
  12588. type: 'string'
  12589. }
  12590. });
  12591. }
  12592. return settings;
  12593. }
  12594. /**
  12595. * Override props assigned to save component to inject colors classnames.
  12596. *
  12597. * @param {Object} props Additional props applied to save element
  12598. * @param {Object} blockType Block type
  12599. * @param {Object} attributes Block attributes
  12600. * @return {Object} Filtered props applied to save element
  12601. */
  12602. function color_addSaveProps(props, blockType, attributes) {
  12603. var _style$color, _style$color2, _style$color3, _style$color4, _style$elements, _style$elements$link;
  12604. if (!hasColorSupport(blockType) || color_shouldSkipSerialization(blockType)) {
  12605. return props;
  12606. }
  12607. const hasGradient = hasGradientSupport(blockType); // I'd have prefered to avoid the "style" attribute usage here
  12608. const {
  12609. backgroundColor,
  12610. textColor,
  12611. gradient,
  12612. style
  12613. } = attributes;
  12614. const backgroundClass = getColorClassName('background-color', backgroundColor);
  12615. const gradientClass = __experimentalGetGradientClass(gradient);
  12616. const textClass = getColorClassName('color', textColor);
  12617. const newClassName = classnames_default()(props.className, textClass, gradientClass, {
  12618. // Don't apply the background class if there's a custom gradient
  12619. [backgroundClass]: (!hasGradient || !(style !== null && style !== void 0 && (_style$color = style.color) !== null && _style$color !== void 0 && _style$color.gradient)) && !!backgroundClass,
  12620. 'has-text-color': textColor || (style === null || style === void 0 ? void 0 : (_style$color2 = style.color) === null || _style$color2 === void 0 ? void 0 : _style$color2.text),
  12621. 'has-background': backgroundColor || (style === null || style === void 0 ? void 0 : (_style$color3 = style.color) === null || _style$color3 === void 0 ? void 0 : _style$color3.background) || hasGradient && (gradient || (style === null || style === void 0 ? void 0 : (_style$color4 = style.color) === null || _style$color4 === void 0 ? void 0 : _style$color4.gradient)),
  12622. 'has-link-color': style === null || style === void 0 ? void 0 : (_style$elements = style.elements) === null || _style$elements === void 0 ? void 0 : (_style$elements$link = _style$elements.link) === null || _style$elements$link === void 0 ? void 0 : _style$elements$link.color
  12623. });
  12624. props.className = newClassName ? newClassName : undefined;
  12625. return props;
  12626. }
  12627. /**
  12628. * Filters registered block settings to extand the block edit wrapper
  12629. * to apply the desired styles and classnames properly.
  12630. *
  12631. * @param {Object} settings Original block settings
  12632. * @return {Object} Filtered block settings
  12633. */
  12634. function color_addEditProps(settings) {
  12635. if (!hasColorSupport(settings) || color_shouldSkipSerialization(settings)) {
  12636. return settings;
  12637. }
  12638. const existingGetEditWrapperProps = settings.getEditWrapperProps;
  12639. settings.getEditWrapperProps = attributes => {
  12640. let props = {};
  12641. if (existingGetEditWrapperProps) {
  12642. props = existingGetEditWrapperProps(attributes);
  12643. }
  12644. return color_addSaveProps(props, settings, attributes);
  12645. };
  12646. return settings;
  12647. }
  12648. const getLinkColorFromAttributeValue = (colors, value) => {
  12649. const attributeParsed = /var:preset\|color\|(.+)/.exec(value);
  12650. if (attributeParsed && attributeParsed[1]) {
  12651. return getColorObjectByAttributeValues(colors, attributeParsed[1]).color;
  12652. }
  12653. return value;
  12654. };
  12655. function immutableSet(object, path, value) {
  12656. return Object(external_lodash_["setWith"])(object ? Object(external_lodash_["clone"])(object) : {}, path, value, external_lodash_["clone"]);
  12657. }
  12658. /**
  12659. * Inspector control panel containing the color related configuration
  12660. *
  12661. * @param {Object} props
  12662. *
  12663. * @return {WPElement} Color edit element.
  12664. */
  12665. function ColorEdit(props) {
  12666. var _style$color6, _style$color7, _style$color8, _style$elements2, _style$elements2$link, _style$elements2$link2, _style$elements3, _style$elements3$link, _style$elements3$link2;
  12667. const {
  12668. name: blockName,
  12669. attributes
  12670. } = props;
  12671. const solids = useSetting('color.palette') || color_EMPTY_ARRAY;
  12672. const gradients = useSetting('color.gradients') || color_EMPTY_ARRAY;
  12673. const areCustomSolidsEnabled = useSetting('color.custom');
  12674. const areCustomGradientsEnabled = useSetting('color.customGradient');
  12675. const isLinkEnabled = useSetting('color.link'); // Shouldn't be needed but right now the ColorGradientsPanel
  12676. // can trigger both onChangeColor and onChangeBackground
  12677. // synchronously causing our two callbacks to override changes
  12678. // from each other.
  12679. const localAttributes = Object(external_wp_element_["useRef"])(attributes);
  12680. Object(external_wp_element_["useEffect"])(() => {
  12681. localAttributes.current = attributes;
  12682. }, [attributes]);
  12683. if (!hasColorSupport(blockName) || external_wp_element_["Platform"].OS !== 'web') {
  12684. return null;
  12685. }
  12686. const hasLinkColor = hasLinkColorSupport(blockName) && isLinkEnabled && (solids.length > 0 || areCustomSolidsEnabled);
  12687. const hasTextColor = hasTextColorSupport(blockName) && (solids.length > 0 || areCustomSolidsEnabled);
  12688. const hasBackgroundColor = hasBackgroundColorSupport(blockName) && (solids.length > 0 || areCustomSolidsEnabled);
  12689. const hasGradientColor = hasGradientSupport(blockName) && (gradients.length > 0 || areCustomGradientsEnabled);
  12690. if (!hasLinkColor && !hasTextColor && !hasBackgroundColor && !hasGradientColor) {
  12691. return null;
  12692. }
  12693. const {
  12694. style,
  12695. textColor,
  12696. backgroundColor,
  12697. gradient
  12698. } = attributes;
  12699. let gradientValue;
  12700. if (hasGradientColor && gradient) {
  12701. gradientValue = getGradientValueBySlug(gradients, gradient);
  12702. } else if (hasGradientColor) {
  12703. var _style$color5;
  12704. gradientValue = style === null || style === void 0 ? void 0 : (_style$color5 = style.color) === null || _style$color5 === void 0 ? void 0 : _style$color5.gradient;
  12705. }
  12706. const onChangeColor = name => value => {
  12707. var _localAttributes$curr, _localAttributes$curr2;
  12708. const colorObject = getColorObjectByColorValue(solids, value);
  12709. const attributeName = name + 'Color';
  12710. const newStyle = { ...localAttributes.current.style,
  12711. color: { ...((_localAttributes$curr = localAttributes.current) === null || _localAttributes$curr === void 0 ? void 0 : (_localAttributes$curr2 = _localAttributes$curr.style) === null || _localAttributes$curr2 === void 0 ? void 0 : _localAttributes$curr2.color),
  12712. [name]: colorObject !== null && colorObject !== void 0 && colorObject.slug ? undefined : value
  12713. }
  12714. };
  12715. const newNamedColor = colorObject !== null && colorObject !== void 0 && colorObject.slug ? colorObject.slug : undefined;
  12716. const newAttributes = {
  12717. style: cleanEmptyObject(newStyle),
  12718. [attributeName]: newNamedColor
  12719. };
  12720. props.setAttributes(newAttributes);
  12721. localAttributes.current = { ...localAttributes.current,
  12722. ...newAttributes
  12723. };
  12724. };
  12725. const onChangeGradient = value => {
  12726. const slug = getGradientSlugByValue(gradients, value);
  12727. let newAttributes;
  12728. if (slug) {
  12729. var _localAttributes$curr3, _localAttributes$curr4, _localAttributes$curr5;
  12730. const newStyle = { ...((_localAttributes$curr3 = localAttributes.current) === null || _localAttributes$curr3 === void 0 ? void 0 : _localAttributes$curr3.style),
  12731. color: { ...((_localAttributes$curr4 = localAttributes.current) === null || _localAttributes$curr4 === void 0 ? void 0 : (_localAttributes$curr5 = _localAttributes$curr4.style) === null || _localAttributes$curr5 === void 0 ? void 0 : _localAttributes$curr5.color),
  12732. gradient: undefined
  12733. }
  12734. };
  12735. newAttributes = {
  12736. style: cleanEmptyObject(newStyle),
  12737. gradient: slug
  12738. };
  12739. } else {
  12740. var _localAttributes$curr6, _localAttributes$curr7, _localAttributes$curr8;
  12741. const newStyle = { ...((_localAttributes$curr6 = localAttributes.current) === null || _localAttributes$curr6 === void 0 ? void 0 : _localAttributes$curr6.style),
  12742. color: { ...((_localAttributes$curr7 = localAttributes.current) === null || _localAttributes$curr7 === void 0 ? void 0 : (_localAttributes$curr8 = _localAttributes$curr7.style) === null || _localAttributes$curr8 === void 0 ? void 0 : _localAttributes$curr8.color),
  12743. gradient: value
  12744. }
  12745. };
  12746. newAttributes = {
  12747. style: cleanEmptyObject(newStyle),
  12748. gradient: undefined
  12749. };
  12750. }
  12751. props.setAttributes(newAttributes);
  12752. localAttributes.current = { ...localAttributes.current,
  12753. ...newAttributes
  12754. };
  12755. };
  12756. const onChangeLinkColor = value => {
  12757. const colorObject = getColorObjectByColorValue(solids, value);
  12758. const newLinkColorValue = colorObject !== null && colorObject !== void 0 && colorObject.slug ? `var:preset|color|${colorObject.slug}` : value;
  12759. const newStyle = immutableSet(style, ['elements', 'link', 'color', 'text'], newLinkColorValue);
  12760. props.setAttributes({
  12761. style: newStyle
  12762. });
  12763. };
  12764. return Object(external_wp_element_["createElement"])(ColorPanel, {
  12765. enableContrastChecking: // Turn on contrast checker for web only since it's not supported on mobile yet.
  12766. external_wp_element_["Platform"].OS === 'web' && !gradient && !(style !== null && style !== void 0 && (_style$color6 = style.color) !== null && _style$color6 !== void 0 && _style$color6.gradient),
  12767. clientId: props.clientId,
  12768. settings: [...(hasTextColor ? [{
  12769. label: Object(external_wp_i18n_["__"])('Text color'),
  12770. onColorChange: onChangeColor('text'),
  12771. colorValue: getColorObjectByAttributeValues(solids, textColor, style === null || style === void 0 ? void 0 : (_style$color7 = style.color) === null || _style$color7 === void 0 ? void 0 : _style$color7.text).color
  12772. }] : []), ...(hasBackgroundColor || hasGradientColor ? [{
  12773. label: Object(external_wp_i18n_["__"])('Background color'),
  12774. onColorChange: hasBackgroundColor ? onChangeColor('background') : undefined,
  12775. colorValue: getColorObjectByAttributeValues(solids, backgroundColor, style === null || style === void 0 ? void 0 : (_style$color8 = style.color) === null || _style$color8 === void 0 ? void 0 : _style$color8.background).color,
  12776. gradientValue,
  12777. onGradientChange: hasGradientColor ? onChangeGradient : undefined
  12778. }] : []), ...(hasLinkColor ? [{
  12779. label: Object(external_wp_i18n_["__"])('Link Color'),
  12780. onColorChange: onChangeLinkColor,
  12781. colorValue: getLinkColorFromAttributeValue(solids, style === null || style === void 0 ? void 0 : (_style$elements2 = style.elements) === null || _style$elements2 === void 0 ? void 0 : (_style$elements2$link = _style$elements2.link) === null || _style$elements2$link === void 0 ? void 0 : (_style$elements2$link2 = _style$elements2$link.color) === null || _style$elements2$link2 === void 0 ? void 0 : _style$elements2$link2.text),
  12782. clearable: !!(style !== null && style !== void 0 && (_style$elements3 = style.elements) !== null && _style$elements3 !== void 0 && (_style$elements3$link = _style$elements3.link) !== null && _style$elements3$link !== void 0 && (_style$elements3$link2 = _style$elements3$link.color) !== null && _style$elements3$link2 !== void 0 && _style$elements3$link2.text)
  12783. }] : [])]
  12784. });
  12785. }
  12786. /**
  12787. * This adds inline styles for color palette colors.
  12788. * Ideally, this is not needed and themes should load their palettes on the editor.
  12789. *
  12790. * @param {Function} BlockListBlock Original component
  12791. * @return {Function} Wrapped component
  12792. */
  12793. const withColorPaletteStyles = Object(external_wp_compose_["createHigherOrderComponent"])(BlockListBlock => props => {
  12794. var _getColorObjectByAttr, _getColorObjectByAttr2, _props$wrapperProps;
  12795. const {
  12796. name,
  12797. attributes
  12798. } = props;
  12799. const {
  12800. backgroundColor,
  12801. textColor
  12802. } = attributes;
  12803. const colors = useSetting('color.palette') || color_EMPTY_ARRAY;
  12804. if (!hasColorSupport(name) || color_shouldSkipSerialization(name)) {
  12805. return Object(external_wp_element_["createElement"])(BlockListBlock, props);
  12806. }
  12807. const extraStyles = {
  12808. color: textColor ? (_getColorObjectByAttr = getColorObjectByAttributeValues(colors, textColor)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color : undefined,
  12809. backgroundColor: backgroundColor ? (_getColorObjectByAttr2 = getColorObjectByAttributeValues(colors, backgroundColor)) === null || _getColorObjectByAttr2 === void 0 ? void 0 : _getColorObjectByAttr2.color : undefined
  12810. };
  12811. let wrapperProps = props.wrapperProps;
  12812. wrapperProps = { ...props.wrapperProps,
  12813. style: { ...extraStyles,
  12814. ...((_props$wrapperProps = props.wrapperProps) === null || _props$wrapperProps === void 0 ? void 0 : _props$wrapperProps.style)
  12815. }
  12816. };
  12817. return Object(external_wp_element_["createElement"])(BlockListBlock, Object(esm_extends["a" /* default */])({}, props, {
  12818. wrapperProps: wrapperProps
  12819. }));
  12820. });
  12821. Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/color/addAttribute', color_addAttributes);
  12822. Object(external_wp_hooks_["addFilter"])('blocks.getSaveContent.extraProps', 'core/color/addSaveProps', color_addSaveProps);
  12823. Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/color/addEditProps', color_addEditProps);
  12824. Object(external_wp_hooks_["addFilter"])('editor.BlockListBlock', 'core/color/with-color-palette-styles', withColorPaletteStyles);
  12825. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-underline.js
  12826. /**
  12827. * WordPress dependencies
  12828. */
  12829. const formatUnderline = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
  12830. xmlns: "http://www.w3.org/2000/svg",
  12831. viewBox: "0 0 24 24"
  12832. }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
  12833. d: "M7 18v1h10v-1H7zm5-2c1.5 0 2.6-.4 3.4-1.2.8-.8 1.1-2 1.1-3.5V5H15v5.8c0 1.2-.2 2.1-.6 2.8-.4.7-1.2 1-2.4 1s-2-.3-2.4-1c-.4-.7-.6-1.6-.6-2.8V5H7.5v6.2c0 1.5.4 2.7 1.1 3.5.8.9 1.9 1.3 3.4 1.3z"
  12834. }));
  12835. /* harmony default export */ var format_underline = (formatUnderline);
  12836. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/format-strikethrough.js
  12837. var format_strikethrough = __webpack_require__("Crq9");
  12838. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/text-decoration-control/index.js
  12839. /**
  12840. * WordPress dependencies
  12841. */
  12842. const TEXT_DECORATIONS = [{
  12843. name: Object(external_wp_i18n_["__"])('Underline'),
  12844. value: 'underline',
  12845. icon: format_underline
  12846. }, {
  12847. name: Object(external_wp_i18n_["__"])('Strikethrough'),
  12848. value: 'line-through',
  12849. icon: format_strikethrough["a" /* default */]
  12850. }];
  12851. /**
  12852. * Control to facilitate text decoration selections.
  12853. *
  12854. * @param {Object} props Component props.
  12855. * @param {string} props.value Currently selected text decoration.
  12856. * @param {Function} props.onChange Handles change in text decoration selection.
  12857. * @return {WPElement} Text decoration control.
  12858. */
  12859. function TextDecorationControl({
  12860. value,
  12861. onChange
  12862. }) {
  12863. return Object(external_wp_element_["createElement"])("fieldset", {
  12864. className: "block-editor-text-decoration-control"
  12865. }, Object(external_wp_element_["createElement"])("legend", null, Object(external_wp_i18n_["__"])('Decoration')), Object(external_wp_element_["createElement"])("div", {
  12866. className: "block-editor-text-decoration-control__buttons"
  12867. }, TEXT_DECORATIONS.map(textDecoration => {
  12868. return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  12869. key: textDecoration.value,
  12870. icon: textDecoration.icon,
  12871. isSmall: true,
  12872. isPressed: textDecoration.value === value,
  12873. onClick: () => onChange(textDecoration.value === value ? undefined : textDecoration.value),
  12874. "aria-label": textDecoration.name
  12875. });
  12876. })));
  12877. }
  12878. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/text-decoration.js
  12879. /**
  12880. * WordPress dependencies
  12881. */
  12882. /**
  12883. * Internal dependencies
  12884. */
  12885. /**
  12886. * Key within block settings' supports array indicating support for text
  12887. * decorations e.g. settings found in `block.json`.
  12888. */
  12889. const TEXT_DECORATION_SUPPORT_KEY = 'typography.__experimentalTextDecoration';
  12890. /**
  12891. * Inspector control panel containing the text decoration options.
  12892. *
  12893. * @param {Object} props Block properties.
  12894. * @return {WPElement} Text decoration edit element.
  12895. */
  12896. function TextDecorationEdit(props) {
  12897. var _style$typography;
  12898. const {
  12899. attributes: {
  12900. style
  12901. },
  12902. setAttributes
  12903. } = props;
  12904. const isDisabled = useIsTextDecorationDisabled(props);
  12905. if (isDisabled) {
  12906. return null;
  12907. }
  12908. function onChange(newDecoration) {
  12909. setAttributes({
  12910. style: cleanEmptyObject({ ...style,
  12911. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  12912. textDecoration: newDecoration
  12913. }
  12914. })
  12915. });
  12916. }
  12917. return Object(external_wp_element_["createElement"])(TextDecorationControl, {
  12918. value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.textDecoration,
  12919. onChange: onChange
  12920. });
  12921. }
  12922. /**
  12923. * Checks if text-decoration settings have been disabled.
  12924. *
  12925. * @param {string} name Name of the block.
  12926. * @return {boolean} Whether or not the setting is disabled.
  12927. */
  12928. function useIsTextDecorationDisabled({
  12929. name: blockName
  12930. } = {}) {
  12931. const notSupported = !Object(external_wp_blocks_["hasBlockSupport"])(blockName, TEXT_DECORATION_SUPPORT_KEY);
  12932. const hasTextDecoration = useSetting('typography.customTextDecorations');
  12933. return notSupported || !hasTextDecoration;
  12934. }
  12935. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-uppercase.js
  12936. /**
  12937. * WordPress dependencies
  12938. */
  12939. const formatUppercase = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
  12940. xmlns: "http://www.w3.org/2000/svg",
  12941. viewBox: "0 0 24 24"
  12942. }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
  12943. d: "M6.1 6.8L2.1 18h1.6l1.1-3h4.3l1.1 3h1.6l-4-11.2H6.1zm-.8 6.8L7 8.9l1.7 4.7H5.3zm15.1-.7c-.4-.5-.9-.8-1.6-1 .4-.2.7-.5.8-.9.2-.4.3-.9.3-1.4 0-.9-.3-1.6-.8-2-.6-.5-1.3-.7-2.4-.7h-3.5V18h4.2c1.1 0 2-.3 2.6-.8.6-.6 1-1.4 1-2.4-.1-.8-.3-1.4-.6-1.9zm-5.7-4.7h1.8c.6 0 1.1.1 1.4.4.3.2.5.7.5 1.3 0 .6-.2 1.1-.5 1.3-.3.2-.8.4-1.4.4h-1.8V8.2zm4 8c-.4.3-.9.5-1.5.5h-2.6v-3.8h2.6c1.4 0 2 .6 2 1.9.1.6-.1 1-.5 1.4z"
  12944. }));
  12945. /* harmony default export */ var format_uppercase = (formatUppercase);
  12946. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-lowercase.js
  12947. /**
  12948. * WordPress dependencies
  12949. */
  12950. const formatLowercase = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
  12951. xmlns: "http://www.w3.org/2000/svg",
  12952. viewBox: "0 0 24 24"
  12953. }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
  12954. d: "M11 16.8c-.1-.1-.2-.3-.3-.5v-2.6c0-.9-.1-1.7-.3-2.2-.2-.5-.5-.9-.9-1.2-.4-.2-.9-.3-1.6-.3-.5 0-1 .1-1.5.2s-.9.3-1.2.6l.2 1.2c.4-.3.7-.4 1.1-.5.3-.1.7-.2 1-.2.6 0 1 .1 1.3.4.3.2.4.7.4 1.4-1.2 0-2.3.2-3.3.7s-1.4 1.1-1.4 2.1c0 .7.2 1.2.7 1.6.4.4 1 .6 1.8.6.9 0 1.7-.4 2.4-1.2.1.3.2.5.4.7.1.2.3.3.6.4.3.1.6.1 1.1.1h.1l.2-1.2h-.1c-.4.1-.6 0-.7-.1zM9.2 16c-.2.3-.5.6-.9.8-.3.1-.7.2-1.1.2-.4 0-.7-.1-.9-.3-.2-.2-.3-.5-.3-.9 0-.6.2-1 .7-1.3.5-.3 1.3-.4 2.5-.5v2zm10.6-3.9c-.3-.6-.7-1.1-1.2-1.5-.6-.4-1.2-.6-1.9-.6-.5 0-.9.1-1.4.3-.4.2-.8.5-1.1.8V6h-1.4v12h1.3l.2-1c.2.4.6.6 1 .8.4.2.9.3 1.4.3.7 0 1.2-.2 1.8-.5.5-.4 1-.9 1.3-1.5.3-.6.5-1.3.5-2.1-.1-.6-.2-1.3-.5-1.9zm-1.7 4c-.4.5-.9.8-1.6.8s-1.2-.2-1.7-.7c-.4-.5-.7-1.2-.7-2.1 0-.9.2-1.6.7-2.1.4-.5 1-.7 1.7-.7s1.2.3 1.6.8c.4.5.6 1.2.6 2s-.2 1.4-.6 2z"
  12955. }));
  12956. /* harmony default export */ var format_lowercase = (formatLowercase);
  12957. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-capitalize.js
  12958. /**
  12959. * WordPress dependencies
  12960. */
  12961. const formatCapitalize = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
  12962. xmlns: "http://www.w3.org/2000/svg",
  12963. viewBox: "0 0 24 24"
  12964. }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
  12965. d: "M7.1 6.8L3.1 18h1.6l1.1-3h4.3l1.1 3h1.6l-4-11.2H7.1zm-.8 6.8L8 8.9l1.7 4.7H6.3zm14.5-1.5c-.3-.6-.7-1.1-1.2-1.5-.6-.4-1.2-.6-1.9-.6-.5 0-.9.1-1.4.3-.4.2-.8.5-1.1.8V6h-1.4v12h1.3l.2-1c.2.4.6.6 1 .8.4.2.9.3 1.4.3.7 0 1.2-.2 1.8-.5.5-.4 1-.9 1.3-1.5.3-.6.5-1.3.5-2.1-.1-.6-.2-1.3-.5-1.9zm-1.7 4c-.4.5-.9.8-1.6.8s-1.2-.2-1.7-.7c-.4-.5-.7-1.2-.7-2.1 0-.9.2-1.6.7-2.1.4-.5 1-.7 1.7-.7s1.2.3 1.6.8c.4.5.6 1.2.6 2 .1.8-.2 1.4-.6 2z"
  12966. }));
  12967. /* harmony default export */ var format_capitalize = (formatCapitalize);
  12968. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/text-transform-control/index.js
  12969. /**
  12970. * WordPress dependencies
  12971. */
  12972. const TEXT_TRANSFORMS = [{
  12973. name: Object(external_wp_i18n_["__"])('Uppercase'),
  12974. value: 'uppercase',
  12975. icon: format_uppercase
  12976. }, {
  12977. name: Object(external_wp_i18n_["__"])('Lowercase'),
  12978. value: 'lowercase',
  12979. icon: format_lowercase
  12980. }, {
  12981. name: Object(external_wp_i18n_["__"])('Capitalize'),
  12982. value: 'capitalize',
  12983. icon: format_capitalize
  12984. }];
  12985. /**
  12986. * Control to facilitate text transform selections.
  12987. *
  12988. * @param {Object} props Component props.
  12989. * @param {string} props.value Currently selected text transform.
  12990. * @param {Function} props.onChange Handles change in text transform selection.
  12991. * @return {WPElement} Text transform control.
  12992. */
  12993. function TextTransformControl({
  12994. value,
  12995. onChange
  12996. }) {
  12997. return Object(external_wp_element_["createElement"])("fieldset", {
  12998. className: "block-editor-text-transform-control"
  12999. }, Object(external_wp_element_["createElement"])("legend", null, Object(external_wp_i18n_["__"])('Letter case')), Object(external_wp_element_["createElement"])("div", {
  13000. className: "block-editor-text-transform-control__buttons"
  13001. }, TEXT_TRANSFORMS.map(textTransform => {
  13002. return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  13003. key: textTransform.value,
  13004. icon: textTransform.icon,
  13005. isSmall: true,
  13006. isPressed: value === textTransform.value,
  13007. "aria-label": textTransform.name,
  13008. onClick: () => onChange(value === textTransform.value ? undefined : textTransform.value)
  13009. });
  13010. })));
  13011. }
  13012. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/text-transform.js
  13013. /**
  13014. * WordPress dependencies
  13015. */
  13016. /**
  13017. * Internal dependencies
  13018. */
  13019. /**
  13020. * Key within block settings' supports array indicating support for text
  13021. * transforms e.g. settings found in `block.json`.
  13022. */
  13023. const TEXT_TRANSFORM_SUPPORT_KEY = 'typography.__experimentalTextTransform';
  13024. /**
  13025. * Inspector control panel containing the text transform options.
  13026. *
  13027. * @param {Object} props Block properties.
  13028. * @return {WPElement} Text transform edit element.
  13029. */
  13030. function TextTransformEdit(props) {
  13031. var _style$typography;
  13032. const {
  13033. attributes: {
  13034. style
  13035. },
  13036. setAttributes
  13037. } = props;
  13038. const isDisabled = useIsTextTransformDisabled(props);
  13039. if (isDisabled) {
  13040. return null;
  13041. }
  13042. function onChange(newTransform) {
  13043. setAttributes({
  13044. style: cleanEmptyObject({ ...style,
  13045. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  13046. textTransform: newTransform
  13047. }
  13048. })
  13049. });
  13050. }
  13051. return Object(external_wp_element_["createElement"])(TextTransformControl, {
  13052. value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.textTransform,
  13053. onChange: onChange
  13054. });
  13055. }
  13056. /**
  13057. * Checks if text-transform settings have been disabled.
  13058. *
  13059. * @param {string} name Name of the block.
  13060. * @return {boolean} Whether or not the setting is disabled.
  13061. */
  13062. function useIsTextTransformDisabled({
  13063. name: blockName
  13064. } = {}) {
  13065. const notSupported = !Object(external_wp_blocks_["hasBlockSupport"])(blockName, TEXT_TRANSFORM_SUPPORT_KEY);
  13066. const hasTextTransforms = useSetting('typography.customTextTransforms');
  13067. return notSupported || !hasTextTransforms;
  13068. }
  13069. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/text-decoration-and-transform/index.js
  13070. /**
  13071. * Internal dependencies
  13072. */
  13073. /**
  13074. * Handles grouping related text decoration and text transform edit components
  13075. * so they can be laid out in a more flexible manner within the Typography
  13076. * InspectorControls panel.
  13077. *
  13078. * @param {Object} props Block props to be passed on to individual controls.
  13079. * @return {WPElement} Component containing text decoration or transform controls.
  13080. */
  13081. function TextDecorationAndTransformEdit(props) {
  13082. const decorationAvailable = !useIsTextDecorationDisabled(props);
  13083. const transformAvailable = !useIsTextTransformDisabled(props);
  13084. if (!decorationAvailable && !transformAvailable) {
  13085. return null;
  13086. }
  13087. return Object(external_wp_element_["createElement"])("div", {
  13088. className: "block-editor-text-decoration-and-transform"
  13089. }, decorationAvailable && Object(external_wp_element_["createElement"])(TextDecorationEdit, props), transformAvailable && Object(external_wp_element_["createElement"])(TextTransformEdit, props));
  13090. }
  13091. // EXTERNAL MODULE: external ["wp","keycodes"]
  13092. var external_wp_keycodes_ = __webpack_require__("RxS6");
  13093. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/line-height-control/utils.js
  13094. const BASE_DEFAULT_VALUE = 1.5;
  13095. const STEP = 0.1;
  13096. /**
  13097. * There are varying value types within LineHeightControl:
  13098. *
  13099. * {undefined} Initial value. No changes from the user.
  13100. * {string} Input value. Value consumed/outputted by the input. Empty would be ''.
  13101. * {number} Block attribute type. Input value needs to be converted for attribute setting.
  13102. *
  13103. * Note: If the value is undefined, the input requires it to be an empty string ('')
  13104. * in order to be considered "controlled" by props (rather than internal state).
  13105. */
  13106. const RESET_VALUE = '';
  13107. /**
  13108. * Determines if the lineHeight attribute has been properly defined.
  13109. *
  13110. * @param {any} lineHeight The value to check.
  13111. *
  13112. * @return {boolean} Whether the lineHeight attribute is valid.
  13113. */
  13114. function isLineHeightDefined(lineHeight) {
  13115. return lineHeight !== undefined && lineHeight !== RESET_VALUE;
  13116. }
  13117. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/line-height-control/index.js
  13118. /**
  13119. * WordPress dependencies
  13120. */
  13121. /**
  13122. * Internal dependencies
  13123. */
  13124. function LineHeightControl({
  13125. value: lineHeight,
  13126. onChange
  13127. }) {
  13128. const isDefined = isLineHeightDefined(lineHeight);
  13129. const handleOnKeyDown = event => {
  13130. const {
  13131. keyCode
  13132. } = event;
  13133. if (keyCode === external_wp_keycodes_["ZERO"] && !isDefined) {
  13134. /**
  13135. * Prevents the onChange callback from firing, which prevents
  13136. * the logic from assuming the change was triggered from
  13137. * an input arrow CLICK.
  13138. */
  13139. event.preventDefault();
  13140. onChange('0');
  13141. }
  13142. };
  13143. const handleOnChange = nextValue => {
  13144. // Set the next value without modification if lineHeight has been defined
  13145. if (isDefined) {
  13146. onChange(nextValue);
  13147. return;
  13148. } // Otherwise...
  13149. /**
  13150. * The following logic handles the initial up/down arrow CLICK of the
  13151. * input element. This is so that the next values (from an undefined value state)
  13152. * are more better suited for line-height rendering.
  13153. */
  13154. let adjustedNextValue = nextValue;
  13155. switch (nextValue) {
  13156. case `${STEP}`:
  13157. // Increment by step value
  13158. adjustedNextValue = BASE_DEFAULT_VALUE + STEP;
  13159. break;
  13160. case '0':
  13161. // Decrement by step value
  13162. adjustedNextValue = BASE_DEFAULT_VALUE - STEP;
  13163. break;
  13164. }
  13165. onChange(adjustedNextValue);
  13166. };
  13167. const value = isDefined ? lineHeight : RESET_VALUE;
  13168. return Object(external_wp_element_["createElement"])("div", {
  13169. className: "block-editor-line-height-control"
  13170. }, Object(external_wp_element_["createElement"])(external_wp_components_["TextControl"], {
  13171. autoComplete: "off",
  13172. onKeyDown: handleOnKeyDown,
  13173. onChange: handleOnChange,
  13174. label: Object(external_wp_i18n_["__"])('Line height'),
  13175. placeholder: BASE_DEFAULT_VALUE,
  13176. step: STEP,
  13177. type: "number",
  13178. value: value,
  13179. min: 0
  13180. }));
  13181. }
  13182. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/line-height.js
  13183. /**
  13184. * WordPress dependencies
  13185. */
  13186. /**
  13187. * Internal dependencies
  13188. */
  13189. const LINE_HEIGHT_SUPPORT_KEY = 'typography.lineHeight';
  13190. /**
  13191. * Inspector control panel containing the line height related configuration
  13192. *
  13193. * @param {Object} props
  13194. *
  13195. * @return {WPElement} Line height edit element.
  13196. */
  13197. function LineHeightEdit(props) {
  13198. var _style$typography;
  13199. const {
  13200. attributes: {
  13201. style
  13202. }
  13203. } = props;
  13204. const isDisabled = useIsLineHeightDisabled(props);
  13205. if (isDisabled) {
  13206. return null;
  13207. }
  13208. const onChange = newLineHeightValue => {
  13209. const newStyle = { ...style,
  13210. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  13211. lineHeight: newLineHeightValue
  13212. }
  13213. };
  13214. props.setAttributes({
  13215. style: cleanEmptyObject(newStyle)
  13216. });
  13217. };
  13218. return Object(external_wp_element_["createElement"])(LineHeightControl, {
  13219. value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.lineHeight,
  13220. onChange: onChange
  13221. });
  13222. }
  13223. /**
  13224. * Custom hook that checks if line-height settings have been disabled.
  13225. *
  13226. * @param {string} name The name of the block.
  13227. * @return {boolean} Whether setting is disabled.
  13228. */
  13229. function useIsLineHeightDisabled({
  13230. name: blockName
  13231. } = {}) {
  13232. const isDisabled = !useSetting('typography.customLineHeight');
  13233. return !Object(external_wp_blocks_["hasBlockSupport"])(blockName, LINE_HEIGHT_SUPPORT_KEY) || isDisabled;
  13234. }
  13235. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-appearance-control/index.js
  13236. /**
  13237. * WordPress dependencies
  13238. */
  13239. const FONT_STYLES = [{
  13240. name: Object(external_wp_i18n_["__"])('Regular'),
  13241. value: 'normal'
  13242. }, {
  13243. name: Object(external_wp_i18n_["__"])('Italic'),
  13244. value: 'italic'
  13245. }];
  13246. const FONT_WEIGHTS = [{
  13247. name: Object(external_wp_i18n_["__"])('Thin'),
  13248. value: '100'
  13249. }, {
  13250. name: Object(external_wp_i18n_["__"])('Extra Light'),
  13251. value: '200'
  13252. }, {
  13253. name: Object(external_wp_i18n_["__"])('Light'),
  13254. value: '300'
  13255. }, {
  13256. name: Object(external_wp_i18n_["__"])('Regular'),
  13257. value: '400'
  13258. }, {
  13259. name: Object(external_wp_i18n_["__"])('Medium'),
  13260. value: '500'
  13261. }, {
  13262. name: Object(external_wp_i18n_["__"])('Semi Bold'),
  13263. value: '600'
  13264. }, {
  13265. name: Object(external_wp_i18n_["__"])('Bold'),
  13266. value: '700'
  13267. }, {
  13268. name: Object(external_wp_i18n_["__"])('Extra Bold'),
  13269. value: '800'
  13270. }, {
  13271. name: Object(external_wp_i18n_["__"])('Black'),
  13272. value: '900'
  13273. }];
  13274. /**
  13275. * Control to display unified font style and weight options.
  13276. *
  13277. * @param {Object} props Component props.
  13278. * @return {WPElement} Font appearance control.
  13279. */
  13280. function FontAppearanceControl(props) {
  13281. const {
  13282. onChange,
  13283. hasFontStyles = true,
  13284. hasFontWeights = true,
  13285. value: {
  13286. fontStyle,
  13287. fontWeight
  13288. }
  13289. } = props;
  13290. const hasStylesOrWeights = hasFontStyles || hasFontWeights;
  13291. const defaultOption = {
  13292. key: 'default',
  13293. name: Object(external_wp_i18n_["__"])('Default'),
  13294. style: {
  13295. fontStyle: undefined,
  13296. fontWeight: undefined
  13297. }
  13298. }; // Combines both font style and weight options into a single dropdown.
  13299. const combineOptions = () => {
  13300. const combinedOptions = [defaultOption];
  13301. FONT_STYLES.forEach(({
  13302. name: styleName,
  13303. value: styleValue
  13304. }) => {
  13305. FONT_WEIGHTS.forEach(({
  13306. name: weightName,
  13307. value: weightValue
  13308. }) => {
  13309. const optionName = styleValue === 'normal' ? weightName : Object(external_wp_i18n_["sprintf"])(
  13310. /* translators: 1: Font weight name. 2: Font style name. */
  13311. Object(external_wp_i18n_["__"])('%1$s %2$s'), weightName, styleName);
  13312. combinedOptions.push({
  13313. key: `${styleValue}-${weightValue}`,
  13314. name: optionName,
  13315. style: {
  13316. fontStyle: styleValue,
  13317. fontWeight: weightValue
  13318. }
  13319. });
  13320. });
  13321. });
  13322. return combinedOptions;
  13323. }; // Generates select options for font styles only.
  13324. const styleOptions = () => {
  13325. const combinedOptions = [defaultOption];
  13326. FONT_STYLES.forEach(({
  13327. name,
  13328. value
  13329. }) => {
  13330. combinedOptions.push({
  13331. key: value,
  13332. name,
  13333. style: {
  13334. fontStyle: value,
  13335. fontWeight: undefined
  13336. }
  13337. });
  13338. });
  13339. return combinedOptions;
  13340. }; // Generates select options for font weights only.
  13341. const weightOptions = () => {
  13342. const combinedOptions = [defaultOption];
  13343. FONT_WEIGHTS.forEach(({
  13344. name,
  13345. value
  13346. }) => {
  13347. combinedOptions.push({
  13348. key: value,
  13349. name,
  13350. style: {
  13351. fontStyle: undefined,
  13352. fontWeight: value
  13353. }
  13354. });
  13355. });
  13356. return combinedOptions;
  13357. }; // Map font styles and weights to select options.
  13358. const selectOptions = Object(external_wp_element_["useMemo"])(() => {
  13359. if (hasFontStyles && hasFontWeights) {
  13360. return combineOptions();
  13361. }
  13362. return hasFontStyles ? styleOptions() : weightOptions();
  13363. }, [props.options]); // Find current selection by comparing font style & weight against options.
  13364. const currentSelection = selectOptions.find(option => option.style.fontStyle === fontStyle && option.style.fontWeight === fontWeight); // Adjusts field label in case either styles or weights are disabled.
  13365. const getLabel = () => {
  13366. if (!hasFontStyles) {
  13367. return Object(external_wp_i18n_["__"])('Font weight');
  13368. }
  13369. if (!hasFontWeights) {
  13370. return Object(external_wp_i18n_["__"])('Font style');
  13371. }
  13372. return Object(external_wp_i18n_["__"])('Appearance');
  13373. };
  13374. return Object(external_wp_element_["createElement"])("fieldset", {
  13375. className: "components-font-appearance-control"
  13376. }, hasStylesOrWeights && Object(external_wp_element_["createElement"])(external_wp_components_["CustomSelectControl"], {
  13377. className: "components-font-appearance-control__select",
  13378. label: getLabel(),
  13379. options: selectOptions,
  13380. value: currentSelection,
  13381. onChange: ({
  13382. selectedItem
  13383. }) => onChange(selectedItem.style)
  13384. }));
  13385. }
  13386. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/font-appearance.js
  13387. /**
  13388. * WordPress dependencies
  13389. */
  13390. /**
  13391. * Internal dependencies
  13392. */
  13393. /**
  13394. * Key within block settings' support array indicating support for font style.
  13395. */
  13396. const FONT_STYLE_SUPPORT_KEY = 'typography.__experimentalFontStyle';
  13397. /**
  13398. * Key within block settings' support array indicating support for font weight.
  13399. */
  13400. const FONT_WEIGHT_SUPPORT_KEY = 'typography.__experimentalFontWeight';
  13401. /**
  13402. * Inspector control panel containing the font appearance options.
  13403. *
  13404. * @param {Object} props Block properties.
  13405. * @return {WPElement} Font appearance edit element.
  13406. */
  13407. function FontAppearanceEdit(props) {
  13408. var _style$typography, _style$typography2;
  13409. const {
  13410. attributes: {
  13411. style
  13412. },
  13413. setAttributes
  13414. } = props;
  13415. const hasFontStyles = !useIsFontStyleDisabled(props);
  13416. const hasFontWeights = !useIsFontWeightDisabled(props);
  13417. if (!hasFontStyles && !hasFontWeights) {
  13418. return null;
  13419. }
  13420. const onChange = newStyles => {
  13421. setAttributes({
  13422. style: cleanEmptyObject({ ...style,
  13423. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  13424. fontStyle: newStyles.fontStyle,
  13425. fontWeight: newStyles.fontWeight
  13426. }
  13427. })
  13428. });
  13429. };
  13430. const fontStyle = style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.fontStyle;
  13431. const fontWeight = style === null || style === void 0 ? void 0 : (_style$typography2 = style.typography) === null || _style$typography2 === void 0 ? void 0 : _style$typography2.fontWeight;
  13432. return Object(external_wp_element_["createElement"])(FontAppearanceControl, {
  13433. onChange: onChange,
  13434. hasFontStyles: hasFontStyles,
  13435. hasFontWeights: hasFontWeights,
  13436. value: {
  13437. fontStyle,
  13438. fontWeight
  13439. }
  13440. });
  13441. }
  13442. /**
  13443. * Checks if font style support has been disabled either by not opting in for
  13444. * support or by failing to provide preset styles.
  13445. *
  13446. * @param {Object} props Block properties.
  13447. * @param {string} props.name Name for the block type.
  13448. * @return {boolean} Whether font style support has been disabled.
  13449. */
  13450. function useIsFontStyleDisabled({
  13451. name: blockName
  13452. } = {}) {
  13453. const styleSupport = Object(external_wp_blocks_["hasBlockSupport"])(blockName, FONT_STYLE_SUPPORT_KEY);
  13454. const hasFontStyles = useSetting('typography.customFontStyle');
  13455. return !styleSupport || !hasFontStyles;
  13456. }
  13457. /**
  13458. * Checks if font weight support has been disabled either by not opting in for
  13459. * support or by failing to provide preset weights.
  13460. *
  13461. * @param {Object} props Block properties.
  13462. * @param {string} props.name Name for the block type.
  13463. * @return {boolean} Whether font weight support has been disabled.
  13464. */
  13465. function useIsFontWeightDisabled({
  13466. name: blockName
  13467. } = {}) {
  13468. const weightSupport = Object(external_wp_blocks_["hasBlockSupport"])(blockName, FONT_WEIGHT_SUPPORT_KEY);
  13469. const hasFontWeights = useSetting('typography.customFontWeight');
  13470. return !weightSupport || !hasFontWeights;
  13471. }
  13472. /**
  13473. * Checks if font appearance support has been disabled.
  13474. *
  13475. * @param {Object} props Block properties.
  13476. * @return {boolean} Whether font appearance support has been disabled.
  13477. */
  13478. function useIsFontAppearanceDisabled(props) {
  13479. const stylesDisabled = useIsFontStyleDisabled(props);
  13480. const weightsDisabled = useIsFontWeightDisabled(props);
  13481. return stylesDisabled && weightsDisabled;
  13482. }
  13483. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-family/index.js
  13484. /**
  13485. * External dependencies
  13486. */
  13487. /**
  13488. * WordPress dependencies
  13489. */
  13490. /**
  13491. * Internal dependencies
  13492. */
  13493. function FontFamilyControl({
  13494. value = '',
  13495. onChange,
  13496. fontFamilies,
  13497. ...props
  13498. }) {
  13499. const blockLevelFontFamilies = useSetting('typography.fontFamilies');
  13500. if (!fontFamilies) {
  13501. fontFamilies = blockLevelFontFamilies;
  13502. }
  13503. if (Object(external_lodash_["isEmpty"])(fontFamilies)) {
  13504. return null;
  13505. }
  13506. const options = [{
  13507. value: '',
  13508. label: Object(external_wp_i18n_["__"])('Default')
  13509. }, ...fontFamilies.map(({
  13510. fontFamily,
  13511. name
  13512. }) => {
  13513. return {
  13514. value: fontFamily,
  13515. label: name || fontFamily
  13516. };
  13517. })];
  13518. return Object(external_wp_element_["createElement"])(external_wp_components_["SelectControl"], Object(esm_extends["a" /* default */])({
  13519. label: Object(external_wp_i18n_["__"])('Font family'),
  13520. options: options,
  13521. value: value,
  13522. onChange: onChange,
  13523. labelPosition: "top"
  13524. }, props));
  13525. }
  13526. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/font-family.js
  13527. /**
  13528. * External dependencies
  13529. */
  13530. /**
  13531. * WordPress dependencies
  13532. */
  13533. /**
  13534. * Internal dependencies
  13535. */
  13536. const FONT_FAMILY_SUPPORT_KEY = 'typography.__experimentalFontFamily';
  13537. const getFontFamilyFromAttributeValue = (fontFamilies, value) => {
  13538. const attributeParsed = /var:preset\|font-family\|(.+)/.exec(value);
  13539. if (attributeParsed && attributeParsed[1]) {
  13540. const fontFamilyObject = Object(external_lodash_["find"])(fontFamilies, ({
  13541. slug
  13542. }) => {
  13543. return slug === attributeParsed[1];
  13544. });
  13545. if (fontFamilyObject) {
  13546. return fontFamilyObject.fontFamily;
  13547. }
  13548. }
  13549. return value;
  13550. };
  13551. function FontFamilyEdit({
  13552. name,
  13553. setAttributes,
  13554. attributes: {
  13555. style = {}
  13556. }
  13557. }) {
  13558. var _style$typography;
  13559. const fontFamilies = useSetting('typography.fontFamilies');
  13560. const isDisable = useIsFontFamilyDisabled({
  13561. name
  13562. });
  13563. if (isDisable) {
  13564. return null;
  13565. }
  13566. const value = getFontFamilyFromAttributeValue(fontFamilies, (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.fontFamily);
  13567. function onChange(newValue) {
  13568. const predefinedFontFamily = Object(external_lodash_["find"])(fontFamilies, ({
  13569. fontFamily
  13570. }) => fontFamily === newValue);
  13571. setAttributes({
  13572. style: cleanEmptyObject({ ...style,
  13573. typography: { ...(style.typography || {}),
  13574. fontFamily: predefinedFontFamily ? `var:preset|font-family|${predefinedFontFamily.slug}` : newValue || undefined
  13575. }
  13576. })
  13577. });
  13578. }
  13579. return Object(external_wp_element_["createElement"])(FontFamilyControl, {
  13580. className: "block-editor-hooks-font-family-control",
  13581. fontFamilies: fontFamilies,
  13582. value: value,
  13583. onChange: onChange
  13584. });
  13585. }
  13586. /**
  13587. * Custom hook that checks if font-family functionality is disabled.
  13588. *
  13589. * @param {string} name The name of the block.
  13590. * @return {boolean} Whether setting is disabled.
  13591. */
  13592. function useIsFontFamilyDisabled({
  13593. name
  13594. }) {
  13595. const fontFamilies = useSetting('typography.fontFamilies');
  13596. return !fontFamilies || fontFamilies.length === 0 || !Object(external_wp_blocks_["hasBlockSupport"])(name, FONT_FAMILY_SUPPORT_KEY);
  13597. }
  13598. // EXTERNAL MODULE: external ["wp","tokenList"]
  13599. var external_wp_tokenList_ = __webpack_require__("BLeD");
  13600. var external_wp_tokenList_default = /*#__PURE__*/__webpack_require__.n(external_wp_tokenList_);
  13601. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/utils.js
  13602. /**
  13603. * External dependencies
  13604. */
  13605. /**
  13606. * Returns the font size object based on an array of named font sizes and the namedFontSize and customFontSize values.
  13607. * If namedFontSize is undefined or not found in fontSizes an object with just the size value based on customFontSize is returned.
  13608. *
  13609. * @param {Array} fontSizes Array of font size objects containing at least the "name" and "size" values as properties.
  13610. * @param {?string} fontSizeAttribute Content of the font size attribute (slug).
  13611. * @param {?number} customFontSizeAttribute Contents of the custom font size attribute (value).
  13612. *
  13613. * @return {?Object} If fontSizeAttribute is set and an equal slug is found in fontSizes it returns the font size object for that slug.
  13614. * Otherwise, an object with just the size value based on customFontSize is returned.
  13615. */
  13616. const getFontSize = (fontSizes, fontSizeAttribute, customFontSizeAttribute) => {
  13617. if (fontSizeAttribute) {
  13618. const fontSizeObject = Object(external_lodash_["find"])(fontSizes, {
  13619. slug: fontSizeAttribute
  13620. });
  13621. if (fontSizeObject) {
  13622. return fontSizeObject;
  13623. }
  13624. }
  13625. return {
  13626. size: customFontSizeAttribute
  13627. };
  13628. };
  13629. /**
  13630. * Returns the corresponding font size object for a given value.
  13631. *
  13632. * @param {Array} fontSizes Array of font size objects.
  13633. * @param {number} value Font size value.
  13634. *
  13635. * @return {Object} Font size object.
  13636. */
  13637. function getFontSizeObjectByValue(fontSizes, value) {
  13638. const fontSizeObject = Object(external_lodash_["find"])(fontSizes, {
  13639. size: value
  13640. });
  13641. if (fontSizeObject) {
  13642. return fontSizeObject;
  13643. }
  13644. return {
  13645. size: value
  13646. };
  13647. }
  13648. /**
  13649. * Returns a class based on fontSizeName.
  13650. *
  13651. * @param {string} fontSizeSlug Slug of the fontSize.
  13652. *
  13653. * @return {string} String with the class corresponding to the fontSize passed.
  13654. * The class is generated by appending 'has-' followed by fontSizeSlug in kebabCase and ending with '-font-size'.
  13655. */
  13656. function getFontSizeClass(fontSizeSlug) {
  13657. if (!fontSizeSlug) {
  13658. return;
  13659. }
  13660. return `has-${Object(external_lodash_["kebabCase"])(fontSizeSlug)}-font-size`;
  13661. }
  13662. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/font-size-picker.js
  13663. /**
  13664. * WordPress dependencies
  13665. */
  13666. /**
  13667. * Internal dependencies
  13668. */
  13669. function FontSizePicker(props) {
  13670. const fontSizes = useSetting('typography.fontSizes');
  13671. const disableCustomFontSizes = !useSetting('typography.customFontSize');
  13672. return Object(external_wp_element_["createElement"])(external_wp_components_["FontSizePicker"], Object(esm_extends["a" /* default */])({}, props, {
  13673. fontSizes: fontSizes,
  13674. disableCustomFontSizes: disableCustomFontSizes
  13675. }));
  13676. }
  13677. /* harmony default export */ var font_size_picker = (FontSizePicker);
  13678. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/font-size.js
  13679. /**
  13680. * WordPress dependencies
  13681. */
  13682. /**
  13683. * Internal dependencies
  13684. */
  13685. const FONT_SIZE_SUPPORT_KEY = 'typography.fontSize';
  13686. /**
  13687. * Filters registered block settings, extending attributes to include
  13688. * `fontSize` and `fontWeight` attributes.
  13689. *
  13690. * @param {Object} settings Original block settings
  13691. * @return {Object} Filtered block settings
  13692. */
  13693. function font_size_addAttributes(settings) {
  13694. if (!Object(external_wp_blocks_["hasBlockSupport"])(settings, FONT_SIZE_SUPPORT_KEY)) {
  13695. return settings;
  13696. } // Allow blocks to specify a default value if needed.
  13697. if (!settings.attributes.fontSize) {
  13698. Object.assign(settings.attributes, {
  13699. fontSize: {
  13700. type: 'string'
  13701. }
  13702. });
  13703. }
  13704. return settings;
  13705. }
  13706. /**
  13707. * Override props assigned to save component to inject font size.
  13708. *
  13709. * @param {Object} props Additional props applied to save element
  13710. * @param {Object} blockType Block type
  13711. * @param {Object} attributes Block attributes
  13712. * @return {Object} Filtered props applied to save element
  13713. */
  13714. function font_size_addSaveProps(props, blockType, attributes) {
  13715. if (!Object(external_wp_blocks_["hasBlockSupport"])(blockType, FONT_SIZE_SUPPORT_KEY)) {
  13716. return props;
  13717. }
  13718. if (Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'typography.__experimentalSkipSerialization')) {
  13719. return props;
  13720. } // Use TokenList to dedupe classes.
  13721. const classes = new external_wp_tokenList_default.a(props.className);
  13722. classes.add(getFontSizeClass(attributes.fontSize));
  13723. const newClassName = classes.value;
  13724. props.className = newClassName ? newClassName : undefined;
  13725. return props;
  13726. }
  13727. /**
  13728. * Filters registered block settings to expand the block edit wrapper
  13729. * by applying the desired styles and classnames.
  13730. *
  13731. * @param {Object} settings Original block settings
  13732. * @return {Object} Filtered block settings
  13733. */
  13734. function font_size_addEditProps(settings) {
  13735. if (!Object(external_wp_blocks_["hasBlockSupport"])(settings, FONT_SIZE_SUPPORT_KEY)) {
  13736. return settings;
  13737. }
  13738. const existingGetEditWrapperProps = settings.getEditWrapperProps;
  13739. settings.getEditWrapperProps = attributes => {
  13740. let props = {};
  13741. if (existingGetEditWrapperProps) {
  13742. props = existingGetEditWrapperProps(attributes);
  13743. }
  13744. return font_size_addSaveProps(props, settings, attributes);
  13745. };
  13746. return settings;
  13747. }
  13748. /**
  13749. * Inspector control panel containing the font size related configuration
  13750. *
  13751. * @param {Object} props
  13752. *
  13753. * @return {WPElement} Font size edit element.
  13754. */
  13755. function FontSizeEdit(props) {
  13756. var _style$typography, _style$typography2;
  13757. const {
  13758. attributes: {
  13759. fontSize,
  13760. style
  13761. },
  13762. setAttributes
  13763. } = props;
  13764. const isDisabled = useIsFontSizeDisabled(props);
  13765. const fontSizes = useSetting('typography.fontSizes');
  13766. const onChange = value => {
  13767. const fontSizeSlug = getFontSizeObjectByValue(fontSizes, value).slug;
  13768. setAttributes({
  13769. style: cleanEmptyObject({ ...style,
  13770. typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
  13771. fontSize: fontSizeSlug ? undefined : value
  13772. }
  13773. }),
  13774. fontSize: fontSizeSlug
  13775. });
  13776. };
  13777. if (isDisabled) {
  13778. return null;
  13779. }
  13780. const fontSizeObject = getFontSize(fontSizes, fontSize, style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.fontSize);
  13781. const fontSizeValue = (fontSizeObject === null || fontSizeObject === void 0 ? void 0 : fontSizeObject.size) || (style === null || style === void 0 ? void 0 : (_style$typography2 = style.typography) === null || _style$typography2 === void 0 ? void 0 : _style$typography2.fontSize) || fontSize;
  13782. return Object(external_wp_element_["createElement"])(font_size_picker, {
  13783. onChange: onChange,
  13784. value: fontSizeValue
  13785. });
  13786. }
  13787. /**
  13788. * Custom hook that checks if font-size settings have been disabled.
  13789. *
  13790. * @param {string} name The name of the block.
  13791. * @return {boolean} Whether setting is disabled.
  13792. */
  13793. function useIsFontSizeDisabled({
  13794. name: blockName
  13795. } = {}) {
  13796. const fontSizes = useSetting('typography.fontSizes');
  13797. const hasFontSizes = !!(fontSizes !== null && fontSizes !== void 0 && fontSizes.length);
  13798. return !Object(external_wp_blocks_["hasBlockSupport"])(blockName, FONT_SIZE_SUPPORT_KEY) || !hasFontSizes;
  13799. }
  13800. /**
  13801. * Add inline styles for font sizes.
  13802. * Ideally, this is not needed and themes load the font-size classes on the
  13803. * editor.
  13804. *
  13805. * @param {Function} BlockListBlock Original component
  13806. * @return {Function} Wrapped component
  13807. */
  13808. const withFontSizeInlineStyles = Object(external_wp_compose_["createHigherOrderComponent"])(BlockListBlock => props => {
  13809. var _style$typography3, _style$typography4;
  13810. const fontSizes = useSetting('typography.fontSizes');
  13811. const {
  13812. name: blockName,
  13813. attributes: {
  13814. fontSize,
  13815. style
  13816. },
  13817. wrapperProps
  13818. } = props; // Only add inline styles if the block supports font sizes,
  13819. // doesn't skip serialization of font sizes,
  13820. // doesn't already have an inline font size,
  13821. // and does have a class to extract the font size from.
  13822. if (!Object(external_wp_blocks_["hasBlockSupport"])(blockName, FONT_SIZE_SUPPORT_KEY) || Object(external_wp_blocks_["hasBlockSupport"])(blockName, 'typography.__experimentalSkipSerialization') || !fontSize || style !== null && style !== void 0 && (_style$typography3 = style.typography) !== null && _style$typography3 !== void 0 && _style$typography3.fontSize) {
  13823. return Object(external_wp_element_["createElement"])(BlockListBlock, props);
  13824. }
  13825. const fontSizeValue = getFontSize(fontSizes, fontSize, style === null || style === void 0 ? void 0 : (_style$typography4 = style.typography) === null || _style$typography4 === void 0 ? void 0 : _style$typography4.fontSize).size;
  13826. const newProps = { ...props,
  13827. wrapperProps: { ...wrapperProps,
  13828. style: {
  13829. fontSize: fontSizeValue,
  13830. ...(wrapperProps === null || wrapperProps === void 0 ? void 0 : wrapperProps.style)
  13831. }
  13832. }
  13833. };
  13834. return Object(external_wp_element_["createElement"])(BlockListBlock, newProps);
  13835. }, 'withFontSizeInlineStyles');
  13836. Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/font/addAttribute', font_size_addAttributes);
  13837. Object(external_wp_hooks_["addFilter"])('blocks.getSaveContent.extraProps', 'core/font/addSaveProps', font_size_addSaveProps);
  13838. Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/font/addEditProps', font_size_addEditProps);
  13839. Object(external_wp_hooks_["addFilter"])('editor.BlockListBlock', 'core/font-size/with-font-size-inline-styles', withFontSizeInlineStyles);
  13840. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/typography.js
  13841. /**
  13842. * WordPress dependencies
  13843. */
  13844. /**
  13845. * External dependencies
  13846. */
  13847. /**
  13848. * Internal dependencies
  13849. */
  13850. const TYPOGRAPHY_SUPPORT_KEY = 'typography';
  13851. const TYPOGRAPHY_SUPPORT_KEYS = [LINE_HEIGHT_SUPPORT_KEY, FONT_SIZE_SUPPORT_KEY, FONT_STYLE_SUPPORT_KEY, FONT_WEIGHT_SUPPORT_KEY, FONT_FAMILY_SUPPORT_KEY, TEXT_DECORATION_SUPPORT_KEY, TEXT_TRANSFORM_SUPPORT_KEY];
  13852. function TypographyPanel(props) {
  13853. const isDisabled = useIsTypographyDisabled(props);
  13854. const isSupported = hasTypographySupport(props.name);
  13855. if (isDisabled || !isSupported) return null;
  13856. return Object(external_wp_element_["createElement"])(inspector_controls, null, Object(external_wp_element_["createElement"])(external_wp_components_["PanelBody"], {
  13857. title: Object(external_wp_i18n_["__"])('Typography')
  13858. }, Object(external_wp_element_["createElement"])(external_wp_components_["__unstableComponentSystemProvider"], {
  13859. __unstableNextInclude: ['WPComponentsFontSizePicker']
  13860. }, Object(external_wp_element_["createElement"])(FontFamilyEdit, props), Object(external_wp_element_["createElement"])(FontSizeEdit, props), Object(external_wp_element_["createElement"])(FontAppearanceEdit, props), Object(external_wp_element_["createElement"])(LineHeightEdit, props), Object(external_wp_element_["createElement"])(TextDecorationAndTransformEdit, props))));
  13861. }
  13862. const hasTypographySupport = blockName => {
  13863. return external_wp_element_["Platform"].OS === 'web' && TYPOGRAPHY_SUPPORT_KEYS.some(key => Object(external_wp_blocks_["hasBlockSupport"])(blockName, key));
  13864. };
  13865. function useIsTypographyDisabled(props = {}) {
  13866. const configs = [useIsFontAppearanceDisabled(props), useIsFontSizeDisabled(props), useIsLineHeightDisabled(props), useIsFontFamilyDisabled(props), useIsTextDecorationDisabled(props), useIsTextTransformDisabled(props)];
  13867. return configs.filter(Boolean).length === configs.length;
  13868. }
  13869. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/margin.js
  13870. /**
  13871. * WordPress dependencies
  13872. */
  13873. /**
  13874. * Internal dependencies
  13875. */
  13876. /**
  13877. * Determines if there is margin support.
  13878. *
  13879. * @param {string|Object} blockType Block name or Block Type object.
  13880. * @return {boolean} Whether there is support.
  13881. */
  13882. function hasMarginSupport(blockType) {
  13883. const support = Object(external_wp_blocks_["getBlockSupport"])(blockType, SPACING_SUPPORT_KEY);
  13884. return !!(true === support || support !== null && support !== void 0 && support.margin);
  13885. }
  13886. /**
  13887. * Custom hook that checks if margin settings have been disabled.
  13888. *
  13889. * @param {string} name The name of the block.
  13890. * @return {boolean} Whether margin setting is disabled.
  13891. */
  13892. function useIsMarginDisabled({
  13893. name: blockName
  13894. } = {}) {
  13895. const isDisabled = !useSetting('spacing.customMargin');
  13896. return !hasMarginSupport(blockName) || isDisabled;
  13897. }
  13898. /**
  13899. * Inspector control panel containing the margin related configuration
  13900. *
  13901. * @param {Object} props Block props.
  13902. * @return {WPElement} Margin edit element.
  13903. */
  13904. function MarginEdit(props) {
  13905. var _style$spacing;
  13906. const {
  13907. name: blockName,
  13908. attributes: {
  13909. style
  13910. },
  13911. setAttributes
  13912. } = props;
  13913. const units = Object(external_wp_components_["__experimentalUseCustomUnits"])({
  13914. availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
  13915. });
  13916. const sides = useCustomSides(blockName, 'margin');
  13917. if (useIsMarginDisabled(props)) {
  13918. return null;
  13919. }
  13920. const onChange = next => {
  13921. const newStyle = { ...style,
  13922. spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
  13923. margin: next
  13924. }
  13925. };
  13926. setAttributes({
  13927. style: cleanEmptyObject(newStyle)
  13928. });
  13929. };
  13930. const onChangeShowVisualizer = next => {
  13931. const newStyle = { ...style,
  13932. visualizers: {
  13933. margin: next
  13934. }
  13935. };
  13936. setAttributes({
  13937. style: cleanEmptyObject(newStyle)
  13938. });
  13939. };
  13940. return external_wp_element_["Platform"].select({
  13941. web: Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalBoxControl"], {
  13942. values: style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.margin,
  13943. onChange: onChange,
  13944. onChangeShowVisualizer: onChangeShowVisualizer,
  13945. label: Object(external_wp_i18n_["__"])('Margin'),
  13946. sides: sides,
  13947. units: units
  13948. })),
  13949. native: null
  13950. });
  13951. }
  13952. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/padding.js
  13953. /**
  13954. * WordPress dependencies
  13955. */
  13956. /**
  13957. * Internal dependencies
  13958. */
  13959. /**
  13960. * Determines if there is padding support.
  13961. *
  13962. * @param {string|Object} blockType Block name or Block Type object.
  13963. * @return {boolean} Whether there is support.
  13964. */
  13965. function hasPaddingSupport(blockType) {
  13966. const support = Object(external_wp_blocks_["getBlockSupport"])(blockType, SPACING_SUPPORT_KEY);
  13967. return !!(true === support || support !== null && support !== void 0 && support.padding);
  13968. }
  13969. /**
  13970. * Custom hook that checks if padding settings have been disabled.
  13971. *
  13972. * @param {string} name The name of the block.
  13973. * @return {boolean} Whether padding setting is disabled.
  13974. */
  13975. function useIsPaddingDisabled({
  13976. name: blockName
  13977. } = {}) {
  13978. const isDisabled = !useSetting('spacing.customPadding');
  13979. return !hasPaddingSupport(blockName) || isDisabled;
  13980. }
  13981. /**
  13982. * Inspector control panel containing the padding related configuration
  13983. *
  13984. * @param {Object} props
  13985. *
  13986. * @return {WPElement} Padding edit element.
  13987. */
  13988. function PaddingEdit(props) {
  13989. var _style$spacing;
  13990. const {
  13991. name: blockName,
  13992. attributes: {
  13993. style
  13994. },
  13995. setAttributes
  13996. } = props;
  13997. const units = Object(external_wp_components_["__experimentalUseCustomUnits"])({
  13998. availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
  13999. });
  14000. const sides = useCustomSides(blockName, 'padding');
  14001. if (useIsPaddingDisabled(props)) {
  14002. return null;
  14003. }
  14004. const onChange = next => {
  14005. const newStyle = { ...style,
  14006. spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
  14007. padding: next
  14008. }
  14009. };
  14010. setAttributes({
  14011. style: cleanEmptyObject(newStyle)
  14012. });
  14013. };
  14014. const onChangeShowVisualizer = next => {
  14015. const newStyle = { ...style,
  14016. visualizers: {
  14017. padding: next
  14018. }
  14019. };
  14020. setAttributes({
  14021. style: cleanEmptyObject(newStyle)
  14022. });
  14023. };
  14024. return external_wp_element_["Platform"].select({
  14025. web: Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalBoxControl"], {
  14026. values: style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.padding,
  14027. onChange: onChange,
  14028. onChangeShowVisualizer: onChangeShowVisualizer,
  14029. label: Object(external_wp_i18n_["__"])('Padding'),
  14030. sides: sides,
  14031. units: units
  14032. })),
  14033. native: null
  14034. });
  14035. }
  14036. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/spacing.js
  14037. /**
  14038. * WordPress dependencies
  14039. */
  14040. /**
  14041. * Internal dependencies
  14042. */
  14043. const SPACING_SUPPORT_KEY = 'spacing';
  14044. /**
  14045. * Inspector controls for spacing support.
  14046. *
  14047. * @param {Object} props Block props.
  14048. * @return {WPElement} Inspector controls for spacing support features.
  14049. */
  14050. function SpacingPanel(props) {
  14051. const isDisabled = useIsSpacingDisabled(props);
  14052. const isSupported = hasSpacingSupport(props.name);
  14053. if (isDisabled || !isSupported) {
  14054. return null;
  14055. }
  14056. return Object(external_wp_element_["createElement"])(inspector_controls, {
  14057. key: "spacing"
  14058. }, Object(external_wp_element_["createElement"])(external_wp_components_["PanelBody"], {
  14059. title: Object(external_wp_i18n_["__"])('Spacing')
  14060. }, Object(external_wp_element_["createElement"])(PaddingEdit, props), Object(external_wp_element_["createElement"])(MarginEdit, props)));
  14061. }
  14062. /**
  14063. * Determine whether there is block support for padding or margins.
  14064. *
  14065. * @param {string} blockName Block name.
  14066. * @return {boolean} Whether there is support.
  14067. */
  14068. function hasSpacingSupport(blockName) {
  14069. if (external_wp_element_["Platform"].OS !== 'web') {
  14070. return false;
  14071. }
  14072. return hasPaddingSupport(blockName) || hasMarginSupport(blockName);
  14073. }
  14074. /**
  14075. * Determines whether spacing support has been disabled.
  14076. *
  14077. * @param {Object} props Block properties.
  14078. * @return {boolean} If spacing support is completely disabled.
  14079. */
  14080. const useIsSpacingDisabled = (props = {}) => {
  14081. const paddingDisabled = useIsPaddingDisabled(props);
  14082. const marginDisabled = useIsMarginDisabled(props);
  14083. return paddingDisabled && marginDisabled;
  14084. };
  14085. /**
  14086. * Custom hook to retrieve which padding/margin is supported
  14087. * e.g. top, right, bottom or left.
  14088. *
  14089. * Sides are opted into by default. It is only if a specific side is set to
  14090. * false that it is omitted.
  14091. *
  14092. * @param {string} blockName Block name.
  14093. * @param {string} feature The feature custom sides relate to e.g. padding or margins.
  14094. * @return {Object} Sides supporting custom margin.
  14095. */
  14096. function useCustomSides(blockName, feature) {
  14097. const support = Object(external_wp_blocks_["getBlockSupport"])(blockName, SPACING_SUPPORT_KEY); // Skip when setting is boolean as theme isn't setting arbitrary sides.
  14098. if (typeof support[feature] === 'boolean') {
  14099. return;
  14100. }
  14101. return support[feature];
  14102. }
  14103. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/style.js
  14104. /**
  14105. * External dependencies
  14106. */
  14107. /**
  14108. * WordPress dependencies
  14109. */
  14110. /**
  14111. * Internal dependencies
  14112. */
  14113. const styleSupportKeys = [...TYPOGRAPHY_SUPPORT_KEYS, BORDER_SUPPORT_KEY, COLOR_SUPPORT_KEY, SPACING_SUPPORT_KEY];
  14114. const hasStyleSupport = blockType => styleSupportKeys.some(key => Object(external_wp_blocks_["hasBlockSupport"])(blockType, key));
  14115. const VARIABLE_REFERENCE_PREFIX = 'var:';
  14116. const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
  14117. const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
  14118. function compileStyleValue(uncompiledValue) {
  14119. if (Object(external_lodash_["startsWith"])(uncompiledValue, VARIABLE_REFERENCE_PREFIX)) {
  14120. const variable = uncompiledValue.slice(VARIABLE_REFERENCE_PREFIX.length).split(VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).join(VARIABLE_PATH_SEPARATOR_TOKEN_STYLE);
  14121. return `var(--wp--${variable})`;
  14122. }
  14123. return uncompiledValue;
  14124. }
  14125. /**
  14126. * Returns the inline styles to add depending on the style object
  14127. *
  14128. * @param {Object} styles Styles configuration
  14129. * @return {Object} Flattened CSS variables declaration
  14130. */
  14131. function getInlineStyles(styles = {}) {
  14132. const output = {};
  14133. Object.keys(external_wp_blocks_["__EXPERIMENTAL_STYLE_PROPERTY"]).forEach(propKey => {
  14134. const path = external_wp_blocks_["__EXPERIMENTAL_STYLE_PROPERTY"][propKey].value;
  14135. const subPaths = external_wp_blocks_["__EXPERIMENTAL_STYLE_PROPERTY"][propKey].properties; // Ignore styles on elements because they are handled on the server.
  14136. if (Object(external_lodash_["has"])(styles, path) && 'elements' !== Object(external_lodash_["first"])(path)) {
  14137. if (!!subPaths) {
  14138. subPaths.forEach(suffix => {
  14139. output[propKey + Object(external_lodash_["capitalize"])(suffix)] = compileStyleValue(Object(external_lodash_["get"])(styles, [...path, suffix]));
  14140. });
  14141. } else {
  14142. output[propKey] = compileStyleValue(Object(external_lodash_["get"])(styles, path));
  14143. }
  14144. }
  14145. });
  14146. return output;
  14147. }
  14148. function compileElementsStyles(selector, elements = {}) {
  14149. return Object(external_lodash_["map"])(elements, (styles, element) => {
  14150. const elementStyles = getInlineStyles(styles);
  14151. if (!Object(external_lodash_["isEmpty"])(elementStyles)) {
  14152. return [`.${selector} ${external_wp_blocks_["__EXPERIMENTAL_ELEMENTS"][element]}{`, ...Object(external_lodash_["map"])(elementStyles, (value, property) => `\t${Object(external_lodash_["kebabCase"])(property)}: ${value}${element === 'link' ? '!important' : ''};`), '}'].join('\n');
  14153. }
  14154. return '';
  14155. }).join('\n');
  14156. }
  14157. /**
  14158. * Filters registered block settings, extending attributes to include `style` attribute.
  14159. *
  14160. * @param {Object} settings Original block settings
  14161. * @return {Object} Filtered block settings
  14162. */
  14163. function style_addAttribute(settings) {
  14164. if (!hasStyleSupport(settings)) {
  14165. return settings;
  14166. } // allow blocks to specify their own attribute definition with default values if needed.
  14167. if (!settings.attributes.style) {
  14168. Object.assign(settings.attributes, {
  14169. style: {
  14170. type: 'object'
  14171. }
  14172. });
  14173. }
  14174. return settings;
  14175. }
  14176. const skipSerializationPaths = {
  14177. [`${BORDER_SUPPORT_KEY}.__experimentalSkipSerialization`]: ['border'],
  14178. [`${COLOR_SUPPORT_KEY}.__experimentalSkipSerialization`]: [COLOR_SUPPORT_KEY],
  14179. [`${TYPOGRAPHY_SUPPORT_KEY}.__experimentalSkipSerialization`]: [TYPOGRAPHY_SUPPORT_KEY]
  14180. };
  14181. /**
  14182. * Override props assigned to save component to inject the CSS variables definition.
  14183. *
  14184. * @param {Object} props Additional props applied to save element
  14185. * @param {Object} blockType Block type
  14186. * @param {Object} attributes Block attributes
  14187. * @return {Object} Filtered props applied to save element
  14188. */
  14189. function style_addSaveProps(props, blockType, attributes) {
  14190. if (!hasStyleSupport(blockType)) {
  14191. return props;
  14192. }
  14193. let {
  14194. style
  14195. } = attributes;
  14196. Object(external_lodash_["forEach"])(skipSerializationPaths, (path, indicator) => {
  14197. if (Object(external_wp_blocks_["getBlockSupport"])(blockType, indicator)) {
  14198. style = Object(external_lodash_["omit"])(style, path);
  14199. }
  14200. });
  14201. props.style = { ...getInlineStyles(style),
  14202. ...props.style
  14203. };
  14204. return props;
  14205. }
  14206. /**
  14207. * Filters registered block settings to extend the block edit wrapper
  14208. * to apply the desired styles and classnames properly.
  14209. *
  14210. * @param {Object} settings Original block settings
  14211. * @return {Object} Filtered block settings
  14212. */
  14213. function style_addEditProps(settings) {
  14214. if (!hasStyleSupport(settings)) {
  14215. return settings;
  14216. }
  14217. const existingGetEditWrapperProps = settings.getEditWrapperProps;
  14218. settings.getEditWrapperProps = attributes => {
  14219. let props = {};
  14220. if (existingGetEditWrapperProps) {
  14221. props = existingGetEditWrapperProps(attributes);
  14222. }
  14223. return style_addSaveProps(props, settings, attributes);
  14224. };
  14225. return settings;
  14226. }
  14227. /**
  14228. * Override the default edit UI to include new inspector controls for
  14229. * all the custom styles configs.
  14230. *
  14231. * @param {Function} BlockEdit Original component
  14232. * @return {Function} Wrapped component
  14233. */
  14234. const withBlockControls = Object(external_wp_compose_["createHigherOrderComponent"])(BlockEdit => props => {
  14235. const shouldDisplayControls = useDisplayBlockControls();
  14236. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, shouldDisplayControls && Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(TypographyPanel, props), Object(external_wp_element_["createElement"])(BorderPanel, props), Object(external_wp_element_["createElement"])(ColorEdit, props), Object(external_wp_element_["createElement"])(SpacingPanel, props)), Object(external_wp_element_["createElement"])(BlockEdit, props));
  14237. }, 'withToolbarControls');
  14238. /**
  14239. * Override the default block element to include duotone styles.
  14240. *
  14241. * @param {Function} BlockListBlock Original component
  14242. * @return {Function} Wrapped component
  14243. */
  14244. const withElementsStyles = Object(external_wp_compose_["createHigherOrderComponent"])(BlockListBlock => props => {
  14245. var _props$attributes$sty, _props$attributes$sty2;
  14246. const elements = (_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : _props$attributes$sty.elements;
  14247. const blockElementsContainerIdentifier = `wp-elements-${Object(external_wp_compose_["useInstanceId"])(BlockListBlock)}`;
  14248. const styles = compileElementsStyles(blockElementsContainerIdentifier, (_props$attributes$sty2 = props.attributes.style) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.elements);
  14249. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, elements && Object(external_wp_element_["createElement"])("style", {
  14250. dangerouslySetInnerHTML: {
  14251. __html: styles
  14252. }
  14253. }), Object(external_wp_element_["createElement"])(BlockListBlock, Object(esm_extends["a" /* default */])({}, props, {
  14254. className: elements ? classnames_default()(props.className, blockElementsContainerIdentifier) : props.className
  14255. })));
  14256. });
  14257. Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/style/addAttribute', style_addAttribute);
  14258. Object(external_wp_hooks_["addFilter"])('blocks.getSaveContent.extraProps', 'core/style/addSaveProps', style_addSaveProps);
  14259. Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/style/addEditProps', style_addEditProps);
  14260. Object(external_wp_hooks_["addFilter"])('editor.BlockEdit', 'core/style/with-block-controls', withBlockControls);
  14261. Object(external_wp_hooks_["addFilter"])('editor.BlockListBlock', 'core/editor/with-elements-styles', withElementsStyles);
  14262. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/duotone-control/duotone-picker-popover.js
  14263. /**
  14264. * WordPress dependencies
  14265. */
  14266. function DuotonePickerPopover({
  14267. value,
  14268. onChange,
  14269. onToggle,
  14270. duotonePalette,
  14271. colorPalette,
  14272. disableCustomColors,
  14273. disableCustomDuotone
  14274. }) {
  14275. return Object(external_wp_element_["createElement"])(external_wp_components_["Popover"], {
  14276. className: "block-editor-duotone-control__popover",
  14277. headerTitle: Object(external_wp_i18n_["__"])('Duotone'),
  14278. onFocusOutside: onToggle
  14279. }, Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], {
  14280. label: Object(external_wp_i18n_["__"])('Duotone')
  14281. }, Object(external_wp_element_["createElement"])(external_wp_components_["DuotonePicker"], {
  14282. colorPalette: colorPalette,
  14283. duotonePalette: duotonePalette,
  14284. disableCustomColors: disableCustomColors,
  14285. disableCustomDuotone: disableCustomDuotone,
  14286. value: value,
  14287. onChange: onChange
  14288. })));
  14289. }
  14290. /* harmony default export */ var duotone_picker_popover = (DuotonePickerPopover);
  14291. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/duotone-control/index.js
  14292. /**
  14293. * WordPress dependencies
  14294. */
  14295. /**
  14296. * Internal dependencies
  14297. */
  14298. function DuotoneControl({
  14299. colorPalette,
  14300. duotonePalette,
  14301. disableCustomColors,
  14302. disableCustomDuotone,
  14303. value,
  14304. onChange
  14305. }) {
  14306. const [isOpen, setIsOpen] = Object(external_wp_element_["useState"])(false);
  14307. const onToggle = () => {
  14308. setIsOpen(prev => !prev);
  14309. };
  14310. const openOnArrowDown = event => {
  14311. if (!isOpen && event.keyCode === external_wp_keycodes_["DOWN"]) {
  14312. event.preventDefault();
  14313. event.stopPropagation();
  14314. onToggle();
  14315. }
  14316. };
  14317. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarButton"], {
  14318. showTooltip: true,
  14319. onClick: onToggle,
  14320. "aria-haspopup": "true",
  14321. "aria-expanded": isOpen,
  14322. onKeyDown: openOnArrowDown,
  14323. label: Object(external_wp_i18n_["__"])('Apply duotone filter'),
  14324. icon: Object(external_wp_element_["createElement"])(external_wp_components_["DuotoneSwatch"], {
  14325. values: value
  14326. })
  14327. }), isOpen && Object(external_wp_element_["createElement"])(duotone_picker_popover, {
  14328. value: value,
  14329. onChange: onChange,
  14330. onToggle: onToggle,
  14331. duotonePalette: duotonePalette,
  14332. colorPalette: colorPalette,
  14333. disableCustomColors: disableCustomColors,
  14334. disableCustomDuotone: disableCustomDuotone
  14335. }));
  14336. }
  14337. /* harmony default export */ var duotone_control = (DuotoneControl);
  14338. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/head.js
  14339. /**
  14340. * WordPress dependencies
  14341. */
  14342. const head_context = Object(external_wp_element_["createContext"])();
  14343. function Head({
  14344. children
  14345. }) {
  14346. const [element, setElement] = Object(external_wp_element_["useState"])();
  14347. return Object(external_wp_element_["createElement"])(head_context.Provider, {
  14348. value: element
  14349. }, Object(external_wp_element_["createElement"])("div", {
  14350. ref: setElement
  14351. }), children);
  14352. }
  14353. Head.context = head_context;
  14354. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/duotone.js
  14355. /**
  14356. * External dependencies
  14357. */
  14358. /**
  14359. * WordPress dependencies
  14360. */
  14361. /**
  14362. * Internal dependencies
  14363. */
  14364. const duotone_EMPTY_ARRAY = [];
  14365. /**
  14366. * Convert a list of colors to an object of R, G, and B values.
  14367. *
  14368. * @param {string[]} colors Array of RBG color strings.
  14369. *
  14370. * @return {Object} R, G, and B values.
  14371. */
  14372. function getValuesFromColors(colors = []) {
  14373. const values = {
  14374. r: [],
  14375. g: [],
  14376. b: []
  14377. };
  14378. colors.forEach(color => {
  14379. // Access values directly to skip extra rounding that tinycolor.toRgb() does.
  14380. const tcolor = tinycolor_default()(color);
  14381. values.r.push(tcolor._r / 255);
  14382. values.g.push(tcolor._g / 255);
  14383. values.b.push(tcolor._b / 255);
  14384. });
  14385. return values;
  14386. }
  14387. /**
  14388. * Values for the SVG `feComponentTransfer`.
  14389. *
  14390. * @typedef Values {Object}
  14391. * @property {number[]} r Red values.
  14392. * @property {number[]} g Green values.
  14393. * @property {number[]} b Blue values.
  14394. */
  14395. /**
  14396. * SVG and stylesheet needed for rendering the duotone filter.
  14397. *
  14398. * @param {Object} props Duotone props.
  14399. * @param {string} props.selector Selector to apply the filter to.
  14400. * @param {string} props.id Unique id for this duotone filter.
  14401. * @param {Values} props.values R, G, and B values to filter with.
  14402. * @return {WPElement} Duotone element.
  14403. */
  14404. function DuotoneFilter({
  14405. selector,
  14406. id,
  14407. values
  14408. }) {
  14409. const stylesheet = `
  14410. ${selector} {
  14411. filter: url( #${id} );
  14412. }
  14413. `;
  14414. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["SVG"], {
  14415. xmlnsXlink: "http://www.w3.org/1999/xlink",
  14416. viewBox: "0 0 0 0",
  14417. width: "0",
  14418. height: "0",
  14419. focusable: "false",
  14420. role: "none",
  14421. style: {
  14422. visibility: 'hidden',
  14423. position: 'absolute',
  14424. left: '-9999px',
  14425. overflow: 'hidden'
  14426. }
  14427. }, Object(external_wp_element_["createElement"])("defs", null, Object(external_wp_element_["createElement"])("filter", {
  14428. id: id
  14429. }, Object(external_wp_element_["createElement"])("feColorMatrix", {
  14430. type: "matrix" // Use perceptual brightness to convert to grayscale.
  14431. // prettier-ignore
  14432. ,
  14433. values: ".299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 0 0 0 1 0"
  14434. }), Object(external_wp_element_["createElement"])("feComponentTransfer", {
  14435. // Use sRGB instead of linearRGB to be consistent with how CSS gradients work.
  14436. colorInterpolationFilters: "sRGB"
  14437. }, Object(external_wp_element_["createElement"])("feFuncR", {
  14438. type: "table",
  14439. tableValues: values.r.join(' ')
  14440. }), Object(external_wp_element_["createElement"])("feFuncG", {
  14441. type: "table",
  14442. tableValues: values.g.join(' ')
  14443. }), Object(external_wp_element_["createElement"])("feFuncB", {
  14444. type: "table",
  14445. tableValues: values.b.join(' ')
  14446. }))))), Object(external_wp_element_["createElement"])("style", {
  14447. dangerouslySetInnerHTML: {
  14448. __html: stylesheet
  14449. }
  14450. }));
  14451. }
  14452. function DuotonePanel({
  14453. attributes,
  14454. setAttributes
  14455. }) {
  14456. var _style$color;
  14457. const style = attributes === null || attributes === void 0 ? void 0 : attributes.style;
  14458. const duotone = style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.duotone;
  14459. const duotonePalette = useSetting('color.duotone') || duotone_EMPTY_ARRAY;
  14460. const colorPalette = useSetting('color.palette') || duotone_EMPTY_ARRAY;
  14461. const disableCustomColors = !useSetting('color.custom');
  14462. const disableCustomDuotone = !useSetting('color.customDuotone') || (colorPalette === null || colorPalette === void 0 ? void 0 : colorPalette.length) === 0 && disableCustomColors;
  14463. if ((duotonePalette === null || duotonePalette === void 0 ? void 0 : duotonePalette.length) === 0 && disableCustomDuotone) {
  14464. return null;
  14465. }
  14466. return Object(external_wp_element_["createElement"])(block_controls, {
  14467. group: "block"
  14468. }, Object(external_wp_element_["createElement"])(duotone_control, {
  14469. duotonePalette: duotonePalette,
  14470. colorPalette: colorPalette,
  14471. disableCustomDuotone: disableCustomDuotone,
  14472. disableCustomColors: disableCustomColors,
  14473. value: duotone,
  14474. onChange: newDuotone => {
  14475. const newStyle = { ...style,
  14476. color: { ...(style === null || style === void 0 ? void 0 : style.color),
  14477. duotone: newDuotone
  14478. }
  14479. };
  14480. setAttributes({
  14481. style: newStyle
  14482. });
  14483. }
  14484. }));
  14485. }
  14486. /**
  14487. * Filters registered block settings, extending attributes to include
  14488. * the `duotone` attribute.
  14489. *
  14490. * @param {Object} settings Original block settings
  14491. * @return {Object} Filtered block settings
  14492. */
  14493. function addDuotoneAttributes(settings) {
  14494. if (!Object(external_wp_blocks_["hasBlockSupport"])(settings, 'color.__experimentalDuotone')) {
  14495. return settings;
  14496. } // Allow blocks to specify their own attribute definition with default
  14497. // values if needed.
  14498. if (!settings.attributes.style) {
  14499. Object.assign(settings.attributes, {
  14500. style: {
  14501. type: 'object'
  14502. }
  14503. });
  14504. }
  14505. return settings;
  14506. }
  14507. /**
  14508. * Override the default edit UI to include toolbar controls for duotone if the
  14509. * block supports duotone.
  14510. *
  14511. * @param {Function} BlockEdit Original component
  14512. * @return {Function} Wrapped component
  14513. */
  14514. const withDuotoneControls = Object(external_wp_compose_["createHigherOrderComponent"])(BlockEdit => props => {
  14515. const hasDuotoneSupport = Object(external_wp_blocks_["hasBlockSupport"])(props.name, 'color.__experimentalDuotone');
  14516. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(BlockEdit, props), hasDuotoneSupport && Object(external_wp_element_["createElement"])(DuotonePanel, props));
  14517. }, 'withDuotoneControls');
  14518. /**
  14519. * Override the default block element to include duotone styles.
  14520. *
  14521. * @param {Function} BlockListBlock Original component
  14522. * @return {Function} Wrapped component
  14523. */
  14524. const withDuotoneStyles = Object(external_wp_compose_["createHigherOrderComponent"])(BlockListBlock => props => {
  14525. var _props$attributes, _props$attributes$sty, _props$attributes$sty2;
  14526. const duotoneSupport = Object(external_wp_blocks_["getBlockSupport"])(props.name, 'color.__experimentalDuotone');
  14527. const values = props === null || props === void 0 ? void 0 : (_props$attributes = props.attributes) === null || _props$attributes === void 0 ? void 0 : (_props$attributes$sty = _props$attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.color) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.duotone;
  14528. if (!duotoneSupport || !values) {
  14529. return Object(external_wp_element_["createElement"])(BlockListBlock, props);
  14530. }
  14531. const id = `wp-duotone-filter-${Object(external_wp_compose_["useInstanceId"])(BlockListBlock)}`;
  14532. const selectors = duotoneSupport.split(',');
  14533. const selectorsScoped = selectors.map(selector => `.${id} ${selector.trim()}`);
  14534. const selectorsGroup = selectorsScoped.join(', ');
  14535. const className = classnames_default()(props === null || props === void 0 ? void 0 : props.className, id);
  14536. const element = Object(external_wp_element_["useContext"])(Head.context);
  14537. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, element && Object(external_wp_element_["createPortal"])(Object(external_wp_element_["createElement"])(DuotoneFilter, {
  14538. selector: selectorsGroup,
  14539. id: id,
  14540. values: getValuesFromColors(values)
  14541. }), element), Object(external_wp_element_["createElement"])(BlockListBlock, Object(esm_extends["a" /* default */])({}, props, {
  14542. className: className
  14543. })));
  14544. }, 'withDuotoneStyles');
  14545. Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/editor/duotone/add-attributes', addDuotoneAttributes);
  14546. Object(external_wp_hooks_["addFilter"])('editor.BlockEdit', 'core/editor/duotone/with-editor-controls', withDuotoneControls);
  14547. Object(external_wp_hooks_["addFilter"])('editor.BlockListBlock', 'core/editor/duotone/with-styles', withDuotoneStyles);
  14548. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js
  14549. var build_module_icon = __webpack_require__("iClF");
  14550. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/layout.js
  14551. /**
  14552. * External dependencies
  14553. */
  14554. /**
  14555. * WordPress dependencies
  14556. */
  14557. /**
  14558. * Internal dependencies
  14559. */
  14560. function LayoutPanel({
  14561. setAttributes,
  14562. attributes
  14563. }) {
  14564. const {
  14565. layout = {}
  14566. } = attributes;
  14567. const {
  14568. wideSize,
  14569. contentSize,
  14570. inherit = false
  14571. } = layout;
  14572. const defaultLayout = useSetting('layout');
  14573. const themeSupportsLayout = Object(external_wp_data_["useSelect"])(select => {
  14574. const {
  14575. getSettings
  14576. } = select(store);
  14577. return getSettings().supportsLayout;
  14578. }, []);
  14579. const units = Object(external_wp_components_["__experimentalUseCustomUnits"])({
  14580. availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
  14581. });
  14582. if (!themeSupportsLayout) {
  14583. return null;
  14584. }
  14585. return Object(external_wp_element_["createElement"])(inspector_controls, null, Object(external_wp_element_["createElement"])(external_wp_components_["PanelBody"], {
  14586. title: Object(external_wp_i18n_["__"])('Layout')
  14587. }, !!defaultLayout && Object(external_wp_element_["createElement"])(external_wp_components_["ToggleControl"], {
  14588. label: Object(external_wp_i18n_["__"])('Inherit default layout'),
  14589. checked: !!inherit,
  14590. onChange: () => setAttributes({
  14591. layout: {
  14592. inherit: !inherit
  14593. }
  14594. })
  14595. }), !inherit && Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])("div", {
  14596. className: "block-editor-hooks__layout-controls"
  14597. }, Object(external_wp_element_["createElement"])("div", {
  14598. className: "block-editor-hooks__layout-controls-unit"
  14599. }, Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalUnitControl"], {
  14600. label: Object(external_wp_i18n_["__"])('Content'),
  14601. labelPosition: "top",
  14602. __unstableInputWidth: "80px",
  14603. value: contentSize || wideSize || '',
  14604. onChange: nextWidth => {
  14605. nextWidth = 0 > parseFloat(nextWidth) ? '0' : nextWidth;
  14606. setAttributes({
  14607. layout: { ...layout,
  14608. contentSize: nextWidth
  14609. }
  14610. });
  14611. },
  14612. units: units
  14613. }), Object(external_wp_element_["createElement"])(build_module_icon["a" /* default */], {
  14614. icon: position_center
  14615. })), Object(external_wp_element_["createElement"])("div", {
  14616. className: "block-editor-hooks__layout-controls-unit"
  14617. }, Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalUnitControl"], {
  14618. label: Object(external_wp_i18n_["__"])('Wide'),
  14619. labelPosition: "top",
  14620. __unstableInputWidth: "80px",
  14621. value: wideSize || contentSize || '',
  14622. onChange: nextWidth => {
  14623. nextWidth = 0 > parseFloat(nextWidth) ? '0' : nextWidth;
  14624. setAttributes({
  14625. layout: { ...layout,
  14626. wideSize: nextWidth
  14627. }
  14628. });
  14629. },
  14630. units: units
  14631. }), Object(external_wp_element_["createElement"])(build_module_icon["a" /* default */], {
  14632. icon: stretch_wide
  14633. }))), Object(external_wp_element_["createElement"])("div", {
  14634. className: "block-editor-hooks__layout-controls-reset"
  14635. }, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  14636. isSecondary: true,
  14637. isSmall: true,
  14638. disabled: !contentSize && !wideSize,
  14639. onClick: () => setAttributes({
  14640. layout: {
  14641. contentSize: undefined,
  14642. wideSize: undefined,
  14643. inherit: false
  14644. }
  14645. })
  14646. }, Object(external_wp_i18n_["__"])('Reset')))), Object(external_wp_element_["createElement"])("p", {
  14647. className: "block-editor-hooks__layout-controls-helptext"
  14648. }, Object(external_wp_i18n_["__"])('Customize the width for all elements that are assigned to the center or wide columns.'))));
  14649. }
  14650. /**
  14651. * Filters registered block settings, extending attributes to include `layout`.
  14652. *
  14653. * @param {Object} settings Original block settings
  14654. * @return {Object} Filtered block settings
  14655. */
  14656. function layout_addAttribute(settings) {
  14657. if (Object(external_lodash_["has"])(settings.attributes, ['layout', 'type'])) {
  14658. return settings;
  14659. }
  14660. if (Object(external_wp_blocks_["hasBlockSupport"])(settings, '__experimentalLayout')) {
  14661. settings.attributes = { ...settings.attributes,
  14662. layout: {
  14663. type: 'object'
  14664. }
  14665. };
  14666. }
  14667. return settings;
  14668. }
  14669. /**
  14670. * Override the default edit UI to include layout controls
  14671. *
  14672. * @param {Function} BlockEdit Original component
  14673. * @return {Function} Wrapped component
  14674. */
  14675. const withInspectorControls = Object(external_wp_compose_["createHigherOrderComponent"])(BlockEdit => props => {
  14676. const {
  14677. name: blockName
  14678. } = props;
  14679. const supportLayout = Object(external_wp_blocks_["hasBlockSupport"])(blockName, '__experimentalLayout');
  14680. return [supportLayout && Object(external_wp_element_["createElement"])(LayoutPanel, Object(esm_extends["a" /* default */])({
  14681. key: "layout"
  14682. }, props)), Object(external_wp_element_["createElement"])(BlockEdit, Object(esm_extends["a" /* default */])({
  14683. key: "edit"
  14684. }, props))];
  14685. }, 'withInspectorControls');
  14686. /**
  14687. * Override the default block element to add the layout styles.
  14688. *
  14689. * @param {Function} BlockListBlock Original component
  14690. * @return {Function} Wrapped component
  14691. */
  14692. const withLayoutStyles = Object(external_wp_compose_["createHigherOrderComponent"])(BlockListBlock => props => {
  14693. const {
  14694. name,
  14695. attributes
  14696. } = props;
  14697. const supportLayout = Object(external_wp_blocks_["hasBlockSupport"])(name, '__experimentalLayout');
  14698. const id = Object(external_wp_compose_["useInstanceId"])(BlockListBlock);
  14699. const defaultLayout = useSetting('layout') || {};
  14700. if (!supportLayout) {
  14701. return Object(external_wp_element_["createElement"])(BlockListBlock, props);
  14702. }
  14703. const {
  14704. layout = {}
  14705. } = attributes;
  14706. const usedLayout = !!layout && layout.inherit ? defaultLayout : layout;
  14707. const className = classnames_default()(props === null || props === void 0 ? void 0 : props.className, `wp-container-${id}`);
  14708. const element = Object(external_wp_element_["useContext"])(Head.context);
  14709. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, element && Object(external_wp_element_["createPortal"])(Object(external_wp_element_["createElement"])(LayoutStyle, {
  14710. selector: `.wp-container-${id}`,
  14711. layout: usedLayout
  14712. }), element), Object(external_wp_element_["createElement"])(BlockListBlock, Object(esm_extends["a" /* default */])({}, props, {
  14713. className: className
  14714. })));
  14715. });
  14716. Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/layout/addAttribute', layout_addAttribute);
  14717. Object(external_wp_hooks_["addFilter"])('editor.BlockListBlock', 'core/editor/layout/with-layout-styles', withLayoutStyles);
  14718. Object(external_wp_hooks_["addFilter"])('editor.BlockEdit', 'core/editor/layout/with-inspector-controls', withInspectorControls);
  14719. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/use-border-props.js
  14720. /**
  14721. * External dependencies
  14722. */
  14723. /**
  14724. * Internal dependencies
  14725. */
  14726. // This utility is intended to assist where the serialization of the border
  14727. // block support is being skipped for a block but the border related CSS classes
  14728. // & styles still need to be generated so they can be applied to inner elements.
  14729. const use_border_props_EMPTY_ARRAY = [];
  14730. /**
  14731. * Provides the CSS class names and inline styles for a block's border support
  14732. * attributes.
  14733. *
  14734. * @param {Object} attributes Block attributes.
  14735. * @param {string} attributes.borderColor Selected named border color.
  14736. * @param {Object} attributes.style Block's styles attribute.
  14737. *
  14738. * @return {Object} Border block support derived CSS classes & styles.
  14739. */
  14740. function getBorderClassesAndStyles({
  14741. borderColor,
  14742. style
  14743. }) {
  14744. var _style$border;
  14745. const borderStyles = (style === null || style === void 0 ? void 0 : style.border) || {};
  14746. const borderClass = getColorClassName('border-color', borderColor);
  14747. const className = classnames_default()({
  14748. [borderClass]: !!borderClass,
  14749. 'has-border-color': borderColor || (style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.color)
  14750. });
  14751. return {
  14752. className: className || undefined,
  14753. style: getInlineStyles({
  14754. border: borderStyles
  14755. })
  14756. };
  14757. }
  14758. /**
  14759. * Derives the border related props for a block from its border block support
  14760. * attributes.
  14761. *
  14762. * Inline styles are forced for named colors to ensure these selections are
  14763. * reflected when themes do not load their color stylesheets in the editor.
  14764. *
  14765. * @param {Object} attributes Block attributes.
  14766. * @return {Object} ClassName & style props from border block support.
  14767. */
  14768. function useBorderProps(attributes) {
  14769. const colors = useSetting('color.palette') || use_border_props_EMPTY_ARRAY;
  14770. const borderProps = getBorderClassesAndStyles(attributes); // Force inline style to apply border color when themes do not load their
  14771. // color stylesheets in the editor.
  14772. if (attributes.borderColor) {
  14773. const borderColorObject = getColorObjectByAttributeValues(colors, attributes.borderColor);
  14774. borderProps.style.borderColor = borderColorObject.color;
  14775. }
  14776. return borderProps;
  14777. }
  14778. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/use-color-props.js
  14779. /**
  14780. * External dependencies
  14781. */
  14782. /**
  14783. * Internal dependencies
  14784. */
  14785. // The code in this file has largely been lifted from the color block support
  14786. // hook.
  14787. //
  14788. // This utility is intended to assist where the serialization of the colors
  14789. // block support is being skipped for a block but the color related CSS classes
  14790. // & styles still need to be generated so they can be applied to inner elements.
  14791. const use_color_props_EMPTY_ARRAY = [];
  14792. /**
  14793. * Provides the CSS class names and inline styles for a block's color support
  14794. * attributes.
  14795. *
  14796. * @param {Object} attributes Block attributes.
  14797. * @return {Object} Color block support derived CSS classes & styles.
  14798. */
  14799. function getColorClassesAndStyles(attributes) {
  14800. var _style$color, _style$color2, _style$color3, _style$color4, _style$elements, _style$elements$link;
  14801. const {
  14802. backgroundColor,
  14803. textColor,
  14804. gradient,
  14805. style
  14806. } = attributes; // Collect color CSS classes.
  14807. const backgroundClass = getColorClassName('background-color', backgroundColor);
  14808. const textClass = getColorClassName('color', textColor);
  14809. const gradientClass = __experimentalGetGradientClass(gradient);
  14810. const hasGradient = gradientClass || (style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.gradient); // Determine color CSS class name list.
  14811. const className = classnames_default()(textClass, gradientClass, {
  14812. // Don't apply the background class if there's a gradient.
  14813. [backgroundClass]: !hasGradient && !!backgroundClass,
  14814. 'has-text-color': textColor || (style === null || style === void 0 ? void 0 : (_style$color2 = style.color) === null || _style$color2 === void 0 ? void 0 : _style$color2.text),
  14815. 'has-background': backgroundColor || (style === null || style === void 0 ? void 0 : (_style$color3 = style.color) === null || _style$color3 === void 0 ? void 0 : _style$color3.background) || gradient || (style === null || style === void 0 ? void 0 : (_style$color4 = style.color) === null || _style$color4 === void 0 ? void 0 : _style$color4.gradient),
  14816. 'has-link-color': style === null || style === void 0 ? void 0 : (_style$elements = style.elements) === null || _style$elements === void 0 ? void 0 : (_style$elements$link = _style$elements.link) === null || _style$elements$link === void 0 ? void 0 : _style$elements$link.color
  14817. }); // Collect inline styles for colors.
  14818. const colorStyles = (style === null || style === void 0 ? void 0 : style.color) || {};
  14819. const styleProp = getInlineStyles({
  14820. color: colorStyles
  14821. });
  14822. return {
  14823. className: className || undefined,
  14824. style: styleProp
  14825. };
  14826. }
  14827. /**
  14828. * Determines the color related props for a block derived from its color block
  14829. * support attributes.
  14830. *
  14831. * Inline styles are forced for named colors to ensure these selections are
  14832. * reflected when themes do not load their color stylesheets in the editor.
  14833. *
  14834. * @param {Object} attributes Block attributes.
  14835. * @return {Object} ClassName & style props from colors block support.
  14836. */
  14837. function useColorProps(attributes) {
  14838. const {
  14839. backgroundColor,
  14840. textColor,
  14841. gradient
  14842. } = attributes;
  14843. const colors = useSetting('color.palette') || use_color_props_EMPTY_ARRAY;
  14844. const gradients = useSetting('color.gradients') || use_color_props_EMPTY_ARRAY;
  14845. const colorProps = getColorClassesAndStyles(attributes); // Force inline styles to apply colors when themes do not load their color
  14846. // stylesheets in the editor.
  14847. if (backgroundColor) {
  14848. const backgroundColorObject = getColorObjectByAttributeValues(colors, backgroundColor);
  14849. colorProps.style.backgroundColor = backgroundColorObject.color;
  14850. }
  14851. if (gradient) {
  14852. colorProps.style.background = getGradientValueBySlug(gradients, gradient);
  14853. }
  14854. if (textColor) {
  14855. const textColorObject = getColorObjectByAttributeValues(colors, textColor);
  14856. colorProps.style.color = textColorObject.color;
  14857. }
  14858. return colorProps;
  14859. }
  14860. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/index.js
  14861. /**
  14862. * Internal dependencies
  14863. */
  14864. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/with-colors.js
  14865. /**
  14866. * External dependencies
  14867. */
  14868. /**
  14869. * WordPress dependencies
  14870. */
  14871. /**
  14872. * Internal dependencies
  14873. */
  14874. const DEFAULT_COLORS = [];
  14875. /**
  14876. * Higher order component factory for injecting the `colorsArray` argument as
  14877. * the colors prop in the `withCustomColors` HOC.
  14878. *
  14879. * @param {Array} colorsArray An array of color objects.
  14880. *
  14881. * @return {Function} The higher order component.
  14882. */
  14883. const withCustomColorPalette = colorsArray => Object(external_wp_compose_["createHigherOrderComponent"])(WrappedComponent => props => Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, props, {
  14884. colors: colorsArray
  14885. })), 'withCustomColorPalette');
  14886. /**
  14887. * Higher order component factory for injecting the editor colors as the
  14888. * `colors` prop in the `withColors` HOC.
  14889. *
  14890. * @return {Function} The higher order component.
  14891. */
  14892. const withEditorColorPalette = () => Object(external_wp_compose_["createHigherOrderComponent"])(WrappedComponent => props => {
  14893. const colors = useSetting('color.palette') || DEFAULT_COLORS;
  14894. return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, props, {
  14895. colors: colors
  14896. }));
  14897. }, 'withEditorColorPalette');
  14898. /**
  14899. * Helper function used with `createHigherOrderComponent` to create
  14900. * higher order components for managing color logic.
  14901. *
  14902. * @param {Array} colorTypes An array of color types (e.g. 'backgroundColor, borderColor).
  14903. * @param {Function} withColorPalette A HOC for injecting the 'colors' prop into the WrappedComponent.
  14904. *
  14905. * @return {WPComponent} The component that can be used as a HOC.
  14906. */
  14907. function createColorHOC(colorTypes, withColorPalette) {
  14908. const colorMap = Object(external_lodash_["reduce"])(colorTypes, (colorObject, colorType) => {
  14909. return { ...colorObject,
  14910. ...(Object(external_lodash_["isString"])(colorType) ? {
  14911. [colorType]: Object(external_lodash_["kebabCase"])(colorType)
  14912. } : colorType)
  14913. };
  14914. }, {});
  14915. return Object(external_wp_compose_["compose"])([withColorPalette, WrappedComponent => {
  14916. return class extends external_wp_element_["Component"] {
  14917. constructor(props) {
  14918. super(props);
  14919. this.setters = this.createSetters();
  14920. this.colorUtils = {
  14921. getMostReadableColor: this.getMostReadableColor.bind(this)
  14922. };
  14923. this.state = {};
  14924. }
  14925. getMostReadableColor(colorValue) {
  14926. const {
  14927. colors
  14928. } = this.props;
  14929. return getMostReadableColor(colors, colorValue);
  14930. }
  14931. createSetters() {
  14932. return Object(external_lodash_["reduce"])(colorMap, (settersAccumulator, colorContext, colorAttributeName) => {
  14933. const upperFirstColorAttributeName = Object(external_lodash_["upperFirst"])(colorAttributeName);
  14934. const customColorAttributeName = `custom${upperFirstColorAttributeName}`;
  14935. settersAccumulator[`set${upperFirstColorAttributeName}`] = this.createSetColor(colorAttributeName, customColorAttributeName);
  14936. return settersAccumulator;
  14937. }, {});
  14938. }
  14939. createSetColor(colorAttributeName, customColorAttributeName) {
  14940. return colorValue => {
  14941. const colorObject = getColorObjectByColorValue(this.props.colors, colorValue);
  14942. this.props.setAttributes({
  14943. [colorAttributeName]: colorObject && colorObject.slug ? colorObject.slug : undefined,
  14944. [customColorAttributeName]: colorObject && colorObject.slug ? undefined : colorValue
  14945. });
  14946. };
  14947. }
  14948. static getDerivedStateFromProps({
  14949. attributes,
  14950. colors
  14951. }, previousState) {
  14952. return Object(external_lodash_["reduce"])(colorMap, (newState, colorContext, colorAttributeName) => {
  14953. const colorObject = getColorObjectByAttributeValues(colors, attributes[colorAttributeName], attributes[`custom${Object(external_lodash_["upperFirst"])(colorAttributeName)}`]);
  14954. const previousColorObject = previousState[colorAttributeName];
  14955. const previousColor = previousColorObject === null || previousColorObject === void 0 ? void 0 : previousColorObject.color;
  14956. /**
  14957. * The "and previousColorObject" condition checks that a previous color object was already computed.
  14958. * At the start previousColorObject and colorValue are both equal to undefined
  14959. * bus as previousColorObject does not exist we should compute the object.
  14960. */
  14961. if (previousColor === colorObject.color && previousColorObject) {
  14962. newState[colorAttributeName] = previousColorObject;
  14963. } else {
  14964. newState[colorAttributeName] = { ...colorObject,
  14965. class: getColorClassName(colorContext, colorObject.slug)
  14966. };
  14967. }
  14968. return newState;
  14969. }, {});
  14970. }
  14971. render() {
  14972. return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, this.props, {
  14973. colors: undefined
  14974. }, this.state, this.setters, {
  14975. colorUtils: this.colorUtils
  14976. }));
  14977. }
  14978. };
  14979. }]);
  14980. }
  14981. /**
  14982. * A higher-order component factory for creating a 'withCustomColors' HOC, which handles color logic
  14983. * for class generation color value, retrieval and color attribute setting.
  14984. *
  14985. * Use this higher-order component to work with a custom set of colors.
  14986. *
  14987. * @example
  14988. *
  14989. * ```jsx
  14990. * const CUSTOM_COLORS = [ { name: 'Red', slug: 'red', color: '#ff0000' }, { name: 'Blue', slug: 'blue', color: '#0000ff' } ];
  14991. * const withCustomColors = createCustomColorsHOC( CUSTOM_COLORS );
  14992. * // ...
  14993. * export default compose(
  14994. * withCustomColors( 'backgroundColor', 'borderColor' ),
  14995. * MyColorfulComponent,
  14996. * );
  14997. * ```
  14998. *
  14999. * @param {Array} colorsArray The array of color objects (name, slug, color, etc... ).
  15000. *
  15001. * @return {Function} Higher-order component.
  15002. */
  15003. function createCustomColorsHOC(colorsArray) {
  15004. return (...colorTypes) => {
  15005. const withColorPalette = withCustomColorPalette(colorsArray);
  15006. return Object(external_wp_compose_["createHigherOrderComponent"])(createColorHOC(colorTypes, withColorPalette), 'withCustomColors');
  15007. };
  15008. }
  15009. /**
  15010. * A higher-order component, which handles color logic for class generation color value, retrieval and color attribute setting.
  15011. *
  15012. * For use with the default editor/theme color palette.
  15013. *
  15014. * @example
  15015. *
  15016. * ```jsx
  15017. * export default compose(
  15018. * withColors( 'backgroundColor', { textColor: 'color' } ),
  15019. * MyColorfulComponent,
  15020. * );
  15021. * ```
  15022. *
  15023. * @param {...(Object|string)} colorTypes The arguments can be strings or objects. If the argument is an object,
  15024. * it should contain the color attribute name as key and the color context as value.
  15025. * If the argument is a string the value should be the color attribute name,
  15026. * the color context is computed by applying a kebab case transform to the value.
  15027. * Color context represents the context/place where the color is going to be used.
  15028. * The class name of the color is generated using 'has' followed by the color name
  15029. * and ending with the color context all in kebab case e.g: has-green-background-color.
  15030. *
  15031. * @return {Function} Higher-order component.
  15032. */
  15033. function withColors(...colorTypes) {
  15034. const withColorPalette = withEditorColorPalette();
  15035. return Object(external_wp_compose_["createHigherOrderComponent"])(createColorHOC(colorTypes, withColorPalette), 'withColors');
  15036. }
  15037. // EXTERNAL MODULE: ./node_modules/memize/index.js
  15038. var memize = __webpack_require__("4eJC");
  15039. var memize_default = /*#__PURE__*/__webpack_require__.n(memize);
  15040. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/panel-color-settings/index.js
  15041. /**
  15042. * Internal dependencies
  15043. */
  15044. const PanelColorSettings = ({
  15045. colorSettings,
  15046. ...props
  15047. }) => {
  15048. const settings = colorSettings.map(({
  15049. value,
  15050. onChange,
  15051. ...otherSettings
  15052. }) => ({ ...otherSettings,
  15053. colorValue: value,
  15054. onColorChange: onChange
  15055. }));
  15056. return Object(external_wp_element_["createElement"])(panel_color_gradient_settings, Object(esm_extends["a" /* default */])({
  15057. settings: settings,
  15058. gradients: [],
  15059. disableCustomGradients: true
  15060. }, props));
  15061. };
  15062. /* harmony default export */ var panel_color_settings = (PanelColorSettings);
  15063. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/color-panel.js
  15064. /**
  15065. * External dependencies
  15066. */
  15067. /**
  15068. * Internal dependencies
  15069. */
  15070. const resolveContrastCheckerColor = (color, colorSettings, detectedColor) => {
  15071. if (typeof color === 'function') {
  15072. return color(colorSettings);
  15073. } else if (color === true) {
  15074. return detectedColor;
  15075. }
  15076. return color;
  15077. };
  15078. function color_panel_ColorPanel({
  15079. title,
  15080. colorSettings,
  15081. colorPanelProps,
  15082. contrastCheckers,
  15083. detectedBackgroundColor,
  15084. detectedColor,
  15085. panelChildren,
  15086. initialOpen
  15087. }) {
  15088. return Object(external_wp_element_["createElement"])(panel_color_settings, Object(esm_extends["a" /* default */])({
  15089. title: title,
  15090. initialOpen: initialOpen,
  15091. colorSettings: Object.values(colorSettings)
  15092. }, colorPanelProps), contrastCheckers && (Array.isArray(contrastCheckers) ? contrastCheckers.map(({
  15093. backgroundColor,
  15094. textColor,
  15095. ...rest
  15096. }) => {
  15097. backgroundColor = resolveContrastCheckerColor(backgroundColor, colorSettings, detectedBackgroundColor);
  15098. textColor = resolveContrastCheckerColor(textColor, colorSettings, detectedColor);
  15099. return Object(external_wp_element_["createElement"])(contrast_checker, Object(esm_extends["a" /* default */])({
  15100. key: `${backgroundColor}-${textColor}`,
  15101. backgroundColor: backgroundColor,
  15102. textColor: textColor
  15103. }, rest));
  15104. }) : Object(external_lodash_["map"])(colorSettings, ({
  15105. value
  15106. }) => {
  15107. let {
  15108. backgroundColor,
  15109. textColor
  15110. } = contrastCheckers;
  15111. backgroundColor = resolveContrastCheckerColor(backgroundColor || value, colorSettings, detectedBackgroundColor);
  15112. textColor = resolveContrastCheckerColor(textColor || value, colorSettings, detectedColor);
  15113. return Object(external_wp_element_["createElement"])(contrast_checker, Object(esm_extends["a" /* default */])({}, contrastCheckers, {
  15114. key: `${backgroundColor}-${textColor}`,
  15115. backgroundColor: backgroundColor,
  15116. textColor: textColor
  15117. }));
  15118. })), typeof panelChildren === 'function' ? panelChildren(colorSettings) : panelChildren);
  15119. }
  15120. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/use-colors.js
  15121. /**
  15122. * External dependencies
  15123. */
  15124. /**
  15125. * WordPress dependencies
  15126. */
  15127. /**
  15128. * Internal dependencies
  15129. */
  15130. function use_colors_getComputedStyle(node) {
  15131. return node.ownerDocument.defaultView.getComputedStyle(node);
  15132. }
  15133. const use_colors_DEFAULT_COLORS = [];
  15134. const COMMON_COLOR_LABELS = {
  15135. textColor: Object(external_wp_i18n_["__"])('Text color'),
  15136. backgroundColor: Object(external_wp_i18n_["__"])('Background color')
  15137. };
  15138. const InspectorControlsColorPanel = props => Object(external_wp_element_["createElement"])(inspector_controls, null, Object(external_wp_element_["createElement"])(color_panel_ColorPanel, props));
  15139. function __experimentalUseColors(colorConfigs, {
  15140. panelTitle = Object(external_wp_i18n_["__"])('Color'),
  15141. colorPanelProps,
  15142. contrastCheckers,
  15143. panelChildren,
  15144. colorDetector: {
  15145. targetRef,
  15146. backgroundColorTargetRef = targetRef,
  15147. textColorTargetRef = targetRef
  15148. } = {}
  15149. } = {
  15150. panelTitle: Object(external_wp_i18n_["__"])('Color')
  15151. }, deps = []) {
  15152. const {
  15153. clientId
  15154. } = useBlockEditContext();
  15155. const settingsColors = useSetting('color.palette') || use_colors_DEFAULT_COLORS;
  15156. const {
  15157. attributes
  15158. } = Object(external_wp_data_["useSelect"])(select => {
  15159. const {
  15160. getBlockAttributes
  15161. } = select(store);
  15162. return {
  15163. attributes: getBlockAttributes(clientId)
  15164. };
  15165. }, [clientId]);
  15166. const {
  15167. updateBlockAttributes
  15168. } = Object(external_wp_data_["useDispatch"])(store);
  15169. const setAttributes = Object(external_wp_element_["useCallback"])(newAttributes => updateBlockAttributes(clientId, newAttributes), [updateBlockAttributes, clientId]);
  15170. const createComponent = Object(external_wp_element_["useMemo"])(() => memize_default()((name, property, className, color, colorValue, customColor) => ({
  15171. children,
  15172. className: componentClassName = '',
  15173. style: componentStyle = {}
  15174. }) => {
  15175. let colorStyle = {};
  15176. if (color) {
  15177. colorStyle = {
  15178. [property]: colorValue
  15179. };
  15180. } else if (customColor) {
  15181. colorStyle = {
  15182. [property]: customColor
  15183. };
  15184. }
  15185. const extraProps = {
  15186. className: classnames_default()(componentClassName, {
  15187. [`has-${Object(external_lodash_["kebabCase"])(color)}-${Object(external_lodash_["kebabCase"])(property)}`]: color,
  15188. [className || `has-${Object(external_lodash_["kebabCase"])(name)}`]: color || customColor
  15189. }),
  15190. style: { ...colorStyle,
  15191. ...componentStyle
  15192. }
  15193. };
  15194. if (Object(external_lodash_["isFunction"])(children)) {
  15195. return children(extraProps);
  15196. }
  15197. return (// Clone children, setting the style property from the color configuration,
  15198. // if not already set explicitly through props.
  15199. external_wp_element_["Children"].map(children, child => {
  15200. return Object(external_wp_element_["cloneElement"])(child, {
  15201. className: classnames_default()(child.props.className, extraProps.className),
  15202. style: { ...extraProps.style,
  15203. ...(child.props.style || {})
  15204. }
  15205. });
  15206. })
  15207. );
  15208. }, {
  15209. maxSize: colorConfigs.length
  15210. }), [colorConfigs.length]);
  15211. const createSetColor = Object(external_wp_element_["useMemo"])(() => memize_default()((name, colors) => newColor => {
  15212. const color = colors.find(_color => _color.color === newColor);
  15213. setAttributes({
  15214. [color ? Object(external_lodash_["camelCase"])(`custom ${name}`) : name]: undefined
  15215. });
  15216. setAttributes({
  15217. [color ? name : Object(external_lodash_["camelCase"])(`custom ${name}`)]: color ? color.slug : newColor
  15218. });
  15219. }, {
  15220. maxSize: colorConfigs.length
  15221. }), [setAttributes, colorConfigs.length]);
  15222. const [detectedBackgroundColor, setDetectedBackgroundColor] = Object(external_wp_element_["useState"])();
  15223. const [detectedColor, setDetectedColor] = Object(external_wp_element_["useState"])();
  15224. Object(external_wp_element_["useEffect"])(() => {
  15225. if (!contrastCheckers) {
  15226. return undefined;
  15227. }
  15228. let needsBackgroundColor = false;
  15229. let needsColor = false;
  15230. for (const {
  15231. backgroundColor,
  15232. textColor
  15233. } of Object(external_lodash_["castArray"])(contrastCheckers)) {
  15234. if (!needsBackgroundColor) {
  15235. needsBackgroundColor = backgroundColor === true;
  15236. }
  15237. if (!needsColor) {
  15238. needsColor = textColor === true;
  15239. }
  15240. if (needsBackgroundColor && needsColor) {
  15241. break;
  15242. }
  15243. }
  15244. if (needsColor) {
  15245. setDetectedColor(use_colors_getComputedStyle(textColorTargetRef.current).color);
  15246. }
  15247. if (needsBackgroundColor) {
  15248. let backgroundColorNode = backgroundColorTargetRef.current;
  15249. let backgroundColor = use_colors_getComputedStyle(backgroundColorNode).backgroundColor;
  15250. while (backgroundColor === 'rgba(0, 0, 0, 0)' && backgroundColorNode.parentNode && backgroundColorNode.parentNode.nodeType === backgroundColorNode.parentNode.ELEMENT_NODE) {
  15251. backgroundColorNode = backgroundColorNode.parentNode;
  15252. backgroundColor = use_colors_getComputedStyle(backgroundColorNode).backgroundColor;
  15253. }
  15254. setDetectedBackgroundColor(backgroundColor);
  15255. }
  15256. }, [colorConfigs.reduce((acc, colorConfig) => `${acc} | ${attributes[colorConfig.name]} | ${attributes[Object(external_lodash_["camelCase"])(`custom ${colorConfig.name}`)]}`, ''), ...deps]);
  15257. return Object(external_wp_element_["useMemo"])(() => {
  15258. const colorSettings = {};
  15259. const components = colorConfigs.reduce((acc, colorConfig) => {
  15260. if (typeof colorConfig === 'string') {
  15261. colorConfig = {
  15262. name: colorConfig
  15263. };
  15264. }
  15265. const {
  15266. name,
  15267. // E.g. 'backgroundColor'.
  15268. property = name,
  15269. // E.g. 'backgroundColor'.
  15270. className,
  15271. panelLabel = colorConfig.label || COMMON_COLOR_LABELS[name] || Object(external_lodash_["startCase"])(name),
  15272. // E.g. 'Background color'.
  15273. componentName = Object(external_lodash_["startCase"])(name).replace(/\s/g, ''),
  15274. // E.g. 'BackgroundColor'.
  15275. color = colorConfig.color,
  15276. colors = settingsColors
  15277. } = { ...colorConfig,
  15278. color: attributes[colorConfig.name]
  15279. };
  15280. const customColor = attributes[Object(external_lodash_["camelCase"])(`custom ${name}`)]; // We memoize the non-primitives to avoid unnecessary updates
  15281. // when they are used as props for other components.
  15282. const _color = customColor ? undefined : colors.find(__color => __color.slug === color);
  15283. acc[componentName] = createComponent(name, property, className, color, _color && _color.color, customColor);
  15284. acc[componentName].displayName = componentName;
  15285. acc[componentName].color = customColor ? customColor : _color && _color.color;
  15286. acc[componentName].slug = color;
  15287. acc[componentName].setColor = createSetColor(name, colors);
  15288. colorSettings[componentName] = {
  15289. value: _color ? _color.color : attributes[Object(external_lodash_["camelCase"])(`custom ${name}`)],
  15290. onChange: acc[componentName].setColor,
  15291. label: panelLabel,
  15292. colors
  15293. }; // These settings will be spread over the `colors` in
  15294. // `colorPanelProps`, so we need to unset the key here,
  15295. // if not set to an actual value, to avoid overwriting
  15296. // an actual value in `colorPanelProps`.
  15297. if (!colors) {
  15298. delete colorSettings[componentName].colors;
  15299. }
  15300. return acc;
  15301. }, {});
  15302. const wrappedColorPanelProps = {
  15303. title: panelTitle,
  15304. initialOpen: false,
  15305. colorSettings,
  15306. colorPanelProps,
  15307. contrastCheckers,
  15308. detectedBackgroundColor,
  15309. detectedColor,
  15310. panelChildren
  15311. };
  15312. return { ...components,
  15313. ColorPanel: Object(external_wp_element_["createElement"])(color_panel_ColorPanel, wrappedColorPanelProps),
  15314. InspectorControlsColorPanel: Object(external_wp_element_["createElement"])(InspectorControlsColorPanel, wrappedColorPanelProps)
  15315. };
  15316. }, [attributes, setAttributes, detectedColor, detectedBackgroundColor, ...deps]);
  15317. }
  15318. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/index.js
  15319. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/gradients/index.js
  15320. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/with-font-sizes.js
  15321. /**
  15322. * External dependencies
  15323. */
  15324. /**
  15325. * WordPress dependencies
  15326. */
  15327. /**
  15328. * Internal dependencies
  15329. */
  15330. const DEFAULT_FONT_SIZES = [];
  15331. /**
  15332. * Higher-order component, which handles font size logic for class generation,
  15333. * font size value retrieval, and font size change handling.
  15334. *
  15335. * @param {...(Object|string)} fontSizeNames The arguments should all be strings.
  15336. * Each string contains the font size
  15337. * attribute name e.g: 'fontSize'.
  15338. *
  15339. * @return {Function} Higher-order component.
  15340. */
  15341. /* harmony default export */ var with_font_sizes = ((...fontSizeNames) => {
  15342. /*
  15343. * Computes an object whose key is the font size attribute name as passed in the array,
  15344. * and the value is the custom font size attribute name.
  15345. * Custom font size is automatically compted by appending custom followed by the font size attribute name in with the first letter capitalized.
  15346. */
  15347. const fontSizeAttributeNames = Object(external_lodash_["reduce"])(fontSizeNames, (fontSizeAttributeNamesAccumulator, fontSizeAttributeName) => {
  15348. fontSizeAttributeNamesAccumulator[fontSizeAttributeName] = `custom${Object(external_lodash_["upperFirst"])(fontSizeAttributeName)}`;
  15349. return fontSizeAttributeNamesAccumulator;
  15350. }, {});
  15351. return Object(external_wp_compose_["createHigherOrderComponent"])(Object(external_wp_compose_["compose"])([Object(external_wp_compose_["createHigherOrderComponent"])(WrappedComponent => props => {
  15352. const fontSizes = useSetting('typography.fontSizes') || DEFAULT_FONT_SIZES;
  15353. return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, props, {
  15354. fontSizes: fontSizes
  15355. }));
  15356. }, 'withFontSizes'), WrappedComponent => {
  15357. return class extends external_wp_element_["Component"] {
  15358. constructor(props) {
  15359. super(props);
  15360. this.setters = this.createSetters();
  15361. this.state = {};
  15362. }
  15363. createSetters() {
  15364. return Object(external_lodash_["reduce"])(fontSizeAttributeNames, (settersAccumulator, customFontSizeAttributeName, fontSizeAttributeName) => {
  15365. const upperFirstFontSizeAttributeName = Object(external_lodash_["upperFirst"])(fontSizeAttributeName);
  15366. settersAccumulator[`set${upperFirstFontSizeAttributeName}`] = this.createSetFontSize(fontSizeAttributeName, customFontSizeAttributeName);
  15367. return settersAccumulator;
  15368. }, {});
  15369. }
  15370. createSetFontSize(fontSizeAttributeName, customFontSizeAttributeName) {
  15371. return fontSizeValue => {
  15372. const fontSizeObject = Object(external_lodash_["find"])(this.props.fontSizes, {
  15373. size: Number(fontSizeValue)
  15374. });
  15375. this.props.setAttributes({
  15376. [fontSizeAttributeName]: fontSizeObject && fontSizeObject.slug ? fontSizeObject.slug : undefined,
  15377. [customFontSizeAttributeName]: fontSizeObject && fontSizeObject.slug ? undefined : fontSizeValue
  15378. });
  15379. };
  15380. }
  15381. static getDerivedStateFromProps({
  15382. attributes,
  15383. fontSizes
  15384. }, previousState) {
  15385. const didAttributesChange = (customFontSizeAttributeName, fontSizeAttributeName) => {
  15386. if (previousState[fontSizeAttributeName]) {
  15387. // if new font size is name compare with the previous slug
  15388. if (attributes[fontSizeAttributeName]) {
  15389. return attributes[fontSizeAttributeName] !== previousState[fontSizeAttributeName].slug;
  15390. } // if font size is not named, update when the font size value changes.
  15391. return previousState[fontSizeAttributeName].size !== attributes[customFontSizeAttributeName];
  15392. } // in this case we need to build the font size object
  15393. return true;
  15394. };
  15395. if (!Object(external_lodash_["some"])(fontSizeAttributeNames, didAttributesChange)) {
  15396. return null;
  15397. }
  15398. const newState = Object(external_lodash_["reduce"])(Object(external_lodash_["pickBy"])(fontSizeAttributeNames, didAttributesChange), (newStateAccumulator, customFontSizeAttributeName, fontSizeAttributeName) => {
  15399. const fontSizeAttributeValue = attributes[fontSizeAttributeName];
  15400. const fontSizeObject = getFontSize(fontSizes, fontSizeAttributeValue, attributes[customFontSizeAttributeName]);
  15401. newStateAccumulator[fontSizeAttributeName] = { ...fontSizeObject,
  15402. class: getFontSizeClass(fontSizeAttributeValue)
  15403. };
  15404. return newStateAccumulator;
  15405. }, {});
  15406. return { ...previousState,
  15407. ...newState
  15408. };
  15409. }
  15410. render() {
  15411. return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, this.props, {
  15412. fontSizes: undefined
  15413. }, this.state, this.setters));
  15414. }
  15415. };
  15416. }]), 'withFontSizes');
  15417. });
  15418. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/index.js
  15419. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/align-left.js
  15420. var align_left = __webpack_require__("fPbg");
  15421. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/align-center.js
  15422. var align_center = __webpack_require__("plpT");
  15423. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/align-right.js
  15424. var align_right = __webpack_require__("ziDm");
  15425. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/alignment-control/ui.js
  15426. /**
  15427. * External dependencies
  15428. */
  15429. /**
  15430. * WordPress dependencies
  15431. */
  15432. const DEFAULT_ALIGNMENT_CONTROLS = [{
  15433. icon: align_left["a" /* default */],
  15434. title: Object(external_wp_i18n_["__"])('Align text left'),
  15435. align: 'left'
  15436. }, {
  15437. icon: align_center["a" /* default */],
  15438. title: Object(external_wp_i18n_["__"])('Align text center'),
  15439. align: 'center'
  15440. }, {
  15441. icon: align_right["a" /* default */],
  15442. title: Object(external_wp_i18n_["__"])('Align text right'),
  15443. align: 'right'
  15444. }];
  15445. const alignment_control_ui_POPOVER_PROPS = {
  15446. position: 'bottom right',
  15447. isAlternate: true
  15448. };
  15449. function AlignmentUI({
  15450. value,
  15451. onChange,
  15452. alignmentControls = DEFAULT_ALIGNMENT_CONTROLS,
  15453. label = Object(external_wp_i18n_["__"])('Align'),
  15454. describedBy = Object(external_wp_i18n_["__"])('Change text alignment'),
  15455. isCollapsed = true,
  15456. isToolbar
  15457. }) {
  15458. function applyOrUnset(align) {
  15459. return () => onChange(value === align ? undefined : align);
  15460. }
  15461. const activeAlignment = Object(external_lodash_["find"])(alignmentControls, control => control.align === value);
  15462. function setIcon() {
  15463. if (activeAlignment) return activeAlignment.icon;
  15464. return Object(external_wp_i18n_["isRTL"])() ? align_right["a" /* default */] : align_left["a" /* default */];
  15465. }
  15466. const UIComponent = isToolbar ? external_wp_components_["ToolbarGroup"] : external_wp_components_["ToolbarDropdownMenu"];
  15467. const extraProps = isToolbar ? {
  15468. isCollapsed
  15469. } : {};
  15470. return Object(external_wp_element_["createElement"])(UIComponent, Object(esm_extends["a" /* default */])({
  15471. icon: setIcon(),
  15472. label: label,
  15473. toggleProps: {
  15474. describedBy
  15475. },
  15476. popoverProps: alignment_control_ui_POPOVER_PROPS,
  15477. controls: alignmentControls.map(control => {
  15478. const {
  15479. align
  15480. } = control;
  15481. const isActive = value === align;
  15482. return { ...control,
  15483. isActive,
  15484. role: isCollapsed ? 'menuitemradio' : undefined,
  15485. onClick: applyOrUnset(align)
  15486. };
  15487. })
  15488. }, extraProps));
  15489. }
  15490. /* harmony default export */ var alignment_control_ui = (AlignmentUI);
  15491. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/alignment-control/index.js
  15492. /**
  15493. * Internal dependencies
  15494. */
  15495. function AlignmentControl(props) {
  15496. return Object(external_wp_element_["createElement"])(alignment_control_ui, Object(esm_extends["a" /* default */])({}, props, {
  15497. isToolbar: false
  15498. }));
  15499. }
  15500. function AlignmentToolbar(props) {
  15501. return Object(external_wp_element_["createElement"])(alignment_control_ui, Object(esm_extends["a" /* default */])({}, props, {
  15502. isToolbar: true
  15503. }));
  15504. }
  15505. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/search-items.js
  15506. /**
  15507. * External dependencies
  15508. */
  15509. // Default search helpers
  15510. const defaultGetName = item => item.name || '';
  15511. const defaultGetTitle = item => item.title;
  15512. const defaultGetDescription = item => item.description || '';
  15513. const defaultGetKeywords = item => item.keywords || [];
  15514. const defaultGetCategory = item => item.category;
  15515. const defaultGetCollection = () => null;
  15516. /**
  15517. * Sanitizes the search input string.
  15518. *
  15519. * @param {string} input The search input to normalize.
  15520. *
  15521. * @return {string} The normalized search input.
  15522. */
  15523. function normalizeSearchInput(input = '') {
  15524. // Disregard diacritics.
  15525. // Input: "média"
  15526. input = Object(external_lodash_["deburr"])(input); // Accommodate leading slash, matching autocomplete expectations.
  15527. // Input: "/media"
  15528. input = input.replace(/^\//, ''); // Lowercase.
  15529. // Input: "MEDIA"
  15530. input = input.toLowerCase();
  15531. return input;
  15532. }
  15533. /**
  15534. * Converts the search term into a list of normalized terms.
  15535. *
  15536. * @param {string} input The search term to normalize.
  15537. *
  15538. * @return {string[]} The normalized list of search terms.
  15539. */
  15540. const getNormalizedSearchTerms = (input = '') => {
  15541. // Extract words.
  15542. return Object(external_lodash_["words"])(normalizeSearchInput(input));
  15543. };
  15544. const removeMatchingTerms = (unmatchedTerms, unprocessedTerms) => {
  15545. return Object(external_lodash_["differenceWith"])(unmatchedTerms, getNormalizedSearchTerms(unprocessedTerms), (unmatchedTerm, unprocessedTerm) => unprocessedTerm.includes(unmatchedTerm));
  15546. };
  15547. const searchBlockItems = (items, categories, collections, searchInput) => {
  15548. const normalizedSearchTerms = getNormalizedSearchTerms(searchInput);
  15549. if (normalizedSearchTerms.length === 0) {
  15550. return items;
  15551. }
  15552. const config = {
  15553. getCategory: item => {
  15554. var _find;
  15555. return (_find = Object(external_lodash_["find"])(categories, {
  15556. slug: item.category
  15557. })) === null || _find === void 0 ? void 0 : _find.title;
  15558. },
  15559. getCollection: item => {
  15560. var _collections$item$nam;
  15561. return (_collections$item$nam = collections[item.name.split('/')[0]]) === null || _collections$item$nam === void 0 ? void 0 : _collections$item$nam.title;
  15562. }
  15563. };
  15564. return searchItems(items, searchInput, config);
  15565. };
  15566. /**
  15567. * Filters an item list given a search term.
  15568. *
  15569. * @param {Array} items Item list
  15570. * @param {string} searchInput Search input.
  15571. * @param {Object} config Search Config.
  15572. * @return {Array} Filtered item list.
  15573. */
  15574. const searchItems = (items = [], searchInput = '', config = {}) => {
  15575. const normalizedSearchTerms = getNormalizedSearchTerms(searchInput);
  15576. if (normalizedSearchTerms.length === 0) {
  15577. return items;
  15578. }
  15579. const rankedItems = items.map(item => {
  15580. return [item, getItemSearchRank(item, searchInput, config)];
  15581. }).filter(([, rank]) => rank > 0);
  15582. rankedItems.sort(([, rank1], [, rank2]) => rank2 - rank1);
  15583. return rankedItems.map(([item]) => item);
  15584. };
  15585. /**
  15586. * Get the search rank for a given item and a specific search term.
  15587. * The better the match, the higher the rank.
  15588. * If the rank equals 0, it should be excluded from the results.
  15589. *
  15590. * @param {Object} item Item to filter.
  15591. * @param {string} searchTerm Search term.
  15592. * @param {Object} config Search Config.
  15593. * @return {number} Search Rank.
  15594. */
  15595. function getItemSearchRank(item, searchTerm, config = {}) {
  15596. const {
  15597. getName = defaultGetName,
  15598. getTitle = defaultGetTitle,
  15599. getDescription = defaultGetDescription,
  15600. getKeywords = defaultGetKeywords,
  15601. getCategory = defaultGetCategory,
  15602. getCollection = defaultGetCollection
  15603. } = config;
  15604. const name = getName(item);
  15605. const title = getTitle(item);
  15606. const description = getDescription(item);
  15607. const keywords = getKeywords(item);
  15608. const category = getCategory(item);
  15609. const collection = getCollection(item);
  15610. const normalizedSearchInput = normalizeSearchInput(searchTerm);
  15611. const normalizedTitle = normalizeSearchInput(title);
  15612. let rank = 0; // Prefers exact matches
  15613. // Then prefers if the beginning of the title matches the search term
  15614. // name, keywords, categories, collection, variations match come later.
  15615. if (normalizedSearchInput === normalizedTitle) {
  15616. rank += 30;
  15617. } else if (normalizedTitle.startsWith(normalizedSearchInput)) {
  15618. rank += 20;
  15619. } else {
  15620. const terms = [name, title, description, ...keywords, category, collection].join(' ');
  15621. const normalizedSearchTerms = Object(external_lodash_["words"])(normalizedSearchInput);
  15622. const unmatchedTerms = removeMatchingTerms(normalizedSearchTerms, terms);
  15623. if (unmatchedTerms.length === 0) {
  15624. rank += 10;
  15625. }
  15626. } // Give a better rank to "core" namespaced items.
  15627. if (rank !== 0 && name.startsWith('core/')) {
  15628. rank++;
  15629. }
  15630. return rank;
  15631. }
  15632. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/hooks/use-block-types-state.js
  15633. /**
  15634. * WordPress dependencies
  15635. */
  15636. /**
  15637. * Internal dependencies
  15638. */
  15639. /**
  15640. * Retrieves the block types inserter state.
  15641. *
  15642. * @param {string=} rootClientId Insertion's root client ID.
  15643. * @param {Function} onInsert function called when inserter a list of blocks.
  15644. * @return {Array} Returns the block types state. (block types, categories, collections, onSelect handler)
  15645. */
  15646. const useBlockTypesState = (rootClientId, onInsert) => {
  15647. const {
  15648. categories,
  15649. collections,
  15650. items
  15651. } = Object(external_wp_data_["useSelect"])(select => {
  15652. const {
  15653. getInserterItems
  15654. } = select(store);
  15655. const {
  15656. getCategories,
  15657. getCollections
  15658. } = select(external_wp_blocks_["store"]);
  15659. return {
  15660. categories: getCategories(),
  15661. collections: getCollections(),
  15662. items: getInserterItems(rootClientId)
  15663. };
  15664. }, [rootClientId]);
  15665. const onSelectItem = Object(external_wp_element_["useCallback"])(({
  15666. name,
  15667. initialAttributes,
  15668. innerBlocks
  15669. }, shouldFocusBlock) => {
  15670. const insertedBlock = Object(external_wp_blocks_["createBlock"])(name, initialAttributes, Object(external_wp_blocks_["createBlocksFromInnerBlocksTemplate"])(innerBlocks));
  15671. onInsert(insertedBlock, undefined, shouldFocusBlock);
  15672. }, [onInsert]);
  15673. return [items, categories, collections, onSelectItem];
  15674. };
  15675. /* harmony default export */ var use_block_types_state = (useBlockTypesState);
  15676. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/block-default.js
  15677. var block_default = __webpack_require__("//Lo");
  15678. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-icon/index.js
  15679. /**
  15680. * External dependencies
  15681. */
  15682. /**
  15683. * WordPress dependencies
  15684. */
  15685. function BlockIcon({
  15686. icon,
  15687. showColors = false,
  15688. className
  15689. }) {
  15690. var _icon;
  15691. if (((_icon = icon) === null || _icon === void 0 ? void 0 : _icon.src) === 'block-default') {
  15692. icon = {
  15693. src: block_default["a" /* default */]
  15694. };
  15695. }
  15696. const renderedIcon = Object(external_wp_element_["createElement"])(external_wp_components_["Icon"], {
  15697. icon: icon && icon.src ? icon.src : icon
  15698. });
  15699. const style = showColors ? {
  15700. backgroundColor: icon && icon.background,
  15701. color: icon && icon.foreground
  15702. } : {};
  15703. return Object(external_wp_element_["createElement"])("span", {
  15704. style: style,
  15705. className: classnames_default()('block-editor-block-icon', className, {
  15706. 'has-colors': showColors
  15707. })
  15708. }, renderedIcon);
  15709. }
  15710. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/autocompleters/block.js
  15711. /**
  15712. * External dependencies
  15713. */
  15714. /**
  15715. * WordPress dependencies
  15716. */
  15717. /**
  15718. * Internal dependencies
  15719. */
  15720. const SHOWN_BLOCK_TYPES = 9;
  15721. /** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */
  15722. /**
  15723. * Creates a blocks repeater for replacing the current block with a selected block type.
  15724. *
  15725. * @return {WPCompleter} A blocks completer.
  15726. */
  15727. function createBlockCompleter() {
  15728. return {
  15729. name: 'blocks',
  15730. className: 'block-editor-autocompleters__block',
  15731. triggerPrefix: '/',
  15732. useItems(filterValue) {
  15733. const {
  15734. rootClientId,
  15735. selectedBlockName
  15736. } = Object(external_wp_data_["useSelect"])(select => {
  15737. const {
  15738. getSelectedBlockClientId,
  15739. getBlockName,
  15740. getBlockInsertionPoint
  15741. } = select(store);
  15742. const selectedBlockClientId = getSelectedBlockClientId();
  15743. return {
  15744. selectedBlockName: selectedBlockClientId ? getBlockName(selectedBlockClientId) : null,
  15745. rootClientId: getBlockInsertionPoint().rootClientId
  15746. };
  15747. }, []);
  15748. const [items, categories, collections] = use_block_types_state(rootClientId, external_lodash_["noop"]);
  15749. const filteredItems = Object(external_wp_element_["useMemo"])(() => {
  15750. const initialFilteredItems = !!filterValue.trim() ? searchBlockItems(items, categories, collections, filterValue) : Object(external_lodash_["orderBy"])(items, ['frecency'], ['desc']);
  15751. return initialFilteredItems.filter(item => item.name !== selectedBlockName).slice(0, SHOWN_BLOCK_TYPES);
  15752. }, [filterValue, selectedBlockName, items, categories, collections]);
  15753. const options = Object(external_wp_element_["useMemo"])(() => filteredItems.map(blockItem => {
  15754. const {
  15755. title,
  15756. icon,
  15757. isDisabled
  15758. } = blockItem;
  15759. return {
  15760. key: `block-${blockItem.id}`,
  15761. value: blockItem,
  15762. label: Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(BlockIcon, {
  15763. key: "icon",
  15764. icon: icon,
  15765. showColors: true
  15766. }), title),
  15767. isDisabled
  15768. };
  15769. }), [filteredItems]);
  15770. return [options];
  15771. },
  15772. allowContext(before, after) {
  15773. return !(/\S/.test(before) || /\S/.test(after));
  15774. },
  15775. getOptionCompletion(inserterItem) {
  15776. const {
  15777. name,
  15778. initialAttributes,
  15779. innerBlocks
  15780. } = inserterItem;
  15781. return {
  15782. action: 'replace',
  15783. value: Object(external_wp_blocks_["createBlock"])(name, initialAttributes, Object(external_wp_blocks_["createBlocksFromInnerBlocksTemplate"])(innerBlocks))
  15784. };
  15785. }
  15786. };
  15787. }
  15788. /**
  15789. * Creates a blocks repeater for replacing the current block with a selected block type.
  15790. *
  15791. * @return {WPCompleter} A blocks completer.
  15792. */
  15793. /* harmony default export */ var autocompleters_block = (createBlockCompleter());
  15794. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/autocomplete/index.js
  15795. /**
  15796. * External dependencies
  15797. */
  15798. /**
  15799. * WordPress dependencies
  15800. */
  15801. /**
  15802. * Internal dependencies
  15803. */
  15804. /**
  15805. * Shared reference to an empty array for cases where it is important to avoid
  15806. * returning a new array reference on every invocation.
  15807. *
  15808. * @type {Array}
  15809. */
  15810. const autocomplete_EMPTY_ARRAY = [];
  15811. function useCompleters({
  15812. completers = autocomplete_EMPTY_ARRAY
  15813. }) {
  15814. const {
  15815. name
  15816. } = useBlockEditContext();
  15817. return Object(external_wp_element_["useMemo"])(() => {
  15818. let filteredCompleters = completers;
  15819. if (name === Object(external_wp_blocks_["getDefaultBlockName"])()) {
  15820. filteredCompleters = filteredCompleters.concat([autocompleters_block]);
  15821. }
  15822. if (Object(external_wp_hooks_["hasFilter"])('editor.Autocomplete.completers')) {
  15823. // Provide copies so filters may directly modify them.
  15824. if (filteredCompleters === completers) {
  15825. filteredCompleters = filteredCompleters.map(external_lodash_["clone"]);
  15826. }
  15827. filteredCompleters = Object(external_wp_hooks_["applyFilters"])('editor.Autocomplete.completers', filteredCompleters, name);
  15828. }
  15829. return filteredCompleters;
  15830. }, [completers, name]);
  15831. }
  15832. function useBlockEditorAutocompleteProps(props) {
  15833. return Object(external_wp_components_["__unstableUseAutocompleteProps"])({ ...props,
  15834. completers: useCompleters(props)
  15835. });
  15836. }
  15837. /**
  15838. * Wrap the default Autocomplete component with one that supports a filter hook
  15839. * for customizing its list of autocompleters.
  15840. *
  15841. * @type {import('react').FC}
  15842. */
  15843. function BlockEditorAutocomplete(props) {
  15844. return Object(external_wp_element_["createElement"])(external_wp_components_["Autocomplete"], Object(esm_extends["a" /* default */])({}, props, {
  15845. completers: useCompleters(props)
  15846. }));
  15847. }
  15848. /**
  15849. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/autocomplete/README.md
  15850. */
  15851. /* harmony default export */ var autocomplete = (BlockEditorAutocomplete);
  15852. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/fullscreen.js
  15853. /**
  15854. * WordPress dependencies
  15855. */
  15856. const fullscreen = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
  15857. xmlns: "http://www.w3.org/2000/svg",
  15858. viewBox: "0 0 24 24"
  15859. }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
  15860. d: "M4.2 9h1.5V5.8H9V4.2H4.2V9zm14 9.2H15v1.5h4.8V15h-1.5v3.2zM15 4.2v1.5h3.2V9h1.5V4.2H15zM5.8 15H4.2v4.8H9v-1.5H5.8V15z"
  15861. }));
  15862. /* harmony default export */ var library_fullscreen = (fullscreen);
  15863. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-full-height-alignment-control/index.js
  15864. /**
  15865. * WordPress dependencies
  15866. */
  15867. function BlockFullHeightAlignmentControl({
  15868. isActive,
  15869. label = Object(external_wp_i18n_["__"])('Toggle full height'),
  15870. onToggle,
  15871. isDisabled
  15872. }) {
  15873. return Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarButton"], {
  15874. isActive: isActive,
  15875. icon: library_fullscreen,
  15876. label: label,
  15877. onClick: () => onToggle(!isActive),
  15878. disabled: isDisabled
  15879. });
  15880. }
  15881. /* harmony default export */ var block_full_height_alignment_control = (BlockFullHeightAlignmentControl);
  15882. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-alignment-matrix-control/index.js
  15883. /**
  15884. * External dependencies
  15885. */
  15886. /**
  15887. * WordPress dependencies
  15888. */
  15889. function BlockAlignmentMatrixControl(props) {
  15890. const {
  15891. label = Object(external_wp_i18n_["__"])('Change matrix alignment'),
  15892. onChange = external_lodash_["noop"],
  15893. value = 'center',
  15894. isDisabled
  15895. } = props;
  15896. const icon = Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalAlignmentMatrixControl"].Icon, {
  15897. value: value
  15898. });
  15899. const className = 'block-editor-block-alignment-matrix-control';
  15900. const popoverClassName = `${className}__popover`;
  15901. const isAlternate = true;
  15902. return Object(external_wp_element_["createElement"])(external_wp_components_["Dropdown"], {
  15903. position: "bottom right",
  15904. className: className,
  15905. popoverProps: {
  15906. className: popoverClassName,
  15907. isAlternate
  15908. },
  15909. renderToggle: ({
  15910. onToggle,
  15911. isOpen
  15912. }) => {
  15913. const openOnArrowDown = event => {
  15914. if (!isOpen && event.keyCode === external_wp_keycodes_["DOWN"]) {
  15915. event.preventDefault();
  15916. event.stopPropagation();
  15917. onToggle();
  15918. }
  15919. };
  15920. return Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarButton"], {
  15921. onClick: onToggle,
  15922. "aria-haspopup": "true",
  15923. "aria-expanded": isOpen,
  15924. onKeyDown: openOnArrowDown,
  15925. label: label,
  15926. icon: icon,
  15927. showTooltip: true,
  15928. disabled: isDisabled
  15929. });
  15930. },
  15931. renderContent: () => Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalAlignmentMatrixControl"], {
  15932. hasFocusBorder: false,
  15933. onChange: onChange,
  15934. value: value
  15935. })
  15936. });
  15937. }
  15938. /* harmony default export */ var block_alignment_matrix_control = (BlockAlignmentMatrixControl);
  15939. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-block-display-information/index.js
  15940. /**
  15941. * WordPress dependencies
  15942. */
  15943. /**
  15944. * Internal dependencies
  15945. */
  15946. /** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */
  15947. /**
  15948. * Contains basic block's information for display reasons.
  15949. *
  15950. * @typedef {Object} WPBlockDisplayInformation
  15951. *
  15952. * @property {string} title Human-readable block type label.
  15953. * @property {WPIcon} icon Block type icon.
  15954. * @property {string} description A detailed block type description.
  15955. */
  15956. /**
  15957. * Hook used to try to find a matching block variation and return
  15958. * the appropriate information for display reasons. In order to
  15959. * to try to find a match we need to things:
  15960. * 1. Block's client id to extract it's current attributes.
  15961. * 2. A block variation should have set `isActive` prop to a proper function.
  15962. *
  15963. * If for any reason a block variaton match cannot be found,
  15964. * the returned information come from the Block Type.
  15965. * If no blockType is found with the provided clientId, returns null.
  15966. *
  15967. * @param {string} clientId Block's client id.
  15968. * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found.
  15969. */
  15970. function useBlockDisplayInformation(clientId) {
  15971. return Object(external_wp_data_["useSelect"])(select => {
  15972. if (!clientId) return null;
  15973. const {
  15974. getBlockName,
  15975. getBlockAttributes
  15976. } = select(store);
  15977. const {
  15978. getBlockType,
  15979. getActiveBlockVariation
  15980. } = select(external_wp_blocks_["store"]);
  15981. const blockName = getBlockName(clientId);
  15982. const blockType = getBlockType(blockName);
  15983. if (!blockType) return null;
  15984. const attributes = getBlockAttributes(clientId);
  15985. const match = getActiveBlockVariation(blockName, attributes);
  15986. const blockTypeInfo = {
  15987. title: blockType.title,
  15988. icon: blockType.icon,
  15989. description: blockType.description,
  15990. anchor: attributes === null || attributes === void 0 ? void 0 : attributes.anchor
  15991. };
  15992. if (!match) return blockTypeInfo;
  15993. return {
  15994. title: match.title || blockType.title,
  15995. icon: match.icon || blockType.icon,
  15996. description: match.description || blockType.description
  15997. };
  15998. }, [clientId]);
  15999. }
  16000. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-title/index.js
  16001. /**
  16002. * External dependencies
  16003. */
  16004. /**
  16005. * WordPress dependencies
  16006. */
  16007. /**
  16008. * Internal dependencies
  16009. */
  16010. /**
  16011. * Renders the block's configured title as a string, or empty if the title
  16012. * cannot be determined.
  16013. *
  16014. * @example
  16015. *
  16016. * ```jsx
  16017. * <BlockTitle clientId="afd1cb17-2c08-4e7a-91be-007ba7ddc3a1" />
  16018. * ```
  16019. *
  16020. * @param {Object} props
  16021. * @param {string} props.clientId Client ID of block.
  16022. *
  16023. * @return {?string} Block title.
  16024. */
  16025. function BlockTitle({
  16026. clientId
  16027. }) {
  16028. const {
  16029. attributes,
  16030. name,
  16031. reusableBlockTitle
  16032. } = Object(external_wp_data_["useSelect"])(select => {
  16033. if (!clientId) {
  16034. return {};
  16035. }
  16036. const {
  16037. getBlockName,
  16038. getBlockAttributes,
  16039. __experimentalGetReusableBlockTitle
  16040. } = select(store);
  16041. const blockName = getBlockName(clientId);
  16042. if (!blockName) {
  16043. return {};
  16044. }
  16045. const isReusable = Object(external_wp_blocks_["isReusableBlock"])(Object(external_wp_blocks_["getBlockType"])(blockName));
  16046. return {
  16047. attributes: getBlockAttributes(clientId),
  16048. name: blockName,
  16049. reusableBlockTitle: isReusable && __experimentalGetReusableBlockTitle(getBlockAttributes(clientId).ref)
  16050. };
  16051. }, [clientId]);
  16052. const blockInformation = useBlockDisplayInformation(clientId);
  16053. if (!name || !blockInformation) return null;
  16054. const blockType = Object(external_wp_blocks_["getBlockType"])(name);
  16055. const label = reusableBlockTitle || Object(external_wp_blocks_["__experimentalGetBlockLabel"])(blockType, attributes); // Label will fallback to the title if no label is defined for the current
  16056. // label context. If the label is defined we prioritize it over possible
  16057. // possible block variation title match.
  16058. if (label !== blockType.title) {
  16059. return Object(external_lodash_["truncate"])(label, {
  16060. length: 35
  16061. });
  16062. }
  16063. return blockInformation.title;
  16064. }
  16065. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-breadcrumb/index.js
  16066. /**
  16067. * WordPress dependencies
  16068. */
  16069. /**
  16070. * Internal dependencies
  16071. */
  16072. /**
  16073. * Block breadcrumb component, displaying the hierarchy of the current block selection as a breadcrumb.
  16074. *
  16075. * @param {Object} props Component props.
  16076. * @param {string} props.rootLabelText Translated label for the root element of the breadcrumb trail.
  16077. * @return {WPElement} Block Breadcrumb.
  16078. */
  16079. function BlockBreadcrumb({
  16080. rootLabelText
  16081. }) {
  16082. const {
  16083. selectBlock,
  16084. clearSelectedBlock
  16085. } = Object(external_wp_data_["useDispatch"])(store);
  16086. const {
  16087. clientId,
  16088. parents,
  16089. hasSelection
  16090. } = Object(external_wp_data_["useSelect"])(select => {
  16091. const {
  16092. getSelectionStart,
  16093. getSelectedBlockClientId,
  16094. getBlockParents
  16095. } = select(store);
  16096. const selectedBlockClientId = getSelectedBlockClientId();
  16097. return {
  16098. parents: getBlockParents(selectedBlockClientId),
  16099. clientId: selectedBlockClientId,
  16100. hasSelection: !!getSelectionStart().clientId
  16101. };
  16102. }, []);
  16103. const rootLabel = rootLabelText || Object(external_wp_i18n_["__"])('Document');
  16104. /*
  16105. * Disable reason: The `list` ARIA role is redundant but
  16106. * Safari+VoiceOver won't announce the list otherwise.
  16107. */
  16108. /* eslint-disable jsx-a11y/no-redundant-roles */
  16109. return Object(external_wp_element_["createElement"])("ul", {
  16110. className: "block-editor-block-breadcrumb",
  16111. role: "list",
  16112. "aria-label": Object(external_wp_i18n_["__"])('Block breadcrumb')
  16113. }, Object(external_wp_element_["createElement"])("li", {
  16114. className: !hasSelection ? 'block-editor-block-breadcrumb__current' : undefined,
  16115. "aria-current": !hasSelection ? 'true' : undefined
  16116. }, hasSelection && Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  16117. className: "block-editor-block-breadcrumb__button",
  16118. isTertiary: true,
  16119. onClick: clearSelectedBlock
  16120. }, rootLabel), !hasSelection && rootLabel), parents.map(parentClientId => Object(external_wp_element_["createElement"])("li", {
  16121. key: parentClientId
  16122. }, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  16123. className: "block-editor-block-breadcrumb__button",
  16124. isTertiary: true,
  16125. onClick: () => selectBlock(parentClientId)
  16126. }, Object(external_wp_element_["createElement"])(BlockTitle, {
  16127. clientId: parentClientId
  16128. })))), !!clientId && Object(external_wp_element_["createElement"])("li", {
  16129. className: "block-editor-block-breadcrumb__current",
  16130. "aria-current": "true"
  16131. }, Object(external_wp_element_["createElement"])(BlockTitle, {
  16132. clientId: clientId
  16133. })))
  16134. /* eslint-enable jsx-a11y/no-redundant-roles */
  16135. ;
  16136. }
  16137. /* harmony default export */ var block_breadcrumb = (BlockBreadcrumb);
  16138. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-context/index.js
  16139. /**
  16140. * WordPress dependencies
  16141. */
  16142. /** @typedef {import('react').ReactNode} ReactNode */
  16143. /**
  16144. * @typedef BlockContextProviderProps
  16145. *
  16146. * @property {Record<string,*>} value Context value to merge with current
  16147. * value.
  16148. * @property {ReactNode} children Component children.
  16149. */
  16150. /** @type {import('react').Context<Record<string,*>>} */
  16151. const block_context_Context = Object(external_wp_element_["createContext"])({});
  16152. /**
  16153. * Component which merges passed value with current consumed block context.
  16154. *
  16155. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-context/README.md
  16156. *
  16157. * @param {BlockContextProviderProps} props
  16158. */
  16159. function BlockContextProvider({
  16160. value,
  16161. children
  16162. }) {
  16163. const context = Object(external_wp_element_["useContext"])(block_context_Context);
  16164. const nextValue = Object(external_wp_element_["useMemo"])(() => ({ ...context,
  16165. ...value
  16166. }), [context, value]);
  16167. return Object(external_wp_element_["createElement"])(block_context_Context.Provider, {
  16168. value: nextValue,
  16169. children: children
  16170. });
  16171. }
  16172. /* harmony default export */ var block_context = (block_context_Context);
  16173. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-style-selector/index.js
  16174. /**
  16175. * WordPress dependencies
  16176. */
  16177. const ColorSelectorSVGIcon = () => Object(external_wp_element_["createElement"])(external_wp_components_["SVG"], {
  16178. xmlns: "https://www.w3.org/2000/svg",
  16179. viewBox: "0 0 20 20"
  16180. }, Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
  16181. d: "M7.434 5l3.18 9.16H8.538l-.692-2.184H4.628l-.705 2.184H2L5.18 5h2.254zm-1.13 1.904h-.115l-1.148 3.593H7.44L6.304 6.904zM14.348 7.006c1.853 0 2.9.876 2.9 2.374v4.78h-1.79v-.914h-.114c-.362.64-1.123 1.022-2.031 1.022-1.346 0-2.292-.826-2.292-2.108 0-1.27.972-2.006 2.71-2.107l1.696-.102V9.38c0-.584-.42-.914-1.18-.914-.667 0-1.112.228-1.264.647h-1.701c.12-1.295 1.307-2.107 3.066-2.107zm1.079 4.1l-1.416.09c-.793.056-1.18.342-1.18.844 0 .52.45.837 1.091.837.857 0 1.505-.545 1.505-1.256v-.515z"
  16182. }));
  16183. /**
  16184. * Color Selector Icon component.
  16185. *
  16186. * @param {Object} props Component properties.
  16187. * @param {Object} props.style Style object.
  16188. * @param {string} props.className Class name for component.
  16189. *
  16190. * @return {*} React Icon component.
  16191. */
  16192. const ColorSelectorIcon = ({
  16193. style,
  16194. className
  16195. }) => {
  16196. return Object(external_wp_element_["createElement"])("div", {
  16197. className: "block-library-colors-selector__icon-container"
  16198. }, Object(external_wp_element_["createElement"])("div", {
  16199. className: `${className} block-library-colors-selector__state-selection`,
  16200. style: style
  16201. }, Object(external_wp_element_["createElement"])(ColorSelectorSVGIcon, null)));
  16202. };
  16203. /**
  16204. * Renders the Colors Selector Toolbar with the icon button.
  16205. *
  16206. * @param {Object} props Component properties.
  16207. * @param {Object} props.TextColor Text color component that wraps icon.
  16208. * @param {Object} props.BackgroundColor Background color component that wraps icon.
  16209. *
  16210. * @return {*} React toggle button component.
  16211. */
  16212. const renderToggleComponent = ({
  16213. TextColor,
  16214. BackgroundColor
  16215. }) => ({
  16216. onToggle,
  16217. isOpen
  16218. }) => {
  16219. const openOnArrowDown = event => {
  16220. if (!isOpen && event.keyCode === external_wp_keycodes_["DOWN"]) {
  16221. event.preventDefault();
  16222. event.stopPropagation();
  16223. onToggle();
  16224. }
  16225. };
  16226. return Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], null, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarButton"], {
  16227. className: "components-toolbar__control block-library-colors-selector__toggle",
  16228. label: Object(external_wp_i18n_["__"])('Open Colors Selector'),
  16229. onClick: onToggle,
  16230. onKeyDown: openOnArrowDown,
  16231. icon: Object(external_wp_element_["createElement"])(BackgroundColor, null, Object(external_wp_element_["createElement"])(TextColor, null, Object(external_wp_element_["createElement"])(ColorSelectorIcon, null)))
  16232. }));
  16233. };
  16234. const BlockColorsStyleSelector = ({
  16235. children,
  16236. ...other
  16237. }) => Object(external_wp_element_["createElement"])(external_wp_components_["Dropdown"], {
  16238. position: "bottom right",
  16239. className: "block-library-colors-selector",
  16240. contentClassName: "block-library-colors-selector__popover",
  16241. renderToggle: renderToggleComponent(other),
  16242. renderContent: () => children
  16243. });
  16244. /* harmony default export */ var color_style_selector = (BlockColorsStyleSelector);
  16245. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-edit/edit.js
  16246. /**
  16247. * External dependencies
  16248. */
  16249. /**
  16250. * WordPress dependencies
  16251. */
  16252. /**
  16253. * Internal dependencies
  16254. */
  16255. /**
  16256. * Default value used for blocks which do not define their own context needs,
  16257. * used to guarantee that a block's `context` prop will always be an object. It
  16258. * is assigned as a constant since it is always expected to be an empty object,
  16259. * and in order to avoid unnecessary React reconciliations of a changing object.
  16260. *
  16261. * @type {{}}
  16262. */
  16263. const DEFAULT_BLOCK_CONTEXT = {};
  16264. const edit_Edit = props => {
  16265. const {
  16266. attributes = {},
  16267. name
  16268. } = props;
  16269. const blockType = Object(external_wp_blocks_["getBlockType"])(name);
  16270. const blockContext = Object(external_wp_element_["useContext"])(block_context); // Assign context values using the block type's declared context needs.
  16271. const context = Object(external_wp_element_["useMemo"])(() => {
  16272. return blockType && blockType.usesContext ? Object(external_lodash_["pick"])(blockContext, blockType.usesContext) : DEFAULT_BLOCK_CONTEXT;
  16273. }, [blockType, blockContext]);
  16274. if (!blockType) {
  16275. return null;
  16276. } // `edit` and `save` are functions or components describing the markup
  16277. // with which a block is displayed. If `blockType` is valid, assign
  16278. // them preferentially as the render value for the block.
  16279. const Component = blockType.edit || blockType.save;
  16280. if (blockType.apiVersion > 1 || Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'lightBlockWrapper', false)) {
  16281. return Object(external_wp_element_["createElement"])(Component, Object(esm_extends["a" /* default */])({}, props, {
  16282. context: context
  16283. }));
  16284. } // Generate a class name for the block's editable form
  16285. const generatedClassName = Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'className', true) ? Object(external_wp_blocks_["getBlockDefaultClassName"])(name) : null;
  16286. const className = classnames_default()(generatedClassName, attributes.className);
  16287. return Object(external_wp_element_["createElement"])(Component, Object(esm_extends["a" /* default */])({}, props, {
  16288. context: context,
  16289. className: className
  16290. }));
  16291. };
  16292. /* harmony default export */ var edit = (Object(external_wp_components_["withFilters"])('editor.BlockEdit')(edit_Edit));
  16293. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-edit/index.js
  16294. /**
  16295. * WordPress dependencies
  16296. */
  16297. /**
  16298. * Internal dependencies
  16299. */
  16300. function block_edit_BlockEdit(props) {
  16301. const {
  16302. name,
  16303. isSelected,
  16304. clientId
  16305. } = props;
  16306. const context = {
  16307. name,
  16308. isSelected,
  16309. clientId
  16310. };
  16311. return Object(external_wp_element_["createElement"])(context_Provider // It is important to return the same object if props haven't
  16312. // changed to avoid unnecessary rerenders.
  16313. // See https://reactjs.org/docs/context.html#caveats.
  16314. , {
  16315. value: Object(external_wp_element_["useMemo"])(() => context, Object.values(context))
  16316. }, Object(external_wp_element_["createElement"])(edit, props));
  16317. }
  16318. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/list-view.js
  16319. var list_view = __webpack_require__("OzlF");
  16320. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/more-vertical.js
  16321. var more_vertical = __webpack_require__("VKE3");
  16322. // EXTERNAL MODULE: ./node_modules/react-spring/web.cjs.js
  16323. var web_cjs = __webpack_require__("ZO3Q");
  16324. // EXTERNAL MODULE: external ["wp","dom"]
  16325. var external_wp_dom_ = __webpack_require__("1CF3");
  16326. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-moving-animation/index.js
  16327. /**
  16328. * External dependencies
  16329. */
  16330. /**
  16331. * WordPress dependencies
  16332. */
  16333. /**
  16334. * Simple reducer used to increment a counter.
  16335. *
  16336. * @param {number} state Previous counter value.
  16337. * @return {number} New state value.
  16338. */
  16339. const counterReducer = state => state + 1;
  16340. const getAbsolutePosition = element => {
  16341. return {
  16342. top: element.offsetTop,
  16343. left: element.offsetLeft
  16344. };
  16345. };
  16346. /**
  16347. * Hook used to compute the styles required to move a div into a new position.
  16348. *
  16349. * The way this animation works is the following:
  16350. * - It first renders the element as if there was no animation.
  16351. * - It takes a snapshot of the position of the block to use it
  16352. * as a destination point for the animation.
  16353. * - It restores the element to the previous position using a CSS transform
  16354. * - It uses the "resetAnimation" flag to reset the animation
  16355. * from the beginning in order to animate to the new destination point.
  16356. *
  16357. * @param {Object} $1 Options
  16358. * @param {boolean} $1.isSelected Whether it's the current block or not.
  16359. * @param {boolean} $1.adjustScrolling Adjust the scroll position to the current block.
  16360. * @param {boolean} $1.enableAnimation Enable/Disable animation.
  16361. * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes.
  16362. */
  16363. function useMovingAnimation({
  16364. isSelected,
  16365. adjustScrolling,
  16366. enableAnimation,
  16367. triggerAnimationOnChange
  16368. }) {
  16369. const ref = Object(external_wp_element_["useRef"])();
  16370. const prefersReducedMotion = Object(external_wp_compose_["useReducedMotion"])() || !enableAnimation;
  16371. const [triggeredAnimation, triggerAnimation] = Object(external_wp_element_["useReducer"])(counterReducer, 0);
  16372. const [finishedAnimation, endAnimation] = Object(external_wp_element_["useReducer"])(counterReducer, 0);
  16373. const [transform, setTransform] = Object(external_wp_element_["useState"])({
  16374. x: 0,
  16375. y: 0
  16376. });
  16377. const previous = Object(external_wp_element_["useMemo"])(() => ref.current ? getAbsolutePosition(ref.current) : null, [triggerAnimationOnChange]); // Calculate the previous position of the block relative to the viewport and
  16378. // return a function to maintain that position by scrolling.
  16379. const preserveScrollPosition = Object(external_wp_element_["useMemo"])(() => {
  16380. if (!adjustScrolling || !ref.current) {
  16381. return () => {};
  16382. }
  16383. const scrollContainer = Object(external_wp_dom_["getScrollContainer"])(ref.current);
  16384. if (!scrollContainer) {
  16385. return () => {};
  16386. }
  16387. const prevRect = ref.current.getBoundingClientRect();
  16388. return () => {
  16389. const blockRect = ref.current.getBoundingClientRect();
  16390. const diff = blockRect.top - prevRect.top;
  16391. if (diff) {
  16392. scrollContainer.scrollTop += diff;
  16393. }
  16394. };
  16395. }, [triggerAnimationOnChange, adjustScrolling]);
  16396. Object(external_wp_element_["useLayoutEffect"])(() => {
  16397. if (triggeredAnimation) {
  16398. endAnimation();
  16399. }
  16400. }, [triggeredAnimation]);
  16401. Object(external_wp_element_["useLayoutEffect"])(() => {
  16402. if (!previous) {
  16403. return;
  16404. }
  16405. if (prefersReducedMotion) {
  16406. // if the animation is disabled and the scroll needs to be adjusted,
  16407. // just move directly to the final scroll position.
  16408. preserveScrollPosition();
  16409. return;
  16410. }
  16411. ref.current.style.transform = '';
  16412. const destination = getAbsolutePosition(ref.current);
  16413. triggerAnimation();
  16414. setTransform({
  16415. x: Math.round(previous.left - destination.left),
  16416. y: Math.round(previous.top - destination.top)
  16417. });
  16418. }, [triggerAnimationOnChange]); // Only called when either the x or y value changes.
  16419. function onFrameChange({
  16420. x,
  16421. y
  16422. }) {
  16423. if (!ref.current) {
  16424. return;
  16425. }
  16426. const isMoving = x === 0 && y === 0;
  16427. ref.current.style.transformOrigin = isMoving ? '' : 'center';
  16428. ref.current.style.transform = isMoving ? '' : `translate3d(${x}px,${y}px,0)`;
  16429. ref.current.style.zIndex = !isSelected || isMoving ? '' : '1';
  16430. preserveScrollPosition();
  16431. } // Called for every frame computed by useSpring.
  16432. function onFrame({
  16433. x,
  16434. y
  16435. }) {
  16436. x = Math.round(x);
  16437. y = Math.round(y);
  16438. if (x !== onFrame.x || y !== onFrame.y) {
  16439. onFrameChange({
  16440. x,
  16441. y
  16442. });
  16443. onFrame.x = x;
  16444. onFrame.y = y;
  16445. }
  16446. }
  16447. onFrame.x = 0;
  16448. onFrame.y = 0;
  16449. Object(web_cjs["useSpring"])({
  16450. from: {
  16451. x: transform.x,
  16452. y: transform.y
  16453. },
  16454. to: {
  16455. x: 0,
  16456. y: 0
  16457. },
  16458. reset: triggeredAnimation !== finishedAnimation,
  16459. config: {
  16460. mass: 5,
  16461. tension: 2000,
  16462. friction: 200
  16463. },
  16464. immediate: prefersReducedMotion,
  16465. onFrame
  16466. });
  16467. return ref;
  16468. }
  16469. /* harmony default export */ var use_moving_animation = (useMovingAnimation);
  16470. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/leaf.js
  16471. /**
  16472. * External dependencies
  16473. */
  16474. /**
  16475. * WordPress dependencies
  16476. */
  16477. /**
  16478. * Internal dependencies
  16479. */
  16480. const AnimatedTreeGridRow = Object(web_cjs["animated"])(external_wp_components_["__experimentalTreeGridRow"]);
  16481. function BlockNavigationLeaf({
  16482. isSelected,
  16483. position,
  16484. level,
  16485. rowCount,
  16486. children,
  16487. className,
  16488. path,
  16489. ...props
  16490. }) {
  16491. const ref = use_moving_animation({
  16492. isSelected,
  16493. adjustScrolling: false,
  16494. enableAnimation: true,
  16495. triggerAnimationOnChange: path.join('_')
  16496. });
  16497. return Object(external_wp_element_["createElement"])(AnimatedTreeGridRow, Object(esm_extends["a" /* default */])({
  16498. ref: ref,
  16499. className: classnames_default()('block-editor-block-navigation-leaf', className),
  16500. level: level,
  16501. positionInSet: position,
  16502. setSize: rowCount
  16503. }, props), children);
  16504. }
  16505. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-right.js
  16506. var chevron_right = __webpack_require__("1iEr");
  16507. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-left.js
  16508. var chevron_left = __webpack_require__("2gm7");
  16509. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-up.js
  16510. var chevron_up = __webpack_require__("XgzB");
  16511. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-down.js
  16512. var chevron_down = __webpack_require__("NWDH");
  16513. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-mover/mover-description.js
  16514. /**
  16515. * WordPress dependencies
  16516. */
  16517. /**
  16518. * Return a label for the block movement controls depending on block position.
  16519. *
  16520. * @param {number} selectedCount Number of blocks selected.
  16521. * @param {string} type Block type - in the case of a single block, should
  16522. * define its 'type'. I.e. 'Text', 'Heading', 'Image' etc.
  16523. * @param {number} firstIndex The index (position - 1) of the first block selected.
  16524. * @param {boolean} isFirst This is the first block.
  16525. * @param {boolean} isLast This is the last block.
  16526. * @param {number} dir Direction of movement (> 0 is considered to be going
  16527. * down, < 0 is up).
  16528. * @param {string} orientation The orientation of the block movers, vertical or
  16529. * horizontal.
  16530. *
  16531. * @return {string} Label for the block movement controls.
  16532. */
  16533. function getBlockMoverDescription(selectedCount, type, firstIndex, isFirst, isLast, dir, orientation) {
  16534. const position = firstIndex + 1;
  16535. const getMovementDirection = moveDirection => {
  16536. if (moveDirection === 'up') {
  16537. if (orientation === 'horizontal') {
  16538. return Object(external_wp_i18n_["isRTL"])() ? 'right' : 'left';
  16539. }
  16540. return 'up';
  16541. } else if (moveDirection === 'down') {
  16542. if (orientation === 'horizontal') {
  16543. return Object(external_wp_i18n_["isRTL"])() ? 'left' : 'right';
  16544. }
  16545. return 'down';
  16546. }
  16547. return null;
  16548. };
  16549. if (selectedCount > 1) {
  16550. return getMultiBlockMoverDescription(selectedCount, firstIndex, isFirst, isLast, dir);
  16551. }
  16552. if (isFirst && isLast) {
  16553. return Object(external_wp_i18n_["sprintf"])( // translators: %s: Type of block (i.e. Text, Image etc)
  16554. Object(external_wp_i18n_["__"])('Block %s is the only block, and cannot be moved'), type);
  16555. }
  16556. if (dir > 0 && !isLast) {
  16557. // moving down
  16558. const movementDirection = getMovementDirection('down');
  16559. if (movementDirection === 'down') {
  16560. return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
  16561. Object(external_wp_i18n_["__"])('Move %1$s block from position %2$d down to position %3$d'), type, position, position + 1);
  16562. }
  16563. if (movementDirection === 'left') {
  16564. return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
  16565. Object(external_wp_i18n_["__"])('Move %1$s block from position %2$d left to position %3$d'), type, position, position + 1);
  16566. }
  16567. if (movementDirection === 'right') {
  16568. return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
  16569. Object(external_wp_i18n_["__"])('Move %1$s block from position %2$d right to position %3$d'), type, position, position + 1);
  16570. }
  16571. }
  16572. if (dir > 0 && isLast) {
  16573. // moving down, and is the last item
  16574. const movementDirection = getMovementDirection('down');
  16575. if (movementDirection === 'down') {
  16576. return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc)
  16577. Object(external_wp_i18n_["__"])('Block %1$s is at the end of the content and can’t be moved down'), type);
  16578. }
  16579. if (movementDirection === 'left') {
  16580. return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc)
  16581. Object(external_wp_i18n_["__"])('Block %1$s is at the end of the content and can’t be moved left'), type);
  16582. }
  16583. if (movementDirection === 'right') {
  16584. return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc)
  16585. Object(external_wp_i18n_["__"])('Block %1$s is at the end of the content and can’t be moved right'), type);
  16586. }
  16587. }
  16588. if (dir < 0 && !isFirst) {
  16589. // moving up
  16590. const movementDirection = getMovementDirection('up');
  16591. if (movementDirection === 'up') {
  16592. return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
  16593. Object(external_wp_i18n_["__"])('Move %1$s block from position %2$d up to position %3$d'), type, position, position - 1);
  16594. }
  16595. if (movementDirection === 'left') {
  16596. return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
  16597. Object(external_wp_i18n_["__"])('Move %1$s block from position %2$d left to position %3$d'), type, position, position - 1);
  16598. }
  16599. if (movementDirection === 'right') {
  16600. return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
  16601. Object(external_wp_i18n_["__"])('Move %1$s block from position %2$d right to position %3$d'), type, position, position - 1);
  16602. }
  16603. }
  16604. if (dir < 0 && isFirst) {
  16605. // moving up, and is the first item
  16606. const movementDirection = getMovementDirection('up');
  16607. if (movementDirection === 'up') {
  16608. return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc)
  16609. Object(external_wp_i18n_["__"])('Block %1$s is at the beginning of the content and can’t be moved up'), type);
  16610. }
  16611. if (movementDirection === 'left') {
  16612. return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc)
  16613. Object(external_wp_i18n_["__"])('Block %1$s is at the beginning of the content and can’t be moved left'), type);
  16614. }
  16615. if (movementDirection === 'right') {
  16616. return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc)
  16617. Object(external_wp_i18n_["__"])('Block %1$s is at the beginning of the content and can’t be moved right'), type);
  16618. }
  16619. }
  16620. }
  16621. /**
  16622. * Return a label for the block movement controls depending on block position.
  16623. *
  16624. * @param {number} selectedCount Number of blocks selected.
  16625. * @param {number} firstIndex The index (position - 1) of the first block selected.
  16626. * @param {boolean} isFirst This is the first block.
  16627. * @param {boolean} isLast This is the last block.
  16628. * @param {number} dir Direction of movement (> 0 is considered to be going
  16629. * down, < 0 is up).
  16630. *
  16631. * @return {string} Label for the block movement controls.
  16632. */
  16633. function getMultiBlockMoverDescription(selectedCount, firstIndex, isFirst, isLast, dir) {
  16634. const position = firstIndex + 1;
  16635. if (dir < 0 && isFirst) {
  16636. return Object(external_wp_i18n_["__"])('Blocks cannot be moved up as they are already at the top');
  16637. }
  16638. if (dir > 0 && isLast) {
  16639. return Object(external_wp_i18n_["__"])('Blocks cannot be moved down as they are already at the bottom');
  16640. }
  16641. if (dir < 0 && !isFirst) {
  16642. return Object(external_wp_i18n_["sprintf"])( // translators: 1: Number of selected blocks, 2: Position of selected blocks
  16643. Object(external_wp_i18n_["_n"])('Move %1$d block from position %2$d up by one place', 'Move %1$d blocks from position %2$d up by one place', selectedCount), selectedCount, position);
  16644. }
  16645. if (dir > 0 && !isLast) {
  16646. return Object(external_wp_i18n_["sprintf"])( // translators: 1: Number of selected blocks, 2: Position of selected blocks
  16647. Object(external_wp_i18n_["_n"])('Move %1$d block from position %2$d down by one place', 'Move %1$d blocks from position %2$d down by one place', selectedCount), selectedCount, position);
  16648. }
  16649. }
  16650. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-mover/button.js
  16651. /**
  16652. * External dependencies
  16653. */
  16654. /**
  16655. * WordPress dependencies
  16656. */
  16657. /**
  16658. * Internal dependencies
  16659. */
  16660. const getArrowIcon = (direction, orientation) => {
  16661. if (direction === 'up') {
  16662. if (orientation === 'horizontal') {
  16663. return Object(external_wp_i18n_["isRTL"])() ? chevron_right["a" /* default */] : chevron_left["a" /* default */];
  16664. }
  16665. return chevron_up["a" /* default */];
  16666. } else if (direction === 'down') {
  16667. if (orientation === 'horizontal') {
  16668. return Object(external_wp_i18n_["isRTL"])() ? chevron_left["a" /* default */] : chevron_right["a" /* default */];
  16669. }
  16670. return chevron_down["a" /* default */];
  16671. }
  16672. return null;
  16673. };
  16674. const getMovementDirectionLabel = (moveDirection, orientation) => {
  16675. if (moveDirection === 'up') {
  16676. if (orientation === 'horizontal') {
  16677. return Object(external_wp_i18n_["isRTL"])() ? Object(external_wp_i18n_["__"])('Move right') : Object(external_wp_i18n_["__"])('Move left');
  16678. }
  16679. return Object(external_wp_i18n_["__"])('Move up');
  16680. } else if (moveDirection === 'down') {
  16681. if (orientation === 'horizontal') {
  16682. return Object(external_wp_i18n_["isRTL"])() ? Object(external_wp_i18n_["__"])('Move left') : Object(external_wp_i18n_["__"])('Move right');
  16683. }
  16684. return Object(external_wp_i18n_["__"])('Move down');
  16685. }
  16686. return null;
  16687. };
  16688. const BlockMoverButton = Object(external_wp_element_["forwardRef"])(({
  16689. clientIds,
  16690. direction,
  16691. orientation: moverOrientation,
  16692. ...props
  16693. }, ref) => {
  16694. const instanceId = Object(external_wp_compose_["useInstanceId"])(BlockMoverButton);
  16695. const blocksCount = Object(external_lodash_["castArray"])(clientIds).length;
  16696. const {
  16697. blockType,
  16698. isDisabled,
  16699. rootClientId,
  16700. isFirst,
  16701. isLast,
  16702. firstIndex,
  16703. orientation = 'vertical'
  16704. } = Object(external_wp_data_["useSelect"])(select => {
  16705. const {
  16706. getBlockIndex,
  16707. getBlockRootClientId,
  16708. getBlockOrder,
  16709. getBlock,
  16710. getBlockListSettings
  16711. } = select(store);
  16712. const normalizedClientIds = Object(external_lodash_["castArray"])(clientIds);
  16713. const firstClientId = Object(external_lodash_["first"])(normalizedClientIds);
  16714. const blockRootClientId = getBlockRootClientId(firstClientId);
  16715. const firstBlockIndex = getBlockIndex(firstClientId, blockRootClientId);
  16716. const lastBlockIndex = getBlockIndex(Object(external_lodash_["last"])(normalizedClientIds), blockRootClientId);
  16717. const blockOrder = getBlockOrder(blockRootClientId);
  16718. const block = getBlock(firstClientId);
  16719. const isFirstBlock = firstBlockIndex === 0;
  16720. const isLastBlock = lastBlockIndex === blockOrder.length - 1;
  16721. const {
  16722. orientation: blockListOrientation
  16723. } = getBlockListSettings(blockRootClientId) || {};
  16724. return {
  16725. blockType: block ? Object(external_wp_blocks_["getBlockType"])(block.name) : null,
  16726. isDisabled: direction === 'up' ? isFirstBlock : isLastBlock,
  16727. rootClientId: blockRootClientId,
  16728. firstIndex: firstBlockIndex,
  16729. isFirst: isFirstBlock,
  16730. isLast: isLastBlock,
  16731. orientation: moverOrientation || blockListOrientation
  16732. };
  16733. }, [clientIds, direction]);
  16734. const {
  16735. moveBlocksDown,
  16736. moveBlocksUp
  16737. } = Object(external_wp_data_["useDispatch"])(store);
  16738. const moverFunction = direction === 'up' ? moveBlocksUp : moveBlocksDown;
  16739. const onClick = event => {
  16740. moverFunction(clientIds, rootClientId);
  16741. if (props.onClick) {
  16742. props.onClick(event);
  16743. }
  16744. };
  16745. const descriptionId = `block-editor-block-mover-button__description-${instanceId}`;
  16746. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], Object(esm_extends["a" /* default */])({
  16747. ref: ref,
  16748. className: classnames_default()('block-editor-block-mover-button', `is-${direction}-button`),
  16749. icon: getArrowIcon(direction, orientation),
  16750. label: getMovementDirectionLabel(direction, orientation),
  16751. "aria-describedby": descriptionId
  16752. }, props, {
  16753. onClick: isDisabled ? null : onClick,
  16754. "aria-disabled": isDisabled
  16755. })), Object(external_wp_element_["createElement"])("span", {
  16756. id: descriptionId,
  16757. className: "block-editor-block-mover-button__description"
  16758. }, getBlockMoverDescription(blocksCount, blockType && blockType.title, firstIndex, isFirst, isLast, direction === 'up' ? -1 : 1, orientation)));
  16759. });
  16760. const BlockMoverUpButton = Object(external_wp_element_["forwardRef"])((props, ref) => {
  16761. return Object(external_wp_element_["createElement"])(BlockMoverButton, Object(esm_extends["a" /* default */])({
  16762. direction: "up",
  16763. ref: ref
  16764. }, props));
  16765. });
  16766. const BlockMoverDownButton = Object(external_wp_element_["forwardRef"])((props, ref) => {
  16767. return Object(external_wp_element_["createElement"])(BlockMoverButton, Object(esm_extends["a" /* default */])({
  16768. direction: "down",
  16769. ref: ref
  16770. }, props));
  16771. });
  16772. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/context.js
  16773. /**
  16774. * WordPress dependencies
  16775. */
  16776. const BlockNavigationContext = Object(external_wp_element_["createContext"])({
  16777. __experimentalFeatures: false,
  16778. __experimentalPersistentListViewFeatures: false
  16779. });
  16780. const useBlockNavigationContext = () => Object(external_wp_element_["useContext"])(BlockNavigationContext);
  16781. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/more-horizontal.js
  16782. /**
  16783. * WordPress dependencies
  16784. */
  16785. const moreHorizontal = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
  16786. xmlns: "http://www.w3.org/2000/svg",
  16787. viewBox: "0 0 24 24"
  16788. }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
  16789. d: "M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z"
  16790. }));
  16791. /* harmony default export */ var more_horizontal = (moreHorizontal);
  16792. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/warning/index.js
  16793. /**
  16794. * External dependencies
  16795. */
  16796. /**
  16797. * WordPress dependencies
  16798. */
  16799. function Warning({
  16800. className,
  16801. actions,
  16802. children,
  16803. secondaryActions
  16804. }) {
  16805. return Object(external_wp_element_["createElement"])("div", {
  16806. className: classnames_default()(className, 'block-editor-warning')
  16807. }, Object(external_wp_element_["createElement"])("div", {
  16808. className: "block-editor-warning__contents"
  16809. }, Object(external_wp_element_["createElement"])("p", {
  16810. className: "block-editor-warning__message"
  16811. }, children), (external_wp_element_["Children"].count(actions) > 0 || secondaryActions) && Object(external_wp_element_["createElement"])("div", {
  16812. className: "block-editor-warning__actions"
  16813. }, external_wp_element_["Children"].count(actions) > 0 && external_wp_element_["Children"].map(actions, (action, i) => Object(external_wp_element_["createElement"])("span", {
  16814. key: i,
  16815. className: "block-editor-warning__action"
  16816. }, action)), secondaryActions && Object(external_wp_element_["createElement"])(external_wp_components_["DropdownMenu"], {
  16817. className: "block-editor-warning__secondary",
  16818. icon: more_horizontal,
  16819. label: Object(external_wp_i18n_["__"])('More options'),
  16820. popoverProps: {
  16821. position: 'bottom left',
  16822. className: 'block-editor-warning__dropdown'
  16823. },
  16824. noIcons: true
  16825. }, () => Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], null, secondaryActions.map((item, pos) => Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  16826. onClick: item.onClick,
  16827. key: pos
  16828. }, item.title)))))));
  16829. }
  16830. /**
  16831. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md
  16832. */
  16833. /* harmony default export */ var warning = (Warning);
  16834. // EXTERNAL MODULE: ./node_modules/diff/lib/diff/character.js
  16835. var diff_character = __webpack_require__("iA5R");
  16836. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-compare/block-view.js
  16837. /**
  16838. * WordPress dependencies
  16839. */
  16840. function BlockView({
  16841. title,
  16842. rawContent,
  16843. renderedContent,
  16844. action,
  16845. actionText,
  16846. className
  16847. }) {
  16848. return Object(external_wp_element_["createElement"])("div", {
  16849. className: className
  16850. }, Object(external_wp_element_["createElement"])("div", {
  16851. className: "block-editor-block-compare__content"
  16852. }, Object(external_wp_element_["createElement"])("h2", {
  16853. className: "block-editor-block-compare__heading"
  16854. }, title), Object(external_wp_element_["createElement"])("div", {
  16855. className: "block-editor-block-compare__html"
  16856. }, rawContent), Object(external_wp_element_["createElement"])("div", {
  16857. className: "block-editor-block-compare__preview edit-post-visual-editor"
  16858. }, Object(external_wp_element_["createElement"])(external_wp_element_["RawHTML"], null, Object(external_wp_dom_["safeHTML"])(renderedContent)))), Object(external_wp_element_["createElement"])("div", {
  16859. className: "block-editor-block-compare__action"
  16860. }, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  16861. isSecondary: true,
  16862. tabIndex: "0",
  16863. onClick: action
  16864. }, actionText)));
  16865. }
  16866. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-compare/index.js
  16867. /**
  16868. * External dependencies
  16869. */
  16870. // diff doesn't tree-shake correctly, so we import from the individual
  16871. // module here, to avoid including too much of the library
  16872. /**
  16873. * WordPress dependencies
  16874. */
  16875. /**
  16876. * Internal dependencies
  16877. */
  16878. function BlockCompare({
  16879. block,
  16880. onKeep,
  16881. onConvert,
  16882. convertor,
  16883. convertButtonText
  16884. }) {
  16885. function getDifference(originalContent, newContent) {
  16886. const difference = Object(diff_character["diffChars"])(originalContent, newContent);
  16887. return difference.map((item, pos) => {
  16888. const classes = classnames_default()({
  16889. 'block-editor-block-compare__added': item.added,
  16890. 'block-editor-block-compare__removed': item.removed
  16891. });
  16892. return Object(external_wp_element_["createElement"])("span", {
  16893. key: pos,
  16894. className: classes
  16895. }, item.value);
  16896. });
  16897. }
  16898. function getConvertedContent(convertedBlock) {
  16899. // The convertor may return an array of items or a single item
  16900. const newBlocks = Object(external_lodash_["castArray"])(convertedBlock); // Get converted block details
  16901. const newContent = newBlocks.map(item => Object(external_wp_blocks_["getSaveContent"])(item.name, item.attributes, item.innerBlocks));
  16902. return newContent.join('');
  16903. }
  16904. const converted = getConvertedContent(convertor(block));
  16905. const difference = getDifference(block.originalContent, converted);
  16906. return Object(external_wp_element_["createElement"])("div", {
  16907. className: "block-editor-block-compare__wrapper"
  16908. }, Object(external_wp_element_["createElement"])(BlockView, {
  16909. title: Object(external_wp_i18n_["__"])('Current'),
  16910. className: "block-editor-block-compare__current",
  16911. action: onKeep,
  16912. actionText: Object(external_wp_i18n_["__"])('Convert to HTML'),
  16913. rawContent: block.originalContent,
  16914. renderedContent: block.originalContent
  16915. }), Object(external_wp_element_["createElement"])(BlockView, {
  16916. title: Object(external_wp_i18n_["__"])('After Conversion'),
  16917. className: "block-editor-block-compare__converted",
  16918. action: onConvert,
  16919. actionText: convertButtonText,
  16920. rawContent: difference,
  16921. renderedContent: converted
  16922. }));
  16923. }
  16924. /* harmony default export */ var block_compare = (BlockCompare);
  16925. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-invalid-warning.js
  16926. /**
  16927. * WordPress dependencies
  16928. */
  16929. /**
  16930. * Internal dependencies
  16931. */
  16932. function BlockInvalidWarning({
  16933. convertToHTML,
  16934. convertToBlocks,
  16935. convertToClassic,
  16936. attemptBlockRecovery,
  16937. block
  16938. }) {
  16939. const hasHTMLBlock = !!Object(external_wp_blocks_["getBlockType"])('core/html');
  16940. const [compare, setCompare] = Object(external_wp_element_["useState"])(false);
  16941. const onCompare = Object(external_wp_element_["useCallback"])(() => setCompare(true), []);
  16942. const onCompareClose = Object(external_wp_element_["useCallback"])(() => setCompare(false), []); // We memo the array here to prevent the children components from being updated unexpectedly
  16943. const hiddenActions = Object(external_wp_element_["useMemo"])(() => [{
  16944. // translators: Button to fix block content
  16945. title: Object(external_wp_i18n_["_x"])('Resolve', 'imperative verb'),
  16946. onClick: onCompare
  16947. }, hasHTMLBlock && {
  16948. title: Object(external_wp_i18n_["__"])('Convert to HTML'),
  16949. onClick: convertToHTML
  16950. }, {
  16951. title: Object(external_wp_i18n_["__"])('Convert to Classic Block'),
  16952. onClick: convertToClassic
  16953. }].filter(Boolean), [onCompare, convertToHTML, convertToClassic]);
  16954. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(warning, {
  16955. actions: [Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  16956. key: "recover",
  16957. onClick: attemptBlockRecovery,
  16958. isPrimary: true
  16959. }, Object(external_wp_i18n_["__"])('Attempt Block Recovery'))],
  16960. secondaryActions: hiddenActions
  16961. }, Object(external_wp_i18n_["__"])('This block contains unexpected or invalid content.')), compare && Object(external_wp_element_["createElement"])(external_wp_components_["Modal"], {
  16962. title: // translators: Dialog title to fix block content
  16963. Object(external_wp_i18n_["__"])('Resolve Block'),
  16964. onRequestClose: onCompareClose,
  16965. className: "block-editor-block-compare"
  16966. }, Object(external_wp_element_["createElement"])(block_compare, {
  16967. block: block,
  16968. onKeep: convertToHTML,
  16969. onConvert: convertToBlocks,
  16970. convertor: blockToBlocks,
  16971. convertButtonText: Object(external_wp_i18n_["__"])('Convert to Blocks')
  16972. })));
  16973. }
  16974. const blockToClassic = block => Object(external_wp_blocks_["createBlock"])('core/freeform', {
  16975. content: block.originalContent
  16976. });
  16977. const blockToHTML = block => Object(external_wp_blocks_["createBlock"])('core/html', {
  16978. content: block.originalContent
  16979. });
  16980. const blockToBlocks = block => Object(external_wp_blocks_["rawHandler"])({
  16981. HTML: block.originalContent
  16982. });
  16983. const recoverBlock = ({
  16984. name,
  16985. attributes,
  16986. innerBlocks
  16987. }) => Object(external_wp_blocks_["createBlock"])(name, attributes, innerBlocks);
  16988. /* harmony default export */ var block_invalid_warning = (Object(external_wp_compose_["compose"])([Object(external_wp_data_["withSelect"])((select, {
  16989. clientId
  16990. }) => ({
  16991. block: select(store).getBlock(clientId)
  16992. })), Object(external_wp_data_["withDispatch"])((dispatch, {
  16993. block
  16994. }) => {
  16995. const {
  16996. replaceBlock
  16997. } = dispatch(store);
  16998. return {
  16999. convertToClassic() {
  17000. replaceBlock(block.clientId, blockToClassic(block));
  17001. },
  17002. convertToHTML() {
  17003. replaceBlock(block.clientId, blockToHTML(block));
  17004. },
  17005. convertToBlocks() {
  17006. replaceBlock(block.clientId, blockToBlocks(block));
  17007. },
  17008. attemptBlockRecovery() {
  17009. replaceBlock(block.clientId, recoverBlock(block));
  17010. }
  17011. };
  17012. })])(BlockInvalidWarning));
  17013. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-crash-warning.js
  17014. /**
  17015. * WordPress dependencies
  17016. */
  17017. /**
  17018. * Internal dependencies
  17019. */
  17020. const block_crash_warning_warning = Object(external_wp_element_["createElement"])(warning, {
  17021. className: "block-editor-block-list__block-crash-warning"
  17022. }, Object(external_wp_i18n_["__"])('This block has encountered an error and cannot be previewed.'));
  17023. /* harmony default export */ var block_crash_warning = (() => block_crash_warning_warning);
  17024. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-crash-boundary.js
  17025. /**
  17026. * WordPress dependencies
  17027. */
  17028. class block_crash_boundary_BlockCrashBoundary extends external_wp_element_["Component"] {
  17029. constructor() {
  17030. super(...arguments);
  17031. this.state = {
  17032. hasError: false
  17033. };
  17034. }
  17035. componentDidCatch() {
  17036. this.setState({
  17037. hasError: true
  17038. });
  17039. }
  17040. render() {
  17041. if (this.state.hasError) {
  17042. return this.props.fallback;
  17043. }
  17044. return this.props.children;
  17045. }
  17046. }
  17047. /* harmony default export */ var block_crash_boundary = (block_crash_boundary_BlockCrashBoundary);
  17048. // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js
  17049. var lib = __webpack_require__("O6Fj");
  17050. var lib_default = /*#__PURE__*/__webpack_require__.n(lib);
  17051. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-html.js
  17052. /**
  17053. * External dependencies
  17054. */
  17055. /**
  17056. * WordPress dependencies
  17057. */
  17058. /**
  17059. * Internal dependencies
  17060. */
  17061. function BlockHTML({
  17062. clientId
  17063. }) {
  17064. const [html, setHtml] = Object(external_wp_element_["useState"])('');
  17065. const block = Object(external_wp_data_["useSelect"])(select => select(store).getBlock(clientId), [clientId]);
  17066. const {
  17067. updateBlock
  17068. } = Object(external_wp_data_["useDispatch"])(store);
  17069. const onChange = () => {
  17070. const blockType = Object(external_wp_blocks_["getBlockType"])(block.name);
  17071. const attributes = Object(external_wp_blocks_["getBlockAttributes"])(blockType, html, block.attributes); // If html is empty we reset the block to the default HTML and mark it as valid to avoid triggering an error
  17072. const content = html ? html : Object(external_wp_blocks_["getSaveContent"])(blockType, attributes);
  17073. const isValid = html ? Object(external_wp_blocks_["isValidBlockContent"])(blockType, attributes, content) : true;
  17074. updateBlock(clientId, {
  17075. attributes,
  17076. originalContent: content,
  17077. isValid
  17078. }); // Ensure the state is updated if we reset so it displays the default content
  17079. if (!html) {
  17080. setHtml({
  17081. content
  17082. });
  17083. }
  17084. };
  17085. Object(external_wp_element_["useEffect"])(() => {
  17086. setHtml(Object(external_wp_blocks_["getBlockContent"])(block));
  17087. }, [block]);
  17088. return Object(external_wp_element_["createElement"])(lib_default.a, {
  17089. className: "block-editor-block-list__block-html-textarea",
  17090. value: html,
  17091. onBlur: onChange,
  17092. onChange: event => setHtml(event.target.value)
  17093. });
  17094. }
  17095. /* harmony default export */ var block_html = (BlockHTML);
  17096. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/dom.js
  17097. const BLOCK_SELECTOR = '.block-editor-block-list__block';
  17098. /**
  17099. * Returns true if two elements are contained within the same block.
  17100. *
  17101. * @param {Element} a First element.
  17102. * @param {Element} b Second element.
  17103. *
  17104. * @return {boolean} Whether elements are in the same block.
  17105. */
  17106. function isInSameBlock(a, b) {
  17107. return a.closest(BLOCK_SELECTOR) === b.closest(BLOCK_SELECTOR);
  17108. }
  17109. /**
  17110. * Returns true if an element is considered part of the block and not its
  17111. * children.
  17112. *
  17113. * @param {Element} blockElement Block container element.
  17114. * @param {Element} element Element.
  17115. *
  17116. * @return {boolean} Whether element is in the block Element but not its
  17117. * children.
  17118. */
  17119. function isInsideRootBlock(blockElement, element) {
  17120. const parentBlock = element.closest(BLOCK_SELECTOR);
  17121. return parentBlock === blockElement;
  17122. }
  17123. /**
  17124. * Finds the block client ID given any DOM node inside the block.
  17125. *
  17126. * @param {Node?} node DOM node.
  17127. *
  17128. * @return {string|undefined} Client ID or undefined if the node is not part of
  17129. * a block.
  17130. */
  17131. function getBlockClientId(node) {
  17132. while (node && node.nodeType !== node.ELEMENT_NODE) {
  17133. node = node.parentNode;
  17134. }
  17135. if (!node) {
  17136. return;
  17137. }
  17138. const elementNode =
  17139. /** @type {Element} */
  17140. node;
  17141. const blockNode = elementNode.closest(BLOCK_SELECTOR);
  17142. if (!blockNode) {
  17143. return;
  17144. }
  17145. return blockNode.id.slice('block-'.length);
  17146. }
  17147. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-focus-first-element.js
  17148. /**
  17149. * External dependencies
  17150. */
  17151. /**
  17152. * WordPress dependencies
  17153. */
  17154. /**
  17155. * Internal dependencies
  17156. */
  17157. /** @typedef {import('@wordpress/element').RefObject} RefObject */
  17158. /**
  17159. * Returns the initial position if the block needs to be focussed, `undefined`
  17160. * otherwise. The initial position is either 0 (start) or -1 (end).
  17161. *
  17162. * @param {string} clientId Block client ID.
  17163. *
  17164. * @return {number} The initial position, either 0 (start) or -1 (end).
  17165. */
  17166. function useInitialPosition(clientId) {
  17167. return Object(external_wp_data_["useSelect"])(select => {
  17168. const {
  17169. getSelectedBlocksInitialCaretPosition,
  17170. isMultiSelecting,
  17171. isNavigationMode,
  17172. isBlockSelected
  17173. } = select(store);
  17174. if (!isBlockSelected(clientId)) {
  17175. return;
  17176. }
  17177. if (isMultiSelecting() || isNavigationMode()) {
  17178. return;
  17179. } // If there's no initial position, return 0 to focus the start.
  17180. return getSelectedBlocksInitialCaretPosition();
  17181. }, [clientId]);
  17182. }
  17183. /**
  17184. * Transitions focus to the block or inner tabbable when the block becomes
  17185. * selected and an initial position is set.
  17186. *
  17187. * @param {string} clientId Block client ID.
  17188. *
  17189. * @return {RefObject} React ref with the block element.
  17190. */
  17191. function useFocusFirstElement(clientId) {
  17192. const ref = Object(external_wp_element_["useRef"])();
  17193. const initialPosition = useInitialPosition(clientId);
  17194. Object(external_wp_element_["useEffect"])(() => {
  17195. if (initialPosition === undefined || initialPosition === null) {
  17196. return;
  17197. }
  17198. if (!ref.current) {
  17199. return;
  17200. }
  17201. const {
  17202. ownerDocument
  17203. } = ref.current; // Do not focus the block if it already contains the active element.
  17204. if (ref.current.contains(ownerDocument.activeElement)) {
  17205. return;
  17206. } // Find all tabbables within node.
  17207. const textInputs = external_wp_dom_["focus"].tabbable.find(ref.current).filter(node => Object(external_wp_dom_["isTextField"])(node)); // If reversed (e.g. merge via backspace), use the last in the set of
  17208. // tabbables.
  17209. const isReverse = -1 === initialPosition;
  17210. const target = (isReverse ? external_lodash_["last"] : external_lodash_["first"])(textInputs) || ref.current;
  17211. if ( // Don't focus inner block or block appenders.
  17212. !isInsideRootBlock(ref.current, target) || target.closest('.block-list-appender')) {
  17213. ref.current.focus();
  17214. return;
  17215. }
  17216. Object(external_wp_dom_["placeCaretAtHorizontalEdge"])(target, isReverse);
  17217. }, [initialPosition]);
  17218. return ref;
  17219. }
  17220. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-is-hovered.js
  17221. /**
  17222. * WordPress dependencies
  17223. */
  17224. /**
  17225. * Internal dependencies
  17226. */
  17227. function listener(event) {
  17228. if (event.defaultPrevented) {
  17229. return;
  17230. }
  17231. const action = event.type === 'mouseover' ? 'add' : 'remove';
  17232. event.preventDefault();
  17233. event.currentTarget.classList[action]('is-hovered');
  17234. }
  17235. /**
  17236. * Adds `is-hovered` class when the block is hovered and in navigation or
  17237. * outline mode.
  17238. */
  17239. function useIsHovered() {
  17240. const isEnabled = Object(external_wp_data_["useSelect"])(select => {
  17241. const {
  17242. isNavigationMode,
  17243. getSettings
  17244. } = select(store);
  17245. return isNavigationMode() || getSettings().outlineMode;
  17246. }, []);
  17247. return Object(external_wp_compose_["useRefEffect"])(node => {
  17248. if (isEnabled) {
  17249. node.addEventListener('mouseout', listener);
  17250. node.addEventListener('mouseover', listener);
  17251. return () => {
  17252. node.removeEventListener('mouseout', listener);
  17253. node.removeEventListener('mouseover', listener); // Remove class in case it lingers.
  17254. node.classList.remove('is-hovered');
  17255. };
  17256. }
  17257. }, [isEnabled]);
  17258. }
  17259. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-class-names.js
  17260. /**
  17261. * External dependencies
  17262. */
  17263. /**
  17264. * WordPress dependencies
  17265. */
  17266. /**
  17267. * Internal dependencies
  17268. */
  17269. /**
  17270. * Returns the class names used for the different states of the block.
  17271. *
  17272. * @param {string} clientId The block client ID.
  17273. *
  17274. * @return {string} The class names.
  17275. */
  17276. function useBlockClassNames(clientId) {
  17277. return Object(external_wp_data_["useSelect"])(select => {
  17278. const {
  17279. isBlockBeingDragged,
  17280. isBlockHighlighted,
  17281. isBlockSelected,
  17282. isBlockMultiSelected,
  17283. getBlockName,
  17284. getSettings,
  17285. hasSelectedInnerBlock,
  17286. isTyping,
  17287. __experimentalGetActiveBlockIdByBlockNames: getActiveBlockIdByBlockNames
  17288. } = select(store);
  17289. const {
  17290. __experimentalSpotlightEntityBlocks: spotlightEntityBlocks,
  17291. outlineMode
  17292. } = getSettings();
  17293. const isDragging = isBlockBeingDragged(clientId);
  17294. const isSelected = isBlockSelected(clientId);
  17295. const name = getBlockName(clientId);
  17296. const checkDeep = true; // "ancestor" is the more appropriate label due to "deep" check
  17297. const isAncestorOfSelectedBlock = hasSelectedInnerBlock(clientId, checkDeep);
  17298. const activeEntityBlockId = getActiveBlockIdByBlockNames(spotlightEntityBlocks);
  17299. return classnames_default()({
  17300. 'is-selected': isSelected,
  17301. 'is-highlighted': isBlockHighlighted(clientId),
  17302. 'is-multi-selected': isBlockMultiSelected(clientId),
  17303. 'is-reusable': Object(external_wp_blocks_["isReusableBlock"])(Object(external_wp_blocks_["getBlockType"])(name)),
  17304. 'is-dragging': isDragging,
  17305. 'has-child-selected': isAncestorOfSelectedBlock,
  17306. 'has-active-entity': activeEntityBlockId,
  17307. // Determine if there is an active entity area to spotlight.
  17308. 'is-active-entity': activeEntityBlockId === clientId,
  17309. 'remove-outline': isSelected && outlineMode && isTyping()
  17310. });
  17311. }, [clientId]);
  17312. }
  17313. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-default-class-name.js
  17314. /**
  17315. * WordPress dependencies
  17316. */
  17317. /**
  17318. * Internal dependencies
  17319. */
  17320. /**
  17321. * Returns the default class name if the block is a light block and it supports
  17322. * `className`.
  17323. *
  17324. * @param {string} clientId The block client ID.
  17325. *
  17326. * @return {string} The class name, e.g. `wp-block-paragraph`.
  17327. */
  17328. function useBlockDefaultClassName(clientId) {
  17329. return Object(external_wp_data_["useSelect"])(select => {
  17330. const name = select(store).getBlockName(clientId);
  17331. const blockType = Object(external_wp_blocks_["getBlockType"])(name);
  17332. const hasLightBlockWrapper = blockType.apiVersion > 1 || Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'lightBlockWrapper', false);
  17333. if (!hasLightBlockWrapper) {
  17334. return;
  17335. }
  17336. return Object(external_wp_blocks_["getBlockDefaultClassName"])(name);
  17337. }, [clientId]);
  17338. }
  17339. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-custom-class-name.js
  17340. /**
  17341. * WordPress dependencies
  17342. */
  17343. /**
  17344. * Internal dependencies
  17345. */
  17346. /**
  17347. * Returns the custom class name if the block is a light block.
  17348. *
  17349. * @param {string} clientId The block client ID.
  17350. *
  17351. * @return {string} The custom class name.
  17352. */
  17353. function useBlockCustomClassName(clientId) {
  17354. // It's good for this to be a separate selector because it will be executed
  17355. // on every attribute change, while the other selectors are not re-evaluated
  17356. // as much.
  17357. return Object(external_wp_data_["useSelect"])(select => {
  17358. const {
  17359. getBlockName,
  17360. getBlockAttributes
  17361. } = select(store);
  17362. const {
  17363. className
  17364. } = getBlockAttributes(clientId);
  17365. if (!className) {
  17366. return;
  17367. }
  17368. const blockType = Object(external_wp_blocks_["getBlockType"])(getBlockName(clientId));
  17369. const hasLightBlockWrapper = blockType.apiVersion > 1 || Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'lightBlockWrapper', false);
  17370. if (!hasLightBlockWrapper) {
  17371. return;
  17372. }
  17373. return className;
  17374. }, [clientId]);
  17375. }
  17376. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-moving-mode-class-names.js
  17377. /**
  17378. * External dependencies
  17379. */
  17380. /**
  17381. * WordPress dependencies
  17382. */
  17383. /**
  17384. * Internal dependencies
  17385. */
  17386. /**
  17387. * Returns the class names used for block moving mode.
  17388. *
  17389. * @param {string} clientId The block client ID to insert above.
  17390. *
  17391. * @return {string} The class names.
  17392. */
  17393. function useBlockMovingModeClassNames(clientId) {
  17394. return Object(external_wp_data_["useSelect"])(select => {
  17395. const {
  17396. hasBlockMovingClientId,
  17397. canInsertBlockType,
  17398. getBlockName,
  17399. getBlockRootClientId,
  17400. isBlockSelected
  17401. } = select(store); // The classes are only relevant for the selected block. Avoid
  17402. // re-rendering all blocks!
  17403. if (!isBlockSelected(clientId)) {
  17404. return;
  17405. }
  17406. const movingClientId = hasBlockMovingClientId();
  17407. if (!movingClientId) {
  17408. return;
  17409. }
  17410. return classnames_default()('is-block-moving-mode', {
  17411. 'can-insert-moving-block': canInsertBlockType(getBlockName(movingClientId), getBlockRootClientId(clientId))
  17412. });
  17413. }, [clientId]);
  17414. }
  17415. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-focus-handler.js
  17416. /**
  17417. * WordPress dependencies
  17418. */
  17419. /**
  17420. * Internal dependencies
  17421. */
  17422. /**
  17423. * Selects the block if it receives focus.
  17424. *
  17425. * @param {string} clientId Block client ID.
  17426. */
  17427. function useFocusHandler(clientId) {
  17428. const {
  17429. isBlockSelected
  17430. } = Object(external_wp_data_["useSelect"])(store);
  17431. const {
  17432. selectBlock,
  17433. selectionChange
  17434. } = Object(external_wp_data_["useDispatch"])(store);
  17435. return Object(external_wp_compose_["useRefEffect"])(node => {
  17436. /**
  17437. * Marks the block as selected when focused and not already
  17438. * selected. This specifically handles the case where block does not
  17439. * set focus on its own (via `setFocus`), typically if there is no
  17440. * focusable input in the block.
  17441. *
  17442. * @param {FocusEvent} event Focus event.
  17443. */
  17444. function onFocus(event) {
  17445. // Check synchronously because a non-selected block might be
  17446. // getting data through `useSelect` asynchronously.
  17447. if (isBlockSelected(clientId)) {
  17448. // Potentially change selection away from rich text.
  17449. if (!event.target.isContentEditable) {
  17450. selectionChange(clientId);
  17451. }
  17452. return;
  17453. } // If an inner block is focussed, that block is resposible for
  17454. // setting the selected block.
  17455. if (!isInsideRootBlock(node, event.target)) {
  17456. return;
  17457. }
  17458. selectBlock(clientId);
  17459. }
  17460. node.addEventListener('focusin', onFocus);
  17461. return () => {
  17462. node.removeEventListener('focusin', onFocus);
  17463. };
  17464. }, [isBlockSelected, selectBlock]);
  17465. }
  17466. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js
  17467. /**
  17468. * WordPress dependencies
  17469. */
  17470. /**
  17471. * Internal dependencies
  17472. */
  17473. /**
  17474. * Adds block behaviour:
  17475. * - Removes the block on BACKSPACE.
  17476. * - Inserts a default block on ENTER.
  17477. * - Disables dragging of block contents.
  17478. *
  17479. * @param {string} clientId Block client ID.
  17480. */
  17481. function useEventHandlers(clientId) {
  17482. const isSelected = Object(external_wp_data_["useSelect"])(select => select(store).isBlockSelected(clientId), [clientId]);
  17483. const {
  17484. getBlockRootClientId,
  17485. getBlockIndex
  17486. } = Object(external_wp_data_["useSelect"])(store);
  17487. const {
  17488. insertDefaultBlock,
  17489. removeBlock
  17490. } = Object(external_wp_data_["useDispatch"])(store);
  17491. return Object(external_wp_compose_["useRefEffect"])(node => {
  17492. if (!isSelected) {
  17493. return;
  17494. }
  17495. /**
  17496. * Interprets keydown event intent to remove or insert after block if
  17497. * key event occurs on wrapper node. This can occur when the block has
  17498. * no text fields of its own, particularly after initial insertion, to
  17499. * allow for easy deletion and continuous writing flow to add additional
  17500. * content.
  17501. *
  17502. * @param {KeyboardEvent} event Keydown event.
  17503. */
  17504. function onKeyDown(event) {
  17505. const {
  17506. keyCode,
  17507. target
  17508. } = event;
  17509. if (keyCode !== external_wp_keycodes_["ENTER"] && keyCode !== external_wp_keycodes_["BACKSPACE"] && keyCode !== external_wp_keycodes_["DELETE"]) {
  17510. return;
  17511. }
  17512. if (target !== node || Object(external_wp_dom_["isTextField"])(target)) {
  17513. return;
  17514. }
  17515. event.preventDefault();
  17516. if (keyCode === external_wp_keycodes_["ENTER"]) {
  17517. insertDefaultBlock({}, getBlockRootClientId(clientId), getBlockIndex(clientId) + 1);
  17518. } else {
  17519. removeBlock(clientId);
  17520. }
  17521. }
  17522. /**
  17523. * Prevents default dragging behavior within a block. To do: we must
  17524. * handle this in the future and clean up the drag target.
  17525. *
  17526. * @param {DragEvent} event Drag event.
  17527. */
  17528. function onDragStart(event) {
  17529. event.preventDefault();
  17530. }
  17531. node.addEventListener('keydown', onKeyDown);
  17532. node.addEventListener('dragstart', onDragStart);
  17533. return () => {
  17534. node.removeEventListener('keydown', onKeyDown);
  17535. node.removeEventListener('dragstart', onDragStart);
  17536. };
  17537. }, [clientId, isSelected, getBlockRootClientId, getBlockIndex, insertDefaultBlock, removeBlock]);
  17538. }
  17539. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-nav-mode-exit.js
  17540. /**
  17541. * WordPress dependencies
  17542. */
  17543. /**
  17544. * Internal dependencies
  17545. */
  17546. /**
  17547. * Allows navigation mode to be exited by clicking in the selected block.
  17548. *
  17549. * @param {string} clientId Block client ID.
  17550. */
  17551. function useNavModeExit(clientId) {
  17552. const {
  17553. isNavigationMode,
  17554. isBlockSelected
  17555. } = Object(external_wp_data_["useSelect"])(store);
  17556. const {
  17557. setNavigationMode,
  17558. selectBlock
  17559. } = Object(external_wp_data_["useDispatch"])(store);
  17560. return Object(external_wp_compose_["useRefEffect"])(node => {
  17561. function onMouseDown(event) {
  17562. // Don't select a block if it's already handled by a child
  17563. // block.
  17564. if (isNavigationMode() && !event.defaultPrevented) {
  17565. // Prevent focus from moving to the block.
  17566. event.preventDefault(); // When clicking on a selected block, exit navigation mode.
  17567. if (isBlockSelected(clientId)) {
  17568. setNavigationMode(false);
  17569. } else {
  17570. selectBlock(clientId);
  17571. }
  17572. }
  17573. }
  17574. node.addEventListener('mousedown', onMouseDown);
  17575. return () => {
  17576. node.addEventListener('mousedown', onMouseDown);
  17577. };
  17578. }, [clientId, isNavigationMode, isBlockSelected, setNavigationMode]);
  17579. }
  17580. // EXTERNAL MODULE: ./node_modules/dom-scroll-into-view/lib/index.js
  17581. var dom_scroll_into_view_lib = __webpack_require__("9Do8");
  17582. var dom_scroll_into_view_lib_default = /*#__PURE__*/__webpack_require__.n(dom_scroll_into_view_lib);
  17583. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-scroll-into-view.js
  17584. /**
  17585. * External dependencies
  17586. */
  17587. /**
  17588. * WordPress dependencies
  17589. */
  17590. /**
  17591. * WordPress dependencies
  17592. */
  17593. /**
  17594. * Internal dependencies
  17595. */
  17596. function useScrollIntoView(clientId) {
  17597. const ref = Object(external_wp_element_["useRef"])();
  17598. const isSelectionEnd = Object(external_wp_data_["useSelect"])(select => {
  17599. const {
  17600. isBlockSelected,
  17601. getBlockSelectionEnd
  17602. } = select(store);
  17603. return isBlockSelected(clientId) || getBlockSelectionEnd() === clientId;
  17604. }, [clientId]); // Note that we can't use `useRefEffect` here, since an element change does
  17605. // not mean we can scroll. `isSelectionEnd` should be the sole dependency,
  17606. // while with `useRefEffect`, the element is a dependency as well.
  17607. Object(external_wp_element_["useEffect"])(() => {
  17608. if (!isSelectionEnd) {
  17609. return;
  17610. }
  17611. const extentNode = ref.current;
  17612. if (!extentNode) {
  17613. return;
  17614. } // If the block is focused, the browser will already have scrolled into
  17615. // view if necessary.
  17616. if (extentNode.contains(extentNode.ownerDocument.activeElement)) {
  17617. return;
  17618. }
  17619. const scrollContainer = Object(external_wp_dom_["getScrollContainer"])(extentNode) || extentNode.ownerDocument.defaultView; // If there's no scroll container, it follows that there's no scrollbar
  17620. // and thus there's no need to try to scroll into view.
  17621. if (!scrollContainer) {
  17622. return;
  17623. }
  17624. dom_scroll_into_view_lib_default()(extentNode, scrollContainer, {
  17625. onlyScrollIfNeeded: true
  17626. });
  17627. }, [isSelectionEnd]);
  17628. return ref;
  17629. }
  17630. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-multi-selection.js
  17631. /**
  17632. * WordPress dependencies
  17633. */
  17634. /**
  17635. * Internal dependencies
  17636. */
  17637. function toggleRichText(container, toggle) {
  17638. Array.from(container.closest('.is-root-container').querySelectorAll('.rich-text')).forEach(node => {
  17639. if (toggle) {
  17640. node.setAttribute('contenteditable', true);
  17641. } else {
  17642. node.removeAttribute('contenteditable');
  17643. }
  17644. });
  17645. }
  17646. /**
  17647. * Sets a multi-selection based on the native selection across blocks.
  17648. *
  17649. * @param {string} clientId Block client ID.
  17650. */
  17651. function useMultiSelection(clientId) {
  17652. const {
  17653. startMultiSelect,
  17654. stopMultiSelect,
  17655. multiSelect,
  17656. selectBlock
  17657. } = Object(external_wp_data_["useDispatch"])(store);
  17658. const {
  17659. isSelectionEnabled,
  17660. isBlockSelected,
  17661. getBlockParents,
  17662. getBlockSelectionStart,
  17663. hasMultiSelection
  17664. } = Object(external_wp_data_["useSelect"])(store);
  17665. return Object(external_wp_compose_["useRefEffect"])(node => {
  17666. const {
  17667. ownerDocument
  17668. } = node;
  17669. const {
  17670. defaultView
  17671. } = ownerDocument;
  17672. let anchorElement;
  17673. let rafId;
  17674. function onSelectionChange({
  17675. isSelectionEnd
  17676. }) {
  17677. const selection = defaultView.getSelection(); // If no selection is found, end multi selection and enable all rich
  17678. // text areas.
  17679. if (!selection.rangeCount || selection.isCollapsed) {
  17680. toggleRichText(node, true);
  17681. return;
  17682. }
  17683. const endClientId = getBlockClientId(selection.focusNode);
  17684. const isSingularSelection = clientId === endClientId;
  17685. if (isSingularSelection) {
  17686. selectBlock(clientId); // If the selection is complete (on mouse up), and no
  17687. // multiple blocks have been selected, set focus back to the
  17688. // anchor element. if the anchor element contains the
  17689. // selection. Additionally, rich text elements that were
  17690. // previously disabled can now be enabled again.
  17691. if (isSelectionEnd) {
  17692. toggleRichText(node, true);
  17693. if (selection.rangeCount) {
  17694. const {
  17695. commonAncestorContainer
  17696. } = selection.getRangeAt(0);
  17697. if (anchorElement.contains(commonAncestorContainer)) {
  17698. anchorElement.focus();
  17699. }
  17700. }
  17701. }
  17702. } else {
  17703. const startPath = [...getBlockParents(clientId), clientId];
  17704. const endPath = [...getBlockParents(endClientId), endClientId];
  17705. const depth = Math.min(startPath.length, endPath.length) - 1;
  17706. multiSelect(startPath[depth], endPath[depth]);
  17707. }
  17708. }
  17709. function onSelectionEnd() {
  17710. ownerDocument.removeEventListener('selectionchange', onSelectionChange); // Equivalent to attaching the listener once.
  17711. defaultView.removeEventListener('mouseup', onSelectionEnd); // The browser selection won't have updated yet at this point,
  17712. // so wait until the next animation frame to get the browser
  17713. // selection.
  17714. rafId = defaultView.requestAnimationFrame(() => {
  17715. onSelectionChange({
  17716. isSelectionEnd: true
  17717. });
  17718. stopMultiSelect();
  17719. });
  17720. }
  17721. function onMouseLeave({
  17722. buttons
  17723. }) {
  17724. // The primary button must be pressed to initiate selection.
  17725. // See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  17726. if (buttons !== 1) {
  17727. return;
  17728. }
  17729. if (!isSelectionEnabled() || !isBlockSelected(clientId)) {
  17730. return;
  17731. }
  17732. anchorElement = ownerDocument.activeElement;
  17733. startMultiSelect(); // `onSelectionStart` is called after `mousedown` and
  17734. // `mouseleave` (from a block). The selection ends when
  17735. // `mouseup` happens anywhere in the window.
  17736. ownerDocument.addEventListener('selectionchange', onSelectionChange);
  17737. defaultView.addEventListener('mouseup', onSelectionEnd); // Removing the contenteditable attributes within the block
  17738. // editor is essential for selection to work across editable
  17739. // areas. The edible hosts are removed, allowing selection to be
  17740. // extended outside the DOM element. `startMultiSelect` sets a
  17741. // flag in the store so the rich text components are updated,
  17742. // but the rerender may happen very slowly, especially in Safari
  17743. // for the blocks that are asynchonously rendered. To ensure the
  17744. // browser instantly removes the selection boundaries, we remove
  17745. // the contenteditable attributes manually.
  17746. toggleRichText(node, false);
  17747. }
  17748. function onMouseDown(event) {
  17749. // The main button.
  17750. // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
  17751. if (!isSelectionEnabled() || event.button !== 0) {
  17752. return;
  17753. }
  17754. if (event.shiftKey) {
  17755. const blockSelectionStart = getBlockSelectionStart();
  17756. if (blockSelectionStart !== clientId) {
  17757. toggleRichText(node, false);
  17758. multiSelect(blockSelectionStart, clientId);
  17759. event.preventDefault();
  17760. }
  17761. } else if (hasMultiSelection()) {
  17762. // Allow user to escape out of a multi-selection to a
  17763. // singular selection of a block via click. This is handled
  17764. // here since focus handling excludes blocks when there is
  17765. // multiselection, as focus can be incurred by starting a
  17766. // multiselection (focus moved to first block's multi-
  17767. // controls).
  17768. selectBlock(clientId);
  17769. }
  17770. }
  17771. node.addEventListener('mousedown', onMouseDown);
  17772. node.addEventListener('mouseleave', onMouseLeave);
  17773. return () => {
  17774. node.removeEventListener('mousedown', onMouseDown);
  17775. node.removeEventListener('mouseleave', onMouseLeave);
  17776. ownerDocument.removeEventListener('selectionchange', onSelectionChange);
  17777. defaultView.removeEventListener('mouseup', onSelectionEnd);
  17778. defaultView.cancelAnimationFrame(rafId);
  17779. };
  17780. }, [clientId, startMultiSelect, stopMultiSelect, multiSelect, selectBlock, isSelectionEnabled, isBlockSelected, getBlockParents]);
  17781. }
  17782. // EXTERNAL MODULE: external ["wp","htmlEntities"]
  17783. var external_wp_htmlEntities_ = __webpack_require__("rmEH");
  17784. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/plus.js
  17785. var plus = __webpack_require__("Q4Sy");
  17786. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/tips.js
  17787. /**
  17788. * WordPress dependencies
  17789. */
  17790. const globalTips = [Object(external_wp_element_["createInterpolateElement"])(Object(external_wp_i18n_["__"])('While writing, you can press <kbd>/</kbd> to quickly insert new blocks.'), {
  17791. kbd: Object(external_wp_element_["createElement"])("kbd", null)
  17792. }), Object(external_wp_element_["createInterpolateElement"])(Object(external_wp_i18n_["__"])('Indent a list by pressing <kbd>space</kbd> at the beginning of a line.'), {
  17793. kbd: Object(external_wp_element_["createElement"])("kbd", null)
  17794. }), Object(external_wp_element_["createInterpolateElement"])(Object(external_wp_i18n_["__"])('Outdent a list by pressing <kbd>backspace</kbd> at the beginning of a line.'), {
  17795. kbd: Object(external_wp_element_["createElement"])("kbd", null)
  17796. }), Object(external_wp_i18n_["__"])('Drag files into the editor to automatically insert media blocks.'), Object(external_wp_i18n_["__"])("Change a block's type by pressing the block icon on the toolbar.")];
  17797. function Tips() {
  17798. const [randomIndex] = Object(external_wp_element_["useState"])( // Disable Reason: I'm not generating an HTML id.
  17799. // eslint-disable-next-line no-restricted-syntax
  17800. Math.floor(Math.random() * globalTips.length));
  17801. return Object(external_wp_element_["createElement"])(external_wp_components_["Tip"], null, globalTips[randomIndex]);
  17802. }
  17803. /* harmony default export */ var tips = (Tips);
  17804. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/close-small.js
  17805. var close_small = __webpack_require__("bWcr");
  17806. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/search.js
  17807. var search = __webpack_require__("cGtP");
  17808. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/search-form.js
  17809. /**
  17810. * External dependencies
  17811. */
  17812. /**
  17813. * WordPress dependencies
  17814. */
  17815. function InserterSearchForm({
  17816. className,
  17817. onChange,
  17818. value,
  17819. label,
  17820. placeholder
  17821. }) {
  17822. const instanceId = Object(external_wp_compose_["useInstanceId"])(InserterSearchForm);
  17823. const searchInput = Object(external_wp_element_["useRef"])();
  17824. return Object(external_wp_element_["createElement"])("div", {
  17825. className: classnames_default()('block-editor-inserter__search', className)
  17826. }, Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], {
  17827. as: "label",
  17828. htmlFor: `block-editor-inserter__search-${instanceId}`
  17829. }, label || placeholder), Object(external_wp_element_["createElement"])("input", {
  17830. ref: searchInput,
  17831. className: "block-editor-inserter__search-input",
  17832. id: `block-editor-inserter__search-${instanceId}`,
  17833. type: "search",
  17834. placeholder: placeholder,
  17835. onChange: event => onChange(event.target.value),
  17836. autoComplete: "off",
  17837. value: value || ''
  17838. }), Object(external_wp_element_["createElement"])("div", {
  17839. className: "block-editor-inserter__search-icon"
  17840. }, !!value && Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  17841. icon: close_small["a" /* default */],
  17842. label: Object(external_wp_i18n_["__"])('Reset search'),
  17843. onClick: () => {
  17844. onChange('');
  17845. searchInput.current.focus();
  17846. }
  17847. }), !value && Object(external_wp_element_["createElement"])(build_module_icon["a" /* default */], {
  17848. icon: search["a" /* default */]
  17849. })));
  17850. }
  17851. /* harmony default export */ var search_form = (InserterSearchForm);
  17852. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-card/index.js
  17853. /**
  17854. * WordPress dependencies
  17855. */
  17856. /**
  17857. * Internal dependencies
  17858. */
  17859. function BlockCard({
  17860. title,
  17861. icon,
  17862. description,
  17863. blockType
  17864. }) {
  17865. if (blockType) {
  17866. external_wp_deprecated_default()('`blockType` property in `BlockCard component`', {
  17867. since: '5.7',
  17868. alternative: '`title, icon and description` properties'
  17869. });
  17870. ({
  17871. title,
  17872. icon,
  17873. description
  17874. } = blockType);
  17875. }
  17876. return Object(external_wp_element_["createElement"])("div", {
  17877. className: "block-editor-block-card"
  17878. }, Object(external_wp_element_["createElement"])(BlockIcon, {
  17879. icon: icon,
  17880. showColors: true
  17881. }), Object(external_wp_element_["createElement"])("div", {
  17882. className: "block-editor-block-card__content"
  17883. }, Object(external_wp_element_["createElement"])("h2", {
  17884. className: "block-editor-block-card__title"
  17885. }, title), Object(external_wp_element_["createElement"])("span", {
  17886. className: "block-editor-block-card__description"
  17887. }, description)));
  17888. }
  17889. /* harmony default export */ var block_card = (BlockCard);
  17890. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/provider/with-registry-provider.js
  17891. /**
  17892. * WordPress dependencies
  17893. */
  17894. /**
  17895. * Internal dependencies
  17896. */
  17897. const withRegistryProvider = Object(external_wp_compose_["createHigherOrderComponent"])(WrappedComponent => {
  17898. return Object(external_wp_data_["withRegistry"])(({
  17899. useSubRegistry = true,
  17900. registry,
  17901. ...props
  17902. }) => {
  17903. if (!useSubRegistry) {
  17904. return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({
  17905. registry: registry
  17906. }, props));
  17907. }
  17908. const [subRegistry, setSubRegistry] = Object(external_wp_element_["useState"])(null);
  17909. Object(external_wp_element_["useEffect"])(() => {
  17910. const newRegistry = Object(external_wp_data_["createRegistry"])({}, registry);
  17911. newRegistry.registerStore(STORE_NAME, storeConfig);
  17912. setSubRegistry(newRegistry);
  17913. }, [registry]);
  17914. if (!subRegistry) {
  17915. return null;
  17916. }
  17917. return Object(external_wp_element_["createElement"])(external_wp_data_["RegistryProvider"], {
  17918. value: subRegistry
  17919. }, Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({
  17920. registry: subRegistry
  17921. }, props)));
  17922. });
  17923. }, 'withRegistryProvider');
  17924. /* harmony default export */ var with_registry_provider = (withRegistryProvider);
  17925. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/provider/use-block-sync.js
  17926. /**
  17927. * External dependencies
  17928. */
  17929. /**
  17930. * WordPress dependencies
  17931. */
  17932. /**
  17933. * Internal dependencies
  17934. */
  17935. /**
  17936. * A function to call when the block value has been updated in the block-editor
  17937. * store.
  17938. *
  17939. * @callback onBlockUpdate
  17940. * @param {Object[]} blocks The updated blocks.
  17941. * @param {Object} options The updated block options, such as selectionStart
  17942. * and selectionEnd.
  17943. */
  17944. /**
  17945. * useBlockSync is a side effect which handles bidirectional sync between the
  17946. * block-editor store and a controlling data source which provides blocks. This
  17947. * is most commonly used by the BlockEditorProvider to synchronize the contents
  17948. * of the block-editor store with the root entity, like a post.
  17949. *
  17950. * Another example would be the template part block, which provides blocks from
  17951. * a separate entity data source than a root entity. This hook syncs edits to
  17952. * the template part in the block editor back to the entity and vice-versa.
  17953. *
  17954. * Here are some of its basic functions:
  17955. * - Initalizes the block-editor store for the given clientID to the blocks
  17956. * given via props.
  17957. * - Adds incoming changes (like undo) to the block-editor store.
  17958. * - Adds outgoing changes (like editing content) to the controlling entity,
  17959. * determining if a change should be considered persistent or not.
  17960. * - Handles edge cases and race conditions which occur in those operations.
  17961. * - Ignores changes which happen to other entities (like nested inner block
  17962. * controllers.
  17963. * - Passes selection state from the block-editor store to the controlling entity.
  17964. *
  17965. * @param {Object} props Props for the block sync hook
  17966. * @param {string} props.clientId The client ID of the inner block controller.
  17967. * If none is passed, then it is assumed to be a
  17968. * root controller rather than an inner block
  17969. * controller.
  17970. * @param {Object[]} props.value The control value for the blocks. This value
  17971. * is used to initalize the block-editor store
  17972. * and for resetting the blocks to incoming
  17973. * changes like undo.
  17974. * @param {Object} props.selection The selection state responsible to restore the selection on undo/redo.
  17975. * @param {onBlockUpdate} props.onChange Function to call when a persistent
  17976. * change has been made in the block-editor blocks
  17977. * for the given clientId. For example, after
  17978. * this function is called, an entity is marked
  17979. * dirty because it has changes to save.
  17980. * @param {onBlockUpdate} props.onInput Function to call when a non-persistent
  17981. * change has been made in the block-editor blocks
  17982. * for the given clientId. When this is called,
  17983. * controlling sources do not become dirty.
  17984. */
  17985. function useBlockSync({
  17986. clientId = null,
  17987. value: controlledBlocks,
  17988. selection: controlledSelection,
  17989. onChange = external_lodash_["noop"],
  17990. onInput = external_lodash_["noop"]
  17991. }) {
  17992. const registry = Object(external_wp_data_["useRegistry"])();
  17993. const {
  17994. resetBlocks,
  17995. resetSelection,
  17996. replaceInnerBlocks,
  17997. setHasControlledInnerBlocks,
  17998. __unstableMarkNextChangeAsNotPersistent
  17999. } = registry.dispatch(store);
  18000. const {
  18001. getBlockName,
  18002. getBlocks
  18003. } = registry.select(store);
  18004. const pendingChanges = Object(external_wp_element_["useRef"])({
  18005. incoming: null,
  18006. outgoing: []
  18007. });
  18008. const subscribed = Object(external_wp_element_["useRef"])(false);
  18009. const setControlledBlocks = () => {
  18010. if (!controlledBlocks) {
  18011. return;
  18012. } // We don't need to persist this change because we only replace
  18013. // controlled inner blocks when the change was caused by an entity,
  18014. // and so it would already be persisted.
  18015. __unstableMarkNextChangeAsNotPersistent();
  18016. if (clientId) {
  18017. setHasControlledInnerBlocks(clientId, true);
  18018. __unstableMarkNextChangeAsNotPersistent();
  18019. const storeBlocks = controlledBlocks.map(block => Object(external_wp_blocks_["cloneBlock"])(block));
  18020. if (subscribed.current) {
  18021. pendingChanges.current.incoming = storeBlocks;
  18022. }
  18023. replaceInnerBlocks(clientId, storeBlocks);
  18024. } else {
  18025. if (subscribed.current) {
  18026. pendingChanges.current.incoming = controlledBlocks;
  18027. }
  18028. resetBlocks(controlledBlocks);
  18029. }
  18030. }; // Add a subscription to the block-editor registry to detect when changes
  18031. // have been made. This lets us inform the data source of changes. This
  18032. // is an effect so that the subscriber can run synchronously without
  18033. // waiting for React renders for changes.
  18034. const onInputRef = Object(external_wp_element_["useRef"])(onInput);
  18035. const onChangeRef = Object(external_wp_element_["useRef"])(onChange);
  18036. Object(external_wp_element_["useEffect"])(() => {
  18037. onInputRef.current = onInput;
  18038. onChangeRef.current = onChange;
  18039. }, [onInput, onChange]); // Determine if blocks need to be reset when they change.
  18040. Object(external_wp_element_["useEffect"])(() => {
  18041. if (pendingChanges.current.outgoing.includes(controlledBlocks)) {
  18042. // Skip block reset if the value matches expected outbound sync
  18043. // triggered by this component by a preceding change detection.
  18044. // Only skip if the value matches expectation, since a reset should
  18045. // still occur if the value is modified (not equal by reference),
  18046. // to allow that the consumer may apply modifications to reflect
  18047. // back on the editor.
  18048. if (Object(external_lodash_["last"])(pendingChanges.current.outgoing) === controlledBlocks) {
  18049. pendingChanges.current.outgoing = [];
  18050. }
  18051. } else if (getBlocks(clientId) !== controlledBlocks) {
  18052. // Reset changing value in all other cases than the sync described
  18053. // above. Since this can be reached in an update following an out-
  18054. // bound sync, unset the outbound value to avoid considering it in
  18055. // subsequent renders.
  18056. pendingChanges.current.outgoing = [];
  18057. setControlledBlocks();
  18058. if (controlledSelection) {
  18059. resetSelection(controlledSelection.selectionStart, controlledSelection.selectionEnd, controlledSelection.initialPosition);
  18060. }
  18061. }
  18062. }, [controlledBlocks, clientId]);
  18063. Object(external_wp_element_["useEffect"])(() => {
  18064. const {
  18065. getSelectionStart,
  18066. getSelectionEnd,
  18067. getSelectedBlocksInitialCaretPosition,
  18068. isLastBlockChangePersistent,
  18069. __unstableIsLastBlockChangeIgnored
  18070. } = registry.select(store);
  18071. let blocks = getBlocks(clientId);
  18072. let isPersistent = isLastBlockChangePersistent();
  18073. let previousAreBlocksDifferent = false;
  18074. subscribed.current = true;
  18075. const unsubscribe = registry.subscribe(() => {
  18076. // Sometimes, when changing block lists, lingering subscriptions
  18077. // might trigger before they are cleaned up. If the block for which
  18078. // the subscription runs is no longer in the store, this would clear
  18079. // its parent entity's block list. To avoid this, we bail out if
  18080. // the subscription is triggering for a block (`clientId !== null`)
  18081. // and its block name can't be found because it's not on the list.
  18082. // (`getBlockName( clientId ) === null`).
  18083. if (clientId !== null && getBlockName(clientId) === null) return;
  18084. const newIsPersistent = isLastBlockChangePersistent();
  18085. const newBlocks = getBlocks(clientId);
  18086. const areBlocksDifferent = newBlocks !== blocks;
  18087. blocks = newBlocks;
  18088. if (areBlocksDifferent && (pendingChanges.current.incoming || __unstableIsLastBlockChangeIgnored())) {
  18089. pendingChanges.current.incoming = null;
  18090. isPersistent = newIsPersistent;
  18091. return;
  18092. } // Since we often dispatch an action to mark the previous action as
  18093. // persistent, we need to make sure that the blocks changed on the
  18094. // previous action before committing the change.
  18095. const didPersistenceChange = previousAreBlocksDifferent && !areBlocksDifferent && newIsPersistent && !isPersistent;
  18096. if (areBlocksDifferent || didPersistenceChange) {
  18097. isPersistent = newIsPersistent; // We know that onChange/onInput will update controlledBlocks.
  18098. // We need to be aware that it was caused by an outgoing change
  18099. // so that we do not treat it as an incoming change later on,
  18100. // which would cause a block reset.
  18101. pendingChanges.current.outgoing.push(blocks); // Inform the controlling entity that changes have been made to
  18102. // the block-editor store they should be aware about.
  18103. const updateParent = isPersistent ? onChangeRef.current : onInputRef.current;
  18104. updateParent(blocks, {
  18105. selection: {
  18106. selectionStart: getSelectionStart(),
  18107. selectionEnd: getSelectionEnd(),
  18108. initialPosition: getSelectedBlocksInitialCaretPosition()
  18109. }
  18110. });
  18111. }
  18112. previousAreBlocksDifferent = areBlocksDifferent;
  18113. });
  18114. return () => unsubscribe();
  18115. }, [registry, clientId]);
  18116. }
  18117. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/provider/index.js
  18118. /**
  18119. * WordPress dependencies
  18120. */
  18121. /**
  18122. * Internal dependencies
  18123. */
  18124. /** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */
  18125. function BlockEditorProvider(props) {
  18126. const {
  18127. children,
  18128. settings
  18129. } = props;
  18130. const {
  18131. updateSettings
  18132. } = Object(external_wp_data_["useDispatch"])(store);
  18133. Object(external_wp_element_["useEffect"])(() => {
  18134. updateSettings(settings);
  18135. }, [settings]); // Syncs the entity provider with changes in the block-editor store.
  18136. useBlockSync(props);
  18137. return Object(external_wp_element_["createElement"])(BlockRefsProvider, null, children);
  18138. }
  18139. /* harmony default export */ var provider = (with_registry_provider(BlockEditorProvider));
  18140. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-preview/live.js
  18141. /**
  18142. * WordPress dependencies
  18143. */
  18144. /**
  18145. * Internal dependencies
  18146. */
  18147. function LiveBlockPreview({
  18148. onClick
  18149. }) {
  18150. return Object(external_wp_element_["createElement"])("div", {
  18151. tabIndex: 0,
  18152. role: "button",
  18153. onClick: onClick,
  18154. onKeyPress: onClick
  18155. }, Object(external_wp_element_["createElement"])(external_wp_components_["Disabled"], null, Object(external_wp_element_["createElement"])(BlockList, null)));
  18156. }
  18157. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-preview/auto.js
  18158. /**
  18159. * WordPress dependencies
  18160. */
  18161. /**
  18162. * Internal dependencies
  18163. */
  18164. // This is used to avoid rendering the block list if the sizes change.
  18165. let MemoizedBlockList;
  18166. function AutoBlockPreview({
  18167. viewportWidth,
  18168. __experimentalPadding
  18169. }) {
  18170. const [containerResizeListener, {
  18171. width: containerWidth
  18172. }] = Object(external_wp_compose_["useResizeObserver"])();
  18173. const [containtResizeListener, {
  18174. height: contentHeight
  18175. }] = Object(external_wp_compose_["useResizeObserver"])(); // Initialize on render instead of module top level, to avoid circular dependency issues.
  18176. MemoizedBlockList = MemoizedBlockList || Object(external_wp_compose_["pure"])(BlockList);
  18177. const scale = (containerWidth - 2 * __experimentalPadding) / viewportWidth;
  18178. return Object(external_wp_element_["createElement"])("div", {
  18179. className: "block-editor-block-preview__container editor-styles-wrapper",
  18180. "aria-hidden": true,
  18181. style: {
  18182. height: contentHeight * scale + 2 * __experimentalPadding
  18183. }
  18184. }, containerResizeListener, Object(external_wp_element_["createElement"])(external_wp_components_["Disabled"], {
  18185. style: {
  18186. transform: `scale(${scale})`,
  18187. width: viewportWidth,
  18188. left: __experimentalPadding,
  18189. right: __experimentalPadding,
  18190. top: __experimentalPadding
  18191. },
  18192. className: "block-editor-block-preview__content"
  18193. }, containtResizeListener, Object(external_wp_element_["createElement"])(MemoizedBlockList, null)));
  18194. }
  18195. /* harmony default export */ var auto = (AutoBlockPreview);
  18196. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-preview/index.js
  18197. /**
  18198. * External dependencies
  18199. */
  18200. /**
  18201. * WordPress dependencies
  18202. */
  18203. /**
  18204. * Internal dependencies
  18205. */
  18206. function BlockPreview({
  18207. blocks,
  18208. __experimentalPadding = 0,
  18209. viewportWidth = 1200,
  18210. __experimentalLive = false,
  18211. __experimentalOnClick
  18212. }) {
  18213. const originalSettings = Object(external_wp_data_["useSelect"])(select => select(store).getSettings(), []);
  18214. const settings = Object(external_wp_element_["useMemo"])(() => {
  18215. const _settings = { ...originalSettings
  18216. };
  18217. _settings.__experimentalBlockPatterns = [];
  18218. return _settings;
  18219. }, [originalSettings]);
  18220. const renderedBlocks = Object(external_wp_element_["useMemo"])(() => Object(external_lodash_["castArray"])(blocks), [blocks]);
  18221. if (!blocks || blocks.length === 0) {
  18222. return null;
  18223. }
  18224. return Object(external_wp_element_["createElement"])(provider, {
  18225. value: renderedBlocks,
  18226. settings: settings
  18227. }, __experimentalLive ? Object(external_wp_element_["createElement"])(LiveBlockPreview, {
  18228. onClick: __experimentalOnClick
  18229. }) : Object(external_wp_element_["createElement"])(auto, {
  18230. viewportWidth: viewportWidth,
  18231. __experimentalPadding: __experimentalPadding
  18232. }));
  18233. }
  18234. /**
  18235. * BlockPreview renders a preview of a block or array of blocks.
  18236. *
  18237. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-preview/README.md
  18238. *
  18239. * @param {Object} preview options for how the preview should be shown
  18240. * @param {Array|Object} preview.blocks A block instance (object) or an array of blocks to be previewed.
  18241. * @param {number} preview.viewportWidth Width of the preview container in pixels. Controls at what size the blocks will be rendered inside the preview. Default: 700.
  18242. *
  18243. * @return {WPComponent} The component to be rendered.
  18244. */
  18245. /* harmony default export */ var block_preview = (Object(external_wp_element_["memo"])(BlockPreview));
  18246. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/preview-panel.js
  18247. /**
  18248. * WordPress dependencies
  18249. */
  18250. /**
  18251. * Internal dependencies
  18252. */
  18253. function InserterPreviewPanel({
  18254. item
  18255. }) {
  18256. var _hoveredItemBlockType, _hoveredItemBlockType2;
  18257. const {
  18258. name,
  18259. title,
  18260. icon,
  18261. description,
  18262. initialAttributes
  18263. } = item;
  18264. const hoveredItemBlockType = Object(external_wp_blocks_["getBlockType"])(name);
  18265. const isReusable = Object(external_wp_blocks_["isReusableBlock"])(item);
  18266. return Object(external_wp_element_["createElement"])("div", {
  18267. className: "block-editor-inserter__preview-container"
  18268. }, Object(external_wp_element_["createElement"])("div", {
  18269. className: "block-editor-inserter__preview"
  18270. }, isReusable || hoveredItemBlockType.example ? Object(external_wp_element_["createElement"])("div", {
  18271. className: "block-editor-inserter__preview-content"
  18272. }, Object(external_wp_element_["createElement"])(block_preview, {
  18273. __experimentalPadding: 16,
  18274. viewportWidth: (_hoveredItemBlockType = (_hoveredItemBlockType2 = hoveredItemBlockType.example) === null || _hoveredItemBlockType2 === void 0 ? void 0 : _hoveredItemBlockType2.viewportWidth) !== null && _hoveredItemBlockType !== void 0 ? _hoveredItemBlockType : 500,
  18275. blocks: hoveredItemBlockType.example ? Object(external_wp_blocks_["getBlockFromExample"])(item.name, {
  18276. attributes: { ...hoveredItemBlockType.example.attributes,
  18277. ...initialAttributes
  18278. },
  18279. innerBlocks: hoveredItemBlockType.example.innerBlocks
  18280. }) : Object(external_wp_blocks_["createBlock"])(name, initialAttributes)
  18281. })) : Object(external_wp_element_["createElement"])("div", {
  18282. className: "block-editor-inserter__preview-content-missing"
  18283. }, Object(external_wp_i18n_["__"])('No Preview Available.'))), !isReusable && Object(external_wp_element_["createElement"])(block_card, {
  18284. title: title,
  18285. icon: icon,
  18286. description: description
  18287. }));
  18288. }
  18289. /* harmony default export */ var preview_panel = (InserterPreviewPanel);
  18290. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-listbox/context.js
  18291. /**
  18292. * WordPress dependencies
  18293. */
  18294. const InserterListboxContext = Object(external_wp_element_["createContext"])();
  18295. /* harmony default export */ var inserter_listbox_context = (InserterListboxContext);
  18296. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-listbox/item.js
  18297. /**
  18298. * WordPress dependencies
  18299. */
  18300. /**
  18301. * Internal dependencies
  18302. */
  18303. function InserterListboxItem({
  18304. isFirst,
  18305. as: Component,
  18306. children,
  18307. ...props
  18308. }, ref) {
  18309. const state = Object(external_wp_element_["useContext"])(inserter_listbox_context);
  18310. return Object(external_wp_element_["createElement"])(external_wp_components_["__unstableCompositeItem"], Object(esm_extends["a" /* default */])({
  18311. ref: ref,
  18312. state: state,
  18313. role: "option" // Use the CompositeItem `focusable` prop over Button's
  18314. // isFocusable. The latter was shown to cause an issue
  18315. // with tab order in the inserter list.
  18316. ,
  18317. focusable: true
  18318. }, props), htmlProps => {
  18319. const propsWithTabIndex = { ...htmlProps,
  18320. tabIndex: isFirst ? 0 : htmlProps.tabIndex
  18321. };
  18322. if (Component) {
  18323. return Object(external_wp_element_["createElement"])(Component, propsWithTabIndex, children);
  18324. }
  18325. if (typeof children === 'function') {
  18326. return children(propsWithTabIndex);
  18327. }
  18328. return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], propsWithTabIndex, children);
  18329. });
  18330. }
  18331. /* harmony default export */ var inserter_listbox_item = (Object(external_wp_element_["forwardRef"])(InserterListboxItem));
  18332. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/drag-handle.js
  18333. /**
  18334. * WordPress dependencies
  18335. */
  18336. const dragHandle = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
  18337. width: "18",
  18338. height: "18",
  18339. xmlns: "http://www.w3.org/2000/svg",
  18340. viewBox: "0 0 18 18"
  18341. }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
  18342. d: "M5 4h2V2H5v2zm6-2v2h2V2h-2zm-6 8h2V8H5v2zm6 0h2V8h-2v2zm-6 6h2v-2H5v2zm6 0h2v-2h-2v2z"
  18343. }));
  18344. /* harmony default export */ var drag_handle = (dragHandle);
  18345. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-draggable/draggable-chip.js
  18346. /**
  18347. * WordPress dependencies
  18348. */
  18349. /**
  18350. * Internal dependencies
  18351. */
  18352. function BlockDraggableChip({
  18353. count,
  18354. icon
  18355. }) {
  18356. return Object(external_wp_element_["createElement"])("div", {
  18357. className: "block-editor-block-draggable-chip-wrapper"
  18358. }, Object(external_wp_element_["createElement"])("div", {
  18359. className: "block-editor-block-draggable-chip"
  18360. }, Object(external_wp_element_["createElement"])(external_wp_components_["Flex"], {
  18361. justify: "center",
  18362. className: "block-editor-block-draggable-chip__content"
  18363. }, Object(external_wp_element_["createElement"])(external_wp_components_["FlexItem"], null, icon ? Object(external_wp_element_["createElement"])(BlockIcon, {
  18364. icon: icon
  18365. }) : Object(external_wp_i18n_["sprintf"])(
  18366. /* translators: %d: Number of blocks. */
  18367. Object(external_wp_i18n_["_n"])('%d block', '%d blocks', count), count)), Object(external_wp_element_["createElement"])(external_wp_components_["FlexItem"], null, Object(external_wp_element_["createElement"])(BlockIcon, {
  18368. icon: drag_handle
  18369. })))));
  18370. }
  18371. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-draggable-blocks/index.js
  18372. /**
  18373. * WordPress dependencies
  18374. */
  18375. /**
  18376. * Internal dependencies
  18377. */
  18378. const InserterDraggableBlocks = ({
  18379. isEnabled,
  18380. blocks,
  18381. icon,
  18382. children
  18383. }) => {
  18384. const transferData = {
  18385. type: 'inserter',
  18386. blocks
  18387. };
  18388. return Object(external_wp_element_["createElement"])(external_wp_components_["Draggable"], {
  18389. __experimentalTransferDataType: "wp-blocks",
  18390. transferData: transferData,
  18391. __experimentalDragComponent: Object(external_wp_element_["createElement"])(BlockDraggableChip, {
  18392. count: blocks.length,
  18393. icon: icon
  18394. })
  18395. }, ({
  18396. onDraggableStart,
  18397. onDraggableEnd
  18398. }) => {
  18399. return children({
  18400. draggable: isEnabled,
  18401. onDragStart: isEnabled ? onDraggableStart : undefined,
  18402. onDragEnd: isEnabled ? onDraggableEnd : undefined
  18403. });
  18404. });
  18405. };
  18406. /* harmony default export */ var inserter_draggable_blocks = (InserterDraggableBlocks);
  18407. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-list-item/index.js
  18408. /**
  18409. * External dependencies
  18410. */
  18411. /**
  18412. * WordPress dependencies
  18413. */
  18414. /**
  18415. * Internal dependencies
  18416. */
  18417. /**
  18418. * Return true if platform is MacOS.
  18419. *
  18420. * @param {Object} _window window object by default; used for DI testing.
  18421. *
  18422. * @return {boolean} True if MacOS; false otherwise.
  18423. */
  18424. function isAppleOS(_window = window) {
  18425. const {
  18426. platform
  18427. } = _window.navigator;
  18428. return platform.indexOf('Mac') !== -1 || ['iPad', 'iPhone'].includes(platform);
  18429. }
  18430. function InserterListItem({
  18431. className,
  18432. isFirst,
  18433. item,
  18434. onSelect,
  18435. onHover,
  18436. isDraggable,
  18437. ...props
  18438. }) {
  18439. const isDragging = Object(external_wp_element_["useRef"])(false);
  18440. const itemIconStyle = item.icon ? {
  18441. backgroundColor: item.icon.background,
  18442. color: item.icon.foreground
  18443. } : {};
  18444. const blocks = Object(external_wp_element_["useMemo"])(() => {
  18445. return [Object(external_wp_blocks_["createBlock"])(item.name, item.initialAttributes, Object(external_wp_blocks_["createBlocksFromInnerBlocksTemplate"])(item.innerBlocks))];
  18446. }, [item.name, item.initialAttributes, item.initialAttributes]);
  18447. return Object(external_wp_element_["createElement"])(inserter_draggable_blocks, {
  18448. isEnabled: isDraggable && !item.disabled,
  18449. blocks: blocks,
  18450. icon: item.icon
  18451. }, ({
  18452. draggable,
  18453. onDragStart,
  18454. onDragEnd
  18455. }) => Object(external_wp_element_["createElement"])("div", {
  18456. className: "block-editor-block-types-list__list-item",
  18457. draggable: draggable,
  18458. onDragStart: event => {
  18459. isDragging.current = true;
  18460. if (onDragStart) {
  18461. onHover(null);
  18462. onDragStart(event);
  18463. }
  18464. },
  18465. onDragEnd: event => {
  18466. isDragging.current = false;
  18467. if (onDragEnd) {
  18468. onDragEnd(event);
  18469. }
  18470. }
  18471. }, Object(external_wp_element_["createElement"])(inserter_listbox_item, Object(esm_extends["a" /* default */])({
  18472. isFirst: isFirst,
  18473. className: classnames_default()('block-editor-block-types-list__item', className),
  18474. disabled: item.isDisabled,
  18475. onClick: event => {
  18476. event.preventDefault();
  18477. onSelect(item, isAppleOS() ? event.metaKey : event.ctrlKey);
  18478. onHover(null);
  18479. },
  18480. onKeyDown: event => {
  18481. const {
  18482. keyCode
  18483. } = event;
  18484. if (keyCode === external_wp_keycodes_["ENTER"]) {
  18485. event.preventDefault();
  18486. onSelect(item, isAppleOS() ? event.metaKey : event.ctrlKey);
  18487. onHover(null);
  18488. }
  18489. },
  18490. onFocus: () => {
  18491. if (isDragging.current) {
  18492. return;
  18493. }
  18494. onHover(item);
  18495. },
  18496. onMouseEnter: () => {
  18497. if (isDragging.current) {
  18498. return;
  18499. }
  18500. onHover(item);
  18501. },
  18502. onMouseLeave: () => onHover(null),
  18503. onBlur: () => onHover(null)
  18504. }, props), Object(external_wp_element_["createElement"])("span", {
  18505. className: "block-editor-block-types-list__item-icon",
  18506. style: itemIconStyle
  18507. }, Object(external_wp_element_["createElement"])(BlockIcon, {
  18508. icon: item.icon,
  18509. showColors: true
  18510. })), Object(external_wp_element_["createElement"])("span", {
  18511. className: "block-editor-block-types-list__item-title"
  18512. }, item.title))));
  18513. }
  18514. /* harmony default export */ var inserter_list_item = (Object(external_wp_element_["memo"])(InserterListItem));
  18515. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-listbox/group.js
  18516. /**
  18517. * WordPress dependencies
  18518. */
  18519. function InserterListboxGroup(props, ref) {
  18520. const [shouldSpeak, setShouldSpeak] = Object(external_wp_element_["useState"])(false);
  18521. Object(external_wp_element_["useEffect"])(() => {
  18522. if (shouldSpeak) {
  18523. Object(external_wp_a11y_["speak"])(Object(external_wp_i18n_["__"])('Use left and right arrow keys to move through blocks'));
  18524. }
  18525. }, [shouldSpeak]);
  18526. return Object(external_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({
  18527. ref: ref,
  18528. role: "listbox",
  18529. "aria-orientation": "horizontal",
  18530. onFocus: () => {
  18531. setShouldSpeak(true);
  18532. },
  18533. onBlur: event => {
  18534. const focusingOutsideGroup = !event.currentTarget.contains(event.relatedTarget);
  18535. if (focusingOutsideGroup) {
  18536. setShouldSpeak(false);
  18537. }
  18538. }
  18539. }, props));
  18540. }
  18541. /* harmony default export */ var inserter_listbox_group = (Object(external_wp_element_["forwardRef"])(InserterListboxGroup));
  18542. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-listbox/row.js
  18543. /**
  18544. * WordPress dependencies
  18545. */
  18546. /**
  18547. * Internal dependencies
  18548. */
  18549. function InserterListboxRow(props, ref) {
  18550. const state = Object(external_wp_element_["useContext"])(inserter_listbox_context);
  18551. return Object(external_wp_element_["createElement"])(external_wp_components_["__unstableCompositeGroup"], Object(esm_extends["a" /* default */])({
  18552. state: state,
  18553. role: "presentation",
  18554. ref: ref
  18555. }, props));
  18556. }
  18557. /* harmony default export */ var inserter_listbox_row = (Object(external_wp_element_["forwardRef"])(InserterListboxRow));
  18558. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-types-list/index.js
  18559. /**
  18560. * WordPress dependencies
  18561. */
  18562. /**
  18563. * Internal dependencies
  18564. */
  18565. function chunk(array, size) {
  18566. const chunks = [];
  18567. for (let i = 0, j = array.length; i < j; i += size) {
  18568. chunks.push(array.slice(i, i + size));
  18569. }
  18570. return chunks;
  18571. }
  18572. function BlockTypesList({
  18573. items = [],
  18574. onSelect,
  18575. onHover = () => {},
  18576. children,
  18577. label,
  18578. isDraggable = true
  18579. }) {
  18580. return Object(external_wp_element_["createElement"])(inserter_listbox_group, {
  18581. className: "block-editor-block-types-list",
  18582. "aria-label": label
  18583. }, chunk(items, 3).map((row, i) => Object(external_wp_element_["createElement"])(inserter_listbox_row, {
  18584. key: i
  18585. }, row.map((item, j) => Object(external_wp_element_["createElement"])(inserter_list_item, {
  18586. key: item.id,
  18587. item: item,
  18588. className: Object(external_wp_blocks_["getBlockMenuDefaultClassName"])(item.id),
  18589. onSelect: onSelect,
  18590. onHover: onHover,
  18591. isDraggable: isDraggable,
  18592. isFirst: i === 0 && j === 0
  18593. })))), children);
  18594. }
  18595. /* harmony default export */ var block_types_list = (BlockTypesList);
  18596. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/panel.js
  18597. /**
  18598. * WordPress dependencies
  18599. */
  18600. function InserterPanel({
  18601. title,
  18602. icon,
  18603. children
  18604. }) {
  18605. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])("div", {
  18606. className: "block-editor-inserter__panel-header"
  18607. }, Object(external_wp_element_["createElement"])("h2", {
  18608. className: "block-editor-inserter__panel-title"
  18609. }, title), Object(external_wp_element_["createElement"])(external_wp_components_["Icon"], {
  18610. icon: icon
  18611. })), Object(external_wp_element_["createElement"])("div", {
  18612. className: "block-editor-inserter__panel-content"
  18613. }, children));
  18614. }
  18615. /* harmony default export */ var panel = (InserterPanel);
  18616. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-listbox/index.js
  18617. /**
  18618. * WordPress dependencies
  18619. */
  18620. /**
  18621. * Internal dependencies
  18622. */
  18623. function InserterListbox({
  18624. children
  18625. }) {
  18626. const compositeState = Object(external_wp_components_["__unstableUseCompositeState"])({
  18627. shift: true,
  18628. wrap: 'horizontal'
  18629. });
  18630. return Object(external_wp_element_["createElement"])(inserter_listbox_context.Provider, {
  18631. value: compositeState
  18632. }, children);
  18633. }
  18634. /* harmony default export */ var inserter_listbox = (InserterListbox);
  18635. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/block-types-tab.js
  18636. /**
  18637. * External dependencies
  18638. */
  18639. /**
  18640. * WordPress dependencies
  18641. */
  18642. /**
  18643. * Internal dependencies
  18644. */
  18645. const getBlockNamespace = item => item.name.split('/')[0];
  18646. const MAX_SUGGESTED_ITEMS = 6;
  18647. function BlockTypesTab({
  18648. rootClientId,
  18649. onInsert,
  18650. onHover,
  18651. showMostUsedBlocks
  18652. }) {
  18653. const [items, categories, collections, onSelectItem] = use_block_types_state(rootClientId, onInsert);
  18654. const suggestedItems = Object(external_wp_element_["useMemo"])(() => {
  18655. return Object(external_lodash_["orderBy"])(items, ['frecency'], ['desc']).slice(0, MAX_SUGGESTED_ITEMS);
  18656. }, [items]);
  18657. const uncategorizedItems = Object(external_wp_element_["useMemo"])(() => {
  18658. return items.filter(item => !item.category);
  18659. }, [items]);
  18660. const itemsPerCategory = Object(external_wp_element_["useMemo"])(() => {
  18661. return Object(external_lodash_["flow"])(itemList => itemList.filter(item => item.category && item.category !== 'reusable'), itemList => Object(external_lodash_["groupBy"])(itemList, 'category'))(items);
  18662. }, [items]);
  18663. const itemsPerCollection = Object(external_wp_element_["useMemo"])(() => {
  18664. // Create a new Object to avoid mutating collection.
  18665. const result = { ...collections
  18666. };
  18667. Object.keys(collections).forEach(namespace => {
  18668. result[namespace] = items.filter(item => getBlockNamespace(item) === namespace);
  18669. if (result[namespace].length === 0) {
  18670. delete result[namespace];
  18671. }
  18672. });
  18673. return result;
  18674. }, [items, collections]); // Hide block preview on unmount.
  18675. Object(external_wp_element_["useEffect"])(() => () => onHover(null), []);
  18676. return Object(external_wp_element_["createElement"])(inserter_listbox, null, Object(external_wp_element_["createElement"])("div", null, showMostUsedBlocks && !!suggestedItems.length && Object(external_wp_element_["createElement"])(panel, {
  18677. title: Object(external_wp_i18n_["_x"])('Most used', 'blocks')
  18678. }, Object(external_wp_element_["createElement"])(block_types_list, {
  18679. items: suggestedItems,
  18680. onSelect: onSelectItem,
  18681. onHover: onHover,
  18682. label: Object(external_wp_i18n_["_x"])('Most used', 'blocks')
  18683. })), Object(external_lodash_["map"])(categories, category => {
  18684. const categoryItems = itemsPerCategory[category.slug];
  18685. if (!categoryItems || !categoryItems.length) {
  18686. return null;
  18687. }
  18688. return Object(external_wp_element_["createElement"])(panel, {
  18689. key: category.slug,
  18690. title: category.title,
  18691. icon: category.icon
  18692. }, Object(external_wp_element_["createElement"])(block_types_list, {
  18693. items: categoryItems,
  18694. onSelect: onSelectItem,
  18695. onHover: onHover,
  18696. label: category.title
  18697. }));
  18698. }), uncategorizedItems.length > 0 && Object(external_wp_element_["createElement"])(panel, {
  18699. className: "block-editor-inserter__uncategorized-blocks-panel",
  18700. title: Object(external_wp_i18n_["__"])('Uncategorized')
  18701. }, Object(external_wp_element_["createElement"])(block_types_list, {
  18702. items: uncategorizedItems,
  18703. onSelect: onSelectItem,
  18704. onHover: onHover,
  18705. label: Object(external_wp_i18n_["__"])('Uncategorized')
  18706. })), Object(external_lodash_["map"])(collections, (collection, namespace) => {
  18707. const collectionItems = itemsPerCollection[namespace];
  18708. if (!collectionItems || !collectionItems.length) {
  18709. return null;
  18710. }
  18711. return Object(external_wp_element_["createElement"])(panel, {
  18712. key: namespace,
  18713. title: collection.title,
  18714. icon: collection.icon
  18715. }, Object(external_wp_element_["createElement"])(block_types_list, {
  18716. items: collectionItems,
  18717. onSelect: onSelectItem,
  18718. onHover: onHover,
  18719. label: collection.title
  18720. }));
  18721. })));
  18722. }
  18723. /* harmony default export */ var block_types_tab = (BlockTypesTab);
  18724. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/pattern-panel.js
  18725. /**
  18726. * External dependencies
  18727. */
  18728. /**
  18729. * WordPress dependencies
  18730. */
  18731. function PatternInserterPanel({
  18732. selectedCategory,
  18733. patternCategories,
  18734. onClickCategory,
  18735. children
  18736. }) {
  18737. const categoryOptions = () => {
  18738. const options = [];
  18739. patternCategories.map(patternCategory => {
  18740. return options.push({
  18741. value: patternCategory.name,
  18742. label: patternCategory.label
  18743. });
  18744. });
  18745. return options;
  18746. };
  18747. const onChangeSelect = selected => {
  18748. onClickCategory(patternCategories.find(patternCategory => selected === patternCategory.name));
  18749. };
  18750. const getPanelHeaderClassName = () => {
  18751. return classnames_default()('block-editor-inserter__panel-header', 'block-editor-inserter__panel-header-patterns');
  18752. }; // In iOS-based mobile devices, the onBlur will fire when selecting an option
  18753. // from a Select element. To prevent closing the useDialog on iOS devices, we
  18754. // stop propagating the onBlur event if there is no relatedTarget, which means
  18755. // that the user most likely did not click on an element within the editor canvas.
  18756. const onBlur = event => {
  18757. if (!(event !== null && event !== void 0 && event.relatedTarget)) {
  18758. event.stopPropagation();
  18759. }
  18760. };
  18761. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])("div", {
  18762. className: getPanelHeaderClassName()
  18763. }, Object(external_wp_element_["createElement"])(external_wp_components_["SelectControl"], {
  18764. className: "block-editor-inserter__panel-dropdown",
  18765. label: Object(external_wp_i18n_["__"])('Filter patterns'),
  18766. hideLabelFromVision: true,
  18767. value: selectedCategory.name,
  18768. onChange: onChangeSelect,
  18769. onBlur: onBlur,
  18770. options: categoryOptions()
  18771. })), Object(external_wp_element_["createElement"])("div", {
  18772. className: "block-editor-inserter__panel-content"
  18773. }, children));
  18774. }
  18775. /* harmony default export */ var pattern_panel = (PatternInserterPanel);
  18776. // EXTERNAL MODULE: external ["wp","notices"]
  18777. var external_wp_notices_ = __webpack_require__("onLe");
  18778. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/hooks/use-patterns-state.js
  18779. /**
  18780. * External dependencies
  18781. */
  18782. /**
  18783. * WordPress dependencies
  18784. */
  18785. /**
  18786. * Internal dependencies
  18787. */
  18788. /**
  18789. * Retrieves the block patterns inserter state.
  18790. *
  18791. * @param {Function} onInsert function called when inserter a list of blocks.
  18792. * @param {string=} rootClientId Insertion's root client ID.
  18793. *
  18794. * @return {Array} Returns the patterns state. (patterns, categories, onSelect handler)
  18795. */
  18796. const usePatternsState = (onInsert, rootClientId) => {
  18797. const {
  18798. patternCategories,
  18799. patterns
  18800. } = Object(external_wp_data_["useSelect"])(select => {
  18801. const {
  18802. __experimentalGetAllowedPatterns,
  18803. getSettings
  18804. } = select(store);
  18805. return {
  18806. patterns: __experimentalGetAllowedPatterns(rootClientId),
  18807. patternCategories: getSettings().__experimentalBlockPatternCategories
  18808. };
  18809. }, [rootClientId]);
  18810. const {
  18811. createSuccessNotice
  18812. } = Object(external_wp_data_["useDispatch"])(external_wp_notices_["store"]);
  18813. const onClickPattern = Object(external_wp_element_["useCallback"])((pattern, blocks) => {
  18814. onInsert(Object(external_lodash_["map"])(blocks, block => Object(external_wp_blocks_["cloneBlock"])(block)), pattern.name);
  18815. createSuccessNotice(Object(external_wp_i18n_["sprintf"])(
  18816. /* translators: %s: block pattern title. */
  18817. Object(external_wp_i18n_["__"])('Block pattern "%s" inserted.'), pattern.title), {
  18818. type: 'snackbar'
  18819. });
  18820. }, []);
  18821. return [patterns, patternCategories, onClickPattern];
  18822. };
  18823. /* harmony default export */ var use_patterns_state = (usePatternsState);
  18824. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-patterns-list/index.js
  18825. /**
  18826. * WordPress dependencies
  18827. */
  18828. /**
  18829. * Internal dependencies
  18830. */
  18831. function BlockPattern({
  18832. isDraggable,
  18833. pattern,
  18834. onClick,
  18835. composite
  18836. }) {
  18837. const {
  18838. name,
  18839. viewportWidth
  18840. } = pattern;
  18841. const {
  18842. blocks
  18843. } = Object(external_wp_data_["useSelect"])(select => select(store).__experimentalGetParsedPattern(name), [name]);
  18844. const instanceId = Object(external_wp_compose_["useInstanceId"])(BlockPattern);
  18845. const descriptionId = `block-editor-block-patterns-list__item-description-${instanceId}`;
  18846. return Object(external_wp_element_["createElement"])(inserter_draggable_blocks, {
  18847. isEnabled: isDraggable,
  18848. blocks: blocks
  18849. }, ({
  18850. draggable,
  18851. onDragStart,
  18852. onDragEnd
  18853. }) => Object(external_wp_element_["createElement"])("div", {
  18854. className: "block-editor-block-patterns-list__list-item",
  18855. "aria-label": pattern.title,
  18856. "aria-describedby": pattern.description ? descriptionId : undefined,
  18857. draggable: draggable,
  18858. onDragStart: onDragStart,
  18859. onDragEnd: onDragEnd
  18860. }, Object(external_wp_element_["createElement"])(external_wp_components_["__unstableCompositeItem"], Object(esm_extends["a" /* default */])({
  18861. role: "option",
  18862. as: "div"
  18863. }, composite, {
  18864. className: "block-editor-block-patterns-list__item",
  18865. onClick: () => onClick(pattern, blocks)
  18866. }), Object(external_wp_element_["createElement"])(block_preview, {
  18867. blocks: blocks,
  18868. viewportWidth: viewportWidth
  18869. }), Object(external_wp_element_["createElement"])("div", {
  18870. className: "block-editor-block-patterns-list__item-title"
  18871. }, pattern.title), !!pattern.description && Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], {
  18872. id: descriptionId
  18873. }, pattern.description))));
  18874. }
  18875. function BlockPatternPlaceholder() {
  18876. return Object(external_wp_element_["createElement"])("div", {
  18877. className: "block-editor-block-patterns-list__item is-placeholder"
  18878. });
  18879. }
  18880. function BlockPatternList({
  18881. isDraggable,
  18882. blockPatterns,
  18883. shownPatterns,
  18884. onClickPattern,
  18885. orientation,
  18886. label = Object(external_wp_i18n_["__"])('Block Patterns')
  18887. }) {
  18888. const composite = Object(external_wp_components_["__unstableUseCompositeState"])({
  18889. orientation
  18890. });
  18891. return Object(external_wp_element_["createElement"])(external_wp_components_["__unstableComposite"], Object(esm_extends["a" /* default */])({}, composite, {
  18892. role: "listbox",
  18893. className: "block-editor-block-patterns-list",
  18894. "aria-label": label
  18895. }), blockPatterns.map(pattern => {
  18896. const isShown = shownPatterns.includes(pattern);
  18897. return isShown ? Object(external_wp_element_["createElement"])(BlockPattern, {
  18898. key: pattern.name,
  18899. pattern: pattern,
  18900. onClick: onClickPattern,
  18901. isDraggable: isDraggable,
  18902. composite: composite
  18903. }) : Object(external_wp_element_["createElement"])(BlockPatternPlaceholder, {
  18904. key: pattern.name
  18905. });
  18906. }));
  18907. }
  18908. /* harmony default export */ var block_patterns_list = (BlockPatternList);
  18909. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/block-patterns-tab.js
  18910. /**
  18911. * External dependencies
  18912. */
  18913. /**
  18914. * WordPress dependencies
  18915. */
  18916. /**
  18917. * Internal dependencies
  18918. */
  18919. function BlockPatternsCategory({
  18920. rootClientId,
  18921. onInsert,
  18922. selectedCategory,
  18923. onClickCategory
  18924. }) {
  18925. const [allPatterns, allCategories, onClick] = use_patterns_state(onInsert, rootClientId); // Remove any empty categories
  18926. const populatedCategories = Object(external_wp_element_["useMemo"])(() => allCategories.filter(category => allPatterns.some(pattern => {
  18927. var _pattern$categories;
  18928. return (_pattern$categories = pattern.categories) === null || _pattern$categories === void 0 ? void 0 : _pattern$categories.includes(category.name);
  18929. })), [allPatterns, allCategories]);
  18930. const patternCategory = selectedCategory ? selectedCategory : populatedCategories[0];
  18931. Object(external_wp_element_["useEffect"])(() => {
  18932. if (allPatterns.some(pattern => getPatternIndex(pattern) === Infinity) && !populatedCategories.find(category => category.name === 'uncategorized')) {
  18933. populatedCategories.push({
  18934. name: 'uncategorized',
  18935. label: Object(external_wp_i18n_["_x"])('Uncategorized')
  18936. });
  18937. }
  18938. }, [populatedCategories, allPatterns]);
  18939. const getPatternIndex = Object(external_wp_element_["useCallback"])(pattern => {
  18940. if (!pattern.categories || !pattern.categories.length) {
  18941. return Infinity;
  18942. }
  18943. const indexedCategories = Object(external_lodash_["fromPairs"])(populatedCategories.map(({
  18944. name
  18945. }, index) => [name, index]));
  18946. return Math.min(...pattern.categories.map(cat => indexedCategories[cat] !== undefined ? indexedCategories[cat] : Infinity));
  18947. }, [populatedCategories]);
  18948. const currentCategoryPatterns = Object(external_wp_element_["useMemo"])(() => allPatterns.filter(pattern => patternCategory.name === 'uncategorized' ? getPatternIndex(pattern) === Infinity : pattern.categories && pattern.categories.includes(patternCategory.name)), [allPatterns, patternCategory]); // Ordering the patterns is important for the async rendering.
  18949. const orderedPatterns = Object(external_wp_element_["useMemo"])(() => {
  18950. return currentCategoryPatterns.sort((a, b) => {
  18951. return getPatternIndex(a) - getPatternIndex(b);
  18952. });
  18953. }, [currentCategoryPatterns, getPatternIndex]);
  18954. const currentShownPatterns = Object(external_wp_compose_["useAsyncList"])(orderedPatterns);
  18955. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, !!currentCategoryPatterns.length && Object(external_wp_element_["createElement"])(pattern_panel, {
  18956. selectedCategory: patternCategory,
  18957. patternCategories: populatedCategories,
  18958. onClickCategory: onClickCategory
  18959. }, Object(external_wp_element_["createElement"])(block_patterns_list, {
  18960. shownPatterns: currentShownPatterns,
  18961. blockPatterns: currentCategoryPatterns,
  18962. onClickPattern: onClick,
  18963. label: patternCategory.label,
  18964. orientation: "vertical",
  18965. isDraggable: true
  18966. })));
  18967. }
  18968. function BlockPatternsTabs({
  18969. rootClientId,
  18970. onInsert,
  18971. onClickCategory,
  18972. selectedCategory
  18973. }) {
  18974. return Object(external_wp_element_["createElement"])(BlockPatternsCategory, {
  18975. rootClientId: rootClientId,
  18976. selectedCategory: selectedCategory,
  18977. onInsert: onInsert,
  18978. onClickCategory: onClickCategory
  18979. });
  18980. }
  18981. /* harmony default export */ var block_patterns_tab = (BlockPatternsTabs);
  18982. // EXTERNAL MODULE: external ["wp","url"]
  18983. var external_wp_url_ = __webpack_require__("Mmq9");
  18984. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/no-results.js
  18985. /**
  18986. * WordPress dependencies
  18987. */
  18988. function InserterNoResults() {
  18989. return Object(external_wp_element_["createElement"])("div", {
  18990. className: "block-editor-inserter__no-results"
  18991. }, Object(external_wp_element_["createElement"])(build_module_icon["a" /* default */], {
  18992. className: "block-editor-inserter__no-results-icon",
  18993. icon: block_default["a" /* default */]
  18994. }), Object(external_wp_element_["createElement"])("p", null, Object(external_wp_i18n_["__"])('No results found.')));
  18995. }
  18996. /* harmony default export */ var no_results = (InserterNoResults);
  18997. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/reusable-blocks-tab.js
  18998. /**
  18999. * WordPress dependencies
  19000. */
  19001. /**
  19002. * Internal dependencies
  19003. */
  19004. function ReusableBlocksList({
  19005. onHover,
  19006. onInsert,
  19007. rootClientId
  19008. }) {
  19009. const [items,,, onSelectItem] = use_block_types_state(rootClientId, onInsert);
  19010. const filteredItems = Object(external_wp_element_["useMemo"])(() => {
  19011. return items.filter(({
  19012. category
  19013. }) => category === 'reusable');
  19014. }, [items]);
  19015. if (filteredItems.length === 0) {
  19016. return Object(external_wp_element_["createElement"])(no_results, null);
  19017. }
  19018. return Object(external_wp_element_["createElement"])(panel, {
  19019. title: Object(external_wp_i18n_["__"])('Reusable blocks')
  19020. }, Object(external_wp_element_["createElement"])(block_types_list, {
  19021. items: filteredItems,
  19022. onSelect: onSelectItem,
  19023. onHover: onHover,
  19024. label: Object(external_wp_i18n_["__"])('Reusable blocks')
  19025. }));
  19026. } // The unwrapped component is only exported for use by unit tests.
  19027. /**
  19028. * List of reusable blocks shown in the "Reusable" tab of the inserter.
  19029. *
  19030. * @param {Object} props Component props.
  19031. * @param {?string} props.rootClientId Client id of block to insert into.
  19032. * @param {Function} props.onInsert Callback to run when item is inserted.
  19033. * @param {Function} props.onHover Callback to run when item is hovered.
  19034. *
  19035. * @return {WPComponent} The component.
  19036. */
  19037. function ReusableBlocksTab({
  19038. rootClientId,
  19039. onInsert,
  19040. onHover
  19041. }) {
  19042. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(ReusableBlocksList, {
  19043. onHover: onHover,
  19044. onInsert: onInsert,
  19045. rootClientId: rootClientId
  19046. }), Object(external_wp_element_["createElement"])("div", {
  19047. className: "block-editor-inserter__manage-reusable-blocks-container"
  19048. }, Object(external_wp_element_["createElement"])("a", {
  19049. className: "block-editor-inserter__manage-reusable-blocks",
  19050. href: Object(external_wp_url_["addQueryArgs"])('edit.php', {
  19051. post_type: 'wp_block'
  19052. })
  19053. }, Object(external_wp_i18n_["__"])('Manage Reusable blocks'))));
  19054. }
  19055. /* harmony default export */ var reusable_blocks_tab = (ReusableBlocksTab);
  19056. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-menu-extension/index.js
  19057. /**
  19058. * WordPress dependencies
  19059. */
  19060. const {
  19061. Fill: __unstableInserterMenuExtension,
  19062. Slot: inserter_menu_extension_Slot
  19063. } = Object(external_wp_components_["createSlotFill"])('__unstableInserterMenuExtension');
  19064. __unstableInserterMenuExtension.Slot = inserter_menu_extension_Slot;
  19065. /* harmony default export */ var inserter_menu_extension = (__unstableInserterMenuExtension);
  19066. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/hooks/use-insertion-point.js
  19067. /**
  19068. * External dependencies
  19069. */
  19070. /**
  19071. * WordPress dependencies
  19072. */
  19073. /**
  19074. * Internal dependencies
  19075. */
  19076. /**
  19077. * @typedef WPInserterConfig
  19078. *
  19079. * @property {string=} rootClientId If set, insertion will be into the
  19080. * block with this ID.
  19081. * @property {number=} insertionIndex If set, insertion will be into this
  19082. * explicit position.
  19083. * @property {string=} clientId If set, insertion will be after the
  19084. * block with this ID.
  19085. * @property {boolean=} isAppender Whether the inserter is an appender
  19086. * or not.
  19087. * @property {Function=} onSelect Called after insertion.
  19088. */
  19089. /**
  19090. * Returns the insertion point state given the inserter config.
  19091. *
  19092. * @param {WPInserterConfig} config Inserter Config.
  19093. * @return {Array} Insertion Point State (rootClientID, onInsertBlocks and onToggle).
  19094. */
  19095. function useInsertionPoint({
  19096. rootClientId = '',
  19097. insertionIndex,
  19098. clientId,
  19099. isAppender,
  19100. onSelect,
  19101. shouldFocusBlock = true
  19102. }) {
  19103. const {
  19104. getSelectedBlock
  19105. } = Object(external_wp_data_["useSelect"])(store);
  19106. const {
  19107. destinationRootClientId,
  19108. destinationIndex
  19109. } = Object(external_wp_data_["useSelect"])(select => {
  19110. const {
  19111. getSelectedBlockClientId,
  19112. getBlockRootClientId,
  19113. getBlockIndex,
  19114. getBlockOrder
  19115. } = select(store);
  19116. const selectedBlockClientId = getSelectedBlockClientId();
  19117. let _destinationRootClientId = rootClientId;
  19118. let _destinationIndex;
  19119. if (insertionIndex !== undefined) {
  19120. // Insert into a specific index.
  19121. _destinationIndex = insertionIndex;
  19122. } else if (clientId) {
  19123. // Insert after a specific client ID.
  19124. _destinationIndex = getBlockIndex(clientId, _destinationRootClientId);
  19125. } else if (!isAppender && selectedBlockClientId) {
  19126. _destinationRootClientId = getBlockRootClientId(selectedBlockClientId);
  19127. _destinationIndex = getBlockIndex(selectedBlockClientId, _destinationRootClientId) + 1;
  19128. } else {
  19129. // Insert at the end of the list.
  19130. _destinationIndex = getBlockOrder(_destinationRootClientId).length;
  19131. }
  19132. return {
  19133. destinationRootClientId: _destinationRootClientId,
  19134. destinationIndex: _destinationIndex
  19135. };
  19136. }, [rootClientId, insertionIndex, clientId, isAppender]);
  19137. const {
  19138. replaceBlocks,
  19139. insertBlocks,
  19140. showInsertionPoint,
  19141. hideInsertionPoint
  19142. } = Object(external_wp_data_["useDispatch"])(store);
  19143. const onInsertBlocks = Object(external_wp_element_["useCallback"])((blocks, meta, shouldForceFocusBlock = false) => {
  19144. const selectedBlock = getSelectedBlock();
  19145. if (!isAppender && selectedBlock && Object(external_wp_blocks_["isUnmodifiedDefaultBlock"])(selectedBlock)) {
  19146. replaceBlocks(selectedBlock.clientId, blocks, null, shouldFocusBlock || shouldForceFocusBlock ? 0 : null, meta);
  19147. } else {
  19148. insertBlocks(blocks, destinationIndex, destinationRootClientId, true, shouldFocusBlock || shouldForceFocusBlock ? 0 : null, meta);
  19149. }
  19150. const message = Object(external_wp_i18n_["sprintf"])( // translators: %d: the name of the block that has been added
  19151. Object(external_wp_i18n_["_n"])('%d block added.', '%d blocks added.', Object(external_lodash_["castArray"])(blocks).length), Object(external_lodash_["castArray"])(blocks).length);
  19152. Object(external_wp_a11y_["speak"])(message);
  19153. if (onSelect) {
  19154. onSelect();
  19155. }
  19156. }, [isAppender, getSelectedBlock, replaceBlocks, insertBlocks, destinationRootClientId, destinationIndex, onSelect, shouldFocusBlock]);
  19157. const onToggleInsertionPoint = Object(external_wp_element_["useCallback"])(show => {
  19158. if (show) {
  19159. showInsertionPoint(destinationRootClientId, destinationIndex);
  19160. } else {
  19161. hideInsertionPoint();
  19162. }
  19163. }, [showInsertionPoint, hideInsertionPoint, destinationRootClientId, destinationIndex]);
  19164. return [destinationRootClientId, onInsertBlocks, onToggleInsertionPoint];
  19165. }
  19166. /* harmony default export */ var use_insertion_point = (useInsertionPoint);
  19167. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/search-results.js
  19168. /**
  19169. * External dependencies
  19170. */
  19171. /**
  19172. * WordPress dependencies
  19173. */
  19174. /**
  19175. * Internal dependencies
  19176. */
  19177. function InserterSearchResults({
  19178. filterValue,
  19179. onSelect,
  19180. onHover,
  19181. rootClientId,
  19182. clientId,
  19183. isAppender,
  19184. __experimentalInsertionIndex,
  19185. maxBlockPatterns,
  19186. maxBlockTypes,
  19187. showBlockDirectory = false,
  19188. isDraggable = true,
  19189. shouldFocusBlock = true
  19190. }) {
  19191. const debouncedSpeak = Object(external_wp_compose_["useDebounce"])(external_wp_a11y_["speak"], 500);
  19192. const [destinationRootClientId, onInsertBlocks] = use_insertion_point({
  19193. onSelect,
  19194. rootClientId,
  19195. clientId,
  19196. isAppender,
  19197. insertionIndex: __experimentalInsertionIndex,
  19198. shouldFocusBlock
  19199. });
  19200. const [blockTypes, blockTypeCategories, blockTypeCollections, onSelectBlockType] = use_block_types_state(destinationRootClientId, onInsertBlocks);
  19201. const [patterns,, onSelectBlockPattern] = use_patterns_state(onInsertBlocks, destinationRootClientId);
  19202. const filteredBlockTypes = Object(external_wp_element_["useMemo"])(() => {
  19203. const results = searchBlockItems(Object(external_lodash_["orderBy"])(blockTypes, ['frecency'], ['desc']), blockTypeCategories, blockTypeCollections, filterValue);
  19204. return maxBlockTypes !== undefined ? results.slice(0, maxBlockTypes) : results;
  19205. }, [filterValue, blockTypes, blockTypeCategories, blockTypeCollections, maxBlockTypes]);
  19206. const filteredBlockPatterns = Object(external_wp_element_["useMemo"])(() => {
  19207. const results = searchItems(patterns, filterValue);
  19208. return maxBlockPatterns !== undefined ? results.slice(0, maxBlockPatterns) : results;
  19209. }, [filterValue, patterns, maxBlockPatterns]); // Announce search results on change
  19210. Object(external_wp_element_["useEffect"])(() => {
  19211. if (!filterValue) {
  19212. return;
  19213. }
  19214. const count = filteredBlockTypes.length + filteredBlockPatterns.length;
  19215. const resultsFoundMessage = Object(external_wp_i18n_["sprintf"])(
  19216. /* translators: %d: number of results. */
  19217. Object(external_wp_i18n_["_n"])('%d result found.', '%d results found.', count), count);
  19218. debouncedSpeak(resultsFoundMessage);
  19219. }, [filterValue, debouncedSpeak]);
  19220. const currentShownPatterns = Object(external_wp_compose_["useAsyncList"])(filteredBlockPatterns);
  19221. const hasItems = !Object(external_lodash_["isEmpty"])(filteredBlockTypes) || !Object(external_lodash_["isEmpty"])(filteredBlockPatterns);
  19222. return Object(external_wp_element_["createElement"])(inserter_listbox, null, !showBlockDirectory && !hasItems && Object(external_wp_element_["createElement"])(no_results, null), !!filteredBlockTypes.length && Object(external_wp_element_["createElement"])(panel, {
  19223. title: Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], null, Object(external_wp_i18n_["__"])('Blocks'))
  19224. }, Object(external_wp_element_["createElement"])(block_types_list, {
  19225. items: filteredBlockTypes,
  19226. onSelect: onSelectBlockType,
  19227. onHover: onHover,
  19228. label: Object(external_wp_i18n_["__"])('Blocks'),
  19229. isDraggable: isDraggable
  19230. })), !!filteredBlockTypes.length && !!filteredBlockPatterns.length && Object(external_wp_element_["createElement"])("div", {
  19231. className: "block-editor-inserter__quick-inserter-separator"
  19232. }), !!filteredBlockPatterns.length && Object(external_wp_element_["createElement"])(panel, {
  19233. title: Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], null, Object(external_wp_i18n_["__"])('Block Patterns'))
  19234. }, Object(external_wp_element_["createElement"])("div", {
  19235. className: "block-editor-inserter__quick-inserter-patterns"
  19236. }, Object(external_wp_element_["createElement"])(block_patterns_list, {
  19237. shownPatterns: currentShownPatterns,
  19238. blockPatterns: filteredBlockPatterns,
  19239. onClickPattern: onSelectBlockPattern,
  19240. isDraggable: isDraggable
  19241. }))), showBlockDirectory && Object(external_wp_element_["createElement"])(inserter_menu_extension.Slot, {
  19242. fillProps: {
  19243. onSelect: onSelectBlockType,
  19244. onHover,
  19245. filterValue,
  19246. hasItems,
  19247. rootClientId: destinationRootClientId
  19248. }
  19249. }, fills => {
  19250. if (fills.length) {
  19251. return fills;
  19252. }
  19253. if (!hasItems) {
  19254. return Object(external_wp_element_["createElement"])(no_results, null);
  19255. }
  19256. return null;
  19257. }));
  19258. }
  19259. /* harmony default export */ var search_results = (InserterSearchResults);
  19260. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/tabs.js
  19261. /**
  19262. * WordPress dependencies
  19263. */
  19264. const tabs_blocksTab = {
  19265. name: 'blocks',
  19266. /* translators: Blocks tab title in the block inserter. */
  19267. title: Object(external_wp_i18n_["__"])('Blocks')
  19268. };
  19269. const tabs_patternsTab = {
  19270. name: 'patterns',
  19271. /* translators: Patterns tab title in the block inserter. */
  19272. title: Object(external_wp_i18n_["__"])('Patterns')
  19273. };
  19274. const tabs_reusableBlocksTab = {
  19275. name: 'reusable',
  19276. /* translators: Reusable blocks tab title in the block inserter. */
  19277. title: Object(external_wp_i18n_["__"])('Reusable')
  19278. };
  19279. function InserterTabs({
  19280. children,
  19281. showPatterns = false,
  19282. showReusableBlocks = false,
  19283. onSelect
  19284. }) {
  19285. const tabs = Object(external_wp_element_["useMemo"])(() => {
  19286. const tempTabs = [tabs_blocksTab];
  19287. if (showPatterns) {
  19288. tempTabs.push(tabs_patternsTab);
  19289. }
  19290. if (showReusableBlocks) {
  19291. tempTabs.push(tabs_reusableBlocksTab);
  19292. }
  19293. return tempTabs;
  19294. }, [tabs_blocksTab, showPatterns, tabs_patternsTab, showReusableBlocks, tabs_reusableBlocksTab]);
  19295. return Object(external_wp_element_["createElement"])(external_wp_components_["TabPanel"], {
  19296. className: "block-editor-inserter__tabs",
  19297. tabs: tabs,
  19298. onSelect: onSelect
  19299. }, children);
  19300. }
  19301. /* harmony default export */ var inserter_tabs = (InserterTabs);
  19302. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/menu.js
  19303. /**
  19304. * WordPress dependencies
  19305. */
  19306. /**
  19307. * Internal dependencies
  19308. */
  19309. function InserterMenu({
  19310. rootClientId,
  19311. clientId,
  19312. isAppender,
  19313. __experimentalInsertionIndex,
  19314. onSelect,
  19315. showInserterHelpPanel,
  19316. showMostUsedBlocks,
  19317. shouldFocusBlock = true
  19318. }) {
  19319. const [filterValue, setFilterValue] = Object(external_wp_element_["useState"])('');
  19320. const [hoveredItem, setHoveredItem] = Object(external_wp_element_["useState"])(null);
  19321. const [selectedPatternCategory, setSelectedPatternCategory] = Object(external_wp_element_["useState"])(null);
  19322. const [destinationRootClientId, onInsertBlocks, onToggleInsertionPoint] = use_insertion_point({
  19323. rootClientId,
  19324. clientId,
  19325. isAppender,
  19326. insertionIndex: __experimentalInsertionIndex,
  19327. shouldFocusBlock
  19328. });
  19329. const {
  19330. showPatterns,
  19331. hasReusableBlocks
  19332. } = Object(external_wp_data_["useSelect"])(select => {
  19333. var _getSettings$__experi;
  19334. const {
  19335. __experimentalGetAllowedPatterns,
  19336. getSettings
  19337. } = select(store);
  19338. return {
  19339. showPatterns: !!__experimentalGetAllowedPatterns(destinationRootClientId).length,
  19340. hasReusableBlocks: !!((_getSettings$__experi = getSettings().__experimentalReusableBlocks) !== null && _getSettings$__experi !== void 0 && _getSettings$__experi.length)
  19341. };
  19342. }, [destinationRootClientId]);
  19343. const onInsert = Object(external_wp_element_["useCallback"])((blocks, meta, shouldForceFocusBlock) => {
  19344. onInsertBlocks(blocks, meta, shouldForceFocusBlock);
  19345. onSelect();
  19346. }, [onInsertBlocks, onSelect]);
  19347. const onInsertPattern = Object(external_wp_element_["useCallback"])((blocks, patternName) => {
  19348. onInsertBlocks(blocks, {
  19349. patternName
  19350. });
  19351. onSelect();
  19352. }, [onInsertBlocks, onSelect]);
  19353. const onHover = Object(external_wp_element_["useCallback"])(item => {
  19354. onToggleInsertionPoint(!!item);
  19355. setHoveredItem(item);
  19356. }, [onToggleInsertionPoint, setHoveredItem]);
  19357. const onClickPatternCategory = Object(external_wp_element_["useCallback"])(patternCategory => {
  19358. setSelectedPatternCategory(patternCategory);
  19359. }, [setSelectedPatternCategory]);
  19360. const blocksTab = Object(external_wp_element_["useMemo"])(() => Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])("div", {
  19361. className: "block-editor-inserter__block-list"
  19362. }, Object(external_wp_element_["createElement"])(block_types_tab, {
  19363. rootClientId: destinationRootClientId,
  19364. onInsert: onInsert,
  19365. onHover: onHover,
  19366. showMostUsedBlocks: showMostUsedBlocks
  19367. })), showInserterHelpPanel && Object(external_wp_element_["createElement"])("div", {
  19368. className: "block-editor-inserter__tips"
  19369. }, Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], {
  19370. as: "h2"
  19371. }, Object(external_wp_i18n_["__"])('A tip for using the block editor')), Object(external_wp_element_["createElement"])(tips, null))), [destinationRootClientId, onInsert, onHover, filterValue, showMostUsedBlocks, showInserterHelpPanel]);
  19372. const patternsTab = Object(external_wp_element_["useMemo"])(() => Object(external_wp_element_["createElement"])(block_patterns_tab, {
  19373. rootClientId: destinationRootClientId,
  19374. onInsert: onInsertPattern,
  19375. onClickCategory: onClickPatternCategory,
  19376. selectedCategory: selectedPatternCategory
  19377. }), [destinationRootClientId, onInsertPattern, onClickPatternCategory, selectedPatternCategory]);
  19378. const reusableBlocksTab = Object(external_wp_element_["useMemo"])(() => Object(external_wp_element_["createElement"])(reusable_blocks_tab, {
  19379. rootClientId: destinationRootClientId,
  19380. onInsert: onInsert,
  19381. onHover: onHover
  19382. }), [destinationRootClientId, onInsert, onHover]);
  19383. const getCurrentTab = Object(external_wp_element_["useCallback"])(tab => {
  19384. if (tab.name === 'blocks') {
  19385. return blocksTab;
  19386. } else if (tab.name === 'patterns') {
  19387. return patternsTab;
  19388. }
  19389. return reusableBlocksTab;
  19390. }, [blocksTab, patternsTab, reusableBlocksTab]);
  19391. return Object(external_wp_element_["createElement"])("div", {
  19392. className: "block-editor-inserter__menu"
  19393. }, Object(external_wp_element_["createElement"])("div", {
  19394. className: "block-editor-inserter__main-area"
  19395. }, Object(external_wp_element_["createElement"])("div", {
  19396. className: "block-editor-inserter__content"
  19397. }, Object(external_wp_element_["createElement"])(search_form, {
  19398. onChange: value => {
  19399. if (hoveredItem) setHoveredItem(null);
  19400. setFilterValue(value);
  19401. },
  19402. value: filterValue,
  19403. label: Object(external_wp_i18n_["__"])('Search for blocks and patterns'),
  19404. placeholder: Object(external_wp_i18n_["__"])('Search')
  19405. }), !!filterValue && Object(external_wp_element_["createElement"])(search_results, {
  19406. filterValue: filterValue,
  19407. onSelect: onSelect,
  19408. onHover: onHover,
  19409. rootClientId: rootClientId,
  19410. clientId: clientId,
  19411. isAppender: isAppender,
  19412. __experimentalInsertionIndex: __experimentalInsertionIndex,
  19413. showBlockDirectory: true,
  19414. shouldFocusBlock: shouldFocusBlock
  19415. }), !filterValue && (showPatterns || hasReusableBlocks) && Object(external_wp_element_["createElement"])(inserter_tabs, {
  19416. showPatterns: showPatterns,
  19417. showReusableBlocks: hasReusableBlocks
  19418. }, getCurrentTab), !filterValue && !showPatterns && !hasReusableBlocks && blocksTab)), showInserterHelpPanel && hoveredItem && Object(external_wp_element_["createElement"])(preview_panel, {
  19419. item: hoveredItem
  19420. }));
  19421. }
  19422. /* harmony default export */ var menu = (InserterMenu);
  19423. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/quick-inserter.js
  19424. /**
  19425. * External dependencies
  19426. */
  19427. /**
  19428. * WordPress dependencies
  19429. */
  19430. /**
  19431. * Internal dependencies
  19432. */
  19433. const SEARCH_THRESHOLD = 6;
  19434. const quick_inserter_SHOWN_BLOCK_TYPES = 6;
  19435. const SHOWN_BLOCK_PATTERNS = 2;
  19436. function QuickInserter({
  19437. onSelect,
  19438. rootClientId,
  19439. clientId,
  19440. isAppender
  19441. }) {
  19442. const [filterValue, setFilterValue] = Object(external_wp_element_["useState"])('');
  19443. const [destinationRootClientId, onInsertBlocks] = use_insertion_point({
  19444. onSelect,
  19445. rootClientId,
  19446. clientId,
  19447. isAppender
  19448. });
  19449. const [blockTypes] = use_block_types_state(destinationRootClientId, onInsertBlocks);
  19450. const [patterns] = use_patterns_state(onInsertBlocks, destinationRootClientId);
  19451. const showPatterns = patterns.length && !!filterValue;
  19452. const showSearch = showPatterns && patterns.length > SEARCH_THRESHOLD || blockTypes.length > SEARCH_THRESHOLD;
  19453. const {
  19454. setInserterIsOpened,
  19455. insertionIndex
  19456. } = Object(external_wp_data_["useSelect"])(select => {
  19457. const {
  19458. getSettings,
  19459. getBlockIndex,
  19460. getBlockCount
  19461. } = select(store);
  19462. const index = getBlockIndex(clientId, rootClientId);
  19463. return {
  19464. setInserterIsOpened: getSettings().__experimentalSetIsInserterOpened,
  19465. insertionIndex: index === -1 ? getBlockCount() : index
  19466. };
  19467. }, [clientId, rootClientId]);
  19468. Object(external_wp_element_["useEffect"])(() => {
  19469. if (setInserterIsOpened) {
  19470. setInserterIsOpened(false);
  19471. }
  19472. }, [setInserterIsOpened]); // When clicking Browse All select the appropriate block so as
  19473. // the insertion point can work as expected
  19474. const onBrowseAll = () => {
  19475. setInserterIsOpened({
  19476. rootClientId,
  19477. insertionIndex
  19478. });
  19479. };
  19480. return Object(external_wp_element_["createElement"])("div", {
  19481. className: classnames_default()('block-editor-inserter__quick-inserter', {
  19482. 'has-search': showSearch,
  19483. 'has-expand': setInserterIsOpened
  19484. })
  19485. }, showSearch && Object(external_wp_element_["createElement"])(search_form, {
  19486. value: filterValue,
  19487. onChange: value => {
  19488. setFilterValue(value);
  19489. },
  19490. label: Object(external_wp_i18n_["__"])('Search for blocks and patterns'),
  19491. placeholder: Object(external_wp_i18n_["__"])('Search')
  19492. }), Object(external_wp_element_["createElement"])("div", {
  19493. className: "block-editor-inserter__quick-inserter-results"
  19494. }, Object(external_wp_element_["createElement"])(search_results, {
  19495. filterValue: filterValue,
  19496. onSelect: onSelect,
  19497. rootClientId: rootClientId,
  19498. clientId: clientId,
  19499. isAppender: isAppender,
  19500. maxBlockPatterns: showPatterns ? SHOWN_BLOCK_PATTERNS : 0,
  19501. maxBlockTypes: quick_inserter_SHOWN_BLOCK_TYPES,
  19502. isDraggable: false
  19503. })), setInserterIsOpened && Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  19504. className: "block-editor-inserter__quick-inserter-expand",
  19505. onClick: onBrowseAll,
  19506. "aria-label": Object(external_wp_i18n_["__"])('Browse all. This will open the main inserter panel in the editor toolbar.')
  19507. }, Object(external_wp_i18n_["__"])('Browse all')));
  19508. }
  19509. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/index.js
  19510. /**
  19511. * External dependencies
  19512. */
  19513. /**
  19514. * WordPress dependencies
  19515. */
  19516. /**
  19517. * Internal dependencies
  19518. */
  19519. const defaultRenderToggle = ({
  19520. onToggle,
  19521. disabled,
  19522. isOpen,
  19523. blockTitle,
  19524. hasSingleBlockType,
  19525. toggleProps = {}
  19526. }) => {
  19527. let label;
  19528. if (hasSingleBlockType) {
  19529. label = Object(external_wp_i18n_["sprintf"])( // translators: %s: the name of the block when there is only one
  19530. Object(external_wp_i18n_["_x"])('Add %s', 'directly add the only allowed block'), blockTitle);
  19531. } else {
  19532. label = Object(external_wp_i18n_["_x"])('Add block', 'Generic label for block inserter button');
  19533. }
  19534. const {
  19535. onClick,
  19536. ...rest
  19537. } = toggleProps; // Handle both onClick functions from the toggle and the parent component
  19538. function handleClick(event) {
  19539. if (onToggle) {
  19540. onToggle(event);
  19541. }
  19542. if (onClick) {
  19543. onClick(event);
  19544. }
  19545. }
  19546. return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], Object(esm_extends["a" /* default */])({
  19547. icon: plus["a" /* default */],
  19548. label: label,
  19549. tooltipPosition: "bottom",
  19550. onClick: handleClick,
  19551. className: "block-editor-inserter__toggle",
  19552. "aria-haspopup": !hasSingleBlockType ? 'true' : false,
  19553. "aria-expanded": !hasSingleBlockType ? isOpen : false,
  19554. disabled: disabled
  19555. }, rest));
  19556. };
  19557. class inserter_Inserter extends external_wp_element_["Component"] {
  19558. constructor() {
  19559. super(...arguments);
  19560. this.onToggle = this.onToggle.bind(this);
  19561. this.renderToggle = this.renderToggle.bind(this);
  19562. this.renderContent = this.renderContent.bind(this);
  19563. }
  19564. onToggle(isOpen) {
  19565. const {
  19566. onToggle
  19567. } = this.props; // Surface toggle callback to parent component
  19568. if (onToggle) {
  19569. onToggle(isOpen);
  19570. }
  19571. }
  19572. /**
  19573. * Render callback to display Dropdown toggle element.
  19574. *
  19575. * @param {Object} options
  19576. * @param {Function} options.onToggle Callback to invoke when toggle is
  19577. * pressed.
  19578. * @param {boolean} options.isOpen Whether dropdown is currently open.
  19579. *
  19580. * @return {WPElement} Dropdown toggle element.
  19581. */
  19582. renderToggle({
  19583. onToggle,
  19584. isOpen
  19585. }) {
  19586. const {
  19587. disabled,
  19588. blockTitle,
  19589. hasSingleBlockType,
  19590. toggleProps,
  19591. hasItems,
  19592. renderToggle = defaultRenderToggle
  19593. } = this.props;
  19594. return renderToggle({
  19595. onToggle,
  19596. isOpen,
  19597. disabled: disabled || !hasItems,
  19598. blockTitle,
  19599. hasSingleBlockType,
  19600. toggleProps
  19601. });
  19602. }
  19603. /**
  19604. * Render callback to display Dropdown content element.
  19605. *
  19606. * @param {Object} options
  19607. * @param {Function} options.onClose Callback to invoke when dropdown is
  19608. * closed.
  19609. *
  19610. * @return {WPElement} Dropdown content element.
  19611. */
  19612. renderContent({
  19613. onClose
  19614. }) {
  19615. const {
  19616. rootClientId,
  19617. clientId,
  19618. isAppender,
  19619. showInserterHelpPanel,
  19620. // This prop is experimental to give some time for the quick inserter to mature
  19621. // Feel free to make them stable after a few releases.
  19622. __experimentalIsQuick: isQuick
  19623. } = this.props;
  19624. if (isQuick) {
  19625. return Object(external_wp_element_["createElement"])(QuickInserter, {
  19626. onSelect: () => {
  19627. onClose();
  19628. },
  19629. rootClientId: rootClientId,
  19630. clientId: clientId,
  19631. isAppender: isAppender
  19632. });
  19633. }
  19634. return Object(external_wp_element_["createElement"])(menu, {
  19635. onSelect: () => {
  19636. onClose();
  19637. },
  19638. rootClientId: rootClientId,
  19639. clientId: clientId,
  19640. isAppender: isAppender,
  19641. showInserterHelpPanel: showInserterHelpPanel
  19642. });
  19643. }
  19644. render() {
  19645. const {
  19646. position,
  19647. hasSingleBlockType,
  19648. insertOnlyAllowedBlock,
  19649. __experimentalIsQuick: isQuick,
  19650. onSelectOrClose
  19651. } = this.props;
  19652. if (hasSingleBlockType) {
  19653. return this.renderToggle({
  19654. onToggle: insertOnlyAllowedBlock
  19655. });
  19656. }
  19657. return Object(external_wp_element_["createElement"])(external_wp_components_["Dropdown"], {
  19658. className: "block-editor-inserter",
  19659. contentClassName: classnames_default()('block-editor-inserter__popover', {
  19660. 'is-quick': isQuick
  19661. }),
  19662. position: position,
  19663. onToggle: this.onToggle,
  19664. expandOnMobile: true,
  19665. headerTitle: Object(external_wp_i18n_["__"])('Add a block'),
  19666. renderToggle: this.renderToggle,
  19667. renderContent: this.renderContent,
  19668. onClose: onSelectOrClose
  19669. });
  19670. }
  19671. }
  19672. /* harmony default export */ var inserter = (Object(external_wp_compose_["compose"])([Object(external_wp_data_["withSelect"])((select, {
  19673. clientId,
  19674. rootClientId
  19675. }) => {
  19676. const {
  19677. getBlockRootClientId,
  19678. hasInserterItems,
  19679. __experimentalGetAllowedBlocks
  19680. } = select(store);
  19681. const {
  19682. getBlockVariations
  19683. } = select(external_wp_blocks_["store"]);
  19684. rootClientId = rootClientId || getBlockRootClientId(clientId) || undefined;
  19685. const allowedBlocks = __experimentalGetAllowedBlocks(rootClientId);
  19686. const hasSingleBlockType = Object(external_lodash_["size"])(allowedBlocks) === 1 && Object(external_lodash_["size"])(getBlockVariations(allowedBlocks[0].name, 'inserter')) === 0;
  19687. let allowedBlockType = false;
  19688. if (hasSingleBlockType) {
  19689. allowedBlockType = allowedBlocks[0];
  19690. }
  19691. return {
  19692. hasItems: hasInserterItems(rootClientId),
  19693. hasSingleBlockType,
  19694. blockTitle: allowedBlockType ? allowedBlockType.title : '',
  19695. allowedBlockType,
  19696. rootClientId
  19697. };
  19698. }), Object(external_wp_data_["withDispatch"])((dispatch, ownProps, {
  19699. select
  19700. }) => {
  19701. return {
  19702. insertOnlyAllowedBlock() {
  19703. const {
  19704. rootClientId,
  19705. clientId,
  19706. isAppender,
  19707. hasSingleBlockType,
  19708. allowedBlockType,
  19709. onSelectOrClose
  19710. } = ownProps;
  19711. if (!hasSingleBlockType) {
  19712. return;
  19713. }
  19714. function getInsertionIndex() {
  19715. const {
  19716. getBlockIndex,
  19717. getBlockSelectionEnd,
  19718. getBlockOrder,
  19719. getBlockRootClientId
  19720. } = select(store); // If the clientId is defined, we insert at the position of the block.
  19721. if (clientId) {
  19722. return getBlockIndex(clientId, rootClientId);
  19723. } // If there a selected block, we insert after the selected block.
  19724. const end = getBlockSelectionEnd();
  19725. if (!isAppender && end && getBlockRootClientId(end) === rootClientId) {
  19726. return getBlockIndex(end, rootClientId) + 1;
  19727. } // Otherwise, we insert at the end of the current rootClientId
  19728. return getBlockOrder(rootClientId).length;
  19729. }
  19730. const {
  19731. insertBlock
  19732. } = dispatch(store);
  19733. const blockToInsert = Object(external_wp_blocks_["createBlock"])(allowedBlockType.name);
  19734. insertBlock(blockToInsert, getInsertionIndex(), rootClientId);
  19735. if (onSelectOrClose) {
  19736. onSelectOrClose();
  19737. }
  19738. const message = Object(external_wp_i18n_["sprintf"])( // translators: %s: the name of the block that has been added
  19739. Object(external_wp_i18n_["__"])('%s block added'), allowedBlockType.title);
  19740. Object(external_wp_a11y_["speak"])(message);
  19741. }
  19742. };
  19743. }), // The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as
  19744. // a way to detect the global Inserter.
  19745. Object(external_wp_compose_["ifCondition"])(({
  19746. hasItems,
  19747. isAppender,
  19748. rootClientId,
  19749. clientId
  19750. }) => hasItems || !isAppender && !rootClientId && !clientId)])(inserter_Inserter));
  19751. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/default-block-appender/index.js
  19752. /**
  19753. * WordPress dependencies
  19754. */
  19755. /**
  19756. * Internal dependencies
  19757. */
  19758. /**
  19759. * Zero width non-breaking space, used as padding for the paragraph when it is
  19760. * empty.
  19761. */
  19762. const ZWNBSP = '\ufeff';
  19763. function DefaultBlockAppender({
  19764. isLocked,
  19765. isVisible,
  19766. onAppend,
  19767. showPrompt,
  19768. placeholder,
  19769. rootClientId
  19770. }) {
  19771. if (isLocked || !isVisible) {
  19772. return null;
  19773. }
  19774. const value = Object(external_wp_htmlEntities_["decodeEntities"])(placeholder) || Object(external_wp_i18n_["__"])('Type / to choose a block');
  19775. return Object(external_wp_element_["createElement"])("div", {
  19776. "data-root-client-id": rootClientId || '',
  19777. className: "block-editor-default-block-appender"
  19778. }, Object(external_wp_element_["createElement"])("p", {
  19779. tabIndex: "0" // Only necessary for `useCanvasClickRedirect` to consider it
  19780. // as a target. Ideally it should consider any tabbable target,
  19781. // but the inserter is rendered in place while it should be
  19782. // rendered in a popover, just like it does for an empty
  19783. // paragraph block.
  19784. ,
  19785. contentEditable: true,
  19786. suppressContentEditableWarning: true // We want this element to be styled as a paragraph by themes.
  19787. // eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
  19788. ,
  19789. role: "button",
  19790. "aria-label": Object(external_wp_i18n_["__"])('Add block') // The wp-block className is important for editor styles.
  19791. ,
  19792. className: "wp-block block-editor-default-block-appender__content",
  19793. onFocus: onAppend
  19794. }, showPrompt ? value : ZWNBSP), Object(external_wp_element_["createElement"])(inserter, {
  19795. rootClientId: rootClientId,
  19796. position: "bottom right",
  19797. isAppender: true,
  19798. __experimentalIsQuick: true
  19799. }));
  19800. }
  19801. /* harmony default export */ var default_block_appender = (Object(external_wp_compose_["compose"])(Object(external_wp_data_["withSelect"])((select, ownProps) => {
  19802. const {
  19803. getBlockCount,
  19804. getBlockName,
  19805. isBlockValid,
  19806. getSettings,
  19807. getTemplateLock
  19808. } = select(store);
  19809. const isEmpty = !getBlockCount(ownProps.rootClientId);
  19810. const isLastBlockDefault = getBlockName(ownProps.lastBlockClientId) === Object(external_wp_blocks_["getDefaultBlockName"])();
  19811. const isLastBlockValid = isBlockValid(ownProps.lastBlockClientId);
  19812. const {
  19813. bodyPlaceholder
  19814. } = getSettings();
  19815. return {
  19816. isVisible: isEmpty || !isLastBlockDefault || !isLastBlockValid,
  19817. showPrompt: isEmpty,
  19818. isLocked: !!getTemplateLock(ownProps.rootClientId),
  19819. placeholder: bodyPlaceholder
  19820. };
  19821. }), Object(external_wp_data_["withDispatch"])((dispatch, ownProps) => {
  19822. const {
  19823. insertDefaultBlock,
  19824. startTyping
  19825. } = dispatch(store);
  19826. return {
  19827. onAppend() {
  19828. const {
  19829. rootClientId
  19830. } = ownProps;
  19831. insertDefaultBlock(undefined, rootClientId);
  19832. startTyping();
  19833. }
  19834. };
  19835. }))(DefaultBlockAppender));
  19836. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/button-block-appender/index.js
  19837. /**
  19838. * External dependencies
  19839. */
  19840. /**
  19841. * WordPress dependencies
  19842. */
  19843. /**
  19844. * Internal dependencies
  19845. */
  19846. function ButtonBlockAppender({
  19847. rootClientId,
  19848. className,
  19849. onFocus,
  19850. tabIndex
  19851. }, ref) {
  19852. return Object(external_wp_element_["createElement"])(inserter, {
  19853. position: "bottom center",
  19854. rootClientId: rootClientId,
  19855. __experimentalIsQuick: true,
  19856. renderToggle: ({
  19857. onToggle,
  19858. disabled,
  19859. isOpen,
  19860. blockTitle,
  19861. hasSingleBlockType
  19862. }) => {
  19863. let label;
  19864. if (hasSingleBlockType) {
  19865. label = Object(external_wp_i18n_["sprintf"])( // translators: %s: the name of the block when there is only one
  19866. Object(external_wp_i18n_["_x"])('Add %s', 'directly add the only allowed block'), blockTitle);
  19867. } else {
  19868. label = Object(external_wp_i18n_["_x"])('Add block', 'Generic label for block inserter button');
  19869. }
  19870. const isToggleButton = !hasSingleBlockType;
  19871. let inserterButton = Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  19872. ref: ref,
  19873. onFocus: onFocus,
  19874. tabIndex: tabIndex,
  19875. className: classnames_default()(className, 'block-editor-button-block-appender'),
  19876. onClick: onToggle,
  19877. "aria-haspopup": isToggleButton ? 'true' : undefined,
  19878. "aria-expanded": isToggleButton ? isOpen : undefined,
  19879. disabled: disabled,
  19880. label: label
  19881. }, !hasSingleBlockType && Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], {
  19882. as: "span"
  19883. }, label), Object(external_wp_element_["createElement"])(build_module_icon["a" /* default */], {
  19884. icon: plus["a" /* default */]
  19885. }));
  19886. if (isToggleButton || hasSingleBlockType) {
  19887. inserterButton = Object(external_wp_element_["createElement"])(external_wp_components_["Tooltip"], {
  19888. text: label
  19889. }, inserterButton);
  19890. }
  19891. return inserterButton;
  19892. },
  19893. isAppender: true
  19894. });
  19895. }
  19896. /**
  19897. * Use `ButtonBlockAppender` instead.
  19898. *
  19899. * @deprecated
  19900. */
  19901. const ButtonBlockerAppender = Object(external_wp_element_["forwardRef"])((props, ref) => {
  19902. external_wp_deprecated_default()(`wp.blockEditor.ButtonBlockerAppender`, {
  19903. alternative: 'wp.blockEditor.ButtonBlockAppender'
  19904. });
  19905. return ButtonBlockAppender(props, ref);
  19906. });
  19907. /**
  19908. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/button-block-appender/README.md
  19909. */
  19910. /* harmony default export */ var button_block_appender = (Object(external_wp_element_["forwardRef"])(ButtonBlockAppender));
  19911. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list-appender/index.js
  19912. /**
  19913. * External dependencies
  19914. */
  19915. /**
  19916. * WordPress dependencies
  19917. */
  19918. /**
  19919. * Internal dependencies
  19920. */
  19921. // A Context to store the map of the appender map.
  19922. const AppenderNodesContext = Object(external_wp_element_["createContext"])();
  19923. function stopPropagation(event) {
  19924. event.stopPropagation();
  19925. }
  19926. function BlockListAppender({
  19927. blockClientIds,
  19928. rootClientId,
  19929. canInsertDefaultBlock,
  19930. isLocked,
  19931. renderAppender: CustomAppender,
  19932. className,
  19933. selectedBlockClientId,
  19934. tagName: TagName = 'div'
  19935. }) {
  19936. if (isLocked || CustomAppender === false) {
  19937. return null;
  19938. }
  19939. let appender;
  19940. if (CustomAppender) {
  19941. // Prefer custom render prop if provided.
  19942. appender = Object(external_wp_element_["createElement"])(CustomAppender, null);
  19943. } else {
  19944. const isDocumentAppender = !rootClientId;
  19945. const isParentSelected = selectedBlockClientId === rootClientId;
  19946. const isAnotherDefaultAppenderAlreadyDisplayed = selectedBlockClientId && !blockClientIds.includes(selectedBlockClientId);
  19947. if (!isDocumentAppender && !isParentSelected && (!selectedBlockClientId || isAnotherDefaultAppenderAlreadyDisplayed)) {
  19948. return null;
  19949. }
  19950. if (canInsertDefaultBlock) {
  19951. // Render the default block appender when renderAppender has not been
  19952. // provided and the context supports use of the default appender.
  19953. appender = Object(external_wp_element_["createElement"])(default_block_appender, {
  19954. rootClientId: rootClientId,
  19955. lastBlockClientId: Object(external_lodash_["last"])(blockClientIds)
  19956. });
  19957. } else {
  19958. // Fallback in the case no renderAppender has been provided and the
  19959. // default block can't be inserted.
  19960. appender = Object(external_wp_element_["createElement"])(button_block_appender, {
  19961. rootClientId: rootClientId,
  19962. className: "block-list-appender__toggle"
  19963. });
  19964. }
  19965. }
  19966. return Object(external_wp_element_["createElement"])(TagName // A `tabIndex` is used on the wrapping `div` element in order to
  19967. // force a focus event to occur when an appender `button` element
  19968. // is clicked. In some browsers (Firefox, Safari), button clicks do
  19969. // not emit a focus event, which could cause this event to propagate
  19970. // unexpectedly. The `tabIndex` ensures that the interaction is
  19971. // captured as a focus, without also adding an extra tab stop.
  19972. //
  19973. // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
  19974. , {
  19975. tabIndex: -1 // Prevent the block from being selected when the appender is
  19976. // clicked.
  19977. ,
  19978. onFocus: stopPropagation,
  19979. className: classnames_default()('block-list-appender', className)
  19980. }, appender);
  19981. }
  19982. /* harmony default export */ var block_list_appender = (Object(external_wp_data_["withSelect"])((select, {
  19983. rootClientId
  19984. }) => {
  19985. const {
  19986. getBlockOrder,
  19987. canInsertBlockType,
  19988. getTemplateLock,
  19989. getSelectedBlockClientId
  19990. } = select(store);
  19991. return {
  19992. isLocked: !!getTemplateLock(rootClientId),
  19993. blockClientIds: getBlockOrder(rootClientId),
  19994. canInsertDefaultBlock: canInsertBlockType(Object(external_wp_blocks_["getDefaultBlockName"])(), rootClientId),
  19995. selectedBlockClientId: getSelectedBlockClientId()
  19996. };
  19997. })(BlockListAppender));
  19998. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-on-block-drop/index.js
  19999. /**
  20000. * WordPress dependencies
  20001. */
  20002. /**
  20003. * Internal dependencies
  20004. */
  20005. /** @typedef {import('@wordpress/element').WPSyntheticEvent} WPSyntheticEvent */
  20006. /**
  20007. * Retrieve the data for a block drop event.
  20008. *
  20009. * @param {WPSyntheticEvent} event The drop event.
  20010. *
  20011. * @return {Object} An object with block drag and drop data.
  20012. */
  20013. function parseDropEvent(event) {
  20014. let result = {
  20015. srcRootClientId: null,
  20016. srcClientIds: null,
  20017. srcIndex: null,
  20018. type: null,
  20019. blocks: null
  20020. };
  20021. if (!event.dataTransfer) {
  20022. return result;
  20023. }
  20024. try {
  20025. result = Object.assign(result, JSON.parse(event.dataTransfer.getData('wp-blocks')));
  20026. } catch (err) {
  20027. return result;
  20028. }
  20029. return result;
  20030. }
  20031. /**
  20032. * A function that returns an event handler function for block drop events.
  20033. *
  20034. * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
  20035. * @param {number} targetBlockIndex The index where the block(s) will be inserted.
  20036. * @param {Function} getBlockIndex A function that gets the index of a block.
  20037. * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.
  20038. * @param {Function} moveBlocksToPosition A function that moves blocks.
  20039. * @param {Function} insertBlocks A function that inserts blocks.
  20040. * @param {Function} clearSelectedBlock A function that clears block selection.
  20041. * @return {Function} The event handler for a block drop event.
  20042. */
  20043. function use_on_block_drop_onBlockDrop(targetRootClientId, targetBlockIndex, getBlockIndex, getClientIdsOfDescendants, moveBlocksToPosition, insertBlocks, clearSelectedBlock) {
  20044. return event => {
  20045. const {
  20046. srcRootClientId: sourceRootClientId,
  20047. srcClientIds: sourceClientIds,
  20048. type: dropType,
  20049. blocks
  20050. } = parseDropEvent(event); // If the user is inserting a block
  20051. if (dropType === 'inserter') {
  20052. clearSelectedBlock();
  20053. insertBlocks(blocks, targetBlockIndex, targetRootClientId, true, null);
  20054. } // If the user is moving a block
  20055. if (dropType === 'block') {
  20056. const sourceBlockIndex = getBlockIndex(sourceClientIds[0], sourceRootClientId); // If the user is dropping to the same position, return early.
  20057. if (sourceRootClientId === targetRootClientId && sourceBlockIndex === targetBlockIndex) {
  20058. return;
  20059. } // If the user is attempting to drop a block within its own
  20060. // nested blocks, return early as this would create infinite
  20061. // recursion.
  20062. if (sourceClientIds.includes(targetRootClientId) || getClientIdsOfDescendants(sourceClientIds).some(id => id === targetRootClientId)) {
  20063. return;
  20064. }
  20065. const isAtSameLevel = sourceRootClientId === targetRootClientId;
  20066. const draggedBlockCount = sourceClientIds.length; // If the block is kept at the same level and moved downwards,
  20067. // subtract to take into account that the blocks being dragged
  20068. // were removed from the block list above the insertion point.
  20069. const insertIndex = isAtSameLevel && sourceBlockIndex < targetBlockIndex ? targetBlockIndex - draggedBlockCount : targetBlockIndex;
  20070. moveBlocksToPosition(sourceClientIds, sourceRootClientId, targetRootClientId, insertIndex);
  20071. }
  20072. };
  20073. }
  20074. /**
  20075. * A function that returns an event handler function for block-related file drop events.
  20076. *
  20077. * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
  20078. * @param {number} targetBlockIndex The index where the block(s) will be inserted.
  20079. * @param {boolean} hasUploadPermissions Whether the user has upload permissions.
  20080. * @param {Function} updateBlockAttributes A function that updates a block's attributes.
  20081. * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.
  20082. * @param {Function} insertBlocks A function that inserts blocks.
  20083. *
  20084. * @return {Function} The event handler for a block-related file drop event.
  20085. */
  20086. function onFilesDrop(targetRootClientId, targetBlockIndex, hasUploadPermissions, updateBlockAttributes, canInsertBlockType, insertBlocks) {
  20087. return files => {
  20088. if (!hasUploadPermissions) {
  20089. return;
  20090. }
  20091. const transformation = Object(external_wp_blocks_["findTransform"])(Object(external_wp_blocks_["getBlockTransforms"])('from'), transform => transform.type === 'files' && canInsertBlockType(transform.blockName, targetRootClientId) && transform.isMatch(files));
  20092. if (transformation) {
  20093. const blocks = transformation.transform(files, updateBlockAttributes);
  20094. insertBlocks(blocks, targetBlockIndex, targetRootClientId);
  20095. }
  20096. };
  20097. }
  20098. /**
  20099. * A function that returns an event handler function for block-related HTML drop events.
  20100. *
  20101. * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
  20102. * @param {number} targetBlockIndex The index where the block(s) will be inserted.
  20103. * @param {Function} insertBlocks A function that inserts blocks.
  20104. *
  20105. * @return {Function} The event handler for a block-related HTML drop event.
  20106. */
  20107. function use_on_block_drop_onHTMLDrop(targetRootClientId, targetBlockIndex, insertBlocks) {
  20108. return HTML => {
  20109. const blocks = Object(external_wp_blocks_["pasteHandler"])({
  20110. HTML,
  20111. mode: 'BLOCKS'
  20112. });
  20113. if (blocks.length) {
  20114. insertBlocks(blocks, targetBlockIndex, targetRootClientId);
  20115. }
  20116. };
  20117. }
  20118. /**
  20119. * A React hook for handling block drop events.
  20120. *
  20121. * @param {string} targetRootClientId The root client id where the block(s) will be inserted.
  20122. * @param {number} targetBlockIndex The index where the block(s) will be inserted.
  20123. *
  20124. * @return {Object} An object that contains the event handlers `onDrop`, `onFilesDrop` and `onHTMLDrop`.
  20125. */
  20126. function useOnBlockDrop(targetRootClientId, targetBlockIndex) {
  20127. const hasUploadPermissions = Object(external_wp_data_["useSelect"])(select => select(store).getSettings().mediaUpload, []);
  20128. const {
  20129. canInsertBlockType,
  20130. getBlockIndex,
  20131. getClientIdsOfDescendants
  20132. } = Object(external_wp_data_["useSelect"])(store);
  20133. const {
  20134. insertBlocks,
  20135. moveBlocksToPosition,
  20136. updateBlockAttributes,
  20137. clearSelectedBlock
  20138. } = Object(external_wp_data_["useDispatch"])(store);
  20139. const _onDrop = use_on_block_drop_onBlockDrop(targetRootClientId, targetBlockIndex, getBlockIndex, getClientIdsOfDescendants, moveBlocksToPosition, insertBlocks, clearSelectedBlock);
  20140. const _onFilesDrop = onFilesDrop(targetRootClientId, targetBlockIndex, hasUploadPermissions, updateBlockAttributes, canInsertBlockType, insertBlocks);
  20141. const _onHTMLDrop = use_on_block_drop_onHTMLDrop(targetRootClientId, targetBlockIndex, insertBlocks);
  20142. return event => {
  20143. const files = Object(external_wp_dom_["getFilesFromDataTransfer"])(event.dataTransfer);
  20144. const html = event.dataTransfer.getData('text/html');
  20145. if (files.length) {
  20146. _onFilesDrop(files);
  20147. } else if (html) {
  20148. _onHTMLDrop(html);
  20149. } else {
  20150. _onDrop(event);
  20151. }
  20152. };
  20153. }
  20154. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/math.js
  20155. /**
  20156. * A string representing the name of an edge.
  20157. *
  20158. * @typedef {'top'|'right'|'bottom'|'left'} WPEdgeName
  20159. */
  20160. /**
  20161. * @typedef {Object} WPPoint
  20162. * @property {number} x The horizontal position.
  20163. * @property {number} y The vertical position.
  20164. */
  20165. /**
  20166. * Given a point, a DOMRect and the name of an edge, returns the distance to
  20167. * that edge of the rect.
  20168. *
  20169. * This function works for edges that are horizontal or vertical (e.g. not
  20170. * rotated), the following terms are used so that the function works in both
  20171. * orientations:
  20172. *
  20173. * - Forward, meaning the axis running horizontally when an edge is vertical
  20174. * and vertically when an edge is horizontal.
  20175. * - Lateral, meaning the axis running vertically when an edge is vertical
  20176. * and horizontally when an edge is horizontal.
  20177. *
  20178. * @param {WPPoint} point The point to measure distance from.
  20179. * @param {DOMRect} rect A DOM Rect containing edge positions.
  20180. * @param {WPEdgeName} edge The edge to measure to.
  20181. */
  20182. function getDistanceFromPointToEdge(point, rect, edge) {
  20183. const isHorizontal = edge === 'top' || edge === 'bottom';
  20184. const {
  20185. x,
  20186. y
  20187. } = point;
  20188. const pointLateralPosition = isHorizontal ? x : y;
  20189. const pointForwardPosition = isHorizontal ? y : x;
  20190. const edgeStart = isHorizontal ? rect.left : rect.top;
  20191. const edgeEnd = isHorizontal ? rect.right : rect.bottom;
  20192. const edgeForwardPosition = rect[edge]; // Measure the straight line distance to the edge of the rect, when the
  20193. // point is adjacent to the edge.
  20194. // Else, if the point is positioned diagonally to the edge of the rect,
  20195. // measure diagonally to the nearest corner that the edge meets.
  20196. let edgeLateralPosition;
  20197. if (pointLateralPosition >= edgeStart && pointLateralPosition <= edgeEnd) {
  20198. edgeLateralPosition = pointLateralPosition;
  20199. } else if (pointLateralPosition < edgeEnd) {
  20200. edgeLateralPosition = edgeStart;
  20201. } else {
  20202. edgeLateralPosition = edgeEnd;
  20203. }
  20204. return Math.sqrt((pointLateralPosition - edgeLateralPosition) ** 2 + (pointForwardPosition - edgeForwardPosition) ** 2);
  20205. }
  20206. /**
  20207. * Given a point, a DOMRect and a list of allowed edges returns the name of and
  20208. * distance to the nearest edge.
  20209. *
  20210. * @param {WPPoint} point The point to measure distance from.
  20211. * @param {DOMRect} rect A DOM Rect containing edge positions.
  20212. * @param {WPEdgeName[]} allowedEdges A list of the edges included in the
  20213. * calculation. Defaults to all edges.
  20214. *
  20215. * @return {[number, string]} An array where the first value is the distance
  20216. * and a second is the edge name.
  20217. */
  20218. function getDistanceToNearestEdge(point, rect, allowedEdges = ['top', 'bottom', 'left', 'right']) {
  20219. let candidateDistance;
  20220. let candidateEdge;
  20221. allowedEdges.forEach(edge => {
  20222. const distance = getDistanceFromPointToEdge(point, rect, edge);
  20223. if (candidateDistance === undefined || distance < candidateDistance) {
  20224. candidateDistance = distance;
  20225. candidateEdge = edge;
  20226. }
  20227. });
  20228. return [candidateDistance, candidateEdge];
  20229. }
  20230. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-block-drop-zone/index.js
  20231. /**
  20232. * WordPress dependencies
  20233. */
  20234. /**
  20235. * Internal dependencies
  20236. */
  20237. /** @typedef {import('../../utils/math').WPPoint} WPPoint */
  20238. /**
  20239. * The orientation of a block list.
  20240. *
  20241. * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation
  20242. */
  20243. /**
  20244. * Given a list of block DOM elements finds the index that a block should be dropped
  20245. * at.
  20246. *
  20247. * @param {Element[]} elements Array of DOM elements that represent each block in a block list.
  20248. * @param {WPPoint} position The position of the item being dragged.
  20249. * @param {WPBlockListOrientation} orientation The orientation of a block list.
  20250. *
  20251. * @return {number|undefined} The block index that's closest to the drag position.
  20252. */
  20253. function getNearestBlockIndex(elements, position, orientation) {
  20254. const allowedEdges = orientation === 'horizontal' ? ['left', 'right'] : ['top', 'bottom'];
  20255. const isRightToLeft = Object(external_wp_i18n_["isRTL"])();
  20256. let candidateIndex;
  20257. let candidateDistance;
  20258. elements.forEach((element, index) => {
  20259. const rect = element.getBoundingClientRect();
  20260. const [distance, edge] = getDistanceToNearestEdge(position, rect, allowedEdges);
  20261. if (candidateDistance === undefined || distance < candidateDistance) {
  20262. // If the user is dropping to the trailing edge of the block
  20263. // add 1 to the index to represent dragging after.
  20264. // Take RTL languages into account where the left edge is
  20265. // the trailing edge.
  20266. const isTrailingEdge = edge === 'bottom' || !isRightToLeft && edge === 'right' || isRightToLeft && edge === 'left';
  20267. const offset = isTrailingEdge ? 1 : 0; // Update the currently known best candidate.
  20268. candidateDistance = distance;
  20269. candidateIndex = index + offset;
  20270. }
  20271. });
  20272. return candidateIndex;
  20273. }
  20274. /**
  20275. * @typedef {Object} WPBlockDropZoneConfig
  20276. * @property {string} rootClientId The root client id for the block list.
  20277. */
  20278. /**
  20279. * A React hook that can be used to make a block list handle drag and drop.
  20280. *
  20281. * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.
  20282. */
  20283. function useBlockDropZone({
  20284. // An undefined value represents a top-level block. Default to an empty
  20285. // string for this so that `targetRootClientId` can be easily compared to
  20286. // values returned by the `getRootBlockClientId` selector, which also uses
  20287. // an empty string to represent top-level blocks.
  20288. rootClientId: targetRootClientId = ''
  20289. } = {}) {
  20290. const [targetBlockIndex, setTargetBlockIndex] = Object(external_wp_element_["useState"])(null);
  20291. const isLockedAll = Object(external_wp_data_["useSelect"])(select => {
  20292. const {
  20293. getTemplateLock
  20294. } = select(store);
  20295. return getTemplateLock(targetRootClientId) === 'all';
  20296. }, [targetRootClientId]);
  20297. const {
  20298. getBlockListSettings
  20299. } = Object(external_wp_data_["useSelect"])(store);
  20300. const {
  20301. showInsertionPoint,
  20302. hideInsertionPoint
  20303. } = Object(external_wp_data_["useDispatch"])(store);
  20304. const onBlockDrop = useOnBlockDrop(targetRootClientId, targetBlockIndex);
  20305. const throttled = Object(external_wp_compose_["useThrottle"])(Object(external_wp_element_["useCallback"])((event, currentTarget) => {
  20306. var _getBlockListSettings;
  20307. const blockElements = Array.from(currentTarget.children).filter( // Ensure the element is a block. It should have the `wp-block` class.
  20308. element => element.classList.contains('wp-block'));
  20309. const targetIndex = getNearestBlockIndex(blockElements, {
  20310. x: event.clientX,
  20311. y: event.clientY
  20312. }, (_getBlockListSettings = getBlockListSettings(targetRootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation);
  20313. setTargetBlockIndex(targetIndex === undefined ? 0 : targetIndex);
  20314. if (targetIndex !== null) {
  20315. showInsertionPoint(targetRootClientId, targetIndex);
  20316. }
  20317. }, []), 200);
  20318. return Object(external_wp_compose_["__experimentalUseDropZone"])({
  20319. isDisabled: isLockedAll,
  20320. onDrop: onBlockDrop,
  20321. onDragOver(event) {
  20322. // `currentTarget` is only available while the event is being
  20323. // handled, so get it now and pass it to the thottled function.
  20324. // https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget
  20325. throttled(event, event.currentTarget);
  20326. },
  20327. onDragLeave() {
  20328. throttled.cancel();
  20329. hideInsertionPoint();
  20330. setTargetBlockIndex(null);
  20331. },
  20332. onDragEnd() {
  20333. throttled.cancel();
  20334. hideInsertionPoint();
  20335. setTargetBlockIndex(null);
  20336. }
  20337. });
  20338. }
  20339. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/use-popover-scroll.js
  20340. /**
  20341. * WordPress dependencies
  20342. */
  20343. /**
  20344. * Allow scrolling "through" popovers over the canvas. This is only called for
  20345. * as long as the pointer is over a popover. Do not use React events because it
  20346. * will bubble through portals.
  20347. *
  20348. * @param {Object} scrollableRef
  20349. */
  20350. function usePopoverScroll(scrollableRef) {
  20351. return Object(external_wp_compose_["useRefEffect"])(node => {
  20352. if (!scrollableRef) {
  20353. return;
  20354. }
  20355. function onWheel(event) {
  20356. const {
  20357. deltaX,
  20358. deltaY
  20359. } = event;
  20360. scrollableRef.current.scrollBy(deltaX, deltaY);
  20361. }
  20362. node.addEventListener('wheel', onWheel);
  20363. return () => {
  20364. node.removeEventListener('wheel', onWheel);
  20365. };
  20366. }, [scrollableRef]);
  20367. }
  20368. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/insertion-point.js
  20369. /**
  20370. * External dependencies
  20371. */
  20372. /**
  20373. * WordPress dependencies
  20374. */
  20375. /**
  20376. * Internal dependencies
  20377. */
  20378. const InsertionPointOpenRef = Object(external_wp_element_["createContext"])();
  20379. function InsertionPointPopover({
  20380. __unstablePopoverSlot,
  20381. __unstableContentRef
  20382. }) {
  20383. const {
  20384. selectBlock
  20385. } = Object(external_wp_data_["useDispatch"])(store);
  20386. const openRef = Object(external_wp_element_["useContext"])(InsertionPointOpenRef);
  20387. const ref = Object(external_wp_element_["useRef"])();
  20388. const {
  20389. orientation,
  20390. previousClientId,
  20391. nextClientId,
  20392. rootClientId,
  20393. isInserterShown
  20394. } = Object(external_wp_data_["useSelect"])(select => {
  20395. var _getBlockListSettings;
  20396. const {
  20397. getBlockOrder,
  20398. getBlockListSettings,
  20399. getBlockInsertionPoint,
  20400. isBlockBeingDragged,
  20401. getPreviousBlockClientId,
  20402. getNextBlockClientId
  20403. } = select(store);
  20404. const insertionPoint = getBlockInsertionPoint();
  20405. const order = getBlockOrder(insertionPoint.rootClientId);
  20406. if (!order.length) {
  20407. return {};
  20408. }
  20409. let _previousClientId = order[insertionPoint.index - 1];
  20410. let _nextClientId = order[insertionPoint.index];
  20411. while (isBlockBeingDragged(_previousClientId)) {
  20412. _previousClientId = getPreviousBlockClientId(_previousClientId);
  20413. }
  20414. while (isBlockBeingDragged(_nextClientId)) {
  20415. _nextClientId = getNextBlockClientId(_nextClientId);
  20416. }
  20417. return {
  20418. previousClientId: _previousClientId,
  20419. nextClientId: _nextClientId,
  20420. orientation: ((_getBlockListSettings = getBlockListSettings(insertionPoint.rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation) || 'vertical',
  20421. rootClientId: insertionPoint.rootClientId,
  20422. isInserterShown: insertionPoint === null || insertionPoint === void 0 ? void 0 : insertionPoint.__unstableWithInserter
  20423. };
  20424. }, []);
  20425. const previousElement = useBlockElement(previousClientId);
  20426. const nextElement = useBlockElement(nextClientId);
  20427. const style = Object(external_wp_element_["useMemo"])(() => {
  20428. if (!previousElement && !nextElement) {
  20429. return {};
  20430. }
  20431. const previousRect = previousElement ? previousElement.getBoundingClientRect() : null;
  20432. const nextRect = nextElement ? nextElement.getBoundingClientRect() : null;
  20433. if (orientation === 'vertical') {
  20434. return {
  20435. width: previousElement ? previousElement.offsetWidth : nextElement.offsetWidth,
  20436. height: nextRect && previousRect ? nextRect.top - previousRect.bottom : 0
  20437. };
  20438. }
  20439. let width = 0;
  20440. if (previousRect && nextRect) {
  20441. width = Object(external_wp_i18n_["isRTL"])() ? previousRect.left - nextRect.right : nextRect.left - previousRect.right;
  20442. }
  20443. return {
  20444. width,
  20445. height: previousElement ? previousElement.offsetHeight : nextElement.offsetHeight
  20446. };
  20447. }, [previousElement, nextElement]);
  20448. const getAnchorRect = Object(external_wp_element_["useCallback"])(() => {
  20449. if (!previousElement && !nextElement) {
  20450. return {};
  20451. }
  20452. const {
  20453. ownerDocument
  20454. } = previousElement || nextElement;
  20455. const previousRect = previousElement ? previousElement.getBoundingClientRect() : null;
  20456. const nextRect = nextElement ? nextElement.getBoundingClientRect() : null;
  20457. if (orientation === 'vertical') {
  20458. if (Object(external_wp_i18n_["isRTL"])()) {
  20459. return {
  20460. top: previousRect ? previousRect.bottom : nextRect.top,
  20461. left: previousRect ? previousRect.right : nextRect.right,
  20462. right: previousRect ? previousRect.left : nextRect.left,
  20463. bottom: nextRect ? nextRect.top : previousRect.bottom,
  20464. ownerDocument
  20465. };
  20466. }
  20467. return {
  20468. top: previousRect ? previousRect.bottom : nextRect.top,
  20469. left: previousRect ? previousRect.left : nextRect.left,
  20470. right: previousRect ? previousRect.right : nextRect.right,
  20471. bottom: nextRect ? nextRect.top : previousRect.bottom,
  20472. ownerDocument
  20473. };
  20474. }
  20475. if (Object(external_wp_i18n_["isRTL"])()) {
  20476. return {
  20477. top: previousRect ? previousRect.top : nextRect.top,
  20478. left: previousRect ? previousRect.left : nextRect.right,
  20479. right: nextRect ? nextRect.right : previousRect.left,
  20480. bottom: previousRect ? previousRect.bottom : nextRect.bottom,
  20481. ownerDocument
  20482. };
  20483. }
  20484. return {
  20485. top: previousRect ? previousRect.top : nextRect.top,
  20486. left: previousRect ? previousRect.right : nextRect.left,
  20487. right: nextRect ? nextRect.left : previousRect.right,
  20488. bottom: previousRect ? previousRect.bottom : nextRect.bottom,
  20489. ownerDocument
  20490. };
  20491. }, [previousElement, nextElement]);
  20492. const popoverScrollRef = usePopoverScroll(__unstableContentRef);
  20493. const className = classnames_default()('block-editor-block-list__insertion-point', 'is-' + orientation);
  20494. function onClick(event) {
  20495. if (event.target === ref.current && nextClientId) {
  20496. selectBlock(nextClientId, -1);
  20497. }
  20498. }
  20499. function onFocus(event) {
  20500. // Only handle click on the wrapper specifically, and not an event
  20501. // bubbled from the inserter itself.
  20502. if (event.target !== ref.current) {
  20503. openRef.current = true;
  20504. }
  20505. } // Only show the in-between inserter between blocks, so when there's a
  20506. // previous and a next element.
  20507. const showInsertionPointInserter = previousElement && nextElement && isInserterShown;
  20508. /* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
  20509. // While ideally it would be enough to capture the
  20510. // bubbling focus event from the Inserter, due to the
  20511. // characteristics of click focusing of `button`s in
  20512. // Firefox and Safari, it is not reliable.
  20513. //
  20514. // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
  20515. return Object(external_wp_element_["createElement"])(external_wp_components_["Popover"], {
  20516. ref: popoverScrollRef,
  20517. noArrow: true,
  20518. animate: false,
  20519. getAnchorRect: getAnchorRect,
  20520. focusOnMount: false,
  20521. className: "block-editor-block-list__insertion-point-popover" // Render in the old slot if needed for backward compatibility,
  20522. // otherwise render in place (not in the the default popover slot).
  20523. ,
  20524. __unstableSlotName: __unstablePopoverSlot || null
  20525. }, Object(external_wp_element_["createElement"])("div", {
  20526. ref: ref,
  20527. tabIndex: -1,
  20528. onClick: onClick,
  20529. onFocus: onFocus,
  20530. className: classnames_default()(className, {
  20531. 'is-with-inserter': showInsertionPointInserter
  20532. }),
  20533. style: style
  20534. }, Object(external_wp_element_["createElement"])("div", {
  20535. className: "block-editor-block-list__insertion-point-indicator"
  20536. }), showInsertionPointInserter && Object(external_wp_element_["createElement"])("div", {
  20537. className: classnames_default()('block-editor-block-list__insertion-point-inserter')
  20538. }, Object(external_wp_element_["createElement"])(inserter, {
  20539. position: "bottom center",
  20540. clientId: nextClientId,
  20541. rootClientId: rootClientId,
  20542. __experimentalIsQuick: true,
  20543. onToggle: isOpen => {
  20544. openRef.current = isOpen;
  20545. },
  20546. onSelectOrClose: () => {
  20547. openRef.current = false;
  20548. }
  20549. }))));
  20550. /* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
  20551. }
  20552. function InsertionPoint({
  20553. children,
  20554. __unstablePopoverSlot,
  20555. __unstableContentRef
  20556. }) {
  20557. const isVisible = Object(external_wp_data_["useSelect"])(select => {
  20558. return select(store).isBlockInsertionPointVisible();
  20559. }, []);
  20560. return Object(external_wp_element_["createElement"])(InsertionPointOpenRef.Provider, {
  20561. value: Object(external_wp_element_["useRef"])(false)
  20562. }, isVisible && Object(external_wp_element_["createElement"])(InsertionPointPopover, {
  20563. __unstablePopoverSlot: __unstablePopoverSlot,
  20564. __unstableContentRef: __unstableContentRef
  20565. }), children);
  20566. }
  20567. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-in-between-inserter.js
  20568. /**
  20569. * WordPress dependencies
  20570. */
  20571. /**
  20572. * Internal dependencies
  20573. */
  20574. function useInBetweenInserter() {
  20575. const openRef = Object(external_wp_element_["useContext"])(InsertionPointOpenRef);
  20576. const hasReducedUI = Object(external_wp_data_["useSelect"])(select => select(store).getSettings().hasReducedUI, []);
  20577. const {
  20578. getBlockListSettings,
  20579. getBlockRootClientId,
  20580. getBlockIndex,
  20581. isBlockInsertionPointVisible,
  20582. isMultiSelecting,
  20583. getSelectedBlockClientIds,
  20584. getTemplateLock
  20585. } = Object(external_wp_data_["useSelect"])(store);
  20586. const {
  20587. showInsertionPoint,
  20588. hideInsertionPoint
  20589. } = Object(external_wp_data_["useDispatch"])(store);
  20590. return Object(external_wp_compose_["useRefEffect"])(node => {
  20591. if (hasReducedUI) {
  20592. return;
  20593. }
  20594. function onMouseMove(event) {
  20595. var _getBlockListSettings;
  20596. if (openRef.current) {
  20597. return;
  20598. }
  20599. if (isMultiSelecting()) {
  20600. return;
  20601. }
  20602. if (!event.target.classList.contains('block-editor-block-list__layout')) {
  20603. if (isBlockInsertionPointVisible()) {
  20604. hideInsertionPoint();
  20605. }
  20606. return;
  20607. }
  20608. let rootClientId;
  20609. if (!event.target.classList.contains('is-root-container')) {
  20610. const blockElement = !!event.target.getAttribute('data-block') ? event.target : event.target.closest('[data-block]');
  20611. rootClientId = blockElement.getAttribute('data-block');
  20612. } // Don't set the insertion point if the template is locked.
  20613. if (getTemplateLock(rootClientId)) {
  20614. return;
  20615. }
  20616. const orientation = ((_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation) || 'vertical';
  20617. const rect = event.target.getBoundingClientRect();
  20618. const offsetTop = event.clientY - rect.top;
  20619. const offsetLeft = event.clientX - rect.left;
  20620. const children = Array.from(event.target.children);
  20621. let element = children.find(blockEl => {
  20622. return blockEl.classList.contains('wp-block') && orientation === 'vertical' && blockEl.offsetTop > offsetTop || blockEl.classList.contains('wp-block') && orientation === 'horizontal' && blockEl.offsetLeft > offsetLeft;
  20623. });
  20624. if (!element) {
  20625. return;
  20626. } // The block may be in an alignment wrapper, so check the first direct
  20627. // child if the element has no ID.
  20628. if (!element.id) {
  20629. element = element.firstElementChild;
  20630. if (!element) {
  20631. return;
  20632. }
  20633. }
  20634. const clientId = element.id.slice('block-'.length);
  20635. if (!clientId) {
  20636. return;
  20637. } // Don't show the inserter when hovering above (conflicts with
  20638. // block toolbar) or inside selected block(s).
  20639. if (getSelectedBlockClientIds().includes(clientId)) {
  20640. return;
  20641. }
  20642. const elementRect = element.getBoundingClientRect();
  20643. if (orientation === 'horizontal' && (event.clientY > elementRect.bottom || event.clientY < elementRect.top) || orientation === 'vertical' && (event.clientX > elementRect.right || event.clientX < elementRect.left)) {
  20644. if (isBlockInsertionPointVisible()) {
  20645. hideInsertionPoint();
  20646. }
  20647. return;
  20648. }
  20649. const index = getBlockIndex(clientId, rootClientId); // Don't show the in-between inserter before the first block in
  20650. // the list (preserves the original behaviour).
  20651. if (index === 0) {
  20652. if (isBlockInsertionPointVisible()) {
  20653. hideInsertionPoint();
  20654. }
  20655. return;
  20656. }
  20657. showInsertionPoint(rootClientId, index, {
  20658. __unstableWithInserter: true
  20659. });
  20660. }
  20661. node.addEventListener('mousemove', onMouseMove);
  20662. return () => {
  20663. node.removeEventListener('mousemove', onMouseMove);
  20664. };
  20665. }, [openRef, getBlockListSettings, getBlockRootClientId, getBlockIndex, isBlockInsertionPointVisible, isMultiSelecting, showInsertionPoint, hideInsertionPoint, getSelectedBlockClientIds]);
  20666. }
  20667. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/pre-parse-patterns.js
  20668. /**
  20669. * WordPress dependencies
  20670. */
  20671. /**
  20672. * Internal dependencies
  20673. */
  20674. const pre_parse_patterns_requestIdleCallback = (() => {
  20675. if (typeof window === 'undefined') {
  20676. return callback => {
  20677. setTimeout(() => callback(Date.now()), 0);
  20678. };
  20679. }
  20680. return window.requestIdleCallback || window.requestAnimationFrame;
  20681. })();
  20682. const cancelIdleCallback = (() => {
  20683. if (typeof window === 'undefined') {
  20684. return clearTimeout;
  20685. }
  20686. return window.cancelIdleCallback || window.cancelAnimationFrame;
  20687. })();
  20688. function usePreParsePatterns() {
  20689. const patterns = Object(external_wp_data_["useSelect"])(_select => _select(store).getSettings().__experimentalBlockPatterns, []);
  20690. Object(external_wp_element_["useEffect"])(() => {
  20691. if (!(patterns !== null && patterns !== void 0 && patterns.length)) {
  20692. return;
  20693. }
  20694. let handle;
  20695. let index = -1;
  20696. const callback = () => {
  20697. index++;
  20698. if (index >= patterns.length) {
  20699. return;
  20700. }
  20701. Object(external_wp_data_["select"])(store).__experimentalGetParsedPattern(patterns[index].name);
  20702. handle = pre_parse_patterns_requestIdleCallback(callback);
  20703. };
  20704. handle = pre_parse_patterns_requestIdleCallback(callback);
  20705. return () => cancelIdleCallback(handle);
  20706. }, [patterns]);
  20707. return null;
  20708. }
  20709. // EXTERNAL MODULE: external ["wp","keyboardShortcuts"]
  20710. var external_wp_keyboardShortcuts_ = __webpack_require__("hF7m");
  20711. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-draggable/use-scroll-when-dragging.js
  20712. /**
  20713. * WordPress dependencies
  20714. */
  20715. const SCROLL_INACTIVE_DISTANCE_PX = 50;
  20716. const SCROLL_INTERVAL_MS = 25;
  20717. const PIXELS_PER_SECOND_PER_PERCENTAGE = 1000;
  20718. const VELOCITY_MULTIPLIER = PIXELS_PER_SECOND_PER_PERCENTAGE * (SCROLL_INTERVAL_MS / 1000);
  20719. /**
  20720. * React hook that scrolls the scroll container when a block is being dragged.
  20721. *
  20722. * @return {Function[]} `startScrolling`, `scrollOnDragOver`, `stopScrolling`
  20723. * functions to be called in `onDragStart`, `onDragOver`
  20724. * and `onDragEnd` events respectively.
  20725. */
  20726. function useScrollWhenDragging() {
  20727. const dragStartY = Object(external_wp_element_["useRef"])(null);
  20728. const velocityY = Object(external_wp_element_["useRef"])(null);
  20729. const scrollParentY = Object(external_wp_element_["useRef"])(null);
  20730. const scrollEditorInterval = Object(external_wp_element_["useRef"])(null); // Clear interval when unmounting.
  20731. Object(external_wp_element_["useEffect"])(() => () => {
  20732. if (scrollEditorInterval.current) {
  20733. clearInterval(scrollEditorInterval.current);
  20734. scrollEditorInterval.current = null;
  20735. }
  20736. }, []);
  20737. const startScrolling = Object(external_wp_element_["useCallback"])(event => {
  20738. dragStartY.current = event.clientY; // Find nearest parent(s) to scroll.
  20739. scrollParentY.current = Object(external_wp_dom_["getScrollContainer"])(event.target);
  20740. scrollEditorInterval.current = setInterval(() => {
  20741. if (scrollParentY.current && velocityY.current) {
  20742. const newTop = scrollParentY.current.scrollTop + velocityY.current; // Setting `behavior: 'smooth'` as a scroll property seems to hurt performance.
  20743. // Better to use a small scroll interval.
  20744. scrollParentY.current.scroll({
  20745. top: newTop
  20746. });
  20747. }
  20748. }, SCROLL_INTERVAL_MS);
  20749. }, []);
  20750. const scrollOnDragOver = Object(external_wp_element_["useCallback"])(event => {
  20751. if (!scrollParentY.current) {
  20752. return;
  20753. }
  20754. const scrollParentHeight = scrollParentY.current.offsetHeight;
  20755. const offsetDragStartPosition = dragStartY.current - scrollParentY.current.offsetTop;
  20756. const offsetDragPosition = event.clientY - scrollParentY.current.offsetTop;
  20757. if (event.clientY > offsetDragStartPosition) {
  20758. // User is dragging downwards.
  20759. const moveableDistance = Math.max(scrollParentHeight - offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
  20760. const dragDistance = Math.max(offsetDragPosition - offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
  20761. const distancePercentage = dragDistance / moveableDistance;
  20762. velocityY.current = VELOCITY_MULTIPLIER * distancePercentage;
  20763. } else if (event.clientY < offsetDragStartPosition) {
  20764. // User is dragging upwards.
  20765. const moveableDistance = Math.max(offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
  20766. const dragDistance = Math.max(offsetDragStartPosition - offsetDragPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
  20767. const distancePercentage = dragDistance / moveableDistance;
  20768. velocityY.current = -VELOCITY_MULTIPLIER * distancePercentage;
  20769. } else {
  20770. velocityY.current = 0;
  20771. }
  20772. }, []);
  20773. const stopScrolling = () => {
  20774. dragStartY.current = null;
  20775. scrollParentY.current = null;
  20776. if (scrollEditorInterval.current) {
  20777. clearInterval(scrollEditorInterval.current);
  20778. scrollEditorInterval.current = null;
  20779. }
  20780. };
  20781. return [startScrolling, scrollOnDragOver, stopScrolling];
  20782. }
  20783. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-draggable/index.js
  20784. /**
  20785. * WordPress dependencies
  20786. */
  20787. /**
  20788. * Internal dependencies
  20789. */
  20790. const BlockDraggable = ({
  20791. children,
  20792. clientIds,
  20793. cloneClassname,
  20794. onDragStart,
  20795. onDragEnd,
  20796. elementId
  20797. }) => {
  20798. const {
  20799. srcRootClientId,
  20800. isDraggable,
  20801. icon
  20802. } = Object(external_wp_data_["useSelect"])(select => {
  20803. var _getBlockType;
  20804. const {
  20805. getBlockRootClientId,
  20806. getTemplateLock,
  20807. getBlockName
  20808. } = select(store);
  20809. const rootClientId = getBlockRootClientId(clientIds[0]);
  20810. const templateLock = rootClientId ? getTemplateLock(rootClientId) : null;
  20811. const blockName = getBlockName(clientIds[0]);
  20812. return {
  20813. srcRootClientId: rootClientId,
  20814. isDraggable: 'all' !== templateLock,
  20815. icon: (_getBlockType = Object(external_wp_blocks_["getBlockType"])(blockName)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.icon
  20816. };
  20817. }, [clientIds]);
  20818. const isDragging = Object(external_wp_element_["useRef"])(false);
  20819. const [startScrolling, scrollOnDragOver, stopScrolling] = useScrollWhenDragging();
  20820. const {
  20821. startDraggingBlocks,
  20822. stopDraggingBlocks
  20823. } = Object(external_wp_data_["useDispatch"])(store); // Stop dragging blocks if the block draggable is unmounted
  20824. Object(external_wp_element_["useEffect"])(() => {
  20825. return () => {
  20826. if (isDragging.current) {
  20827. stopDraggingBlocks();
  20828. }
  20829. };
  20830. }, []);
  20831. if (!isDraggable) {
  20832. return children({
  20833. isDraggable: false
  20834. });
  20835. }
  20836. const transferData = {
  20837. type: 'block',
  20838. srcClientIds: clientIds,
  20839. srcRootClientId
  20840. };
  20841. return Object(external_wp_element_["createElement"])(external_wp_components_["Draggable"], {
  20842. cloneClassname: cloneClassname,
  20843. elementId: elementId,
  20844. __experimentalTransferDataType: "wp-blocks",
  20845. transferData: transferData,
  20846. onDragStart: event => {
  20847. startDraggingBlocks(clientIds);
  20848. isDragging.current = true;
  20849. startScrolling(event);
  20850. if (onDragStart) {
  20851. onDragStart();
  20852. }
  20853. },
  20854. onDragOver: scrollOnDragOver,
  20855. onDragEnd: () => {
  20856. stopDraggingBlocks();
  20857. isDragging.current = false;
  20858. stopScrolling();
  20859. if (onDragEnd) {
  20860. onDragEnd();
  20861. }
  20862. },
  20863. __experimentalDragComponent: Object(external_wp_element_["createElement"])(BlockDraggableChip, {
  20864. count: clientIds.length,
  20865. icon: icon
  20866. })
  20867. }, ({
  20868. onDraggableStart,
  20869. onDraggableEnd
  20870. }) => {
  20871. return children({
  20872. draggable: true,
  20873. onDragStart: onDraggableStart,
  20874. onDragEnd: onDraggableEnd
  20875. });
  20876. });
  20877. };
  20878. /* harmony default export */ var block_draggable = (BlockDraggable);
  20879. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/block-selection-button.js
  20880. /**
  20881. * External dependencies
  20882. */
  20883. /**
  20884. * WordPress dependencies
  20885. */
  20886. /**
  20887. * Internal dependencies
  20888. */
  20889. /**
  20890. * Returns true if the user is using windows.
  20891. *
  20892. * @return {boolean} Whether the user is using Windows.
  20893. */
  20894. function isWindows() {
  20895. return window.navigator.platform.indexOf('Win') > -1;
  20896. }
  20897. /**
  20898. * Block selection button component, displaying the label of the block. If the block
  20899. * descends from a root block, a button is displayed enabling the user to select
  20900. * the root block.
  20901. *
  20902. * @param {string} props Component props.
  20903. * @param {string} props.clientId Client ID of block.
  20904. *
  20905. * @return {WPComponent} The component to be rendered.
  20906. */
  20907. function BlockSelectionButton({
  20908. clientId,
  20909. rootClientId,
  20910. blockElement
  20911. }) {
  20912. const blockInformation = useBlockDisplayInformation(clientId);
  20913. const selected = Object(external_wp_data_["useSelect"])(select => {
  20914. var _getBlockListSettings;
  20915. const {
  20916. __unstableGetBlockWithoutInnerBlocks,
  20917. getBlockIndex,
  20918. hasBlockMovingClientId,
  20919. getBlockListSettings
  20920. } = select(store);
  20921. const index = getBlockIndex(clientId, rootClientId);
  20922. const {
  20923. name,
  20924. attributes
  20925. } = __unstableGetBlockWithoutInnerBlocks(clientId);
  20926. const blockMovingMode = hasBlockMovingClientId();
  20927. return {
  20928. index,
  20929. name,
  20930. attributes,
  20931. blockMovingMode,
  20932. orientation: (_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation
  20933. };
  20934. }, [clientId, rootClientId]);
  20935. const {
  20936. index,
  20937. name,
  20938. attributes,
  20939. blockMovingMode,
  20940. orientation
  20941. } = selected;
  20942. const {
  20943. setNavigationMode,
  20944. removeBlock
  20945. } = Object(external_wp_data_["useDispatch"])(store);
  20946. const ref = Object(external_wp_element_["useRef"])(); // Focus the breadcrumb in navigation mode.
  20947. Object(external_wp_element_["useEffect"])(() => {
  20948. ref.current.focus(); // NVDA on windows suffers from a bug where focus changes are not announced properly
  20949. // See WordPress/gutenberg#24121 and nvaccess/nvda#5825 for more details
  20950. // To solve it we announce the focus change manually.
  20951. if (isWindows()) {
  20952. Object(external_wp_a11y_["speak"])(label);
  20953. }
  20954. }, []);
  20955. const {
  20956. hasBlockMovingClientId,
  20957. getBlockIndex,
  20958. getBlockRootClientId,
  20959. getClientIdsOfDescendants,
  20960. getSelectedBlockClientId,
  20961. getMultiSelectedBlocksEndClientId,
  20962. getPreviousBlockClientId,
  20963. getNextBlockClientId
  20964. } = Object(external_wp_data_["useSelect"])(store);
  20965. const {
  20966. selectBlock,
  20967. clearSelectedBlock,
  20968. setBlockMovingClientId,
  20969. moveBlockToPosition
  20970. } = Object(external_wp_data_["useDispatch"])(store);
  20971. function onKeyDown(event) {
  20972. const {
  20973. keyCode
  20974. } = event;
  20975. const isUp = keyCode === external_wp_keycodes_["UP"];
  20976. const isDown = keyCode === external_wp_keycodes_["DOWN"];
  20977. const isLeft = keyCode === external_wp_keycodes_["LEFT"];
  20978. const isRight = keyCode === external_wp_keycodes_["RIGHT"];
  20979. const isTab = keyCode === external_wp_keycodes_["TAB"];
  20980. const isEscape = keyCode === external_wp_keycodes_["ESCAPE"];
  20981. const isEnter = keyCode === external_wp_keycodes_["ENTER"];
  20982. const isSpace = keyCode === external_wp_keycodes_["SPACE"];
  20983. const isShift = event.shiftKey;
  20984. if (keyCode === external_wp_keycodes_["BACKSPACE"] || keyCode === external_wp_keycodes_["DELETE"]) {
  20985. removeBlock(clientId);
  20986. event.preventDefault();
  20987. return;
  20988. }
  20989. const selectedBlockClientId = getSelectedBlockClientId();
  20990. const selectionEndClientId = getMultiSelectedBlocksEndClientId();
  20991. const selectionBeforeEndClientId = getPreviousBlockClientId(selectionEndClientId || selectedBlockClientId);
  20992. const selectionAfterEndClientId = getNextBlockClientId(selectionEndClientId || selectedBlockClientId);
  20993. const navigateUp = isTab && isShift || isUp;
  20994. const navigateDown = isTab && !isShift || isDown; // Move out of current nesting level (no effect if at root level).
  20995. const navigateOut = isLeft; // Move into next nesting level (no effect if the current block has no innerBlocks).
  20996. const navigateIn = isRight;
  20997. let focusedBlockUid;
  20998. if (navigateUp) {
  20999. focusedBlockUid = selectionBeforeEndClientId;
  21000. } else if (navigateDown) {
  21001. focusedBlockUid = selectionAfterEndClientId;
  21002. } else if (navigateOut) {
  21003. var _getBlockRootClientId;
  21004. focusedBlockUid = (_getBlockRootClientId = getBlockRootClientId(selectedBlockClientId)) !== null && _getBlockRootClientId !== void 0 ? _getBlockRootClientId : selectedBlockClientId;
  21005. } else if (navigateIn) {
  21006. var _getClientIdsOfDescen;
  21007. focusedBlockUid = (_getClientIdsOfDescen = getClientIdsOfDescendants([selectedBlockClientId])[0]) !== null && _getClientIdsOfDescen !== void 0 ? _getClientIdsOfDescen : selectedBlockClientId;
  21008. }
  21009. const startingBlockClientId = hasBlockMovingClientId();
  21010. if (isEscape && startingBlockClientId) {
  21011. setBlockMovingClientId(null);
  21012. }
  21013. if ((isEnter || isSpace) && startingBlockClientId) {
  21014. const sourceRoot = getBlockRootClientId(startingBlockClientId);
  21015. const destRoot = getBlockRootClientId(selectedBlockClientId);
  21016. const sourceBlockIndex = getBlockIndex(startingBlockClientId, sourceRoot);
  21017. let destinationBlockIndex = getBlockIndex(selectedBlockClientId, destRoot);
  21018. if (sourceBlockIndex < destinationBlockIndex && sourceRoot === destRoot) {
  21019. destinationBlockIndex -= 1;
  21020. }
  21021. moveBlockToPosition(startingBlockClientId, sourceRoot, destRoot, destinationBlockIndex);
  21022. selectBlock(startingBlockClientId);
  21023. setBlockMovingClientId(null);
  21024. }
  21025. if (navigateDown || navigateUp || navigateOut || navigateIn) {
  21026. if (focusedBlockUid) {
  21027. event.preventDefault();
  21028. selectBlock(focusedBlockUid);
  21029. } else if (isTab && selectedBlockClientId) {
  21030. let nextTabbable;
  21031. if (navigateDown) {
  21032. nextTabbable = external_wp_dom_["focus"].tabbable.findNext(blockElement);
  21033. if (!nextTabbable) {
  21034. nextTabbable = blockElement.ownerDocument.defaultView.frameElement;
  21035. nextTabbable = external_wp_dom_["focus"].tabbable.findNext(nextTabbable);
  21036. }
  21037. } else {
  21038. nextTabbable = external_wp_dom_["focus"].tabbable.findPrevious(blockElement);
  21039. }
  21040. if (nextTabbable) {
  21041. event.preventDefault();
  21042. nextTabbable.focus();
  21043. clearSelectedBlock();
  21044. }
  21045. }
  21046. }
  21047. }
  21048. const blockType = Object(external_wp_blocks_["getBlockType"])(name);
  21049. const label = Object(external_wp_blocks_["__experimentalGetAccessibleBlockLabel"])(blockType, attributes, index + 1, orientation);
  21050. const classNames = classnames_default()('block-editor-block-list__block-selection-button', {
  21051. 'is-block-moving-mode': !!blockMovingMode
  21052. });
  21053. const dragHandleLabel = Object(external_wp_i18n_["__"])('Drag');
  21054. return Object(external_wp_element_["createElement"])("div", {
  21055. className: classNames
  21056. }, Object(external_wp_element_["createElement"])(external_wp_components_["Flex"], {
  21057. justify: "center",
  21058. className: "block-editor-block-list__block-selection-button__content"
  21059. }, Object(external_wp_element_["createElement"])(external_wp_components_["FlexItem"], null, Object(external_wp_element_["createElement"])(BlockIcon, {
  21060. icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon,
  21061. showColors: true
  21062. })), Object(external_wp_element_["createElement"])(external_wp_components_["FlexItem"], null, Object(external_wp_element_["createElement"])(block_draggable, {
  21063. clientIds: [clientId]
  21064. }, draggableProps => Object(external_wp_element_["createElement"])(external_wp_components_["Button"], Object(esm_extends["a" /* default */])({
  21065. icon: drag_handle,
  21066. className: "block-selection-button_drag-handle",
  21067. "aria-hidden": "true",
  21068. label: dragHandleLabel // Should not be able to tab to drag handle as this
  21069. // button can only be used with a pointer device.
  21070. ,
  21071. tabIndex: "-1"
  21072. }, draggableProps)))), Object(external_wp_element_["createElement"])(external_wp_components_["FlexItem"], null, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  21073. ref: ref,
  21074. onClick: () => setNavigationMode(false),
  21075. onKeyDown: onKeyDown,
  21076. label: label,
  21077. className: "block-selection-button_select-button"
  21078. }, Object(external_wp_element_["createElement"])(BlockTitle, {
  21079. clientId: clientId
  21080. })))));
  21081. }
  21082. /* harmony default export */ var block_selection_button = (BlockSelectionButton);
  21083. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/navigable-toolbar/index.js
  21084. /**
  21085. * WordPress dependencies
  21086. */
  21087. function hasOnlyToolbarItem(elements) {
  21088. const dataProp = 'toolbarItem';
  21089. return !elements.some(element => !(dataProp in element.dataset));
  21090. }
  21091. function getAllToolbarItemsIn(container) {
  21092. return Array.from(container.querySelectorAll('[data-toolbar-item]'));
  21093. }
  21094. function hasFocusWithin(container) {
  21095. return container.contains(container.ownerDocument.activeElement);
  21096. }
  21097. function focusFirstTabbableIn(container) {
  21098. const [firstTabbable] = external_wp_dom_["focus"].tabbable.find(container);
  21099. if (firstTabbable) {
  21100. firstTabbable.focus();
  21101. }
  21102. }
  21103. function useIsAccessibleToolbar(ref) {
  21104. /*
  21105. * By default, we'll assume the starting accessible state of the Toolbar
  21106. * is true, as it seems to be the most common case.
  21107. *
  21108. * Transitioning from an (initial) false to true state causes the
  21109. * <Toolbar /> component to mount twice, which is causing undesired
  21110. * side-effects. These side-effects appear to only affect certain
  21111. * E2E tests.
  21112. *
  21113. * This was initial discovered in this pull-request:
  21114. * https://github.com/WordPress/gutenberg/pull/23425
  21115. */
  21116. const initialAccessibleToolbarState = true; // By default, it's gonna render NavigableMenu. If all the tabbable elements
  21117. // inside the toolbar are ToolbarItem components (or derived components like
  21118. // ToolbarButton), then we can wrap them with the accessible Toolbar
  21119. // component.
  21120. const [isAccessibleToolbar, setIsAccessibleToolbar] = Object(external_wp_element_["useState"])(initialAccessibleToolbarState);
  21121. const determineIsAccessibleToolbar = Object(external_wp_element_["useCallback"])(() => {
  21122. const tabbables = external_wp_dom_["focus"].tabbable.find(ref.current);
  21123. const onlyToolbarItem = hasOnlyToolbarItem(tabbables);
  21124. if (!onlyToolbarItem) {
  21125. external_wp_deprecated_default()('Using custom components as toolbar controls', {
  21126. since: '5.6',
  21127. alternative: 'ToolbarItem, ToolbarButton or ToolbarDropdownMenu components',
  21128. link: 'https://developer.wordpress.org/block-editor/components/toolbar-button/#inside-blockcontrols'
  21129. });
  21130. }
  21131. setIsAccessibleToolbar(onlyToolbarItem);
  21132. }, []);
  21133. Object(external_wp_element_["useLayoutEffect"])(() => {
  21134. // Toolbar buttons may be rendered asynchronously, so we use
  21135. // MutationObserver to check if the toolbar subtree has been modified
  21136. const observer = new window.MutationObserver(determineIsAccessibleToolbar);
  21137. observer.observe(ref.current, {
  21138. childList: true,
  21139. subtree: true
  21140. });
  21141. return () => observer.disconnect();
  21142. }, [isAccessibleToolbar]);
  21143. return isAccessibleToolbar;
  21144. }
  21145. function useToolbarFocus(ref, focusOnMount, isAccessibleToolbar, defaultIndex, onIndexChange) {
  21146. // Make sure we don't use modified versions of this prop
  21147. const [initialFocusOnMount] = Object(external_wp_element_["useState"])(focusOnMount);
  21148. const [initialIndex] = Object(external_wp_element_["useState"])(defaultIndex);
  21149. const focusToolbar = Object(external_wp_element_["useCallback"])(() => {
  21150. focusFirstTabbableIn(ref.current);
  21151. }, []); // Focus on toolbar when pressing alt+F10 when the toolbar is visible
  21152. Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/focus-toolbar', focusToolbar, {
  21153. bindGlobal: true,
  21154. eventName: 'keydown'
  21155. });
  21156. Object(external_wp_element_["useEffect"])(() => {
  21157. if (initialFocusOnMount) {
  21158. focusToolbar();
  21159. }
  21160. }, [isAccessibleToolbar, initialFocusOnMount, focusToolbar]);
  21161. Object(external_wp_element_["useEffect"])(() => {
  21162. // If initialIndex is passed, we focus on that toolbar item when the
  21163. // toolbar gets mounted and initial focus is not forced.
  21164. // We have to wait for the next browser paint because block controls aren't
  21165. // rendered right away when the toolbar gets mounted.
  21166. let raf = 0;
  21167. if (initialIndex && !initialFocusOnMount) {
  21168. raf = window.requestAnimationFrame(() => {
  21169. const items = getAllToolbarItemsIn(ref.current);
  21170. const index = initialIndex || 0;
  21171. if (items[index] && hasFocusWithin(ref.current)) {
  21172. items[index].focus();
  21173. }
  21174. });
  21175. }
  21176. return () => {
  21177. window.cancelAnimationFrame(raf);
  21178. if (!onIndexChange) return; // When the toolbar element is unmounted and onIndexChange is passed, we
  21179. // pass the focused toolbar item index so it can be hydrated later.
  21180. const items = getAllToolbarItemsIn(ref.current);
  21181. const index = items.findIndex(item => item.tabIndex === 0);
  21182. onIndexChange(index);
  21183. };
  21184. }, [initialIndex, initialFocusOnMount]);
  21185. }
  21186. function NavigableToolbar({
  21187. children,
  21188. focusOnMount,
  21189. __experimentalInitialIndex: initialIndex,
  21190. __experimentalOnIndexChange: onIndexChange,
  21191. ...props
  21192. }) {
  21193. const ref = Object(external_wp_element_["useRef"])();
  21194. const isAccessibleToolbar = useIsAccessibleToolbar(ref);
  21195. useToolbarFocus(ref, focusOnMount, isAccessibleToolbar, initialIndex, onIndexChange);
  21196. if (isAccessibleToolbar) {
  21197. return Object(external_wp_element_["createElement"])(external_wp_components_["Toolbar"], Object(esm_extends["a" /* default */])({
  21198. label: props['aria-label'],
  21199. ref: ref
  21200. }, props), children);
  21201. }
  21202. return Object(external_wp_element_["createElement"])(external_wp_components_["NavigableMenu"], Object(esm_extends["a" /* default */])({
  21203. orientation: "horizontal",
  21204. role: "toolbar",
  21205. ref: ref
  21206. }, props), children);
  21207. }
  21208. /* harmony default export */ var navigable_toolbar = (NavigableToolbar);
  21209. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-mover/index.js
  21210. /**
  21211. * External dependencies
  21212. */
  21213. /**
  21214. * WordPress dependencies
  21215. */
  21216. /**
  21217. * Internal dependencies
  21218. */
  21219. function BlockMover({
  21220. isFirst,
  21221. isLast,
  21222. clientIds,
  21223. isLocked,
  21224. isHidden,
  21225. rootClientId,
  21226. orientation,
  21227. hideDragHandle
  21228. }) {
  21229. const [isFocused, setIsFocused] = Object(external_wp_element_["useState"])(false);
  21230. const onFocus = () => setIsFocused(true);
  21231. const onBlur = () => setIsFocused(false);
  21232. if (isLocked || isFirst && isLast && !rootClientId) {
  21233. return null;
  21234. }
  21235. const dragHandleLabel = Object(external_wp_i18n_["__"])('Drag'); // We emulate a disabled state because forcefully applying the `disabled`
  21236. // attribute on the buttons while it has focus causes the screen to change
  21237. // to an unfocused state (body as active element) without firing blur on,
  21238. // the rendering parent, leaving it unable to react to focus out.
  21239. return Object(external_wp_element_["createElement"])("div", {
  21240. className: classnames_default()('block-editor-block-mover', {
  21241. 'is-visible': isFocused || !isHidden,
  21242. 'is-horizontal': orientation === 'horizontal'
  21243. })
  21244. }, !hideDragHandle && Object(external_wp_element_["createElement"])(block_draggable, {
  21245. clientIds: clientIds,
  21246. cloneClassname: "block-editor-block-mover__drag-clone"
  21247. }, draggableProps => Object(external_wp_element_["createElement"])(external_wp_components_["Button"], Object(esm_extends["a" /* default */])({
  21248. icon: drag_handle,
  21249. className: "block-editor-block-mover__drag-handle",
  21250. "aria-hidden": "true",
  21251. label: dragHandleLabel // Should not be able to tab to drag handle as this
  21252. // button can only be used with a pointer device.
  21253. ,
  21254. tabIndex: "-1"
  21255. }, draggableProps))), Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], {
  21256. className: "block-editor-block-mover__move-button-container"
  21257. }, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarItem"], {
  21258. onFocus: onFocus,
  21259. onBlur: onBlur
  21260. }, itemProps => Object(external_wp_element_["createElement"])(BlockMoverUpButton, Object(esm_extends["a" /* default */])({
  21261. clientIds: clientIds
  21262. }, itemProps))), Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarItem"], {
  21263. onFocus: onFocus,
  21264. onBlur: onBlur
  21265. }, itemProps => Object(external_wp_element_["createElement"])(BlockMoverDownButton, Object(esm_extends["a" /* default */])({
  21266. clientIds: clientIds
  21267. }, itemProps)))));
  21268. }
  21269. /* harmony default export */ var block_mover = (Object(external_wp_data_["withSelect"])((select, {
  21270. clientIds
  21271. }) => {
  21272. var _getBlockListSettings;
  21273. const {
  21274. getBlock,
  21275. getBlockIndex,
  21276. getBlockListSettings,
  21277. getTemplateLock,
  21278. getBlockOrder,
  21279. getBlockRootClientId
  21280. } = select(store);
  21281. const normalizedClientIds = Object(external_lodash_["castArray"])(clientIds);
  21282. const firstClientId = Object(external_lodash_["first"])(normalizedClientIds);
  21283. const block = getBlock(firstClientId);
  21284. const rootClientId = getBlockRootClientId(Object(external_lodash_["first"])(normalizedClientIds));
  21285. const firstIndex = getBlockIndex(firstClientId, rootClientId);
  21286. const lastIndex = getBlockIndex(Object(external_lodash_["last"])(normalizedClientIds), rootClientId);
  21287. const blockOrder = getBlockOrder(rootClientId);
  21288. const isFirst = firstIndex === 0;
  21289. const isLast = lastIndex === blockOrder.length - 1;
  21290. return {
  21291. blockType: block ? Object(external_wp_blocks_["getBlockType"])(block.name) : null,
  21292. isLocked: getTemplateLock(rootClientId) === 'all',
  21293. rootClientId,
  21294. firstIndex,
  21295. isFirst,
  21296. isLast,
  21297. orientation: (_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation
  21298. };
  21299. })(BlockMover));
  21300. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-toolbar/utils.js
  21301. /**
  21302. * External dependencies
  21303. */
  21304. /**
  21305. * WordPress dependencies
  21306. */
  21307. const {
  21308. clearTimeout: utils_clearTimeout,
  21309. setTimeout: utils_setTimeout
  21310. } = window;
  21311. const DEBOUNCE_TIMEOUT = 200;
  21312. /**
  21313. * Hook that creates a showMover state, as well as debounced show/hide callbacks.
  21314. *
  21315. * @param {Object} props Component props.
  21316. * @param {Object} props.ref Element reference.
  21317. * @param {boolean} props.isFocused Whether the component has current focus.
  21318. * @param {number} [props.debounceTimeout=250] Debounce timeout in milliseconds.
  21319. * @param {Function} [props.onChange=noop] Callback function.
  21320. */
  21321. function useDebouncedShowMovers({
  21322. ref,
  21323. isFocused,
  21324. debounceTimeout = DEBOUNCE_TIMEOUT,
  21325. onChange = external_lodash_["noop"]
  21326. }) {
  21327. const [showMovers, setShowMovers] = Object(external_wp_element_["useState"])(false);
  21328. const timeoutRef = Object(external_wp_element_["useRef"])();
  21329. const handleOnChange = nextIsFocused => {
  21330. if (ref !== null && ref !== void 0 && ref.current) {
  21331. setShowMovers(nextIsFocused);
  21332. }
  21333. onChange(nextIsFocused);
  21334. };
  21335. const getIsHovered = () => {
  21336. return (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.matches(':hover');
  21337. };
  21338. const shouldHideMovers = () => {
  21339. const isHovered = getIsHovered();
  21340. return !isFocused && !isHovered;
  21341. };
  21342. const clearTimeoutRef = () => {
  21343. const timeout = timeoutRef.current;
  21344. if (timeout && utils_clearTimeout) {
  21345. utils_clearTimeout(timeout);
  21346. }
  21347. };
  21348. const debouncedShowMovers = event => {
  21349. if (event) {
  21350. event.stopPropagation();
  21351. }
  21352. clearTimeoutRef();
  21353. if (!showMovers) {
  21354. handleOnChange(true);
  21355. }
  21356. };
  21357. const debouncedHideMovers = event => {
  21358. if (event) {
  21359. event.stopPropagation();
  21360. }
  21361. clearTimeoutRef();
  21362. timeoutRef.current = utils_setTimeout(() => {
  21363. if (shouldHideMovers()) {
  21364. handleOnChange(false);
  21365. }
  21366. }, debounceTimeout);
  21367. };
  21368. Object(external_wp_element_["useEffect"])(() => () => clearTimeoutRef(), []);
  21369. return {
  21370. showMovers,
  21371. debouncedShowMovers,
  21372. debouncedHideMovers
  21373. };
  21374. }
  21375. /**
  21376. * Hook that provides a showMovers state and gesture events for DOM elements
  21377. * that interact with the showMovers state.
  21378. *
  21379. * @param {Object} props Component props.
  21380. * @param {Object} props.ref Element reference.
  21381. * @param {number} [props.debounceTimeout=250] Debounce timeout in milliseconds.
  21382. * @param {Function} [props.onChange=noop] Callback function.
  21383. */
  21384. function useShowMoversGestures({
  21385. ref,
  21386. debounceTimeout = DEBOUNCE_TIMEOUT,
  21387. onChange = external_lodash_["noop"]
  21388. }) {
  21389. const [isFocused, setIsFocused] = Object(external_wp_element_["useState"])(false);
  21390. const {
  21391. showMovers,
  21392. debouncedShowMovers,
  21393. debouncedHideMovers
  21394. } = useDebouncedShowMovers({
  21395. ref,
  21396. debounceTimeout,
  21397. isFocused,
  21398. onChange
  21399. });
  21400. const registerRef = Object(external_wp_element_["useRef"])(false);
  21401. const isFocusedWithin = () => {
  21402. return (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.contains(ref.current.ownerDocument.activeElement);
  21403. };
  21404. Object(external_wp_element_["useEffect"])(() => {
  21405. const node = ref.current;
  21406. const handleOnFocus = () => {
  21407. if (isFocusedWithin()) {
  21408. setIsFocused(true);
  21409. debouncedShowMovers();
  21410. }
  21411. };
  21412. const handleOnBlur = () => {
  21413. if (!isFocusedWithin()) {
  21414. setIsFocused(false);
  21415. debouncedHideMovers();
  21416. }
  21417. };
  21418. /**
  21419. * Events are added via DOM events (vs. React synthetic events),
  21420. * as the child React components swallow mouse events.
  21421. */
  21422. if (node && !registerRef.current) {
  21423. node.addEventListener('focus', handleOnFocus, true);
  21424. node.addEventListener('blur', handleOnBlur, true);
  21425. registerRef.current = true;
  21426. }
  21427. return () => {
  21428. if (node) {
  21429. node.removeEventListener('focus', handleOnFocus);
  21430. node.removeEventListener('blur', handleOnBlur);
  21431. }
  21432. };
  21433. }, [ref, registerRef, setIsFocused, debouncedShowMovers, debouncedHideMovers]);
  21434. return {
  21435. showMovers,
  21436. gestures: {
  21437. onMouseMove: debouncedShowMovers,
  21438. onMouseLeave: debouncedHideMovers
  21439. }
  21440. };
  21441. }
  21442. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-parent-selector/index.js
  21443. /**
  21444. * WordPress dependencies
  21445. */
  21446. /**
  21447. * Internal dependencies
  21448. */
  21449. /**
  21450. * Block parent selector component, displaying the hierarchy of the
  21451. * current block selection as a single icon to "go up" a level.
  21452. *
  21453. * @return {WPComponent} Parent block selector.
  21454. */
  21455. function BlockParentSelector() {
  21456. const {
  21457. selectBlock,
  21458. toggleBlockHighlight
  21459. } = Object(external_wp_data_["useDispatch"])(store);
  21460. const {
  21461. firstParentClientId,
  21462. shouldHide,
  21463. hasReducedUI
  21464. } = Object(external_wp_data_["useSelect"])(select => {
  21465. const {
  21466. getBlockName,
  21467. getBlockParents,
  21468. getSelectedBlockClientId,
  21469. getSettings
  21470. } = select(store);
  21471. const {
  21472. hasBlockSupport
  21473. } = select(external_wp_blocks_["store"]);
  21474. const selectedBlockClientId = getSelectedBlockClientId();
  21475. const parents = getBlockParents(selectedBlockClientId);
  21476. const _firstParentClientId = parents[parents.length - 1];
  21477. const parentBlockName = getBlockName(_firstParentClientId);
  21478. const _parentBlockType = Object(external_wp_blocks_["getBlockType"])(parentBlockName);
  21479. const settings = getSettings();
  21480. return {
  21481. firstParentClientId: _firstParentClientId,
  21482. shouldHide: !hasBlockSupport(_parentBlockType, '__experimentalParentSelector', true),
  21483. hasReducedUI: settings.hasReducedUI
  21484. };
  21485. }, []);
  21486. const blockInformation = useBlockDisplayInformation(firstParentClientId); // Allows highlighting the parent block outline when focusing or hovering
  21487. // the parent block selector within the child.
  21488. const nodeRef = Object(external_wp_element_["useRef"])();
  21489. const {
  21490. gestures: showMoversGestures
  21491. } = useShowMoversGestures({
  21492. ref: nodeRef,
  21493. onChange(isFocused) {
  21494. if (isFocused && hasReducedUI) {
  21495. return;
  21496. }
  21497. toggleBlockHighlight(firstParentClientId, isFocused);
  21498. }
  21499. });
  21500. if (shouldHide || firstParentClientId === undefined) {
  21501. return null;
  21502. }
  21503. return Object(external_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({
  21504. className: "block-editor-block-parent-selector",
  21505. key: firstParentClientId,
  21506. ref: nodeRef
  21507. }, showMoversGestures), Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarButton"], {
  21508. className: "block-editor-block-parent-selector__button",
  21509. onClick: () => selectBlock(firstParentClientId),
  21510. label: Object(external_wp_i18n_["sprintf"])(
  21511. /* translators: %s: Name of the block's parent. */
  21512. Object(external_wp_i18n_["__"])('Select %s'), blockInformation.title),
  21513. showTooltip: true,
  21514. icon: Object(external_wp_element_["createElement"])(BlockIcon, {
  21515. icon: blockInformation.icon
  21516. })
  21517. }));
  21518. }
  21519. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/stack.js
  21520. /**
  21521. * WordPress dependencies
  21522. */
  21523. const stack_stack = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
  21524. xmlns: "http://www.w3.org/2000/svg",
  21525. viewBox: "0 0 24 24"
  21526. }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
  21527. d: "M20.2 8v11c0 .7-.6 1.2-1.2 1.2H6v1.5h13c1.5 0 2.7-1.2 2.7-2.8V8zM18 16.4V4.6c0-.9-.7-1.6-1.6-1.6H4.6C3.7 3 3 3.7 3 4.6v11.8c0 .9.7 1.6 1.6 1.6h11.8c.9 0 1.6-.7 1.6-1.6zm-13.5 0V4.6c0-.1.1-.1.1-.1h11.8c.1 0 .1.1.1.1v11.8c0 .1-.1.1-.1.1H4.6l-.1-.1z"
  21528. }));
  21529. /* harmony default export */ var library_stack = (stack_stack);
  21530. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/preview-block-popover.js
  21531. /**
  21532. * WordPress dependencies
  21533. */
  21534. /**
  21535. * Internal dependencies
  21536. */
  21537. function PreviewBlockPopover({
  21538. blocks
  21539. }) {
  21540. return Object(external_wp_element_["createElement"])("div", {
  21541. className: "block-editor-block-switcher__popover__preview__parent"
  21542. }, Object(external_wp_element_["createElement"])("div", {
  21543. className: "block-editor-block-switcher__popover__preview__container"
  21544. }, Object(external_wp_element_["createElement"])(external_wp_components_["Popover"], {
  21545. className: "block-editor-block-switcher__preview__popover",
  21546. position: "bottom right",
  21547. focusOnMount: false
  21548. }, Object(external_wp_element_["createElement"])("div", {
  21549. className: "block-editor-block-switcher__preview"
  21550. }, Object(external_wp_element_["createElement"])("div", {
  21551. className: "block-editor-block-switcher__preview-title"
  21552. }, Object(external_wp_i18n_["__"])('Preview')), Object(external_wp_element_["createElement"])(block_preview, {
  21553. viewportWidth: 500,
  21554. blocks: blocks
  21555. })))));
  21556. }
  21557. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/block-transformations-menu.js
  21558. /**
  21559. * WordPress dependencies
  21560. */
  21561. /**
  21562. * Internal dependencies
  21563. */
  21564. const BlockTransformationsMenu = ({
  21565. className,
  21566. possibleBlockTransformations,
  21567. onSelect,
  21568. blocks
  21569. }) => {
  21570. const [hoveredTransformItemName, setHoveredTransformItemName] = Object(external_wp_element_["useState"])();
  21571. return Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], {
  21572. label: Object(external_wp_i18n_["__"])('Transform to'),
  21573. className: className
  21574. }, hoveredTransformItemName && Object(external_wp_element_["createElement"])(PreviewBlockPopover, {
  21575. blocks: Object(external_wp_blocks_["switchToBlockType"])(blocks, hoveredTransformItemName)
  21576. }), possibleBlockTransformations.map(item => {
  21577. const {
  21578. name,
  21579. icon,
  21580. title,
  21581. isDisabled
  21582. } = item;
  21583. return Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  21584. key: name,
  21585. className: Object(external_wp_blocks_["getBlockMenuDefaultClassName"])(name),
  21586. onClick: event => {
  21587. event.preventDefault();
  21588. onSelect(name);
  21589. },
  21590. disabled: isDisabled,
  21591. onMouseLeave: () => setHoveredTransformItemName(null),
  21592. onMouseEnter: () => setHoveredTransformItemName(name)
  21593. }, Object(external_wp_element_["createElement"])(BlockIcon, {
  21594. icon: icon,
  21595. showColors: true
  21596. }), title);
  21597. }));
  21598. };
  21599. /* harmony default export */ var block_transformations_menu = (BlockTransformationsMenu);
  21600. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/utils.js
  21601. /**
  21602. * External dependencies
  21603. */
  21604. /**
  21605. * WordPress dependencies
  21606. */
  21607. /**
  21608. * Returns the active style from the given className.
  21609. *
  21610. * @param {Array} styles Block style variations.
  21611. * @param {string} className Class name
  21612. *
  21613. * @return {Object?} The active style.
  21614. */
  21615. function getActiveStyle(styles, className) {
  21616. for (const style of new external_wp_tokenList_default.a(className).values()) {
  21617. if (style.indexOf('is-style-') === -1) {
  21618. continue;
  21619. }
  21620. const potentialStyleName = style.substring(9);
  21621. const activeStyle = Object(external_lodash_["find"])(styles, {
  21622. name: potentialStyleName
  21623. });
  21624. if (activeStyle) {
  21625. return activeStyle;
  21626. }
  21627. }
  21628. return Object(external_lodash_["find"])(styles, 'isDefault');
  21629. }
  21630. /**
  21631. * Replaces the active style in the block's className.
  21632. *
  21633. * @param {string} className Class name.
  21634. * @param {Object?} activeStyle The replaced style.
  21635. * @param {Object} newStyle The replacing style.
  21636. *
  21637. * @return {string} The updated className.
  21638. */
  21639. function replaceActiveStyle(className, activeStyle, newStyle) {
  21640. const list = new external_wp_tokenList_default.a(className);
  21641. if (activeStyle) {
  21642. list.remove('is-style-' + activeStyle.name);
  21643. }
  21644. list.add('is-style-' + newStyle.name);
  21645. return list.value;
  21646. }
  21647. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/index.js
  21648. /**
  21649. * External dependencies
  21650. */
  21651. /**
  21652. * WordPress dependencies
  21653. */
  21654. /**
  21655. * Internal dependencies
  21656. */
  21657. const EMPTY_OBJECT = {};
  21658. function useGenericPreviewBlock(block, type) {
  21659. return Object(external_wp_element_["useMemo"])(() => {
  21660. const example = type === null || type === void 0 ? void 0 : type.example;
  21661. const blockName = type === null || type === void 0 ? void 0 : type.name;
  21662. if (example && blockName) {
  21663. return Object(external_wp_blocks_["getBlockFromExample"])(blockName, {
  21664. attributes: example.attributes,
  21665. innerBlocks: example.innerBlocks
  21666. });
  21667. }
  21668. if (block) {
  21669. return Object(external_wp_blocks_["cloneBlock"])(block);
  21670. }
  21671. }, [type !== null && type !== void 0 && type.example ? block === null || block === void 0 ? void 0 : block.name : block, type]);
  21672. }
  21673. function BlockStyles({
  21674. clientId,
  21675. onSwitch = external_lodash_["noop"],
  21676. onHoverClassName = external_lodash_["noop"],
  21677. itemRole
  21678. }) {
  21679. const selector = select => {
  21680. const {
  21681. getBlock
  21682. } = select(store);
  21683. const block = getBlock(clientId);
  21684. if (!block) {
  21685. return EMPTY_OBJECT;
  21686. }
  21687. const blockType = Object(external_wp_blocks_["getBlockType"])(block.name);
  21688. const {
  21689. getBlockStyles
  21690. } = select(external_wp_blocks_["store"]);
  21691. return {
  21692. block,
  21693. type: blockType,
  21694. styles: getBlockStyles(block.name),
  21695. className: block.attributes.className || ''
  21696. };
  21697. };
  21698. const {
  21699. styles,
  21700. block,
  21701. type,
  21702. className
  21703. } = Object(external_wp_data_["useSelect"])(selector, [clientId]);
  21704. const {
  21705. updateBlockAttributes
  21706. } = Object(external_wp_data_["useDispatch"])(store);
  21707. const genericPreviewBlock = useGenericPreviewBlock(block, type);
  21708. if (!styles || styles.length === 0) {
  21709. return null;
  21710. }
  21711. const renderedStyles = Object(external_lodash_["find"])(styles, 'isDefault') ? styles : [{
  21712. name: 'default',
  21713. label: Object(external_wp_i18n_["_x"])('Default', 'block style'),
  21714. isDefault: true
  21715. }, ...styles];
  21716. const activeStyle = getActiveStyle(renderedStyles, className);
  21717. return Object(external_wp_element_["createElement"])("div", {
  21718. className: "block-editor-block-styles"
  21719. }, renderedStyles.map(style => {
  21720. const styleClassName = replaceActiveStyle(className, activeStyle, style);
  21721. return Object(external_wp_element_["createElement"])(BlockStyleItem, {
  21722. genericPreviewBlock: genericPreviewBlock,
  21723. className: className,
  21724. isActive: activeStyle === style,
  21725. key: style.name,
  21726. onSelect: () => {
  21727. updateBlockAttributes(clientId, {
  21728. className: styleClassName
  21729. });
  21730. onHoverClassName(null);
  21731. onSwitch();
  21732. },
  21733. onBlur: () => onHoverClassName(null),
  21734. onHover: () => onHoverClassName(styleClassName),
  21735. style: style,
  21736. styleClassName: styleClassName,
  21737. itemRole: itemRole
  21738. });
  21739. }));
  21740. }
  21741. function BlockStyleItem({
  21742. genericPreviewBlock,
  21743. style,
  21744. isActive,
  21745. onBlur,
  21746. onHover,
  21747. onSelect,
  21748. styleClassName,
  21749. itemRole
  21750. }) {
  21751. const previewBlocks = Object(external_wp_element_["useMemo"])(() => {
  21752. return { ...genericPreviewBlock,
  21753. attributes: { ...genericPreviewBlock.attributes,
  21754. className: styleClassName
  21755. }
  21756. };
  21757. }, [genericPreviewBlock, styleClassName]);
  21758. return Object(external_wp_element_["createElement"])("div", {
  21759. key: style.name,
  21760. className: classnames_default()('block-editor-block-styles__item', {
  21761. 'is-active': isActive
  21762. }),
  21763. onClick: () => onSelect(),
  21764. onKeyDown: event => {
  21765. if (external_wp_keycodes_["ENTER"] === event.keyCode || external_wp_keycodes_["SPACE"] === event.keyCode) {
  21766. event.preventDefault();
  21767. onSelect();
  21768. }
  21769. },
  21770. onMouseEnter: onHover,
  21771. onMouseLeave: onBlur,
  21772. role: itemRole || 'button',
  21773. tabIndex: "0",
  21774. "aria-label": style.label || style.name
  21775. }, Object(external_wp_element_["createElement"])("div", {
  21776. className: "block-editor-block-styles__item-preview"
  21777. }, Object(external_wp_element_["createElement"])(block_preview, {
  21778. viewportWidth: 500,
  21779. blocks: previewBlocks
  21780. })), Object(external_wp_element_["createElement"])("div", {
  21781. className: "block-editor-block-styles__item-label"
  21782. }, style.label || style.name));
  21783. }
  21784. /* harmony default export */ var block_styles = (BlockStyles);
  21785. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/block-styles-menu.js
  21786. /**
  21787. * WordPress dependencies
  21788. */
  21789. /**
  21790. * Internal dependencies
  21791. */
  21792. function BlockStylesMenu({
  21793. hoveredBlock,
  21794. onSwitch
  21795. }) {
  21796. const {
  21797. name,
  21798. clientId
  21799. } = hoveredBlock;
  21800. const [hoveredClassName, setHoveredClassName] = Object(external_wp_element_["useState"])();
  21801. const blockType = Object(external_wp_data_["useSelect"])(select => select(external_wp_blocks_["store"]).getBlockType(name), [name]);
  21802. return Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], {
  21803. label: Object(external_wp_i18n_["__"])('Styles'),
  21804. className: "block-editor-block-switcher__styles__menugroup"
  21805. }, hoveredClassName && Object(external_wp_element_["createElement"])(PreviewBlockPopover, {
  21806. blocks: blockType.example ? Object(external_wp_blocks_["getBlockFromExample"])(blockType.name, {
  21807. attributes: { ...blockType.example.attributes,
  21808. className: hoveredClassName
  21809. },
  21810. innerBlocks: blockType.example.innerBlocks
  21811. }) : Object(external_wp_blocks_["cloneBlock"])(hoveredBlock, {
  21812. className: hoveredClassName
  21813. })
  21814. }), Object(external_wp_element_["createElement"])(block_styles, {
  21815. clientId: clientId,
  21816. onSwitch: onSwitch,
  21817. onHoverClassName: setHoveredClassName,
  21818. itemRole: "menuitem"
  21819. }));
  21820. }
  21821. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/utils.js
  21822. /**
  21823. * WordPress dependencies
  21824. */
  21825. /**
  21826. * Try to find a matching block by a block's name in a provided
  21827. * block. We recurse through InnerBlocks and return the reference
  21828. * of the matched block (it could be an InnerBlock).
  21829. * If no match is found return nothing.
  21830. *
  21831. * @param {WPBlock} block The block to try to find a match.
  21832. * @param {string} selectedBlockName The block's name to use for matching condition.
  21833. * @param {Set} consumedBlocks A set holding the previously matched/consumed blocks.
  21834. *
  21835. * @return {WPBlock?} The matched block if found or nothing(`undefined`).
  21836. */
  21837. const getMatchingBlockByName = (block, selectedBlockName, consumedBlocks = new Set()) => {
  21838. const {
  21839. clientId,
  21840. name,
  21841. innerBlocks = []
  21842. } = block; // Check if block has been consumed already.
  21843. if (consumedBlocks.has(clientId)) return;
  21844. if (name === selectedBlockName) return block; // Try to find a matching block from InnerBlocks recursively.
  21845. for (const innerBlock of innerBlocks) {
  21846. const match = getMatchingBlockByName(innerBlock, selectedBlockName, consumedBlocks);
  21847. if (match) return match;
  21848. }
  21849. };
  21850. /**
  21851. * Find and return the block attributes to retain through
  21852. * the transformation, based on Block Type's `role:content`
  21853. * attributes. If no `role:content` attributes exist,
  21854. * return selected block's attributes.
  21855. *
  21856. * @param {string} name Block type's namespaced name.
  21857. * @param {Object} attributes Selected block's attributes.
  21858. * @return {Object} The block's attributes to retain.
  21859. */
  21860. const getRetainedBlockAttributes = (name, attributes) => {
  21861. const contentAttributes = Object(external_wp_blocks_["__experimentalGetBlockAttributesNamesByRole"])(name, 'content');
  21862. if (!(contentAttributes !== null && contentAttributes !== void 0 && contentAttributes.length)) return attributes;
  21863. return contentAttributes.reduce((_accumulator, attribute) => {
  21864. if (attributes[attribute]) _accumulator[attribute] = attributes[attribute];
  21865. return _accumulator;
  21866. }, {});
  21867. };
  21868. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/use-transformed-patterns.js
  21869. /**
  21870. * WordPress dependencies
  21871. */
  21872. /**
  21873. * Internal dependencies
  21874. */
  21875. /**
  21876. * Mutate the matched block's attributes by getting
  21877. * which block type's attributes to retain and prioritize
  21878. * them in the merging of the attributes.
  21879. *
  21880. * @param {WPBlock} match The matched block.
  21881. * @param {WPBlock} selectedBlock The selected block.
  21882. * @return {void}
  21883. */
  21884. const transformMatchingBlock = (match, selectedBlock) => {
  21885. // Get the block attributes to retain through the transformation.
  21886. const retainedBlockAttributes = getRetainedBlockAttributes(selectedBlock.name, selectedBlock.attributes);
  21887. match.attributes = { ...match.attributes,
  21888. ...retainedBlockAttributes
  21889. };
  21890. };
  21891. /**
  21892. * By providing the selected blocks and pattern's blocks
  21893. * find the matching blocks, transform them and return them.
  21894. * If not all selected blocks are matched, return nothing.
  21895. *
  21896. * @param {WPBlock[]} selectedBlocks The selected blocks.
  21897. * @param {WPBlock[]} patternBlocks The pattern's blocks.
  21898. * @return {WPBlock[]|void} The transformed pattern's blocks or undefined if not all selected blocks have been matched.
  21899. */
  21900. const getPatternTransformedBlocks = (selectedBlocks, patternBlocks) => {
  21901. // Clone Pattern's blocks to produce new clientIds and be able to mutate the matches.
  21902. const _patternBlocks = patternBlocks.map(block => Object(external_wp_blocks_["cloneBlock"])(block));
  21903. /**
  21904. * Keep track of the consumed pattern blocks.
  21905. * This is needed because we loop the selected blocks
  21906. * and for example we may have selected two paragraphs and
  21907. * the pattern's blocks could have more `paragraphs`.
  21908. */
  21909. const consumedBlocks = new Set();
  21910. for (const selectedBlock of selectedBlocks) {
  21911. let isMatch = false;
  21912. for (const patternBlock of _patternBlocks) {
  21913. const match = getMatchingBlockByName(patternBlock, selectedBlock.name, consumedBlocks);
  21914. if (!match) continue;
  21915. isMatch = true;
  21916. consumedBlocks.add(match.clientId); // We update (mutate) the matching pattern block.
  21917. transformMatchingBlock(match, selectedBlock); // No need to loop through other pattern's blocks.
  21918. break;
  21919. } // Bail eary if a selected block has not been matched.
  21920. if (!isMatch) return;
  21921. }
  21922. return _patternBlocks;
  21923. };
  21924. /**
  21925. * @typedef {WPBlockPattern & {transformedBlocks: WPBlock[]}} TransformedBlockPattern
  21926. */
  21927. /**
  21928. * Custom hook that accepts patterns from state and the selected
  21929. * blocks and tries to match these with the pattern's blocks.
  21930. * If all selected blocks are matched with a Pattern's block,
  21931. * we transform them by retaining block's attributes with `role:content`.
  21932. * The transformed pattern's blocks are set to a new pattern
  21933. * property `transformedBlocks`.
  21934. *
  21935. * @param {WPBlockPattern[]} patterns Patterns from state.
  21936. * @param {WPBlock[]} selectedBlocks The currently selected blocks.
  21937. * @return {TransformedBlockPattern[]} Returns the eligible matched patterns with all the selected blocks.
  21938. */
  21939. // TODO tests
  21940. const useTransformedPatterns = (patterns, selectedBlocks) => {
  21941. return Object(external_wp_element_["useMemo"])(() => patterns.reduce((accumulator, _pattern) => {
  21942. const transformedBlocks = getPatternTransformedBlocks(selectedBlocks, _pattern.blocks);
  21943. if (transformedBlocks) {
  21944. accumulator.push({ ..._pattern,
  21945. transformedBlocks
  21946. });
  21947. }
  21948. return accumulator;
  21949. }, []), [patterns, selectedBlocks]);
  21950. };
  21951. /* harmony default export */ var use_transformed_patterns = (useTransformedPatterns);
  21952. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/pattern-transformations-menu.js
  21953. /**
  21954. * WordPress dependencies
  21955. */
  21956. /**
  21957. * Internal dependencies
  21958. */
  21959. function PatternTransformationsMenu({
  21960. blocks,
  21961. patterns: statePatterns,
  21962. onSelect
  21963. }) {
  21964. const [showTransforms, setShowTransforms] = Object(external_wp_element_["useState"])(false);
  21965. const patterns = use_transformed_patterns(statePatterns, blocks);
  21966. if (!patterns.length) return null;
  21967. return Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], {
  21968. className: "block-editor-block-switcher__pattern__transforms__menugroup"
  21969. }, showTransforms && Object(external_wp_element_["createElement"])(PreviewPatternsPopover, {
  21970. patterns: patterns,
  21971. onSelect: onSelect
  21972. }), Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  21973. onClick: event => {
  21974. event.preventDefault();
  21975. setShowTransforms(!showTransforms);
  21976. },
  21977. icon: chevron_right["a" /* default */]
  21978. }, Object(external_wp_i18n_["__"])('Patterns')));
  21979. }
  21980. function PreviewPatternsPopover({
  21981. patterns,
  21982. onSelect
  21983. }) {
  21984. return Object(external_wp_element_["createElement"])("div", {
  21985. className: "block-editor-block-switcher__popover__preview__parent"
  21986. }, Object(external_wp_element_["createElement"])("div", {
  21987. className: "block-editor-block-switcher__popover__preview__container"
  21988. }, Object(external_wp_element_["createElement"])(external_wp_components_["Popover"], {
  21989. className: "block-editor-block-switcher__preview__popover",
  21990. position: "bottom right"
  21991. }, Object(external_wp_element_["createElement"])("div", {
  21992. className: "block-editor-block-switcher__preview"
  21993. }, Object(external_wp_element_["createElement"])("div", {
  21994. className: "block-editor-block-switcher__preview-title"
  21995. }, Object(external_wp_i18n_["__"])('Preview')), Object(external_wp_element_["createElement"])(BlockPatternsList, {
  21996. patterns: patterns,
  21997. onSelect: onSelect
  21998. })))));
  21999. }
  22000. function BlockPatternsList({
  22001. patterns,
  22002. onSelect
  22003. }) {
  22004. const composite = Object(external_wp_components_["__unstableUseCompositeState"])();
  22005. return Object(external_wp_element_["createElement"])(external_wp_components_["__unstableComposite"], Object(esm_extends["a" /* default */])({}, composite, {
  22006. role: "listbox",
  22007. className: "block-editor-block-switcher__preview-patterns-container",
  22008. "aria-label": Object(external_wp_i18n_["__"])('Patterns list')
  22009. }), patterns.map(pattern => Object(external_wp_element_["createElement"])(pattern_transformations_menu_BlockPattern, {
  22010. key: pattern.name,
  22011. pattern: pattern,
  22012. onSelect: onSelect,
  22013. composite: composite
  22014. })));
  22015. }
  22016. function pattern_transformations_menu_BlockPattern({
  22017. pattern,
  22018. onSelect,
  22019. composite
  22020. }) {
  22021. // TODO check pattern/preview width...
  22022. const baseClassName = 'block-editor-block-switcher__preview-patterns-container';
  22023. const descriptionId = Object(external_wp_compose_["useInstanceId"])(pattern_transformations_menu_BlockPattern, `${baseClassName}-list__item-description`);
  22024. return Object(external_wp_element_["createElement"])("div", {
  22025. className: `${baseClassName}-list__list-item`,
  22026. "aria-label": pattern.title,
  22027. "aria-describedby": pattern.description ? descriptionId : undefined
  22028. }, Object(external_wp_element_["createElement"])(external_wp_components_["__unstableCompositeItem"], Object(esm_extends["a" /* default */])({
  22029. role: "option",
  22030. as: "div"
  22031. }, composite, {
  22032. className: `${baseClassName}-list__item`,
  22033. onClick: () => onSelect(pattern.transformedBlocks)
  22034. }), Object(external_wp_element_["createElement"])(block_preview, {
  22035. blocks: pattern.transformedBlocks,
  22036. viewportWidth: pattern.viewportWidth || 500
  22037. }), Object(external_wp_element_["createElement"])("div", {
  22038. className: `${baseClassName}-list__item-title`
  22039. }, pattern.title)), !!pattern.description && Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], {
  22040. id: descriptionId
  22041. }, pattern.description));
  22042. }
  22043. /* harmony default export */ var pattern_transformations_menu = (PatternTransformationsMenu);
  22044. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/index.js
  22045. /**
  22046. * External dependencies
  22047. */
  22048. /**
  22049. * WordPress dependencies
  22050. */
  22051. /**
  22052. * Internal dependencies
  22053. */
  22054. const BlockSwitcherDropdownMenu = ({
  22055. clientIds,
  22056. blocks
  22057. }) => {
  22058. const {
  22059. replaceBlocks
  22060. } = Object(external_wp_data_["useDispatch"])(store);
  22061. const blockInformation = useBlockDisplayInformation(blocks[0].clientId);
  22062. const {
  22063. possibleBlockTransformations,
  22064. hasBlockStyles,
  22065. icon,
  22066. blockTitle,
  22067. patterns
  22068. } = Object(external_wp_data_["useSelect"])(select => {
  22069. const {
  22070. getBlockRootClientId,
  22071. getBlockTransformItems,
  22072. __experimentalGetPatternTransformItems
  22073. } = select(store);
  22074. const {
  22075. getBlockStyles,
  22076. getBlockType
  22077. } = select(external_wp_blocks_["store"]);
  22078. const rootClientId = getBlockRootClientId(Object(external_lodash_["castArray"])(clientIds)[0]);
  22079. const [{
  22080. name: firstBlockName
  22081. }] = blocks;
  22082. const _isSingleBlockSelected = blocks.length === 1;
  22083. const styles = _isSingleBlockSelected && getBlockStyles(firstBlockName);
  22084. let _icon;
  22085. if (_isSingleBlockSelected) {
  22086. _icon = blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon; // Take into account active block variations.
  22087. } else {
  22088. var _getBlockType;
  22089. const isSelectionOfSameType = Object(external_lodash_["uniq"])(blocks.map(({
  22090. name
  22091. }) => name)).length === 1; // When selection consists of blocks of multiple types, display an
  22092. // appropriate icon to communicate the non-uniformity.
  22093. _icon = isSelectionOfSameType ? (_getBlockType = getBlockType(firstBlockName)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.icon : library_stack;
  22094. }
  22095. return {
  22096. possibleBlockTransformations: getBlockTransformItems(blocks, rootClientId),
  22097. hasBlockStyles: !!(styles !== null && styles !== void 0 && styles.length),
  22098. icon: _icon,
  22099. blockTitle: getBlockType(firstBlockName).title,
  22100. patterns: __experimentalGetPatternTransformItems(blocks, rootClientId)
  22101. };
  22102. }, [clientIds, blocks, blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon]);
  22103. const isReusable = blocks.length === 1 && Object(external_wp_blocks_["isReusableBlock"])(blocks[0]);
  22104. const isTemplate = blocks.length === 1 && Object(external_wp_blocks_["isTemplatePart"])(blocks[0]); // Simple block tranformation based on the `Block Transforms` API.
  22105. const onBlockTransform = name => replaceBlocks(clientIds, Object(external_wp_blocks_["switchToBlockType"])(blocks, name)); // Pattern transformation through the `Patterns` API.
  22106. const onPatternTransform = transformedBlocks => replaceBlocks(clientIds, transformedBlocks);
  22107. const hasPossibleBlockTransformations = !!possibleBlockTransformations.length;
  22108. const hasPatternTransformation = !!(patterns !== null && patterns !== void 0 && patterns.length);
  22109. if (!hasBlockStyles && !hasPossibleBlockTransformations) {
  22110. return Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], null, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarButton"], {
  22111. disabled: true,
  22112. className: "block-editor-block-switcher__no-switcher-icon",
  22113. title: blockTitle,
  22114. icon: Object(external_wp_element_["createElement"])(BlockIcon, {
  22115. icon: icon,
  22116. showColors: true
  22117. })
  22118. }));
  22119. }
  22120. const blockSwitcherLabel = blockTitle;
  22121. const blockSwitcherDescription = 1 === blocks.length ? Object(external_wp_i18n_["sprintf"])(
  22122. /* translators: %s: block title. */
  22123. Object(external_wp_i18n_["__"])('%s: Change block type or style'), blockTitle) : Object(external_wp_i18n_["sprintf"])(
  22124. /* translators: %d: number of blocks. */
  22125. Object(external_wp_i18n_["_n"])('Change type of %d block', 'Change type of %d blocks', blocks.length), blocks.length);
  22126. const showDropDown = hasBlockStyles || hasPossibleBlockTransformations || hasPatternTransformation;
  22127. return Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], null, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarItem"], null, toggleProps => Object(external_wp_element_["createElement"])(external_wp_components_["DropdownMenu"], {
  22128. className: "block-editor-block-switcher",
  22129. label: blockSwitcherLabel,
  22130. popoverProps: {
  22131. position: 'bottom right',
  22132. isAlternate: true,
  22133. className: 'block-editor-block-switcher__popover'
  22134. },
  22135. icon: Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(BlockIcon, {
  22136. icon: icon,
  22137. className: "block-editor-block-switcher__toggle",
  22138. showColors: true
  22139. }), (isReusable || isTemplate) && Object(external_wp_element_["createElement"])("span", {
  22140. className: "block-editor-block-switcher__toggle-text"
  22141. }, Object(external_wp_element_["createElement"])(BlockTitle, {
  22142. clientId: clientIds
  22143. }))),
  22144. toggleProps: {
  22145. describedBy: blockSwitcherDescription,
  22146. ...toggleProps
  22147. },
  22148. menuProps: {
  22149. orientation: 'both'
  22150. }
  22151. }, ({
  22152. onClose
  22153. }) => showDropDown && Object(external_wp_element_["createElement"])("div", {
  22154. className: "block-editor-block-switcher__container"
  22155. }, hasPatternTransformation && Object(external_wp_element_["createElement"])(pattern_transformations_menu, {
  22156. blocks: blocks,
  22157. patterns: patterns,
  22158. onSelect: transformedBlocks => {
  22159. onPatternTransform(transformedBlocks);
  22160. onClose();
  22161. }
  22162. }), hasPossibleBlockTransformations && Object(external_wp_element_["createElement"])(block_transformations_menu, {
  22163. className: "block-editor-block-switcher__transforms__menugroup",
  22164. possibleBlockTransformations: possibleBlockTransformations,
  22165. blocks: blocks,
  22166. onSelect: name => {
  22167. onBlockTransform(name);
  22168. onClose();
  22169. }
  22170. }), hasBlockStyles && Object(external_wp_element_["createElement"])(BlockStylesMenu, {
  22171. hoveredBlock: blocks[0],
  22172. onSwitch: onClose
  22173. })))));
  22174. };
  22175. const BlockSwitcher = ({
  22176. clientIds
  22177. }) => {
  22178. const blocks = Object(external_wp_data_["useSelect"])(select => select(store).getBlocksByClientId(clientIds), [clientIds]);
  22179. if (!blocks.length || blocks.some(block => !block)) {
  22180. return null;
  22181. }
  22182. return Object(external_wp_element_["createElement"])(BlockSwitcherDropdownMenu, {
  22183. clientIds: clientIds,
  22184. blocks: blocks
  22185. });
  22186. };
  22187. /* harmony default export */ var block_switcher = (BlockSwitcher);
  22188. // EXTERNAL MODULE: external ["wp","blob"]
  22189. var external_wp_blob_ = __webpack_require__("xTGt");
  22190. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/get-paste-event-data.js
  22191. /**
  22192. * WordPress dependencies
  22193. */
  22194. function getPasteEventData({
  22195. clipboardData
  22196. }) {
  22197. let plainText = '';
  22198. let html = ''; // IE11 only supports `Text` as an argument for `getData` and will
  22199. // otherwise throw an invalid argument error, so we try the standard
  22200. // arguments first, then fallback to `Text` if they fail.
  22201. try {
  22202. plainText = clipboardData.getData('text/plain');
  22203. html = clipboardData.getData('text/html');
  22204. } catch (error1) {
  22205. try {
  22206. html = clipboardData.getData('Text');
  22207. } catch (error2) {
  22208. // Some browsers like UC Browser paste plain text by default and
  22209. // don't support clipboardData at all, so allow default
  22210. // behaviour.
  22211. return;
  22212. }
  22213. }
  22214. const files = Object(external_wp_dom_["getFilesFromDataTransfer"])(clipboardData).filter(({
  22215. type
  22216. }) => /^image\/(?:jpe?g|png|gif)$/.test(type)); // Only process files if no HTML is present.
  22217. // A pasted file may have the URL as plain text.
  22218. if (files.length && !html) {
  22219. html = files.map(file => `<img src="${Object(external_wp_blob_["createBlobURL"])(file)}">`).join('');
  22220. plainText = '';
  22221. }
  22222. return {
  22223. html,
  22224. plainText
  22225. };
  22226. }
  22227. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/copy-handler/index.js
  22228. /**
  22229. * WordPress dependencies
  22230. */
  22231. /**
  22232. * Internal dependencies
  22233. */
  22234. function useNotifyCopy() {
  22235. const {
  22236. getBlockName
  22237. } = Object(external_wp_data_["useSelect"])(store);
  22238. const {
  22239. getBlockType
  22240. } = Object(external_wp_data_["useSelect"])(external_wp_blocks_["store"]);
  22241. const {
  22242. createSuccessNotice
  22243. } = Object(external_wp_data_["useDispatch"])(external_wp_notices_["store"]);
  22244. return Object(external_wp_element_["useCallback"])((eventType, selectedBlockClientIds) => {
  22245. let notice = '';
  22246. if (selectedBlockClientIds.length === 1) {
  22247. const clientId = selectedBlockClientIds[0];
  22248. const {
  22249. title
  22250. } = getBlockType(getBlockName(clientId));
  22251. notice = eventType === 'copy' ? Object(external_wp_i18n_["sprintf"])( // Translators: Name of the block being copied, e.g. "Paragraph".
  22252. Object(external_wp_i18n_["__"])('Copied "%s" to clipboard.'), title) : Object(external_wp_i18n_["sprintf"])( // Translators: Name of the block being cut, e.g. "Paragraph".
  22253. Object(external_wp_i18n_["__"])('Moved "%s" to clipboard.'), title);
  22254. } else {
  22255. notice = eventType === 'copy' ? Object(external_wp_i18n_["sprintf"])( // Translators: %d: Number of blocks being copied.
  22256. Object(external_wp_i18n_["_n"])('Copied %d block to clipboard.', 'Copied %d blocks to clipboard.', selectedBlockClientIds.length), selectedBlockClientIds.length) : Object(external_wp_i18n_["sprintf"])( // Translators: %d: Number of blocks being cut.
  22257. Object(external_wp_i18n_["_n"])('Moved %d block to clipboard.', 'Moved %d blocks to clipboard.', selectedBlockClientIds.length), selectedBlockClientIds.length);
  22258. }
  22259. createSuccessNotice(notice, {
  22260. type: 'snackbar'
  22261. });
  22262. }, []);
  22263. }
  22264. function useClipboardHandler() {
  22265. const {
  22266. getBlocksByClientId,
  22267. getSelectedBlockClientIds,
  22268. hasMultiSelection,
  22269. getSettings
  22270. } = Object(external_wp_data_["useSelect"])(store);
  22271. const {
  22272. flashBlock,
  22273. removeBlocks,
  22274. replaceBlocks
  22275. } = Object(external_wp_data_["useDispatch"])(store);
  22276. const notifyCopy = useNotifyCopy();
  22277. return Object(external_wp_compose_["useRefEffect"])(node => {
  22278. function handler(event) {
  22279. const selectedBlockClientIds = getSelectedBlockClientIds();
  22280. if (selectedBlockClientIds.length === 0) {
  22281. return;
  22282. } // Always handle multiple selected blocks.
  22283. if (!hasMultiSelection()) {
  22284. const {
  22285. target
  22286. } = event;
  22287. const {
  22288. ownerDocument
  22289. } = target; // If copying, only consider actual text selection as selection.
  22290. // Otherwise, any focus on an input field is considered.
  22291. const hasSelection = event.type === 'copy' || event.type === 'cut' ? Object(external_wp_dom_["documentHasUncollapsedSelection"])(ownerDocument) : Object(external_wp_dom_["documentHasSelection"])(ownerDocument); // Let native copy behaviour take over in input fields.
  22292. if (hasSelection) {
  22293. return;
  22294. }
  22295. }
  22296. if (!node.contains(event.target.ownerDocument.activeElement)) {
  22297. return;
  22298. }
  22299. event.preventDefault();
  22300. if (event.type === 'copy' || event.type === 'cut') {
  22301. if (selectedBlockClientIds.length === 1) {
  22302. flashBlock(selectedBlockClientIds[0]);
  22303. }
  22304. notifyCopy(event.type, selectedBlockClientIds);
  22305. const blocks = getBlocksByClientId(selectedBlockClientIds);
  22306. const serialized = Object(external_wp_blocks_["serialize"])(blocks);
  22307. event.clipboardData.setData('text/plain', serialized);
  22308. event.clipboardData.setData('text/html', serialized);
  22309. }
  22310. if (event.type === 'cut') {
  22311. removeBlocks(selectedBlockClientIds);
  22312. } else if (event.type === 'paste') {
  22313. const {
  22314. __experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML
  22315. } = getSettings();
  22316. const {
  22317. plainText,
  22318. html
  22319. } = getPasteEventData(event);
  22320. const blocks = Object(external_wp_blocks_["pasteHandler"])({
  22321. HTML: html,
  22322. plainText,
  22323. mode: 'BLOCKS',
  22324. canUserUseUnfilteredHTML
  22325. });
  22326. replaceBlocks(selectedBlockClientIds, blocks, blocks.length - 1, -1);
  22327. }
  22328. }
  22329. node.ownerDocument.addEventListener('copy', handler);
  22330. node.ownerDocument.addEventListener('cut', handler);
  22331. node.ownerDocument.addEventListener('paste', handler);
  22332. return () => {
  22333. node.ownerDocument.removeEventListener('copy', handler);
  22334. node.ownerDocument.removeEventListener('cut', handler);
  22335. node.ownerDocument.removeEventListener('paste', handler);
  22336. };
  22337. }, []);
  22338. }
  22339. function CopyHandler({
  22340. children
  22341. }) {
  22342. return Object(external_wp_element_["createElement"])("div", {
  22343. ref: useClipboardHandler()
  22344. }, children);
  22345. }
  22346. /* harmony default export */ var copy_handler = (CopyHandler);
  22347. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-actions/index.js
  22348. /**
  22349. * External dependencies
  22350. */
  22351. /**
  22352. * WordPress dependencies
  22353. */
  22354. /**
  22355. * Internal dependencies
  22356. */
  22357. function BlockActions({
  22358. clientIds,
  22359. children,
  22360. __experimentalUpdateSelection: updateSelection
  22361. }) {
  22362. const {
  22363. canInsertBlockType,
  22364. getBlockRootClientId,
  22365. getBlocksByClientId,
  22366. getTemplateLock
  22367. } = Object(external_wp_data_["useSelect"])(select => select(store), []);
  22368. const {
  22369. getDefaultBlockName,
  22370. getGroupingBlockName
  22371. } = Object(external_wp_data_["useSelect"])(select => select(external_wp_blocks_["store"]), []);
  22372. const blocks = getBlocksByClientId(clientIds);
  22373. const rootClientId = getBlockRootClientId(clientIds[0]);
  22374. const canDuplicate = Object(external_lodash_["every"])(blocks, block => {
  22375. return !!block && Object(external_wp_blocks_["hasBlockSupport"])(block.name, 'multiple', true) && canInsertBlockType(block.name, rootClientId);
  22376. });
  22377. const canInsertDefaultBlock = canInsertBlockType(getDefaultBlockName(), rootClientId);
  22378. const {
  22379. removeBlocks,
  22380. replaceBlocks,
  22381. duplicateBlocks,
  22382. insertAfterBlock,
  22383. insertBeforeBlock,
  22384. flashBlock,
  22385. setBlockMovingClientId,
  22386. setNavigationMode,
  22387. selectBlock
  22388. } = Object(external_wp_data_["useDispatch"])(store);
  22389. const notifyCopy = useNotifyCopy();
  22390. return children({
  22391. canDuplicate,
  22392. canInsertDefaultBlock,
  22393. isLocked: !!getTemplateLock(rootClientId),
  22394. rootClientId,
  22395. blocks,
  22396. onDuplicate() {
  22397. return duplicateBlocks(clientIds, updateSelection);
  22398. },
  22399. onRemove() {
  22400. return removeBlocks(clientIds, updateSelection);
  22401. },
  22402. onInsertBefore() {
  22403. insertBeforeBlock(Object(external_lodash_["first"])(Object(external_lodash_["castArray"])(clientIds)));
  22404. },
  22405. onInsertAfter() {
  22406. insertAfterBlock(Object(external_lodash_["last"])(Object(external_lodash_["castArray"])(clientIds)));
  22407. },
  22408. onMoveTo() {
  22409. setNavigationMode(true);
  22410. selectBlock(clientIds[0]);
  22411. setBlockMovingClientId(clientIds[0]);
  22412. },
  22413. onGroup() {
  22414. if (!blocks.length) {
  22415. return;
  22416. }
  22417. const groupingBlockName = getGroupingBlockName(); // Activate the `transform` on `core/group` which does the conversion
  22418. const newBlocks = Object(external_wp_blocks_["switchToBlockType"])(blocks, groupingBlockName);
  22419. if (!newBlocks) {
  22420. return;
  22421. }
  22422. replaceBlocks(clientIds, newBlocks);
  22423. },
  22424. onUngroup() {
  22425. if (!blocks.length) {
  22426. return;
  22427. }
  22428. const innerBlocks = blocks[0].innerBlocks;
  22429. if (!innerBlocks.length) {
  22430. return;
  22431. }
  22432. replaceBlocks(clientIds, innerBlocks);
  22433. },
  22434. onCopy() {
  22435. const selectedBlockClientIds = blocks.map(({
  22436. clientId
  22437. }) => clientId);
  22438. if (blocks.length === 1) {
  22439. flashBlock(selectedBlockClientIds[0]);
  22440. }
  22441. notifyCopy('copy', selectedBlockClientIds);
  22442. }
  22443. });
  22444. }
  22445. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-mode-toggle.js
  22446. /**
  22447. * External dependencies
  22448. */
  22449. /**
  22450. * WordPress dependencies
  22451. */
  22452. /**
  22453. * Internal dependencies
  22454. */
  22455. function BlockModeToggle({
  22456. blockType,
  22457. mode,
  22458. onToggleMode,
  22459. small = false,
  22460. isCodeEditingEnabled = true
  22461. }) {
  22462. if (!Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'html', true) || !isCodeEditingEnabled) {
  22463. return null;
  22464. }
  22465. const label = mode === 'visual' ? Object(external_wp_i18n_["__"])('Edit as HTML') : Object(external_wp_i18n_["__"])('Edit visually');
  22466. return Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  22467. onClick: onToggleMode
  22468. }, !small && label);
  22469. }
  22470. /* harmony default export */ var block_mode_toggle = (Object(external_wp_compose_["compose"])([Object(external_wp_data_["withSelect"])((select, {
  22471. clientId
  22472. }) => {
  22473. const {
  22474. getBlock,
  22475. getBlockMode,
  22476. getSettings
  22477. } = select(store);
  22478. const block = getBlock(clientId);
  22479. const isCodeEditingEnabled = getSettings().codeEditingEnabled;
  22480. return {
  22481. mode: getBlockMode(clientId),
  22482. blockType: block ? Object(external_wp_blocks_["getBlockType"])(block.name) : null,
  22483. isCodeEditingEnabled
  22484. };
  22485. }), Object(external_wp_data_["withDispatch"])((dispatch, {
  22486. onToggle = external_lodash_["noop"],
  22487. clientId
  22488. }) => ({
  22489. onToggleMode() {
  22490. dispatch(store).toggleBlockMode(clientId);
  22491. onToggle();
  22492. }
  22493. }))])(BlockModeToggle));
  22494. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-convert-button.js
  22495. /**
  22496. * WordPress dependencies
  22497. */
  22498. function BlockConvertButton({
  22499. shouldRender,
  22500. onClick,
  22501. small
  22502. }) {
  22503. if (!shouldRender) {
  22504. return null;
  22505. }
  22506. const label = Object(external_wp_i18n_["__"])('Convert to Blocks');
  22507. return Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  22508. onClick: onClick
  22509. }, !small && label);
  22510. }
  22511. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-html-convert-button.js
  22512. /**
  22513. * WordPress dependencies
  22514. */
  22515. /**
  22516. * Internal dependencies
  22517. */
  22518. /* harmony default export */ var block_html_convert_button = (Object(external_wp_compose_["compose"])(Object(external_wp_data_["withSelect"])((select, {
  22519. clientId
  22520. }) => {
  22521. const block = select(store).getBlock(clientId);
  22522. return {
  22523. block,
  22524. shouldRender: block && block.name === 'core/html'
  22525. };
  22526. }), Object(external_wp_data_["withDispatch"])((dispatch, {
  22527. block
  22528. }) => ({
  22529. onClick: () => dispatch(store).replaceBlocks(block.clientId, Object(external_wp_blocks_["rawHandler"])({
  22530. HTML: Object(external_wp_blocks_["getBlockContent"])(block)
  22531. }))
  22532. })))(BlockConvertButton));
  22533. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-settings-menu-first-item.js
  22534. /**
  22535. * WordPress dependencies
  22536. */
  22537. const {
  22538. Fill: __unstableBlockSettingsMenuFirstItem,
  22539. Slot: block_settings_menu_first_item_Slot
  22540. } = Object(external_wp_components_["createSlotFill"])('__unstableBlockSettingsMenuFirstItem');
  22541. __unstableBlockSettingsMenuFirstItem.Slot = block_settings_menu_first_item_Slot;
  22542. /* harmony default export */ var block_settings_menu_first_item = (__unstableBlockSettingsMenuFirstItem);
  22543. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js
  22544. /**
  22545. * WordPress dependencies
  22546. */
  22547. /**
  22548. * Internal dependencies
  22549. */
  22550. /**
  22551. * Contains the properties `ConvertToGroupButton` component needs.
  22552. *
  22553. * @typedef {Object} ConvertToGroupButtonProps
  22554. * @property {string[]} clientIds An array of the selected client ids.
  22555. * @property {boolean} isGroupable Indicates if the selected blocks can be grouped.
  22556. * @property {boolean} isUngroupable Indicates if the selected blocks can be ungrouped.
  22557. * @property {WPBlock[]} blocksSelection An array of the selected blocks.
  22558. * @property {string} groupingBlockName The name of block used for handling grouping interactions.
  22559. */
  22560. /**
  22561. * Returns the properties `ConvertToGroupButton` component needs to work properly.
  22562. * It is used in `BlockSettingsMenuControls` to know if `ConvertToGroupButton`
  22563. * should be rendered, to avoid ending up with an empty MenuGroup.
  22564. *
  22565. * @return {ConvertToGroupButtonProps} Returns the properties needed by `ConvertToGroupButton`.
  22566. */
  22567. function useConvertToGroupButtonProps() {
  22568. const {
  22569. clientIds,
  22570. isGroupable,
  22571. isUngroupable,
  22572. blocksSelection,
  22573. groupingBlockName
  22574. } = Object(external_wp_data_["useSelect"])(select => {
  22575. var _blocksSelection$;
  22576. const {
  22577. getBlockRootClientId,
  22578. getBlocksByClientId,
  22579. canInsertBlockType,
  22580. getSelectedBlockClientIds
  22581. } = select(store);
  22582. const {
  22583. getGroupingBlockName
  22584. } = select(external_wp_blocks_["store"]);
  22585. const _clientIds = getSelectedBlockClientIds();
  22586. const _groupingBlockName = getGroupingBlockName();
  22587. const rootClientId = !!(_clientIds !== null && _clientIds !== void 0 && _clientIds.length) ? getBlockRootClientId(_clientIds[0]) : undefined;
  22588. const groupingBlockAvailable = canInsertBlockType(_groupingBlockName, rootClientId);
  22589. const _blocksSelection = getBlocksByClientId(_clientIds);
  22590. const isSingleGroupingBlock = _blocksSelection.length === 1 && ((_blocksSelection$ = _blocksSelection[0]) === null || _blocksSelection$ === void 0 ? void 0 : _blocksSelection$.name) === _groupingBlockName; // Do we have
  22591. // 1. Grouping block available to be inserted?
  22592. // 2. One or more blocks selected
  22593. // (we allow single Blocks to become groups unless
  22594. // they are a soltiary group block themselves)
  22595. const _isGroupable = groupingBlockAvailable && _blocksSelection.length && !isSingleGroupingBlock; // Do we have a single Group Block selected and does that group have inner blocks?
  22596. const _isUngroupable = isSingleGroupingBlock && !!_blocksSelection[0].innerBlocks.length;
  22597. return {
  22598. clientIds: _clientIds,
  22599. isGroupable: _isGroupable,
  22600. isUngroupable: _isUngroupable,
  22601. blocksSelection: _blocksSelection,
  22602. groupingBlockName: _groupingBlockName
  22603. };
  22604. }, []);
  22605. return {
  22606. clientIds,
  22607. isGroupable,
  22608. isUngroupable,
  22609. blocksSelection,
  22610. groupingBlockName
  22611. };
  22612. }
  22613. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/convert-to-group-buttons/index.js
  22614. /**
  22615. * WordPress dependencies
  22616. */
  22617. /**
  22618. * Internal dependencies
  22619. */
  22620. function ConvertToGroupButton({
  22621. clientIds,
  22622. isGroupable,
  22623. isUngroupable,
  22624. blocksSelection,
  22625. groupingBlockName,
  22626. onClose = () => {}
  22627. }) {
  22628. const {
  22629. replaceBlocks
  22630. } = Object(external_wp_data_["useDispatch"])(store);
  22631. const onConvertToGroup = () => {
  22632. // Activate the `transform` on the Grouping Block which does the conversion
  22633. const newBlocks = Object(external_wp_blocks_["switchToBlockType"])(blocksSelection, groupingBlockName);
  22634. if (newBlocks) {
  22635. replaceBlocks(clientIds, newBlocks);
  22636. }
  22637. };
  22638. const onConvertFromGroup = () => {
  22639. const innerBlocks = blocksSelection[0].innerBlocks;
  22640. if (!innerBlocks.length) {
  22641. return;
  22642. }
  22643. replaceBlocks(clientIds, innerBlocks);
  22644. };
  22645. if (!isGroupable && !isUngroupable) {
  22646. return null;
  22647. }
  22648. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, isGroupable && Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  22649. onClick: () => {
  22650. onConvertToGroup();
  22651. onClose();
  22652. }
  22653. }, Object(external_wp_i18n_["_x"])('Group', 'verb')), isUngroupable && Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  22654. onClick: () => {
  22655. onConvertFromGroup();
  22656. onClose();
  22657. }
  22658. }, Object(external_wp_i18n_["_x"])('Ungroup', 'Ungrouping blocks from within a Group block back into individual blocks within the Editor ')));
  22659. }
  22660. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu-controls/index.js
  22661. /**
  22662. * External dependencies
  22663. */
  22664. /**
  22665. * WordPress dependencies
  22666. */
  22667. /**
  22668. * Internal dependencies
  22669. */
  22670. const {
  22671. Fill: block_settings_menu_controls_Fill,
  22672. Slot: block_settings_menu_controls_Slot
  22673. } = Object(external_wp_components_["createSlotFill"])('BlockSettingsMenuControls');
  22674. const BlockSettingsMenuControlsSlot = ({
  22675. fillProps,
  22676. clientIds = null
  22677. }) => {
  22678. const selectedBlocks = Object(external_wp_data_["useSelect"])(select => {
  22679. const {
  22680. getBlocksByClientId,
  22681. getSelectedBlockClientIds
  22682. } = select(store);
  22683. const ids = clientIds !== null ? clientIds : getSelectedBlockClientIds();
  22684. return Object(external_lodash_["map"])(Object(external_lodash_["compact"])(getBlocksByClientId(ids)), block => block.name);
  22685. }, [clientIds]); // Check if current selection of blocks is Groupable or Ungroupable
  22686. // and pass this props down to ConvertToGroupButton.
  22687. const convertToGroupButtonProps = useConvertToGroupButtonProps();
  22688. const {
  22689. isGroupable,
  22690. isUngroupable
  22691. } = convertToGroupButtonProps;
  22692. const showConvertToGroupButton = isGroupable || isUngroupable;
  22693. return Object(external_wp_element_["createElement"])(block_settings_menu_controls_Slot, {
  22694. fillProps: { ...fillProps,
  22695. selectedBlocks
  22696. }
  22697. }, fills => {
  22698. if ((fills === null || fills === void 0 ? void 0 : fills.length) > 0 || showConvertToGroupButton) {
  22699. return Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], null, fills, Object(external_wp_element_["createElement"])(ConvertToGroupButton, Object(esm_extends["a" /* default */])({}, convertToGroupButtonProps, {
  22700. onClose: fillProps === null || fillProps === void 0 ? void 0 : fillProps.onClose
  22701. })));
  22702. }
  22703. });
  22704. };
  22705. /**
  22706. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-settings-menu-controls/README.md
  22707. *
  22708. * @param {Object} props Fill props.
  22709. * @return {WPElement} Element.
  22710. */
  22711. function BlockSettingsMenuControls({ ...props
  22712. }) {
  22713. return Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalStyleProvider"], {
  22714. document: document
  22715. }, Object(external_wp_element_["createElement"])(block_settings_menu_controls_Fill, props));
  22716. }
  22717. BlockSettingsMenuControls.Slot = BlockSettingsMenuControlsSlot;
  22718. /* harmony default export */ var block_settings_menu_controls = (BlockSettingsMenuControls);
  22719. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-settings-dropdown.js
  22720. /**
  22721. * External dependencies
  22722. */
  22723. /**
  22724. * WordPress dependencies
  22725. */
  22726. /**
  22727. * Internal dependencies
  22728. */
  22729. const block_settings_dropdown_POPOVER_PROPS = {
  22730. className: 'block-editor-block-settings-menu__popover',
  22731. position: 'bottom right',
  22732. isAlternate: true
  22733. };
  22734. function CopyMenuItem({
  22735. blocks,
  22736. onCopy
  22737. }) {
  22738. const ref = Object(external_wp_compose_["useCopyToClipboard"])(() => Object(external_wp_blocks_["serialize"])(blocks), onCopy);
  22739. return Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  22740. ref: ref
  22741. }, Object(external_wp_i18n_["__"])('Copy'));
  22742. }
  22743. function BlockSettingsDropdown({
  22744. clientIds,
  22745. __experimentalSelectBlock,
  22746. children,
  22747. ...props
  22748. }) {
  22749. const blockClientIds = Object(external_lodash_["castArray"])(clientIds);
  22750. const count = blockClientIds.length;
  22751. const firstBlockClientId = blockClientIds[0];
  22752. const shortcuts = Object(external_wp_data_["useSelect"])(select => {
  22753. const {
  22754. getShortcutRepresentation
  22755. } = select(external_wp_keyboardShortcuts_["store"]);
  22756. return {
  22757. duplicate: getShortcutRepresentation('core/block-editor/duplicate'),
  22758. remove: getShortcutRepresentation('core/block-editor/remove'),
  22759. insertAfter: getShortcutRepresentation('core/block-editor/insert-after'),
  22760. insertBefore: getShortcutRepresentation('core/block-editor/insert-before')
  22761. };
  22762. }, []);
  22763. const updateSelection = Object(external_wp_element_["useCallback"])(__experimentalSelectBlock ? async clientIdsPromise => {
  22764. const ids = await clientIdsPromise;
  22765. if (ids && ids[0]) {
  22766. __experimentalSelectBlock(ids[0]);
  22767. }
  22768. } : external_lodash_["noop"], [__experimentalSelectBlock]);
  22769. const removeBlockLabel = count === 1 ? Object(external_wp_i18n_["__"])('Remove block') : Object(external_wp_i18n_["__"])('Remove blocks');
  22770. return Object(external_wp_element_["createElement"])(BlockActions, {
  22771. clientIds: clientIds,
  22772. __experimentalUpdateSelection: !__experimentalSelectBlock
  22773. }, ({
  22774. canDuplicate,
  22775. canInsertDefaultBlock,
  22776. isLocked,
  22777. onDuplicate,
  22778. onInsertAfter,
  22779. onInsertBefore,
  22780. onRemove,
  22781. onCopy,
  22782. onMoveTo,
  22783. blocks
  22784. }) => Object(external_wp_element_["createElement"])(external_wp_components_["DropdownMenu"], Object(esm_extends["a" /* default */])({
  22785. icon: more_vertical["a" /* default */],
  22786. label: Object(external_wp_i18n_["__"])('Options'),
  22787. className: "block-editor-block-settings-menu",
  22788. popoverProps: block_settings_dropdown_POPOVER_PROPS,
  22789. noIcons: true
  22790. }, props), ({
  22791. onClose
  22792. }) => Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], null, Object(external_wp_element_["createElement"])(block_settings_menu_first_item.Slot, {
  22793. fillProps: {
  22794. onClose
  22795. }
  22796. }), count === 1 && Object(external_wp_element_["createElement"])(block_html_convert_button, {
  22797. clientId: firstBlockClientId
  22798. }), Object(external_wp_element_["createElement"])(CopyMenuItem, {
  22799. blocks: blocks,
  22800. onCopy: onCopy
  22801. }), canDuplicate && Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  22802. onClick: Object(external_lodash_["flow"])(onClose, onDuplicate, updateSelection),
  22803. shortcut: shortcuts.duplicate
  22804. }, Object(external_wp_i18n_["__"])('Duplicate')), canInsertDefaultBlock && Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  22805. onClick: Object(external_lodash_["flow"])(onClose, onInsertBefore),
  22806. shortcut: shortcuts.insertBefore
  22807. }, Object(external_wp_i18n_["__"])('Insert before')), Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  22808. onClick: Object(external_lodash_["flow"])(onClose, onInsertAfter),
  22809. shortcut: shortcuts.insertAfter
  22810. }, Object(external_wp_i18n_["__"])('Insert after'))), !isLocked && Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  22811. onClick: Object(external_lodash_["flow"])(onClose, onMoveTo)
  22812. }, Object(external_wp_i18n_["__"])('Move to')), count === 1 && Object(external_wp_element_["createElement"])(block_mode_toggle, {
  22813. clientId: firstBlockClientId,
  22814. onToggle: onClose
  22815. })), Object(external_wp_element_["createElement"])(block_settings_menu_controls.Slot, {
  22816. fillProps: {
  22817. onClose
  22818. },
  22819. clientIds: clientIds
  22820. }), typeof children === 'function' ? children({
  22821. onClose
  22822. }) : external_wp_element_["Children"].map(child => Object(external_wp_element_["cloneElement"])(child, {
  22823. onClose
  22824. })), Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], null, !isLocked && Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  22825. onClick: Object(external_lodash_["flow"])(onClose, onRemove, updateSelection),
  22826. shortcut: shortcuts.remove
  22827. }, removeBlockLabel)))));
  22828. }
  22829. /* harmony default export */ var block_settings_dropdown = (BlockSettingsDropdown);
  22830. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/index.js
  22831. /**
  22832. * WordPress dependencies
  22833. */
  22834. /**
  22835. * Internal dependencies
  22836. */
  22837. function BlockSettingsMenu({
  22838. clientIds,
  22839. ...props
  22840. }) {
  22841. return Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], null, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarItem"], null, toggleProps => Object(external_wp_element_["createElement"])(block_settings_dropdown, Object(esm_extends["a" /* default */])({
  22842. clientIds: clientIds,
  22843. toggleProps: toggleProps
  22844. }, props))));
  22845. }
  22846. /* harmony default export */ var block_settings_menu = (BlockSettingsMenu);
  22847. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-toolbar/index.js
  22848. /**
  22849. * External dependencies
  22850. */
  22851. /**
  22852. * WordPress dependencies
  22853. */
  22854. /**
  22855. * Internal dependencies
  22856. */
  22857. function BlockToolbar({
  22858. hideDragHandle
  22859. }) {
  22860. const {
  22861. blockClientIds,
  22862. blockClientId,
  22863. blockType,
  22864. hasFixedToolbar,
  22865. hasReducedUI,
  22866. isValid,
  22867. isVisual
  22868. } = Object(external_wp_data_["useSelect"])(select => {
  22869. const {
  22870. getBlockName,
  22871. getBlockMode,
  22872. getSelectedBlockClientIds,
  22873. isBlockValid,
  22874. getBlockRootClientId,
  22875. getSettings
  22876. } = select(store);
  22877. const selectedBlockClientIds = getSelectedBlockClientIds();
  22878. const selectedBlockClientId = selectedBlockClientIds[0];
  22879. const blockRootClientId = getBlockRootClientId(selectedBlockClientId);
  22880. const settings = getSettings();
  22881. return {
  22882. blockClientIds: selectedBlockClientIds,
  22883. blockClientId: selectedBlockClientId,
  22884. blockType: selectedBlockClientId && Object(external_wp_blocks_["getBlockType"])(getBlockName(selectedBlockClientId)),
  22885. hasFixedToolbar: settings.hasFixedToolbar,
  22886. hasReducedUI: settings.hasReducedUI,
  22887. rootClientId: blockRootClientId,
  22888. isValid: selectedBlockClientIds.every(id => isBlockValid(id)),
  22889. isVisual: selectedBlockClientIds.every(id => getBlockMode(id) === 'visual')
  22890. };
  22891. }, []); // Handles highlighting the current block outline on hover or focus of the
  22892. // block type toolbar area.
  22893. const {
  22894. toggleBlockHighlight
  22895. } = Object(external_wp_data_["useDispatch"])(store);
  22896. const nodeRef = Object(external_wp_element_["useRef"])();
  22897. const {
  22898. showMovers,
  22899. gestures: showMoversGestures
  22900. } = useShowMoversGestures({
  22901. ref: nodeRef,
  22902. onChange(isFocused) {
  22903. if (isFocused && hasReducedUI) {
  22904. return;
  22905. }
  22906. toggleBlockHighlight(blockClientId, isFocused);
  22907. }
  22908. }); // Account for the cases where the block toolbar is rendered within the
  22909. // header area and not contextually to the block.
  22910. const displayHeaderToolbar = Object(external_wp_compose_["useViewportMatch"])('medium', '<') || hasFixedToolbar;
  22911. if (blockType) {
  22912. if (!Object(external_wp_blocks_["hasBlockSupport"])(blockType, '__experimentalToolbar', true)) {
  22913. return null;
  22914. }
  22915. }
  22916. const shouldShowMovers = displayHeaderToolbar || showMovers;
  22917. if (blockClientIds.length === 0) {
  22918. return null;
  22919. }
  22920. const shouldShowVisualToolbar = isValid && isVisual;
  22921. const isMultiToolbar = blockClientIds.length > 1;
  22922. const classes = classnames_default()('block-editor-block-toolbar', shouldShowMovers && 'is-showing-movers');
  22923. return Object(external_wp_element_["createElement"])("div", {
  22924. className: classes
  22925. }, !isMultiToolbar && !displayHeaderToolbar && Object(external_wp_element_["createElement"])(BlockParentSelector, {
  22926. clientIds: blockClientIds
  22927. }), Object(external_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({
  22928. ref: nodeRef
  22929. }, showMoversGestures), (shouldShowVisualToolbar || isMultiToolbar) && Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], {
  22930. className: "block-editor-block-toolbar__block-controls"
  22931. }, Object(external_wp_element_["createElement"])(block_switcher, {
  22932. clientIds: blockClientIds
  22933. }), Object(external_wp_element_["createElement"])(block_mover, {
  22934. clientIds: blockClientIds,
  22935. hideDragHandle: hideDragHandle || hasReducedUI
  22936. }))), shouldShowVisualToolbar && Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(block_controls.Slot, {
  22937. group: "block",
  22938. className: "block-editor-block-toolbar__slot"
  22939. }), Object(external_wp_element_["createElement"])(block_controls.Slot, {
  22940. className: "block-editor-block-toolbar__slot"
  22941. }), Object(external_wp_element_["createElement"])(block_controls.Slot, {
  22942. group: "inline",
  22943. className: "block-editor-block-toolbar__slot"
  22944. }), Object(external_wp_element_["createElement"])(block_controls.Slot, {
  22945. group: "other",
  22946. className: "block-editor-block-toolbar__slot"
  22947. })), Object(external_wp_element_["createElement"])(block_settings_menu, {
  22948. clientIds: blockClientIds
  22949. }));
  22950. }
  22951. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/block-contextual-toolbar.js
  22952. /**
  22953. * External dependencies
  22954. */
  22955. /**
  22956. * WordPress dependencies
  22957. */
  22958. /**
  22959. * Internal dependencies
  22960. */
  22961. function BlockContextualToolbar({
  22962. focusOnMount,
  22963. isFixed,
  22964. ...props
  22965. }) {
  22966. const {
  22967. blockType,
  22968. hasParents,
  22969. showParentSelector
  22970. } = Object(external_wp_data_["useSelect"])(select => {
  22971. const {
  22972. getBlockName,
  22973. getBlockParents,
  22974. getSelectedBlockClientIds
  22975. } = select(store);
  22976. const {
  22977. getBlockType
  22978. } = select(external_wp_blocks_["store"]);
  22979. const selectedBlockClientIds = getSelectedBlockClientIds();
  22980. const selectedBlockClientId = selectedBlockClientIds[0];
  22981. const parents = getBlockParents(selectedBlockClientId);
  22982. const firstParentClientId = parents[parents.length - 1];
  22983. const parentBlockName = getBlockName(firstParentClientId);
  22984. const parentBlockType = getBlockType(parentBlockName);
  22985. return {
  22986. blockType: selectedBlockClientId && getBlockType(getBlockName(selectedBlockClientId)),
  22987. hasParents: parents.length,
  22988. showParentSelector: Object(external_wp_blocks_["hasBlockSupport"])(parentBlockType, '__experimentalParentSelector', true)
  22989. };
  22990. }, []);
  22991. if (blockType) {
  22992. if (!Object(external_wp_blocks_["hasBlockSupport"])(blockType, '__experimentalToolbar', true)) {
  22993. return null;
  22994. }
  22995. } // Shifts the toolbar to make room for the parent block selector.
  22996. const classes = classnames_default()('block-editor-block-contextual-toolbar', {
  22997. 'has-parent': hasParents && showParentSelector,
  22998. 'is-fixed': isFixed
  22999. });
  23000. return Object(external_wp_element_["createElement"])(navigable_toolbar, Object(esm_extends["a" /* default */])({
  23001. focusOnMount: focusOnMount,
  23002. className: classes
  23003. /* translators: accessibility text for the block toolbar */
  23004. ,
  23005. "aria-label": Object(external_wp_i18n_["__"])('Block tools')
  23006. }, props), Object(external_wp_element_["createElement"])(BlockToolbar, {
  23007. hideDragHandle: isFixed
  23008. }));
  23009. }
  23010. /* harmony default export */ var block_contextual_toolbar = (BlockContextualToolbar);
  23011. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/block-popover.js
  23012. /**
  23013. * External dependencies
  23014. */
  23015. /**
  23016. * WordPress dependencies
  23017. */
  23018. /**
  23019. * Internal dependencies
  23020. */
  23021. function block_popover_selector(select) {
  23022. const {
  23023. isNavigationMode,
  23024. isMultiSelecting,
  23025. hasMultiSelection,
  23026. isTyping,
  23027. isCaretWithinFormattedText,
  23028. getSettings,
  23029. getLastMultiSelectedBlockClientId
  23030. } = select(store);
  23031. return {
  23032. isNavigationMode: isNavigationMode(),
  23033. isMultiSelecting: isMultiSelecting(),
  23034. isTyping: isTyping(),
  23035. isCaretWithinFormattedText: isCaretWithinFormattedText(),
  23036. hasMultiSelection: hasMultiSelection(),
  23037. hasFixedToolbar: getSettings().hasFixedToolbar,
  23038. lastClientId: getLastMultiSelectedBlockClientId()
  23039. };
  23040. }
  23041. function BlockPopover({
  23042. clientId,
  23043. rootClientId,
  23044. isValid,
  23045. isEmptyDefaultBlock,
  23046. capturingClientId,
  23047. __unstablePopoverSlot,
  23048. __unstableContentRef
  23049. }) {
  23050. const {
  23051. isNavigationMode,
  23052. isMultiSelecting,
  23053. isTyping,
  23054. isCaretWithinFormattedText,
  23055. hasMultiSelection,
  23056. hasFixedToolbar,
  23057. lastClientId
  23058. } = Object(external_wp_data_["useSelect"])(block_popover_selector, []);
  23059. const isInsertionPointVisible = Object(external_wp_data_["useSelect"])(select => {
  23060. const {
  23061. isBlockInsertionPointVisible,
  23062. getBlockInsertionPoint,
  23063. getBlockOrder
  23064. } = select(store);
  23065. if (!isBlockInsertionPointVisible()) {
  23066. return false;
  23067. }
  23068. const insertionPoint = getBlockInsertionPoint();
  23069. const order = getBlockOrder(insertionPoint.rootClientId);
  23070. return order[insertionPoint.index] === clientId;
  23071. }, [clientId]);
  23072. const isLargeViewport = Object(external_wp_compose_["useViewportMatch"])('medium');
  23073. const [isToolbarForced, setIsToolbarForced] = Object(external_wp_element_["useState"])(false);
  23074. const [isInserterShown, setIsInserterShown] = Object(external_wp_element_["useState"])(false);
  23075. const {
  23076. stopTyping
  23077. } = Object(external_wp_data_["useDispatch"])(store); // Controls when the side inserter on empty lines should
  23078. // be shown, including writing and selection modes.
  23079. const showEmptyBlockSideInserter = !isTyping && !isNavigationMode && isEmptyDefaultBlock && isValid;
  23080. const shouldShowBreadcrumb = isNavigationMode;
  23081. const shouldShowContextualToolbar = !isNavigationMode && !hasFixedToolbar && isLargeViewport && !showEmptyBlockSideInserter && !isMultiSelecting && (!isTyping || isCaretWithinFormattedText);
  23082. const canFocusHiddenToolbar = !isNavigationMode && !shouldShowContextualToolbar && !hasFixedToolbar && !isEmptyDefaultBlock;
  23083. Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/focus-toolbar', Object(external_wp_element_["useCallback"])(() => {
  23084. setIsToolbarForced(true);
  23085. stopTyping(true);
  23086. }, []), {
  23087. bindGlobal: true,
  23088. eventName: 'keydown',
  23089. isDisabled: !canFocusHiddenToolbar
  23090. });
  23091. Object(external_wp_element_["useEffect"])(() => {
  23092. if (!shouldShowContextualToolbar) {
  23093. setIsToolbarForced(false);
  23094. }
  23095. }, [shouldShowContextualToolbar]); // Stores the active toolbar item index so the block toolbar can return focus
  23096. // to it when re-mounting.
  23097. const initialToolbarItemIndexRef = Object(external_wp_element_["useRef"])();
  23098. const selectedElement = useBlockElement(clientId);
  23099. const lastSelectedElement = useBlockElement(lastClientId);
  23100. const capturingElement = useBlockElement(capturingClientId);
  23101. const popoverScrollRef = usePopoverScroll(__unstableContentRef);
  23102. if (!shouldShowBreadcrumb && !shouldShowContextualToolbar && !isToolbarForced && !showEmptyBlockSideInserter) {
  23103. return null;
  23104. }
  23105. let node = selectedElement;
  23106. if (!node) {
  23107. return null;
  23108. }
  23109. if (capturingClientId) {
  23110. node = capturingElement;
  23111. }
  23112. let anchorRef = node;
  23113. if (hasMultiSelection) {
  23114. // Wait to render the popover until the bottom reference is available
  23115. // as well.
  23116. if (!lastSelectedElement) {
  23117. return null;
  23118. }
  23119. anchorRef = {
  23120. top: node,
  23121. bottom: lastSelectedElement
  23122. };
  23123. }
  23124. function onFocus() {
  23125. setIsInserterShown(true);
  23126. }
  23127. function onBlur() {
  23128. setIsInserterShown(false);
  23129. } // Position above the anchor, pop out towards the right, and position in the
  23130. // left corner. For the side inserter, pop out towards the left, and
  23131. // position in the right corner.
  23132. // To do: refactor `Popover` to make this prop clearer.
  23133. const popoverPosition = showEmptyBlockSideInserter ? 'top left right' : 'top right left';
  23134. const {
  23135. ownerDocument
  23136. } = node;
  23137. const stickyBoundaryElement = showEmptyBlockSideInserter ? undefined : // The sticky boundary element should be the boundary at which the
  23138. // the block toolbar becomes sticky when the block scolls out of view.
  23139. // In case of an iframe, this should be the iframe boundary, otherwise
  23140. // the scroll container.
  23141. ownerDocument.defaultView.frameElement || Object(external_wp_dom_["getScrollContainer"])(node) || ownerDocument.body;
  23142. return Object(external_wp_element_["createElement"])(external_wp_components_["Popover"], {
  23143. ref: popoverScrollRef,
  23144. noArrow: true,
  23145. animate: false,
  23146. position: popoverPosition,
  23147. focusOnMount: false,
  23148. anchorRef: anchorRef,
  23149. className: classnames_default()('block-editor-block-list__block-popover', {
  23150. 'is-insertion-point-visible': isInsertionPointVisible
  23151. }),
  23152. __unstableStickyBoundaryElement: stickyBoundaryElement // Render in the old slot if needed for backward compatibility,
  23153. // otherwise render in place (not in the the default popover slot).
  23154. ,
  23155. __unstableSlotName: __unstablePopoverSlot || null,
  23156. __unstableBoundaryParent: true // Observe movement for block animations (especially horizontal).
  23157. ,
  23158. __unstableObserveElement: node,
  23159. shouldAnchorIncludePadding: true
  23160. }, (shouldShowContextualToolbar || isToolbarForced) && Object(external_wp_element_["createElement"])("div", {
  23161. onFocus: onFocus,
  23162. onBlur: onBlur // While ideally it would be enough to capture the
  23163. // bubbling focus event from the Inserter, due to the
  23164. // characteristics of click focusing of `button`s in
  23165. // Firefox and Safari, it is not reliable.
  23166. //
  23167. // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
  23168. ,
  23169. tabIndex: -1,
  23170. className: classnames_default()('block-editor-block-list__block-popover-inserter', {
  23171. 'is-visible': isInserterShown
  23172. })
  23173. }, Object(external_wp_element_["createElement"])(inserter, {
  23174. clientId: clientId,
  23175. rootClientId: rootClientId,
  23176. __experimentalIsQuick: true
  23177. })), (shouldShowContextualToolbar || isToolbarForced) && Object(external_wp_element_["createElement"])(block_contextual_toolbar // If the toolbar is being shown because of being forced
  23178. // it should focus the toolbar right after the mount.
  23179. , {
  23180. focusOnMount: isToolbarForced,
  23181. __experimentalInitialIndex: initialToolbarItemIndexRef.current,
  23182. __experimentalOnIndexChange: index => {
  23183. initialToolbarItemIndexRef.current = index;
  23184. } // Resets the index whenever the active block changes so
  23185. // this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
  23186. ,
  23187. key: clientId
  23188. }), shouldShowBreadcrumb && Object(external_wp_element_["createElement"])(block_selection_button, {
  23189. clientId: clientId,
  23190. rootClientId: rootClientId,
  23191. blockElement: node
  23192. }), showEmptyBlockSideInserter && Object(external_wp_element_["createElement"])("div", {
  23193. className: "block-editor-block-list__empty-block-inserter"
  23194. }, Object(external_wp_element_["createElement"])(inserter, {
  23195. position: "bottom right",
  23196. rootClientId: rootClientId,
  23197. clientId: clientId,
  23198. __experimentalIsQuick: true
  23199. })));
  23200. }
  23201. function wrapperSelector(select) {
  23202. const {
  23203. getSelectedBlockClientId,
  23204. getFirstMultiSelectedBlockClientId,
  23205. getBlockRootClientId,
  23206. __unstableGetBlockWithoutInnerBlocks,
  23207. getBlockParents,
  23208. __experimentalGetBlockListSettingsForBlocks
  23209. } = select(store);
  23210. const clientId = getSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();
  23211. if (!clientId) {
  23212. return;
  23213. }
  23214. const {
  23215. name,
  23216. attributes = {},
  23217. isValid
  23218. } = __unstableGetBlockWithoutInnerBlocks(clientId) || {};
  23219. const blockParentsClientIds = getBlockParents(clientId); // Get Block List Settings for all ancestors of the current Block clientId
  23220. const parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(blockParentsClientIds); // Get the clientId of the topmost parent with the capture toolbars setting.
  23221. const capturingClientId = Object(external_lodash_["find"])(blockParentsClientIds, parentClientId => {
  23222. var _parentBlockListSetti;
  23223. return (_parentBlockListSetti = parentBlockListSettings[parentClientId]) === null || _parentBlockListSetti === void 0 ? void 0 : _parentBlockListSetti.__experimentalCaptureToolbars;
  23224. });
  23225. return {
  23226. clientId,
  23227. rootClientId: getBlockRootClientId(clientId),
  23228. name,
  23229. isValid,
  23230. isEmptyDefaultBlock: name && Object(external_wp_blocks_["isUnmodifiedDefaultBlock"])({
  23231. name,
  23232. attributes
  23233. }),
  23234. capturingClientId
  23235. };
  23236. }
  23237. function WrappedBlockPopover({
  23238. __unstablePopoverSlot,
  23239. __unstableContentRef
  23240. }) {
  23241. const selected = Object(external_wp_data_["useSelect"])(wrapperSelector, []);
  23242. if (!selected) {
  23243. return null;
  23244. }
  23245. const {
  23246. clientId,
  23247. rootClientId,
  23248. name,
  23249. isValid,
  23250. isEmptyDefaultBlock,
  23251. capturingClientId
  23252. } = selected;
  23253. if (!name) {
  23254. return null;
  23255. }
  23256. return Object(external_wp_element_["createElement"])(BlockPopover, {
  23257. clientId: clientId,
  23258. rootClientId: rootClientId,
  23259. isValid: isValid,
  23260. isEmptyDefaultBlock: isEmptyDefaultBlock,
  23261. capturingClientId: capturingClientId,
  23262. __unstablePopoverSlot: __unstablePopoverSlot,
  23263. __unstableContentRef: __unstableContentRef
  23264. });
  23265. }
  23266. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/back-compat.js
  23267. /**
  23268. * WordPress dependencies
  23269. */
  23270. /**
  23271. * Internal dependencies
  23272. */
  23273. function BlockToolsBackCompat({
  23274. children
  23275. }) {
  23276. const openRef = Object(external_wp_element_["useContext"])(InsertionPointOpenRef);
  23277. const isDisabled = Object(external_wp_element_["useContext"])(external_wp_components_["Disabled"].Context); // If context is set, `BlockTools` is a parent component.
  23278. if (openRef || isDisabled) {
  23279. return children;
  23280. }
  23281. external_wp_deprecated_default()('wp.components.Popover.Slot name="block-toolbar"', {
  23282. alternative: 'wp.blockEditor.BlockTools'
  23283. });
  23284. return Object(external_wp_element_["createElement"])(InsertionPoint, {
  23285. __unstablePopoverSlot: "block-toolbar"
  23286. }, Object(external_wp_element_["createElement"])(WrappedBlockPopover, {
  23287. __unstablePopoverSlot: "block-toolbar"
  23288. }), children);
  23289. }
  23290. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-selection-clearer/index.js
  23291. /**
  23292. * WordPress dependencies
  23293. */
  23294. /**
  23295. * Internal dependencies
  23296. */
  23297. /**
  23298. * Pass the returned ref callback to an element that should clear block
  23299. * selection. Selection will only be cleared if the element is clicked directly,
  23300. * not if a child element is clicked.
  23301. *
  23302. * @return {import('react').RefCallback} Ref callback.
  23303. */
  23304. function useBlockSelectionClearer() {
  23305. const {
  23306. hasSelectedBlock,
  23307. hasMultiSelection
  23308. } = Object(external_wp_data_["useSelect"])(store);
  23309. const {
  23310. clearSelectedBlock
  23311. } = Object(external_wp_data_["useDispatch"])(store);
  23312. return Object(external_wp_compose_["useRefEffect"])(node => {
  23313. function onMouseDown(event) {
  23314. if (!hasSelectedBlock() && !hasMultiSelection()) {
  23315. return;
  23316. } // Only handle clicks on the element, not the children.
  23317. if (event.target !== node) {
  23318. return;
  23319. }
  23320. clearSelectedBlock();
  23321. }
  23322. node.addEventListener('mousedown', onMouseDown);
  23323. return () => {
  23324. node.removeEventListener('mousedown', onMouseDown);
  23325. };
  23326. }, [hasSelectedBlock, hasMultiSelection, clearSelectedBlock]);
  23327. }
  23328. function BlockSelectionClearer(props) {
  23329. return Object(external_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({
  23330. ref: useBlockSelectionClearer()
  23331. }, props));
  23332. }
  23333. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/index.js
  23334. /**
  23335. * External dependencies
  23336. */
  23337. /**
  23338. * WordPress dependencies
  23339. */
  23340. /**
  23341. * Internal dependencies
  23342. */
  23343. const IntersectionObserver = Object(external_wp_element_["createContext"])();
  23344. function Root({
  23345. className,
  23346. children
  23347. }) {
  23348. const isLargeViewport = Object(external_wp_compose_["useViewportMatch"])('medium');
  23349. const {
  23350. isOutlineMode,
  23351. isFocusMode,
  23352. isNavigationMode
  23353. } = Object(external_wp_data_["useSelect"])(select => {
  23354. const {
  23355. getSettings,
  23356. isNavigationMode: _isNavigationMode
  23357. } = select(store);
  23358. const {
  23359. outlineMode,
  23360. focusMode
  23361. } = getSettings();
  23362. return {
  23363. isOutlineMode: outlineMode,
  23364. isFocusMode: focusMode,
  23365. isNavigationMode: _isNavigationMode()
  23366. };
  23367. }, []);
  23368. return Object(external_wp_element_["createElement"])(Head, null, Object(external_wp_element_["createElement"])("div", {
  23369. ref: Object(external_wp_compose_["useMergeRefs"])([useBlockSelectionClearer(), useBlockDropZone(), useInBetweenInserter()]),
  23370. className: classnames_default()('block-editor-block-list__layout is-root-container', className, {
  23371. 'is-outline-mode': isOutlineMode,
  23372. 'is-focus-mode': isFocusMode && isLargeViewport,
  23373. 'is-navigate-mode': isNavigationMode
  23374. })
  23375. }, children));
  23376. }
  23377. function BlockList({
  23378. className,
  23379. ...props
  23380. }) {
  23381. usePreParsePatterns();
  23382. return Object(external_wp_element_["createElement"])(BlockToolsBackCompat, null, Object(external_wp_element_["createElement"])(Root, {
  23383. className: className
  23384. }, Object(external_wp_element_["createElement"])(BlockListItems, props)));
  23385. }
  23386. function Items({
  23387. placeholder,
  23388. rootClientId,
  23389. renderAppender,
  23390. __experimentalAppenderTagName,
  23391. __experimentalLayout: layout = layout_defaultLayout
  23392. }) {
  23393. const [intersectingBlocks, setIntersectingBlocks] = Object(external_wp_element_["useState"])(new Set());
  23394. const intersectionObserver = Object(external_wp_element_["useMemo"])(() => {
  23395. const {
  23396. IntersectionObserver: Observer
  23397. } = window;
  23398. if (!Observer) {
  23399. return;
  23400. }
  23401. return new Observer(entries => {
  23402. setIntersectingBlocks(oldIntersectingBlocks => {
  23403. const newIntersectingBlocks = new Set(oldIntersectingBlocks);
  23404. for (const entry of entries) {
  23405. const clientId = entry.target.getAttribute('data-block');
  23406. const action = entry.isIntersecting ? 'add' : 'delete';
  23407. newIntersectingBlocks[action](clientId);
  23408. }
  23409. return newIntersectingBlocks;
  23410. });
  23411. });
  23412. }, [setIntersectingBlocks]);
  23413. const {
  23414. order,
  23415. selectedBlocks
  23416. } = Object(external_wp_data_["useSelect"])(select => {
  23417. const {
  23418. getBlockOrder,
  23419. getSelectedBlockClientIds
  23420. } = select(store);
  23421. return {
  23422. order: getBlockOrder(rootClientId),
  23423. selectedBlocks: getSelectedBlockClientIds()
  23424. };
  23425. }, [rootClientId]);
  23426. return Object(external_wp_element_["createElement"])(LayoutProvider, {
  23427. value: layout
  23428. }, Object(external_wp_element_["createElement"])(IntersectionObserver.Provider, {
  23429. value: intersectionObserver
  23430. }, order.map(clientId => Object(external_wp_element_["createElement"])(external_wp_data_["AsyncModeProvider"], {
  23431. key: clientId,
  23432. value: // Only provide data asynchronously if the block is
  23433. // not visible and not selected.
  23434. !intersectingBlocks.has(clientId) && !selectedBlocks.includes(clientId)
  23435. }, Object(external_wp_element_["createElement"])(block_list_block, {
  23436. rootClientId: rootClientId,
  23437. clientId: clientId
  23438. })))), order.length < 1 && placeholder, Object(external_wp_element_["createElement"])(block_list_appender, {
  23439. tagName: __experimentalAppenderTagName,
  23440. rootClientId: rootClientId,
  23441. renderAppender: renderAppender
  23442. }));
  23443. }
  23444. function BlockListItems(props) {
  23445. // This component needs to always be synchronous as it's the one changing
  23446. // the async mode depending on the block selection.
  23447. return Object(external_wp_element_["createElement"])(external_wp_data_["AsyncModeProvider"], {
  23448. value: false
  23449. }, Object(external_wp_element_["createElement"])(Items, props));
  23450. }
  23451. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-intersection-observer.js
  23452. /**
  23453. * WordPress dependencies
  23454. */
  23455. /**
  23456. * Internal dependencies
  23457. */
  23458. function useIntersectionObserver() {
  23459. const observer = Object(external_wp_element_["useContext"])(IntersectionObserver);
  23460. return Object(external_wp_compose_["useRefEffect"])(node => {
  23461. if (observer) {
  23462. observer.observe(node);
  23463. return () => {
  23464. observer.unobserve(node);
  23465. };
  23466. }
  23467. }, [observer]);
  23468. }
  23469. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/index.js
  23470. /**
  23471. * External dependencies
  23472. */
  23473. /**
  23474. * WordPress dependencies
  23475. */
  23476. /**
  23477. * Internal dependencies
  23478. */
  23479. /**
  23480. * If the block count exceeds the threshold, we disable the reordering animation
  23481. * to avoid laginess.
  23482. */
  23483. const BLOCK_ANIMATION_THRESHOLD = 200;
  23484. /**
  23485. * This hook is used to lightly mark an element as a block element. The element
  23486. * should be the outermost element of a block. Call this hook and pass the
  23487. * returned props to the element to mark as a block. If you define a ref for the
  23488. * element, it is important to pass the ref to this hook, which the hook in turn
  23489. * will pass to the component through the props it returns. Optionally, you can
  23490. * also pass any other props through this hook, and they will be merged and
  23491. * returned.
  23492. *
  23493. * @param {Object} props Optional. Props to pass to the element. Must contain
  23494. * the ref if one is defined.
  23495. * @param {Object} options Options for internal use only.
  23496. * @param {boolean} options.__unstableIsHtml
  23497. *
  23498. * @return {Object} Props to pass to the element to mark as a block.
  23499. */
  23500. function useBlockProps(props = {}, {
  23501. __unstableIsHtml
  23502. } = {}) {
  23503. const {
  23504. clientId,
  23505. className,
  23506. wrapperProps = {},
  23507. isAligned
  23508. } = Object(external_wp_element_["useContext"])(BlockListBlockContext);
  23509. const {
  23510. index,
  23511. mode,
  23512. name,
  23513. blockTitle,
  23514. isPartOfSelection,
  23515. adjustScrolling,
  23516. enableAnimation
  23517. } = Object(external_wp_data_["useSelect"])(select => {
  23518. const {
  23519. getBlockRootClientId,
  23520. getBlockIndex,
  23521. getBlockMode,
  23522. getBlockName,
  23523. isTyping,
  23524. getGlobalBlockCount,
  23525. isBlockSelected,
  23526. isBlockMultiSelected,
  23527. isAncestorMultiSelected,
  23528. isFirstMultiSelectedBlock
  23529. } = select(store);
  23530. const isSelected = isBlockSelected(clientId);
  23531. const isPartOfMultiSelection = isBlockMultiSelected(clientId) || isAncestorMultiSelected(clientId);
  23532. const blockName = getBlockName(clientId);
  23533. const rootClientId = getBlockRootClientId(clientId);
  23534. return {
  23535. index: getBlockIndex(clientId, rootClientId),
  23536. mode: getBlockMode(clientId),
  23537. name: blockName,
  23538. blockTitle: Object(external_wp_blocks_["getBlockType"])(blockName).title,
  23539. isPartOfSelection: isSelected || isPartOfMultiSelection,
  23540. adjustScrolling: isSelected || isFirstMultiSelectedBlock(clientId),
  23541. enableAnimation: !isTyping() && getGlobalBlockCount() <= BLOCK_ANIMATION_THRESHOLD
  23542. };
  23543. }, [clientId]); // translators: %s: Type of block (i.e. Text, Image etc)
  23544. const blockLabel = Object(external_wp_i18n_["sprintf"])(Object(external_wp_i18n_["__"])('Block: %s'), blockTitle);
  23545. const htmlSuffix = mode === 'html' && !__unstableIsHtml ? '-visual' : '';
  23546. const mergedRefs = Object(external_wp_compose_["useMergeRefs"])([props.ref, useFocusFirstElement(clientId), // Must happen after focus because we check for focus in the block.
  23547. useScrollIntoView(clientId), useBlockRefProvider(clientId), useFocusHandler(clientId), useMultiSelection(clientId), useEventHandlers(clientId), useNavModeExit(clientId), useIsHovered(), useIntersectionObserver(), use_moving_animation({
  23548. isSelected: isPartOfSelection,
  23549. adjustScrolling,
  23550. enableAnimation,
  23551. triggerAnimationOnChange: index
  23552. })]);
  23553. return { ...wrapperProps,
  23554. ...props,
  23555. ref: mergedRefs,
  23556. id: `block-${clientId}${htmlSuffix}`,
  23557. tabIndex: 0,
  23558. role: 'group',
  23559. 'aria-label': blockLabel,
  23560. 'data-block': clientId,
  23561. 'data-type': name,
  23562. 'data-title': blockTitle,
  23563. className: classnames_default()( // The wp-block className is important for editor styles.
  23564. classnames_default()('block-editor-block-list__block', {
  23565. 'wp-block': !isAligned
  23566. }), className, props.className, wrapperProps.className, useBlockClassNames(clientId), useBlockDefaultClassName(clientId), useBlockCustomClassName(clientId), useBlockMovingModeClassNames(clientId)),
  23567. style: { ...wrapperProps.style,
  23568. ...props.style
  23569. }
  23570. };
  23571. }
  23572. /**
  23573. * Call within a save function to get the props for the block wrapper.
  23574. *
  23575. * @param {Object} props Optional. Props to pass to the element.
  23576. */
  23577. useBlockProps.save = external_wp_blocks_["__unstableGetBlockProps"];
  23578. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block.js
  23579. /**
  23580. * External dependencies
  23581. */
  23582. /**
  23583. * WordPress dependencies
  23584. */
  23585. /**
  23586. * Internal dependencies
  23587. */
  23588. const BlockListBlockContext = Object(external_wp_element_["createContext"])();
  23589. /**
  23590. * Merges wrapper props with special handling for classNames and styles.
  23591. *
  23592. * @param {Object} propsA
  23593. * @param {Object} propsB
  23594. *
  23595. * @return {Object} Merged props.
  23596. */
  23597. function mergeWrapperProps(propsA, propsB) {
  23598. const newProps = { ...propsA,
  23599. ...propsB
  23600. };
  23601. if (propsA && propsB && propsA.className && propsB.className) {
  23602. newProps.className = classnames_default()(propsA.className, propsB.className);
  23603. }
  23604. if (propsA && propsB && propsA.style && propsB.style) {
  23605. newProps.style = { ...propsA.style,
  23606. ...propsB.style
  23607. };
  23608. }
  23609. return newProps;
  23610. }
  23611. function Block({
  23612. children,
  23613. isHtml,
  23614. ...props
  23615. }) {
  23616. return Object(external_wp_element_["createElement"])("div", useBlockProps(props, {
  23617. __unstableIsHtml: isHtml
  23618. }), children);
  23619. }
  23620. function block_BlockListBlock({
  23621. mode,
  23622. isLocked,
  23623. clientId,
  23624. isSelected,
  23625. isSelectionEnabled,
  23626. className,
  23627. name,
  23628. isValid,
  23629. attributes,
  23630. wrapperProps,
  23631. setAttributes,
  23632. onReplace,
  23633. onInsertBlocksAfter,
  23634. onMerge,
  23635. toggleSelection
  23636. }) {
  23637. const {
  23638. removeBlock
  23639. } = Object(external_wp_data_["useDispatch"])(store);
  23640. const onRemove = Object(external_wp_element_["useCallback"])(() => removeBlock(clientId), [clientId]); // We wrap the BlockEdit component in a div that hides it when editing in
  23641. // HTML mode. This allows us to render all of the ancillary pieces
  23642. // (InspectorControls, etc.) which are inside `BlockEdit` but not
  23643. // `BlockHTML`, even in HTML mode.
  23644. let blockEdit = Object(external_wp_element_["createElement"])(block_edit_BlockEdit, {
  23645. name: name,
  23646. isSelected: isSelected,
  23647. attributes: attributes,
  23648. setAttributes: setAttributes,
  23649. insertBlocksAfter: isLocked ? undefined : onInsertBlocksAfter,
  23650. onReplace: isLocked ? undefined : onReplace,
  23651. onRemove: isLocked ? undefined : onRemove,
  23652. mergeBlocks: isLocked ? undefined : onMerge,
  23653. clientId: clientId,
  23654. isSelectionEnabled: isSelectionEnabled,
  23655. toggleSelection: toggleSelection
  23656. });
  23657. const blockType = Object(external_wp_blocks_["getBlockType"])(name);
  23658. const lightBlockWrapper = blockType.apiVersion > 1 || Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'lightBlockWrapper', false); // Determine whether the block has props to apply to the wrapper.
  23659. if (blockType.getEditWrapperProps) {
  23660. wrapperProps = mergeWrapperProps(wrapperProps, blockType.getEditWrapperProps(attributes));
  23661. }
  23662. const isAligned = wrapperProps && !!wrapperProps['data-align']; // For aligned blocks, provide a wrapper element so the block can be
  23663. // positioned relative to the block column.
  23664. if (isAligned) {
  23665. blockEdit = Object(external_wp_element_["createElement"])("div", {
  23666. className: "wp-block",
  23667. "data-align": wrapperProps['data-align']
  23668. }, blockEdit);
  23669. }
  23670. let block;
  23671. if (!isValid) {
  23672. const saveContent = Object(external_wp_blocks_["getSaveContent"])(blockType, attributes);
  23673. block = Object(external_wp_element_["createElement"])(Block, {
  23674. className: "has-warning"
  23675. }, Object(external_wp_element_["createElement"])(block_invalid_warning, {
  23676. clientId: clientId
  23677. }), Object(external_wp_element_["createElement"])(external_wp_element_["RawHTML"], null, Object(external_wp_dom_["safeHTML"])(saveContent)));
  23678. } else if (mode === 'html') {
  23679. // Render blockEdit so the inspector controls don't disappear.
  23680. // See #8969.
  23681. block = Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])("div", {
  23682. style: {
  23683. display: 'none'
  23684. }
  23685. }, blockEdit), Object(external_wp_element_["createElement"])(Block, {
  23686. isHtml: true
  23687. }, Object(external_wp_element_["createElement"])(block_html, {
  23688. clientId: clientId
  23689. })));
  23690. } else if (lightBlockWrapper) {
  23691. block = blockEdit;
  23692. } else {
  23693. block = Object(external_wp_element_["createElement"])(Block, wrapperProps, blockEdit);
  23694. }
  23695. const value = {
  23696. clientId,
  23697. className,
  23698. wrapperProps: Object(external_lodash_["omit"])(wrapperProps, ['data-align']),
  23699. isAligned
  23700. };
  23701. const memoizedValue = Object(external_wp_element_["useMemo"])(() => value, Object.values(value));
  23702. return Object(external_wp_element_["createElement"])(BlockListBlockContext.Provider, {
  23703. value: memoizedValue
  23704. }, Object(external_wp_element_["createElement"])(block_crash_boundary, {
  23705. fallback: Object(external_wp_element_["createElement"])(Block, {
  23706. className: "has-warning"
  23707. }, Object(external_wp_element_["createElement"])(block_crash_warning, null))
  23708. }, block));
  23709. }
  23710. const applyWithSelect = Object(external_wp_data_["withSelect"])((select, {
  23711. clientId,
  23712. rootClientId
  23713. }) => {
  23714. const {
  23715. isBlockSelected,
  23716. getBlockMode,
  23717. isSelectionEnabled,
  23718. getTemplateLock,
  23719. __unstableGetBlockWithoutInnerBlocks
  23720. } = select(store);
  23721. const block = __unstableGetBlockWithoutInnerBlocks(clientId);
  23722. const isSelected = isBlockSelected(clientId);
  23723. const templateLock = getTemplateLock(rootClientId); // The fallback to `{}` is a temporary fix.
  23724. // This function should never be called when a block is not present in
  23725. // the state. It happens now because the order in withSelect rendering
  23726. // is not correct.
  23727. const {
  23728. name,
  23729. attributes,
  23730. isValid
  23731. } = block || {}; // Do not add new properties here, use `useSelect` instead to avoid
  23732. // leaking new props to the public API (editor.BlockListBlock filter).
  23733. return {
  23734. mode: getBlockMode(clientId),
  23735. isSelectionEnabled: isSelectionEnabled(),
  23736. isLocked: !!templateLock,
  23737. // Users of the editor.BlockListBlock filter used to be able to
  23738. // access the block prop.
  23739. // Ideally these blocks would rely on the clientId prop only.
  23740. // This is kept for backward compatibility reasons.
  23741. block,
  23742. name,
  23743. attributes,
  23744. isValid,
  23745. isSelected
  23746. };
  23747. });
  23748. const applyWithDispatch = Object(external_wp_data_["withDispatch"])((dispatch, ownProps, {
  23749. select
  23750. }) => {
  23751. const {
  23752. updateBlockAttributes,
  23753. insertBlocks,
  23754. mergeBlocks,
  23755. replaceBlocks,
  23756. toggleSelection,
  23757. __unstableMarkLastChangeAsPersistent
  23758. } = dispatch(store); // Do not add new properties here, use `useDispatch` instead to avoid
  23759. // leaking new props to the public API (editor.BlockListBlock filter).
  23760. return {
  23761. setAttributes(newAttributes) {
  23762. const {
  23763. getMultiSelectedBlockClientIds
  23764. } = select(store);
  23765. const multiSelectedBlockClientIds = getMultiSelectedBlockClientIds();
  23766. const {
  23767. clientId
  23768. } = ownProps;
  23769. const clientIds = multiSelectedBlockClientIds.length ? multiSelectedBlockClientIds : [clientId];
  23770. updateBlockAttributes(clientIds, newAttributes);
  23771. },
  23772. onInsertBlocks(blocks, index) {
  23773. const {
  23774. rootClientId
  23775. } = ownProps;
  23776. insertBlocks(blocks, index, rootClientId);
  23777. },
  23778. onInsertBlocksAfter(blocks) {
  23779. const {
  23780. clientId,
  23781. rootClientId
  23782. } = ownProps;
  23783. const {
  23784. getBlockIndex
  23785. } = select(store);
  23786. const index = getBlockIndex(clientId, rootClientId);
  23787. insertBlocks(blocks, index + 1, rootClientId);
  23788. },
  23789. onMerge(forward) {
  23790. const {
  23791. clientId
  23792. } = ownProps;
  23793. const {
  23794. getPreviousBlockClientId,
  23795. getNextBlockClientId
  23796. } = select(store);
  23797. if (forward) {
  23798. const nextBlockClientId = getNextBlockClientId(clientId);
  23799. if (nextBlockClientId) {
  23800. mergeBlocks(clientId, nextBlockClientId);
  23801. }
  23802. } else {
  23803. const previousBlockClientId = getPreviousBlockClientId(clientId);
  23804. if (previousBlockClientId) {
  23805. mergeBlocks(previousBlockClientId, clientId);
  23806. }
  23807. }
  23808. },
  23809. onReplace(blocks, indexToSelect, initialPosition) {
  23810. if (blocks.length && !Object(external_wp_blocks_["isUnmodifiedDefaultBlock"])(blocks[blocks.length - 1])) {
  23811. __unstableMarkLastChangeAsPersistent();
  23812. }
  23813. replaceBlocks([ownProps.clientId], blocks, indexToSelect, initialPosition);
  23814. },
  23815. toggleSelection(selectionEnabled) {
  23816. toggleSelection(selectionEnabled);
  23817. }
  23818. };
  23819. });
  23820. /* harmony default export */ var block_list_block = (Object(external_wp_compose_["compose"])(external_wp_compose_["pure"], applyWithSelect, applyWithDispatch, // block is sometimes not mounted at the right time, causing it be undefined
  23821. // see issue for more info
  23822. // https://github.com/WordPress/gutenberg/issues/17013
  23823. Object(external_wp_compose_["ifCondition"])(({
  23824. block
  23825. }) => !!block), Object(external_wp_components_["withFilters"])('editor.BlockListBlock'))(block_BlockListBlock));
  23826. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/utils.js
  23827. /**
  23828. * External dependencies
  23829. */
  23830. /**
  23831. * WordPress dependencies
  23832. */
  23833. const getBlockPositionDescription = (position, siblingCount, level) => Object(external_wp_i18n_["sprintf"])(
  23834. /* translators: 1: The numerical position of the block. 2: The total number of blocks. 3. The level of nesting for the block. */
  23835. Object(external_wp_i18n_["__"])('Block %1$d of %2$d, Level %3$d'), position, siblingCount, level);
  23836. /**
  23837. * Returns true if the client ID occurs within the block selection or multi-selection,
  23838. * or false otherwise.
  23839. *
  23840. * @param {string} clientId Block client ID.
  23841. * @param {string|string[]} selectedBlockClientIds Selected block client ID, or an array of multi-selected blocks client IDs.
  23842. *
  23843. * @return {boolean} Whether the block is in multi-selection set.
  23844. */
  23845. const isClientIdSelected = (clientId, selectedBlockClientIds) => Object(external_lodash_["isArray"])(selectedBlockClientIds) && selectedBlockClientIds.length ? selectedBlockClientIds.indexOf(clientId) !== -1 : selectedBlockClientIds === clientId;
  23846. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/block-select-button.js
  23847. /**
  23848. * External dependencies
  23849. */
  23850. /**
  23851. * WordPress dependencies
  23852. */
  23853. /**
  23854. * Internal dependencies
  23855. */
  23856. function BlockNavigationBlockSelectButton({
  23857. className,
  23858. block: {
  23859. clientId
  23860. },
  23861. isSelected,
  23862. onClick,
  23863. position,
  23864. siblingBlockCount,
  23865. level,
  23866. tabIndex,
  23867. onFocus,
  23868. onDragStart,
  23869. onDragEnd,
  23870. draggable
  23871. }, ref) {
  23872. const blockInformation = useBlockDisplayInformation(clientId);
  23873. const instanceId = Object(external_wp_compose_["useInstanceId"])(BlockNavigationBlockSelectButton);
  23874. const descriptionId = `block-navigation-block-select-button__${instanceId}`;
  23875. const blockPositionDescription = getBlockPositionDescription(position, siblingBlockCount, level);
  23876. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  23877. className: classnames_default()('block-editor-block-navigation-block-select-button', className),
  23878. onClick: onClick,
  23879. "aria-describedby": descriptionId,
  23880. ref: ref,
  23881. tabIndex: tabIndex,
  23882. onFocus: onFocus,
  23883. onDragStart: onDragStart,
  23884. onDragEnd: onDragEnd,
  23885. draggable: draggable
  23886. }, Object(external_wp_element_["createElement"])(BlockIcon, {
  23887. icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon,
  23888. showColors: true
  23889. }), Object(external_wp_element_["createElement"])(BlockTitle, {
  23890. clientId: clientId
  23891. }), (blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.anchor) && Object(external_wp_element_["createElement"])("span", {
  23892. className: "block-editor-block-navigation-block-select-button__anchor"
  23893. }, blockInformation.anchor), isSelected && Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], null, Object(external_wp_i18n_["__"])('(selected block)'))), Object(external_wp_element_["createElement"])("div", {
  23894. className: "block-editor-block-navigation-block-select-button__description",
  23895. id: descriptionId
  23896. }, blockPositionDescription));
  23897. }
  23898. /* harmony default export */ var block_select_button = (Object(external_wp_element_["forwardRef"])(BlockNavigationBlockSelectButton));
  23899. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/block-slot.js
  23900. /**
  23901. * External dependencies
  23902. */
  23903. /**
  23904. * WordPress dependencies
  23905. */
  23906. /**
  23907. * Internal dependencies
  23908. */
  23909. const getSlotName = clientId => `BlockNavigationBlock-${clientId}`;
  23910. function BlockNavigationBlockSlot(props, ref) {
  23911. const {
  23912. clientId
  23913. } = props.block;
  23914. const {
  23915. name
  23916. } = Object(external_wp_data_["useSelect"])(select => select(store).getBlockName(clientId), [clientId]);
  23917. const instanceId = Object(external_wp_compose_["useInstanceId"])(BlockNavigationBlockSlot);
  23918. return Object(external_wp_element_["createElement"])(external_wp_components_["Slot"], {
  23919. name: getSlotName(clientId)
  23920. }, fills => {
  23921. if (!fills.length) {
  23922. return Object(external_wp_element_["createElement"])(block_select_button, Object(esm_extends["a" /* default */])({
  23923. ref: ref
  23924. }, props));
  23925. }
  23926. const {
  23927. className,
  23928. isSelected,
  23929. position,
  23930. siblingBlockCount,
  23931. level,
  23932. tabIndex,
  23933. onFocus
  23934. } = props;
  23935. const blockType = Object(external_wp_blocks_["getBlockType"])(name);
  23936. const descriptionId = `block-navigation-block-slot__${instanceId}`;
  23937. const blockPositionDescription = getBlockPositionDescription(position, siblingBlockCount, level);
  23938. const forwardedFillProps = {
  23939. // Ensure that the component in the slot can receive
  23940. // keyboard navigation.
  23941. tabIndex,
  23942. onFocus,
  23943. ref,
  23944. // Give the element rendered in the slot a description
  23945. // that describes its position.
  23946. 'aria-describedby': descriptionId
  23947. };
  23948. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])("div", {
  23949. className: classnames_default()('block-editor-block-navigation-block-slot', className)
  23950. }, Object(external_wp_element_["createElement"])(BlockIcon, {
  23951. icon: blockType.icon,
  23952. showColors: true
  23953. }), external_wp_element_["Children"].map(fills, fill => Object(external_wp_element_["cloneElement"])(fill, { ...fill.props,
  23954. ...forwardedFillProps
  23955. })), isSelected && Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], null, Object(external_wp_i18n_["__"])('(selected block)')), Object(external_wp_element_["createElement"])("div", {
  23956. className: "block-editor-block-navigation-block-slot__description",
  23957. id: descriptionId
  23958. }, blockPositionDescription)));
  23959. });
  23960. }
  23961. /* harmony default export */ var block_slot = (Object(external_wp_element_["forwardRef"])(BlockNavigationBlockSlot));
  23962. const BlockNavigationBlockFill = props => {
  23963. const {
  23964. clientId
  23965. } = Object(external_wp_element_["useContext"])(BlockListBlockContext);
  23966. return Object(external_wp_element_["createElement"])(external_wp_components_["Fill"], Object(esm_extends["a" /* default */])({}, props, {
  23967. name: getSlotName(clientId)
  23968. }));
  23969. };
  23970. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/block-contents.js
  23971. /**
  23972. * External dependencies
  23973. */
  23974. /**
  23975. * WordPress dependencies
  23976. */
  23977. /**
  23978. * Internal dependencies
  23979. */
  23980. const BlockNavigationBlockContents = Object(external_wp_element_["forwardRef"])(({
  23981. onClick,
  23982. block,
  23983. isSelected,
  23984. position,
  23985. siblingBlockCount,
  23986. level,
  23987. ...props
  23988. }, ref) => {
  23989. const {
  23990. __experimentalFeatures,
  23991. blockDropTarget = {}
  23992. } = useBlockNavigationContext();
  23993. const {
  23994. clientId
  23995. } = block;
  23996. const {
  23997. rootClientId,
  23998. blockMovingClientId,
  23999. selectedBlockInBlockEditor
  24000. } = Object(external_wp_data_["useSelect"])(select => {
  24001. const {
  24002. getBlockRootClientId,
  24003. hasBlockMovingClientId,
  24004. getSelectedBlockClientId
  24005. } = select(store);
  24006. return {
  24007. rootClientId: getBlockRootClientId(clientId) || '',
  24008. blockMovingClientId: hasBlockMovingClientId(),
  24009. selectedBlockInBlockEditor: getSelectedBlockClientId()
  24010. };
  24011. }, [clientId]);
  24012. const isBlockMoveTarget = blockMovingClientId && selectedBlockInBlockEditor === clientId;
  24013. const {
  24014. rootClientId: dropTargetRootClientId,
  24015. clientId: dropTargetClientId,
  24016. dropPosition
  24017. } = blockDropTarget;
  24018. const isDroppingBefore = dropTargetRootClientId === rootClientId && dropTargetClientId === clientId && dropPosition === 'top';
  24019. const isDroppingAfter = dropTargetRootClientId === rootClientId && dropTargetClientId === clientId && dropPosition === 'bottom';
  24020. const isDroppingToInnerBlocks = dropTargetRootClientId === clientId && dropPosition === 'inside';
  24021. const className = classnames_default()('block-editor-block-navigation-block-contents', {
  24022. 'is-dropping-before': isDroppingBefore || isBlockMoveTarget,
  24023. 'is-dropping-after': isDroppingAfter,
  24024. 'is-dropping-to-inner-blocks': isDroppingToInnerBlocks
  24025. });
  24026. return Object(external_wp_element_["createElement"])(block_draggable, {
  24027. clientIds: [block.clientId],
  24028. elementId: `block-navigation-block-${block.clientId}`
  24029. }, ({
  24030. draggable,
  24031. onDragStart,
  24032. onDragEnd
  24033. }) => __experimentalFeatures ? Object(external_wp_element_["createElement"])(block_slot, Object(esm_extends["a" /* default */])({
  24034. ref: ref,
  24035. className: className,
  24036. block: block,
  24037. onClick: onClick,
  24038. isSelected: isSelected,
  24039. position: position,
  24040. siblingBlockCount: siblingBlockCount,
  24041. level: level,
  24042. draggable: draggable && __experimentalFeatures,
  24043. onDragStart: onDragStart,
  24044. onDragEnd: onDragEnd
  24045. }, props)) : Object(external_wp_element_["createElement"])(block_select_button, Object(esm_extends["a" /* default */])({
  24046. ref: ref,
  24047. className: className,
  24048. block: block,
  24049. onClick: onClick,
  24050. isSelected: isSelected,
  24051. position: position,
  24052. siblingBlockCount: siblingBlockCount,
  24053. level: level,
  24054. draggable: draggable && __experimentalFeatures,
  24055. onDragStart: onDragStart,
  24056. onDragEnd: onDragEnd
  24057. }, props)));
  24058. });
  24059. /* harmony default export */ var block_contents = (BlockNavigationBlockContents);
  24060. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/block.js
  24061. /**
  24062. * External dependencies
  24063. */
  24064. /**
  24065. * WordPress dependencies
  24066. */
  24067. /**
  24068. * Internal dependencies
  24069. */
  24070. function BlockNavigationBlock({
  24071. block,
  24072. isSelected,
  24073. isBranchSelected,
  24074. isLastOfSelectedBranch,
  24075. onClick,
  24076. position,
  24077. level,
  24078. rowCount,
  24079. siblingBlockCount,
  24080. showBlockMovers,
  24081. path
  24082. }) {
  24083. const cellRef = Object(external_wp_element_["useRef"])(null);
  24084. const [isHovered, setIsHovered] = Object(external_wp_element_["useState"])(false);
  24085. const {
  24086. clientId
  24087. } = block;
  24088. const {
  24089. isDragging,
  24090. blockParents
  24091. } = Object(external_wp_data_["useSelect"])(select => {
  24092. const {
  24093. isBlockBeingDragged,
  24094. isAncestorBeingDragged,
  24095. getBlockParents
  24096. } = select(store);
  24097. return {
  24098. isDragging: isBlockBeingDragged(clientId) || isAncestorBeingDragged(clientId),
  24099. blockParents: getBlockParents(clientId)
  24100. };
  24101. }, [clientId]);
  24102. const {
  24103. selectBlock: selectEditorBlock,
  24104. toggleBlockHighlight
  24105. } = Object(external_wp_data_["useDispatch"])(store);
  24106. const hasSiblings = siblingBlockCount > 0;
  24107. const hasRenderedMovers = showBlockMovers && hasSiblings;
  24108. const moverCellClassName = classnames_default()('block-editor-block-navigation-block__mover-cell', {
  24109. 'is-visible': isHovered
  24110. });
  24111. const {
  24112. __experimentalFeatures: withExperimentalFeatures,
  24113. __experimentalPersistentListViewFeatures: withExperimentalPersistentListViewFeatures,
  24114. isTreeGridMounted
  24115. } = useBlockNavigationContext();
  24116. const blockNavigationBlockSettingsClassName = classnames_default()('block-editor-block-navigation-block__menu-cell', {
  24117. 'is-visible': isHovered
  24118. }); // If BlockNavigation has experimental features related to the Persistent List View,
  24119. // only focus the selected list item on mount; otherwise the list would always
  24120. // try to steal the focus from the editor canvas.
  24121. Object(external_wp_element_["useEffect"])(() => {
  24122. if (withExperimentalPersistentListViewFeatures && !isTreeGridMounted && isSelected) {
  24123. cellRef.current.focus();
  24124. }
  24125. }, []); // If BlockNavigation has experimental features (such as drag and drop) enabled,
  24126. // leave the focus handling as it was before, to avoid accidental regressions.
  24127. Object(external_wp_element_["useEffect"])(() => {
  24128. if (withExperimentalFeatures && isSelected) {
  24129. cellRef.current.focus();
  24130. }
  24131. }, [withExperimentalFeatures, isSelected]);
  24132. const highlightBlock = withExperimentalPersistentListViewFeatures ? toggleBlockHighlight : () => {};
  24133. const onMouseEnter = () => {
  24134. setIsHovered(true);
  24135. highlightBlock(clientId, true);
  24136. };
  24137. const onMouseLeave = () => {
  24138. setIsHovered(false);
  24139. highlightBlock(clientId, false);
  24140. };
  24141. const classes = classnames_default()({
  24142. 'is-selected': isSelected,
  24143. 'is-branch-selected': withExperimentalPersistentListViewFeatures && isBranchSelected,
  24144. 'is-last-of-selected-branch': withExperimentalPersistentListViewFeatures && isLastOfSelectedBranch,
  24145. 'is-dragging': isDragging
  24146. });
  24147. return Object(external_wp_element_["createElement"])(BlockNavigationLeaf, {
  24148. className: classes,
  24149. onMouseEnter: onMouseEnter,
  24150. onMouseLeave: onMouseLeave,
  24151. onFocus: onMouseEnter,
  24152. onBlur: onMouseLeave,
  24153. level: level,
  24154. position: position,
  24155. rowCount: rowCount,
  24156. path: path,
  24157. id: `block-navigation-block-${clientId}`,
  24158. "data-block": clientId
  24159. }, Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalTreeGridCell"], {
  24160. className: "block-editor-block-navigation-block__contents-cell",
  24161. colSpan: hasRenderedMovers ? undefined : 2,
  24162. ref: cellRef
  24163. }, ({
  24164. ref,
  24165. tabIndex,
  24166. onFocus
  24167. }) => Object(external_wp_element_["createElement"])("div", {
  24168. className: "block-editor-block-navigation-block__contents-container"
  24169. }, Object(external_wp_element_["createElement"])(block_contents, {
  24170. block: block,
  24171. onClick: () => onClick(block.clientId),
  24172. isSelected: isSelected,
  24173. position: position,
  24174. siblingBlockCount: siblingBlockCount,
  24175. level: level,
  24176. ref: ref,
  24177. tabIndex: tabIndex,
  24178. onFocus: onFocus
  24179. }))), hasRenderedMovers && Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalTreeGridCell"], {
  24180. className: moverCellClassName,
  24181. withoutGridItem: true
  24182. }, Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalTreeGridItem"], null, ({
  24183. ref,
  24184. tabIndex,
  24185. onFocus
  24186. }) => Object(external_wp_element_["createElement"])(BlockMoverUpButton, {
  24187. orientation: "vertical",
  24188. clientIds: [clientId],
  24189. ref: ref,
  24190. tabIndex: tabIndex,
  24191. onFocus: onFocus
  24192. })), Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalTreeGridItem"], null, ({
  24193. ref,
  24194. tabIndex,
  24195. onFocus
  24196. }) => Object(external_wp_element_["createElement"])(BlockMoverDownButton, {
  24197. orientation: "vertical",
  24198. clientIds: [clientId],
  24199. ref: ref,
  24200. tabIndex: tabIndex,
  24201. onFocus: onFocus
  24202. })))), withExperimentalFeatures && Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalTreeGridCell"], {
  24203. className: blockNavigationBlockSettingsClassName
  24204. }, ({
  24205. ref,
  24206. tabIndex,
  24207. onFocus
  24208. }) => Object(external_wp_element_["createElement"])(block_settings_dropdown, {
  24209. clientIds: [clientId],
  24210. icon: more_vertical["a" /* default */],
  24211. toggleProps: {
  24212. ref,
  24213. tabIndex,
  24214. onFocus
  24215. },
  24216. disableOpenOnArrowDown: true,
  24217. __experimentalSelectBlock: onClick
  24218. }, ({
  24219. onClose
  24220. }) => Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], null, Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  24221. onClick: async () => {
  24222. if (blockParents.length) {
  24223. // If the block to select is inside a dropdown, we need to open the dropdown.
  24224. // Otherwise focus won't transfer to the block.
  24225. for (const parent of blockParents) {
  24226. await selectEditorBlock(parent);
  24227. }
  24228. } else {
  24229. // If clientId is already selected, it won't be focused (see block-wrapper.js)
  24230. // This removes the selection first to ensure the focus will always switch.
  24231. await selectEditorBlock(null);
  24232. }
  24233. await selectEditorBlock(clientId);
  24234. onClose();
  24235. }
  24236. }, Object(external_wp_i18n_["__"])('Go to block'))))));
  24237. }
  24238. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/appender.js
  24239. /**
  24240. * External dependencies
  24241. */
  24242. /**
  24243. * WordPress dependencies
  24244. */
  24245. /**
  24246. * Internal dependencies
  24247. */
  24248. function BlockNavigationAppender({
  24249. parentBlockClientId,
  24250. position,
  24251. level,
  24252. rowCount,
  24253. path
  24254. }) {
  24255. const isDragging = Object(external_wp_data_["useSelect"])(select => {
  24256. const {
  24257. isBlockBeingDragged,
  24258. isAncestorBeingDragged
  24259. } = select(store);
  24260. return isBlockBeingDragged(parentBlockClientId) || isAncestorBeingDragged(parentBlockClientId);
  24261. }, [parentBlockClientId]);
  24262. const instanceId = Object(external_wp_compose_["useInstanceId"])(BlockNavigationAppender);
  24263. const descriptionId = `block-navigation-appender-row__description_${instanceId}`;
  24264. const appenderPositionDescription = Object(external_wp_i18n_["sprintf"])(
  24265. /* translators: 1: The numerical position of the block that will be inserted. 2: The level of nesting for the block that will be inserted. */
  24266. Object(external_wp_i18n_["__"])('Add block at position %1$d, Level %2$d'), position, level);
  24267. return Object(external_wp_element_["createElement"])(BlockNavigationLeaf, {
  24268. className: classnames_default()({
  24269. 'is-dragging': isDragging
  24270. }),
  24271. level: level,
  24272. position: position,
  24273. rowCount: rowCount,
  24274. path: path
  24275. }, Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalTreeGridCell"], {
  24276. className: "block-editor-block-navigation-appender__cell",
  24277. colSpan: "3"
  24278. }, ({
  24279. ref,
  24280. tabIndex,
  24281. onFocus
  24282. }) => Object(external_wp_element_["createElement"])("div", {
  24283. className: "block-editor-block-navigation-appender__container"
  24284. }, Object(external_wp_element_["createElement"])(inserter, {
  24285. rootClientId: parentBlockClientId,
  24286. __experimentalIsQuick: true,
  24287. "aria-describedby": descriptionId,
  24288. toggleProps: {
  24289. ref,
  24290. tabIndex,
  24291. onFocus
  24292. }
  24293. }), Object(external_wp_element_["createElement"])("div", {
  24294. className: "block-editor-block-navigation-appender__description",
  24295. id: descriptionId
  24296. }, appenderPositionDescription))));
  24297. }
  24298. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/branch.js
  24299. /**
  24300. * External dependencies
  24301. */
  24302. /**
  24303. * WordPress dependencies
  24304. */
  24305. /**
  24306. * Internal dependencies
  24307. */
  24308. function BlockNavigationBranch(props) {
  24309. const {
  24310. blocks,
  24311. selectBlock,
  24312. selectedBlockClientIds,
  24313. showAppender,
  24314. showBlockMovers,
  24315. showNestedBlocks,
  24316. parentBlockClientId,
  24317. level = 1,
  24318. terminatedLevels = [],
  24319. path = [],
  24320. isBranchSelected = false,
  24321. isLastOfBranch = false
  24322. } = props;
  24323. const isTreeRoot = !parentBlockClientId;
  24324. const filteredBlocks = Object(external_lodash_["compact"])(blocks);
  24325. const itemHasAppender = parentClientId => showAppender && !isTreeRoot && isClientIdSelected(parentClientId, selectedBlockClientIds);
  24326. const hasAppender = itemHasAppender(parentBlockClientId); // Add +1 to the rowCount to take the block appender into account.
  24327. const blockCount = filteredBlocks.length;
  24328. const rowCount = hasAppender ? blockCount + 1 : blockCount;
  24329. const appenderPosition = rowCount;
  24330. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_lodash_["map"])(filteredBlocks, (block, index) => {
  24331. const {
  24332. clientId,
  24333. innerBlocks
  24334. } = block;
  24335. const position = index + 1;
  24336. const isLastRowAtLevel = rowCount === position;
  24337. const updatedTerminatedLevels = isLastRowAtLevel ? [...terminatedLevels, level] : terminatedLevels;
  24338. const updatedPath = [...path, position];
  24339. const hasNestedBlocks = showNestedBlocks && !!innerBlocks && !!innerBlocks.length;
  24340. const hasNestedAppender = itemHasAppender(clientId);
  24341. const hasNestedBranch = hasNestedBlocks || hasNestedAppender;
  24342. const isSelected = isClientIdSelected(clientId, selectedBlockClientIds);
  24343. const isSelectedBranch = isBranchSelected || isSelected && hasNestedBranch; // Logic needed to target the last item of a selected branch which might be deeply nested.
  24344. // This is currently only needed for styling purposes. See: `.is-last-of-selected-branch`.
  24345. const isLastBlock = index === blockCount - 1;
  24346. const isLast = isSelected || isLastOfBranch && isLastBlock;
  24347. const isLastOfSelectedBranch = isLastOfBranch && !hasNestedBranch && isLastBlock;
  24348. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], {
  24349. key: clientId
  24350. }, Object(external_wp_element_["createElement"])(BlockNavigationBlock, {
  24351. block: block,
  24352. onClick: selectBlock,
  24353. isSelected: isSelected,
  24354. isBranchSelected: isSelectedBranch,
  24355. isLastOfSelectedBranch: isLastOfSelectedBranch,
  24356. level: level,
  24357. position: position,
  24358. rowCount: rowCount,
  24359. siblingBlockCount: blockCount,
  24360. showBlockMovers: showBlockMovers,
  24361. terminatedLevels: terminatedLevels,
  24362. path: updatedPath
  24363. }), hasNestedBranch && Object(external_wp_element_["createElement"])(BlockNavigationBranch, {
  24364. blocks: innerBlocks,
  24365. selectedBlockClientIds: selectedBlockClientIds,
  24366. selectBlock: selectBlock,
  24367. isBranchSelected: isSelectedBranch,
  24368. isLastOfBranch: isLast,
  24369. showAppender: showAppender,
  24370. showBlockMovers: showBlockMovers,
  24371. showNestedBlocks: showNestedBlocks,
  24372. parentBlockClientId: clientId,
  24373. level: level + 1,
  24374. terminatedLevels: updatedTerminatedLevels,
  24375. path: updatedPath
  24376. }));
  24377. }), hasAppender && Object(external_wp_element_["createElement"])(BlockNavigationAppender, {
  24378. parentBlockClientId: parentBlockClientId,
  24379. position: rowCount,
  24380. rowCount: appenderPosition,
  24381. level: level,
  24382. terminatedLevels: terminatedLevels,
  24383. path: [...path, appenderPosition]
  24384. }));
  24385. }
  24386. BlockNavigationBranch.defaultProps = {
  24387. selectBlock: () => {}
  24388. };
  24389. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/use-block-navigation-client-ids.js
  24390. /**
  24391. * WordPress dependencies
  24392. */
  24393. /**
  24394. * Internal dependencies
  24395. */
  24396. const useBlockNavigationSelectedClientIds = __experimentalPersistentListViewFeatures => Object(external_wp_data_["useSelect"])(select => {
  24397. const {
  24398. getSelectedBlockClientId,
  24399. getSelectedBlockClientIds
  24400. } = select(store);
  24401. if (__experimentalPersistentListViewFeatures) {
  24402. return getSelectedBlockClientIds();
  24403. }
  24404. return getSelectedBlockClientId();
  24405. }, [__experimentalPersistentListViewFeatures]);
  24406. const useBlockNavigationClientIdsTree = (blocks, selectedClientIds, showOnlyCurrentHierarchy) => Object(external_wp_data_["useSelect"])(select => {
  24407. const {
  24408. getBlockHierarchyRootClientId,
  24409. __unstableGetClientIdsTree,
  24410. __unstableGetClientIdWithClientIdsTree
  24411. } = select(store);
  24412. if (blocks) {
  24413. return blocks;
  24414. }
  24415. const isSingleBlockSelected = selectedClientIds && !Array.isArray(selectedClientIds);
  24416. if (!showOnlyCurrentHierarchy || !isSingleBlockSelected) {
  24417. return __unstableGetClientIdsTree();
  24418. }
  24419. const rootBlock = __unstableGetClientIdWithClientIdsTree(getBlockHierarchyRootClientId(selectedClientIds));
  24420. if (!rootBlock) {
  24421. return __unstableGetClientIdsTree();
  24422. }
  24423. const hasHierarchy = !isClientIdSelected(rootBlock.clientId, selectedClientIds) || rootBlock.innerBlocks && rootBlock.innerBlocks.length !== 0;
  24424. if (hasHierarchy) {
  24425. return [rootBlock];
  24426. }
  24427. return __unstableGetClientIdsTree();
  24428. }, [blocks, selectedClientIds, showOnlyCurrentHierarchy]);
  24429. function useBlockNavigationClientIds(blocks, showOnlyCurrentHierarchy, __experimentalPersistentListViewFeatures) {
  24430. const selectedClientIds = useBlockNavigationSelectedClientIds(__experimentalPersistentListViewFeatures);
  24431. const clientIdsTree = useBlockNavigationClientIdsTree(blocks, selectedClientIds, showOnlyCurrentHierarchy);
  24432. return {
  24433. clientIdsTree,
  24434. selectedClientIds
  24435. };
  24436. }
  24437. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/use-block-navigation-drop-zone.js
  24438. /**
  24439. * WordPress dependencies
  24440. */
  24441. /**
  24442. * Internal dependencies
  24443. */
  24444. /** @typedef {import('../../utils/math').WPPoint} WPPoint */
  24445. /**
  24446. * The type of a drag event.
  24447. *
  24448. * @typedef {'default'|'file'|'html'} WPDragEventType
  24449. */
  24450. /**
  24451. * An array representing data for blocks in the DOM used by drag and drop.
  24452. *
  24453. * @typedef {Object} WPBlockNavigationDropZoneBlocks
  24454. * @property {string} clientId The client id for the block.
  24455. * @property {string} rootClientId The root client id for the block.
  24456. * @property {number} blockIndex The block's index.
  24457. * @property {Element} element The DOM element representing the block.
  24458. * @property {number} innerBlockCount The number of inner blocks the block has.
  24459. * @property {boolean} isDraggedBlock Whether the block is currently being dragged.
  24460. * @property {boolean} canInsertDraggedBlocksAsSibling Whether the dragged block can be a sibling of this block.
  24461. * @property {boolean} canInsertDraggedBlocksAsChild Whether the dragged block can be a child of this block.
  24462. */
  24463. /**
  24464. * An object containing details of a drop target.
  24465. *
  24466. * @typedef {Object} WPBlockNavigationDropZoneTarget
  24467. * @property {string} blockIndex The insertion index.
  24468. * @property {string} rootClientId The root client id for the block.
  24469. * @property {string|undefined} clientId The client id for the block.
  24470. * @property {'top'|'bottom'|'inside'} dropPosition The position relative to the block that the user is dropping to.
  24471. * 'inside' refers to nesting as an inner block.
  24472. */
  24473. /**
  24474. * Is the point contained by the rectangle.
  24475. *
  24476. * @param {WPPoint} point The point.
  24477. * @param {DOMRect} rect The rectangle.
  24478. *
  24479. * @return {boolean} True if the point is contained by the rectangle, false otherwise.
  24480. */
  24481. function isPointContainedByRect(point, rect) {
  24482. return rect.left <= point.x && rect.right >= point.x && rect.top <= point.y && rect.bottom >= point.y;
  24483. }
  24484. /**
  24485. * Determines whether the user positioning the dragged block to nest as an
  24486. * inner block.
  24487. *
  24488. * Presently this is determined by whether the cursor is on the right hand side
  24489. * of the block.
  24490. *
  24491. * @param {WPPoint} point The point representing the cursor position when dragging.
  24492. * @param {DOMRect} rect The rectangle.
  24493. */
  24494. function isNestingGesture(point, rect) {
  24495. const blockCenterX = rect.left + rect.width / 2;
  24496. return point.x > blockCenterX;
  24497. } // Block navigation is always a vertical list, so only allow dropping
  24498. // to the above or below a block.
  24499. const ALLOWED_DROP_EDGES = ['top', 'bottom'];
  24500. /**
  24501. * Given blocks data and the cursor position, compute the drop target.
  24502. *
  24503. * @param {WPBlockNavigationDropZoneBlocks} blocksData Data about the blocks in block navigation.
  24504. * @param {WPPoint} position The point representing the cursor position when dragging.
  24505. *
  24506. * @return {WPBlockNavigationDropZoneTarget} An object containing data about the drop target.
  24507. */
  24508. function getBlockNavigationDropTarget(blocksData, position) {
  24509. let candidateEdge;
  24510. let candidateBlockData;
  24511. let candidateDistance;
  24512. let candidateRect;
  24513. for (const blockData of blocksData) {
  24514. if (blockData.isDraggedBlock) {
  24515. continue;
  24516. }
  24517. const rect = blockData.element.getBoundingClientRect();
  24518. const [distance, edge] = getDistanceToNearestEdge(position, rect, ALLOWED_DROP_EDGES);
  24519. const isCursorWithinBlock = isPointContainedByRect(position, rect);
  24520. if (candidateDistance === undefined || distance < candidateDistance || isCursorWithinBlock) {
  24521. candidateDistance = distance;
  24522. const index = blocksData.indexOf(blockData);
  24523. const previousBlockData = blocksData[index - 1]; // If dragging near the top of a block and the preceding block
  24524. // is at the same level, use the preceding block as the candidate
  24525. // instead, as later it makes determining a nesting drop easier.
  24526. if (edge === 'top' && previousBlockData && previousBlockData.rootClientId === blockData.rootClientId && !previousBlockData.isDraggedBlock) {
  24527. candidateBlockData = previousBlockData;
  24528. candidateEdge = 'bottom';
  24529. candidateRect = previousBlockData.element.getBoundingClientRect();
  24530. } else {
  24531. candidateBlockData = blockData;
  24532. candidateEdge = edge;
  24533. candidateRect = rect;
  24534. } // If the mouse position is within the block, break early
  24535. // as the user would intend to drop either before or after
  24536. // this block.
  24537. //
  24538. // This solves an issue where some rows in the block navigation
  24539. // tree overlap slightly due to sub-pixel rendering.
  24540. if (isCursorWithinBlock) {
  24541. break;
  24542. }
  24543. }
  24544. }
  24545. if (!candidateBlockData) {
  24546. return;
  24547. }
  24548. const isDraggingBelow = candidateEdge === 'bottom'; // If the user is dragging towards the bottom of the block check whether
  24549. // they might be trying to nest the block as a child.
  24550. // If the block already has inner blocks, this should always be treated
  24551. // as nesting since the next block in the tree will be the first child.
  24552. if (isDraggingBelow && candidateBlockData.canInsertDraggedBlocksAsChild && (candidateBlockData.innerBlockCount > 0 || isNestingGesture(position, candidateRect))) {
  24553. return {
  24554. rootClientId: candidateBlockData.clientId,
  24555. blockIndex: 0,
  24556. dropPosition: 'inside'
  24557. };
  24558. } // If dropping as a sibling, but block cannot be inserted in
  24559. // this context, return early.
  24560. if (!candidateBlockData.canInsertDraggedBlocksAsSibling) {
  24561. return;
  24562. }
  24563. const offset = isDraggingBelow ? 1 : 0;
  24564. return {
  24565. rootClientId: candidateBlockData.rootClientId,
  24566. clientId: candidateBlockData.clientId,
  24567. blockIndex: candidateBlockData.blockIndex + offset,
  24568. dropPosition: candidateEdge
  24569. };
  24570. }
  24571. /**
  24572. * A react hook for implementing a drop zone in block navigation.
  24573. *
  24574. * @return {WPBlockNavigationDropZoneTarget} The drop target.
  24575. */
  24576. function useBlockNavigationDropZone() {
  24577. const {
  24578. getBlockRootClientId,
  24579. getBlockIndex,
  24580. getBlockCount,
  24581. getDraggedBlockClientIds,
  24582. canInsertBlocks
  24583. } = Object(external_wp_data_["useSelect"])(store);
  24584. const [target, setTarget] = Object(external_wp_element_["useState"])();
  24585. const {
  24586. rootClientId: targetRootClientId,
  24587. blockIndex: targetBlockIndex
  24588. } = target || {};
  24589. const onBlockDrop = useOnBlockDrop(targetRootClientId, targetBlockIndex);
  24590. const throttled = Object(external_wp_compose_["useThrottle"])(Object(external_wp_element_["useCallback"])((event, currentTarget) => {
  24591. const position = {
  24592. x: event.clientX,
  24593. y: event.clientY
  24594. };
  24595. const isBlockDrag = !!event.dataTransfer.getData('wp-blocks');
  24596. const draggedBlockClientIds = isBlockDrag ? getDraggedBlockClientIds() : undefined;
  24597. const blockElements = Array.from(currentTarget.querySelectorAll('[data-block]'));
  24598. const blocksData = blockElements.map(blockElement => {
  24599. const clientId = blockElement.dataset.block;
  24600. const rootClientId = getBlockRootClientId(clientId);
  24601. return {
  24602. clientId,
  24603. rootClientId,
  24604. blockIndex: getBlockIndex(clientId, rootClientId),
  24605. element: blockElement,
  24606. isDraggedBlock: isBlockDrag ? draggedBlockClientIds.includes(clientId) : false,
  24607. innerBlockCount: getBlockCount(clientId),
  24608. canInsertDraggedBlocksAsSibling: isBlockDrag ? canInsertBlocks(draggedBlockClientIds, rootClientId) : true,
  24609. canInsertDraggedBlocksAsChild: isBlockDrag ? canInsertBlocks(draggedBlockClientIds, clientId) : true
  24610. };
  24611. });
  24612. const newTarget = getBlockNavigationDropTarget(blocksData, position);
  24613. if (newTarget) {
  24614. setTarget(newTarget);
  24615. }
  24616. }, []), 200);
  24617. const ref = Object(external_wp_compose_["__experimentalUseDropZone"])({
  24618. onDrop: onBlockDrop,
  24619. onDragOver(event) {
  24620. // `currentTarget` is only available while the event is being
  24621. // handled, so get it now and pass it to the thottled function.
  24622. // https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget
  24623. throttled(event, event.currentTarget);
  24624. },
  24625. onDragEnd() {
  24626. throttled.cancel();
  24627. setTarget(null);
  24628. }
  24629. });
  24630. return {
  24631. ref,
  24632. target
  24633. };
  24634. }
  24635. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/tree.js
  24636. /**
  24637. * WordPress dependencies
  24638. */
  24639. /**
  24640. * Internal dependencies
  24641. */
  24642. const noop = () => {};
  24643. /**
  24644. * Wrap `BlockNavigationRows` with `TreeGrid`. BlockNavigationRows is a
  24645. * recursive component (it renders itself), so this ensures TreeGrid is only
  24646. * present at the very top of the navigation grid.
  24647. *
  24648. * @param {Object} props Components props.
  24649. * @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.
  24650. * @param {Function} props.onSelect Block selection callback.
  24651. * @param {boolean} props.showNestedBlocks Flag to enable displaying nested blocks.
  24652. * @param {boolean} props.showOnlyCurrentHierarchy Flag to limit the list to the current hierarchy of blocks.
  24653. * @param {boolean} props.__experimentalFeatures Flag to enable experimental features.
  24654. * @param {boolean} props.__experimentalPersistentListViewFeatures Flag to enable features for the Persistent List View experiment.
  24655. */
  24656. function BlockNavigationTree({
  24657. blocks,
  24658. showOnlyCurrentHierarchy,
  24659. onSelect = noop,
  24660. __experimentalFeatures,
  24661. __experimentalPersistentListViewFeatures,
  24662. ...props
  24663. }) {
  24664. const {
  24665. clientIdsTree,
  24666. selectedClientIds
  24667. } = useBlockNavigationClientIds(blocks, showOnlyCurrentHierarchy, __experimentalPersistentListViewFeatures);
  24668. const {
  24669. selectBlock
  24670. } = Object(external_wp_data_["useDispatch"])(store);
  24671. const selectEditorBlock = Object(external_wp_element_["useCallback"])(clientId => {
  24672. selectBlock(clientId);
  24673. onSelect(clientId);
  24674. }, [selectBlock, onSelect]);
  24675. let {
  24676. ref: treeGridRef,
  24677. target: blockDropTarget
  24678. } = useBlockNavigationDropZone();
  24679. const isMounted = Object(external_wp_element_["useRef"])(false);
  24680. Object(external_wp_element_["useEffect"])(() => {
  24681. isMounted.current = true;
  24682. }, []);
  24683. if (!__experimentalFeatures) {
  24684. blockDropTarget = undefined;
  24685. }
  24686. const contextValue = Object(external_wp_element_["useMemo"])(() => ({
  24687. __experimentalFeatures,
  24688. __experimentalPersistentListViewFeatures,
  24689. blockDropTarget,
  24690. isTreeGridMounted: isMounted.current
  24691. }), [__experimentalFeatures, __experimentalPersistentListViewFeatures, blockDropTarget, isMounted.current]);
  24692. return Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalTreeGrid"], {
  24693. className: "block-editor-block-navigation-tree",
  24694. "aria-label": Object(external_wp_i18n_["__"])('Block navigation structure'),
  24695. ref: treeGridRef
  24696. }, Object(external_wp_element_["createElement"])(BlockNavigationContext.Provider, {
  24697. value: contextValue
  24698. }, Object(external_wp_element_["createElement"])(BlockNavigationBranch, Object(esm_extends["a" /* default */])({
  24699. blocks: clientIdsTree,
  24700. selectBlock: selectEditorBlock,
  24701. selectedBlockClientIds: selectedClientIds
  24702. }, props))));
  24703. }
  24704. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/dropdown.js
  24705. /**
  24706. * WordPress dependencies
  24707. */
  24708. /**
  24709. * Internal dependencies
  24710. */
  24711. function BlockNavigationDropdownToggle({
  24712. isEnabled,
  24713. onToggle,
  24714. isOpen,
  24715. innerRef,
  24716. ...props
  24717. }) {
  24718. return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], Object(esm_extends["a" /* default */])({}, props, {
  24719. ref: innerRef,
  24720. icon: list_view["a" /* default */],
  24721. "aria-expanded": isOpen,
  24722. "aria-haspopup": "true",
  24723. onClick: isEnabled ? onToggle : undefined
  24724. /* translators: button label text should, if possible, be under 16 characters. */
  24725. ,
  24726. label: Object(external_wp_i18n_["__"])('List view'),
  24727. className: "block-editor-block-navigation",
  24728. "aria-disabled": !isEnabled
  24729. }));
  24730. }
  24731. function BlockNavigationDropdown({
  24732. isDisabled,
  24733. __experimentalFeatures,
  24734. ...props
  24735. }, ref) {
  24736. const hasBlocks = Object(external_wp_data_["useSelect"])(select => !!select(store).getBlockCount(), []);
  24737. const isEnabled = hasBlocks && !isDisabled;
  24738. return Object(external_wp_element_["createElement"])(external_wp_components_["Dropdown"], {
  24739. contentClassName: "block-editor-block-navigation__popover",
  24740. position: "bottom right",
  24741. renderToggle: ({
  24742. isOpen,
  24743. onToggle
  24744. }) => Object(external_wp_element_["createElement"])(BlockNavigationDropdownToggle, Object(esm_extends["a" /* default */])({}, props, {
  24745. innerRef: ref,
  24746. isOpen: isOpen,
  24747. onToggle: onToggle,
  24748. isEnabled: isEnabled
  24749. })),
  24750. renderContent: () => Object(external_wp_element_["createElement"])("div", {
  24751. className: "block-editor-block-navigation__container"
  24752. }, Object(external_wp_element_["createElement"])("p", {
  24753. className: "block-editor-block-navigation__label"
  24754. }, Object(external_wp_i18n_["__"])('List view')), Object(external_wp_element_["createElement"])(BlockNavigationTree, {
  24755. showNestedBlocks: true,
  24756. showOnlyCurrentHierarchy: true,
  24757. __experimentalFeatures: __experimentalFeatures
  24758. }))
  24759. });
  24760. }
  24761. /* harmony default export */ var dropdown = (Object(external_wp_element_["forwardRef"])(BlockNavigationDropdown));
  24762. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/remove-browser-shortcuts.js
  24763. /**
  24764. * External dependencies
  24765. */
  24766. /**
  24767. * WordPress dependencies
  24768. */
  24769. /**
  24770. * Set of keyboard shortcuts handled internally by RichText.
  24771. *
  24772. * @type {Array}
  24773. */
  24774. const HANDLED_SHORTCUTS = [external_wp_keycodes_["rawShortcut"].primary('z'), external_wp_keycodes_["rawShortcut"].primaryShift('z'), external_wp_keycodes_["rawShortcut"].primary('y')];
  24775. /**
  24776. * An instance of a KeyboardShortcuts element pre-bound for the handled
  24777. * shortcuts. Since shortcuts never change, the element can be considered
  24778. * static, and can be skipped in reconciliation.
  24779. *
  24780. * @type {WPElement}
  24781. */
  24782. const SHORTCUTS_ELEMENT = Object(external_wp_element_["createElement"])(external_wp_components_["KeyboardShortcuts"], {
  24783. bindGlobal: true,
  24784. shortcuts: Object(external_lodash_["fromPairs"])(HANDLED_SHORTCUTS.map(shortcut => {
  24785. return [shortcut, event => event.preventDefault()];
  24786. }))
  24787. });
  24788. /**
  24789. * Component which registered keyboard event handlers to prevent default
  24790. * behaviors for key combinations otherwise handled internally by RichText.
  24791. *
  24792. * @return {WPComponent} The component to be rendered.
  24793. */
  24794. const RemoveBrowserShortcuts = () => SHORTCUTS_ELEMENT;
  24795. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/format-toolbar/index.js
  24796. /**
  24797. * External dependencies
  24798. */
  24799. /**
  24800. * WordPress dependencies
  24801. */
  24802. const format_toolbar_POPOVER_PROPS = {
  24803. position: 'bottom right',
  24804. isAlternate: true
  24805. };
  24806. const FormatToolbar = () => {
  24807. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, ['bold', 'italic', 'link', 'text-color'].map(format => Object(external_wp_element_["createElement"])(external_wp_components_["Slot"], {
  24808. name: `RichText.ToolbarControls.${format}`,
  24809. key: format
  24810. })), Object(external_wp_element_["createElement"])(external_wp_components_["Slot"], {
  24811. name: "RichText.ToolbarControls"
  24812. }, fills => fills.length !== 0 && Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarItem"], null, toggleProps => Object(external_wp_element_["createElement"])(external_wp_components_["DropdownMenu"], {
  24813. icon: chevron_down["a" /* default */]
  24814. /* translators: button label text should, if possible, be under 16 characters. */
  24815. ,
  24816. label: Object(external_wp_i18n_["__"])('More'),
  24817. toggleProps: toggleProps,
  24818. controls: Object(external_lodash_["orderBy"])(fills.map(([{
  24819. props
  24820. }]) => props), 'title'),
  24821. popoverProps: format_toolbar_POPOVER_PROPS
  24822. }))));
  24823. };
  24824. /* harmony default export */ var format_toolbar = (FormatToolbar);
  24825. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/format-toolbar-container.js
  24826. /**
  24827. * WordPress dependencies
  24828. */
  24829. /**
  24830. * Internal dependencies
  24831. */
  24832. const FormatToolbarContainer = ({
  24833. inline,
  24834. anchorRef
  24835. }) => {
  24836. if (inline) {
  24837. // Render in popover
  24838. return Object(external_wp_element_["createElement"])(external_wp_components_["Popover"], {
  24839. noArrow: true,
  24840. position: "top center",
  24841. focusOnMount: false,
  24842. anchorRef: anchorRef,
  24843. className: "block-editor-rich-text__inline-format-toolbar",
  24844. __unstableSlotName: "block-toolbar"
  24845. }, Object(external_wp_element_["createElement"])("div", {
  24846. className: "block-editor-rich-text__inline-format-toolbar-group"
  24847. }, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], null, Object(external_wp_element_["createElement"])(format_toolbar, null))));
  24848. } // Render regular toolbar
  24849. return Object(external_wp_element_["createElement"])(block_controls, {
  24850. group: "inline"
  24851. }, Object(external_wp_element_["createElement"])(format_toolbar, null));
  24852. };
  24853. /* harmony default export */ var format_toolbar_container = (FormatToolbarContainer);
  24854. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-undo-automatic-change.js
  24855. /**
  24856. * WordPress dependencies
  24857. */
  24858. /**
  24859. * Internal dependencies
  24860. */
  24861. function useUndoAutomaticChange() {
  24862. const {
  24863. didAutomaticChange,
  24864. getSettings
  24865. } = Object(external_wp_data_["useSelect"])(store);
  24866. return Object(external_wp_compose_["useRefEffect"])(element => {
  24867. function onKeyDown(event) {
  24868. const {
  24869. keyCode
  24870. } = event;
  24871. if (keyCode !== external_wp_keycodes_["DELETE"] && keyCode !== external_wp_keycodes_["BACKSPACE"] && keyCode !== external_wp_keycodes_["ESCAPE"]) {
  24872. return;
  24873. }
  24874. if (!didAutomaticChange()) {
  24875. return;
  24876. }
  24877. event.preventDefault();
  24878. getSettings().__experimentalUndo();
  24879. }
  24880. element.addEventListener('keydown', onKeyDown);
  24881. return () => {
  24882. element.removeEventListener('keydown', onKeyDown);
  24883. };
  24884. }, []);
  24885. }
  24886. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-caret-in-format.js
  24887. /**
  24888. * WordPress dependencies
  24889. */
  24890. /**
  24891. * Internal dependencies
  24892. */
  24893. function useCaretInFormat({
  24894. value
  24895. }) {
  24896. const hasActiveFormats = value.activeFormats && !!value.activeFormats.length;
  24897. const {
  24898. isCaretWithinFormattedText
  24899. } = Object(external_wp_data_["useSelect"])(store);
  24900. const {
  24901. enterFormattedText,
  24902. exitFormattedText
  24903. } = Object(external_wp_data_["useDispatch"])(store);
  24904. Object(external_wp_element_["useEffect"])(() => {
  24905. if (hasActiveFormats) {
  24906. if (!isCaretWithinFormattedText()) {
  24907. enterFormattedText();
  24908. }
  24909. } else if (isCaretWithinFormattedText()) {
  24910. exitFormattedText();
  24911. }
  24912. }, [hasActiveFormats]);
  24913. }
  24914. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-mark-persistent.js
  24915. /**
  24916. * WordPress dependencies
  24917. */
  24918. /**
  24919. * Internal dependencies
  24920. */
  24921. function useMarkPersistent({
  24922. html,
  24923. value
  24924. }) {
  24925. const previousText = Object(external_wp_element_["useRef"])();
  24926. const hasActiveFormats = value.activeFormats && !!value.activeFormats.length;
  24927. const {
  24928. __unstableMarkLastChangeAsPersistent
  24929. } = Object(external_wp_data_["useDispatch"])(store); // Must be set synchronously to make sure it applies to the last change.
  24930. Object(external_wp_element_["useLayoutEffect"])(() => {
  24931. // Ignore mount.
  24932. if (!previousText.current) {
  24933. previousText.current = value.text;
  24934. return;
  24935. } // Text input, so don't create an undo level for every character.
  24936. // Create an undo level after 1 second of no input.
  24937. if (previousText.current !== value.text) {
  24938. const timeout = window.setTimeout(() => {
  24939. __unstableMarkLastChangeAsPersistent();
  24940. }, 1000);
  24941. previousText.current = value.text;
  24942. return () => {
  24943. window.clearTimeout(timeout);
  24944. };
  24945. }
  24946. __unstableMarkLastChangeAsPersistent();
  24947. }, [html, hasActiveFormats]);
  24948. }
  24949. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/file-paste-handler.js
  24950. /**
  24951. * WordPress dependencies
  24952. */
  24953. function filePasteHandler(files) {
  24954. return files.filter(({
  24955. type
  24956. }) => /^image\/(?:jpe?g|png|gif)$/.test(type)).map(file => `<img src="${Object(external_wp_blob_["createBlobURL"])(file)}">`).join('');
  24957. }
  24958. // EXTERNAL MODULE: external ["wp","shortcode"]
  24959. var external_wp_shortcode_ = __webpack_require__("SVSp");
  24960. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/utils.js
  24961. /**
  24962. * WordPress dependencies
  24963. */
  24964. function addActiveFormats(value, activeFormats) {
  24965. if (activeFormats !== null && activeFormats !== void 0 && activeFormats.length) {
  24966. let index = value.formats.length;
  24967. while (index--) {
  24968. value.formats[index] = [...activeFormats, ...(value.formats[index] || [])];
  24969. }
  24970. }
  24971. }
  24972. /**
  24973. * Get the multiline tag based on the multiline prop.
  24974. *
  24975. * @param {?(string|boolean)} multiline The multiline prop.
  24976. *
  24977. * @return {?string} The multiline tag.
  24978. */
  24979. function getMultilineTag(multiline) {
  24980. if (multiline !== true && multiline !== 'p' && multiline !== 'li') {
  24981. return;
  24982. }
  24983. return multiline === true ? 'p' : multiline;
  24984. }
  24985. function getAllowedFormats({
  24986. allowedFormats,
  24987. formattingControls,
  24988. disableFormats
  24989. }) {
  24990. if (disableFormats) {
  24991. return getAllowedFormats.EMPTY_ARRAY;
  24992. }
  24993. if (!allowedFormats && !formattingControls) {
  24994. return;
  24995. }
  24996. if (allowedFormats) {
  24997. return allowedFormats;
  24998. }
  24999. external_wp_deprecated_default()('wp.blockEditor.RichText formattingControls prop', {
  25000. since: '5.4',
  25001. alternative: 'allowedFormats'
  25002. });
  25003. return formattingControls.map(name => `core/${name}`);
  25004. }
  25005. getAllowedFormats.EMPTY_ARRAY = [];
  25006. const isShortcode = text => Object(external_wp_shortcode_["regexp"])('.*').test(text);
  25007. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/split-value.js
  25008. /**
  25009. * WordPress dependencies
  25010. */
  25011. /*
  25012. * Signals to the RichText owner that the block can be replaced with two blocks
  25013. * as a result of splitting the block by pressing enter, or with blocks as a
  25014. * result of splitting the block by pasting block content in the instance.
  25015. */
  25016. function splitValue({
  25017. value,
  25018. pastedBlocks = [],
  25019. onReplace,
  25020. onSplit,
  25021. onSplitMiddle,
  25022. multilineTag
  25023. }) {
  25024. if (!onReplace || !onSplit) {
  25025. return;
  25026. }
  25027. const blocks = [];
  25028. const [before, after] = Object(external_wp_richText_["split"])(value);
  25029. const hasPastedBlocks = pastedBlocks.length > 0;
  25030. let lastPastedBlockIndex = -1; // Consider the after value to be the original it is not empty and the
  25031. // before value *is* empty.
  25032. const isAfterOriginal = Object(external_wp_richText_["isEmpty"])(before) && !Object(external_wp_richText_["isEmpty"])(after); // Create a block with the content before the caret if there's no pasted
  25033. // blocks, or if there are pasted blocks and the value is not empty. We do
  25034. // not want a leading empty block on paste, but we do if split with e.g. the
  25035. // enter key.
  25036. if (!hasPastedBlocks || !Object(external_wp_richText_["isEmpty"])(before)) {
  25037. blocks.push(onSplit(Object(external_wp_richText_["toHTMLString"])({
  25038. value: before,
  25039. multilineTag
  25040. }), !isAfterOriginal));
  25041. lastPastedBlockIndex += 1;
  25042. }
  25043. if (hasPastedBlocks) {
  25044. blocks.push(...pastedBlocks);
  25045. lastPastedBlockIndex += pastedBlocks.length;
  25046. } else if (onSplitMiddle) {
  25047. blocks.push(onSplitMiddle());
  25048. } // If there's pasted blocks, append a block with non empty content / after
  25049. // the caret. Otherwise, do append an empty block if there is no
  25050. // `onSplitMiddle` prop, but if there is and the content is empty, the
  25051. // middle block is enough to set focus in.
  25052. if (hasPastedBlocks ? !Object(external_wp_richText_["isEmpty"])(after) : !onSplitMiddle || !Object(external_wp_richText_["isEmpty"])(after)) {
  25053. blocks.push(onSplit(Object(external_wp_richText_["toHTMLString"])({
  25054. value: after,
  25055. multilineTag
  25056. }), isAfterOriginal));
  25057. } // If there are pasted blocks, set the selection to the last one. Otherwise,
  25058. // set the selection to the second block.
  25059. const indexToSelect = hasPastedBlocks ? lastPastedBlockIndex : 1; // If there are pasted blocks, move the caret to the end of the selected
  25060. // block Otherwise, retain the default value.
  25061. const initialPosition = hasPastedBlocks ? -1 : 0;
  25062. onReplace(blocks, indexToSelect, initialPosition);
  25063. }
  25064. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-paste-handler.js
  25065. /**
  25066. * WordPress dependencies
  25067. */
  25068. /**
  25069. * Internal dependencies
  25070. */
  25071. function usePasteHandler(props) {
  25072. const propsRef = Object(external_wp_element_["useRef"])(props);
  25073. propsRef.current = props;
  25074. return Object(external_wp_compose_["useRefEffect"])(element => {
  25075. function _onPaste(event) {
  25076. const {
  25077. isSelected,
  25078. disableFormats,
  25079. onChange,
  25080. value,
  25081. formatTypes,
  25082. tagName,
  25083. onReplace,
  25084. onSplit,
  25085. onSplitMiddle,
  25086. __unstableEmbedURLOnPaste,
  25087. multilineTag,
  25088. preserveWhiteSpace,
  25089. pastePlainText
  25090. } = propsRef.current;
  25091. if (!isSelected) {
  25092. event.preventDefault();
  25093. return;
  25094. }
  25095. const {
  25096. clipboardData
  25097. } = event;
  25098. let plainText = '';
  25099. let html = ''; // IE11 only supports `Text` as an argument for `getData` and will
  25100. // otherwise throw an invalid argument error, so we try the standard
  25101. // arguments first, then fallback to `Text` if they fail.
  25102. try {
  25103. plainText = clipboardData.getData('text/plain');
  25104. html = clipboardData.getData('text/html');
  25105. } catch (error1) {
  25106. try {
  25107. html = clipboardData.getData('Text');
  25108. } catch (error2) {
  25109. // Some browsers like UC Browser paste plain text by default and
  25110. // don't support clipboardData at all, so allow default
  25111. // behaviour.
  25112. return;
  25113. }
  25114. }
  25115. event.preventDefault(); // Allows us to ask for this information when we get a report.
  25116. window.console.log('Received HTML:\n\n', html);
  25117. window.console.log('Received plain text:\n\n', plainText);
  25118. if (disableFormats) {
  25119. onChange(Object(external_wp_richText_["insert"])(value, plainText));
  25120. return;
  25121. }
  25122. const transformed = formatTypes.reduce((accumlator, {
  25123. __unstablePasteRule
  25124. }) => {
  25125. // Only allow one transform.
  25126. if (__unstablePasteRule && accumlator === value) {
  25127. accumlator = __unstablePasteRule(value, {
  25128. html,
  25129. plainText
  25130. });
  25131. }
  25132. return accumlator;
  25133. }, value);
  25134. if (transformed !== value) {
  25135. onChange(transformed);
  25136. return;
  25137. }
  25138. const files = [...Object(external_wp_dom_["getFilesFromDataTransfer"])(clipboardData)];
  25139. const isInternal = clipboardData.getData('rich-text') === 'true'; // If the data comes from a rich text instance, we can directly use it
  25140. // without filtering the data. The filters are only meant for externally
  25141. // pasted content and remove inline styles.
  25142. if (isInternal) {
  25143. const pastedValue = Object(external_wp_richText_["create"])({
  25144. html,
  25145. multilineTag,
  25146. multilineWrapperTags: multilineTag === 'li' ? ['ul', 'ol'] : undefined,
  25147. preserveWhiteSpace
  25148. });
  25149. addActiveFormats(pastedValue, value.activeFormats);
  25150. onChange(Object(external_wp_richText_["insert"])(value, pastedValue));
  25151. return;
  25152. }
  25153. if (pastePlainText) {
  25154. onChange(Object(external_wp_richText_["insert"])(value, Object(external_wp_richText_["create"])({
  25155. text: plainText
  25156. })));
  25157. return;
  25158. } // Only process file if no HTML is present.
  25159. // Note: a pasted file may have the URL as plain text.
  25160. if (files && files.length && !html) {
  25161. const content = Object(external_wp_blocks_["pasteHandler"])({
  25162. HTML: filePasteHandler(files),
  25163. mode: 'BLOCKS',
  25164. tagName,
  25165. preserveWhiteSpace
  25166. }); // Allows us to ask for this information when we get a report.
  25167. // eslint-disable-next-line no-console
  25168. window.console.log('Received items:\n\n', files);
  25169. if (onReplace && Object(external_wp_richText_["isEmpty"])(value)) {
  25170. onReplace(content);
  25171. } else {
  25172. splitValue({
  25173. value,
  25174. pastedBlocks: content,
  25175. onReplace,
  25176. onSplit,
  25177. onSplitMiddle,
  25178. multilineTag
  25179. });
  25180. }
  25181. return;
  25182. }
  25183. let mode = onReplace && onSplit ? 'AUTO' : 'INLINE'; // Force the blocks mode when the user is pasting
  25184. // on a new line & the content resembles a shortcode.
  25185. // Otherwise it's going to be detected as inline
  25186. // and the shortcode won't be replaced.
  25187. if (mode === 'AUTO' && Object(external_wp_richText_["isEmpty"])(value) && isShortcode(plainText)) {
  25188. mode = 'BLOCKS';
  25189. }
  25190. if (__unstableEmbedURLOnPaste && Object(external_wp_richText_["isEmpty"])(value) && Object(external_wp_url_["isURL"])(plainText.trim())) {
  25191. mode = 'BLOCKS';
  25192. }
  25193. const content = Object(external_wp_blocks_["pasteHandler"])({
  25194. HTML: html,
  25195. plainText,
  25196. mode,
  25197. tagName,
  25198. preserveWhiteSpace
  25199. });
  25200. if (typeof content === 'string') {
  25201. let valueToInsert = Object(external_wp_richText_["create"])({
  25202. html: content
  25203. });
  25204. addActiveFormats(valueToInsert, value.activeFormats); // If the content should be multiline, we should process text
  25205. // separated by a line break as separate lines.
  25206. if (multilineTag) {
  25207. valueToInsert = Object(external_wp_richText_["replace"])(valueToInsert, /\n+/g, external_wp_richText_["__UNSTABLE_LINE_SEPARATOR"]);
  25208. }
  25209. onChange(Object(external_wp_richText_["insert"])(value, valueToInsert));
  25210. } else if (content.length > 0) {
  25211. if (onReplace && Object(external_wp_richText_["isEmpty"])(value)) {
  25212. onReplace(content, content.length - 1, -1);
  25213. } else {
  25214. splitValue({
  25215. value,
  25216. pastedBlocks: content,
  25217. onReplace,
  25218. onSplit,
  25219. onSplitMiddle,
  25220. multilineTag
  25221. });
  25222. }
  25223. }
  25224. }
  25225. element.addEventListener('paste', _onPaste);
  25226. return () => {
  25227. element.removeEventListener('paste', _onPaste);
  25228. };
  25229. }, []);
  25230. }
  25231. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-input-rules.js
  25232. /**
  25233. * WordPress dependencies
  25234. */
  25235. /**
  25236. * Internal dependencies
  25237. */
  25238. function useInputRules(props) {
  25239. const {
  25240. __unstableMarkLastChangeAsPersistent,
  25241. __unstableMarkAutomaticChange
  25242. } = Object(external_wp_data_["useDispatch"])(store);
  25243. const propsRef = Object(external_wp_element_["useRef"])(props);
  25244. propsRef.current = props;
  25245. return Object(external_wp_compose_["useRefEffect"])(element => {
  25246. function inputRule() {
  25247. const {
  25248. value,
  25249. onReplace
  25250. } = propsRef.current;
  25251. if (!onReplace) {
  25252. return;
  25253. }
  25254. const {
  25255. start,
  25256. text
  25257. } = value;
  25258. const characterBefore = text.slice(start - 1, start); // The character right before the caret must be a plain space.
  25259. if (characterBefore !== ' ') {
  25260. return;
  25261. }
  25262. const trimmedTextBefore = text.slice(0, start).trim();
  25263. const prefixTransforms = Object(external_wp_blocks_["getBlockTransforms"])('from').filter(({
  25264. type
  25265. }) => type === 'prefix');
  25266. const transformation = Object(external_wp_blocks_["findTransform"])(prefixTransforms, ({
  25267. prefix
  25268. }) => {
  25269. return trimmedTextBefore === prefix;
  25270. });
  25271. if (!transformation) {
  25272. return;
  25273. }
  25274. const content = Object(external_wp_richText_["toHTMLString"])({
  25275. value: Object(external_wp_richText_["slice"])(value, start, text.length)
  25276. });
  25277. const block = transformation.transform(content);
  25278. onReplace([block]);
  25279. __unstableMarkAutomaticChange();
  25280. }
  25281. function onInput(event) {
  25282. const {
  25283. inputType,
  25284. type
  25285. } = event;
  25286. const {
  25287. value,
  25288. onChange,
  25289. __unstableAllowPrefixTransformations,
  25290. formatTypes
  25291. } = propsRef.current; // Only run input rules when inserting text.
  25292. if (inputType !== 'insertText' && type !== 'compositionend') {
  25293. return;
  25294. }
  25295. if (__unstableAllowPrefixTransformations && inputRule) {
  25296. inputRule();
  25297. }
  25298. const transformed = formatTypes.reduce((accumlator, {
  25299. __unstableInputRule
  25300. }) => {
  25301. if (__unstableInputRule) {
  25302. accumlator = __unstableInputRule(accumlator);
  25303. }
  25304. return accumlator;
  25305. }, value);
  25306. if (transformed !== value) {
  25307. __unstableMarkLastChangeAsPersistent();
  25308. onChange({ ...transformed,
  25309. activeFormats: value.activeFormats
  25310. });
  25311. __unstableMarkAutomaticChange();
  25312. }
  25313. }
  25314. element.addEventListener('input', onInput);
  25315. element.addEventListener('compositionend', onInput);
  25316. return () => {
  25317. element.removeEventListener('input', onInput);
  25318. element.removeEventListener('compositionend', onInput);
  25319. };
  25320. }, []);
  25321. }
  25322. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-enter.js
  25323. /**
  25324. * WordPress dependencies
  25325. */
  25326. /**
  25327. * WordPress dependencies
  25328. */
  25329. /**
  25330. * Internal dependencies
  25331. */
  25332. function useEnter(props) {
  25333. const {
  25334. __unstableMarkAutomaticChange
  25335. } = Object(external_wp_data_["useDispatch"])(store);
  25336. const propsRef = Object(external_wp_element_["useRef"])(props);
  25337. propsRef.current = props;
  25338. return Object(external_wp_compose_["useRefEffect"])(element => {
  25339. function onKeyDown(event) {
  25340. if (event.defaultPrevented) {
  25341. return;
  25342. }
  25343. const {
  25344. removeEditorOnlyFormats,
  25345. value,
  25346. onReplace,
  25347. onSplit,
  25348. onSplitMiddle,
  25349. multilineTag,
  25350. onChange,
  25351. disableLineBreaks,
  25352. onSplitAtEnd
  25353. } = propsRef.current;
  25354. if (event.keyCode !== external_wp_keycodes_["ENTER"]) {
  25355. return;
  25356. }
  25357. event.preventDefault();
  25358. const _value = { ...value
  25359. };
  25360. _value.formats = removeEditorOnlyFormats(value);
  25361. const canSplit = onReplace && onSplit;
  25362. if (onReplace) {
  25363. const transforms = Object(external_wp_blocks_["getBlockTransforms"])('from').filter(({
  25364. type
  25365. }) => type === 'enter');
  25366. const transformation = Object(external_wp_blocks_["findTransform"])(transforms, item => {
  25367. return item.regExp.test(_value.text);
  25368. });
  25369. if (transformation) {
  25370. onReplace([transformation.transform({
  25371. content: _value.text
  25372. })]);
  25373. __unstableMarkAutomaticChange();
  25374. }
  25375. }
  25376. if (multilineTag) {
  25377. if (event.shiftKey) {
  25378. if (!disableLineBreaks) {
  25379. onChange(Object(external_wp_richText_["insert"])(_value, '\n'));
  25380. }
  25381. } else if (canSplit && Object(external_wp_richText_["__unstableIsEmptyLine"])(_value)) {
  25382. splitValue({
  25383. value: _value,
  25384. onReplace,
  25385. onSplit,
  25386. onSplitMiddle,
  25387. multilineTag
  25388. });
  25389. } else {
  25390. onChange(Object(external_wp_richText_["__unstableInsertLineSeparator"])(_value));
  25391. }
  25392. } else {
  25393. const {
  25394. text,
  25395. start,
  25396. end
  25397. } = _value;
  25398. const canSplitAtEnd = onSplitAtEnd && start === end && end === text.length;
  25399. if (event.shiftKey || !canSplit && !canSplitAtEnd) {
  25400. if (!disableLineBreaks) {
  25401. onChange(Object(external_wp_richText_["insert"])(_value, '\n'));
  25402. }
  25403. } else if (!canSplit && canSplitAtEnd) {
  25404. onSplitAtEnd();
  25405. } else if (canSplit) {
  25406. splitValue({
  25407. value: _value,
  25408. onReplace,
  25409. onSplit,
  25410. onSplitMiddle,
  25411. multilineTag
  25412. });
  25413. }
  25414. }
  25415. }
  25416. element.addEventListener('keydown', onKeyDown);
  25417. return () => {
  25418. element.removeEventListener('keydown', onKeyDown);
  25419. };
  25420. }, []);
  25421. }
  25422. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/use-format-types.js
  25423. /**
  25424. * WordPress dependencies
  25425. */
  25426. /**
  25427. * Internal dependencies
  25428. */
  25429. function formatTypesSelector(select) {
  25430. return select(external_wp_richText_["store"]).getFormatTypes();
  25431. }
  25432. /**
  25433. * Set of all interactive content tags.
  25434. *
  25435. * @see https://html.spec.whatwg.org/multipage/dom.html#interactive-content
  25436. */
  25437. const interactiveContentTags = new Set(['a', 'audio', 'button', 'details', 'embed', 'iframe', 'input', 'label', 'select', 'textarea', 'video']);
  25438. /**
  25439. * This hook provides RichText with the `formatTypes` and its derived props from
  25440. * experimental format type settings.
  25441. *
  25442. * @param {Object} $0 Options
  25443. * @param {string} $0.clientId Block client ID.
  25444. * @param {string} $0.identifier Block attribute.
  25445. * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formattings or not.
  25446. * @param {Array} $0.allowedFormats Allowed formats
  25447. */
  25448. function useFormatTypes({
  25449. clientId,
  25450. identifier,
  25451. withoutInteractiveFormatting,
  25452. allowedFormats
  25453. }) {
  25454. const allFormatTypes = Object(external_wp_data_["useSelect"])(formatTypesSelector, []);
  25455. const formatTypes = Object(external_wp_element_["useMemo"])(() => {
  25456. return allFormatTypes.filter(({
  25457. name,
  25458. tagName
  25459. }) => {
  25460. if (allowedFormats && !allowedFormats.includes(name)) {
  25461. return false;
  25462. }
  25463. if (withoutInteractiveFormatting && interactiveContentTags.has(tagName)) {
  25464. return false;
  25465. }
  25466. return true;
  25467. });
  25468. }, [allFormatTypes, allowedFormats, interactiveContentTags]);
  25469. const keyedSelected = Object(external_wp_data_["useSelect"])(select => formatTypes.reduce((accumulator, type) => {
  25470. if (type.__experimentalGetPropsForEditableTreePreparation) {
  25471. accumulator[type.name] = type.__experimentalGetPropsForEditableTreePreparation(select, {
  25472. richTextIdentifier: identifier,
  25473. blockClientId: clientId
  25474. });
  25475. }
  25476. return accumulator;
  25477. }, {}), [formatTypes, clientId, identifier]);
  25478. const dispatch = Object(external_wp_data_["useDispatch"])();
  25479. const prepareHandlers = [];
  25480. const valueHandlers = [];
  25481. const changeHandlers = [];
  25482. const dependencies = [];
  25483. formatTypes.forEach(type => {
  25484. if (type.__experimentalCreatePrepareEditableTree) {
  25485. const selected = keyedSelected[type.name];
  25486. const handler = type.__experimentalCreatePrepareEditableTree(selected, {
  25487. richTextIdentifier: identifier,
  25488. blockClientId: clientId
  25489. });
  25490. if (type.__experimentalCreateOnChangeEditableValue) {
  25491. valueHandlers.push(handler);
  25492. } else {
  25493. prepareHandlers.push(handler);
  25494. }
  25495. for (const key in selected) {
  25496. dependencies.push(selected[key]);
  25497. }
  25498. }
  25499. if (type.__experimentalCreateOnChangeEditableValue) {
  25500. let dispatchers = {};
  25501. if (type.__experimentalGetPropsForEditableTreeChangeHandler) {
  25502. dispatchers = type.__experimentalGetPropsForEditableTreeChangeHandler(dispatch, {
  25503. richTextIdentifier: identifier,
  25504. blockClientId: clientId
  25505. });
  25506. }
  25507. changeHandlers.push(type.__experimentalCreateOnChangeEditableValue({ ...(keyedSelected[type.name] || {}),
  25508. ...dispatchers
  25509. }, {
  25510. richTextIdentifier: identifier,
  25511. blockClientId: clientId
  25512. }));
  25513. }
  25514. });
  25515. return {
  25516. formatTypes,
  25517. prepareHandlers,
  25518. valueHandlers,
  25519. changeHandlers,
  25520. dependencies
  25521. };
  25522. }
  25523. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/format-edit.js
  25524. /**
  25525. * WordPress dependencies
  25526. */
  25527. function FormatEdit({
  25528. formatTypes,
  25529. onChange,
  25530. onFocus,
  25531. value,
  25532. forwardedRef
  25533. }) {
  25534. return formatTypes.map(settings => {
  25535. const {
  25536. name,
  25537. edit: Edit
  25538. } = settings;
  25539. if (!Edit) {
  25540. return null;
  25541. }
  25542. const activeFormat = Object(external_wp_richText_["getActiveFormat"])(value, name);
  25543. const isActive = activeFormat !== undefined;
  25544. const activeObject = Object(external_wp_richText_["getActiveObject"])(value);
  25545. const isObjectActive = activeObject !== undefined && activeObject.type === name;
  25546. return Object(external_wp_element_["createElement"])(Edit, {
  25547. key: name,
  25548. isActive: isActive,
  25549. activeAttributes: isActive ? activeFormat.attributes || {} : {},
  25550. isObjectActive: isObjectActive,
  25551. activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {},
  25552. value: value,
  25553. onChange: onChange,
  25554. onFocus: onFocus,
  25555. contentRef: forwardedRef
  25556. });
  25557. });
  25558. }
  25559. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/index.js
  25560. /**
  25561. * External dependencies
  25562. */
  25563. /**
  25564. * WordPress dependencies
  25565. */
  25566. /**
  25567. * Internal dependencies
  25568. */
  25569. /**
  25570. * Removes props used for the native version of RichText so that they are not
  25571. * passed to the DOM element and log warnings.
  25572. *
  25573. * @param {Object} props Props to filter.
  25574. *
  25575. * @return {Object} Filtered props.
  25576. */
  25577. function removeNativeProps(props) {
  25578. return Object(external_lodash_["omit"])(props, ['__unstableMobileNoFocusOnMount', 'deleteEnter', 'placeholderTextColor', 'textAlign', 'selectionColor', 'tagsToEliminate', 'rootTagsToEliminate', 'disableEditingMenu', 'fontSize', 'fontFamily', 'fontWeight', 'fontStyle', 'minWidth', 'maxWidth', 'setRef']);
  25579. }
  25580. function RichTextWrapper({
  25581. children,
  25582. tagName = 'div',
  25583. value: originalValue = '',
  25584. onChange: originalOnChange,
  25585. isSelected: originalIsSelected,
  25586. multiline,
  25587. inlineToolbar,
  25588. wrapperClassName,
  25589. autocompleters,
  25590. onReplace,
  25591. placeholder,
  25592. allowedFormats,
  25593. formattingControls,
  25594. withoutInteractiveFormatting,
  25595. onRemove,
  25596. onMerge,
  25597. onSplit,
  25598. __unstableOnSplitAtEnd: onSplitAtEnd,
  25599. __unstableOnSplitMiddle: onSplitMiddle,
  25600. identifier,
  25601. preserveWhiteSpace,
  25602. __unstablePastePlainText: pastePlainText,
  25603. __unstableEmbedURLOnPaste,
  25604. __unstableDisableFormats: disableFormats,
  25605. disableLineBreaks,
  25606. unstableOnFocus,
  25607. __unstableAllowPrefixTransformations,
  25608. ...props
  25609. }, forwardedRef) {
  25610. const instanceId = Object(external_wp_compose_["useInstanceId"])(RichTextWrapper);
  25611. identifier = identifier || instanceId;
  25612. props = removeNativeProps(props);
  25613. const anchorRef = Object(external_wp_element_["useRef"])();
  25614. const {
  25615. clientId
  25616. } = useBlockEditContext();
  25617. const selector = select => {
  25618. const {
  25619. getSelectionStart,
  25620. getSelectionEnd,
  25621. isMultiSelecting,
  25622. hasMultiSelection
  25623. } = select(store);
  25624. const selectionStart = getSelectionStart();
  25625. const selectionEnd = getSelectionEnd();
  25626. let isSelected;
  25627. if (originalIsSelected === undefined) {
  25628. isSelected = selectionStart.clientId === clientId && selectionStart.attributeKey === identifier;
  25629. } else if (originalIsSelected) {
  25630. isSelected = selectionStart.clientId === clientId;
  25631. }
  25632. return {
  25633. selectionStart: isSelected ? selectionStart.offset : undefined,
  25634. selectionEnd: isSelected ? selectionEnd.offset : undefined,
  25635. isSelected,
  25636. disabled: isMultiSelecting() || hasMultiSelection()
  25637. };
  25638. }; // This selector must run on every render so the right selection state is
  25639. // retreived from the store on merge.
  25640. // To do: fix this somehow.
  25641. const {
  25642. selectionStart,
  25643. selectionEnd,
  25644. isSelected,
  25645. disabled
  25646. } = Object(external_wp_data_["useSelect"])(selector);
  25647. const {
  25648. selectionChange
  25649. } = Object(external_wp_data_["useDispatch"])(store);
  25650. const multilineTag = getMultilineTag(multiline);
  25651. const adjustedAllowedFormats = getAllowedFormats({
  25652. allowedFormats,
  25653. formattingControls,
  25654. disableFormats
  25655. });
  25656. const hasFormats = !adjustedAllowedFormats || adjustedAllowedFormats.length > 0;
  25657. let adjustedValue = originalValue;
  25658. let adjustedOnChange = originalOnChange; // Handle deprecated format.
  25659. if (Array.isArray(originalValue)) {
  25660. adjustedValue = external_wp_blocks_["children"].toHTML(originalValue);
  25661. adjustedOnChange = newValue => originalOnChange(external_wp_blocks_["children"].fromDOM(Object(external_wp_richText_["__unstableCreateElement"])(document, newValue).childNodes));
  25662. }
  25663. const onSelectionChange = Object(external_wp_element_["useCallback"])((start, end) => {
  25664. selectionChange(clientId, identifier, start, end);
  25665. }, [clientId, identifier]);
  25666. const {
  25667. formatTypes,
  25668. prepareHandlers,
  25669. valueHandlers,
  25670. changeHandlers,
  25671. dependencies
  25672. } = useFormatTypes({
  25673. clientId,
  25674. identifier,
  25675. withoutInteractiveFormatting,
  25676. allowedFormats: adjustedAllowedFormats
  25677. });
  25678. function addEditorOnlyFormats(value) {
  25679. return valueHandlers.reduce((accumulator, fn) => fn(accumulator, value.text), value.formats);
  25680. }
  25681. function removeEditorOnlyFormats(value) {
  25682. formatTypes.forEach(formatType => {
  25683. // Remove formats created by prepareEditableTree, because they are editor only.
  25684. if (formatType.__experimentalCreatePrepareEditableTree) {
  25685. value = Object(external_wp_richText_["removeFormat"])(value, formatType.name, 0, value.text.length);
  25686. }
  25687. });
  25688. return value.formats;
  25689. }
  25690. function addInvisibleFormats(value) {
  25691. return prepareHandlers.reduce((accumulator, fn) => fn(accumulator, value.text), value.formats);
  25692. }
  25693. const {
  25694. value,
  25695. onChange,
  25696. onFocus,
  25697. ref: richTextRef
  25698. } = Object(external_wp_richText_["__unstableUseRichText"])({
  25699. value: adjustedValue,
  25700. onChange(html, {
  25701. __unstableFormats,
  25702. __unstableText
  25703. }) {
  25704. adjustedOnChange(html);
  25705. Object.values(changeHandlers).forEach(changeHandler => {
  25706. changeHandler(__unstableFormats, __unstableText);
  25707. });
  25708. },
  25709. selectionStart,
  25710. selectionEnd,
  25711. onSelectionChange,
  25712. placeholder,
  25713. __unstableIsSelected: isSelected,
  25714. __unstableMultilineTag: multilineTag,
  25715. __unstableDisableFormats: disableFormats,
  25716. preserveWhiteSpace,
  25717. __unstableDependencies: [...dependencies, tagName],
  25718. __unstableAfterParse: addEditorOnlyFormats,
  25719. __unstableBeforeSerialize: removeEditorOnlyFormats,
  25720. __unstableAddInvisibleFormats: addInvisibleFormats
  25721. });
  25722. const autocompleteProps = useBlockEditorAutocompleteProps({
  25723. onReplace,
  25724. completers: autocompleters,
  25725. record: value,
  25726. onChange
  25727. });
  25728. useCaretInFormat({
  25729. value
  25730. });
  25731. useMarkPersistent({
  25732. html: adjustedValue,
  25733. value
  25734. });
  25735. function onKeyDown(event) {
  25736. const {
  25737. keyCode
  25738. } = event;
  25739. if (event.defaultPrevented) {
  25740. return;
  25741. }
  25742. if (keyCode === external_wp_keycodes_["DELETE"] || keyCode === external_wp_keycodes_["BACKSPACE"]) {
  25743. const {
  25744. start,
  25745. end,
  25746. text
  25747. } = value;
  25748. const isReverse = keyCode === external_wp_keycodes_["BACKSPACE"];
  25749. const hasActiveFormats = value.activeFormats && !!value.activeFormats.length; // Only process delete if the key press occurs at an uncollapsed edge.
  25750. if (!Object(external_wp_richText_["isCollapsed"])(value) || hasActiveFormats || isReverse && start !== 0 || !isReverse && end !== text.length) {
  25751. return;
  25752. }
  25753. if (onMerge) {
  25754. onMerge(!isReverse);
  25755. } // Only handle remove on Backspace. This serves dual-purpose of being
  25756. // an intentional user interaction distinguishing between Backspace and
  25757. // Delete to remove the empty field, but also to avoid merge & remove
  25758. // causing destruction of two fields (merge, then removed merged).
  25759. if (onRemove && Object(external_wp_richText_["isEmpty"])(value) && isReverse) {
  25760. onRemove(!isReverse);
  25761. }
  25762. event.preventDefault();
  25763. }
  25764. }
  25765. const TagName = tagName;
  25766. const content = Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, isSelected && children && children({
  25767. value,
  25768. onChange,
  25769. onFocus
  25770. }), isSelected && Object(external_wp_element_["createElement"])(RemoveBrowserShortcuts, null), isSelected && Object(external_wp_element_["createElement"])(FormatEdit, {
  25771. value: value,
  25772. onChange: onChange,
  25773. onFocus: onFocus,
  25774. formatTypes: formatTypes,
  25775. forwardedRef: anchorRef
  25776. }), isSelected && hasFormats && Object(external_wp_element_["createElement"])(format_toolbar_container, {
  25777. inline: inlineToolbar,
  25778. anchorRef: anchorRef.current
  25779. }), Object(external_wp_element_["createElement"])(TagName // Overridable props.
  25780. , Object(esm_extends["a" /* default */])({
  25781. role: "textbox",
  25782. "aria-multiline": true,
  25783. "aria-label": placeholder
  25784. }, props, autocompleteProps, {
  25785. ref: Object(external_wp_compose_["useMergeRefs"])([autocompleteProps.ref, props.ref, richTextRef, useInputRules({
  25786. value,
  25787. onChange,
  25788. __unstableAllowPrefixTransformations,
  25789. formatTypes,
  25790. onReplace
  25791. }), useUndoAutomaticChange(), usePasteHandler({
  25792. isSelected,
  25793. disableFormats,
  25794. onChange,
  25795. value,
  25796. formatTypes,
  25797. tagName,
  25798. onReplace,
  25799. onSplit,
  25800. onSplitMiddle,
  25801. __unstableEmbedURLOnPaste,
  25802. multilineTag,
  25803. preserveWhiteSpace,
  25804. pastePlainText
  25805. }), useEnter({
  25806. removeEditorOnlyFormats,
  25807. value,
  25808. onReplace,
  25809. onSplit,
  25810. onSplitMiddle,
  25811. multilineTag,
  25812. onChange,
  25813. disableLineBreaks,
  25814. onSplitAtEnd
  25815. }), anchorRef, forwardedRef]) // Do not set the attribute if disabled.
  25816. ,
  25817. contentEditable: disabled ? undefined : true,
  25818. suppressContentEditableWarning: !disabled,
  25819. className: classnames_default()('block-editor-rich-text__editable', props.className, 'rich-text'),
  25820. onFocus: unstableOnFocus,
  25821. onKeyDown: onKeyDown
  25822. })));
  25823. if (!wrapperClassName) {
  25824. return content;
  25825. }
  25826. external_wp_deprecated_default()('wp.blockEditor.RichText wrapperClassName prop', {
  25827. since: '5.4',
  25828. alternative: 'className prop or create your own wrapper div'
  25829. });
  25830. const className = classnames_default()('block-editor-rich-text', wrapperClassName);
  25831. return Object(external_wp_element_["createElement"])("div", {
  25832. className: className
  25833. }, content);
  25834. }
  25835. const ForwardedRichTextContainer = Object(external_wp_element_["forwardRef"])(RichTextWrapper);
  25836. ForwardedRichTextContainer.Content = ({
  25837. value,
  25838. tagName: Tag,
  25839. multiline,
  25840. ...props
  25841. }) => {
  25842. // Handle deprecated `children` and `node` sources.
  25843. if (Array.isArray(value)) {
  25844. value = external_wp_blocks_["children"].toHTML(value);
  25845. }
  25846. const MultilineTag = getMultilineTag(multiline);
  25847. if (!value && MultilineTag) {
  25848. value = `<${MultilineTag}></${MultilineTag}>`;
  25849. }
  25850. const content = Object(external_wp_element_["createElement"])(external_wp_element_["RawHTML"], null, value);
  25851. if (Tag) {
  25852. return Object(external_wp_element_["createElement"])(Tag, Object(external_lodash_["omit"])(props, ['format']), content);
  25853. }
  25854. return content;
  25855. };
  25856. ForwardedRichTextContainer.isEmpty = value => {
  25857. return !value || value.length === 0;
  25858. };
  25859. /**
  25860. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md
  25861. */
  25862. /* harmony default export */ var rich_text = (ForwardedRichTextContainer);
  25863. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/editor.js
  25864. /**
  25865. * WordPress dependencies
  25866. */
  25867. /**
  25868. * Internal dependencies
  25869. */
  25870. function BlockNavigationEditor({
  25871. value,
  25872. onChange
  25873. }) {
  25874. return Object(external_wp_element_["createElement"])(BlockNavigationBlockFill, null, Object(external_wp_element_["createElement"])(rich_text, {
  25875. value: value,
  25876. onChange: onChange,
  25877. placeholder: Object(external_wp_i18n_["__"])('Navigation item'),
  25878. withoutInteractiveFormatting: true,
  25879. allowedFormats: ['core/bold', 'core/italic', 'core/image', 'core/strikethrough']
  25880. }));
  25881. }
  25882. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/layout.js
  25883. var library_layout = __webpack_require__("Civd");
  25884. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-variation-picker/index.js
  25885. /**
  25886. * External dependencies
  25887. */
  25888. /**
  25889. * WordPress dependencies
  25890. */
  25891. function BlockVariationPicker({
  25892. icon = library_layout["a" /* default */],
  25893. label = Object(external_wp_i18n_["__"])('Choose variation'),
  25894. instructions = Object(external_wp_i18n_["__"])('Select a variation to start with.'),
  25895. variations,
  25896. onSelect,
  25897. allowSkip
  25898. }) {
  25899. const classes = classnames_default()('block-editor-block-variation-picker', {
  25900. 'has-many-variations': variations.length > 4
  25901. });
  25902. return Object(external_wp_element_["createElement"])(external_wp_components_["Placeholder"], {
  25903. icon: icon,
  25904. label: label,
  25905. instructions: instructions,
  25906. className: classes
  25907. }, Object(external_wp_element_["createElement"])("ul", {
  25908. className: "block-editor-block-variation-picker__variations",
  25909. role: "list",
  25910. "aria-label": Object(external_wp_i18n_["__"])('Block variations')
  25911. }, variations.map(variation => Object(external_wp_element_["createElement"])("li", {
  25912. key: variation.name
  25913. }, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  25914. isSecondary: true,
  25915. icon: variation.icon,
  25916. iconSize: 48,
  25917. onClick: () => onSelect(variation),
  25918. className: "block-editor-block-variation-picker__variation",
  25919. label: variation.description || variation.title
  25920. }), Object(external_wp_element_["createElement"])("span", {
  25921. className: "block-editor-block-variation-picker__variation-label",
  25922. role: "presentation"
  25923. }, variation.title)))), allowSkip && Object(external_wp_element_["createElement"])("div", {
  25924. className: "block-editor-block-variation-picker__skip"
  25925. }, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  25926. isLink: true,
  25927. onClick: () => onSelect()
  25928. }, Object(external_wp_i18n_["__"])('Skip'))));
  25929. }
  25930. /* harmony default export */ var block_variation_picker = (BlockVariationPicker);
  25931. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/grid.js
  25932. var grid = __webpack_require__("b2RC");
  25933. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-pattern-setup/constants.js
  25934. const VIEWMODES = {
  25935. carousel: 'carousel',
  25936. grid: 'grid'
  25937. };
  25938. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-pattern-setup/setup-toolbar.js
  25939. /**
  25940. * WordPress dependencies
  25941. */
  25942. /**
  25943. * Internal dependencies
  25944. */
  25945. const Actions = ({
  25946. onStartBlank,
  25947. onBlockPatternSelect
  25948. }) => Object(external_wp_element_["createElement"])("div", {
  25949. className: "block-editor-block-pattern-setup__actions"
  25950. }, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  25951. onClick: onStartBlank
  25952. }, Object(external_wp_i18n_["__"])('Start blank')), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  25953. isPrimary: true,
  25954. onClick: onBlockPatternSelect
  25955. }, Object(external_wp_i18n_["__"])('Choose')));
  25956. const CarouselNavigation = ({
  25957. handlePrevious,
  25958. handleNext,
  25959. activeSlide,
  25960. totalSlides
  25961. }) => Object(external_wp_element_["createElement"])("div", {
  25962. className: "block-editor-block-pattern-setup__navigation"
  25963. }, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  25964. icon: chevron_left["a" /* default */],
  25965. label: Object(external_wp_i18n_["__"])('Previous pattern'),
  25966. onClick: handlePrevious,
  25967. disabled: activeSlide === 0
  25968. }), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  25969. icon: chevron_right["a" /* default */],
  25970. label: Object(external_wp_i18n_["__"])('Next pattern'),
  25971. onClick: handleNext,
  25972. disabled: activeSlide === totalSlides - 1
  25973. }));
  25974. const SetupToolbar = ({
  25975. viewMode,
  25976. setViewMode,
  25977. handlePrevious,
  25978. handleNext,
  25979. activeSlide,
  25980. totalSlides,
  25981. onBlockPatternSelect,
  25982. onStartBlank
  25983. }) => {
  25984. const isCarouselView = viewMode === VIEWMODES.carousel;
  25985. const displayControls = Object(external_wp_element_["createElement"])("div", {
  25986. className: "block-editor-block-pattern-setup__display-controls"
  25987. }, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  25988. icon: stretch_full_width,
  25989. label: Object(external_wp_i18n_["__"])('Carousel view'),
  25990. onClick: () => setViewMode(VIEWMODES.carousel),
  25991. isPressed: isCarouselView
  25992. }), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  25993. icon: grid["a" /* default */],
  25994. label: Object(external_wp_i18n_["__"])('Grid view'),
  25995. onClick: () => setViewMode(VIEWMODES.grid),
  25996. isPressed: viewMode === VIEWMODES.grid
  25997. }));
  25998. return Object(external_wp_element_["createElement"])("div", {
  25999. className: "block-editor-block-pattern-setup__toolbar"
  26000. }, isCarouselView && Object(external_wp_element_["createElement"])(CarouselNavigation, {
  26001. handlePrevious: handlePrevious,
  26002. handleNext: handleNext,
  26003. activeSlide: activeSlide,
  26004. totalSlides: totalSlides
  26005. }), displayControls, isCarouselView && Object(external_wp_element_["createElement"])(Actions, {
  26006. onBlockPatternSelect: onBlockPatternSelect,
  26007. onStartBlank: onStartBlank
  26008. }));
  26009. };
  26010. /* harmony default export */ var setup_toolbar = (SetupToolbar);
  26011. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-pattern-setup/use-patterns-setup.js
  26012. /**
  26013. * WordPress dependencies
  26014. */
  26015. /**
  26016. * Internal dependencies
  26017. */
  26018. function usePatternsSetup(clientId, blockName, filterPatternsFn) {
  26019. return Object(external_wp_data_["useSelect"])(select => {
  26020. const {
  26021. getBlockRootClientId,
  26022. __experimentalGetPatternsByBlockTypes,
  26023. __experimentalGetAllowedPatterns
  26024. } = select(store);
  26025. const rootClientId = getBlockRootClientId(clientId);
  26026. if (filterPatternsFn) {
  26027. return __experimentalGetAllowedPatterns(rootClientId).filter(filterPatternsFn);
  26028. }
  26029. return __experimentalGetPatternsByBlockTypes(blockName, rootClientId);
  26030. }, [clientId, blockName, filterPatternsFn]);
  26031. }
  26032. /* harmony default export */ var use_patterns_setup = (usePatternsSetup);
  26033. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-pattern-setup/index.js
  26034. /**
  26035. * WordPress dependencies
  26036. */
  26037. /**
  26038. * Internal dependencies
  26039. */
  26040. const SetupContent = ({
  26041. viewMode,
  26042. activeSlide,
  26043. patterns,
  26044. onBlockPatternSelect
  26045. }) => {
  26046. const composite = Object(external_wp_components_["__unstableUseCompositeState"])();
  26047. const containerClass = 'block-editor-block-pattern-setup__container';
  26048. if (viewMode === VIEWMODES.carousel) {
  26049. const slideClass = new Map([[activeSlide, 'active-slide'], [activeSlide - 1, 'previous-slide'], [activeSlide + 1, 'next-slide']]);
  26050. return Object(external_wp_element_["createElement"])("div", {
  26051. className: containerClass
  26052. }, Object(external_wp_element_["createElement"])("ul", {
  26053. className: "carousel-container"
  26054. }, patterns.map((pattern, index) => Object(external_wp_element_["createElement"])(BlockPatternSlide, {
  26055. className: slideClass.get(index) || '',
  26056. key: pattern.name,
  26057. pattern: pattern
  26058. }))));
  26059. }
  26060. return Object(external_wp_element_["createElement"])(external_wp_components_["__unstableComposite"], Object(esm_extends["a" /* default */])({}, composite, {
  26061. role: "listbox",
  26062. className: containerClass,
  26063. "aria-label": Object(external_wp_i18n_["__"])('Patterns list')
  26064. }), patterns.map(pattern => Object(external_wp_element_["createElement"])(block_pattern_setup_BlockPattern, {
  26065. key: pattern.name,
  26066. pattern: pattern,
  26067. onSelect: onBlockPatternSelect,
  26068. composite: composite
  26069. })));
  26070. };
  26071. function block_pattern_setup_BlockPattern({
  26072. pattern,
  26073. onSelect,
  26074. composite
  26075. }) {
  26076. const baseClassName = 'block-editor-block-pattern-setup-list';
  26077. const {
  26078. blocks,
  26079. title,
  26080. description,
  26081. viewportWidth = 700
  26082. } = pattern;
  26083. const descriptionId = Object(external_wp_compose_["useInstanceId"])(block_pattern_setup_BlockPattern, `${baseClassName}__item-description`);
  26084. return Object(external_wp_element_["createElement"])("div", {
  26085. className: `${baseClassName}__list-item`,
  26086. "aria-label": pattern.title,
  26087. "aria-describedby": pattern.description ? descriptionId : undefined
  26088. }, Object(external_wp_element_["createElement"])(external_wp_components_["__unstableCompositeItem"], Object(esm_extends["a" /* default */])({
  26089. role: "option",
  26090. as: "div"
  26091. }, composite, {
  26092. className: `${baseClassName}__item`,
  26093. onClick: () => onSelect(blocks)
  26094. }), Object(external_wp_element_["createElement"])(block_preview, {
  26095. blocks: blocks,
  26096. viewportWidth: viewportWidth
  26097. }), Object(external_wp_element_["createElement"])("div", {
  26098. className: `${baseClassName}__item-title`
  26099. }, title)), !!description && Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], {
  26100. id: descriptionId
  26101. }, description));
  26102. }
  26103. function BlockPatternSlide({
  26104. className,
  26105. pattern
  26106. }) {
  26107. const {
  26108. blocks,
  26109. title,
  26110. description
  26111. } = pattern;
  26112. const descriptionId = Object(external_wp_compose_["useInstanceId"])(BlockPatternSlide, 'block-editor-block-pattern-setup-list__item-description');
  26113. return Object(external_wp_element_["createElement"])("li", {
  26114. className: `pattern-slide ${className}`,
  26115. "aria-label": title,
  26116. "aria-describedby": description ? descriptionId : undefined
  26117. }, Object(external_wp_element_["createElement"])(block_preview, {
  26118. blocks: blocks,
  26119. __experimentalLive: true
  26120. }), !!description && Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], {
  26121. id: descriptionId
  26122. }, description));
  26123. }
  26124. const BlockPatternSetup = ({
  26125. clientId,
  26126. blockName,
  26127. filterPatternsFn,
  26128. startBlankComponent,
  26129. onBlockPatternSelect
  26130. }) => {
  26131. const [viewMode, setViewMode] = Object(external_wp_element_["useState"])(VIEWMODES.carousel);
  26132. const [activeSlide, setActiveSlide] = Object(external_wp_element_["useState"])(0);
  26133. const [showBlank, setShowBlank] = Object(external_wp_element_["useState"])(false);
  26134. const {
  26135. replaceBlock
  26136. } = Object(external_wp_data_["useDispatch"])(store);
  26137. const patterns = use_patterns_setup(clientId, blockName, filterPatternsFn);
  26138. if (!(patterns !== null && patterns !== void 0 && patterns.length) || showBlank) {
  26139. return startBlankComponent;
  26140. }
  26141. const onBlockPatternSelectDefault = blocks => {
  26142. const clonedBlocks = blocks.map(block => Object(external_wp_blocks_["cloneBlock"])(block));
  26143. replaceBlock(clientId, clonedBlocks);
  26144. };
  26145. const onPatternSelectCallback = onBlockPatternSelect || onBlockPatternSelectDefault;
  26146. return Object(external_wp_element_["createElement"])("div", {
  26147. className: `block-editor-block-pattern-setup view-mode-${viewMode}`
  26148. }, Object(external_wp_element_["createElement"])(setup_toolbar, {
  26149. viewMode: viewMode,
  26150. setViewMode: setViewMode,
  26151. activeSlide: activeSlide,
  26152. totalSlides: patterns.length,
  26153. handleNext: () => {
  26154. setActiveSlide(active => active + 1);
  26155. },
  26156. handlePrevious: () => {
  26157. setActiveSlide(active => active - 1);
  26158. },
  26159. onBlockPatternSelect: () => {
  26160. onPatternSelectCallback(patterns[activeSlide].blocks);
  26161. },
  26162. onStartBlank: () => {
  26163. setShowBlank(true);
  26164. }
  26165. }), Object(external_wp_element_["createElement"])(SetupContent, {
  26166. viewMode: viewMode,
  26167. activeSlide: activeSlide,
  26168. patterns: patterns,
  26169. onBlockPatternSelect: onPatternSelectCallback
  26170. }));
  26171. };
  26172. /* harmony default export */ var block_pattern_setup = (BlockPatternSetup);
  26173. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/block-variation-transforms.js
  26174. /**
  26175. * External dependencies
  26176. */
  26177. /** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */
  26178. /**
  26179. * Matches the provided block variations with a block's attributes. If no match
  26180. * or more than one matches are found it returns `undefined`. If a single match is
  26181. * found it returns it.
  26182. *
  26183. * This is a simple implementation for now as it takes into account only the attributes
  26184. * of a block variation and not `InnerBlocks`.
  26185. *
  26186. * @param {Object} blockAttributes - The block attributes to try to find a match.
  26187. * @param {WPBlockVariation[]} variations - A list of block variations to test for a match.
  26188. * @return {?WPBlockVariation} - If a match is found returns it. If not or more than one matches are found returns `undefined`.
  26189. */
  26190. const __experimentalGetMatchingVariation = (blockAttributes, variations) => {
  26191. if (!variations || !blockAttributes) return;
  26192. const matches = variations.filter(({
  26193. attributes
  26194. }) => {
  26195. if (!attributes || !Object.keys(attributes).length) return false;
  26196. return Object(external_lodash_["isMatch"])(blockAttributes, attributes);
  26197. });
  26198. if (matches.length !== 1) return;
  26199. return matches[0];
  26200. };
  26201. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-variation-transforms/index.js
  26202. /**
  26203. * WordPress dependencies
  26204. */
  26205. /**
  26206. * Internal dependencies
  26207. */
  26208. function __experimentalBlockVariationTransforms({
  26209. blockClientId
  26210. }) {
  26211. const [selectedValue, setSelectedValue] = Object(external_wp_element_["useState"])();
  26212. const {
  26213. updateBlockAttributes
  26214. } = Object(external_wp_data_["useDispatch"])(store);
  26215. const {
  26216. variations,
  26217. blockAttributes
  26218. } = Object(external_wp_data_["useSelect"])(select => {
  26219. const {
  26220. getBlockVariations
  26221. } = select(external_wp_blocks_["store"]);
  26222. const {
  26223. getBlockName,
  26224. getBlockAttributes
  26225. } = select(store);
  26226. const blockName = blockClientId && getBlockName(blockClientId);
  26227. return {
  26228. variations: blockName && getBlockVariations(blockName, 'transform'),
  26229. blockAttributes: getBlockAttributes(blockClientId)
  26230. };
  26231. }, [blockClientId]);
  26232. Object(external_wp_element_["useEffect"])(() => {
  26233. var _getMatchingVariation;
  26234. setSelectedValue((_getMatchingVariation = __experimentalGetMatchingVariation(blockAttributes, variations)) === null || _getMatchingVariation === void 0 ? void 0 : _getMatchingVariation.name);
  26235. }, [blockAttributes, variations]);
  26236. if (!(variations !== null && variations !== void 0 && variations.length)) return null;
  26237. const selectOptions = variations.map(({
  26238. name,
  26239. title,
  26240. description
  26241. }) => ({
  26242. value: name,
  26243. label: title,
  26244. info: description
  26245. }));
  26246. const onSelectVariation = variationName => {
  26247. updateBlockAttributes(blockClientId, { ...variations.find(({
  26248. name
  26249. }) => name === variationName).attributes
  26250. });
  26251. };
  26252. const baseClass = 'block-editor-block-variation-transforms';
  26253. return Object(external_wp_element_["createElement"])(external_wp_components_["DropdownMenu"], {
  26254. className: baseClass,
  26255. label: Object(external_wp_i18n_["__"])('Transform to variation'),
  26256. text: Object(external_wp_i18n_["__"])('Transform to variation'),
  26257. popoverProps: {
  26258. position: 'bottom center',
  26259. className: `${baseClass}__popover`
  26260. },
  26261. icon: chevron_down["a" /* default */],
  26262. toggleProps: {
  26263. iconPosition: 'right'
  26264. }
  26265. }, () => Object(external_wp_element_["createElement"])("div", {
  26266. className: `${baseClass}__container`
  26267. }, Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], null, Object(external_wp_element_["createElement"])(external_wp_components_["MenuItemsChoice"], {
  26268. choices: selectOptions,
  26269. value: selectedValue,
  26270. onSelect: onSelectVariation
  26271. }))));
  26272. }
  26273. /* harmony default export */ var block_variation_transforms = (__experimentalBlockVariationTransforms);
  26274. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-vertical-alignment-control/icons.js
  26275. /**
  26276. * WordPress dependencies
  26277. */
  26278. const alignBottom = Object(external_wp_element_["createElement"])(external_wp_components_["SVG"], {
  26279. xmlns: "http://www.w3.org/2000/svg",
  26280. viewBox: "0 0 24 24"
  26281. }, Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
  26282. d: "M15 4H9v11h6V4zM4 18.5V20h16v-1.5H4z"
  26283. }));
  26284. const alignCenter = Object(external_wp_element_["createElement"])(external_wp_components_["SVG"], {
  26285. xmlns: "http://www.w3.org/2000/svg",
  26286. viewBox: "0 0 24 24"
  26287. }, Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
  26288. d: "M20 11h-5V4H9v7H4v1.5h5V20h6v-7.5h5z"
  26289. }));
  26290. const alignTop = Object(external_wp_element_["createElement"])(external_wp_components_["SVG"], {
  26291. xmlns: "http://www.w3.org/2000/svg",
  26292. viewBox: "0 0 24 24"
  26293. }, Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
  26294. d: "M9 20h6V9H9v11zM4 4v1.5h16V4H4z"
  26295. }));
  26296. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-vertical-alignment-control/ui.js
  26297. /**
  26298. * WordPress dependencies
  26299. */
  26300. /**
  26301. * Internal dependencies
  26302. */
  26303. const ui_BLOCK_ALIGNMENTS_CONTROLS = {
  26304. top: {
  26305. icon: alignTop,
  26306. title: Object(external_wp_i18n_["_x"])('Align top', 'Block vertical alignment setting')
  26307. },
  26308. center: {
  26309. icon: alignCenter,
  26310. title: Object(external_wp_i18n_["_x"])('Align middle', 'Block vertical alignment setting')
  26311. },
  26312. bottom: {
  26313. icon: alignBottom,
  26314. title: Object(external_wp_i18n_["_x"])('Align bottom', 'Block vertical alignment setting')
  26315. }
  26316. };
  26317. const ui_DEFAULT_CONTROLS = ['top', 'center', 'bottom'];
  26318. const ui_DEFAULT_CONTROL = 'top';
  26319. const block_vertical_alignment_control_ui_POPOVER_PROPS = {
  26320. isAlternate: true
  26321. };
  26322. function BlockVerticalAlignmentUI({
  26323. value,
  26324. onChange,
  26325. controls = ui_DEFAULT_CONTROLS,
  26326. isCollapsed = true,
  26327. isToolbar
  26328. }) {
  26329. function applyOrUnset(align) {
  26330. return () => onChange(value === align ? undefined : align);
  26331. }
  26332. const activeAlignment = ui_BLOCK_ALIGNMENTS_CONTROLS[value];
  26333. const defaultAlignmentControl = ui_BLOCK_ALIGNMENTS_CONTROLS[ui_DEFAULT_CONTROL];
  26334. const UIComponent = isToolbar ? external_wp_components_["ToolbarGroup"] : external_wp_components_["ToolbarDropdownMenu"];
  26335. const extraProps = isToolbar ? {
  26336. isCollapsed
  26337. } : {};
  26338. return Object(external_wp_element_["createElement"])(UIComponent, Object(esm_extends["a" /* default */])({
  26339. popoverProps: block_vertical_alignment_control_ui_POPOVER_PROPS,
  26340. icon: activeAlignment ? activeAlignment.icon : defaultAlignmentControl.icon,
  26341. label: Object(external_wp_i18n_["_x"])('Change vertical alignment', 'Block vertical alignment setting label'),
  26342. controls: controls.map(control => {
  26343. return { ...ui_BLOCK_ALIGNMENTS_CONTROLS[control],
  26344. isActive: value === control,
  26345. role: isCollapsed ? 'menuitemradio' : undefined,
  26346. onClick: applyOrUnset(control)
  26347. };
  26348. })
  26349. }, extraProps));
  26350. }
  26351. /**
  26352. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-vertical-alignment-toolbar/README.md
  26353. */
  26354. /* harmony default export */ var block_vertical_alignment_control_ui = (BlockVerticalAlignmentUI);
  26355. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-vertical-alignment-control/index.js
  26356. /**
  26357. * Internal dependencies
  26358. */
  26359. function BlockVerticalAlignmentControl(props) {
  26360. return Object(external_wp_element_["createElement"])(block_vertical_alignment_control_ui, Object(esm_extends["a" /* default */])({}, props, {
  26361. isToolbar: false
  26362. }));
  26363. }
  26364. function BlockVerticalAlignmentToolbar(props) {
  26365. return Object(external_wp_element_["createElement"])(block_vertical_alignment_control_ui, Object(esm_extends["a" /* default */])({}, props, {
  26366. isToolbar: true
  26367. }));
  26368. }
  26369. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-palette/with-color-context.js
  26370. /**
  26371. * External dependencies
  26372. */
  26373. /**
  26374. * WordPress dependencies
  26375. */
  26376. /**
  26377. * Internal dependencies
  26378. */
  26379. /* harmony default export */ var with_color_context = (Object(external_wp_compose_["createHigherOrderComponent"])(WrappedComponent => {
  26380. return props => {
  26381. const colorsFeature = useSetting('color.palette');
  26382. const disableCustomColorsFeature = !useSetting('color.custom');
  26383. const colors = props.colors === undefined ? colorsFeature : props.colors;
  26384. const disableCustomColors = props.disableCustomColors === undefined ? disableCustomColorsFeature : props.disableCustomColors;
  26385. const hasColorsToChoose = !Object(external_lodash_["isEmpty"])(colors) || !disableCustomColors;
  26386. return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, props, {
  26387. colors,
  26388. disableCustomColors,
  26389. hasColorsToChoose
  26390. }));
  26391. };
  26392. }, 'withColorContext'));
  26393. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-palette/index.js
  26394. /**
  26395. * WordPress dependencies
  26396. */
  26397. /**
  26398. * Internal dependencies
  26399. */
  26400. /* harmony default export */ var color_palette = (with_color_context(external_wp_components_["ColorPalette"]));
  26401. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-palette/control.js
  26402. /**
  26403. * Internal dependencies
  26404. */
  26405. function ColorPaletteControl({
  26406. onChange,
  26407. value,
  26408. ...otherProps
  26409. }) {
  26410. return Object(external_wp_element_["createElement"])(control, Object(esm_extends["a" /* default */])({}, otherProps, {
  26411. onColorChange: onChange,
  26412. colorValue: value,
  26413. gradients: [],
  26414. disableCustomGradients: true
  26415. }));
  26416. }
  26417. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/gradient-picker/index.js
  26418. /**
  26419. * WordPress dependencies
  26420. */
  26421. /**
  26422. * Internal dependencies
  26423. */
  26424. const gradient_picker_EMPTY_ARRAY = [];
  26425. function GradientPickerWithGradients(props) {
  26426. const gradients = useSetting('color.gradients') || gradient_picker_EMPTY_ARRAY;
  26427. const disableCustomGradients = !useSetting('color.customGradient');
  26428. return Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalGradientPicker"], Object(esm_extends["a" /* default */])({
  26429. gradients: props.gradients !== undefined ? props.gradient : gradients,
  26430. disableCustomGradients: props.disableCustomGradients !== undefined ? props.disableCustomGradients : disableCustomGradients
  26431. }, props));
  26432. }
  26433. /* harmony default export */ var gradient_picker = (function (props) {
  26434. const ComponentToUse = props.gradients !== undefined && props.disableCustomGradients !== undefined ? external_wp_components_["__experimentalGradientPicker"] : GradientPickerWithGradients;
  26435. return Object(external_wp_element_["createElement"])(ComponentToUse, props);
  26436. });
  26437. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/gradient-picker/control.js
  26438. /**
  26439. * External dependencies
  26440. */
  26441. /**
  26442. * WordPress dependencies
  26443. */
  26444. /**
  26445. * Internal dependencies
  26446. */
  26447. function GradientPickerControl({
  26448. className,
  26449. value,
  26450. onChange,
  26451. label = Object(external_wp_i18n_["__"])('Gradient Presets'),
  26452. ...props
  26453. }) {
  26454. const gradients = useSetting('color.gradients');
  26455. const disableCustomGradients = !useSetting('color.customGradient');
  26456. if (Object(external_lodash_["isEmpty"])(gradients) && disableCustomGradients) {
  26457. return null;
  26458. }
  26459. return Object(external_wp_element_["createElement"])(external_wp_components_["BaseControl"], {
  26460. className: classnames_default()('block-editor-gradient-picker-control', className)
  26461. }, Object(external_wp_element_["createElement"])(external_wp_components_["BaseControl"].VisualLabel, null, label), Object(external_wp_element_["createElement"])(gradient_picker, Object(esm_extends["a" /* default */])({
  26462. value: value,
  26463. onChange: onChange,
  26464. className: "block-editor-gradient-picker-control__gradient-picker-presets",
  26465. gradients: gradients,
  26466. disableCustomGradients: disableCustomGradients
  26467. }, props)));
  26468. }
  26469. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/gradient-picker/panel.js
  26470. /**
  26471. * External dependencies
  26472. */
  26473. /**
  26474. * WordPress dependencies
  26475. */
  26476. /**
  26477. * Internal dependencies
  26478. */
  26479. function GradientPanel(props) {
  26480. const gradients = useSetting('color.gradients');
  26481. if (Object(external_lodash_["isEmpty"])(gradients)) {
  26482. return null;
  26483. }
  26484. return Object(external_wp_element_["createElement"])(external_wp_components_["PanelBody"], {
  26485. title: Object(external_wp_i18n_["__"])('Gradient')
  26486. }, Object(external_wp_element_["createElement"])(GradientPickerControl, props));
  26487. }
  26488. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-size-control/index.js
  26489. /**
  26490. * External dependencies
  26491. */
  26492. /**
  26493. * WordPress dependencies
  26494. */
  26495. const IMAGE_SIZE_PRESETS = [25, 50, 75, 100];
  26496. function ImageSizeControl({
  26497. imageWidth,
  26498. imageHeight,
  26499. imageSizeOptions = [],
  26500. isResizable = true,
  26501. slug,
  26502. width,
  26503. height,
  26504. onChange,
  26505. onChangeImage = external_lodash_["noop"]
  26506. }) {
  26507. var _ref, _ref2;
  26508. function updateDimensions(nextWidth, nextHeight) {
  26509. return () => {
  26510. onChange({
  26511. width: nextWidth,
  26512. height: nextHeight
  26513. });
  26514. };
  26515. }
  26516. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, !Object(external_lodash_["isEmpty"])(imageSizeOptions) && Object(external_wp_element_["createElement"])(external_wp_components_["SelectControl"], {
  26517. label: Object(external_wp_i18n_["__"])('Image size'),
  26518. value: slug,
  26519. options: imageSizeOptions,
  26520. onChange: onChangeImage
  26521. }), isResizable && Object(external_wp_element_["createElement"])("div", {
  26522. className: "block-editor-image-size-control"
  26523. }, Object(external_wp_element_["createElement"])("p", {
  26524. className: "block-editor-image-size-control__row"
  26525. }, Object(external_wp_i18n_["__"])('Image dimensions')), Object(external_wp_element_["createElement"])("div", {
  26526. className: "block-editor-image-size-control__row"
  26527. }, Object(external_wp_element_["createElement"])(external_wp_components_["TextControl"], {
  26528. type: "number",
  26529. className: "block-editor-image-size-control__width",
  26530. label: Object(external_wp_i18n_["__"])('Width'),
  26531. value: (_ref = width !== null && width !== void 0 ? width : imageWidth) !== null && _ref !== void 0 ? _ref : '',
  26532. min: 1,
  26533. onChange: value => onChange({
  26534. width: parseInt(value, 10)
  26535. })
  26536. }), Object(external_wp_element_["createElement"])(external_wp_components_["TextControl"], {
  26537. type: "number",
  26538. className: "block-editor-image-size-control__height",
  26539. label: Object(external_wp_i18n_["__"])('Height'),
  26540. value: (_ref2 = height !== null && height !== void 0 ? height : imageHeight) !== null && _ref2 !== void 0 ? _ref2 : '',
  26541. min: 1,
  26542. onChange: value => onChange({
  26543. height: parseInt(value, 10)
  26544. })
  26545. })), Object(external_wp_element_["createElement"])("div", {
  26546. className: "block-editor-image-size-control__row"
  26547. }, Object(external_wp_element_["createElement"])(external_wp_components_["ButtonGroup"], {
  26548. "aria-label": Object(external_wp_i18n_["__"])('Image size presets')
  26549. }, IMAGE_SIZE_PRESETS.map(scale => {
  26550. const scaledWidth = Math.round(imageWidth * (scale / 100));
  26551. const scaledHeight = Math.round(imageHeight * (scale / 100));
  26552. const isCurrent = width === scaledWidth && height === scaledHeight;
  26553. return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  26554. key: scale,
  26555. isSmall: true,
  26556. isPrimary: isCurrent,
  26557. isPressed: isCurrent,
  26558. onClick: updateDimensions(scaledWidth, scaledHeight)
  26559. }, scale, "%");
  26560. })), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  26561. isSmall: true,
  26562. onClick: updateDimensions()
  26563. }, Object(external_wp_i18n_["__"])('Reset')))));
  26564. }
  26565. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/with-client-id.js
  26566. /**
  26567. * WordPress dependencies
  26568. */
  26569. /**
  26570. * Internal dependencies
  26571. */
  26572. const withClientId = Object(external_wp_compose_["createHigherOrderComponent"])(WrappedComponent => props => {
  26573. const {
  26574. clientId
  26575. } = useBlockEditContext();
  26576. return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, props, {
  26577. clientId: clientId
  26578. }));
  26579. }, 'withClientId');
  26580. /* harmony default export */ var with_client_id = (withClientId);
  26581. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/button-block-appender.js
  26582. /**
  26583. * Internal dependencies
  26584. */
  26585. const button_block_appender_ButtonBlockAppender = ({
  26586. clientId,
  26587. showSeparator,
  26588. isFloating,
  26589. onAddBlock
  26590. }) => {
  26591. return Object(external_wp_element_["createElement"])(button_block_appender, {
  26592. rootClientId: clientId,
  26593. showSeparator: showSeparator,
  26594. isFloating: isFloating,
  26595. onAddBlock: onAddBlock
  26596. });
  26597. };
  26598. /* harmony default export */ var inner_blocks_button_block_appender = (with_client_id(button_block_appender_ButtonBlockAppender));
  26599. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/default-block-appender.js
  26600. /**
  26601. * External dependencies
  26602. */
  26603. /**
  26604. * WordPress dependencies
  26605. */
  26606. /**
  26607. * Internal dependencies
  26608. */
  26609. const default_block_appender_DefaultBlockAppender = ({
  26610. clientId,
  26611. lastBlockClientId
  26612. }) => {
  26613. return Object(external_wp_element_["createElement"])(default_block_appender, {
  26614. rootClientId: clientId,
  26615. lastBlockClientId: lastBlockClientId
  26616. });
  26617. };
  26618. /* harmony default export */ var inner_blocks_default_block_appender = (Object(external_wp_compose_["compose"])([with_client_id, Object(external_wp_data_["withSelect"])((select, {
  26619. clientId
  26620. }) => {
  26621. const {
  26622. getBlockOrder
  26623. } = select(store);
  26624. const blockClientIds = getBlockOrder(clientId);
  26625. return {
  26626. lastBlockClientId: Object(external_lodash_["last"])(blockClientIds)
  26627. };
  26628. })])(default_block_appender_DefaultBlockAppender));
  26629. // EXTERNAL MODULE: external ["wp","isShallowEqual"]
  26630. var external_wp_isShallowEqual_ = __webpack_require__("rl8x");
  26631. var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_);
  26632. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/use-nested-settings-update.js
  26633. /**
  26634. * WordPress dependencies
  26635. */
  26636. /**
  26637. * Internal dependencies
  26638. */
  26639. /**
  26640. * This hook is a side effect which updates the block-editor store when changes
  26641. * happen to inner block settings. The given props are transformed into a
  26642. * settings object, and if that is different from the current settings object in
  26643. * the block-editor store, then the store is updated with the new settings which
  26644. * came from props.
  26645. *
  26646. * @param {string} clientId The client ID of the block to update.
  26647. * @param {string[]} allowedBlocks An array of block names which are permitted
  26648. * in inner blocks.
  26649. * @param {string} [templateLock] The template lock specified for the inner
  26650. * blocks component. (e.g. "all")
  26651. * @param {boolean} captureToolbars Whether or children toolbars should be shown
  26652. * in the inner blocks component rather than on
  26653. * the child block.
  26654. * @param {string} orientation The direction in which the block
  26655. * should face.
  26656. */
  26657. function useNestedSettingsUpdate(clientId, allowedBlocks, templateLock, captureToolbars, orientation) {
  26658. const {
  26659. updateBlockListSettings
  26660. } = Object(external_wp_data_["useDispatch"])(store);
  26661. const {
  26662. blockListSettings,
  26663. parentLock
  26664. } = Object(external_wp_data_["useSelect"])(select => {
  26665. const rootClientId = select(store).getBlockRootClientId(clientId);
  26666. return {
  26667. blockListSettings: select(store).getBlockListSettings(clientId),
  26668. parentLock: select(store).getTemplateLock(rootClientId)
  26669. };
  26670. }, [clientId]); // Memoize as inner blocks implementors often pass a new array on every
  26671. // render.
  26672. const _allowedBlocks = Object(external_wp_element_["useMemo"])(() => allowedBlocks, allowedBlocks);
  26673. Object(external_wp_element_["useLayoutEffect"])(() => {
  26674. const newSettings = {
  26675. allowedBlocks: _allowedBlocks,
  26676. templateLock: templateLock === undefined ? parentLock : templateLock
  26677. }; // These values are not defined for RN, so only include them if they
  26678. // are defined.
  26679. if (captureToolbars !== undefined) {
  26680. newSettings.__experimentalCaptureToolbars = captureToolbars;
  26681. }
  26682. if (orientation !== undefined) {
  26683. newSettings.orientation = orientation;
  26684. }
  26685. if (!external_wp_isShallowEqual_default()(blockListSettings, newSettings)) {
  26686. updateBlockListSettings(clientId, newSettings);
  26687. }
  26688. }, [clientId, blockListSettings, _allowedBlocks, templateLock, parentLock, captureToolbars, orientation, updateBlockListSettings]);
  26689. }
  26690. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/use-inner-block-template-sync.js
  26691. /**
  26692. * External dependencies
  26693. */
  26694. /**
  26695. * WordPress dependencies
  26696. */
  26697. /**
  26698. * Internal dependencies
  26699. */
  26700. /**
  26701. * This hook makes sure that a block's inner blocks stay in sync with the given
  26702. * block "template". The template is a block hierarchy to which inner blocks must
  26703. * conform. If the blocks get "out of sync" with the template and the template
  26704. * is meant to be locked (e.g. templateLock = "all"), then we replace the inner
  26705. * blocks with the correct value after synchronizing it with the template.
  26706. *
  26707. * @param {string} clientId The block client ID.
  26708. * @param {Object} template The template to match.
  26709. * @param {string} templateLock The template lock state for the inner blocks. For
  26710. * example, if the template lock is set to "all",
  26711. * then the inner blocks will stay in sync with the
  26712. * template. If not defined or set to false, then
  26713. * the inner blocks will not be synchronized with
  26714. * the given template.
  26715. * @param {boolean} templateInsertUpdatesSelection Whether or not to update the
  26716. * block-editor selection state when inner blocks
  26717. * are replaced after template synchronization.
  26718. */
  26719. function useInnerBlockTemplateSync(clientId, template, templateLock, templateInsertUpdatesSelection) {
  26720. const {
  26721. getSelectedBlocksInitialCaretPosition
  26722. } = Object(external_wp_data_["useSelect"])(store);
  26723. const {
  26724. replaceInnerBlocks
  26725. } = Object(external_wp_data_["useDispatch"])(store);
  26726. const innerBlocks = Object(external_wp_data_["useSelect"])(select => select(store).getBlocks(clientId), [clientId]); // Maintain a reference to the previous value so we can do a deep equality check.
  26727. const existingTemplate = Object(external_wp_element_["useRef"])(null);
  26728. Object(external_wp_element_["useLayoutEffect"])(() => {
  26729. // Only synchronize innerBlocks with template if innerBlocks are empty or
  26730. // a locking all exists directly on the block.
  26731. if (innerBlocks.length === 0 || templateLock === 'all') {
  26732. const hasTemplateChanged = !Object(external_lodash_["isEqual"])(template, existingTemplate.current);
  26733. if (hasTemplateChanged) {
  26734. existingTemplate.current = template;
  26735. const nextBlocks = Object(external_wp_blocks_["synchronizeBlocksWithTemplate"])(innerBlocks, template);
  26736. if (!Object(external_lodash_["isEqual"])(nextBlocks, innerBlocks)) {
  26737. replaceInnerBlocks(clientId, nextBlocks, innerBlocks.length === 0 && templateInsertUpdatesSelection && nextBlocks.length !== 0, // This ensures the "initialPosition" doesn't change when applying the template
  26738. // If we're supposed to focus the block, we'll focus the first inner block
  26739. // otherwise, we won't apply any auto-focus.
  26740. // This ensures for instance that the focus stays in the inserter when inserting the "buttons" block.
  26741. getSelectedBlocksInitialCaretPosition());
  26742. }
  26743. }
  26744. }
  26745. }, [innerBlocks, template, templateLock, clientId]);
  26746. }
  26747. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/get-block-context.js
  26748. /**
  26749. * External dependencies
  26750. */
  26751. /**
  26752. * Block context cache, implemented as a WeakMap mapping block types to a
  26753. * WeakMap mapping attributes object to context value.
  26754. *
  26755. * @type {WeakMap<string,WeakMap<string,*>>}
  26756. */
  26757. const BLOCK_CONTEXT_CACHE = new WeakMap();
  26758. /**
  26759. * Returns a cached context object value for a given set of attributes for the
  26760. * block type.
  26761. *
  26762. * @param {Record<string,*>} attributes Block attributes object.
  26763. * @param {WPBlockType} blockType Block type settings.
  26764. *
  26765. * @return {Record<string,*>} Context value.
  26766. */
  26767. function getBlockContext(attributes, blockType) {
  26768. if (!BLOCK_CONTEXT_CACHE.has(blockType)) {
  26769. BLOCK_CONTEXT_CACHE.set(blockType, new WeakMap());
  26770. }
  26771. const blockTypeCache = BLOCK_CONTEXT_CACHE.get(blockType);
  26772. if (!blockTypeCache.has(attributes)) {
  26773. const context = Object(external_lodash_["mapValues"])(blockType.providesContext, attributeName => attributes[attributeName]);
  26774. blockTypeCache.set(attributes, context);
  26775. }
  26776. return blockTypeCache.get(attributes);
  26777. }
  26778. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/index.js
  26779. /**
  26780. * External dependencies
  26781. */
  26782. /**
  26783. * WordPress dependencies
  26784. */
  26785. /**
  26786. * Internal dependencies
  26787. */
  26788. /**
  26789. * InnerBlocks is a component which allows a single block to have multiple blocks
  26790. * as children. The UncontrolledInnerBlocks component is used whenever the inner
  26791. * blocks are not controlled by another entity. In other words, it is normally
  26792. * used for inner blocks in the post editor
  26793. *
  26794. * @param {Object} props The component props.
  26795. */
  26796. function UncontrolledInnerBlocks(props) {
  26797. const {
  26798. clientId,
  26799. allowedBlocks,
  26800. template,
  26801. templateLock,
  26802. wrapperRef,
  26803. templateInsertUpdatesSelection,
  26804. __experimentalCaptureToolbars: captureToolbars,
  26805. __experimentalAppenderTagName,
  26806. renderAppender,
  26807. orientation,
  26808. placeholder,
  26809. __experimentalLayout
  26810. } = props;
  26811. useNestedSettingsUpdate(clientId, allowedBlocks, templateLock, captureToolbars, orientation);
  26812. useInnerBlockTemplateSync(clientId, template, templateLock, templateInsertUpdatesSelection);
  26813. const context = Object(external_wp_data_["useSelect"])(select => {
  26814. const block = select(store).getBlock(clientId);
  26815. const blockType = Object(external_wp_blocks_["getBlockType"])(block.name);
  26816. if (!blockType || !blockType.providesContext) {
  26817. return;
  26818. }
  26819. return getBlockContext(block.attributes, blockType);
  26820. }, [clientId]); // This component needs to always be synchronous as it's the one changing
  26821. // the async mode depending on the block selection.
  26822. return Object(external_wp_element_["createElement"])(BlockContextProvider, {
  26823. value: context
  26824. }, Object(external_wp_element_["createElement"])(BlockListItems, {
  26825. rootClientId: clientId,
  26826. renderAppender: renderAppender,
  26827. __experimentalAppenderTagName: __experimentalAppenderTagName,
  26828. __experimentalLayout: __experimentalLayout,
  26829. wrapperRef: wrapperRef,
  26830. placeholder: placeholder
  26831. }));
  26832. }
  26833. /**
  26834. * The controlled inner blocks component wraps the uncontrolled inner blocks
  26835. * component with the blockSync hook. This keeps the innerBlocks of the block in
  26836. * the block-editor store in sync with the blocks of the controlling entity. An
  26837. * example of an inner block controller is a template part block, which provides
  26838. * its own blocks from the template part entity data source.
  26839. *
  26840. * @param {Object} props The component props.
  26841. */
  26842. function ControlledInnerBlocks(props) {
  26843. useBlockSync(props);
  26844. return Object(external_wp_element_["createElement"])(UncontrolledInnerBlocks, props);
  26845. }
  26846. const ForwardedInnerBlocks = Object(external_wp_element_["forwardRef"])((props, ref) => {
  26847. const innerBlocksProps = useInnerBlocksProps({
  26848. ref
  26849. }, props);
  26850. return Object(external_wp_element_["createElement"])("div", {
  26851. className: "block-editor-inner-blocks"
  26852. }, Object(external_wp_element_["createElement"])("div", innerBlocksProps));
  26853. });
  26854. /**
  26855. * This hook is used to lightly mark an element as an inner blocks wrapper
  26856. * element. Call this hook and pass the returned props to the element to mark as
  26857. * an inner blocks wrapper, automatically rendering inner blocks as children. If
  26858. * you define a ref for the element, it is important to pass the ref to this
  26859. * hook, which the hook in turn will pass to the component through the props it
  26860. * returns. Optionally, you can also pass any other props through this hook, and
  26861. * they will be merged and returned.
  26862. *
  26863. * @param {Object} props Optional. Props to pass to the element. Must contain
  26864. * the ref if one is defined.
  26865. * @param {Object} options Optional. Inner blocks options.
  26866. *
  26867. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md
  26868. */
  26869. function useInnerBlocksProps(props = {}, options = {}) {
  26870. const {
  26871. clientId
  26872. } = useBlockEditContext();
  26873. const isSmallScreen = Object(external_wp_compose_["useViewportMatch"])('medium', '<');
  26874. const hasOverlay = Object(external_wp_data_["useSelect"])(select => {
  26875. const {
  26876. getBlockName,
  26877. isBlockSelected,
  26878. hasSelectedInnerBlock,
  26879. isNavigationMode
  26880. } = select(store);
  26881. const enableClickThrough = isNavigationMode() || isSmallScreen;
  26882. return getBlockName(clientId) !== 'core/template' && !isBlockSelected(clientId) && !hasSelectedInnerBlock(clientId, true) && enableClickThrough;
  26883. }, [clientId, isSmallScreen]);
  26884. const ref = Object(external_wp_compose_["useMergeRefs"])([props.ref, useBlockDropZone({
  26885. rootClientId: clientId
  26886. })]);
  26887. const InnerBlocks = options.value && options.onChange ? ControlledInnerBlocks : UncontrolledInnerBlocks;
  26888. return { ...props,
  26889. ref,
  26890. className: classnames_default()(props.className, 'block-editor-block-list__layout', {
  26891. 'has-overlay': hasOverlay
  26892. }),
  26893. children: Object(external_wp_element_["createElement"])(InnerBlocks, Object(esm_extends["a" /* default */])({}, options, {
  26894. clientId: clientId
  26895. }))
  26896. };
  26897. } // Expose default appender placeholders as components.
  26898. ForwardedInnerBlocks.DefaultBlockAppender = inner_blocks_default_block_appender;
  26899. ForwardedInnerBlocks.ButtonBlockAppender = inner_blocks_button_block_appender;
  26900. ForwardedInnerBlocks.Content = Object(external_wp_blocks_["withBlockContentContext"])(({
  26901. BlockContent
  26902. }) => Object(external_wp_element_["createElement"])(BlockContent, null));
  26903. /**
  26904. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md
  26905. */
  26906. /* harmony default export */ var inner_blocks = (ForwardedInnerBlocks);
  26907. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/justify-left.js
  26908. /**
  26909. * WordPress dependencies
  26910. */
  26911. const justifyLeft = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
  26912. xmlns: "http://www.w3.org/2000/svg",
  26913. viewBox: "0 0 24 24"
  26914. }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
  26915. d: "M9 9v6h11V9H9zM4 20h1.5V4H4v16z"
  26916. }));
  26917. /* harmony default export */ var justify_left = (justifyLeft);
  26918. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/justify-center.js
  26919. /**
  26920. * WordPress dependencies
  26921. */
  26922. const justifyCenter = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
  26923. xmlns: "http://www.w3.org/2000/svg",
  26924. viewBox: "0 0 24 24"
  26925. }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
  26926. d: "M20 9h-7.2V4h-1.6v5H4v6h7.2v5h1.6v-5H20z"
  26927. }));
  26928. /* harmony default export */ var justify_center = (justifyCenter);
  26929. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/justify-right.js
  26930. /**
  26931. * WordPress dependencies
  26932. */
  26933. const justifyRight = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
  26934. xmlns: "http://www.w3.org/2000/svg",
  26935. viewBox: "0 0 24 24"
  26936. }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
  26937. d: "M4 15h11V9H4v6zM18.5 4v16H20V4h-1.5z"
  26938. }));
  26939. /* harmony default export */ var justify_right = (justifyRight);
  26940. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/justify-space-between.js
  26941. /**
  26942. * WordPress dependencies
  26943. */
  26944. const justifySpaceBetween = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
  26945. xmlns: "http://www.w3.org/2000/svg",
  26946. viewBox: "0 0 24 24"
  26947. }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
  26948. d: "M9 15h6V9H9v6zm-5 5h1.5V4H4v16zM18.5 4v16H20V4h-1.5z"
  26949. }));
  26950. /* harmony default export */ var justify_space_between = (justifySpaceBetween);
  26951. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/justify-content-control/ui.js
  26952. /**
  26953. * WordPress dependencies
  26954. */
  26955. const icons = {
  26956. left: justify_left,
  26957. center: justify_center,
  26958. right: justify_right,
  26959. 'space-between': justify_space_between
  26960. };
  26961. function JustifyContentUI({
  26962. allowedControls = ['left', 'center', 'right', 'space-between'],
  26963. isCollapsed = true,
  26964. onChange,
  26965. value,
  26966. popoverProps,
  26967. isToolbar
  26968. }) {
  26969. // If the control is already selected we want a click
  26970. // again on the control to deselect the item, so we
  26971. // call onChange( undefined )
  26972. const handleClick = next => {
  26973. if (next === value) {
  26974. onChange(undefined);
  26975. } else {
  26976. onChange(next);
  26977. }
  26978. };
  26979. const icon = value ? icons[value] : icons.left;
  26980. const allControls = [{
  26981. name: 'left',
  26982. icon: justify_left,
  26983. title: Object(external_wp_i18n_["__"])('Justify items left'),
  26984. isActive: 'left' === value,
  26985. onClick: () => handleClick('left')
  26986. }, {
  26987. name: 'center',
  26988. icon: justify_center,
  26989. title: Object(external_wp_i18n_["__"])('Justify items center'),
  26990. isActive: 'center' === value,
  26991. onClick: () => handleClick('center')
  26992. }, {
  26993. name: 'right',
  26994. icon: justify_right,
  26995. title: Object(external_wp_i18n_["__"])('Justify items right'),
  26996. isActive: 'right' === value,
  26997. onClick: () => handleClick('right')
  26998. }, {
  26999. name: 'space-between',
  27000. icon: justify_space_between,
  27001. title: Object(external_wp_i18n_["__"])('Space between items'),
  27002. isActive: 'space-between' === value,
  27003. onClick: () => handleClick('space-between')
  27004. }];
  27005. const UIComponent = isToolbar ? external_wp_components_["ToolbarGroup"] : external_wp_components_["ToolbarDropdownMenu"];
  27006. const extraProps = isToolbar ? {
  27007. isCollapsed
  27008. } : {};
  27009. return Object(external_wp_element_["createElement"])(UIComponent, Object(esm_extends["a" /* default */])({
  27010. icon: icon,
  27011. popoverProps: popoverProps,
  27012. label: Object(external_wp_i18n_["__"])('Change items justification'),
  27013. controls: allControls.filter(elem => allowedControls.includes(elem.name))
  27014. }, extraProps));
  27015. }
  27016. /* harmony default export */ var justify_content_control_ui = (JustifyContentUI);
  27017. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/justify-content-control/index.js
  27018. /**
  27019. * Internal dependencies
  27020. */
  27021. function JustifyContentControl(props) {
  27022. return Object(external_wp_element_["createElement"])(justify_content_control_ui, Object(esm_extends["a" /* default */])({}, props, {
  27023. isToolbar: false
  27024. }));
  27025. }
  27026. function JustifyToolbar(props) {
  27027. return Object(external_wp_element_["createElement"])(justify_content_control_ui, Object(esm_extends["a" /* default */])({}, props, {
  27028. isToolbar: true
  27029. }));
  27030. }
  27031. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/keyboard-return.js
  27032. var keyboard_return = __webpack_require__("btIw");
  27033. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/settings-drawer.js
  27034. /**
  27035. * External dependencies
  27036. */
  27037. /**
  27038. * WordPress dependencies
  27039. */
  27040. const defaultSettings = [{
  27041. id: 'opensInNewTab',
  27042. title: Object(external_wp_i18n_["__"])('Open in new tab')
  27043. }];
  27044. const LinkControlSettingsDrawer = ({
  27045. value,
  27046. onChange = external_lodash_["noop"],
  27047. settings = defaultSettings
  27048. }) => {
  27049. if (!settings || !settings.length) {
  27050. return null;
  27051. }
  27052. const handleSettingChange = setting => newValue => {
  27053. onChange({ ...value,
  27054. [setting.id]: newValue
  27055. });
  27056. };
  27057. const theSettings = settings.map(setting => Object(external_wp_element_["createElement"])(external_wp_components_["ToggleControl"], {
  27058. className: "block-editor-link-control__setting",
  27059. key: setting.id,
  27060. label: setting.title,
  27061. onChange: handleSettingChange(setting),
  27062. checked: value ? !!value[setting.id] : false
  27063. }));
  27064. return Object(external_wp_element_["createElement"])("fieldset", {
  27065. className: "block-editor-link-control__settings"
  27066. }, Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], {
  27067. as: "legend"
  27068. }, Object(external_wp_i18n_["__"])('Currently selected link settings')), theSettings);
  27069. };
  27070. /* harmony default export */ var settings_drawer = (LinkControlSettingsDrawer);
  27071. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-input/index.js
  27072. /**
  27073. * External dependencies
  27074. */
  27075. /**
  27076. * WordPress dependencies
  27077. */
  27078. /**
  27079. * Internal dependencies
  27080. */
  27081. class url_input_URLInput extends external_wp_element_["Component"] {
  27082. constructor(props) {
  27083. super(props);
  27084. this.onChange = this.onChange.bind(this);
  27085. this.onFocus = this.onFocus.bind(this);
  27086. this.onKeyDown = this.onKeyDown.bind(this);
  27087. this.selectLink = this.selectLink.bind(this);
  27088. this.handleOnClick = this.handleOnClick.bind(this);
  27089. this.bindSuggestionNode = this.bindSuggestionNode.bind(this);
  27090. this.autocompleteRef = props.autocompleteRef || Object(external_wp_element_["createRef"])();
  27091. this.inputRef = Object(external_wp_element_["createRef"])();
  27092. this.updateSuggestions = Object(external_lodash_["debounce"])(this.updateSuggestions.bind(this), 200);
  27093. this.suggestionNodes = [];
  27094. this.isUpdatingSuggestions = false;
  27095. this.state = {
  27096. suggestions: [],
  27097. showSuggestions: false,
  27098. selectedSuggestion: null,
  27099. suggestionsListboxId: '',
  27100. suggestionOptionIdPrefix: ''
  27101. };
  27102. }
  27103. componentDidUpdate(prevProps) {
  27104. const {
  27105. showSuggestions,
  27106. selectedSuggestion
  27107. } = this.state;
  27108. const {
  27109. value
  27110. } = this.props; // only have to worry about scrolling selected suggestion into view
  27111. // when already expanded
  27112. if (showSuggestions && selectedSuggestion !== null && this.suggestionNodes[selectedSuggestion] && !this.scrollingIntoView) {
  27113. this.scrollingIntoView = true;
  27114. dom_scroll_into_view_lib_default()(this.suggestionNodes[selectedSuggestion], this.autocompleteRef.current, {
  27115. onlyScrollIfNeeded: true
  27116. });
  27117. this.props.setTimeout(() => {
  27118. this.scrollingIntoView = false;
  27119. }, 100);
  27120. } // Only attempt an update on suggestions if the input value has actually changed.
  27121. if (prevProps.value !== value && this.shouldShowInitialSuggestions()) {
  27122. this.updateSuggestions();
  27123. }
  27124. }
  27125. componentDidMount() {
  27126. if (this.shouldShowInitialSuggestions()) {
  27127. this.updateSuggestions();
  27128. }
  27129. }
  27130. componentWillUnmount() {
  27131. var _this$suggestionsRequ, _this$suggestionsRequ2;
  27132. (_this$suggestionsRequ = this.suggestionsRequest) === null || _this$suggestionsRequ === void 0 ? void 0 : (_this$suggestionsRequ2 = _this$suggestionsRequ.cancel) === null || _this$suggestionsRequ2 === void 0 ? void 0 : _this$suggestionsRequ2.call(_this$suggestionsRequ);
  27133. delete this.suggestionsRequest;
  27134. }
  27135. bindSuggestionNode(index) {
  27136. return ref => {
  27137. this.suggestionNodes[index] = ref;
  27138. };
  27139. }
  27140. shouldShowInitialSuggestions() {
  27141. const {
  27142. suggestions
  27143. } = this.state;
  27144. const {
  27145. __experimentalShowInitialSuggestions = false,
  27146. value
  27147. } = this.props;
  27148. return !this.isUpdatingSuggestions && __experimentalShowInitialSuggestions && !(value && value.length) && !(suggestions && suggestions.length);
  27149. }
  27150. updateSuggestions(value = '') {
  27151. const {
  27152. __experimentalFetchLinkSuggestions: fetchLinkSuggestions,
  27153. __experimentalHandleURLSuggestions: handleURLSuggestions
  27154. } = this.props;
  27155. if (!fetchLinkSuggestions) {
  27156. return;
  27157. }
  27158. const isInitialSuggestions = !(value && value.length); // Allow a suggestions request if:
  27159. // - there are at least 2 characters in the search input (except manual searches where
  27160. // search input length is not required to trigger a fetch)
  27161. // - this is a direct entry (eg: a URL)
  27162. if (!isInitialSuggestions && (value.length < 2 || !handleURLSuggestions && Object(external_wp_url_["isURL"])(value))) {
  27163. this.setState({
  27164. showSuggestions: false,
  27165. selectedSuggestion: null,
  27166. loading: false
  27167. });
  27168. return;
  27169. }
  27170. this.isUpdatingSuggestions = true;
  27171. this.setState({
  27172. selectedSuggestion: null,
  27173. loading: true
  27174. });
  27175. const request = fetchLinkSuggestions(value, {
  27176. isInitialSuggestions
  27177. });
  27178. request.then(suggestions => {
  27179. // A fetch Promise doesn't have an abort option. It's mimicked by
  27180. // comparing the request reference in on the instance, which is
  27181. // reset or deleted on subsequent requests or unmounting.
  27182. if (this.suggestionsRequest !== request) {
  27183. return;
  27184. }
  27185. this.setState({
  27186. suggestions,
  27187. loading: false,
  27188. showSuggestions: !!suggestions.length
  27189. });
  27190. if (!!suggestions.length) {
  27191. this.props.debouncedSpeak(Object(external_wp_i18n_["sprintf"])(
  27192. /* translators: %s: number of results. */
  27193. Object(external_wp_i18n_["_n"])('%d result found, use up and down arrow keys to navigate.', '%d results found, use up and down arrow keys to navigate.', suggestions.length), suggestions.length), 'assertive');
  27194. } else {
  27195. this.props.debouncedSpeak(Object(external_wp_i18n_["__"])('No results.'), 'assertive');
  27196. }
  27197. this.isUpdatingSuggestions = false;
  27198. }).catch(() => {
  27199. if (this.suggestionsRequest === request) {
  27200. this.setState({
  27201. loading: false
  27202. });
  27203. this.isUpdatingSuggestions = false;
  27204. }
  27205. }); // Note that this assignment is handled *before* the async search request
  27206. // as a Promise always resolves on the next tick of the event loop.
  27207. this.suggestionsRequest = request;
  27208. }
  27209. onChange(event) {
  27210. const inputValue = event.target.value;
  27211. this.props.onChange(inputValue);
  27212. if (!this.props.disableSuggestions) {
  27213. this.updateSuggestions(inputValue.trim());
  27214. }
  27215. }
  27216. onFocus() {
  27217. const {
  27218. suggestions
  27219. } = this.state;
  27220. const {
  27221. disableSuggestions,
  27222. value
  27223. } = this.props; // When opening the link editor, if there's a value present, we want to load the suggestions pane with the results for this input search value
  27224. // Don't re-run the suggestions on focus if there are already suggestions present (prevents searching again when tabbing between the input and buttons)
  27225. if (value && !disableSuggestions && !this.isUpdatingSuggestions && !(suggestions && suggestions.length)) {
  27226. // Ensure the suggestions are updated with the current input value
  27227. this.updateSuggestions(value.trim());
  27228. }
  27229. }
  27230. onKeyDown(event) {
  27231. const {
  27232. showSuggestions,
  27233. selectedSuggestion,
  27234. suggestions,
  27235. loading
  27236. } = this.state; // If the suggestions are not shown or loading, we shouldn't handle the arrow keys
  27237. // We shouldn't preventDefault to allow block arrow keys navigation
  27238. if (!showSuggestions || !suggestions.length || loading) {
  27239. // In the Windows version of Firefox the up and down arrows don't move the caret
  27240. // within an input field like they do for Mac Firefox/Chrome/Safari. This causes
  27241. // a form of focus trapping that is disruptive to the user experience. This disruption
  27242. // only happens if the caret is not in the first or last position in the text input.
  27243. // See: https://github.com/WordPress/gutenberg/issues/5693#issuecomment-436684747
  27244. switch (event.keyCode) {
  27245. // When UP is pressed, if the caret is at the start of the text, move it to the 0
  27246. // position.
  27247. case external_wp_keycodes_["UP"]:
  27248. {
  27249. if (0 !== event.target.selectionStart) {
  27250. event.stopPropagation();
  27251. event.preventDefault(); // Set the input caret to position 0
  27252. event.target.setSelectionRange(0, 0);
  27253. }
  27254. break;
  27255. }
  27256. // When DOWN is pressed, if the caret is not at the end of the text, move it to the
  27257. // last position.
  27258. case external_wp_keycodes_["DOWN"]:
  27259. {
  27260. if (this.props.value.length !== event.target.selectionStart) {
  27261. event.stopPropagation();
  27262. event.preventDefault(); // Set the input caret to the last position
  27263. event.target.setSelectionRange(this.props.value.length, this.props.value.length);
  27264. }
  27265. break;
  27266. }
  27267. }
  27268. return;
  27269. }
  27270. const suggestion = this.state.suggestions[this.state.selectedSuggestion];
  27271. switch (event.keyCode) {
  27272. case external_wp_keycodes_["UP"]:
  27273. {
  27274. event.stopPropagation();
  27275. event.preventDefault();
  27276. const previousIndex = !selectedSuggestion ? suggestions.length - 1 : selectedSuggestion - 1;
  27277. this.setState({
  27278. selectedSuggestion: previousIndex
  27279. });
  27280. break;
  27281. }
  27282. case external_wp_keycodes_["DOWN"]:
  27283. {
  27284. event.stopPropagation();
  27285. event.preventDefault();
  27286. const nextIndex = selectedSuggestion === null || selectedSuggestion === suggestions.length - 1 ? 0 : selectedSuggestion + 1;
  27287. this.setState({
  27288. selectedSuggestion: nextIndex
  27289. });
  27290. break;
  27291. }
  27292. case external_wp_keycodes_["TAB"]:
  27293. {
  27294. if (this.state.selectedSuggestion !== null) {
  27295. this.selectLink(suggestion); // Announce a link has been selected when tabbing away from the input field.
  27296. this.props.speak(Object(external_wp_i18n_["__"])('Link selected.'));
  27297. }
  27298. break;
  27299. }
  27300. case external_wp_keycodes_["ENTER"]:
  27301. {
  27302. if (this.state.selectedSuggestion !== null) {
  27303. event.stopPropagation();
  27304. this.selectLink(suggestion);
  27305. }
  27306. break;
  27307. }
  27308. }
  27309. }
  27310. selectLink(suggestion) {
  27311. this.props.onChange(suggestion.url, suggestion);
  27312. this.setState({
  27313. selectedSuggestion: null,
  27314. showSuggestions: false
  27315. });
  27316. }
  27317. handleOnClick(suggestion) {
  27318. this.selectLink(suggestion); // Move focus to the input field when a link suggestion is clicked.
  27319. this.inputRef.current.focus();
  27320. }
  27321. static getDerivedStateFromProps({
  27322. value,
  27323. instanceId,
  27324. disableSuggestions,
  27325. __experimentalShowInitialSuggestions = false
  27326. }, {
  27327. showSuggestions
  27328. }) {
  27329. let shouldShowSuggestions = showSuggestions;
  27330. const hasValue = value && value.length;
  27331. if (!__experimentalShowInitialSuggestions && !hasValue) {
  27332. shouldShowSuggestions = false;
  27333. }
  27334. if (disableSuggestions === true) {
  27335. shouldShowSuggestions = false;
  27336. }
  27337. return {
  27338. showSuggestions: shouldShowSuggestions,
  27339. suggestionsListboxId: `block-editor-url-input-suggestions-${instanceId}`,
  27340. suggestionOptionIdPrefix: `block-editor-url-input-suggestion-${instanceId}`
  27341. };
  27342. }
  27343. render() {
  27344. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, this.renderControl(), this.renderSuggestions());
  27345. }
  27346. renderControl() {
  27347. const {
  27348. label,
  27349. className,
  27350. isFullWidth,
  27351. instanceId,
  27352. placeholder = Object(external_wp_i18n_["__"])('Paste URL or type to search'),
  27353. __experimentalRenderControl: renderControl,
  27354. value = ''
  27355. } = this.props;
  27356. const {
  27357. loading,
  27358. showSuggestions,
  27359. selectedSuggestion,
  27360. suggestionsListboxId,
  27361. suggestionOptionIdPrefix
  27362. } = this.state;
  27363. const controlProps = {
  27364. id: `url-input-control-${instanceId}`,
  27365. label,
  27366. className: classnames_default()('block-editor-url-input', className, {
  27367. 'is-full-width': isFullWidth
  27368. })
  27369. };
  27370. const inputProps = {
  27371. value,
  27372. required: true,
  27373. className: 'block-editor-url-input__input',
  27374. type: 'text',
  27375. onChange: this.onChange,
  27376. onFocus: this.onFocus,
  27377. placeholder,
  27378. onKeyDown: this.onKeyDown,
  27379. role: 'combobox',
  27380. 'aria-label': Object(external_wp_i18n_["__"])('URL'),
  27381. 'aria-expanded': showSuggestions,
  27382. 'aria-autocomplete': 'list',
  27383. 'aria-owns': suggestionsListboxId,
  27384. 'aria-activedescendant': selectedSuggestion !== null ? `${suggestionOptionIdPrefix}-${selectedSuggestion}` : undefined,
  27385. ref: this.inputRef
  27386. };
  27387. if (renderControl) {
  27388. return renderControl(controlProps, inputProps, loading);
  27389. }
  27390. return Object(external_wp_element_["createElement"])(external_wp_components_["BaseControl"], controlProps, Object(external_wp_element_["createElement"])("input", inputProps), loading && Object(external_wp_element_["createElement"])(external_wp_components_["Spinner"], null));
  27391. }
  27392. renderSuggestions() {
  27393. const {
  27394. className,
  27395. __experimentalRenderSuggestions: renderSuggestions,
  27396. value = '',
  27397. __experimentalShowInitialSuggestions = false
  27398. } = this.props;
  27399. const {
  27400. showSuggestions,
  27401. suggestions,
  27402. selectedSuggestion,
  27403. suggestionsListboxId,
  27404. suggestionOptionIdPrefix,
  27405. loading
  27406. } = this.state;
  27407. const suggestionsListProps = {
  27408. id: suggestionsListboxId,
  27409. ref: this.autocompleteRef,
  27410. role: 'listbox'
  27411. };
  27412. const buildSuggestionItemProps = (suggestion, index) => {
  27413. return {
  27414. role: 'option',
  27415. tabIndex: '-1',
  27416. id: `${suggestionOptionIdPrefix}-${index}`,
  27417. ref: this.bindSuggestionNode(index),
  27418. 'aria-selected': index === selectedSuggestion
  27419. };
  27420. };
  27421. if (Object(external_lodash_["isFunction"])(renderSuggestions) && showSuggestions && !!suggestions.length) {
  27422. return renderSuggestions({
  27423. suggestions,
  27424. selectedSuggestion,
  27425. suggestionsListProps,
  27426. buildSuggestionItemProps,
  27427. isLoading: loading,
  27428. handleSuggestionClick: this.handleOnClick,
  27429. isInitialSuggestions: __experimentalShowInitialSuggestions && !(value && value.length)
  27430. });
  27431. }
  27432. if (!Object(external_lodash_["isFunction"])(renderSuggestions) && showSuggestions && !!suggestions.length) {
  27433. return Object(external_wp_element_["createElement"])(external_wp_components_["Popover"], {
  27434. position: "bottom",
  27435. noArrow: true,
  27436. focusOnMount: false
  27437. }, Object(external_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({}, suggestionsListProps, {
  27438. className: classnames_default()('block-editor-url-input__suggestions', `${className}__suggestions`)
  27439. }), suggestions.map((suggestion, index) => Object(external_wp_element_["createElement"])(external_wp_components_["Button"], Object(esm_extends["a" /* default */])({}, buildSuggestionItemProps(suggestion, index), {
  27440. key: suggestion.id,
  27441. className: classnames_default()('block-editor-url-input__suggestion', {
  27442. 'is-selected': index === selectedSuggestion
  27443. }),
  27444. onClick: () => this.handleOnClick(suggestion)
  27445. }), suggestion.title))));
  27446. }
  27447. return null;
  27448. }
  27449. }
  27450. /**
  27451. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md
  27452. */
  27453. /* harmony default export */ var url_input = (Object(external_wp_compose_["compose"])(external_wp_compose_["withSafeTimeout"], external_wp_components_["withSpokenMessages"], external_wp_compose_["withInstanceId"], Object(external_wp_data_["withSelect"])((select, props) => {
  27454. // If a link suggestions handler is already provided then
  27455. // bail
  27456. if (Object(external_lodash_["isFunction"])(props.__experimentalFetchLinkSuggestions)) {
  27457. return;
  27458. }
  27459. const {
  27460. getSettings
  27461. } = select(store);
  27462. return {
  27463. __experimentalFetchLinkSuggestions: getSettings().__experimentalFetchLinkSuggestions
  27464. };
  27465. }))(url_input_URLInput));
  27466. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/search-create-button.js
  27467. /**
  27468. * External dependencies
  27469. */
  27470. /**
  27471. * WordPress dependencies
  27472. */
  27473. const LinkControlSearchCreate = ({
  27474. searchTerm,
  27475. onClick,
  27476. itemProps,
  27477. isSelected,
  27478. buttonText
  27479. }) => {
  27480. if (!searchTerm) {
  27481. return null;
  27482. }
  27483. let text;
  27484. if (buttonText) {
  27485. text = Object(external_lodash_["isFunction"])(buttonText) ? buttonText(searchTerm) : buttonText;
  27486. } else {
  27487. text = Object(external_wp_element_["createInterpolateElement"])(Object(external_wp_i18n_["sprintf"])(
  27488. /* translators: %s: search term. */
  27489. Object(external_wp_i18n_["__"])('Create: <mark>%s</mark>'), searchTerm), {
  27490. mark: Object(external_wp_element_["createElement"])("mark", null)
  27491. });
  27492. }
  27493. return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], Object(esm_extends["a" /* default */])({}, itemProps, {
  27494. className: classnames_default()('block-editor-link-control__search-create block-editor-link-control__search-item', {
  27495. 'is-selected': isSelected
  27496. }),
  27497. onClick: onClick
  27498. }), Object(external_wp_element_["createElement"])(build_module_icon["a" /* default */], {
  27499. className: "block-editor-link-control__search-item-icon",
  27500. icon: plus["a" /* default */]
  27501. }), Object(external_wp_element_["createElement"])("span", {
  27502. className: "block-editor-link-control__search-item-header"
  27503. }, Object(external_wp_element_["createElement"])("span", {
  27504. className: "block-editor-link-control__search-item-title"
  27505. }, text)));
  27506. };
  27507. /* harmony default export */ var search_create_button = (LinkControlSearchCreate);
  27508. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/globe.js
  27509. /**
  27510. * WordPress dependencies
  27511. */
  27512. const globe = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
  27513. xmlns: "http://www.w3.org/2000/svg",
  27514. viewBox: "-2 -2 24 24"
  27515. }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
  27516. d: "M9 0C4.03 0 0 4.03 0 9s4.03 9 9 9 9-4.03 9-9-4.03-9-9-9zM1.11 9.68h2.51c.04.91.167 1.814.38 2.7H1.84c-.403-.85-.65-1.764-.73-2.7zm8.57-5.4V1.19c.964.366 1.756 1.08 2.22 2 .205.347.386.708.54 1.08l-2.76.01zm3.22 1.35c.232.883.37 1.788.41 2.7H9.68v-2.7h3.22zM8.32 1.19v3.09H5.56c.154-.372.335-.733.54-1.08.462-.924 1.255-1.64 2.22-2.01zm0 4.44v2.7H4.7c.04-.912.178-1.817.41-2.7h3.21zm-4.7 2.69H1.11c.08-.936.327-1.85.73-2.7H4c-.213.886-.34 1.79-.38 2.7zM4.7 9.68h3.62v2.7H5.11c-.232-.883-.37-1.788-.41-2.7zm3.63 4v3.09c-.964-.366-1.756-1.08-2.22-2-.205-.347-.386-.708-.54-1.08l2.76-.01zm1.35 3.09v-3.04h2.76c-.154.372-.335.733-.54 1.08-.464.92-1.256 1.634-2.22 2v-.04zm0-4.44v-2.7h3.62c-.04.912-.178 1.817-.41 2.7H9.68zm4.71-2.7h2.51c-.08.936-.327 1.85-.73 2.7H14c.21-.87.337-1.757.38-2.65l.01-.05zm0-1.35c-.046-.894-.176-1.78-.39-2.65h2.16c.403.85.65 1.764.73 2.7l-2.5-.05zm1-4H13.6c-.324-.91-.793-1.76-1.39-2.52 1.244.56 2.325 1.426 3.14 2.52h.04zm-9.6-2.52c-.597.76-1.066 1.61-1.39 2.52H2.65c.815-1.094 1.896-1.96 3.14-2.52zm-3.15 12H4.4c.324.91.793 1.76 1.39 2.52-1.248-.567-2.33-1.445-3.14-2.55l-.01.03zm9.56 2.52c.597-.76 1.066-1.61 1.39-2.52h1.76c-.82 1.08-1.9 1.933-3.14 2.48l-.01.04z"
  27517. }));
  27518. /* harmony default export */ var library_globe = (globe);
  27519. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/search-item.js
  27520. /**
  27521. * External dependencies
  27522. */
  27523. /**
  27524. * WordPress dependencies
  27525. */
  27526. const LinkControlSearchItem = ({
  27527. itemProps,
  27528. suggestion,
  27529. isSelected = false,
  27530. onClick,
  27531. isURL = false,
  27532. searchTerm = '',
  27533. shouldShowType = false
  27534. }) => {
  27535. return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], Object(esm_extends["a" /* default */])({}, itemProps, {
  27536. onClick: onClick,
  27537. className: classnames_default()('block-editor-link-control__search-item', {
  27538. 'is-selected': isSelected,
  27539. 'is-url': isURL,
  27540. 'is-entity': !isURL
  27541. })
  27542. }), isURL && Object(external_wp_element_["createElement"])(build_module_icon["a" /* default */], {
  27543. className: "block-editor-link-control__search-item-icon",
  27544. icon: library_globe
  27545. }), Object(external_wp_element_["createElement"])("span", {
  27546. className: "block-editor-link-control__search-item-header"
  27547. }, Object(external_wp_element_["createElement"])("span", {
  27548. className: "block-editor-link-control__search-item-title"
  27549. }, Object(external_wp_element_["createElement"])(external_wp_components_["TextHighlight"], {
  27550. text: suggestion.title,
  27551. highlight: searchTerm
  27552. })), Object(external_wp_element_["createElement"])("span", {
  27553. "aria-hidden": !isURL,
  27554. className: "block-editor-link-control__search-item-info"
  27555. }, !isURL && (Object(external_wp_url_["filterURLForDisplay"])(Object(external_wp_url_["safeDecodeURI"])(suggestion.url)) || ''), isURL && Object(external_wp_i18n_["__"])('Press ENTER to add this link'))), shouldShowType && suggestion.type && Object(external_wp_element_["createElement"])("span", {
  27556. className: "block-editor-link-control__search-item-type"
  27557. }, suggestion.type === 'post_tag' ? 'tag' : suggestion.type));
  27558. };
  27559. /* harmony default export */ var search_item = (LinkControlSearchItem);
  27560. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/constants.js
  27561. // Used as a unique identifier for the "Create" option within search results.
  27562. // Used to help distinguish the "Create" suggestion within the search results in
  27563. // order to handle it as a unique case.
  27564. const CREATE_TYPE = '__CREATE__';
  27565. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/search-results.js
  27566. /**
  27567. * WordPress dependencies
  27568. */
  27569. /**
  27570. * External dependencies
  27571. */
  27572. /**
  27573. * Internal dependencies
  27574. */
  27575. function LinkControlSearchResults({
  27576. instanceId,
  27577. withCreateSuggestion,
  27578. currentInputValue,
  27579. handleSuggestionClick,
  27580. suggestionsListProps,
  27581. buildSuggestionItemProps,
  27582. suggestions,
  27583. selectedSuggestion,
  27584. isLoading,
  27585. isInitialSuggestions,
  27586. createSuggestionButtonText,
  27587. suggestionsQuery
  27588. }) {
  27589. const resultsListClasses = classnames_default()('block-editor-link-control__search-results', {
  27590. 'is-loading': isLoading
  27591. });
  27592. const directLinkEntryTypes = ['url', 'mailto', 'tel', 'internal'];
  27593. const isSingleDirectEntryResult = suggestions.length === 1 && directLinkEntryTypes.includes(suggestions[0].type.toLowerCase());
  27594. const shouldShowCreateSuggestion = withCreateSuggestion && !isSingleDirectEntryResult && !isInitialSuggestions; // If the query has a specified type, then we can skip showing them in the result. See #24839.
  27595. const shouldShowSuggestionsTypes = !(suggestionsQuery !== null && suggestionsQuery !== void 0 && suggestionsQuery.type); // According to guidelines aria-label should be added if the label
  27596. // itself is not visible.
  27597. // See: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role
  27598. const searchResultsLabelId = `block-editor-link-control-search-results-label-${instanceId}`;
  27599. const labelText = isInitialSuggestions ? Object(external_wp_i18n_["__"])('Recently updated') : Object(external_wp_i18n_["sprintf"])(
  27600. /* translators: %s: search term. */
  27601. Object(external_wp_i18n_["__"])('Search results for "%s"'), currentInputValue); // VisuallyHidden rightly doesn't accept custom classNames
  27602. // so we conditionally render it as a wrapper to visually hide the label
  27603. // when that is required.
  27604. const searchResultsLabel = Object(external_wp_element_["createElement"])(isInitialSuggestions ? external_wp_element_["Fragment"] : external_wp_components_["VisuallyHidden"], {}, // empty props
  27605. Object(external_wp_element_["createElement"])("span", {
  27606. className: "block-editor-link-control__search-results-label",
  27607. id: searchResultsLabelId
  27608. }, labelText));
  27609. return Object(external_wp_element_["createElement"])("div", {
  27610. className: "block-editor-link-control__search-results-wrapper"
  27611. }, searchResultsLabel, Object(external_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({}, suggestionsListProps, {
  27612. className: resultsListClasses,
  27613. "aria-labelledby": searchResultsLabelId
  27614. }), suggestions.map((suggestion, index) => {
  27615. if (shouldShowCreateSuggestion && CREATE_TYPE === suggestion.type) {
  27616. return Object(external_wp_element_["createElement"])(search_create_button, {
  27617. searchTerm: currentInputValue,
  27618. buttonText: createSuggestionButtonText,
  27619. onClick: () => handleSuggestionClick(suggestion) // Intentionally only using `type` here as
  27620. // the constant is enough to uniquely
  27621. // identify the single "CREATE" suggestion.
  27622. ,
  27623. key: suggestion.type,
  27624. itemProps: buildSuggestionItemProps(suggestion, index),
  27625. isSelected: index === selectedSuggestion
  27626. });
  27627. } // If we're not handling "Create" suggestions above then
  27628. // we don't want them in the main results so exit early
  27629. if (CREATE_TYPE === suggestion.type) {
  27630. return null;
  27631. }
  27632. return Object(external_wp_element_["createElement"])(search_item, {
  27633. key: `${suggestion.id}-${suggestion.type}`,
  27634. itemProps: buildSuggestionItemProps(suggestion, index),
  27635. suggestion: suggestion,
  27636. index: index,
  27637. onClick: () => {
  27638. handleSuggestionClick(suggestion);
  27639. },
  27640. isSelected: index === selectedSuggestion,
  27641. isURL: directLinkEntryTypes.includes(suggestion.type.toLowerCase()),
  27642. searchTerm: currentInputValue,
  27643. shouldShowType: shouldShowSuggestionsTypes
  27644. });
  27645. })));
  27646. }
  27647. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/is-url-like.js
  27648. /**
  27649. * External dependencies
  27650. */
  27651. /**
  27652. * WordPress dependencies
  27653. */
  27654. /**
  27655. * Determines whether a given value could be a URL. Note this does not
  27656. * guarantee the value is a URL only that it looks like it might be one. For
  27657. * example, just because a string has `www.` in it doesn't make it a URL,
  27658. * but it does make it highly likely that it will be so in the context of
  27659. * creating a link it makes sense to treat it like one.
  27660. *
  27661. * @param {string} val the candidate for being URL-like (or not).
  27662. * @return {boolean} whether or not the value is potentially a URL.
  27663. */
  27664. function isURLLike(val) {
  27665. const isInternal = Object(external_lodash_["startsWith"])(val, '#');
  27666. return Object(external_wp_url_["isURL"])(val) || val && val.includes('www.') || isInternal;
  27667. }
  27668. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/use-search-handler.js
  27669. /**
  27670. * WordPress dependencies
  27671. */
  27672. /**
  27673. * External dependencies
  27674. */
  27675. /**
  27676. * Internal dependencies
  27677. */
  27678. const handleNoop = () => Promise.resolve([]);
  27679. const handleDirectEntry = val => {
  27680. let type = 'URL';
  27681. const protocol = Object(external_wp_url_["getProtocol"])(val) || '';
  27682. if (protocol.includes('mailto')) {
  27683. type = 'mailto';
  27684. }
  27685. if (protocol.includes('tel')) {
  27686. type = 'tel';
  27687. }
  27688. if (Object(external_lodash_["startsWith"])(val, '#')) {
  27689. type = 'internal';
  27690. }
  27691. return Promise.resolve([{
  27692. id: val,
  27693. title: val,
  27694. url: type === 'URL' ? Object(external_wp_url_["prependHTTP"])(val) : val,
  27695. type
  27696. }]);
  27697. };
  27698. const handleEntitySearch = async (val, suggestionsQuery, fetchSearchSuggestions, directEntryHandler, withCreateSuggestion, withURLSuggestion) => {
  27699. const {
  27700. isInitialSuggestions
  27701. } = suggestionsQuery;
  27702. let results = await Promise.all([fetchSearchSuggestions(val, suggestionsQuery), directEntryHandler(val)]);
  27703. const couldBeURL = !val.includes(' '); // If it's potentially a URL search then concat on a URL search suggestion
  27704. // just for good measure. That way once the actual results run out we always
  27705. // have a URL option to fallback on.
  27706. if (couldBeURL && withURLSuggestion && !isInitialSuggestions) {
  27707. results = results[0].concat(results[1]);
  27708. } else {
  27709. results = results[0];
  27710. } // If displaying initial suggestions just return plain results.
  27711. if (isInitialSuggestions) {
  27712. return results;
  27713. } // Here we append a faux suggestion to represent a "CREATE" option. This
  27714. // is detected in the rendering of the search results and handled as a
  27715. // special case. This is currently necessary because the suggestions
  27716. // dropdown will only appear if there are valid suggestions and
  27717. // therefore unless the create option is a suggestion it will not
  27718. // display in scenarios where there are no results returned from the
  27719. // API. In addition promoting CREATE to a first class suggestion affords
  27720. // the a11y benefits afforded by `URLInput` to all suggestions (eg:
  27721. // keyboard handling, ARIA roles...etc).
  27722. //
  27723. // Note also that the value of the `title` and `url` properties must correspond
  27724. // to the text value of the `<input>`. This is because `title` is used
  27725. // when creating the suggestion. Similarly `url` is used when using keyboard to select
  27726. // the suggestion (the <form> `onSubmit` handler falls-back to `url`).
  27727. return isURLLike(val) || !withCreateSuggestion ? results : results.concat({
  27728. // the `id` prop is intentionally ommitted here because it
  27729. // is never exposed as part of the component's public API.
  27730. // see: https://github.com/WordPress/gutenberg/pull/19775#discussion_r378931316.
  27731. title: val,
  27732. // must match the existing `<input>`s text value
  27733. url: val,
  27734. // must match the existing `<input>`s text value
  27735. type: CREATE_TYPE
  27736. });
  27737. };
  27738. function useSearchHandler(suggestionsQuery, allowDirectEntry, withCreateSuggestion, withURLSuggestion) {
  27739. const {
  27740. fetchSearchSuggestions
  27741. } = Object(external_wp_data_["useSelect"])(select => {
  27742. const {
  27743. getSettings
  27744. } = select(store);
  27745. return {
  27746. fetchSearchSuggestions: getSettings().__experimentalFetchLinkSuggestions
  27747. };
  27748. }, []);
  27749. const directEntryHandler = allowDirectEntry ? handleDirectEntry : handleNoop;
  27750. return Object(external_wp_element_["useCallback"])((val, {
  27751. isInitialSuggestions
  27752. }) => {
  27753. return isURLLike(val) ? directEntryHandler(val, {
  27754. isInitialSuggestions
  27755. }) : handleEntitySearch(val, { ...suggestionsQuery,
  27756. isInitialSuggestions
  27757. }, fetchSearchSuggestions, directEntryHandler, withCreateSuggestion, withURLSuggestion);
  27758. }, [directEntryHandler, fetchSearchSuggestions, withCreateSuggestion]);
  27759. }
  27760. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/search-input.js
  27761. /**
  27762. * External dependencies
  27763. */
  27764. /**
  27765. * WordPress dependencies
  27766. */
  27767. /**
  27768. * Internal dependencies
  27769. */
  27770. const noopSearchHandler = Promise.resolve([]);
  27771. const LinkControlSearchInput = Object(external_wp_element_["forwardRef"])(({
  27772. value,
  27773. children,
  27774. currentLink = {},
  27775. className = null,
  27776. placeholder = null,
  27777. withCreateSuggestion = false,
  27778. onCreateSuggestion = external_lodash_["noop"],
  27779. onChange = external_lodash_["noop"],
  27780. onSelect = external_lodash_["noop"],
  27781. showSuggestions = true,
  27782. renderSuggestions = props => Object(external_wp_element_["createElement"])(LinkControlSearchResults, props),
  27783. fetchSuggestions = null,
  27784. allowDirectEntry = true,
  27785. showInitialSuggestions = false,
  27786. suggestionsQuery = {},
  27787. withURLSuggestion = true,
  27788. createSuggestionButtonText
  27789. }, ref) => {
  27790. const genericSearchHandler = useSearchHandler(suggestionsQuery, allowDirectEntry, withCreateSuggestion, withURLSuggestion);
  27791. const searchHandler = showSuggestions ? fetchSuggestions || genericSearchHandler : noopSearchHandler;
  27792. const instanceId = Object(external_wp_compose_["useInstanceId"])(LinkControlSearchInput);
  27793. const [focusedSuggestion, setFocusedSuggestion] = Object(external_wp_element_["useState"])();
  27794. /**
  27795. * Handles the user moving between different suggestions. Does not handle
  27796. * choosing an individual item.
  27797. *
  27798. * @param {string} selection the url of the selected suggestion.
  27799. * @param {Object} suggestion the suggestion object.
  27800. */
  27801. const onInputChange = (selection, suggestion) => {
  27802. onChange(selection);
  27803. setFocusedSuggestion(suggestion);
  27804. };
  27805. const onFormSubmit = event => {
  27806. event.preventDefault();
  27807. onSuggestionSelected(focusedSuggestion || {
  27808. url: value
  27809. });
  27810. };
  27811. const handleRenderSuggestions = props => renderSuggestions({ ...props,
  27812. instanceId,
  27813. withCreateSuggestion,
  27814. currentInputValue: value,
  27815. createSuggestionButtonText,
  27816. suggestionsQuery,
  27817. handleSuggestionClick: suggestion => {
  27818. if (props.handleSuggestionClick) {
  27819. props.handleSuggestionClick(suggestion);
  27820. }
  27821. onSuggestionSelected(suggestion);
  27822. }
  27823. });
  27824. const onSuggestionSelected = async selectedSuggestion => {
  27825. let suggestion = selectedSuggestion;
  27826. if (CREATE_TYPE === selectedSuggestion.type) {
  27827. // Create a new page and call onSelect with the output from the onCreateSuggestion callback
  27828. try {
  27829. var _suggestion;
  27830. suggestion = await onCreateSuggestion(selectedSuggestion.title);
  27831. if ((_suggestion = suggestion) !== null && _suggestion !== void 0 && _suggestion.url) {
  27832. onSelect(suggestion);
  27833. }
  27834. } catch (e) {}
  27835. return;
  27836. }
  27837. if (allowDirectEntry || suggestion && Object.keys(suggestion).length >= 1) {
  27838. onSelect( // Some direct entries don't have types or IDs, and we still need to clear the previous ones.
  27839. { ...Object(external_lodash_["omit"])(currentLink, 'id', 'url'),
  27840. ...suggestion
  27841. }, suggestion);
  27842. }
  27843. };
  27844. return Object(external_wp_element_["createElement"])("form", {
  27845. onSubmit: onFormSubmit
  27846. }, Object(external_wp_element_["createElement"])(url_input, {
  27847. className: className,
  27848. value: value,
  27849. onChange: onInputChange,
  27850. placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : Object(external_wp_i18n_["__"])('Search or type url'),
  27851. __experimentalRenderSuggestions: showSuggestions ? handleRenderSuggestions : null,
  27852. __experimentalFetchLinkSuggestions: searchHandler,
  27853. __experimentalHandleURLSuggestions: true,
  27854. __experimentalShowInitialSuggestions: showInitialSuggestions,
  27855. ref: ref
  27856. }), children);
  27857. });
  27858. /* harmony default export */ var search_input = (LinkControlSearchInput);
  27859. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/viewer-slot.js
  27860. /**
  27861. * WordPress dependencies
  27862. */
  27863. const {
  27864. Slot: ViewerSlot,
  27865. Fill: ViewerFill
  27866. } = Object(external_wp_components_["createSlotFill"])('BlockEditorLinkControlViewer');
  27867. /* harmony default export */ var viewer_slot = (ViewerSlot);
  27868. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/link-preview.js
  27869. /**
  27870. * External dependencies
  27871. */
  27872. /**
  27873. * WordPress dependencies
  27874. */
  27875. /**
  27876. * Internal dependencies
  27877. */
  27878. function LinkPreview({
  27879. value,
  27880. onEditClick
  27881. }) {
  27882. const displayURL = value && Object(external_wp_url_["filterURLForDisplay"])(Object(external_wp_url_["safeDecodeURI"])(value.url), 16) || '';
  27883. return Object(external_wp_element_["createElement"])("div", {
  27884. "aria-label": Object(external_wp_i18n_["__"])('Currently selected'),
  27885. "aria-selected": "true",
  27886. className: classnames_default()('block-editor-link-control__search-item', {
  27887. 'is-current': true
  27888. })
  27889. }, Object(external_wp_element_["createElement"])("span", {
  27890. className: "block-editor-link-control__search-item-header"
  27891. }, Object(external_wp_element_["createElement"])(external_wp_components_["ExternalLink"], {
  27892. className: "block-editor-link-control__search-item-title",
  27893. href: value.url
  27894. }, value && value.title || displayURL), value && value.title && Object(external_wp_element_["createElement"])("span", {
  27895. className: "block-editor-link-control__search-item-info"
  27896. }, displayURL)), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  27897. isSecondary: true,
  27898. onClick: () => onEditClick(),
  27899. className: "block-editor-link-control__search-item-action"
  27900. }, Object(external_wp_i18n_["__"])('Edit')), Object(external_wp_element_["createElement"])(ViewerSlot, {
  27901. fillProps: value
  27902. }));
  27903. }
  27904. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/use-create-page.js
  27905. /**
  27906. * WordPress dependencies
  27907. */
  27908. function useCreatePage(handleCreatePage) {
  27909. const cancelableCreateSuggestion = Object(external_wp_element_["useRef"])();
  27910. const [isCreatingPage, setIsCreatingPage] = Object(external_wp_element_["useState"])(false);
  27911. const [errorMessage, setErrorMessage] = Object(external_wp_element_["useState"])(null);
  27912. const createPage = async function (suggestionTitle) {
  27913. setIsCreatingPage(true);
  27914. setErrorMessage(null);
  27915. try {
  27916. // Make cancellable in order that we can avoid setting State
  27917. // if the component unmounts during the call to `createSuggestion`
  27918. cancelableCreateSuggestion.current = makeCancelable( // Using Promise.resolve to allow createSuggestion to return a
  27919. // non-Promise based value.
  27920. Promise.resolve(handleCreatePage(suggestionTitle)));
  27921. return await cancelableCreateSuggestion.current.promise;
  27922. } catch (error) {
  27923. if (error && error.isCanceled) {
  27924. return; // bail if canceled to avoid setting state
  27925. }
  27926. setErrorMessage(error.message || Object(external_wp_i18n_["__"])('An unknown error occurred during creation. Please try again.'));
  27927. throw error;
  27928. } finally {
  27929. setIsCreatingPage(false);
  27930. }
  27931. };
  27932. /**
  27933. * Handles cancelling any pending Promises that have been made cancelable.
  27934. */
  27935. Object(external_wp_element_["useEffect"])(() => {
  27936. return () => {
  27937. // componentDidUnmount
  27938. if (cancelableCreateSuggestion.current) {
  27939. cancelableCreateSuggestion.current.cancel();
  27940. }
  27941. };
  27942. }, []);
  27943. return {
  27944. createPage,
  27945. isCreatingPage,
  27946. errorMessage
  27947. };
  27948. }
  27949. /**
  27950. * Creates a wrapper around a promise which allows it to be programmatically
  27951. * cancelled.
  27952. * See: https://reactjs.org/blog/2015/12/16/ismounted-antipattern.html
  27953. *
  27954. * @param {Promise} promise the Promise to make cancelable
  27955. */
  27956. const makeCancelable = promise => {
  27957. let hasCanceled_ = false;
  27958. const wrappedPromise = new Promise((resolve, reject) => {
  27959. promise.then(val => hasCanceled_ ? reject({
  27960. isCanceled: true
  27961. }) : resolve(val), error => hasCanceled_ ? reject({
  27962. isCanceled: true
  27963. }) : reject(error));
  27964. });
  27965. return {
  27966. promise: wrappedPromise,
  27967. cancel() {
  27968. hasCanceled_ = true;
  27969. }
  27970. };
  27971. };
  27972. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/index.js
  27973. /**
  27974. * External dependencies
  27975. */
  27976. /**
  27977. * WordPress dependencies
  27978. */
  27979. /**
  27980. * Internal dependencies
  27981. */
  27982. /**
  27983. * Default properties associated with a link control value.
  27984. *
  27985. * @typedef WPLinkControlDefaultValue
  27986. *
  27987. * @property {string} url Link URL.
  27988. * @property {string=} title Link title.
  27989. * @property {boolean=} opensInNewTab Whether link should open in a new browser
  27990. * tab. This value is only assigned if not
  27991. * providing a custom `settings` prop.
  27992. */
  27993. /* eslint-disable jsdoc/valid-types */
  27994. /**
  27995. * Custom settings values associated with a link.
  27996. *
  27997. * @typedef {{[setting:string]:any}} WPLinkControlSettingsValue
  27998. */
  27999. /* eslint-enable */
  28000. /**
  28001. * Custom settings values associated with a link.
  28002. *
  28003. * @typedef WPLinkControlSetting
  28004. *
  28005. * @property {string} id Identifier to use as property for setting value.
  28006. * @property {string} title Human-readable label to show in user interface.
  28007. */
  28008. /**
  28009. * Properties associated with a link control value, composed as a union of the
  28010. * default properties and any custom settings values.
  28011. *
  28012. * @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue
  28013. */
  28014. /** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */
  28015. /**
  28016. * Properties associated with a search suggestion used within the LinkControl.
  28017. *
  28018. * @typedef WPLinkControlSuggestion
  28019. *
  28020. * @property {string} id Identifier to use to uniquely identify the suggestion.
  28021. * @property {string} type Identifies the type of the suggestion (eg: `post`,
  28022. * `page`, `url`...etc)
  28023. * @property {string} title Human-readable label to show in user interface.
  28024. * @property {string} url A URL for the suggestion.
  28025. */
  28026. /** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */
  28027. /**
  28028. * @typedef WPLinkControlProps
  28029. *
  28030. * @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to
  28031. * render a `ToggleControl` for that setting.
  28032. * @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the
  28033. * internal editing state of the component to respective
  28034. * show or not show the URL input field.
  28035. * @property {WPLinkControlValue=} value Current link value.
  28036. * @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if
  28037. * the user selects a new link or updates settings.
  28038. * @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.
  28039. * @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.
  28040. * @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.
  28041. * @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.
  28042. * @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.
  28043. * @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.
  28044. * @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.
  28045. */
  28046. /**
  28047. * Renders a link control. A link control is a controlled input which maintains
  28048. * a value associated with a link (HTML anchor element) and relevant settings
  28049. * for how that link is expected to behave.
  28050. *
  28051. * @param {WPLinkControlProps} props Component props.
  28052. */
  28053. function LinkControl({
  28054. searchInputPlaceholder,
  28055. value,
  28056. settings,
  28057. onChange = external_lodash_["noop"],
  28058. noDirectEntry = false,
  28059. showSuggestions = true,
  28060. showInitialSuggestions,
  28061. forceIsEditingLink,
  28062. createSuggestion,
  28063. withCreateSuggestion,
  28064. inputValue: propInputValue = '',
  28065. suggestionsQuery = {},
  28066. noURLSuggestion = false,
  28067. createSuggestionButtonText
  28068. }) {
  28069. if (withCreateSuggestion === undefined && createSuggestion) {
  28070. withCreateSuggestion = true;
  28071. }
  28072. const isMounting = Object(external_wp_element_["useRef"])(true);
  28073. const wrapperNode = Object(external_wp_element_["useRef"])();
  28074. const [internalInputValue, setInternalInputValue] = Object(external_wp_element_["useState"])(value && value.url || '');
  28075. const currentInputValue = propInputValue || internalInputValue;
  28076. const [isEditingLink, setIsEditingLink] = Object(external_wp_element_["useState"])(forceIsEditingLink !== undefined ? forceIsEditingLink : !value || !value.url);
  28077. const isEndingEditWithFocus = Object(external_wp_element_["useRef"])(false);
  28078. Object(external_wp_element_["useEffect"])(() => {
  28079. if (forceIsEditingLink !== undefined && forceIsEditingLink !== isEditingLink) {
  28080. setIsEditingLink(forceIsEditingLink);
  28081. }
  28082. }, [forceIsEditingLink]);
  28083. Object(external_wp_element_["useEffect"])(() => {
  28084. if (isMounting.current) {
  28085. isMounting.current = false;
  28086. return;
  28087. } // When `isEditingLink` changes, a focus loss could occur
  28088. // since the link input may be removed from the DOM. To avoid this,
  28089. // reinstate focus to a suitable target if focus has in-fact been lost.
  28090. // Note that the check is necessary because while typically unsetting
  28091. // edit mode would render the read-only mode's link element, it isn't
  28092. // guaranteed. The link input may continue to be shown if the next value
  28093. // is still unassigned after calling `onChange`.
  28094. const hadFocusLoss = !wrapperNode.current.contains(wrapperNode.current.ownerDocument.activeElement);
  28095. if (hadFocusLoss) {
  28096. // Prefer to focus a natural focusable descendent of the wrapper,
  28097. // but settle for the wrapper if there are no other options.
  28098. const nextFocusTarget = external_wp_dom_["focus"].focusable.find(wrapperNode.current)[0] || wrapperNode.current;
  28099. nextFocusTarget.focus();
  28100. }
  28101. isEndingEditWithFocus.current = false;
  28102. }, [isEditingLink]);
  28103. /**
  28104. * Cancels editing state and marks that focus may need to be restored after
  28105. * the next render, if focus was within the wrapper when editing finished.
  28106. */
  28107. function stopEditing() {
  28108. var _wrapperNode$current;
  28109. isEndingEditWithFocus.current = !!((_wrapperNode$current = wrapperNode.current) !== null && _wrapperNode$current !== void 0 && _wrapperNode$current.contains(wrapperNode.current.ownerDocument.activeElement));
  28110. setIsEditingLink(false);
  28111. }
  28112. const {
  28113. createPage,
  28114. isCreatingPage,
  28115. errorMessage
  28116. } = useCreatePage(createSuggestion);
  28117. const handleSelectSuggestion = updatedValue => {
  28118. onChange(updatedValue);
  28119. stopEditing();
  28120. };
  28121. return Object(external_wp_element_["createElement"])("div", {
  28122. tabIndex: -1,
  28123. ref: wrapperNode,
  28124. className: "block-editor-link-control"
  28125. }, isCreatingPage && Object(external_wp_element_["createElement"])("div", {
  28126. className: "block-editor-link-control__loading"
  28127. }, Object(external_wp_element_["createElement"])(external_wp_components_["Spinner"], null), " ", Object(external_wp_i18n_["__"])('Creating'), "\u2026"), (isEditingLink || !value) && !isCreatingPage && Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])("div", {
  28128. className: "block-editor-link-control__search-input-wrapper"
  28129. }, Object(external_wp_element_["createElement"])(search_input, {
  28130. currentLink: value,
  28131. className: "block-editor-link-control__search-input",
  28132. placeholder: searchInputPlaceholder,
  28133. value: currentInputValue,
  28134. withCreateSuggestion: withCreateSuggestion,
  28135. onCreateSuggestion: createPage,
  28136. onChange: setInternalInputValue,
  28137. onSelect: handleSelectSuggestion,
  28138. showInitialSuggestions: showInitialSuggestions,
  28139. allowDirectEntry: !noDirectEntry,
  28140. showSuggestions: showSuggestions,
  28141. suggestionsQuery: suggestionsQuery,
  28142. withURLSuggestion: !noURLSuggestion,
  28143. createSuggestionButtonText: createSuggestionButtonText
  28144. }, Object(external_wp_element_["createElement"])("div", {
  28145. className: "block-editor-link-control__search-actions"
  28146. }, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  28147. type: "submit",
  28148. label: Object(external_wp_i18n_["__"])('Submit'),
  28149. icon: keyboard_return["a" /* default */],
  28150. className: "block-editor-link-control__search-submit"
  28151. })))), errorMessage && Object(external_wp_element_["createElement"])(external_wp_components_["Notice"], {
  28152. className: "block-editor-link-control__search-error",
  28153. status: "error",
  28154. isDismissible: false
  28155. }, errorMessage)), value && !isEditingLink && !isCreatingPage && Object(external_wp_element_["createElement"])(LinkPreview, {
  28156. value: value,
  28157. onEditClick: () => setIsEditingLink(true)
  28158. }), Object(external_wp_element_["createElement"])(settings_drawer, {
  28159. value: value,
  28160. settings: settings,
  28161. onChange: onChange
  28162. }));
  28163. }
  28164. LinkControl.ViewerFill = ViewerFill;
  28165. /* harmony default export */ var link_control = (LinkControl);
  28166. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/media.js
  28167. var library_media = __webpack_require__("rH4q");
  28168. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/upload.js
  28169. var upload = __webpack_require__("NTP4");
  28170. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-upload/index.js
  28171. /**
  28172. * WordPress dependencies
  28173. */
  28174. /**
  28175. * This is a placeholder for the media upload component necessary to make it possible to provide
  28176. * an integration with the core blocks that handle media files. By default it renders nothing but
  28177. * it provides a way to have it overridden with the `editor.MediaUpload` filter.
  28178. *
  28179. * @return {WPComponent} The component to be rendered.
  28180. */
  28181. const MediaUpload = () => null;
  28182. /**
  28183. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-upload/README.md
  28184. */
  28185. /* harmony default export */ var media_upload = (Object(external_wp_components_["withFilters"])('editor.MediaUpload')(MediaUpload));
  28186. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-upload/check.js
  28187. /**
  28188. * WordPress dependencies
  28189. */
  28190. /**
  28191. * Internal dependencies
  28192. */
  28193. function MediaUploadCheck({
  28194. fallback = null,
  28195. children
  28196. }) {
  28197. const hasUploadPermissions = Object(external_wp_data_["useSelect"])(select => {
  28198. const {
  28199. getSettings
  28200. } = select(store);
  28201. return !!getSettings().mediaUpload;
  28202. }, []);
  28203. return hasUploadPermissions ? children : fallback;
  28204. }
  28205. /**
  28206. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-upload/README.md
  28207. */
  28208. /* harmony default export */ var check = (MediaUploadCheck);
  28209. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-replace-flow/index.js
  28210. /**
  28211. * External dependencies
  28212. */
  28213. /**
  28214. * WordPress dependencies
  28215. */
  28216. /**
  28217. * Internal dependencies
  28218. */
  28219. const MediaReplaceFlow = ({
  28220. mediaURL,
  28221. mediaId,
  28222. allowedTypes,
  28223. accept,
  28224. onSelect,
  28225. onSelectURL,
  28226. onFilesUpload = external_lodash_["noop"],
  28227. name = Object(external_wp_i18n_["__"])('Replace'),
  28228. createNotice,
  28229. removeNotice
  28230. }) => {
  28231. const [mediaURLValue, setMediaURLValue] = Object(external_wp_element_["useState"])(mediaURL);
  28232. const mediaUpload = Object(external_wp_data_["useSelect"])(select => {
  28233. return select(store).getSettings().mediaUpload;
  28234. }, []);
  28235. const editMediaButtonRef = Object(external_wp_element_["createRef"])();
  28236. const errorNoticeID = Object(external_lodash_["uniqueId"])('block-editor/media-replace-flow/error-notice/');
  28237. const onError = message => {
  28238. const errorElement = document.createElement('div');
  28239. errorElement.innerHTML = Object(external_wp_element_["renderToString"])(message); // The default error contains some HTML that,
  28240. // for example, makes the filename bold.
  28241. // The notice, by default, accepts strings only and so
  28242. // we need to remove the html from the error.
  28243. const renderMsg = errorElement.textContent || errorElement.innerText || ''; // We need to set a timeout for showing the notice
  28244. // so that VoiceOver and possibly other screen readers
  28245. // can announce the error afer the toolbar button
  28246. // regains focus once the upload dialog closes.
  28247. // Otherwise VO simply skips over the notice and announces
  28248. // the focused element and the open menu.
  28249. setTimeout(() => {
  28250. createNotice('error', renderMsg, {
  28251. speak: true,
  28252. id: errorNoticeID,
  28253. isDismissible: true
  28254. });
  28255. }, 1000);
  28256. };
  28257. const selectMedia = media => {
  28258. onSelect(media);
  28259. setMediaURLValue(media.url);
  28260. Object(external_wp_a11y_["speak"])(Object(external_wp_i18n_["__"])('The media file has been replaced'));
  28261. removeNotice(errorNoticeID);
  28262. };
  28263. const selectURL = newURL => {
  28264. onSelectURL(newURL);
  28265. };
  28266. const uploadFiles = event => {
  28267. const files = event.target.files;
  28268. onFilesUpload(files);
  28269. const setMedia = ([media]) => {
  28270. selectMedia(media);
  28271. };
  28272. mediaUpload({
  28273. allowedTypes,
  28274. filesList: files,
  28275. onFileChange: setMedia,
  28276. onError
  28277. });
  28278. };
  28279. const openOnArrowDown = event => {
  28280. if (event.keyCode === external_wp_keycodes_["DOWN"]) {
  28281. event.preventDefault();
  28282. event.stopPropagation();
  28283. event.target.click();
  28284. }
  28285. };
  28286. const POPOVER_PROPS = {
  28287. isAlternate: true
  28288. };
  28289. return Object(external_wp_element_["createElement"])(external_wp_components_["Dropdown"], {
  28290. popoverProps: POPOVER_PROPS,
  28291. contentClassName: "block-editor-media-replace-flow__options",
  28292. renderToggle: ({
  28293. isOpen,
  28294. onToggle
  28295. }) => Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarButton"], {
  28296. ref: editMediaButtonRef,
  28297. "aria-expanded": isOpen,
  28298. "aria-haspopup": "true",
  28299. onClick: onToggle,
  28300. onKeyDown: openOnArrowDown
  28301. }, name),
  28302. renderContent: ({
  28303. onClose
  28304. }) => Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["NavigableMenu"], {
  28305. className: "block-editor-media-replace-flow__media-upload-menu"
  28306. }, Object(external_wp_element_["createElement"])(media_upload, {
  28307. value: mediaId,
  28308. onSelect: media => selectMedia(media),
  28309. allowedTypes: allowedTypes,
  28310. render: ({
  28311. open
  28312. }) => Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  28313. icon: library_media["a" /* default */],
  28314. onClick: open
  28315. }, Object(external_wp_i18n_["__"])('Open Media Library'))
  28316. }), Object(external_wp_element_["createElement"])(check, null, Object(external_wp_element_["createElement"])(external_wp_components_["FormFileUpload"], {
  28317. onChange: event => {
  28318. uploadFiles(event, onClose);
  28319. },
  28320. accept: accept,
  28321. render: ({
  28322. openFileDialog
  28323. }) => {
  28324. return Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  28325. icon: upload["a" /* default */],
  28326. onClick: () => {
  28327. openFileDialog();
  28328. }
  28329. }, Object(external_wp_i18n_["__"])('Upload'));
  28330. }
  28331. }))), onSelectURL && // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
  28332. Object(external_wp_element_["createElement"])("form", {
  28333. className: "block-editor-media-flow__url-input",
  28334. onKeyDown: event => {
  28335. if (![external_wp_keycodes_["TAB"], external_wp_keycodes_["ESCAPE"]].includes(event.keyCode)) {
  28336. event.stopPropagation();
  28337. }
  28338. },
  28339. onKeyPress: event => {
  28340. if (![external_wp_keycodes_["TAB"], external_wp_keycodes_["ESCAPE"]].includes(event.keyCode)) {
  28341. event.stopPropagation();
  28342. }
  28343. }
  28344. }, Object(external_wp_element_["createElement"])("span", {
  28345. className: "block-editor-media-replace-flow__image-url-label"
  28346. }, Object(external_wp_i18n_["__"])('Current media URL:')), Object(external_wp_element_["createElement"])(link_control, {
  28347. value: {
  28348. url: mediaURLValue
  28349. },
  28350. settings: [],
  28351. showSuggestions: false,
  28352. onChange: ({
  28353. url
  28354. }) => {
  28355. setMediaURLValue(url);
  28356. selectURL(url);
  28357. editMediaButtonRef.current.focus();
  28358. }
  28359. })))
  28360. });
  28361. };
  28362. /* harmony default export */ var media_replace_flow = (Object(external_wp_compose_["compose"])([Object(external_wp_data_["withDispatch"])(dispatch => {
  28363. const {
  28364. createNotice,
  28365. removeNotice
  28366. } = dispatch(external_wp_notices_["store"]);
  28367. return {
  28368. createNotice,
  28369. removeNotice
  28370. };
  28371. }), Object(external_wp_components_["withFilters"])('editor.MediaReplaceFlow')])(MediaReplaceFlow));
  28372. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/edit.js + 1 modules
  28373. var library_edit = __webpack_require__("B9Az");
  28374. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/link-viewer-url.js
  28375. /**
  28376. * External dependencies
  28377. */
  28378. /**
  28379. * WordPress dependencies
  28380. */
  28381. function LinkViewerURL({
  28382. url,
  28383. urlLabel,
  28384. className
  28385. }) {
  28386. const linkClassName = classnames_default()(className, 'block-editor-url-popover__link-viewer-url');
  28387. if (!url) {
  28388. return Object(external_wp_element_["createElement"])("span", {
  28389. className: linkClassName
  28390. });
  28391. }
  28392. return Object(external_wp_element_["createElement"])(external_wp_components_["ExternalLink"], {
  28393. className: linkClassName,
  28394. href: url
  28395. }, urlLabel || Object(external_wp_url_["filterURLForDisplay"])(Object(external_wp_url_["safeDecodeURI"])(url)));
  28396. }
  28397. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/link-viewer.js
  28398. /**
  28399. * External dependencies
  28400. */
  28401. /**
  28402. * WordPress dependencies
  28403. */
  28404. /**
  28405. * Internal dependencies
  28406. */
  28407. function LinkViewer({
  28408. className,
  28409. linkClassName,
  28410. onEditLinkClick,
  28411. url,
  28412. urlLabel,
  28413. ...props
  28414. }) {
  28415. return Object(external_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({
  28416. className: classnames_default()('block-editor-url-popover__link-viewer', className)
  28417. }, props), Object(external_wp_element_["createElement"])(LinkViewerURL, {
  28418. url: url,
  28419. urlLabel: urlLabel,
  28420. className: linkClassName
  28421. }), onEditLinkClick && Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  28422. icon: library_edit["a" /* default */],
  28423. label: Object(external_wp_i18n_["__"])('Edit'),
  28424. onClick: onEditLinkClick
  28425. }));
  28426. }
  28427. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/link-editor.js
  28428. /**
  28429. * External dependencies
  28430. */
  28431. /**
  28432. * WordPress dependencies
  28433. */
  28434. /**
  28435. * Internal dependencies
  28436. */
  28437. function LinkEditor({
  28438. autocompleteRef,
  28439. className,
  28440. onChangeInputValue,
  28441. value,
  28442. ...props
  28443. }) {
  28444. return Object(external_wp_element_["createElement"])("form", Object(esm_extends["a" /* default */])({
  28445. className: classnames_default()('block-editor-url-popover__link-editor', className)
  28446. }, props), Object(external_wp_element_["createElement"])(url_input, {
  28447. value: value,
  28448. onChange: onChangeInputValue,
  28449. autocompleteRef: autocompleteRef
  28450. }), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  28451. icon: keyboard_return["a" /* default */],
  28452. label: Object(external_wp_i18n_["__"])('Apply'),
  28453. type: "submit"
  28454. }));
  28455. }
  28456. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/index.js
  28457. /**
  28458. * WordPress dependencies
  28459. */
  28460. /**
  28461. * Internal dependencies
  28462. */
  28463. function URLPopover({
  28464. additionalControls,
  28465. children,
  28466. renderSettings,
  28467. position = 'bottom center',
  28468. focusOnMount = 'firstElement',
  28469. ...popoverProps
  28470. }) {
  28471. const [isSettingsExpanded, setIsSettingsExpanded] = Object(external_wp_element_["useState"])(false);
  28472. const showSettings = !!renderSettings && isSettingsExpanded;
  28473. const toggleSettingsVisibility = () => {
  28474. setIsSettingsExpanded(!isSettingsExpanded);
  28475. };
  28476. return Object(external_wp_element_["createElement"])(external_wp_components_["Popover"], Object(esm_extends["a" /* default */])({
  28477. className: "block-editor-url-popover",
  28478. focusOnMount: focusOnMount,
  28479. position: position
  28480. }, popoverProps), Object(external_wp_element_["createElement"])("div", {
  28481. className: "block-editor-url-popover__input-container"
  28482. }, Object(external_wp_element_["createElement"])("div", {
  28483. className: "block-editor-url-popover__row"
  28484. }, children, !!renderSettings && Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  28485. className: "block-editor-url-popover__settings-toggle",
  28486. icon: chevron_down["a" /* default */],
  28487. label: Object(external_wp_i18n_["__"])('Link settings'),
  28488. onClick: toggleSettingsVisibility,
  28489. "aria-expanded": isSettingsExpanded
  28490. })), showSettings && Object(external_wp_element_["createElement"])("div", {
  28491. className: "block-editor-url-popover__row block-editor-url-popover__settings"
  28492. }, renderSettings())), additionalControls && !showSettings && Object(external_wp_element_["createElement"])("div", {
  28493. className: "block-editor-url-popover__additional-controls"
  28494. }, additionalControls));
  28495. }
  28496. URLPopover.LinkEditor = LinkEditor;
  28497. URLPopover.LinkViewer = LinkViewer;
  28498. /**
  28499. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-popover/README.md
  28500. */
  28501. /* harmony default export */ var url_popover = (URLPopover);
  28502. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-placeholder/index.js
  28503. /**
  28504. * External dependencies
  28505. */
  28506. /**
  28507. * WordPress dependencies
  28508. */
  28509. /**
  28510. * Internal dependencies
  28511. */
  28512. const InsertFromURLPopover = ({
  28513. src,
  28514. onChange,
  28515. onSubmit,
  28516. onClose
  28517. }) => Object(external_wp_element_["createElement"])(url_popover, {
  28518. onClose: onClose
  28519. }, Object(external_wp_element_["createElement"])("form", {
  28520. className: "block-editor-media-placeholder__url-input-form",
  28521. onSubmit: onSubmit
  28522. }, Object(external_wp_element_["createElement"])("input", {
  28523. className: "block-editor-media-placeholder__url-input-field",
  28524. type: "url",
  28525. "aria-label": Object(external_wp_i18n_["__"])('URL'),
  28526. placeholder: Object(external_wp_i18n_["__"])('Paste or type URL'),
  28527. onChange: onChange,
  28528. value: src
  28529. }), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  28530. className: "block-editor-media-placeholder__url-input-submit-button",
  28531. icon: keyboard_return["a" /* default */],
  28532. label: Object(external_wp_i18n_["__"])('Apply'),
  28533. type: "submit"
  28534. })));
  28535. function MediaPlaceholder({
  28536. value = {},
  28537. allowedTypes,
  28538. className,
  28539. icon,
  28540. labels = {},
  28541. mediaPreview,
  28542. notices,
  28543. isAppender,
  28544. accept,
  28545. addToGallery,
  28546. multiple = false,
  28547. dropZoneUIOnly,
  28548. disableDropZone,
  28549. disableMediaButtons,
  28550. onError,
  28551. onSelect,
  28552. onCancel,
  28553. onSelectURL,
  28554. onDoubleClick,
  28555. onFilesPreUpload = external_lodash_["noop"],
  28556. onHTMLDrop = external_lodash_["noop"],
  28557. children
  28558. }) {
  28559. const mediaUpload = Object(external_wp_data_["useSelect"])(select => {
  28560. const {
  28561. getSettings
  28562. } = select(store);
  28563. return getSettings().mediaUpload;
  28564. }, []);
  28565. const [src, setSrc] = Object(external_wp_element_["useState"])('');
  28566. const [isURLInputVisible, setIsURLInputVisible] = Object(external_wp_element_["useState"])(false);
  28567. Object(external_wp_element_["useEffect"])(() => {
  28568. var _value$src;
  28569. setSrc((_value$src = value === null || value === void 0 ? void 0 : value.src) !== null && _value$src !== void 0 ? _value$src : '');
  28570. }, [value === null || value === void 0 ? void 0 : value.src]);
  28571. const onlyAllowsImages = () => {
  28572. if (!allowedTypes || allowedTypes.length === 0) {
  28573. return false;
  28574. }
  28575. return allowedTypes.every(allowedType => allowedType === 'image' || allowedType.startsWith('image/'));
  28576. };
  28577. const onChangeSrc = event => {
  28578. setSrc(event.target.value);
  28579. };
  28580. const openURLInput = () => {
  28581. setIsURLInputVisible(true);
  28582. };
  28583. const closeURLInput = () => {
  28584. setIsURLInputVisible(false);
  28585. };
  28586. const onSubmitSrc = event => {
  28587. event.preventDefault();
  28588. if (src && onSelectURL) {
  28589. onSelectURL(src);
  28590. closeURLInput();
  28591. }
  28592. };
  28593. const onFilesUpload = files => {
  28594. onFilesPreUpload(files);
  28595. let setMedia;
  28596. if (multiple) {
  28597. if (addToGallery) {
  28598. // Since the setMedia function runs multiple times per upload group
  28599. // and is passed newMedia containing every item in its group each time, we must
  28600. // filter out whatever this upload group had previously returned to the
  28601. // gallery before adding and returning the image array with replacement newMedia
  28602. // values.
  28603. // Define an array to store urls from newMedia between subsequent function calls.
  28604. let lastMediaPassed = [];
  28605. setMedia = newMedia => {
  28606. // Remove any images this upload group is responsible for (lastMediaPassed).
  28607. // Their replacements are contained in newMedia.
  28608. const filteredMedia = (value !== null && value !== void 0 ? value : []).filter(item => {
  28609. // If Item has id, only remove it if lastMediaPassed has an item with that id.
  28610. if (item.id) {
  28611. return !lastMediaPassed.some( // Be sure to convert to number for comparison.
  28612. ({
  28613. id
  28614. }) => Number(id) === Number(item.id));
  28615. } // Compare transient images via .includes since gallery may append extra info onto the url.
  28616. return !lastMediaPassed.some(({
  28617. urlSlug
  28618. }) => item.url.includes(urlSlug));
  28619. }); // Return the filtered media array along with newMedia.
  28620. onSelect(filteredMedia.concat(newMedia)); // Reset lastMediaPassed and set it with ids and urls from newMedia.
  28621. lastMediaPassed = newMedia.map(media => {
  28622. // Add everything up to '.fileType' to compare via .includes.
  28623. const cutOffIndex = media.url.lastIndexOf('.');
  28624. const urlSlug = media.url.slice(0, cutOffIndex);
  28625. return {
  28626. id: media.id,
  28627. urlSlug
  28628. };
  28629. });
  28630. };
  28631. } else {
  28632. setMedia = onSelect;
  28633. }
  28634. } else {
  28635. setMedia = ([media]) => onSelect(media);
  28636. }
  28637. mediaUpload({
  28638. allowedTypes,
  28639. filesList: files,
  28640. onFileChange: setMedia,
  28641. onError
  28642. });
  28643. };
  28644. const onUpload = event => {
  28645. onFilesUpload(event.target.files);
  28646. };
  28647. const renderPlaceholder = (content, onClick) => {
  28648. let {
  28649. instructions,
  28650. title
  28651. } = labels;
  28652. if (!mediaUpload && !onSelectURL) {
  28653. instructions = Object(external_wp_i18n_["__"])('To edit this block, you need permission to upload media.');
  28654. }
  28655. if (instructions === undefined || title === undefined) {
  28656. const typesAllowed = allowedTypes !== null && allowedTypes !== void 0 ? allowedTypes : [];
  28657. const [firstAllowedType] = typesAllowed;
  28658. const isOneType = 1 === typesAllowed.length;
  28659. const isAudio = isOneType && 'audio' === firstAllowedType;
  28660. const isImage = isOneType && 'image' === firstAllowedType;
  28661. const isVideo = isOneType && 'video' === firstAllowedType;
  28662. if (instructions === undefined && mediaUpload) {
  28663. instructions = Object(external_wp_i18n_["__"])('Upload a media file or pick one from your media library.');
  28664. if (isAudio) {
  28665. instructions = Object(external_wp_i18n_["__"])('Upload an audio file, pick one from your media library, or add one with a URL.');
  28666. } else if (isImage) {
  28667. instructions = Object(external_wp_i18n_["__"])('Upload an image file, pick one from your media library, or add one with a URL.');
  28668. } else if (isVideo) {
  28669. instructions = Object(external_wp_i18n_["__"])('Upload a video file, pick one from your media library, or add one with a URL.');
  28670. }
  28671. }
  28672. if (title === undefined) {
  28673. title = Object(external_wp_i18n_["__"])('Media');
  28674. if (isAudio) {
  28675. title = Object(external_wp_i18n_["__"])('Audio');
  28676. } else if (isImage) {
  28677. title = Object(external_wp_i18n_["__"])('Image');
  28678. } else if (isVideo) {
  28679. title = Object(external_wp_i18n_["__"])('Video');
  28680. }
  28681. }
  28682. }
  28683. const placeholderClassName = classnames_default()('block-editor-media-placeholder', className, {
  28684. 'is-appender': isAppender
  28685. });
  28686. return Object(external_wp_element_["createElement"])(external_wp_components_["Placeholder"], {
  28687. icon: icon,
  28688. label: title,
  28689. instructions: instructions,
  28690. className: placeholderClassName,
  28691. notices: notices,
  28692. onClick: onClick,
  28693. onDoubleClick: onDoubleClick,
  28694. preview: mediaPreview
  28695. }, content, children);
  28696. };
  28697. const renderDropZone = () => {
  28698. if (disableDropZone) {
  28699. return null;
  28700. }
  28701. return Object(external_wp_element_["createElement"])(external_wp_components_["DropZone"], {
  28702. onFilesDrop: onFilesUpload,
  28703. onHTMLDrop: onHTMLDrop
  28704. });
  28705. };
  28706. const renderCancelLink = () => {
  28707. return onCancel && Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  28708. className: "block-editor-media-placeholder__cancel-button",
  28709. title: Object(external_wp_i18n_["__"])('Cancel'),
  28710. isLink: true,
  28711. onClick: onCancel
  28712. }, Object(external_wp_i18n_["__"])('Cancel'));
  28713. };
  28714. const renderUrlSelectionUI = () => {
  28715. return onSelectURL && Object(external_wp_element_["createElement"])("div", {
  28716. className: "block-editor-media-placeholder__url-input-container"
  28717. }, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  28718. className: "block-editor-media-placeholder__button",
  28719. onClick: openURLInput,
  28720. isPressed: isURLInputVisible,
  28721. isTertiary: true
  28722. }, Object(external_wp_i18n_["__"])('Insert from URL')), isURLInputVisible && Object(external_wp_element_["createElement"])(InsertFromURLPopover, {
  28723. src: src,
  28724. onChange: onChangeSrc,
  28725. onSubmit: onSubmitSrc,
  28726. onClose: closeURLInput
  28727. }));
  28728. };
  28729. const renderMediaUploadChecked = () => {
  28730. const mediaLibraryButton = Object(external_wp_element_["createElement"])(media_upload, {
  28731. addToGallery: addToGallery,
  28732. gallery: multiple && onlyAllowsImages(),
  28733. multiple: multiple,
  28734. onSelect: onSelect,
  28735. allowedTypes: allowedTypes,
  28736. value: Array.isArray(value) ? value.map(({
  28737. id
  28738. }) => id) : value.id,
  28739. render: ({
  28740. open
  28741. }) => {
  28742. return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  28743. isTertiary: true,
  28744. onClick: event => {
  28745. event.stopPropagation();
  28746. open();
  28747. }
  28748. }, Object(external_wp_i18n_["__"])('Media Library'));
  28749. }
  28750. });
  28751. if (mediaUpload && isAppender) {
  28752. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, renderDropZone(), Object(external_wp_element_["createElement"])(external_wp_components_["FormFileUpload"], {
  28753. onChange: onUpload,
  28754. accept: accept,
  28755. multiple: multiple,
  28756. render: ({
  28757. openFileDialog
  28758. }) => {
  28759. const content = Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  28760. isPrimary: true,
  28761. className: classnames_default()('block-editor-media-placeholder__button', 'block-editor-media-placeholder__upload-button')
  28762. }, Object(external_wp_i18n_["__"])('Upload')), mediaLibraryButton, renderUrlSelectionUI(), renderCancelLink());
  28763. return renderPlaceholder(content, openFileDialog);
  28764. }
  28765. }));
  28766. }
  28767. if (mediaUpload) {
  28768. const content = Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, renderDropZone(), Object(external_wp_element_["createElement"])(external_wp_components_["FormFileUpload"], {
  28769. isPrimary: true,
  28770. className: classnames_default()('block-editor-media-placeholder__button', 'block-editor-media-placeholder__upload-button'),
  28771. onChange: onUpload,
  28772. accept: accept,
  28773. multiple: multiple
  28774. }, Object(external_wp_i18n_["__"])('Upload')), mediaLibraryButton, renderUrlSelectionUI(), renderCancelLink());
  28775. return renderPlaceholder(content);
  28776. }
  28777. return renderPlaceholder(mediaLibraryButton);
  28778. };
  28779. if (dropZoneUIOnly || disableMediaButtons) {
  28780. if (dropZoneUIOnly) {
  28781. external_wp_deprecated_default()('wp.blockEditor.MediaPlaceholder dropZoneUIOnly prop', {
  28782. since: '5.4',
  28783. alternative: 'disableMediaButtons'
  28784. });
  28785. }
  28786. return Object(external_wp_element_["createElement"])(check, null, renderDropZone());
  28787. }
  28788. return Object(external_wp_element_["createElement"])(check, {
  28789. fallback: renderPlaceholder(renderUrlSelectionUI())
  28790. }, renderMediaUploadChecked());
  28791. }
  28792. /**
  28793. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-placeholder/README.md
  28794. */
  28795. /* harmony default export */ var media_placeholder = (Object(external_wp_components_["withFilters"])('editor.MediaPlaceholder')(MediaPlaceholder));
  28796. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/editable-text/index.js
  28797. /**
  28798. * WordPress dependencies
  28799. */
  28800. /**
  28801. * Internal dependencies
  28802. */
  28803. const EditableText = Object(external_wp_element_["forwardRef"])((props, ref) => {
  28804. return Object(external_wp_element_["createElement"])(rich_text, Object(esm_extends["a" /* default */])({
  28805. ref: ref
  28806. }, props, {
  28807. __unstableDisableFormats: true,
  28808. preserveWhiteSpace: true
  28809. }));
  28810. });
  28811. EditableText.Content = ({
  28812. value = '',
  28813. tagName: Tag = 'div',
  28814. ...props
  28815. }) => {
  28816. return Object(external_wp_element_["createElement"])(Tag, props, value);
  28817. };
  28818. /**
  28819. * Renders an editable text input in which text formatting is not allowed.
  28820. */
  28821. /* harmony default export */ var editable_text = (EditableText);
  28822. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/plain-text/index.js
  28823. /**
  28824. * External dependencies
  28825. */
  28826. /**
  28827. * WordPress dependencies
  28828. */
  28829. /**
  28830. * Internal dependencies
  28831. */
  28832. /**
  28833. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/plain-text/README.md
  28834. */
  28835. const PlainText = Object(external_wp_element_["forwardRef"])(({
  28836. __experimentalVersion,
  28837. ...props
  28838. }, ref) => {
  28839. if (__experimentalVersion === 2) {
  28840. return Object(external_wp_element_["createElement"])(editable_text, Object(esm_extends["a" /* default */])({
  28841. ref: ref
  28842. }, props));
  28843. }
  28844. const {
  28845. className,
  28846. onChange,
  28847. ...remainingProps
  28848. } = props;
  28849. return Object(external_wp_element_["createElement"])(lib_default.a, Object(esm_extends["a" /* default */])({
  28850. ref: ref,
  28851. className: classnames_default()('block-editor-plain-text', className),
  28852. onChange: event => onChange(event.target.value)
  28853. }, remainingProps));
  28854. });
  28855. /* harmony default export */ var plain_text = (PlainText);
  28856. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/responsive-block-control/label.js
  28857. /**
  28858. * WordPress dependencies
  28859. */
  28860. function ResponsiveBlockControlLabel({
  28861. property,
  28862. viewport,
  28863. desc
  28864. }) {
  28865. const instanceId = Object(external_wp_compose_["useInstanceId"])(ResponsiveBlockControlLabel);
  28866. const accessibleLabel = desc || Object(external_wp_i18n_["sprintf"])(
  28867. /* translators: 1: property name. 2: viewport name. */
  28868. Object(external_wp_i18n_["_x"])('Controls the %1$s property for %2$s viewports.', 'Text labelling a interface as controlling a given layout property (eg: margin) for a given screen size.'), property, viewport.label);
  28869. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])("span", {
  28870. "aria-describedby": `rbc-desc-${instanceId}`
  28871. }, viewport.label), Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], {
  28872. as: "span",
  28873. id: `rbc-desc-${instanceId}`
  28874. }, accessibleLabel));
  28875. }
  28876. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/responsive-block-control/index.js
  28877. /**
  28878. * External dependencies
  28879. */
  28880. /**
  28881. * WordPress dependencies
  28882. */
  28883. /**
  28884. * Internal dependencies
  28885. */
  28886. function ResponsiveBlockControl(props) {
  28887. const {
  28888. title,
  28889. property,
  28890. toggleLabel,
  28891. onIsResponsiveChange,
  28892. renderDefaultControl,
  28893. renderResponsiveControls,
  28894. isResponsive = false,
  28895. defaultLabel = {
  28896. id: 'all',
  28897. /* translators: 'Label. Used to signify a layout property (eg: margin, padding) will apply uniformly to all screensizes.' */
  28898. label: Object(external_wp_i18n_["__"])('All')
  28899. },
  28900. viewports = [{
  28901. id: 'small',
  28902. label: Object(external_wp_i18n_["__"])('Small screens')
  28903. }, {
  28904. id: 'medium',
  28905. label: Object(external_wp_i18n_["__"])('Medium screens')
  28906. }, {
  28907. id: 'large',
  28908. label: Object(external_wp_i18n_["__"])('Large screens')
  28909. }]
  28910. } = props;
  28911. if (!title || !property || !renderDefaultControl) {
  28912. return null;
  28913. }
  28914. const toggleControlLabel = toggleLabel || Object(external_wp_i18n_["sprintf"])(
  28915. /* translators: 'Toggle control label. Should the property be the same across all screen sizes or unique per screen size.'. %s property value for the control (eg: margin, padding...etc) */
  28916. Object(external_wp_i18n_["__"])('Use the same %s on all screensizes.'), property);
  28917. /* translators: 'Help text for the responsive mode toggle control.' */
  28918. const toggleHelpText = Object(external_wp_i18n_["__"])('Toggle between using the same value for all screen sizes or using a unique value per screen size.');
  28919. const defaultControl = renderDefaultControl(Object(external_wp_element_["createElement"])(ResponsiveBlockControlLabel, {
  28920. property: property,
  28921. viewport: defaultLabel
  28922. }), defaultLabel);
  28923. const defaultResponsiveControls = () => {
  28924. return viewports.map(viewport => Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], {
  28925. key: viewport.id
  28926. }, renderDefaultControl(Object(external_wp_element_["createElement"])(ResponsiveBlockControlLabel, {
  28927. property: property,
  28928. viewport: viewport
  28929. }), viewport)));
  28930. };
  28931. return Object(external_wp_element_["createElement"])("fieldset", {
  28932. className: "block-editor-responsive-block-control"
  28933. }, Object(external_wp_element_["createElement"])("legend", {
  28934. className: "block-editor-responsive-block-control__title"
  28935. }, title), Object(external_wp_element_["createElement"])("div", {
  28936. className: "block-editor-responsive-block-control__inner"
  28937. }, Object(external_wp_element_["createElement"])(external_wp_components_["ToggleControl"], {
  28938. className: "block-editor-responsive-block-control__toggle",
  28939. label: toggleControlLabel,
  28940. checked: !isResponsive,
  28941. onChange: onIsResponsiveChange,
  28942. help: toggleHelpText
  28943. }), Object(external_wp_element_["createElement"])("div", {
  28944. className: classnames_default()('block-editor-responsive-block-control__group', {
  28945. 'is-responsive': isResponsive
  28946. })
  28947. }, !isResponsive && defaultControl, isResponsive && (renderResponsiveControls ? renderResponsiveControls(viewports) : defaultResponsiveControls()))));
  28948. }
  28949. /* harmony default export */ var responsive_block_control = (ResponsiveBlockControl);
  28950. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/shortcut.js
  28951. /**
  28952. * WordPress dependencies
  28953. */
  28954. function RichTextShortcut({
  28955. character,
  28956. type,
  28957. onUse
  28958. }) {
  28959. const callback = () => {
  28960. onUse();
  28961. return false;
  28962. };
  28963. Object(external_wp_compose_["useKeyboardShortcut"])(external_wp_keycodes_["rawShortcut"][type](character), callback, {
  28964. bindGlobal: true
  28965. });
  28966. return null;
  28967. }
  28968. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/toolbar-button.js
  28969. /**
  28970. * WordPress dependencies
  28971. */
  28972. function RichTextToolbarButton({
  28973. name,
  28974. shortcutType,
  28975. shortcutCharacter,
  28976. ...props
  28977. }) {
  28978. let shortcut;
  28979. let fillName = 'RichText.ToolbarControls';
  28980. if (name) {
  28981. fillName += `.${name}`;
  28982. }
  28983. if (shortcutType && shortcutCharacter) {
  28984. shortcut = external_wp_keycodes_["displayShortcut"][shortcutType](shortcutCharacter);
  28985. }
  28986. return Object(external_wp_element_["createElement"])(external_wp_components_["Fill"], {
  28987. name: fillName
  28988. }, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarButton"], Object(esm_extends["a" /* default */])({}, props, {
  28989. shortcut: shortcut
  28990. })));
  28991. }
  28992. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/input-event.js
  28993. /**
  28994. * WordPress dependencies
  28995. */
  28996. class input_event_unstableRichTextInputEvent extends external_wp_element_["Component"] {
  28997. constructor() {
  28998. super(...arguments);
  28999. this.onInput = this.onInput.bind(this);
  29000. }
  29001. onInput(event) {
  29002. if (event.inputType === this.props.inputType) {
  29003. this.props.onInput();
  29004. }
  29005. }
  29006. componentDidMount() {
  29007. document.addEventListener('input', this.onInput, true);
  29008. }
  29009. componentWillUnmount() {
  29010. document.removeEventListener('input', this.onInput, true);
  29011. }
  29012. render() {
  29013. return null;
  29014. }
  29015. }
  29016. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/tool-selector/index.js
  29017. /**
  29018. * WordPress dependencies
  29019. */
  29020. /**
  29021. * Internal dependencies
  29022. */
  29023. const selectIcon = Object(external_wp_element_["createElement"])(external_wp_components_["SVG"], {
  29024. xmlns: "http://www.w3.org/2000/svg",
  29025. width: "24",
  29026. height: "24",
  29027. viewBox: "0 0 24 24"
  29028. }, Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
  29029. d: "M9.4 20.5L5.2 3.8l14.6 9-2 .3c-.2 0-.4.1-.7.1-.9.2-1.6.3-2.2.5-.8.3-1.4.5-1.8.8-.4.3-.8.8-1.3 1.5-.4.5-.8 1.2-1.2 2l-.3.6-.9 1.9zM7.6 7.1l2.4 9.3c.2-.4.5-.8.7-1.1.6-.8 1.1-1.4 1.6-1.8.5-.4 1.3-.8 2.2-1.1l1.2-.3-8.1-5z"
  29030. }));
  29031. function ToolSelector(props, ref) {
  29032. const isNavigationTool = Object(external_wp_data_["useSelect"])(select => select(store).isNavigationMode(), []);
  29033. const {
  29034. setNavigationMode
  29035. } = Object(external_wp_data_["useDispatch"])(store);
  29036. const onSwitchMode = mode => {
  29037. setNavigationMode(mode === 'edit' ? false : true);
  29038. };
  29039. return Object(external_wp_element_["createElement"])(external_wp_components_["Dropdown"], {
  29040. renderToggle: ({
  29041. isOpen,
  29042. onToggle
  29043. }) => Object(external_wp_element_["createElement"])(external_wp_components_["Button"], Object(esm_extends["a" /* default */])({}, props, {
  29044. ref: ref,
  29045. icon: isNavigationTool ? selectIcon : library_edit["a" /* default */],
  29046. "aria-expanded": isOpen,
  29047. "aria-haspopup": "true",
  29048. onClick: onToggle
  29049. /* translators: button label text should, if possible, be under 16 characters. */
  29050. ,
  29051. label: Object(external_wp_i18n_["__"])('Tools')
  29052. })),
  29053. position: "bottom right",
  29054. renderContent: () => Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["NavigableMenu"], {
  29055. role: "menu",
  29056. "aria-label": Object(external_wp_i18n_["__"])('Tools')
  29057. }, Object(external_wp_element_["createElement"])(external_wp_components_["MenuItemsChoice"], {
  29058. value: isNavigationTool ? 'select' : 'edit',
  29059. onSelect: onSwitchMode,
  29060. choices: [{
  29061. value: 'edit',
  29062. label: Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(build_module_icon["a" /* default */], {
  29063. icon: library_edit["a" /* default */]
  29064. }), Object(external_wp_i18n_["__"])('Edit'))
  29065. }, {
  29066. value: 'select',
  29067. label: Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, selectIcon, Object(external_wp_i18n_["__"])('Select'))
  29068. }]
  29069. })), Object(external_wp_element_["createElement"])("div", {
  29070. className: "block-editor-tool-selector__help"
  29071. }, Object(external_wp_i18n_["__"])('Tools provide different interactions for selecting, navigating, and editing blocks. Toggle between select and edit by pressing Escape and Enter.')))
  29072. });
  29073. }
  29074. /* harmony default export */ var tool_selector = (Object(external_wp_element_["forwardRef"])(ToolSelector));
  29075. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/unit-control/index.js
  29076. /**
  29077. * WordPress dependencies
  29078. */
  29079. /**
  29080. * Internal dependencies
  29081. */
  29082. function UnitControl({
  29083. units: unitsProp,
  29084. ...props
  29085. }) {
  29086. const units = Object(external_wp_components_["__experimentalUseCustomUnits"])({
  29087. availableUnits: useSetting('spacing.units') || ['%', 'px', 'em', 'rem', 'vw'],
  29088. units: unitsProp
  29089. });
  29090. return Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalUnitControl"], Object(esm_extends["a" /* default */])({
  29091. units: units
  29092. }, props));
  29093. }
  29094. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/link.js
  29095. var library_link = __webpack_require__("Bpkj");
  29096. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/arrow-left.js
  29097. var arrow_left = __webpack_require__("cjQ8");
  29098. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-input/button.js
  29099. /**
  29100. * WordPress dependencies
  29101. */
  29102. /**
  29103. * Internal dependencies
  29104. */
  29105. class button_URLInputButton extends external_wp_element_["Component"] {
  29106. constructor() {
  29107. super(...arguments);
  29108. this.toggle = this.toggle.bind(this);
  29109. this.submitLink = this.submitLink.bind(this);
  29110. this.state = {
  29111. expanded: false
  29112. };
  29113. }
  29114. toggle() {
  29115. this.setState({
  29116. expanded: !this.state.expanded
  29117. });
  29118. }
  29119. submitLink(event) {
  29120. event.preventDefault();
  29121. this.toggle();
  29122. }
  29123. render() {
  29124. const {
  29125. url,
  29126. onChange
  29127. } = this.props;
  29128. const {
  29129. expanded
  29130. } = this.state;
  29131. const buttonLabel = url ? Object(external_wp_i18n_["__"])('Edit link') : Object(external_wp_i18n_["__"])('Insert link');
  29132. return Object(external_wp_element_["createElement"])("div", {
  29133. className: "block-editor-url-input__button"
  29134. }, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  29135. icon: library_link["a" /* default */],
  29136. label: buttonLabel,
  29137. onClick: this.toggle,
  29138. className: "components-toolbar__control",
  29139. isPressed: !!url
  29140. }), expanded && Object(external_wp_element_["createElement"])("form", {
  29141. className: "block-editor-url-input__button-modal",
  29142. onSubmit: this.submitLink
  29143. }, Object(external_wp_element_["createElement"])("div", {
  29144. className: "block-editor-url-input__button-modal-line"
  29145. }, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  29146. className: "block-editor-url-input__back",
  29147. icon: arrow_left["a" /* default */],
  29148. label: Object(external_wp_i18n_["__"])('Close'),
  29149. onClick: this.toggle
  29150. }), Object(external_wp_element_["createElement"])(url_input, {
  29151. value: url || '',
  29152. onChange: onChange
  29153. }), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  29154. icon: keyboard_return["a" /* default */],
  29155. label: Object(external_wp_i18n_["__"])('Submit'),
  29156. type: "submit"
  29157. }))));
  29158. }
  29159. }
  29160. /**
  29161. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md
  29162. */
  29163. /* harmony default export */ var url_input_button = (button_URLInputButton);
  29164. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/close.js
  29165. var library_close = __webpack_require__("w95h");
  29166. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/image-url-input-ui.js
  29167. /**
  29168. * External dependencies
  29169. */
  29170. /**
  29171. * WordPress dependencies
  29172. */
  29173. /**
  29174. * Internal dependencies
  29175. */
  29176. const LINK_DESTINATION_NONE = 'none';
  29177. const LINK_DESTINATION_CUSTOM = 'custom';
  29178. const LINK_DESTINATION_MEDIA = 'media';
  29179. const LINK_DESTINATION_ATTACHMENT = 'attachment';
  29180. const NEW_TAB_REL = ['noreferrer', 'noopener'];
  29181. const image_url_input_ui_icon = Object(external_wp_element_["createElement"])(external_wp_components_["SVG"], {
  29182. viewBox: "0 0 24 24",
  29183. xmlns: "http://www.w3.org/2000/svg"
  29184. }, Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
  29185. d: "M0,0h24v24H0V0z",
  29186. fill: "none"
  29187. }), Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
  29188. d: "m19 5v14h-14v-14h14m0-2h-14c-1.1 0-2 0.9-2 2v14c0 1.1 0.9 2 2 2h14c1.1 0 2-0.9 2-2v-14c0-1.1-0.9-2-2-2z"
  29189. }), Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
  29190. d: "m14.14 11.86l-3 3.87-2.14-2.59-3 3.86h12l-3.86-5.14z"
  29191. }));
  29192. const ImageURLInputUI = ({
  29193. linkDestination,
  29194. onChangeUrl,
  29195. url,
  29196. mediaType = 'image',
  29197. mediaUrl,
  29198. mediaLink,
  29199. linkTarget,
  29200. linkClass,
  29201. rel
  29202. }) => {
  29203. const [isOpen, setIsOpen] = Object(external_wp_element_["useState"])(false);
  29204. const openLinkUI = Object(external_wp_element_["useCallback"])(() => {
  29205. setIsOpen(true);
  29206. });
  29207. const [isEditingLink, setIsEditingLink] = Object(external_wp_element_["useState"])(false);
  29208. const [urlInput, setUrlInput] = Object(external_wp_element_["useState"])(null);
  29209. const autocompleteRef = Object(external_wp_element_["useRef"])(null);
  29210. const startEditLink = Object(external_wp_element_["useCallback"])(() => {
  29211. if (linkDestination === LINK_DESTINATION_MEDIA || linkDestination === LINK_DESTINATION_ATTACHMENT) {
  29212. setUrlInput('');
  29213. }
  29214. setIsEditingLink(true);
  29215. });
  29216. const stopEditLink = Object(external_wp_element_["useCallback"])(() => {
  29217. setIsEditingLink(false);
  29218. });
  29219. const closeLinkUI = Object(external_wp_element_["useCallback"])(() => {
  29220. setUrlInput(null);
  29221. stopEditLink();
  29222. setIsOpen(false);
  29223. });
  29224. const removeNewTabRel = currentRel => {
  29225. let newRel = currentRel;
  29226. if (currentRel !== undefined && !Object(external_lodash_["isEmpty"])(newRel)) {
  29227. if (!Object(external_lodash_["isEmpty"])(newRel)) {
  29228. Object(external_lodash_["each"])(NEW_TAB_REL, relVal => {
  29229. const regExp = new RegExp('\\b' + relVal + '\\b', 'gi');
  29230. newRel = newRel.replace(regExp, '');
  29231. }); // Only trim if NEW_TAB_REL values was replaced.
  29232. if (newRel !== currentRel) {
  29233. newRel = newRel.trim();
  29234. }
  29235. if (Object(external_lodash_["isEmpty"])(newRel)) {
  29236. newRel = undefined;
  29237. }
  29238. }
  29239. }
  29240. return newRel;
  29241. };
  29242. const getUpdatedLinkTargetSettings = value => {
  29243. const newLinkTarget = value ? '_blank' : undefined;
  29244. let updatedRel;
  29245. if (!newLinkTarget && !rel) {
  29246. updatedRel = undefined;
  29247. } else {
  29248. updatedRel = removeNewTabRel(rel);
  29249. }
  29250. return {
  29251. linkTarget: newLinkTarget,
  29252. rel: updatedRel
  29253. };
  29254. };
  29255. const onFocusOutside = Object(external_wp_element_["useCallback"])(() => {
  29256. return event => {
  29257. // The autocomplete suggestions list renders in a separate popover (in a portal),
  29258. // so onFocusOutside fails to detect that a click on a suggestion occurred in the
  29259. // LinkContainer. Detect clicks on autocomplete suggestions using a ref here, and
  29260. // return to avoid the popover being closed.
  29261. const autocompleteElement = autocompleteRef.current;
  29262. if (autocompleteElement && autocompleteElement.contains(event.target)) {
  29263. return;
  29264. }
  29265. setIsOpen(false);
  29266. setUrlInput(null);
  29267. stopEditLink();
  29268. };
  29269. });
  29270. const onSubmitLinkChange = Object(external_wp_element_["useCallback"])(() => {
  29271. return event => {
  29272. if (urlInput) {
  29273. var _getLinkDestinations$;
  29274. // It is possible the entered URL actually matches a named link destination.
  29275. // This check will ensure our link destination is correct.
  29276. const selectedDestination = ((_getLinkDestinations$ = getLinkDestinations().find(destination => destination.url === urlInput)) === null || _getLinkDestinations$ === void 0 ? void 0 : _getLinkDestinations$.linkDestination) || LINK_DESTINATION_CUSTOM;
  29277. onChangeUrl({
  29278. href: urlInput,
  29279. linkDestination: selectedDestination
  29280. });
  29281. }
  29282. stopEditLink();
  29283. setUrlInput(null);
  29284. event.preventDefault();
  29285. };
  29286. });
  29287. const onLinkRemove = Object(external_wp_element_["useCallback"])(() => {
  29288. onChangeUrl({
  29289. linkDestination: LINK_DESTINATION_NONE,
  29290. href: ''
  29291. });
  29292. });
  29293. const getLinkDestinations = () => {
  29294. const linkDestinations = [{
  29295. linkDestination: LINK_DESTINATION_MEDIA,
  29296. title: Object(external_wp_i18n_["__"])('Media File'),
  29297. url: mediaType === 'image' ? mediaUrl : undefined,
  29298. icon: image_url_input_ui_icon
  29299. }];
  29300. if (mediaType === 'image' && mediaLink) {
  29301. linkDestinations.push({
  29302. linkDestination: LINK_DESTINATION_ATTACHMENT,
  29303. title: Object(external_wp_i18n_["__"])('Attachment Page'),
  29304. url: mediaType === 'image' ? mediaLink : undefined,
  29305. icon: Object(external_wp_element_["createElement"])(external_wp_components_["SVG"], {
  29306. viewBox: "0 0 24 24",
  29307. xmlns: "http://www.w3.org/2000/svg"
  29308. }, Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
  29309. d: "M0 0h24v24H0V0z",
  29310. fill: "none"
  29311. }), Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
  29312. d: "M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zM6 20V4h7v5h5v11H6z"
  29313. }))
  29314. });
  29315. }
  29316. return linkDestinations;
  29317. };
  29318. const onSetHref = value => {
  29319. const linkDestinations = getLinkDestinations();
  29320. let linkDestinationInput;
  29321. if (!value) {
  29322. linkDestinationInput = LINK_DESTINATION_NONE;
  29323. } else {
  29324. linkDestinationInput = (Object(external_lodash_["find"])(linkDestinations, destination => {
  29325. return destination.url === value;
  29326. }) || {
  29327. linkDestination: LINK_DESTINATION_CUSTOM
  29328. }).linkDestination;
  29329. }
  29330. onChangeUrl({
  29331. linkDestination: linkDestinationInput,
  29332. href: value
  29333. });
  29334. };
  29335. const onSetNewTab = value => {
  29336. const updatedLinkTarget = getUpdatedLinkTargetSettings(value);
  29337. onChangeUrl(updatedLinkTarget);
  29338. };
  29339. const onSetLinkRel = value => {
  29340. onChangeUrl({
  29341. rel: value
  29342. });
  29343. };
  29344. const onSetLinkClass = value => {
  29345. onChangeUrl({
  29346. linkClass: value
  29347. });
  29348. };
  29349. const advancedOptions = Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["ToggleControl"], {
  29350. label: Object(external_wp_i18n_["__"])('Open in new tab'),
  29351. onChange: onSetNewTab,
  29352. checked: linkTarget === '_blank'
  29353. }), Object(external_wp_element_["createElement"])(external_wp_components_["TextControl"], {
  29354. label: Object(external_wp_i18n_["__"])('Link Rel'),
  29355. value: removeNewTabRel(rel) || '',
  29356. onChange: onSetLinkRel
  29357. }), Object(external_wp_element_["createElement"])(external_wp_components_["TextControl"], {
  29358. label: Object(external_wp_i18n_["__"])('Link CSS Class'),
  29359. value: linkClass || '',
  29360. onChange: onSetLinkClass
  29361. }));
  29362. const linkEditorValue = urlInput !== null ? urlInput : url;
  29363. const urlLabel = (Object(external_lodash_["find"])(getLinkDestinations(), ['linkDestination', linkDestination]) || {}).title;
  29364. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarButton"], {
  29365. icon: library_link["a" /* default */],
  29366. className: "components-toolbar__control",
  29367. label: url ? Object(external_wp_i18n_["__"])('Edit link') : Object(external_wp_i18n_["__"])('Insert link'),
  29368. "aria-expanded": isOpen,
  29369. onClick: openLinkUI
  29370. }), isOpen && Object(external_wp_element_["createElement"])(url_popover, {
  29371. onFocusOutside: onFocusOutside(),
  29372. onClose: closeLinkUI,
  29373. renderSettings: () => advancedOptions,
  29374. additionalControls: !linkEditorValue && Object(external_wp_element_["createElement"])(external_wp_components_["NavigableMenu"], null, Object(external_lodash_["map"])(getLinkDestinations(), link => Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  29375. key: link.linkDestination,
  29376. icon: link.icon,
  29377. onClick: () => {
  29378. setUrlInput(null);
  29379. onSetHref(link.url);
  29380. stopEditLink();
  29381. }
  29382. }, link.title)))
  29383. }, (!url || isEditingLink) && Object(external_wp_element_["createElement"])(url_popover.LinkEditor, {
  29384. className: "block-editor-format-toolbar__link-container-content",
  29385. value: linkEditorValue,
  29386. onChangeInputValue: setUrlInput,
  29387. onSubmit: onSubmitLinkChange(),
  29388. autocompleteRef: autocompleteRef
  29389. }), url && !isEditingLink && Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(url_popover.LinkViewer, {
  29390. className: "block-editor-format-toolbar__link-container-content",
  29391. url: url,
  29392. onEditLinkClick: startEditLink,
  29393. urlLabel: urlLabel
  29394. }), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  29395. icon: library_close["a" /* default */],
  29396. label: Object(external_wp_i18n_["__"])('Remove link'),
  29397. onClick: onLinkRemove
  29398. }))));
  29399. };
  29400. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/check.js
  29401. var library_check = __webpack_require__("RMJe");
  29402. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/preview-options/index.js
  29403. /**
  29404. * External dependencies
  29405. */
  29406. /**
  29407. * WordPress dependencies
  29408. */
  29409. function PreviewOptions({
  29410. children,
  29411. className,
  29412. isEnabled = true,
  29413. deviceType,
  29414. setDeviceType
  29415. }) {
  29416. const isMobile = Object(external_wp_compose_["useViewportMatch"])('small', '<');
  29417. if (isMobile) return null;
  29418. const popoverProps = {
  29419. className: classnames_default()(className, 'block-editor-post-preview__dropdown-content'),
  29420. position: 'bottom left'
  29421. };
  29422. const toggleProps = {
  29423. isTertiary: true,
  29424. className: 'block-editor-post-preview__button-toggle',
  29425. disabled: !isEnabled,
  29426. /* translators: button label text should, if possible, be under 16 characters. */
  29427. children: Object(external_wp_i18n_["__"])('Preview')
  29428. };
  29429. return Object(external_wp_element_["createElement"])(external_wp_components_["DropdownMenu"], {
  29430. className: "block-editor-post-preview__dropdown",
  29431. popoverProps: popoverProps,
  29432. toggleProps: toggleProps,
  29433. icon: null
  29434. }, () => Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], null, Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  29435. className: "block-editor-post-preview__button-resize",
  29436. onClick: () => setDeviceType('Desktop'),
  29437. icon: deviceType === 'Desktop' && library_check["a" /* default */]
  29438. }, Object(external_wp_i18n_["__"])('Desktop')), Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  29439. className: "block-editor-post-preview__button-resize",
  29440. onClick: () => setDeviceType('Tablet'),
  29441. icon: deviceType === 'Tablet' && library_check["a" /* default */]
  29442. }, Object(external_wp_i18n_["__"])('Tablet')), Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  29443. className: "block-editor-post-preview__button-resize",
  29444. onClick: () => setDeviceType('Mobile'),
  29445. icon: deviceType === 'Mobile' && library_check["a" /* default */]
  29446. }, Object(external_wp_i18n_["__"])('Mobile'))), children));
  29447. }
  29448. // EXTERNAL MODULE: ./node_modules/css-mediaquery/index.js
  29449. var css_mediaquery = __webpack_require__("6fKw");
  29450. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-simulated-media-query/index.js
  29451. /**
  29452. * External dependencies
  29453. */
  29454. /**
  29455. * WordPress dependencies
  29456. */
  29457. const ENABLED_MEDIA_QUERY = '(min-width:0px)';
  29458. const DISABLED_MEDIA_QUERY = '(min-width:999999px)';
  29459. const VALID_MEDIA_QUERY_REGEX = /\((min|max)-width:[^\(]*?\)/g;
  29460. function getStyleSheetsThatMatchHostname() {
  29461. var _window$document$styl, _window, _window$document;
  29462. if (typeof window === 'undefined') {
  29463. return [];
  29464. }
  29465. return Object(external_lodash_["filter"])((_window$document$styl = (_window = window) === null || _window === void 0 ? void 0 : (_window$document = _window.document) === null || _window$document === void 0 ? void 0 : _window$document.styleSheets) !== null && _window$document$styl !== void 0 ? _window$document$styl : [], styleSheet => {
  29466. if (!styleSheet.href) {
  29467. return false;
  29468. }
  29469. return Object(external_wp_url_["getProtocol"])(styleSheet.href) === window.location.protocol && Object(external_wp_url_["getAuthority"])(styleSheet.href) === window.location.host;
  29470. });
  29471. }
  29472. function isReplaceableMediaRule(rule) {
  29473. if (!rule.media) {
  29474. return false;
  29475. } // Need to use "media.mediaText" instead of "conditionText" for IE support.
  29476. return !!rule.media.mediaText.match(VALID_MEDIA_QUERY_REGEX);
  29477. }
  29478. function replaceRule(styleSheet, newRuleText, index) {
  29479. styleSheet.deleteRule(index);
  29480. styleSheet.insertRule(newRuleText, index);
  29481. }
  29482. function replaceMediaQueryWithWidthEvaluation(ruleText, widthValue) {
  29483. return ruleText.replace(VALID_MEDIA_QUERY_REGEX, matchedSubstring => {
  29484. if (Object(css_mediaquery["match"])(matchedSubstring, {
  29485. type: 'screen',
  29486. width: widthValue
  29487. })) {
  29488. return ENABLED_MEDIA_QUERY;
  29489. }
  29490. return DISABLED_MEDIA_QUERY;
  29491. });
  29492. }
  29493. /**
  29494. * Function that manipulates media queries from stylesheets to simulate a given
  29495. * viewport width.
  29496. *
  29497. * @param {string} marker CSS selector string defining start and end of
  29498. * manipulable styles.
  29499. * @param {number?} width Viewport width to simulate. If provided null, the
  29500. * stylesheets will not be modified.
  29501. */
  29502. function useSimulatedMediaQuery(marker, width) {
  29503. Object(external_wp_element_["useEffect"])(() => {
  29504. if (!width) {
  29505. return;
  29506. }
  29507. const styleSheets = getStyleSheetsThatMatchHostname();
  29508. const originalStyles = [];
  29509. styleSheets.forEach((styleSheet, styleSheetIndex) => {
  29510. let relevantSection = false;
  29511. for (let ruleIndex = 0; ruleIndex < styleSheet.cssRules.length; ++ruleIndex) {
  29512. const rule = styleSheet.cssRules[ruleIndex];
  29513. if (rule.type !== window.CSSRule.STYLE_RULE && rule.type !== window.CSSRule.MEDIA_RULE) {
  29514. continue;
  29515. }
  29516. if (!relevantSection && !!rule.cssText.match(new RegExp(`#start-${marker}`))) {
  29517. relevantSection = true;
  29518. }
  29519. if (relevantSection && !!rule.cssText.match(new RegExp(`#end-${marker}`))) {
  29520. relevantSection = false;
  29521. }
  29522. if (!relevantSection || !isReplaceableMediaRule(rule)) {
  29523. continue;
  29524. }
  29525. const ruleText = rule.cssText;
  29526. if (!originalStyles[styleSheetIndex]) {
  29527. originalStyles[styleSheetIndex] = [];
  29528. }
  29529. originalStyles[styleSheetIndex][ruleIndex] = ruleText;
  29530. replaceRule(styleSheet, replaceMediaQueryWithWidthEvaluation(ruleText, width), ruleIndex);
  29531. }
  29532. });
  29533. return () => {
  29534. originalStyles.forEach((rulesCollection, styleSheetIndex) => {
  29535. if (!rulesCollection) {
  29536. return;
  29537. }
  29538. for (let ruleIndex = 0; ruleIndex < rulesCollection.length; ++ruleIndex) {
  29539. const originalRuleText = rulesCollection[ruleIndex];
  29540. if (originalRuleText) {
  29541. replaceRule(styleSheets[styleSheetIndex], originalRuleText, ruleIndex);
  29542. }
  29543. }
  29544. });
  29545. };
  29546. }, [width]);
  29547. }
  29548. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-resize-canvas/index.js
  29549. /**
  29550. * WordPress dependencies
  29551. */
  29552. /**
  29553. * Internal dependencies
  29554. */
  29555. /**
  29556. * Function to resize the editor window.
  29557. *
  29558. * @param {string} deviceType Used for determining the size of the container (e.g. Desktop, Tablet, Mobile)
  29559. * @param {boolean} __unstableDisableSimulation Whether to disable media query simulation.
  29560. *
  29561. * @return {Object} Inline styles to be added to resizable container.
  29562. */
  29563. function useResizeCanvas(deviceType, __unstableDisableSimulation) {
  29564. const [actualWidth, updateActualWidth] = Object(external_wp_element_["useState"])(window.innerWidth);
  29565. Object(external_wp_element_["useEffect"])(() => {
  29566. if (deviceType === 'Desktop') {
  29567. return;
  29568. }
  29569. const resizeListener = () => updateActualWidth(window.innerWidth);
  29570. window.addEventListener('resize', resizeListener);
  29571. return () => {
  29572. window.removeEventListener('resize', resizeListener);
  29573. };
  29574. }, [deviceType]);
  29575. const getCanvasWidth = device => {
  29576. let deviceWidth;
  29577. switch (device) {
  29578. case 'Tablet':
  29579. deviceWidth = 780;
  29580. break;
  29581. case 'Mobile':
  29582. deviceWidth = 360;
  29583. break;
  29584. default:
  29585. return null;
  29586. }
  29587. return deviceWidth < actualWidth ? deviceWidth : actualWidth;
  29588. };
  29589. const marginValue = () => window.innerHeight < 800 ? 36 : 72;
  29590. const contentInlineStyles = device => {
  29591. const height = device === 'Mobile' ? '768px' : '1024px';
  29592. switch (device) {
  29593. case 'Tablet':
  29594. case 'Mobile':
  29595. return {
  29596. width: getCanvasWidth(device),
  29597. margin: marginValue() + 'px auto',
  29598. height,
  29599. borderRadius: '2px 2px 2px 2px',
  29600. border: '1px solid #ddd',
  29601. overflowY: 'auto'
  29602. };
  29603. default:
  29604. return null;
  29605. }
  29606. };
  29607. const width = __unstableDisableSimulation ? null : getCanvasWidth(deviceType);
  29608. useSimulatedMediaQuery('resizable-editor-section', width);
  29609. return contentInlineStyles(deviceType);
  29610. }
  29611. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/skip-to-selected-block/index.js
  29612. /**
  29613. * WordPress dependencies
  29614. */
  29615. /**
  29616. * Internal dependencies
  29617. */
  29618. const SkipToSelectedBlock = ({
  29619. selectedBlockClientId
  29620. }) => {
  29621. const ref = useBlockRef(selectedBlockClientId);
  29622. const onClick = () => {
  29623. ref.current.focus();
  29624. };
  29625. return selectedBlockClientId ? Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  29626. isSecondary: true,
  29627. className: "block-editor-skip-to-selected-block",
  29628. onClick: onClick
  29629. }, Object(external_wp_i18n_["__"])('Skip to the selected block')) : null;
  29630. };
  29631. /* harmony default export */ var skip_to_selected_block = (Object(external_wp_data_["withSelect"])(select => {
  29632. return {
  29633. selectedBlockClientId: select(store).getBlockSelectionStart()
  29634. };
  29635. })(SkipToSelectedBlock));
  29636. // EXTERNAL MODULE: external ["wp","wordcount"]
  29637. var external_wp_wordcount_ = __webpack_require__("7fqt");
  29638. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/multi-selection-inspector/index.js
  29639. /**
  29640. * WordPress dependencies
  29641. */
  29642. /**
  29643. * Internal dependencies
  29644. */
  29645. function MultiSelectionInspector({
  29646. blocks
  29647. }) {
  29648. const words = Object(external_wp_wordcount_["count"])(Object(external_wp_blocks_["serialize"])(blocks), 'words');
  29649. return Object(external_wp_element_["createElement"])("div", {
  29650. className: "block-editor-multi-selection-inspector__card"
  29651. }, Object(external_wp_element_["createElement"])(BlockIcon, {
  29652. icon: library_stack,
  29653. showColors: true
  29654. }), Object(external_wp_element_["createElement"])("div", {
  29655. className: "block-editor-multi-selection-inspector__card-content"
  29656. }, Object(external_wp_element_["createElement"])("div", {
  29657. className: "block-editor-multi-selection-inspector__card-title"
  29658. }, Object(external_wp_i18n_["sprintf"])(
  29659. /* translators: %d: number of blocks */
  29660. Object(external_wp_i18n_["_n"])('%d block', '%d blocks', blocks.length), blocks.length)), Object(external_wp_element_["createElement"])("div", {
  29661. className: "block-editor-multi-selection-inspector__card-description"
  29662. }, Object(external_wp_i18n_["sprintf"])(
  29663. /* translators: %d: number of words */
  29664. Object(external_wp_i18n_["_n"])('%d word', '%d words', words), words))));
  29665. }
  29666. /* harmony default export */ var multi_selection_inspector = (Object(external_wp_data_["withSelect"])(select => {
  29667. const {
  29668. getMultiSelectedBlocks
  29669. } = select(store);
  29670. return {
  29671. blocks: getMultiSelectedBlocks()
  29672. };
  29673. })(MultiSelectionInspector));
  29674. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/default-style-picker/index.js
  29675. /**
  29676. * WordPress dependencies
  29677. */
  29678. /**
  29679. * Internal dependencies
  29680. */
  29681. function DefaultStylePicker({
  29682. blockName
  29683. }) {
  29684. const {
  29685. preferredStyle,
  29686. onUpdatePreferredStyleVariations,
  29687. styles
  29688. } = Object(external_wp_data_["useSelect"])(select => {
  29689. var _preferredStyleVariat, _preferredStyleVariat2;
  29690. const settings = select(store).getSettings();
  29691. const preferredStyleVariations = settings.__experimentalPreferredStyleVariations;
  29692. return {
  29693. preferredStyle: preferredStyleVariations === null || preferredStyleVariations === void 0 ? void 0 : (_preferredStyleVariat = preferredStyleVariations.value) === null || _preferredStyleVariat === void 0 ? void 0 : _preferredStyleVariat[blockName],
  29694. onUpdatePreferredStyleVariations: (_preferredStyleVariat2 = preferredStyleVariations === null || preferredStyleVariations === void 0 ? void 0 : preferredStyleVariations.onChange) !== null && _preferredStyleVariat2 !== void 0 ? _preferredStyleVariat2 : null,
  29695. styles: select(external_wp_blocks_["store"]).getBlockStyles(blockName)
  29696. };
  29697. }, [blockName]);
  29698. const selectOptions = Object(external_wp_element_["useMemo"])(() => [{
  29699. label: Object(external_wp_i18n_["__"])('Not set'),
  29700. value: ''
  29701. }, ...styles.map(({
  29702. label,
  29703. name
  29704. }) => ({
  29705. label,
  29706. value: name
  29707. }))], [styles]);
  29708. const selectOnChange = Object(external_wp_element_["useCallback"])(blockStyle => {
  29709. onUpdatePreferredStyleVariations(blockName, blockStyle);
  29710. }, [blockName, onUpdatePreferredStyleVariations]);
  29711. return onUpdatePreferredStyleVariations && Object(external_wp_element_["createElement"])(external_wp_components_["SelectControl"], {
  29712. options: selectOptions,
  29713. value: preferredStyle || '',
  29714. label: Object(external_wp_i18n_["__"])('Default Style'),
  29715. onChange: selectOnChange
  29716. });
  29717. }
  29718. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-inspector/index.js
  29719. /**
  29720. * WordPress dependencies
  29721. */
  29722. /**
  29723. * Internal dependencies
  29724. */
  29725. const BlockInspector = ({
  29726. showNoBlockSelectedMessage = true,
  29727. bubblesVirtually = true
  29728. }) => {
  29729. const {
  29730. count,
  29731. hasBlockStyles,
  29732. selectedBlockName,
  29733. selectedBlockClientId,
  29734. blockType
  29735. } = Object(external_wp_data_["useSelect"])(select => {
  29736. const {
  29737. getSelectedBlockClientId,
  29738. getSelectedBlockCount,
  29739. getBlockName
  29740. } = select(store);
  29741. const {
  29742. getBlockStyles
  29743. } = select(external_wp_blocks_["store"]);
  29744. const _selectedBlockClientId = getSelectedBlockClientId();
  29745. const _selectedBlockName = _selectedBlockClientId && getBlockName(_selectedBlockClientId);
  29746. const _blockType = _selectedBlockName && Object(external_wp_blocks_["getBlockType"])(_selectedBlockName);
  29747. const blockStyles = _selectedBlockName && getBlockStyles(_selectedBlockName);
  29748. return {
  29749. count: getSelectedBlockCount(),
  29750. selectedBlockClientId: _selectedBlockClientId,
  29751. selectedBlockName: _selectedBlockName,
  29752. blockType: _blockType,
  29753. hasBlockStyles: blockStyles && blockStyles.length > 0
  29754. };
  29755. }, []);
  29756. if (count > 1) {
  29757. return Object(external_wp_element_["createElement"])("div", {
  29758. className: "block-editor-block-inspector"
  29759. }, Object(external_wp_element_["createElement"])(multi_selection_inspector, null), Object(external_wp_element_["createElement"])(inspector_controls.Slot, {
  29760. bubblesVirtually: bubblesVirtually
  29761. }));
  29762. }
  29763. const isSelectedBlockUnregistered = selectedBlockName === Object(external_wp_blocks_["getUnregisteredTypeHandlerName"])();
  29764. /*
  29765. * If the selected block is of an unregistered type, avoid showing it as an actual selection
  29766. * because we want the user to focus on the unregistered block warning, not block settings.
  29767. */
  29768. if (!blockType || !selectedBlockClientId || isSelectedBlockUnregistered) {
  29769. if (showNoBlockSelectedMessage) {
  29770. return Object(external_wp_element_["createElement"])("span", {
  29771. className: "block-editor-block-inspector__no-blocks"
  29772. }, Object(external_wp_i18n_["__"])('No block selected.'));
  29773. }
  29774. return null;
  29775. }
  29776. return Object(external_wp_element_["createElement"])(BlockInspectorSingleBlock, {
  29777. clientId: selectedBlockClientId,
  29778. blockName: blockType.name,
  29779. hasBlockStyles: hasBlockStyles,
  29780. bubblesVirtually: bubblesVirtually
  29781. });
  29782. };
  29783. const BlockInspectorSingleBlock = ({
  29784. clientId,
  29785. blockName,
  29786. hasBlockStyles,
  29787. bubblesVirtually
  29788. }) => {
  29789. const blockInformation = useBlockDisplayInformation(clientId);
  29790. return Object(external_wp_element_["createElement"])("div", {
  29791. className: "block-editor-block-inspector"
  29792. }, Object(external_wp_element_["createElement"])(block_card, blockInformation), Object(external_wp_element_["createElement"])(block_variation_transforms, {
  29793. blockClientId: clientId
  29794. }), hasBlockStyles && Object(external_wp_element_["createElement"])("div", null, Object(external_wp_element_["createElement"])(external_wp_components_["PanelBody"], {
  29795. title: Object(external_wp_i18n_["__"])('Styles')
  29796. }, Object(external_wp_element_["createElement"])(block_styles, {
  29797. clientId: clientId
  29798. }), Object(external_wp_blocks_["hasBlockSupport"])(blockName, 'defaultStylePicker', true) && Object(external_wp_element_["createElement"])(DefaultStylePicker, {
  29799. blockName: blockName
  29800. }))), Object(external_wp_element_["createElement"])(inspector_controls.Slot, {
  29801. bubblesVirtually: bubblesVirtually
  29802. }), Object(external_wp_element_["createElement"])("div", null, Object(external_wp_element_["createElement"])(AdvancedControls, {
  29803. slotName: inspector_advanced_controls.slotName,
  29804. bubblesVirtually: bubblesVirtually
  29805. })), Object(external_wp_element_["createElement"])(skip_to_selected_block, {
  29806. key: "back"
  29807. }));
  29808. };
  29809. const AdvancedControls = ({
  29810. slotName,
  29811. bubblesVirtually
  29812. }) => {
  29813. const slot = Object(external_wp_components_["__experimentalUseSlot"])(slotName);
  29814. const hasFills = Boolean(slot.fills && slot.fills.length);
  29815. if (!hasFills) {
  29816. return null;
  29817. }
  29818. return Object(external_wp_element_["createElement"])(external_wp_components_["PanelBody"], {
  29819. className: "block-editor-block-inspector__advanced",
  29820. title: Object(external_wp_i18n_["__"])('Advanced'),
  29821. initialOpen: false
  29822. }, Object(external_wp_element_["createElement"])(inspector_advanced_controls.Slot, {
  29823. bubblesVirtually: bubblesVirtually
  29824. }));
  29825. };
  29826. /* harmony default export */ var block_inspector = (BlockInspector);
  29827. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-tools/index.js
  29828. /**
  29829. * WordPress dependencies
  29830. */
  29831. /**
  29832. * Internal dependencies
  29833. */
  29834. /**
  29835. * Renders block tools (the block toolbar, select/navigation mode toolbar, the
  29836. * insertion point and a slot for the inline rich text toolbar). Must be wrapped
  29837. * around the block content and editor styles wrapper or iframe.
  29838. *
  29839. * @param {Object} $0 Props.
  29840. * @param {Object} $0.children The block content and style container.
  29841. * @param {Object} $0.__unstableContentRef Ref holding the content scroll container.
  29842. */
  29843. function BlockTools({
  29844. children,
  29845. __unstableContentRef
  29846. }) {
  29847. const isLargeViewport = Object(external_wp_compose_["useViewportMatch"])('medium');
  29848. const hasFixedToolbar = Object(external_wp_data_["useSelect"])(select => select(store).getSettings().hasFixedToolbar, []);
  29849. return Object(external_wp_element_["createElement"])(InsertionPoint, {
  29850. __unstableContentRef: __unstableContentRef
  29851. }, (hasFixedToolbar || !isLargeViewport) && Object(external_wp_element_["createElement"])(block_contextual_toolbar, {
  29852. isFixed: true
  29853. }), Object(external_wp_element_["createElement"])(WrappedBlockPopover, {
  29854. __unstableContentRef: __unstableContentRef
  29855. }), Object(external_wp_element_["createElement"])(external_wp_components_["Popover"].Slot, {
  29856. name: "block-toolbar",
  29857. ref: usePopoverScroll(__unstableContentRef)
  29858. }), children);
  29859. }
  29860. // EXTERNAL MODULE: ./node_modules/traverse/index.js
  29861. var traverse = __webpack_require__("eGrx");
  29862. var traverse_default = /*#__PURE__*/__webpack_require__.n(traverse);
  29863. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/parse.js
  29864. /* eslint-disable @wordpress/no-unused-vars-before-return */
  29865. // Adapted from https://github.com/reworkcss/css
  29866. // because we needed to remove source map support.
  29867. // http://www.w3.org/TR/CSS21/grammar.htm
  29868. // https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
  29869. const commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
  29870. /* harmony default export */ var parse = (function (css, options) {
  29871. options = options || {};
  29872. /**
  29873. * Positional.
  29874. */
  29875. let lineno = 1;
  29876. let column = 1;
  29877. /**
  29878. * Update lineno and column based on `str`.
  29879. */
  29880. function updatePosition(str) {
  29881. const lines = str.match(/\n/g);
  29882. if (lines) {
  29883. lineno += lines.length;
  29884. }
  29885. const i = str.lastIndexOf('\n'); // eslint-disable-next-line no-bitwise
  29886. column = ~i ? str.length - i : column + str.length;
  29887. }
  29888. /**
  29889. * Mark position and patch `node.position`.
  29890. */
  29891. function position() {
  29892. const start = {
  29893. line: lineno,
  29894. column
  29895. };
  29896. return function (node) {
  29897. node.position = new Position(start);
  29898. whitespace();
  29899. return node;
  29900. };
  29901. }
  29902. /**
  29903. * Store position information for a node
  29904. */
  29905. function Position(start) {
  29906. this.start = start;
  29907. this.end = {
  29908. line: lineno,
  29909. column
  29910. };
  29911. this.source = options.source;
  29912. }
  29913. /**
  29914. * Non-enumerable source string
  29915. */
  29916. Position.prototype.content = css;
  29917. /**
  29918. * Error `msg`.
  29919. */
  29920. const errorsList = [];
  29921. function error(msg) {
  29922. const err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);
  29923. err.reason = msg;
  29924. err.filename = options.source;
  29925. err.line = lineno;
  29926. err.column = column;
  29927. err.source = css;
  29928. if (options.silent) {
  29929. errorsList.push(err);
  29930. } else {
  29931. throw err;
  29932. }
  29933. }
  29934. /**
  29935. * Parse stylesheet.
  29936. */
  29937. function stylesheet() {
  29938. const rulesList = rules();
  29939. return {
  29940. type: 'stylesheet',
  29941. stylesheet: {
  29942. source: options.source,
  29943. rules: rulesList,
  29944. parsingErrors: errorsList
  29945. }
  29946. };
  29947. }
  29948. /**
  29949. * Opening brace.
  29950. */
  29951. function open() {
  29952. return match(/^{\s*/);
  29953. }
  29954. /**
  29955. * Closing brace.
  29956. */
  29957. function close() {
  29958. return match(/^}/);
  29959. }
  29960. /**
  29961. * Parse ruleset.
  29962. */
  29963. function rules() {
  29964. let node;
  29965. const accumulator = [];
  29966. whitespace();
  29967. comments(accumulator);
  29968. while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {
  29969. if (node !== false) {
  29970. accumulator.push(node);
  29971. comments(accumulator);
  29972. }
  29973. }
  29974. return accumulator;
  29975. }
  29976. /**
  29977. * Match `re` and return captures.
  29978. */
  29979. function match(re) {
  29980. const m = re.exec(css);
  29981. if (!m) {
  29982. return;
  29983. }
  29984. const str = m[0];
  29985. updatePosition(str);
  29986. css = css.slice(str.length);
  29987. return m;
  29988. }
  29989. /**
  29990. * Parse whitespace.
  29991. */
  29992. function whitespace() {
  29993. match(/^\s*/);
  29994. }
  29995. /**
  29996. * Parse comments;
  29997. */
  29998. function comments(accumulator) {
  29999. let c;
  30000. accumulator = accumulator || []; // eslint-disable-next-line no-cond-assign
  30001. while (c = comment()) {
  30002. if (c !== false) {
  30003. accumulator.push(c);
  30004. }
  30005. }
  30006. return accumulator;
  30007. }
  30008. /**
  30009. * Parse comment.
  30010. */
  30011. function comment() {
  30012. const pos = position();
  30013. if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {
  30014. return;
  30015. }
  30016. let i = 2;
  30017. while ('' !== css.charAt(i) && ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {
  30018. ++i;
  30019. }
  30020. i += 2;
  30021. if ('' === css.charAt(i - 1)) {
  30022. return error('End of comment missing');
  30023. }
  30024. const str = css.slice(2, i - 2);
  30025. column += 2;
  30026. updatePosition(str);
  30027. css = css.slice(i);
  30028. column += 2;
  30029. return pos({
  30030. type: 'comment',
  30031. comment: str
  30032. });
  30033. }
  30034. /**
  30035. * Parse selector.
  30036. */
  30037. function selector() {
  30038. const m = match(/^([^{]+)/);
  30039. if (!m) {
  30040. return;
  30041. } // FIXME: Remove all comments from selectors http://ostermiller.org/findcomment.html
  30042. return trim(m[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '').replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function (matched) {
  30043. return matched.replace(/,/g, '\u200C');
  30044. }).split(/\s*(?![^(]*\)),\s*/).map(function (s) {
  30045. return s.replace(/\u200C/g, ',');
  30046. });
  30047. }
  30048. /**
  30049. * Parse declaration.
  30050. */
  30051. function declaration() {
  30052. const pos = position(); // prop
  30053. let prop = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
  30054. if (!prop) {
  30055. return;
  30056. }
  30057. prop = trim(prop[0]); // :
  30058. if (!match(/^:\s*/)) {
  30059. return error("property missing ':'");
  30060. } // val
  30061. const val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
  30062. const ret = pos({
  30063. type: 'declaration',
  30064. property: prop.replace(commentre, ''),
  30065. value: val ? trim(val[0]).replace(commentre, '') : ''
  30066. }); // ;
  30067. match(/^[;\s]*/);
  30068. return ret;
  30069. }
  30070. /**
  30071. * Parse declarations.
  30072. */
  30073. function declarations() {
  30074. const decls = [];
  30075. if (!open()) {
  30076. return error("missing '{'");
  30077. }
  30078. comments(decls); // declarations
  30079. let decl; // eslint-disable-next-line no-cond-assign
  30080. while (decl = declaration()) {
  30081. if (decl !== false) {
  30082. decls.push(decl);
  30083. comments(decls);
  30084. }
  30085. }
  30086. if (!close()) {
  30087. return error("missing '}'");
  30088. }
  30089. return decls;
  30090. }
  30091. /**
  30092. * Parse keyframe.
  30093. */
  30094. function keyframe() {
  30095. let m;
  30096. const vals = [];
  30097. const pos = position(); // eslint-disable-next-line no-cond-assign
  30098. while (m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/)) {
  30099. vals.push(m[1]);
  30100. match(/^,\s*/);
  30101. }
  30102. if (!vals.length) {
  30103. return;
  30104. }
  30105. return pos({
  30106. type: 'keyframe',
  30107. values: vals,
  30108. declarations: declarations()
  30109. });
  30110. }
  30111. /**
  30112. * Parse keyframes.
  30113. */
  30114. function atkeyframes() {
  30115. const pos = position();
  30116. let m = match(/^@([-\w]+)?keyframes\s*/);
  30117. if (!m) {
  30118. return;
  30119. }
  30120. const vendor = m[1]; // identifier
  30121. m = match(/^([-\w]+)\s*/);
  30122. if (!m) {
  30123. return error('@keyframes missing name');
  30124. }
  30125. const name = m[1];
  30126. if (!open()) {
  30127. return error("@keyframes missing '{'");
  30128. }
  30129. let frame;
  30130. let frames = comments(); // eslint-disable-next-line no-cond-assign
  30131. while (frame = keyframe()) {
  30132. frames.push(frame);
  30133. frames = frames.concat(comments());
  30134. }
  30135. if (!close()) {
  30136. return error("@keyframes missing '}'");
  30137. }
  30138. return pos({
  30139. type: 'keyframes',
  30140. name,
  30141. vendor,
  30142. keyframes: frames
  30143. });
  30144. }
  30145. /**
  30146. * Parse supports.
  30147. */
  30148. function atsupports() {
  30149. const pos = position();
  30150. const m = match(/^@supports *([^{]+)/);
  30151. if (!m) {
  30152. return;
  30153. }
  30154. const supports = trim(m[1]);
  30155. if (!open()) {
  30156. return error("@supports missing '{'");
  30157. }
  30158. const style = comments().concat(rules());
  30159. if (!close()) {
  30160. return error("@supports missing '}'");
  30161. }
  30162. return pos({
  30163. type: 'supports',
  30164. supports,
  30165. rules: style
  30166. });
  30167. }
  30168. /**
  30169. * Parse host.
  30170. */
  30171. function athost() {
  30172. const pos = position();
  30173. const m = match(/^@host\s*/);
  30174. if (!m) {
  30175. return;
  30176. }
  30177. if (!open()) {
  30178. return error("@host missing '{'");
  30179. }
  30180. const style = comments().concat(rules());
  30181. if (!close()) {
  30182. return error("@host missing '}'");
  30183. }
  30184. return pos({
  30185. type: 'host',
  30186. rules: style
  30187. });
  30188. }
  30189. /**
  30190. * Parse media.
  30191. */
  30192. function atmedia() {
  30193. const pos = position();
  30194. const m = match(/^@media *([^{]+)/);
  30195. if (!m) {
  30196. return;
  30197. }
  30198. const media = trim(m[1]);
  30199. if (!open()) {
  30200. return error("@media missing '{'");
  30201. }
  30202. const style = comments().concat(rules());
  30203. if (!close()) {
  30204. return error("@media missing '}'");
  30205. }
  30206. return pos({
  30207. type: 'media',
  30208. media,
  30209. rules: style
  30210. });
  30211. }
  30212. /**
  30213. * Parse custom-media.
  30214. */
  30215. function atcustommedia() {
  30216. const pos = position();
  30217. const m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
  30218. if (!m) {
  30219. return;
  30220. }
  30221. return pos({
  30222. type: 'custom-media',
  30223. name: trim(m[1]),
  30224. media: trim(m[2])
  30225. });
  30226. }
  30227. /**
  30228. * Parse paged media.
  30229. */
  30230. function atpage() {
  30231. const pos = position();
  30232. const m = match(/^@page */);
  30233. if (!m) {
  30234. return;
  30235. }
  30236. const sel = selector() || [];
  30237. if (!open()) {
  30238. return error("@page missing '{'");
  30239. }
  30240. let decls = comments(); // declarations
  30241. let decl; // eslint-disable-next-line no-cond-assign
  30242. while (decl = declaration()) {
  30243. decls.push(decl);
  30244. decls = decls.concat(comments());
  30245. }
  30246. if (!close()) {
  30247. return error("@page missing '}'");
  30248. }
  30249. return pos({
  30250. type: 'page',
  30251. selectors: sel,
  30252. declarations: decls
  30253. });
  30254. }
  30255. /**
  30256. * Parse document.
  30257. */
  30258. function atdocument() {
  30259. const pos = position();
  30260. const m = match(/^@([-\w]+)?document *([^{]+)/);
  30261. if (!m) {
  30262. return;
  30263. }
  30264. const vendor = trim(m[1]);
  30265. const doc = trim(m[2]);
  30266. if (!open()) {
  30267. return error("@document missing '{'");
  30268. }
  30269. const style = comments().concat(rules());
  30270. if (!close()) {
  30271. return error("@document missing '}'");
  30272. }
  30273. return pos({
  30274. type: 'document',
  30275. document: doc,
  30276. vendor,
  30277. rules: style
  30278. });
  30279. }
  30280. /**
  30281. * Parse font-face.
  30282. */
  30283. function atfontface() {
  30284. const pos = position();
  30285. const m = match(/^@font-face\s*/);
  30286. if (!m) {
  30287. return;
  30288. }
  30289. if (!open()) {
  30290. return error("@font-face missing '{'");
  30291. }
  30292. let decls = comments(); // declarations
  30293. let decl; // eslint-disable-next-line no-cond-assign
  30294. while (decl = declaration()) {
  30295. decls.push(decl);
  30296. decls = decls.concat(comments());
  30297. }
  30298. if (!close()) {
  30299. return error("@font-face missing '}'");
  30300. }
  30301. return pos({
  30302. type: 'font-face',
  30303. declarations: decls
  30304. });
  30305. }
  30306. /**
  30307. * Parse import
  30308. */
  30309. const atimport = _compileAtrule('import');
  30310. /**
  30311. * Parse charset
  30312. */
  30313. const atcharset = _compileAtrule('charset');
  30314. /**
  30315. * Parse namespace
  30316. */
  30317. const atnamespace = _compileAtrule('namespace');
  30318. /**
  30319. * Parse non-block at-rules
  30320. */
  30321. function _compileAtrule(name) {
  30322. const re = new RegExp('^@' + name + '\\s*([^;]+);');
  30323. return function () {
  30324. const pos = position();
  30325. const m = match(re);
  30326. if (!m) {
  30327. return;
  30328. }
  30329. const ret = {
  30330. type: name
  30331. };
  30332. ret[name] = m[1].trim();
  30333. return pos(ret);
  30334. };
  30335. }
  30336. /**
  30337. * Parse at rule.
  30338. */
  30339. function atrule() {
  30340. if (css[0] !== '@') {
  30341. return;
  30342. }
  30343. return atkeyframes() || atmedia() || atcustommedia() || atsupports() || atimport() || atcharset() || atnamespace() || atdocument() || atpage() || athost() || atfontface();
  30344. }
  30345. /**
  30346. * Parse rule.
  30347. */
  30348. function rule() {
  30349. const pos = position();
  30350. const sel = selector();
  30351. if (!sel) {
  30352. return error('selector missing');
  30353. }
  30354. comments();
  30355. return pos({
  30356. type: 'rule',
  30357. selectors: sel,
  30358. declarations: declarations()
  30359. });
  30360. }
  30361. return addParent(stylesheet());
  30362. });
  30363. /**
  30364. * Trim `str`.
  30365. */
  30366. function trim(str) {
  30367. return str ? str.replace(/^\s+|\s+$/g, '') : '';
  30368. }
  30369. /**
  30370. * Adds non-enumerable parent node reference to each node.
  30371. */
  30372. function addParent(obj, parent) {
  30373. const isNode = obj && typeof obj.type === 'string';
  30374. const childParent = isNode ? obj : parent;
  30375. for (const k in obj) {
  30376. const value = obj[k];
  30377. if (Array.isArray(value)) {
  30378. value.forEach(function (v) {
  30379. addParent(v, childParent);
  30380. });
  30381. } else if (value && typeof value === 'object') {
  30382. addParent(value, childParent);
  30383. }
  30384. }
  30385. if (isNode) {
  30386. Object.defineProperty(obj, 'parent', {
  30387. configurable: true,
  30388. writable: true,
  30389. enumerable: false,
  30390. value: parent || null
  30391. });
  30392. }
  30393. return obj;
  30394. }
  30395. /* eslint-enable @wordpress/no-unused-vars-before-return */
  30396. // EXTERNAL MODULE: ./node_modules/inherits/inherits_browser.js
  30397. var inherits_browser = __webpack_require__("P7XM");
  30398. var inherits_browser_default = /*#__PURE__*/__webpack_require__.n(inherits_browser);
  30399. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/stringify/compiler.js
  30400. // Adapted from https://github.com/reworkcss/css
  30401. // because we needed to remove source map support.
  30402. /**
  30403. * Expose `Compiler`.
  30404. */
  30405. /* harmony default export */ var stringify_compiler = (Compiler);
  30406. /**
  30407. * Initialize a compiler.
  30408. */
  30409. function Compiler(opts) {
  30410. this.options = opts || {};
  30411. }
  30412. /**
  30413. * Emit `str`
  30414. */
  30415. Compiler.prototype.emit = function (str) {
  30416. return str;
  30417. };
  30418. /**
  30419. * Visit `node`.
  30420. */
  30421. Compiler.prototype.visit = function (node) {
  30422. return this[node.type](node);
  30423. };
  30424. /**
  30425. * Map visit over array of `nodes`, optionally using a `delim`
  30426. */
  30427. Compiler.prototype.mapVisit = function (nodes, delim) {
  30428. let buf = '';
  30429. delim = delim || '';
  30430. for (let i = 0, length = nodes.length; i < length; i++) {
  30431. buf += this.visit(nodes[i]);
  30432. if (delim && i < length - 1) {
  30433. buf += this.emit(delim);
  30434. }
  30435. }
  30436. return buf;
  30437. };
  30438. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/stringify/compress.js
  30439. // Adapted from https://github.com/reworkcss/css
  30440. // because we needed to remove source map support.
  30441. /**
  30442. * External dependencies
  30443. */
  30444. /**
  30445. * Internal dependencies
  30446. */
  30447. /**
  30448. * Expose compiler.
  30449. */
  30450. /* harmony default export */ var compress = (compress_Compiler);
  30451. /**
  30452. * Initialize a new `Compiler`.
  30453. */
  30454. function compress_Compiler(options) {
  30455. stringify_compiler.call(this, options);
  30456. }
  30457. /**
  30458. * Inherit from `Base.prototype`.
  30459. */
  30460. inherits_browser_default()(compress_Compiler, stringify_compiler);
  30461. /**
  30462. * Compile `node`.
  30463. */
  30464. compress_Compiler.prototype.compile = function (node) {
  30465. return node.stylesheet.rules.map(this.visit, this).join('');
  30466. };
  30467. /**
  30468. * Visit comment node.
  30469. */
  30470. compress_Compiler.prototype.comment = function (node) {
  30471. return this.emit('', node.position);
  30472. };
  30473. /**
  30474. * Visit import node.
  30475. */
  30476. compress_Compiler.prototype.import = function (node) {
  30477. return this.emit('@import ' + node.import + ';', node.position);
  30478. };
  30479. /**
  30480. * Visit media node.
  30481. */
  30482. compress_Compiler.prototype.media = function (node) {
  30483. return this.emit('@media ' + node.media, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
  30484. };
  30485. /**
  30486. * Visit document node.
  30487. */
  30488. compress_Compiler.prototype.document = function (node) {
  30489. const doc = '@' + (node.vendor || '') + 'document ' + node.document;
  30490. return this.emit(doc, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
  30491. };
  30492. /**
  30493. * Visit charset node.
  30494. */
  30495. compress_Compiler.prototype.charset = function (node) {
  30496. return this.emit('@charset ' + node.charset + ';', node.position);
  30497. };
  30498. /**
  30499. * Visit namespace node.
  30500. */
  30501. compress_Compiler.prototype.namespace = function (node) {
  30502. return this.emit('@namespace ' + node.namespace + ';', node.position);
  30503. };
  30504. /**
  30505. * Visit supports node.
  30506. */
  30507. compress_Compiler.prototype.supports = function (node) {
  30508. return this.emit('@supports ' + node.supports, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
  30509. };
  30510. /**
  30511. * Visit keyframes node.
  30512. */
  30513. compress_Compiler.prototype.keyframes = function (node) {
  30514. return this.emit('@' + (node.vendor || '') + 'keyframes ' + node.name, node.position) + this.emit('{') + this.mapVisit(node.keyframes) + this.emit('}');
  30515. };
  30516. /**
  30517. * Visit keyframe node.
  30518. */
  30519. compress_Compiler.prototype.keyframe = function (node) {
  30520. const decls = node.declarations;
  30521. return this.emit(node.values.join(','), node.position) + this.emit('{') + this.mapVisit(decls) + this.emit('}');
  30522. };
  30523. /**
  30524. * Visit page node.
  30525. */
  30526. compress_Compiler.prototype.page = function (node) {
  30527. const sel = node.selectors.length ? node.selectors.join(', ') : '';
  30528. return this.emit('@page ' + sel, node.position) + this.emit('{') + this.mapVisit(node.declarations) + this.emit('}');
  30529. };
  30530. /**
  30531. * Visit font-face node.
  30532. */
  30533. compress_Compiler.prototype['font-face'] = function (node) {
  30534. return this.emit('@font-face', node.position) + this.emit('{') + this.mapVisit(node.declarations) + this.emit('}');
  30535. };
  30536. /**
  30537. * Visit host node.
  30538. */
  30539. compress_Compiler.prototype.host = function (node) {
  30540. return this.emit('@host', node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
  30541. };
  30542. /**
  30543. * Visit custom-media node.
  30544. */
  30545. compress_Compiler.prototype['custom-media'] = function (node) {
  30546. return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position);
  30547. };
  30548. /**
  30549. * Visit rule node.
  30550. */
  30551. compress_Compiler.prototype.rule = function (node) {
  30552. const decls = node.declarations;
  30553. if (!decls.length) {
  30554. return '';
  30555. }
  30556. return this.emit(node.selectors.join(','), node.position) + this.emit('{') + this.mapVisit(decls) + this.emit('}');
  30557. };
  30558. /**
  30559. * Visit declaration node.
  30560. */
  30561. compress_Compiler.prototype.declaration = function (node) {
  30562. return this.emit(node.property + ':' + node.value, node.position) + this.emit(';');
  30563. };
  30564. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/stringify/identity.js
  30565. /* eslint-disable @wordpress/no-unused-vars-before-return */
  30566. // Adapted from https://github.com/reworkcss/css
  30567. // because we needed to remove source map support.
  30568. /**
  30569. * External dependencies
  30570. */
  30571. /**
  30572. * Internal dependencies
  30573. */
  30574. /**
  30575. * Expose compiler.
  30576. */
  30577. /* harmony default export */ var identity = (identity_Compiler);
  30578. /**
  30579. * Initialize a new `Compiler`.
  30580. */
  30581. function identity_Compiler(options) {
  30582. options = options || {};
  30583. stringify_compiler.call(this, options);
  30584. this.indentation = options.indent;
  30585. }
  30586. /**
  30587. * Inherit from `Base.prototype`.
  30588. */
  30589. inherits_browser_default()(identity_Compiler, stringify_compiler);
  30590. /**
  30591. * Compile `node`.
  30592. */
  30593. identity_Compiler.prototype.compile = function (node) {
  30594. return this.stylesheet(node);
  30595. };
  30596. /**
  30597. * Visit stylesheet node.
  30598. */
  30599. identity_Compiler.prototype.stylesheet = function (node) {
  30600. return this.mapVisit(node.stylesheet.rules, '\n\n');
  30601. };
  30602. /**
  30603. * Visit comment node.
  30604. */
  30605. identity_Compiler.prototype.comment = function (node) {
  30606. return this.emit(this.indent() + '/*' + node.comment + '*/', node.position);
  30607. };
  30608. /**
  30609. * Visit import node.
  30610. */
  30611. identity_Compiler.prototype.import = function (node) {
  30612. return this.emit('@import ' + node.import + ';', node.position);
  30613. };
  30614. /**
  30615. * Visit media node.
  30616. */
  30617. identity_Compiler.prototype.media = function (node) {
  30618. return this.emit('@media ' + node.media, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}');
  30619. };
  30620. /**
  30621. * Visit document node.
  30622. */
  30623. identity_Compiler.prototype.document = function (node) {
  30624. const doc = '@' + (node.vendor || '') + 'document ' + node.document;
  30625. return this.emit(doc, node.position) + this.emit(' ' + ' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}');
  30626. };
  30627. /**
  30628. * Visit charset node.
  30629. */
  30630. identity_Compiler.prototype.charset = function (node) {
  30631. return this.emit('@charset ' + node.charset + ';', node.position);
  30632. };
  30633. /**
  30634. * Visit namespace node.
  30635. */
  30636. identity_Compiler.prototype.namespace = function (node) {
  30637. return this.emit('@namespace ' + node.namespace + ';', node.position);
  30638. };
  30639. /**
  30640. * Visit supports node.
  30641. */
  30642. identity_Compiler.prototype.supports = function (node) {
  30643. return this.emit('@supports ' + node.supports, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}');
  30644. };
  30645. /**
  30646. * Visit keyframes node.
  30647. */
  30648. identity_Compiler.prototype.keyframes = function (node) {
  30649. return this.emit('@' + (node.vendor || '') + 'keyframes ' + node.name, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.keyframes, '\n') + this.emit(this.indent(-1) + '}');
  30650. };
  30651. /**
  30652. * Visit keyframe node.
  30653. */
  30654. identity_Compiler.prototype.keyframe = function (node) {
  30655. const decls = node.declarations;
  30656. return this.emit(this.indent()) + this.emit(node.values.join(', '), node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(decls, '\n') + this.emit(this.indent(-1) + '\n' + this.indent() + '}\n');
  30657. };
  30658. /**
  30659. * Visit page node.
  30660. */
  30661. identity_Compiler.prototype.page = function (node) {
  30662. const sel = node.selectors.length ? node.selectors.join(', ') + ' ' : '';
  30663. return this.emit('@page ' + sel, node.position) + this.emit('{\n') + this.emit(this.indent(1)) + this.mapVisit(node.declarations, '\n') + this.emit(this.indent(-1)) + this.emit('\n}');
  30664. };
  30665. /**
  30666. * Visit font-face node.
  30667. */
  30668. identity_Compiler.prototype['font-face'] = function (node) {
  30669. return this.emit('@font-face ', node.position) + this.emit('{\n') + this.emit(this.indent(1)) + this.mapVisit(node.declarations, '\n') + this.emit(this.indent(-1)) + this.emit('\n}');
  30670. };
  30671. /**
  30672. * Visit host node.
  30673. */
  30674. identity_Compiler.prototype.host = function (node) {
  30675. return this.emit('@host', node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}');
  30676. };
  30677. /**
  30678. * Visit custom-media node.
  30679. */
  30680. identity_Compiler.prototype['custom-media'] = function (node) {
  30681. return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position);
  30682. };
  30683. /**
  30684. * Visit rule node.
  30685. */
  30686. identity_Compiler.prototype.rule = function (node) {
  30687. const indent = this.indent();
  30688. const decls = node.declarations;
  30689. if (!decls.length) {
  30690. return '';
  30691. }
  30692. return this.emit(node.selectors.map(function (s) {
  30693. return indent + s;
  30694. }).join(',\n'), node.position) + this.emit(' {\n') + this.emit(this.indent(1)) + this.mapVisit(decls, '\n') + this.emit(this.indent(-1)) + this.emit('\n' + this.indent() + '}');
  30695. };
  30696. /**
  30697. * Visit declaration node.
  30698. */
  30699. identity_Compiler.prototype.declaration = function (node) {
  30700. return this.emit(this.indent()) + this.emit(node.property + ': ' + node.value, node.position) + this.emit(';');
  30701. };
  30702. /**
  30703. * Increase, decrease or return current indentation.
  30704. */
  30705. identity_Compiler.prototype.indent = function (level) {
  30706. this.level = this.level || 1;
  30707. if (null !== level) {
  30708. this.level += level;
  30709. return '';
  30710. }
  30711. return Array(this.level).join(this.indentation || ' ');
  30712. };
  30713. /* eslint-enable @wordpress/no-unused-vars-before-return */
  30714. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/stringify/index.js
  30715. // Adapted from https://github.com/reworkcss/css
  30716. // because we needed to remove source map support.
  30717. /**
  30718. * Internal dependencies
  30719. */
  30720. /**
  30721. * Stringfy the given AST `node`.
  30722. *
  30723. * Options:
  30724. *
  30725. * - `compress` space-optimized output
  30726. * - `sourcemap` return an object with `.code` and `.map`
  30727. *
  30728. * @param {Object} node
  30729. * @param {Object} [options]
  30730. * @return {string}
  30731. */
  30732. /* harmony default export */ var stringify = (function (node, options) {
  30733. options = options || {};
  30734. const compiler = options.compress ? new compress(options) : new identity(options);
  30735. const code = compiler.compile(node);
  30736. return code;
  30737. });
  30738. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/traverse.js
  30739. /**
  30740. * External dependencies
  30741. */
  30742. /**
  30743. * Internal dependencies
  30744. */
  30745. function traverseCSS(css, callback) {
  30746. try {
  30747. const parsed = parse(css);
  30748. const updated = traverse_default.a.map(parsed, function (node) {
  30749. if (!node) {
  30750. return node;
  30751. }
  30752. const updatedNode = callback(node);
  30753. return this.update(updatedNode);
  30754. });
  30755. return stringify(updated);
  30756. } catch (err) {
  30757. // eslint-disable-next-line no-console
  30758. console.warn('Error while traversing the CSS: ' + err);
  30759. return null;
  30760. }
  30761. }
  30762. /* harmony default export */ var transform_styles_traverse = (traverseCSS);
  30763. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/transforms/url-rewrite.js
  30764. /**
  30765. * Return `true` if the given path is http/https.
  30766. *
  30767. * @param {string} filePath path
  30768. *
  30769. * @return {boolean} is remote path.
  30770. */
  30771. function isRemotePath(filePath) {
  30772. return /^(?:https?:)?\/\//.test(filePath);
  30773. }
  30774. /**
  30775. * Return `true` if the given filePath is an absolute url.
  30776. *
  30777. * @param {string} filePath path
  30778. *
  30779. * @return {boolean} is absolute path.
  30780. */
  30781. function isAbsolutePath(filePath) {
  30782. return /^\/(?!\/)/.test(filePath);
  30783. }
  30784. /**
  30785. * Whether or not the url should be inluded.
  30786. *
  30787. * @param {Object} meta url meta info
  30788. *
  30789. * @return {boolean} is valid.
  30790. */
  30791. function isValidURL(meta) {
  30792. // ignore hashes or data uris
  30793. if (meta.value.indexOf('data:') === 0 || meta.value.indexOf('#') === 0) {
  30794. return false;
  30795. }
  30796. if (isAbsolutePath(meta.value)) {
  30797. return false;
  30798. } // do not handle the http/https urls if `includeRemote` is false
  30799. if (isRemotePath(meta.value)) {
  30800. return false;
  30801. }
  30802. return true;
  30803. }
  30804. /**
  30805. * Get the absolute path of the url, relative to the basePath
  30806. *
  30807. * @param {string} str the url
  30808. * @param {string} baseURL base URL
  30809. *
  30810. * @return {string} the full path to the file
  30811. */
  30812. function getResourcePath(str, baseURL) {
  30813. return new URL(str, baseURL).toString();
  30814. }
  30815. /**
  30816. * Process the single `url()` pattern
  30817. *
  30818. * @param {string} baseURL the base URL for relative URLs
  30819. * @return {Promise} the Promise
  30820. */
  30821. function processURL(baseURL) {
  30822. return meta => ({ ...meta,
  30823. newUrl: 'url(' + meta.before + meta.quote + getResourcePath(meta.value, baseURL) + meta.quote + meta.after + ')'
  30824. });
  30825. }
  30826. /**
  30827. * Get all `url()`s, and return the meta info
  30828. *
  30829. * @param {string} value decl.value
  30830. *
  30831. * @return {Array} the urls
  30832. */
  30833. function getURLs(value) {
  30834. const reg = /url\((\s*)(['"]?)(.+?)\2(\s*)\)/g;
  30835. let match;
  30836. const URLs = [];
  30837. while ((match = reg.exec(value)) !== null) {
  30838. const meta = {
  30839. source: match[0],
  30840. before: match[1],
  30841. quote: match[2],
  30842. value: match[3],
  30843. after: match[4]
  30844. };
  30845. if (isValidURL(meta)) {
  30846. URLs.push(meta);
  30847. }
  30848. }
  30849. return URLs;
  30850. }
  30851. /**
  30852. * Replace the raw value's `url()` segment to the new value
  30853. *
  30854. * @param {string} raw the raw value
  30855. * @param {Array} URLs the URLs to replace
  30856. *
  30857. * @return {string} the new value
  30858. */
  30859. function replaceURLs(raw, URLs) {
  30860. URLs.forEach(item => {
  30861. raw = raw.replace(item.source, item.newUrl);
  30862. });
  30863. return raw;
  30864. }
  30865. const rewrite = rootURL => node => {
  30866. if (node.type === 'declaration') {
  30867. const updatedURLs = getURLs(node.value).map(processURL(rootURL));
  30868. return { ...node,
  30869. value: replaceURLs(node.value, updatedURLs)
  30870. };
  30871. }
  30872. return node;
  30873. };
  30874. /* harmony default export */ var url_rewrite = (rewrite);
  30875. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/transforms/wrap.js
  30876. /**
  30877. * @constant string IS_ROOT_TAG Regex to check if the selector is a root tag selector.
  30878. */
  30879. const IS_ROOT_TAG = /^(body|html|:root).*$/;
  30880. const wrap = (namespace, ignore = []) => node => {
  30881. const updateSelector = selector => {
  30882. if (ignore.includes(selector.trim())) {
  30883. return selector;
  30884. } // Anything other than a root tag is always prefixed.
  30885. {
  30886. if (!selector.match(IS_ROOT_TAG)) {
  30887. return namespace + ' ' + selector;
  30888. }
  30889. } // HTML and Body elements cannot be contained within our container so lets extract their styles.
  30890. return selector.replace(/^(body|html|:root)/, namespace);
  30891. };
  30892. if (node.type === 'rule') {
  30893. return { ...node,
  30894. selectors: node.selectors.map(updateSelector)
  30895. };
  30896. }
  30897. return node;
  30898. };
  30899. /* harmony default export */ var transforms_wrap = (wrap);
  30900. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/index.js
  30901. /**
  30902. * External dependencies
  30903. */
  30904. /**
  30905. * WordPress dependencies
  30906. */
  30907. /**
  30908. * Internal dependencies
  30909. */
  30910. /**
  30911. * Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed.
  30912. *
  30913. * @param {Array} styles CSS rules.
  30914. * @param {string} wrapperClassName Wrapper Class Name.
  30915. * @return {Array} converted rules.
  30916. */
  30917. const transformStyles = (styles, wrapperClassName = '') => {
  30918. return Object(external_lodash_["map"])(styles, ({
  30919. css,
  30920. baseURL,
  30921. __experimentalNoWrapper = false
  30922. }) => {
  30923. const transforms = [];
  30924. if (wrapperClassName && !__experimentalNoWrapper) {
  30925. transforms.push(transforms_wrap(wrapperClassName));
  30926. }
  30927. if (baseURL) {
  30928. transforms.push(url_rewrite(baseURL));
  30929. }
  30930. if (transforms.length) {
  30931. return transform_styles_traverse(css, Object(external_wp_compose_["compose"])(transforms));
  30932. }
  30933. return css;
  30934. });
  30935. };
  30936. /* harmony default export */ var transform_styles = (transformStyles);
  30937. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/editor-styles/index.js
  30938. /**
  30939. * External dependencies
  30940. */
  30941. /**
  30942. * WordPress dependencies
  30943. */
  30944. /**
  30945. * Internal dependencies
  30946. */
  30947. const EDITOR_STYLES_SELECTOR = '.editor-styles-wrapper';
  30948. function useDarkThemeBodyClassName(styles) {
  30949. return Object(external_wp_element_["useCallback"])(node => {
  30950. if (!node) {
  30951. return;
  30952. }
  30953. const {
  30954. ownerDocument
  30955. } = node;
  30956. const {
  30957. defaultView,
  30958. body
  30959. } = ownerDocument;
  30960. const canvas = ownerDocument.querySelector(EDITOR_STYLES_SELECTOR);
  30961. let backgroundColor;
  30962. if (!canvas) {
  30963. // The real .editor-styles-wrapper element might not exist in the
  30964. // DOM, so calculate the background color by creating a fake
  30965. // wrapper.
  30966. const tempCanvas = ownerDocument.createElement('div');
  30967. tempCanvas.classList.add('editor-styles-wrapper');
  30968. body.appendChild(tempCanvas);
  30969. backgroundColor = defaultView.getComputedStyle(tempCanvas, null).getPropertyValue('background-color');
  30970. body.removeChild(tempCanvas);
  30971. } else {
  30972. backgroundColor = defaultView.getComputedStyle(canvas, null).getPropertyValue('background-color');
  30973. } // If background is transparent, it should be treated as light color.
  30974. if (tinycolor_default()(backgroundColor).getLuminance() > 0.5 || tinycolor_default()(backgroundColor).getAlpha() === 0) {
  30975. body.classList.remove('is-dark-theme');
  30976. } else {
  30977. body.classList.add('is-dark-theme');
  30978. }
  30979. }, [styles]);
  30980. }
  30981. function EditorStyles({
  30982. styles
  30983. }) {
  30984. const transformedStyles = Object(external_wp_element_["useMemo"])(() => transform_styles(styles, EDITOR_STYLES_SELECTOR), [styles]);
  30985. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])("style", {
  30986. ref: useDarkThemeBodyClassName(styles)
  30987. }), transformedStyles.map((css, index) => Object(external_wp_element_["createElement"])("style", {
  30988. key: index
  30989. }, css)));
  30990. }
  30991. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/library.js
  30992. /**
  30993. * External dependencies
  30994. */
  30995. /**
  30996. * WordPress dependencies
  30997. */
  30998. /**
  30999. * Internal dependencies
  31000. */
  31001. function InserterLibrary({
  31002. rootClientId,
  31003. clientId,
  31004. isAppender,
  31005. showInserterHelpPanel,
  31006. showMostUsedBlocks = false,
  31007. __experimentalInsertionIndex,
  31008. onSelect = external_lodash_["noop"],
  31009. shouldFocusBlock = false
  31010. }) {
  31011. const destinationRootClientId = Object(external_wp_data_["useSelect"])(select => {
  31012. const {
  31013. getBlockRootClientId
  31014. } = select(store);
  31015. return rootClientId || getBlockRootClientId(clientId) || undefined;
  31016. }, [clientId, rootClientId]);
  31017. return Object(external_wp_element_["createElement"])(menu, {
  31018. onSelect: onSelect,
  31019. rootClientId: destinationRootClientId,
  31020. clientId: clientId,
  31021. isAppender: isAppender,
  31022. showInserterHelpPanel: showInserterHelpPanel,
  31023. showMostUsedBlocks: showMostUsedBlocks,
  31024. __experimentalInsertionIndex: __experimentalInsertionIndex,
  31025. shouldFocusBlock: shouldFocusBlock
  31026. });
  31027. }
  31028. /* harmony default export */ var library = (InserterLibrary);
  31029. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/keyboard-shortcuts/index.js
  31030. /**
  31031. * External dependencies
  31032. */
  31033. /**
  31034. * WordPress dependencies
  31035. */
  31036. /**
  31037. * Internal dependencies
  31038. */
  31039. function KeyboardShortcuts() {
  31040. // Shortcuts Logic
  31041. const {
  31042. clientIds,
  31043. rootClientId
  31044. } = Object(external_wp_data_["useSelect"])(select => {
  31045. const {
  31046. getSelectedBlockClientIds,
  31047. getBlockRootClientId
  31048. } = select(store);
  31049. const selectedClientIds = getSelectedBlockClientIds();
  31050. const [firstClientId] = selectedClientIds;
  31051. return {
  31052. clientIds: selectedClientIds,
  31053. rootClientId: getBlockRootClientId(firstClientId)
  31054. };
  31055. }, []);
  31056. const {
  31057. duplicateBlocks,
  31058. removeBlocks,
  31059. insertAfterBlock,
  31060. insertBeforeBlock,
  31061. clearSelectedBlock,
  31062. moveBlocksUp,
  31063. moveBlocksDown
  31064. } = Object(external_wp_data_["useDispatch"])(store); // Moves selected block/blocks up
  31065. Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/move-up', Object(external_wp_element_["useCallback"])(event => {
  31066. event.preventDefault();
  31067. moveBlocksUp(clientIds, rootClientId);
  31068. }, [clientIds, moveBlocksUp]), {
  31069. bindGlobal: true,
  31070. isDisabled: clientIds.length === 0
  31071. }); // Moves selected block/blocks up
  31072. Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/move-down', Object(external_wp_element_["useCallback"])(event => {
  31073. event.preventDefault();
  31074. moveBlocksDown(clientIds, rootClientId);
  31075. }, [clientIds, moveBlocksDown]), {
  31076. bindGlobal: true,
  31077. isDisabled: clientIds.length === 0
  31078. }); // Prevents bookmark all Tabs shortcut in Chrome when devtools are closed.
  31079. // Prevents reposition Chrome devtools pane shortcut when devtools are open.
  31080. Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/duplicate', Object(external_wp_element_["useCallback"])(event => {
  31081. event.preventDefault();
  31082. duplicateBlocks(clientIds);
  31083. }, [clientIds, duplicateBlocks]), {
  31084. bindGlobal: true,
  31085. isDisabled: clientIds.length === 0
  31086. }); // Does not clash with any known browser/native shortcuts, but preventDefault
  31087. // is used to prevent any obscure unknown shortcuts from triggering.
  31088. Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/remove', Object(external_wp_element_["useCallback"])(event => {
  31089. event.preventDefault();
  31090. removeBlocks(clientIds);
  31091. }, [clientIds, removeBlocks]), {
  31092. bindGlobal: true,
  31093. isDisabled: clientIds.length === 0
  31094. }); // Does not clash with any known browser/native shortcuts, but preventDefault
  31095. // is used to prevent any obscure unknown shortcuts from triggering.
  31096. Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/insert-after', Object(external_wp_element_["useCallback"])(event => {
  31097. event.preventDefault();
  31098. insertAfterBlock(Object(external_lodash_["last"])(clientIds));
  31099. }, [clientIds, insertAfterBlock]), {
  31100. bindGlobal: true,
  31101. isDisabled: clientIds.length === 0
  31102. }); // Prevent 'view recently closed tabs' in Opera using preventDefault.
  31103. Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/insert-before', Object(external_wp_element_["useCallback"])(event => {
  31104. event.preventDefault();
  31105. insertBeforeBlock(Object(external_lodash_["first"])(clientIds));
  31106. }, [clientIds, insertBeforeBlock]), {
  31107. bindGlobal: true,
  31108. isDisabled: clientIds.length === 0
  31109. });
  31110. Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/delete-multi-selection', Object(external_wp_element_["useCallback"])(event => {
  31111. event.preventDefault();
  31112. removeBlocks(clientIds);
  31113. }, [clientIds, removeBlocks]), {
  31114. isDisabled: clientIds.length < 2
  31115. });
  31116. Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/unselect', Object(external_wp_element_["useCallback"])(event => {
  31117. event.preventDefault();
  31118. clearSelectedBlock();
  31119. event.target.ownerDocument.defaultView.getSelection().removeAllRanges();
  31120. }, [clientIds, clearSelectedBlock]), {
  31121. isDisabled: clientIds.length < 2
  31122. });
  31123. return null;
  31124. }
  31125. function KeyboardShortcutsRegister() {
  31126. // Registering the shortcuts
  31127. const {
  31128. registerShortcut
  31129. } = Object(external_wp_data_["useDispatch"])(external_wp_keyboardShortcuts_["store"]);
  31130. Object(external_wp_element_["useEffect"])(() => {
  31131. registerShortcut({
  31132. name: 'core/block-editor/duplicate',
  31133. category: 'block',
  31134. description: Object(external_wp_i18n_["__"])('Duplicate the selected block(s).'),
  31135. keyCombination: {
  31136. modifier: 'primaryShift',
  31137. character: 'd'
  31138. }
  31139. });
  31140. registerShortcut({
  31141. name: 'core/block-editor/remove',
  31142. category: 'block',
  31143. description: Object(external_wp_i18n_["__"])('Remove the selected block(s).'),
  31144. keyCombination: {
  31145. modifier: 'access',
  31146. character: 'z'
  31147. }
  31148. });
  31149. registerShortcut({
  31150. name: 'core/block-editor/insert-before',
  31151. category: 'block',
  31152. description: Object(external_wp_i18n_["__"])('Insert a new block before the selected block(s).'),
  31153. keyCombination: {
  31154. modifier: 'primaryAlt',
  31155. character: 't'
  31156. }
  31157. });
  31158. registerShortcut({
  31159. name: 'core/block-editor/insert-after',
  31160. category: 'block',
  31161. description: Object(external_wp_i18n_["__"])('Insert a new block after the selected block(s).'),
  31162. keyCombination: {
  31163. modifier: 'primaryAlt',
  31164. character: 'y'
  31165. }
  31166. });
  31167. registerShortcut({
  31168. name: 'core/block-editor/delete-multi-selection',
  31169. category: 'block',
  31170. description: Object(external_wp_i18n_["__"])('Remove multiple selected blocks.'),
  31171. keyCombination: {
  31172. character: 'del'
  31173. },
  31174. aliases: [{
  31175. character: 'backspace'
  31176. }]
  31177. });
  31178. registerShortcut({
  31179. name: 'core/block-editor/select-all',
  31180. category: 'selection',
  31181. description: Object(external_wp_i18n_["__"])('Select all text when typing. Press again to select all blocks.'),
  31182. keyCombination: {
  31183. modifier: 'primary',
  31184. character: 'a'
  31185. }
  31186. });
  31187. registerShortcut({
  31188. name: 'core/block-editor/unselect',
  31189. category: 'selection',
  31190. description: Object(external_wp_i18n_["__"])('Clear selection.'),
  31191. keyCombination: {
  31192. character: 'escape'
  31193. }
  31194. });
  31195. registerShortcut({
  31196. name: 'core/block-editor/focus-toolbar',
  31197. category: 'global',
  31198. description: Object(external_wp_i18n_["__"])('Navigate to the nearest toolbar.'),
  31199. keyCombination: {
  31200. modifier: 'alt',
  31201. character: 'F10'
  31202. }
  31203. });
  31204. registerShortcut({
  31205. name: 'core/block-editor/move-up',
  31206. category: 'block',
  31207. description: Object(external_wp_i18n_["__"])('Move the selected block(s) up.'),
  31208. keyCombination: {
  31209. modifier: 'secondary',
  31210. character: 't'
  31211. }
  31212. });
  31213. registerShortcut({
  31214. name: 'core/block-editor/move-down',
  31215. category: 'block',
  31216. description: Object(external_wp_i18n_["__"])('Move the selected block(s) down.'),
  31217. keyCombination: {
  31218. modifier: 'secondary',
  31219. character: 'y'
  31220. }
  31221. });
  31222. }, [registerShortcut]);
  31223. return null;
  31224. }
  31225. KeyboardShortcuts.Register = KeyboardShortcutsRegister;
  31226. /* harmony default export */ var keyboard_shortcuts = (KeyboardShortcuts);
  31227. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/selection-scroll-into-view/index.js
  31228. /**
  31229. * WordPress dependencies
  31230. */
  31231. /**
  31232. * Scrolls the multi block selection end into view if not in view already. This
  31233. * is important to do after selection by keyboard.
  31234. *
  31235. * @deprecated
  31236. */
  31237. function MultiSelectScrollIntoView() {
  31238. external_wp_deprecated_default()('wp.blockEditor.MultiSelectScrollIntoView', {
  31239. hint: 'This behaviour is now built-in.'
  31240. });
  31241. return null;
  31242. }
  31243. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/observe-typing/index.js
  31244. /**
  31245. * WordPress dependencies
  31246. */
  31247. /**
  31248. * Internal dependencies
  31249. */
  31250. /**
  31251. * Set of key codes upon which typing is to be initiated on a keydown event.
  31252. *
  31253. * @type {Set<number>}
  31254. */
  31255. const KEY_DOWN_ELIGIBLE_KEY_CODES = new Set([external_wp_keycodes_["UP"], external_wp_keycodes_["RIGHT"], external_wp_keycodes_["DOWN"], external_wp_keycodes_["LEFT"], external_wp_keycodes_["ENTER"], external_wp_keycodes_["BACKSPACE"]]);
  31256. /**
  31257. * Returns true if a given keydown event can be inferred as intent to start
  31258. * typing, or false otherwise. A keydown is considered eligible if it is a
  31259. * text navigation without shift active.
  31260. *
  31261. * @param {KeyboardEvent} event Keydown event to test.
  31262. *
  31263. * @return {boolean} Whether event is eligible to start typing.
  31264. */
  31265. function isKeyDownEligibleForStartTyping(event) {
  31266. const {
  31267. keyCode,
  31268. shiftKey
  31269. } = event;
  31270. return !shiftKey && KEY_DOWN_ELIGIBLE_KEY_CODES.has(keyCode);
  31271. }
  31272. /**
  31273. * Removes the `isTyping` flag when the mouse moves in the document of the given
  31274. * element.
  31275. */
  31276. function useMouseMoveTypingReset() {
  31277. const isTyping = Object(external_wp_data_["useSelect"])(select => select(store).isTyping());
  31278. const {
  31279. stopTyping
  31280. } = Object(external_wp_data_["useDispatch"])(store);
  31281. return Object(external_wp_compose_["useRefEffect"])(node => {
  31282. if (!isTyping) {
  31283. return;
  31284. }
  31285. const {
  31286. ownerDocument
  31287. } = node;
  31288. let lastClientX;
  31289. let lastClientY;
  31290. /**
  31291. * On mouse move, unset typing flag if user has moved cursor.
  31292. *
  31293. * @param {MouseEvent} event Mousemove event.
  31294. */
  31295. function stopTypingOnMouseMove(event) {
  31296. const {
  31297. clientX,
  31298. clientY
  31299. } = event; // We need to check that the mouse really moved because Safari
  31300. // triggers mousemove events when shift or ctrl are pressed.
  31301. if (lastClientX && lastClientY && (lastClientX !== clientX || lastClientY !== clientY)) {
  31302. stopTyping();
  31303. }
  31304. lastClientX = clientX;
  31305. lastClientY = clientY;
  31306. }
  31307. ownerDocument.addEventListener('mousemove', stopTypingOnMouseMove);
  31308. return () => {
  31309. ownerDocument.removeEventListener('mousemove', stopTypingOnMouseMove);
  31310. };
  31311. }, [isTyping, stopTyping]);
  31312. }
  31313. /**
  31314. * Sets and removes the `isTyping` flag based on user actions:
  31315. *
  31316. * - Sets the flag if the user types within the given element.
  31317. * - Removes the flag when the user selects some text, focusses a non-text
  31318. * field, presses ESC or TAB, or moves the mouse in the document.
  31319. */
  31320. function useTypingObserver() {
  31321. const isTyping = Object(external_wp_data_["useSelect"])(select => select(store).isTyping());
  31322. const {
  31323. startTyping,
  31324. stopTyping
  31325. } = Object(external_wp_data_["useDispatch"])(store);
  31326. const ref1 = useMouseMoveTypingReset();
  31327. const ref2 = Object(external_wp_compose_["useRefEffect"])(node => {
  31328. const {
  31329. ownerDocument
  31330. } = node;
  31331. const {
  31332. defaultView
  31333. } = ownerDocument; // Listeners to stop typing should only be added when typing.
  31334. // Listeners to start typing should only be added when not typing.
  31335. if (isTyping) {
  31336. let timerId;
  31337. /**
  31338. * Stops typing when focus transitions to a non-text field element.
  31339. *
  31340. * @param {FocusEvent} event Focus event.
  31341. */
  31342. function stopTypingOnNonTextField(event) {
  31343. const {
  31344. target
  31345. } = event; // Since focus to a non-text field via arrow key will trigger
  31346. // before the keydown event, wait until after current stack
  31347. // before evaluating whether typing is to be stopped. Otherwise,
  31348. // typing will re-start.
  31349. timerId = defaultView.setTimeout(() => {
  31350. if (!Object(external_wp_dom_["isTextField"])(target)) {
  31351. stopTyping();
  31352. }
  31353. });
  31354. }
  31355. /**
  31356. * Unsets typing flag if user presses Escape while typing flag is
  31357. * active.
  31358. *
  31359. * @param {KeyboardEvent} event Keypress or keydown event to
  31360. * interpret.
  31361. */
  31362. function stopTypingOnEscapeKey(event) {
  31363. const {
  31364. keyCode
  31365. } = event;
  31366. if (keyCode === external_wp_keycodes_["ESCAPE"] || keyCode === external_wp_keycodes_["TAB"]) {
  31367. stopTyping();
  31368. }
  31369. }
  31370. /**
  31371. * On selection change, unset typing flag if user has made an
  31372. * uncollapsed (shift) selection.
  31373. */
  31374. function stopTypingOnSelectionUncollapse() {
  31375. const selection = defaultView.getSelection();
  31376. const isCollapsed = selection.rangeCount > 0 && selection.getRangeAt(0).collapsed;
  31377. if (!isCollapsed) {
  31378. stopTyping();
  31379. }
  31380. }
  31381. node.addEventListener('focus', stopTypingOnNonTextField);
  31382. node.addEventListener('keydown', stopTypingOnEscapeKey);
  31383. ownerDocument.addEventListener('selectionchange', stopTypingOnSelectionUncollapse);
  31384. return () => {
  31385. defaultView.clearTimeout(timerId);
  31386. node.removeEventListener('focus', stopTypingOnNonTextField);
  31387. node.removeEventListener('keydown', stopTypingOnEscapeKey);
  31388. ownerDocument.removeEventListener('selectionchange', stopTypingOnSelectionUncollapse);
  31389. };
  31390. }
  31391. /**
  31392. * Handles a keypress or keydown event to infer intention to start
  31393. * typing.
  31394. *
  31395. * @param {KeyboardEvent} event Keypress or keydown event to interpret.
  31396. */
  31397. function startTypingInTextField(event) {
  31398. const {
  31399. type,
  31400. target
  31401. } = event; // Abort early if already typing, or key press is incurred outside a
  31402. // text field (e.g. arrow-ing through toolbar buttons).
  31403. // Ignore typing if outside the current DOM container
  31404. if (!Object(external_wp_dom_["isTextField"])(target) || !node.contains(target)) {
  31405. return;
  31406. } // Special-case keydown because certain keys do not emit a keypress
  31407. // event. Conversely avoid keydown as the canonical event since
  31408. // there are many keydown which are explicitly not targeted for
  31409. // typing.
  31410. if (type === 'keydown' && !isKeyDownEligibleForStartTyping(event)) {
  31411. return;
  31412. }
  31413. startTyping();
  31414. }
  31415. node.addEventListener('keypress', startTypingInTextField);
  31416. node.addEventListener('keydown', startTypingInTextField);
  31417. return () => {
  31418. node.removeEventListener('keypress', startTypingInTextField);
  31419. node.removeEventListener('keydown', startTypingInTextField);
  31420. };
  31421. }, [isTyping, startTyping, stopTyping]);
  31422. return Object(external_wp_compose_["useMergeRefs"])([ref1, ref2]);
  31423. }
  31424. function ObserveTyping({
  31425. children
  31426. }) {
  31427. return Object(external_wp_element_["createElement"])("div", {
  31428. ref: useTypingObserver()
  31429. }, children);
  31430. }
  31431. /**
  31432. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/observe-typing/README.md
  31433. */
  31434. /* harmony default export */ var observe_typing = (ObserveTyping);
  31435. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/preserve-scroll-in-reorder/index.js
  31436. /**
  31437. * WordPress dependencies
  31438. */
  31439. function PreserveScrollInReorder() {
  31440. external_wp_deprecated_default()('PreserveScrollInReorder component', {
  31441. since: '5.4',
  31442. hint: 'This behavior is now built-in the block list'
  31443. });
  31444. return null;
  31445. }
  31446. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/typewriter/index.js
  31447. /**
  31448. * WordPress dependencies
  31449. */
  31450. /**
  31451. * Internal dependencies
  31452. */
  31453. const isIE = window.navigator.userAgent.indexOf('Trident') !== -1;
  31454. const arrowKeyCodes = new Set([external_wp_keycodes_["UP"], external_wp_keycodes_["DOWN"], external_wp_keycodes_["LEFT"], external_wp_keycodes_["RIGHT"]]);
  31455. const initialTriggerPercentage = 0.75;
  31456. function useTypewriter() {
  31457. const hasSelectedBlock = Object(external_wp_data_["useSelect"])(select => select(store).hasSelectedBlock());
  31458. return Object(external_wp_compose_["useRefEffect"])(node => {
  31459. if (!hasSelectedBlock) {
  31460. return;
  31461. }
  31462. const {
  31463. ownerDocument
  31464. } = node;
  31465. const {
  31466. defaultView
  31467. } = ownerDocument;
  31468. let scrollResizeRafId;
  31469. let onKeyDownRafId;
  31470. let caretRect;
  31471. function onScrollResize() {
  31472. if (scrollResizeRafId) {
  31473. return;
  31474. }
  31475. scrollResizeRafId = defaultView.requestAnimationFrame(() => {
  31476. computeCaretRectangle();
  31477. scrollResizeRafId = null;
  31478. });
  31479. }
  31480. function onKeyDown(event) {
  31481. // Ensure the any remaining request is cancelled.
  31482. if (onKeyDownRafId) {
  31483. defaultView.cancelAnimationFrame(onKeyDownRafId);
  31484. } // Use an animation frame for a smooth result.
  31485. onKeyDownRafId = defaultView.requestAnimationFrame(() => {
  31486. maintainCaretPosition(event);
  31487. onKeyDownRafId = null;
  31488. });
  31489. }
  31490. /**
  31491. * Maintains the scroll position after a selection change caused by a
  31492. * keyboard event.
  31493. *
  31494. * @param {KeyboardEvent} event Keyboard event.
  31495. */
  31496. function maintainCaretPosition({
  31497. keyCode
  31498. }) {
  31499. if (!isSelectionEligibleForScroll()) {
  31500. return;
  31501. }
  31502. const currentCaretRect = Object(external_wp_dom_["computeCaretRect"])(defaultView);
  31503. if (!currentCaretRect) {
  31504. return;
  31505. } // If for some reason there is no position set to be scrolled to, let
  31506. // this be the position to be scrolled to in the future.
  31507. if (!caretRect) {
  31508. caretRect = currentCaretRect;
  31509. return;
  31510. } // Even though enabling the typewriter effect for arrow keys results in
  31511. // a pleasant experience, it may not be the case for everyone, so, for
  31512. // now, let's disable it.
  31513. if (arrowKeyCodes.has(keyCode)) {
  31514. // Reset the caret position to maintain.
  31515. caretRect = currentCaretRect;
  31516. return;
  31517. }
  31518. const diff = currentCaretRect.top - caretRect.top;
  31519. if (diff === 0) {
  31520. return;
  31521. }
  31522. const scrollContainer = Object(external_wp_dom_["getScrollContainer"])(node); // The page must be scrollable.
  31523. if (!scrollContainer) {
  31524. return;
  31525. }
  31526. const windowScroll = scrollContainer === ownerDocument.body;
  31527. const scrollY = windowScroll ? defaultView.scrollY : scrollContainer.scrollTop;
  31528. const scrollContainerY = windowScroll ? 0 : scrollContainer.getBoundingClientRect().top;
  31529. const relativeScrollPosition = windowScroll ? caretRect.top / defaultView.innerHeight : (caretRect.top - scrollContainerY) / (defaultView.innerHeight - scrollContainerY); // If the scroll position is at the start, the active editable element
  31530. // is the last one, and the caret is positioned within the initial
  31531. // trigger percentage of the page, do not scroll the page.
  31532. // The typewriter effect should not kick in until an empty page has been
  31533. // filled with the initial trigger percentage or the user scrolls
  31534. // intentionally down.
  31535. if (scrollY === 0 && relativeScrollPosition < initialTriggerPercentage && isLastEditableNode()) {
  31536. // Reset the caret position to maintain.
  31537. caretRect = currentCaretRect;
  31538. return;
  31539. }
  31540. const scrollContainerHeight = windowScroll ? defaultView.innerHeight : scrollContainer.clientHeight; // Abort if the target scroll position would scroll the caret out of
  31541. // view.
  31542. if ( // The caret is under the lower fold.
  31543. caretRect.top + caretRect.height > scrollContainerY + scrollContainerHeight || // The caret is above the upper fold.
  31544. caretRect.top < scrollContainerY) {
  31545. // Reset the caret position to maintain.
  31546. caretRect = currentCaretRect;
  31547. return;
  31548. }
  31549. if (windowScroll) {
  31550. defaultView.scrollBy(0, diff);
  31551. } else {
  31552. scrollContainer.scrollTop += diff;
  31553. }
  31554. }
  31555. /**
  31556. * Adds a `selectionchange` listener to reset the scroll position to be
  31557. * maintained.
  31558. */
  31559. function addSelectionChangeListener() {
  31560. ownerDocument.addEventListener('selectionchange', computeCaretRectOnSelectionChange);
  31561. }
  31562. /**
  31563. * Resets the scroll position to be maintained during a `selectionchange`
  31564. * event. Also removes the listener, so it acts as a one-time listener.
  31565. */
  31566. function computeCaretRectOnSelectionChange() {
  31567. ownerDocument.removeEventListener('selectionchange', computeCaretRectOnSelectionChange);
  31568. computeCaretRectangle();
  31569. }
  31570. /**
  31571. * Resets the scroll position to be maintained.
  31572. */
  31573. function computeCaretRectangle() {
  31574. if (isSelectionEligibleForScroll()) {
  31575. caretRect = Object(external_wp_dom_["computeCaretRect"])(defaultView);
  31576. }
  31577. }
  31578. /**
  31579. * Checks if the current situation is elegible for scroll:
  31580. * - There should be one and only one block selected.
  31581. * - The component must contain the selection.
  31582. * - The active element must be contenteditable.
  31583. */
  31584. function isSelectionEligibleForScroll() {
  31585. return node.contains(ownerDocument.activeElement) && ownerDocument.activeElement.isContentEditable;
  31586. }
  31587. function isLastEditableNode() {
  31588. const editableNodes = node.querySelectorAll('[contenteditable="true"]');
  31589. const lastEditableNode = editableNodes[editableNodes.length - 1];
  31590. return lastEditableNode === ownerDocument.activeElement;
  31591. } // When the user scrolls or resizes, the scroll position should be
  31592. // reset.
  31593. defaultView.addEventListener('scroll', onScrollResize, true);
  31594. defaultView.addEventListener('resize', onScrollResize, true);
  31595. node.addEventListener('keydown', onKeyDown);
  31596. node.addEventListener('keyup', maintainCaretPosition);
  31597. node.addEventListener('mousedown', addSelectionChangeListener);
  31598. node.addEventListener('touchstart', addSelectionChangeListener);
  31599. return () => {
  31600. defaultView.removeEventListener('scroll', onScrollResize, true);
  31601. defaultView.removeEventListener('resize', onScrollResize, true);
  31602. node.removeEventListener('keydown', onKeyDown);
  31603. node.removeEventListener('keyup', maintainCaretPosition);
  31604. node.removeEventListener('mousedown', addSelectionChangeListener);
  31605. node.removeEventListener('touchstart', addSelectionChangeListener);
  31606. ownerDocument.removeEventListener('selectionchange', computeCaretRectOnSelectionChange);
  31607. defaultView.cancelAnimationFrame(scrollResizeRafId);
  31608. defaultView.cancelAnimationFrame(onKeyDownRafId);
  31609. };
  31610. }, [hasSelectedBlock]);
  31611. }
  31612. function Typewriter({
  31613. children
  31614. }) {
  31615. return Object(external_wp_element_["createElement"])("div", {
  31616. ref: useTypewriter(),
  31617. className: "block-editor__typewriter"
  31618. }, children);
  31619. }
  31620. /**
  31621. * The exported component. The implementation of Typewriter faced technical
  31622. * challenges in Internet Explorer, and is simply skipped, rendering the given
  31623. * props children instead.
  31624. *
  31625. * @type {WPComponent}
  31626. */
  31627. const TypewriterOrIEBypass = isIE ? props => props.children : Typewriter;
  31628. /**
  31629. * Ensures that the text selection keeps the same vertical distance from the
  31630. * viewport during keyboard events within this component. The vertical distance
  31631. * can vary. It is the last clicked or scrolled to position.
  31632. */
  31633. /* harmony default export */ var typewriter = (TypewriterOrIEBypass);
  31634. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-multi-selection.js
  31635. /**
  31636. * External dependencies
  31637. */
  31638. /**
  31639. * WordPress dependencies
  31640. */
  31641. /**
  31642. * Internal dependencies
  31643. */
  31644. function use_multi_selection_toggleRichText(container, toggle) {
  31645. Array.from(container.querySelectorAll('.rich-text')).forEach(node => {
  31646. if (toggle) {
  31647. node.setAttribute('contenteditable', true);
  31648. } else {
  31649. node.removeAttribute('contenteditable');
  31650. }
  31651. });
  31652. }
  31653. /**
  31654. * Returns for the deepest node at the start or end of a container node. Ignores
  31655. * any text nodes that only contain HTML formatting whitespace.
  31656. *
  31657. * @param {Element} node Container to search.
  31658. * @param {string} type 'start' or 'end'.
  31659. */
  31660. function getDeepestNode(node, type) {
  31661. const child = type === 'start' ? 'firstChild' : 'lastChild';
  31662. const sibling = type === 'start' ? 'nextSibling' : 'previousSibling';
  31663. while (node[child]) {
  31664. node = node[child];
  31665. while (node.nodeType === node.TEXT_NODE && /^[ \t\n]*$/.test(node.data) && node[sibling]) {
  31666. node = node[sibling];
  31667. }
  31668. }
  31669. return node;
  31670. }
  31671. function use_multi_selection_selector(select) {
  31672. const {
  31673. isMultiSelecting,
  31674. getMultiSelectedBlockClientIds,
  31675. hasMultiSelection,
  31676. getSelectedBlockClientId
  31677. } = select(store);
  31678. return {
  31679. isMultiSelecting: isMultiSelecting(),
  31680. multiSelectedBlockClientIds: getMultiSelectedBlockClientIds(),
  31681. hasMultiSelection: hasMultiSelection(),
  31682. selectedBlockClientId: getSelectedBlockClientId()
  31683. };
  31684. }
  31685. function use_multi_selection_useMultiSelection() {
  31686. const ref = Object(external_wp_element_["useRef"])();
  31687. const {
  31688. isMultiSelecting,
  31689. multiSelectedBlockClientIds,
  31690. hasMultiSelection,
  31691. selectedBlockClientId
  31692. } = Object(external_wp_data_["useSelect"])(use_multi_selection_selector, []);
  31693. const {
  31694. selectBlock
  31695. } = Object(external_wp_data_["useDispatch"])(store);
  31696. const selectedRef = useBlockRef(selectedBlockClientId); // These must be in the right DOM order.
  31697. const startRef = useBlockRef(Object(external_lodash_["first"])(multiSelectedBlockClientIds));
  31698. const endRef = useBlockRef(Object(external_lodash_["last"])(multiSelectedBlockClientIds));
  31699. /**
  31700. * When the component updates, and there is multi selection, we need to
  31701. * select the entire block contents.
  31702. */
  31703. Object(external_wp_element_["useEffect"])(() => {
  31704. const {
  31705. ownerDocument
  31706. } = ref.current;
  31707. const {
  31708. defaultView
  31709. } = ownerDocument;
  31710. if (!hasMultiSelection || isMultiSelecting) {
  31711. if (!selectedBlockClientId || isMultiSelecting) {
  31712. return;
  31713. }
  31714. const selection = defaultView.getSelection();
  31715. if (selection.rangeCount && !selection.isCollapsed) {
  31716. const blockNode = selectedRef.current;
  31717. const {
  31718. startContainer,
  31719. endContainer
  31720. } = selection.getRangeAt(0);
  31721. if (!!blockNode && (!blockNode.contains(startContainer) || !blockNode.contains(endContainer))) {
  31722. selection.removeAllRanges();
  31723. }
  31724. }
  31725. return;
  31726. }
  31727. const {
  31728. length
  31729. } = multiSelectedBlockClientIds;
  31730. if (length < 2) {
  31731. return;
  31732. } // For some browsers, like Safari, it is important that focus happens
  31733. // BEFORE selection.
  31734. ref.current.focus();
  31735. const selection = defaultView.getSelection();
  31736. const range = ownerDocument.createRange(); // These must be in the right DOM order.
  31737. // The most stable way to select the whole block contents is to start
  31738. // and end at the deepest points.
  31739. const startNode = getDeepestNode(startRef.current, 'start');
  31740. const endNode = getDeepestNode(endRef.current, 'end'); // While rich text will be disabled with a delay when there is a multi
  31741. // selection, we must do it immediately because it's not possible to set
  31742. // selection across editable hosts.
  31743. use_multi_selection_toggleRichText(ref.current, false);
  31744. range.setStartBefore(startNode);
  31745. range.setEndAfter(endNode);
  31746. selection.removeAllRanges();
  31747. selection.addRange(range);
  31748. }, [hasMultiSelection, isMultiSelecting, multiSelectedBlockClientIds, selectBlock, selectedBlockClientId]);
  31749. return ref;
  31750. }
  31751. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-tab-nav.js
  31752. /**
  31753. * WordPress dependencies
  31754. */
  31755. /**
  31756. * Internal dependencies
  31757. */
  31758. function isFormElement(element) {
  31759. const {
  31760. tagName
  31761. } = element;
  31762. return tagName === 'INPUT' || tagName === 'BUTTON' || tagName === 'SELECT' || tagName === 'TEXTAREA';
  31763. }
  31764. function useTabNav() {
  31765. const container = Object(external_wp_element_["useRef"])();
  31766. const focusCaptureBeforeRef = Object(external_wp_element_["useRef"])();
  31767. const focusCaptureAfterRef = Object(external_wp_element_["useRef"])();
  31768. const lastFocus = Object(external_wp_element_["useRef"])();
  31769. const {
  31770. hasMultiSelection,
  31771. getSelectedBlockClientId
  31772. } = Object(external_wp_data_["useSelect"])(store);
  31773. const {
  31774. setNavigationMode
  31775. } = Object(external_wp_data_["useDispatch"])(store);
  31776. const isNavigationMode = Object(external_wp_data_["useSelect"])(select => select(store).isNavigationMode(), []); // Don't allow tabbing to this element in Navigation mode.
  31777. const focusCaptureTabIndex = !isNavigationMode ? '0' : undefined; // Reference that holds the a flag for enabling or disabling
  31778. // capturing on the focus capture elements.
  31779. const noCapture = Object(external_wp_element_["useRef"])();
  31780. function onFocusCapture(event) {
  31781. // Do not capture incoming focus if set by us in WritingFlow.
  31782. if (noCapture.current) {
  31783. noCapture.current = null;
  31784. } else if (hasMultiSelection()) {
  31785. container.current.focus();
  31786. } else if (getSelectedBlockClientId()) {
  31787. lastFocus.current.focus();
  31788. } else {
  31789. setNavigationMode(true);
  31790. const isBefore = // eslint-disable-next-line no-bitwise
  31791. event.target.compareDocumentPosition(container.current) & event.target.DOCUMENT_POSITION_FOLLOWING;
  31792. const action = isBefore ? 'findNext' : 'findPrevious';
  31793. external_wp_dom_["focus"].tabbable[action](event.target).focus();
  31794. }
  31795. }
  31796. const before = Object(external_wp_element_["createElement"])("div", {
  31797. ref: focusCaptureBeforeRef,
  31798. tabIndex: focusCaptureTabIndex,
  31799. onFocus: onFocusCapture
  31800. });
  31801. const after = Object(external_wp_element_["createElement"])("div", {
  31802. ref: focusCaptureAfterRef,
  31803. tabIndex: focusCaptureTabIndex,
  31804. onFocus: onFocusCapture
  31805. });
  31806. const ref = Object(external_wp_compose_["useRefEffect"])(node => {
  31807. function onKeyDown(event) {
  31808. if (event.keyCode === external_wp_keycodes_["ESCAPE"] && !hasMultiSelection()) {
  31809. event.stopPropagation();
  31810. event.preventDefault();
  31811. setNavigationMode(true);
  31812. return;
  31813. } // In Edit mode, Tab should focus the first tabbable element after
  31814. // the content, which is normally the sidebar (with block controls)
  31815. // and Shift+Tab should focus the first tabbable element before the
  31816. // content, which is normally the block toolbar.
  31817. // Arrow keys can be used, and Tab and arrow keys can be used in
  31818. // Navigation mode (press Esc), to navigate through blocks.
  31819. if (event.keyCode !== external_wp_keycodes_["TAB"]) {
  31820. return;
  31821. }
  31822. const isShift = event.shiftKey;
  31823. const direction = isShift ? 'findPrevious' : 'findNext';
  31824. if (!hasMultiSelection() && !getSelectedBlockClientId()) {
  31825. // Preserve the behaviour of entering navigation mode when
  31826. // tabbing into the content without a block selection.
  31827. // `onFocusCapture` already did this previously, but we need to
  31828. // do it again here because after clearing block selection,
  31829. // focus land on the writing flow container and pressing Tab
  31830. // will no longer send focus through the focus capture element.
  31831. if (event.target === node) setNavigationMode(true);
  31832. return;
  31833. } // Allow tabbing between form elements rendered in a block,
  31834. // such as inside a placeholder. Form elements are generally
  31835. // meant to be UI rather than part of the content. Ideally
  31836. // these are not rendered in the content and perhaps in the
  31837. // future they can be rendered in an iframe or shadow DOM.
  31838. if (isFormElement(event.target) && isFormElement(external_wp_dom_["focus"].tabbable[direction](event.target))) {
  31839. return;
  31840. }
  31841. const next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef; // Disable focus capturing on the focus capture element, so it
  31842. // doesn't refocus this block and so it allows default behaviour
  31843. // (moving focus to the next tabbable element).
  31844. noCapture.current = true; // Focusing the focus capture element, which is located above and
  31845. // below the editor, should not scroll the page all the way up or
  31846. // down.
  31847. next.current.focus({
  31848. preventScroll: true
  31849. });
  31850. }
  31851. function onFocusOut(event) {
  31852. lastFocus.current = event.target;
  31853. } // When tabbing back to an element in block list, this event handler prevents scrolling if the
  31854. // focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph
  31855. // when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the
  31856. // top or bottom of the document.
  31857. //
  31858. // Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this
  31859. // earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.
  31860. // https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters
  31861. function preventScrollOnTab(event) {
  31862. var _event$target;
  31863. if (event.keyCode !== external_wp_keycodes_["TAB"]) {
  31864. return;
  31865. }
  31866. if (((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.getAttribute('role')) === 'region') {
  31867. return;
  31868. }
  31869. if (container.current === event.target) {
  31870. return;
  31871. }
  31872. const isShift = event.shiftKey;
  31873. const direction = isShift ? 'findPrevious' : 'findNext';
  31874. const target = external_wp_dom_["focus"].tabbable[direction](event.target); // only do something when the next tabbable is a focus capture div (before/after)
  31875. if (target === focusCaptureBeforeRef.current || target === focusCaptureAfterRef.current) {
  31876. event.preventDefault();
  31877. target.focus({
  31878. preventScroll: true
  31879. });
  31880. }
  31881. }
  31882. node.ownerDocument.defaultView.addEventListener('keydown', preventScrollOnTab);
  31883. node.addEventListener('keydown', onKeyDown);
  31884. node.addEventListener('focusout', onFocusOut);
  31885. return () => {
  31886. node.ownerDocument.defaultView.removeEventListener('keydown', preventScrollOnTab);
  31887. node.removeEventListener('keydown', onKeyDown);
  31888. node.removeEventListener('focusout', onFocusOut);
  31889. };
  31890. }, []);
  31891. const mergedRefs = Object(external_wp_compose_["useMergeRefs"])([container, ref]);
  31892. return [before, mergedRefs, after];
  31893. }
  31894. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-arrow-nav.js
  31895. /**
  31896. * External dependencies
  31897. */
  31898. /**
  31899. * WordPress dependencies
  31900. */
  31901. /**
  31902. * Internal dependencies
  31903. */
  31904. /**
  31905. * Returns true if the element should consider edge navigation upon a keyboard
  31906. * event of the given directional key code, or false otherwise.
  31907. *
  31908. * @param {Element} element HTML element to test.
  31909. * @param {number} keyCode KeyboardEvent keyCode to test.
  31910. * @param {boolean} hasModifier Whether a modifier is pressed.
  31911. *
  31912. * @return {boolean} Whether element should consider edge navigation.
  31913. */
  31914. function isNavigationCandidate(element, keyCode, hasModifier) {
  31915. const isVertical = keyCode === external_wp_keycodes_["UP"] || keyCode === external_wp_keycodes_["DOWN"]; // Currently, all elements support unmodified vertical navigation.
  31916. if (isVertical && !hasModifier) {
  31917. return true;
  31918. } // Native inputs should not navigate horizontally.
  31919. const {
  31920. tagName
  31921. } = element;
  31922. return tagName !== 'INPUT' && tagName !== 'TEXTAREA';
  31923. }
  31924. /**
  31925. * Returns the optimal tab target from the given focused element in the desired
  31926. * direction. A preference is made toward text fields, falling back to the block
  31927. * focus stop if no other candidates exist for the block.
  31928. *
  31929. * @param {Element} target Currently focused text field.
  31930. * @param {boolean} isReverse True if considering as the first field.
  31931. * @param {Element} containerElement Element containing all blocks.
  31932. * @param {boolean} onlyVertical Whether to only consider tabbable elements
  31933. * that are visually above or under the
  31934. * target.
  31935. *
  31936. * @return {?Element} Optimal tab target, if one exists.
  31937. */
  31938. function getClosestTabbable(target, isReverse, containerElement, onlyVertical) {
  31939. // Since the current focus target is not guaranteed to be a text field, find
  31940. // all focusables. Tabbability is considered later.
  31941. let focusableNodes = external_wp_dom_["focus"].focusable.find(containerElement);
  31942. if (isReverse) {
  31943. focusableNodes = Object(external_lodash_["reverse"])(focusableNodes);
  31944. } // Consider as candidates those focusables after the current target. It's
  31945. // assumed this can only be reached if the target is focusable (on its
  31946. // keydown event), so no need to verify it exists in the set.
  31947. focusableNodes = focusableNodes.slice(focusableNodes.indexOf(target) + 1);
  31948. let targetRect;
  31949. if (onlyVertical) {
  31950. targetRect = target.getBoundingClientRect();
  31951. }
  31952. function isTabCandidate(node) {
  31953. // Not a candidate if the node is not tabbable.
  31954. if (!external_wp_dom_["focus"].tabbable.isTabbableIndex(node)) {
  31955. return false;
  31956. } // Skip focusable elements such as links within content editable nodes.
  31957. if (node.isContentEditable && node.contentEditable !== 'true') {
  31958. return false;
  31959. }
  31960. if (onlyVertical) {
  31961. const nodeRect = node.getBoundingClientRect();
  31962. if (nodeRect.left >= targetRect.right || nodeRect.right <= targetRect.left) {
  31963. return false;
  31964. }
  31965. }
  31966. return true;
  31967. }
  31968. return Object(external_lodash_["find"])(focusableNodes, isTabCandidate);
  31969. }
  31970. function useArrowNav() {
  31971. const {
  31972. getSelectedBlockClientId,
  31973. getMultiSelectedBlocksStartClientId,
  31974. getMultiSelectedBlocksEndClientId,
  31975. getPreviousBlockClientId,
  31976. getNextBlockClientId,
  31977. getFirstMultiSelectedBlockClientId,
  31978. getLastMultiSelectedBlockClientId,
  31979. getSettings,
  31980. hasMultiSelection
  31981. } = Object(external_wp_data_["useSelect"])(store);
  31982. const {
  31983. multiSelect,
  31984. selectBlock
  31985. } = Object(external_wp_data_["useDispatch"])(store);
  31986. return Object(external_wp_compose_["useRefEffect"])(node => {
  31987. // Here a DOMRect is stored while moving the caret vertically so
  31988. // vertical position of the start position can be restored. This is to
  31989. // recreate browser behaviour across blocks.
  31990. let verticalRect;
  31991. function onMouseDown() {
  31992. verticalRect = null;
  31993. }
  31994. function expandSelection(isReverse) {
  31995. const selectedBlockClientId = getSelectedBlockClientId();
  31996. const selectionStartClientId = getMultiSelectedBlocksStartClientId();
  31997. const selectionEndClientId = getMultiSelectedBlocksEndClientId();
  31998. const selectionBeforeEndClientId = getPreviousBlockClientId(selectionEndClientId || selectedBlockClientId);
  31999. const selectionAfterEndClientId = getNextBlockClientId(selectionEndClientId || selectedBlockClientId);
  32000. const nextSelectionEndClientId = isReverse ? selectionBeforeEndClientId : selectionAfterEndClientId;
  32001. if (nextSelectionEndClientId) {
  32002. if (selectionStartClientId === nextSelectionEndClientId) {
  32003. selectBlock(nextSelectionEndClientId);
  32004. } else {
  32005. multiSelect(selectionStartClientId || selectedBlockClientId, nextSelectionEndClientId);
  32006. }
  32007. }
  32008. }
  32009. function moveSelection(isReverse) {
  32010. const selectedFirstClientId = getFirstMultiSelectedBlockClientId();
  32011. const selectedLastClientId = getLastMultiSelectedBlockClientId();
  32012. const focusedBlockClientId = isReverse ? selectedFirstClientId : selectedLastClientId;
  32013. if (focusedBlockClientId) {
  32014. selectBlock(focusedBlockClientId);
  32015. }
  32016. }
  32017. /**
  32018. * Returns true if the given target field is the last in its block which
  32019. * can be considered for tab transition. For example, in a block with
  32020. * two text fields, this would return true when reversing from the first
  32021. * of the two fields, but false when reversing from the second.
  32022. *
  32023. * @param {Element} target Currently focused text field.
  32024. * @param {boolean} isReverse True if considering as the first field.
  32025. *
  32026. * @return {boolean} Whether field is at edge for tab transition.
  32027. */
  32028. function isTabbableEdge(target, isReverse) {
  32029. const closestTabbable = getClosestTabbable(target, isReverse, node);
  32030. return !closestTabbable || !isInSameBlock(target, closestTabbable);
  32031. }
  32032. function onKeyDown(event) {
  32033. const {
  32034. keyCode,
  32035. target
  32036. } = event;
  32037. const isUp = keyCode === external_wp_keycodes_["UP"];
  32038. const isDown = keyCode === external_wp_keycodes_["DOWN"];
  32039. const isLeft = keyCode === external_wp_keycodes_["LEFT"];
  32040. const isRight = keyCode === external_wp_keycodes_["RIGHT"];
  32041. const isReverse = isUp || isLeft;
  32042. const isHorizontal = isLeft || isRight;
  32043. const isVertical = isUp || isDown;
  32044. const isNav = isHorizontal || isVertical;
  32045. const isShift = event.shiftKey;
  32046. const hasModifier = isShift || event.ctrlKey || event.altKey || event.metaKey;
  32047. const isNavEdge = isVertical ? external_wp_dom_["isVerticalEdge"] : external_wp_dom_["isHorizontalEdge"];
  32048. const {
  32049. ownerDocument
  32050. } = node;
  32051. const {
  32052. defaultView
  32053. } = ownerDocument;
  32054. if (hasMultiSelection()) {
  32055. if (isNav) {
  32056. const action = isShift ? expandSelection : moveSelection;
  32057. action(isReverse);
  32058. event.preventDefault();
  32059. }
  32060. return;
  32061. } // When presing any key other than up or down, the initial vertical
  32062. // position must ALWAYS be reset. The vertical position is saved so
  32063. // it can be restored as well as possible on sebsequent vertical
  32064. // arrow key presses. It may not always be possible to restore the
  32065. // exact same position (such as at an empty line), so it wouldn't be
  32066. // good to compute the position right before any vertical arrow key
  32067. // press.
  32068. if (!isVertical) {
  32069. verticalRect = null;
  32070. } else if (!verticalRect) {
  32071. verticalRect = Object(external_wp_dom_["computeCaretRect"])(defaultView);
  32072. } // Abort if navigation has already been handled (e.g. RichText
  32073. // inline boundaries).
  32074. if (event.defaultPrevented) {
  32075. return;
  32076. }
  32077. if (!isNav) {
  32078. return;
  32079. } // Abort if our current target is not a candidate for navigation
  32080. // (e.g. preserve native input behaviors).
  32081. if (!isNavigationCandidate(target, keyCode, hasModifier)) {
  32082. return;
  32083. } // In the case of RTL scripts, right means previous and left means
  32084. // next, which is the exact reverse of LTR.
  32085. const isReverseDir = Object(external_wp_dom_["isRTL"])(target) ? !isReverse : isReverse;
  32086. const {
  32087. keepCaretInsideBlock
  32088. } = getSettings();
  32089. const selectedBlockClientId = getSelectedBlockClientId();
  32090. if (isShift) {
  32091. const selectionEndClientId = getMultiSelectedBlocksEndClientId();
  32092. const selectionBeforeEndClientId = getPreviousBlockClientId(selectionEndClientId || selectedBlockClientId);
  32093. const selectionAfterEndClientId = getNextBlockClientId(selectionEndClientId || selectedBlockClientId);
  32094. if ( // Ensure that there is a target block.
  32095. (isReverse && selectionBeforeEndClientId || !isReverse && selectionAfterEndClientId) && isTabbableEdge(target, isReverse) && isNavEdge(target, isReverse)) {
  32096. // Shift key is down, and there is multi selection or we're
  32097. // at the end of the current block.
  32098. expandSelection(isReverse);
  32099. event.preventDefault();
  32100. }
  32101. } else if (isVertical && Object(external_wp_dom_["isVerticalEdge"])(target, isReverse) && !keepCaretInsideBlock) {
  32102. const closestTabbable = getClosestTabbable(target, isReverse, node, true);
  32103. if (closestTabbable) {
  32104. Object(external_wp_dom_["placeCaretAtVerticalEdge"])(closestTabbable, isReverse, verticalRect);
  32105. event.preventDefault();
  32106. }
  32107. } else if (isHorizontal && defaultView.getSelection().isCollapsed && Object(external_wp_dom_["isHorizontalEdge"])(target, isReverseDir) && !keepCaretInsideBlock) {
  32108. const closestTabbable = getClosestTabbable(target, isReverseDir, node);
  32109. Object(external_wp_dom_["placeCaretAtHorizontalEdge"])(closestTabbable, isReverse);
  32110. event.preventDefault();
  32111. }
  32112. }
  32113. node.addEventListener('mousedown', onMouseDown);
  32114. node.addEventListener('keydown', onKeyDown);
  32115. return () => {
  32116. node.removeEventListener('mousedown', onMouseDown);
  32117. node.removeEventListener('keydown', onKeyDown);
  32118. };
  32119. }, []);
  32120. }
  32121. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-select-all.js
  32122. /**
  32123. * External dependencies
  32124. */
  32125. /**
  32126. * WordPress dependencies
  32127. */
  32128. /**
  32129. * Internal dependencies
  32130. */
  32131. function useSelectAll() {
  32132. const {
  32133. getBlockOrder,
  32134. getSelectedBlockClientIds,
  32135. getBlockRootClientId
  32136. } = Object(external_wp_data_["useSelect"])(store);
  32137. const {
  32138. multiSelect
  32139. } = Object(external_wp_data_["useDispatch"])(store);
  32140. const isMatch = Object(external_wp_keyboardShortcuts_["__unstableUseShortcutEventMatch"])();
  32141. return Object(external_wp_compose_["useRefEffect"])(node => {
  32142. function onKeyDown(event) {
  32143. if (!isMatch('core/block-editor/select-all', event)) {
  32144. return;
  32145. }
  32146. if (!Object(external_wp_dom_["isEntirelySelected"])(event.target)) {
  32147. return;
  32148. }
  32149. const selectedClientIds = getSelectedBlockClientIds();
  32150. const [firstSelectedClientId] = selectedClientIds;
  32151. const rootClientId = getBlockRootClientId(firstSelectedClientId);
  32152. let blockClientIds = getBlockOrder(rootClientId); // If we have selected all sibling nested blocks, try selecting up a
  32153. // level. See: https://github.com/WordPress/gutenberg/pull/31859/
  32154. if (selectedClientIds.length === blockClientIds.length) {
  32155. blockClientIds = getBlockOrder(getBlockRootClientId(rootClientId));
  32156. }
  32157. const firstClientId = Object(external_lodash_["first"])(blockClientIds);
  32158. const lastClientId = Object(external_lodash_["last"])(blockClientIds);
  32159. if (firstClientId === lastClientId) {
  32160. return;
  32161. }
  32162. multiSelect(firstClientId, lastClientId);
  32163. event.preventDefault();
  32164. }
  32165. node.addEventListener('keydown', onKeyDown);
  32166. return () => {
  32167. node.removeEventListener('keydown', onKeyDown);
  32168. };
  32169. });
  32170. }
  32171. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/index.js
  32172. /**
  32173. * External dependencies
  32174. */
  32175. /**
  32176. * WordPress dependencies
  32177. */
  32178. /**
  32179. * Internal dependencies
  32180. */
  32181. function WritingFlow({
  32182. children,
  32183. ...props
  32184. }, forwardedRef) {
  32185. const [before, ref, after] = useTabNav();
  32186. const hasMultiSelection = Object(external_wp_data_["useSelect"])(select => select(store).hasMultiSelection(), []);
  32187. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, before, Object(external_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({}, props, {
  32188. ref: Object(external_wp_compose_["useMergeRefs"])([forwardedRef, ref, use_multi_selection_useMultiSelection(), useSelectAll(), useArrowNav()]),
  32189. className: classnames_default()(props.className, 'block-editor-writing-flow'),
  32190. tabIndex: -1,
  32191. "aria-label": hasMultiSelection ? Object(external_wp_i18n_["__"])('Multiple selected blocks') : undefined
  32192. }), children), after);
  32193. }
  32194. /**
  32195. * Handles selection and navigation across blocks. This component should be
  32196. * wrapped around BlockList.
  32197. *
  32198. * @param {Object} props Component properties.
  32199. * @param {WPElement} props.children Children to be rendered.
  32200. */
  32201. /* harmony default export */ var writing_flow = (Object(external_wp_element_["forwardRef"])(WritingFlow));
  32202. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-canvas-click-redirect/index.js
  32203. /**
  32204. * External dependencies
  32205. */
  32206. /**
  32207. * WordPress dependencies
  32208. */
  32209. /**
  32210. * Given an element, returns true if the element is a tabbable text field, or
  32211. * false otherwise.
  32212. *
  32213. * @param {Element} element Element to test.
  32214. *
  32215. * @return {boolean} Whether element is a tabbable text field.
  32216. */
  32217. const isTabbableTextField = Object(external_lodash_["overEvery"])([external_wp_dom_["isTextField"], external_wp_dom_["focus"].tabbable.isTabbableIndex]);
  32218. function useCanvasClickRedirect() {
  32219. return Object(external_wp_compose_["useRefEffect"])(node => {
  32220. function onMouseDown(event) {
  32221. // Only handle clicks on the canvas, not the content.
  32222. if (event.target !== node) {
  32223. return;
  32224. }
  32225. const focusableNodes = external_wp_dom_["focus"].focusable.find(node);
  32226. const target = Object(external_lodash_["findLast"])(focusableNodes, isTabbableTextField);
  32227. if (!target) {
  32228. return;
  32229. }
  32230. const {
  32231. bottom
  32232. } = target.getBoundingClientRect(); // Ensure the click is below the last block.
  32233. if (event.clientY < bottom) {
  32234. return;
  32235. }
  32236. Object(external_wp_dom_["placeCaretAtHorizontalEdge"])(target, true);
  32237. event.preventDefault();
  32238. }
  32239. node.addEventListener('mousedown', onMouseDown);
  32240. return () => {
  32241. node.addEventListener('mousedown', onMouseDown);
  32242. };
  32243. }, []);
  32244. }
  32245. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/iframe/index.js
  32246. /**
  32247. * WordPress dependencies
  32248. */
  32249. /**
  32250. * Internal dependencies
  32251. */
  32252. const BODY_CLASS_NAME = 'editor-styles-wrapper';
  32253. const BLOCK_PREFIX = 'wp-block';
  32254. /**
  32255. * Clones stylesheets targetting the editor canvas to the given document. A
  32256. * stylesheet is considered targetting the editor a canvas if it contains the
  32257. * `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors.
  32258. *
  32259. * Ideally, this hook should be removed in the future and styles should be added
  32260. * explicitly as editor styles.
  32261. *
  32262. * @param {Document} doc The document to append cloned stylesheets to.
  32263. */
  32264. function styleSheetsCompat(doc) {
  32265. // Search the document for stylesheets targetting the editor canvas.
  32266. Array.from(document.styleSheets).forEach(styleSheet => {
  32267. try {
  32268. // May fail for external styles.
  32269. // eslint-disable-next-line no-unused-expressions
  32270. styleSheet.cssRules;
  32271. } catch (e) {
  32272. return;
  32273. }
  32274. const {
  32275. ownerNode,
  32276. cssRules
  32277. } = styleSheet;
  32278. if (!cssRules) {
  32279. return;
  32280. } // Generally, ignore inline styles. We add inline styles belonging to a
  32281. // stylesheet later, which may or may not match the selectors.
  32282. if (ownerNode.tagName !== 'LINK') {
  32283. return;
  32284. } // Don't try to add the reset styles, which were removed as a dependency
  32285. // from `edit-blocks` for the iframe since we don't need to reset admin
  32286. // styles.
  32287. if (ownerNode.id === 'wp-reset-editor-styles-css') {
  32288. return;
  32289. }
  32290. const isMatch = Array.from(cssRules).find(({
  32291. selectorText
  32292. }) => selectorText && (selectorText.includes(`.${BODY_CLASS_NAME}`) || selectorText.includes(`.${BLOCK_PREFIX}`)));
  32293. if (isMatch && !doc.getElementById(ownerNode.id)) {
  32294. // eslint-disable-next-line no-console
  32295. console.error(`Stylesheet ${ownerNode.id} was not properly added.
  32296. For blocks, use the block API's style (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#style) or editorStyle (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#editor-style).
  32297. For themes, use add_editor_style (https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#editor-styles).`, ownerNode.outerHTML);
  32298. doc.head.appendChild(ownerNode.cloneNode(true)); // Add inline styles belonging to the stylesheet.
  32299. const inlineCssId = ownerNode.id.replace('-css', '-inline-css');
  32300. const inlineCssElement = document.getElementById(inlineCssId);
  32301. if (inlineCssElement) {
  32302. doc.head.appendChild(inlineCssElement.cloneNode(true));
  32303. }
  32304. }
  32305. });
  32306. }
  32307. /**
  32308. * Bubbles some event types (keydown, keypress, and dragover) to parent document
  32309. * document to ensure that the keyboard shortcuts and drag and drop work.
  32310. *
  32311. * Ideally, we should remove event bubbling in the future. Keyboard shortcuts
  32312. * should be context dependent, e.g. actions on blocks like Cmd+A should not
  32313. * work globally outside the block editor.
  32314. *
  32315. * @param {Document} doc Document to attach listeners to.
  32316. */
  32317. function bubbleEvents(doc) {
  32318. const {
  32319. defaultView
  32320. } = doc;
  32321. const {
  32322. frameElement
  32323. } = defaultView;
  32324. function bubbleEvent(event) {
  32325. const prototype = Object.getPrototypeOf(event);
  32326. const constructorName = prototype.constructor.name;
  32327. const Constructor = window[constructorName];
  32328. const init = {};
  32329. for (const key in event) {
  32330. init[key] = event[key];
  32331. }
  32332. if (event instanceof defaultView.MouseEvent) {
  32333. const rect = frameElement.getBoundingClientRect();
  32334. init.clientX += rect.left;
  32335. init.clientY += rect.top;
  32336. }
  32337. const newEvent = new Constructor(event.type, init);
  32338. const cancelled = !frameElement.dispatchEvent(newEvent);
  32339. if (cancelled) {
  32340. event.preventDefault();
  32341. }
  32342. }
  32343. const eventTypes = ['keydown', 'keypress', 'dragover'];
  32344. for (const name of eventTypes) {
  32345. doc.addEventListener(name, bubbleEvent);
  32346. }
  32347. }
  32348. /**
  32349. * Sets the document direction.
  32350. *
  32351. * Sets the `editor-styles-wrapper` class name on the body.
  32352. *
  32353. * Copies the `admin-color-*` class name to the body so that the admin color
  32354. * scheme applies to components in the iframe.
  32355. *
  32356. * @param {Document} doc Document to add class name to.
  32357. */
  32358. function setBodyClassName(doc) {
  32359. doc.dir = document.dir;
  32360. doc.body.className = BODY_CLASS_NAME;
  32361. for (const name of document.body.classList) {
  32362. if (name.startsWith('admin-color-')) {
  32363. doc.body.classList.add(name);
  32364. } else if (name === 'wp-embed-responsive') {
  32365. // Ideally ALL classes that are added through get_body_class should
  32366. // be added in the editor too, which we'll somehow have to get from
  32367. // the server in the future (which will run the PHP filters).
  32368. doc.body.classList.add('wp-embed-responsive');
  32369. }
  32370. }
  32371. }
  32372. function useParsedAssets(html) {
  32373. return Object(external_wp_element_["useMemo"])(() => {
  32374. const doc = document.implementation.createHTMLDocument('');
  32375. doc.body.innerHTML = html;
  32376. return Array.from(doc.body.children);
  32377. }, [html]);
  32378. }
  32379. async function loadScript(doc, {
  32380. id,
  32381. src
  32382. }) {
  32383. return new Promise((resolve, reject) => {
  32384. const script = doc.createElement('script');
  32385. script.id = id;
  32386. if (src) {
  32387. script.src = src;
  32388. script.onload = () => resolve();
  32389. script.onerror = () => reject();
  32390. } else {
  32391. resolve();
  32392. }
  32393. doc.head.appendChild(script);
  32394. });
  32395. }
  32396. function Iframe({
  32397. contentRef,
  32398. children,
  32399. head,
  32400. ...props
  32401. }, ref) {
  32402. const [, forceRender] = Object(external_wp_element_["useReducer"])(() => ({}));
  32403. const [iframeDocument, setIframeDocument] = Object(external_wp_element_["useState"])();
  32404. const styles = useParsedAssets(window.__editorAssets.styles);
  32405. const scripts = useParsedAssets(window.__editorAssets.scripts);
  32406. const clearerRef = useBlockSelectionClearer();
  32407. const setRef = Object(external_wp_element_["useCallback"])(node => {
  32408. if (!node) {
  32409. return;
  32410. }
  32411. function setDocumentIfReady() {
  32412. const {
  32413. contentDocument
  32414. } = node;
  32415. const {
  32416. readyState,
  32417. body,
  32418. documentElement
  32419. } = contentDocument;
  32420. if (readyState !== 'interactive' && readyState !== 'complete') {
  32421. return false;
  32422. }
  32423. if (typeof contentRef === 'function') {
  32424. contentRef(body);
  32425. } else if (contentRef) {
  32426. contentRef.current = body;
  32427. }
  32428. setBodyClassName(contentDocument);
  32429. bubbleEvents(contentDocument);
  32430. setBodyClassName(contentDocument);
  32431. setIframeDocument(contentDocument);
  32432. clearerRef(documentElement);
  32433. clearerRef(body);
  32434. scripts.reduce((promise, script) => promise.then(() => loadScript(contentDocument, script)), Promise.resolve()).finally(() => {
  32435. // When script are loaded, re-render blocks to allow them
  32436. // to initialise.
  32437. forceRender();
  32438. });
  32439. return true;
  32440. }
  32441. if (setDocumentIfReady()) {
  32442. return;
  32443. } // Document is not immediately loaded in Firefox.
  32444. node.addEventListener('load', () => {
  32445. setDocumentIfReady();
  32446. });
  32447. }, []);
  32448. Object(external_wp_element_["useEffect"])(() => {
  32449. if (iframeDocument) {
  32450. styleSheetsCompat(iframeDocument);
  32451. }
  32452. }, [iframeDocument]);
  32453. head = Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])("style", null, 'body{margin:0}'), styles.map(({
  32454. tagName,
  32455. href,
  32456. id,
  32457. rel,
  32458. media,
  32459. textContent
  32460. }) => {
  32461. const TagName = tagName.toLowerCase();
  32462. if (TagName === 'style') {
  32463. return Object(external_wp_element_["createElement"])(TagName, {
  32464. id,
  32465. key: id
  32466. }, textContent);
  32467. }
  32468. return Object(external_wp_element_["createElement"])(TagName, {
  32469. href,
  32470. id,
  32471. rel,
  32472. media,
  32473. key: id
  32474. });
  32475. }), head);
  32476. return Object(external_wp_element_["createElement"])("iframe", Object(esm_extends["a" /* default */])({}, props, {
  32477. ref: Object(external_wp_compose_["useMergeRefs"])([ref, setRef]),
  32478. tabIndex: "0",
  32479. title: Object(external_wp_i18n_["__"])('Editor canvas'),
  32480. name: "editor-canvas"
  32481. }), iframeDocument && Object(external_wp_element_["createPortal"])(Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalStyleProvider"], {
  32482. document: iframeDocument
  32483. }, children), iframeDocument.body), iframeDocument && Object(external_wp_element_["createPortal"])(head, iframeDocument.head));
  32484. }
  32485. /* harmony default export */ var iframe = (Object(external_wp_element_["forwardRef"])(Iframe));
  32486. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-no-recursive-renders/index.js
  32487. /**
  32488. * WordPress dependencies
  32489. */
  32490. /**
  32491. * Internal dependencies
  32492. */
  32493. const RenderedRefsContext = Object(external_wp_element_["createContext"])({});
  32494. /**
  32495. * Immutably adds an unique identifier to a set scoped for a given block type.
  32496. *
  32497. * @param {Object} renderedBlocks Rendered blocks grouped by block name
  32498. * @param {string} blockName Name of the block.
  32499. * @param {*} uniqueId Any value that acts as a unique identifier for a block instance.
  32500. *
  32501. * @return {Object} The list of rendered blocks grouped by block name.
  32502. */
  32503. function addToBlockType(renderedBlocks, blockName, uniqueId) {
  32504. const result = { ...renderedBlocks,
  32505. [blockName]: renderedBlocks[blockName] ? new Set(renderedBlocks[blockName]) : new Set()
  32506. };
  32507. result[blockName].add(uniqueId);
  32508. return result;
  32509. }
  32510. /**
  32511. * A React hook for keeping track of blocks previously rendered up in the block
  32512. * tree. Blocks susceptible to recursion can use this hook in their `Edit`
  32513. * function to prevent said recursion.
  32514. *
  32515. * @param {*} uniqueId Any value that acts as a unique identifier for a block instance.
  32516. * @param {string} blockName Optional block name.
  32517. *
  32518. * @return {[boolean, Function]} A tuple of:
  32519. * - a boolean describing whether the provided id
  32520. * has already been rendered;
  32521. * - a React context provider to be used to wrap
  32522. * other elements.
  32523. */
  32524. function useNoRecursiveRenders(uniqueId, blockName = '') {
  32525. var _previouslyRenderedBl;
  32526. const previouslyRenderedBlocks = Object(external_wp_element_["useContext"])(RenderedRefsContext);
  32527. const {
  32528. name
  32529. } = useBlockEditContext();
  32530. blockName = blockName || name;
  32531. const hasAlreadyRendered = Boolean((_previouslyRenderedBl = previouslyRenderedBlocks[blockName]) === null || _previouslyRenderedBl === void 0 ? void 0 : _previouslyRenderedBl.has(uniqueId));
  32532. const newRenderedBlocks = Object(external_wp_element_["useMemo"])(() => addToBlockType(previouslyRenderedBlocks, blockName, uniqueId), [previouslyRenderedBlocks, blockName, uniqueId]);
  32533. const Provider = Object(external_wp_element_["useCallback"])(({
  32534. children
  32535. }) => Object(external_wp_element_["createElement"])(RenderedRefsContext.Provider, {
  32536. value: newRenderedBlocks
  32537. }, children), [newRenderedBlocks]);
  32538. return [hasAlreadyRendered, Provider];
  32539. }
  32540. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/index.js
  32541. /*
  32542. * Block Creation Components
  32543. */
  32544. /*
  32545. * Content Related Components
  32546. */
  32547. /*
  32548. * State Related Components
  32549. */
  32550. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/theme.js
  32551. /**
  32552. * Internal dependencies
  32553. */
  32554. /**
  32555. * Given an array of theme colors checks colors for validity
  32556. *
  32557. * @param {Array} colors The array of theme colors
  32558. *
  32559. * @return {Array} The array of valid theme colors or the default colors
  32560. */
  32561. function validateThemeColors(colors) {
  32562. if (colors === undefined) {
  32563. colors = SETTINGS_DEFAULTS.colors;
  32564. } else {
  32565. const validColors = colors.filter(c => c.color);
  32566. if (validColors.length === 0) {
  32567. colors = SETTINGS_DEFAULTS.colors;
  32568. } else if (validColors.length < colors.length) {
  32569. // Filter out invalid colors
  32570. colors = validColors;
  32571. }
  32572. }
  32573. return colors;
  32574. }
  32575. /**
  32576. * Given an array of theme gradients checks gradients for validity
  32577. *
  32578. * @param {Array} gradients The array of theme gradients
  32579. *
  32580. * @return {Array} The array of valid theme gradients or the default gradients
  32581. */
  32582. function validateThemeGradients(gradients) {
  32583. if (gradients === undefined) {
  32584. gradients = SETTINGS_DEFAULTS.gradients;
  32585. } else {
  32586. const validGradients = gradients.filter(c => c.gradient);
  32587. if (validGradients.length === 0) {
  32588. gradients = SETTINGS_DEFAULTS.gradients;
  32589. } else if (validGradients.length < gradients.length) {
  32590. // Filter out invalid gradients
  32591. gradients = validGradients;
  32592. }
  32593. }
  32594. return gradients;
  32595. }
  32596. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/index.js
  32597. // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/index.js
  32598. /**
  32599. * WordPress dependencies
  32600. */
  32601. /**
  32602. * Internal dependencies
  32603. */
  32604. /***/ }),
  32605. /***/ "w95h":
  32606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  32607. "use strict";
  32608. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  32609. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  32610. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  32611. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  32612. /**
  32613. * WordPress dependencies
  32614. */
  32615. const close = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  32616. xmlns: "http://www.w3.org/2000/svg",
  32617. viewBox: "0 0 24 24"
  32618. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  32619. d: "M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"
  32620. }));
  32621. /* harmony default export */ __webpack_exports__["a"] = (close);
  32622. /***/ }),
  32623. /***/ "wx14":
  32624. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  32625. "use strict";
  32626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; });
  32627. function _extends() {
  32628. _extends = Object.assign || function (target) {
  32629. for (var i = 1; i < arguments.length; i++) {
  32630. var source = arguments[i];
  32631. for (var key in source) {
  32632. if (Object.prototype.hasOwnProperty.call(source, key)) {
  32633. target[key] = source[key];
  32634. }
  32635. }
  32636. }
  32637. return target;
  32638. };
  32639. return _extends.apply(this, arguments);
  32640. }
  32641. /***/ }),
  32642. /***/ "xTGt":
  32643. /***/ (function(module, exports) {
  32644. (function() { module.exports = window["wp"]["blob"]; }());
  32645. /***/ }),
  32646. /***/ "ziDm":
  32647. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  32648. "use strict";
  32649. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  32650. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  32651. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  32652. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  32653. /**
  32654. * WordPress dependencies
  32655. */
  32656. const alignRight = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  32657. xmlns: "http://www.w3.org/2000/svg",
  32658. viewBox: "0 0 24 24"
  32659. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  32660. d: "M11.1 19.8H20v-1.5h-8.9v1.5zm0-15.6v1.5H20V4.2h-8.9zM4 12.8h16v-1.5H4v1.5z"
  32661. }));
  32662. /* harmony default export */ __webpack_exports__["a"] = (alignRight);
  32663. /***/ }),
  32664. /***/ "zt9T":
  32665. /***/ (function(module, exports, __webpack_require__) {
  32666. "use strict";
  32667. var util = __webpack_require__("jB5C");
  32668. function scrollIntoView(elem, container, config) {
  32669. config = config || {};
  32670. // document 归一化到 window
  32671. if (container.nodeType === 9) {
  32672. container = util.getWindow(container);
  32673. }
  32674. var allowHorizontalScroll = config.allowHorizontalScroll;
  32675. var onlyScrollIfNeeded = config.onlyScrollIfNeeded;
  32676. var alignWithTop = config.alignWithTop;
  32677. var alignWithLeft = config.alignWithLeft;
  32678. var offsetTop = config.offsetTop || 0;
  32679. var offsetLeft = config.offsetLeft || 0;
  32680. var offsetBottom = config.offsetBottom || 0;
  32681. var offsetRight = config.offsetRight || 0;
  32682. allowHorizontalScroll = allowHorizontalScroll === undefined ? true : allowHorizontalScroll;
  32683. var isWin = util.isWindow(container);
  32684. var elemOffset = util.offset(elem);
  32685. var eh = util.outerHeight(elem);
  32686. var ew = util.outerWidth(elem);
  32687. var containerOffset = undefined;
  32688. var ch = undefined;
  32689. var cw = undefined;
  32690. var containerScroll = undefined;
  32691. var diffTop = undefined;
  32692. var diffBottom = undefined;
  32693. var win = undefined;
  32694. var winScroll = undefined;
  32695. var ww = undefined;
  32696. var wh = undefined;
  32697. if (isWin) {
  32698. win = container;
  32699. wh = util.height(win);
  32700. ww = util.width(win);
  32701. winScroll = {
  32702. left: util.scrollLeft(win),
  32703. top: util.scrollTop(win)
  32704. };
  32705. // elem 相对 container 可视视窗的距离
  32706. diffTop = {
  32707. left: elemOffset.left - winScroll.left - offsetLeft,
  32708. top: elemOffset.top - winScroll.top - offsetTop
  32709. };
  32710. diffBottom = {
  32711. left: elemOffset.left + ew - (winScroll.left + ww) + offsetRight,
  32712. top: elemOffset.top + eh - (winScroll.top + wh) + offsetBottom
  32713. };
  32714. containerScroll = winScroll;
  32715. } else {
  32716. containerOffset = util.offset(container);
  32717. ch = container.clientHeight;
  32718. cw = container.clientWidth;
  32719. containerScroll = {
  32720. left: container.scrollLeft,
  32721. top: container.scrollTop
  32722. };
  32723. // elem 相对 container 可视视窗的距离
  32724. // 注意边框, offset 是边框到根节点
  32725. diffTop = {
  32726. left: elemOffset.left - (containerOffset.left + (parseFloat(util.css(container, 'borderLeftWidth')) || 0)) - offsetLeft,
  32727. top: elemOffset.top - (containerOffset.top + (parseFloat(util.css(container, 'borderTopWidth')) || 0)) - offsetTop
  32728. };
  32729. diffBottom = {
  32730. left: elemOffset.left + ew - (containerOffset.left + cw + (parseFloat(util.css(container, 'borderRightWidth')) || 0)) + offsetRight,
  32731. top: elemOffset.top + eh - (containerOffset.top + ch + (parseFloat(util.css(container, 'borderBottomWidth')) || 0)) + offsetBottom
  32732. };
  32733. }
  32734. if (diffTop.top < 0 || diffBottom.top > 0) {
  32735. // 强制向上
  32736. if (alignWithTop === true) {
  32737. util.scrollTop(container, containerScroll.top + diffTop.top);
  32738. } else if (alignWithTop === false) {
  32739. util.scrollTop(container, containerScroll.top + diffBottom.top);
  32740. } else {
  32741. // 自动调整
  32742. if (diffTop.top < 0) {
  32743. util.scrollTop(container, containerScroll.top + diffTop.top);
  32744. } else {
  32745. util.scrollTop(container, containerScroll.top + diffBottom.top);
  32746. }
  32747. }
  32748. } else {
  32749. if (!onlyScrollIfNeeded) {
  32750. alignWithTop = alignWithTop === undefined ? true : !!alignWithTop;
  32751. if (alignWithTop) {
  32752. util.scrollTop(container, containerScroll.top + diffTop.top);
  32753. } else {
  32754. util.scrollTop(container, containerScroll.top + diffBottom.top);
  32755. }
  32756. }
  32757. }
  32758. if (allowHorizontalScroll) {
  32759. if (diffTop.left < 0 || diffBottom.left > 0) {
  32760. // 强制向上
  32761. if (alignWithLeft === true) {
  32762. util.scrollLeft(container, containerScroll.left + diffTop.left);
  32763. } else if (alignWithLeft === false) {
  32764. util.scrollLeft(container, containerScroll.left + diffBottom.left);
  32765. } else {
  32766. // 自动调整
  32767. if (diffTop.left < 0) {
  32768. util.scrollLeft(container, containerScroll.left + diffTop.left);
  32769. } else {
  32770. util.scrollLeft(container, containerScroll.left + diffBottom.left);
  32771. }
  32772. }
  32773. } else {
  32774. if (!onlyScrollIfNeeded) {
  32775. alignWithLeft = alignWithLeft === undefined ? true : !!alignWithLeft;
  32776. if (alignWithLeft) {
  32777. util.scrollLeft(container, containerScroll.left + diffTop.left);
  32778. } else {
  32779. util.scrollLeft(container, containerScroll.left + diffBottom.left);
  32780. }
  32781. }
  32782. }
  32783. }
  32784. }
  32785. module.exports = scrollIntoView;
  32786. /***/ })
  32787. /******/ });