Нема описа

data.js 148KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619
  1. /******/ (function() { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ 2167:
  4. /***/ (function(module) {
  5. "use strict";
  6. function _typeof(obj) {
  7. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  8. _typeof = function (obj) {
  9. return typeof obj;
  10. };
  11. } else {
  12. _typeof = function (obj) {
  13. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  14. };
  15. }
  16. return _typeof(obj);
  17. }
  18. function _classCallCheck(instance, Constructor) {
  19. if (!(instance instanceof Constructor)) {
  20. throw new TypeError("Cannot call a class as a function");
  21. }
  22. }
  23. function _defineProperties(target, props) {
  24. for (var i = 0; i < props.length; i++) {
  25. var descriptor = props[i];
  26. descriptor.enumerable = descriptor.enumerable || false;
  27. descriptor.configurable = true;
  28. if ("value" in descriptor) descriptor.writable = true;
  29. Object.defineProperty(target, descriptor.key, descriptor);
  30. }
  31. }
  32. function _createClass(Constructor, protoProps, staticProps) {
  33. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  34. if (staticProps) _defineProperties(Constructor, staticProps);
  35. return Constructor;
  36. }
  37. /**
  38. * Given an instance of EquivalentKeyMap, returns its internal value pair tuple
  39. * for a key, if one exists. The tuple members consist of the last reference
  40. * value for the key (used in efficient subsequent lookups) and the value
  41. * assigned for the key at the leaf node.
  42. *
  43. * @param {EquivalentKeyMap} instance EquivalentKeyMap instance.
  44. * @param {*} key The key for which to return value pair.
  45. *
  46. * @return {?Array} Value pair, if exists.
  47. */
  48. function getValuePair(instance, key) {
  49. var _map = instance._map,
  50. _arrayTreeMap = instance._arrayTreeMap,
  51. _objectTreeMap = instance._objectTreeMap; // Map keeps a reference to the last object-like key used to set the
  52. // value, which can be used to shortcut immediately to the value.
  53. if (_map.has(key)) {
  54. return _map.get(key);
  55. } // Sort keys to ensure stable retrieval from tree.
  56. var properties = Object.keys(key).sort(); // Tree by type to avoid conflicts on numeric object keys, empty value.
  57. var map = Array.isArray(key) ? _arrayTreeMap : _objectTreeMap;
  58. for (var i = 0; i < properties.length; i++) {
  59. var property = properties[i];
  60. map = map.get(property);
  61. if (map === undefined) {
  62. return;
  63. }
  64. var propertyValue = key[property];
  65. map = map.get(propertyValue);
  66. if (map === undefined) {
  67. return;
  68. }
  69. }
  70. var valuePair = map.get('_ekm_value');
  71. if (!valuePair) {
  72. return;
  73. } // If reached, it implies that an object-like key was set with another
  74. // reference, so delete the reference and replace with the current.
  75. _map.delete(valuePair[0]);
  76. valuePair[0] = key;
  77. map.set('_ekm_value', valuePair);
  78. _map.set(key, valuePair);
  79. return valuePair;
  80. }
  81. /**
  82. * Variant of a Map object which enables lookup by equivalent (deeply equal)
  83. * object and array keys.
  84. */
  85. var EquivalentKeyMap =
  86. /*#__PURE__*/
  87. function () {
  88. /**
  89. * Constructs a new instance of EquivalentKeyMap.
  90. *
  91. * @param {Iterable.<*>} iterable Initial pair of key, value for map.
  92. */
  93. function EquivalentKeyMap(iterable) {
  94. _classCallCheck(this, EquivalentKeyMap);
  95. this.clear();
  96. if (iterable instanceof EquivalentKeyMap) {
  97. // Map#forEach is only means of iterating with support for IE11.
  98. var iterablePairs = [];
  99. iterable.forEach(function (value, key) {
  100. iterablePairs.push([key, value]);
  101. });
  102. iterable = iterablePairs;
  103. }
  104. if (iterable != null) {
  105. for (var i = 0; i < iterable.length; i++) {
  106. this.set(iterable[i][0], iterable[i][1]);
  107. }
  108. }
  109. }
  110. /**
  111. * Accessor property returning the number of elements.
  112. *
  113. * @return {number} Number of elements.
  114. */
  115. _createClass(EquivalentKeyMap, [{
  116. key: "set",
  117. /**
  118. * Add or update an element with a specified key and value.
  119. *
  120. * @param {*} key The key of the element to add.
  121. * @param {*} value The value of the element to add.
  122. *
  123. * @return {EquivalentKeyMap} Map instance.
  124. */
  125. value: function set(key, value) {
  126. // Shortcut non-object-like to set on internal Map.
  127. if (key === null || _typeof(key) !== 'object') {
  128. this._map.set(key, value);
  129. return this;
  130. } // Sort keys to ensure stable assignment into tree.
  131. var properties = Object.keys(key).sort();
  132. var valuePair = [key, value]; // Tree by type to avoid conflicts on numeric object keys, empty value.
  133. var map = Array.isArray(key) ? this._arrayTreeMap : this._objectTreeMap;
  134. for (var i = 0; i < properties.length; i++) {
  135. var property = properties[i];
  136. if (!map.has(property)) {
  137. map.set(property, new EquivalentKeyMap());
  138. }
  139. map = map.get(property);
  140. var propertyValue = key[property];
  141. if (!map.has(propertyValue)) {
  142. map.set(propertyValue, new EquivalentKeyMap());
  143. }
  144. map = map.get(propertyValue);
  145. } // If an _ekm_value exists, there was already an equivalent key. Before
  146. // overriding, ensure that the old key reference is removed from map to
  147. // avoid memory leak of accumulating equivalent keys. This is, in a
  148. // sense, a poor man's WeakMap, while still enabling iterability.
  149. var previousValuePair = map.get('_ekm_value');
  150. if (previousValuePair) {
  151. this._map.delete(previousValuePair[0]);
  152. }
  153. map.set('_ekm_value', valuePair);
  154. this._map.set(key, valuePair);
  155. return this;
  156. }
  157. /**
  158. * Returns a specified element.
  159. *
  160. * @param {*} key The key of the element to return.
  161. *
  162. * @return {?*} The element associated with the specified key or undefined
  163. * if the key can't be found.
  164. */
  165. }, {
  166. key: "get",
  167. value: function get(key) {
  168. // Shortcut non-object-like to get from internal Map.
  169. if (key === null || _typeof(key) !== 'object') {
  170. return this._map.get(key);
  171. }
  172. var valuePair = getValuePair(this, key);
  173. if (valuePair) {
  174. return valuePair[1];
  175. }
  176. }
  177. /**
  178. * Returns a boolean indicating whether an element with the specified key
  179. * exists or not.
  180. *
  181. * @param {*} key The key of the element to test for presence.
  182. *
  183. * @return {boolean} Whether an element with the specified key exists.
  184. */
  185. }, {
  186. key: "has",
  187. value: function has(key) {
  188. if (key === null || _typeof(key) !== 'object') {
  189. return this._map.has(key);
  190. } // Test on the _presence_ of the pair, not its value, as even undefined
  191. // can be a valid member value for a key.
  192. return getValuePair(this, key) !== undefined;
  193. }
  194. /**
  195. * Removes the specified element.
  196. *
  197. * @param {*} key The key of the element to remove.
  198. *
  199. * @return {boolean} Returns true if an element existed and has been
  200. * removed, or false if the element does not exist.
  201. */
  202. }, {
  203. key: "delete",
  204. value: function _delete(key) {
  205. if (!this.has(key)) {
  206. return false;
  207. } // This naive implementation will leave orphaned child trees. A better
  208. // implementation should traverse and remove orphans.
  209. this.set(key, undefined);
  210. return true;
  211. }
  212. /**
  213. * Executes a provided function once per each key/value pair, in insertion
  214. * order.
  215. *
  216. * @param {Function} callback Function to execute for each element.
  217. * @param {*} thisArg Value to use as `this` when executing
  218. * `callback`.
  219. */
  220. }, {
  221. key: "forEach",
  222. value: function forEach(callback) {
  223. var _this = this;
  224. var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this;
  225. this._map.forEach(function (value, key) {
  226. // Unwrap value from object-like value pair.
  227. if (key !== null && _typeof(key) === 'object') {
  228. value = value[1];
  229. }
  230. callback.call(thisArg, value, key, _this);
  231. });
  232. }
  233. /**
  234. * Removes all elements.
  235. */
  236. }, {
  237. key: "clear",
  238. value: function clear() {
  239. this._map = new Map();
  240. this._arrayTreeMap = new Map();
  241. this._objectTreeMap = new Map();
  242. }
  243. }, {
  244. key: "size",
  245. get: function get() {
  246. return this._map.size;
  247. }
  248. }]);
  249. return EquivalentKeyMap;
  250. }();
  251. module.exports = EquivalentKeyMap;
  252. /***/ }),
  253. /***/ 9125:
  254. /***/ (function(module) {
  255. function combineReducers( reducers ) {
  256. var keys = Object.keys( reducers ),
  257. getNextState;
  258. getNextState = ( function() {
  259. var fn, i, key;
  260. fn = 'return {';
  261. for ( i = 0; i < keys.length; i++ ) {
  262. // Rely on Quoted escaping of JSON.stringify with guarantee that
  263. // each member of Object.keys is a string.
  264. //
  265. // "If Type(value) is String, then return the result of calling the
  266. // abstract operation Quote with argument value. [...] The abstract
  267. // operation Quote(value) wraps a String value in double quotes and
  268. // escapes characters within it."
  269. //
  270. // https://www.ecma-international.org/ecma-262/5.1/#sec-15.12.3
  271. key = JSON.stringify( keys[ i ] );
  272. fn += key + ':r[' + key + '](s[' + key + '],a),';
  273. }
  274. fn += '}';
  275. return new Function( 'r,s,a', fn );
  276. } )();
  277. return function combinedReducer( state, action ) {
  278. var nextState, i, key;
  279. // Assumed changed if initial state.
  280. if ( state === undefined ) {
  281. return getNextState( reducers, {}, action );
  282. }
  283. nextState = getNextState( reducers, state, action );
  284. // Determine whether state has changed.
  285. i = keys.length;
  286. while ( i-- ) {
  287. key = keys[ i ];
  288. if ( state[ key ] !== nextState[ key ] ) {
  289. // Return immediately if a changed value is encountered.
  290. return nextState;
  291. }
  292. }
  293. return state;
  294. };
  295. }
  296. module.exports = combineReducers;
  297. /***/ })
  298. /******/ });
  299. /************************************************************************/
  300. /******/ // The module cache
  301. /******/ var __webpack_module_cache__ = {};
  302. /******/
  303. /******/ // The require function
  304. /******/ function __webpack_require__(moduleId) {
  305. /******/ // Check if module is in cache
  306. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  307. /******/ if (cachedModule !== undefined) {
  308. /******/ return cachedModule.exports;
  309. /******/ }
  310. /******/ // Create a new module (and put it into the cache)
  311. /******/ var module = __webpack_module_cache__[moduleId] = {
  312. /******/ // no module.id needed
  313. /******/ // no module.loaded needed
  314. /******/ exports: {}
  315. /******/ };
  316. /******/
  317. /******/ // Execute the module function
  318. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  319. /******/
  320. /******/ // Return the exports of the module
  321. /******/ return module.exports;
  322. /******/ }
  323. /******/
  324. /************************************************************************/
  325. /******/ /* webpack/runtime/compat get default export */
  326. /******/ !function() {
  327. /******/ // getDefaultExport function for compatibility with non-harmony modules
  328. /******/ __webpack_require__.n = function(module) {
  329. /******/ var getter = module && module.__esModule ?
  330. /******/ function() { return module['default']; } :
  331. /******/ function() { return module; };
  332. /******/ __webpack_require__.d(getter, { a: getter });
  333. /******/ return getter;
  334. /******/ };
  335. /******/ }();
  336. /******/
  337. /******/ /* webpack/runtime/define property getters */
  338. /******/ !function() {
  339. /******/ // define getter functions for harmony exports
  340. /******/ __webpack_require__.d = function(exports, definition) {
  341. /******/ for(var key in definition) {
  342. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  343. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  344. /******/ }
  345. /******/ }
  346. /******/ };
  347. /******/ }();
  348. /******/
  349. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  350. /******/ !function() {
  351. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  352. /******/ }();
  353. /******/
  354. /******/ /* webpack/runtime/make namespace object */
  355. /******/ !function() {
  356. /******/ // define __esModule on exports
  357. /******/ __webpack_require__.r = function(exports) {
  358. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  359. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  360. /******/ }
  361. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  362. /******/ };
  363. /******/ }();
  364. /******/
  365. /************************************************************************/
  366. var __webpack_exports__ = {};
  367. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  368. !function() {
  369. "use strict";
  370. // ESM COMPAT FLAG
  371. __webpack_require__.r(__webpack_exports__);
  372. // EXPORTS
  373. __webpack_require__.d(__webpack_exports__, {
  374. "AsyncModeProvider": function() { return /* reexport */ async_mode_provider_context; },
  375. "RegistryConsumer": function() { return /* reexport */ RegistryConsumer; },
  376. "RegistryProvider": function() { return /* reexport */ context; },
  377. "combineReducers": function() { return /* reexport */ (turbo_combine_reducers_default()); },
  378. "controls": function() { return /* reexport */ controls; },
  379. "createReduxStore": function() { return /* reexport */ createReduxStore; },
  380. "createRegistry": function() { return /* reexport */ createRegistry; },
  381. "createRegistryControl": function() { return /* reexport */ createRegistryControl; },
  382. "createRegistrySelector": function() { return /* reexport */ createRegistrySelector; },
  383. "dispatch": function() { return /* binding */ build_module_dispatch; },
  384. "plugins": function() { return /* reexport */ plugins_namespaceObject; },
  385. "register": function() { return /* binding */ register; },
  386. "registerGenericStore": function() { return /* binding */ registerGenericStore; },
  387. "registerStore": function() { return /* binding */ registerStore; },
  388. "resolveSelect": function() { return /* binding */ build_module_resolveSelect; },
  389. "select": function() { return /* binding */ build_module_select; },
  390. "subscribe": function() { return /* binding */ subscribe; },
  391. "use": function() { return /* binding */ use; },
  392. "useDispatch": function() { return /* reexport */ use_dispatch; },
  393. "useRegistry": function() { return /* reexport */ useRegistry; },
  394. "useSelect": function() { return /* reexport */ useSelect; },
  395. "withDispatch": function() { return /* reexport */ with_dispatch; },
  396. "withRegistry": function() { return /* reexport */ with_registry; },
  397. "withSelect": function() { return /* reexport */ with_select; }
  398. });
  399. // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js
  400. var selectors_namespaceObject = {};
  401. __webpack_require__.r(selectors_namespaceObject);
  402. __webpack_require__.d(selectors_namespaceObject, {
  403. "getCachedResolvers": function() { return getCachedResolvers; },
  404. "getIsResolving": function() { return getIsResolving; },
  405. "getResolutionError": function() { return getResolutionError; },
  406. "getResolutionState": function() { return getResolutionState; },
  407. "hasFinishedResolution": function() { return hasFinishedResolution; },
  408. "hasResolutionFailed": function() { return hasResolutionFailed; },
  409. "hasStartedResolution": function() { return hasStartedResolution; },
  410. "isResolving": function() { return isResolving; }
  411. });
  412. // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js
  413. var actions_namespaceObject = {};
  414. __webpack_require__.r(actions_namespaceObject);
  415. __webpack_require__.d(actions_namespaceObject, {
  416. "failResolution": function() { return failResolution; },
  417. "failResolutions": function() { return failResolutions; },
  418. "finishResolution": function() { return finishResolution; },
  419. "finishResolutions": function() { return finishResolutions; },
  420. "invalidateResolution": function() { return invalidateResolution; },
  421. "invalidateResolutionForStore": function() { return invalidateResolutionForStore; },
  422. "invalidateResolutionForStoreSelector": function() { return invalidateResolutionForStoreSelector; },
  423. "startResolution": function() { return startResolution; },
  424. "startResolutions": function() { return startResolutions; }
  425. });
  426. // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/plugins/index.js
  427. var plugins_namespaceObject = {};
  428. __webpack_require__.r(plugins_namespaceObject);
  429. __webpack_require__.d(plugins_namespaceObject, {
  430. "persistence": function() { return persistence; }
  431. });
  432. // EXTERNAL MODULE: ./node_modules/turbo-combine-reducers/index.js
  433. var turbo_combine_reducers = __webpack_require__(9125);
  434. var turbo_combine_reducers_default = /*#__PURE__*/__webpack_require__.n(turbo_combine_reducers);
  435. ;// CONCATENATED MODULE: external "lodash"
  436. var external_lodash_namespaceObject = window["lodash"];
  437. ;// CONCATENATED MODULE: external ["wp","deprecated"]
  438. var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
  439. var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
  440. ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
  441. function _defineProperty(obj, key, value) {
  442. if (key in obj) {
  443. Object.defineProperty(obj, key, {
  444. value: value,
  445. enumerable: true,
  446. configurable: true,
  447. writable: true
  448. });
  449. } else {
  450. obj[key] = value;
  451. }
  452. return obj;
  453. }
  454. ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js
  455. function ownKeys(object, enumerableOnly) {
  456. var keys = Object.keys(object);
  457. if (Object.getOwnPropertySymbols) {
  458. var symbols = Object.getOwnPropertySymbols(object);
  459. enumerableOnly && (symbols = symbols.filter(function (sym) {
  460. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  461. })), keys.push.apply(keys, symbols);
  462. }
  463. return keys;
  464. }
  465. function _objectSpread2(target) {
  466. for (var i = 1; i < arguments.length; i++) {
  467. var source = null != arguments[i] ? arguments[i] : {};
  468. i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
  469. _defineProperty(target, key, source[key]);
  470. }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
  471. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  472. });
  473. }
  474. return target;
  475. }
  476. ;// CONCATENATED MODULE: ./node_modules/redux/es/redux.js
  477. /**
  478. * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
  479. *
  480. * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
  481. * during build.
  482. * @param {number} code
  483. */
  484. function formatProdErrorMessage(code) {
  485. return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. ';
  486. }
  487. // Inlined version of the `symbol-observable` polyfill
  488. var $$observable = (function () {
  489. return typeof Symbol === 'function' && Symbol.observable || '@@observable';
  490. })();
  491. /**
  492. * These are private action types reserved by Redux.
  493. * For any unknown actions, you must return the current state.
  494. * If the current state is undefined, you must return the initial state.
  495. * Do not reference these action types directly in your code.
  496. */
  497. var randomString = function randomString() {
  498. return Math.random().toString(36).substring(7).split('').join('.');
  499. };
  500. var ActionTypes = {
  501. INIT: "@@redux/INIT" + randomString(),
  502. REPLACE: "@@redux/REPLACE" + randomString(),
  503. PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
  504. return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
  505. }
  506. };
  507. /**
  508. * @param {any} obj The object to inspect.
  509. * @returns {boolean} True if the argument appears to be a plain object.
  510. */
  511. function isPlainObject(obj) {
  512. if (typeof obj !== 'object' || obj === null) return false;
  513. var proto = obj;
  514. while (Object.getPrototypeOf(proto) !== null) {
  515. proto = Object.getPrototypeOf(proto);
  516. }
  517. return Object.getPrototypeOf(obj) === proto;
  518. }
  519. // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
  520. function miniKindOf(val) {
  521. if (val === void 0) return 'undefined';
  522. if (val === null) return 'null';
  523. var type = typeof val;
  524. switch (type) {
  525. case 'boolean':
  526. case 'string':
  527. case 'number':
  528. case 'symbol':
  529. case 'function':
  530. {
  531. return type;
  532. }
  533. }
  534. if (Array.isArray(val)) return 'array';
  535. if (isDate(val)) return 'date';
  536. if (isError(val)) return 'error';
  537. var constructorName = ctorName(val);
  538. switch (constructorName) {
  539. case 'Symbol':
  540. case 'Promise':
  541. case 'WeakMap':
  542. case 'WeakSet':
  543. case 'Map':
  544. case 'Set':
  545. return constructorName;
  546. } // other
  547. return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
  548. }
  549. function ctorName(val) {
  550. return typeof val.constructor === 'function' ? val.constructor.name : null;
  551. }
  552. function isError(val) {
  553. return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
  554. }
  555. function isDate(val) {
  556. if (val instanceof Date) return true;
  557. return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
  558. }
  559. function kindOf(val) {
  560. var typeOfVal = typeof val;
  561. if (false) {}
  562. return typeOfVal;
  563. }
  564. /**
  565. * @deprecated
  566. *
  567. * **We recommend using the `configureStore` method
  568. * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
  569. *
  570. * Redux Toolkit is our recommended approach for writing Redux logic today,
  571. * including store setup, reducers, data fetching, and more.
  572. *
  573. * **For more details, please read this Redux docs page:**
  574. * **https://redux.js.org/introduction/why-rtk-is-redux-today**
  575. *
  576. * `configureStore` from Redux Toolkit is an improved version of `createStore` that
  577. * simplifies setup and helps avoid common bugs.
  578. *
  579. * You should not be using the `redux` core package by itself today, except for learning purposes.
  580. * The `createStore` method from the core `redux` package will not be removed, but we encourage
  581. * all users to migrate to using Redux Toolkit for all Redux code.
  582. *
  583. * If you want to use `createStore` without this visual deprecation warning, use
  584. * the `legacy_createStore` import instead:
  585. *
  586. * `import { legacy_createStore as createStore} from 'redux'`
  587. *
  588. */
  589. function createStore(reducer, preloadedState, enhancer) {
  590. var _ref2;
  591. if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
  592. throw new Error( true ? formatProdErrorMessage(0) : 0);
  593. }
  594. if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
  595. enhancer = preloadedState;
  596. preloadedState = undefined;
  597. }
  598. if (typeof enhancer !== 'undefined') {
  599. if (typeof enhancer !== 'function') {
  600. throw new Error( true ? formatProdErrorMessage(1) : 0);
  601. }
  602. return enhancer(createStore)(reducer, preloadedState);
  603. }
  604. if (typeof reducer !== 'function') {
  605. throw new Error( true ? formatProdErrorMessage(2) : 0);
  606. }
  607. var currentReducer = reducer;
  608. var currentState = preloadedState;
  609. var currentListeners = [];
  610. var nextListeners = currentListeners;
  611. var isDispatching = false;
  612. /**
  613. * This makes a shallow copy of currentListeners so we can use
  614. * nextListeners as a temporary list while dispatching.
  615. *
  616. * This prevents any bugs around consumers calling
  617. * subscribe/unsubscribe in the middle of a dispatch.
  618. */
  619. function ensureCanMutateNextListeners() {
  620. if (nextListeners === currentListeners) {
  621. nextListeners = currentListeners.slice();
  622. }
  623. }
  624. /**
  625. * Reads the state tree managed by the store.
  626. *
  627. * @returns {any} The current state tree of your application.
  628. */
  629. function getState() {
  630. if (isDispatching) {
  631. throw new Error( true ? formatProdErrorMessage(3) : 0);
  632. }
  633. return currentState;
  634. }
  635. /**
  636. * Adds a change listener. It will be called any time an action is dispatched,
  637. * and some part of the state tree may potentially have changed. You may then
  638. * call `getState()` to read the current state tree inside the callback.
  639. *
  640. * You may call `dispatch()` from a change listener, with the following
  641. * caveats:
  642. *
  643. * 1. The subscriptions are snapshotted just before every `dispatch()` call.
  644. * If you subscribe or unsubscribe while the listeners are being invoked, this
  645. * will not have any effect on the `dispatch()` that is currently in progress.
  646. * However, the next `dispatch()` call, whether nested or not, will use a more
  647. * recent snapshot of the subscription list.
  648. *
  649. * 2. The listener should not expect to see all state changes, as the state
  650. * might have been updated multiple times during a nested `dispatch()` before
  651. * the listener is called. It is, however, guaranteed that all subscribers
  652. * registered before the `dispatch()` started will be called with the latest
  653. * state by the time it exits.
  654. *
  655. * @param {Function} listener A callback to be invoked on every dispatch.
  656. * @returns {Function} A function to remove this change listener.
  657. */
  658. function subscribe(listener) {
  659. if (typeof listener !== 'function') {
  660. throw new Error( true ? formatProdErrorMessage(4) : 0);
  661. }
  662. if (isDispatching) {
  663. throw new Error( true ? formatProdErrorMessage(5) : 0);
  664. }
  665. var isSubscribed = true;
  666. ensureCanMutateNextListeners();
  667. nextListeners.push(listener);
  668. return function unsubscribe() {
  669. if (!isSubscribed) {
  670. return;
  671. }
  672. if (isDispatching) {
  673. throw new Error( true ? formatProdErrorMessage(6) : 0);
  674. }
  675. isSubscribed = false;
  676. ensureCanMutateNextListeners();
  677. var index = nextListeners.indexOf(listener);
  678. nextListeners.splice(index, 1);
  679. currentListeners = null;
  680. };
  681. }
  682. /**
  683. * Dispatches an action. It is the only way to trigger a state change.
  684. *
  685. * The `reducer` function, used to create the store, will be called with the
  686. * current state tree and the given `action`. Its return value will
  687. * be considered the **next** state of the tree, and the change listeners
  688. * will be notified.
  689. *
  690. * The base implementation only supports plain object actions. If you want to
  691. * dispatch a Promise, an Observable, a thunk, or something else, you need to
  692. * wrap your store creating function into the corresponding middleware. For
  693. * example, see the documentation for the `redux-thunk` package. Even the
  694. * middleware will eventually dispatch plain object actions using this method.
  695. *
  696. * @param {Object} action A plain object representing “what changed”. It is
  697. * a good idea to keep actions serializable so you can record and replay user
  698. * sessions, or use the time travelling `redux-devtools`. An action must have
  699. * a `type` property which may not be `undefined`. It is a good idea to use
  700. * string constants for action types.
  701. *
  702. * @returns {Object} For convenience, the same action object you dispatched.
  703. *
  704. * Note that, if you use a custom middleware, it may wrap `dispatch()` to
  705. * return something else (for example, a Promise you can await).
  706. */
  707. function dispatch(action) {
  708. if (!isPlainObject(action)) {
  709. throw new Error( true ? formatProdErrorMessage(7) : 0);
  710. }
  711. if (typeof action.type === 'undefined') {
  712. throw new Error( true ? formatProdErrorMessage(8) : 0);
  713. }
  714. if (isDispatching) {
  715. throw new Error( true ? formatProdErrorMessage(9) : 0);
  716. }
  717. try {
  718. isDispatching = true;
  719. currentState = currentReducer(currentState, action);
  720. } finally {
  721. isDispatching = false;
  722. }
  723. var listeners = currentListeners = nextListeners;
  724. for (var i = 0; i < listeners.length; i++) {
  725. var listener = listeners[i];
  726. listener();
  727. }
  728. return action;
  729. }
  730. /**
  731. * Replaces the reducer currently used by the store to calculate the state.
  732. *
  733. * You might need this if your app implements code splitting and you want to
  734. * load some of the reducers dynamically. You might also need this if you
  735. * implement a hot reloading mechanism for Redux.
  736. *
  737. * @param {Function} nextReducer The reducer for the store to use instead.
  738. * @returns {void}
  739. */
  740. function replaceReducer(nextReducer) {
  741. if (typeof nextReducer !== 'function') {
  742. throw new Error( true ? formatProdErrorMessage(10) : 0);
  743. }
  744. currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
  745. // Any reducers that existed in both the new and old rootReducer
  746. // will receive the previous state. This effectively populates
  747. // the new state tree with any relevant data from the old one.
  748. dispatch({
  749. type: ActionTypes.REPLACE
  750. });
  751. }
  752. /**
  753. * Interoperability point for observable/reactive libraries.
  754. * @returns {observable} A minimal observable of state changes.
  755. * For more information, see the observable proposal:
  756. * https://github.com/tc39/proposal-observable
  757. */
  758. function observable() {
  759. var _ref;
  760. var outerSubscribe = subscribe;
  761. return _ref = {
  762. /**
  763. * The minimal observable subscription method.
  764. * @param {Object} observer Any object that can be used as an observer.
  765. * The observer object should have a `next` method.
  766. * @returns {subscription} An object with an `unsubscribe` method that can
  767. * be used to unsubscribe the observable from the store, and prevent further
  768. * emission of values from the observable.
  769. */
  770. subscribe: function subscribe(observer) {
  771. if (typeof observer !== 'object' || observer === null) {
  772. throw new Error( true ? formatProdErrorMessage(11) : 0);
  773. }
  774. function observeState() {
  775. if (observer.next) {
  776. observer.next(getState());
  777. }
  778. }
  779. observeState();
  780. var unsubscribe = outerSubscribe(observeState);
  781. return {
  782. unsubscribe: unsubscribe
  783. };
  784. }
  785. }, _ref[$$observable] = function () {
  786. return this;
  787. }, _ref;
  788. } // When a store is created, an "INIT" action is dispatched so that every
  789. // reducer returns their initial state. This effectively populates
  790. // the initial state tree.
  791. dispatch({
  792. type: ActionTypes.INIT
  793. });
  794. return _ref2 = {
  795. dispatch: dispatch,
  796. subscribe: subscribe,
  797. getState: getState,
  798. replaceReducer: replaceReducer
  799. }, _ref2[$$observable] = observable, _ref2;
  800. }
  801. /**
  802. * Creates a Redux store that holds the state tree.
  803. *
  804. * **We recommend using `configureStore` from the
  805. * `@reduxjs/toolkit` package**, which replaces `createStore`:
  806. * **https://redux.js.org/introduction/why-rtk-is-redux-today**
  807. *
  808. * The only way to change the data in the store is to call `dispatch()` on it.
  809. *
  810. * There should only be a single store in your app. To specify how different
  811. * parts of the state tree respond to actions, you may combine several reducers
  812. * into a single reducer function by using `combineReducers`.
  813. *
  814. * @param {Function} reducer A function that returns the next state tree, given
  815. * the current state tree and the action to handle.
  816. *
  817. * @param {any} [preloadedState] The initial state. You may optionally specify it
  818. * to hydrate the state from the server in universal apps, or to restore a
  819. * previously serialized user session.
  820. * If you use `combineReducers` to produce the root reducer function, this must be
  821. * an object with the same shape as `combineReducers` keys.
  822. *
  823. * @param {Function} [enhancer] The store enhancer. You may optionally specify it
  824. * to enhance the store with third-party capabilities such as middleware,
  825. * time travel, persistence, etc. The only store enhancer that ships with Redux
  826. * is `applyMiddleware()`.
  827. *
  828. * @returns {Store} A Redux store that lets you read the state, dispatch actions
  829. * and subscribe to changes.
  830. */
  831. var legacy_createStore = (/* unused pure expression or super */ null && (createStore));
  832. /**
  833. * Prints a warning in the console if it exists.
  834. *
  835. * @param {String} message The warning message.
  836. * @returns {void}
  837. */
  838. function warning(message) {
  839. /* eslint-disable no-console */
  840. if (typeof console !== 'undefined' && typeof console.error === 'function') {
  841. console.error(message);
  842. }
  843. /* eslint-enable no-console */
  844. try {
  845. // This error was thrown as a convenience so that if you enable
  846. // "break on all exceptions" in your console,
  847. // it would pause the execution at this line.
  848. throw new Error(message);
  849. } catch (e) {} // eslint-disable-line no-empty
  850. }
  851. function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
  852. var reducerKeys = Object.keys(reducers);
  853. var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
  854. if (reducerKeys.length === 0) {
  855. return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
  856. }
  857. if (!isPlainObject(inputState)) {
  858. return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
  859. }
  860. var unexpectedKeys = Object.keys(inputState).filter(function (key) {
  861. return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
  862. });
  863. unexpectedKeys.forEach(function (key) {
  864. unexpectedKeyCache[key] = true;
  865. });
  866. if (action && action.type === ActionTypes.REPLACE) return;
  867. if (unexpectedKeys.length > 0) {
  868. return "Unexpected " + (unexpectedKeys.length > 1 ? 'keys' : 'key') + " " + ("\"" + unexpectedKeys.join('", "') + "\" found in " + argumentName + ". ") + "Expected to find one of the known reducer keys instead: " + ("\"" + reducerKeys.join('", "') + "\". Unexpected keys will be ignored.");
  869. }
  870. }
  871. function assertReducerShape(reducers) {
  872. Object.keys(reducers).forEach(function (key) {
  873. var reducer = reducers[key];
  874. var initialState = reducer(undefined, {
  875. type: ActionTypes.INIT
  876. });
  877. if (typeof initialState === 'undefined') {
  878. throw new Error( true ? formatProdErrorMessage(12) : 0);
  879. }
  880. if (typeof reducer(undefined, {
  881. type: ActionTypes.PROBE_UNKNOWN_ACTION()
  882. }) === 'undefined') {
  883. throw new Error( true ? formatProdErrorMessage(13) : 0);
  884. }
  885. });
  886. }
  887. /**
  888. * Turns an object whose values are different reducer functions, into a single
  889. * reducer function. It will call every child reducer, and gather their results
  890. * into a single state object, whose keys correspond to the keys of the passed
  891. * reducer functions.
  892. *
  893. * @param {Object} reducers An object whose values correspond to different
  894. * reducer functions that need to be combined into one. One handy way to obtain
  895. * it is to use ES6 `import * as reducers` syntax. The reducers may never return
  896. * undefined for any action. Instead, they should return their initial state
  897. * if the state passed to them was undefined, and the current state for any
  898. * unrecognized action.
  899. *
  900. * @returns {Function} A reducer function that invokes every reducer inside the
  901. * passed object, and builds a state object with the same shape.
  902. */
  903. function combineReducers(reducers) {
  904. var reducerKeys = Object.keys(reducers);
  905. var finalReducers = {};
  906. for (var i = 0; i < reducerKeys.length; i++) {
  907. var key = reducerKeys[i];
  908. if (false) {}
  909. if (typeof reducers[key] === 'function') {
  910. finalReducers[key] = reducers[key];
  911. }
  912. }
  913. var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
  914. // keys multiple times.
  915. var unexpectedKeyCache;
  916. if (false) {}
  917. var shapeAssertionError;
  918. try {
  919. assertReducerShape(finalReducers);
  920. } catch (e) {
  921. shapeAssertionError = e;
  922. }
  923. return function combination(state, action) {
  924. if (state === void 0) {
  925. state = {};
  926. }
  927. if (shapeAssertionError) {
  928. throw shapeAssertionError;
  929. }
  930. if (false) { var warningMessage; }
  931. var hasChanged = false;
  932. var nextState = {};
  933. for (var _i = 0; _i < finalReducerKeys.length; _i++) {
  934. var _key = finalReducerKeys[_i];
  935. var reducer = finalReducers[_key];
  936. var previousStateForKey = state[_key];
  937. var nextStateForKey = reducer(previousStateForKey, action);
  938. if (typeof nextStateForKey === 'undefined') {
  939. var actionType = action && action.type;
  940. throw new Error( true ? formatProdErrorMessage(14) : 0);
  941. }
  942. nextState[_key] = nextStateForKey;
  943. hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
  944. }
  945. hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
  946. return hasChanged ? nextState : state;
  947. };
  948. }
  949. function bindActionCreator(actionCreator, dispatch) {
  950. return function () {
  951. return dispatch(actionCreator.apply(this, arguments));
  952. };
  953. }
  954. /**
  955. * Turns an object whose values are action creators, into an object with the
  956. * same keys, but with every function wrapped into a `dispatch` call so they
  957. * may be invoked directly. This is just a convenience method, as you can call
  958. * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
  959. *
  960. * For convenience, you can also pass an action creator as the first argument,
  961. * and get a dispatch wrapped function in return.
  962. *
  963. * @param {Function|Object} actionCreators An object whose values are action
  964. * creator functions. One handy way to obtain it is to use ES6 `import * as`
  965. * syntax. You may also pass a single function.
  966. *
  967. * @param {Function} dispatch The `dispatch` function available on your Redux
  968. * store.
  969. *
  970. * @returns {Function|Object} The object mimicking the original object, but with
  971. * every action creator wrapped into the `dispatch` call. If you passed a
  972. * function as `actionCreators`, the return value will also be a single
  973. * function.
  974. */
  975. function bindActionCreators(actionCreators, dispatch) {
  976. if (typeof actionCreators === 'function') {
  977. return bindActionCreator(actionCreators, dispatch);
  978. }
  979. if (typeof actionCreators !== 'object' || actionCreators === null) {
  980. throw new Error( true ? formatProdErrorMessage(16) : 0);
  981. }
  982. var boundActionCreators = {};
  983. for (var key in actionCreators) {
  984. var actionCreator = actionCreators[key];
  985. if (typeof actionCreator === 'function') {
  986. boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
  987. }
  988. }
  989. return boundActionCreators;
  990. }
  991. /**
  992. * Composes single-argument functions from right to left. The rightmost
  993. * function can take multiple arguments as it provides the signature for
  994. * the resulting composite function.
  995. *
  996. * @param {...Function} funcs The functions to compose.
  997. * @returns {Function} A function obtained by composing the argument functions
  998. * from right to left. For example, compose(f, g, h) is identical to doing
  999. * (...args) => f(g(h(...args))).
  1000. */
  1001. function compose() {
  1002. for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
  1003. funcs[_key] = arguments[_key];
  1004. }
  1005. if (funcs.length === 0) {
  1006. return function (arg) {
  1007. return arg;
  1008. };
  1009. }
  1010. if (funcs.length === 1) {
  1011. return funcs[0];
  1012. }
  1013. return funcs.reduce(function (a, b) {
  1014. return function () {
  1015. return a(b.apply(void 0, arguments));
  1016. };
  1017. });
  1018. }
  1019. /**
  1020. * Creates a store enhancer that applies middleware to the dispatch method
  1021. * of the Redux store. This is handy for a variety of tasks, such as expressing
  1022. * asynchronous actions in a concise manner, or logging every action payload.
  1023. *
  1024. * See `redux-thunk` package as an example of the Redux middleware.
  1025. *
  1026. * Because middleware is potentially asynchronous, this should be the first
  1027. * store enhancer in the composition chain.
  1028. *
  1029. * Note that each middleware will be given the `dispatch` and `getState` functions
  1030. * as named arguments.
  1031. *
  1032. * @param {...Function} middlewares The middleware chain to be applied.
  1033. * @returns {Function} A store enhancer applying the middleware.
  1034. */
  1035. function applyMiddleware() {
  1036. for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
  1037. middlewares[_key] = arguments[_key];
  1038. }
  1039. return function (createStore) {
  1040. return function () {
  1041. var store = createStore.apply(void 0, arguments);
  1042. var _dispatch = function dispatch() {
  1043. throw new Error( true ? formatProdErrorMessage(15) : 0);
  1044. };
  1045. var middlewareAPI = {
  1046. getState: store.getState,
  1047. dispatch: function dispatch() {
  1048. return _dispatch.apply(void 0, arguments);
  1049. }
  1050. };
  1051. var chain = middlewares.map(function (middleware) {
  1052. return middleware(middlewareAPI);
  1053. });
  1054. _dispatch = compose.apply(void 0, chain)(store.dispatch);
  1055. return _objectSpread2(_objectSpread2({}, store), {}, {
  1056. dispatch: _dispatch
  1057. });
  1058. };
  1059. };
  1060. }
  1061. /*
  1062. * This is a dummy function to check if the function name has been altered by minification.
  1063. * If the function has been minified and NODE_ENV !== 'production', warn the user.
  1064. */
  1065. function isCrushed() {}
  1066. if (false) {}
  1067. // EXTERNAL MODULE: ./node_modules/equivalent-key-map/equivalent-key-map.js
  1068. var equivalent_key_map = __webpack_require__(2167);
  1069. var equivalent_key_map_default = /*#__PURE__*/__webpack_require__.n(equivalent_key_map);
  1070. ;// CONCATENATED MODULE: external ["wp","reduxRoutine"]
  1071. var external_wp_reduxRoutine_namespaceObject = window["wp"]["reduxRoutine"];
  1072. var external_wp_reduxRoutine_default = /*#__PURE__*/__webpack_require__.n(external_wp_reduxRoutine_namespaceObject);
  1073. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/factory.js
  1074. /**
  1075. * Creates a selector function that takes additional curried argument with the
  1076. * registry `select` function. While a regular selector has signature
  1077. * ```js
  1078. * ( state, ...selectorArgs ) => ( result )
  1079. * ```
  1080. * that allows to select data from the store's `state`, a registry selector
  1081. * has signature:
  1082. * ```js
  1083. * ( select ) => ( state, ...selectorArgs ) => ( result )
  1084. * ```
  1085. * that supports also selecting from other registered stores.
  1086. *
  1087. * @example
  1088. * ```js
  1089. * const getCurrentPostId = createRegistrySelector( ( select ) => ( state ) => {
  1090. * return select( 'core/editor' ).getCurrentPostId();
  1091. * } );
  1092. *
  1093. * const getPostEdits = createRegistrySelector( ( select ) => ( state ) => {
  1094. * // calling another registry selector just like any other function
  1095. * const postType = getCurrentPostType( state );
  1096. * const postId = getCurrentPostId( state );
  1097. * return select( 'core' ).getEntityRecordEdits( 'postType', postType, postId );
  1098. * } );
  1099. * ```
  1100. *
  1101. * Note how the `getCurrentPostId` selector can be called just like any other function,
  1102. * (it works even inside a regular non-registry selector) and we don't need to pass the
  1103. * registry as argument. The registry binding happens automatically when registering the selector
  1104. * with a store.
  1105. *
  1106. * @param {Function} registrySelector Function receiving a registry `select`
  1107. * function and returning a state selector.
  1108. *
  1109. * @return {Function} Registry selector that can be registered with a store.
  1110. */
  1111. function createRegistrySelector(registrySelector) {
  1112. // Create a selector function that is bound to the registry referenced by `selector.registry`
  1113. // and that has the same API as a regular selector. Binding it in such a way makes it
  1114. // possible to call the selector directly from another selector.
  1115. const selector = function () {
  1116. return registrySelector(selector.registry.select)(...arguments);
  1117. };
  1118. /**
  1119. * Flag indicating that the selector is a registry selector that needs the correct registry
  1120. * reference to be assigned to `selecto.registry` to make it work correctly.
  1121. * be mapped as a registry selector.
  1122. *
  1123. * @type {boolean}
  1124. */
  1125. selector.isRegistrySelector = true;
  1126. return selector;
  1127. }
  1128. /**
  1129. * Creates a control function that takes additional curried argument with the `registry` object.
  1130. * While a regular control has signature
  1131. * ```js
  1132. * ( action ) => ( iteratorOrPromise )
  1133. * ```
  1134. * where the control works with the `action` that it's bound to, a registry control has signature:
  1135. * ```js
  1136. * ( registry ) => ( action ) => ( iteratorOrPromise )
  1137. * ```
  1138. * A registry control is typically used to select data or dispatch an action to a registered
  1139. * store.
  1140. *
  1141. * When registering a control created with `createRegistryControl` with a store, the store
  1142. * knows which calling convention to use when executing the control.
  1143. *
  1144. * @param {Function} registryControl Function receiving a registry object and returning a control.
  1145. *
  1146. * @return {Function} Registry control that can be registered with a store.
  1147. */
  1148. function createRegistryControl(registryControl) {
  1149. registryControl.isRegistryControl = true;
  1150. return registryControl;
  1151. }
  1152. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/controls.js
  1153. /**
  1154. * External dependencies
  1155. */
  1156. /**
  1157. * Internal dependencies
  1158. */
  1159. /** @typedef {import('./types').StoreDescriptor} StoreDescriptor */
  1160. const SELECT = '@@data/SELECT';
  1161. const RESOLVE_SELECT = '@@data/RESOLVE_SELECT';
  1162. const DISPATCH = '@@data/DISPATCH';
  1163. /**
  1164. * Dispatches a control action for triggering a synchronous registry select.
  1165. *
  1166. * Note: This control synchronously returns the current selector value, triggering the
  1167. * resolution, but not waiting for it.
  1168. *
  1169. * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
  1170. * @param {string} selectorName The name of the selector.
  1171. * @param {Array} args Arguments for the selector.
  1172. *
  1173. * @example
  1174. * ```js
  1175. * import { controls } from '@wordpress/data';
  1176. *
  1177. * // Action generator using `select`.
  1178. * export function* myAction() {
  1179. * const isEditorSideBarOpened = yield controls.select( 'core/edit-post', 'isEditorSideBarOpened' );
  1180. * // Do stuff with the result from the `select`.
  1181. * }
  1182. * ```
  1183. *
  1184. * @return {Object} The control descriptor.
  1185. */
  1186. function controls_select(storeNameOrDescriptor, selectorName) {
  1187. for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  1188. args[_key - 2] = arguments[_key];
  1189. }
  1190. return {
  1191. type: SELECT,
  1192. storeKey: (0,external_lodash_namespaceObject.isObject)(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor,
  1193. selectorName,
  1194. args
  1195. };
  1196. }
  1197. /**
  1198. * Dispatches a control action for triggering and resolving a registry select.
  1199. *
  1200. * Note: when this control action is handled, it automatically considers
  1201. * selectors that may have a resolver. In such case, it will return a `Promise` that resolves
  1202. * after the selector finishes resolving, with the final result value.
  1203. *
  1204. * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
  1205. * @param {string} selectorName The name of the selector
  1206. * @param {Array} args Arguments for the selector.
  1207. *
  1208. * @example
  1209. * ```js
  1210. * import { controls } from '@wordpress/data';
  1211. *
  1212. * // Action generator using resolveSelect
  1213. * export function* myAction() {
  1214. * const isSidebarOpened = yield controls.resolveSelect( 'core/edit-post', 'isEditorSideBarOpened' );
  1215. * // do stuff with the result from the select.
  1216. * }
  1217. * ```
  1218. *
  1219. * @return {Object} The control descriptor.
  1220. */
  1221. function resolveSelect(storeNameOrDescriptor, selectorName) {
  1222. for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  1223. args[_key2 - 2] = arguments[_key2];
  1224. }
  1225. return {
  1226. type: RESOLVE_SELECT,
  1227. storeKey: (0,external_lodash_namespaceObject.isObject)(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor,
  1228. selectorName,
  1229. args
  1230. };
  1231. }
  1232. /**
  1233. * Dispatches a control action for triggering a registry dispatch.
  1234. *
  1235. * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
  1236. * @param {string} actionName The name of the action to dispatch
  1237. * @param {Array} args Arguments for the dispatch action.
  1238. *
  1239. * @example
  1240. * ```js
  1241. * import { controls } from '@wordpress/data-controls';
  1242. *
  1243. * // Action generator using dispatch
  1244. * export function* myAction() {
  1245. * yield controls.dispatch( 'core/edit-post', 'togglePublishSidebar' );
  1246. * // do some other things.
  1247. * }
  1248. * ```
  1249. *
  1250. * @return {Object} The control descriptor.
  1251. */
  1252. function dispatch(storeNameOrDescriptor, actionName) {
  1253. for (var _len3 = arguments.length, args = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
  1254. args[_key3 - 2] = arguments[_key3];
  1255. }
  1256. return {
  1257. type: DISPATCH,
  1258. storeKey: (0,external_lodash_namespaceObject.isObject)(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor,
  1259. actionName,
  1260. args
  1261. };
  1262. }
  1263. const controls = {
  1264. select: controls_select,
  1265. resolveSelect,
  1266. dispatch
  1267. };
  1268. const builtinControls = {
  1269. [SELECT]: createRegistryControl(registry => _ref => {
  1270. let {
  1271. storeKey,
  1272. selectorName,
  1273. args
  1274. } = _ref;
  1275. return registry.select(storeKey)[selectorName](...args);
  1276. }),
  1277. [RESOLVE_SELECT]: createRegistryControl(registry => _ref2 => {
  1278. let {
  1279. storeKey,
  1280. selectorName,
  1281. args
  1282. } = _ref2;
  1283. const method = registry.select(storeKey)[selectorName].hasResolver ? 'resolveSelect' : 'select';
  1284. return registry[method](storeKey)[selectorName](...args);
  1285. }),
  1286. [DISPATCH]: createRegistryControl(registry => _ref3 => {
  1287. let {
  1288. storeKey,
  1289. actionName,
  1290. args
  1291. } = _ref3;
  1292. return registry.dispatch(storeKey)[actionName](...args);
  1293. })
  1294. };
  1295. ;// CONCATENATED MODULE: ./node_modules/is-promise/index.mjs
  1296. function isPromise(obj) {
  1297. return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
  1298. }
  1299. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/promise-middleware.js
  1300. /**
  1301. * External dependencies
  1302. */
  1303. /**
  1304. * Simplest possible promise redux middleware.
  1305. *
  1306. * @type {import('redux').Middleware}
  1307. */
  1308. const promiseMiddleware = () => next => action => {
  1309. if (isPromise(action)) {
  1310. return action.then(resolvedAction => {
  1311. if (resolvedAction) {
  1312. return next(resolvedAction);
  1313. }
  1314. });
  1315. }
  1316. return next(action);
  1317. };
  1318. /* harmony default export */ var promise_middleware = (promiseMiddleware);
  1319. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/store/index.js
  1320. const coreDataStore = {
  1321. name: 'core/data',
  1322. instantiate(registry) {
  1323. const getCoreDataSelector = selectorName => function (key) {
  1324. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1325. args[_key - 1] = arguments[_key];
  1326. }
  1327. return registry.select(key)[selectorName](...args);
  1328. };
  1329. const getCoreDataAction = actionName => function (key) {
  1330. for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  1331. args[_key2 - 1] = arguments[_key2];
  1332. }
  1333. return registry.dispatch(key)[actionName](...args);
  1334. };
  1335. return {
  1336. getSelectors() {
  1337. return Object.fromEntries(['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers'].map(selectorName => [selectorName, getCoreDataSelector(selectorName)]));
  1338. },
  1339. getActions() {
  1340. return Object.fromEntries(['startResolution', 'finishResolution', 'invalidateResolution', 'invalidateResolutionForStore', 'invalidateResolutionForStoreSelector'].map(actionName => [actionName, getCoreDataAction(actionName)]));
  1341. },
  1342. subscribe() {
  1343. // There's no reasons to trigger any listener when we subscribe to this store
  1344. // because there's no state stored in this store that need to retrigger selectors
  1345. // if a change happens, the corresponding store where the tracking stated live
  1346. // would have already triggered a "subscribe" call.
  1347. return () => () => {};
  1348. }
  1349. };
  1350. }
  1351. };
  1352. /* harmony default export */ var store = (coreDataStore);
  1353. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/resolvers-cache-middleware.js
  1354. /**
  1355. * External dependencies
  1356. */
  1357. /**
  1358. * Internal dependencies
  1359. */
  1360. /** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */
  1361. /**
  1362. * Creates a middleware handling resolvers cache invalidation.
  1363. *
  1364. * @param {WPDataRegistry} registry The registry reference for which to create
  1365. * the middleware.
  1366. * @param {string} reducerKey The namespace for which to create the
  1367. * middleware.
  1368. *
  1369. * @return {Function} Middleware function.
  1370. */
  1371. const createResolversCacheMiddleware = (registry, reducerKey) => () => next => action => {
  1372. const resolvers = registry.select(store).getCachedResolvers(reducerKey);
  1373. Object.entries(resolvers).forEach(_ref => {
  1374. let [selectorName, resolversByArgs] = _ref;
  1375. const resolver = (0,external_lodash_namespaceObject.get)(registry.stores, [reducerKey, 'resolvers', selectorName]);
  1376. if (!resolver || !resolver.shouldInvalidate) {
  1377. return;
  1378. }
  1379. resolversByArgs.forEach((value, args) => {
  1380. // resolversByArgs is the map Map([ args ] => boolean) storing the cache resolution status for a given selector.
  1381. // If the value is "finished" or "error" it means this resolver has finished its resolution which means we need
  1382. // to invalidate it, if it's true it means it's inflight and the invalidation is not necessary.
  1383. if ((value === null || value === void 0 ? void 0 : value.status) !== 'finished' && (value === null || value === void 0 ? void 0 : value.status) !== 'error' || !resolver.shouldInvalidate(action, ...args)) {
  1384. return;
  1385. } // Trigger cache invalidation
  1386. registry.dispatch(store).invalidateResolution(reducerKey, selectorName, args);
  1387. });
  1388. });
  1389. return next(action);
  1390. };
  1391. /* harmony default export */ var resolvers_cache_middleware = (createResolversCacheMiddleware);
  1392. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/thunk-middleware.js
  1393. function createThunkMiddleware(args) {
  1394. return () => next => action => {
  1395. if (typeof action === 'function') {
  1396. return action(args);
  1397. }
  1398. return next(action);
  1399. };
  1400. }
  1401. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/utils.js
  1402. /**
  1403. * External dependencies
  1404. */
  1405. /**
  1406. * Higher-order reducer creator which creates a combined reducer object, keyed
  1407. * by a property on the action object.
  1408. *
  1409. * @param actionProperty Action property by which to key object.
  1410. * @return Higher-order reducer.
  1411. */
  1412. const onSubKey = actionProperty => reducer => function () {
  1413. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1414. let action = arguments.length > 1 ? arguments[1] : undefined;
  1415. // Retrieve subkey from action. Do not track if undefined; useful for cases
  1416. // where reducer is scoped by action shape.
  1417. const key = action[actionProperty];
  1418. if (key === undefined) {
  1419. return state;
  1420. } // Avoid updating state if unchanged. Note that this also accounts for a
  1421. // reducer which returns undefined on a key which is not yet tracked.
  1422. const nextKeyState = reducer(state[key], action);
  1423. if (nextKeyState === state[key]) {
  1424. return state;
  1425. }
  1426. return { ...state,
  1427. [key]: nextKeyState
  1428. };
  1429. };
  1430. /**
  1431. * Normalize selector argument array by defaulting `undefined` value to an empty array
  1432. * and removing trailing `undefined` values.
  1433. *
  1434. * @param args Selector argument array
  1435. * @return Normalized state key array
  1436. */
  1437. function selectorArgsToStateKey(args) {
  1438. if (args === undefined || args === null) {
  1439. return [];
  1440. }
  1441. const len = args.length;
  1442. let idx = len;
  1443. while (idx > 0 && args[idx - 1] === undefined) {
  1444. idx--;
  1445. }
  1446. return idx === len ? args : args.slice(0, idx);
  1447. }
  1448. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/reducer.js
  1449. /**
  1450. * External dependencies
  1451. */
  1452. /**
  1453. * Internal dependencies
  1454. */
  1455. /**
  1456. * Reducer function returning next state for selector resolution of
  1457. * subkeys, object form:
  1458. *
  1459. * selectorName -> EquivalentKeyMap<Array,boolean>
  1460. */
  1461. const subKeysIsResolved = onSubKey('selectorName')(function () {
  1462. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new (equivalent_key_map_default())();
  1463. let action = arguments.length > 1 ? arguments[1] : undefined;
  1464. switch (action.type) {
  1465. case 'START_RESOLUTION':
  1466. {
  1467. const nextState = new (equivalent_key_map_default())(state);
  1468. nextState.set(selectorArgsToStateKey(action.args), {
  1469. status: 'resolving'
  1470. });
  1471. return nextState;
  1472. }
  1473. case 'FINISH_RESOLUTION':
  1474. {
  1475. const nextState = new (equivalent_key_map_default())(state);
  1476. nextState.set(selectorArgsToStateKey(action.args), {
  1477. status: 'finished'
  1478. });
  1479. return nextState;
  1480. }
  1481. case 'FAIL_RESOLUTION':
  1482. {
  1483. const nextState = new (equivalent_key_map_default())(state);
  1484. nextState.set(selectorArgsToStateKey(action.args), {
  1485. status: 'error',
  1486. error: action.error
  1487. });
  1488. return nextState;
  1489. }
  1490. case 'START_RESOLUTIONS':
  1491. {
  1492. const nextState = new (equivalent_key_map_default())(state);
  1493. for (const resolutionArgs of action.args) {
  1494. nextState.set(selectorArgsToStateKey(resolutionArgs), {
  1495. status: 'resolving'
  1496. });
  1497. }
  1498. return nextState;
  1499. }
  1500. case 'FINISH_RESOLUTIONS':
  1501. {
  1502. const nextState = new (equivalent_key_map_default())(state);
  1503. for (const resolutionArgs of action.args) {
  1504. nextState.set(selectorArgsToStateKey(resolutionArgs), {
  1505. status: 'finished'
  1506. });
  1507. }
  1508. return nextState;
  1509. }
  1510. case 'FAIL_RESOLUTIONS':
  1511. {
  1512. const nextState = new (equivalent_key_map_default())(state);
  1513. action.args.forEach((resolutionArgs, idx) => {
  1514. const resolutionState = {
  1515. status: 'error',
  1516. error: undefined
  1517. };
  1518. const error = action.errors[idx];
  1519. if (error) {
  1520. resolutionState.error = error;
  1521. }
  1522. nextState.set(selectorArgsToStateKey(resolutionArgs), resolutionState);
  1523. });
  1524. return nextState;
  1525. }
  1526. case 'INVALIDATE_RESOLUTION':
  1527. {
  1528. const nextState = new (equivalent_key_map_default())(state);
  1529. nextState.delete(selectorArgsToStateKey(action.args));
  1530. return nextState;
  1531. }
  1532. }
  1533. return state;
  1534. });
  1535. /**
  1536. * Reducer function returning next state for selector resolution, object form:
  1537. *
  1538. * selectorName -> EquivalentKeyMap<Array, boolean>
  1539. *
  1540. * @param state Current state.
  1541. * @param action Dispatched action.
  1542. *
  1543. * @return Next state.
  1544. */
  1545. const isResolved = function () {
  1546. let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1547. let action = arguments.length > 1 ? arguments[1] : undefined;
  1548. switch (action.type) {
  1549. case 'INVALIDATE_RESOLUTION_FOR_STORE':
  1550. return {};
  1551. case 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR':
  1552. return (0,external_lodash_namespaceObject.has)(state, [action.selectorName]) ? (0,external_lodash_namespaceObject.omit)(state, [action.selectorName]) : state;
  1553. case 'START_RESOLUTION':
  1554. case 'FINISH_RESOLUTION':
  1555. case 'FAIL_RESOLUTION':
  1556. case 'START_RESOLUTIONS':
  1557. case 'FINISH_RESOLUTIONS':
  1558. case 'FAIL_RESOLUTIONS':
  1559. case 'INVALIDATE_RESOLUTION':
  1560. return subKeysIsResolved(state, action);
  1561. }
  1562. return state;
  1563. };
  1564. /* harmony default export */ var metadata_reducer = (isResolved);
  1565. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js
  1566. /**
  1567. * External dependencies
  1568. */
  1569. /**
  1570. * Internal dependencies
  1571. */
  1572. /** @typedef {Record<string, import('./reducer').State>} State */
  1573. /** @typedef {import('./reducer').StateValue} StateValue */
  1574. /** @typedef {import('./reducer').Status} Status */
  1575. /**
  1576. * Returns the raw resolution state value for a given selector name,
  1577. * and arguments set. May be undefined if the selector has never been resolved
  1578. * or not resolved for the given set of arguments, otherwise true or false for
  1579. * resolution started and completed respectively.
  1580. *
  1581. * @param {State} state Data state.
  1582. * @param {string} selectorName Selector name.
  1583. * @param {unknown[]?} args Arguments passed to selector.
  1584. *
  1585. * @return {StateValue|undefined} isResolving value.
  1586. */
  1587. function getResolutionState(state, selectorName, args) {
  1588. const map = (0,external_lodash_namespaceObject.get)(state, [selectorName]);
  1589. if (!map) {
  1590. return;
  1591. }
  1592. return map.get(selectorArgsToStateKey(args));
  1593. }
  1594. /**
  1595. * Returns the raw `isResolving` value for a given selector name,
  1596. * and arguments set. May be undefined if the selector has never been resolved
  1597. * or not resolved for the given set of arguments, otherwise true or false for
  1598. * resolution started and completed respectively.
  1599. *
  1600. * @param {State} state Data state.
  1601. * @param {string} selectorName Selector name.
  1602. * @param {unknown[]?} args Arguments passed to selector.
  1603. *
  1604. * @return {boolean | undefined} isResolving value.
  1605. */
  1606. function getIsResolving(state, selectorName, args) {
  1607. const resolutionState = getResolutionState(state, selectorName, args);
  1608. return resolutionState && resolutionState.status === 'resolving';
  1609. }
  1610. /**
  1611. * Returns true if resolution has already been triggered for a given
  1612. * selector name, and arguments set.
  1613. *
  1614. * @param {State} state Data state.
  1615. * @param {string} selectorName Selector name.
  1616. * @param {unknown[]?} args Arguments passed to selector.
  1617. *
  1618. * @return {boolean} Whether resolution has been triggered.
  1619. */
  1620. function hasStartedResolution(state, selectorName, args) {
  1621. return getResolutionState(state, selectorName, args) !== undefined;
  1622. }
  1623. /**
  1624. * Returns true if resolution has completed for a given selector
  1625. * name, and arguments set.
  1626. *
  1627. * @param {State} state Data state.
  1628. * @param {string} selectorName Selector name.
  1629. * @param {unknown[]?} args Arguments passed to selector.
  1630. *
  1631. * @return {boolean} Whether resolution has completed.
  1632. */
  1633. function hasFinishedResolution(state, selectorName, args) {
  1634. var _getResolutionState;
  1635. const status = (_getResolutionState = getResolutionState(state, selectorName, args)) === null || _getResolutionState === void 0 ? void 0 : _getResolutionState.status;
  1636. return status === 'finished' || status === 'error';
  1637. }
  1638. /**
  1639. * Returns true if resolution has failed for a given selector
  1640. * name, and arguments set.
  1641. *
  1642. * @param {State} state Data state.
  1643. * @param {string} selectorName Selector name.
  1644. * @param {unknown[]?} args Arguments passed to selector.
  1645. *
  1646. * @return {boolean} Has resolution failed
  1647. */
  1648. function hasResolutionFailed(state, selectorName, args) {
  1649. var _getResolutionState2;
  1650. return ((_getResolutionState2 = getResolutionState(state, selectorName, args)) === null || _getResolutionState2 === void 0 ? void 0 : _getResolutionState2.status) === 'error';
  1651. }
  1652. /**
  1653. * Returns the resolution error for a given selector name, and arguments set.
  1654. * Note it may be of an Error type, but may also be null, undefined, or anything else
  1655. * that can be `throw`-n.
  1656. *
  1657. * @param {State} state Data state.
  1658. * @param {string} selectorName Selector name.
  1659. * @param {unknown[]?} args Arguments passed to selector.
  1660. *
  1661. * @return {Error|unknown} Last resolution error
  1662. */
  1663. function getResolutionError(state, selectorName, args) {
  1664. const resolutionState = getResolutionState(state, selectorName, args);
  1665. return (resolutionState === null || resolutionState === void 0 ? void 0 : resolutionState.status) === 'error' ? resolutionState.error : null;
  1666. }
  1667. /**
  1668. * Returns true if resolution has been triggered but has not yet completed for
  1669. * a given selector name, and arguments set.
  1670. *
  1671. * @param {State} state Data state.
  1672. * @param {string} selectorName Selector name.
  1673. * @param {unknown[]?} args Arguments passed to selector.
  1674. *
  1675. * @return {boolean} Whether resolution is in progress.
  1676. */
  1677. function isResolving(state, selectorName, args) {
  1678. var _getResolutionState3;
  1679. return ((_getResolutionState3 = getResolutionState(state, selectorName, args)) === null || _getResolutionState3 === void 0 ? void 0 : _getResolutionState3.status) === 'resolving';
  1680. }
  1681. /**
  1682. * Returns the list of the cached resolvers.
  1683. *
  1684. * @param {State} state Data state.
  1685. *
  1686. * @return {State} Resolvers mapped by args and selectorName.
  1687. */
  1688. function getCachedResolvers(state) {
  1689. return state;
  1690. }
  1691. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js
  1692. /**
  1693. * Returns an action object used in signalling that selector resolution has
  1694. * started.
  1695. *
  1696. * @param {string} selectorName Name of selector for which resolver triggered.
  1697. * @param {unknown[]} args Arguments to associate for uniqueness.
  1698. *
  1699. * @return {{ type: 'START_RESOLUTION', selectorName: string, args: unknown[] }} Action object.
  1700. */
  1701. function startResolution(selectorName, args) {
  1702. return {
  1703. type: 'START_RESOLUTION',
  1704. selectorName,
  1705. args
  1706. };
  1707. }
  1708. /**
  1709. * Returns an action object used in signalling that selector resolution has
  1710. * completed.
  1711. *
  1712. * @param {string} selectorName Name of selector for which resolver triggered.
  1713. * @param {unknown[]} args Arguments to associate for uniqueness.
  1714. *
  1715. * @return {{ type: 'FINISH_RESOLUTION', selectorName: string, args: unknown[] }} Action object.
  1716. */
  1717. function finishResolution(selectorName, args) {
  1718. return {
  1719. type: 'FINISH_RESOLUTION',
  1720. selectorName,
  1721. args
  1722. };
  1723. }
  1724. /**
  1725. * Returns an action object used in signalling that selector resolution has
  1726. * failed.
  1727. *
  1728. * @param {string} selectorName Name of selector for which resolver triggered.
  1729. * @param {unknown[]} args Arguments to associate for uniqueness.
  1730. * @param {Error|unknown} error The error that caused the failure.
  1731. *
  1732. * @return {{ type: 'FAIL_RESOLUTION', selectorName: string, args: unknown[], error: Error|unknown }} Action object.
  1733. */
  1734. function failResolution(selectorName, args, error) {
  1735. return {
  1736. type: 'FAIL_RESOLUTION',
  1737. selectorName,
  1738. args,
  1739. error
  1740. };
  1741. }
  1742. /**
  1743. * Returns an action object used in signalling that a batch of selector resolutions has
  1744. * started.
  1745. *
  1746. * @param {string} selectorName Name of selector for which resolver triggered.
  1747. * @param {unknown[][]} args Array of arguments to associate for uniqueness, each item
  1748. * is associated to a resolution.
  1749. *
  1750. * @return {{ type: 'START_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object.
  1751. */
  1752. function startResolutions(selectorName, args) {
  1753. return {
  1754. type: 'START_RESOLUTIONS',
  1755. selectorName,
  1756. args
  1757. };
  1758. }
  1759. /**
  1760. * Returns an action object used in signalling that a batch of selector resolutions has
  1761. * completed.
  1762. *
  1763. * @param {string} selectorName Name of selector for which resolver triggered.
  1764. * @param {unknown[][]} args Array of arguments to associate for uniqueness, each item
  1765. * is associated to a resolution.
  1766. *
  1767. * @return {{ type: 'FINISH_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object.
  1768. */
  1769. function finishResolutions(selectorName, args) {
  1770. return {
  1771. type: 'FINISH_RESOLUTIONS',
  1772. selectorName,
  1773. args
  1774. };
  1775. }
  1776. /**
  1777. * Returns an action object used in signalling that a batch of selector resolutions has
  1778. * completed and at least one of them has failed.
  1779. *
  1780. * @param {string} selectorName Name of selector for which resolver triggered.
  1781. * @param {unknown[]} args Array of arguments to associate for uniqueness, each item
  1782. * is associated to a resolution.
  1783. * @param {(Error|unknown)[]} errors Array of errors to associate for uniqueness, each item
  1784. * is associated to a resolution.
  1785. * @return {{ type: 'FAIL_RESOLUTIONS', selectorName: string, args: unknown[], errors: Array<Error|unknown> }} Action object.
  1786. */
  1787. function failResolutions(selectorName, args, errors) {
  1788. return {
  1789. type: 'FAIL_RESOLUTIONS',
  1790. selectorName,
  1791. args,
  1792. errors
  1793. };
  1794. }
  1795. /**
  1796. * Returns an action object used in signalling that we should invalidate the resolution cache.
  1797. *
  1798. * @param {string} selectorName Name of selector for which resolver should be invalidated.
  1799. * @param {unknown[]} args Arguments to associate for uniqueness.
  1800. *
  1801. * @return {{ type: 'INVALIDATE_RESOLUTION', selectorName: string, args: any[] }} Action object.
  1802. */
  1803. function invalidateResolution(selectorName, args) {
  1804. return {
  1805. type: 'INVALIDATE_RESOLUTION',
  1806. selectorName,
  1807. args
  1808. };
  1809. }
  1810. /**
  1811. * Returns an action object used in signalling that the resolution
  1812. * should be invalidated.
  1813. *
  1814. * @return {{ type: 'INVALIDATE_RESOLUTION_FOR_STORE' }} Action object.
  1815. */
  1816. function invalidateResolutionForStore() {
  1817. return {
  1818. type: 'INVALIDATE_RESOLUTION_FOR_STORE'
  1819. };
  1820. }
  1821. /**
  1822. * Returns an action object used in signalling that the resolution cache for a
  1823. * given selectorName should be invalidated.
  1824. *
  1825. * @param {string} selectorName Name of selector for which all resolvers should
  1826. * be invalidated.
  1827. *
  1828. * @return {{ type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR', selectorName: string }} Action object.
  1829. */
  1830. function invalidateResolutionForStoreSelector(selectorName) {
  1831. return {
  1832. type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR',
  1833. selectorName
  1834. };
  1835. }
  1836. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/index.js
  1837. /**
  1838. * External dependencies
  1839. */
  1840. /**
  1841. * WordPress dependencies
  1842. */
  1843. /**
  1844. * Internal dependencies
  1845. */
  1846. /** @typedef {import('../types').DataRegistry} DataRegistry */
  1847. /** @typedef {import('../types').StoreDescriptor} StoreDescriptor */
  1848. /** @typedef {import('../types').ReduxStoreConfig} ReduxStoreConfig */
  1849. const trimUndefinedValues = array => {
  1850. const result = [...array];
  1851. for (let i = result.length - 1; i >= 0; i--) {
  1852. if (result[i] === undefined) {
  1853. result.splice(i, 1);
  1854. }
  1855. }
  1856. return result;
  1857. };
  1858. /**
  1859. * Create a cache to track whether resolvers started running or not.
  1860. *
  1861. * @return {Object} Resolvers Cache.
  1862. */
  1863. function createResolversCache() {
  1864. const cache = {};
  1865. return {
  1866. isRunning(selectorName, args) {
  1867. return cache[selectorName] && cache[selectorName].get(trimUndefinedValues(args));
  1868. },
  1869. clear(selectorName, args) {
  1870. if (cache[selectorName]) {
  1871. cache[selectorName].delete(trimUndefinedValues(args));
  1872. }
  1873. },
  1874. markAsRunning(selectorName, args) {
  1875. if (!cache[selectorName]) {
  1876. cache[selectorName] = new (equivalent_key_map_default())();
  1877. }
  1878. cache[selectorName].set(trimUndefinedValues(args), true);
  1879. }
  1880. };
  1881. }
  1882. /**
  1883. * Creates a data store descriptor for the provided Redux store configuration containing
  1884. * properties describing reducer, actions, selectors, controls and resolvers.
  1885. *
  1886. * @example
  1887. * ```js
  1888. * import { createReduxStore } from '@wordpress/data';
  1889. *
  1890. * const store = createReduxStore( 'demo', {
  1891. * reducer: ( state = 'OK' ) => state,
  1892. * selectors: {
  1893. * getValue: ( state ) => state,
  1894. * },
  1895. * } );
  1896. * ```
  1897. *
  1898. * @param {string} key Unique namespace identifier.
  1899. * @param {ReduxStoreConfig} options Registered store options, with properties
  1900. * describing reducer, actions, selectors,
  1901. * and resolvers.
  1902. *
  1903. * @return {StoreDescriptor} Store Object.
  1904. */
  1905. function createReduxStore(key, options) {
  1906. return {
  1907. name: key,
  1908. instantiate: registry => {
  1909. const reducer = options.reducer;
  1910. const thunkArgs = {
  1911. registry,
  1912. get dispatch() {
  1913. return Object.assign(action => store.dispatch(action), getActions());
  1914. },
  1915. get select() {
  1916. return Object.assign(selector => selector(store.__unstableOriginalGetState()), getSelectors());
  1917. },
  1918. get resolveSelect() {
  1919. return getResolveSelectors();
  1920. }
  1921. };
  1922. const store = instantiateReduxStore(key, options, registry, thunkArgs);
  1923. const resolversCache = createResolversCache();
  1924. let resolvers;
  1925. const actions = mapActions({ ...actions_namespaceObject,
  1926. ...options.actions
  1927. }, store);
  1928. let selectors = mapSelectors({ ...(0,external_lodash_namespaceObject.mapValues)(selectors_namespaceObject, selector => function (state) {
  1929. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  1930. args[_key - 1] = arguments[_key];
  1931. }
  1932. return selector(state.metadata, ...args);
  1933. }),
  1934. ...(0,external_lodash_namespaceObject.mapValues)(options.selectors, selector => {
  1935. if (selector.isRegistrySelector) {
  1936. selector.registry = registry;
  1937. }
  1938. return function (state) {
  1939. for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  1940. args[_key2 - 1] = arguments[_key2];
  1941. }
  1942. return selector(state.root, ...args);
  1943. };
  1944. })
  1945. }, store);
  1946. if (options.resolvers) {
  1947. const result = mapResolvers(options.resolvers, selectors, store, resolversCache);
  1948. resolvers = result.resolvers;
  1949. selectors = result.selectors;
  1950. }
  1951. const resolveSelectors = mapResolveSelectors(selectors, store);
  1952. const getSelectors = () => selectors;
  1953. const getActions = () => actions;
  1954. const getResolveSelectors = () => resolveSelectors; // We have some modules monkey-patching the store object
  1955. // It's wrong to do so but until we refactor all of our effects to controls
  1956. // We need to keep the same "store" instance here.
  1957. store.__unstableOriginalGetState = store.getState;
  1958. store.getState = () => store.__unstableOriginalGetState().root; // Customize subscribe behavior to call listeners only on effective change,
  1959. // not on every dispatch.
  1960. const subscribe = store && (listener => {
  1961. let lastState = store.__unstableOriginalGetState();
  1962. return store.subscribe(() => {
  1963. const state = store.__unstableOriginalGetState();
  1964. const hasChanged = state !== lastState;
  1965. lastState = state;
  1966. if (hasChanged) {
  1967. listener();
  1968. }
  1969. });
  1970. }); // This can be simplified to just { subscribe, getSelectors, getActions }
  1971. // Once we remove the use function.
  1972. return {
  1973. reducer,
  1974. store,
  1975. actions,
  1976. selectors,
  1977. resolvers,
  1978. getSelectors,
  1979. getResolveSelectors,
  1980. getActions,
  1981. subscribe
  1982. };
  1983. }
  1984. };
  1985. }
  1986. /**
  1987. * Creates a redux store for a namespace.
  1988. *
  1989. * @param {string} key Unique namespace identifier.
  1990. * @param {Object} options Registered store options, with properties
  1991. * describing reducer, actions, selectors,
  1992. * and resolvers.
  1993. * @param {DataRegistry} registry Registry reference.
  1994. * @param {Object} thunkArgs Argument object for the thunk middleware.
  1995. * @return {Object} Newly created redux store.
  1996. */
  1997. function instantiateReduxStore(key, options, registry, thunkArgs) {
  1998. const controls = { ...options.controls,
  1999. ...builtinControls
  2000. };
  2001. const normalizedControls = (0,external_lodash_namespaceObject.mapValues)(controls, control => control.isRegistryControl ? control(registry) : control);
  2002. const middlewares = [resolvers_cache_middleware(registry, key), promise_middleware, external_wp_reduxRoutine_default()(normalizedControls), createThunkMiddleware(thunkArgs)];
  2003. const enhancers = [applyMiddleware(...middlewares)];
  2004. if (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__) {
  2005. enhancers.push(window.__REDUX_DEVTOOLS_EXTENSION__({
  2006. name: key,
  2007. instanceId: key
  2008. }));
  2009. }
  2010. const {
  2011. reducer,
  2012. initialState
  2013. } = options;
  2014. const enhancedReducer = turbo_combine_reducers_default()({
  2015. metadata: metadata_reducer,
  2016. root: reducer
  2017. });
  2018. return createStore(enhancedReducer, {
  2019. root: initialState
  2020. }, (0,external_lodash_namespaceObject.flowRight)(enhancers));
  2021. }
  2022. /**
  2023. * Maps selectors to a store.
  2024. *
  2025. * @param {Object} selectors Selectors to register. Keys will be used as the
  2026. * public facing API. Selectors will get passed the
  2027. * state as first argument.
  2028. * @param {Object} store The store to which the selectors should be mapped.
  2029. * @return {Object} Selectors mapped to the provided store.
  2030. */
  2031. function mapSelectors(selectors, store) {
  2032. const createStateSelector = registrySelector => {
  2033. const selector = function runSelector() {
  2034. // This function is an optimized implementation of:
  2035. //
  2036. // selector( store.getState(), ...arguments )
  2037. //
  2038. // Where the above would incur an `Array#concat` in its application,
  2039. // the logic here instead efficiently constructs an arguments array via
  2040. // direct assignment.
  2041. const argsLength = arguments.length;
  2042. const args = new Array(argsLength + 1);
  2043. args[0] = store.__unstableOriginalGetState();
  2044. for (let i = 0; i < argsLength; i++) {
  2045. args[i + 1] = arguments[i];
  2046. }
  2047. return registrySelector(...args);
  2048. };
  2049. selector.hasResolver = false;
  2050. return selector;
  2051. };
  2052. return (0,external_lodash_namespaceObject.mapValues)(selectors, createStateSelector);
  2053. }
  2054. /**
  2055. * Maps actions to dispatch from a given store.
  2056. *
  2057. * @param {Object} actions Actions to register.
  2058. * @param {Object} store The redux store to which the actions should be mapped.
  2059. *
  2060. * @return {Object} Actions mapped to the redux store provided.
  2061. */
  2062. function mapActions(actions, store) {
  2063. const createBoundAction = action => function () {
  2064. return Promise.resolve(store.dispatch(action(...arguments)));
  2065. };
  2066. return (0,external_lodash_namespaceObject.mapValues)(actions, createBoundAction);
  2067. }
  2068. /**
  2069. * Maps selectors to functions that return a resolution promise for them
  2070. *
  2071. * @param {Object} selectors Selectors to map.
  2072. * @param {Object} store The redux store the selectors select from.
  2073. *
  2074. * @return {Object} Selectors mapped to their resolution functions.
  2075. */
  2076. function mapResolveSelectors(selectors, store) {
  2077. const storeSelectors = (0,external_lodash_namespaceObject.omit)(selectors, ['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'hasResolutionFailed', 'isResolving', 'getCachedResolvers', 'getResolutionState', 'getResolutionError']);
  2078. return (0,external_lodash_namespaceObject.mapValues)(storeSelectors, (selector, selectorName) => {
  2079. // If the selector doesn't have a resolver, just convert the return value
  2080. // (including exceptions) to a Promise, no additional extra behavior is needed.
  2081. if (!selector.hasResolver) {
  2082. return async function () {
  2083. for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  2084. args[_key3] = arguments[_key3];
  2085. }
  2086. return selector.apply(null, args);
  2087. };
  2088. }
  2089. return function () {
  2090. for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  2091. args[_key4] = arguments[_key4];
  2092. }
  2093. return new Promise((resolve, reject) => {
  2094. const hasFinished = () => selectors.hasFinishedResolution(selectorName, args);
  2095. const finalize = result => {
  2096. const hasFailed = selectors.hasResolutionFailed(selectorName, args);
  2097. if (hasFailed) {
  2098. const error = selectors.getResolutionError(selectorName, args);
  2099. reject(error);
  2100. } else {
  2101. resolve(result);
  2102. }
  2103. };
  2104. const getResult = () => selector.apply(null, args); // Trigger the selector (to trigger the resolver)
  2105. const result = getResult();
  2106. if (hasFinished()) {
  2107. return finalize(result);
  2108. }
  2109. const unsubscribe = store.subscribe(() => {
  2110. if (hasFinished()) {
  2111. unsubscribe();
  2112. finalize(getResult());
  2113. }
  2114. });
  2115. });
  2116. };
  2117. });
  2118. }
  2119. /**
  2120. * Returns resolvers with matched selectors for a given namespace.
  2121. * Resolvers are side effects invoked once per argument set of a given selector call,
  2122. * used in ensuring that the data needs for the selector are satisfied.
  2123. *
  2124. * @param {Object} resolvers Resolvers to register.
  2125. * @param {Object} selectors The current selectors to be modified.
  2126. * @param {Object} store The redux store to which the resolvers should be mapped.
  2127. * @param {Object} resolversCache Resolvers Cache.
  2128. */
  2129. function mapResolvers(resolvers, selectors, store, resolversCache) {
  2130. // The `resolver` can be either a function that does the resolution, or, in more advanced
  2131. // cases, an object with a `fullfill` method and other optional methods like `isFulfilled`.
  2132. // Here we normalize the `resolver` function to an object with `fulfill` method.
  2133. const mappedResolvers = (0,external_lodash_namespaceObject.mapValues)(resolvers, resolver => {
  2134. if (resolver.fulfill) {
  2135. return resolver;
  2136. }
  2137. return { ...resolver,
  2138. // Copy the enumerable properties of the resolver function.
  2139. fulfill: resolver // Add the fulfill method.
  2140. };
  2141. });
  2142. const mapSelector = (selector, selectorName) => {
  2143. const resolver = resolvers[selectorName];
  2144. if (!resolver) {
  2145. selector.hasResolver = false;
  2146. return selector;
  2147. }
  2148. const selectorResolver = function () {
  2149. for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
  2150. args[_key5] = arguments[_key5];
  2151. }
  2152. async function fulfillSelector() {
  2153. const state = store.getState();
  2154. if (resolversCache.isRunning(selectorName, args) || typeof resolver.isFulfilled === 'function' && resolver.isFulfilled(state, ...args)) {
  2155. return;
  2156. }
  2157. const {
  2158. metadata
  2159. } = store.__unstableOriginalGetState();
  2160. if (hasStartedResolution(metadata, selectorName, args)) {
  2161. return;
  2162. }
  2163. resolversCache.markAsRunning(selectorName, args);
  2164. setTimeout(async () => {
  2165. resolversCache.clear(selectorName, args);
  2166. store.dispatch(startResolution(selectorName, args));
  2167. try {
  2168. await fulfillResolver(store, mappedResolvers, selectorName, ...args);
  2169. store.dispatch(finishResolution(selectorName, args));
  2170. } catch (error) {
  2171. store.dispatch(failResolution(selectorName, args, error));
  2172. }
  2173. });
  2174. }
  2175. fulfillSelector(...args);
  2176. return selector(...args);
  2177. };
  2178. selectorResolver.hasResolver = true;
  2179. return selectorResolver;
  2180. };
  2181. return {
  2182. resolvers: mappedResolvers,
  2183. selectors: (0,external_lodash_namespaceObject.mapValues)(selectors, mapSelector)
  2184. };
  2185. }
  2186. /**
  2187. * Calls a resolver given arguments
  2188. *
  2189. * @param {Object} store Store reference, for fulfilling via resolvers
  2190. * @param {Object} resolvers Store Resolvers
  2191. * @param {string} selectorName Selector name to fulfill.
  2192. * @param {Array} args Selector Arguments.
  2193. */
  2194. async function fulfillResolver(store, resolvers, selectorName) {
  2195. const resolver = (0,external_lodash_namespaceObject.get)(resolvers, [selectorName]);
  2196. if (!resolver) {
  2197. return;
  2198. }
  2199. for (var _len6 = arguments.length, args = new Array(_len6 > 3 ? _len6 - 3 : 0), _key6 = 3; _key6 < _len6; _key6++) {
  2200. args[_key6 - 3] = arguments[_key6];
  2201. }
  2202. const action = resolver.fulfill(...args);
  2203. if (action) {
  2204. await store.dispatch(action);
  2205. }
  2206. }
  2207. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/utils/emitter.js
  2208. /**
  2209. * Create an event emitter.
  2210. *
  2211. * @return {import("../types").DataEmitter} Emitter.
  2212. */
  2213. function createEmitter() {
  2214. let isPaused = false;
  2215. let isPending = false;
  2216. const listeners = new Set();
  2217. const notifyListeners = () => // We use Array.from to clone the listeners Set
  2218. // This ensures that we don't run a listener
  2219. // that was added as a response to another listener.
  2220. Array.from(listeners).forEach(listener => listener());
  2221. return {
  2222. get isPaused() {
  2223. return isPaused;
  2224. },
  2225. subscribe(listener) {
  2226. listeners.add(listener);
  2227. return () => listeners.delete(listener);
  2228. },
  2229. pause() {
  2230. isPaused = true;
  2231. },
  2232. resume() {
  2233. isPaused = false;
  2234. if (isPending) {
  2235. isPending = false;
  2236. notifyListeners();
  2237. }
  2238. },
  2239. emit() {
  2240. if (isPaused) {
  2241. isPending = true;
  2242. return;
  2243. }
  2244. notifyListeners();
  2245. }
  2246. };
  2247. }
  2248. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/registry.js
  2249. /**
  2250. * External dependencies
  2251. */
  2252. /**
  2253. * WordPress dependencies
  2254. */
  2255. /**
  2256. * Internal dependencies
  2257. */
  2258. /** @typedef {import('./types').StoreDescriptor} StoreDescriptor */
  2259. /**
  2260. * @typedef {Object} WPDataRegistry An isolated orchestrator of store registrations.
  2261. *
  2262. * @property {Function} registerGenericStore Given a namespace key and settings
  2263. * object, registers a new generic
  2264. * store.
  2265. * @property {Function} registerStore Given a namespace key and settings
  2266. * object, registers a new namespace
  2267. * store.
  2268. * @property {Function} subscribe Given a function callback, invokes
  2269. * the callback on any change to state
  2270. * within any registered store.
  2271. * @property {Function} select Given a namespace key, returns an
  2272. * object of the store's registered
  2273. * selectors.
  2274. * @property {Function} dispatch Given a namespace key, returns an
  2275. * object of the store's registered
  2276. * action dispatchers.
  2277. */
  2278. /**
  2279. * @typedef {Object} WPDataPlugin An object of registry function overrides.
  2280. *
  2281. * @property {Function} registerStore registers store.
  2282. */
  2283. /**
  2284. * Creates a new store registry, given an optional object of initial store
  2285. * configurations.
  2286. *
  2287. * @param {Object} storeConfigs Initial store configurations.
  2288. * @param {Object?} parent Parent registry.
  2289. *
  2290. * @return {WPDataRegistry} Data registry.
  2291. */
  2292. function createRegistry() {
  2293. let storeConfigs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  2294. let parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  2295. const stores = {};
  2296. const emitter = createEmitter();
  2297. const listeningStores = new Set();
  2298. /**
  2299. * Global listener called for each store's update.
  2300. */
  2301. function globalListener() {
  2302. emitter.emit();
  2303. }
  2304. /**
  2305. * Subscribe to changes to any data.
  2306. *
  2307. * @param {Function} listener Listener function.
  2308. *
  2309. * @return {Function} Unsubscribe function.
  2310. */
  2311. const subscribe = listener => {
  2312. return emitter.subscribe(listener);
  2313. };
  2314. /**
  2315. * Calls a selector given the current state and extra arguments.
  2316. *
  2317. * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
  2318. * or the store descriptor.
  2319. *
  2320. * @return {*} The selector's returned value.
  2321. */
  2322. function select(storeNameOrDescriptor) {
  2323. const storeName = (0,external_lodash_namespaceObject.isObject)(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor;
  2324. listeningStores.add(storeName);
  2325. const store = stores[storeName];
  2326. if (store) {
  2327. return store.getSelectors();
  2328. }
  2329. return parent && parent.select(storeName);
  2330. }
  2331. function __unstableMarkListeningStores(callback, ref) {
  2332. listeningStores.clear();
  2333. const result = callback.call(this);
  2334. ref.current = Array.from(listeningStores);
  2335. return result;
  2336. }
  2337. /**
  2338. * Given the name of a registered store, returns an object containing the store's
  2339. * selectors pre-bound to state so that you only need to supply additional arguments,
  2340. * and modified so that they return promises that resolve to their eventual values,
  2341. * after any resolvers have ran.
  2342. *
  2343. * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
  2344. * or the store descriptor.
  2345. *
  2346. * @return {Object} Each key of the object matches the name of a selector.
  2347. */
  2348. function resolveSelect(storeNameOrDescriptor) {
  2349. const storeName = (0,external_lodash_namespaceObject.isObject)(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor;
  2350. listeningStores.add(storeName);
  2351. const store = stores[storeName];
  2352. if (store) {
  2353. return store.getResolveSelectors();
  2354. }
  2355. return parent && parent.resolveSelect(storeName);
  2356. }
  2357. /**
  2358. * Returns the available actions for a part of the state.
  2359. *
  2360. * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
  2361. * or the store descriptor.
  2362. *
  2363. * @return {*} The action's returned value.
  2364. */
  2365. function dispatch(storeNameOrDescriptor) {
  2366. const storeName = (0,external_lodash_namespaceObject.isObject)(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor;
  2367. const store = stores[storeName];
  2368. if (store) {
  2369. return store.getActions();
  2370. }
  2371. return parent && parent.dispatch(storeName);
  2372. } //
  2373. // Deprecated
  2374. // TODO: Remove this after `use()` is removed.
  2375. function withPlugins(attributes) {
  2376. return (0,external_lodash_namespaceObject.mapValues)(attributes, (attribute, key) => {
  2377. if (typeof attribute !== 'function') {
  2378. return attribute;
  2379. }
  2380. return function () {
  2381. return registry[key].apply(null, arguments);
  2382. };
  2383. });
  2384. }
  2385. /**
  2386. * Registers a store instance.
  2387. *
  2388. * @param {string} name Store registry name.
  2389. * @param {Object} store Store instance object (getSelectors, getActions, subscribe).
  2390. */
  2391. function registerStoreInstance(name, store) {
  2392. if (typeof store.getSelectors !== 'function') {
  2393. throw new TypeError('store.getSelectors must be a function');
  2394. }
  2395. if (typeof store.getActions !== 'function') {
  2396. throw new TypeError('store.getActions must be a function');
  2397. }
  2398. if (typeof store.subscribe !== 'function') {
  2399. throw new TypeError('store.subscribe must be a function');
  2400. } // The emitter is used to keep track of active listeners when the registry
  2401. // get paused, that way, when resumed we should be able to call all these
  2402. // pending listeners.
  2403. store.emitter = createEmitter();
  2404. const currentSubscribe = store.subscribe;
  2405. store.subscribe = listener => {
  2406. const unsubscribeFromEmitter = store.emitter.subscribe(listener);
  2407. const unsubscribeFromStore = currentSubscribe(() => {
  2408. if (store.emitter.isPaused) {
  2409. store.emitter.emit();
  2410. return;
  2411. }
  2412. listener();
  2413. });
  2414. return () => {
  2415. unsubscribeFromStore === null || unsubscribeFromStore === void 0 ? void 0 : unsubscribeFromStore();
  2416. unsubscribeFromEmitter === null || unsubscribeFromEmitter === void 0 ? void 0 : unsubscribeFromEmitter();
  2417. };
  2418. };
  2419. stores[name] = store;
  2420. store.subscribe(globalListener);
  2421. }
  2422. /**
  2423. * Registers a new store given a store descriptor.
  2424. *
  2425. * @param {StoreDescriptor} store Store descriptor.
  2426. */
  2427. function register(store) {
  2428. registerStoreInstance(store.name, store.instantiate(registry));
  2429. }
  2430. function registerGenericStore(name, store) {
  2431. external_wp_deprecated_default()('wp.data.registerGenericStore', {
  2432. since: '5.9',
  2433. alternative: 'wp.data.register( storeDescriptor )'
  2434. });
  2435. registerStoreInstance(name, store);
  2436. }
  2437. /**
  2438. * Registers a standard `@wordpress/data` store.
  2439. *
  2440. * @param {string} storeName Unique namespace identifier.
  2441. * @param {Object} options Store description (reducer, actions, selectors, resolvers).
  2442. *
  2443. * @return {Object} Registered store object.
  2444. */
  2445. function registerStore(storeName, options) {
  2446. if (!options.reducer) {
  2447. throw new TypeError('Must specify store reducer');
  2448. }
  2449. const store = createReduxStore(storeName, options).instantiate(registry);
  2450. registerStoreInstance(storeName, store);
  2451. return store.store;
  2452. }
  2453. /**
  2454. * Subscribe handler to a store.
  2455. *
  2456. * @param {string[]} storeName The store name.
  2457. * @param {Function} handler The function subscribed to the store.
  2458. * @return {Function} A function to unsubscribe the handler.
  2459. */
  2460. function __unstableSubscribeStore(storeName, handler) {
  2461. if (storeName in stores) {
  2462. return stores[storeName].subscribe(handler);
  2463. } // Trying to access a store that hasn't been registered,
  2464. // this is a pattern rarely used but seen in some places.
  2465. // We fallback to regular `subscribe` here for backward-compatibility for now.
  2466. // See https://github.com/WordPress/gutenberg/pull/27466 for more info.
  2467. if (!parent) {
  2468. return subscribe(handler);
  2469. }
  2470. return parent.__unstableSubscribeStore(storeName, handler);
  2471. }
  2472. function batch(callback) {
  2473. emitter.pause();
  2474. (0,external_lodash_namespaceObject.forEach)(stores, store => store.emitter.pause());
  2475. callback();
  2476. emitter.resume();
  2477. (0,external_lodash_namespaceObject.forEach)(stores, store => store.emitter.resume());
  2478. }
  2479. let registry = {
  2480. batch,
  2481. stores,
  2482. namespaces: stores,
  2483. // TODO: Deprecate/remove this.
  2484. subscribe,
  2485. select,
  2486. resolveSelect,
  2487. dispatch,
  2488. use,
  2489. register,
  2490. registerGenericStore,
  2491. registerStore,
  2492. __unstableMarkListeningStores,
  2493. __unstableSubscribeStore
  2494. }; //
  2495. // TODO:
  2496. // This function will be deprecated as soon as it is no longer internally referenced.
  2497. function use(plugin, options) {
  2498. if (!plugin) {
  2499. return;
  2500. }
  2501. registry = { ...registry,
  2502. ...plugin(registry, options)
  2503. };
  2504. return registry;
  2505. }
  2506. registry.register(store);
  2507. for (const [name, config] of Object.entries(storeConfigs)) {
  2508. registry.register(createReduxStore(name, config));
  2509. }
  2510. if (parent) {
  2511. parent.subscribe(globalListener);
  2512. }
  2513. return withPlugins(registry);
  2514. }
  2515. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/default-registry.js
  2516. /**
  2517. * Internal dependencies
  2518. */
  2519. /* harmony default export */ var default_registry = (createRegistry());
  2520. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/object.js
  2521. let objectStorage;
  2522. const storage = {
  2523. getItem(key) {
  2524. if (!objectStorage || !objectStorage[key]) {
  2525. return null;
  2526. }
  2527. return objectStorage[key];
  2528. },
  2529. setItem(key, value) {
  2530. if (!objectStorage) {
  2531. storage.clear();
  2532. }
  2533. objectStorage[key] = String(value);
  2534. },
  2535. clear() {
  2536. objectStorage = Object.create(null);
  2537. }
  2538. };
  2539. /* harmony default export */ var object = (storage);
  2540. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/default.js
  2541. /**
  2542. * Internal dependencies
  2543. */
  2544. let default_storage;
  2545. try {
  2546. // Private Browsing in Safari 10 and earlier will throw an error when
  2547. // attempting to set into localStorage. The test here is intentional in
  2548. // causing a thrown error as condition for using fallback object storage.
  2549. default_storage = window.localStorage;
  2550. default_storage.setItem('__wpDataTestLocalStorage', '');
  2551. default_storage.removeItem('__wpDataTestLocalStorage');
  2552. } catch (error) {
  2553. default_storage = object;
  2554. }
  2555. /* harmony default export */ var storage_default = (default_storage);
  2556. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/index.js
  2557. /**
  2558. * External dependencies
  2559. */
  2560. /**
  2561. * Internal dependencies
  2562. */
  2563. /** @typedef {import('../../registry').WPDataRegistry} WPDataRegistry */
  2564. /** @typedef {import('../../registry').WPDataPlugin} WPDataPlugin */
  2565. /**
  2566. * @typedef {Object} WPDataPersistencePluginOptions Persistence plugin options.
  2567. *
  2568. * @property {Storage} storage Persistent storage implementation. This must
  2569. * at least implement `getItem` and `setItem` of
  2570. * the Web Storage API.
  2571. * @property {string} storageKey Key on which to set in persistent storage.
  2572. *
  2573. */
  2574. /**
  2575. * Default plugin storage.
  2576. *
  2577. * @type {Storage}
  2578. */
  2579. const DEFAULT_STORAGE = storage_default;
  2580. /**
  2581. * Default plugin storage key.
  2582. *
  2583. * @type {string}
  2584. */
  2585. const DEFAULT_STORAGE_KEY = 'WP_DATA';
  2586. /**
  2587. * Higher-order reducer which invokes the original reducer only if state is
  2588. * inequal from that of the action's `nextState` property, otherwise returning
  2589. * the original state reference.
  2590. *
  2591. * @param {Function} reducer Original reducer.
  2592. *
  2593. * @return {Function} Enhanced reducer.
  2594. */
  2595. const withLazySameState = reducer => (state, action) => {
  2596. if (action.nextState === state) {
  2597. return state;
  2598. }
  2599. return reducer(state, action);
  2600. };
  2601. /**
  2602. * Creates a persistence interface, exposing getter and setter methods (`get`
  2603. * and `set` respectively).
  2604. *
  2605. * @param {WPDataPersistencePluginOptions} options Plugin options.
  2606. *
  2607. * @return {Object} Persistence interface.
  2608. */
  2609. function createPersistenceInterface(options) {
  2610. const {
  2611. storage = DEFAULT_STORAGE,
  2612. storageKey = DEFAULT_STORAGE_KEY
  2613. } = options;
  2614. let data;
  2615. /**
  2616. * Returns the persisted data as an object, defaulting to an empty object.
  2617. *
  2618. * @return {Object} Persisted data.
  2619. */
  2620. function getData() {
  2621. if (data === undefined) {
  2622. // If unset, getItem is expected to return null. Fall back to
  2623. // empty object.
  2624. const persisted = storage.getItem(storageKey);
  2625. if (persisted === null) {
  2626. data = {};
  2627. } else {
  2628. try {
  2629. data = JSON.parse(persisted);
  2630. } catch (error) {
  2631. // Similarly, should any error be thrown during parse of
  2632. // the string (malformed JSON), fall back to empty object.
  2633. data = {};
  2634. }
  2635. }
  2636. }
  2637. return data;
  2638. }
  2639. /**
  2640. * Merges an updated reducer state into the persisted data.
  2641. *
  2642. * @param {string} key Key to update.
  2643. * @param {*} value Updated value.
  2644. */
  2645. function setData(key, value) {
  2646. data = { ...data,
  2647. [key]: value
  2648. };
  2649. storage.setItem(storageKey, JSON.stringify(data));
  2650. }
  2651. return {
  2652. get: getData,
  2653. set: setData
  2654. };
  2655. }
  2656. /**
  2657. * Data plugin to persist store state into a single storage key.
  2658. *
  2659. * @param {WPDataRegistry} registry Data registry.
  2660. * @param {?WPDataPersistencePluginOptions} pluginOptions Plugin options.
  2661. *
  2662. * @return {WPDataPlugin} Data plugin.
  2663. */
  2664. function persistencePlugin(registry, pluginOptions) {
  2665. const persistence = createPersistenceInterface(pluginOptions);
  2666. /**
  2667. * Creates an enhanced store dispatch function, triggering the state of the
  2668. * given store name to be persisted when changed.
  2669. *
  2670. * @param {Function} getState Function which returns current state.
  2671. * @param {string} storeName Store name.
  2672. * @param {?Array<string>} keys Optional subset of keys to save.
  2673. *
  2674. * @return {Function} Enhanced dispatch function.
  2675. */
  2676. function createPersistOnChange(getState, storeName, keys) {
  2677. let getPersistedState;
  2678. if (Array.isArray(keys)) {
  2679. // Given keys, the persisted state should by produced as an object
  2680. // of the subset of keys. This implementation uses combineReducers
  2681. // to leverage its behavior of returning the same object when none
  2682. // of the property values changes. This allows a strict reference
  2683. // equality to bypass a persistence set on an unchanging state.
  2684. const reducers = keys.reduce((accumulator, key) => Object.assign(accumulator, {
  2685. [key]: (state, action) => action.nextState[key]
  2686. }), {});
  2687. getPersistedState = withLazySameState(turbo_combine_reducers_default()(reducers));
  2688. } else {
  2689. getPersistedState = (state, action) => action.nextState;
  2690. }
  2691. let lastState = getPersistedState(undefined, {
  2692. nextState: getState()
  2693. });
  2694. return () => {
  2695. const state = getPersistedState(lastState, {
  2696. nextState: getState()
  2697. });
  2698. if (state !== lastState) {
  2699. persistence.set(storeName, state);
  2700. lastState = state;
  2701. }
  2702. };
  2703. }
  2704. return {
  2705. registerStore(storeName, options) {
  2706. if (!options.persist) {
  2707. return registry.registerStore(storeName, options);
  2708. } // Load from persistence to use as initial state.
  2709. const persistedState = persistence.get()[storeName];
  2710. if (persistedState !== undefined) {
  2711. let initialState = options.reducer(options.initialState, {
  2712. type: '@@WP/PERSISTENCE_RESTORE'
  2713. });
  2714. if ((0,external_lodash_namespaceObject.isPlainObject)(initialState) && (0,external_lodash_namespaceObject.isPlainObject)(persistedState)) {
  2715. // If state is an object, ensure that:
  2716. // - Other keys are left intact when persisting only a
  2717. // subset of keys.
  2718. // - New keys in what would otherwise be used as initial
  2719. // state are deeply merged as base for persisted value.
  2720. initialState = (0,external_lodash_namespaceObject.merge)({}, initialState, persistedState);
  2721. } else {
  2722. // If there is a mismatch in object-likeness of default
  2723. // initial or persisted state, defer to persisted value.
  2724. initialState = persistedState;
  2725. }
  2726. options = { ...options,
  2727. initialState
  2728. };
  2729. }
  2730. const store = registry.registerStore(storeName, options);
  2731. store.subscribe(createPersistOnChange(store.getState, storeName, options.persist));
  2732. return store;
  2733. }
  2734. };
  2735. }
  2736. /**
  2737. * Move the 'features' object in local storage from the sourceStoreName to the
  2738. * preferences store.
  2739. *
  2740. * @param {Object} persistence The persistence interface.
  2741. * @param {string} sourceStoreName The name of the store that has persisted
  2742. * preferences to migrate to the preferences
  2743. * package.
  2744. */
  2745. function migrateFeaturePreferencesToPreferencesStore(persistence, sourceStoreName) {
  2746. var _state$interfaceStore, _state$interfaceStore2, _state$interfaceStore3, _state$sourceStoreNam, _state$sourceStoreNam2;
  2747. const preferencesStoreName = 'core/preferences';
  2748. const interfaceStoreName = 'core/interface';
  2749. const state = persistence.get(); // Features most recently (and briefly) lived in the interface package.
  2750. // If data exists there, prioritize using that for the migration. If not
  2751. // also check the original package as the user may have updated from an
  2752. // older block editor version.
  2753. const interfaceFeatures = (_state$interfaceStore = state[interfaceStoreName]) === null || _state$interfaceStore === void 0 ? void 0 : (_state$interfaceStore2 = _state$interfaceStore.preferences) === null || _state$interfaceStore2 === void 0 ? void 0 : (_state$interfaceStore3 = _state$interfaceStore2.features) === null || _state$interfaceStore3 === void 0 ? void 0 : _state$interfaceStore3[sourceStoreName];
  2754. const sourceFeatures = (_state$sourceStoreNam = state[sourceStoreName]) === null || _state$sourceStoreNam === void 0 ? void 0 : (_state$sourceStoreNam2 = _state$sourceStoreNam.preferences) === null || _state$sourceStoreNam2 === void 0 ? void 0 : _state$sourceStoreNam2.features;
  2755. const featuresToMigrate = interfaceFeatures ? interfaceFeatures : sourceFeatures;
  2756. if (featuresToMigrate) {
  2757. var _state$preferencesSto;
  2758. const existingPreferences = (_state$preferencesSto = state[preferencesStoreName]) === null || _state$preferencesSto === void 0 ? void 0 : _state$preferencesSto.preferences; // Avoid migrating features again if they've previously been migrated.
  2759. if (!(existingPreferences !== null && existingPreferences !== void 0 && existingPreferences[sourceStoreName])) {
  2760. // Set the feature values in the interface store, the features
  2761. // object is keyed by 'scope', which matches the store name for
  2762. // the source.
  2763. persistence.set(preferencesStoreName, {
  2764. preferences: { ...existingPreferences,
  2765. [sourceStoreName]: featuresToMigrate
  2766. }
  2767. }); // Remove migrated feature preferences from `interface`.
  2768. if (interfaceFeatures) {
  2769. var _state$interfaceStore4, _state$interfaceStore5;
  2770. const otherInterfaceState = state[interfaceStoreName];
  2771. const otherInterfaceScopes = (_state$interfaceStore4 = state[interfaceStoreName]) === null || _state$interfaceStore4 === void 0 ? void 0 : (_state$interfaceStore5 = _state$interfaceStore4.preferences) === null || _state$interfaceStore5 === void 0 ? void 0 : _state$interfaceStore5.features;
  2772. persistence.set(interfaceStoreName, { ...otherInterfaceState,
  2773. preferences: {
  2774. features: { ...otherInterfaceScopes,
  2775. [sourceStoreName]: undefined
  2776. }
  2777. }
  2778. });
  2779. } // Remove migrated feature preferences from the source.
  2780. if (sourceFeatures) {
  2781. var _state$sourceStoreNam3;
  2782. const otherSourceState = state[sourceStoreName];
  2783. const sourcePreferences = (_state$sourceStoreNam3 = state[sourceStoreName]) === null || _state$sourceStoreNam3 === void 0 ? void 0 : _state$sourceStoreNam3.preferences;
  2784. persistence.set(sourceStoreName, { ...otherSourceState,
  2785. preferences: { ...sourcePreferences,
  2786. features: undefined
  2787. }
  2788. });
  2789. }
  2790. }
  2791. }
  2792. }
  2793. /**
  2794. * Migrates an individual item inside the `preferences` object for a store.
  2795. *
  2796. * @param {Object} persistence The persistence interface.
  2797. * @param {Object} migrate An options object that contains details of the migration.
  2798. * @param {string} migrate.from The name of the store to migrate from.
  2799. * @param {string} migrate.scope The scope in the preferences store to migrate to.
  2800. * @param {string} key The key in the preferences object to migrate.
  2801. * @param {?Function} convert A function that converts preferences from one format to another.
  2802. */
  2803. function migrateIndividualPreferenceToPreferencesStore(persistence, _ref, key) {
  2804. var _state$sourceStoreNam4, _state$sourceStoreNam5, _state$preferencesSto2, _state$preferencesSto3, _state$preferencesSto4, _state$preferencesSto5, _state$preferencesSto6, _state$preferencesSto7, _state$sourceStoreNam6;
  2805. let {
  2806. from: sourceStoreName,
  2807. scope
  2808. } = _ref;
  2809. let convert = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : external_lodash_namespaceObject.identity;
  2810. const preferencesStoreName = 'core/preferences';
  2811. const state = persistence.get();
  2812. const sourcePreference = (_state$sourceStoreNam4 = state[sourceStoreName]) === null || _state$sourceStoreNam4 === void 0 ? void 0 : (_state$sourceStoreNam5 = _state$sourceStoreNam4.preferences) === null || _state$sourceStoreNam5 === void 0 ? void 0 : _state$sourceStoreNam5[key]; // There's nothing to migrate, exit early.
  2813. if (sourcePreference === undefined) {
  2814. return;
  2815. }
  2816. const targetPreference = (_state$preferencesSto2 = state[preferencesStoreName]) === null || _state$preferencesSto2 === void 0 ? void 0 : (_state$preferencesSto3 = _state$preferencesSto2.preferences) === null || _state$preferencesSto3 === void 0 ? void 0 : (_state$preferencesSto4 = _state$preferencesSto3[scope]) === null || _state$preferencesSto4 === void 0 ? void 0 : _state$preferencesSto4[key]; // There's existing data at the target, so don't overwrite it, exit early.
  2817. if (targetPreference) {
  2818. return;
  2819. }
  2820. const otherScopes = (_state$preferencesSto5 = state[preferencesStoreName]) === null || _state$preferencesSto5 === void 0 ? void 0 : _state$preferencesSto5.preferences;
  2821. const otherPreferences = (_state$preferencesSto6 = state[preferencesStoreName]) === null || _state$preferencesSto6 === void 0 ? void 0 : (_state$preferencesSto7 = _state$preferencesSto6.preferences) === null || _state$preferencesSto7 === void 0 ? void 0 : _state$preferencesSto7[scope]; // Pass an object with the key and value as this allows the convert
  2822. // function to convert to a data structure that has different keys.
  2823. const convertedPreferences = convert({
  2824. [key]: sourcePreference
  2825. });
  2826. persistence.set(preferencesStoreName, {
  2827. preferences: { ...otherScopes,
  2828. [scope]: { ...otherPreferences,
  2829. ...convertedPreferences
  2830. }
  2831. }
  2832. }); // Remove migrated feature preferences from the source.
  2833. const otherSourceState = state[sourceStoreName];
  2834. const allSourcePreferences = (_state$sourceStoreNam6 = state[sourceStoreName]) === null || _state$sourceStoreNam6 === void 0 ? void 0 : _state$sourceStoreNam6.preferences;
  2835. persistence.set(sourceStoreName, { ...otherSourceState,
  2836. preferences: { ...allSourcePreferences,
  2837. [key]: undefined
  2838. }
  2839. });
  2840. }
  2841. /**
  2842. * Convert from:
  2843. * ```
  2844. * {
  2845. * panels: {
  2846. * tags: {
  2847. * enabled: true,
  2848. * opened: true,
  2849. * },
  2850. * permalinks: {
  2851. * enabled: false,
  2852. * opened: false,
  2853. * },
  2854. * },
  2855. * }
  2856. * ```
  2857. *
  2858. * to:
  2859. * {
  2860. * inactivePanels: [
  2861. * 'permalinks',
  2862. * ],
  2863. * openPanels: [
  2864. * 'tags',
  2865. * ],
  2866. * }
  2867. *
  2868. * @param {Object} preferences A preferences object.
  2869. *
  2870. * @return {Object} The converted data.
  2871. */
  2872. function convertEditPostPanels(preferences) {
  2873. var _preferences$panels;
  2874. const panels = (_preferences$panels = preferences === null || preferences === void 0 ? void 0 : preferences.panels) !== null && _preferences$panels !== void 0 ? _preferences$panels : {};
  2875. return Object.keys(panels).reduce((convertedData, panelName) => {
  2876. const panel = panels[panelName];
  2877. if ((panel === null || panel === void 0 ? void 0 : panel.enabled) === false) {
  2878. convertedData.inactivePanels.push(panelName);
  2879. }
  2880. if ((panel === null || panel === void 0 ? void 0 : panel.opened) === true) {
  2881. convertedData.openPanels.push(panelName);
  2882. }
  2883. return convertedData;
  2884. }, {
  2885. inactivePanels: [],
  2886. openPanels: []
  2887. });
  2888. }
  2889. function migrateThirdPartyFeaturePreferencesToPreferencesStore(persistence) {
  2890. var _state$interfaceStore6, _state$interfaceStore7;
  2891. const interfaceStoreName = 'core/interface';
  2892. const preferencesStoreName = 'core/preferences';
  2893. let state = persistence.get();
  2894. const interfaceScopes = (_state$interfaceStore6 = state[interfaceStoreName]) === null || _state$interfaceStore6 === void 0 ? void 0 : (_state$interfaceStore7 = _state$interfaceStore6.preferences) === null || _state$interfaceStore7 === void 0 ? void 0 : _state$interfaceStore7.features;
  2895. for (const scope in interfaceScopes) {
  2896. var _state$preferencesSto8, _state$interfaceStore8, _state$interfaceStore9;
  2897. // Don't migrate any core 'scopes'.
  2898. if (scope.startsWith('core')) {
  2899. continue;
  2900. } // Skip this scope if there are no features to migrate.
  2901. const featuresToMigrate = interfaceScopes[scope];
  2902. if (!featuresToMigrate) {
  2903. continue;
  2904. }
  2905. const existingPreferences = (_state$preferencesSto8 = state[preferencesStoreName]) === null || _state$preferencesSto8 === void 0 ? void 0 : _state$preferencesSto8.preferences; // Add the data to the preferences store structure.
  2906. persistence.set(preferencesStoreName, {
  2907. preferences: { ...existingPreferences,
  2908. [scope]: featuresToMigrate
  2909. }
  2910. }); // Remove the data from the interface store structure.
  2911. // Call `persistence.get` again to make sure `state` is up-to-date with
  2912. // any changes from the previous iteration of this loop.
  2913. state = persistence.get();
  2914. const otherInterfaceState = state[interfaceStoreName];
  2915. const otherInterfaceScopes = (_state$interfaceStore8 = state[interfaceStoreName]) === null || _state$interfaceStore8 === void 0 ? void 0 : (_state$interfaceStore9 = _state$interfaceStore8.preferences) === null || _state$interfaceStore9 === void 0 ? void 0 : _state$interfaceStore9.features;
  2916. persistence.set(interfaceStoreName, { ...otherInterfaceState,
  2917. preferences: {
  2918. features: { ...otherInterfaceScopes,
  2919. [scope]: undefined
  2920. }
  2921. }
  2922. });
  2923. }
  2924. }
  2925. /**
  2926. * Migrates interface 'enableItems' data to the preferences store.
  2927. *
  2928. * The interface package stores this data in this format:
  2929. * ```js
  2930. * {
  2931. * enableItems: {
  2932. * singleEnableItems: {
  2933. * complementaryArea: {
  2934. * 'core/edit-post': 'edit-post/document',
  2935. * 'core/edit-site': 'edit-site/global-styles',
  2936. * }
  2937. * },
  2938. * multipleEnableItems: {
  2939. * pinnedItems: {
  2940. * 'core/edit-post': {
  2941. * 'plugin-1': true,
  2942. * },
  2943. * 'core/edit-site': {
  2944. * 'plugin-2': true,
  2945. * },
  2946. * },
  2947. * }
  2948. * }
  2949. * }
  2950. * ```
  2951. * and it should be migrated it to:
  2952. * ```js
  2953. * {
  2954. * 'core/edit-post': {
  2955. * complementaryArea: 'edit-post/document',
  2956. * pinnedItems: {
  2957. * 'plugin-1': true,
  2958. * },
  2959. * },
  2960. * 'core/edit-site': {
  2961. * complementaryArea: 'edit-site/global-styles',
  2962. * pinnedItems: {
  2963. * 'plugin-2': true,
  2964. * },
  2965. * },
  2966. * }
  2967. * ```
  2968. *
  2969. * @param {Object} persistence The persistence interface.
  2970. */
  2971. function migrateInterfaceEnableItemsToPreferencesStore(persistence) {
  2972. var _state$interfaceStore10, _state$preferencesSto9, _state$preferencesSto10, _sourceEnableItems$si, _sourceEnableItems$si2, _sourceEnableItems$mu, _sourceEnableItems$mu2;
  2973. const interfaceStoreName = 'core/interface';
  2974. const preferencesStoreName = 'core/preferences';
  2975. const state = persistence.get();
  2976. const sourceEnableItems = (_state$interfaceStore10 = state[interfaceStoreName]) === null || _state$interfaceStore10 === void 0 ? void 0 : _state$interfaceStore10.enableItems; // There's nothing to migrate, exit early.
  2977. if (!sourceEnableItems) {
  2978. return;
  2979. }
  2980. const allPreferences = (_state$preferencesSto9 = (_state$preferencesSto10 = state[preferencesStoreName]) === null || _state$preferencesSto10 === void 0 ? void 0 : _state$preferencesSto10.preferences) !== null && _state$preferencesSto9 !== void 0 ? _state$preferencesSto9 : {}; // First convert complementaryAreas into the right format.
  2981. // Use the existing preferences as the accumulator so that the data is
  2982. // merged.
  2983. const sourceComplementaryAreas = (_sourceEnableItems$si = sourceEnableItems === null || sourceEnableItems === void 0 ? void 0 : (_sourceEnableItems$si2 = sourceEnableItems.singleEnableItems) === null || _sourceEnableItems$si2 === void 0 ? void 0 : _sourceEnableItems$si2.complementaryArea) !== null && _sourceEnableItems$si !== void 0 ? _sourceEnableItems$si : {};
  2984. const convertedComplementaryAreas = Object.keys(sourceComplementaryAreas).reduce((accumulator, scope) => {
  2985. var _accumulator$scope;
  2986. const data = sourceComplementaryAreas[scope]; // Don't overwrite any existing data in the preferences store.
  2987. if ((_accumulator$scope = accumulator[scope]) !== null && _accumulator$scope !== void 0 && _accumulator$scope.complementaryArea) {
  2988. return accumulator;
  2989. }
  2990. return { ...accumulator,
  2991. [scope]: { ...accumulator[scope],
  2992. complementaryArea: data
  2993. }
  2994. };
  2995. }, allPreferences); // Next feed the converted complementary areas back into a reducer that
  2996. // converts the pinned items, resulting in the fully migrated data.
  2997. const sourcePinnedItems = (_sourceEnableItems$mu = sourceEnableItems === null || sourceEnableItems === void 0 ? void 0 : (_sourceEnableItems$mu2 = sourceEnableItems.multipleEnableItems) === null || _sourceEnableItems$mu2 === void 0 ? void 0 : _sourceEnableItems$mu2.pinnedItems) !== null && _sourceEnableItems$mu !== void 0 ? _sourceEnableItems$mu : {};
  2998. const allConvertedData = Object.keys(sourcePinnedItems).reduce((accumulator, scope) => {
  2999. var _accumulator$scope2;
  3000. const data = sourcePinnedItems[scope]; // Don't overwrite any existing data in the preferences store.
  3001. if ((_accumulator$scope2 = accumulator[scope]) !== null && _accumulator$scope2 !== void 0 && _accumulator$scope2.pinnedItems) {
  3002. return accumulator;
  3003. }
  3004. return { ...accumulator,
  3005. [scope]: { ...accumulator[scope],
  3006. pinnedItems: data
  3007. }
  3008. };
  3009. }, convertedComplementaryAreas);
  3010. persistence.set(preferencesStoreName, {
  3011. preferences: allConvertedData
  3012. }); // Remove migrated preferences.
  3013. const otherInterfaceItems = state[interfaceStoreName];
  3014. persistence.set(interfaceStoreName, { ...otherInterfaceItems,
  3015. enableItems: undefined
  3016. });
  3017. }
  3018. persistencePlugin.__unstableMigrate = pluginOptions => {
  3019. const persistence = createPersistenceInterface(pluginOptions); // Boolean feature preferences.
  3020. migrateFeaturePreferencesToPreferencesStore(persistence, 'core/edit-widgets');
  3021. migrateFeaturePreferencesToPreferencesStore(persistence, 'core/customize-widgets');
  3022. migrateFeaturePreferencesToPreferencesStore(persistence, 'core/edit-post');
  3023. migrateFeaturePreferencesToPreferencesStore(persistence, 'core/edit-site');
  3024. migrateThirdPartyFeaturePreferencesToPreferencesStore(persistence); // Other ad-hoc preferences.
  3025. migrateIndividualPreferenceToPreferencesStore(persistence, {
  3026. from: 'core/edit-post',
  3027. scope: 'core/edit-post'
  3028. }, 'hiddenBlockTypes');
  3029. migrateIndividualPreferenceToPreferencesStore(persistence, {
  3030. from: 'core/edit-post',
  3031. scope: 'core/edit-post'
  3032. }, 'editorMode');
  3033. migrateIndividualPreferenceToPreferencesStore(persistence, {
  3034. from: 'core/edit-post',
  3035. scope: 'core/edit-post'
  3036. }, 'preferredStyleVariations');
  3037. migrateIndividualPreferenceToPreferencesStore(persistence, {
  3038. from: 'core/edit-post',
  3039. scope: 'core/edit-post'
  3040. }, 'panels', convertEditPostPanels);
  3041. migrateIndividualPreferenceToPreferencesStore(persistence, {
  3042. from: 'core/editor',
  3043. scope: 'core/edit-post'
  3044. }, 'isPublishSidebarEnabled');
  3045. migrateIndividualPreferenceToPreferencesStore(persistence, {
  3046. from: 'core/edit-site',
  3047. scope: 'core/edit-site'
  3048. }, 'editorMode');
  3049. migrateInterfaceEnableItemsToPreferencesStore(persistence);
  3050. };
  3051. /* harmony default export */ var persistence = (persistencePlugin);
  3052. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/index.js
  3053. ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
  3054. function _extends() {
  3055. _extends = Object.assign || function (target) {
  3056. for (var i = 1; i < arguments.length; i++) {
  3057. var source = arguments[i];
  3058. for (var key in source) {
  3059. if (Object.prototype.hasOwnProperty.call(source, key)) {
  3060. target[key] = source[key];
  3061. }
  3062. }
  3063. }
  3064. return target;
  3065. };
  3066. return _extends.apply(this, arguments);
  3067. }
  3068. ;// CONCATENATED MODULE: external ["wp","element"]
  3069. var external_wp_element_namespaceObject = window["wp"]["element"];
  3070. ;// CONCATENATED MODULE: external ["wp","compose"]
  3071. var external_wp_compose_namespaceObject = window["wp"]["compose"];
  3072. ;// CONCATENATED MODULE: external "React"
  3073. var external_React_namespaceObject = window["React"];
  3074. ;// CONCATENATED MODULE: ./node_modules/use-memo-one/dist/use-memo-one.esm.js
  3075. function areInputsEqual(newInputs, lastInputs) {
  3076. if (newInputs.length !== lastInputs.length) {
  3077. return false;
  3078. }
  3079. for (var i = 0; i < newInputs.length; i++) {
  3080. if (newInputs[i] !== lastInputs[i]) {
  3081. return false;
  3082. }
  3083. }
  3084. return true;
  3085. }
  3086. function useMemoOne(getResult, inputs) {
  3087. var initial = (0,external_React_namespaceObject.useState)(function () {
  3088. return {
  3089. inputs: inputs,
  3090. result: getResult()
  3091. };
  3092. })[0];
  3093. var isFirstRun = (0,external_React_namespaceObject.useRef)(true);
  3094. var committed = (0,external_React_namespaceObject.useRef)(initial);
  3095. var useCache = isFirstRun.current || Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs));
  3096. var cache = useCache ? committed.current : {
  3097. inputs: inputs,
  3098. result: getResult()
  3099. };
  3100. (0,external_React_namespaceObject.useEffect)(function () {
  3101. isFirstRun.current = false;
  3102. committed.current = cache;
  3103. }, [cache]);
  3104. return cache.result;
  3105. }
  3106. function useCallbackOne(callback, inputs) {
  3107. return useMemoOne(function () {
  3108. return callback;
  3109. }, inputs);
  3110. }
  3111. var useMemo = (/* unused pure expression or super */ null && (useMemoOne));
  3112. var useCallback = (/* unused pure expression or super */ null && (useCallbackOne));
  3113. ;// CONCATENATED MODULE: external ["wp","priorityQueue"]
  3114. var external_wp_priorityQueue_namespaceObject = window["wp"]["priorityQueue"];
  3115. ;// CONCATENATED MODULE: external ["wp","isShallowEqual"]
  3116. var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"];
  3117. var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject);
  3118. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/context.js
  3119. /**
  3120. * WordPress dependencies
  3121. */
  3122. /**
  3123. * Internal dependencies
  3124. */
  3125. const Context = (0,external_wp_element_namespaceObject.createContext)(default_registry);
  3126. const {
  3127. Consumer,
  3128. Provider
  3129. } = Context;
  3130. /**
  3131. * A custom react Context consumer exposing the provided `registry` to
  3132. * children components. Used along with the RegistryProvider.
  3133. *
  3134. * You can read more about the react context api here:
  3135. * https://reactjs.org/docs/context.html#contextprovider
  3136. *
  3137. * @example
  3138. * ```js
  3139. * import {
  3140. * RegistryProvider,
  3141. * RegistryConsumer,
  3142. * createRegistry
  3143. * } from '@wordpress/data';
  3144. *
  3145. * const registry = createRegistry( {} );
  3146. *
  3147. * const App = ( { props } ) => {
  3148. * return <RegistryProvider value={ registry }>
  3149. * <div>Hello There</div>
  3150. * <RegistryConsumer>
  3151. * { ( registry ) => (
  3152. * <ComponentUsingRegistry
  3153. * { ...props }
  3154. * registry={ registry }
  3155. * ) }
  3156. * </RegistryConsumer>
  3157. * </RegistryProvider>
  3158. * }
  3159. * ```
  3160. */
  3161. const RegistryConsumer = Consumer;
  3162. /**
  3163. * A custom Context provider for exposing the provided `registry` to children
  3164. * components via a consumer.
  3165. *
  3166. * See <a name="#RegistryConsumer">RegistryConsumer</a> documentation for
  3167. * example.
  3168. */
  3169. /* harmony default export */ var context = (Provider);
  3170. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/use-registry.js
  3171. /**
  3172. * WordPress dependencies
  3173. */
  3174. /**
  3175. * Internal dependencies
  3176. */
  3177. /**
  3178. * A custom react hook exposing the registry context for use.
  3179. *
  3180. * This exposes the `registry` value provided via the
  3181. * <a href="#RegistryProvider">Registry Provider</a> to a component implementing
  3182. * this hook.
  3183. *
  3184. * It acts similarly to the `useContext` react hook.
  3185. *
  3186. * Note: Generally speaking, `useRegistry` is a low level hook that in most cases
  3187. * won't be needed for implementation. Most interactions with the `@wordpress/data`
  3188. * API can be performed via the `useSelect` hook, or the `withSelect` and
  3189. * `withDispatch` higher order components.
  3190. *
  3191. * @example
  3192. * ```js
  3193. * import {
  3194. * RegistryProvider,
  3195. * createRegistry,
  3196. * useRegistry,
  3197. * } from '@wordpress/data';
  3198. *
  3199. * const registry = createRegistry( {} );
  3200. *
  3201. * const SomeChildUsingRegistry = ( props ) => {
  3202. * const registry = useRegistry();
  3203. * // ...logic implementing the registry in other react hooks.
  3204. * };
  3205. *
  3206. *
  3207. * const ParentProvidingRegistry = ( props ) => {
  3208. * return <RegistryProvider value={ registry }>
  3209. * <SomeChildUsingRegistry { ...props } />
  3210. * </RegistryProvider>
  3211. * };
  3212. * ```
  3213. *
  3214. * @return {Function} A custom react hook exposing the registry context value.
  3215. */
  3216. function useRegistry() {
  3217. return (0,external_wp_element_namespaceObject.useContext)(Context);
  3218. }
  3219. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/context.js
  3220. /**
  3221. * WordPress dependencies
  3222. */
  3223. const context_Context = (0,external_wp_element_namespaceObject.createContext)(false);
  3224. const {
  3225. Consumer: context_Consumer,
  3226. Provider: context_Provider
  3227. } = context_Context;
  3228. const AsyncModeConsumer = (/* unused pure expression or super */ null && (context_Consumer));
  3229. /**
  3230. * Context Provider Component used to switch the data module component rerendering
  3231. * between Sync and Async modes.
  3232. *
  3233. * @example
  3234. *
  3235. * ```js
  3236. * import { useSelect, AsyncModeProvider } from '@wordpress/data';
  3237. *
  3238. * function BlockCount() {
  3239. * const count = useSelect( ( select ) => {
  3240. * return select( 'core/block-editor' ).getBlockCount()
  3241. * }, [] );
  3242. *
  3243. * return count;
  3244. * }
  3245. *
  3246. * function App() {
  3247. * return (
  3248. * <AsyncModeProvider value={ true }>
  3249. * <BlockCount />
  3250. * </AsyncModeProvider>
  3251. * );
  3252. * }
  3253. * ```
  3254. *
  3255. * In this example, the BlockCount component is rerendered asynchronously.
  3256. * It means if a more critical task is being performed (like typing in an input),
  3257. * the rerendering is delayed until the browser becomes IDLE.
  3258. * It is possible to nest multiple levels of AsyncModeProvider to fine-tune the rendering behavior.
  3259. *
  3260. * @param {boolean} props.value Enable Async Mode.
  3261. * @return {WPComponent} The component to be rendered.
  3262. */
  3263. /* harmony default export */ var async_mode_provider_context = (context_Provider);
  3264. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/use-async-mode.js
  3265. /**
  3266. * WordPress dependencies
  3267. */
  3268. /**
  3269. * Internal dependencies
  3270. */
  3271. function useAsyncMode() {
  3272. return (0,external_wp_element_namespaceObject.useContext)(context_Context);
  3273. }
  3274. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-select/index.js
  3275. /**
  3276. * External dependencies
  3277. */
  3278. /**
  3279. * WordPress dependencies
  3280. */
  3281. /**
  3282. * Internal dependencies
  3283. */
  3284. const noop = () => {};
  3285. const renderQueue = (0,external_wp_priorityQueue_namespaceObject.createQueue)();
  3286. /** @typedef {import('../../types').StoreDescriptor} StoreDescriptor */
  3287. /**
  3288. * Custom react hook for retrieving props from registered selectors.
  3289. *
  3290. * In general, this custom React hook follows the
  3291. * [rules of hooks](https://reactjs.org/docs/hooks-rules.html).
  3292. *
  3293. * @param {Function|StoreDescriptor|string} mapSelect Function called on every state change. The
  3294. * returned value is exposed to the component
  3295. * implementing this hook. The function receives
  3296. * the `registry.select` method on the first
  3297. * argument and the `registry` on the second
  3298. * argument.
  3299. * When a store key is passed, all selectors for
  3300. * the store will be returned. This is only meant
  3301. * for usage of these selectors in event
  3302. * callbacks, not for data needed to create the
  3303. * element tree.
  3304. * @param {Array} deps If provided, this memoizes the mapSelect so the
  3305. * same `mapSelect` is invoked on every state
  3306. * change unless the dependencies change.
  3307. *
  3308. * @example
  3309. * ```js
  3310. * import { useSelect } from '@wordpress/data';
  3311. *
  3312. * function HammerPriceDisplay( { currency } ) {
  3313. * const price = useSelect( ( select ) => {
  3314. * return select( 'my-shop' ).getPrice( 'hammer', currency )
  3315. * }, [ currency ] );
  3316. * return new Intl.NumberFormat( 'en-US', {
  3317. * style: 'currency',
  3318. * currency,
  3319. * } ).format( price );
  3320. * }
  3321. *
  3322. * // Rendered in the application:
  3323. * // <HammerPriceDisplay currency="USD" />
  3324. * ```
  3325. *
  3326. * In the above example, when `HammerPriceDisplay` is rendered into an
  3327. * application, the price will be retrieved from the store state using the
  3328. * `mapSelect` callback on `useSelect`. If the currency prop changes then
  3329. * any price in the state for that currency is retrieved. If the currency prop
  3330. * doesn't change and other props are passed in that do change, the price will
  3331. * not change because the dependency is just the currency.
  3332. *
  3333. * When data is only used in an event callback, the data should not be retrieved
  3334. * on render, so it may be useful to get the selectors function instead.
  3335. *
  3336. * **Don't use `useSelect` this way when calling the selectors in the render
  3337. * function because your component won't re-render on a data change.**
  3338. *
  3339. * ```js
  3340. * import { useSelect } from '@wordpress/data';
  3341. *
  3342. * function Paste( { children } ) {
  3343. * const { getSettings } = useSelect( 'my-shop' );
  3344. * function onPaste() {
  3345. * // Do something with the settings.
  3346. * const settings = getSettings();
  3347. * }
  3348. * return <div onPaste={ onPaste }>{ children }</div>;
  3349. * }
  3350. * ```
  3351. *
  3352. * @return {Function} A custom react hook.
  3353. */
  3354. function useSelect(mapSelect, deps) {
  3355. const hasMappingFunction = 'function' === typeof mapSelect; // If we're recalling a store by its name or by
  3356. // its descriptor then we won't be caching the
  3357. // calls to `mapSelect` because we won't be calling it.
  3358. if (!hasMappingFunction) {
  3359. deps = [];
  3360. } // Because of the "rule of hooks" we have to call `useCallback`
  3361. // on every invocation whether or not we have a real function
  3362. // for `mapSelect`. we'll create this intermediate variable to
  3363. // fulfill that need and then reference it with our "real"
  3364. // `_mapSelect` if we can.
  3365. const callbackMapper = (0,external_wp_element_namespaceObject.useCallback)(hasMappingFunction ? mapSelect : noop, deps);
  3366. const _mapSelect = hasMappingFunction ? callbackMapper : null;
  3367. const registry = useRegistry();
  3368. const isAsync = useAsyncMode(); // React can sometimes clear the `useMemo` cache.
  3369. // We use the cache-stable `useMemoOne` to avoid
  3370. // losing queues.
  3371. const queueContext = useMemoOne(() => ({
  3372. queue: true
  3373. }), [registry]);
  3374. const [, forceRender] = (0,external_wp_element_namespaceObject.useReducer)(s => s + 1, 0);
  3375. const latestMapSelect = (0,external_wp_element_namespaceObject.useRef)();
  3376. const latestIsAsync = (0,external_wp_element_namespaceObject.useRef)(isAsync);
  3377. const latestMapOutput = (0,external_wp_element_namespaceObject.useRef)();
  3378. const latestMapOutputError = (0,external_wp_element_namespaceObject.useRef)();
  3379. const isMountedAndNotUnsubscribing = (0,external_wp_element_namespaceObject.useRef)(); // Keep track of the stores being selected in the _mapSelect function,
  3380. // and only subscribe to those stores later.
  3381. const listeningStores = (0,external_wp_element_namespaceObject.useRef)([]);
  3382. const wrapSelect = (0,external_wp_element_namespaceObject.useCallback)(callback => registry.__unstableMarkListeningStores(() => callback(registry.select, registry), listeningStores), [registry]); // Generate a "flag" for used in the effect dependency array.
  3383. // It's different than just using `mapSelect` since deps could be undefined,
  3384. // in that case, we would still want to memoize it.
  3385. const depsChangedFlag = (0,external_wp_element_namespaceObject.useMemo)(() => ({}), deps || []);
  3386. let mapOutput;
  3387. if (_mapSelect) {
  3388. mapOutput = latestMapOutput.current;
  3389. const hasReplacedMapSelect = latestMapSelect.current !== _mapSelect;
  3390. const lastMapSelectFailed = !!latestMapOutputError.current;
  3391. if (hasReplacedMapSelect || lastMapSelectFailed) {
  3392. try {
  3393. mapOutput = wrapSelect(_mapSelect);
  3394. } catch (error) {
  3395. let errorMessage = `An error occurred while running 'mapSelect': ${error.message}`;
  3396. if (latestMapOutputError.current) {
  3397. errorMessage += `\nThe error may be correlated with this previous error:\n`;
  3398. errorMessage += `${latestMapOutputError.current.stack}\n\n`;
  3399. errorMessage += 'Original stack trace:';
  3400. } // eslint-disable-next-line no-console
  3401. console.error(errorMessage);
  3402. }
  3403. }
  3404. }
  3405. (0,external_wp_compose_namespaceObject.useIsomorphicLayoutEffect)(() => {
  3406. if (!hasMappingFunction) {
  3407. return;
  3408. }
  3409. latestMapSelect.current = _mapSelect;
  3410. latestMapOutput.current = mapOutput;
  3411. latestMapOutputError.current = undefined;
  3412. isMountedAndNotUnsubscribing.current = true; // This has to run after the other ref updates
  3413. // to avoid using stale values in the flushed
  3414. // callbacks or potentially overwriting a
  3415. // changed `latestMapOutput.current`.
  3416. if (latestIsAsync.current !== isAsync) {
  3417. latestIsAsync.current = isAsync;
  3418. renderQueue.flush(queueContext);
  3419. }
  3420. });
  3421. (0,external_wp_compose_namespaceObject.useIsomorphicLayoutEffect)(() => {
  3422. if (!hasMappingFunction) {
  3423. return;
  3424. }
  3425. const onStoreChange = () => {
  3426. if (isMountedAndNotUnsubscribing.current) {
  3427. try {
  3428. const newMapOutput = wrapSelect(latestMapSelect.current);
  3429. if (external_wp_isShallowEqual_default()(latestMapOutput.current, newMapOutput)) {
  3430. return;
  3431. }
  3432. latestMapOutput.current = newMapOutput;
  3433. } catch (error) {
  3434. latestMapOutputError.current = error;
  3435. }
  3436. forceRender();
  3437. }
  3438. };
  3439. const onChange = () => {
  3440. if (latestIsAsync.current) {
  3441. renderQueue.add(queueContext, onStoreChange);
  3442. } else {
  3443. onStoreChange();
  3444. }
  3445. }; // Catch any possible state changes during mount before the subscription
  3446. // could be set.
  3447. onChange();
  3448. const unsubscribers = listeningStores.current.map(storeName => registry.__unstableSubscribeStore(storeName, onChange));
  3449. return () => {
  3450. isMountedAndNotUnsubscribing.current = false; // The return value of the subscribe function could be undefined if the store is a custom generic store.
  3451. unsubscribers.forEach(unsubscribe => unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe());
  3452. renderQueue.flush(queueContext);
  3453. }; // If you're tempted to eliminate the spread dependencies below don't do it!
  3454. // We're passing these in from the calling function and want to make sure we're
  3455. // examining every individual value inside the `deps` array.
  3456. }, [registry, wrapSelect, hasMappingFunction, depsChangedFlag]);
  3457. return hasMappingFunction ? mapOutput : registry.select(mapSelect);
  3458. }
  3459. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-select/index.js
  3460. /**
  3461. * WordPress dependencies
  3462. */
  3463. /**
  3464. * Internal dependencies
  3465. */
  3466. /**
  3467. * Higher-order component used to inject state-derived props using registered
  3468. * selectors.
  3469. *
  3470. * @param {Function} mapSelectToProps Function called on every state change,
  3471. * expected to return object of props to
  3472. * merge with the component's own props.
  3473. *
  3474. * @example
  3475. * ```js
  3476. * import { withSelect } from '@wordpress/data';
  3477. *
  3478. * function PriceDisplay( { price, currency } ) {
  3479. * return new Intl.NumberFormat( 'en-US', {
  3480. * style: 'currency',
  3481. * currency,
  3482. * } ).format( price );
  3483. * }
  3484. *
  3485. * const HammerPriceDisplay = withSelect( ( select, ownProps ) => {
  3486. * const { getPrice } = select( 'my-shop' );
  3487. * const { currency } = ownProps;
  3488. *
  3489. * return {
  3490. * price: getPrice( 'hammer', currency ),
  3491. * };
  3492. * } )( PriceDisplay );
  3493. *
  3494. * // Rendered in the application:
  3495. * //
  3496. * // <HammerPriceDisplay currency="USD" />
  3497. * ```
  3498. * In the above example, when `HammerPriceDisplay` is rendered into an
  3499. * application, it will pass the price into the underlying `PriceDisplay`
  3500. * component and update automatically if the price of a hammer ever changes in
  3501. * the store.
  3502. *
  3503. * @return {WPComponent} Enhanced component with merged state data props.
  3504. */
  3505. const withSelect = mapSelectToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => (0,external_wp_compose_namespaceObject.pure)(ownProps => {
  3506. const mapSelect = (select, registry) => mapSelectToProps(select, ownProps, registry);
  3507. const mergeProps = useSelect(mapSelect);
  3508. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, ownProps, mergeProps));
  3509. }), 'withSelect');
  3510. /* harmony default export */ var with_select = (withSelect);
  3511. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch-with-map.js
  3512. /**
  3513. * External dependencies
  3514. */
  3515. /**
  3516. * WordPress dependencies
  3517. */
  3518. /**
  3519. * Internal dependencies
  3520. */
  3521. /**
  3522. * Custom react hook for returning aggregate dispatch actions using the provided
  3523. * dispatchMap.
  3524. *
  3525. * Currently this is an internal api only and is implemented by `withDispatch`
  3526. *
  3527. * @param {Function} dispatchMap Receives the `registry.dispatch` function as
  3528. * the first argument and the `registry` object
  3529. * as the second argument. Should return an
  3530. * object mapping props to functions.
  3531. * @param {Array} deps An array of dependencies for the hook.
  3532. * @return {Object} An object mapping props to functions created by the passed
  3533. * in dispatchMap.
  3534. */
  3535. const useDispatchWithMap = (dispatchMap, deps) => {
  3536. const registry = useRegistry();
  3537. const currentDispatchMap = (0,external_wp_element_namespaceObject.useRef)(dispatchMap);
  3538. (0,external_wp_compose_namespaceObject.useIsomorphicLayoutEffect)(() => {
  3539. currentDispatchMap.current = dispatchMap;
  3540. });
  3541. return (0,external_wp_element_namespaceObject.useMemo)(() => {
  3542. const currentDispatchProps = currentDispatchMap.current(registry.dispatch, registry);
  3543. return (0,external_lodash_namespaceObject.mapValues)(currentDispatchProps, (dispatcher, propName) => {
  3544. if (typeof dispatcher !== 'function') {
  3545. // eslint-disable-next-line no-console
  3546. console.warn(`Property ${propName} returned from dispatchMap in useDispatchWithMap must be a function.`);
  3547. }
  3548. return function () {
  3549. return currentDispatchMap.current(registry.dispatch, registry)[propName](...arguments);
  3550. };
  3551. });
  3552. }, [registry, ...deps]);
  3553. };
  3554. /* harmony default export */ var use_dispatch_with_map = (useDispatchWithMap);
  3555. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-dispatch/index.js
  3556. /**
  3557. * WordPress dependencies
  3558. */
  3559. /**
  3560. * Internal dependencies
  3561. */
  3562. /**
  3563. * Higher-order component used to add dispatch props using registered action
  3564. * creators.
  3565. *
  3566. * @param {Function} mapDispatchToProps A function of returning an object of
  3567. * prop names where value is a
  3568. * dispatch-bound action creator, or a
  3569. * function to be called with the
  3570. * component's props and returning an
  3571. * action creator.
  3572. *
  3573. * @example
  3574. * ```jsx
  3575. * function Button( { onClick, children } ) {
  3576. * return <button type="button" onClick={ onClick }>{ children }</button>;
  3577. * }
  3578. *
  3579. * import { withDispatch } from '@wordpress/data';
  3580. *
  3581. * const SaleButton = withDispatch( ( dispatch, ownProps ) => {
  3582. * const { startSale } = dispatch( 'my-shop' );
  3583. * const { discountPercent } = ownProps;
  3584. *
  3585. * return {
  3586. * onClick() {
  3587. * startSale( discountPercent );
  3588. * },
  3589. * };
  3590. * } )( Button );
  3591. *
  3592. * // Rendered in the application:
  3593. * //
  3594. * // <SaleButton discountPercent="20">Start Sale!</SaleButton>
  3595. * ```
  3596. *
  3597. * @example
  3598. * In the majority of cases, it will be sufficient to use only two first params
  3599. * passed to `mapDispatchToProps` as illustrated in the previous example.
  3600. * However, there might be some very advanced use cases where using the
  3601. * `registry` object might be used as a tool to optimize the performance of
  3602. * your component. Using `select` function from the registry might be useful
  3603. * when you need to fetch some dynamic data from the store at the time when the
  3604. * event is fired, but at the same time, you never use it to render your
  3605. * component. In such scenario, you can avoid using the `withSelect` higher
  3606. * order component to compute such prop, which might lead to unnecessary
  3607. * re-renders of your component caused by its frequent value change.
  3608. * Keep in mind, that `mapDispatchToProps` must return an object with functions
  3609. * only.
  3610. *
  3611. * ```jsx
  3612. * function Button( { onClick, children } ) {
  3613. * return <button type="button" onClick={ onClick }>{ children }</button>;
  3614. * }
  3615. *
  3616. * import { withDispatch } from '@wordpress/data';
  3617. *
  3618. * const SaleButton = withDispatch( ( dispatch, ownProps, { select } ) => {
  3619. * // Stock number changes frequently.
  3620. * const { getStockNumber } = select( 'my-shop' );
  3621. * const { startSale } = dispatch( 'my-shop' );
  3622. * return {
  3623. * onClick() {
  3624. * const discountPercent = getStockNumber() > 50 ? 10 : 20;
  3625. * startSale( discountPercent );
  3626. * },
  3627. * };
  3628. * } )( Button );
  3629. *
  3630. * // Rendered in the application:
  3631. * //
  3632. * // <SaleButton>Start Sale!</SaleButton>
  3633. * ```
  3634. *
  3635. * _Note:_ It is important that the `mapDispatchToProps` function always
  3636. * returns an object with the same keys. For example, it should not contain
  3637. * conditions under which a different value would be returned.
  3638. *
  3639. * @return {WPComponent} Enhanced component with merged dispatcher props.
  3640. */
  3641. const withDispatch = mapDispatchToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => ownProps => {
  3642. const mapDispatch = (dispatch, registry) => mapDispatchToProps(dispatch, ownProps, registry);
  3643. const dispatchProps = use_dispatch_with_map(mapDispatch, []);
  3644. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, ownProps, dispatchProps));
  3645. }, 'withDispatch');
  3646. /* harmony default export */ var with_dispatch = (withDispatch);
  3647. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-registry/index.js
  3648. /**
  3649. * WordPress dependencies
  3650. */
  3651. /**
  3652. * Internal dependencies
  3653. */
  3654. /**
  3655. * Higher-order component which renders the original component with the current
  3656. * registry context passed as its `registry` prop.
  3657. *
  3658. * @param {WPComponent} OriginalComponent Original component.
  3659. *
  3660. * @return {WPComponent} Enhanced component.
  3661. */
  3662. const withRegistry = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(OriginalComponent => props => (0,external_wp_element_namespaceObject.createElement)(RegistryConsumer, null, registry => (0,external_wp_element_namespaceObject.createElement)(OriginalComponent, _extends({}, props, {
  3663. registry: registry
  3664. }))), 'withRegistry');
  3665. /* harmony default export */ var with_registry = (withRegistry);
  3666. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch.js
  3667. /**
  3668. * Internal dependencies
  3669. */
  3670. /** @typedef {import('../../types').StoreDescriptor} StoreDescriptor */
  3671. /**
  3672. * A custom react hook returning the current registry dispatch actions creators.
  3673. *
  3674. * Note: The component using this hook must be within the context of a
  3675. * RegistryProvider.
  3676. *
  3677. * @param {string|StoreDescriptor} [storeNameOrDescriptor] Optionally provide the name of the
  3678. * store or its descriptor from which to
  3679. * retrieve action creators. If not
  3680. * provided, the registry.dispatch
  3681. * function is returned instead.
  3682. *
  3683. * @example
  3684. * This illustrates a pattern where you may need to retrieve dynamic data from
  3685. * the server via the `useSelect` hook to use in combination with the dispatch
  3686. * action.
  3687. *
  3688. * ```jsx
  3689. * import { useDispatch, useSelect } from '@wordpress/data';
  3690. * import { useCallback } from '@wordpress/element';
  3691. *
  3692. * function Button( { onClick, children } ) {
  3693. * return <button type="button" onClick={ onClick }>{ children }</button>
  3694. * }
  3695. *
  3696. * const SaleButton = ( { children } ) => {
  3697. * const { stockNumber } = useSelect(
  3698. * ( select ) => select( 'my-shop' ).getStockNumber(),
  3699. * []
  3700. * );
  3701. * const { startSale } = useDispatch( 'my-shop' );
  3702. * const onClick = useCallback( () => {
  3703. * const discountPercent = stockNumber > 50 ? 10: 20;
  3704. * startSale( discountPercent );
  3705. * }, [ stockNumber ] );
  3706. * return <Button onClick={ onClick }>{ children }</Button>
  3707. * }
  3708. *
  3709. * // Rendered somewhere in the application:
  3710. * //
  3711. * // <SaleButton>Start Sale!</SaleButton>
  3712. * ```
  3713. * @return {Function} A custom react hook.
  3714. */
  3715. const useDispatch = storeNameOrDescriptor => {
  3716. const {
  3717. dispatch
  3718. } = useRegistry();
  3719. return storeNameOrDescriptor === void 0 ? dispatch : dispatch(storeNameOrDescriptor);
  3720. };
  3721. /* harmony default export */ var use_dispatch = (useDispatch);
  3722. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/index.js
  3723. /**
  3724. * External dependencies
  3725. */
  3726. /**
  3727. * Internal dependencies
  3728. */
  3729. /** @typedef {import('./types').StoreDescriptor} StoreDescriptor */
  3730. /**
  3731. * Object of available plugins to use with a registry.
  3732. *
  3733. * @see [use](#use)
  3734. *
  3735. * @type {Object}
  3736. */
  3737. /**
  3738. * The combineReducers helper function turns an object whose values are different
  3739. * reducing functions into a single reducing function you can pass to registerReducer.
  3740. *
  3741. * @param {Object} reducers An object whose values correspond to different reducing
  3742. * functions that need to be combined into one.
  3743. *
  3744. * @example
  3745. * ```js
  3746. * import { combineReducers, createReduxStore, register } from '@wordpress/data';
  3747. *
  3748. * const prices = ( state = {}, action ) => {
  3749. * return action.type === 'SET_PRICE' ?
  3750. * {
  3751. * ...state,
  3752. * [ action.item ]: action.price,
  3753. * } :
  3754. * state;
  3755. * };
  3756. *
  3757. * const discountPercent = ( state = 0, action ) => {
  3758. * return action.type === 'START_SALE' ?
  3759. * action.discountPercent :
  3760. * state;
  3761. * };
  3762. *
  3763. * const store = createReduxStore( 'my-shop', {
  3764. * reducer: combineReducers( {
  3765. * prices,
  3766. * discountPercent,
  3767. * } ),
  3768. * } );
  3769. * register( store );
  3770. * ```
  3771. *
  3772. * @return {Function} A reducer that invokes every reducer inside the reducers
  3773. * object, and constructs a state object with the same shape.
  3774. */
  3775. /**
  3776. * Given the name or descriptor of a registered store, returns an object of the store's selectors.
  3777. * The selector functions are been pre-bound to pass the current state automatically.
  3778. * As a consumer, you need only pass arguments of the selector, if applicable.
  3779. *
  3780. * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
  3781. * or the store descriptor.
  3782. *
  3783. * @example
  3784. * ```js
  3785. * import { select } from '@wordpress/data';
  3786. *
  3787. * select( 'my-shop' ).getPrice( 'hammer' );
  3788. * ```
  3789. *
  3790. * @return {Object} Object containing the store's selectors.
  3791. */
  3792. const build_module_select = default_registry.select;
  3793. /**
  3794. * Given the name of a registered store, returns an object containing the store's
  3795. * selectors pre-bound to state so that you only need to supply additional arguments,
  3796. * and modified so that they return promises that resolve to their eventual values,
  3797. * after any resolvers have ran.
  3798. *
  3799. * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
  3800. * or the store descriptor.
  3801. *
  3802. * @example
  3803. * ```js
  3804. * import { resolveSelect } from '@wordpress/data';
  3805. *
  3806. * resolveSelect( 'my-shop' ).getPrice( 'hammer' ).then(console.log)
  3807. * ```
  3808. *
  3809. * @return {Object} Object containing the store's promise-wrapped selectors.
  3810. */
  3811. const build_module_resolveSelect = default_registry.resolveSelect;
  3812. /**
  3813. * Given the name of a registered store, returns an object of the store's action creators.
  3814. * Calling an action creator will cause it to be dispatched, updating the state value accordingly.
  3815. *
  3816. * Note: Action creators returned by the dispatch will return a promise when
  3817. * they are called.
  3818. *
  3819. * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
  3820. * or the store descriptor.
  3821. *
  3822. * @example
  3823. * ```js
  3824. * import { dispatch } from '@wordpress/data';
  3825. *
  3826. * dispatch( 'my-shop' ).setPrice( 'hammer', 9.75 );
  3827. * ```
  3828. * @return {Object} Object containing the action creators.
  3829. */
  3830. const build_module_dispatch = default_registry.dispatch;
  3831. /**
  3832. * Given a listener function, the function will be called any time the state value
  3833. * of one of the registered stores has changed. This function returns a `unsubscribe`
  3834. * function used to stop the subscription.
  3835. *
  3836. * @param {Function} listener Callback function.
  3837. *
  3838. * @example
  3839. * ```js
  3840. * import { subscribe } from '@wordpress/data';
  3841. *
  3842. * const unsubscribe = subscribe( () => {
  3843. * // You could use this opportunity to test whether the derived result of a
  3844. * // selector has subsequently changed as the result of a state update.
  3845. * } );
  3846. *
  3847. * // Later, if necessary...
  3848. * unsubscribe();
  3849. * ```
  3850. */
  3851. const subscribe = default_registry.subscribe;
  3852. /**
  3853. * Registers a generic store instance.
  3854. *
  3855. * @deprecated Use `register( storeDescriptor )` instead.
  3856. *
  3857. * @param {string} name Store registry name.
  3858. * @param {Object} store Store instance (`{ getSelectors, getActions, subscribe }`).
  3859. */
  3860. const registerGenericStore = default_registry.registerGenericStore;
  3861. /**
  3862. * Registers a standard `@wordpress/data` store.
  3863. *
  3864. * @deprecated Use `register` instead.
  3865. *
  3866. * @param {string} storeName Unique namespace identifier for the store.
  3867. * @param {Object} options Store description (reducer, actions, selectors, resolvers).
  3868. *
  3869. * @return {Object} Registered store object.
  3870. */
  3871. const registerStore = default_registry.registerStore;
  3872. /**
  3873. * Extends a registry to inherit functionality provided by a given plugin. A
  3874. * plugin is an object with properties aligning to that of a registry, merged
  3875. * to extend the default registry behavior.
  3876. *
  3877. * @param {Object} plugin Plugin object.
  3878. */
  3879. const use = default_registry.use;
  3880. /**
  3881. * Registers a standard `@wordpress/data` store descriptor.
  3882. *
  3883. * @example
  3884. * ```js
  3885. * import { createReduxStore, register } from '@wordpress/data';
  3886. *
  3887. * const store = createReduxStore( 'demo', {
  3888. * reducer: ( state = 'OK' ) => state,
  3889. * selectors: {
  3890. * getValue: ( state ) => state,
  3891. * },
  3892. * } );
  3893. * register( store );
  3894. * ```
  3895. *
  3896. * @param {StoreDescriptor} store Store descriptor.
  3897. */
  3898. const register = default_registry.register;
  3899. }();
  3900. (window.wp = window.wp || {}).data = __webpack_exports__;
  3901. /******/ })()
  3902. ;