1import{u as e,g as n,q as t,a4 as a,a5 as o,z as i,o as c,h as r,T as s,S as l}from"./2c1ab0fe.B2yRRyAW.js";import{b as d,a as m}from"./efa0389a.DgBvBH2e.js";import{ab as p,j as u,b,cq as f,bi as k,a9 as y,aa as h,S as _,B as g,c as j,a1 as v}from"./164ad2e3.-hfWY9cN.js";import{c as C,c4 as S,b5 as B,b0 as T}from"./4b4bc88f.JFrEI7LU.js";import{P as A}from"./86720dbb.C0NBtMoX.js";import{P as I}from"./598fef4e.C__a6xIj.js";import{g as N,F as w,D as x,M as P}from"./e77f7fe0.B1UY2cg5.js";import{u as E,W as F}from"./8536083a.C5C5qnTL.js";import{S as L}from"./ee2bb050.C2oice07.js";import{u as D,a as O}from"./3a819064.DQ0jt2oZ.js";import"./22345fd4.CQJ0n-1P.js";import"./app.C_W8kcQ4.js";import"./d0bb51ec.CiN57OqX.js";import"./f67abd2c.Boj0gJpa.js";import"./60a453ce.aSs2kW8G.js";import"./e12db40c.ZpKYxNRe.js";import"./9dba8418.BqWu-Ch9.js";import"./d25d1b95.DkedqTWK.js";import"./dfca5da5.CtpsmRuf.js";import"./dae24aab.xiAL8T3Q.js";import"./55098bf1.OVeEjE2R.js";import"./0e67bd3b.DYIAHGYe.js";import"./74835653.B3C9_9vV.js";import"./3ca8ef7e.CGmhNbCs.js";import"./2495faa4.B5RDSEV2.js";import"./a9fa9fda.DtwHg2w5.js";import"./ca3e798e.j1SNghYW.js";import"./47b970b2.B55cGlxq.js";import"./064f6ac1.CZOb24JP.js";import"./4b1c22b7.BOiV_1od.js";import"./6bfea526.DhpjKDX-.js";import"./ac5a19ff.BhdcadwW.js";import"./a422df8c.p_hgP_ap.js";import"./cc6ff67d.C_qUEjhN.js";import"./08a3b809.DE8GX3m3.js";import"./bf513f9c.BITc5iYn.js";import"./e39bc11c.DZRk2vl_.js";import"./7a8217fd.C2rM5fX2.js";import"./8599b02a.C02H2K0N.js";import"./cf29e63b.CWl11nWq.js";import"./f692f62f.T4hOHGz4.js";import"./9babe369.YjVJF-bz.js";import"./b684bff6.YNZp59HI.js";import"./79974aab.Du4uYIZv.js";import"./58314944.DeRGAACO.js";import"./c6c0cbda.AqWWc50G.js";import"./17e57de1.d8zWzF56.js";function q({accountType:n,bankName:t,lastDigits:a,id:o}){const{i18n:i}=C();return e(d,{id:o,value:o,children:[e(p,{gridAutoFlow:"column",gridTemplateColumns:"minmax(auto, max-content) minmax(0, 1fr)",gridTemplateRows:"minmax(0, 1fr)",gap:"small-200",padding:"none",alignItems:"center",alignContent:"center",children:[e(I,{type:N(t)}),e(u,{type:"strong",children:[t," ",e("span",{className:"vr1Ob",children:i.translate("payment.masked_digits_label",{last_digits:a})})]})]}),n&&e(b,{padding:"small-400 none none none",children:e(u,{children:(()=>{const e=n?.toLowerCase();return"checking"===e?i.translate("payment.bank_account_type.checking"):"savings"===e?i.translate("payment.bank_account_type.savings"):""})()})})]},o)}const M={id:"137c4da513561030856913c790967e4e298bea45ad3d6adfc786bc844ca55be2",type:"query",name:"StripeFinancialConnectionsClientSecret",source:""};class z extends Error{constructor(){super(...arguments),this.name="BankPaymentTokenInterceptError"}}function K(e){return{bankName:e.bankName??"",lastDigits:e.lastDigits??"",id:e.shopifyPublicToken??"",accountType:e.accountType??"savings",type:"SHOPIFY_PUBLIC_TOKEN"}}function R({method:d,setSelected:p,id:b,setIcon:T}){const{paymentProviderClientCredentials:A,availableInstruments:I}=d,{i18n:N,shop:w,observability:x}=C(),[P,R]=i(),{connectedBankAccount:G,handleBankConnectionClick:H,isLoading:Q,Sandbox:U}=function({clientCredentials:s,observability:l,onBankAccountCollected:d}){const m=D(),p=E(),u=(()=>{const{observability:e,graphql:{coreGraphql:i}}=C(),c=n(null);return t(async()=>c.current?c.current:c.current=(async({graphql:e,observability:n})=>{const t=async n=>{const{data:t,error:a}=await e.staticQuery(M,{cache:!1,variables:{input:n?{pendingTask:{taskId:n}}:{}}});return null!=a?(r(a.message),null):null==t?(r("NO_DATA"),null):t};let i=0,c="";for(;;){const e=await t(c);if(null===e)return null;const{stripeFinancialConnectionsClientSecret:n}=e;switch(n.__typename){case"StripeFinancialConnectionsClientSecretCreationFailed":return r(n.errorCode),null;case"StripeFinancialConnectionsClientSecretCreationSuccess":return n.clientSecret;case"PendingTask":if(c=n.taskId,i+=1,i>=5)return r("REACHED_MAX_POLLING"),null;await o(n.pollDelay);break;default:a(n)}}function r(e){return n.counter({name:"stripe_financial_connections_client_secret_error",value:1,attributes:{code:e}}),n.log("use_get_client_secret_stripe_client_secret_creation_failed","createStripeFinancialConnectionsClientSecret failed",{attributes:{code:e}}),null}})({graphql:i,observability:e}).finally(()=>{c.current=null}),[i,e])})(),[b,y]=i(!0),h=f(),{i18n:_}=C(),g=c(null),[j,v]=i(!1),[S,B]=i(null),[T,A]=i(null);r(()=>{(async()=>{A(await u())})()},[u]);const I=()=>{y(!1),v(!1)},N=e=>{l.leaveErrorBreadcrumb("Bank account token collection failed",{error:e}),h(_.translate("payment.bank_account_generic_error")),I()},w=O({breadcrumb:m,onBankAccountCollected:e=>{l.leaveErrorBreadcrumb("bank_account_collected",{bankAccountId:e.id,bankName:e.bankName??"",type:e.type}),B(e),d(e),I()},onModalClosed:I,onError:N,telemetry:p}),x=()=>{g.value=null};return{connectedBankAccount:S,handleBankConnectionClick:async()=>
1{if(g.value){y(!T);const e=T||await u();v(!0),e?(g.value.call.collectBankAccount(e),T&&A(null)):(y(!1),v(!1),N("No client secret")),y(!1)}},terminateSandbox:x,isLoading:b,Sandbox:e(k,{children:e(F,{wallet:"STRIPE_BANK",onConnect:async e=>{g.value=e;const n=await e.call.configure(s?.apiClientKey??"",s?.merchantAccountId??"");n?.status!==L.Success&&(l.leaveErrorBreadcrumb("Stripe Bank sandbox configuration failed",{status:n.status}),h(_.translate("payment.bank_account_generic_error"))),y(!1)},hostMethods:w,isSdkOnly:!j,isFullScreen:j,onTerminate:x})})}}({clientCredentials:A,observability:x,onBankAccountCollected:e=>{J(e??null),R(void 0)}});S(async({parts:e,reason:n})=>{const t=e.paymentLines.value.find(e=>"bank"===e.method.type);if(("completion"===n||"progression"===n)&&t){if(!$)return{behavior:"block",reason:B.MissingBankAccount,perform(){R(N.translate("payment.bank_account_missing"))}};if(!t.method.selectedToken)return x.error(new z("Bank payment blocked at completion: selectedBankAccount is set but selectedToken is missing from payment line")),{behavior:"block",reason:B.MissingBankAccount,perform(){R(N.translate("payment.bank_account_missing"))}}}return{behavior:"allow"}});const W=s(()=>[...I.map(K),...G?[G]:[]],[I,G]),{selectedBankAccount:$,setSelectedBankAccount:J}=function(e,n,a,o){const{checkout:{negotiator:c}}=C(),s=c.parts.paymentLines.value,{bankPaymentTokenSignal:l}=c.context,[d,m]=i(e[0]??null),p=t(e=>{e?(n(a,{type:"bank",selectedToken:e.id,selectedType:e.type}),o(e.bankName??"")):n(a,{type:"bank",selectedToken:void 0,selectedType:void 0})},[a,n,o]),u=t(e=>{m(e),l.value=e?{selectedToken:e.id,selectedType:e.type}:void 0,p(e),e&&o(e.bankName??"")},[m,p,o]);return r(()=>{const n=s.find(e=>"bank"===e.method.type)?.method;if(n)if(n.selectedToken&&n.selectedType){const t=e.find(e=>e.id===n.selectedToken);t?(m(t),o(t.bankName??"")):(l.value=void 0,p(null))}else if(d){if(!e.some(e=>e.id===d.id))return;l.value={selectedToken:d.id,selectedType:d.type},p(d)}},[e,p,s,d,o]),{selectedBankAccount:d,setSelectedBankAccount:u}}(W,p,b,T),X=t(([e])=>{const n=W.find(n=>n.id===e);J(n??null)},[W,J]),Y=s(()=>[$?.id??""],[$?.id]),V=Boolean(G);return e(_,{gap:"base",children:[U,P&&e(y,{tone:"critical",errorType:h.PaymentError,children:P}),W.length>0?e(l,{children:[e(_,{gap:"small-100",padding:"none none small-100 none",children:[V?e(u,{color:"subdued",children:N.translate("payment.new_bank_account_disclaimer",{shop_name:w?.name||""})}):null,e(u,{color:"subdued",children:N.translate("payment.bank_account_disclaimer")})]}),e(m,{values:Y,onChange:X,variant:"grid",children:W.map(n=>e(q,{...n},n.id))})]}):e(u,{children:N.translate("payment.bank_account_choose")}),e(g,{variant:"plain",textDecoration:"none",disabled:Q,onClick:H,tone:Q?"monochrome":"auto",children:e(_,{direction:"inline",alignItems:"center",gap:"small-100",minBlockSize:"10px",minInlineSize:"10px",children:[Q?e(j,{size:"base"}):e(v,{type:"plus"}),e(u,{color:"subdued",children:W.length>0?N.translate("payment.bank_account_connect_another"):N.translate("payment.bank_account_connect")})]})})]})}function G({method:n,setSelected:a,id:o,showSelectedContent:c=!0,bare:r=!1}){const{i18n:s}=C(),l=n.availableInstruments[0]?.bankName,m=l?[N(l)]:x,[p,b]=i(m),[f,k]=i(l?void 0:P),y=n.displayName??s.translate("payment.bank_payment_method_label"),h=t(e=>{b([e?N(e):w]),k(void 0)},[]);if(r)return e(R,{id:o,method:n,setIcon:h,setSelected:a});const _=T(s,p,f),g=_?`${y}, ${_}`:y;return e(d,{renderSelectedContentWhenCollapsed:!0,secondaryContent:e(A,{paymentBrands:p,brandCountOverride:f}),value:o,accessibilityLabel:g,selectedContent:c?e(R,{id:o,method:n,setIcon:h,setSelected:a}):void 0,children:e(u,{type:"strong",children:y})})}export{G as BankPaymentMethod,R as BankPaymentMethodDetails};
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.