import{_ as t}from"./fc-bits.js?ver=3.1.10";import{c1 as e,W as i,X as r,Z as l}from"./vendor.js?ver=3.1.10";import{_ as s}from"./fc-bits-ui.js?ver=3.1.10";const n={class:"fcrm_intl_tel_input"},a=["placeholder"];const o=s({name:"IntlTelInput",props:{modelValue:{type:String,default:""},placeholder:{type:String,default:""}},emits:["update:modelValue","validate","blur"],data:()=>({}),created(){this.iti=null},watch:{modelValue:{handler(t){if(!this.iti)return;const e=(t||"").trim();if(!e)return;let i="";try{i=this.iti.getNumber()||""}catch(r){}e!==i&&this.iti.setNumber(e)},immediate:!1}},mounted(){const i=this.$refs.inputRef;if(!i)return;this.iti=e(i,{initialCountry:"",preferredCountries:[],separateDialCode:!0,countrySearch:!0,formatAsYouType:!0,strictMode:!0,loadUtils:()=>t(()=>import("./vendor.js?ver=3.1.10").then(t=>t.c9),[],import.meta.url).catch(()=>null),customPlaceholder:()=>this.placeholder||this.$t("Enter phone number")}),this.modelValue&&this.iti.setNumber(this.modelValue);const r=()=>{let t="",e=!0;try{t=this.iti.getNumber()||"",e="function"==typeof this.iti.isValidNumber?this.iti.isValidNumber():!t||t.length>=10}catch(i){e=!t||t.length>=10}this.$emit("update:modelValue",t),this.$emit("validate",{number:t,valid:e})};i.addEventListener("input",r),i.addEventListener("blur",()=>{r(),this.$emit("blur")}),i.addEventListener("countrychange",r),this._emitNumber=r},beforeUnmount(){this.iti&&(this.iti.destroy(),this.iti=null)}},[["render",function(t,e,s,o,u,d){return i(),r("div",n,[l("input",{ref:"inputRef",type:"tel",placeholder:s.placeholder,autocomplete:"off",class:"fcrm_phone_tel_input"},null,8,a)])}]]);export{o as I};
