(()=>{var e={942(e,t){var l;!function(){"use strict";var r={}.hasOwnProperty;function n(){for(var e="",t=0;t<arguments.length;t++){var l=arguments[t];l&&(e=a(e,s(l)))}return e}function s(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return n.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var t="";for(var l in e)r.call(e,l)&&e[l]&&(t=a(t,l));return t}function a(e,t){return t?e?e+" "+t:e+t:e}e.exports?(n.default=n,e.exports=n):void 0===(l=function(){return n}.apply(t,[]))||(e.exports=l)}()}},t={};function l(r){var n=t[r];if(void 0!==n)return n.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,l),s.exports}l.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return l.d(t,{a:t}),t},l.d=(e,t)=>{for(var r in t)l.o(t,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.wp.blocks;function t(){return t=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var l=arguments[t];for(var r in l)({}).hasOwnProperty.call(l,r)&&(e[r]=l[r])}return e},t.apply(null,arguments)}const r=window.wp.element;var n=l(942),s=l.n(n);const a=window.wp.i18n,o=window.wp.blockEditor,i=window.wp.components,c=window.wp.data,p=JSON.parse('{"UU":"pmpro/checkout-button"}');(0,e.registerBlockType)(p.UU,{icon:{background:"#FFFFFF",foreground:"#1A688B",src:"button"},edit:function(e){const l=[{value:0,label:(0,a.__)("Choose a level","paid-memberships-pro")}].concat(pmpro.all_level_values_and_labels),{attributes:n,setAttributes:p,className:u}=e,{textAlign:m,placeholder:d,style:_,text:b,level:v,css_class:g,selected_membership_level:h}=n;if(v&&v.length>0&&(p({selected_membership_level:v}),delete n.level),g&&g.length>0){const e=g.replace(/\bpmpro_btn\b/g,"").trim(),t=s()(u,e);p({className:t}),delete n.css_class}const y=(0,c.useSelect)(t=>{const{getBlockParents:l,getBlockName:r}=t("core/block-editor");return l(e.clientId).map(e=>r(e)).includes("pmpro/single-level")},[e.clientId]),x=(0,o.__experimentalUseBorderProps)(n),f=(0,o.__experimentalUseColorProps)(n),w=(0,o.__experimentalGetSpacingClassesAndStyles)(n),N=(0,o.useBlockProps)(),k=s()("wp-block-buttons",{[`has-text-align-${m}`]:m}),C=s()("wp-block-button");return[(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:k},(0,r.createElement)("div",{className:C},!y&&(0,r.createElement)(o.InspectorControls,null,(0,r.createElement)(i.PanelBody,{title:(0,a.__)("Checkout Button Settings","paid-memberships-pro"),initialOpen:!0},(0,r.createElement)(i.SelectControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,a.__)("Choose a Level","paid-memberships-pro"),value:h,options:l,onChange:e=>p({selected_membership_level:e})}))),(0,r.createElement)(o.BlockControls,null,(0,r.createElement)(o.AlignmentControl,{value:m,onChange:e=>{p({textAlign:e})}})),(0,r.createElement)(o.RichText,t({},N,{allowedFormats:[],"aria-label":(0,a.__)("Button text","paid-memberships-pro"),placeholder:d||(0,a.__)("Buy Now","paid-memberships-pro"),value:b,onChange:e=>{p({text:e})},withoutInteractiveFormatting:!0,className:s()(u,"wp-block-button__link",N.className,f.className,x.className,{"no-border-radius":0===_?.border?.radius},(0,o.__experimentalGetElementClassName)("button")),style:{...N.style,...x.style,...f.style,...w.style,textAlign:m},identifier:"text"})))))]},save:function({attributes:e,className:l}){const{textAlign:n,style:a,text:i}=e,c=o.useBlockProps.save(),p=(0,o.__experimentalGetBorderClassesAndStyles)(e),u=(0,o.__experimentalGetColorClassesAndStyles)(e),m=(0,o.__experimentalGetSpacingClassesAndStyles)(e),d=s()("wp-block-button__link",c.className,u.className,p.className,{[`has-text-align-${n}`]:n,"no-border-radius":0===a?.border?.radius},(0,o.__experimentalGetElementClassName)("button")),_={...c.style,...p.style,...u.style,...m.style},b=s()("wp-block-buttons",{[`has-text-align-${n}`]:n}),v=s()("wp-block-button");return(0,r.createElement)("div",{className:b},(0,r.createElement)("div",{className:v},(0,r.createElement)(o.RichText.Content,t({},c,{tagName:"a",className:d,href:(g=e.selected_membership_level,pmpro.checkout_url+"?pmpro_level="+g),style:_,value:i}))));var g}})})()})();