Current File : /home/bravetechrwanda/dantho.rw/wp-includes/js/dist//reusable-blocks.min.js
var wp;(wp||={}).reusableBlocks=(()=>{var Da=Object.create;var E=Object.defineProperty;var Ea=Object.getOwnPropertyDescriptor;var Ua=Object.getOwnPropertyNames;var ja=Object.getPrototypeOf,Ma=Object.prototype.hasOwnProperty;var d=(a,t)=>()=>(t||a((t={exports:{}}).exports,t),t.exports),H=(a,t)=>{for(var o in t)E(a,o,{get:t[o],enumerable:!0})},Y=(a,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ua(t))!Ma.call(a,s)&&s!==o&&E(a,s,{get:()=>t[s],enumerable:!(r=Ea(t,s))||r.enumerable});return a};var e=(a,t,o)=>(o=a!=null?Da(ja(a)):{},Y(t||!a||!a.__esModule?E(o,"default",{value:a,enumerable:!0}):o,a)),Ia=a=>Y(E({},"__esModule",{value:!0}),a);var R=d((Wa,Z)=>{Z.exports=window.wp.data});var C=d((Qa,$)=>{$.exports=window.wp.blockEditor});var U=d((Xa,aa)=>{aa.exports=window.wp.blocks});var j=d((Ya,ta)=>{ta.exports=window.wp.i18n});var q=d((tt,fa)=>{fa.exports=window.wp.element});var G=d((et,la)=>{la.exports=window.wp.components});var ma=d((ot,sa)=>{sa.exports=window.wp.primitives});var S=d((rt,ua)=>{ua.exports=window.ReactJSXRuntime});var ia=d((mt,da)=>{da.exports=window.wp.notices});var W=d((ut,pa)=>{pa.exports=window.wp.coreData});var ga=d((nt,ba)=>{ba.exports=window.wp.url});var qa={};H(qa,{ReusableBlocksMenuItems:()=>xa,store:()=>k});var M=e(R(),1);var O={};H(O,{__experimentalConvertBlockToStatic:()=>Aa,__experimentalConvertBlocksToReusable:()=>Na,__experimentalDeleteReusableBlock:()=>Va,__experimentalSetEditingReusableBlock:()=>za});var g=e(C(),1),h=e(U(),1),ea=e(j(),1),Aa=a=>({registry:t})=>{let o=t.select(g.store).getBlock(a),r=t.select("core").getEditedEntityRecord("postType","wp_block",o.attributes.ref),s=(0,h.parse)(typeof r.content=="function"?r.content(r):r.content);t.dispatch(g.store).replaceBlocks(o.clientId,s)},Na=(a,t,o)=>async({registry:r,dispatch:s})=>{let c=o==="unsynced"?{wp_pattern_sync_status:o}:void 0,u={title:t||(0,ea.__)("Untitled pattern block"),content:(0,h.serialize)(r.select(g.store).getBlocksByClientId(a)),status:"publish",meta:c},w=await r.dispatch("core").saveEntityRecord("postType","wp_block",u);if(o==="unsynced")return;let i=(0,h.createBlock)("core/block",{ref:w.id});r.dispatch(g.store).replaceBlocks(a,i),s.__experimentalSetEditingReusableBlock(i.clientId,!0)},Va=a=>async({registry:t})=>{if(!t.select("core").getEditedEntityRecord("postType","wp_block",a))return;let c=t.select(g.store).getBlocks().filter(u=>(0,h.isReusableBlock)(u)&&u.attributes.ref===a).map(u=>u.clientId);c.length&&t.dispatch(g.store).removeBlocks(c),await t.dispatch("core").deleteEntityRecord("postType","wp_block",a)};function za(a,t){return{type:"SET_EDITING_REUSABLE_BLOCK",clientId:a,isEditing:t}}var oa=e(R(),1);function Fa(a={},t){return t?.type==="SET_EDITING_REUSABLE_BLOCK"?{...a,[t.clientId]:t.isEditing}:a}var ra=(0,oa.combineReducers)({isEditingReusableBlock:Fa});var P={};H(P,{__experimentalIsEditingReusableBlock:()=>Ha});function Ha(a,t){return a.isEditingReusableBlock[t]}var Oa="core/reusable-blocks",k=(0,M.createReduxStore)(Oa,{actions:O,reducer:ra,selectors:P});(0,M.register)(k);var _a=e(C(),1);var A=e(U(),1),na=e(C(),1),B=e(q(),1),l=e(G(),1);var I=e(ma(),1),J=e(S(),1),K=(0,J.jsx)(I.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,J.jsx)(I.Path,{d:"M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z"})});var L=e(R(),1),f=e(j(),1),ca=e(ia(),1),Q=e(W(),1);var m=e(S(),1);function ha({clientIds:a,rootClientId:t,onClose:o}){let[r,s]=(0,B.useState)(void 0),[c,u]=(0,B.useState)(!1),[w,i]=(0,B.useState)(""),V=(0,L.useSelect)(n=>{let{canUser:z}=n(Q.store),{getBlocksByClientId:Ca,canInsertBlockType:Sa,getBlockRootClientId:La}=n(na.store),Ta=t||(a.length>0?La(a[0]):void 0),x=Ca(a)??[];return!(x.length===1&&x[0]&&(0,A.isReusableBlock)(x[0])&&!!n(Q.store).getEntityRecord("postType","wp_block",x[0].attributes.ref))&&Sa("core/block",Ta)&&x.every(F=>!!F&&F.isValid&&(0,A.hasBlockSupport)(F.name,"reusable",!0))&&!!z("create",{kind:"postType",name:"wp_block"})},[a,t]),{__experimentalConvertBlocksToReusable:D}=(0,L.useDispatch)(k),{createSuccessNotice:_,createErrorNotice:y}=(0,L.useDispatch)(ca.store),Ra=(0,B.useCallback)(async function(n){try{await D(a,n,r),_(r?(0,f.sprintf)((0,f.__)("Unsynced pattern created: %s"),n):(0,f.sprintf)((0,f.__)("Synced pattern created: %s"),n),{type:"snackbar",id:"convert-to-reusable-block-success"})}catch(z){y(z.message,{type:"snackbar",id:"convert-to-reusable-block-error"})}},[D,a,r,_,y]);return V?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(l.MenuItem,{icon:K,onClick:()=>u(!0),children:(0,f.__)("Create pattern")}),c&&(0,m.jsx)(l.Modal,{title:(0,f.__)("Create pattern"),onRequestClose:()=>{u(!1),i("")},overlayClassName:"reusable-blocks-menu-items__convert-modal",children:(0,m.jsx)("form",{onSubmit:n=>{n.preventDefault(),Ra(w),u(!1),i(""),o()},children:(0,m.jsxs)(l.__experimentalVStack,{spacing:"5",children:[(0,m.jsx)(l.TextControl,{__next40pxDefaultSize:!0,label:(0,f.__)("Name"),value:w,onChange:i,placeholder:(0,f.__)("My pattern")}),(0,m.jsx)(l.ToggleControl,{label:(0,f._x)("Synced","pattern (singular)"),help:(0,f.__)("Sync this pattern across multiple locations."),checked:!r,onChange:()=>{s(r?void 0:"unsynced")}}),(0,m.jsxs)(l.__experimentalHStack,{justify:"right",children:[(0,m.jsx)(l.Button,{__next40pxDefaultSize:!0,variant:"tertiary",onClick:()=>{u(!1),i("")},children:(0,f.__)("Cancel")}),(0,m.jsx)(l.Button,{__next40pxDefaultSize:!0,variant:"primary",type:"submit",children:(0,f.__)("Create")})]})]})})})]}):null}var T=e(G(),1),v=e(j(),1),ka=e(U(),1),N=e(R(),1),wa=e(q(),1),ya=e(C(),1),X=e(ga(),1),Ba=e(W(),1);var p=e(S(),1);function Pa({clientId:a}){let[t,o]=(0,wa.useState)(!1),{canRemove:r,isVisible:s,managePatternsUrl:c}=(0,N.useSelect)(i=>{let{getBlock:V,canRemoveBlock:D}=i(ya.store),{canUser:_}=i(Ba.store),y=V(a);return{canRemove:D(a),isVisible:!!y&&(0,ka.isReusableBlock)(y)&&!!_("update",{kind:"postType",name:"wp_block",id:y.attributes.ref}),managePatternsUrl:_("create",{kind:"postType",name:"wp_template"})?(0,X.addQueryArgs)("site-editor.php",{p:"/pattern"}):(0,X.addQueryArgs)("edit.php",{post_type:"wp_block"})}},[a]),{__experimentalConvertBlockToStatic:u}=(0,N.useDispatch)(k);if(!s)return null;let w=()=>{u(a),o(!1)};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(T.MenuItem,{href:c,children:(0,v.__)("Manage patterns")}),r&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(T.MenuItem,{onClick:()=>o(!0),children:(0,v.__)("Disconnect pattern")}),(0,p.jsx)(T.__experimentalConfirmDialog,{isOpen:t,onConfirm:w,onCancel:()=>o(!1),confirmButtonText:(0,v.__)("Disconnect"),size:"medium",title:(0,v.__)("Disconnect pattern?"),__experimentalHideHeader:!1,children:(0,v.__)("Blocks will be separated from the original pattern and will be fully editable. Future changes to the pattern will not apply here.")})]})]})}var va=Pa;var b=e(S(),1);function xa({rootClientId:a}){return(0,b.jsx)(_a.BlockSettingsMenuControls,{children:({onClose:t,selectedClientIds:o})=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(ha,{clientIds:o,rootClientId:a,onClose:t}),o.length===1&&(0,b.jsx)(va,{clientId:o[0]})]})})}return Ia(qa);})();