(()=>{"use strict";const e=window.wp.blocks,t=window.wp.blockEditor,a=window.wp.components,l=window.wp.i18n,o=JSON.parse('{"UU":"gateway/gtx-context-select"}'),r=window.ReactJSXRuntime;(0,e.registerBlockType)(o.UU,{edit:({attributes:e,setAttributes:o})=>{const{contextName:n,arrayProperty:s,valueProperty:c,labelProperty:i,placeholder:d}=e,x=(0,t.useBlockProps)({className:"gateway-context-select"}),p=n&&s&&c&&i;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.InspectorControls,{children:(0,r.jsxs)(a.PanelBody,{title:(0,l.__)("Context Select Settings","gateway"),children:[(0,r.jsx)(a.TextControl,{label:(0,l.__)("Context Name","gateway"),value:n,onChange:e=>o({contextName:e}),help:(0,l.__)("Enter the name of the context to read from (e.g., gateway/data-source-2)","gateway")}),(0,r.jsx)(a.TextControl,{label:(0,l.__)("Array Property","gateway"),value:s,onChange:e=>o({arrayProperty:e}),help:(0,l.__)("Property path to the array in the context (e.g., records, items)","gateway")}),(0,r.jsx)(a.TextControl,{label:(0,l.__)("Value Property","gateway"),value:c,onChange:e=>o({valueProperty:e}),help:(0,l.__)("Property path for the option value (e.g., id, slug)","gateway")}),(0,r.jsx)(a.TextControl,{label:(0,l.__)("Label Property","gateway"),value:i,onChange:e=>o({labelProperty:e}),help:(0,l.__)("Property path for the option label (e.g., title, name)","gateway")}),(0,r.jsx)(a.TextControl,{label:(0,l.__)("Placeholder","gateway"),value:d,onChange:e=>o({placeholder:e}),help:(0,l.__)("Placeholder text for the select box","gateway")})]})}),(0,r.jsx)("div",{...x,children:(0,r.jsxs)("div",{className:"gateway-context-select-editor",children:[(0,r.jsxs)("div",{className:"gateway-context-select-header",children:[(0,r.jsx)("h3",{children:(0,l.__)("GT Context Select","gateway")}),p?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("p",{children:[(0,l.__)("Context:","gateway")," ",(0,r.jsx)("strong",{children:n})]}),(0,r.jsxs)("p",{children:[(0,l.__)("Array:","gateway")," ",(0,r.jsx)("strong",{children:s})]}),(0,r.jsxs)("p",{children:[(0,l.__)("Value/Label:","gateway")," ",(0,r.jsx)("strong",{children:c})," / ",(0,r.jsx)("strong",{children:i})]})]}):(0,r.jsx)("p",{className:"gateway-context-select-notice",children:(0,l.__)("Configure context and properties in block settings →","gateway")})]}),(0,r.jsxs)("div",{className:"gateway-context-select-preview",children:[(0,r.jsx)("label",{className:"gateway-context-select-label",children:(0,l.__)("Select Box Preview:","gateway")}),(0,r.jsxs)("select",{className:"gateway-context-select-control",disabled:!0,children:[(0,r.jsx)("option",{children:d||(0,l.__)("Select an option...","gateway")}),(0,r.jsx)("option",{children:(0,l.__)("(Options will be loaded from context)","gateway")})]})]})]})})]})},save:({attributes:e})=>{const{contextName:t,arrayProperty:a,valueProperty:l,labelProperty:o,placeholder:n,selectedValue:s}=e;return(0,r.jsx)("div",{"data-wp-interactive":t||"gateway/context-select","data-wp-context":JSON.stringify({arrayProperty:a,valueProperty:l,labelProperty:o,placeholder:n,selectedValue:s||""}),children:(0,r.jsxs)("select",{"data-wp-on--change":"actions.handleChange","data-wp-bind--value":"context.selectedValue",className:"gateway-context-select-control",children:[(0,r.jsx)("option",{value:"","data-wp-text":"context.placeholder"}),(0,r.jsx)("template",{"data-wp-each--item":"state.options","data-wp-each-key":"context.item.value",children:(0,r.jsx)("option",{"data-wp-bind--value":"context.item.value","data-wp-text":"context.item.label"})})]})})}})})();