straumur-web-component 2.0.0-alpha.2 → 2.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import{h as he,render as Pe}from"preact";function _(e,{insertAt:t}={}){if(!e||ty
|
|
|
4
4
|
`);import{useRef as Ir,useState as Er}from"preact/hooks";var me=({children:e,content:t})=>{let[r,o]=Er(!1),a=Ir(null);return rt("div",{style:{position:"relative"}},rt("div",{ref:a,onMouseEnter:()=>{o(!0)},onMouseLeave:()=>{o(!1)}},e),r&&a&&rt("div",{className:"straumur__tooltip__content"},t))};import{useEffect as Ar,useState as Rr}from"preact/hooks";function ot(e){let t=()=>window.matchMedia(e).matches,[r,o]=Rr(t);return Ar(()=>{let a=window.matchMedia(e),n=i=>o(i.matches);return o(a.matches),a.addEventListener("change",n),()=>{a.removeEventListener("change",n)}},[e]),r}function Ae({brands:e,brandHidden:t=[],limit:r=3}){let o=ot("(max-width: 380px)"),n=ot("(max-width: 335px)")?1:o?2:r,i=e.filter(l=>{let{brand:m}=l;return!t.some(f=>f.brand===m)});return A(Ft,null,i.map(({brand:l},m)=>m>=Math.min(r,n)?m===Math.min(r,n)?A(me,{content:A("span",{style:{display:"flex",gap:"4px",overflow:"visible"}},i.slice(Math.min(r,n)).map(({brand:d})=>A(Ee,{key:d,brand:d})))},A("span",{key:l,className:"straumur__render-brand-icons__overflow"},"+",i.length-Math.min(r,n))):null:A(Ee,{key:l,brand:l})))}var Ee=({brand:e,defaultToBrandName:t=!0})=>{switch(e){case"visa":return A(It,null);case"mc":return A(kt,null);case"maestro":return A(Et,null);case"amex":return A(At,null);case"jcb":return A(Rt,null);case"diners":return A(Dt,null);case"discover":return A(Tt,null);case"cup":return A(zt,null);default:return t?A("span",null,e):A(Ft,null)}};import{Fragment as Or,h as y}from"preact";import{useRef as Be,useState as ne,useEffect as it}from"preact/hooks";import{AdyenCheckout as Gr,CustomCard as Vr}from"@adyen/adyen-web";import{h as oe}from"preact";var Dr=()=>oe("svg",{width:"21",height:"20",viewBox:"0 0 21 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},oe("g",{"clip-path":"url(#clip0_10626_39119)"},oe("path",{d:"M10.6641 7.5C11.3543 7.5 11.9141 6.94023 11.9141 6.25C11.9141 5.55977 11.3543 5 10.6641 5C9.97383 5 9.41406 5.55859 9.41406 6.25C9.41406 6.94141 9.97266 7.5 10.6641 7.5ZM12.2266 13.125H11.6016V9.6875C11.6016 9.17188 11.1836 8.75 10.6641 8.75H9.41406C8.89844 8.75 8.47656 9.17188 8.47656 9.6875C8.47656 10.2031 8.89844 10.625 9.41406 10.625H9.72656V13.125H9.10156C8.58594 13.125 8.16406 13.5469 8.16406 14.0625C8.16406 14.5781 8.58594 15 9.10156 15H12.2266C12.7441 15 13.1641 14.5801 13.1641 14.0625C13.1641 13.5449 12.7461 13.125 12.2266 13.125Z",fill:"currentColor"}),oe("path",{opacity:"0.4",d:"M10.6641 0C5.14062 0 0.664062 4.47656 0.664062 10C0.664062 15.5234 5.14062 20 10.6641 20C16.1875 20 20.6641 15.5234 20.6641 10C20.6641 4.47656 16.1875 0 10.6641 0ZM10.6641 5C11.3543 5 11.9141 5.55977 11.9141 6.25C11.9141 6.94023 11.3543 7.5 10.6641 7.5C9.97383 7.5 9.41406 6.94141 9.41406 6.25C9.41406 5.55859 9.97266 5 10.6641 5ZM12.2266 15H9.10156C8.58594 15 8.16406 14.582 8.16406 14.0625C8.16406 13.543 8.58398 13.125 9.10156 13.125H9.72656V10.625H9.41406C8.89648 10.625 8.47656 10.2051 8.47656 9.6875C8.47656 9.16992 8.89844 8.75 9.41406 8.75H10.6641C11.1816 8.75 11.6016 9.16992 11.6016 9.6875V13.125H12.2266C12.7441 13.125 13.1641 13.5449 13.1641 14.0625C13.1641 14.5801 12.7461 15 12.2266 15Z",fill:"currentColor"})),oe("defs",null,oe("clipPath",{id:"clip0_10626_39119"},oe("rect",{width:"20",height:"20",fill:"white",transform:"translate(0.664062)"})))),Re=Dr;import{h as de}from"preact";var Tr=()=>de("svg",{width:"40",height:"40",viewBox:"0 0 40 40",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor"},de("g",{fill:"none","fill-rule":"evenodd"},de("g",{transform:"translate(2 2)","stroke-width":"4"},de("circle",{"stroke-opacity":".3",cx:"18",cy:"18",r:"18"}),de("path",{d:"M36 18c0-9.94-8.06-18-18-18"},de("animateTransform",{attributeName:"transform",type:"rotate",from:"0 18 18",to:"360 18 18",dur:"1s",repeatCount:"indefinite"}))))),J=Tr;import{h as Bt}from"preact";var zr=({color:e="var(--straumur__color-primary)"})=>Bt("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"13",viewBox:"0 0 16 13",fill:"none"},Bt("path",{d:"M2 7L6 11L14 2",stroke:e,"stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round"})),De=zr;import{h as ae}from"preact";function Nt({brand:e,brandName:t,isSelected:r,onBrandClick:o}){let a=n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),n.currentTarget.click())};return ae("span",{className:"straumur__card-component__dual-branding--logo"+(r?" straumur__card-component__dual-branding--logo--selected":""),title:e,"data-value":e,onClick:o,onKeyDown:a,role:"radio","aria-checked":r,"aria-label":t??e,tabIndex:0},ae("div",{className:"straumur__card-component__dual-branding--logo--item"},ae(Ee,{brand:e,defaultToBrandName:!1}),"\xA0",t??""),r&&ae(De,{color:"var(--straumur__color-neon-green-zeta)"}))}function Ht({dualBrandConfiguration:e,selectedBrand:t,onBrandClick:r}){return ae("div",{className:"straumur__card-component__dual-branding",role:"radiogroup","aria-label":"Card brand"},ae(Nt,{brand:e.brand1,brandName:e.brand1Name,isSelected:t===e.brand1,onBrandClick:r}),ae(Nt,{brand:e.brand2,brandName:e.brand2Name,isSelected:t===e.brand2,onBrandClick:r}))}var Fr=["AuthenticationFinished","AuthenticationNotRequired","Authorised","Cancelled","ChallengeShopper","Error","IdentifyShopper","PartiallyAuthorised","Pending","PresentToShopper","Received","RedirectShopper","Refused"];function at(e){return e&&Fr.includes(e)?e:"Error"}var T=class extends Error{messageKey;messageText;constructor(t,r){super(r??t),this.messageKey=t,this.messageText=r}};function be(e,t){return e instanceof T?e.messageText?{text:e.messageText}:{key:e.messageKey}:{key:t}}function Lt(e,t){return{async submitPayment(r){let o={...r,sessionId:t},a=await _t(e,o);if(!a.ok)throw new T("error.failedToSubmitPayment");let n=await a.json();if(!n.resultCode)throw new T("error.paymentFailed");return{resultCode:n.resultCode,action:n.action}},async submitAdditionalDetails(r){let o={...r,sessionId:t},a=await gt(e,o);if(!a.ok)throw new T("error.failedToSubmitPaymentDetails");let n=await a.json();if(!n.resultCode)throw new T("error.paymentDetailsFailed");return{resultCode:n.resultCode,action:n.action}},async disableToken(r){let a=await bt(e,{storedPaymentMethodId:r,sessionId:t});if(!a.ok)throw new T("error.failedToSubmitRemoveStoredPaymentCard");if(!(await a.json()).success)throw new T("error.failedToRemoveStoredPaymentCard")}}}function Ut(e){function t(a,n,i,l){let m=d=>i(d instanceof T?d:new T(l));try{Promise.resolve(a(n,i)).catch(m)}catch(d){m(d)}}let r={submitPayment(a){return new Promise((n,i)=>{t((l,m)=>e.onSubmit({data:a},{resolve:l,reject:d=>m(new T("error.failedToSubmitPayment",d))}),n,i,"error.failedToSubmitPayment")})},submitAdditionalDetails(a){return new Promise((n,i)=>{t((l,m)=>e.onAdditionalDetails({data:a},{resolve:l,reject:d=>m(new T("error.failedToSubmitPaymentDetails",d))}),n,i,"error.failedToSubmitPaymentDetails")})},beforeSubmit:e.onBeforeSubmit},{onDisableToken:o}=e;return o&&(r.disableToken=a=>new Promise((n,i)=>{t((l,m)=>o({storedPaymentMethodId:a},{resolve:()=>l(),reject:()=>m(new T("error.failedToRemoveStoredPaymentCard"))}),n,i,"error.failedToSubmitRemoveStoredPaymentCard")})),r}async function nt(e){let{beforeSubmit:t}=e;return!t||await t()}async function Te(e,t){t()&&await nt(e)&&t()?.submit()}function st(e){return(t,r)=>{let{beforeSubmit:o}=e;if(!o){t();return}let a=o();if(a instanceof Promise){a.then(n=>n?t():r()).catch(()=>r());return}if(a){t();return}r()}}var Br=["Refused","Cancelled","Error"];function $(e){let{configuration:t,handleSuccess:r,handleError:o,setThreeDSecureActive:a,enrichSubmitData:n,onSubmitStart:i,dispatchResultFromAdditionalDetails:l}=e,m;function d(){return m?{text:m}:{key:"error.paymentUnsuccessful"}}function f(g){g==="Authorised"?r({key:"success.paymentAuthorized"}):o(d()),Br.includes(g)?t.onPaymentFailed?.({resultCode:g}):t.onPaymentCompleted?.({resultCode:g})}async function h(g,I,R){i?.();let{paymentFlow:k}=t;if(!await nt(k)){R.reject();return}try{let D=n?n(g.data):g.data,{resultCode:u,action:U,errorMessage:F}=await k.submitPayment(D);m=F,(u==="ChallengeShopper"||u==="IdentifyShopper")&&a(!0),R.resolve({resultCode:u,action:U})}catch(D){R.reject(),o(be(D,"error.failedToSubmitPayment"))}}async function P(g,I,R){try{let{resultCode:k,action:D,errorMessage:u}=await t.paymentFlow.submitAdditionalDetails(g.data);m=u,R.resolve({resultCode:k,action:D}),l&&f(k)}catch(k){R.reject(),o(be(k,"error.failedToSubmitPaymentDetails")),l&&t.onPaymentFailed?.({resultCode:"Error"})}}function w(g,I){f(at(g.resultCode))}function z(g,I){f(g?at(g.resultCode):"Error")}return{handleOnSubmit:h,handleOnSubmitAdditionalData:P,handlePaymentCompleted:w,handlePaymentFailed:z}}import{useEffect as Nr}from"preact/hooks";function ce(e,t,r){Nr(()=>{t()&&r()},[e])}import{useEffect as Hr}from"preact/hooks";function ze(e,t){Hr(()=>{t&&e.current?.focus()},[t,e])}import{useEffect as Lr,useState as Ur}from"preact/hooks";var Zt="(prefers-color-scheme: dark)";function Zr(){return typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(Zt).matches:!1}function ue(e){let[t,r]=Ur(Zr);return Lr(()=>{if(e!=="system"||typeof window>"u"||typeof window.matchMedia!="function")return;let o=window.matchMedia(Zt),a=n=>r(n.matches);return r(o.matches),o.addEventListener("change",a),()=>o.removeEventListener("change",a)},[e]),e==="system"?t?"dark":"light":e}function Fe(e){return e==="dark"?{base:{color:"#e8edf2"},placeholder:{color:"#9aa7b5"},error:{color:"#e08a8a"}}:{base:{color:"#00112c"},placeholder:{color:"#72889d"},error:{color:"#d96666"}}}function Wr({configuration:e,paymentMethods:t,onBrandHidden:r}){let o=Be(null),a=Be(),n=Be(),{i18n:i}=H(),[l,m]=ne(!0),[d,f]=ne("required"),[h,P]=ne(!1),[w,z]=ne(!1),[g,I]=ne(null),[R,k]=ne(null),D=Be(!1),[u,U]=ne({encryptedCardNumber:{visible:!1},encryptedExpiryDate:{visible:!1},encryptedSecurityCode:{visible:!1}}),{activePaymentMethod:F,isPaymentMethodInitialized:E,updatePaymentMethodInitialization:W,handleSuccess:B,handleError:L,setThreeDSecureActive:j,threeDSecureActive:Z,isObscuredByThreeDS:N,hasCard:ie,registerSubmitHandler:b,unregisterSubmitHandler:K}=x(),ee=ue(e.theme);async function fe(){await Te(e.paymentFlow,()=>n.current)}it(()=>{if(!(F==="card"&&E.card)){e.onCardValidityChanged?.(!1,!1);return}return b(fe),()=>{K(fe),e.onCardValidityChanged?.(!1,!1)}},[F,E.card,b,K]);let ye=t.paymentMethods?.paymentMethods?.find(p=>p.type==="scheme")?.brands??[],{handleOnSubmit:Ke,handleOnSubmitAdditionalData:Se,handlePaymentCompleted:Je,handlePaymentFailed:$e}=$({configuration:e,handleSuccess:B,handleError:L,setThreeDSecureActive:j,enrichSubmitData:p=>({...p,storePaymentMethod:D.current})});function Xe(p,C){L({key:"error.unknownError"})}let xe=async()=>{n.current?.remove(),a.current=await Gr({clientKey:t.clientKey,environment:e.environment,locale:e.locale,countryCode:e.countryCode,paymentMethodsResponse:t.paymentMethods,amount:{value:t.minorUnitsAmount,currency:t.currency},onSubmit:Ke,onAdditionalDetails:Se,onError:Xe,onPaymentCompleted:Je,onPaymentFailed:$e}),n.current=new Vr(a.current,{brands:ye,placeholders:e.placeholders,styles:Fe(ee),challengeWindowSize:"05",onBinLookup:p=>{p.supportedBrandsRaw&&p.supportedBrandsRaw.length>1&&(z(!0),I({brand1:p.supportedBrandsRaw[0].brand,brand1Name:p.supportedBrandsRaw[0].localeBrand,brand1ImageUrl:p.supportedBrandsRaw[0].brandImageUrl,brand2:p.supportedBrandsRaw[1].brand,brand2Name:p.supportedBrandsRaw[1].localeBrand,brand2ImageUrl:p.supportedBrandsRaw[1].brandImageUrl}))},onBrand:p=>{if(f(p.cvcPolicy),p.brand==="card"){r([]),k(null);return}let C=ye.filter(S=>S!==p.brand).map(S=>({brand:S}));r(C),ye.filter(S=>S===p.brand).map(S=>({brand:S})).length===1&&k(p.brand)},onConfigSuccess(){W("card",!0)},onValidationError:p=>{let C={encryptedCardNumber:{visible:!1,message:void 0},encryptedExpiryDate:{visible:!1,message:void 0},encryptedSecurityCode:{visible:!1,message:void 0}};p.filter(S=>S.error).forEach(S=>{C[S.fieldType].visible=!0,C[S.fieldType].message=S.errorI18n}),U(C)},onAllValid:p=>{m(!p.allValid),e.onCardValidityChanged?.(p.allValid,!0)}}),o.current&&n.current.mount(o.current)};it(()=>{ie&&F==="card"&&!E.card&&xe()},[e,F]),ce(e,()=>!!(n.current&&E.card),()=>{xe(),U({encryptedCardNumber:{visible:!1,message:void 0},encryptedExpiryDate:{visible:!1,message:void 0},encryptedSecurityCode:{visible:!1,message:void 0}})}),it(()=>{D.current=h},[h]);function yt(p){n.current.dualBrandingChangeHandler(p)}function qe(p){P(p.currentTarget.checked)}return ze(o,Z&&F==="card"),!ie||N("card")||t.paymentMethods?.paymentMethods?.length===0?null:y("div",{className:"straumur__card-component__expandable",ref:o,tabIndex:-1,style:{height:Z?"600px":"auto",minWidth:Z?"350px":"auto"}},!E.card&&y("div",{className:"straumur__card-component__loading-text"},y(J,null)),y("div",{className:"straumur__card-component__form",style:{opacity:E.card&&!Z?1:0,position:E.card&&!Z?"relative":"absolute",transition:"opacity 0.3s ease-in-out"}},y("div",{className:"straumur__card-component__form--wrapper"},y("label",{className:`straumur__card-component__form--wrapper--label ${u.encryptedCardNumber.visible?"straumur__card-component__form--wrapper--label--error":""}`},i.t("cards.cardNumber")),y("span",{className:`straumur__card-component__form--wrapper--input ${u.encryptedCardNumber.visible?"straumur__card-component__form--wrapper--input--error":""}`,"data-cse":"encryptedCardNumber",role:"group","aria-label":i.t("cards.cardNumber")}),u.encryptedCardNumber.visible&&y("span",{className:"straumur__card-component__form--wrapper--error"},u.encryptedCardNumber.message)),y("div",{className:"straumur__card-component__form--field-wrapper"},y("div",{className:"straumur__card-component__form--wrapper"},y("label",{className:`straumur__card-component__form--wrapper--label ${u.encryptedExpiryDate.visible?"straumur__card-component__form--wrapper--label--error":""}`},i.t("cards.expiryDate")),y("span",{className:`straumur__card-component__form--wrapper--input ${u.encryptedExpiryDate.visible?"straumur__card-component__form--wrapper--input--error":""}`,"data-cse":"encryptedExpiryDate",role:"group","aria-label":i.t("cards.expiryDate")}),u.encryptedExpiryDate.visible&&y("span",{className:"straumur__card-component__form--wrapper--error"},u.encryptedExpiryDate.message)),y("div",{className:"straumur__card-component__form--wrapper"},(d==="optional"||d==="required")&&y(Or,null,y("label",{className:`straumur__card-component__form--wrapper--label ${u.encryptedSecurityCode.visible?"straumur__card-component__form--wrapper--label--error":""}`},d==="optional"?i.t("cards.securityCode3DigitsOptional"):i.t("cards.securityCode3Digits")),y("span",{className:`straumur__card-component__form--wrapper--input ${u.encryptedSecurityCode.visible?"straumur__card-component__form--wrapper--input--error":""}`,"data-cse":"encryptedSecurityCode",role:"group","aria-label":i.t("cards.securityCode3Digits")}),u.encryptedSecurityCode.visible&&y("span",{className:"straumur__card-component__form--wrapper--error"},u.encryptedSecurityCode.message),y("div",{className:"straumur__card-component__form--wrapper--label--info"},y(me,{content:y("span",null,i.t("cards.securityCode3DigitsInfo"))},y(Re,null)))))),w&&g&&y(Ht,{dualBrandConfiguration:g,selectedBrand:R,onBrandClick:yt}),t.enableStoreDetails==="AskForConsent"&&y("label",{className:"straumur__card-component__form--wrapper--label-checkbox"},y("div",{className:`straumur__card-component__form--wrapper--label-checkbox--checkmark ${h?"straumur__card-component__form--wrapper--label-checkbox--checkmark--checked":""}`},y("div",{className:`straumur__card-component__form--wrapper--label-checkbox--checkmark--icon ${h?"straumur__card-component__form--wrapper--label-checkbox--checkmark--icon--checked":""}`},y(De,null))),y("input",{type:"checkbox",className:"straumur__card-component__form--wrapper--label-checkbox--checkbox",checked:h,onChange:qe}),i.t("cards.storePaymentMethod")),!e.hideSubmitButton&&y("button",{className:"straumur__card-component__submit-button",disabled:l,onClick:fe},t.minorUnitsAmount===0?i.t("cards.saveCardDetails"):t.formattedAmount)))}var Ot=Wr;import{h as pe}from"preact";_(`.straumur__payment-method-item{position:relative;cursor:pointer;background:var(--straumur__color-white);border-radius:var(--straumur__border-radius-lg);transition:all .3s ease;padding:var(--straumur__space-xxlg) var(--straumur__space-5xlg)}.straumur__payment-method-item--sole{cursor:default}.straumur__payment-method-item:has(.straumur__payment-method-item__radio-selector:checked){cursor:default}.straumur__payment-method-item__radio-selector{position:absolute;opacity:0;cursor:pointer}.straumur__payment-method-item__content{display:flex;align-items:center;gap:var(--straumur__space-lg);transition:background-color .3s ease}.straumur__payment-method-item__radio-selector:checked+.straumur__payment-method-item__content{padding-bottom:var(--straumur__space-xxlg)}.straumur__payment-method-item__content--expanded{padding-bottom:var(--straumur__space-xxlg)}.straumur__payment-method-item--circle{width:var(--straumur__space-5xlg);height:var(--straumur__space-5xlg);border:1px solid var(--straumur__color-cosmos-blue-gamma);background:var(--straumur__color-secondary-gamma);border-radius:50%;position:relative;transition:all .3s ease;flex-shrink:0}.straumur__payment-method-item__content:hover .straumur__payment-method-item--circle{border:1px solid var(--straumur__color-cosmos-blue-delta)}.straumur__payment-method-item--circle:after{content:"";position:absolute;width:100%;height:100%;border-radius:50%;top:50%;left:50%;transform:translate(-50%,-50%) scale(0);transition:transform .2s ease}.straumur__payment-method-item__radio-selector:checked+.straumur__payment-method-item__content .straumur__payment-method-item--circle{background:var(--straumur__color-blue-beta);border-color:var(--straumur__color-transparent)}.straumur__payment-method-item__radio-selector:checked+.straumur__payment-method-item__content .straumur__payment-method-item--circle:after{transform:translate(-50%,-50%) scale(1);background:var(--straumur__color-primary);height:var(--straumur__space-md);width:var(--straumur__space-md)}.straumur__payment-method-item--title{color:var(--straumur__color-text);font-size:16px;user-select:none}.straumur__payment-method-item__expandable{background:var(--straumur__color-white);max-height:0;overflow:hidden;transition:all .3s ease;opacity:0}.straumur__payment-method-item__radio-selector:checked~.straumur__payment-method-item__expandable{max-height:600px;opacity:1}.straumur__payment-method-item__expandable--visible{max-height:600px;opacity:1}
|
|
5
5
|
`);function jr({icon:e,title:t,isActive:r,isSole:o,onChange:a,children:n,headerRight:i,confirmSection:l}){return pe("label",{className:`straumur__payment-method-item${o?" straumur__payment-method-item--sole":""}`},!o&&pe("input",{type:"radio",className:"straumur__payment-method-item__radio-selector",checked:r,onChange:a}),pe("span",{className:`straumur__payment-method-item__content${o?" straumur__payment-method-item__content--expanded":""}`},!o&&pe("span",{className:"straumur__payment-method-item--circle"}),e,pe("span",{className:"straumur__payment-method-item--title"},t),i),l,pe("div",{className:`straumur__payment-method-item__expandable${o?" straumur__payment-method-item__expandable--visible":""}`},n))}var X=jr;function Jr({configuration:e,paymentMethods:t}){let{i18n:r}=H(),[o,a]=Kr([]),{activePaymentMethod:n,setActivePaymentMethod:i,isObscuredByThreeDS:l,isSolePaymentMethod:m,hasCard:d}=x();if(!d||l("card"))return null;let h=t.paymentMethods.paymentMethods.find(P=>P.type==="scheme").brands.map(P=>({brand:P,brandFullName:P}));return Ce(X,{icon:Ce(Mt,null),title:r.t("cards.title"),isActive:n==="card",isSole:m,onChange:()=>i("card"),headerRight:Ce("span",{className:"straumur__card-component--brands"},Ce(Ae,{brands:h,brandHidden:o}))},Ce(Ot,{configuration:e,paymentMethods:t,onBrandHidden:a}))}var Gt=Jr;import{h as mt}from"preact";import{useState as no}from"preact/hooks";_(`.adyen-checkout__paywithgoogle{height:var(--straumur__space-8xlg)}
|
|
6
6
|
`);import{h as q}from"preact";var $r=()=>q("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"26",fill:"none",viewBox:"0 0 40 26"},q("path",{fill:"#fff",d:"M29.13 2.41H10.87C5.17 2.41.5 7.18.5 13.01a10.5 10.5 0 0 0 10.37 10.58h18.26c5.7 0 10.37-4.76 10.37-10.59 0-5.82-4.67-10.59-10.37-10.59Z"}),q("path",{fill:"#3C4043",d:"M29.13 3.27c1.28 0 2.52.26 3.7.77a9.6 9.6 0 0 1 5.08 5.19 9.78 9.78 0 0 1 0 7.55 9.83 9.83 0 0 1-5.08 5.18 9.26 9.26 0 0 1-3.7.77H10.87a9.24 9.24 0 0 1-3.7-.77 9.6 9.6 0 0 1-5.08-5.18 9.78 9.78 0 0 1 0-7.55 9.83 9.83 0 0 1 5.08-5.19 9.24 9.24 0 0 1 3.7-.77h18.26Zm0-.86H10.87C5.17 2.41.5 7.18.5 13.01a10.5 10.5 0 0 0 10.37 10.58h18.26c5.7 0 10.37-4.76 10.37-10.59 0-5.82-4.67-10.59-10.37-10.59Z"}),q("path",{fill:"#3C4043",d:"M19.1 13.75v3.2h-1v-7.9h2.64c.67 0 1.24.23 1.7.68.49.46.72 1.01.72 1.67a2.2 2.2 0 0 1-.71 1.68c-.46.45-1.03.67-1.7.67H19.1Zm0-3.73v2.76h1.66c.4 0 .73-.14.99-.4.26-.28.4-.6.4-.98 0-.36-.14-.68-.4-.95a1.28 1.28 0 0 0-.99-.42H19.1Zm6.67 1.35c.73 0 1.31.2 1.74.6.42.4.64.95.64 1.65v3.34h-.95v-.76h-.04a1.9 1.9 0 0 1-1.65.93 2.1 2.1 0 0 1-1.46-.53c-.4-.35-.6-.8-.6-1.32 0-.56.21-1 .63-1.34.41-.33.97-.5 1.66-.5.59 0 1.07.12 1.45.34v-.23c0-.36-.13-.65-.4-.9a1.4 1.4 0 0 0-.97-.37c-.56 0-1 .24-1.32.72l-.88-.56a2.42 2.42 0 0 1 2.15-1.07Zm-1.29 3.92c0 .27.11.5.33.67.22.17.48.26.78.26.42 0 .79-.16 1.12-.48.32-.31.49-.68.49-1.11a2.02 2.02 0 0 0-1.3-.38c-.4 0-.74.1-1.01.3a.9.9 0 0 0-.4.74Zm9.08-3.75-3.32 7.8h-1.02l1.23-2.73-2.19-5.07h1.09l1.57 3.89h.02l1.54-3.89h1.08Z"}),q("path",{fill:"#4285F4",d:"M15.14 13.1c0-.32-.03-.64-.09-.95h-4.17v1.75h2.4a2.1 2.1 0 0 1-.89 1.4v1.14h1.43a4.49 4.49 0 0 0 1.32-3.33Z"}),q("path",{fill:"#34A853",d:"M12.4 15.3a2.66 2.66 0 0 1-4-1.44H6.9v1.18a4.43 4.43 0 0 0 6.91 1.4l-1.43-1.13Z"}),q("path",{fill:"#FABB05",d:"M8.25 13c0-.3.05-.59.14-.86v-1.17H6.9a4.59 4.59 0 0 0 0 4.07l1.48-1.17a2.79 2.79 0 0 1-.14-.86Z"}),q("path",{fill:"#E94235",d:"M10.88 10.27c.66 0 1.24.23 1.7.68l1.27-1.3a4.22 4.22 0 0 0-2.97-1.18 4.44 4.44 0 0 0-3.97 2.5l1.48 1.17a2.66 2.66 0 0 1 2.5-1.87Z"})),Vt=$r;_(`.straumur__google-pay-button__loading{display:flex;justify-content:center}
|
|
7
|
-
`);import{h as oo}from"preact";import{Fragment as Xr,h as Ne}from"preact";import{useEffect as qr,useRef as lt}from"preact/hooks";import{AdyenCheckout as Yr,ApplePay as Qr,GooglePay as eo}from"@adyen/adyen-web";var Wt="CANCEL";var to={applepay:{loadingClassName:"straumur__apple-pay-button__loading",createElement(e,{configuration:t,paymentMethods:r,walletConfig:o,handleOnSubmit:a}){let n={amount:{value:r.minorUnitsAmount,currency:r.currency},environment:t.environment,onSubmit:a,onClick:st(t.paymentFlow),configuration:{...o,merchantName:r.merchantName}};return new Qr(e,n)}},googlepay:{loadingClassName:"straumur__google-pay-button__loading",createElement(e,{configuration:t,paymentMethods:r,walletConfig:o,handleOnSubmit:a}){let n={amount:{value:r.minorUnitsAmount,currency:r.currency},challengeWindowSize:"05",countryCode:t.countryCode,environment:t.environment,onSubmit:a,onClick:st(t.paymentFlow),buttonSizeMode:"fill",configuration:{...o,merchantName:r.merchantName}};return new eo(e,n)}}};function ro({method:e,configuration:t,paymentMethods:r,isInstantPayment:o,onUnavailable:a}){let n=to[e],i=lt(null),l=lt(),m=lt(),{isPaymentMethodInitialized:d,updatePaymentMethodInitialization:f,handleSuccess:h,handleError:P,setThreeDSecureActive:w,threeDSecureActive:z,isObscuredByThreeDS:g,setActivePaymentMethod:I,activePaymentMethod:R}=x(),{handleOnSubmit:k,handleOnSubmitAdditionalData:D,handlePaymentCompleted:u,handlePaymentFailed:U}=$({configuration:t,handleSuccess:h,handleError:P,setThreeDSecureActive:w,onSubmitStart:()=>{o&&I(e)}});function F(B,L){B.name!==Wt&&P({key:"error.unknownError"})}function E(){f(e,!0),R===e&&I(null),a?.()}let W=async()=>{l.current=await Yr({clientKey:r.clientKey,environment:t.environment,locale:t.locale,countryCode:t.countryCode,paymentMethodsResponse:r.paymentMethods,amount:{value:r.minorUnitsAmount,currency:r.currency},onError:F,onAdditionalDetails:D,onPaymentCompleted:u,onPaymentFailed:U});let L=r.paymentMethods.paymentMethods?.find(j=>j.type===e)?.configuration;if(!L){E();return}m.current=n.createElement(l.current,{configuration:t,paymentMethods:r,walletConfig:L,handleOnSubmit:k}),m.current.isAvailable().then(()=>{m.current.mount(i.current),f(e,!0)}).catch(()=>{E()})};return qr(()=>{d[e]||W()},[t]),ce(t,()=>!!(m.current&&d[e]),()=>{m.current.remove(),W()}),g(e)?null:Ne(Xr,null,d[e]===!1&&Ne("div",{className:n.loadingClassName},Ne(J,null)),Ne("div",{ref:i,style:{height:z?"600px":"auto",minWidth:z?"350px":"auto",position:d[e]?"static":"absolute"}}))}var He=ro;function ao(e){return oo(He,{method:"googlepay",...e})}var Le=ao;function so({configuration:e,paymentMethods:t}){let{i18n:r}=H(),{activePaymentMethod:o,setActivePaymentMethod:a,isObscuredByThreeDS:n,isSolePaymentMethod:i,hasGooglePay:l}=x(),[m,d]=no(!1);return!l||m||e.instantPayments&&e.instantPayments.some(f=>f==="googlepay")||n("googlepay")?null:mt(X,{icon:mt(Vt,null),title:r.t("googlePay.title"),isActive:o==="googlepay",isSole:i,onChange:()=>a("googlepay")},mt(Le,{configuration:e,paymentMethods:t,isInstantPayment:!1,onUnavailable:()=>d(!0)}))}var jt=so;import{h as dt}from"preact";import{useState as co}from"preact/hooks";_("");import{h as Ue}from"preact";var io=()=>Ue("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"26",fill:"none",viewBox:"0 0 40 26"},Ue("path",{fill:"#000",d:"M36.42 0H3.58a69.25 69.25 0 0 0-.75 0c-.25.01-.5.03-.76.07a2.51 2.51 0 0 0-1.32.7A2.43 2.43 0 0 0 .07 2.1 5.14 5.14 0 0 0 0 3.22v19.91c.01.25.03.51.07.76a2.6 2.6 0 0 0 .68 1.35 2.39 2.39 0 0 0 1.32.69 4.98 4.98 0 0 0 1.1.07h34a5 5 0 0 0 .76-.07 2.5 2.5 0 0 0 1.32-.7 2.44 2.44 0 0 0 .68-1.34 5.13 5.13 0 0 0 .07-1.11V2.87a6.5 6.5 0 0 0-.07-.76 2.58 2.58 0 0 0-.68-1.35 2.4 2.4 0 0 0-1.32-.69 4.96 4.96 0 0 0-1.1-.07h-.41Z"}),Ue("path",{fill:"#fff",d:"M36.42.87h.73c.2 0 .42.02.62.06a1.67 1.67 0 0 1 .88.44 1.58 1.58 0 0 1 .44.89 4.38 4.38 0 0 1 .06.97v19.55a14.67 14.67 0 0 1-.06.96 1.7 1.7 0 0 1-.44.89 1.54 1.54 0 0 1-.87.44 4.27 4.27 0 0 1-.96.06H2.85a3.7 3.7 0 0 1-.63-.06 1.66 1.66 0 0 1-.87-.45 1.56 1.56 0 0 1-.44-.88 4.35 4.35 0 0 1-.06-.97V2.9c.01-.2.02-.42.06-.63.03-.18.08-.34.16-.49A1.56 1.56 0 0 1 2.22.93a4.2 4.2 0 0 1 .96-.06h33.24"}),Ue("path",{fill:"#000",d:"M10.92 8.61c.34-.43.57-1 .51-1.59a2.21 2.21 0 0 0-1.99 2.3c.56.04 1.12-.3 1.48-.7Zm.51.81c-.82-.05-1.52.46-1.9.46-.4 0-1-.43-1.64-.42-.84 0-1.62.48-2.05 1.24-.88 1.52-.23 3.76.62 5 .42.6.92 1.27 1.58 1.25.62-.02.86-.4 1.62-.4.75 0 .97.4 1.63.39.69-.01 1.11-.61 1.53-1.22.47-.7.67-1.37.68-1.4-.01-.02-1.32-.52-1.33-2.02-.01-1.26 1.03-1.85 1.07-1.9a2.34 2.34 0 0 0-1.81-.98Zm7.11-1.7a2.87 2.87 0 0 1 3.02 3c0 1.8-1.27 3.03-3.06 3.03h-1.97v3.12h-1.42V7.72h3.43Zm-2 4.83h1.62c1.24 0 1.94-.66 1.94-1.82 0-1.15-.7-1.81-1.93-1.81h-1.64v3.63Zm5.39 2.43c0-1.17.9-1.89 2.48-1.98l1.83-.1v-.52c0-.74-.5-1.18-1.34-1.18-.8 0-1.3.38-1.41.97h-1.3c.08-1.2 1.1-2.09 2.76-2.09 1.62 0 2.65.86 2.65 2.2v4.6h-1.31v-1.1h-.04a2.38 2.38 0 0 1-2.1 1.2c-1.3 0-2.22-.8-2.22-2Zm4.3-.6v-.53l-1.64.1c-.82.06-1.28.42-1.28.99 0 .58.48.96 1.22.96.96 0 1.7-.66 1.7-1.52Zm2.61 4.95v-1.11c.1.03.33.03.44.03.64 0 .98-.27 1.19-.96l.12-.4-2.41-6.69h1.48l1.7 5.43h.02l1.69-5.43h1.44l-2.5 7.02c-.57 1.62-1.23 2.14-2.61 2.14a5.3 5.3 0 0 1-.56-.03Z"})),Kt=io;_(`.straumur__apple-pay-button__loading{display:flex;justify-content:center}
|
|
7
|
+
`);import{h as oo}from"preact";import{Fragment as Xr,h as Ne}from"preact";import{useEffect as qr,useRef as lt}from"preact/hooks";import{AdyenCheckout as Yr,ApplePay as Qr,GooglePay as eo}from"@adyen/adyen-web";var Wt="CANCEL";var to={applepay:{loadingClassName:"straumur__apple-pay-button__loading",createElement(e,{configuration:t,paymentMethods:r,walletConfig:o,handleOnSubmit:a}){let n={amount:{value:r.minorUnitsAmount,currency:r.currency},environment:t.environment,onSubmit:a,onClick:st(t.paymentFlow),configuration:{...o,merchantName:r.merchantName}};return new Qr(e,n)}},googlepay:{loadingClassName:"straumur__google-pay-button__loading",createElement(e,{configuration:t,paymentMethods:r,walletConfig:o,handleOnSubmit:a}){let n={amount:{value:r.minorUnitsAmount,currency:r.currency},challengeWindowSize:"05",countryCode:t.countryCode,environment:t.environment,onSubmit:a,onClick:st(t.paymentFlow),buttonSizeMode:"fill",buttonRadius:8,configuration:{...o,merchantName:r.merchantName}};return new eo(e,n)}}};function ro({method:e,configuration:t,paymentMethods:r,isInstantPayment:o,onUnavailable:a}){let n=to[e],i=lt(null),l=lt(),m=lt(),{isPaymentMethodInitialized:d,updatePaymentMethodInitialization:f,handleSuccess:h,handleError:P,setThreeDSecureActive:w,threeDSecureActive:z,isObscuredByThreeDS:g,setActivePaymentMethod:I,activePaymentMethod:R}=x(),{handleOnSubmit:k,handleOnSubmitAdditionalData:D,handlePaymentCompleted:u,handlePaymentFailed:U}=$({configuration:t,handleSuccess:h,handleError:P,setThreeDSecureActive:w,onSubmitStart:()=>{o&&I(e)}});function F(B,L){B.name!==Wt&&P({key:"error.unknownError"})}function E(){f(e,!0),R===e&&I(null),a?.()}let W=async()=>{l.current=await Yr({clientKey:r.clientKey,environment:t.environment,locale:t.locale,countryCode:t.countryCode,paymentMethodsResponse:r.paymentMethods,amount:{value:r.minorUnitsAmount,currency:r.currency},onError:F,onAdditionalDetails:D,onPaymentCompleted:u,onPaymentFailed:U});let L=r.paymentMethods.paymentMethods?.find(j=>j.type===e)?.configuration;if(!L){E();return}m.current=n.createElement(l.current,{configuration:t,paymentMethods:r,walletConfig:L,handleOnSubmit:k}),m.current.isAvailable().then(()=>{m.current.mount(i.current),f(e,!0)}).catch(()=>{E()})};return qr(()=>{d[e]||W()},[t]),ce(t,()=>!!(m.current&&d[e]),()=>{m.current.remove(),W()}),g(e)?null:Ne(Xr,null,d[e]===!1&&Ne("div",{className:n.loadingClassName},Ne(J,null)),Ne("div",{ref:i,style:{height:z?"600px":"auto",minWidth:z?"350px":"auto",position:d[e]?"static":"absolute"}}))}var He=ro;function ao(e){return oo(He,{method:"googlepay",...e})}var Le=ao;function so({configuration:e,paymentMethods:t}){let{i18n:r}=H(),{activePaymentMethod:o,setActivePaymentMethod:a,isObscuredByThreeDS:n,isSolePaymentMethod:i,hasGooglePay:l}=x(),[m,d]=no(!1);return!l||m||e.instantPayments&&e.instantPayments.some(f=>f==="googlepay")||n("googlepay")?null:mt(X,{icon:mt(Vt,null),title:r.t("googlePay.title"),isActive:o==="googlepay",isSole:i,onChange:()=>a("googlepay")},mt(Le,{configuration:e,paymentMethods:t,isInstantPayment:!1,onUnavailable:()=>d(!0)}))}var jt=so;import{h as dt}from"preact";import{useState as co}from"preact/hooks";_("");import{h as Ue}from"preact";var io=()=>Ue("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"26",fill:"none",viewBox:"0 0 40 26"},Ue("path",{fill:"#000",d:"M36.42 0H3.58a69.25 69.25 0 0 0-.75 0c-.25.01-.5.03-.76.07a2.51 2.51 0 0 0-1.32.7A2.43 2.43 0 0 0 .07 2.1 5.14 5.14 0 0 0 0 3.22v19.91c.01.25.03.51.07.76a2.6 2.6 0 0 0 .68 1.35 2.39 2.39 0 0 0 1.32.69 4.98 4.98 0 0 0 1.1.07h34a5 5 0 0 0 .76-.07 2.5 2.5 0 0 0 1.32-.7 2.44 2.44 0 0 0 .68-1.34 5.13 5.13 0 0 0 .07-1.11V2.87a6.5 6.5 0 0 0-.07-.76 2.58 2.58 0 0 0-.68-1.35 2.4 2.4 0 0 0-1.32-.69 4.96 4.96 0 0 0-1.1-.07h-.41Z"}),Ue("path",{fill:"#fff",d:"M36.42.87h.73c.2 0 .42.02.62.06a1.67 1.67 0 0 1 .88.44 1.58 1.58 0 0 1 .44.89 4.38 4.38 0 0 1 .06.97v19.55a14.67 14.67 0 0 1-.06.96 1.7 1.7 0 0 1-.44.89 1.54 1.54 0 0 1-.87.44 4.27 4.27 0 0 1-.96.06H2.85a3.7 3.7 0 0 1-.63-.06 1.66 1.66 0 0 1-.87-.45 1.56 1.56 0 0 1-.44-.88 4.35 4.35 0 0 1-.06-.97V2.9c.01-.2.02-.42.06-.63.03-.18.08-.34.16-.49A1.56 1.56 0 0 1 2.22.93a4.2 4.2 0 0 1 .96-.06h33.24"}),Ue("path",{fill:"#000",d:"M10.92 8.61c.34-.43.57-1 .51-1.59a2.21 2.21 0 0 0-1.99 2.3c.56.04 1.12-.3 1.48-.7Zm.51.81c-.82-.05-1.52.46-1.9.46-.4 0-1-.43-1.64-.42-.84 0-1.62.48-2.05 1.24-.88 1.52-.23 3.76.62 5 .42.6.92 1.27 1.58 1.25.62-.02.86-.4 1.62-.4.75 0 .97.4 1.63.39.69-.01 1.11-.61 1.53-1.22.47-.7.67-1.37.68-1.4-.01-.02-1.32-.52-1.33-2.02-.01-1.26 1.03-1.85 1.07-1.9a2.34 2.34 0 0 0-1.81-.98Zm7.11-1.7a2.87 2.87 0 0 1 3.02 3c0 1.8-1.27 3.03-3.06 3.03h-1.97v3.12h-1.42V7.72h3.43Zm-2 4.83h1.62c1.24 0 1.94-.66 1.94-1.82 0-1.15-.7-1.81-1.93-1.81h-1.64v3.63Zm5.39 2.43c0-1.17.9-1.89 2.48-1.98l1.83-.1v-.52c0-.74-.5-1.18-1.34-1.18-.8 0-1.3.38-1.41.97h-1.3c.08-1.2 1.1-2.09 2.76-2.09 1.62 0 2.65.86 2.65 2.2v4.6h-1.31v-1.1h-.04a2.38 2.38 0 0 1-2.1 1.2c-1.3 0-2.22-.8-2.22-2Zm4.3-.6v-.53l-1.64.1c-.82.06-1.28.42-1.28.99 0 .58.48.96 1.22.96.96 0 1.7-.66 1.7-1.52Zm2.61 4.95v-1.11c.1.03.33.03.44.03.64 0 .98-.27 1.19-.96l.12-.4-2.41-6.69h1.48l1.7 5.43h.02l1.69-5.43h1.44l-2.5 7.02c-.57 1.62-1.23 2.14-2.61 2.14a5.3 5.3 0 0 1-.56-.03Z"})),Kt=io;_(`.straumur__apple-pay-button__loading{display:flex;justify-content:center}
|
|
8
8
|
`);import{h as lo}from"preact";function mo(e){return lo(He,{method:"applepay",...e})}var Ze=mo;function uo({configuration:e,paymentMethods:t}){let{i18n:r}=H(),{activePaymentMethod:o,setActivePaymentMethod:a,isObscuredByThreeDS:n,isSolePaymentMethod:i,hasApplePay:l}=x(),[m,d]=co(!1);return!l||m||e.instantPayments&&e.instantPayments.some(f=>f==="applepay")||n("applepay")?null:dt(X,{icon:dt(Kt,null),title:r.t("applePay.title"),isActive:o==="applepay",isSole:i,onChange:()=>a("applepay")},dt(Ze,{configuration:e,paymentMethods:t,isInstantPayment:!1,onUnavailable:()=>d(!0)}))}var Jt=uo;import{Fragment as _o,h as qt}from"preact";import{Fragment as ho,h as v}from"preact";import{useEffect as ct,useRef as ut,useState as Oe}from"preact/hooks";_(`.straumur__stored-card-component__remove-stored-card-button{margin-left:auto}.straumur__stored-card-component__remove-stored-card-button--text{color:var(--straumur__color-danger-text);text-decoration:none;background:none;border:none;cursor:pointer;transition:all .2s ease}.straumur__stored-card-component__remove-stored-card-button--text:disabled{cursor:not-allowed;color:var(--straumur__color-secondary)}.straumur__stored-card-component__confirm-remove-stored-card{background-color:var(--straumur__color-warning-bg);border-radius:var(--straumur__border-radius-s);max-height:0;overflow:hidden;transition:all .3s ease;opacity:0}.straumur__stored-card-component__confirm-remove-stored-card--expanded{padding:var(--straumur__space-xxlg);max-height:600px;opacity:1}.straumur__stored-card-component__confirm-remove-stored-card--header{display:flex;align-items:center;gap:var(--straumur__space-lg);color:var(--straumur__color-text);padding-bottom:var(--straumur__space-xxlg)}.straumur__stored-card-component__confirm-remove-stored-card--actions{display:flex;gap:var(--straumur__space-lg);justify-content:end}.straumur__stored-card-component__confirm-remove-stored-card--actions--button{color:var(--straumur__color-warning-text);background:none;border:none;cursor:pointer;text-decoration:none;font-weight:700}.straumur__stored-card-component__loading-text{display:flex;justify-content:center}.straumur__stored-card-component__form{display:flex;padding-top:var(--straumur__space-xxlg);flex-direction:column;gap:var(--straumur__space-5xlg)}.straumur__stored-card-component__form--wrapper{display:flex;flex-direction:column;justify-items:start;position:relative;width:100%}.straumur__stored-card-component__form--wrapper--error{color:var(--straumur__color-red-beta);font-size:12px}.straumur__stored-card-component__form--wrapper--label{transform:translate(10px) translateY(-50%);z-index:1;background:linear-gradient(to top,var(--straumur__color-secondary-gamma) 53%,var(--straumur__color-transparent) 50%);position:absolute;font-weight:500;font-size:14px;padding:0 var(--straumur__space-xxs)}.straumur__stored-card-component__form--wrapper--label--readonly{background:linear-gradient(to top,var(--straumur__color-gray-epsilon) 53%,var(--straumur__color-transparent) 50%)}.straumur__stored-card-component__form--wrapper--label--error{color:var(--straumur__color-red-beta);background:linear-gradient(to top,var(--straumur__color-red-gamma) 53%,var(--straumur__color-transparent) 50%);font-size:13px;font-weight:500}.straumur__stored-card-component__form--wrapper--label--info{position:absolute;top:33%;right:var(--straumur__space-md)}.straumur__stored-card-component__form--wrapper--input{background:var(--straumur__color-secondary-gamma);color:var(--straumur__color-text);display:flex;align-items:center;border:1px solid var(--straumur__color-transparent);border-radius:var(--straumur__border-radius-s);font-size:16px;height:48px;outline:none;padding-left:var(--straumur__space-lg);transition:border .2s ease-out,box-shadow .2s ease-out;position:relative}.straumur__stored-card-component__form--wrapper--input--readonly{background-color:var(--straumur__color-gray-epsilon)}.straumur__stored-card-component__form--wrapper--input:hover{border:1px solid var(--straumur__color-cosmos-blue-delta)}.straumur__stored-card-component__form--wrapper--input--readonly:hover{border:1px solid var(--straumur__color-transparent)}.straumur__stored-card-component__form--wrapper--input--error{background:var(--straumur__color-red-gamma);border:1px solid var(--straumur__color-red-beta)}.straumur__stored-card-component__form--wrapper--input--error:hover{border:1px solid var(--straumur__color-red-beta)}.straumur__stored-card-component__form--field-wrapper{display:flex;width:100%;gap:var(--straumur__space-lg)}.straumur__stored-card-component__submit-button{background:var(--straumur__color-primary);border:none;border-radius:var(--straumur__border-radius-s);color:var(--straumur__color-white);cursor:pointer;font-size:16px;height:40px;outline:none;padding:0 var(--straumur__space-xxlg);transition:background .2s ease-out;width:100%}.straumur__stored-card-component__submit-button:hover{background:var(--straumur__color-primary);border:1px solid var(--straumur__color-border)}.straumur__stored-card-component__submit-button:disabled{background:var(--straumur__color-secondary);border:1px solid var(--straumur__color-border);cursor:not-allowed}
|
|
9
9
|
`);import{AdyenCheckout as fo,CustomCard as yo}from"@adyen/adyen-web";import{h as se}from"preact";var po=()=>se("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},se("g",{"clip-path":"url(#clip0_10650_34968)"},se("path",{d:"M12.0011 15C12.6245 15 13.1261 14.4984 13.1261 13.875V7.875C13.1261 7.25391 12.6222 6.75 12.0433 6.75C11.4644 6.75 10.8761 7.25625 10.8761 7.875V13.875C10.8761 14.4984 11.3823 15 12.0011 15ZM12.0011 16.5516C11.1873 16.5516 10.5273 17.2116 10.5273 18.0253C10.5292 18.8391 11.1855 19.5 12.0011 19.5C12.8167 19.5 13.4748 18.84 13.4748 18.0262C13.473 17.2125 12.8167 16.5516 12.0011 16.5516Z",fill:"#DFAE00"}),se("path",{opacity:"0.4",d:"M23.7312 19.5469L13.7328 2.48438C12.9673 1.17188 11.0356 1.17188 10.2649 2.48438L0.271188 19.5469C-0.49803 20.8547 0.460048 22.5 2.00181 22.5H21.9987C23.5343 22.5 24.4953 20.8594 23.7312 19.5469ZM10.8734 7.875C10.8734 7.25391 11.3773 6.75 11.9984 6.75C12.6195 6.75 13.1234 7.25625 13.1234 7.875V13.875C13.1234 14.4961 12.6195 15 12.0406 15C11.4617 15 10.8734 14.4984 10.8734 13.875V7.875ZM11.9984 19.5C11.1846 19.5 10.5246 18.84 10.5246 18.0262C10.5246 17.2125 11.1842 16.5525 11.9984 16.5525C12.8126 16.5525 13.4721 17.2125 13.4721 18.0262C13.4703 18.8391 12.814 19.5 11.9984 19.5Z",fill:"#DFAE00"})),se("defs",null,se("clipPath",{id:"clip0_10650_34968"},se("rect",{width:"24",height:"24",fill:"white"})))),$t=po;function vo({configuration:e,paymentMethods:t,storedPaymentMethod:r,onStoredCardRemoved:o}){let a=ut(null),n=ut(),i=ut(),{i18n:l}=H(),[m,d]=Oe(!0),[f,h]=Oe("required"),[P,w]=Oe(!1),[z,g]=Oe({encryptedSecurityCode:{visible:!1}}),{activePaymentMethod:I,setActivePaymentMethod:R,activeStoredPaymentMethodId:k,setActiveStoredPaymentMethodId:D,isStoredCardInitialized:u,updateStoredCardInitialization:U,handleSuccess:F,handleError:E,setThreeDSecureActive:W,threeDSecureActive:B,isSolePaymentMethod:L,registerSubmitHandler:j,unregisterSubmitHandler:Z}=x(),N=L?I==="storedcard":I==="storedcard"&&k===r.id,ie=ue(e.theme);async function b(){await Te(e.paymentFlow,()=>i.current)}ct(()=>{if(!(N&&u[r.id])){e.onCardValidityChanged?.(!1,!1);return}return j(b),()=>{Z(b),e.onCardValidityChanged?.(!1,!1)}},[N,u[r.id],j,Z]);let{handleOnSubmit:K,handleOnSubmitAdditionalData:ee,handlePaymentCompleted:fe,handlePaymentFailed:ye}=$({configuration:e,handleSuccess:F,handleError:E,setThreeDSecureActive:W,enrichSubmitData:C=>({...C,paymentMethod:{...C.paymentMethod,storedPaymentMethodId:r.id}})});function Ke(C,S){E({key:"error.unknownError"})}let Se=async()=>{n.current=await fo({clientKey:t.clientKey,environment:e.environment,locale:e.locale,countryCode:e.countryCode,amount:{value:t.minorUnitsAmount,currency:t.currency},paymentMethodsResponse:t.paymentMethods,onError:Ke,onAdditionalDetails:ee,onPaymentCompleted:fe,onPaymentFailed:ye}),i.current=new yo(n.current,{brands:[r.brand],styles:Fe(ie),onSubmit:K,onConfigSuccess(){U(r.id,!0)},onBrand:C=>{h(C.cvcPolicy)},onValidationError:C=>{let S={encryptedSecurityCode:{visible:!1,message:void 0}};C.filter(ve=>ve.error).forEach(ve=>{S[ve.fieldType].visible=!0,S[ve.fieldType].message=ve.errorI18n}),g(S)},onAllValid:C=>{d(!C.allValid),e.onCardValidityChanged?.(C.allValid,!0)},placeholders:e.placeholders,challengeWindowSize:"05"}),a.current&&i.current.mount(a.current)};if(ct(()=>{N&&!u[r.id]&&Se()},[e,N]),ce(e,()=>!!(i.current&&u[k]),()=>{Se(),g({encryptedSecurityCode:{visible:!1,message:void 0}})}),ct(()=>{w(!1)},[I,k]),ze(a,B&&N),B&&!N)return null;function Je(){R("storedcard"),D(r.id)}function $e(){w(!0)}function Xe(){w(!1)}async function xe(){let{disableToken:C}=e.paymentFlow;if(C)try{await C(r.id),o(r.id)}catch(S){E(be(S,"error.failedToSubmitRemoveStoredPaymentCard"))}}let qe=e.paymentFlow.disableToken!==void 0&&N&&u[r.id]?v("div",{className:"straumur__stored-card-component__remove-stored-card-button"},v("button",{onClick:$e,className:"straumur__stored-card-component__remove-stored-card-button--text",disabled:P},l.t("stored-cards.removeStoredCard"))):null,p=v("div",{className:`straumur__stored-card-component__confirm-remove-stored-card ${P?"straumur__stored-card-component__confirm-remove-stored-card--expanded":""}`},v("div",{className:"straumur__stored-card-component__confirm-remove-stored-card--header"},v($t,null),v("span",{className:"straumur__stored-card-component__confirm-remove-stored-card--header--title"},l.t("stored-cards.removeStoredCardQuestion"))),v("div",{className:"straumur__stored-card-component__confirm-remove-stored-card--actions"},v("button",{className:"straumur__stored-card-component__confirm-remove-stored-card--actions--button",onClick:xe},l.t("stored-cards.removeStoredCardQuestionYesRemove")),v("button",{className:"straumur__stored-card-component__confirm-remove-stored-card--actions--button",onClick:Xe},l.t("stored-cards.removeStoredCardQuestionCancel"))));return v(X,{icon:v(Ae,{brands:[{brand:r.brand,brandFullName:r.name}]}),title:`\u2022\u2022\u2022\u2022 ${r.lastFour}`,isActive:N,isSole:L,onChange:Je,headerRight:qe,confirmSection:p},v("div",{ref:a,tabIndex:-1,style:{height:B?"600px":"auto",minWidth:B?"350px":"auto"}},!u[r.id]&&v("div",{className:"straumur__stored-card-component__loading-text"},v(J,null)),v("div",{className:"straumur__stored-card-component__form",style:{opacity:u[r.id]&&!B?1:0,position:u[r.id]&&!B?"relative":"absolute",transition:"opacity 0.3s ease-in-out"}},v("div",{className:"straumur__stored-card-component__form--field-wrapper"},v("div",{className:"straumur__stored-card-component__form--wrapper"},v("label",{className:"straumur__stored-card-component__form--wrapper--label straumur__stored-card-component__form--wrapper--label--readonly"},l.t("stored-cards.expiryDate")),v("span",{className:"straumur__stored-card-component__form--wrapper--input straumur__stored-card-component__form--wrapper--input--readonly"},r.expiryMonth,"/",r.expiryYear)),v("div",{className:"straumur__stored-card-component__form--wrapper"},(f==="optional"||f==="required")&&v(ho,null,v("label",{className:`straumur__stored-card-component__form--wrapper--label ${z.encryptedSecurityCode.visible?"straumur__stored-card-component__form--wrapper--label--error":""}`},f==="optional"?l.t("stored-cards.securityCode3DigitsOptional"):l.t("stored-cards.securityCode3Digits")),v("span",{className:`straumur__stored-card-component__form--wrapper--input ${z.encryptedSecurityCode.visible?"straumur__stored-card-component__form--wrapper--input--error":""}`,"data-cse":"encryptedSecurityCode",role:"group","aria-label":l.t("stored-cards.securityCode3Digits")},v("div",{className:"straumur__stored-card-component__form--wrapper--label--info"},v(me,{content:l.t("stored-cards.securityCode3DigitsInfo")},v(Re,null))))),z.encryptedSecurityCode.visible&&v("span",{className:"straumur__stored-card-component__form--wrapper--error"},z.encryptedSecurityCode.message))),!e.hideSubmitButton&&v("button",{className:"straumur__stored-card-component__submit-button",disabled:m,onClick:b},t.minorUnitsAmount===0?l.t("stored-cards.saveCardDetails"):t.formattedAmount))))}var Xt=vo;import{useState as go}from"preact/hooks";function bo({configuration:e,paymentMethods:t}){let[r,o]=go(t.paymentMethods.storedPaymentMethods??[]),{isObscuredByThreeDS:a,hasStoredPaymentMethods:n}=x();if(!n||a("storedcard"))return null;function i(l){o(m=>m.filter(d=>d.id!==l))}return qt(_o,null,r?.map(l=>qt(Xt,{key:l.id,configuration:e,storedPaymentMethod:l,paymentMethods:t,onStoredCardRemoved:i})))}var Yt=bo;import{h as Qt}from"preact";_(`.straumur__payment-method-group{display:flex;flex-direction:column;gap:var(--straumur__space-xxlg);width:100%}
|
|
10
10
|
`);function Co({children:e,initialValue:t,isSolePaymentMethod:r,hasCard:o,hasGooglePay:a,hasApplePay:n,hasStoredPaymentMethods:i,onSubmitApiReady:l}){return Qt(St,{initialValue:t,isSolePaymentMethod:r,hasCard:o,hasGooglePay:a,hasApplePay:n,hasStoredPaymentMethods:i,onSubmitApiReady:l},Qt("div",{className:"straumur__payment-method-group"},e))}var er=Co;import{Fragment as tr,h as V}from"preact";_(`.straumur__result-component{display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;min-height:300px;background-color:var(--straumur__color-white);border-radius:var(--straumur__border-radius-xxlg)}
|