/*! This file is auto-generated */ !function(){"use strict";var e={n:function(t){var l=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(l,{a:l}),l},d:function(t,l){for(var n in l)e.o(l,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:l[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{store:function(){return $}});var l={};e.r(l),e.d(l,{getDownloadableBlocks:function(){return _},getErrorNoticeForBlock:function(){return h},getErrorNotices:function(){return y},getInstalledBlockTypes:function(){return g},getNewBlockTypes:function(){return w},getUnusedBlockTypes:function(){return E},isInstalling:function(){return f},isRequestingDownloadableBlocks:function(){return b}});var n={};e.r(n),e.d(n,{addInstalledBlockType:function(){return R},clearErrorNotice:function(){return F},fetchDownloadableBlocks:function(){return C},installBlockType:function(){return D},receiveDownloadableBlocks:function(){return O},removeInstalledBlockType:function(){return A},setErrorNotice:function(){return x},setIsInstalling:function(){return M},uninstallBlockType:function(){return P}});var o={};e.r(o),e.d(o,{getDownloadableBlocks:function(){return V}});var r=window.wp.element,a=window.wp.plugins,i=window.wp.hooks,s=window.wp.blocks,c=window.wp.data,d=window.wp.editor,u=window.lodash;var m=(0,c.combineReducers)({downloadableBlocks:function(){let 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{...e,[t.filterValue]:{isRequesting:!0}};case"RECEIVE_DOWNLOADABLE_BLOCKS":return{...e,[t.filterValue]:{results:t.downloadableBlocks,isRequesting:!1}}}return e},blockManagement:function(){let 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{...e,installedBlockTypes:[...e.installedBlockTypes,t.item]};case"REMOVE_INSTALLED_BLOCK_TYPE":return{...e,installedBlockTypes:e.installedBlockTypes.filter((e=>e.name!==t.item.name))};case"SET_INSTALLING_BLOCK":return{...e,isInstalling:{...e.isInstalling,[t.blockId]:t.isInstalling}}}return e},errorNotices:function(){let 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{...e,[t.blockId]:{message:t.message,isFatal:t.isFatal}};case"CLEAR_ERROR_NOTICE":return(0,u.omit)(e,t.blockId)}return e}}),p=window.wp.blockEditor;function k(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!t.length)return!1;if(t.some((t=>{let{name:l}=t;return l===e.name})))return!0;for(let l=0;lt=>{const l=e(p.store).getBlocks();return g(t).filter((e=>k(e,l)))})),E=(0,c.createRegistrySelector)((e=>t=>{const l=e(p.store).getBlocks();return g(t).filter((e=>!k(e,l)))}));function f(e,t){return e.blockManagement.isInstalling[t]||!1}function y(e){return e.errorNotices}function h(e,t){return e.errorNotices[t]}var v=window.wp.i18n,B=window.wp.apiFetch,N=e.n(B),I=window.wp.notices,T=window.wp.url;const L=e=>new Promise(((t,l)=>{const n=document.createElement(e.nodeName);["id","rel","src","href","type"].forEach((t=>{e[t]&&(n[t]=e[t])})),e.innerHTML&&n.appendChild(document.createTextNode(e.innerHTML)),n.onload=()=>t(!0),n.onerror=()=>l(new Error("Error loading asset.")),document.body.appendChild(n),("link"===n.nodeName.toLowerCase()||"script"===n.nodeName.toLowerCase()&&!n.src)&&t()}));function S(e){if(!e)return!1;const t=e.links["wp:plugin"]||e.links.self;return!(!t||!t.length)&&t[0].href}function C(e){return{type:"FETCH_DOWNLOADABLE_BLOCKS",filterValue:e}}function O(e,t){return{type:"RECEIVE_DOWNLOADABLE_BLOCKS",downloadableBlocks:e,filterValue:t}}const D=e=>async t=>{let{registry:l,dispatch:n}=t;const{id:o,name:r}=e;let a=!1;n.clearErrorNotice(o);try{n.setIsInstalling(o,!0);const t=S(e);let i={};if(t)await N()({method:"PUT",url:t,data:{status:"active"}});else{i=(await N()({method:"POST",path:"wp/v2/plugins",data:{slug:o,status:"active"}}))._links}n.addInstalledBlockType({...e,links:{...e.links,...i}});const c=["api_version","title","category","parent","icon","description","keywords","attributes","provides_context","uses_context","supports","styles","example","variations"];await N()({path:(0,T.addQueryArgs)(`/wp/v2/block-types/${r}`,{_fields:c})}).catch((()=>{})).then((e=>{e&&(0,s.unstable__bootstrapServerSideBlockDefinitions)({[r]:(0,u.pick)(e,c)})})),await async function(){const e=await N()({url:document.location.href,parse:!1}),t=await e.text(),l=(new window.DOMParser).parseFromString(t,"text/html"),n=Array.from(l.querySelectorAll('link[rel="stylesheet"],script')).filter((e=>e.id&&!document.getElementById(e.id)));for(const e of n)await L(e)}();if(!l.select(s.store).getBlockTypes().some((e=>e.name===r)))throw new Error((0,v.__)("Error registering block. Try reloading the page."));l.dispatch(I.store).createInfoNotice((0,v.sprintf)((0,v.__)("Block %s installed and added."),e.title),{speak:!0,type:"snackbar"}),a=!0}catch(e){let t=e.message||(0,v.__)("An error occurred."),r=e instanceof Error;const a={folder_exists:(0,v.__)("This block is already installed. Try reloading the page."),unable_to_connect_to_filesystem:(0,v.__)("Error installing block. You can reload the page and try again.")};a[e.code]&&(r=!0,t=a[e.code]),n.setErrorNotice(o,t,r),l.dispatch(I.store).createErrorNotice(t,{speak:!0,isDismissible:!0})}return n.setIsInstalling(o,!1),a},P=e=>async t=>{let{registry:l,dispatch:n}=t;try{const t=S(e);await N()({method:"PUT",url:t,data:{status:"inactive"}}),await N()({method:"DELETE",url:t}),n.removeInstalledBlockType(e)}catch(e){l.dispatch(I.store).createErrorNotice(e.message||(0,v.__)("An error occurred."))}};function R(e){return{type:"ADD_INSTALLED_BLOCK_TYPE",item:e}}function A(e){return{type:"REMOVE_INSTALLED_BLOCK_TYPE",item:e}}function M(e,t){return{type:"SET_INSTALLING_BLOCK",blockId:e,isInstalling:t}}function x(e,t){let l=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{type:"SET_ERROR_NOTICE",blockId:e,message:t,isFatal:l}}function F(e){return{type:"CLEAR_ERROR_NOTICE",blockId:e}}const V=e=>async t=>{let{dispatch:l}=t;if(e)try{l(C(e));const t=await N()({path:`wp/v2/block-directory/search?term=${e}`});l(O(t.map((e=>(0,u.mapKeys)(e,((e,t)=>(0,u.camelCase)(t))))),e))}catch{}},H={reducer:m,selectors:l,actions:n,resolvers:o},$=(0,c.createReduxStore)("core/block-directory",H);function K(){const{uninstallBlockType:e}=(0,c.useDispatch)($),t=(0,c.useSelect)((e=>{const{isAutosavingPost:t,isSavingPost:l}=e(d.store);return l()&&!t()}),[]),l=(0,c.useSelect)((e=>e($).getUnusedBlockTypes()),[]);return(0,r.useEffect)((()=>{t&&l.length&&l.forEach((t=>{e(t),(0,s.unregisterBlockType)(t.name)}))}),[t]),null}(0,c.register)($);var z=window.wp.components,Y=window.wp.compose,j=window.wp.coreData;function q(){return q=Object.assign||function(e){for(var t=1;t(0,r.createElement)(G,{key:`full_stars_${e}`,className:"block-directory-block-ratings__star-full",icon:Q,size:16}))),(0,u.times)(o,(e=>(0,r.createElement)(G,{key:`half_stars_${e}`,className:"block-directory-block-ratings__star-half-full",icon:J,size:16}))),(0,u.times)(a,(e=>(0,r.createElement)(G,{key:`empty_stars_${e}`,className:"block-directory-block-ratings__star-empty",icon:X,size:16}))))};var ee=e=>{let{rating:t}=e;return(0,r.createElement)("span",{className:"block-directory-block-ratings"},(0,r.createElement)(Z,{rating:t}))};var te=function(e){let{icon:t}=e;const l="block-directory-downloadable-block-icon";return null!==t.match(/\.(jpeg|jpg|gif|png|svg)(?:\?.*)?$/)?(0,r.createElement)("img",{className:l,src:t,alt:""}):(0,r.createElement)(p.BlockIcon,{className:l,icon:t,showColors:!0})};var le=e=>{let{block:t}=e;const l=(0,c.useSelect)((e=>e($).getErrorNoticeForBlock(t.id)),[t]);return l?(0,r.createElement)("div",{className:"block-directory-downloadable-block-notice"},(0,r.createElement)("div",{className:"block-directory-downloadable-block-notice__content"},l.message,l.isFatal?" "+(0,v.__)("Try reloading the page."):null)):null};function ne(e,t){let{title:l,rating:n,ratingCount:o}=e,{hasNotice:r,isInstalled:a,isInstalling:i}=t;const s=.5*Math.round(n/.5);return!a&&r?(0,v.sprintf)("Retry installing %s.",(0,U.decodeEntities)(l)):a?(0,v.sprintf)("Add %s.",(0,U.decodeEntities)(l)):i?(0,v.sprintf)("Installing %s.",(0,U.decodeEntities)(l)):o<1?(0,v.sprintf)("Install %s.",(0,U.decodeEntities)(l)):(0,v.sprintf)((0,v._n)("Install %1$s. %2$s stars with %3$s review.","Install %1$s. %2$s stars with %3$s reviews.",o),(0,U.decodeEntities)(l),s,o)}var oe=function(e){let{composite:t,item:l,onClick:n}=e;const{author:o,description:a,icon:i,rating:d,title:u}=l,m=!!(0,s.getBlockType)(l.name),{hasNotice:p,isInstalling:k,isInstallable:b}=(0,c.useSelect)((e=>{const{getErrorNoticeForBlock:t,isInstalling:n}=e($),o=t(l.id),r=o&&o.isFatal;return{hasNotice:!!o,isInstalling:n(l.id),isInstallable:!r}}),[l]);let _="";return m?_=(0,v.__)("Installed!"):k&&(_=(0,v.__)("Installing…")),(0,r.createElement)(z.__unstableCompositeItem,q({__experimentalIsFocusable:!0,role:"option",as:z.Button},t,{className:"block-directory-downloadable-block-list-item",onClick:e=>{e.preventDefault(),n()},isBusy:k,disabled:k||!b,label:ne(l,{hasNotice:p,isInstalled:m,isInstalling:k}),showTooltip:!0,tooltipPosition:"top center"}),(0,r.createElement)("div",{className:"block-directory-downloadable-block-list-item__icon"},(0,r.createElement)(te,{icon:i,title:u}),k?(0,r.createElement)("span",{className:"block-directory-downloadable-block-list-item__spinner"},(0,r.createElement)(z.Spinner,null)):(0,r.createElement)(ee,{rating:d})),(0,r.createElement)("span",{className:"block-directory-downloadable-block-list-item__details"},(0,r.createElement)("span",{className:"block-directory-downloadable-block-list-item__title"},(0,r.createInterpolateElement)((0,v.sprintf)((0,v.__)("%1$s by %2$s"),(0,U.decodeEntities)(u),o),{span:(0,r.createElement)("span",{className:"block-directory-downloadable-block-list-item__author"})})),p?(0,r.createElement)(le,{block:l}):(0,r.createElement)(r.Fragment,null,(0,r.createElement)("span",{className:"block-directory-downloadable-block-list-item__desc"},_||(0,U.decodeEntities)(a)),b&&!(m||k)&&(0,r.createElement)(z.VisuallyHidden,null,(0,v.__)("Install block")))))};var re=function(e){let{items:t,onHover:l=u.noop,onSelect:n}=e;const o=(0,z.__unstableUseCompositeState)(),{installBlockType:a}=(0,c.useDispatch)($);return t.length?(0,r.createElement)(z.__unstableComposite,q({},o,{role:"listbox",className:"block-directory-downloadable-blocks-list","aria-label":(0,v.__)("Blocks available for install")}),t.map((e=>(0,r.createElement)(oe,{key:e.id,composite:o,onClick:()=>{(0,s.getBlockType)(e.name)?n(e):a(e).then((t=>{t&&n(e)})),l(null)},onHover:l,item:e})))):null},ae=window.wp.a11y;var ie=function(e){let{children:t,downloadableItems:l,hasLocalBlocks:n}=e;const o=l.length;return(0,r.useEffect)((()=>{(0,ae.speak)((0,v.sprintf)((0,v._n)("%d additional block is available to install.","%d additional blocks are available to install.",o),o))}),[o]),(0,r.createElement)(r.Fragment,null,!n&&(0,r.createElement)("p",{className:"block-directory-downloadable-blocks-panel__no-local"},(0,v.__)("No results available from your installed blocks.")),(0,r.createElement)("div",{className:"block-editor-inserter__quick-inserter-separator"}),(0,r.createElement)("div",{className:"block-directory-downloadable-blocks-panel"},(0,r.createElement)("div",{className:"block-directory-downloadable-blocks-panel__header"},(0,r.createElement)("h2",{className:"block-directory-downloadable-blocks-panel__title"},(0,v.__)("Available to install")),(0,r.createElement)("p",{className:"block-directory-downloadable-blocks-panel__description"},(0,v.__)("Select a block to install and add it to your post."))),t))};var se=(0,r.createElement)(W.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(W.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"}));var ce=function(){return(0,r.createElement)("div",{className:"block-editor-inserter__no-results"},(0,r.createElement)(G,{className:"block-editor-inserter__no-results-icon",icon:se}),(0,r.createElement)("p",null,(0,v.__)("No results found.")))};var de=(0,Y.compose)([(0,c.withSelect)(((e,t)=>{let{filterValue:l,rootClientId:n=null}=t;const{getDownloadableBlocks:o,isRequestingDownloadableBlocks:r}=e($),{canInsertBlockType:a}=e(p.store),i=e(j.store).canUser("read","block-directory/search");return{downloadableItems:i?o(l).filter((e=>a(e,n,!0))):[],hasPermission:i,isLoading:r(l)}}))])((function(e){let{downloadableItems:t,onSelect:l,onHover:n,hasLocalBlocks:o,hasPermission:a,isLoading:i,isTyping:s}=e;return void 0===a||i||s?(0,r.createElement)(r.Fragment,null,a&&!o&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("p",{className:"block-directory-downloadable-blocks-panel__no-local"},(0,v.__)("No results available from your installed blocks.")),(0,r.createElement)("div",{className:"block-editor-inserter__quick-inserter-separator"})),(0,r.createElement)("div",{className:"block-directory-downloadable-blocks-panel has-blocks-loading"},(0,r.createElement)(z.Spinner,null))):!1===a?o?null:(0,r.createElement)(ce,null):t.length?(0,r.createElement)(ie,{downloadableItems:t,hasLocalBlocks:o},(0,r.createElement)(re,{items:t,onSelect:l,onHover:n})):!o&&(0,r.createElement)(ce,null)}));var ue=function(){const[e,t]=(0,r.useState)(""),l=(0,u.debounce)(t,400);return(0,r.createElement)(p.__unstableInserterMenuExtension,null,(t=>{let{onSelect:n,onHover:o,filterValue:a,hasItems:i,rootClientId:s}=t;return e!==a&&l(a),e?(0,r.createElement)(de,{onSelect:n,onHover:o,rootClientId:s,filterValue:e,hasLocalBlocks:i,isTyping:a!==e}):null}))},me=window.wp.editPost;function pe(e){let{items:t}=e;return t.length?(0,r.createElement)("ul",{className:"block-directory-compact-list"},t.map((e=>{let{icon:t,id:l,title:n,author:o}=e;return(0,r.createElement)("li",{key:l,className:"block-directory-compact-list__item"},(0,r.createElement)(te,{icon:t,title:n}),(0,r.createElement)("div",{className:"block-directory-compact-list__item-details"},(0,r.createElement)("div",{className:"block-directory-compact-list__item-title"},n),(0,r.createElement)("div",{className:"block-directory-compact-list__item-author"},(0,v.sprintf)((0,v.__)("By %s"),o))))}))):null}function ke(){const e=(0,c.useSelect)((e=>e($).getNewBlockTypes()),[]);return e.length?(0,r.createElement)(me.PluginPrePublishPanel,{icon:se,title:(0,v.sprintf)((0,v._n)("Added: %d block","Added: %d blocks",e.length),e.length),initialOpen:!0},(0,r.createElement)("p",{className:"installed-blocks-pre-publish-panel__copy"},(0,v._n)("The following block has been added to your site.","The following blocks have been added to your site.",e.length)),(0,r.createElement)(pe,{items:e})):null}function be(e){let{attributes:t,block:l,clientId:n}=e;const o=(0,c.useSelect)((e=>e($).isInstalling(l.id)),[l.id]),{installBlockType:a}=(0,c.useDispatch)($),{replaceBlock:i}=(0,c.useDispatch)(p.store);return(0,r.createElement)(z.Button,{onClick:()=>a(l).then((e=>{if(e){const e=(0,s.getBlockType)(l.name),[o]=(0,s.parse)(t.originalContent);o&&e&&i(n,(0,s.createBlock)(e.name,o.attributes,o.innerBlocks))}})),disabled:o,isBusy:o,variant:"primary"},(0,v.sprintf)((0,v.__)("Install %s"),l.title))}const _e=e=>{let{originalBlock:t,...l}=e;const{originalName:n,originalUndelimitedContent:o}=l.attributes,{replaceBlock:a}=(0,c.useDispatch)(p.store),i=()=>{a(l.clientId,(0,s.createBlock)("core/html",{content:o}))},d=!!o,u=(0,s.getBlockType)("core/html");let m=(0,v.sprintf)((0,v.__)("Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely."),t.title||n);const k=[(0,r.createElement)(be,{key:"install",block:t,attributes:l.attributes,clientId:l.clientId})];return d&&u&&(m=(0,v.sprintf)((0,v.__)("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||n),k.push((0,r.createElement)(z.Button,{key:"convert",onClick:i,variant:"link"},(0,v.__)("Keep as HTML")))),(0,r.createElement)("div",(0,p.useBlockProps)(),(0,r.createElement)(p.Warning,{actions:k},m),(0,r.createElement)(r.RawHTML,null,o))};var ge=e=>t=>{const{originalName:l}=t.attributes,{block:n,hasPermission:o}=(0,c.useSelect)((e=>{const{getDownloadableBlocks:t}=e($),n=t("block:"+l).filter((e=>{let{name:t}=e;return l===t}));return{hasPermission:e(j.store).canUser("read","block-directory/search"),block:n.length&&n[0]}}),[l]);return o&&n?(0,r.createElement)(_e,q({},t,{originalBlock:n})):(0,r.createElement)(e,t)};(0,a.registerPlugin)("block-directory",{render:()=>(0,r.createElement)(r.Fragment,null,(0,r.createElement)(K,null),(0,r.createElement)(ue,null),(0,r.createElement)(ke,null))}),(0,i.addFilter)("blocks.registerBlockType","block-directory/fallback",((e,t)=>("core/missing"!==t||(e.edit=ge(e.edit)),e))),(window.wp=window.wp||{}).blockDirectory=t}();