!function(){"use strict";var e=window.wp.blocks,s=window.wp.element;const r=(0,s.createElement)("svg",{viewBox:"0 0 24 24",height:"24",width:"24"},(0,s.createElement)("path",{stroke:"#000","stroke-width":"1",fill:"none",d:"M1 20 L1 9 L16 9 L16 20 L1 20 Z M4 9 L4 6 L19 6 L19 17 L16 17 M7 6 L7 3 L22 3 L22 14 L19 14"}));var t=window.wp.i18n,l=window.wp.blockEditor,i=window.wp.components,d=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"bqworks/sliderpro","version":"1.0.0","title":"Slider Pro","category":"widgets","icon":"slides","description":"Insert a Slider Pro instance.","keywords":["sliderpro","slider","slides"],"attributes":{"sliderId":{"type":"integer","default":-1}},"supports":{"html":false,"customClassName":false},"example":{"attributes":{"sliderId":1}},"textdomain":"sliderpro","editorScript":"file:./index.js","editorStyle":"file:./index.css"}');(0,e.registerBlockType)(d,{icon:r,edit:function(e){const{attributes:d,setAttributes:a}=e,[n,o]=(0,s.useState)([]);void 0===window.sliderpro&&(window.sliderpro={sliders:[],slidersDataStatus:""});const c=e=>{const s=n.find((s=>s.value===e));return void 0!==s&&s};return(0,s.useEffect)((()=>{(()=>{if("loaded"===window.sliderpro.slidersDataStatus)o(window.sliderpro.sliders);else if("loading"===window.sliderpro.slidersDataStatus){const e=setInterval((function(){"loaded"===window.sliderpro.slidersDataStatus&&(clearInterval(e),o(window.sliderpro.sliders))}),100)}else window.sliderpro.slidersDataStatus="loading",new Promise((e=>{wp.apiFetch({path:"sliderpro/v1/sliders"}).then((function(s){let r=[];for(const e in s)r.push({label:`${s[e]} (${e})`,value:parseInt(e)});e(r)}))})).then((e=>{window.sliderpro.slidersDataStatus="loaded",window.sliderpro.sliders=e,o(e)}))})()}),[]),(0,s.createElement)("div",(0,l.useBlockProps)(),(0,s.createElement)(i.Placeholder,{label:"Slider Pro",icon:r},"loaded"!==window.sliderpro.slidersDataStatus?(0,s.createElement)("div",{className:"sp-gutenberg-slider-placeholder-content"}," ",(0,t.__)("Loading Slider Pro data...","sliderpro")," "):0===window.sliderpro.sliders.length?(0,s.createElement)("div",{className:"sp-gutenberg-slider-placeholder-content"}," ",(0,t.__)("You don't have any created sliders yet.","sliderpro")," "):!1===c(d.sliderId)?(0,s.createElement)("div",{className:"sp-gutenberg-slider-placeholder-content"}," ",(0,t.__)("Select a slider from the Block settings.","sliderpro")," "):(0,s.createElement)("div",{className:"sp-gutenberg-slider-placeholder-content"},(0,s.createElement)("p",{className:"sp-gutenberg-slider-identifier"}," ",(e=>{const s=c(e);return!1!==s?s.label:""})(d.sliderId)," "),(0,s.createElement)("a",{className:"sp-gutenberg-edit-slider",href:`${sp_gutenberg_js_vars.admin_url}?page=sliderpro&id=${d.sliderId}&action=edit`,target:"_blank"}," ",(0,t.__)("Edit Slider","sliderpro")," "))),(0,s.createElement)(l.InspectorControls,null,(0,s.createElement)(i.SelectControl,{className:"sp-gutenberg-select-slider",label:(0,t.__)("Select a slider from the list:","sliderpro"),options:[{label:(0,t.__)("None","sliderpro"),value:-1},...n],value:d.sliderId,onChange:e=>a({sliderId:parseInt(e)})}),0===window.sliderpro.sliders.length&&(0,s.createElement)("p",{className:"sp-gutenberg-no-sliders-text",dangerouslySetInnerHTML:{__html:sprintf((0,t.__)('You don\'t have any created sliders yet. You can create and manage sliders in the <a href="%s" target="_blank">dedicated area</a>, and then use the block to load the sliders.',"sliderpro"),`${sp_gutenberg_js_vars.admin_url}?page=sliderpro`)}})))},save:function(e){const{attributes:r}=e;return(0,s.createElement)("div",l.useBlockProps.save(),-1!==r.sliderId&&`[sliderpro id="${r.sliderId}"]`)}})}();