(()=>{"use strict";const e=window.wp.blocks,t=window.wp.blockEditor,n=window.wp.components,i=window.wp.data,r=window.wp.element,l=window.wp.i18n,o=window.wp.primitives,a=window.ReactJSXRuntime;var s=(0,a.jsx)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,a.jsx)(o.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"})}),d=(0,a.jsx)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,a.jsx)(o.Path,{d:"M17 10h-1.2V7c0-2.1-1.7-3.8-3.8-3.8-2.1 0-3.8 1.7-3.8 3.8v3H7c-.6 0-1 .4-1 1v8c0 .6.4 1 1 1h10c.6 0 1-.4 1-1v-8c0-.6-.4-1-1-1zm-2.8 0H9.8V7c0-1.2 1-2.2 2.2-2.2s2.2 1 2.2 2.2v3z"})});function c(e){var t,n,i="";if("string"==typeof e||"number"==typeof e)i+=e;else if("object"==typeof e)if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=c(e[t]))&&(i&&(i+=" "),i+=n)}else for(n in e)e[n]&&(i&&(i+=" "),i+=n);return i}const m=function(){for(var e,t,n=0,i="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=c(e))&&(i&&(i+=" "),i+=t);return i};function f(e){const{children:t,className:i,title:r}=e;return(0,a.jsxs)("div",{className:m("mf-premium-notice",i),children:[(0,a.jsx)(n.Icon,{icon:d,size:32}),(0,a.jsxs)(n.__experimentalVStack,{spacing:1,className:"mf-premium-notice__content",children:[r&&(0,a.jsx)("p",{children:(0,a.jsx)("strong",{children:r})}),t]}),(0,a.jsx)(n.Button,{variant:"primary",href:"https://modern-fields.com/features/",target:"_blank",children:(0,l.__)("Get pro","modern-fields")})]})}const p={paragraph:"content",heading:"content",image:"url",button:"text"},u=JSON.parse('{"UU":"modern-fields-display/field"}');(0,e.registerBlockType)(u.UU,{edit:function({clientId:o}){const{replaceBlock:d}=(0,i.useDispatch)("core/block-editor"),[c,m]=(0,r.useState)(""),[u,h]=(0,r.useState)("paragraph");return(0,a.jsx)("div",{...(0,t.useBlockProps)(),children:(0,a.jsxs)(n.Placeholder,{icon:s,label:(0,l.__)("Display a meta field","modern-fields"),instructions:(0,l.__)("Define the field you want to display here.","modern-fields"),children:[(0,a.jsxs)(n.__experimentalHStack,{spacing:6,justify:"stretch",children:[(0,a.jsx)(n.TextControl,{label:(0,l.__)("Field identifier","modern-fields"),help:(0,l.__)("Unique name of the field.","modern-fields"),value:c,onChange:m,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,a.jsx)(n.SelectControl,{label:(0,l.__)("Display as","modern-fields"),help:(0,l.__)("Select the block to convert.","modern-fields"),options:[{label:(0,l.__)("Paragraph","modern-fields"),value:"paragraph"},{label:(0,l.__)("Heading","modern-fields"),value:"heading"},{label:(0,l.__)("Button","modern-fields"),value:"button"},{label:(0,l.__)("Image","modern-fields"),value:"image"}],value:u,onChange:h,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,a.jsx)(n.Button,{variant:"secondary",onClick:()=>{if(!c.trim())return;const t=c.trim(),n="heading"===u?{level:2}:{},i=()=>({source:"modern-fields/field-image",args:{key:t}}),r="image"===u?{url:i(),id:i(),alt:i()}:{[p[u]]:{source:"core/post-meta",args:{key:t}}};if("button"===u)return void d(o,(0,e.createBlock)("core/buttons",{},[(0,e.createBlock)("core/button",{metadata:{bindings:r}})]));const l=(0,e.createBlock)(`core/${u}`,{...n,metadata:{bindings:r}});d(o,l)},disabled:!c.trim(),children:(0,l.__)("Bind to block","modern-fields")})]}),(0,a.jsx)(f,{title:(0,l.__)("Skip the guesswork with Modern Fields Pro!","modern-fields"),children:(0,a.jsx)("p",{children:(0,l.__)("Get all your available fields in a dropdown, ready to bind.","modern-fields")})})]})})},save:function(){return null}})})();