(()=>{"use strict";var o,l={983:()=>{const o=window.wp.blocks,l=window.wp.i18n,e=window.wp.element,n=window.wp.blockEditor,t=window.wp.components,s=window.wp.primitives,i=window.ReactJSXRuntime,r=(0,i.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(s.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"})}),a=(0,i.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(s.Path,{d:"M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z"})}),c=window.React,p=JSON.parse('{"UU":"buntywp/polls-block"}');(0,o.registerBlockType)(p.UU,{edit:function({attributes:o,setAttributes:s,clientId:p}){const{question:d,options:w,blockId:u,allowAnonymous:h}=o;(0,e.useEffect)((()=>{u||s({blockId:p})}),[u,p,s]);const b=()=>{s({options:[...w,{option:"",votes:0}]})};return(0,c.createElement)("div",{...(0,n.useBlockProps)(),key:u},(0,i.jsx)(n.InspectorControls,{children:(0,i.jsx)(t.PanelBody,{title:(0,l.__)("Poll Setting","toggle-content"),children:(0,i.jsx)(t.ToggleControl,{__nextHasNoMarginBottom:!0,checked:h,label:(0,l.__)("Allow Anonymous Polls","polls-block"),onChange:o=>{s({allowAnonymous:o})}})})}),(0,i.jsxs)("div",{className:"poll-block-editor",children:[(0,i.jsx)("div",{className:"poll-question",children:(0,i.jsx)(n.RichText,{tagName:"h3",placeholder:(0,l.__)("Ask a question","polls-block"),value:d,onChange:o=>s({question:o})})}),w.map(((o,e)=>(0,i.jsxs)("div",{className:"poll-option",children:[(0,i.jsx)(t.TextControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,placeholder:(0,l.__)("Choice","polls-block")+" "+(e+1),value:o.option,onChange:o=>((o,l)=>{const e=w.map(((e,n)=>n===o?{...e,option:l}:e));s({options:e})})(e,o)}),(0,i.jsx)(t.Button,{icon:r,isSmall:!0,label:(0,l.__)("Remove option","polls-block"),onClick:()=>(o=>{const l=[...w];l.splice(o,1),s({options:l})})(e),className:"poll-remove-button",disabled:w.length<=2}),e===w.length-1&&(0,i.jsx)(t.Button,{icon:a,onClick:b,className:"poll-add-button",label:(0,l.__)("Add option","polls-block")})]},e)))]}))},save:function(){return null}})}},e={};function n(o){var t=e[o];if(void 0!==t)return t.exports;var s=e[o]={exports:{}};return l[o](s,s.exports,n),s.exports}n.m=l,o=[],n.O=(l,e,t,s)=>{if(!e){var i=1/0;for(p=0;p<o.length;p++){for(var[e,t,s]=o[p],r=!0,a=0;a<e.length;a++)(!1&s||i>=s)&&Object.keys(n.O).every((o=>n.O[o](e[a])))?e.splice(a--,1):(r=!1,s<i&&(i=s));if(r){o.splice(p--,1);var c=t();void 0!==c&&(l=c)}}return l}s=s||0;for(var p=o.length;p>0&&o[p-1][2]>s;p--)o[p]=o[p-1];o[p]=[e,t,s]},n.o=(o,l)=>Object.prototype.hasOwnProperty.call(o,l),(()=>{var o={78:0,498:0};n.O.j=l=>0===o[l];var l=(l,e)=>{var t,s,[i,r,a]=e,c=0;if(i.some((l=>0!==o[l]))){for(t in r)n.o(r,t)&&(n.m[t]=r[t]);if(a)var p=a(n)}for(l&&l(e);c<i.length;c++)s=i[c],n.o(o,s)&&o[s]&&o[s][0](),o[s]=0;return n.O(p)},e=globalThis.webpackChunkpolls_block=globalThis.webpackChunkpolls_block||[];e.forEach(l.bind(null,0)),e.push=l.bind(null,e.push.bind(e))})();var t=n.O(void 0,[498],(()=>n(983)));t=n.O(t)})();