"use strict";(globalThis.webpackChunkplugin_slug=globalThis.webpackChunkplugin_slug||[]).push([[175],{9175:(e,a,t)=>{t.r(a),t.d(a,{default:()=>m});var l=t(1609),c=t.n(l),n=t(7723),s=t(937),r=t(5698),o=t(4715);const i=({tag:e="p",placeholder:a=(0,n.__)("Enter text...","section-collection"),value:t="",isBackend:s=!1,onChange:r=()=>{},className:i=""})=>s?(0,l.createElement)(o.RichText,{tagName:e,className:i,placeholder:a,value:t,onChange:r}):t&&c().createElement(e,{className:i,dangerouslySetInnerHTML:{__html:t}}),m=({attributes:e,setAttributes:a,isBackend:t=!1})=>{const[c,o]=(0,l.useState)("all"),[m,u]=(0,l.useState)(""),[g,d]=(0,l.useState)(null),{faqData:h=[],faqHeader:p={}}=e||{},E=(0,l.useCallback)((e=>{d((a=>a===e?null:e))}),[]),v=(0,l.useCallback)((()=>u("")),[]),N=(0,l.useMemo)((()=>{const e=m.toLowerCase();return h.filter((e=>"all"===c||e.category===c)).map((a=>({...a,items:a.items.filter((a=>a.question.toLowerCase().includes(e)||a.answer.toLowerCase().includes(e)))}))).filter((e=>e.items.length>0))}),[h,c,m]);return(0,l.useEffect)((()=>{d(null)}),[c,m]),(0,l.createElement)("div",{className:"bpl-sc-mfaq-section"},(0,l.createElement)("div",{className:"faq-container"},(0,l.createElement)("div",{className:"faq-header"},(0,l.createElement)(i,{tag:"h1",placeholder:(0,n.__)("title...","section-collection"),isBackend:t,value:p.title,onChange:e=>a({faqHeader:(0,r.O)(p,e,"title")})}),(0,l.createElement)(i,{isBackend:t,tagName:"p",placeholder:(0,n.__)("sub title...","section-collection"),value:p.subTitle,onChange:e=>a({faqHeader:(0,r.O)(p,e,"subTitle")})}),(0,l.createElement)("div",{className:"search-container"},(0,l.createElement)("div",{className:"search-box"},(0,l.createElement)(s.KSO,{className:"search-icon"}),(0,l.createElement)("input",{type:"text",value:m,placeholder:"Search questions...",onChange:e=>u(e.target.value)}),m&&(0,l.createElement)("button",{className:"clear-search visible",onClick:v,title:"Clear search"},(0,l.createElement)(s.QCr,null)))),(0,l.createElement)("div",{className:"category-filter"},(0,l.createElement)("button",{className:"category-btn "+("all"===c?"active":""),onClick:()=>o("all"),"data-category":"all"},"All"),h.map((e=>(0,l.createElement)("button",{key:e.category,className:"category-btn "+(c===e.category?"active":""),onClick:()=>o(e.category),"data-category":e.category},e.category.charAt(0).toUpperCase()+e.category.slice(1)))))),(0,l.createElement)("div",{className:"faq-content"},N.length>0?N.map(((e,c)=>(0,l.createElement)("div",{className:"faq-category",key:e.category||c,"data-category":e.category},(0,l.createElement)(i,{tag:"h2",placeholder:(0,n.__)("category name...","section-collection"),value:e.title,isBackend:t,onChange:e=>a({faqData:(0,r.O)(h,e,c,"title")})}),e.items.map(((e,o)=>{const m=`${c}-${o}`,u=g===m;return(0,l.createElement)("div",{className:"faq-item "+(u?"active":""),key:m},(0,l.createElement)("div",{className:"faq-question",onClick:()=>E(m)},(0,l.createElement)(i,{isBackend:t,tag:"h3",placeholder:(0,n.__)("question...","section-collection"),value:e.question,onChange:e=>a({faqData:(0,r.O)(h,e,c,"items",o,"question")})}),(0,l.createElement)("span",{className:"faq-icon"},(0,l.createElement)(s.OiG,{className:"plus-icon"}))),(0,l.createElement)("div",{className:"faq-answer "+(u?"active":"")},(0,l.createElement)(i,{isBackend:t,tagName:"p",placeholder:(0,n.__)("answer...","section-collection"),value:e.answer,onChange:e=>a({faqData:(0,r.O)(h,e,c,"items",o,"answer")})})))}))))):(0,l.createElement)(i,{isBackend:t,tagName:"p",className:"no-data-message",placeholder:(0,n.__)("No FAQ available","section-collection"),value:p.noDataMessage,onChange:e=>a({faqHeader:(0,r.O)(p,e,"noDataMessage")})}))))}}}]);