(()=>{"use strict";var e,o={20:(e,o,t)=>{var s=t(609),r=Symbol.for("react.element"),i=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),n=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function l(e,o,t){var s,l={},a=null,d=null;for(s in void 0!==t&&(a=""+t),void 0!==o.key&&(a=""+o.key),void 0!==o.ref&&(d=o.ref),o)i.call(o,s)&&!c.hasOwnProperty(s)&&(l[s]=o[s]);if(e&&e.defaultProps)for(s in o=e.defaultProps)void 0===l[s]&&(l[s]=o[s]);return{$$typeof:r,type:e,key:a,ref:d,props:l,_owner:n.current}}o.jsx=l,o.jsxs=l},314:(e,o,t)=>{const s=window.wp.blocks,r=window.wp.element,i=(0,r.forwardRef)((function({icon:e,size:o=24,...t},s){return(0,r.cloneElement)(e,{width:o,height:o,...t,ref:s})})),n=window.wp.primitives;var c=t(848);const l=(0,c.jsx)(n.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,c.jsx)(n.Path,{fillRule:"evenodd",d:"M5 5.5h14a.5.5 0 01.5.5v1.5a.5.5 0 01-.5.5H5a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 9.232A2 2 0 013 7.5V6a2 2 0 012-2h14a2 2 0 012 2v1.5a2 2 0 01-1 1.732V18a2 2 0 01-2 2H6a2 2 0 01-2-2V9.232zm1.5.268V18a.5.5 0 00.5.5h12a.5.5 0 00.5-.5V9.5h-13z",clipRule:"evenodd"})}),a=window.wc.wcSettings,d=JSON.parse('{"apiVersion":2,"name":"woocommerce-checkout-field-editor-pro/additional-sections","version":"2.0.0","title":"Additional Checkout Sections Block","category":"woocommerce","description":"Render additional Section.","supports":{"html":false,"align":false,"multiple":false,"reusable":false},"attributes":{"className":{"type":"string","default":""},"lock":{"type":"object","default":{"remove":true,"move":false}},"title":{"type":"string","default":"Additional Information"},"description":{"type":"string","default":"Additional Fields"}},"parent":["woocommerce/checkout-fields-block"],"textdomain":"woocommerce-checkout-field-editor-pro"}'),p=window.wp.blockEditor,u=window.wp.i18n;function h(e){var o,t,s="";if("string"==typeof e||"number"==typeof e)s+=e;else if("object"==typeof e)if(Array.isArray(e)){var r=e.length;for(o=0;onull}),window.wc.blocksComponents),_=({children:e,stepHeadingContent:o})=>(0,c.jsxs)("div",{className:"wc-block-components-checkout-step__heading",style:{pointerEvents:"none"},children:[(0,c.jsx)(w.Title,{"aria-hidden":"true",className:"wc-block-components-checkout-step__title",headingLevel:"2",children:e}),!!o&&(0,c.jsx)("span",{className:"wc-block-components-checkout-step__heading-content",children:o})]}),f=({attributes:e,setAttributes:o,className:t="",children:s})=>{const{showFormStepNumbers:i}=(0,r.useContext)(b),{title:n,description:l}=e,a=(0,p.useBlockProps)({className:m("wc-block-components-checkout-step wc-block-components-checkout-step--with-step-number",t,{"wc-block-components-checkout-step--with-step-number":i})});return(0,c.jsxs)("div",{...a,children:[(0,c.jsx)(_,{children:(0,c.jsx)(p.PlainText,{className:"",value:n,onChange:e=>o({title:e}),style:{backgroundColor:"transparent"}})}),(0,c.jsxs)("div",{className:"wc-block-components-checkout-step__container",children:[(0,c.jsx)("p",{className:"wc-block-components-checkout-step__description",children:(0,c.jsx)(p.PlainText,{className:l?"":"wc-block-components-checkout-step__description-placeholder",value:l,placeholder:(0,u.__)("Optional text for this form step.","woocommerce"),onChange:e=>o({description:e}),style:{backgroundColor:"transparent"}})}),(0,c.jsx)("div",{className:"wc-block-components-checkout-step__content",children:s})]})]})},k=(0,c.jsx)(n.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,c.jsx)(n.Path,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"})}),v=window.wp.data,g=window.wc.wcBlocksData,x=e=>{const{onChange:o,options:t,label:s,value:n="",className:l,size:a,errorId:d,required:p,errorMessage:h=(0,u.__)("Please select a valid option","woo-checkout-field-editor-pro"),placeholder:b,..._}=e,f=(0,r.useCallback)((e=>{o(e.target.value)}),[o]),x=(0,r.useMemo)((()=>({value:"",label:null!=b?b:(0,u.sprintf)( // translators: %s will be label of the field. For example "country/region". // translators: %s will be label of the field. For example "country/region". (0,u.__)("Select a %s","woo-checkout-field-editor-pro"),s?.toLowerCase()),disabled:!!p})),[s,b,p]),y=(0,r.useId)(),j=_.id||`wc-blocks-components-select-${y}`,N=d||j,C=(0,r.useMemo)((()=>p&&n?t:[x].concat(t)),[p,n,x,t]),{setValidationErrors:E,clearValidationError:O}=(0,v.useDispatch)(g.VALIDATION_STORE_KEY),{error:A,validationErrorId:I}=(0,v.useSelect)((e=>{const o=e(g.VALIDATION_STORE_KEY);return{error:o.getValidationError(N),validationErrorId:o.getValidationErrorId(N)}}));(0,r.useEffect)((()=>(!p||n?O(N):E({[N]:{message:h,hidden:!0}}),()=>{O(N)})),[O,n,N,h,p,E]);const T=(0,v.useSelect)((e=>e(g.VALIDATION_STORE_KEY).getValidationError(N||"")||{hidden:!0}));return(0,c.jsxs)("div",{className:m(l,{"has-error":!T.hidden}),children:[(0,c.jsx)("div",{className:"wc-blocks-components-select",children:(0,c.jsxs)("div",{className:"wc-blocks-components-select__container",children:[(0,c.jsx)("label",{htmlFor:j,className:"wc-blocks-components-select__label",children:s}),(0,c.jsx)("select",{className:"wc-blocks-components-select__select",id:j,size:void 0!==a?a:1,onChange:f,value:n,"aria-invalid":!(!A?.message||A?.hidden),"aria-errormessage":I,..._,children:C.map((e=>(0,c.jsx)("option",{value:e.value,"data-alternate-values":`[${e.label}]`,disabled:void 0!==e.disabled&&e.disabled,children:e.label},e.value)))},j),(0,c.jsx)(i,{className:"wc-blocks-components-select__expand",icon:k})]})}),(0,c.jsx)(w.ValidationInputError,{propertyName:N})]})};var y=t(609);const j=window.wp.compose,N=({label:e,secondaryLabel:o,description:t,secondaryDescription:s,id:r})=>(0,c.jsxs)("div",{className:"wc-block-components-radio-control__option-layout",children:[(0,c.jsxs)("div",{className:"wc-block-components-radio-control__label-group",children:[e&&(0,c.jsx)("span",{id:r&&`${r}__label`,className:"wc-block-components-radio-control__label",children:e}),o&&(0,c.jsx)("span",{id:r&&`${r}__secondary-label`,className:"wc-block-components-radio-control__secondary-label",children:o})]}),(t||s)&&(0,c.jsxs)("div",{className:"wc-block-components-radio-control__description-group",children:[t&&(0,c.jsx)("span",{id:r&&`${r}__description`,className:"wc-block-components-radio-control__description",children:t}),s&&(0,c.jsx)("span",{id:r&&`${r}__secondary-description`,className:"wc-block-components-radio-control__secondary-description",children:s})]})]}),C=({checked:e,name:o,onChange:t,option:s,disabled:r=!1,highlightChecked:i=!1})=>{const{value:n,label:l,description:a,secondaryLabel:d,secondaryDescription:p}=s;return(0,c.jsxs)("label",{className:m("wc-block-components-radio-control__option",{"wc-block-components-radio-control__option-checked":e,"wc-block-components-radio-control__option--checked-option-highlighted":e&&i}),htmlFor:`${o}-${n}`,children:[(0,c.jsx)("input",{id:`${o}-${n}`,className:"wc-block-components-radio-control__input",type:"radio",name:o,value:n,onChange:e=>t(e.target.value),checked:e,"aria-describedby":m({[`${o}-${n}__label`]:l,[`${o}-${n}__secondary-label`]:d,[`${o}-${n}__description`]:a,[`${o}-${n}__secondary-description`]:p}),"aria-disabled":r,onKeyDown:e=>{r&&["ArrowUp","ArrowDown","AllowLeft","ArrowRight"].includes(e.key)&&e.preventDefault()}}),(0,c.jsx)(N,{id:`${o}-${n}`,label:l,secondaryLabel:d,description:a,secondaryDescription:p})]})},E=({className:e="",id:o,selected:t="",onChange:s,options:r=[],disabled:i=!1,highlightChecked:n=!1,title:l="",required:a=!1,errorMessage:d=(0,u.__)("Please select an option","woo-checkout-field-editor-pro"),errorId:p})=>{const h=(0,j.useInstanceId)(E),b=o||h,_=p||b,{setValidationErrors:f,clearValidationError:k}=(0,v.useDispatch)(g.VALIDATION_STORE_KEY),x=(0,v.useSelect)((e=>e(g.VALIDATION_STORE_KEY).getValidationError(_)||{hidden:!0}));(0,y.useEffect)((()=>(!a||t?k(_):f({[_]:{message:d,hidden:!0}}),()=>{k(_)})),[t,a,_,d]);const N=(0,y.useMemo)((()=>r.findIndex((e=>e.value===t))),[r,t]);return r.length?(0,c.jsxs)("div",{className:m("wc-block-components-radio-control thwcfe-radio-control",{"has-error":!x.hidden,"wc-block-components-radio-control--highlight-checked--first-selected":n&&0===N,"wc-block-components-radio-control--highlight-checked--last-selected":n&&N===r.length-1,"wc-block-components-radio-control--highlight-checked":n},e),children:[(0,c.jsxs)("div",{className:"wc-block-components-cfe-radio-control__heading",children:[" ",l||""," "]}),r.map((e=>(0,c.jsx)(C,{highlightChecked:n,name:`radio-control-${b}`,checked:e.value===t,option:e,onChange:o=>{s(o),"function"==typeof e.onChange&&e.onChange(o)},disabled:i},`${b}-${e.value}`))),(0,c.jsx)(w.ValidationInputError,{propertyName:_})]}):null},O=E,A=(window.wc.blocksCheckout,window.wp.url),I=({field:e})=>{const{id:o,label:t,type:s,value:r,placeholder:i,required:n,options:l,title:a,validate:d,enabled:p,cssclass:h,property_set:b}=e,{default:_,checked:f}=b,k=T(e),v=(0,y.useRef)({});if(!p||"0"===p)return null;const g=e=>{};return"checkbox"===s?(0,c.jsx)(w.CheckboxControl,{checked:r,onChange:g,...$(k),className:m(h?.split(",").map((e=>e.trim()))),required:n},o):"select"===s&&e.options?(0,c.jsx)(x,{...k,label:a||"",className:m(h?.split(",").map((e=>e.trim())),"wc-block-components-select-input",`wc-block-components-select-input-${o}`.replaceAll("/","-")),value:r,onChange:g,options:k.options,required:n,errorMessage:k.errorMessage||void 0,placeholder:i||null},o):"radio"===s?(0,c.jsx)(O,{...k,selected:r,onChange:g,options:k.options,disabled:!1,highlightChecked:!0,title:a||"",className:m(h?.split(",").map((e=>e.trim()))),required:n}):(0,c.jsx)(w.ValidatedTextInput,{ref:e=>v.current[o]=e,...k,type:s,value:r,onChange:g,customFormatter:o=>"postcode"===e.type?o.trimStart().toUpperCase():o,customValidation:e=>((e,o)=>!((e.required||e.value)&&("phone"!==o||(0,A.isPhoneNumber)(e.value)?"url"!==o||(0,A.isURL)(e.value)?"email"===o&&!(0,A.isEmail)(e.value)&&(e.setCustomValidity((0,u.__)("Please enter a valid email address","woo-checkout-field-editor-pro")),1):(e.setCustomValidity((0,u.__)("Please enter a valid URL","woo-checkout-field-editor-pro")),1):(e.setCustomValidity((0,u.__)("Please enter a valid Phone Number","woo-checkout-field-editor-pro")),1))))(e,d),className:m(h?.split(",").map((e=>e.trim())))},o)},T=e=>({id:`section_one-${e?.id}`.replaceAll("/","-"),errorId:`section_${e?.id}`,label:e?.title,autoCapitalize:e?.autocapitalize,autoComplete:e?.autocomplete,errorMessage:e?.errorMessage,required:e?.required,placeholder:e?.placeholder,className:`wc-block-components-address-form__${e?.id}`.replaceAll("/","-"),options:e?.options?Object.values(e.options).map((e=>({value:e.key,label:e.text}))):[],...e?.attributes}),$=e=>{const{errorId:o,errorMessage:t,autoCapitalize:s,autoComplete:r,placeholder:i,...n}=e;return n},V=window.wp.dom,S=["BUTTON","FIELDSET","INPUT","OPTGROUP","OPTION","SELECT","TEXTAREA","A"],P=({children:e,style:o={},...t})=>{const s=(0,r.useRef)(null),i=()=>{s.current&&V.focus.focusable.find(s.current).forEach((e=>{S.includes(e.nodeName)&&e.setAttribute("tabindex","-1"),e.hasAttribute("contenteditable")&&e.setAttribute("contenteditable","false")}))};return(0,r.useLayoutEffect)((()=>{let e,o;return i(),s.current&&(e=new MutationObserver((()=>{clearTimeout(o),o=setTimeout(i,0)})),e.observe(s.current,{childList:!0,attributes:!0,subtree:!0})),()=>{e&&e.disconnect(),clearTimeout(o)}}),[]),(0,c.jsx)("div",{ref:s,"aria-disabled":"true",style:{userSelect:"none",pointerEvents:"none",cursor:"normal",...o},...t,children:e})},R=({field:e})=>(0,c.jsx)("div",{className:"wc-block-checkout__additional-fields__field",children:(0,c.jsx)(P,{children:(0,c.jsx)(I,{field:e})})},e.id),L=({attributes:e,setAttributes:o})=>{const t=(0,p.useBlockProps)(),{sectionData:s,className:r}=e;if(!s)return(0,c.jsx)("div",{...t});if("object"!=typeof s)return console.error("Invalid section data:",s),(0,c.jsx)("div",{...t,children:(0,u.__)("Error: Invalid section data","woocommerce")});const{fields:i={},show_title:n}=s;if(!(Object.keys(i).length>0))return null;const l=n?f:"div";return(0,c.jsx)("div",{...t,children:(0,c.jsx)(l,{id:s.id,className:m("wc-block-checkout__additional-fields",s.cssclass),...n&&{setAttributes:o,attributes:e},children:(0,c.jsx)("div",{children:Object.entries(i).map((([e,o])=>(0,c.jsx)(R,{field:o},o.id||e)))})})})},D=({attributes:e})=>{const{sectionData:o}=e,t=(s=o?.id,`thwcfe_sections_${s||"default_section"}`);var s;return(0,c.jsx)("div",{className:t})},F=(0,a.getSetting)("thwcfe-block-integration_data",""),{allSections:M}=F,{additional_info:q}=M||{};if(q&&Object.keys(q).length>0){const e=q.title||"Additional Information",o={...d,attributes:{...d.attributes,title:{...d.attributes.title,default:e},description:{...d.attributes.description,default:q.subtitle||""},sectionData:{type:"object",default:q}}};(0,s.registerBlockType)(o,{icon:{src:(0,c.jsx)(i,{icon:l})},edit:L,save:D})}},609:e=>{e.exports=window.React},848:(e,o,t)=>{e.exports=t(20)}},t={};function s(e){var r=t[e];if(void 0!==r)return r.exports;var i=t[e]={exports:{}};return o[e](i,i.exports,s),i.exports}s.m=o,e=[],s.O=(o,t,r,i)=>{if(!t){var n=1/0;for(d=0;d=i)&&Object.keys(s.O).every((e=>s.O[e](t[l])))?t.splice(l--,1):(c=!1,i0&&e[d-1][2]>i;d--)e[d]=e[d-1];e[d]=[t,r,i]},s.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),(()=>{var e={309:0,185:0};s.O.j=o=>0===e[o];var o=(o,t)=>{var r,i,[n,c,l]=t,a=0;if(n.some((o=>0!==e[o]))){for(r in c)s.o(c,r)&&(s.m[r]=c[r]);if(l)var d=l(s)}for(o&&o(t);as(314)));r=s.O(r)})();