(()=>{"use strict";var e={n:o=>{var t=o&&o.__esModule?()=>o.default:()=>o;return e.d(t,{a:t}),t},d:(o,t)=>{for(var l in t)e.o(t,l)&&!e.o(o,l)&&Object.defineProperty(o,l,{enumerable:!0,get:t[l]})},o:(e,o)=>Object.prototype.hasOwnProperty.call(e,o)};const o=window.wp.blocks,t=window.wp.blockEditor,l=window.wp.serverSideRender;var n=e.n(l);const a=window.wp.components,s=window.wp.element,r=window.wp.apiFetch;var i=e.n(r);const c=window.ReactJSXRuntime;function u({value:e,onChange:o,label:t}){const[l,n]=(0,s.useState)([]),[r,u]=(0,s.useState)(!1);function h(e){u(!0);const o=e?`/ggmc/v1/products/search?q=${encodeURIComponent(e)}`:"/ggmc/v1/products/search";i()({path:o}).then(e=>{n(e.map(e=>({value:e.id,label:e.sku?`${e.name} (${e.sku})`:e.name})))}).catch(()=>n([])).finally(()=>u(!1))}return(0,s.useEffect)(()=>{h("")},[]),(0,s.useEffect)(()=>{e&&!l.find(o=>o.value===e)&&i()({path:`/ggmc/v1/products/${e}`}).then(e=>{n(o=>o.find(o=>o.value===e.id)?o:[{value:e.id,label:e.sku?`${e.name} (${e.sku})`:e.name},...o])}).catch(()=>{})},[e]),(0,c.jsx)(a.ComboboxControl,{label:t||"Product",value:e,options:l,onChange:o,onFilterValueChange:e=>h(e),__nextHasNoMarginBottom:!0})}const h=JSON.parse('{"UU":"ggmc/review-list"}');(0,o.registerBlockType)(h.UU,{edit:({attributes:e,setAttributes:o})=>(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(t.InspectorControls,{children:(0,c.jsxs)(a.PanelBody,{title:"Content",children:[(0,c.jsx)(a.SelectControl,{label:"Product Source",value:e.productSource,options:[{label:"Current Product (Auto-detect)",value:"current"},{label:"Select Product",value:"custom"}],onChange:e=>o({productSource:e})}),"custom"===e.productSource&&(0,c.jsx)(u,{value:e.productId,onChange:e=>o({productId:e})}),(0,c.jsx)(a.__experimentalNumberControl,{label:"Reviews per Page",value:e.reviewsPerPage,min:1,max:50,onChange:e=>o({reviewsPerPage:parseInt(e)||5})}),(0,c.jsx)(a.SelectControl,{label:"Order By",value:e.orderby,options:[{label:"Date",value:"created_at"},{label:"Rating",value:"rating"},{label:"Most Helpful",value:"helpful_votes"}],onChange:e=>o({orderby:e})}),(0,c.jsx)(a.SelectControl,{label:"Order",value:e.order,options:[{label:"Descending",value:"DESC"},{label:"Ascending",value:"ASC"}],onChange:e=>o({order:e})}),(0,c.jsx)(a.ToggleControl,{label:"Show Section Title",checked:"yes"===e.showTitle,onChange:e=>o({showTitle:e?"yes":""})}),"yes"===e.showTitle&&(0,c.jsx)(a.TextControl,{label:"Section Title",value:e.sectionTitle,onChange:e=>o({sectionTitle:e})}),(0,c.jsx)(a.ToggleControl,{label:"Show Rating Summary",checked:"yes"===e.showSummary,onChange:e=>o({showSummary:e?"yes":""})}),(0,c.jsx)(a.ToggleControl,{label:"Show Review Title",checked:"yes"===e.showReviewTitle,onChange:e=>o({showReviewTitle:e?"yes":""})}),(0,c.jsx)(a.ToggleControl,{label:"Show Reviewer Name",checked:"yes"===e.showReviewerName,onChange:e=>o({showReviewerName:e?"yes":""})}),(0,c.jsx)(a.ToggleControl,{label:"Show Review Date",checked:"yes"===e.showDate,onChange:e=>o({showDate:e?"yes":""})}),(0,c.jsx)(a.ToggleControl,{label:"Show Verified Badge",checked:"yes"===e.showVerifiedBadge,onChange:e=>o({showVerifiedBadge:e?"yes":""})}),(0,c.jsx)(a.ToggleControl,{label:"Show Helpful Button",checked:"yes"===e.showHelpful,onChange:e=>o({showHelpful:e?"yes":""})}),(0,c.jsx)(a.ToggleControl,{label:"Show Pagination",checked:"yes"===e.showPagination,onChange:e=>o({showPagination:e?"yes":""})}),(0,c.jsx)(a.TextareaControl,{label:"No Reviews Text",value:e.noReviewsText,onChange:e=>o({noReviewsText:e})})]})}),(0,c.jsx)(n(),{block:h.UU,attributes:e})]}),save:()=>null})})();