@salla.sa/twilight-components 2.14.270 → 2.14.271
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{app-globals-e5ir-FZU.js → app-globals-DfTgypwp.js} +1 -1
- package/dist/cjs/{filepond-D12fTEcr.js → filepond-DZKo1pV9.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-DjNwqUMH.js → filepond-plugin-file-poster-Ddu0-eEg.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-DYnBW_Uf.js → filepond-plugin-file-validate-size-B2VId_n-.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-l0NWdm48.js → filepond-plugin-file-validate-type-lGUMFCde.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-CSYxt_TT.js → filepond-plugin-image-edit-BlEvC0bv.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-Dx_jvGKP.js → filepond-plugin-image-exif-orientation-C9yPmasn.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-DXcGotPw.js → filepond-plugin-image-preview-BPQ9o2YT.js} +1 -1
- package/dist/cjs/{index-DIkhoTLV.js → index-4c5cqxT-.js} +1 -1
- package/dist/cjs/{index-DMP4XxGx.js → index-DpqjX7F3.js} +2 -2
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/salla-accordion_4.cjs.entry.js +1 -1
- package/dist/cjs/salla-add-product-button_51.cjs.entry.js +10 -9
- package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
- package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
- package/dist/cjs/salla-booking-field_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-item-offers.cjs.entry.js +1 -1
- package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters.cjs.entry.js +1 -1
- package/dist/cjs/salla-installment.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-program.cjs.entry.js +1 -1
- package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
- package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
- package/dist/cjs/salla-orders.cjs.entry.js +1 -1
- package/dist/cjs/salla-payments.cjs.entry.js +1 -1
- package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
- package/dist/cjs/salla-product-options.cjs.entry.js +1 -1
- package/dist/cjs/salla-review-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-reviews-page.cjs.entry.js +1 -1
- package/dist/cjs/salla-reviews.cjs.entry.js +1 -1
- package/dist/cjs/salla-social.cjs.entry.js +1 -1
- package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
- package/dist/cjs/salla-verify.cjs.entry.js +1 -1
- package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
- package/dist/cjs/twilight.cjs.js +2 -2
- package/dist/collection/components/salla-login-modal/salla-login-modal.js +1 -0
- package/dist/components/index.js +2 -2
- package/dist/components/salla-login-modal.js +1 -0
- package/dist/esm/{app-globals-WQPw89Ls.js → app-globals-i4_OI7UA.js} +1 -1
- package/dist/esm/{filepond-BD4hHnGh.js → filepond-DbqR2fSR.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-Dirg4Lb_.js → filepond-plugin-file-poster-oSU_je8q.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size-MiPnEWU1.js → filepond-plugin-file-validate-size-DBNbjpCq.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-B35ZduxA.js → filepond-plugin-file-validate-type-FNihY0D1.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-BffS2MIp.js → filepond-plugin-image-edit-BvLwmvqS.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-YnKxYLPF.js → filepond-plugin-image-exif-orientation-CzDuHCvL.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-CwZFI2pC.js → filepond-plugin-image-preview-OJew5tLP.js} +1 -1
- package/dist/esm/{index-BxxbBrdi.js → index-DFnMPSip.js} +1 -1
- package/dist/esm/{index-DVlAsZVJ.js → index-DXrQDmAN.js} +2 -2
- package/dist/esm/loader.js +3 -3
- package/dist/esm/salla-accordion_4.entry.js +1 -1
- package/dist/esm/salla-add-product-button_51.entry.js +10 -9
- package/dist/esm/salla-advertisement.entry.js +1 -1
- package/dist/esm/salla-app-install-alert.entry.js +1 -1
- package/dist/esm/salla-apps-icons.entry.js +1 -1
- package/dist/esm/salla-booking-field_2.entry.js +1 -1
- package/dist/esm/salla-cart-item-offers.entry.js +1 -1
- package/dist/esm/salla-conditional-offer.entry.js +1 -1
- package/dist/esm/salla-contacts.entry.js +1 -1
- package/dist/esm/salla-filters-widget.entry.js +1 -1
- package/dist/esm/salla-filters.entry.js +1 -1
- package/dist/esm/salla-installment.entry.js +1 -1
- package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
- package/dist/esm/salla-loyalty-program.entry.js +1 -1
- package/dist/esm/salla-metadata.entry.js +1 -1
- package/dist/esm/salla-notification-item.entry.js +1 -1
- package/dist/esm/salla-notifications.entry.js +1 -1
- package/dist/esm/salla-offer.entry.js +1 -1
- package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-order-details.entry.js +1 -1
- package/dist/esm/salla-order-summary.entry.js +1 -1
- package/dist/esm/salla-orders.entry.js +1 -1
- package/dist/esm/salla-payments.entry.js +1 -1
- package/dist/esm/salla-price-range.entry.js +1 -1
- package/dist/esm/salla-product-options.entry.js +1 -1
- package/dist/esm/salla-review-card.entry.js +1 -1
- package/dist/esm/salla-reviews-page.entry.js +1 -1
- package/dist/esm/salla-reviews.entry.js +1 -1
- package/dist/esm/salla-social.entry.js +1 -1
- package/dist/esm/salla-tiered-offer.entry.js +1 -1
- package/dist/esm/salla-tooltip.entry.js +1 -1
- package/dist/esm/salla-verify.entry.js +1 -1
- package/dist/esm/salla-wallet.entry.js +1 -1
- package/dist/esm/twilight.js +3 -3
- package/dist/twilight/{p-d5ff336a.entry.js → p-01b67a23.entry.js} +1 -1
- package/dist/twilight/{p-a6a4973f.entry.js → p-0e18add0.entry.js} +1 -1
- package/dist/twilight/{p-0e53becf.entry.js → p-11c1fc02.entry.js} +1 -1
- package/dist/twilight/{p-3d84ba33.entry.js → p-137e1751.entry.js} +1 -1
- package/dist/twilight/{p-4ffd238b.entry.js → p-18cd5d66.entry.js} +1 -1
- package/dist/twilight/{p-b508bbfb.entry.js → p-1d1672e8.entry.js} +1 -1
- package/dist/twilight/{p-95f40576.entry.js → p-36b30807.entry.js} +1 -1
- package/dist/twilight/{p-5b1171b4.entry.js → p-57e8c6b5.entry.js} +1 -1
- package/dist/twilight/{p-a99b9322.entry.js → p-591043a2.entry.js} +1 -1
- package/dist/twilight/{p-f6bbc574.entry.js → p-5aa17da1.entry.js} +1 -1
- package/dist/twilight/{p-7500e640.entry.js → p-5c67f412.entry.js} +1 -1
- package/dist/twilight/{p-ecf7a473.entry.js → p-6159654b.entry.js} +1 -1
- package/dist/twilight/{p-5a4190f1.entry.js → p-62312d5b.entry.js} +1 -1
- package/dist/twilight/{p-efdf9dcb.entry.js → p-6ed0de44.entry.js} +1 -1
- package/dist/twilight/{p-77d28752.entry.js → p-81131b67.entry.js} +1 -1
- package/dist/twilight/{p-aa18655f.entry.js → p-849be825.entry.js} +1 -1
- package/dist/twilight/{p-7b754cd9.entry.js → p-86f00281.entry.js} +1 -1
- package/dist/twilight/{p-1c95f0c0.entry.js → p-906ec5e3.entry.js} +1 -1
- package/dist/twilight/{p-7e9ae747.entry.js → p-93b26c0b.entry.js} +1 -1
- package/dist/twilight/{p-b59bde72.entry.js → p-9d9e5493.entry.js} +1 -1
- package/dist/twilight/{p-DviNrjCC.js → p-B3DRwtQ_.js} +1 -1
- package/dist/twilight/{p-JOmrY_UH.js → p-BQuXdlAk.js} +1 -1
- package/dist/twilight/{p-B6LiBPf6.js → p-BeXdXg7Q.js} +1 -1
- package/dist/twilight/{p-DlrTDuTu.js → p-BvKpNEUI.js} +1 -1
- package/dist/twilight/{p-DO3kuXJ_.js → p-C3joUrVg.js} +1 -1
- package/dist/twilight/{p-CqS6rEea.js → p-CqZlwzcH.js} +1 -1
- package/dist/twilight/{p-DVlAsZVJ.js → p-DXrQDmAN.js} +1 -1
- package/dist/twilight/{p-BfVZrFhv.js → p-E9O3bnHS.js} +1 -1
- package/dist/twilight/{p-BYyDgfij.js → p-MbgAyDn3.js} +1 -1
- package/dist/twilight/{p-acb5623f.entry.js → p-a71a3922.entry.js} +1 -1
- package/dist/twilight/{p-56ec9d3d.entry.js → p-adc5a167.entry.js} +1 -1
- package/dist/twilight/p-affed6bd.entry.js +11 -0
- package/dist/twilight/{p-c65798a5.entry.js → p-c0450f72.entry.js} +1 -1
- package/dist/twilight/p-c2f0f504.entry.js +4 -0
- package/dist/twilight/{p-b38e2249.entry.js → p-c87e16b6.entry.js} +1 -1
- package/dist/twilight/{p-c1a08858.entry.js → p-cfbd199f.entry.js} +1 -1
- package/dist/twilight/{p-bac7b0a9.entry.js → p-d060275b.entry.js} +1 -1
- package/dist/twilight/{p-06bd3202.entry.js → p-d3022e35.entry.js} +1 -1
- package/dist/twilight/{p-bd8c882b.entry.js → p-d8e500cc.entry.js} +1 -1
- package/dist/twilight/{p-6f7b6a8e.entry.js → p-e162d003.entry.js} +1 -1
- package/dist/twilight/{p-106330fa.entry.js → p-e987bf56.entry.js} +1 -1
- package/dist/twilight/{p-2d8c4aee.entry.js → p-fed06a9f.entry.js} +1 -1
- package/dist/twilight/{p-CkuD5670.js → p-yWcVqMiP.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/package.json +5 -5
- package/dist/twilight/p-9cb344c8.entry.js +0 -4
- package/dist/twilight/p-edca8e85.entry.js +0 -11
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as a,h as t,H as l}from"./p-
|
|
4
|
+
import{r as a,h as t,H as l}from"./p-DXrQDmAN.js";const s=class{constructor(t){a(this,t),this.isLoading=!1,this.nextPageUrl="",this.handleClick=()=>{this.loadMoreTransactions()}}componentWillLoad(){return salla.onReady().then((()=>this.loadTransactions()))}async loadTransactions(){this.isLoading=!0;try{let a="/balance/wallet?per_page=10&page=1",t=await salla.api.request(a);this.nextPageUrl=t.data.transactions.next_page_url,this.transactionsArray=t.data.transactions,this.balance=t.data.balance}catch(a){console.error("Error loading wallet transactions",a)}finally{this.isLoading=!1}}async loadMoreTransactions(){this.isLoading=!0;try{let a=this.nextPageUrl||"/balance/wallet?page=2&per_page=10",t=await salla.api.request(a);this.nextPageUrl=t.data.transactions.next_page_url,this.transactionsArray.push(...t.data.transactions.data),this.balance=t.data.balance}catch(a){console.error("Error loading wallet transactions",a)}finally{this.isLoading=!1}}render(){return this.transactionsArray.length>0?t(l,null,t("table",{class:"s-wallet-table"},t("tbody",{class:"s-wallet-table-tbody"},t("tr",{class:"s-table__tr"},t("td",null,t("div",{class:"s-wallet-table-balance-container"},t("i",{class:"s-wallet-table-balance-icon sicon-wallet"}),t("div",null,t("div",{innerHTML:salla.money(this.balance)}),t("div",{class:"font-normal text-gray-400"}," ",salla.lang.get("pages.wallet.balance")))))))),t("h2",{style:{"margin-top":"32px"}},salla.lang.get("pages.wallet.title")),t("table",{class:"s-wallet-table"},t("thead",{class:"s-wallet-table-head"},t("tr",{class:"s-wallet-table-head-tr"},t("th",{scope:"col"},salla.lang.get("pages.wallet.transaction_number")),t("th",{scope:"col",class:"s-wallet-table-head-tr-th"},salla.lang.get("pages.wallet.amount")),t("th",{scope:"col",class:"s-wallet-table-head-tr-th"},salla.lang.get("pages.wallet.date")),t("th",{scope:"col",class:"s-wallet-table-head-tr-th"},salla.lang.get("pages.wallet.order_no")),t("th",{scope:"col",class:"s-wallet-table-head-tr-th"},salla.lang.get("pages.wallet.expiry_date")),t("th",{scope:"col",class:"s-wallet-table-head-tr-th"},salla.lang.get("pages.wallet.transaction_type")," "))),t("tbody",{class:"s-wallet-table-tbody"},this.transactionsArray.map((a=>t("tr",{class:"s-wallet-table-tbody-tr s-wallet-table-tbody-tr-shadow animated"},t("td",{class:"s-wallet-table-tbody-tr-td"},t("div",{class:"s-wallet-table-tbody-tr-td-content"},t("span",{class:"s-wallet-mobile-title"},salla.lang.get("pages.wallet.transaction_number"),":"),a.id&&t("span",{class:"hidden md:inline-block"},"#",a.id),t("div",{class:"flex items-center md:hidden"},t("salla-button",{class:"relative",color:"dark",shape:"link","data-content":a.order_id},a.order_id&&t("span",null,"#",a.order_id))))),t("td",{id:"main123",class:"s-wallet-table-tbody-tr-td"},t("div",{id:"main124",class:"s-wallet-table-tbody-tr-td-content"},t("span",{id:"main125",class:"s-wallet-mobile-title"},salla.lang.get("pages.wallet.amount"),":"),t("div",{innerHTML:salla.money(a.amount)}))),t("td",{class:"s-wallet-table-tbody-tr-td"},t("div",{class:"s-wallet-table-tbody-tr-td-content"},t("span",{class:"s-wallet-mobile-title"},salla.lang.get("pages.wallet.date"),":"),a.created_at&&new Date(1e3*a.created_at).toLocaleDateString(salla.lang.locale,{weekday:"long",year:"numeric",month:"long",day:"numeric",hour:"numeric"}))),t("td",{id:"main133",class:"s-wallet-table-tbody-tr-td"},t("div",{id:"main134",class:"s-wallet-table-tbody-tr-td-content"},t("span",{id:"main135",class:"s-wallet-mobile-title"},salla.lang.get("pages.wallet.order_no"),":"),t("span",{class:"rtl:mr-auto ltr:ml-auto md:mx-0"},a.order_id&&t("span",null,"#",a.order_id)))),t("td",{id:"main143",class:"s-wallet-table-tbody-tr-td"},t("div",{id:"main144",class:"s-wallet-table-tbody-tr-td-content"},t("span",{id:"main145",class:"s-wallet-mobile-title"},salla.lang.get("pages.wallet.expiry_date"),":"),t("span",null,a.expired_at&&new Date(1e3*a.expired_at).toLocaleDateString(salla.lang.locale,{weekday:"long",year:"numeric",month:"long",day:"numeric",hour:"numeric"})))),t("td",{class:"s-wallet-table-tbody-tr-td"},t("div",{class:"s-wallet-table-tbody-tr-td-content"},t("div",null,t("span",{class:"s-wallet-mobile-title"},salla.lang.get("pages.wallet.transaction_type"),":")),t("div",{class:{"s-wallet-table-transaction-status-default":!0,"s-wallet-table-transaction-status-cashback":"cashback"===a.action_type,"s-wallet-table-transaction-status-refund":"refund"===a.action_type,"s-wallet-table-transaction-status-purchase":"purchase_by_wallet"===a.action_type}},!!a.description&&t("i",{id:a.id.toString(),class:"sicon-information text-lg rtl:ml-4 ltr:mr-4 s-wallet-table-transaction-status-icon-success"}),!!a.description&&t("salla-tooltip",{text:a.description,targetId:a.id.toString()}),t("span",null,a.title))))))))),t("div",{class:"s-infinite-scroll-wrapper"},!!this.nextPageUrl&&t("salla-button",{onClick:this.handleClick,loading:this.isLoading},salla.lang.get("common.elements.load_more")))):t(l,null,t("h2",{style:{"margin-top":"32px"}},salla.lang.get("pages.wallet.title")),t("div",{class:"s-wallet-table-empty-state"},t("i",{class:"sicon-full-wallet"}),t("div",{class:"text-center p-3 text-xl font-bold "},salla.lang.get("pages.wallet.no_transactions")),t("div",{class:"text-center text-gray-400 text-sm font-normal "},salla.lang.get("pages.wallet.zero_balance")," ")))}};s.style=".s-wallet-table{min-width:100%}.s-wallet-table-balance-container{display:flex !important;align-items:center !important;justify-content:flex-start !important;gap:1rem}.s-wallet-table-balance-icon{border-radius:50%;width:52px;height:52px;font-size:25px;padding:16px 13px;background:var(--color-primary-reverse);color:var(--color-primary)}.s-wallet-table-empty-state{display:flex;flex-direction:column;align-items:center}.s-wallet-table-empty-state i{font-size:80px;margin:4rem 0 2rem;color:var(--infinte-color)}.s-wallet-table-transaction-status{padding:6px 19px !important;border-radius:20px;width:max-content;display:flex;align-items:center}.s-wallet-table-transaction-status-default{background:#fff6eb;color:#a46f29}.s-wallet-table-transaction-status-cashback{background:#effbf6;color:#00af6c}.s-wallet-table-transaction-status-refund{background:#ecf3fe;color:#5196f3}.s-wallet-table-transaction-status-purchase{background:#feecec;color:#f55157}.s-wallet-table-transaction-status-icons-success{color:#00af6c}";export{s as salla_wallet}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as t,h as s,g as i}from"./p-
|
|
4
|
+
import{r as t,h as s,g as i}from"./p-DXrQDmAN.js";import{H as n}from"./p-X-ZUrwUQ.js";import"./p-CgtvEd63.js";const a=class{constructor(s){t(this,s),this.itemPerPage=10,this.no_notifications_trans=salla.lang.get("blocks.header.no_notifications"),this.load_more_text_trans=salla.lang.get("common.elements.load_more"),salla.lang.onLoaded((()=>{this.no_notifications_trans=salla.lang.get("blocks.header.no_notifications"),this.load_more_text_trans=salla.lang.get("common.elements.load_more")}))}loading(t=!0){let s=this.status?.querySelector(".s-button-text");s&&(n.toggleElementClassIf(s,"s-button-hide","s-button-show",(()=>t)),this.btnLoader.style.display=t?"inherit":"none")}getNotificationCard(t){const s=document.createElement("salla-notification-item");return s.notification=t,s.classList.add("s-block"),s}render(){return this.showPlaceholder?s("div",{class:"s-notifications-no-content"},s("salla-placeholder",{alignment:"center"},s("span",{slot:"title"},this.no_notifications_trans))):s("div",{class:"s-notifications-wrapper"},s("div",{class:"s-notifications-container",ref:t=>this.wrapper=t}),this.nextPage&&s("div",{class:"s-infinite-scroll-wrapper",ref:t=>this.status=t},s("button",{onClick:()=>this.loadMore(),class:"s-infinite-scroll-btn s-button-btn s-button-primary"},s("span",{class:"s-button-text s-infinite-scroll-btn-text"},this.loadMoreText??this.load_more_text_trans),s("span",{class:"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader",ref:t=>this.btnLoader=t,style:{display:"none"}}))))}handleResponse(t){return t.map((t=>this.getNotificationCard(t)))}initiateInfiniteScroll(){this.wrapper?(this.infiniteScroll=salla.infiniteScroll.initiate(this.wrapper,this.wrapper,{path:()=>this.nextPage,history:!0,nextPage:this.nextPage,scrollThreshold:!1},!0),this.infiniteScroll?.on("request",(()=>{this.loading()})),this.infiniteScroll?.on("load",(t=>{this.loading(!1),this.pagination=t.pagination,this.nextPage=t.pagination.links?.next||null,this.handleResponse(t.data).forEach((t=>this.wrapper.append(t)));let s=this.host.querySelectorAll("salla-notification-item:not(.animated)");n.animateItems(s)})),this.infiniteScroll?.on("error",(t=>{salla.logger.error("Error loading more comments:",t)}))):salla.logger.error("Wrapper is undefined. Cannot initiate infinite scroll.")}async loadInitialData(){await salla.api.notifications.fetch({per_page:this.itemPerPage}).then((t=>{this.pagination=t.pagination,this.total=t.pagination.total,this.nextPage=t.pagination.links?.next||null,setTimeout((()=>{if(!t.data.length)return this.showPlaceholder=!0;this.handleResponse(t.data).forEach((t=>this.wrapper.append(t))),this.initiateInfiniteScroll();let s=this.wrapper.querySelectorAll("salla-notification-item:not(.animated)");n.animateItems(s)}),100)})).catch((t=>{salla.logger.error(t),this.showPlaceholder=!0,this.loading(!1)}))}async loadMore(){this.infiniteScroll?.loadNextPage()}async componentWillLoad(){await this.loadInitialData()}get host(){return i(this)}};a.style="";export{a as salla_notifications}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as t,c as e,h as s,H as i}from"./p-
|
|
4
|
+
import{r as t,c as e,h as s,H as i}from"./p-DXrQDmAN.js";import{a}from"./p-BedNk7k1.js";const l=class{constructor(s){t(this,s),this.changed=e(this,"changed"),this.min=0,this.max=1e4,this.moreThanLabel="أكثر من",this.lessThanLabel="أقل من",this.toLabel="الى",this.fromLabel="من",this.typing=!1,this.isMin=!1,this.isRTL=salla.config.get("theme.is_rtl",!0),this.filterValues=[]}connectedCallback(){if(this.filtersData&&this.filtersData?.price&&(this.minPrice=this.filtersData.price.min,this.maxPrice=this.filtersData.price.max),salla.lang.onLoaded((()=>{this.moreThanLabel=salla.lang.getWithDefault("common.elements.more_than",this.moreThanLabel),this.lessThanLabel=salla.lang.getWithDefault("common.elements.less_than",this.lessThanLabel),this.toLabel=salla.lang.getWithDefault("common.elements.to",this.toLabel),this.fromLabel=salla.lang.getWithDefault("common.elements.from",this.fromLabel)})),1==this.option.values.length)return;if(this.option.values.length<=5)return void(this.filterValues=this.option.values);const t=Math.ceil(this.option.values.length/5);for(let e=0;e<this.option.values.length;e+=t)this.filterValues.push(this.option.values.slice(e,e+t).reduce(((t,e)=>(t.to=e.to,t.count+=e.count,t))))}async reset(){this.minInput.value=null,this.maxInput.value=null,this.minPrice=null,this.maxPrice=null}getPriceLabel(t){return isNaN(t.from)||t.from<1?`${this.lessThanLabel} ${salla.money(t.to)}`:isNaN(t.to)||t.to<1?`${this.moreThanLabel} ${salla.money(t.from)}`:`${salla.money(t.from)} ${this.toLabel} ${salla.money(t.to)}`}minInputValidation(t){t&&(t>this.max||this.maxPrice&&t>this.maxPrice)||(t<this.min?this.minPrice=this.min:t&&(this.minPrice=t))}maxInputValidation(t){t&&(t<this.min||this.minPrice&&t<this.minPrice)||t>this.max&&(this.maxPrice=this.max)}async changedEventHandler(t){salla.helpers.inputDigitsOnly(this.minInput),salla.helpers.inputDigitsOnly(this.maxInput);const e=this.minPrice?1*+this.minPrice:null,s=this.maxPrice?1*+this.maxPrice:null;this.maxPrice||(this.maxPrice=""),this.isMin?this.minInputValidation(e):(this.minPrice||(this.minPrice=0),this.maxInputValidation(s)),this.isReady&&this.changed.emit({event:t,option:this.option,value:{max:this.maxPrice,min:this.minPrice}})}handleMinMaxPrice(t,e){this.minPrice=e.from,this.maxPrice="*"!==e.to?e.to:"",this.changedEventHandler(t)}isChecked(t){return!(!this.minPrice&&!this.maxPrice)&&(((t.from<1||"*"==t.from)&&0==this.minPrice||t.from==this.minPrice)&&("*"==t.to||!t.to||t.to==this.maxPrice))}handleMinPrice(t){this.isMin=!0;const e=t.target.value;this.minPrice=""===e?0:e}handleMaxPrice(t){this.isMin=!1;const e=t.target.value;this.maxPrice=void 0===e?"":e}render(){return s(i,{key:"dc09f4be81c3652da570b522894917f6b70faf61"},this.filterValues.map(((t,e)=>s("label",{class:"s-filters-label",htmlFor:`${this.option.key}-${e}`,key:e},s("input",{id:`${this.option.key}-${e}`,name:"price",type:"radio",checked:this.isChecked(t),class:"s-filters-radio",onChange:e=>this.handleMinMaxPrice(e,t)}),s("span",{innerHTML:this.getPriceLabel(t)})))),s("div",{key:"97f20e2bcff15d906dc5566a7f147339e4423138",class:"flex justify-center items-center"},s("div",{key:"4c631a9f5c77890bcffd365db6dab471ba989246",class:"relative max-w-xl w-full"},s("div",{key:"3e4c53b29c4e6fa90eba1a23f646d8391b1ce462",class:"s-price-range-inputs"},s("div",{key:"6bb515095db500d78c5cc22f2bd25635d157793d",class:"s-price-range-relative"},s("div",{key:"59617a36c7095a0766155521afb20d517fc5321a",class:"s-price-range-currency"}," ",salla.config.currency().symbol),s("input",{key:"bc1ae88ba28bcc11a7373cad13cdd2104646023b",type:"number",maxlength:"5",ref:t=>this.minInput=t,onBlur:t=>this.handleMinPrice(t),value:this.minPrice,placeholder:this.fromLabel,class:"s-price-range-number-input"})),s("div",{key:"49e12143570efe2f019e9a3240f9d1c184482f9c",class:"s-price-range-gray-text"}," -"),s("div",{key:"1e61ef602dbb0f1622bbd7279f15b5ef71d0f2db",class:"s-price-range-relative"},s("div",{key:"5aac7489a79f52156f382e0e4e181b6d0a8e5fb3",class:"s-price-range-currency"}," ",salla.config.currency().symbol),s("input",{key:"104a3ce0be1d461715fdc6a29d0df33a8a378ad3",type:"number",maxlength:"5",ref:t=>this.maxInput=t,onBlur:t=>this.handleMaxPrice(t),value:this.maxPrice,placeholder:this.toLabel,class:"s-price-range-number-input","aria-describedby":"price-currency"})),s("salla-button",{key:"2e722552816b6ceabf030d596fac580e1fa8d41a",color:"gray",shape:"icon",size:"small",fill:"outline",onClick:t=>this.changedEventHandler(t)},s("span",{key:"6f41a0dfa95c9910ab5d17e98ba815444fab8cca",innerHTML:this.isRTL?a:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>arrow-right</title>\n<path d="M29.217 15.465c-0.019-0.044-0.056-0.077-0.080-0.119-0.067-0.116-0.139-0.227-0.236-0.317-0.011-0.009-0.013-0.024-0.024-0.033l-10.667-9.333c-0.553-0.484-1.396-0.429-1.881 0.125-0.484 0.555-0.428 1.396 0.127 1.881l7.996 6.997h-20.452c-0.737 0-1.333 0.597-1.333 1.333s0.596 1.333 1.333 1.333h20.452l-7.996 6.997c-0.555 0.485-0.611 1.327-0.127 1.881 0.264 0.3 0.633 0.455 1.004 0.455 0.312 0 0.625-0.109 0.877-0.331l10.667-9.333c0.011-0.009 0.015-0.024 0.024-0.033 0.097-0.091 0.169-0.201 0.236-0.317 0.024-0.041 0.060-0.075 0.080-0.119 0.073-0.163 0.116-0.343 0.116-0.533s-0.043-0.371-0.116-0.535z"></path>\n</svg>\n'}))))))}componentDidLoad(){this.isReady=!0}};l.style=":host{display:block}.rtl .rtl-range-slider,[dir=rtl] .rtl-range-slider{transform:rotateY(180deg)}.rtl .rtl-range-numbers,[dir=rtl] .rtl-range-numbers{flex-direction:row-reverse}.rtl .form-select,.rtl select,[dir=rtl] .form-select,[dir=rtl] select{background-position:left 0.5rem center;padding-right:12px}.rtl .menu-divide li:not(:last-child):after,[dir=rtl] .menu-divide li:not(:last-child):after{left:0;right:auto}input[type=range]::-webkit-slider-thumb{pointer-events:all;width:24px;height:24px;-webkit-appearance:none}[type=checkbox]:checked{background-size:80%}";export{l as salla_price_range}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as e,c as t,h as s,H as a,g as i}from"./p-DVlAsZVJ.js";const n=class{constructor(s){e(this,s),this.invalidInput=t(this,"invalidInput"),this.bookNowLabel=salla.lang.get("pages.cart.book_an_appointment","حجز موعد"),this.editLabel=salla.lang.get("pages.cart.edit_an_appointment","تعديل الموعد"),this.bookedLabel=salla.lang.get("pages.cart.booked_successfully","تمت اضافة الموعد بنجاح"),this.selectDate=salla.lang.get("pages.cart.select_appointment_date","حدد تاريخ الموعد"),this.bookingUrl="",this.iframeReady=!1,this.reservations=[],salla.lang.onLoaded((()=>this.setTranslations())),Salla.event.on("booking::open",(e=>this.handleBookingOpen(e)))}async setTranslations(){const e=(e,t,s)=>new Promise((a=>{salla.helpers.setNested(salla.lang.messages[e],t,s),a(!0)}));await e("ar.trans","pages.cart.book_an_appointment","حجز موعد"),await e("en.trans","pages.cart.book_an_appointment","Book an Appointment"),await e("ar.trans","pages.cart.edit_an_appointment","تعديل الموعد"),await e("en.trans","pages.cart.edit_an_appointment","Edit an Appointment"),await e("ar.trans","pages.cart.booked_successfully","تمت اضافة الموعد بنجاح"),await e("en.trans","pages.cart.booked_successfully","Booked Successfully"),await e("ar.trans","pages.cart.select_appointment_date","حدد تاريخ الموعد"),await e("en.trans","pages.cart.select_appointment_date","Select appointment date"),this.bookNowLabel=salla.lang.get("pages.cart.book_an_appointment"),this.editLabel=salla.lang.get("pages.cart.edit_an_appointment"),this.bookedLabel=salla.lang.get("pages.cart.booked_successfully"),this.selectDate=salla.lang.get("pages.cart.select_appointment_date")}openBookingModal(e,t=!1){if(!t||e.detail&&"number"==typeof e.detail&&e.detail===this.productId)return salla.config.isGuest()?(this.setAfterReloadEvent("booking::open-after-reload",this.productId),void salla.event.dispatch("login::open")):void salla.booking.add(this.productId,!1).then((e=>{if("booking"!==e.data.redirect.to)throw new Error("Unexpected redirect!");salla.event.dispatch("booking::open",{url:e.data.redirect.url,id:this.productId})})).catch((e=>{salla.error(salla.lang.get("common.errors.error_occurred")),salla.logger.error(e.response||e)}))}handleBookingOpen(e){e.id===this.productId&&(this.bookingUrl=salla.url.addParamToUrl("product_id",e.id,e.url),this.iframeReady=!0,setTimeout((()=>{this.modal.setTitle(this.selectDate),this.modal.open()}),100))}setAfterReloadEvent(e,t){salla.storage.set("afterReloadEvent",{event:e,payload:t})}emitAfterReloadEvent(){const e=salla.storage.get("afterReloadEvent");if(e&&e.event){const t=new CustomEvent(e.event,{detail:e.payload});window.dispatchEvent(t),salla.storage.remove("afterReloadEvent")}}componentWillLoad(){this.option&&this.option.details.length&&(this.reservations=this.option.details)}componentDidLoad(){window.addEventListener("booking::open-after-reload",(e=>this.openBookingModal(e,!0))),this.emitAfterReloadEvent(),window.addEventListener("message",this.handleMessageEvent.bind(this)),this.reservationsInput.addEventListener("invalid",(e=>this.invalidInput.emit(e))),this.reservationsInput.addEventListener("input",(()=>{this.reservationsInput.setCustomValidity(""),this.reservationsInput.reportValidity()}))}handleMessageEvent(e){if("booking"!==e.data.source)return;const t=e.data.type,s=e.data.message;if(localStorage.getItem("debug")&&console.log(`Received an action:${t}`,e.data),"error"===t){if(s.fields?.reservation)return void salla.notify.error(s.fields.reservation[0]);const e=Object.values(s.fields||[s.message]).flat().map((e=>`<li>${e}</li>`)).join("");salla.notify.error(`<ul>${e}</ul>`)}if("success"===t){if(Number(s.productId)!==Number(this.productId))return;this.reservations=s.data.reservations.map((e=>{if(e.time&&e.time.length>0){const t=e.time[0];return{date:e.date,day:e.day,from_timestamp:t.from,to_timestamp:t.to}}return null})).filter((e=>null!==e)),salla.notify.success(this.bookedLabel),this.modal?.close(),setTimeout((()=>window.location.reload()))}"height"===t&&(this.iframe.height=s?.height+"px")}bookingModal(){return s("salla-modal",{class:"s-booking-field-modal",ref:e=>this.modal=e,width:"md",position:"middle",noPadding:!0},s("iframe",{ref:e=>this.iframe=e,src:this.bookingUrl,frameborder:"0"}))}renderReservationDate(e){return s("span",{class:e.from_timestamp?"s-booking-field-reservations-has-time":""},s("i",{class:"s-booking-field-reservations-icon",innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>calendar</title>\n<path d="M28 2.667h-2.667v-1.333c0-0.736-0.597-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v1.333h-13.333v-1.333c0-0.736-0.597-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v1.333h-2.667c-2.205 0-4 1.795-4 4v21.333c0 2.205 1.795 4 4 4h24c2.205 0 4-1.795 4-4v-21.333c0-2.205-1.795-4-4-4zM29.333 28c0 0.736-0.599 1.333-1.333 1.333h-24c-0.736 0-1.333-0.599-1.333-1.333v-13.333h26.667zM29.333 12h-26.667v-5.333c0-0.736 0.599-1.333 1.333-1.333h2.667v2.667c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.667h13.333v2.667c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.667h2.667c0.736 0 1.333 0.599 1.333 1.333z"></path>\n</svg>\n'}),e.date)}renderReservationTime(e){return e.from_timestamp?s("span",{class:"s-booking-field-reservations-time"},s("i",{class:"s-booking-field-reservations-icon",innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>time</title>\n<path d="M16 0c-8.823 0-16 7.177-16 16s7.177 16 16 16 16-7.177 16-16-7.177-16-16-16zM16 29.333c-7.352 0-13.333-5.981-13.333-13.333s5.981-13.333 13.333-13.333 13.333 5.981 13.333 13.333-5.981 13.333-13.333 13.333zM16 8c-0.736 0-1.333 0.596-1.333 1.333v6.667h-4c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333h5.333c0.736 0 1.333-0.596 1.333-1.333v-8c0-0.737-0.597-1.333-1.333-1.333z"></path>\n</svg>\n'}),s("span",null,e.from_timestamp," - ",e.to_timestamp)):""}render(){return s(a,{key:"04c9e3dc3dc825bd6905221d858c260f7ca34748"},s("div",{key:"07ec38cec1bd1798640dd7ea9592bb3b17d945c6",class:"s-booking-field-main"},this.option.required||this.reservations.length>0?s("div",{class:"s-booking-field-price"},s("span",{innerHTML:salla.money(this.option.price)})):"",s("salla-button",{key:"6b71889cfc0429d15c466a6f194df31549f09786",class:"s-booking-field-book-now",size:"small",loaderPosition:"center",fill:"outline",onClick:e=>this.openBookingModal(e,!1)},s("span",{key:"a16f8db6f52c7751ea605efcae04057ca0dc5b61",class:"s-booking-field-book-now-content"},s("span",{key:"95f6086a599bcc620c87ece6c6ae9620dba15581",innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>calendar-time</title>\n<path d="M22.667 17.333c-0.737 0-1.333 0.596-1.333 1.333v2.667h-2.667c-0.737 0-1.333 0.596-1.333 1.333s0.596 1.333 1.333 1.333h4c0.737 0 1.333-0.596 1.333-1.333v-4c0-0.737-0.596-1.333-1.333-1.333zM28 2.667h-2.667v-1.333c0-0.736-0.596-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v1.333h-13.333v-1.333c0-0.736-0.596-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v1.333h-2.667c-2.205 0-4 1.795-4 4v21.333c0 2.205 1.795 4 4 4h5.363c0.737 0 1.333-0.596 1.333-1.333s-0.596-1.333-1.333-1.333h-5.363c-0.736 0-1.333-0.597-1.333-1.333v-21.333c0-0.736 0.597-1.333 1.333-1.333h2.667v2.667c0 0.736 0.596 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.667h13.333v2.667c0 0.736 0.596 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.667h2.667c0.736 0 1.333 0.599 1.333 1.333v2.696c0 0.736 0.596 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.696c0-2.205-1.795-4-4-4zM22 12c-5.515 0-10 4.485-10 10s4.485 10 10 10 10-4.485 10-10-4.485-10-10-10zM22 29.333c-4.043 0-7.333-3.291-7.333-7.333s3.291-7.333 7.333-7.333 7.333 3.291 7.333 7.333-3.291 7.333-7.333 7.333z"></path>\n</svg>\n'}),this.reservations.length?this.editLabel:this.bookNowLabel))),this.reservations.length>0&&s("div",{key:"b3615100bbfff3d98d0ac99145aaf53449790c94",class:"s-booking-field-reservations"},this.reservations.map(((e,t)=>s("div",{key:t,class:"s-booking-field-reservations-item"},this.renderReservationDate(e),this.renderReservationTime(e))))),s("input",{key:"126f14f2e520b8696bc7450e209bad30b267878b",class:"s-hidden",name:this.option.name,required:this.option.required,value:"[]"===JSON.stringify(this.reservations)?"":JSON.stringify(this.reservations),ref:e=>this.reservationsInput=e}),this.iframeReady&&this.bookingModal())}get host(){return i(this)}};n.style=":host{display:block}";const o=class{constructor(t){e(this,t)}hideAllOptions(e){this.host.querySelectorAll(`[data-show-when^="options[${e}"]`).forEach((e=>{e.classList.add("hidden"),this.hideAllOptions(e.dataset.optionId),this.disableInputs(e)}))}disableInputs(e){e.querySelectorAll("[name]").forEach((e=>{e.setAttribute("disabled",""),e.removeAttribute("required"),"select"===e?.tagName?.toLowerCase()&&(e.value=""),["checkbox"].includes(e.getAttribute("type"))&&e.hasOwnProperty("checked")&&(e.checked=!1)}))}changeHandler(e){if(salla.event.emit("salla-onditional-fields::change",e),salla.log("Received the change event: ",e),!e.target||!["SELECT"].includes(e.target.tagName)&&!["checkbox","radio"].includes(e.target.getAttribute("type")))return void salla.log("Ignore the change because is not a supported input: "+(e?.target?.tagName||"N/A"));let t=e.target.name.replace("[]",""),s="checkbox"===e.target.getAttribute("type"),a="radio"===e.target.getAttribute("type");salla.log("Trying to find all elements with condition:",`[data-show-when^="${t}"]`),this.host.querySelectorAll(`[data-show-when^="${t}"]`).forEach((t=>{let i,n=!t?.dataset.showWhen.includes("!="),o=t?.dataset.showWhen.replace(/(.*)(=|!=)(.*)/gm,"$3").trim();i=s?Array.from(this.host.querySelectorAll(`input[name="${e.target.name}"]:checked`),(e=>e?.value)).includes(o.toString()):a?e.target.checked&&e.target.value===o:o===e.target.value,salla.log("The input is ",s?"Multiple":a?"Radio":"Single"," value:",i),n&&i||!n&&!i?(t.classList.remove("hidden"),t.querySelectorAll("[name]").forEach((e=>{if(e.removeAttribute("disabled"),"true"===e.closest(".s-product-options-option").dataset.optionRequired&&e.setAttribute("required",""),"checkbox"===e.getAttribute("type")){const t=Array.from(document.querySelectorAll(`input[type="checkbox"][name="${e.getAttribute("name")}"]`));t.some((e=>e.checked))&&t.forEach((e=>{e.removeAttribute("required")}))}}))):(this.hideAllOptions(t.dataset.optionId),t.classList.add("hidden"),this.disableInputs(t))}))}componentDidRender(){this.host.querySelectorAll("[data-show-when]").forEach((e=>{let t=e?.dataset?.showWhen.replace(/(.*)(=|!=)(.*)/gm,"$1").trim();t&&this.changeHandler({target:this.host.querySelector('[name^="'+t+'"]')})}))}render(){return s(a,{key:"405156ba83b8731039c2dd0ff800f617150cc722"},s("slot",{key:"2bff17ce7b49fef9b028d673992d256b00e9481b"}))}get host(){return i(this)}};export{n as salla_booking_field,o as salla_conditional_fields}
|
|
4
|
+
import{r as e,c as t,h as s,H as a,g as i}from"./p-DXrQDmAN.js";const n=class{constructor(s){e(this,s),this.invalidInput=t(this,"invalidInput"),this.bookNowLabel=salla.lang.get("pages.cart.book_an_appointment","حجز موعد"),this.editLabel=salla.lang.get("pages.cart.edit_an_appointment","تعديل الموعد"),this.bookedLabel=salla.lang.get("pages.cart.booked_successfully","تمت اضافة الموعد بنجاح"),this.selectDate=salla.lang.get("pages.cart.select_appointment_date","حدد تاريخ الموعد"),this.bookingUrl="",this.iframeReady=!1,this.reservations=[],salla.lang.onLoaded((()=>this.setTranslations())),Salla.event.on("booking::open",(e=>this.handleBookingOpen(e)))}async setTranslations(){const e=(e,t,s)=>new Promise((a=>{salla.helpers.setNested(salla.lang.messages[e],t,s),a(!0)}));await e("ar.trans","pages.cart.book_an_appointment","حجز موعد"),await e("en.trans","pages.cart.book_an_appointment","Book an Appointment"),await e("ar.trans","pages.cart.edit_an_appointment","تعديل الموعد"),await e("en.trans","pages.cart.edit_an_appointment","Edit an Appointment"),await e("ar.trans","pages.cart.booked_successfully","تمت اضافة الموعد بنجاح"),await e("en.trans","pages.cart.booked_successfully","Booked Successfully"),await e("ar.trans","pages.cart.select_appointment_date","حدد تاريخ الموعد"),await e("en.trans","pages.cart.select_appointment_date","Select appointment date"),this.bookNowLabel=salla.lang.get("pages.cart.book_an_appointment"),this.editLabel=salla.lang.get("pages.cart.edit_an_appointment"),this.bookedLabel=salla.lang.get("pages.cart.booked_successfully"),this.selectDate=salla.lang.get("pages.cart.select_appointment_date")}openBookingModal(e,t=!1){if(!t||e.detail&&"number"==typeof e.detail&&e.detail===this.productId)return salla.config.isGuest()?(this.setAfterReloadEvent("booking::open-after-reload",this.productId),void salla.event.dispatch("login::open")):void salla.booking.add(this.productId,!1).then((e=>{if("booking"!==e.data.redirect.to)throw new Error("Unexpected redirect!");salla.event.dispatch("booking::open",{url:e.data.redirect.url,id:this.productId})})).catch((e=>{salla.error(salla.lang.get("common.errors.error_occurred")),salla.logger.error(e.response||e)}))}handleBookingOpen(e){e.id===this.productId&&(this.bookingUrl=salla.url.addParamToUrl("product_id",e.id,e.url),this.iframeReady=!0,setTimeout((()=>{this.modal.setTitle(this.selectDate),this.modal.open()}),100))}setAfterReloadEvent(e,t){salla.storage.set("afterReloadEvent",{event:e,payload:t})}emitAfterReloadEvent(){const e=salla.storage.get("afterReloadEvent");if(e&&e.event){const t=new CustomEvent(e.event,{detail:e.payload});window.dispatchEvent(t),salla.storage.remove("afterReloadEvent")}}componentWillLoad(){this.option&&this.option.details.length&&(this.reservations=this.option.details)}componentDidLoad(){window.addEventListener("booking::open-after-reload",(e=>this.openBookingModal(e,!0))),this.emitAfterReloadEvent(),window.addEventListener("message",this.handleMessageEvent.bind(this)),this.reservationsInput.addEventListener("invalid",(e=>this.invalidInput.emit(e))),this.reservationsInput.addEventListener("input",(()=>{this.reservationsInput.setCustomValidity(""),this.reservationsInput.reportValidity()}))}handleMessageEvent(e){if("booking"!==e.data.source)return;const t=e.data.type,s=e.data.message;if(localStorage.getItem("debug")&&console.log(`Received an action:${t}`,e.data),"error"===t){if(s.fields?.reservation)return void salla.notify.error(s.fields.reservation[0]);const e=Object.values(s.fields||[s.message]).flat().map((e=>`<li>${e}</li>`)).join("");salla.notify.error(`<ul>${e}</ul>`)}if("success"===t){if(Number(s.productId)!==Number(this.productId))return;this.reservations=s.data.reservations.map((e=>{if(e.time&&e.time.length>0){const t=e.time[0];return{date:e.date,day:e.day,from_timestamp:t.from,to_timestamp:t.to}}return null})).filter((e=>null!==e)),salla.notify.success(this.bookedLabel),this.modal?.close(),setTimeout((()=>window.location.reload()))}"height"===t&&(this.iframe.height=s?.height+"px")}bookingModal(){return s("salla-modal",{class:"s-booking-field-modal",ref:e=>this.modal=e,width:"md",position:"middle",noPadding:!0},s("iframe",{ref:e=>this.iframe=e,src:this.bookingUrl,frameborder:"0"}))}renderReservationDate(e){return s("span",{class:e.from_timestamp?"s-booking-field-reservations-has-time":""},s("i",{class:"s-booking-field-reservations-icon",innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>calendar</title>\n<path d="M28 2.667h-2.667v-1.333c0-0.736-0.597-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v1.333h-13.333v-1.333c0-0.736-0.597-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v1.333h-2.667c-2.205 0-4 1.795-4 4v21.333c0 2.205 1.795 4 4 4h24c2.205 0 4-1.795 4-4v-21.333c0-2.205-1.795-4-4-4zM29.333 28c0 0.736-0.599 1.333-1.333 1.333h-24c-0.736 0-1.333-0.599-1.333-1.333v-13.333h26.667zM29.333 12h-26.667v-5.333c0-0.736 0.599-1.333 1.333-1.333h2.667v2.667c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.667h13.333v2.667c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.667h2.667c0.736 0 1.333 0.599 1.333 1.333z"></path>\n</svg>\n'}),e.date)}renderReservationTime(e){return e.from_timestamp?s("span",{class:"s-booking-field-reservations-time"},s("i",{class:"s-booking-field-reservations-icon",innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>time</title>\n<path d="M16 0c-8.823 0-16 7.177-16 16s7.177 16 16 16 16-7.177 16-16-7.177-16-16-16zM16 29.333c-7.352 0-13.333-5.981-13.333-13.333s5.981-13.333 13.333-13.333 13.333 5.981 13.333 13.333-5.981 13.333-13.333 13.333zM16 8c-0.736 0-1.333 0.596-1.333 1.333v6.667h-4c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333h5.333c0.736 0 1.333-0.596 1.333-1.333v-8c0-0.737-0.597-1.333-1.333-1.333z"></path>\n</svg>\n'}),s("span",null,e.from_timestamp," - ",e.to_timestamp)):""}render(){return s(a,{key:"04c9e3dc3dc825bd6905221d858c260f7ca34748"},s("div",{key:"07ec38cec1bd1798640dd7ea9592bb3b17d945c6",class:"s-booking-field-main"},this.option.required||this.reservations.length>0?s("div",{class:"s-booking-field-price"},s("span",{innerHTML:salla.money(this.option.price)})):"",s("salla-button",{key:"6b71889cfc0429d15c466a6f194df31549f09786",class:"s-booking-field-book-now",size:"small",loaderPosition:"center",fill:"outline",onClick:e=>this.openBookingModal(e,!1)},s("span",{key:"a16f8db6f52c7751ea605efcae04057ca0dc5b61",class:"s-booking-field-book-now-content"},s("span",{key:"95f6086a599bcc620c87ece6c6ae9620dba15581",innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>calendar-time</title>\n<path d="M22.667 17.333c-0.737 0-1.333 0.596-1.333 1.333v2.667h-2.667c-0.737 0-1.333 0.596-1.333 1.333s0.596 1.333 1.333 1.333h4c0.737 0 1.333-0.596 1.333-1.333v-4c0-0.737-0.596-1.333-1.333-1.333zM28 2.667h-2.667v-1.333c0-0.736-0.596-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v1.333h-13.333v-1.333c0-0.736-0.596-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v1.333h-2.667c-2.205 0-4 1.795-4 4v21.333c0 2.205 1.795 4 4 4h5.363c0.737 0 1.333-0.596 1.333-1.333s-0.596-1.333-1.333-1.333h-5.363c-0.736 0-1.333-0.597-1.333-1.333v-21.333c0-0.736 0.597-1.333 1.333-1.333h2.667v2.667c0 0.736 0.596 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.667h13.333v2.667c0 0.736 0.596 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.667h2.667c0.736 0 1.333 0.599 1.333 1.333v2.696c0 0.736 0.596 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-2.696c0-2.205-1.795-4-4-4zM22 12c-5.515 0-10 4.485-10 10s4.485 10 10 10 10-4.485 10-10-4.485-10-10-10zM22 29.333c-4.043 0-7.333-3.291-7.333-7.333s3.291-7.333 7.333-7.333 7.333 3.291 7.333 7.333-3.291 7.333-7.333 7.333z"></path>\n</svg>\n'}),this.reservations.length?this.editLabel:this.bookNowLabel))),this.reservations.length>0&&s("div",{key:"b3615100bbfff3d98d0ac99145aaf53449790c94",class:"s-booking-field-reservations"},this.reservations.map(((e,t)=>s("div",{key:t,class:"s-booking-field-reservations-item"},this.renderReservationDate(e),this.renderReservationTime(e))))),s("input",{key:"126f14f2e520b8696bc7450e209bad30b267878b",class:"s-hidden",name:this.option.name,required:this.option.required,value:"[]"===JSON.stringify(this.reservations)?"":JSON.stringify(this.reservations),ref:e=>this.reservationsInput=e}),this.iframeReady&&this.bookingModal())}get host(){return i(this)}};n.style=":host{display:block}";const o=class{constructor(t){e(this,t)}hideAllOptions(e){this.host.querySelectorAll(`[data-show-when^="options[${e}"]`).forEach((e=>{e.classList.add("hidden"),this.hideAllOptions(e.dataset.optionId),this.disableInputs(e)}))}disableInputs(e){e.querySelectorAll("[name]").forEach((e=>{e.setAttribute("disabled",""),e.removeAttribute("required"),"select"===e?.tagName?.toLowerCase()&&(e.value=""),["checkbox"].includes(e.getAttribute("type"))&&e.hasOwnProperty("checked")&&(e.checked=!1)}))}changeHandler(e){if(salla.event.emit("salla-onditional-fields::change",e),salla.log("Received the change event: ",e),!e.target||!["SELECT"].includes(e.target.tagName)&&!["checkbox","radio"].includes(e.target.getAttribute("type")))return void salla.log("Ignore the change because is not a supported input: "+(e?.target?.tagName||"N/A"));let t=e.target.name.replace("[]",""),s="checkbox"===e.target.getAttribute("type"),a="radio"===e.target.getAttribute("type");salla.log("Trying to find all elements with condition:",`[data-show-when^="${t}"]`),this.host.querySelectorAll(`[data-show-when^="${t}"]`).forEach((t=>{let i,n=!t?.dataset.showWhen.includes("!="),o=t?.dataset.showWhen.replace(/(.*)(=|!=)(.*)/gm,"$3").trim();i=s?Array.from(this.host.querySelectorAll(`input[name="${e.target.name}"]:checked`),(e=>e?.value)).includes(o.toString()):a?e.target.checked&&e.target.value===o:o===e.target.value,salla.log("The input is ",s?"Multiple":a?"Radio":"Single"," value:",i),n&&i||!n&&!i?(t.classList.remove("hidden"),t.querySelectorAll("[name]").forEach((e=>{if(e.removeAttribute("disabled"),"true"===e.closest(".s-product-options-option").dataset.optionRequired&&e.setAttribute("required",""),"checkbox"===e.getAttribute("type")){const t=Array.from(document.querySelectorAll(`input[type="checkbox"][name="${e.getAttribute("name")}"]`));t.some((e=>e.checked))&&t.forEach((e=>{e.removeAttribute("required")}))}}))):(this.hideAllOptions(t.dataset.optionId),t.classList.add("hidden"),this.disableInputs(t))}))}componentDidRender(){this.host.querySelectorAll("[data-show-when]").forEach((e=>{let t=e?.dataset?.showWhen.replace(/(.*)(=|!=)(.*)/gm,"$1").trim();t&&this.changeHandler({target:this.host.querySelector('[name^="'+t+'"]')})}))}render(){return s(a,{key:"405156ba83b8731039c2dd0ff800f617150cc722"},s("slot",{key:"2bff17ce7b49fef9b028d673992d256b00e9481b"}))}get host(){return i(this)}};export{n as salla_booking_field,o as salla_conditional_fields}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{a as i}from"./p-DVlAsZVJ.js";function t(i,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(e){if("default"!==e&&!(e in i)){var s=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(i,e,s.get?s:{enumerable:!0,get:function(){return t[e]}})}}))})),Object.freeze(i)}var e,s,n,a={exports:{}};var r,o=n?s:(n=1,e||(e=1,r=function(i){return function(){for(var t=[["Afghanistan","af","93"],["Albania","al","355"],["Algeria","dz","213"],["American Samoa","as","1",5,["684"]],["Andorra","ad","376"],["Angola","ao","244"],["Anguilla","ai","1",6,["264"]],["Antigua & Barbuda","ag","1",7,["268"]],["Argentina","ar","54"],["Armenia","am","374"],["Aruba","aw","297"],["Ascension Island","ac","247"],["Australia","au","61",0],["Austria","at","43"],["Azerbaijan","az","994"],["Bahamas","bs","1",8,["242"]],["Bahrain","bh","973"],["Bangladesh","bd","880"],["Barbados","bb","1",9,["246"]],["Belarus","by","375"],["Belgium","be","32"],["Belize","bz","501"],["Benin","bj","229"],["Bermuda","bm","1",10,["441"]],["Bhutan","bt","975"],["Bolivia","bo","591"],["Bosnia & Herzegovina","ba","387"],["Botswana","bw","267"],["Brazil","br","55"],["British Indian Ocean Territory","io","246"],["British Virgin Islands","vg","1",11,["284"]],["Brunei","bn","673"],["Bulgaria","bg","359"],["Burkina Faso","bf","226"],["Burundi","bi","257"],["Cambodia","kh","855"],["Cameroon","cm","237"],["Canada","ca","1",1,["204","226","236","249","250","263","289","306","343","354","365","367","368","382","387","403","416","418","428","431","437","438","450","584","468","474","506","514","519","548","579","581","584","587","604","613","639","647","672","683","705","709","742","753","778","780","782","807","819","825","867","873","902","905"]],["Cape Verde","cv","238"],["Caribbean Netherlands","bq","599",1,["3","4","7"]],["Cayman Islands","ky","1",12,["345"]],["Central African Republic","cf","236"],["Chad","td","235"],["Chile","cl","56"],["China","cn","86"],["Christmas Island","cx","61",2,["89164"]],["Cocos (Keeling) Islands","cc","61",1,["89162"]],["Colombia","co","57"],["Comoros","km","269"],["Congo - Brazzaville","cg","242"],["Congo - Kinshasa","cd","243"],["Cook Islands","ck","682"],["Costa Rica","cr","506"],["Côte d’Ivoire","ci","225"],["Croatia","hr","385"],["Cuba","cu","53"],["Curaçao","cw","599",0],["Cyprus","cy","357"],["Czech Republic","cz","420"],["Denmark","dk","45"],["Djibouti","dj","253"],["Dominica","dm","1",13,["767"]],["Dominican Republic","do","1",2,["809","829","849"]],["Ecuador","ec","593"],["Egypt","eg","20"],["El Salvador","sv","503"],["Equatorial Guinea","gq","240"],["Eritrea","er","291"],["Estonia","ee","372"],["Eswatini","sz","268"],["Ethiopia","et","251"],["Falkland Islands","fk","500"],["Faroe Islands","fo","298"],["Fiji","fj","679"],["Finland","fi","358",0],["France","fr","33"],["French Guiana","gf","594"],["French Polynesia","pf","689"],["Gabon","ga","241"],["Gambia","gm","220"],["Georgia","ge","995"],["Germany","de","49"],["Ghana","gh","233"],["Gibraltar","gi","350"],["Greece","gr","30"],["Greenland","gl","299"],["Grenada","gd","1",14,["473"]],["Guadeloupe","gp","590",0],["Guam","gu","1",15,["671"]],["Guatemala","gt","502"],["Guernsey","gg","44",1,["1481","7781","7839","7911"]],["Guinea","gn","224"],["Guinea-Bissau","gw","245"],["Guyana","gy","592"],["Haiti","ht","509"],["Honduras","hn","504"],["Hong Kong","hk","852"],["Hungary","hu","36"],["Iceland","is","354"],["India","in","91"],["Indonesia","id","62"],["Iran","ir","98"],["Iraq","iq","964"],["Ireland","ie","353"],["Isle of Man","im","44",2,["1624","74576","7524","7924","7624"]],["Israel","il","972"],["Italy","it","39",0],["Jamaica","jm","1",4,["876","658"]],["Japan","jp","81"],["Jersey","je","44",3,["1534","7509","7700","7797","7829","7937"]],["Jordan","jo","962"],["Kazakhstan","kz","7",1,["33","7"]],["Kenya","ke","254"],["Kiribati","ki","686"],["Kosovo","xk","383"],["Kuwait","kw","965"],["Kyrgyzstan","kg","996"],["Laos","la","856"],["Latvia","lv","371"],["Lebanon","lb","961"],["Lesotho","ls","266"],["Liberia","lr","231"],["Libya","ly","218"],["Liechtenstein","li","423"],["Lithuania","lt","370"],["Luxembourg","lu","352"],["Macau","mo","853"],["Madagascar","mg","261"],["Malawi","mw","265"],["Malaysia","my","60"],["Maldives","mv","960"],["Mali","ml","223"],["Malta","mt","356"],["Marshall Islands","mh","692"],["Martinique","mq","596"],["Mauritania","mr","222"],["Mauritius","mu","230"],["Mayotte","yt","262",1,["269","639"]],["Mexico","mx","52"],["Micronesia","fm","691"],["Moldova","md","373"],["Monaco","mc","377"],["Mongolia","mn","976"],["Montenegro","me","382"],["Montserrat","ms","1",16,["664"]],["Morocco","ma","212",0],["Mozambique","mz","258"],["Myanmar (Burma)","mm","95"],["Namibia","na","264"],["Nauru","nr","674"],["Nepal","np","977"],["Netherlands","nl","31"],["New Caledonia","nc","687"],["New Zealand","nz","64"],["Nicaragua","ni","505"],["Niger","ne","227"],["Nigeria","ng","234"],["Niue","nu","683"],["Norfolk Island","nf","672"],["North Korea","kp","850"],["North Macedonia","mk","389"],["Northern Mariana Islands","mp","1",17,["670"]],["Norway","no","47",0],["Oman","om","968"],["Pakistan","pk","92"],["Palau","pw","680"],["Palestine","ps","970"],["Panama","pa","507"],["Papua New Guinea","pg","675"],["Paraguay","py","595"],["Peru","pe","51"],["Philippines","ph","63"],["Poland","pl","48"],["Portugal","pt","351"],["Puerto Rico","pr","1",3,["787","939"]],["Qatar","qa","974"],["Réunion","re","262",0],["Romania","ro","40"],["Russia","ru","7",0],["Rwanda","rw","250"],["Samoa","ws","685"],["San Marino","sm","378"],["São Tomé & Príncipe","st","239"],["Saudi Arabia","sa","966"],["Senegal","sn","221"],["Serbia","rs","381"],["Seychelles","sc","248"],["Sierra Leone","sl","232"],["Singapore","sg","65"],["Sint Maarten","sx","1",21,["721"]],["Slovakia","sk","421"],["Slovenia","si","386"],["Solomon Islands","sb","677"],["Somalia","so","252"],["South Africa","za","27"],["South Korea","kr","82"],["South Sudan","ss","211"],["Spain","es","34"],["Sri Lanka","lk","94"],["St Barthélemy","bl","590",1],["St Helena","sh","290"],["St Kitts & Nevis","kn","1",18,["869"]],["St Lucia","lc","1",19,["758"]],["St Martin","mf","590",2],["St Pierre & Miquelon","pm","508"],["St Vincent & Grenadines","vc","1",20,["784"]],["Sudan","sd","249"],["Suriname","sr","597"],["Svalbard & Jan Mayen","sj","47",1,["79"]],["Sweden","se","46"],["Switzerland","ch","41"],["Syria","sy","963"],["Taiwan","tw","886"],["Tajikistan","tj","992"],["Tanzania","tz","255"],["Thailand","th","66"],["Timor-Leste","tl","670"],["Togo","tg","228"],["Tokelau","tk","690"],["Tonga","to","676"],["Trinidad & Tobago","tt","1",22,["868"]],["Tunisia","tn","216"],["Turkey","tr","90"],["Turkmenistan","tm","993"],["Turks & Caicos Islands","tc","1",23,["649"]],["Tuvalu","tv","688"],["Uganda","ug","256"],["Ukraine","ua","380"],["United Arab Emirates","ae","971"],["United Kingdom","gb","44",0],["United States","us","1",0],["Uruguay","uy","598"],["US Virgin Islands","vi","1",24,["340"]],["Uzbekistan","uz","998"],["Vanuatu","vu","678"],["Vatican City","va","39",1,["06698"]],["Venezuela","ve","58"],["Vietnam","vn","84"],["Wallis & Futuna","wf","681"],["Western Sahara","eh","212",1,["5288","5289"]],["Yemen","ye","967"],["Zambia","zm","260"],["Zimbabwe","zw","263"],["Åland Islands","ax","358",1,["18"]]],e=0;e<t.length;e++){var s=t[e];t[e]={name:s[0],iso2:s[1],dialCode:s[2],priority:s[3]||0,areaCodes:s[4]||null}}function n(i,t,e){return(t=a(t))in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}function a(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(e!==i){var s=e.call(t,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}var r={getInstance:function(i){var t=i.getAttribute("data-intl-tel-input-id");return window.intlTelInputGlobals.instances[t]},instances:{},documentReady:function(){return"complete"===document.readyState}};"object"==typeof window&&(window.intlTelInputGlobals=r);var o=0,h={allowDropdown:!0,autoInsertDialCode:!1,autoPlaceholder:"polite",countrySearch:!1,customContainer:"",customPlaceholder:null,dropdownContainer:null,excludeCountries:[],fixDropdownWidth:!1,formatOnDisplay:!0,geoIpLookup:null,hiddenInput:"",initialCountry:"",localizedCountries:null,nationalMode:!0,onlyCountries:[],placeholderNumberType:"MOBILE",preferredCountries:["us","gb"],separateDialCode:!1,showFlags:!0,useFullscreenPopup:"undefined"!=typeof navigator&&"undefined"!=typeof window&&(/Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||window.innerWidth<=500),utilsScript:""},u=["800","822","833","844","855","866","877","880","881","882","883","884","885","886","887","888","889"],l=function(i,t){for(var e=Object.keys(i),s=0;s<e.length;s++)t(e[s],i[e[s]])},c=function(i){l(window.intlTelInputGlobals.instances,(function(t){window.intlTelInputGlobals.instances[t][i]()}))},d=function(){function e(i,t){var s=this;!function(i,t){if(!(i instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.id=o++,this.telInput=i,this.activeItem=null,this.highlightedItem=null;var n=t||{};this.options={},l(h,(function(i,t){s.options[i]=n.hasOwnProperty(i)?n[i]:t})),this.hadInitialPlaceholder=Boolean(i.getAttribute("placeholder"))}return s=e,r=[{key:"_init",value:function(){var i=this;if(this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!1),this.options.countrySearch&&!this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!0),this.options.nationalMode&&(this.options.autoInsertDialCode=!1),this.options.separateDialCode&&(this.options.autoInsertDialCode=!1),!this.options.showFlags&&this.options.allowDropdown&&!this.options.separateDialCode&&(this.options.showFlags=!0),this.options.useFullscreenPopup&&!this.options.dropdownContainer&&(this.options.dropdownContainer=document.body),this.isRTL=!!this.telInput.closest("[dir=rtl]"),"undefined"!=typeof Promise){var t=new Promise((function(t,e){i.resolveAutoCountryPromise=t,i.rejectAutoCountryPromise=e})),e=new Promise((function(t,e){i.resolveUtilsScriptPromise=t,i.rejectUtilsScriptPromise=e}));this.promise=Promise.all([t,e])}else this.resolveAutoCountryPromise=this.rejectAutoCountryPromise=function(){},this.resolveUtilsScriptPromise=this.rejectUtilsScriptPromise=function(){};this.selectedCountryData={},this._processCountryData(),this._generateMarkup(),this._setInitialState(),this._initListeners(),this._initRequests()}},{key:"_processCountryData",value:function(){this._processAllCountries(),this._processCountryCodes(),this._processPreferredCountries(),this.options.localizedCountries&&this._translateCountriesByLocale(),(this.options.onlyCountries.length||this.options.localizedCountries)&&this.countries.sort(this._countryNameSort)}},{key:"_addCountryCode",value:function(t,e,s){e.length>this.countryCodeMaxLen&&(this.countryCodeMaxLen=e.length),this.countryCodes.hasOwnProperty(e)||(this.countryCodes[e]=[]);for(var n=0;n<this.countryCodes[e].length;n++)if(this.countryCodes[e][n]===t)return;this.countryCodes[e][s!==i?s:this.countryCodes[e].length]=t}},{key:"_processAllCountries",value:function(){if(this.options.onlyCountries.length){var i=this.options.onlyCountries.map((function(i){return i.toLowerCase()}));this.countries=t.filter((function(t){return i.indexOf(t.iso2)>-1}))}else if(this.options.excludeCountries.length){var e=this.options.excludeCountries.map((function(i){return i.toLowerCase()}));this.countries=t.filter((function(i){return-1===e.indexOf(i.iso2)}))}else this.countries=t}},{key:"_translateCountriesByLocale",value:function(){for(var i=0;i<this.countries.length;i++){var t=this.countries[i].iso2.toLowerCase();this.options.localizedCountries.hasOwnProperty(t)&&(this.countries[i].name=this.options.localizedCountries[t])}}},{key:"_countryNameSort",value:function(i,t){return i.name<t.name?-1:i.name>t.name?1:0}},{key:"_processCountryCodes",value:function(){this.countryCodeMaxLen=0,this.dialCodes={},this.countryCodes={};for(var i=0;i<this.countries.length;i++){var t=this.countries[i];this.dialCodes[t.dialCode]||(this.dialCodes[t.dialCode]=!0),this._addCountryCode(t.iso2,t.dialCode,t.priority)}for(var e=0;e<this.countries.length;e++){var s=this.countries[e];if(s.areaCodes)for(var n=this.countryCodes[s.dialCode][0],a=0;a<s.areaCodes.length;a++){for(var r=s.areaCodes[a],o=1;o<r.length;o++){var h=s.dialCode+r.substr(0,o);this._addCountryCode(n,h),this._addCountryCode(s.iso2,h)}this._addCountryCode(s.iso2,s.dialCode+r)}}}},{key:"_processPreferredCountries",value:function(){this.preferredCountries=[];for(var i=0;i<this.options.preferredCountries.length;i++){var t=this.options.preferredCountries[i].toLowerCase(),e=this._getCountryData(t,!1,!0);e&&this.preferredCountries.push(e)}}},{key:"_createEl",value:function(i,t,e){var s=document.createElement(i);return t&&l(t,(function(i,t){return s.setAttribute(i,t)})),e&&e.appendChild(s),s}},{key:"_generateMarkup",value:function(){this.telInput.classList.add("iti__tel-input"),this.telInput.hasAttribute("autocomplete")||this.telInput.form&&this.telInput.form.hasAttribute("autocomplete")||this.telInput.setAttribute("autocomplete","off");var i=this.options,t=i.allowDropdown,e=i.separateDialCode,s=i.showFlags,a=i.customContainer,r=i.hiddenInput,o=i.dropdownContainer,h=i.fixDropdownWidth,u=i.useFullscreenPopup,l=i.countrySearch,c="iti";t&&(c+=" iti--allow-dropdown"),e&&(c+=" iti--separate-dial-code"),s&&(c+=" iti--show-flags"),a&&(c+=" ".concat(a));var d=this._createEl("div",{class:c});this.telInput.parentNode.insertBefore(d,this.telInput);var f=t||s||e;if(f&&(this.flagsContainer=this._createEl("div",{class:"iti__flag-container"},d)),d.appendChild(this.telInput),f&&(this.selectedFlag=this._createEl("div",function(i){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?Object(arguments[t]):{},s=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&s.push.apply(s,Object.getOwnPropertySymbols(e).filter((function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable}))),s.forEach((function(t){n(i,t,e[t])}))}return i}({class:"iti__selected-flag"},t&&{role:"combobox","aria-haspopup":"listbox","aria-controls":"iti-".concat(this.id,"__country-listbox"),"aria-expanded":"false","aria-label":"Telephone country code"}),this.flagsContainer)),s&&(this.selectedFlagInner=this._createEl("div",{class:"iti__flag"},this.selectedFlag)),this.selectedFlag&&this.telInput.disabled&&this.selectedFlag.setAttribute("aria-disabled","true"),e&&(this.selectedDialCode=this._createEl("div",{class:"iti__selected-dial-code"},this.selectedFlag)),t)if(this.telInput.disabled||this.selectedFlag.setAttribute("tabindex","0"),this.dropdownArrow=this._createEl("div",{class:"iti__arrow"},this.selectedFlag),this.dropdownContent=this._createEl("div",{class:"iti__dropdown-content iti__hide ".concat(h?"":"iti--flexible-dropdown-width")}),l&&(this.searchInput=this._createEl("input",{type:"text",class:"iti__search-input",placeholder:"Search"},this.dropdownContent)),this.countryList=this._createEl("ul",{class:"iti__country-list",id:"iti-".concat(this.id,"__country-listbox"),role:"listbox","aria-label":"List of countries"},this.dropdownContent),this.preferredCountries.length&&!l&&(this._appendListItems(this.preferredCountries,"iti__preferred",!0),this._createEl("li",{class:"iti__divider","aria-hidden":"true"},this.countryList)),this._appendListItems(this.countries,"iti__standard"),o){var v="iti iti--container";u&&(v+=" iti--fullscreen-popup"),l&&(v+=" iti--country-search"),this.dropdown=this._createEl("div",{class:v}),this.dropdown.appendChild(this.dropdownContent)}else this.flagsContainer.appendChild(this.dropdownContent);if(r){var p=r,y=this.telInput.getAttribute("name");if(y){var m=y.lastIndexOf("[");-1!==m&&(p="".concat(y.substr(0,m),"[").concat(p,"]"))}this.hiddenInput=this._createEl("input",{type:"hidden",name:p}),d.appendChild(this.hiddenInput)}}},{key:"_appendListItems",value:function(i,t,e){for(var s=0;s<i.length;s++){var n=i[s],a=e?"-preferred":"",r=this._createEl("li",{id:"iti-".concat(this.id,"__item-").concat(n.iso2).concat(a),class:"iti__country ".concat(t),tabindex:"-1",role:"option","data-dial-code":n.dialCode,"data-country-code":n.iso2,"aria-selected":"false"},this.countryList);n.node=r;var o="";this.options.showFlags&&(o+="<div class='iti__flag-box'><div class='iti__flag iti__".concat(n.iso2,"'></div></div>")),o+="<span class='iti__country-name'>".concat(n.name,"</span>"),o+="<span class='iti__dial-code'>+".concat(n.dialCode,"</span>"),r.insertAdjacentHTML("beforeend",o)}}},{key:"_setInitialState",value:function(){var i=this.telInput.getAttribute("value"),t=this.telInput.value,e=!i||"+"!==i.charAt(0)||t&&"+"===t.charAt(0)?t:i,s=this._getDialCode(e),n=this._isRegionlessNanp(e),a=this.options,r=a.initialCountry,o=a.autoInsertDialCode;s&&!n?this._updateFlagFromNumber(e):"auto"!==r&&(r&&this._getCountryData(r,!1,!0)?this._setFlag(r.toLowerCase()):s&&n?this._setFlag("us"):(this.defaultCountry=this.preferredCountries.length?this.preferredCountries[0].iso2:this.countries[0].iso2,e||this._setFlag(this.defaultCountry)),!e&&o&&(this.telInput.value="+".concat(this.selectedCountryData.dialCode))),e&&this._updateValFromNumber(e)}},{key:"_initListeners",value:function(){this._initKeyListeners(),this.options.autoInsertDialCode&&this._initBlurListeners(),this.options.allowDropdown&&this._initDropdownListeners(),this.hiddenInput&&this._initHiddenInputListener()}},{key:"_initHiddenInputListener",value:function(){var i=this;this._handleHiddenInputSubmit=function(){i.hiddenInput.value=i.getNumber()},this.telInput.form&&this.telInput.form.addEventListener("submit",this._handleHiddenInputSubmit)}},{key:"_getClosestLabel",value:function(){for(var i=this.telInput;i&&"LABEL"!==i.tagName;)i=i.parentNode;return i}},{key:"_initDropdownListeners",value:function(){var i=this;this._handleLabelClick=function(t){i.dropdownContent.classList.contains("iti__hide")?i.telInput.focus():t.preventDefault()};var t=this._getClosestLabel();t&&t.addEventListener("click",this._handleLabelClick),this._handleClickSelectedFlag=function(){!i.dropdownContent.classList.contains("iti__hide")||i.telInput.disabled||i.telInput.readOnly||i._showDropdown()},this.selectedFlag.addEventListener("click",this._handleClickSelectedFlag),this._handleFlagsContainerKeydown=function(t){i.dropdownContent.classList.contains("iti__hide")&&["ArrowUp","ArrowDown"," ","Enter"].includes(t.key)&&(t.preventDefault(),t.stopPropagation(),i._showDropdown()),"Tab"===t.key&&i._closeDropdown()},this.flagsContainer.addEventListener("keydown",this._handleFlagsContainerKeydown)}},{key:"_initRequests",value:function(){var i=this;this.options.utilsScript&&!window.intlTelInputUtils?window.intlTelInputGlobals.documentReady()?window.intlTelInputGlobals.loadUtils(this.options.utilsScript):window.addEventListener("load",(function(){window.intlTelInputGlobals.loadUtils(i.options.utilsScript)})):this.resolveUtilsScriptPromise(),"auto"===this.options.initialCountry?this._loadAutoCountry():this.resolveAutoCountryPromise()}},{key:"_loadAutoCountry",value:function(){window.intlTelInputGlobals.autoCountry?this.handleAutoCountry():window.intlTelInputGlobals.startedLoadingAutoCountry||(window.intlTelInputGlobals.startedLoadingAutoCountry=!0,"function"==typeof this.options.geoIpLookup&&this.options.geoIpLookup((function(i){window.intlTelInputGlobals.autoCountry=i.toLowerCase(),setTimeout((function(){return c("handleAutoCountry")}))}),(function(){return c("rejectAutoCountryPromise")})))}},{key:"_initKeyListeners",value:function(){var i=this;this._handleKeyupEvent=function(){i._updateFlagFromNumber(i.telInput.value)&&i._triggerCountryChange()},this.telInput.addEventListener("keyup",this._handleKeyupEvent),this._handleClipboardEvent=function(){setTimeout(i._handleKeyupEvent)},this.telInput.addEventListener("cut",this._handleClipboardEvent),this.telInput.addEventListener("paste",this._handleClipboardEvent)}},{key:"_cap",value:function(i){var t=this.telInput.getAttribute("maxlength");return t&&i.length>t?i.substr(0,t):i}},{key:"_initBlurListeners",value:function(){var i=this;this._handleSubmitOrBlurEvent=function(){i._removeEmptyDialCode()},this.telInput.form&&this.telInput.form.addEventListener("submit",this._handleSubmitOrBlurEvent),this.telInput.addEventListener("blur",this._handleSubmitOrBlurEvent)}},{key:"_removeEmptyDialCode",value:function(){if("+"===this.telInput.value.charAt(0)){var i=this._getNumeric(this.telInput.value);i&&this.selectedCountryData.dialCode!==i||(this.telInput.value="")}}},{key:"_getNumeric",value:function(i){return i.replace(/\D/g,"")}},{key:"_trigger",value:function(i){var t=document.createEvent("Event");t.initEvent(i,!0,!0),this.telInput.dispatchEvent(t)}},{key:"_showDropdown",value:function(){this.options.fixDropdownWidth&&(this.dropdownContent.style.width="".concat(this.telInput.offsetWidth,"px")),this.dropdownContent.classList.remove("iti__hide"),this.selectedFlag.setAttribute("aria-expanded","true"),this._setDropdownPosition(),this.options.countrySearch?(this._highlightListItem(this.countryList.firstElementChild,!1),this.searchInput.focus()):this.activeItem&&(this._highlightListItem(this.activeItem,!1),this._scrollTo(this.activeItem,!0)),this._bindDropdownListeners(),this.dropdownArrow.classList.add("iti__arrow--up"),this._trigger("open:countrydropdown")}},{key:"_toggleClass",value:function(i,t,e){e&&!i.classList.contains(t)?i.classList.add(t):!e&&i.classList.contains(t)&&i.classList.remove(t)}},{key:"_setDropdownPosition",value:function(){var i=this;if(this.options.dropdownContainer&&this.options.dropdownContainer.appendChild(this.dropdown),!this.options.useFullscreenPopup){var t=this.telInput.getBoundingClientRect(),e=window.pageYOffset||document.documentElement.scrollTop,s=t.top+e,n=this.dropdownContent.offsetHeight,a=s+this.telInput.offsetHeight+n<e+window.innerHeight,r=!this.options.countrySearch&&!a&&s-n>e;this._toggleClass(this.dropdownContent,"iti__dropdown-content--dropup",r),this.options.dropdownContainer&&(this.dropdown.style.top="".concat(s+(r?0:this.telInput.offsetHeight),"px"),this.dropdown.style.left="".concat(t.left+document.body.scrollLeft,"px"),this._handleWindowScroll=function(){return i._closeDropdown()},window.addEventListener("scroll",this._handleWindowScroll))}}},{key:"_getClosestListItem",value:function(i){for(var t=i;t&&t!==this.countryList&&!t.classList.contains("iti__country");)t=t.parentNode;return t===this.countryList?null:t}},{key:"_bindDropdownListeners",value:function(){var i=this;this._handleMouseoverCountryList=function(t){var e=i._getClosestListItem(t.target);e&&i._highlightListItem(e,!1)},this.countryList.addEventListener("mouseover",this._handleMouseoverCountryList),this._handleClickCountryList=function(t){var e=i._getClosestListItem(t.target);e&&i._selectListItem(e)},this.countryList.addEventListener("click",this._handleClickCountryList);var t=!0;this._handleClickOffToClose=function(){t||i._closeDropdown(),t=!1},document.documentElement.addEventListener("click",this._handleClickOffToClose);var e="",s=null;if(this._handleKeydownOnDropdown=function(t){["ArrowUp","ArrowDown","Enter","Escape"].includes(t.key)&&(t.preventDefault(),t.stopPropagation(),"ArrowUp"===t.key||"ArrowDown"===t.key?i._handleUpDownKey(t.key):"Enter"===t.key?i._handleEnterKey():"Escape"===t.key&&i._closeDropdown()),!i.options.countrySearch&&/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(t.key)&&(t.stopPropagation(),s&&clearTimeout(s),e+=t.key.toLowerCase(),i._searchForCountry(e),s=setTimeout((function(){e=""}),1e3))},document.addEventListener("keydown",this._handleKeydownOnDropdown),this.options.countrySearch){var n=null;this._handleSearchChange=function(){n&&clearTimeout(n),n=setTimeout((function(){var t;(t=i.searchInput.value.trim())?i._filterCountries(t.toLowerCase()):i._filterCountries(null,!0),n=null}),100)},this.searchInput.addEventListener("input",this._handleSearchChange),this.searchInput.addEventListener("click",(function(i){return i.stopPropagation()}))}}},{key:"_filterCountries",value:function(t){var e=arguments.length>1&&arguments[1]!==i&&arguments[1],s=!0;this.countryList.innerHTML="";for(var n=0;n<this.countries.length;n++){var a=this.countries[n],r=a.name.toLowerCase(),o="+".concat(a.dialCode);(e||r.includes(t)||o.includes(t))&&(this.countryList.appendChild(a.node),s&&(this._highlightListItem(a.node,!1),s=!1))}}},{key:"_handleUpDownKey",value:function(i){var t="ArrowUp"===i?this.highlightedItem.previousElementSibling:this.highlightedItem.nextElementSibling;t?t.classList.contains("iti__divider")&&(t="ArrowUp"===i?t.previousElementSibling:t.nextElementSibling):this.countryList.childElementCount>1&&(t="ArrowUp"===i?this.countryList.lastElementChild:this.countryList.firstElementChild),t&&(this._highlightListItem(t,!this.options.countrySearch),this.options.countrySearch&&this._scrollTo(t,!1))}},{key:"_handleEnterKey",value:function(){this.highlightedItem&&this._selectListItem(this.highlightedItem)}},{key:"_searchForCountry",value:function(i){for(var t=0;t<this.countries.length;t++)if(this._startsWith(this.countries[t].name,i)){var e=this.countries[t].node;this._highlightListItem(e,!1),this._scrollTo(e,!0);break}}},{key:"_startsWith",value:function(i,t){return i.substr(0,t.length).toLowerCase()===t}},{key:"_updateValFromNumber",value:function(i){var t=i;if(this.options.formatOnDisplay&&window.intlTelInputUtils&&this.selectedCountryData){var e=this.options.nationalMode||"+"!==t.charAt(0)&&!this.options.separateDialCode,s=intlTelInputUtils.numberFormat;t=intlTelInputUtils.formatNumber(t,this.selectedCountryData.iso2,e?s.NATIONAL:s.INTERNATIONAL)}t=this._beforeSetNumber(t),this.telInput.value=t}},{key:"_updateFlagFromNumber",value:function(i){var t=i.indexOf("+"),e=t?i.substring(t):i,s=this.selectedCountryData.dialCode;e&&"1"===s&&"+"!==e.charAt(0)&&("1"!==e.charAt(0)&&(e="1".concat(e)),e="+".concat(e)),this.options.separateDialCode&&s&&"+"!==e.charAt(0)&&(e="+".concat(s).concat(e));var n=this._getDialCode(e,!0),a=this._getNumeric(e),r=null;if(n){var o=this.countryCodes[this._getNumeric(n)],h=-1!==o.indexOf(this.selectedCountryData.iso2)&&a.length<=n.length-1;if(!("1"===s&&this._isRegionlessNanp(a)||h))for(var u=0;u<o.length;u++)if(o[u]){r=o[u];break}}else"+"===e.charAt(0)&&a.length?r="":e&&"+"!==e||(r=this.defaultCountry);return null!==r&&this._setFlag(r)}},{key:"_isRegionlessNanp",value:function(i){var t=this._getNumeric(i);if("1"===t.charAt(0)){var e=t.substr(1,3);return-1!==u.indexOf(e)}return!1}},{key:"_highlightListItem",value:function(i,t){var e=this.highlightedItem;e&&e.classList.remove("iti__highlight"),this.highlightedItem=i,this.highlightedItem.classList.add("iti__highlight"),this.selectedFlag.setAttribute("aria-activedescendant",i.getAttribute("id")),t&&this.highlightedItem.focus()}},{key:"_getCountryData",value:function(i,e,s){for(var n=e?t:this.countries,a=0;a<n.length;a++)if(n[a].iso2===i)return n[a];if(s)return null;throw new Error("No country data for '".concat(i,"'"))}},{key:"_setFlag",value:function(i){var t=this.options,e=t.allowDropdown,s=t.separateDialCode,n=t.showFlags,a=this.selectedCountryData.iso2?this.selectedCountryData:{};if(this.selectedCountryData=i?this._getCountryData(i,!1,!1):{},this.selectedCountryData.iso2&&(this.defaultCountry=this.selectedCountryData.iso2),n&&this.selectedFlagInner.setAttribute("class","iti__flag iti__".concat(i)),this._setSelectedCountryFlagTitleAttribute(i,s),s){var r=this.selectedCountryData.dialCode?"+".concat(this.selectedCountryData.dialCode):"";this.selectedDialCode.innerHTML=r;var o=this.selectedFlag.offsetWidth||this._getHiddenSelectedFlagWidth();this.isRTL?this.telInput.style.paddingRight="".concat(o+6,"px"):this.telInput.style.paddingLeft="".concat(o+6,"px")}if(this._updatePlaceholder(),e){var h=this.activeItem;if(h&&(h.classList.remove("iti__active"),h.setAttribute("aria-selected","false")),i){var u=this.countryList.querySelector("#iti-".concat(this.id,"__item-").concat(i,"-preferred"))||this.countryList.querySelector("#iti-".concat(this.id,"__item-").concat(i));u.setAttribute("aria-selected","true"),u.classList.add("iti__active"),this.activeItem=u}}return a.iso2!==i}},{key:"_setSelectedCountryFlagTitleAttribute",value:function(i,t){var e;this.selectedFlag&&(e=i&&!t?"".concat(this.selectedCountryData.name,": +").concat(this.selectedCountryData.dialCode):i?this.selectedCountryData.name:"Unknown",this.selectedFlag.setAttribute("title",e))}},{key:"_getHiddenSelectedFlagWidth",value:function(){var i=this.telInput.parentNode.cloneNode();i.style.visibility="hidden",document.body.appendChild(i);var t=this.flagsContainer.cloneNode();i.appendChild(t);var e=this.selectedFlag.cloneNode(!0);t.appendChild(e);var s=e.offsetWidth;return i.parentNode.removeChild(i),s}},{key:"_updatePlaceholder",value:function(){if(window.intlTelInputUtils&&("aggressive"===this.options.autoPlaceholder||!this.hadInitialPlaceholder&&"polite"===this.options.autoPlaceholder)){var i=intlTelInputUtils.numberType[this.options.placeholderNumberType],t=this.selectedCountryData.iso2?intlTelInputUtils.getExampleNumber(this.selectedCountryData.iso2,this.options.nationalMode,i):"";t=this._beforeSetNumber(t),"function"==typeof this.options.customPlaceholder&&(t=this.options.customPlaceholder(t,this.selectedCountryData)),this.telInput.setAttribute("placeholder",t)}}},{key:"_selectListItem",value:function(i){var t=this._setFlag(i.getAttribute("data-country-code"));this._closeDropdown(),this._updateDialCode(i.getAttribute("data-dial-code")),this.telInput.focus();var e=this.telInput.value.length;this.telInput.setSelectionRange(e,e),t&&this._triggerCountryChange()}},{key:"_closeDropdown",value:function(){this.dropdownContent.classList.add("iti__hide"),this.selectedFlag.setAttribute("aria-expanded","false"),this.selectedFlag.removeAttribute("aria-activedescendant"),this.dropdownArrow.classList.remove("iti__arrow--up"),document.removeEventListener("keydown",this._handleKeydownOnDropdown),this.options.countrySearch&&this.searchInput.removeEventListener("input",this._handleSearchChange),document.documentElement.removeEventListener("click",this._handleClickOffToClose),this.countryList.removeEventListener("mouseover",this._handleMouseoverCountryList),this.countryList.removeEventListener("click",this._handleClickCountryList),this.options.dropdownContainer&&(this.options.useFullscreenPopup||window.removeEventListener("scroll",this._handleWindowScroll),this.dropdown.parentNode&&this.dropdown.parentNode.removeChild(this.dropdown)),this._trigger("close:countrydropdown")}},{key:"_scrollTo",value:function(i,t){var e=this.dropdownContent,s=window.pageYOffset||document.documentElement.scrollTop,n=e.offsetHeight,a=e.getBoundingClientRect().top+s,r=a+n,o=i.offsetHeight,h=i.getBoundingClientRect().top+s,u=h+o,l=h-a+e.scrollTop,c=n/2-o/2;h<a?(t&&(l-=c),e.scrollTop=l):u>r&&(t&&(l+=c),e.scrollTop=l-(n-o))}},{key:"_updateDialCode",value:function(i){var t,e=this.telInput.value,s="+".concat(i);if("+"===e.charAt(0)){var n=this._getDialCode(e);t=n?e.replace(n,s):s,this.telInput.value=t}else this.options.autoInsertDialCode&&(this.telInput.value=t=e?s+e:s)}},{key:"_getDialCode",value:function(i,t){var e="";if("+"===i.charAt(0))for(var s="",n=0;n<i.length;n++){var a=i.charAt(n);if(!isNaN(parseInt(a,10))){if(s+=a,t)this.countryCodes[s]&&(e=i.substr(0,n+1));else if(this.dialCodes[s]){e=i.substr(0,n+1);break}if(s.length===this.countryCodeMaxLen)break}}return e}},{key:"_getFullNumber",value:function(){var i=this.telInput.value.trim(),t=this.selectedCountryData.dialCode,e=this._getNumeric(i);return(this.options.separateDialCode&&"+"!==i.charAt(0)&&t&&e?"+".concat(t):"")+i}},{key:"_beforeSetNumber",value:function(i){var t=i;if(this.options.separateDialCode){var e=this._getDialCode(t);e&&(e="+".concat(this.selectedCountryData.dialCode),t=t.substr(" "===t[e.length]||"-"===t[e.length]?e.length+1:e.length))}return this._cap(t)}},{key:"_triggerCountryChange",value:function(){this._trigger("countrychange")}},{key:"handleAutoCountry",value:function(){"auto"===this.options.initialCountry&&(this.defaultCountry=window.intlTelInputGlobals.autoCountry,this.telInput.value||this.setCountry(this.defaultCountry),this.resolveAutoCountryPromise())}},{key:"handleUtils",value:function(){window.intlTelInputUtils&&(this.telInput.value&&this._updateValFromNumber(this.telInput.value),this._updatePlaceholder()),this.resolveUtilsScriptPromise()}},{key:"destroy",value:function(){var i=this.telInput.form;if(this.options.allowDropdown){this._closeDropdown(),this.selectedFlag.removeEventListener("click",this._handleClickSelectedFlag),this.flagsContainer.removeEventListener("keydown",this._handleFlagsContainerKeydown);var t=this._getClosestLabel();t&&t.removeEventListener("click",this._handleLabelClick)}this.hiddenInput&&i&&i.removeEventListener("submit",this._handleHiddenInputSubmit),this.options.autoInsertDialCode&&(i&&i.removeEventListener("submit",this._handleSubmitOrBlurEvent),this.telInput.removeEventListener("blur",this._handleSubmitOrBlurEvent)),this.telInput.removeEventListener("keyup",this._handleKeyupEvent),this.telInput.removeEventListener("cut",this._handleClipboardEvent),this.telInput.removeEventListener("paste",this._handleClipboardEvent),this.telInput.removeAttribute("data-intl-tel-input-id");var e=this.telInput.parentNode;e.parentNode.insertBefore(this.telInput,e),e.parentNode.removeChild(e),delete window.intlTelInputGlobals.instances[this.id]}},{key:"getExtension",value:function(){return window.intlTelInputUtils?intlTelInputUtils.getExtension(this._getFullNumber(),this.selectedCountryData.iso2):""}},{key:"getNumber",value:function(i){if(window.intlTelInputUtils){var t=this.selectedCountryData.iso2;return intlTelInputUtils.formatNumber(this._getFullNumber(),t,i)}return""}},{key:"getNumberType",value:function(){return window.intlTelInputUtils?intlTelInputUtils.getNumberType(this._getFullNumber(),this.selectedCountryData.iso2):-99}},{key:"getSelectedCountryData",value:function(){return this.selectedCountryData}},{key:"getValidationError",value:function(){if(window.intlTelInputUtils){var i=this.selectedCountryData.iso2;return intlTelInputUtils.getValidationError(this._getFullNumber(),i)}return-99}},{key:"isValidNumber",value:function(){var i=this._getFullNumber().trim();return window.intlTelInputUtils?intlTelInputUtils.isValidNumber(i,this.selectedCountryData.iso2):null}},{key:"isPossibleNumber",value:function(){var i=this._getFullNumber().trim();return window.intlTelInputUtils?intlTelInputUtils.isPossibleNumber(i,this.selectedCountryData.iso2):null}},{key:"setCountry",value:function(i){var t=i.toLowerCase();this.selectedCountryData.iso2!==t&&(this._setFlag(t),this._updateDialCode(this.selectedCountryData.dialCode),this._triggerCountryChange())}},{key:"setNumber",value:function(i){var t=this._updateFlagFromNumber(i);this._updateValFromNumber(i),t&&this._triggerCountryChange()}},{key:"setPlaceholderNumberType",value:function(i){this.options.placeholderNumberType=i,this._updatePlaceholder()}}],r&&function(i,t){for(var e=0;e<t.length;e++){var s=t[e];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(i,a(s.key),s)}}(s.prototype,r),Object.defineProperty(s,"prototype",{writable:!1}),e;var s,r}();r.getCountryData=function(){return t};var f=function(i,t,e){var s=document.createElement("script");s.onload=function(){c("handleUtils"),t&&t()},s.onerror=function(){c("rejectUtilsScriptPromise"),e&&e()},s.className="iti-load-utils",s.async=!0,s.src=i,document.body.appendChild(s)};return r.loadUtils=function(i){if(!window.intlTelInputUtils&&!window.intlTelInputGlobals.startedLoadingUtilsScript){if(window.intlTelInputGlobals.startedLoadingUtilsScript=!0,"undefined"!=typeof Promise)return new Promise((function(t,e){return f(i,t,e)}));f(i)}return null},r.defaults=h,r.version="18.5.3",function(i,t){var e=new d(i,t);return e._init(),i.setAttribute("data-intl-tel-input-id",e.id),window.intlTelInputGlobals.instances[e.id]=e,e}}()},a.exports?a.exports=r():window.intlTelInput=r()),s=a.exports),h=t({__proto__:null,default:i(o)},[o]);export{h as i}
|
|
4
|
+
import{a as i}from"./p-DXrQDmAN.js";function t(i,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(e){if("default"!==e&&!(e in i)){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(i,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})}}))})),Object.freeze(i)}var e,n,s,a={exports:{}};var r,o=s?n:(s=1,e||(e=1,r=function(i){return function(){for(var t=[["Afghanistan","af","93"],["Albania","al","355"],["Algeria","dz","213"],["American Samoa","as","1",5,["684"]],["Andorra","ad","376"],["Angola","ao","244"],["Anguilla","ai","1",6,["264"]],["Antigua & Barbuda","ag","1",7,["268"]],["Argentina","ar","54"],["Armenia","am","374"],["Aruba","aw","297"],["Ascension Island","ac","247"],["Australia","au","61",0],["Austria","at","43"],["Azerbaijan","az","994"],["Bahamas","bs","1",8,["242"]],["Bahrain","bh","973"],["Bangladesh","bd","880"],["Barbados","bb","1",9,["246"]],["Belarus","by","375"],["Belgium","be","32"],["Belize","bz","501"],["Benin","bj","229"],["Bermuda","bm","1",10,["441"]],["Bhutan","bt","975"],["Bolivia","bo","591"],["Bosnia & Herzegovina","ba","387"],["Botswana","bw","267"],["Brazil","br","55"],["British Indian Ocean Territory","io","246"],["British Virgin Islands","vg","1",11,["284"]],["Brunei","bn","673"],["Bulgaria","bg","359"],["Burkina Faso","bf","226"],["Burundi","bi","257"],["Cambodia","kh","855"],["Cameroon","cm","237"],["Canada","ca","1",1,["204","226","236","249","250","263","289","306","343","354","365","367","368","382","387","403","416","418","428","431","437","438","450","584","468","474","506","514","519","548","579","581","584","587","604","613","639","647","672","683","705","709","742","753","778","780","782","807","819","825","867","873","902","905"]],["Cape Verde","cv","238"],["Caribbean Netherlands","bq","599",1,["3","4","7"]],["Cayman Islands","ky","1",12,["345"]],["Central African Republic","cf","236"],["Chad","td","235"],["Chile","cl","56"],["China","cn","86"],["Christmas Island","cx","61",2,["89164"]],["Cocos (Keeling) Islands","cc","61",1,["89162"]],["Colombia","co","57"],["Comoros","km","269"],["Congo - Brazzaville","cg","242"],["Congo - Kinshasa","cd","243"],["Cook Islands","ck","682"],["Costa Rica","cr","506"],["Côte d’Ivoire","ci","225"],["Croatia","hr","385"],["Cuba","cu","53"],["Curaçao","cw","599",0],["Cyprus","cy","357"],["Czech Republic","cz","420"],["Denmark","dk","45"],["Djibouti","dj","253"],["Dominica","dm","1",13,["767"]],["Dominican Republic","do","1",2,["809","829","849"]],["Ecuador","ec","593"],["Egypt","eg","20"],["El Salvador","sv","503"],["Equatorial Guinea","gq","240"],["Eritrea","er","291"],["Estonia","ee","372"],["Eswatini","sz","268"],["Ethiopia","et","251"],["Falkland Islands","fk","500"],["Faroe Islands","fo","298"],["Fiji","fj","679"],["Finland","fi","358",0],["France","fr","33"],["French Guiana","gf","594"],["French Polynesia","pf","689"],["Gabon","ga","241"],["Gambia","gm","220"],["Georgia","ge","995"],["Germany","de","49"],["Ghana","gh","233"],["Gibraltar","gi","350"],["Greece","gr","30"],["Greenland","gl","299"],["Grenada","gd","1",14,["473"]],["Guadeloupe","gp","590",0],["Guam","gu","1",15,["671"]],["Guatemala","gt","502"],["Guernsey","gg","44",1,["1481","7781","7839","7911"]],["Guinea","gn","224"],["Guinea-Bissau","gw","245"],["Guyana","gy","592"],["Haiti","ht","509"],["Honduras","hn","504"],["Hong Kong","hk","852"],["Hungary","hu","36"],["Iceland","is","354"],["India","in","91"],["Indonesia","id","62"],["Iran","ir","98"],["Iraq","iq","964"],["Ireland","ie","353"],["Isle of Man","im","44",2,["1624","74576","7524","7924","7624"]],["Israel","il","972"],["Italy","it","39",0],["Jamaica","jm","1",4,["876","658"]],["Japan","jp","81"],["Jersey","je","44",3,["1534","7509","7700","7797","7829","7937"]],["Jordan","jo","962"],["Kazakhstan","kz","7",1,["33","7"]],["Kenya","ke","254"],["Kiribati","ki","686"],["Kosovo","xk","383"],["Kuwait","kw","965"],["Kyrgyzstan","kg","996"],["Laos","la","856"],["Latvia","lv","371"],["Lebanon","lb","961"],["Lesotho","ls","266"],["Liberia","lr","231"],["Libya","ly","218"],["Liechtenstein","li","423"],["Lithuania","lt","370"],["Luxembourg","lu","352"],["Macau","mo","853"],["Madagascar","mg","261"],["Malawi","mw","265"],["Malaysia","my","60"],["Maldives","mv","960"],["Mali","ml","223"],["Malta","mt","356"],["Marshall Islands","mh","692"],["Martinique","mq","596"],["Mauritania","mr","222"],["Mauritius","mu","230"],["Mayotte","yt","262",1,["269","639"]],["Mexico","mx","52"],["Micronesia","fm","691"],["Moldova","md","373"],["Monaco","mc","377"],["Mongolia","mn","976"],["Montenegro","me","382"],["Montserrat","ms","1",16,["664"]],["Morocco","ma","212",0],["Mozambique","mz","258"],["Myanmar (Burma)","mm","95"],["Namibia","na","264"],["Nauru","nr","674"],["Nepal","np","977"],["Netherlands","nl","31"],["New Caledonia","nc","687"],["New Zealand","nz","64"],["Nicaragua","ni","505"],["Niger","ne","227"],["Nigeria","ng","234"],["Niue","nu","683"],["Norfolk Island","nf","672"],["North Korea","kp","850"],["North Macedonia","mk","389"],["Northern Mariana Islands","mp","1",17,["670"]],["Norway","no","47",0],["Oman","om","968"],["Pakistan","pk","92"],["Palau","pw","680"],["Palestine","ps","970"],["Panama","pa","507"],["Papua New Guinea","pg","675"],["Paraguay","py","595"],["Peru","pe","51"],["Philippines","ph","63"],["Poland","pl","48"],["Portugal","pt","351"],["Puerto Rico","pr","1",3,["787","939"]],["Qatar","qa","974"],["Réunion","re","262",0],["Romania","ro","40"],["Russia","ru","7",0],["Rwanda","rw","250"],["Samoa","ws","685"],["San Marino","sm","378"],["São Tomé & Príncipe","st","239"],["Saudi Arabia","sa","966"],["Senegal","sn","221"],["Serbia","rs","381"],["Seychelles","sc","248"],["Sierra Leone","sl","232"],["Singapore","sg","65"],["Sint Maarten","sx","1",21,["721"]],["Slovakia","sk","421"],["Slovenia","si","386"],["Solomon Islands","sb","677"],["Somalia","so","252"],["South Africa","za","27"],["South Korea","kr","82"],["South Sudan","ss","211"],["Spain","es","34"],["Sri Lanka","lk","94"],["St Barthélemy","bl","590",1],["St Helena","sh","290"],["St Kitts & Nevis","kn","1",18,["869"]],["St Lucia","lc","1",19,["758"]],["St Martin","mf","590",2],["St Pierre & Miquelon","pm","508"],["St Vincent & Grenadines","vc","1",20,["784"]],["Sudan","sd","249"],["Suriname","sr","597"],["Svalbard & Jan Mayen","sj","47",1,["79"]],["Sweden","se","46"],["Switzerland","ch","41"],["Syria","sy","963"],["Taiwan","tw","886"],["Tajikistan","tj","992"],["Tanzania","tz","255"],["Thailand","th","66"],["Timor-Leste","tl","670"],["Togo","tg","228"],["Tokelau","tk","690"],["Tonga","to","676"],["Trinidad & Tobago","tt","1",22,["868"]],["Tunisia","tn","216"],["Turkey","tr","90"],["Turkmenistan","tm","993"],["Turks & Caicos Islands","tc","1",23,["649"]],["Tuvalu","tv","688"],["Uganda","ug","256"],["Ukraine","ua","380"],["United Arab Emirates","ae","971"],["United Kingdom","gb","44",0],["United States","us","1",0],["Uruguay","uy","598"],["US Virgin Islands","vi","1",24,["340"]],["Uzbekistan","uz","998"],["Vanuatu","vu","678"],["Vatican City","va","39",1,["06698"]],["Venezuela","ve","58"],["Vietnam","vn","84"],["Wallis & Futuna","wf","681"],["Western Sahara","eh","212",1,["5288","5289"]],["Yemen","ye","967"],["Zambia","zm","260"],["Zimbabwe","zw","263"],["Åland Islands","ax","358",1,["18"]]],e=0;e<t.length;e++){var n=t[e];t[e]={name:n[0],iso2:n[1],dialCode:n[2],priority:n[3]||0,areaCodes:n[4]||null}}function s(i,t,e){return(t=a(t))in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}function a(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(e!==i){var n=e.call(t,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}var r={getInstance:function(i){var t=i.getAttribute("data-intl-tel-input-id");return window.intlTelInputGlobals.instances[t]},instances:{},documentReady:function(){return"complete"===document.readyState}};"object"==typeof window&&(window.intlTelInputGlobals=r);var o=0,h={allowDropdown:!0,autoInsertDialCode:!1,autoPlaceholder:"polite",countrySearch:!1,customContainer:"",customPlaceholder:null,dropdownContainer:null,excludeCountries:[],fixDropdownWidth:!1,formatOnDisplay:!0,geoIpLookup:null,hiddenInput:"",initialCountry:"",localizedCountries:null,nationalMode:!0,onlyCountries:[],placeholderNumberType:"MOBILE",preferredCountries:["us","gb"],separateDialCode:!1,showFlags:!0,useFullscreenPopup:"undefined"!=typeof navigator&&"undefined"!=typeof window&&(/Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||window.innerWidth<=500),utilsScript:""},u=["800","822","833","844","855","866","877","880","881","882","883","884","885","886","887","888","889"],l=function(i,t){for(var e=Object.keys(i),n=0;n<e.length;n++)t(e[n],i[e[n]])},c=function(i){l(window.intlTelInputGlobals.instances,(function(t){window.intlTelInputGlobals.instances[t][i]()}))},d=function(){function e(i,t){var n=this;!function(i,t){if(!(i instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.id=o++,this.telInput=i,this.activeItem=null,this.highlightedItem=null;var s=t||{};this.options={},l(h,(function(i,t){n.options[i]=s.hasOwnProperty(i)?s[i]:t})),this.hadInitialPlaceholder=Boolean(i.getAttribute("placeholder"))}return n=e,r=[{key:"_init",value:function(){var i=this;if(this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!1),this.options.countrySearch&&!this.options.useFullscreenPopup&&(this.options.fixDropdownWidth=!0),this.options.nationalMode&&(this.options.autoInsertDialCode=!1),this.options.separateDialCode&&(this.options.autoInsertDialCode=!1),!this.options.showFlags&&this.options.allowDropdown&&!this.options.separateDialCode&&(this.options.showFlags=!0),this.options.useFullscreenPopup&&!this.options.dropdownContainer&&(this.options.dropdownContainer=document.body),this.isRTL=!!this.telInput.closest("[dir=rtl]"),"undefined"!=typeof Promise){var t=new Promise((function(t,e){i.resolveAutoCountryPromise=t,i.rejectAutoCountryPromise=e})),e=new Promise((function(t,e){i.resolveUtilsScriptPromise=t,i.rejectUtilsScriptPromise=e}));this.promise=Promise.all([t,e])}else this.resolveAutoCountryPromise=this.rejectAutoCountryPromise=function(){},this.resolveUtilsScriptPromise=this.rejectUtilsScriptPromise=function(){};this.selectedCountryData={},this._processCountryData(),this._generateMarkup(),this._setInitialState(),this._initListeners(),this._initRequests()}},{key:"_processCountryData",value:function(){this._processAllCountries(),this._processCountryCodes(),this._processPreferredCountries(),this.options.localizedCountries&&this._translateCountriesByLocale(),(this.options.onlyCountries.length||this.options.localizedCountries)&&this.countries.sort(this._countryNameSort)}},{key:"_addCountryCode",value:function(t,e,n){e.length>this.countryCodeMaxLen&&(this.countryCodeMaxLen=e.length),this.countryCodes.hasOwnProperty(e)||(this.countryCodes[e]=[]);for(var s=0;s<this.countryCodes[e].length;s++)if(this.countryCodes[e][s]===t)return;this.countryCodes[e][n!==i?n:this.countryCodes[e].length]=t}},{key:"_processAllCountries",value:function(){if(this.options.onlyCountries.length){var i=this.options.onlyCountries.map((function(i){return i.toLowerCase()}));this.countries=t.filter((function(t){return i.indexOf(t.iso2)>-1}))}else if(this.options.excludeCountries.length){var e=this.options.excludeCountries.map((function(i){return i.toLowerCase()}));this.countries=t.filter((function(i){return-1===e.indexOf(i.iso2)}))}else this.countries=t}},{key:"_translateCountriesByLocale",value:function(){for(var i=0;i<this.countries.length;i++){var t=this.countries[i].iso2.toLowerCase();this.options.localizedCountries.hasOwnProperty(t)&&(this.countries[i].name=this.options.localizedCountries[t])}}},{key:"_countryNameSort",value:function(i,t){return i.name<t.name?-1:i.name>t.name?1:0}},{key:"_processCountryCodes",value:function(){this.countryCodeMaxLen=0,this.dialCodes={},this.countryCodes={};for(var i=0;i<this.countries.length;i++){var t=this.countries[i];this.dialCodes[t.dialCode]||(this.dialCodes[t.dialCode]=!0),this._addCountryCode(t.iso2,t.dialCode,t.priority)}for(var e=0;e<this.countries.length;e++){var n=this.countries[e];if(n.areaCodes)for(var s=this.countryCodes[n.dialCode][0],a=0;a<n.areaCodes.length;a++){for(var r=n.areaCodes[a],o=1;o<r.length;o++){var h=n.dialCode+r.substr(0,o);this._addCountryCode(s,h),this._addCountryCode(n.iso2,h)}this._addCountryCode(n.iso2,n.dialCode+r)}}}},{key:"_processPreferredCountries",value:function(){this.preferredCountries=[];for(var i=0;i<this.options.preferredCountries.length;i++){var t=this.options.preferredCountries[i].toLowerCase(),e=this._getCountryData(t,!1,!0);e&&this.preferredCountries.push(e)}}},{key:"_createEl",value:function(i,t,e){var n=document.createElement(i);return t&&l(t,(function(i,t){return n.setAttribute(i,t)})),e&&e.appendChild(n),n}},{key:"_generateMarkup",value:function(){this.telInput.classList.add("iti__tel-input"),this.telInput.hasAttribute("autocomplete")||this.telInput.form&&this.telInput.form.hasAttribute("autocomplete")||this.telInput.setAttribute("autocomplete","off");var i=this.options,t=i.allowDropdown,e=i.separateDialCode,n=i.showFlags,a=i.customContainer,r=i.hiddenInput,o=i.dropdownContainer,h=i.fixDropdownWidth,u=i.useFullscreenPopup,l=i.countrySearch,c="iti";t&&(c+=" iti--allow-dropdown"),e&&(c+=" iti--separate-dial-code"),n&&(c+=" iti--show-flags"),a&&(c+=" ".concat(a));var d=this._createEl("div",{class:c});this.telInput.parentNode.insertBefore(d,this.telInput);var f=t||n||e;if(f&&(this.flagsContainer=this._createEl("div",{class:"iti__flag-container"},d)),d.appendChild(this.telInput),f&&(this.selectedFlag=this._createEl("div",function(i){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?Object(arguments[t]):{},n=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&n.push.apply(n,Object.getOwnPropertySymbols(e).filter((function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable}))),n.forEach((function(t){s(i,t,e[t])}))}return i}({class:"iti__selected-flag"},t&&{role:"combobox","aria-haspopup":"listbox","aria-controls":"iti-".concat(this.id,"__country-listbox"),"aria-expanded":"false","aria-label":"Telephone country code"}),this.flagsContainer)),n&&(this.selectedFlagInner=this._createEl("div",{class:"iti__flag"},this.selectedFlag)),this.selectedFlag&&this.telInput.disabled&&this.selectedFlag.setAttribute("aria-disabled","true"),e&&(this.selectedDialCode=this._createEl("div",{class:"iti__selected-dial-code"},this.selectedFlag)),t)if(this.telInput.disabled||this.selectedFlag.setAttribute("tabindex","0"),this.dropdownArrow=this._createEl("div",{class:"iti__arrow"},this.selectedFlag),this.dropdownContent=this._createEl("div",{class:"iti__dropdown-content iti__hide ".concat(h?"":"iti--flexible-dropdown-width")}),l&&(this.searchInput=this._createEl("input",{type:"text",class:"iti__search-input",placeholder:"Search"},this.dropdownContent)),this.countryList=this._createEl("ul",{class:"iti__country-list",id:"iti-".concat(this.id,"__country-listbox"),role:"listbox","aria-label":"List of countries"},this.dropdownContent),this.preferredCountries.length&&!l&&(this._appendListItems(this.preferredCountries,"iti__preferred",!0),this._createEl("li",{class:"iti__divider","aria-hidden":"true"},this.countryList)),this._appendListItems(this.countries,"iti__standard"),o){var v="iti iti--container";u&&(v+=" iti--fullscreen-popup"),l&&(v+=" iti--country-search"),this.dropdown=this._createEl("div",{class:v}),this.dropdown.appendChild(this.dropdownContent)}else this.flagsContainer.appendChild(this.dropdownContent);if(r){var p=r,y=this.telInput.getAttribute("name");if(y){var m=y.lastIndexOf("[");-1!==m&&(p="".concat(y.substr(0,m),"[").concat(p,"]"))}this.hiddenInput=this._createEl("input",{type:"hidden",name:p}),d.appendChild(this.hiddenInput)}}},{key:"_appendListItems",value:function(i,t,e){for(var n=0;n<i.length;n++){var s=i[n],a=e?"-preferred":"",r=this._createEl("li",{id:"iti-".concat(this.id,"__item-").concat(s.iso2).concat(a),class:"iti__country ".concat(t),tabindex:"-1",role:"option","data-dial-code":s.dialCode,"data-country-code":s.iso2,"aria-selected":"false"},this.countryList);s.node=r;var o="";this.options.showFlags&&(o+="<div class='iti__flag-box'><div class='iti__flag iti__".concat(s.iso2,"'></div></div>")),o+="<span class='iti__country-name'>".concat(s.name,"</span>"),o+="<span class='iti__dial-code'>+".concat(s.dialCode,"</span>"),r.insertAdjacentHTML("beforeend",o)}}},{key:"_setInitialState",value:function(){var i=this.telInput.getAttribute("value"),t=this.telInput.value,e=!i||"+"!==i.charAt(0)||t&&"+"===t.charAt(0)?t:i,n=this._getDialCode(e),s=this._isRegionlessNanp(e),a=this.options,r=a.initialCountry,o=a.autoInsertDialCode;n&&!s?this._updateFlagFromNumber(e):"auto"!==r&&(r&&this._getCountryData(r,!1,!0)?this._setFlag(r.toLowerCase()):n&&s?this._setFlag("us"):(this.defaultCountry=this.preferredCountries.length?this.preferredCountries[0].iso2:this.countries[0].iso2,e||this._setFlag(this.defaultCountry)),!e&&o&&(this.telInput.value="+".concat(this.selectedCountryData.dialCode))),e&&this._updateValFromNumber(e)}},{key:"_initListeners",value:function(){this._initKeyListeners(),this.options.autoInsertDialCode&&this._initBlurListeners(),this.options.allowDropdown&&this._initDropdownListeners(),this.hiddenInput&&this._initHiddenInputListener()}},{key:"_initHiddenInputListener",value:function(){var i=this;this._handleHiddenInputSubmit=function(){i.hiddenInput.value=i.getNumber()},this.telInput.form&&this.telInput.form.addEventListener("submit",this._handleHiddenInputSubmit)}},{key:"_getClosestLabel",value:function(){for(var i=this.telInput;i&&"LABEL"!==i.tagName;)i=i.parentNode;return i}},{key:"_initDropdownListeners",value:function(){var i=this;this._handleLabelClick=function(t){i.dropdownContent.classList.contains("iti__hide")?i.telInput.focus():t.preventDefault()};var t=this._getClosestLabel();t&&t.addEventListener("click",this._handleLabelClick),this._handleClickSelectedFlag=function(){!i.dropdownContent.classList.contains("iti__hide")||i.telInput.disabled||i.telInput.readOnly||i._showDropdown()},this.selectedFlag.addEventListener("click",this._handleClickSelectedFlag),this._handleFlagsContainerKeydown=function(t){i.dropdownContent.classList.contains("iti__hide")&&["ArrowUp","ArrowDown"," ","Enter"].includes(t.key)&&(t.preventDefault(),t.stopPropagation(),i._showDropdown()),"Tab"===t.key&&i._closeDropdown()},this.flagsContainer.addEventListener("keydown",this._handleFlagsContainerKeydown)}},{key:"_initRequests",value:function(){var i=this;this.options.utilsScript&&!window.intlTelInputUtils?window.intlTelInputGlobals.documentReady()?window.intlTelInputGlobals.loadUtils(this.options.utilsScript):window.addEventListener("load",(function(){window.intlTelInputGlobals.loadUtils(i.options.utilsScript)})):this.resolveUtilsScriptPromise(),"auto"===this.options.initialCountry?this._loadAutoCountry():this.resolveAutoCountryPromise()}},{key:"_loadAutoCountry",value:function(){window.intlTelInputGlobals.autoCountry?this.handleAutoCountry():window.intlTelInputGlobals.startedLoadingAutoCountry||(window.intlTelInputGlobals.startedLoadingAutoCountry=!0,"function"==typeof this.options.geoIpLookup&&this.options.geoIpLookup((function(i){window.intlTelInputGlobals.autoCountry=i.toLowerCase(),setTimeout((function(){return c("handleAutoCountry")}))}),(function(){return c("rejectAutoCountryPromise")})))}},{key:"_initKeyListeners",value:function(){var i=this;this._handleKeyupEvent=function(){i._updateFlagFromNumber(i.telInput.value)&&i._triggerCountryChange()},this.telInput.addEventListener("keyup",this._handleKeyupEvent),this._handleClipboardEvent=function(){setTimeout(i._handleKeyupEvent)},this.telInput.addEventListener("cut",this._handleClipboardEvent),this.telInput.addEventListener("paste",this._handleClipboardEvent)}},{key:"_cap",value:function(i){var t=this.telInput.getAttribute("maxlength");return t&&i.length>t?i.substr(0,t):i}},{key:"_initBlurListeners",value:function(){var i=this;this._handleSubmitOrBlurEvent=function(){i._removeEmptyDialCode()},this.telInput.form&&this.telInput.form.addEventListener("submit",this._handleSubmitOrBlurEvent),this.telInput.addEventListener("blur",this._handleSubmitOrBlurEvent)}},{key:"_removeEmptyDialCode",value:function(){if("+"===this.telInput.value.charAt(0)){var i=this._getNumeric(this.telInput.value);i&&this.selectedCountryData.dialCode!==i||(this.telInput.value="")}}},{key:"_getNumeric",value:function(i){return i.replace(/\D/g,"")}},{key:"_trigger",value:function(i){var t=document.createEvent("Event");t.initEvent(i,!0,!0),this.telInput.dispatchEvent(t)}},{key:"_showDropdown",value:function(){this.options.fixDropdownWidth&&(this.dropdownContent.style.width="".concat(this.telInput.offsetWidth,"px")),this.dropdownContent.classList.remove("iti__hide"),this.selectedFlag.setAttribute("aria-expanded","true"),this._setDropdownPosition(),this.options.countrySearch?(this._highlightListItem(this.countryList.firstElementChild,!1),this.searchInput.focus()):this.activeItem&&(this._highlightListItem(this.activeItem,!1),this._scrollTo(this.activeItem,!0)),this._bindDropdownListeners(),this.dropdownArrow.classList.add("iti__arrow--up"),this._trigger("open:countrydropdown")}},{key:"_toggleClass",value:function(i,t,e){e&&!i.classList.contains(t)?i.classList.add(t):!e&&i.classList.contains(t)&&i.classList.remove(t)}},{key:"_setDropdownPosition",value:function(){var i=this;if(this.options.dropdownContainer&&this.options.dropdownContainer.appendChild(this.dropdown),!this.options.useFullscreenPopup){var t=this.telInput.getBoundingClientRect(),e=window.pageYOffset||document.documentElement.scrollTop,n=t.top+e,s=this.dropdownContent.offsetHeight,a=n+this.telInput.offsetHeight+s<e+window.innerHeight,r=!this.options.countrySearch&&!a&&n-s>e;this._toggleClass(this.dropdownContent,"iti__dropdown-content--dropup",r),this.options.dropdownContainer&&(this.dropdown.style.top="".concat(n+(r?0:this.telInput.offsetHeight),"px"),this.dropdown.style.left="".concat(t.left+document.body.scrollLeft,"px"),this._handleWindowScroll=function(){return i._closeDropdown()},window.addEventListener("scroll",this._handleWindowScroll))}}},{key:"_getClosestListItem",value:function(i){for(var t=i;t&&t!==this.countryList&&!t.classList.contains("iti__country");)t=t.parentNode;return t===this.countryList?null:t}},{key:"_bindDropdownListeners",value:function(){var i=this;this._handleMouseoverCountryList=function(t){var e=i._getClosestListItem(t.target);e&&i._highlightListItem(e,!1)},this.countryList.addEventListener("mouseover",this._handleMouseoverCountryList),this._handleClickCountryList=function(t){var e=i._getClosestListItem(t.target);e&&i._selectListItem(e)},this.countryList.addEventListener("click",this._handleClickCountryList);var t=!0;this._handleClickOffToClose=function(){t||i._closeDropdown(),t=!1},document.documentElement.addEventListener("click",this._handleClickOffToClose);var e="",n=null;if(this._handleKeydownOnDropdown=function(t){["ArrowUp","ArrowDown","Enter","Escape"].includes(t.key)&&(t.preventDefault(),t.stopPropagation(),"ArrowUp"===t.key||"ArrowDown"===t.key?i._handleUpDownKey(t.key):"Enter"===t.key?i._handleEnterKey():"Escape"===t.key&&i._closeDropdown()),!i.options.countrySearch&&/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(t.key)&&(t.stopPropagation(),n&&clearTimeout(n),e+=t.key.toLowerCase(),i._searchForCountry(e),n=setTimeout((function(){e=""}),1e3))},document.addEventListener("keydown",this._handleKeydownOnDropdown),this.options.countrySearch){var s=null;this._handleSearchChange=function(){s&&clearTimeout(s),s=setTimeout((function(){var t;(t=i.searchInput.value.trim())?i._filterCountries(t.toLowerCase()):i._filterCountries(null,!0),s=null}),100)},this.searchInput.addEventListener("input",this._handleSearchChange),this.searchInput.addEventListener("click",(function(i){return i.stopPropagation()}))}}},{key:"_filterCountries",value:function(t){var e=arguments.length>1&&arguments[1]!==i&&arguments[1],n=!0;this.countryList.innerHTML="";for(var s=0;s<this.countries.length;s++){var a=this.countries[s],r=a.name.toLowerCase(),o="+".concat(a.dialCode);(e||r.includes(t)||o.includes(t))&&(this.countryList.appendChild(a.node),n&&(this._highlightListItem(a.node,!1),n=!1))}}},{key:"_handleUpDownKey",value:function(i){var t="ArrowUp"===i?this.highlightedItem.previousElementSibling:this.highlightedItem.nextElementSibling;t?t.classList.contains("iti__divider")&&(t="ArrowUp"===i?t.previousElementSibling:t.nextElementSibling):this.countryList.childElementCount>1&&(t="ArrowUp"===i?this.countryList.lastElementChild:this.countryList.firstElementChild),t&&(this._highlightListItem(t,!this.options.countrySearch),this.options.countrySearch&&this._scrollTo(t,!1))}},{key:"_handleEnterKey",value:function(){this.highlightedItem&&this._selectListItem(this.highlightedItem)}},{key:"_searchForCountry",value:function(i){for(var t=0;t<this.countries.length;t++)if(this._startsWith(this.countries[t].name,i)){var e=this.countries[t].node;this._highlightListItem(e,!1),this._scrollTo(e,!0);break}}},{key:"_startsWith",value:function(i,t){return i.substr(0,t.length).toLowerCase()===t}},{key:"_updateValFromNumber",value:function(i){var t=i;if(this.options.formatOnDisplay&&window.intlTelInputUtils&&this.selectedCountryData){var e=this.options.nationalMode||"+"!==t.charAt(0)&&!this.options.separateDialCode,n=intlTelInputUtils.numberFormat;t=intlTelInputUtils.formatNumber(t,this.selectedCountryData.iso2,e?n.NATIONAL:n.INTERNATIONAL)}t=this._beforeSetNumber(t),this.telInput.value=t}},{key:"_updateFlagFromNumber",value:function(i){var t=i.indexOf("+"),e=t?i.substring(t):i,n=this.selectedCountryData.dialCode;e&&"1"===n&&"+"!==e.charAt(0)&&("1"!==e.charAt(0)&&(e="1".concat(e)),e="+".concat(e)),this.options.separateDialCode&&n&&"+"!==e.charAt(0)&&(e="+".concat(n).concat(e));var s=this._getDialCode(e,!0),a=this._getNumeric(e),r=null;if(s){var o=this.countryCodes[this._getNumeric(s)],h=-1!==o.indexOf(this.selectedCountryData.iso2)&&a.length<=s.length-1;if(!("1"===n&&this._isRegionlessNanp(a)||h))for(var u=0;u<o.length;u++)if(o[u]){r=o[u];break}}else"+"===e.charAt(0)&&a.length?r="":e&&"+"!==e||(r=this.defaultCountry);return null!==r&&this._setFlag(r)}},{key:"_isRegionlessNanp",value:function(i){var t=this._getNumeric(i);if("1"===t.charAt(0)){var e=t.substr(1,3);return-1!==u.indexOf(e)}return!1}},{key:"_highlightListItem",value:function(i,t){var e=this.highlightedItem;e&&e.classList.remove("iti__highlight"),this.highlightedItem=i,this.highlightedItem.classList.add("iti__highlight"),this.selectedFlag.setAttribute("aria-activedescendant",i.getAttribute("id")),t&&this.highlightedItem.focus()}},{key:"_getCountryData",value:function(i,e,n){for(var s=e?t:this.countries,a=0;a<s.length;a++)if(s[a].iso2===i)return s[a];if(n)return null;throw new Error("No country data for '".concat(i,"'"))}},{key:"_setFlag",value:function(i){var t=this.options,e=t.allowDropdown,n=t.separateDialCode,s=t.showFlags,a=this.selectedCountryData.iso2?this.selectedCountryData:{};if(this.selectedCountryData=i?this._getCountryData(i,!1,!1):{},this.selectedCountryData.iso2&&(this.defaultCountry=this.selectedCountryData.iso2),s&&this.selectedFlagInner.setAttribute("class","iti__flag iti__".concat(i)),this._setSelectedCountryFlagTitleAttribute(i,n),n){var r=this.selectedCountryData.dialCode?"+".concat(this.selectedCountryData.dialCode):"";this.selectedDialCode.innerHTML=r;var o=this.selectedFlag.offsetWidth||this._getHiddenSelectedFlagWidth();this.isRTL?this.telInput.style.paddingRight="".concat(o+6,"px"):this.telInput.style.paddingLeft="".concat(o+6,"px")}if(this._updatePlaceholder(),e){var h=this.activeItem;if(h&&(h.classList.remove("iti__active"),h.setAttribute("aria-selected","false")),i){var u=this.countryList.querySelector("#iti-".concat(this.id,"__item-").concat(i,"-preferred"))||this.countryList.querySelector("#iti-".concat(this.id,"__item-").concat(i));u.setAttribute("aria-selected","true"),u.classList.add("iti__active"),this.activeItem=u}}return a.iso2!==i}},{key:"_setSelectedCountryFlagTitleAttribute",value:function(i,t){var e;this.selectedFlag&&(e=i&&!t?"".concat(this.selectedCountryData.name,": +").concat(this.selectedCountryData.dialCode):i?this.selectedCountryData.name:"Unknown",this.selectedFlag.setAttribute("title",e))}},{key:"_getHiddenSelectedFlagWidth",value:function(){var i=this.telInput.parentNode.cloneNode();i.style.visibility="hidden",document.body.appendChild(i);var t=this.flagsContainer.cloneNode();i.appendChild(t);var e=this.selectedFlag.cloneNode(!0);t.appendChild(e);var n=e.offsetWidth;return i.parentNode.removeChild(i),n}},{key:"_updatePlaceholder",value:function(){if(window.intlTelInputUtils&&("aggressive"===this.options.autoPlaceholder||!this.hadInitialPlaceholder&&"polite"===this.options.autoPlaceholder)){var i=intlTelInputUtils.numberType[this.options.placeholderNumberType],t=this.selectedCountryData.iso2?intlTelInputUtils.getExampleNumber(this.selectedCountryData.iso2,this.options.nationalMode,i):"";t=this._beforeSetNumber(t),"function"==typeof this.options.customPlaceholder&&(t=this.options.customPlaceholder(t,this.selectedCountryData)),this.telInput.setAttribute("placeholder",t)}}},{key:"_selectListItem",value:function(i){var t=this._setFlag(i.getAttribute("data-country-code"));this._closeDropdown(),this._updateDialCode(i.getAttribute("data-dial-code")),this.telInput.focus();var e=this.telInput.value.length;this.telInput.setSelectionRange(e,e),t&&this._triggerCountryChange()}},{key:"_closeDropdown",value:function(){this.dropdownContent.classList.add("iti__hide"),this.selectedFlag.setAttribute("aria-expanded","false"),this.selectedFlag.removeAttribute("aria-activedescendant"),this.dropdownArrow.classList.remove("iti__arrow--up"),document.removeEventListener("keydown",this._handleKeydownOnDropdown),this.options.countrySearch&&this.searchInput.removeEventListener("input",this._handleSearchChange),document.documentElement.removeEventListener("click",this._handleClickOffToClose),this.countryList.removeEventListener("mouseover",this._handleMouseoverCountryList),this.countryList.removeEventListener("click",this._handleClickCountryList),this.options.dropdownContainer&&(this.options.useFullscreenPopup||window.removeEventListener("scroll",this._handleWindowScroll),this.dropdown.parentNode&&this.dropdown.parentNode.removeChild(this.dropdown)),this._trigger("close:countrydropdown")}},{key:"_scrollTo",value:function(i,t){var e=this.dropdownContent,n=window.pageYOffset||document.documentElement.scrollTop,s=e.offsetHeight,a=e.getBoundingClientRect().top+n,r=a+s,o=i.offsetHeight,h=i.getBoundingClientRect().top+n,u=h+o,l=h-a+e.scrollTop,c=s/2-o/2;h<a?(t&&(l-=c),e.scrollTop=l):u>r&&(t&&(l+=c),e.scrollTop=l-(s-o))}},{key:"_updateDialCode",value:function(i){var t,e=this.telInput.value,n="+".concat(i);if("+"===e.charAt(0)){var s=this._getDialCode(e);t=s?e.replace(s,n):n,this.telInput.value=t}else this.options.autoInsertDialCode&&(this.telInput.value=t=e?n+e:n)}},{key:"_getDialCode",value:function(i,t){var e="";if("+"===i.charAt(0))for(var n="",s=0;s<i.length;s++){var a=i.charAt(s);if(!isNaN(parseInt(a,10))){if(n+=a,t)this.countryCodes[n]&&(e=i.substr(0,s+1));else if(this.dialCodes[n]){e=i.substr(0,s+1);break}if(n.length===this.countryCodeMaxLen)break}}return e}},{key:"_getFullNumber",value:function(){var i=this.telInput.value.trim(),t=this.selectedCountryData.dialCode,e=this._getNumeric(i);return(this.options.separateDialCode&&"+"!==i.charAt(0)&&t&&e?"+".concat(t):"")+i}},{key:"_beforeSetNumber",value:function(i){var t=i;if(this.options.separateDialCode){var e=this._getDialCode(t);e&&(e="+".concat(this.selectedCountryData.dialCode),t=t.substr(" "===t[e.length]||"-"===t[e.length]?e.length+1:e.length))}return this._cap(t)}},{key:"_triggerCountryChange",value:function(){this._trigger("countrychange")}},{key:"handleAutoCountry",value:function(){"auto"===this.options.initialCountry&&(this.defaultCountry=window.intlTelInputGlobals.autoCountry,this.telInput.value||this.setCountry(this.defaultCountry),this.resolveAutoCountryPromise())}},{key:"handleUtils",value:function(){window.intlTelInputUtils&&(this.telInput.value&&this._updateValFromNumber(this.telInput.value),this._updatePlaceholder()),this.resolveUtilsScriptPromise()}},{key:"destroy",value:function(){var i=this.telInput.form;if(this.options.allowDropdown){this._closeDropdown(),this.selectedFlag.removeEventListener("click",this._handleClickSelectedFlag),this.flagsContainer.removeEventListener("keydown",this._handleFlagsContainerKeydown);var t=this._getClosestLabel();t&&t.removeEventListener("click",this._handleLabelClick)}this.hiddenInput&&i&&i.removeEventListener("submit",this._handleHiddenInputSubmit),this.options.autoInsertDialCode&&(i&&i.removeEventListener("submit",this._handleSubmitOrBlurEvent),this.telInput.removeEventListener("blur",this._handleSubmitOrBlurEvent)),this.telInput.removeEventListener("keyup",this._handleKeyupEvent),this.telInput.removeEventListener("cut",this._handleClipboardEvent),this.telInput.removeEventListener("paste",this._handleClipboardEvent),this.telInput.removeAttribute("data-intl-tel-input-id");var e=this.telInput.parentNode;e.parentNode.insertBefore(this.telInput,e),e.parentNode.removeChild(e),delete window.intlTelInputGlobals.instances[this.id]}},{key:"getExtension",value:function(){return window.intlTelInputUtils?intlTelInputUtils.getExtension(this._getFullNumber(),this.selectedCountryData.iso2):""}},{key:"getNumber",value:function(i){if(window.intlTelInputUtils){var t=this.selectedCountryData.iso2;return intlTelInputUtils.formatNumber(this._getFullNumber(),t,i)}return""}},{key:"getNumberType",value:function(){return window.intlTelInputUtils?intlTelInputUtils.getNumberType(this._getFullNumber(),this.selectedCountryData.iso2):-99}},{key:"getSelectedCountryData",value:function(){return this.selectedCountryData}},{key:"getValidationError",value:function(){if(window.intlTelInputUtils){var i=this.selectedCountryData.iso2;return intlTelInputUtils.getValidationError(this._getFullNumber(),i)}return-99}},{key:"isValidNumber",value:function(){var i=this._getFullNumber().trim();return window.intlTelInputUtils?intlTelInputUtils.isValidNumber(i,this.selectedCountryData.iso2):null}},{key:"isPossibleNumber",value:function(){var i=this._getFullNumber().trim();return window.intlTelInputUtils?intlTelInputUtils.isPossibleNumber(i,this.selectedCountryData.iso2):null}},{key:"setCountry",value:function(i){var t=i.toLowerCase();this.selectedCountryData.iso2!==t&&(this._setFlag(t),this._updateDialCode(this.selectedCountryData.dialCode),this._triggerCountryChange())}},{key:"setNumber",value:function(i){var t=this._updateFlagFromNumber(i);this._updateValFromNumber(i),t&&this._triggerCountryChange()}},{key:"setPlaceholderNumberType",value:function(i){this.options.placeholderNumberType=i,this._updatePlaceholder()}}],r&&function(i,t){for(var e=0;e<t.length;e++){var n=t[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(i,a(n.key),n)}}(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),e;var n,r}();r.getCountryData=function(){return t};var f=function(i,t,e){var n=document.createElement("script");n.onload=function(){c("handleUtils"),t&&t()},n.onerror=function(){c("rejectUtilsScriptPromise"),e&&e()},n.className="iti-load-utils",n.async=!0,n.src=i,document.body.appendChild(n)};return r.loadUtils=function(i){if(!window.intlTelInputUtils&&!window.intlTelInputGlobals.startedLoadingUtilsScript){if(window.intlTelInputGlobals.startedLoadingUtilsScript=!0,"undefined"!=typeof Promise)return new Promise((function(t,e){return f(i,t,e)}));f(i)}return null},r.defaults=h,r.version="18.5.3",function(i,t){var e=new d(i,t);return e._init(),i.setAttribute("data-intl-tel-input-id",e.id),window.intlTelInputGlobals.instances[e.id]=e,e}}()},a.exports?a.exports=r():window.intlTelInput=r()),n=a.exports),h=t({__proto__:null,default:i(o)},[o]);export{h as i}
|