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