WordPress/wp-includes/js/dist/block-directory.min.js

2 lines
31 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*! 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=463)}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},11:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(38);var c=n(31),o=n(39);function a(e,t){return Object(r.a)(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],r=!0,c=!1,o=void 0;try{for(var a,i=e[Symbol.iterator]();!(r=(a=i.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){c=!0,o=e}finally{try{r||null==i.return||i.return()}finally{if(c)throw o}}return n}}(e,t)||Object(c.a)(e,t)||Object(o.a)()}},12:function(e,t){e.exports=window.wp.compose},13:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(44);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}},138:function(e,t,n){"use strict";var r=n(5),c=n(13),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,i=void 0===n?24:n,l=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:i,height:i},l))}},15:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(24);var c=n(37),o=n(31);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},215: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}))},278:function(e,t){e.exports=window.wp.editPost},3:function(e,t){e.exports=window.wp.components},303: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},304: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,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}}},33:function(e,t){e.exports=window.wp.hooks},37:function(e,t,n){"use strict";function r(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}n.d(t,"a",(function(){return r}))},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},44: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}))},463:function(e,t,n){"use strict";n.r(t),n.d(t,"store",(function(){return ne}));var r={};n.r(r),n.d(r,"isRequestingDownloadableBlocks",(function(){return y})),n.d(r,"getDownloadableBlocks",(function(){return v})),n.d(r,"getInstalledBlockTypes",(function(){return k})),n.d(r,"getNewBlockTypes",(function(){return h})),n.d(r,"getUnusedBlockTypes",(function(){return g})),n.d(r,"isInstalling",(function(){return w})),n.d(r,"getErrorNotices",(function(){return E})),n.d(r,"getErrorNoticeForBlock",(function(){return _}));var c={};n.r(c),n.d(c,"fetchDownloadableBlocks",(function(){return U})),n.d(c,"receiveDownloadableBlocks",(function(){return K})),n.d(c,"installBlockType",(function(){return W})),n.d(c,"uninstallBlockType",(function(){return Y})),n.d(c,"addInstalledBlockType",(function(){return $})),n.d(c,"removeInstalledBlockType",(function(){return G})),n.d(c,"setIsInstalling",(function(){return q})),n.d(c,"setErrorNotice",(function(){return J})),n.d(c,"clearErrorNotice",(function(){return Q}));var o=n(0),a=n(73),i=n(33),l=n(9),s=n(4),u=n(5),b=n(49),d=n(15),f=n(2);function p(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 O(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach((function(t){Object(u.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var m=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 O(O({},e),{},Object(u.a)({},t.filterValue,{isRequesting:!0}));case"RECEIVE_DOWNLOADABLE_BLOCKS":return O(O({},e),{},Object(u.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 O(O({},e),{},{installedBlockTypes:[].concat(Object(d.a)(e.installedBlockTypes),[t.item])});case"REMOVE_INSTALLED_BLOCK_TYPE":return O(O({},e),{},{installedBlockTypes:e.installedBlockTypes.filter((function(e){return e.name!==t.item.name}))});case"SET_INSTALLING_BLOCK":return O(O({},e),{},{isInstalling:O(O({},e.isInstalling),{},Object(u.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 O(O({},e),{},Object(u.a)({},t.blockId,{message:t.message,isFatal:t.isFatal}));case"CLEAR_ERROR_NOTICE":return Object(f.omit)(e,t.blockId)}return e}});function j(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(j(e,t[n].innerBlocks))return!0;return!1}function y(e,t){return!(!e.downloadableBlocks[t]||!e.downloadableBlocks[t].isRequesting)&&e.downloadableBlocks[t].isRequesting}function v(e,t){return e.downloadableBlocks[t]&&e.downloadableBlocks[t].results?e.downloadableBlocks[t].results:[]}function k(e){return e.blockManagement.installedBlockTypes}var h=Object(s.createRegistrySelector)((function(e){return function(t){var n=e("core/block-editor").getBlocks();return k(t).filter((function(e){return j(e,n)}))}})),g=Object(s.createRegistrySelector)((function(e){return function(t){var n=e("core/block-editor").getBlocks();return k(t).filter((function(e){return!j(e,n)}))}}));function w(e,t){return e.blockManagement.isInstalling[t]||!1}function E(e){return e.errorNotices}function _(e,t){return e.errorNotices[t]}var B=n(16),S=n.n(B),x=n(1),P=n(51),N=n(47),T=n(50),I=n.n(T);function L(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,i=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return a=e.done,e},e:function(e){i=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(i)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 D=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 A(e){return{type:"LOAD_ASSETS",assets:e}}var R={LOAD_ASSETS:function(){return Object(N.a)(S.a.mark((function e(){var t,n,r,c,o,a,i;return S.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,I()({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=L(c),e.prev=9,o.s();case 11:if((a=o.n()).done){e.next=17;break}return i=a.value,e.next=15,D(i);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 M(e){if(!e)return!1;var t=e.links["wp:plugin"]||e.links.self;return!(!t||!t.length)&&t[0].href}var F=S.a.mark(W),V=S.a.mark(Y);function z(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 H(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?z(Object(n),!0).forEach((function(t){Object(u.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):z(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 K(e,t){return{type:"RECEIVE_DOWNLOADABLE_BLOCKS",downloadableBlocks:e,filterValue:t}}function W(e){var t,n,r,c,o,a,i,u,d;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,Q(t);case 4:return f.prev=4,f.next=7,q(e.id,!0);case 7:if(c=M(e),o={},!c){f.next=14;break}return f.next=12,Object(b.apiFetch)({url:c,data:{status:"active"},method:"PUT"});case 12:f.next=18;break;case 14:return f.next=16,Object(b.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,$(H(H({},e),{},{links:H(H({},e.links),o)}));case 20:return f.next=22,A(n);case 22:return f.next=24,s.controls.select(l.store.name,"getBlockTypes");case 24:if(f.sent.some((function(t){return t.name===e.name}))){f.next=27;break}throw new Error(Object(x.__)("Error registering block. Try reloading the page."));case 27:r=!0,f.next=38;break;case 30:return f.prev=30,f.t0=f.catch(4),i=f.t0.message||Object(x.__)("An error occurred."),u=f.t0 instanceof Error,(d={folder_exists:Object(x.__)("This block is already installed. Try reloading the page."),unable_to_connect_to_filesystem:Object(x.__)("Error installing block. You can reload the page and try again.")})[f.t0.code]&&(u=!0,i=d[f.t0.code]),f.next=38,J(t,i,u);case 38:return f.next=40,q(e.id,!1);case 40:return f.abrupt("return",r);case 41:case"end":return f.stop()}}),F,null,[[4,30]])}function Y(e){return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,Object(b.apiFetch)({url:M(e),data:{status:"inactive"},method:"PUT"});case 3:return t.next=5,Object(b.apiFetch)({url:M(e),method:"DELETE"});case 5:return t.next=7,G(e);case 7:t.next=13;break;case 9:return t.prev=9,t.t0=t.catch(0),t.next=13,s.controls.dispatch(P.store,"createErrorNotice",t.t0.message||Object(x.__)("An error occurred."));case 13:case"end":return t.stop()}}),V,null,[[0,9]])}function $(e){return{type:"ADD_INSTALLED_BLOCK_TYPE",item:e}}function G(e){return{type:"REMOVE_INSTALLED_BLOCK_TYPE",item:e}}function q(e,t){return{type:"SET_INSTALLING_BLOCK",blockId:e,isInstalling:t}}function J(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 Q(e){return{type:"CLEAR_ERROR_NOTICE",blockId:e}}var X={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(b.apiFetch)({path:"wp/v2/block-directory/search?term=".concat(t)});case 7:return n=e.sent,r=n.map((function(e){return Object(f.mapKeys)(e,(function(e,t){return Object(f.camelCase)(t)}))})),e.next=11,K(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 Z(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 ee(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Z(Object(n),!0).forEach((function(t){Object(u.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Z(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var te={reducer:m,selectors:r,actions:c,controls:ee(ee({},b.controls),R),resolvers:X},ne=Object(s.createReduxStore)("core/block-directory",te);function re(){var e=Object(s.useDispatch)(ne).uninstallBlockType,t=Object(s.useSelect)((function(e){var t=e("core/editor"),n=t.isAutosavingPost;return(0,t.isSavingPost)()&&!n()}),[]),n=Object(s.useSelect)((function(e){return e(ne).getUnusedBlockTypes()}),[]);return Object(o.useEffect)((function(){t&&n.length&&n.forEach((function(t){e(t),Object(l.unregisterBlockType)(t.name)}))}),[t]),null}Object(s.register)(ne);var ce=n(11),oe=n(6),ae=n(12),ie=n(3),le=n(48);var se=function(e){var t=e.author,n=e.authorBlockCount,r=e.authorBlockRating;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)("span",{className:"block-directory-downloadable-block-author-info__content-author"},Object(x.sprintf)(Object(x.__)("Authored by %s"),t)),Object(o.createElement)("span",{className:"block-directory-downloadable-block-author-info__content"},r>0?Object(x.sprintf)(Object(x._n)("This author has %1$d block, with an average rating of %2$.1f.","This author has %1$d blocks, with an average rating of %2$.1f.",n),n,r):Object(x.sprintf)(Object(x._n)("This author has %1$d block.","This author has %1$d blocks.",n),n)))},ue=n(64),be=n(138),de=n(303),fe=n(7),pe=Object(o.createElement)(fe.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(o.createElement)(fe.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"})),Oe=n(304);var me=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)("div",{"aria-label":Object(x.sprintf)(Object(x.__)("%s out of 5 stars"),n)},Object(f.times)(r,(function(e){return Object(o.createElement)(be.a,{key:"full_stars_".concat(e),icon:de.a,size:16})})),Object(f.times)(c,(function(e){return Object(o.createElement)(be.a,{key:"half_stars_".concat(e),icon:pe,size:16})})),Object(f.times)(a,(function(e){return Object(o.createElement)(be.a,{key:"empty_stars_".concat(e),icon:Oe.a,size:16})})))},je=function(e){var t=e.rating,n=e.ratingCount;return Object(o.createElement)("div",{className:"block-directory-block-ratings"},Object(o.createElement)(me,{rating:t}),Object(o.createElement)("span",{className:"block-directory-block-ratings__rating-count","aria-label":Object(x.sprintf)(Object(x._n)("%d total rating","%d total ratings",n),n)},"(",n,")"))};var ye=function(e){var t=e.icon,n=e.title;return Object(o.createElement)("div",{className:"block-directory-downloadable-block-icon"},null!==t.match(/\.(jpeg|jpg|gif|png|svg)(?:\?.*)?$/)?Object(o.createElement)("img",{src:t,alt:Object(x.sprintf)(Object(x.__)("%s block icon"),n)}):Object(o.createElement)(oe.BlockIcon,{icon:t,showColors:!0}))};var ve=function(e){var t=e.icon,n=e.title,r=e.rating,c=e.ratingCount,a=e.isLoading,i=void 0!==a&&a,l=e.isInstallable,s=void 0===l||l,u=e.onClick;return Object(o.createElement)("div",{className:"block-directory-downloadable-block-header__row"},Object(o.createElement)(ye,{icon:t,title:n}),Object(o.createElement)("div",{className:"block-directory-downloadable-block-header__column"},Object(o.createElement)("h2",{className:"block-directory-downloadable-block-header__title"},Object(ue.decodeEntities)(n)),Object(o.createElement)(je,{rating:r,ratingCount:c})),Object(o.createElement)(ie.Button,{isSecondary:!0,isBusy:i,disabled:i||!s,onClick:function(e){e.preventDefault(),!i&&s&&u()}},i?Object(x.__)("Adding…"):Object(x.__)("Add block")))},ke=Object(o.createElement)(fe.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"-2 -2 24 24"},Object(o.createElement)(fe.Path,{d:"M18 3.5c0 .62-.38 1.16-.92 1.38v13.11H1.99l4.22-6.73c-.13-.23-.21-.48-.21-.76C6 9.67 6.67 9 7.5 9S9 9.67 9 10.5c0 .13-.02.25-.05.37l1.44.63c.27-.3.67-.5 1.11-.5.18 0 .35.04.51.09l3.58-6.41c-.36-.27-.59-.7-.59-1.18 0-.83.67-1.5 1.5-1.5.19 0 .36.04.53.1l.05-.09v.11c.54.22.92.76.92 1.38zm-1.92 13.49V5.85l-3.29 5.89c.13.23.21.48.21.76 0 .83-.67 1.5-1.5 1.5s-1.5-.67-1.5-1.5l.01-.07-1.63-.72c-.25.18-.55.29-.88.29-.18 0-.35-.04-.51-.1l-3.2 5.09h12.29z"})),he=Object(o.createElement)(fe.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"-2 -2 24 24"},Object(o.createElement)(fe.Path,{d:"M10.2 3.28c3.53 0 6.43 2.61 6.92 6h2.08l-3.5 4-3.5-4h2.32c-.45-1.97-2.21-3.45-4.32-3.45-1.45 0-2.73.71-3.54 1.78L4.95 5.66C6.23 4.2 8.11 3.28 10.2 3.28zm-.4 13.44c-3.52 0-6.43-2.61-6.92-6H.8l3.5-4c1.17 1.33 2.33 2.67 3.5 4H5.48c.45 1.97 2.21 3.45 4.32 3.45 1.45 0 2.73-.71 3.54-1.78l1.71 1.95c-1.28 1.46-3.15 2.38-5.25 2.38z"}));var ge=function(e){var t,n=e.activeInstalls,r=e.description,c=e.humanizedUpdated;return t=n>1e6?Object(x.sprintf)(Object(x.__)("%d+ Million active installations"),Math.floor(n/1e6)):0===n?Object(x.__)("Less than 10 active installations"):Object(x.sprintf)(Object(x.__)("%d+ active installations"),n),Object(o.createElement)(o.Fragment,null,Object(o.createElement)("p",{className:"block-directory-downloadable-block-info__content"},Object(ue.decodeEntities)(r)),Object(o.createElement)("div",{className:"block-directory-downloadable-block-info__meta"},Object(o.createElement)(be.a,{className:"block-directory-downloadable-block-info__icon",icon:ke}),t),Object(o.createElement)("div",{className:"block-directory-downloadable-block-info__meta"},Object(o.createElement)(be.a,{className:"block-directory-downloadable-block-info__icon",icon:he}),Object(x.sprintf)(Object(x.__)("Updated %s"),c)))},we=function(e){var t=e.block,n=e.onClick,r=Object(s.useSelect)((function(e){return e(ne).getErrorNoticeForBlock(t.id)}),[t]);return r?Object(o.createElement)(ie.Notice,{status:"error",isDismissible:!1,className:"block-directory-downloadable-block-notice"},Object(o.createElement)("div",{className:"block-directory-downloadable-block-notice__content"},r.message),Object(o.createElement)(ie.Button,{isSmall:!0,isPrimary:!0,onClick:function(){if(r.isFatal)return window.location.reload(),!1;n(t)}},r.isFatal?Object(x.__)("Reload"):Object(x.__)("Retry"))):null};function Ee(e){var t=e.item,n=e.onClick,r=Object(s.useSelect)((function(e){var n=e(ne),r=n.isInstalling,c=(0,n.getErrorNoticeForBlock)(t.id),o=c&&c.isFatal;return{isLoading:r(t.id),isInstallable:!o}}),[t]),c=r.isLoading,a=r.isInstallable,i=t.icon,l=t.title,u=t.description,b=t.rating,d=t.activeInstalls,f=t.ratingCount,p=t.author,O=t.humanizedUpdated,m=t.authorBlockCount,j=t.authorBlockRating;return Object(o.createElement)("li",{className:"block-directory-downloadable-block-list-item"},Object(o.createElement)("article",{className:"block-directory-downloadable-block-list-item__panel"},Object(o.createElement)("header",{className:"block-directory-downloadable-block-list-item__header"},Object(o.createElement)(ve,{icon:i,onClick:n,title:l,rating:b,ratingCount:f,isLoading:c,isInstallable:a})),Object(o.createElement)("section",{className:"block-directory-downloadable-block-list-item__body"},Object(o.createElement)(we,{onClick:n,block:t}),Object(o.createElement)(ge,{activeInstalls:d,description:u,humanizedUpdated:O})),Object(o.createElement)("footer",{className:"block-directory-downloadable-block-list-item__footer"},Object(o.createElement)(se,{author:p,authorBlockCount:m,authorBlockRating:j}))))}var _e=function(e){var t=e.items,n=e.onHover,r=void 0===n?f.noop:n,c=e.onSelect,a=Object(s.useDispatch)(ne).installBlockType;return t.length?Object(o.createElement)("ul",{role:"list",className:"block-directory-downloadable-blocks-list"},t.map((function(e){return Object(o.createElement)(Ee,{key:e.id,onClick:function(){Object(l.getBlockType)(e.name)?c(e):a(e).then((function(t){t&&c(e)})),r(null)},item:e})}))):null};var Be=Object(ae.compose)([Object(s.withSelect)((function(e,t){var n=t.filterValue,r=t.rootClientId,c=void 0===r?null:r,o=e(ne),a=o.getDownloadableBlocks,i=o.isRequestingDownloadableBlocks,l=e(oe.store).canInsertBlockType,s=e("core").canUser("read","block-directory/search");return{downloadableItems:s?a(n).filter((function(e){return l(e,c,!0)})):[],hasPermission:s,isLoading:i(n)}}))])((function(e){var t=e.downloadableItems,n=e.onSelect,r=e.onHover,c=e.hasPermission,a=e.isLoading,i=e.isWaiting,l=Object(ae.useDebounce)(le.speak,500);return!1===c?(l(Object(x.__)("No blocks found in your library.")),Object(o.createElement)("p",{className:"block-directory-downloadable-blocks-panel__description has-no-results"},Object(x.__)("No blocks found in your library."))):void 0===c||a||i?Object(o.createElement)("p",{className:"block-directory-downloadable-blocks-panel__description has-no-results"},Object(o.createElement)(ie.Spinner,null)):t.length?(l(Object(x.sprintf)(Object(x._n)("No blocks found in your library. We did find %d block available for download.","No blocks found in your library. We did find %d blocks available for download.",t.length),t.length)),Object(o.createElement)(o.Fragment,null,Object(o.createElement)("p",{className:"block-directory-downloadable-blocks-panel__description"},Object(x.__)("No blocks found in your library. These blocks can be downloaded and installed:")),Object(o.createElement)(_e,{items:t,onSelect:n,onHover:r}))):Object(o.createElement)("p",{className:"block-directory-downloadable-blocks-panel__description has-no-results"},Object(x.__)("No blocks found in your library."))}));var Se=function(){var e=Object(o.useState)(""),t=Object(ce.a)(e,2),n=t[0],r=t[1],c=Object(f.debounce)(r,400);return Object(o.createElement)(oe.__experimentalInserterMenuExtension,null,(function(e){var t=e.onSelect,r=e.onHover,a=e.filterValue,i=e.hasItems,l=e.rootClientId;return i||!a?null:(n!==a&&c(a),Object(o.createElement)(Be,{onSelect:t,onHover:r,rootClientId:l,filterValue:n,isWaiting:a!==n}))}))},xe=n(278),Pe=n(215);function Ne(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)(ye,{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(x.sprintf)(Object(x.__)("By %s"),c))))}))):null}function Te(){var e=Object(s.useSelect)((function(e){return e(ne).getNewBlockTypes()}),[]);return e.length?Object(o.createElement)(xe.PluginPrePublishPanel,{icon:Pe.a,title:Object(x.sprintf)(Object(x._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(x._n)("The following block has been added to your site.","The following blocks have been added to your site.",e.length)),Object(o.createElement)(Ne,{items:e})):null}var Ie=n(13),Le=n(8);function Ce(e){var t=e.attributes,n=e.block,r=e.clientId,c=Object(s.useSelect)((function(e){return e(ne).isInstalling(n.id)})),a=Object(s.useDispatch)(ne).installBlockType,i=Object(s.useDispatch)("core/block-editor").replaceBlock;return Object(o.createElement)(ie.Button,{onClick:function(){return a(n).then((function(e){if(e){var c=Object(l.getBlockType)(n.name),o=Object(l.parse)(t.originalContent),a=Object(ce.a)(o,1)[0];a&&i(r,Object(l.createBlock)(c.name,a.attributes,a.innerBlocks))}}))},disabled:c,isBusy:c,isPrimary:!0},Object(x.sprintf)(Object(x.__)("Install %s"),n.title))}var De=function(e){var t=e.originalBlock,n=Object(Ie.a)(e,["originalBlock"]),r=n.attributes,c=r.originalName,a=r.originalUndelimitedContent,i=Object(s.useDispatch)("core/block-editor").replaceBlock,u=!!a,b=Object(l.getBlockType)("core/html"),d=Object(x.sprintf)(Object(x.__)("Your site doesnt include support for the %s block. You can try installing the block or remove it entirely!"),t.title||c),f=[Object(o.createElement)(Ce,{key:"install",block:t,attributes:n.attributes,clientId:n.clientId})];return u&&b&&(d=Object(x.sprintf)(Object(x.__)("Your site doesnt 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)(ie.Button,{key:"convert",onClick:function(){i(n.clientId,Object(l.createBlock)("core/html",{content:a}))},isLink:!0},Object(x.__)("Keep as HTML")))),Object(o.createElement)("div",Object(oe.useBlockProps)(),Object(o.createElement)(oe.Warning,{actions:f},d),Object(o.createElement)(o.RawHTML,null,a))},Ae=function(e){return function(t){var n=t.attributes.originalName,r=Object(s.useSelect)((function(e){var t=(0,e(ne).getDownloadableBlocks)("block:"+n).filter((function(e){var t=e.name;return n===t}));return{hasPermission:e("core").canUser("read","block-directory/search"),block:t.length&&t[0]}}),[n]),c=r.block;return r.hasPermission&&c?Object(o.createElement)(De,Object(Le.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)(re,null),Object(o.createElement)(Se,null),Object(o.createElement)(Te,null))}}),Object(i.addFilter)("blocks.registerBlockType","block-directory/fallback",(function(e,t){return"core/missing"!==t||(e.edit=Ae(e.edit)),e}))},47:function(e,t,n){"use strict";function r(e,t,n,r,c,o,a){try{var i=e[o](a),l=i.value}catch(e){return void n(e)}i.done?t(l):Promise.resolve(l).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 i(e){r(a,c,o,i,l,"next",e)}function l(e){r(a,c,o,i,l,"throw",e)}i(void 0)}))}}n.d(t,"a",(function(){return c}))},48:function(e,t){e.exports=window.wp.a11y},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},6:function(e,t){e.exports=window.wp.blockEditor},64:function(e,t){e.exports=window.wp.htmlEntities},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}});