@adyen/adyen-web
Version:
[](https://www.npmjs.com/package/@adyen/adyen-web)
3 lines (2 loc) • 1.76 kB
JavaScript
import e from"./createCardVariantSwitcher.js";import{BRAND_ICON_UI_EXCLUSION_LIST as n}from"../lib/constants.js";const t=(e,n)=>e.reduce(((e,t)=>e||n.includes(t.brand)),!1),r=e=>e.map((e=>({...e}))),s=(e,n="mc",t="visa")=>{const s=r(e);return s[0].brand!==n&&s[0].brand!==t&&s.reverse(),s.length=1,s};function o(o,u,a,d={}){const{type:c,cvcPolicy:i}=o,{sfp:l}=u,{dualBrandSelectElements:p,setDualBrandSelectElements:B,setSelectedBrandValue:g,issuingCountryCode:C,setIssuingCountryCode:b}=a;return{processBinLookup:(o,u)=>{const a=o?.issuingCountryCode?o.issuingCountryCode.toLowerCase():null;if(b(a),!o||!Object.keys(o).length){B([]),g("");const e=u&&"card"!==c?c:null;return l.current.processBinLookupResponse(o,{brand:e,cvcPolicy:i}),void(d.current=0)}if(o.supportedBrands?.length){const u=t(o.supportedBrands,n),a=u?s(o.supportedBrands):r(o.supportedBrands);if(a.length>1){const n=e(a);B(n.dualBrandSelectElements),g(n.selectedBrandValue),l.current.processBinLookupResponse({issuingCountryCode:o.issuingCountryCode,supportedBrands:[n.leadBrand]}),n.leadBrand.panLength>0&&(d.current=n.leadBrand.panLength)}else B([]),g(""),u||g(a[0].brand),l.current.processBinLookupResponse({issuingCountryCode:o.issuingCountryCode,supportedBrands:a}),a[0].panLength>0&&(d.current=a[0].panLength)}},handleDualBrandSelection:e=>{let n=e;if(e instanceof Event){const t=e.target;n=t.getAttribute("data-value")||t.getAttribute("value")}let t=[];n&&(t=p.reduce(((e,t)=>(t.brandObject.brand===n&&e.push(t.brandObject),e)),[]),t.length&&(g(n),l.current.processBinLookupResponse({issuingCountryCode:C,supportedBrands:t,isDualBrandSelection:!0})))}}}export{r as cloneBrandsArr,t as containsExcludedBrand,o as default,s as removeExcludedBrand};
//# sourceMappingURL=extensions.js.map