(()=>{var e={186(e,t,n){"use strict";var r=n(985);function o(){}function s(){}s.resetWarningCache=o,e.exports=function(){function e(e,t,n,o,s,a){if(a!==r){var i=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:s,resetWarningCache:o};return n.PropTypes=n,n}},489(e){"use strict";e.exports=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var r,o,s;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(o=r;0!==o--;)if(!e(t[o],n[o]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(o of t.entries())if(!n.has(o[0]))return!1;for(o of t.entries())if(!e(o[1],n.get(o[0])))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(o of t.entries())if(!n.has(o[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if((r=t.length)!=n.length)return!1;for(o=r;0!==o--;)if(t[o]!==n[o])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(s=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(o=r;0!==o--;)if(!Object.prototype.hasOwnProperty.call(n,s[o]))return!1;for(o=r;0!==o--;){var a=s[o];if(!e(t[a],n[a]))return!1}return!0}return t!=t&&n!=n}},500(e,t){var n;!function(){"use strict";var r={}.hasOwnProperty;function o(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=a(e,s(n)))}return e}function s(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return o.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var t="";for(var n in e)r.call(e,n)&&e[n]&&(t=a(t,n));return t}function a(e,t){return t?e?e+" "+t:e+t:e}e.exports?(o.default=o,e.exports=o):void 0===(n=function(){return o}.apply(t,[]))||(e.exports=n)}()},736(e,t,n){e.exports=n(186)()},985(e){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.React;var t=n.n(e);const r=window.lodash;var o=n(500),s=n.n(o),a=n(736),i=n.n(a);function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}function c(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,l(e,t)}function u(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}const d=window.ReactDOM;var p=n.n(d);const f=t().createContext(null);var m=function(e){return e.scrollTop},h="unmounted",E="exited",b="entering",g="entered",v="exiting",S=function(e){function n(t,n){var r;r=e.call(this,t,n)||this;var o,s=n&&!n.isMounting?t.enter:t.appear;return r.appearStatus=null,t.in?s?(o=E,r.appearStatus=b):o=g:o=t.unmountOnExit||t.mountOnEnter?h:E,r.state={status:o},r.nextCallback=null,r}c(n,e),n.getDerivedStateFromProps=function(e,t){return e.in&&t.status===h?{status:E}:null};var r=n.prototype;return r.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},r.componentDidUpdate=function(e){var t=null;if(e!==this.props){var n=this.state.status;this.props.in?n!==b&&n!==g&&(t=b):n!==b&&n!==g||(t=v)}this.updateStatus(!1,t)},r.componentWillUnmount=function(){this.cancelNextCallback()},r.getTimeouts=function(){var e,t,n,r=this.props.timeout;return e=t=n=r,null!=r&&"number"!=typeof r&&(e=r.exit,t=r.enter,n=void 0!==r.appear?r.appear:t),{exit:e,enter:t,appear:n}},r.updateStatus=function(e,t){if(void 0===e&&(e=!1),null!==t)if(this.cancelNextCallback(),t===b){if(this.props.unmountOnExit||this.props.mountOnEnter){var n=this.props.nodeRef?this.props.nodeRef.current:p().findDOMNode(this);n&&m(n)}this.performEnter(e)}else this.performExit();else this.props.unmountOnExit&&this.state.status===E&&this.setState({status:h})},r.performEnter=function(e){var t=this,n=this.props.enter,r=this.context?this.context.isMounting:e,o=this.props.nodeRef?[r]:[p().findDOMNode(this),r],s=o[0],a=o[1],i=this.getTimeouts(),l=r?i.appear:i.enter;e||n?(this.props.onEnter(s,a),this.safeSetState({status:b},function(){t.props.onEntering(s,a),t.onTransitionEnd(l,function(){t.safeSetState({status:g},function(){t.props.onEntered(s,a)})})})):this.safeSetState({status:g},function(){t.props.onEntered(s)})},r.performExit=function(){var e=this,t=this.props.exit,n=this.getTimeouts(),r=this.props.nodeRef?void 0:p().findDOMNode(this);t?(this.props.onExit(r),this.safeSetState({status:v},function(){e.props.onExiting(r),e.onTransitionEnd(n.exit,function(){e.safeSetState({status:E},function(){e.props.onExited(r)})})})):this.safeSetState({status:E},function(){e.props.onExited(r)})},r.cancelNextCallback=function(){null!==this.nextCallback&&(this.nextCallback.cancel(),this.nextCallback=null)},r.safeSetState=function(e,t){t=this.setNextCallback(t),this.setState(e,t)},r.setNextCallback=function(e){var t=this,n=!0;return this.nextCallback=function(r){n&&(n=!1,t.nextCallback=null,e(r))},this.nextCallback.cancel=function(){n=!1},this.nextCallback},r.onTransitionEnd=function(e,t){this.setNextCallback(t);var n=this.props.nodeRef?this.props.nodeRef.current:p().findDOMNode(this),r=null==e&&!this.props.addEndListener;if(n&&!r){if(this.props.addEndListener){var o=this.props.nodeRef?[this.nextCallback]:[n,this.nextCallback],s=o[0],a=o[1];this.props.addEndListener(s,a)}null!=e&&setTimeout(this.nextCallback,e)}else setTimeout(this.nextCallback,0)},r.render=function(){var e=this.state.status;if(e===h)return null;var n=this.props,r=n.children,o=(n.in,n.mountOnEnter,n.unmountOnExit,n.appear,n.enter,n.exit,n.timeout,n.addEndListener,n.onEnter,n.onEntering,n.onEntered,n.onExit,n.onExiting,n.onExited,n.nodeRef,u(n,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]));return t().createElement(f.Provider,{value:null},"function"==typeof r?r(e,o):t().cloneElement(t().Children.only(r),o))},n}(t().Component);function w(){}S.contextType=f,S.propTypes={},S.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:w,onEntering:w,onEntered:w,onExit:w,onExiting:w,onExited:w},S.UNMOUNTED=h,S.EXITED=E,S.ENTERING=b,S.ENTERED=g,S.EXITING=v;const C=S;var y,O,x="out-in",N="in-out",R=function(e,t,n){return function(){var r;e.props[t]&&(r=e.props)[t].apply(r,arguments),n()}},A=((y={})[x]=function(e){var n=e.current,r=e.changeState;return t().cloneElement(n,{in:!1,onExited:R(n,"onExited",function(){r(b,null)})})},y[N]=function(e){var n=e.current,r=e.changeState,o=e.children;return[n,t().cloneElement(o,{in:!0,onEntered:R(o,"onEntered",function(){r(b)})})]},y),k=((O={})[x]=function(e){var n=e.children,r=e.changeState;return t().cloneElement(n,{in:!0,onEntered:R(n,"onEntered",function(){r(g,t().cloneElement(n,{in:!0}))})})},O[N]=function(e){var n=e.current,r=e.children,o=e.changeState;return[t().cloneElement(n,{in:!1,onExited:R(n,"onExited",function(){o(g,t().cloneElement(r,{in:!0}))})}),t().cloneElement(r,{in:!0})]},O),T=function(e){function n(){for(var t,n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return(t=e.call.apply(e,[this].concat(r))||this).state={status:g,current:null},t.appeared=!1,t.changeState=function(e,n){void 0===n&&(n=t.state.current),t.setState({status:e,current:n})},t}c(n,e);var r=n.prototype;return r.componentDidMount=function(){this.appeared=!0},n.getDerivedStateFromProps=function(e,n){return null==e.children?{current:null}:n.status===b&&e.mode===N?{status:b}:!n.current||((r=n.current)===(o=e.children)||t().isValidElement(r)&&t().isValidElement(o)&&null!=r.key&&r.key===o.key)?{current:t().cloneElement(e.children,{in:!0})}:{status:v};var r,o},r.render=function(){var e,n=this.props,r=n.children,o=n.mode,s=this.state,a=s.status,i=s.current,l={children:r,current:i,changeState:this.changeState,status:a};switch(a){case b:e=k[o](l);break;case v:e=A[o](l);break;case g:e=i}return t().createElement(f.Provider,{value:{isMounting:!this.appeared}},e)},n}(t().Component);T.propTypes={},T.defaultProps={mode:x};const L=T;function I(){return I=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},I.apply(null,arguments)}function _(e,t){return e.replace(new RegExp("(^|\\s)"+t+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")}var P=function(e,t){return e&&t&&t.split(" ").forEach(function(t){return r=t,void((n=e).classList?n.classList.remove(r):"string"==typeof n.className?n.className=_(n.className,r):n.setAttribute("class",_(n.className&&n.className.baseVal||"",r)));var n,r})},D=function(e){function n(){for(var t,n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return(t=e.call.apply(e,[this].concat(r))||this).appliedClasses={appear:{},enter:{},exit:{}},t.onEnter=function(e,n){var r=t.resolveArguments(e,n),o=r[0],s=r[1];t.removeClasses(o,"exit"),t.addClass(o,s?"appear":"enter","base"),t.props.onEnter&&t.props.onEnter(e,n)},t.onEntering=function(e,n){var r=t.resolveArguments(e,n),o=r[0],s=r[1]?"appear":"enter";t.addClass(o,s,"active"),t.props.onEntering&&t.props.onEntering(e,n)},t.onEntered=function(e,n){var r=t.resolveArguments(e,n),o=r[0],s=r[1]?"appear":"enter";t.removeClasses(o,s),t.addClass(o,s,"done"),t.props.onEntered&&t.props.onEntered(e,n)},t.onExit=function(e){var n=t.resolveArguments(e)[0];t.removeClasses(n,"appear"),t.removeClasses(n,"enter"),t.addClass(n,"exit","base"),t.props.onExit&&t.props.onExit(e)},t.onExiting=function(e){var n=t.resolveArguments(e)[0];t.addClass(n,"exit","active"),t.props.onExiting&&t.props.onExiting(e)},t.onExited=function(e){var n=t.resolveArguments(e)[0];t.removeClasses(n,"exit"),t.addClass(n,"exit","done"),t.props.onExited&&t.props.onExited(e)},t.resolveArguments=function(e,n){return t.props.nodeRef?[t.props.nodeRef.current,e]:[e,n]},t.getClassNames=function(e){var n=t.props.classNames,r="string"==typeof n,o=r?(r&&n?n+"-":"")+e:n[e];return{baseClassName:o,activeClassName:r?o+"-active":n[e+"Active"],doneClassName:r?o+"-done":n[e+"Done"]}},t}c(n,e);var r=n.prototype;return r.addClass=function(e,t,n){var r=this.getClassNames(t)[n+"ClassName"],o=this.getClassNames("enter").doneClassName;"appear"===t&&"done"===n&&o&&(r+=" "+o),"active"===n&&e&&m(e),r&&(this.appliedClasses[t][n]=r,function(e,t){e&&t&&t.split(" ").forEach(function(t){return r=t,void((n=e).classList?n.classList.add(r):function(e,t){return e.classList?!!t&&e.classList.contains(t):-1!==(" "+(e.className.baseVal||e.className)+" ").indexOf(" "+t+" ")}(n,r)||("string"==typeof n.className?n.className=n.className+" "+r:n.setAttribute("class",(n.className&&n.className.baseVal||"")+" "+r)));var n,r})}(e,r))},r.removeClasses=function(e,t){var n=this.appliedClasses[t],r=n.base,o=n.active,s=n.done;this.appliedClasses[t]={},r&&P(e,r),o&&P(e,o),s&&P(e,s)},r.render=function(){var e=this.props,n=(e.classNames,u(e,["classNames"]));return t().createElement(C,I({},n,{onEnter:this.onEnter,onEntered:this.onEntered,onEntering:this.onEntering,onExit:this.onExit,onExiting:this.onExiting,onExited:this.onExited}))},n}(t().Component);D.defaultProps={classNames:""},D.propTypes={};const M=D,U=({className:t,fillColor:n="black"})=>(0,e.createElement)("svg",{className:t,width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,e.createElement)("g",{clipPath:"url(#clipThumbsUp)"},(0,e.createElement)("mask",{id:"maskThumbsUp","mask-type":"alpha",maskUnits:"userSpaceOnUse",x:"2",y:"-1",width:"20",height:"20"},(0,e.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.35 6.24998H13.5658L14.4366 2.06081L14.4641 1.76748C14.4641 1.39165 14.3083 1.04331 14.0608 0.795813L13.0891 -0.166687L7.05748 5.87415C6.71831 6.20415 6.51664 6.66248 6.51664 7.16665L2.84998 7.16665V16.425H6.51664V16.3333C6.51664 17.3416 7.34164 18.1666 8.34998 18.1666H16.6C17.3608 18.1666 18.0116 17.7083 18.2866 17.0483L21.055 10.5858C21.1375 10.375 21.1833 10.155 21.1833 9.91665V8.08331C21.1833 7.07498 20.3583 6.24998 19.35 6.24998ZM19.35 9.91665L16.6 16.3333H8.34998V7.16665L12.3283 3.18831L11.3108 8.08331H19.35V9.91665Z",fill:"white"})),(0,e.createElement)("g",{mask:"url(#maskThumbsUp)"},(0,e.createElement)("rect",{x:"0.999878",y:"-3.05176e-05",width:"22",height:"22",fill:n}))),(0,e.createElement)("defs",null,(0,e.createElement)("clipPath",{id:"clipThumbsUp"},(0,e.createElement)("rect",{width:"24",height:"24",fill:"white"})))),j=({className:t,fillColor:n="black"})=>(0,e.createElement)("svg",{className:t,width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,e.createElement)("g",{clipPath:"url(#clipThumbsDown)"},(0,e.createElement)("mask",{id:"maskThumbsDown","mask-type":"alpha",maskUnits:"userSpaceOnUse",x:"2",y:"5",width:"20",height:"20"},(0,e.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.65002 17.75H10.4342L9.56336 21.9392L9.53586 22.2325C9.53586 22.6083 9.69169 22.9567 9.93919 23.2042L10.9109 24.1667L16.9425 18.1258C17.2817 17.7958 17.4834 17.3375 17.4834 16.8333L21.15 16.8333L21.15 7.57499H17.4834V7.66666C17.4834 6.65832 16.6584 5.83332 15.65 5.83332H7.40003C6.63919 5.83332 5.98836 6.29165 5.71336 6.95166L2.94503 13.4142C2.86253 13.625 2.81669 13.845 2.81669 14.0833V15.9167C2.81669 16.925 3.64169 17.75 4.65002 17.75ZM4.65002 14.0833L7.40002 7.66666H15.65L15.65 16.8333L11.6717 20.8117L12.6892 15.9167H4.65002V14.0833Z",fill:"white"})),(0,e.createElement)("g",{mask:"url(#maskThumbsDown)"},(0,e.createElement)("rect",{x:"23.0001",y:"24",width:"22",height:"22",transform:"rotate(-180 23.0001 24)",fill:n}))),(0,e.createElement)("defs",null,(0,e.createElement)("clipPath",{id:"clipThumbsDown"},(0,e.createElement)("rect",{width:"24",height:"24",fill:"white"})))),V=t=>{const{attributes:n,voteCount:o,apiAnswerId:a,onVote:i,disabled:l,isVotedOn:c,hideCount:u,fallbackStyles:d,isInEditor:p}=t,{className:f,type:m}=n,[h,E]=(0,e.useState)(0),b=()=>{!l&&i&&(E(1),i(a))},g="up"===m?U:j,v=((e,...t)=>s()({"has-bg-color":e.backgroundColor,"has-text-color":e.textColor,"has-border-color":e.borderColor},t))(n,"crowdsignal-forms-vote-item",f,{"is-voted-on":c,"is-disabled":l,"is-in-editor":p},`is-type-${m}`),S=((e,t)=>{const n=(0,r.isEmpty)(e.textColor)?t.textColor:e.textColor,o=(0,r.isEmpty)(e.backgroundColor)?t.backgroundColor:e.backgroundColor;return(0,r.mapKeys)({borderColor:e.borderColor,bgColor:o,textColor:n,votedColor:t.accentColor},(e,t)=>`--crowdsignal-forms-vote-${(0,r.kebabCase)(t)}`)})(n,d),w=o+h;return(0,e.createElement)("div",{className:v,onClick:b,onKeyPress:b,role:"button",style:S,tabIndex:0},(0,e.createElement)(g,{className:"crowdsignal-forms-vote-item__icon",fillColor:"currentColor"}),!u&&(0,e.createElement)(L,{mode:"in-out"},(0,e.createElement)(M,{key:h,classNames:"crowdsignal-forms-vote-item__count",timeout:300},(0,e.createElement)("div",{className:"crowdsignal-forms-vote-item__count"},(C=w)?C>=1e7?`${(0,r.round)(C/1e6)}M`:C>=1e6?`${(C/1e6).toFixed(1)}M`:C>=1e4?`${(0,r.round)(C/1e3)}K`:C>=1e3?`${(C/1e3).toFixed(1)}K`:C.toString():"0"))));var C};V.propTypes={apiAnswerId:i().number,className:i().string,disabled:i().bool,isVotedOn:i().bool,onVote:i().func,type:i().string.isRequired,voteCount:i().number.isRequired};const F=V;function B(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}var H=function e(t,n){function r(e,r,o){if("undefined"!=typeof document){"number"==typeof(o=B({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var a in o)o[a]&&(s+="; "+a,!0!==o[a]&&(s+="="+o[a].split(";")[0]));return document.cookie=e+"="+t.write(r,e)+s}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],r={},o=0;o<n.length;o++){var s=n[o].split("="),a=s.slice(1).join("=");try{var i=decodeURIComponent(s[0]);if(r[i]=t.read(a,i),e===i)break}catch(e){}}return e?r[e]:r}},remove:function(e,t){r(e,"",B({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,B({},this.attributes,t))},withConverter:function(t){return e(B({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});window.wp.apiFetch;const $=window.wp.i18n;class W extends Error{}class z extends W{constructor(){super((0,$.__)("Server error. Please try again.","crowdsignal-forms"))}}const G=(t,n=!0)=>{const{data:r,error:o,loading:s}=((r,o)=>{const[s,a]=(0,e.useState)(null),[i,l]=(0,e.useState)(null),[c,u]=(0,e.useState)(!0);return(0,e.useEffect)(()=>{u(!0),l(null),a(null),(async(e,t=!0)=>t?window.fetch(`https://api.crowdsignal.com/v3/polls/${e}/results`,{method:"GET",headers:{"content-type":"application/json"}}).then(e=>{if(e.status>=200&&e.status<300)return e.json();throw e}).then(e=>{if(404===e.status)return{};if(e.error)throw new Error(e.message);return e.results.votes_by_answer}):null)(t,n).then(a).catch(l).finally(()=>u(!1))},o),{data:s,error:i,loading:c}})(0,[t]);return{error:o,loading:s,results:r}};var K=n(489),q=n.n(K);const Y=window.wp.element,J=window.wp.compose,Z=e=>{const t=e.ownerDocument.defaultView;let n=t.getComputedStyle(e).backgroundColor;for(;"rgba(0, 0, 0, 0)"===n&&e.parentNode&&1===e.parentNode.nodeType;)e=e.parentNode,n=t.getComputedStyle(e).backgroundColor;return n},X=()=>(0,e.createElement)("div",{className:"crowdsignal-forms__style-probe"},(0,e.createElement)("p",null),(0,e.createElement)("h3",null,"Text"),(0,e.createElement)("div",{className:"wp-block-button"},(0,e.createElement)("div",{className:"wp-block-button__link"})),(0,e.createElement)("div",{className:"entry-content"},(0,e.createElement)("div",{className:"alignwide"}))),Q=e=>{if(null===e)return{};const t=e.querySelector(".wp-block-button__link"),n=e.querySelector("p"),r=e.querySelector("h3"),o=e.querySelector(".alignwide"),s=e.ownerDocument.defaultView;let a=Z(t);const i=Z(n),l=s.getComputedStyle(n).color;if(a===i){const e=(e=>{const t=e.ownerDocument.defaultView;return"0px"!==t.getComputedStyle(e).borderBlockStartWidth?t.getComputedStyle(e).borderBlockStartColor:null})(t);a=e||l}return{accentColor:a,backgroundColor:i,textColor:l,textColorInverted:s.getComputedStyle(t).color,textFont:s.getComputedStyle(n).fontFamily,textSize:s.getComputedStyle(n).fontSize,headingFont:s.getComputedStyle(r).fontFamily,contentWideWidth:s.getComputedStyle(o).maxWidth}},ee=({showBranding:t,referralCode:n})=>(0,e.createElement)("div",{className:"crowdsignal-forms__branding"},t&&(0,e.createElement)("a",{className:"crowdsignal-forms__branding-link with-external-icon",href:`https://crowdsignal.com?ref=${n}`,target:"blank",rel:"noopener noreferrer"},(0,$.__)("Powered by Crowdsignal","crowdsignal-forms")),!t&&(0,e.createElement)("span",{className:"crowdsignal-forms__branding-link"}," "));ee.propTypes={showBranding:i().bool,referralCode:i().string.isRequired};const te=ee,ne=(window.wp.blocks,Object.freeze({THANK_YOU:"thank-you",CUSTOM_TEXT:"custom-text",REDIRECT:"redirect",RESULTS:"results"}),Object.freeze({THEME_DEFAULT:"theme-default",GEORGIA:"georgia",PALATINO:"palatino",TIMES_NEW_ROMAN:"times-new-roman",ARIAL:"arial",IMPACT:"impact",LUCIDA:"lucida",TAHOMA:"tahoma",TREBUCHET:"trebuchet",VERDANA:"verdana",COURIER:"courier",CABIN:"Cabin",CHIVO:"Chivo",OPEN_SANS:"Open+Sans",FIRA_SANS:"Fira+Sans",ROBOTO:"Roboto",NUNITO:"Nunito",OVERPASS:"Overpass",LATO:"Lato",LIBRE_FRANKLIN:"Libre+Franklin",MONTSERRAT:"Montserrat",POPPINS:"Poppins",RUBIK:"Rubik",RALEWAY:"Raleway",JOSEFIN_SANS:"Josefin+Sans",ALEGREYA_SANS:"Alegreya+Sans",OSWALD:"Oswald"})),re=(Object.freeze([ne.CABIN,ne.CHIVO,ne.OPEN_SANS,ne.FIRA_SANS,ne.ROBOTO,ne.NUNITO,ne.OVERPASS,ne.LATO,ne.LIBRE_FRANKLIN,ne.MONTSERRAT,ne.POPPINS,ne.RUBIK,ne.RALEWAY,ne.JOSEFIN_SANS,ne.ALEGREYA_SANS,ne.OSWALD]),Object.freeze({[ne.THEME_DEFAULT]:null,[ne.GEORGIA]:"Georgia, serif",[ne.PALATINO]:'"Palatino Linotype", "Book Antiqua", Palatino, serif',[ne.TIMES_NEW_ROMAN]:'"Times New Roman", Times, serif',[ne.ARIAL]:"Arial, Helvetica, sans-serif",[ne.IMPACT]:"Impact, Charcoal, sans-serif",[ne.LUCIDA]:'"Lucida Sans Unicode", "Lucida Grande", sans-serif',[ne.TAHOMA]:"Tahoma, Geneva, sans-serif",[ne.TREBUCHET]:'"Trebuchet MS", Helvetica, sans-serif',[ne.VERDANA]:"Verdana, Geneva, sans-serif",[ne.COURIER]:'"Courier New", Courier, monospace',[ne.CABIN]:'"Cabin", sans-serif',[ne.CHIVO]:'"Chivo", sans-serif',[ne.OPEN_SANS]:'"Open Sans", sans-serif',[ne.FIRA_SANS]:'"Fira Sans", sans-serif',[ne.ROBOTO]:'"Roboto", sans-serif',[ne.NUNITO]:'"Nunito", sans-serif',[ne.OVERPASS]:'"Overpass", sans-serif',[ne.LATO]:'"Lato", sans-serif',[ne.LIBRE_FRANKLIN]:'"Libre Franklin", sans-serif',[ne.MONTSERRAT]:'"Montserrat", sans-serif',[ne.POPPINS]:'"Poppins", sans-serif',[ne.RUBIK]:'"Rubik", sans-serif',[ne.RALEWAY]:'"Raleway", sans-serif',[ne.JOSEFIN_SANS]:'"Josefin Sans", sans-serif',[ne.ALEGREYA_SANS]:'"Alegreya Sans", sans-serif',[ne.OSWALD]:'"Oswald", sans-serif'}),Object.freeze({OPEN:"open",CLOSED:"closed",CLOSED_AFTER:"closed-after"})),oe=(Object.freeze({SHOW_RESULTS:"show-results",SHOW_CLOSED_BANNER:"show-closed-banner",HIDDEN:"hidden"}),Object.freeze({RADIO:"radio",BUTTON:"button"}),Object.freeze({LIST:"list",INLINE:"inline"}),ae=({attributes:t,fallbackStyles:n,fallbackStylesRef:o,renderStyleProbe:a})=>{const i=t.apiPollData.id,[l,c]=(0,e.useState)(0),{hasVoted:u,vote:d,storedCookieValue:p}=((t,n=!1,r=!1)=>{const o=`cs-poll-${t}`,[s,a]=(0,e.useState)(!1),[i,l]=(0,e.useState)(!1),[c,u]=(0,e.useState)("");return(0,e.useEffect)(()=>{n&&void 0!==H.get(o)&&(l(!0),u(H.get(o)))},[]),{hasVoted:i,isVoting:s,vote:async(e,s=1)=>{try{a(!0);const i=await(async e=>{const t=(new Date).getTime(),n=await window.fetch(`https://poll.fm/n/5430eeac3911395001d731d9702fc38b/${e}?${t}&format=json`);if(!n.ok)throw new z;const r=await n.json();if(!r.nonce)throw new z;return r.nonce})(t);if(await(async(e,t,n,r)=>{const o=n.join(","),s=await window.fetch(`https://polls.polldaddy.com/vote-js.php?format=json&p=${t}&b=1&a=${o}&o=&va=16&cookie=0&n=${e}&url=${encodeURIComponent(window.location)}&vi=${r}`);if(!s.ok)throw new z;const a=await s.json();if("error"===a.status)throw new W(a.error)})(i,t,e,s),l(!0),n){const t=r?e.join(","):(new Date).getTime();H.set(o,t,{sameSite:"Strict",expires:365}),u(t)}}finally{a(!1)}},storedCookieValue:c}})(i,!0,!0),{results:f}=G(i,!t.hideResults);(0,e.useEffect)(()=>{""!==p&&c(parseInt(p.split(",")[0],10))},[p]);const m=async e=>{c(e),await d([e])},h=s()("crowdsignal-forms-vote",t.className,`size-${t.size}`),E=(0,r.zipObject)((0,r.map)(t.apiPollData.answers,"client_id"),(0,r.map)(t.apiPollData.answers,"id")),b=(e=>(0,r.mapKeys)({borderRadius:`${e.borderRadius}px`,borderWidth:`${e.borderWidth}px`},(e,t)=>`--crowdsignal-forms-vote-${(0,r.kebabCase)(t)}`))(t),g=((e,t,n=new Date)=>re.CLOSED===e||re.CLOSED_AFTER===e&&new Date(t)<n)(t.pollStatus,t.closedAfterDateTime);return(0,e.createElement)("div",{ref:o,className:h,style:b},(0,e.createElement)("div",{className:"crowdsignal-forms-vote__items"},(0,r.map)(t.innerBlocks,r=>{const o=E[r.answerId];return(0,e.createElement)(F,{attributes:r,fallbackStyles:n,key:r.answerId,apiAnswerId:o,onVote:m,disabled:u||0!==l||g,isVotedOn:o===l,voteCount:f?f[o]:0,hideCount:t.hideResults,type:r.type})})),(0,e.createElement)(te,{showBranding:u&&!t.hideBranding,referralCode:"cs-forms-vote"}),a())},(se=e=>({fallbackStyles:Q(e.querySelector(".crowdsignal-forms__style-probe"))}),(0,J.createHigherOrderComponent)(t=>class extends Y.Component{constructor(e){super(e),this.nodeRef=this.props.node,this.state={fallbackStyles:void 0,grabStylesCompleted:!1},this.bindRef=this.bindRef.bind(this)}bindRef(e){e&&(this.nodeRef=e)}componentDidMount(){this.grabFallbackStyles()}componentDidUpdate(){this.grabFallbackStyles()}grabFallbackStyles(){const{grabStylesCompleted:e,fallbackStyles:t}=this.state;if(this.nodeRef&&!e){const e=se(this.nodeRef,this.props);q()(e,t)||this.setState({fallbackStyles:e,grabStylesCompleted:Object.values(e).every(Boolean)})}}render(){return(0,e.createElement)(t,{...this.props,...this.state.fallbackStyles,fallbackStylesRef:this.bindRef})}},"withFallbackStyles"))(({fallbackStyles:t,fallbackStylesRef:n,...r})=>(0,e.createElement)(ae,{fallbackStyles:t||{},fallbackStylesRef:n,renderStyleProbe:()=>t?null:(0,e.createElement)(X,null),...r})));var se,ae;const ie=(e,t)=>(0,r.forEach)(document.querySelectorAll(`div[${e}]`),n=>{try{const o=JSON.parse(n.dataset[(0,r.camelCase)(e.substr(5))]),s=t(o,n);n.removeAttribute(e),(0,d.render)(s,n)}catch(t){console.error("Crowdsignal Forms: Failed to parse block data for: %s",e)}}),le=(e,t)=>{((0,r.isEmpty)(window.CrowdsignalMutationObservers)||!0!==window.CrowdsignalMutationObservers[e])&&(new window.MutationObserver(()=>ie(e,t)).observe(document.body,{attributes:!0,attributeFilter:[e],childList:!0,subtree:!0}),(0,r.isEmpty)(window.CrowdsignalMutationObservers)&&(window.CrowdsignalMutationObservers=[]),window.CrowdsignalMutationObservers[e]=!0,ie(e,t))};((e,t)=>{if("complete"===document.readyState||"interactive"===document.readyState)return le(e,t);document.addEventListener("DOMContentLoaded",()=>le(e,t))})("data-crowdsignal-vote",(t,n)=>{const o=[];(0,r.forEach)(n.children,e=>{(0,r.isEmpty)(e.dataset.crowdsignalVoteItem)||o.push(JSON.parse(e.dataset.crowdsignalVoteItem))});const s={...t,innerBlocks:o};return(0,e.createElement)(oe,{attributes:s})})})()})();