File: /home/slyfwmm/adspray/wp-content/plugins/lazy-blocks/build/admin-tools.js
(()=>{"use strict";const e=window.wp.element,t=window.wp.i18n,n=window.wp.components;function l(e){var n=e.children;return wp.element.createElement("div",{className:"lazyblocks-component-copied"},n||(0,t.__)("Copied!","lazy-blocks"))}function o(e){return o="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},o(e)}function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,l)}return n}function r(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==o(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var l=n.call(e,"string");if("object"!==o(l))return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===o(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var l,o,_x,a,r=[],_n=!0,c=!1;try{if(_x=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;_n=!1}else for(;!(_n=(l=_x.call(n)).done)&&(r.push(l.value),r.length!==t);_n=!0);}catch(e){c=!0,o=e}finally{try{if(!_n&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return i(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)?i(e,t):void 0}}(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 i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,l=new Array(t);n<t;n++)l[n]=e[n];return l}var s=window,m=s.navigator,p=s.lazyblocksToolsData;function u(){var o=c((0,e.useState)(!1),2),i=o[0],s=o[1],u=c((0,e.useState)(!1),2),d=u[0],b=u[1],w=c((0,e.useState)({}),2),y=w[0],h=w[1],f=c((0,e.useState)({}),2),E=f[0],v=f[1],k=c((0,e.useState)(!1),2),g=k[0],_=k[1],x=c((0,e.useState)(!1),2),N=x[0],S=x[1],O={showBlocksPHP:i,showTemplatesPHP:d},z={disabledBlocks:y,disabledTemplates:E},j={copiedBlocks:g,copiedTemplates:N},P=(0,e.useRef)({});function T(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"blocks",t=e.charAt(0).toUpperCase()+e.slice(1),n=window.location.href;return p[e].forEach((function(l){z["disabled".concat(t)][l.data.id]||(n+="&lazyblocks_export_".concat(e,"[]=").concat(l.data.id))})),n}function C(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"blocks",t=e.charAt(0).toUpperCase()+e.slice(1),n="";return p[e].forEach((function(e){z["disabled".concat(t)][e.data.id]||(n+=e.php_string_code)})),n&&(n="add_action( 'lzb/init', function() {\n".concat(n,"\n} );")),n}function B(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"blocks",o=e.charAt(0).toUpperCase()+e.slice(1),c=Object.keys(z["disabled".concat(o)]).length===p[e].length;return wp.element.createElement(wp.element.Fragment,null,wp.element.createElement("div",{className:"lzb-export-select-items"},wp.element.createElement(n.BaseControl,null,wp.element.createElement(n.ToggleControl,{label:(0,t.__)("Select all","lazy-blocks"),checked:0===Object.keys(z["disabled".concat(o)]).length,onChange:function(){var t={};0===Object.keys(z["disabled".concat(o)]).length&&p[e].forEach((function(e){t[e.data.id]=!0})),"Blocks"===o?h(t):"Templates"===o&&v(t)}}),p[e].map((function(t){var l=!z["disabled".concat(o)][t.data.id];return wp.element.createElement(n.ToggleControl,{key:t.data.id,label:wp.element.createElement(wp.element.Fragment,null,"blocks"===e?wp.element.createElement(wp.element.Fragment,null,t.data.icon&&/^dashicons/.test(t.data.icon)?wp.element.createElement("span",{className:t.data.icon}):"",t.data.icon&&!/^dashicons/.test(t.data.icon)?wp.element.createElement("span",{dangerouslySetInnerHTML:{__html:t.data.icon}}):""," "):"",t.data.title),checked:l,onChange:function(){var e=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},z["disabled".concat(o)]);l&&!e[t.data.id]?e[t.data.id]=!0:l||void 0===e[t.data.id]||delete e[t.data.id],"Blocks"===o?h(e):"Templates"===o&&v(e)}})})))),O["show".concat(o,"PHP")]?wp.element.createElement(wp.element.Fragment,null,wp.element.createElement("div",{className:"lzb-export-textarea"},wp.element.createElement(n.TextareaControl,{className:"lzb-export-code",readOnly:!0,value:C(e)})),wp.element.createElement("div",{className:"lzb-export-buttons"},wp.element.createElement("button",{className:"button",onClick:function(){!function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"blocks",t=e.charAt(0).toUpperCase()+e.slice(1);m.clipboard.writeText(C(e)).then((function(){"Blocks"===t?_(!0):"Templates"===t&&S(!0),clearTimeout(P.current[t]),P.current[t]=setTimeout((function(){"Blocks"===t?_(!1):"Templates"===t&&S(!1)}),350)}))}(e)}},(0,t.__)("Copy to Clipboard","lazy-blocks"),j["copied".concat(o)]?wp.element.createElement(l,null):""))):wp.element.createElement("div",{className:"lzb-export-buttons"},wp.element.createElement("a",{className:"button button-primary",disabled:c,href:T(e)},(0,t.__)("Export JSON","lazy-blocks")),wp.element.createElement("button",{className:"button",onClick:function(){"Blocks"===o?s(!0):"Templates"===o&&b(!0)},disabled:c},(0,t.__)("Generate PHP","lazy-blocks"))))}return wp.element.createElement("div",{className:"metabox-holder"},wp.element.createElement("div",{className:"postbox-container"},wp.element.createElement("div",{id:"normal-sortables"},wp.element.createElement("div",{className:"postbox-container"},wp.element.createElement("div",{className:"postbox"},wp.element.createElement("h2",{className:"hndle"},wp.element.createElement("span",null,(0,t.__)("Export Blocks","lazy-blocks"))),p.blocks&&p.blocks.length?wp.element.createElement("div",{className:"inside"},wp.element.createElement("p",null,(0,t.__)("Select the blocks you would like to export and then select your export method. Use the download button to export to a .json file which you can then import to another Lazy Blocks installation. Use the generate button to export to PHP code which you can place in your theme.")),B("blocks")):wp.element.createElement("div",{className:"inside"},wp.element.createElement("p",null,(0,t.__)("There are no blocks to export.")))),wp.element.createElement("div",{className:"postbox"},wp.element.createElement("h2",{className:"hndle"},wp.element.createElement("span",null,(0,t.__)("Export Templates","lazy-blocks"))),p.templates&&p.templates.length?wp.element.createElement("div",{className:"inside"},wp.element.createElement("p",null,(0,t.__)("Select the templates you would like to export and then select your export method. Use the download button to export to a .json file which you can then import to another Lazy Blocks installation. Use the generate button to export to PHP code which you can place in your theme.")),B("templates")):wp.element.createElement("div",{className:"inside"},wp.element.createElement("p",null,(0,t.__)("There are no templates to export."))))),wp.element.createElement("div",{className:"postbox-container"},wp.element.createElement("div",{className:"postbox"},wp.element.createElement("h2",{className:"hndle"},wp.element.createElement("span",null,(0,t.__)("Import","lazy-blocks"))),wp.element.createElement("div",{className:"inside"},wp.element.createElement("p",null,(0,t.__)("Select the Lazy Blocks JSON file you would like to import. When you click the import button below, Lazy Blocks will import the blocks or templates.")),wp.element.createElement("form",{method:"post",encType:"multipart/form-data"},wp.element.createElement("div",{className:"lzb-export-select-items"},wp.element.createElement("input",{type:"file",name:"lzb_tools_import_json"})),wp.element.createElement("input",{type:"hidden",name:"lzb_tools_import_nonce",value:p.nonce}),wp.element.createElement("div",{className:"lzb-export-buttons"},wp.element.createElement("button",{className:"button button-primary"},(0,t.__)("Import","lazy-blocks"))))))))))}window.addEventListener("load",(function(){(0,e.render)(wp.element.createElement(u,null),document.querySelector(".lazyblocks-tools-page"))}))})();