(()=>{"use strict";const e=window.wp.blocks,s=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"seopulse/faq","version":"3.0.0","title":"SEOPulse FAQ","category":"text","description":"FAQ block with automatic FAQPage structured data (JSON-LD).","keywords":["faq","schema","structured data","seo"],"textdomain":"seopulse","attributes":{"items":{"type":"array","default":[],"items":{"type":"object"}},"schemaType":{"type":"string","default":"FAQPage","enum":["FAQPage","QAPage"]}},"supports":{"html":false,"align":["wide","full"],"anchor":true,"className":true},"editorScript":"file:../../../build/faq-block.js","editorStyle":"file:../../../build/faq-block.css","style":"file:../../../build/faq-block.css"}'),l=window.wp.element,a=window.wp.i18n,t=window.wp.blockEditor,o=window.wp.components,i=window.ReactJSXRuntime;(0,e.registerBlockType)(s.name,{...s,icon:"editor-help",edit:({attributes:e,setAttributes:s})=>{const{items:n,schemaType:c}=e,r=(0,t.useBlockProps)({className:"wp-block-seopulse-faq"}),p=(0,l.useCallback)((e,l,a)=>{const t=n.map((s,t)=>t===e?{...s,[l]:a}:s);s({items:t})},[n,s]),u=(0,l.useCallback)(()=>{s({items:[...n,{question:"",answer:""}]})},[n,s]),d=(0,l.useCallback)(e=>{s({items:n.filter((s,l)=>l!==e)})},[n,s]),m=(0,l.useCallback)((e,l)=>{const a=e+l;if(a<0||a>=n.length)return;const t=[...n];[t[e],t[a]]=[t[a],t[e]],s({items:t})},[n,s]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t.InspectorControls,{children:(0,i.jsxs)(o.PanelBody,{title:(0,a.__)("FAQ Settings","seopulse"),children:[(0,i.jsx)(o.SelectControl,{__next40pxDefaultSize:!0,label:(0,a.__)("Schema Type","seopulse"),value:c,options:[{label:"FAQPage",value:"FAQPage"},{label:"QAPage",value:"QAPage"}],onChange:e=>s({schemaType:e}),__nextHasNoMarginBottom:!0}),(0,i.jsxs)("p",{className:"components-base-control__help",children:[(0,a.__)("Items:","seopulse")," ",n.length]})]})}),(0,i.jsxs)("div",{...r,children:[(0,i.jsxs)("div",{className:"wp-block-seopulse-faq__header",children:[(0,i.jsx)("span",{className:"wp-block-seopulse-faq__icon","aria-hidden":"true",children:"❓"}),(0,i.jsx)("span",{className:"wp-block-seopulse-faq__title",children:(0,a.__)("SEOPulse FAQ","seopulse")})]}),0===n.length&&(0,i.jsx)("p",{className:"wp-block-seopulse-faq__empty",children:(0,a.__)('No FAQ items yet. Click "Add FAQ" to get started.',"seopulse")}),n.map((e,s)=>(0,i.jsxs)("div",{className:"wp-block-seopulse-faq__item","aria-label":`${(0,a.__)("FAQ item","seopulse")} ${s+1}`,children:[(0,i.jsxs)("div",{className:"wp-block-seopulse-faq__item-header",children:[(0,i.jsxs)("span",{className:"wp-block-seopulse-faq__item-number",children:[s+1,"."]}),(0,i.jsxs)("div",{className:"wp-block-seopulse-faq__item-actions",children:[(0,i.jsx)(o.Button,{icon:"arrow-up-alt2",label:(0,a.__)("Move up","seopulse"),onClick:()=>m(s,-1),disabled:0===s,isSmall:!0}),(0,i.jsx)(o.Button,{icon:"arrow-down-alt2",label:(0,a.__)("Move down","seopulse"),onClick:()=>m(s,1),disabled:s===n.length-1,isSmall:!0}),(0,i.jsx)(o.Button,{icon:"trash",label:(0,a.__)("Remove","seopulse"),onClick:()=>d(s),isSmall:!0,isDestructive:!0})]})]}),(0,i.jsx)("div",{className:"wp-block-seopulse-faq__question",children:(0,i.jsx)(t.RichText,{tagName:"p",value:e.question,onChange:e=>p(s,"question",e),placeholder:(0,a.__)("Question…","seopulse"),allowedFormats:[],"aria-label":`${(0,a.__)("Question","seopulse")} ${s+1}`})}),(0,i.jsx)("div",{className:"wp-block-seopulse-faq__answer",children:(0,i.jsx)(t.RichText,{tagName:"div",value:e.answer,onChange:e=>p(s,"answer",e),placeholder:(0,a.__)("Answer…","seopulse"),allowedFormats:["core/bold","core/italic","core/link","core/list"],"aria-label":`${(0,a.__)("Answer","seopulse")} ${s+1}`})})]},s)),(0,i.jsx)(o.Button,{variant:"secondary",onClick:u,className:"wp-block-seopulse-faq__add-btn",icon:"plus-alt2",children:(0,a.__)("Add FAQ","seopulse")}),(0,i.jsx)("div",{className:"wp-block-seopulse-faq__schema-badge",children:(0,i.jsxs)("small",{children:[(0,a.__)("Schema:","seopulse")," ",c," ·"," ",n.length," ",1===n.length?(0,a.__)("item","seopulse"):(0,a.__)("items","seopulse")]})})]})]})},save:({attributes:e})=>{const{items:s}=e,l=t.useBlockProps.save({className:"wp-block-seopulse-faq"});return 0===s.length?null:(0,i.jsx)("div",{...l,children:s.map((e,s)=>e.question&&e.answer?(0,i.jsxs)("details",{className:"wp-block-seopulse-faq__item",children:[(0,i.jsx)("summary",{className:"wp-block-seopulse-faq__question",children:(0,i.jsx)(t.RichText.Content,{tagName:"span",value:e.question})}),(0,i.jsx)("div",{className:"wp-block-seopulse-faq__answer",children:(0,i.jsx)(t.RichText.Content,{tagName:"div",value:e.answer})})]},s):null)})}})})();