{"version":3,"mappings":";4KAOA,MAAMA,EAAkB,+BAGxB,SAASC,GAAkB,CACzB,OAAOC,EAAQ,QAAAC,EAAA,IACb,OACE,qBACF,uCACC,KAAMC,GAAWA,EAAO,OAAO,CAClC,CACF,CAEA,MAAMC,EAAO,CAACC,EAAmB,uBACxBL,EAAgB,EACtB,KAAMM,GAAiB,CACtBC,EAAEF,CAAQ,EAAE,KAAMG,GAAO,CAChBA,aAAc,mBAEjBA,EAAG,UAAU,SAAST,CAAe,IAEzCO,EAAaE,EAAI,CACf,cAAkB,GAClB,mBAAoB,GACpB,gBAAkB,SAClB,aAAkB,GAMlB,iBAAkB,GAElB,eAAoB,OACpB,mBAAoB,CAClB,KACA,KACA,KACA,KACA,KACA,KACA,IACF,EAEA,YAAcC,GAAkC,CACrCC,EAAA,CACP,IAAU,mBACV,OAAU,MACV,SAAU,MACX,GACA,KAAK,CAAC,CAAC,KAAAC,KAAU,CAChB,MAAMC,EAAeD,GAAA,MAAAA,EAAM,aAAgBA,EAAK,aAAe,GAC/DF,EAASG,CAAW,EACrB,EACA,MAAM,IAAM,CAEZ,GACA,KAAK,EACR,CACD,EAGEJ,EAAA,iBAAiB,QAAS,IAAM,CAE3B,sBAAuBA,GAK7B,WAAW,IAAM,CACZA,EAAA,kBAAkB,KAAM,KAAM,SAAS,GACzC,CAAC,EACL,EAEEA,EAAA,UAAU,IAAIT,CAAe,IACjC,EACF,EAGYc,EAAA,CACb,KAAAT,EACA,gBAAAJ,CACF","names":["INIT_DONE_CLASS","getIntlTelInput","Promise","__vitePreload","module","init","selector","intlTelInput","u","el","callback","q_ajax_3","data","countryCode","IntlTelInput"],"ignoreList":[],"sources":["../../../app/assets/javascripts/plugins/intl_tel_input/index.ts"],"sourcesContent":["\nimport u from \"umbrellajs\"\nimport Promise from \"plugins/bluebird\"\n\nimport q_ajax_3 from \"app/utils/q_ajax/q_ajax_3\"\n\n\nconst INIT_DONE_CLASS = \"js-intl-tel-input--init-done\"\n\n\nfunction getIntlTelInput() {\n return Promise.resolve(\n import(\n \"intl-tel-input\"\n )\n .then((module) => module.default)\n )\n}\n\nconst init = (selector: string = \".js-intl-tel-input\"): Promise => {\n return getIntlTelInput()\n .then((intlTelInput) => {\n u(selector).each((el) => {\n if (! (el instanceof HTMLInputElement)) { return }\n\n if (el.classList.contains(INIT_DONE_CLASS)) { return }\n\n intlTelInput(el, {\n allowDropdown: true,\n autoInsertDialCode: true,\n autoPlaceholder: \"polite\",\n nationalMode: false,\n // `separateDialCode: true` requires custom JS\n // to handle submission of country code\n // Thus unsafe to set it as `true`\n // since simple pages like /zh-tw/my/settings\n // are bugged (not saving country code)\n separateDialCode: false,\n\n initialCountry: \"auto\",\n preferredCountries: [\n \"hk\",\n \"tw\",\n \"cn\",\n \"mo\",\n \"jp\",\n \"us\",\n \"gb\",\n ],\n\n geoIpLookup: (callback: (c: string) => void) => {\n q_ajax_3({\n url: \"/my_country_code\",\n method: \"GET\",\n dataType: \"json\",\n })\n .then(({data}) => {\n const countryCode = (data?.country_code) ? data.country_code : \"\"\n callback(countryCode)\n })\n .catch(() => {\n // Do nothing\n })\n .done()\n },\n })\n\n // On focus move the cursor to the end\n el.addEventListener(\"focus\", () => {\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange\n if (!(\"setSelectionRange\" in el)) { return }\n\n // Timeout is required\n // Since the cursor seems to be moved to where the pointer clicks\n // after the event listeners\n setTimeout(() => {\n el.setSelectionRange(9999, 9999, \"forward\")\n }, 0)\n })\n\n el.classList.add(INIT_DONE_CLASS)\n })\n })\n}\n\nexport default {\n init,\n getIntlTelInput,\n}\n"],"file":"assets/index-C45x3AOR.js"}