2 lines
30 KiB
JavaScript
2 lines
30 KiB
JavaScript
/*! This file is auto-generated */
|
||
this.wp=this.wp||{},this.wp.blockDirectory=function(e){var t={};function n(r){if(t[r])return t[r].exports;var c=t[r]={i:r,l:!1,exports:{}};return e[r].call(c.exports,c,c.exports,n),c.l=!0,c.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var c in e)n.d(r,c,function(t){return e[t]}.bind(null,c));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=459)}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},11:function(e,t){e.exports=window.wp.compose},12:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(38);var c=n(28),o=n(39);function a(e,t){return Object(r.a)(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null!=n){var r,c,o=[],a=!0,l=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);a=!0);}catch(e){l=!0,c=e}finally{try{a||null==n.return||n.return()}finally{if(l)throw c}}return o}}(e,t)||Object(c.a)(e,t)||Object(o.a)()}},133:function(e,t,n){"use strict";var r=n(5),c=n(14),o=n(0);function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}t.a=function(e){var t=e.icon,n=e.size,l=void 0===n?24:n,i=Object(c.a)(e,["icon","size"]);return Object(o.cloneElement)(t,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){Object(r.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({width:l,height:l},i))}},14:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(45);function c(e,t){if(null==e)return{};var n,c,o=Object(r.a)(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(c=0;c<a.length;c++)n=a[c],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}},15:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(24);var c=n(42),o=n(28);function a(e){return function(e){if(Array.isArray(e))return Object(r.a)(e)}(e)||Object(c.a)(e)||Object(o.a)(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}},16:function(e,t){e.exports=window.regeneratorRuntime},2:function(e,t){e.exports=window.lodash},217:function(e,t,n){"use strict";var r=n(0),c=n(7),o=Object(r.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(r.createElement)(c.Path,{d:"M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z"}));t.a=o},24:function(e,t,n){"use strict";function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,"a",(function(){return r}))},279:function(e,t){e.exports=window.wp.editPost},28:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(24);function c(e,t){if(e){if("string"==typeof e)return Object(r.a)(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Object(r.a)(e,t):void 0}}},3:function(e,t){e.exports=window.wp.components},30:function(e,t){e.exports=window.wp.hooks},301:function(e,t,n){"use strict";var r=n(0),c=n(7),o=Object(r.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(r.createElement)(c.Path,{d:"M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"}));t.a=o},302:function(e,t,n){"use strict";var r=n(0),c=n(7),o=Object(r.createElement)(c.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(r.createElement)(c.Path,{fillRule:"evenodd",d:"M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z",clipRule:"evenodd"}));t.a=o},31:function(e,t){e.exports=window.wp.editor},37:function(e,t){e.exports=window.wp.coreData},38:function(e,t,n){"use strict";function r(e){if(Array.isArray(e))return e}n.d(t,"a",(function(){return r}))},39:function(e,t,n){"use strict";function r(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}n.d(t,"a",(function(){return r}))},4:function(e,t){e.exports=window.wp.data},42:function(e,t,n){"use strict";function r(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}n.d(t,"a",(function(){return r}))},45:function(e,t,n){"use strict";function r(e,t){if(null==e)return{};var n,r,c={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(c[n]=e[n]);return c}n.d(t,"a",(function(){return r}))},459:function(e,t,n){"use strict";n.r(t),n.d(t,"store",(function(){return ce}));var r={};n.r(r),n.d(r,"isRequestingDownloadableBlocks",(function(){return k})),n.d(r,"getDownloadableBlocks",(function(){return g})),n.d(r,"getInstalledBlockTypes",(function(){return w})),n.d(r,"getNewBlockTypes",(function(){return h})),n.d(r,"getUnusedBlockTypes",(function(){return E})),n.d(r,"isInstalling",(function(){return _})),n.d(r,"getErrorNotices",(function(){return B})),n.d(r,"getErrorNoticeForBlock",(function(){return x}));var c={};n.r(c),n.d(c,"fetchDownloadableBlocks",(function(){return U})),n.d(c,"receiveDownloadableBlocks",(function(){return q})),n.d(c,"installBlockType",(function(){return Y})),n.d(c,"uninstallBlockType",(function(){return G})),n.d(c,"addInstalledBlockType",(function(){return W})),n.d(c,"removeInstalledBlockType",(function(){return J})),n.d(c,"setIsInstalling",(function(){return Q})),n.d(c,"setErrorNotice",(function(){return X})),n.d(c,"clearErrorNotice",(function(){return Z}));var o=n(0),a=n(73),l=n(30),i=n(9),s=n(4),u=n(31),b=n(5),d=n(49),f=n(15),p=n(2);function O(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function m(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?O(Object(n),!0).forEach((function(t){Object(b.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):O(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var j=Object(s.combineReducers)({downloadableBlocks:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"FETCH_DOWNLOADABLE_BLOCKS":return m(m({},e),{},Object(b.a)({},t.filterValue,{isRequesting:!0}));case"RECEIVE_DOWNLOADABLE_BLOCKS":return m(m({},e),{},Object(b.a)({},t.filterValue,{results:t.downloadableBlocks,isRequesting:!1}))}return e},blockManagement:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{installedBlockTypes:[],isInstalling:{}},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"ADD_INSTALLED_BLOCK_TYPE":return m(m({},e),{},{installedBlockTypes:[].concat(Object(f.a)(e.installedBlockTypes),[t.item])});case"REMOVE_INSTALLED_BLOCK_TYPE":return m(m({},e),{},{installedBlockTypes:e.installedBlockTypes.filter((function(e){return e.name!==t.item.name}))});case"SET_INSTALLING_BLOCK":return m(m({},e),{},{isInstalling:m(m({},e.isInstalling),{},Object(b.a)({},t.blockId,t.isInstalling))})}return e},errorNotices:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SET_ERROR_NOTICE":return m(m({},e),{},Object(b.a)({},t.blockId,{message:t.message,isFatal:t.isFatal}));case"CLEAR_ERROR_NOTICE":return Object(p.omit)(e,t.blockId)}return e}}),y=n(6);function v(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!t.length)return!1;if(t.some((function(t){return t.name===e.name})))return!0;for(var n=0;n<t.length;n++)if(v(e,t[n].innerBlocks))return!0;return!1}function k(e,t){return!(!e.downloadableBlocks[t]||!e.downloadableBlocks[t].isRequesting)&&e.downloadableBlocks[t].isRequesting}function g(e,t){return e.downloadableBlocks[t]&&e.downloadableBlocks[t].results?e.downloadableBlocks[t].results:[]}function w(e){return e.blockManagement.installedBlockTypes}var h=Object(s.createRegistrySelector)((function(e){return function(t){var n=e(y.store).getBlocks();return w(t).filter((function(e){return v(e,n)}))}})),E=Object(s.createRegistrySelector)((function(e){return function(t){var n=e(y.store).getBlocks();return w(t).filter((function(e){return!v(e,n)}))}}));function _(e,t){return e.blockManagement.isInstalling[t]||!1}function B(e){return e.errorNotices}function x(e,t){return e.errorNotices[t]}var I=n(16),S=n.n(I),N=n(1),T=n(51),P=n(48),L=n(50),D=n.n(L);function A(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return C(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return C(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,c=function(){};return{s:c,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:c}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,l=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return a=e.done,e},e:function(e){l=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(l)throw o}}}}function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var R=function(e){return new Promise((function(t,n){var r=document.createElement(e.nodeName);["id","rel","src","href","type"].forEach((function(t){e[t]&&(r[t]=e[t])})),e.innerHTML&&r.appendChild(document.createTextNode(e.innerHTML)),r.onload=function(){return t(!0)},r.onerror=function(){return n(new Error("Error loading asset."))},document.body.appendChild(r),("link"===r.nodeName.toLowerCase()||"script"===r.nodeName.toLowerCase()&&!r.src)&&t()}))};function M(e){return{type:"LOAD_ASSETS",assets:e}}var F={LOAD_ASSETS:function(){return Object(P.a)(S.a.mark((function e(){var t,n,r,c,o,a,l;return S.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,D()({url:document.location.href,parse:!1});case 2:return t=e.sent,e.next=5,t.text();case 5:n=e.sent,r=(new window.DOMParser).parseFromString(n,"text/html"),c=Array.from(r.querySelectorAll('link[rel="stylesheet"],script')).filter((function(e){return e.id&&!document.getElementById(e.id)})),o=A(c),e.prev=9,o.s();case 11:if((a=o.n()).done){e.next=17;break}return l=a.value,e.next=15,R(l);case 15:e.next=11;break;case 17:e.next=22;break;case 19:e.prev=19,e.t0=e.catch(9),o.e(e.t0);case 22:return e.prev=22,o.f(),e.finish(22);case 25:case"end":return e.stop()}}),e,null,[[9,19,22,25]])})))()}};function V(e){if(!e)return!1;var t=e.links["wp:plugin"]||e.links.self;return!(!t||!t.length)&&t[0].href}var H=S.a.mark(Y),z=S.a.mark(G);function K(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function $(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?K(Object(n),!0).forEach((function(t){Object(b.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):K(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function U(e){return{type:"FETCH_DOWNLOADABLE_BLOCKS",filterValue:e}}function q(e,t){return{type:"RECEIVE_DOWNLOADABLE_BLOCKS",downloadableBlocks:e,filterValue:t}}function Y(e){var t,n,r,c,o,a,l,u,b;return S.a.wrap((function(f){for(;;)switch(f.prev=f.next){case 0:return t=e.id,n=e.assets,r=!1,f.next=4,Z(t);case 4:return f.prev=4,f.next=7,Q(e.id,!0);case 7:if(c=V(e),o={},!c){f.next=14;break}return f.next=12,Object(d.apiFetch)({url:c,data:{status:"active"},method:"PUT"});case 12:f.next=18;break;case 14:return f.next=16,Object(d.apiFetch)({path:"wp/v2/plugins",data:{slug:e.id,status:"active"},method:"POST"});case 16:a=f.sent,o=a._links;case 18:return f.next=20,W($($({},e),{},{links:$($({},e.links),o)}));case 20:return f.next=22,M(n);case 22:return f.next=24,s.controls.select(i.store.name,"getBlockTypes");case 24:if(f.sent.some((function(t){return t.name===e.name}))){f.next=27;break}throw new Error(Object(N.__)("Error registering block. Try reloading the page."));case 27:return f.next=29,s.controls.dispatch(T.store,"createInfoNotice",Object(N.sprintf)(Object(N.__)("Block %s installed and added."),e.title),{speak:!0,type:"snackbar"});case 29:r=!0,f.next=42;break;case 32:return f.prev=32,f.t0=f.catch(4),l=f.t0.message||Object(N.__)("An error occurred."),u=f.t0 instanceof Error,(b={folder_exists:Object(N.__)("This block is already installed. Try reloading the page."),unable_to_connect_to_filesystem:Object(N.__)("Error installing block. You can reload the page and try again.")})[f.t0.code]&&(u=!0,l=b[f.t0.code]),f.next=40,X(t,l,u);case 40:return f.next=42,s.controls.dispatch(T.store,"createErrorNotice",l,{speak:!0,isDismissible:!0});case 42:return f.next=44,Q(e.id,!1);case 44:return f.abrupt("return",r);case 45:case"end":return f.stop()}}),H,null,[[4,32]])}function G(e){return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,Object(d.apiFetch)({url:V(e),data:{status:"inactive"},method:"PUT"});case 3:return t.next=5,Object(d.apiFetch)({url:V(e),method:"DELETE"});case 5:return t.next=7,J(e);case 7:t.next=13;break;case 9:return t.prev=9,t.t0=t.catch(0),t.next=13,s.controls.dispatch(T.store,"createErrorNotice",t.t0.message||Object(N.__)("An error occurred."));case 13:case"end":return t.stop()}}),z,null,[[0,9]])}function W(e){return{type:"ADD_INSTALLED_BLOCK_TYPE",item:e}}function J(e){return{type:"REMOVE_INSTALLED_BLOCK_TYPE",item:e}}function Q(e,t){return{type:"SET_INSTALLING_BLOCK",blockId:e,isInstalling:t}}function X(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{type:"SET_ERROR_NOTICE",blockId:e,message:t,isFatal:n}}function Z(e){return{type:"CLEAR_ERROR_NOTICE",blockId:e}}var ee={getDownloadableBlocks:S.a.mark((function e(t){var n,r;return S.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=5,U(t);case 5:return e.next=7,Object(d.apiFetch)({path:"wp/v2/block-directory/search?term=".concat(t)});case 7:return n=e.sent,r=n.map((function(e){return Object(p.mapKeys)(e,(function(e,t){return Object(p.camelCase)(t)}))})),e.next=11,q(r,t);case 11:e.next=15;break;case 13:e.prev=13,e.t0=e.catch(2);case 15:case"end":return e.stop()}}),e,null,[[2,13]])}))};function te(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ne(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?te(Object(n),!0).forEach((function(t){Object(b.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):te(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var re={reducer:j,selectors:r,actions:c,controls:ne(ne({},d.controls),F),resolvers:ee},ce=Object(s.createReduxStore)("core/block-directory",re);function oe(){var e=Object(s.useDispatch)(ce).uninstallBlockType,t=Object(s.useSelect)((function(e){var t=e(u.store),n=t.isAutosavingPost;return(0,t.isSavingPost)()&&!n()}),[]),n=Object(s.useSelect)((function(e){return e(ce).getUnusedBlockTypes()}),[]);return Object(o.useEffect)((function(){t&&n.length&&n.forEach((function(t){e(t),Object(i.unregisterBlockType)(t.name)}))}),[t]),null}Object(s.register)(ce);var ae=n(12),le=n(3),ie=n(11),se=n(37),ue=n(8),be=n(57),de=n(133),fe=n(301),pe=n(7),Oe=Object(o.createElement)(pe.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(o.createElement)(pe.Path,{d:"M9.518 8.783a.25.25 0 00.188-.137l2.069-4.192a.25.25 0 01.448 0l2.07 4.192a.25.25 0 00.187.137l4.626.672a.25.25 0 01.139.427l-3.347 3.262a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.363.264l-4.137-2.176a.25.25 0 00-.233 0l-4.138 2.175a.25.25 0 01-.362-.263l.79-4.607a.25.25 0 00-.072-.222L4.753 9.882a.25.25 0 01.14-.427l4.625-.672zM12 14.533c.28 0 .559.067.814.2l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39v7.143z"})),me=n(302);var je=function(e){var t=e.rating,n=.5*Math.round(t/.5),r=Math.floor(t),c=Math.ceil(t-r),a=5-(r+c);return Object(o.createElement)("span",{"aria-label":Object(N.sprintf)(Object(N.__)("%s out of 5 stars"),n)},Object(p.times)(r,(function(e){return Object(o.createElement)(de.a,{key:"full_stars_".concat(e),className:"block-directory-block-ratings__star-full",icon:fe.a,size:16})})),Object(p.times)(c,(function(e){return Object(o.createElement)(de.a,{key:"half_stars_".concat(e),className:"block-directory-block-ratings__star-half-full",icon:Oe,size:16})})),Object(p.times)(a,(function(e){return Object(o.createElement)(de.a,{key:"empty_stars_".concat(e),className:"block-directory-block-ratings__star-empty",icon:me.a,size:16})})))},ye=function(e){var t=e.rating;return Object(o.createElement)("span",{className:"block-directory-block-ratings"},Object(o.createElement)(je,{rating:t}))};var ve=function(e){var t=e.icon,n="block-directory-downloadable-block-icon";return null!==t.match(/\.(jpeg|jpg|gif|png|svg)(?:\?.*)?$/)?Object(o.createElement)("img",{className:n,src:t,alt:""}):Object(o.createElement)(y.BlockIcon,{className:n,icon:t,showColors:!0})},ke=function(e){var t=e.block,n=Object(s.useSelect)((function(e){return e(ce).getErrorNoticeForBlock(t.id)}),[t]);return n?Object(o.createElement)("div",{className:"block-directory-downloadable-block-notice"},Object(o.createElement)("div",{className:"block-directory-downloadable-block-notice__content"},n.message,n.isFatal?" "+Object(N.__)("Try reloading the page."):null)):null};function ge(e,t){var n=e.title,r=e.rating,c=e.ratingCount,o=t.hasNotice,a=t.isInstalled,l=t.isInstalling,i=.5*Math.round(r/.5);return!a&&o?Object(N.sprintf)("Retry installing %s.",Object(be.decodeEntities)(n)):a?Object(N.sprintf)("Add %s.",Object(be.decodeEntities)(n)):l?Object(N.sprintf)("Installing %s.",Object(be.decodeEntities)(n)):c<1?Object(N.sprintf)("Install %s.",Object(be.decodeEntities)(n)):Object(N.sprintf)(Object(N._n)("Install %1$s. %2$s stars with %3$s review.","Install %1$s. %2$s stars with %3$s reviews.",c),Object(be.decodeEntities)(n),i,c)}var we=function(e){var t=e.composite,n=e.item,r=e.onClick,c=n.author,a=n.description,l=n.icon,u=n.rating,b=n.title,d=!!Object(i.getBlockType)(n.name),f=Object(s.useSelect)((function(e){var t=e(ce),r=t.getErrorNoticeForBlock,c=t.isInstalling,o=r(n.id),a=o&&o.isFatal;return{hasNotice:!!o,isInstalling:c(n.id),isInstallable:!a}}),[n]),p=f.hasNotice,O=f.isInstalling,m=f.isInstallable,j="";return d?j=Object(N.__)("Installed!"):O&&(j=Object(N.__)("Installing…")),Object(o.createElement)(le.__unstableCompositeItem,Object(ue.a)({role:"option",as:le.Button},t,{className:"block-directory-downloadable-block-list-item",onClick:function(e){e.preventDefault(),r()},isBusy:O,disabled:O||!m,label:ge(n,{hasNotice:p,isInstalled:d,isInstalling:O}),showTooltip:!0,tooltipPosition:"top center"}),Object(o.createElement)("div",{className:"block-directory-downloadable-block-list-item__icon"},Object(o.createElement)(ve,{icon:l,title:b}),O?Object(o.createElement)("span",{className:"block-directory-downloadable-block-list-item__spinner"},Object(o.createElement)(le.Spinner,null)):Object(o.createElement)(ye,{rating:u})),Object(o.createElement)("span",{className:"block-directory-downloadable-block-list-item__details"},Object(o.createElement)("span",{className:"block-directory-downloadable-block-list-item__title"},Object(o.createInterpolateElement)(Object(N.sprintf)(Object(N.__)("%1$s <span>by %2$s</span>"),Object(be.decodeEntities)(b),c),{span:Object(o.createElement)("span",{className:"block-directory-downloadable-block-list-item__author"})})),p?Object(o.createElement)(ke,{block:n}):Object(o.createElement)(o.Fragment,null,Object(o.createElement)("span",{className:"block-directory-downloadable-block-list-item__desc"},j||Object(be.decodeEntities)(a)),m&&!(d||O)&&Object(o.createElement)(le.VisuallyHidden,null,Object(N.__)("Install block")))))};var he=function(e){var t=e.items,n=e.onHover,r=void 0===n?p.noop:n,c=e.onSelect,a=Object(le.__unstableUseCompositeState)(),l=Object(s.useDispatch)(ce).installBlockType;return t.length?Object(o.createElement)(le.__unstableComposite,Object(ue.a)({},a,{role:"listbox",className:"block-directory-downloadable-blocks-list","aria-label":Object(N.__)("Blocks available for install")}),t.map((function(e){return Object(o.createElement)(we,{key:e.id,composite:a,onClick:function(){Object(i.getBlockType)(e.name)?c(e):l(e).then((function(t){t&&c(e)})),r(null)},onHover:r,item:e})}))):null},Ee=n(46);var _e=function(e){var t=e.children,n=e.downloadableItems,r=e.hasLocalBlocks,c=n.length;return Object(o.useEffect)((function(){Object(Ee.speak)(Object(N.sprintf)(Object(N._n)("%d additional block is available to install.","%d additional blocks are available to install.",c),c))}),[c]),Object(o.createElement)(o.Fragment,null,!r&&Object(o.createElement)("p",{className:"block-directory-downloadable-blocks-panel__no-local"},Object(N.__)("No results available from your installed blocks.")),Object(o.createElement)("div",{className:"block-editor-inserter__quick-inserter-separator"}),Object(o.createElement)("div",{className:"block-directory-downloadable-blocks-panel"},Object(o.createElement)("div",{className:"block-directory-downloadable-blocks-panel__header"},Object(o.createElement)("h2",{className:"block-directory-downloadable-blocks-panel__title"},Object(N.__)("Available to install")),Object(o.createElement)("p",{className:"block-directory-downloadable-blocks-panel__description"},Object(N.__)("Select a block to install and add it to your post."))),t))},Be=n(217);var xe=function(){return Object(o.createElement)("div",{className:"block-editor-inserter__no-results"},Object(o.createElement)(de.a,{className:"block-editor-inserter__no-results-icon",icon:Be.a}),Object(o.createElement)("p",null,Object(N.__)("No results found.")))};var Ie=Object(ie.compose)([Object(s.withSelect)((function(e,t){var n=t.filterValue,r=t.rootClientId,c=void 0===r?null:r,o=e(ce),a=o.getDownloadableBlocks,l=o.isRequestingDownloadableBlocks,i=e(y.store).canInsertBlockType,s=e(se.store).canUser("read","block-directory/search");return{downloadableItems:s?a(n).filter((function(e){return i(e,c,!0)})):[],hasPermission:s,isLoading:l(n)}}))])((function(e){var t=e.downloadableItems,n=e.onSelect,r=e.onHover,c=e.hasLocalBlocks,a=e.hasPermission,l=e.isLoading,i=e.isTyping;return void 0===a||l||i?Object(o.createElement)(o.Fragment,null,a&&!c&&Object(o.createElement)(o.Fragment,null,Object(o.createElement)("p",{className:"block-directory-downloadable-blocks-panel__no-local"},Object(N.__)("No results available from your installed blocks.")),Object(o.createElement)("div",{className:"block-editor-inserter__quick-inserter-separator"})),Object(o.createElement)("div",{className:"block-directory-downloadable-blocks-panel has-blocks-loading"},Object(o.createElement)(le.Spinner,null))):!1===a?c?null:Object(o.createElement)(xe,null):t.length?Object(o.createElement)(_e,{downloadableItems:t,hasLocalBlocks:c},Object(o.createElement)(he,{items:t,onSelect:n,onHover:r})):!c&&Object(o.createElement)(xe,null)}));var Se=function(){var e=Object(o.useState)(""),t=Object(ae.a)(e,2),n=t[0],r=t[1],c=Object(p.debounce)(r,400);return Object(o.createElement)(y.__experimentalInserterMenuExtension,null,(function(e){var t=e.onSelect,r=e.onHover,a=e.filterValue,l=e.hasItems,i=e.rootClientId;return n!==a&&c(a),n?Object(o.createElement)(Ie,{onSelect:t,onHover:r,rootClientId:i,filterValue:n,hasLocalBlocks:l,isTyping:a!==n}):null}))},Ne=n(279);function Te(e){var t=e.items;return t.length?Object(o.createElement)("ul",{className:"block-directory-compact-list"},t.map((function(e){var t=e.icon,n=e.id,r=e.title,c=e.author;return Object(o.createElement)("li",{key:n,className:"block-directory-compact-list__item"},Object(o.createElement)(ve,{icon:t,title:r}),Object(o.createElement)("div",{className:"block-directory-compact-list__item-details"},Object(o.createElement)("div",{className:"block-directory-compact-list__item-title"},r),Object(o.createElement)("div",{className:"block-directory-compact-list__item-author"},Object(N.sprintf)(Object(N.__)("By %s"),c))))}))):null}function Pe(){var e=Object(s.useSelect)((function(e){return e(ce).getNewBlockTypes()}),[]);return e.length?Object(o.createElement)(Ne.PluginPrePublishPanel,{icon:Be.a,title:Object(N.sprintf)(Object(N._n)("Added: %d block","Added: %d blocks",e.length),e.length),initialOpen:!0},Object(o.createElement)("p",{className:"installed-blocks-pre-publish-panel__copy"},Object(N._n)("The following block has been added to your site.","The following blocks have been added to your site.",e.length)),Object(o.createElement)(Te,{items:e})):null}var Le=n(14);function De(e){var t=e.attributes,n=e.block,r=e.clientId,c=Object(s.useSelect)((function(e){return e(ce).isInstalling(n.id)})),a=Object(s.useDispatch)(ce).installBlockType,l=Object(s.useDispatch)(y.store).replaceBlock;return Object(o.createElement)(le.Button,{onClick:function(){return a(n).then((function(e){if(e){var c=Object(i.getBlockType)(n.name),o=Object(i.parse)(t.originalContent),a=Object(ae.a)(o,1)[0];a&&l(r,Object(i.createBlock)(c.name,a.attributes,a.innerBlocks))}}))},disabled:c,isBusy:c,isPrimary:!0},Object(N.sprintf)(Object(N.__)("Install %s"),n.title))}var Ae=function(e){var t=e.originalBlock,n=Object(Le.a)(e,["originalBlock"]),r=n.attributes,c=r.originalName,a=r.originalUndelimitedContent,l=Object(s.useDispatch)(y.store).replaceBlock,u=!!a,b=Object(i.getBlockType)("core/html"),d=Object(N.sprintf)(Object(N.__)("Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely."),t.title||c),f=[Object(o.createElement)(De,{key:"install",block:t,attributes:n.attributes,clientId:n.clientId})];return u&&b&&(d=Object(N.sprintf)(Object(N.__)("Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely."),t.title||c),f.push(Object(o.createElement)(le.Button,{key:"convert",onClick:function(){l(n.clientId,Object(i.createBlock)("core/html",{content:a}))},isLink:!0},Object(N.__)("Keep as HTML")))),Object(o.createElement)("div",Object(y.useBlockProps)(),Object(o.createElement)(y.Warning,{actions:f},d),Object(o.createElement)(o.RawHTML,null,a))},Ce=function(e){return function(t){var n=t.attributes.originalName,r=Object(s.useSelect)((function(e){var t=(0,e(ce).getDownloadableBlocks)("block:"+n).filter((function(e){var t=e.name;return n===t}));return{hasPermission:e(se.store).canUser("read","block-directory/search"),block:t.length&&t[0]}}),[n]),c=r.block;return r.hasPermission&&c?Object(o.createElement)(Ae,Object(ue.a)({},t,{originalBlock:c})):Object(o.createElement)(e,t)}};Object(a.registerPlugin)("block-directory",{render:function(){return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(oe,null),Object(o.createElement)(Se,null),Object(o.createElement)(Pe,null))}}),Object(l.addFilter)("blocks.registerBlockType","block-directory/fallback",(function(e,t){return"core/missing"!==t||(e.edit=Ce(e.edit)),e}))},46:function(e,t){e.exports=window.wp.a11y},48:function(e,t,n){"use strict";function r(e,t,n,r,c,o,a){try{var l=e[o](a),i=l.value}catch(e){return void n(e)}l.done?t(i):Promise.resolve(i).then(r,c)}function c(e){return function(){var t=this,n=arguments;return new Promise((function(c,o){var a=e.apply(t,n);function l(e){r(a,c,o,l,i,"next",e)}function i(e){r(a,c,o,l,i,"throw",e)}l(void 0)}))}}n.d(t,"a",(function(){return c}))},49:function(e,t){e.exports=window.wp.dataControls},5:function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,"a",(function(){return r}))},50:function(e,t){e.exports=window.wp.apiFetch},51:function(e,t){e.exports=window.wp.notices},57:function(e,t){e.exports=window.wp.htmlEntities},6:function(e,t){e.exports=window.wp.blockEditor},7:function(e,t){e.exports=window.wp.primitives},73:function(e,t){e.exports=window.wp.plugins},8:function(e,t,n){"use strict";function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}n.d(t,"a",(function(){return r}))},9:function(e,t){e.exports=window.wp.blocks}}); |