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