import{t as e}from"../../jsx-runtime-B-hbsSup.js";var t=e(),{__:n}=wp.i18n,{registerPlugin:r}=wp.plugins,{PluginDocumentSettingPanel:i}=wp.editPost,{PanelRow:a,RadioControl:o,CheckboxControl:s,TextControl:c,Notice:l}=wp.components,{useSelect:u,useDispatch:d}=wp.data,{Fragment:f}=wp.element;function p(){let e=window.BuymecoffeePostAccess&&window.BuymecoffeePostAccess.levels||[],r=u(function(e){return e(`core/editor`).getEditedPostAttribute(`meta`)||{}}),{editPost:p}=d(`core/editor`),m=r._buymecoffee_access||`free`,h=r._buymecoffee_level_ids||[],g=r._buymecoffee_preview_words||0;function _(e){p({meta:{_buymecoffee_access:e}})}function v(e,t){var n=Array.isArray(h)?h.slice():[];t?n.indexOf(e)===-1&&n.push(e):n=n.filter(function(t){return t!==e}),p({meta:{_buymecoffee_level_ids:n}})}function y(e){var t=parseInt(e,10);p({meta:{_buymecoffee_preview_words:isNaN(t)?0:t}})}return(0,t.jsxs)(i,{name:`buymecoffee-post-access`,title:n(`Content Access (Buy Me Coffee)`,`buy-me-coffee`),icon:`lock`,children:[(0,t.jsx)(a,{children:(0,t.jsx)(o,{label:n(`Access Level`,`buy-me-coffee`),selected:m,options:[{label:n(`Free — visible to everyone`,`buy-me-coffee`),value:`free`},{label:n(`Paid — members only`,`buy-me-coffee`),value:`paid`}],onChange:_})}),m===`paid`&&(0,t.jsxs)(f,{children:[e.length>0?(0,t.jsx)(a,{children:(0,t.jsxs)(`div`,{style:{width:`100%`},children:[(0,t.jsx)(`p`,{style:{fontSize:`11px`,fontWeight:600,textTransform:`uppercase`,color:`#757575`,marginBottom:`8px`},children:n(`Allowed Levels`,`buy-me-coffee`)}),e.map(function(e){return(0,t.jsx)(s,{label:e.name+` ($`+(e.price/100).toFixed(2)+`/`+e.interval_type+`)`,checked:Array.isArray(h)&&h.indexOf(e.id)!==-1,onChange:function(t){v(e.id,t)}},e.id)})]})}):(0,t.jsx)(a,{children:(0,t.jsx)(l,{status:`warning`,isDismissible:!1,style:{width:`100%`},children:n(`No active membership levels. Create one in the Memberships section.`,`buy-me-coffee`)})}),(0,t.jsx)(a,{children:(0,t.jsx)(c,{label:n(`Preview words (0 = global default)`,`buy-me-coffee`),type:`number`,value:g||``,min:`0`,onChange:y,help:n(`Non-members see this many words before the paywall.`,`buy-me-coffee`)})})]})]})}r(`buymecoffee-post-access`,{render:p});