(()=>{"use strict";var e,o={182(){const e=window.wp.blocks,o=window.wp.blockEditor,n=window.wp.i18n,l=window.wp.components,t=window.ReactJSXRuntime,i=[{label:(0,n.__)("Everyone","clanbite"),value:"all"},{label:(0,n.__)("Guests only (not logged in)","clanbite"),value:"guests"},{label:(0,n.__)("Logged-in users","clanbite"),value:"logged_in"},{label:(0,n.__)("Selected roles only","clanbite"),value:"roles"}],s=[{label:(0,n.__)("No one (do not hide)","clanbite"),value:"none"},{label:(0,n.__)("Guests","clanbite"),value:"guests"},{label:(0,n.__)("Logged-in users","clanbite"),value:"logged_in"},{label:(0,n.__)("Selected roles","clanbite"),value:"roles"}];function a(e){const o="undefined"!=typeof window?window.clanbiteVisibilityContainer:null;if(!o?.roles?.length)return e.map(e=>String(e).toLowerCase().replace(/\s+/g,"_"));const n=new Map(o.roles.map(e=>[String(e.label).toLowerCase(),e.slug]));return e.map(e=>{const o=String(e).toLowerCase();return n.has(o)?n.get(o):String(e).toLowerCase().replace(/[^a-z0-9_-]+/g,"_").replace(/^_+|_+$/g,"")})}function r(e,o){if(!o?.length||!e?.length)return e||[];const n=new Map(o.map(e=>[e.slug,e.label||e.slug]));return e.map(e=>n.get(e)||e)}const c=JSON.parse('{"UU":"clanbite/visibility-container"}');(0,e.registerBlockType)(c.UU,{edit:function({attributes:e,setAttributes:c}){const{showTo:u,hideFrom:b,showToRoles:_=[],hideFromRoles:d=[]}=e,h=(0,o.useBlockProps)({className:"clanbite-visibility-container-editor"}),p=(0,o.useInnerBlocksProps)(h,{renderAppender:o.InnerBlocks.ButtonBlockAppender}),g=function(){const e="undefined"!=typeof window?window.clanbiteVisibilityContainer:null;return e?.roles?.length?e.roles.map(e=>e.label||e.slug):[]}(),w="undefined"!=typeof window?window.clanbiteVisibilityContainer:null;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.InspectorControls,{children:(0,t.jsxs)(l.PanelBody,{title:(0,n.__)("Visibility","clanbite"),initialOpen:!0,children:[(0,t.jsx)(l.SelectControl,{label:(0,n.__)("Show to","clanbite"),help:(0,n.__)("Who should see the content inside this block.","clanbite"),value:u,options:i,onChange:e=>c({showTo:e||"all"}),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),"roles"===u&&(0,t.jsx)(l.FormTokenField,{label:(0,n.__)("Roles (show to)","clanbite"),value:r(_,w?.roles),suggestions:g,onChange:e=>c({showToRoles:a(e)}),__experimentalShowHowTo:!1,__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),(0,t.jsx)(l.SelectControl,{label:(0,n.__)("Hide from","clanbite"),help:(0,n.__)("Remove the block for these visitors (applied after “Show to”).","clanbite"),value:b,options:s,onChange:e=>c({hideFrom:e||"none"}),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),"roles"===b&&(0,t.jsx)(l.FormTokenField,{label:(0,n.__)("Roles (hide from)","clanbite"),value:r(d,w?.roles),suggestions:g,onChange:e=>c({hideFromRoles:a(e)}),__experimentalShowHowTo:!1,__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),"roles"===u&&0===_.length&&(0,t.jsx)(l.Notice,{status:"warning",isDismissible:!1,children:(0,n.__)("Pick at least one role. Until you do, the block is shown to everyone (same as “Everyone”).","clanbite")}),!w?.roles?.length&&(0,t.jsx)(l.Notice,{status:"info",isDismissible:!1,children:(0,n.__)("Role labels load from the site; you can type role slugs (e.g. administrator) in the token fields.","clanbite")})]})}),(0,t.jsx)("div",{...p})]})},save:()=>(0,t.jsx)(o.InnerBlocks.Content,{})})}},n={};function l(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return o[e](i,i.exports,l),i.exports}l.m=o,e=[],l.O=(o,n,t,i)=>{if(!n){var s=1/0;for(u=0;u<e.length;u++){for(var[n,t,i]=e[u],a=!0,r=0;r<n.length;r++)(!1&i||s>=i)&&Object.keys(l.O).every(e=>l.O[e](n[r]))?n.splice(r--,1):(a=!1,i<s&&(s=i));if(a){e.splice(u--,1);var c=t();void 0!==c&&(o=c)}}return o}i=i||0;for(var u=e.length;u>0&&e[u-1][2]>i;u--)e[u]=e[u-1];e[u]=[n,t,i]},l.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),(()=>{var e={5966:0,6226:0};l.O.j=o=>0===e[o];var o=(o,n)=>{var t,i,[s,a,r]=n,c=0;if(s.some(o=>0!==e[o])){for(t in a)l.o(a,t)&&(l.m[t]=a[t]);if(r)var u=r(l)}for(o&&o(n);c<s.length;c++)i=s[c],l.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return l.O(u)},n=globalThis.webpackChunkclanbite=globalThis.webpackChunkclanbite||[];n.forEach(o.bind(null,0)),n.push=o.bind(null,n.push.bind(n))})();var t=l.O(void 0,[6226],()=>l(182));t=l.O(t)})();