1import{A as I,q as b,l as W,T as X,h as u,u as o}from"./2c1ab0fe.BqEHHmaW.js";import{h as Y,bi as Z,a as $,bj as w,bk as x,n as V,c as ee}from"./164ad2e3.BA-GikTU.js";import{O as H,bp as ne,G as te,aT as le,Q as ae,bq as U}from"./4c290a1e.FJVsH4yi.js";import{a as ie,g as re}from"./f3fe2775.BuWC6GWF.js";import"./app.D2gvVyTR.js";import"./65f3d4da.BdKZt11Z.js";import"./60a453ce.BClq-svk.js";import"./0a7dffce.BHf0S_6c.js";import"./bb728e1c.uhKc-SJ5.js";import"./ac5a19ff.BHoedVx2.js";import"./598fef4e.PfG1A8vt.js";import"./e77f7fe0.B6M5o7QB.js";import"./a422df8c.ggO-AlYl.js";import"./efa0389a.CmzfQUTJ.js";import"./31cc568e.Dti0cJak.js";import"./8599b02a.DjDpxYLZ.js";import"./cc6ff67d.CQwyXWHD.js";import"./08a3b809.BqMk-s3U.js";import"./e477f96c.CCUKKy0S.js";import"./87bfafec.a5jzmgqb.js";import"./e39bc11c.w_dcLWzY.js";import"./bff2ff9b.BZBliUVS.js";import"./cf29e63b.UPVrnMYo.js";const se=1e3;function oe(c){const{userEvents:m,source:P,shop:d}=H(),i=ne(),v=I(0),a=b(e=>{m.monorailEvent({schemaId:"checkout_credit_card_installment_track/1.0",payload:{eventName:e.eventName,shopId:parseInt(te(d.id),10),checkoutToken:P.checkoutSessionIdentifier??"",...e.planCount!=null&&{planCount:e.planCount},eligiblePlans:e.eligiblePlans,cartTotal:e.cartTotal,cartCurrency:e.cartCurrency}})},[m,d.id,P.checkoutSessionIdentifier]),p=b(()=>{const e=i.value?.amount,t=i.value?.currencyCode;e==null||!t||a({eventName:"credit_card_installment_dropdown_shown",eligiblePlans:c.join(","),cartTotal:e.toFixed(2),cartCurrency:t})},[a,i,c]),S=b(()=>{const e=Date.now();if(e-v.current<se)return;v.current=e;const t=i.value?.amount,r=i.value?.currencyCode;t==null||!r||a({eventName:"credit_card_installment_dropdown_opened",eligiblePlans:c.join(","),cartTotal:t.toFixed(2),cartCurrency:r})},[a,i,c]),k=b(e=>{const t=i.value?.amount,r=i.value?.currencyCode;t==null||!r||a({eventName:"credit_card_installment_plan_selected",planCount:e,eligiblePlans:c.join(","),cartTotal:t.toFixed(2),cartCurrency:r})},[a,i,c]);return{trackDropdownShown:p,trackDropdownOpened:S,trackPlanSelected:k}}function Ee({paymentMethod:c,isSelected:m,canEditBin:P=!0,isVaultedContext:d=!1,id:i="msiInstallmentsSelect"}){const v=P&&!d,{i18n:a}=H(),p=a.translate("msi_installments.payment_plan_label"),{bankIdNumberSignal:S,installmentMonthsSignal:k,lastNegotiatedBinSignal:e,msiInvalidationReasonSignal:t,msiInvalidationSnapshotSignal:r,msiHadInstallmentsSignal:f}=le(),{paymentLines:T}=ae(),{negotiate:E}=Y(),F=I(void 0),[O,R]=W(!1),M=I(null),h=t.value,y=c.installmentPlans?.find(n=>n.type==="MSI"),l=X(()=>y?.supportedInstallments??[],[y?.supportedInstallments]),N=U(S.value),g=ie(),J=g.value&&l.includes(g.value)?String(g.value):"",s=b(n=>{T.value=Z(T.value,n)},[T]);u(()=>{k.value=g.value},[g.value,k]);const{trackDropdownShown:j,trackDropdownOpened:Q,trackPlanSelected:A}=oe(l),G=I(!1),z=b(n=>{const _=n?parseInt(n,10):void 0;s(_&&_>0?_:void 0),t.value=null,_&&_>0&&A(_)},[s,t,A]);u(()=>{l.length>0&&!f.value&&(f.value=!0)},[l,f]),u(()=>{const n=g.value;n&&(l.includes(n)||(l.length>0?(t.value="some_eligible",r.value=l.join(","),s(void 0)):f.value&&(t.value="none_eligible",r.value="",s(void 0))))},[l,g.value,s,t,r,f]),u(()=>{!h||l.join(",")===r.value||(l.length>0?t.value=null:f.value&&(t.value="none_eligible",r.value=""))},[h,l,t,r,f]),u(()=>{h&&M.current&&M.current.scrollIntoView({behavior:"smooth",block:"center"})},[h]),u(()=>{if(!y||!m){s(void 0);return}const n=U(S.value);if(!n){(v||l.length===0)&&s(void 0);return}if(!d){if(n.length<8&&v){s(void 0);return}n!==e.value&&(s(void 0),e.value=n,F.current=n,R(!0),E({include:[]}).catch(()=>{e.value===n&&(e.value=void 0)}).finally(()=>{F.current===n&&R(!1)}))}},[S.value,v,y,m,d,l.length,E,s,e]);const L=!d&&N!==void 0&&e.value!==void 0&&N!==e.value,q=m&&!O&&!L&&l.length>0;u(()=>{q&&!G.current&&(G.current=!0,j())},[q,j]);const C=re({isSelected:!!m,hasMsiPlan:!!y,isStale:L,binPrefix:N,canEditBin:v,supportedInstallmentsCount:l.length,isNegotiating:O}),B=C==="dropdown"&&l.length>0,K=I(B);if(u(()=>{if(!(!B||K.current))return K.current=!0,$({content:p})},[B,p]),C==="hidden")return null;if(C==="prompt")return o(x,{id:i,name:"msiInstallments",label:p,value:"prompt",onCh
1ange:()=>{},children:o(w,{value:"prompt",children:a.translate("msi_installments.enter_card_details_prompt")})});if(C==="loading")return o(x,{id:i,name:"msiInstallments",label:p,value:"loading",disabled:!0,onChange:()=>{},children:o(w,{value:"loading",children:a.translate("msi_installments.loading_installments")})});let D;return h&&(D=h==="none_eligible"?a.translate("msi_installments.no_plans_available"):a.translate("msi_installments.plan_no_longer_available")),o(ee,{ref:M,gap:"small-400",children:[o(x,{id:i,name:"msiInstallments",label:p,value:J,onChange:z,onFocus:Q,children:[o(w,{value:"",children:a.translate("msi_installments.pay_in_full")}),l.map(n=>o(w,{value:String(n),children:a.translate("msi_installments.months_interest_free",{months:n})},n))]}),D?o(V,{color:"subdued",accessibilityLive:"polite",children:D}):null]})}export{Ee as MsiInstallmentsSelect};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.