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