!function(){var e={785:function(e,t,n){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}var o="object"===("undefined"==typeof window?"undefined":r(window))&&window.window===window?window:"object"===("undefined"==typeof self?"undefined":r(self))&&self.self===self?self:"object"===(void 0===n.g?"undefined":r(n.g))&&n.g.global===n.g?n.g:this;function a(e,t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){l(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function i(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return t.status>=200&&t.status<=299}function c(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var l="object"!==("undefined"==typeof window?"undefined":r(window))||window!==o?function(){}:"download"in HTMLAnchorElement.prototype?function(e,t,n){var r=o.URL||o.webkitURL,l=document.createElement("a");t=t||e.name||"download",l.download=t,l.rel="noopener","string"==typeof e?(l.href=e,l.origin!==location.origin?i(l.href)?a(e,t,n):c(l,l.target="_blank"):c(l)):(l.href=r.createObjectURL(e),setTimeout((function(){r.revokeObjectURL(l.href)}),4e4),setTimeout((function(){c(l)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,t,n){if(t=t||e.name||"download","string"==typeof e)if(i(e))a(e,t,n);else{var o=document.createElement("a");o.href=e,o.target="_blank",setTimeout((function(){c(o)}))}else navigator.msSaveOrOpenBlob(function(e,t){return void 0===t?t={autoBom:!1}:"object"!==r(t)&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([String.fromCharCode(65279),e],{type:e.type}):e}(e,n),t)}:function(e,t,n,i){if((i=i||open("","_blank"))&&(i.document.title=i.document.body.innerText="downloading..."),"string"==typeof e)return a(e,t,n);var c="application/octet-stream"===e.type,l=/constructor/i.test(o.HTMLElement)||o.safari,u=/CriOS\/[\d]+/.test(navigator.userAgent);if((u||c&&l)&&"object"===("undefined"==typeof FileReader?"undefined":r(FileReader))){var s=new FileReader;s.onloadend=function(){var e=s.result;e=u?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),i?i.location.href=e:location=e,i=null},s.readAsDataURL(e)}else{var d=o.URL||o.webkitURL,p=d.createObjectURL(e);i?i.location=p:location.href=p,i=null,setTimeout((function(){d.revokeObjectURL(p)}),4e4)}};e.exports=l},184:function(e,t){var n;
/*!
  Copyright (c) 2017 Jed Watson.
  Licensed under the MIT License (MIT), see
  http://jedwatson.github.io/classnames
*/!function(){"use strict";var r={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var n=arguments[t];if(n){var a=typeof n;if("string"===a||"number"===a)e.push(n);else if(Array.isArray(n)&&n.length){var i=o.apply(null,n);i&&e.push(i)}else if("object"===a)for(var c in n)r.call(n,c)&&n[c]&&e.push(c)}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(n=function(){return o}.apply(t,[]))||(e.exports=n)}()},496:function(e){for(var t=self.crypto||self.msCrypto,n="-_",r=36;r--;)n+=r.toString(36);for(r=36;r---10;)n+=r.toString(36).toUpperCase();e.exports=function(e){var o="",a=t.getRandomValues(new Uint8Array(e||21));for(r=e||21;r--;)o+=n[63&a[r]];return o}},539:function(e,t){var n,r,o;
/*!
 * php-unserialize-js JavaScript Library
 * https://github.com/bd808/php-unserialize-js
 *
 * Copyright 2013 Bryan Davis and contributors
 * Released under the MIT license
 * http://www.opensource.org/licenses/MIT
 */!function(a,i){"use strict";r=[],void 0===(o="function"==typeof(n=function(){return function(e){var t,n=0,r=[],o=0,a=function(){var t=e.indexOf(":",n),r=e.substring(n,t);return n=t+2,parseInt(r,10)},i=function(){var t=e.indexOf(";",n),r=e.substring(n,t);return n=t+1,parseInt(r,10)},c=function(){var e=i();return r[o++]=e,e},l=function(){var t=e.indexOf(";",n),a=e.substring(n,t);return n=t+1,a=parseFloat(a),r[o++]=a,a},u=function(){var t=e.indexOf(";",n),a=e.substring(n,t);return n=t+1,a="1"===a,r[o++]=a,a},s=function(t='"'){for(var r,o,i=a(),c=0,l=0;l<i;)(r=e.charCodeAt(n+c++))<=127?l++:l+=r>2047?3:2;return e.charAt(n+c)!==t&&(c+=e.indexOf('"',n+c)-n-c),o=e.substring(n,n+c),n+=c+2,o},d=function(){var e=s();return r[o++]=e,e},p=function(){var t=e.charAt(n);return n+=2,t},f=function(){var e=p();switch(e){case"i":return i();case"s":return s();default:throw new Error("Unknown key type '"+e+"' at position "+(n-2))}},m=function(){var e,i,c,l,u,s=a(),d=[],p={},m=d,y=o++;r[y]=m;try{for(c=0;c<s;c++)if(e=f(),i=t(),m===d&&e+""==c+"")d.push(i);else{if(m!==p){for(l=0,u=d.length;l<u;l++)p[l]=d[l];m=p,r[y]=m}p[e]=i}}catch(e){throw e.state=m,e}return n++,m},y=function(e,t){var r,o,a;if("\0"===e.charAt(0)){if((a=e.indexOf("\0",1))>0)return r=e.substring(1,a),o=e.substr(a+1),"*"===r||t===r?o:r+"::"+o;var i="Expected two <NUL> characters in non-public property name '"+e+"' at position "+(n-e.length-2);throw new Error(i)}return e},b=function(){var e,i,c,l,u={},d=o++,p=s();r[d]=u,e=a();try{for(l=0;l<e;l++)i=y(f(),p),c=t(),u[i]=c}catch(e){throw e.state=u,e}return n++,u},h=function(){return{__PHP_Incomplete_Class_Name:s(),serialized:s("}")}},v=function(){var e=i(),t=r[e-1];return r[o++]=t,t},g=function(){var e=i();return r[e-1]},_=function(){var e=null;return r[o++]=e,e};return(t=function(){var e=p();switch(e){case"i":return c();case"d":return l();case"b":return u();case"s":return d();case"a":return m();case"O":return b();case"C":return h();case"r":return v();case"R":return g();case"N":return _();default:throw new Error("Unknown type '"+e+"' at position "+(n-2))}})()}})?n.apply(t,r):n)||(e.exports=o)}()},459:function(e,t,n){var r=n(967);function o(e,t,n,r,a){var i=new Error(n,r,a);return i.name="UseFetchError",i.status=e,i.statusText=t,Object.setPrototypeOf(i,Object.getPrototypeOf(this)),Error.captureStackTrace&&Error.captureStackTrace(i,o),i}o.prototype=Object.create(Error.prototype,{constructor:{value:Error,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf(o,Error),e.exports=function(e,t,n){var a=(n&&n.depends||t&&t.depends||[]).reduce((function(e,t){return e||!t}),!1);return r(!a&&function(e,t,n){return fetch(e,t).then(n&&n.formatter||t&&t.formatter||function(e){if(!e.ok)throw new o(e.status,e.statusText,"Fetch error");return e.json()})},e,t||{},n||{})}},967:function(e,t,n){var r=n(313),o=n(923);e.exports=function(e){var t=Array.prototype.slice.call(arguments,[1]),n=r.useState({isLoading:!!e});return r.useEffect((function(){e&&(!n[0].isLoading&&n[1]({data:n[0].data,isLoading:!0}),e.apply(null,t).then((function(e){n[1]({data:e,isLoading:!1})})).catch((function(e){n[1]({error:e,isLoading:!1})})))}),o(t)),n[0]}},923:function(e){e.exports=function e(){for(var t=[],n=0;n<arguments.length;n++){var r=arguments[n];if(r instanceof Array)for(var o=0;o<r.length;o++)t=t.concat(e(r[o]));else if("undefined"!=typeof URL&&r instanceof URL)t=t.concat(r.toJSON());else if(r instanceof Object)for(var a=Object.keys(r),i=0;i<a.length;i++){var c=a[i];t=t.concat([c]).concat(e(r[c]))}else t=t.concat(r)}return t}},616:function(e,t,n){var r=n(496);e.exports=function(){var e=function(){e.id=r(),e.subscribers.forEach((function(e){e()}))};return e.id=r(),e.subscribers=[],e.subscribe=function(t){e.subscribers.push(t)},e.unsubscribe=function(t){e.subscribers.indexOf(t)>=0&&e.subscribers.splice(e.subscribers.indexOf(t),1)},e}},382:function(e,t,n){var r=n(313);e.exports=function(e){var t=r.useState(e.id),n=function(){return t[1](e.id)};return r.useEffect((function(){return e.subscribe(n),function(){return e.unsubscribe(n)}}),[]),t[0]}},313:function(e){"use strict";e.exports=window.React}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var a=t[r]={exports:{}};return e[r].call(a.exports,a,a.exports,n),a.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(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.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){"use strict";var e=window.wp.element,t=window.wp.components,r=window.wp.i18n,o=window.blocksyOptions,a=n(184),i=n.n(a);function c(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function d(e){return function(e){if(Array.isArray(e))return p(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return p(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return p(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var f=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=(0,e.useContext)(ie),r=n.isAdvancedMode,o=n.filter,a=n.allTaxonomies,i=n.allLanguages,l=n.allUsers,s=blocksy_admin.all_condition_rules;return"singular"===o&&(s=blocksy_admin.singular_condition_rules),"archive"===o&&(s=blocksy_admin.archive_condition_rules),"product_tabs"===o&&(s=blocksy_admin.product_tabs_rules),"maintenance-mode"===o&&(s=blocksy_admin.maintenance_mode_rules),{isAdvancedMode:r,allRules:s.reduce((function(e,t){var n=t.rules,r=t.title;return[].concat(d(e),d(n.map((function(e){return u(u({},e),{},{group:r})}))))}),[]).reduce((function(e,n){var r=n.title,o=n.id,a=n.sub_ids,i=void 0===a?[]:a,l=c(n,["title","id","sub_ids"]);return[].concat(d(e),[u({key:t&&i.length>0&&i.find((function(e){return e.id===t.rule}))?t.rule:o,value:r,sub_ids:i},l)])}),[]),rulesToUse:s,allTaxonomies:a,allLanguages:i,allUsers:l}};function m(e){return function(e){if(Array.isArray(e))return _(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||g(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function b(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?y(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function h(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,a=void 0;try{for(var i,c=e[Symbol.iterator]();!(r=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){o=!0,a=e}finally{try{r||null==c.return||c.return()}finally{if(o)throw a}}return n}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){if(e){if("string"==typeof e)return _(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_(e,t):void 0}}function _(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var E=function(e){return e.filter((function(e,t,n){return n.findIndex((function(t){return t.ID===e.ID}))===t}))},w=[],O=function(t){var n=t.condition,a=t.onChange,i=v((0,e.useState)(w),2),c=i[0],l=i[1],u=(0,e.useMemo)((function(){return{post_ids:"post",page_ids:"page",product_ids:"product",custom_post_type_ids:"ct_cpt"}[n.rule]}),[n.rule]),s=(0,e.useMemo)((function(){return(n.payload||{}).post_id||""}),[n.payload&&n.payload.post_id]),d=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";fetch("".concat(wp.ajax.settings.url,"?action=blocksy_conditions_get_all_posts"),{headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(b(b({post_type:u},e?{search_query:e}:{}),s?{alsoInclude:s}:{})),method:"POST"}).then((function(e){return e.json()})).then((function(e){var t=e.data.posts;l((function(e){return E([].concat(m(e),m(t)))})),w=E([].concat(m(w),m(t)))}))};return(0,e.useEffect)((function(){d()}),[u]),(0,e.createElement)(o.Select,{option:{appendToBody:!0,defaultToFirstItem:!1,searchPlaceholder:(0,r.__)("Type to search by ID or title...","blocksy-companion"),placeholder:"post_ids"===n.rule?(0,r.__)("Select post","blocksy-companion"):"page_ids"===n.rule?(0,r.__)("Select page","blocksy-companion"):"product_ids"===n.rule?(0,r.__)("Select product","blocksy-companion"):(0,r.__)("Custom Post Type ID","blocksy-companion"),choices:m(c.filter((function(e){var t=e.post_type;return"ct_cpt"===u?"post"!==t&&"page"!==t:u===t})).map((function(e){return{key:e.ID,value:e.post_title}}))),search:!0},value:s,onChange:function(e){return a(e)},onInputValueChange:function(e){c.find((function(t){return t.post_title===e}))||d(e)}})};function j(){return j=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},j.apply(this,arguments)}function k(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function S(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?k(Object(n),!0).forEach((function(t){C(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):k(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function C(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,a=void 0;try{for(var i,c=e[Symbol.iterator]();!(r=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){o=!0,a=e}finally{try{r||null==c.return||c.return()}finally{if(o)throw a}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return A(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return A(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var P=function(t){var n=t.onChange,r=t.condition,a=x((0,e.useState)("start"),2),c=a[0],l=a[1],u=(0,e.useRef)(),s=x((0,e.useState)(!1),2),d=s[0],p=s[1],f=(0,o.usePopoverMaker)({ref:u,defaultHeight:228,shouldCalculate:!0}),m=f.styles,y=f.popoverProps,b=r.payload.start||new Date,h=r.payload.end||new Date,v=[wp.date.format("j/n/Y",b),wp.date.format("j/n/Y",h)];return v[0]===v[1]&&(v=[wp.date.format(wp.date.getSettings().formats.time,b),wp.date.format(wp.date.getSettings().formats.time,h)]),(0,e.createElement)(e.Fragment,null,(0,e.createElement)(o.OutsideClickHandler,{className:"ct-select-input",wrapperProps:{ref:u,role:"combobox","aria-expanded":d,"aria-haspopup":"listbox",onClick:function(){p(!d)}},onOutsideClick:function(e){e.target.closest(".ct-select-dropdown")||p(!1)}},(0,e.createElement)("input",{value:v.join(" - "),onChange:function(){},readOnly:!0})),d&&(0,e.createPortal)((0,e.createElement)("div",j({className:i()("ct-select-dropdown ct-date-time-picker-dropdown",{"ct-fixed":!0})},y,{style:m}),(0,e.createElement)("div",{className:"ct-start-end-date-switcher components-button-group"},["start","end"].map((function(t){return(0,e.createElement)("button",{key:t,className:i()("components-button",{"is-primary":t===c}),onClick:function(){l(t)}},"start"===t?"Start Date":"Expiration Date")}))),(0,e.createElement)(o.DateTimePicker,{value:(r.payload||{})[c]||new Date,onChange:function(e){n(S(S({},r),{},{payload:S(S({},r.payload),{},C({},c,e))}))}})),document.body))},N=window.wp.date;function D(){return D=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},D.apply(this,arguments)}function T(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function I(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?T(Object(n),!0).forEach((function(t){M(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function M(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function L(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,a=void 0;try{for(var i,c=e[Symbol.iterator]();!(r=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){o=!0,a=e}finally{try{r||null==c.return||c.return()}finally{if(o)throw a}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return z(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var R=function(n){var a=n.onChange,c=n.condition,l=(0,e.useRef)(),u=L((0,e.useState)(!1),2),s=u[0],d=u[1],p=(0,o.usePopoverMaker)({ref:l,defaultHeight:228,shouldCalculate:!0}),f=p.styles,m=p.popoverProps,y={monday:!0,tuesday:!0,wednesday:!0,thursday:!0,friday:!0,saturday:!0,sunday:!0},b=Object.keys(y).filter((function(e){return(c.payload.days||y)[e]})),h="Only "+b.map((function(e){return function(e){return{monday:(0,r.__)("Mon","blocksy-companion"),tuesday:(0,r.__)("Tue","blocksy-companion"),wednesday:(0,r.__)("Wed","blocksy-companion"),thursday:(0,r.__)("Thu","blocksy-companion"),friday:(0,r.__)("Fri","blocksy-companion"),saturday:(0,r.__)("Sat","blocksy-companion"),sunday:(0,r.__)("Sun","blocksy-companion")}[e]}(e)})).join(", ");7===b.length&&(h=(0,r.__)("Every day","blocksy-companion")),2===b.length&&b.includes("saturday")&&b.includes("sunday")&&(h=(0,r.__)("Only weekends","blocksy-companion")),5!==b.length||b.includes("saturday")||b.includes("sunday")||(h=(0,r.__)("Only weekdays","blocksy-companion")),0===b.length&&(h=(0,r.__)("Never","blocksy-companion"));var v=c.payload.time_start||"00:00",g=c.payload.time_end||"23:59",_=new Date;_.setHours(v.split(":")[0]),_.setMinutes(v.split(":")[1],0,0);var E=new Date;E.setHours(g.split(":")[0]),E.setMinutes(g.split(":")[1],0,0);var w=(0,N.getSettings)(),O=/a(?!\\)/i.test(w.formats.time.toLowerCase().replace(/\\\\/g,"").split("").reverse().join(""));return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(o.OutsideClickHandler,{className:"ct-select-input",wrapperProps:{ref:l,role:"combobox","aria-expanded":s,"aria-haspopup":"listbox",onClick:function(){d(!s)}},onOutsideClick:function(e){e.target.closest(".ct-select-dropdown")||d(!1)}},(0,e.createElement)("input",{value:h,onChange:function(){},readOnly:!0})),s&&(0,e.createPortal)((0,e.createElement)("div",D({className:i()("ct-select-dropdown ct-recurring-scheduling-dropdown",{"ct-fixed":!0})},m,{style:f}),(0,e.createElement)("div",{className:"ct-recurring-scheduling-days"},(0,e.createElement)("label",{className:"ct-label"},(0,r.__)("Recurring Days","blocksy-companion")),[{key:"monday",value:(0,r.__)("Monday","blocksy-companion")},{key:"tuesday",value:(0,r.__)("Tuesday","blocksy-companion")},{key:"wednesday",value:(0,r.__)("Wednesday","blocksy-companion")},{key:"thursday",value:(0,r.__)("Thursday","blocksy-companion")},{key:"friday",value:(0,r.__)("Friday","blocksy-companion")},{key:"saturday",value:(0,r.__)("Saturday","blocksy-companion")},{key:"sunday",value:(0,r.__)("Sunday","blocksy-companion")}].map((function(n){var r=n.key,o=n.value;return(0,e.createElement)(t.CheckboxControl,{label:o,checked:(c.payload.days||y)[r],onChange:function(){a(I(I({},c),{},{payload:I(I({},c.payload),{},{days:I(I({},c.payload.days||y),{},M({},r,!(c.payload.days||y)[r]))})}))}})}))),(0,e.createElement)("div",{className:"ct-recurring-scheduling-time"},(0,e.createElement)("div",{className:"ct-recurring-start-time"},(0,e.createElement)("label",{className:"ct-label"},(0,r.__)("Start Time","blocksy-companion")),(0,e.createElement)(t.TimePicker,{is12Hour:O,currentTime:_,onChange:function(e){a(I(I({},c),{},{payload:I(I({},c.payload),{},{time_start:wp.date.format("H:i",e)})}))}})),(0,e.createElement)("div",{className:"ct-recurring-stop-time"},(0,e.createElement)("label",{className:"ct-label"},(0,r.__)("Stop Time","blocksy-companion")),(0,e.createElement)(t.TimePicker,{is12Hour:O,currentTime:E,onChange:function(e){a(I(I({},c),{},{payload:I(I({},c.payload),{},{time_end:wp.date.format("H:i",e)})}))}})))),document.body))};function U(e){return function(e){if(Array.isArray(e))return F(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return F(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return F(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function F(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function B(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function H(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?B(Object(n),!0).forEach((function(t){V(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):B(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function V(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var $=function(t){var n=t.className,a=void 0===n?"":n,c=t.condition,l=t.onRemove,u=t.onChange;c=H(H({},c),{},{payload:H({},c.payload)});var s=f(c),d=s.allRules,p=s.allTaxonomies,m=s.allLanguages,y=s.allUsers,b=d.find((function(e){return e.key===c.rule})),h="post_ids"===c.rule||"page_ids"===c.rule||"product_ids"===c.rule||"custom_post_type_ids"===c.rule||"taxonomy_ids"===c.rule||"post_with_taxonomy_ids"===c.rule||"product_with_taxonomy_ids"===c.rule||"product_taxonomy_ids"===c.rule||"current_language"===c.rule||"user_post_author_id"===c.rule||"author"===c.rule||"start_end_date"===c.rule||"schedule_date"===c.rule||"request_referer"===c.rule||"request_cookie"===c.rule||"request_url"===c.rule||b&&b.sub_ids&&b.sub_ids.length>0;return(0,e.createElement)("div",{className:i()("ct-condition-group",a,{"ct-cols-3":h,"ct-cols-2":!h})},(0,e.createElement)(o.Select,{key:"first",option:{inputClassName:"ct-condition-type",selectInputStart:function(){return"include"===c.type?(0,e.createElement)("span",{className:"ct-include"},(0,e.createElement)("svg",{width:"8",height:"8",fill:"currentColor",viewBox:"0 0 20 20"},(0,e.createElement)("path",{d:"M20,11h-9v9H9v-9H0V9h9V0h2v9h9V11z"}))):"exclude"===c.type?(0,e.createElement)("span",{className:"ct-exclude"},(0,e.createElement)("svg",{width:"8",height:"8",fill:"currentColor",viewBox:"0 0 20 20"},(0,e.createElement)("path",{d:"M20,9v2H0V9H20z"}))):null},placeholder:(0,r.__)("Select variation","blocksy-companion"),choices:{include:(0,r.__)("Include","blocksy-companion"),exclude:(0,r.__)("Exclude","blocksy-companion")}},value:c.type,onChange:function(e){u(H(H({},c),{},{type:e}))}}),(0,e.createElement)(o.Select,{key:"second",option:{appendToBody:!0,placeholder:(0,r.__)("Select rule","blocksy-companion"),choices:d,search:!0},value:c.rule,onChange:function(e){var t=d.find((function(t){return t.key===e}));t.sub_ids&&t.sub_ids.length>0?u(H(H({},c),{},{rule:t.sub_ids[0].id})):u(H(H({},c),{},{rule:e}))}}),("post_ids"===c.rule||"custom_post_type_ids"===c.rule||"product_ids"===c.rule||"page_ids"===c.rule)&&(0,e.createElement)(O,{condition:c,onChange:function(e){u(H(H({},c),{},{payload:H(H({},c.payload),{},{post_id:e})}))}}),("taxonomy_ids"===c.rule||"post_with_taxonomy_ids"===c.rule)&&(0,e.createElement)(o.Select,{option:{appendToBody:!0,defaultToFirstItem:!1,placeholder:(0,r.__)("Select taxonomy","blocksy-companion"),choices:p.filter((function(e){return!((null==e?void 0:e.post_types)||[]).includes("product")})).map((function(e){return H({key:e.id,value:e.name},e.group?{group:e.group}:{})})),search:!0},value:(c.payload||{}).taxonomy_id||"",onChange:function(e){u(H(H({},c),{},{payload:H(H({},c.payload),{},{taxonomy_id:e})}))}}),("product_with_taxonomy_ids"===c.rule||"product_taxonomy_ids"===c.rule)&&(0,e.createElement)(o.Select,{option:{appendToBody:!0,defaultToFirstItem:!1,placeholder:(0,r.__)("Select taxonomy","blocksy-companion"),choices:p.filter((function(e){return((null==e?void 0:e.post_types)||[]).includes("product")})).map((function(e){return H({key:e.id,value:e.name},e.group?{group:e.group}:{})})),search:!0},value:(c.payload||{}).taxonomy_id||"",onChange:function(e){u(H(H({},c),{},{payload:H(H({},c.payload),{},{taxonomy_id:e})}))}}),"current_language"===c.rule&&(0,e.createElement)(o.Select,{option:{appendToBody:!0,defaultToFirstItem:!1,placeholder:(0,r.__)("Select language","blocksy-companion"),choices:m.map((function(e){return{key:e.id,value:e.name}})),search:!0},value:(c.payload||{}).language||"",onChange:function(e){u(H(H({},c),{},{payload:H(H({},c.payload),{},{language:e})}))}}),"user_post_author_id"===c.rule&&(0,e.createElement)(o.Select,{option:{appendToBody:!0,defaultToFirstItem:!1,placeholder:(0,r.__)("Select user","blocksy-companion"),choices:[{key:"current_user",value:(0,r.__)("Current user","blocksy-companion")}].concat(U(y.map((function(e){return{key:e.id,value:e.name}})))),search:!0},value:(c.payload||{}).user_id||"",onChange:function(e){u(H(H({},c),{},{payload:H(H({},c.payload),{},{user_id:e})}))}}),"author"===c.rule&&(0,e.createElement)(o.Select,{option:{appendToBody:!0,placeholder:(0,r.__)("Select user","blocksy-companion"),choices:[{key:"all_users",value:(0,r.__)("All authors","blocksy-companion")}].concat(U(y.map((function(e){return{key:e.id,value:e.name}})))),search:!0},value:(c.payload||{}).user_id||"all_users",onChange:function(e){u(H(H({},c),{},{payload:H(H({},c.payload),{},{user_id:e})}))}}),b&&b.sub_ids&&b.sub_ids.length>0&&(0,e.createElement)(o.Select,{option:{appendToBody:!0,placeholder:(0,r.__)("Select sub field","blocksy-companion"),choices:b.sub_ids.map((function(e){return{key:e.id,value:e.title}})),search:!0,inputClassName:"ct-dropdown-normal-width"},value:c.rule,onChange:function(e){u(H(H({},c),{},{rule:e}))}}),"start_end_date"===c.rule&&(0,e.createElement)(P,{condition:c,onChange:u}),"schedule_date"===c.rule&&(0,e.createElement)(R,{condition:c,onChange:u}),"request_referer"===c.rule&&(0,e.createElement)("div",{className:"ct-option-input"},(0,e.createElement)("input",{type:"text",placeholder:"website.com",value:c.payload.referer,onChange:function(e){u(H(H({},c),{},{payload:H(H({},c.payload),{},{referer:e.target.value})}))}}),(0,e.createElement)("span",{className:"ct-condition-info","data-tooltip":"top"},(0,e.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 24 24"},(0,e.createElement)("path",{d:"M12,2C6.477,2,2,6.477,2,12s4.477,10,10,10s10-4.477,10-10S17.523,2,12,2z M12,17L12,17c-0.552,0-1-0.448-1-1v-4 c0-0.552,0.448-1,1-1h0c0.552,0,1,0.448,1,1v4C13,16.552,12.552,17,12,17z M12.5,9h-1C11.224,9,11,8.776,11,8.5v-1 C11,7.224,11.224,7,11.5,7h1C12.776,7,13,7.224,13,7.5v1C13,8.776,12.776,9,12.5,9z"})),(0,e.createElement)("i",{className:"ct-tooltip"},(0,r.__)("Display based on referer domain","blocksy-companion")))),"request_cookie"===c.rule&&(0,e.createElement)("div",{className:"ct-option-input"},(0,e.createElement)("input",{type:"text",placeholder:"cookie_name",value:(c.payload||{}).cookie||"",onChange:function(e){u(H(H({},c),{},{payload:H(H({},c.payload),{},{cookie:e.target.value})}))}}),(0,e.createElement)("span",{className:"ct-condition-info","data-tooltip":"top"},(0,e.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 24 24"},(0,e.createElement)("path",{d:"M12,2C6.477,2,2,6.477,2,12s4.477,10,10,10s10-4.477,10-10S17.523,2,12,2z M12,17L12,17c-0.552,0-1-0.448-1-1v-4 c0-0.552,0.448-1,1-1h0c0.552,0,1,0.448,1,1v4C13,16.552,12.552,17,12,17z M12.5,9h-1C11.224,9,11,8.776,11,8.5v-1 C11,7.224,11.224,7,11.5,7h1C12.776,7,13,7.224,13,7.5v1C13,8.776,12.776,9,12.5,9z"})),(0,e.createElement)("i",{className:"ct-tooltip"},(0,r.__)("Display if cookie is present","blocksy-companion")))),"request_url"===c.rule&&(0,e.createElement)("div",{className:"ct-option-input"},(0,e.createElement)("input",{type:"text",placeholder:"example=campaignID",value:c.payload.url||"",onChange:function(e){u(H(H({},c),{},{payload:H(H({},c.payload),{},{url:e.target.value})}))}}),(0,e.createElement)("span",{className:"ct-condition-info","data-tooltip":"top"},(0,e.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 24 24"},(0,e.createElement)("path",{d:"M12,2C6.477,2,2,6.477,2,12s4.477,10,10,10s10-4.477,10-10S17.523,2,12,2z M12,17L12,17c-0.552,0-1-0.448-1-1v-4 c0-0.552,0.448-1,1-1h0c0.552,0,1,0.448,1,1v4C13,16.552,12.552,17,12,17z M12.5,9h-1C11.224,9,11,8.776,11,8.5v-1 C11,7.224,11.224,7,11.5,7h1C12.776,7,13,7.224,13,7.5v1C13,8.776,12.776,9,12.5,9z"})),(0,e.createElement)("i",{className:"ct-tooltip"},(0,r.__)("Display if query string is present in URL","blocksy-companion")))),(0,e.createElement)("button",{type:"button",className:"ct-remove-condition-group",onClick:function(e){e.preventDefault(),l()}},(0,e.createElement)("svg",{width:"7px",height:"7px",fill:"currentColor",viewBox:"0 0 24 24"},(0,e.createElement)("path",{d:"m12 14.7 9.3 9.3 2.7-2.7-9.3-9.3L24 2.7 21.3 0 12 9.3 2.7 0 0 2.7 9.3 12 0 21.3 2.7 24l9.3-9.3z"}))))};function q(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Y(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?q(Object(n),!0).forEach((function(t){G(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):q(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function G(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function J(e){return function(e){if(Array.isArray(e))return K(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||X(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function W(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,a=void 0;try{for(var i,c=e[Symbol.iterator]();!(r=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){o=!0,a=e}finally{try{r||null==c.return||c.return()}finally{if(o)throw a}}return n}(e,t)||X(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function X(e,t){if(e){if("string"==typeof e)return K(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?K(e,t):void 0}}function K(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Q=function t(n){var r=n.conditionsListDescriptor,o=n.onChange,a=n.extractRulesIntoRoot,c=void 0===a?null:a,l=n.className,u=void 0===l?"":l,s=W((0,e.useState)(null),2),d=s[0],p=s[1],m=f(),y=m.rulesToUse,b=m.isAdvancedMode;if(0===r.conditions.length)return null;var h=r.conditions.map((function(n,a){var l=null,u="";return d!==a&&d-1!==a||(u="ct-hovered"),n.relation&&(l=(0,e.createElement)(t,{className:u,key:a,conditionsListDescriptor:n,extractRulesIntoRoot:function(e){var t=[].concat(J(n.conditions.slice(0,e-1)),J(n.conditions.slice(e+1)));o([].concat(J(r.conditions.slice(0,a)),J(n.conditions.slice(e-1,e+1)),J(t.length>0?[Y(Y({},n),{},{conditions:t})]:[]),J(r.conditions.slice(a+1))))},onChange:function(e){0===e.length?o([].concat(J(r.conditions.slice(0,a)),J(r.conditions.slice(a+1)))):o(r.conditions.map((function(t,n){return Y({},n===a?Y(Y({},t),{},{conditions:e}):t)})))}})),n.relation||(l=(0,e.createElement)($,{className:u,condition:n,onChange:function(e){o(r.conditions.map((function(t,n){return Y({},n===a?e:t)})))},onAdd:function(){"OR"!==r.relation?o([].concat(J(r.conditions),[{type:"include",rule:y[0].rules[0].id,payload:{}}])):o(r.conditions.map((function(e,t){return Y({},t===a?{relation:"AND",conditions:[e,{type:"include",rule:y[0].rules[0].id,payload:{}}]}:e)})))},onRemove:function(){o([].concat(J(r.conditions.slice(0,a)),J(r.conditions.slice(a+1))))}})),(0,e.createElement)(e.Fragment,{key:a},b&&a>0&&(0,e.createElement)("div",{className:i()("ct-condition-relation",{"ct-hovered":d===a})},(0,e.createElement)("ul",{onMouseEnter:function(){p(a)},onMouseLeave:function(){p(null)}},"AND"===r.relation&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("li",{onClick:function(){c&&(p(null),c(a))}},(0,e.createElement)("span",null,"OR")),(0,e.createElement)("li",{className:"active"},(0,e.createElement)("span",null,"AND"))),"OR"===r.relation&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("li",{className:"active"},(0,e.createElement)("span",null,"OR")),(0,e.createElement)("li",{onClick:function(){p(null),o([].concat(J(r.conditions.slice(0,a-1)),[{relation:"AND",conditions:r.conditions.slice(a-1,a+1).reduce((function(e,t){return[].concat(J(e),J(t.conditions?t.conditions:[t]))}),[])}],J(r.conditions.slice(a+1,r.conditions.length))))}},(0,e.createElement)("span",null,"AND"))))),l)}));return"OR"===r.relation&&1===r.conditions.length||!b?h:(0,e.createElement)("div",{className:i()("ct-relation-group",u),"data-relation":r.relation},h,"AND"===r.relation&&(0,e.createElement)("div",{className:"ct-condition-relation ct-add-and-relation"},(0,e.createElement)("span",{onClick:function(){o([].concat(J(r.conditions),[{type:"include",rule:y[0].rules[0].id,payload:{}}]))}},(0,e.createElement)("svg",{width:"8",height:"8",fill:"currentColor",viewBox:"0 0 20 20"},(0,e.createElement)("path",{d:"M20,11h-9v9H9v-9H0V9h9V0h2v9h9V11z"})))))};function Z(e){return function(e){if(Array.isArray(e))return ae(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||oe(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ee(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function te(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ee(Object(n),!0).forEach((function(t){ne(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ee(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ne(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function re(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,a=void 0;try{for(var i,c=e[Symbol.iterator]();!(r=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){o=!0,a=e}finally{try{r||null==c.return||c.return()}finally{if(o)throw a}}return n}(e,t)||oe(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function oe(e,t){if(e){if("string"==typeof e)return ae(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ae(e,t):void 0}}function ae(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ie=(0,e.createContext)({filter:"all",allTaxonomies:[],allLanguages:[],allUsers:[]}),ce=[],le=[],ue=[],se=function(t){var n=t.value,a=t.onChange,i=t.filter,c=void 0===i?"all":i,l=t.addConditionButtonLabel,u=f().rulesToUse,s=re((0,e.useState)(ce),2),d=s[0],p=s[1],m=re((0,e.useState)(le),2),y=m[0],b=m[1],h=re((0,e.useState)(ue),2),v=h[0],g=h[1],_=re((0,e.useState)("__EMPTY__"),2),E=_[0],w=_[1];(0,e.useEffect)((function(){fetch("".concat(wp.ajax.settings.url,"?action=blocksy_conditions_get_all_taxonomies"),{headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"}).then((function(e){return e.json()})).then((function(e){var t=e.data,n=t.taxonomies,r=t.languages,o=t.users;p(n),ce=n,b(r),le=r,g(o),ue=o}))}),[]);var O=Array.isArray(n)?{relation:"OR",conditions:n}:n,j="__EMPTY__"!==E&&E;return O.conditions.find((function(e){return e.relation}))&&(j=!0),(0,e.createElement)(ie.Provider,{value:{allTaxonomies:d,allLanguages:y,allUsers:v,filter:c,isAdvancedMode:j}},(0,e.createElement)("div",{className:"ct-display-conditions"},(0,e.createElement)(Q,{conditionsListDescriptor:O,onChange:function(e){a(te(te({},O),{},{conditions:e}))}}),(0,e.createElement)("div",{className:"ct-conditions-actions"},(0,e.createElement)("button",{type:"button",className:"button add-condition",onClick:function(e){e.preventDefault(),a(te(te({},O),{},{conditions:[].concat(Z(O.conditions),[{type:"include",rule:u[0].rules[0].id,payload:{}}])}))}},l),(O.conditions.length>1||O.conditions.find((function(e){return e.relation})))&&(0,e.createElement)("span",null,(0,r.__)("Advanced Mode","blocksy-companion"),(0,e.createElement)(o.Switch,{value:j,onChange:function(e){O.conditions.find((function(e){return e.relation}))&&a(te(te({},O),{},{conditions:O.conditions.reduce((function(e,t){return[].concat(Z(e),Z(t.conditions?t.conditions:[t]))}),[])})),w(e)},option:{behavior:"boolean"}})))))};function de(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,a=void 0;try{for(var i,c=e[Symbol.iterator]();!(r=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){o=!0,a=e}finally{try{r||null==c.return||c.return()}finally{if(o)throw a}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return pe(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return pe(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var fe=function(t){var n=t.option,a=n.display,i=void 0===a?"inline":a,c=n.filter,l=void 0===c?"all":c,u=n.modalTitle,s=void 0===u?(0,r.__)("Transparent Header Display Conditions","blocksy-companion"):u,d=n.modalDescription,p=void 0===d?(0,r.__)("Add one or more conditions to display the transparent header.","blocksy-companion"):d,f=n.addConditionButtonLabel,m=void 0===f?(0,r.__)("Add Display Condition","blocksy-companion"):f,y=t.value,b=t.onChange,h=de((0,e.useState)(!1),2),v=h[0],g=h[1],_=de((0,e.useState)(null),2),E=_[0],w=_[1];return"inline"===i?(0,e.createElement)(se,{filter:l,value:y,onChange:b,addConditionButtonLabel:m}):(0,e.createElement)(e.Fragment,null,(0,e.createElement)("button",{className:"button-primary",style:{width:"100%"},onClick:function(e){e.preventDefault(),g(!0),w(null)}},Object.keys(y).length>0?(0,r.__)("Edit Conditions","blocksy-companion"):(0,r.__)("Add Conditions","blocksy-companion")),(0,e.createElement)(o.Overlay,{items:v,className:"ct-admin-modal ct-builder-conditions-modal",onDismiss:function(){g(!1),w(null)},render:function(){return(0,e.createElement)("div",{className:"ct-modal-content"},(0,e.createElement)("h2",null,s),(0,e.createElement)("p",null,p),(0,e.createElement)("div",{className:"ct-modal-scroll"},(0,e.createElement)(se,{filter:l,value:E||y,onChange:function(e){w(e)},addConditionButtonLabel:m})),(0,e.createElement)("div",{className:"ct-modal-actions has-divider"},(0,e.createElement)("button",{className:"button-primary",disabled:!E,onClick:function(){b(E),g(!1)}},(0,r.__)("Save Conditions","blocksy-companion"))))}}))},me=n(785),ye=n.n(me),be=n(539),he=n.n(be);function ve(e){return function(e){if(Array.isArray(e))return Ee(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||_e(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ge(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,a=void 0;try{for(var i,c=e[Symbol.iterator]();!(r=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){o=!0,a=e}finally{try{r||null==c.return||c.return()}finally{if(o)throw a}}return n}(e,t)||_e(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _e(e,t){if(e){if("string"==typeof e)return Ee(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ee(e,t):void 0}}function Ee(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var we=function(){var t=ge((0,e.useState)(null),2),n=t[0],a=t[1],c=ge((0,e.useState)(null),2),l=c[0],u=c[1],s=ge((0,e.useState)(!1),2),d=s[0],p=s[1],f=ge((0,e.useState)(!1),2),m=f[0],y=f[1],b=ge((0,e.useState)(!1),2),h=b[0],v=b[1],g=ge((0,e.useState)(["options"]),2),_=g[0],E=g[1],w=(0,e.useRef)(),O=(0,e.useRef)();return(0,e.useEffect)((function(){var e=function(e){e.stopPropagation(),e.preventDefault(),e.dataTransfer.dropEffect="copy",p(!0)},t=function(e){e.stopPropagation(),e.preventDefault(),p(!1)},n=function(e){e.stopPropagation(),e.preventDefault(),p(!1);var t=Array.from(e.dataTransfer.files||[]);if(Array.from(e.dataTransfer.items||[]).length>0){var n=e.dataTransfer.items[0].getAsFile();a(n)}else t.length>0&&a(t[0])};return O.current.addEventListener("dragover",e,!1),O.current.addEventListener("dragleave",t,!1),O.current.addEventListener("drop",n,!1),function(){O.current&&(O.current.removeEventListener("dragover",e,!1),O.current.removeEventListener("dragleave",t,!1),O.current.removeEventListener("drop",n,!1))}}),[]),(0,e.createElement)("div",{className:"ct-import-export"},(0,e.createElement)("div",{className:"ct-title","data-type":"simple"},(0,e.createElement)("h3",null,(0,r.__)("Export Options","blocksy-companion")),(0,e.createElement)("div",{className:"ct-option-description"},(0,r.__)("Easily export the theme customizer settings.","blocksy-companion"))),(0,e.createElement)("div",{className:"ct-control","data-design":"block"},(0,e.createElement)("header",null),(0,e.createElement)("section",null,(0,e.createElement)("button",{className:"button-primary",onClick:function(e){e.preventDefault(),y(!0)}},(0,r.__)("Export Customizations","blocksy-companion")))),(0,e.createElement)("div",{className:"ct-title","data-type":"simple"},(0,e.createElement)("h3",null,(0,r.__)("Import Options","blocksy-companion")),(0,e.createElement)("div",{className:"ct-option-description"},(0,r.__)("Easily import the theme customizer settings.","blocksy-companion"))),(0,e.createElement)("div",{className:"ct-control","data-design":"block"},(0,e.createElement)("header",null),(0,e.createElement)("section",null,(0,e.createElement)("div",{className:"ct-file-upload"},(0,e.createElement)("div",{className:"ct-attachment"},(0,e.createElement)("button",{type:"button",className:i()("ct-upload-button",{active:d}),ref:O,onClick:function(){w.current.click()}},n?n.name:(0,r.__)("Click or drop to upload a file...","blocksy-companion"))),(0,e.createElement)("input",{ref:w,type:"file",onChange:function(e){var t=ge(e.target.files,1)[0];a(t)}}),(0,e.createElement)("button",{className:i()("button-primary",{"ct-loading":h}),disabled:!n,onClick:function(e){if(e.preventDefault(),n){v(!0);var t=new FileReader;t.readAsText(n,"UTF-8"),t.onload=function(e){try{fetch("".concat(window.ajaxurl,"?action=blocksy_customizer_import&wp_customize=on&nonce=").concat(ct_customizer_localizations.customizer_reset_none),{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(he()(e.target.result))}).then((function(e){200===e.status&&e.json().then((function(e){e.success,e.data;location.reload()}))}))}catch(e){}}}}},h?(0,e.createElement)("svg",{width:"14",height:"14",viewBox:"0 0 100 100"},(0,e.createElement)("g",{transform:"translate(50,50)"},(0,e.createElement)("g",{transform:"scale(1)"},(0,e.createElement)("circle",{cx:"0",cy:"0",r:"50",fill:"currentColor"}),(0,e.createElement)("circle",{cx:"0",cy:"-26",r:"12",fill:"var(--ui-accent-color)",transform:"rotate(161.634)"},(0,e.createElement)("animateTransform",{attributeName:"transform",type:"rotate",calcMode:"linear",values:"0 0 0;360 0 0",keyTimes:"0;1",dur:"1s",begin:"0s",repeatCount:"indefinite"}))))):(0,r.__)("Import Customizations","blocksy-companion"))))),ct_customizer_localizations.has_child_theme&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:"ct-title","data-type":"simple"},(0,e.createElement)("h3",null,(0,r.__)("Copy Options","blocksy-companion")),(0,e.createElement)("div",{className:"ct-option-description"},(0,r.__)("Copy and import your customizations from parent or child theme.","blocksy-companion"))),ct_customizer_localizations.is_parent_theme&&(0,e.createElement)("div",{className:"ct-control","data-design":"block"},(0,e.createElement)("header",null),(0,e.createElement)("section",null,(0,e.createElement)("button",{className:"button-primary",onClick:function(e){e.preventDefault(),u("child")}},(0,r.__)("Copy From Child Theme","blocksy-companion")))),!ct_customizer_localizations.is_parent_theme&&(0,e.createElement)("div",{className:"ct-control","data-design":"block"},(0,e.createElement)("header",null),(0,e.createElement)("section",null,(0,e.createElement)("button",{className:"button-primary",onClick:function(e){e.preventDefault(),u("parent")}},(0,r.__)("Copy From Parent Theme","blocksy-companion"))))),(0,e.createElement)(o.Overlay,{items:l,className:"ct-admin-modal ct-import-export-modal",onDismiss:function(){return u(!1)},render:function(){return(0,e.createElement)("div",{className:"ct-modal-content"},(0,e.createElement)("h2",{className:"ct-modal-title"},!ct_customizer_localizations.is_parent_theme&&(0,r.__)("Copy From Parent Theme","blocksy-companion"),ct_customizer_localizations.is_parent_theme&&(0,r.__)("Copy From Child Theme","blocksy-companion")),(0,e.createElement)("p",null,!ct_customizer_localizations.is_parent_theme&&(0,r.__)("You are about to copy all the settings from your parent theme into the child theme. Are you sure you want to continue?","blocksy-companion"),ct_customizer_localizations.is_parent_theme&&(0,r.__)("You are about to copy all the settings from your child theme into the parent theme. Are you sure you want to continue?","blocksy-companion")),(0,e.createElement)("div",{className:"ct-modal-actions has-divider","data-buttons":"2"},(0,e.createElement)("button",{onClick:function(e){e.preventDefault(),e.stopPropagation(),u(!1)},className:"button"},(0,r.__)("Cancel","blocksy-companion")),(0,e.createElement)("button",{className:"button button-primary",onClick:function(e){e.preventDefault();var t=new FormData;t.append("action","blocksy_customizer_copy_options"),t.append("wp_customize","on"),t.append("strategy",l);try{fetch(window.ajaxurl,{method:"POST",body:t}).then((function(e){200===e.status&&e.json().then((function(e){e.success,e.data;location.reload()}))}))}catch(e){}}},(0,r.__)("Yes, I am sure","blocksy-companion"))))}}),(0,e.createElement)(o.Overlay,{items:m,className:"ct-admin-modal ct-export-modal",onDismiss:function(){return y(!1)},render:function(){return(0,e.createElement)("div",{className:"ct-modal-content"},(0,e.createElement)("h2",{className:"ct-modal-title"},(0,r.__)("Export Settings","blocksy-companion")),(0,e.createElement)("p",null,(0,r.__)("Choose what set of settings you want to export.","blocksy-companion")),(0,e.createElement)("div",{className:"ct-checkboxes-container","data-type":"grid:bordered"},["options","widgets"].map((function(t){return(0,e.createElement)("div",{className:"ct-checkbox-container",onClick:function(){1===_.length&&_[0]===t||E((function(e){return e.includes(t)?e.filter((function(e){return e!==t})):[].concat(ve(e),[t])}))}},(0,e.createElement)("span",{className:i()("ct-checkbox",{active:_.includes(t)})},(0,e.createElement)("svg",{width:"10",height:"8",viewBox:"0 0 11.2 9.1"},(0,e.createElement)("polyline",{className:"check",points:"1.2,4.8 4.4,7.9 9.9,1.2 "}))),{options:(0,r.__)("Customizer settings","blocksy-companion"),widgets:(0,r.__)("Widgets settings","blocksy-companion")}[t])}))),(0,e.createElement)("div",{className:"ct-modal-actions has-divider","data-buttons":"2"},(0,e.createElement)("button",{onClick:function(e){e.preventDefault(),e.stopPropagation(),y(!1)},className:"button"},(0,r.__)("Cancel","blocksy-companion")),(0,e.createElement)("button",{className:"button button-primary",onClick:function(e){e.preventDefault();var t=new FormData;t.append("action","blocksy_customizer_export"),t.append("strategy",_.join(":")),t.append("wp_customize","on");try{fetch(window.ajaxurl,{method:"POST",body:t}).then((function(e){200===e.status&&e.json().then((function(e){var t=e.success,n=e.data;if(t){var r=new Blob([n.data],{type:"application/octet-stream;charset=utf-8"});ye()(r,"".concat(n.site_url.replace("http://","").replace("https://","").replace(".","-").replace("/","-"),"-export.dat")),y(!1)}}))}))}catch(e){}}},(0,r.__)("Export","blocksy-companion"))))}}))},Oe=window.ctEvents,je=n.n(Oe),ke=window.wp.hooks,Se=n(459),Ce=n.n(Se),xe=n(616),Ae=n.n(xe),Pe=n(382),Ne=n.n(Pe);function De(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Te(e){return function(e){if(Array.isArray(e))return ze(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||Le(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ie(e,t,n,r,o,a,i){try{var c=e[a](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,o)}function Me(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,a=void 0;try{for(var i,c=e[Symbol.iterator]();!(r=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){o=!0,a=e}finally{try{r||null==c.return||c.return()}finally{if(o)throw a}}return n}(e,t)||Le(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Le(e,t){if(e){if("string"==typeof e)return ze(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ze(e,t):void 0}}function ze(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Re=Ae()(),Ue=function(t){t.forcedEdit;var n,a,i=t.headerId,c=Me((0,e.useState)(!1),2),l=c[0],u=c[1],s=Me((0,e.useState)(null),2),d=s[0],p=s[1],f=(0,e.useContext)(o.PlacementsDragDropContext),m=(f.builderValueCollection,f.builderValueDispatch,(0,e.useRef)()),y=Ne()(Re),b=Ce()("".concat(blocksy_admin.ajax_url,"?action=blocksy_header_get_all_conditions"),{method:"POST",formatter:(n=regeneratorRuntime.mark((function e(t){var n,r,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:if(n=e.sent,r=n.success,o=n.data,r&&o.conditions){e.next=7;break}throw new Error;case 7:return e.abrupt("return",o.conditions);case 8:case"end":return e.stop()}}),e)})),a=function(){var e=this,t=arguments;return new Promise((function(r,o){var a=n.apply(e,t);function i(e){Ie(a,r,o,i,c,"next",e)}function c(e){Ie(a,r,o,i,c,"throw",e)}i(void 0)}))},function(e){return a.apply(this,arguments)}),depends:[y]}),h=b.data,v=b.isLoading;b.error;return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("button",{className:"button-primary",style:{width:"100%"},onClick:function(e){e.preventDefault(),e.stopPropagation(),v||u(!0)}},(0,r.__)("Add/Edit Conditions","blocksy-companion")),(0,e.createElement)(o.Overlay,{items:l,initialFocusRef:m,className:"ct-admin-modal ct-builder-conditions-modal",onDismiss:function(){u(!1),p(null)},render:function(){var t;return(0,e.createElement)("div",{className:"ct-modal-content",ref:m},(0,e.createElement)("h2",null,sprintf((0,r.__)("Display Conditions","blocksy-companion"))),(0,e.createElement)("p",null,(0,r.__)("Add one or more conditions in order to display your header.","blocksy-companion")),(0,e.createElement)("div",{className:"ct-modal-scroll"},(0,e.createElement)(o.OptionsPanel,{onChange:function(e,t){p((function(e){return[].concat(Te((e||h).filter((function(e){return e.id!==i}))),[{id:i,conditions:t}])}))},options:{conditions:(t={type:"blocksy-display-condition",design:"none",value:[]},De(t,"design","none"),De(t,"label",!1),t)},value:{conditions:((d||h).find((function(e){return e.id===i}))||{conditions:[]}).conditions},hasRevertButton:!1})),(0,e.createElement)("div",{className:"ct-modal-actions has-divider"},(0,e.createElement)("button",{className:"button-primary",disabled:!d,onClick:function(){fetch("".concat(wp.ajax.settings.url,"?action=blocksy_header_update_all_conditions"),{headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST",body:JSON.stringify(d)}).then((function(e){return e.json()})).then((function(){Re(),u(!1)}))}},(0,r.__)("Save Conditions","blocksy-companion"))))}}))};function Fe(){return Fe=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Fe.apply(this,arguments)}function Be(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function He(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Be(Object(n),!0).forEach((function(t){Ve(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Ve(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $e(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,a=void 0;try{for(var i,c=e[Symbol.iterator]();!(r=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){o=!0,a=e}finally{try{r||null==c.return||c.return()}finally{if(o)throw a}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return qe(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return qe(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function qe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ye=function(){var n=$e((0,e.useState)(!1),2),a=n[0],c=n[1],l=(ct_customizer_localizations.header_builder_data.secondary_items.header,ct_customizer_localizations.header_builder_data.header,(0,e.useContext)(o.PlacementsDragDropContext)),u=l.builderValueDispatch,s=l.builderValue,d=(l.option,l.builderValueCollection),p=l.panelsActions,f=(0,ke.applyFilters)("blocksy.header.available-sections",null,d.sections)||d.sections.filter((function(e){var t=e.id;return"type-2"!==t&&"type-3"!==t&&-1===t.indexOf("ct-custom")}));return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("ul",{className:i()("ct-panels-manager")},f.map((function(t){var n=t.name,a=t.id,l=n||{"type-1":(0,r.__)("Global Header","blocksy-companion")}[a]||a,d="builder_header_panel_".concat(a),f=ct_customizer_localizations.header_builder_data.header_data.header_options,m={label:l,"inner-options":He(He({},a.indexOf("ct-custom")>-1?{conditions_button:{label:(0,r.__)("Edit Conditions","blocksy-companion"),type:"jsx",design:"block",render:function(){return(0,e.createElement)(Ue,{headerId:a})}},divider:{type:"ct-divider"}}:{}),f)};return(0,e.createElement)(o.PanelMetaWrapper,Fe({id:d,key:a,option:m},p,{getActualOption:function(t){var n=t.open;return(0,e.createElement)(e.Fragment,null,a===s.id&&(0,e.createElement)(o.Panel,{id:d,getValues:function(){return He({id:a},s.settings||{})},option:m,onChangeFor:function(e,t){u({type:"BUILDER_GLOBAL_SETTING_ON_CHANGE",payload:{optionId:e,optionValue:t,values:(0,o.getValueFromInput)(f,Array.isArray(s.settings)?{}:s.settings||{})}})},view:"simple"}),(0,e.createElement)("li",{className:i()({active:a===s.id,"ct-global":"type-1"===a}),onClick:function(){a===s.id?n():u({type:"PICK_BUILDER_SECTION",payload:{id:a}})}},(0,e.createElement)("span",{className:"ct-panel-name"},l),a.indexOf("ct-custom")>-1&&a!==s.id&&(0,e.createElement)("span",{className:"ct-remove-instance","data-tooltip":"top",onClick:function(e){e.preventDefault(),e.stopPropagation(),c(a)}},(0,e.createElement)("svg",{width:"11px",height:"11px",viewBox:"0 0 24 24"},(0,e.createElement)("path",{d:"M9.6,0l0,1.2H1.2v2.4h21.6V1.2h-8.4l0-1.2H9.6z M2.8,6l1.8,15.9C4.8,23.1,5.9,24,7.1,24h9.9c1.2,0,2.2-0.9,2.4-2.1L21.2,6H2.8z"})),(0,e.createElement)("i",{className:"ct-tooltip"},(0,r.__)("Remove header","blocksy-companion")))))}}))}))),(0,e.createElement)(t.Slot,{name:"PlacementsBuilderPanelsManagerAfter"},(function(e){return 0===e.length?null:e})),(0,e.createElement)(o.Overlay,{items:a,className:"ct-admin-modal ct-reset-options",onDismiss:function(){return c(!1)},render:function(){return(0,e.createElement)("div",{className:"ct-modal-content"},(0,e.createElement)("h2",{className:"ct-modal-title"},(0,r.__)("Remove Header","blocksy-companion")),(0,e.createElement)("p",null,(0,r.__)("You are about to remove a custom header, are you sure you want to continue?","blocksy-companion")),(0,e.createElement)("div",{className:"ct-modal-actions has-divider","data-buttons":"2"},(0,e.createElement)("button",{onClick:function(e){e.preventDefault(),e.stopPropagation(),c(!1)},className:"button"},(0,r.__)("Cancel","blocksy-companion")),(0,e.createElement)("button",{className:"button button-primary",onClick:function(e){e.preventDefault(),u({type:"REMOVE_BUILDER_SECTION",payload:{id:a}}),c(!1)}},(0,r.__)("Confirm","blocksy-companion"))))}}))};je().on("blocksy:options:before-option",(function(n){if(n.option&&"ct-header-builder"===n.option.type){var r=n.content;n.content=(0,e.createElement)(e.Fragment,null,r,(0,e.createElement)(t.Fill,{name:"PlacementsBuilderPanelsManager"},(0,e.createElement)(Ye,null)))}})),je().on("blocksy:options:register",(function(e){e["blocksy-display-condition"]=fe,e["blocksy-customizer-options-manager"]=we}))}()}();