@adyen/adyen-web
Version:
[](https://www.npmjs.com/package/@adyen/adyen-web)
3 lines (2 loc) • 2.34 kB
JavaScript
import e from"./createCardVariantSwitcher.js";import{BRAND_ICON_UI_EXCLUSION_LIST as n}from"../lib/constants.js";import{requiresDualBrandSelection as r}from"../../../Card/components/CardInput/utils.js";import{DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM as t}from"../../../Card/constants.js";function o(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}const s=(e,n)=>e.reduce((e,r)=>e||n.includes(r.brand),!1),u=e=>e.map(e=>function(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{},t=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),t.forEach(function(n){o(e,n,r[n])})}return e}({},e)),a=(e,n="mc",r="visa")=>{const t=u(e);return t[0].brand!==n&&t[0].brand!==r&&t.reverse(),t.length=1,t};function d(o,d,c,i={}){const{type:l,cvcPolicy:p}=o,{sfp:b}=d,{dualBrandSelectElements:g,setDualBrandSelectElements:C,setSelectedBrandValue:B,issuingCountryCode:f,setIssuingCountryCode:y}=c;return{processBinLookup:(o,d)=>{var c;const g=(null==o?void 0:o.issuingCountryCode)?o.issuingCountryCode.toLowerCase():null;if(y(g),!o||!Object.keys(o).length){C([]),B("");const e=d&&"card"!==l?l:null;return b.current.processBinLookupResponse(o,{brand:e,cvcPolicy:p}),void(i.current=0)}if(null===(c=o.supportedBrands)||void 0===c?void 0:c.length){const d=s(o.supportedBrands,n),c=d?a(o.supportedBrands):u(o.supportedBrands);if(c.length>1){const n=r(t,c,"brand"),s=e(c,n);C(s.dualBrandSelectElements),B(s.selectedBrandValue),b.current.processBinLookupResponse({issuingCountryCode:o.issuingCountryCode,supportedBrands:[s.leadBrand]}),s.leadBrand.panLength>0&&(i.current=s.leadBrand.panLength)}else C([]),B(""),d||B(c[0].brand),b.current.processBinLookupResponse({issuingCountryCode:o.issuingCountryCode,supportedBrands:c}),c[0].panLength>0&&(i.current=c[0].panLength)}},handleDualBrandSelection:e=>{let n=[];e&&(n=g.reduce((n,r)=>(r.brandObject.brand===e&&n.push(r.brandObject),n),[]),n.length&&(B(e),b.current.processBinLookupResponse({issuingCountryCode:f,supportedBrands:n,isDualBrandSelection:!0})))}}}export{u as cloneBrandsArr,s as containsExcludedBrand,d as default,a as removeExcludedBrand};
//# sourceMappingURL=extensions.js.map