(()=>{"use strict";var e,s={604(){const e=window.wp.blocks,s=window.wp.blockEditor,n=window.wp.components,i=window.wp.i18n,o=window.wp.element,t=window.ReactJSXRuntime;(0,e.registerBlockType)("jvb/faq",{edit:function({attributes:e,setAttributes:l}){const{sectionOrder:a,showSectionTitles:c,collapseByDefault:r}=e,[d,h]=(0,o.useState)([]),p=window.jvbFaq?.sections||[];(0,o.useEffect)(()=>{if(p.length)if(0===a.length){const e=p.map(e=>({id:e.id,name:e.name}));h(e),l({sectionOrder:e.map(e=>e.id)})}else{const e=[],s=new Set(a);a.forEach(s=>{const n=p.find(e=>e.id===s);n&&e.push({id:n.id,name:n.name})}),p.forEach(n=>{s.has(n.id)||e.push({id:n.id,name:n.name})}),h(e)}},[p,a]);const b=(e,s)=>{const n=[...d],i="up"===s?e-1:e+1;i<0||i>=n.length||([n[e],n[i]]=[n[i],n[e]],h(n),l({sectionOrder:n.map(e=>e.id)}))},v=(0,s.useBlockProps)({className:"faq-block-editor"});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(s.InspectorControls,{children:[(0,t.jsxs)(n.PanelBody,{title:(0,i.__)("FAQ Settings","jvb"),initialOpen:!0,children:[(0,t.jsx)(n.ToggleControl,{label:(0,i.__)("Show Section Titles","jvb"),checked:c,onChange:e=>l({showSectionTitles:e}),help:(0,i.__)("Display section names as headings","jvb")}),(0,t.jsx)(n.ToggleControl,{label:(0,i.__)("Collapse by Default","jvb"),checked:r,onChange:e=>l({collapseByDefault:e}),help:(0,i.__)("Questions start collapsed and expand on click","jvb")})]}),(0,t.jsxs)(n.PanelBody,{title:(0,i.__)("Section Order","jvb"),initialOpen:!1,children:[(0,t.jsx)("p",{className:"components-base-control__help",children:(0,i.__)("Use the arrow buttons to reorder sections","jvb")}),d.length>0?(0,t.jsx)("div",{className:"faq-section-list",children:d.map((e,s)=>(0,t.jsxs)("div",{className:"faq-section-item",children:[(0,t.jsxs)("div",{className:"faq-section-controls",children:[(0,t.jsx)(n.Button,{icon:"arrow-up-alt2",label:(0,i.__)("Move up","jvb"),disabled:0===s,onClick:()=>b(s,"up"),className:"faq-section-button"}),(0,t.jsx)(n.Button,{icon:"arrow-down-alt2",label:(0,i.__)("Move down","jvb"),disabled:s===d.length-1,onClick:()=>b(s,"down"),className:"faq-section-button"})]}),(0,t.jsx)("span",{className:"faq-section-name",children:e.name})]},e.id))}):(0,t.jsx)(n.Notice,{status:"info",isDismissible:!1,children:(0,i.__)("No sections found. Create sections in the FAQ taxonomy.","jvb")})]})]}),(0,t.jsx)("div",{...v,children:(0,t.jsxs)("div",{className:"faq-block-preview",children:[(0,t.jsx)("h3",{children:(0,i.__)("FAQ Block","jvb")}),(0,t.jsx)("p",{children:(0,i.__)("This block will display FAQs organized by sections.","jvb")}),d.length>0?(0,t.jsxs)("div",{className:"faq-sections-preview",children:[(0,t.jsx)("strong",{children:(0,i.__)("Section Order:","jvb")}),(0,t.jsx)("ol",{children:d.map(e=>(0,t.jsx)("li",{children:e.name},e.id))})]}):(0,t.jsx)(n.Notice,{status:"warning",isDismissible:!1,children:(0,i.__)("No sections available. Create sections in the FAQ taxonomy.","jvb")})]})})]})},save:()=>null})}},n={};function i(e){var o=n[e];if(void 0!==o)return o.exports;var t=n[e]={exports:{}};return s[e](t,t.exports,i),t.exports}i.m=s,e=[],i.O=(s,n,o,t)=>{if(!n){var l=1/0;for(d=0;d=t)&&Object.keys(i.O).every(e=>i.O[e](n[c]))?n.splice(c--,1):(a=!1,t0&&e[d-1][2]>t;d--)e[d]=e[d-1];e[d]=[n,o,t]},i.o=(e,s)=>Object.prototype.hasOwnProperty.call(e,s),(()=>{var e={456:0,656:0};i.O.j=s=>0===e[s];var s=(s,n)=>{var o,t,[l,a,c]=n,r=0;if(l.some(s=>0!==e[s])){for(o in a)i.o(a,o)&&(i.m[o]=a[o]);if(c)var d=c(i)}for(s&&s(n);ri(604));o=i.O(o)})();