(()=>{"use strict";const e={n:t=>{const r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{if(Array.isArray(r))for(var n=0;n<r.length;){var s=r[n++],o=r[n++];e.o(t,s)?0===o&&n++:0===o?Object.defineProperty(t,s,{enumerable:!0,value:r[n++]}):Object.defineProperty(t,s,{enumerable:!0,get:o})}else for(var s in r)e.o(r,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:r[s]})},o:(e,t)=>Object.hasOwn(e,t)},t=window.React,r=window.ReactDOM,n=(0,t.createContext)(null),s={didCatch:!1,error:null};class o extends t.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=s}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(...e){const{error:t}=this.state;null!==t&&(this.props.onReset?.({args:e,reason:"imperative-api"}),this.setState(s))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){const{didCatch:r}=this.state,{resetKeys:n}=this.props;r&&null!==t.error&&function(e=[],t=[]){return e.length!==t.length||e.some((e,r)=>!Object.is(e,t[r]))}(e.resetKeys,n)&&(this.props.onReset?.({next:n,prev:e.resetKeys,reason:"keys"}),this.setState(s))}render(){const{children:e,fallbackRender:r,FallbackComponent:s,fallback:o}=this.props,{didCatch:a,error:i}=this.state;let l=e;if(a){const e={error:i,resetErrorBoundary:this.resetErrorBoundary};if("function"==typeof r)l=r(e);else if(s)l=(0,t.createElement)(s,e);else{if(void 0===o)throw i;l=o}}return(0,t.createElement)(n.Provider,{value:{didCatch:a,error:i,resetErrorBoundary:this.resetErrorBoundary}},l)}}const a=window.wp.i18n,i=window.ReactJSXRuntime,l=new Map,d=class{fallbackRender({error:e}){return(0,i.jsx)("div",{role:"alert",className:"hulk-error-boundary",children:(0,i.jsxs)("pre",{style:{color:"red"},children:[(0,a.__)("Something went wrong:","advanced-fields-for-elementor-forms"),(0,i.jsx)("br",{}),e.message]})})}handleField(e){const t=e.closest(".elementor-form"),n=e.getAttribute("data-key"),s=document.getElementById(n),a=JSON.parse(s.textContent);a.formElement=t,l.has(e)||l.set(e,(0,r.createRoot)(e));const d=this.fieldComponent(a);l.get(e)?.render((0,i.jsx)(o,{fallbackRender:this.fallbackRender.bind(this),children:d}))}handleWidget(){document.querySelectorAll(".elementor-form").forEach(e=>{e.querySelectorAll(`.${this.name}_wrap`).forEach(e=>this.handleField(e))})}onInit(){document.querySelectorAll(".elementor-form").length>0?this.handleWidget.bind(this)():elementorFrontend.hooks.addAction("frontend/element_ready/form.default",this.handleWidget.bind(this))}constructor(e){this.name=e,window.addEventListener("elementor/frontend/init",this.onInit.bind(this))}},c=window.jQuery;var u=e.n(c);const h=e=>{const r=(0,t.useMemo)(()=>function(e){const t={};for(let[r,n]of Object.entries(e)){let e=n;Array.isArray(n)&&(e=n.join(" ")),"class"===r&&(r="className"),t[r]=String(e)}return t}(e.attrs),[e.attrs]),n=(0,t.useMemo)(()=>{const t=Number(e.attrs.max),r=Number(e.attrs.min);return t<r?r:r+(t-r)/2},[e.attrs.max,e.attrs.min]),s=(0,t.useMemo)(()=>r.value?.trim()||n.toString(),[r.value,n]),o=(0,t.useRef)(null),[a,l]=(0,t.useState)(s);return function(e,r,n){(0,t.useEffect)(()=>{if(!e.current)return;const t=u()(e.current).closest(".elementor-form");return t.on("submit_success.hulk_affef",r),()=>{t.off("submit_success.hulk_affef",r)}},n)}(o,()=>{l(s)},[s]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"hulk-range-input-wrap",children:(0,i.jsx)("input",{ref:o,...r,type:"range",value:a,onChange:function(e){l(e.target.value)}})}),e.showInput&&(0,i.jsx)("div",{className:"hulk-show-input-wrap",children:(0,i.jsx)("input",{type:"number",className:"elementor-field elementor-field-textual hulk-show-input",value:a,onChange:function(e){l(e.target.value)},min:r.min,max:r.max,step:r.step})})]})};new class extends d{fieldComponent(e){return(0,i.jsx)(h,{...e})}}("hulk_affef_native_range")})();