@test-glide/glide-payment 0.0.3 → 0.0.5

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.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function u(n,e={}){const t=document.createElement(n),{className:l,id:a,innerHTML:h,textContent:i,attributes:c,styles:p,dataset:s,children:r,events:m}=e;if(l){const d=Array.isArray(l)?l:l.split(" ");t.classList.add(...d.filter(Boolean))}if(a&&(t.id=a),h&&(t.innerHTML=h),i&&(t.textContent=i),c)for(const[d,o]of Object.entries(c))o&&t.setAttribute(d,o);if(p)for(const[d,o]of Object.entries(p))t.style[d]=o;if(s)for(const[d,o]of Object.entries(s))t.dataset[d]=o;if(r&&t.append(...r.filter(Boolean)),m)for(const[d,o]of Object.entries(m))t.addEventListener(d,o);return t}function x(n,e){const t="id"in n?[document.getElementById(n.id)].filter(Boolean):"className"in n?Array.from(document.getElementsByClassName(n.className)):[n.element];if(!t.length){console.warn("updateElements: no elements found for",n);return}for(const l of t){const{styles:a,attributes:h,dataset:i,innerHTML:c,textContent:p,className:s}=e;if(a)for(const[r,m]of Object.entries(a))l.style[r]=m;if(h)for(const[r,m]of Object.entries(h))l.setAttribute(r,m);if(i)for(const[r,m]of Object.entries(i))l.dataset[r]=m;if(c!==void 0&&(l.innerHTML=c),p!==void 0&&(l.textContent=p),s?.add){const r=Array.isArray(s.add)?s.add:[s.add];l.classList.add(...r)}if(s?.remove){const r=Array.isArray(s.remove)?s.remove:[s.remove];l.classList.remove(...r)}s?.toggle&&(Array.isArray(s.toggle)?s.toggle:[s.toggle]).forEach(m=>l.classList.toggle(m))}}const Q=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function u(t,n={}){const e=document.createElement(t),{className:a,id:l,innerHTML:m,textContent:c,attributes:o,styles:h,dataset:s,children:r,events:d}=n;if(a){const p=Array.isArray(a)?a:a.split(" ");e.classList.add(...p.filter(Boolean))}if(l&&(e.id=l),m&&(e.innerHTML=m),c&&(e.textContent=c),o)for(const[p,i]of Object.entries(o))i&&e.setAttribute(p,i);if(h)for(const[p,i]of Object.entries(h))e.style[p]=i;if(s)for(const[p,i]of Object.entries(s))e.dataset[p]=i;if(r&&e.append(...r.filter(Boolean)),d)for(const[p,i]of Object.entries(d))e.addEventListener(p,i);return e}function M(t,n){const e="id"in t?[document.getElementById(t.id)].filter(Boolean):"className"in t?Array.from(document.getElementsByClassName(t.className)):[t.element];if(!e.length){console.warn("updateElements: no elements found for",t);return}for(const a of e){const{styles:l,attributes:m,dataset:c,innerHTML:o,textContent:h,className:s}=n;if(l)for(const[r,d]of Object.entries(l))a.style[r]=d;if(m)for(const[r,d]of Object.entries(m))a.setAttribute(r,d);if(c)for(const[r,d]of Object.entries(c))a.dataset[r]=d;if(o!==void 0&&(a.innerHTML=o),h!==void 0&&(a.textContent=h),s?.add){const r=Array.isArray(s.add)?s.add:[s.add];a.classList.add(...r)}if(s?.remove){const r=Array.isArray(s.remove)?s.remove:[s.remove];a.classList.remove(...r)}s?.toggle&&(Array.isArray(s.toggle)?s.toggle:[s.toggle]).forEach(d=>a.classList.toggle(d))}}const J=`
2
2
  <svg
3
3
  xmlns="http://www.w3.org/2000/svg"
4
4
  width="16"
@@ -13,7 +13,7 @@
13
13
  clip-rule="evenodd"
14
14
  ></path>
15
15
  </svg>
16
- `,X=`
16
+ `,Q=`
17
17
  <svg
18
18
  xmlns="http://www.w3.org/2000/svg"
19
19
  width="16"
@@ -28,7 +28,7 @@
28
28
  >
29
29
  <path d="M12 2v4M16.2 7.8l2.9-2.9M18 12h4M16.2 16.2l2.9 2.9M12 18v4M4.9 19.1l2.9-2.9M2 12h4M4.9 4.9l2.9 2.9"></path>
30
30
  </svg>
31
- `,ee=`<svg
31
+ `,X=`<svg
32
32
  xmlns="http://www.w3.org/2000/svg"
33
33
  width="20"
34
34
  height="20"
@@ -45,28 +45,28 @@
45
45
  ></path>
46
46
  </svg>`,k=`
47
47
  <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 256 256"><path d="M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z"></path></svg>
48
- `,te=({children:n,onClick:e,disabled:t=!1,size:l="medium",type:a="button",className:h="",variant:i="primary"})=>{const c=u("span",{className:"button-spinner",innerHTML:X,dataset:{show:"false"}}),p=u("span",{className:"button-label",children:[null],textContent:n}),s=u("button",{className:`custom-button ${i} ${l} ${h}`,attributes:{type:a,...t?{disabled:"true"}:{}},events:{click:e},children:[c,p]}),r=(d=!1)=>{x({element:c},{dataset:{show:String(d)}}),m(d)},m=(d=!1)=>{d?s.setAttribute("disabled","true"):s.removeAttribute("disabled")};return{element:s,setLoading:r,setDisabled:m}},ne=({content:n,position:e="top",delay:t=200,maxWidth:l=250,className:a="",id:h=""})=>{var i=u("div",{className:`tooltip ${e} ${a}`,styles:{maxWidth:`${l}px`},attributes:{role:"tooltip"},dataset:{show:"false"},innerHTML:`
49
- <div class="tooltip-content">${n}</div>
48
+ `,ee=({children:t,onClick:n,disabled:e=!1,size:a="medium",type:l="button",className:m="",variant:c="primary"})=>{const o=u("span",{className:"button-spinner",innerHTML:Q,dataset:{show:"false"}}),h=u("span",{className:"button-label",children:[null],textContent:t}),s=u("button",{className:`custom-button ${c} ${a} ${m}`,attributes:{type:l,...e?{disabled:"true"}:{}},events:{click:n},children:[o,h]}),r=(p=!1)=>{M({element:o},{dataset:{show:String(p)}}),d(p)},d=(p=!1)=>{p?s.setAttribute("disabled","true"):s.removeAttribute("disabled")};return{element:s,setLoading:r,setDisabled:d}},te=({content:t,position:n="top",delay:e=200,maxWidth:a=250,className:l="",id:m=""})=>{var c=u("div",{className:`tooltip ${n} ${l}`,styles:{maxWidth:`${a}px`},attributes:{role:"tooltip"},dataset:{show:"false"},innerHTML:`
49
+ <div class="tooltip-content">${t}</div>
50
50
  <div class="tooltip-arrow"></div>
51
- `});let c=null;var r=u("span",{className:"tooltip-trigger",innerHTML:k,events:{mouseenter:()=>{t>0?c=window.setTimeout(()=>{i.dataset.show="true",m()},t):(i.dataset.show="true",m())},mouseleave:()=>{c&&clearTimeout(c),i.dataset.show="false"}}});function m(){if(!r||!i)return;const o=r.getBoundingClientRect(),v=i.getBoundingClientRect(),y=8;let w,g;switch(e){case"top":w=o.top-v.height-y,g=o.left+o.width/2-v.width/2;break;case"bottom":w=o.bottom+y,g=o.left+o.width/2-v.width/2;break;case"left":w=o.top+o.height/2-v.height/2,g=o.left-v.width-y;break;case"right":w=o.top+o.height/2-v.height/2,g=o.right+y;break;default:w=o.top-v.height-y,g=o.left+o.width/2-v.width/2}const N=window.innerWidth,C=window.innerHeight;g<0&&(g=y),g+v.width>N&&(g=N-v.width-y),w<0&&(w=y),w+v.height>C&&(w=C-v.height-y),i.style.top=`${w}px`,i.style.left=`${g}px`}return u("div",{className:"tooltip-wrapper",id:`tooltip-${h}`,children:[r,i]})},se=n=>{const e={},t=Object.values(n).every(a=>!a||a.trim()===""),l=n.cardNumber?.replace(/\s/g,"");if(l?/^\d{13,19}$/.test(l)||(e.cardNumber="Card number must be 13-19 digits"):e.cardNumber="Card number is required",!n.expiryDate)e.expiryDate="Expiry date is required";else{const a=n.expiryDate.replace(/\D/g,"");if(a.length<4)e.expiryDate="Enter complete expiry date (MM/YY)";else{const h=parseInt(a.substring(0,2),10),i=parseInt(a.substring(2,4),10);if(isNaN(h)||h<1||h>12)e.expiryDate="Invalid month (must be 01-12)";else if(isNaN(i)||i<0||i>99)e.expiryDate="Invalid year";else{const c=new Date,p=c.getFullYear(),s=c.getMonth()+1,r=Math.floor(p/100)*100,m=r+i,d=r+100+i;let o;m>=p&&m<=p+20?o=m:(d>=p&&d<=p+20,o=d),o<p||o===p&&h<s?e.expiryDate="Card has expired":o>p+20&&(e.expiryDate="Expiry year is too far in the future")}}}return n.cvv?.trim()?/^\d{3,4}$/.test(n.cvv.trim())||(e.cvv="CVV must be 3 or 4 digits"):e.cvv="CVV is required",n.zipCode?.trim()?/^[A-Z0-9\s-]{3,10}$/i.test(n.zipCode.trim())||(e.zipCode="Invalid ZIP code format"):e.zipCode="Postal code is required",{isValid:Object.keys(e).length===0,errors:e,isEmpty:t}};function re(n){const e=parseInt(n,10);if(isNaN(e)||e<0||e>99)return null;const t=new Date().getFullYear(),l=Math.floor(t/100)*100;let a=l+e;return a>=t&&a<=t+20||(a=l+100+e,a>=t&&a<=t+20)?a:l+100+e}function V(n=""){return n.trim().replaceAll(/\s/g,"").replaceAll("-","")}const oe={card:n=>n.replace(/\s+/g,"").replace(/[^0-9]/gi,"").substring(0,16).match(/.{1,4}/g)?.join(" ")??"",phone:n=>{const e=n.replace(/\D/g,"").substring(0,10),t=e.match(/^(\d{3})(\d{3})(\d{4})$/);return t?`(${t[1]}) ${t[2]}-${t[3]}`:e},expiry:n=>{const e=n.replace(/\//g,"");return e.substring(0,2)+(n.length>2?"/":"")+e.substring(2,4)},cvv:n=>n.replace(/\D/g,"").substring(0,4),zip:n=>{const e=n.replace(/\D/g,"").substring(0,9);return e.length>5?`${e.substring(0,5)}-${e.substring(5)}`:e}};function ae(n,e){return e==="none"?n:oe[e](n)}const $=({label:n,maskType:e,id:t,name:l,type:a="text",placeholder:h="Enter value",tooltip:i="",onChange:c})=>{const p=["card","expiry","phone","cvv","zip"].includes(e)?"numeric":"",s=u("label",{className:"input-label",innerHTML:n,attributes:{for:t}});let r=!1;const d=u("input",{id:t||"input-id",className:"styled-input",attributes:{placeholder:h,type:a,inputMode:p,name:l},events:{input:o,blur:v,keydown:b=>{b.key==="Enter"&&(r=!0)}}});function o(b){const D=e!=="none"?ae(b?.target?.value,e):b?.target?.value;d.value=D,c?.(D)}function v(){r=!0,c?.(d?.value||"")}const y=u("div",{className:"input-loader",innerHTML:'<div class="loader"></div>',dataset:{show:"false"}}),w=i?u("div",{className:"input-right-element",children:[ne({content:i,id:t})]}):null,g=u("div",{className:"input-wrapper",children:[d,y,w]}),N=u("div",{className:"error-message",dataset:{show:"false"},innerHTML:`
51
+ `});let o=null;var r=u("span",{className:"tooltip-trigger",innerHTML:k,events:{mouseenter:()=>{e>0?o=window.setTimeout(()=>{c.dataset.show="true",d()},e):(c.dataset.show="true",d())},mouseleave:()=>{o&&clearTimeout(o),c.dataset.show="false"}}});function d(){if(!r||!c)return;const i=r.getBoundingClientRect(),g=c.getBoundingClientRect(),b=8;let f,y;switch(n){case"top":f=i.top-g.height-b,y=i.left+i.width/2-g.width/2;break;case"bottom":f=i.bottom+b,y=i.left+i.width/2-g.width/2;break;case"left":f=i.top+i.height/2-g.height/2,y=i.left-g.width-b;break;case"right":f=i.top+i.height/2-g.height/2,y=i.right+b;break;default:f=i.top-g.height-b,y=i.left+i.width/2-g.width/2}const N=window.innerWidth,D=window.innerHeight;y<0&&(y=b),y+g.width>N&&(y=N-g.width-b),f<0&&(f=b),f+g.height>D&&(f=D-g.height-b),c.style.top=`${f}px`,c.style.left=`${y}px`}return u("div",{className:"tooltip-wrapper",id:`tooltip-${m}`,children:[r,c]})},ne=(t,n=!1)=>{const e={},a=Object.values(t).every(o=>!o||o.trim()===""),l=t.cardNumber?.replace(/\s/g,"");if(l?/^\d{13,19}$/.test(l)||(e.cardNumber="Card number must be 13-19 digits"):e.cardNumber="Card number is required",!t.expiryDate&&!n)e.expiryDate="Expiry date is required";else if(t.expiryDate){const o=t.expiryDate.replace(/\D/g,"");if(o.length<4)e.expiryDate="Enter complete expiry date (MM/YY)";else{const h=parseInt(o.substring(0,2),10),s=parseInt(o.substring(2,4),10);if(isNaN(h)||h<1||h>12)e.expiryDate="Invalid month (must be 01-12)";else if(isNaN(s)||s<0||s>99)e.expiryDate="Invalid year";else{const r=new Date,d=r.getFullYear(),p=r.getMonth()+1,i=Math.floor(d/100)*100,g=i+s,b=i+100+s;let f;g>=d&&g<=d+20?f=g:(b>=d&&b<=d+20,f=b),f<d||f===d&&h<p?e.expiryDate="Card has expired":f>d+20&&(e.expiryDate="Expiry year is too far in the future")}}}const m=t.cvv.trim();m&&!/^\d{3,4}$/.test(m)&&(e.cvv="CVV must be 3 or 4 digits");const c=t.zipCode.trim();return c&&!/^[A-Z0-9\s-]{3,10}$/i.test(c)&&(e.zipCode="Invalid ZIP code format"),{isValid:Object.keys(e).length===0,errors:e,isEmpty:a}};function se(t){const n=parseInt(t,10);if(isNaN(n)||n<0||n>99)return null;const e=new Date().getFullYear(),a=Math.floor(e/100)*100;let l=a+n;return l>=e&&l<=e+20||(l=a+100+n,l>=e&&l<=e+20)?l:a+100+n}function I(t=""){return t.trim().replaceAll(/\s/g,"").replaceAll("-","")}const re={card:t=>t.replace(/\s+/g,"").replace(/[^0-9]/gi,"").substring(0,16).match(/.{1,4}/g)?.join(" ")??"",phone:t=>{const n=t.replace(/\D/g,"").substring(0,10),e=n.match(/^(\d{3})(\d{3})(\d{4})$/);return e?`(${e[1]}) ${e[2]}-${e[3]}`:n},expiry:t=>{const n=t.replace(/[^0-9/]/g,"");return n.length<=2?n:n.includes("/")?n.substring(0,5):n.substring(0,2)+"/"+n.substring(2,4)},cvv:t=>t.replace(/\D/g,"").substring(0,4),zip:t=>{const n=t.replace(/\D/g,"").substring(0,9);return n.length>5?`${n.substring(0,5)}-${n.substring(5)}`:n}};function ae(t,n){return n==="none"?t:re[n](t)}const $=({label:t,maskType:n,id:e,name:a,type:l="text",placeholder:m="Enter value",tooltip:c="",onChange:o})=>{const h=["card","expiry","phone","cvv","zip"].includes(n)?"numeric":"",s=u("label",{className:"input-label",innerHTML:t,attributes:{for:e}});let r=!1;const p=u("input",{id:e||"input-id",className:"styled-input",attributes:{placeholder:m,type:l,inputMode:h,name:a},events:{input:i,blur:g,keydown:w=>{w.key==="Enter"&&(r=!0)}}});function i(w){const T=n!=="none"?ae(w?.target?.value,n):w?.target?.value;p.value=T,o?.(T)}function g(){r=!0,o?.(p?.value||"")}const b=u("div",{className:"input-loader",innerHTML:'<div class="loader"></div>',dataset:{show:"false"}}),f=c?u("div",{className:"input-right-element",children:[te({content:c,id:e})]}):null,y=u("div",{className:"input-wrapper",children:[p,b,f]}),N=u("div",{className:"error-message",dataset:{show:"false"},innerHTML:`
52
52
  ${k}
53
53
  <span></span>
54
- `});return{element:u("div",{className:"custom-input-group",children:[s,g,N]}),setLoading:b=>{x({element:g},{dataset:{loading:b?"true":"false"}}),x({element:d},{attributes:{disabled:b?"true":"false"}}),x({element:y},{dataset:{show:b?"true":"false"}})},setError:(b="")=>{x({element:g},{className:b&&r?{add:"input-error"}:{remove:"input-error"}}),x({element:N},{dataset:{show:b&&r?"true":"false"},innerHTML:`
54
+ `});return{element:u("div",{className:"custom-input-group",children:[s,y,N]}),setLoading:w=>{M({element:y},{dataset:{loading:w?"true":"false"}}),M({element:p},{attributes:{disabled:w?"true":"false"}}),M({element:b},{dataset:{show:w?"true":"false"}})},setError:(w="")=>{M({element:y},{className:w&&r?{add:"input-error"}:{remove:"input-error"}}),M({element:N},{dataset:{show:w&&r?"true":"false"},innerHTML:`
55
55
  ${k}
56
- <span>${b||""}</span>
57
- `})}}},ie=async(n,e={})=>{const{method:t="GET",headers:l={},body:a=null,...h}=e;try{const i={method:t,headers:{Accept:"*/*","Content-Type":"application/json",...l},...h};a&&["POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())&&(i.body=typeof a=="string"?a:JSON.stringify(a));const c=await fetch(n,i),p=c.headers.get("content-type");let s;if(p?.includes("application/json")?s=await c.json():s=await c.text(),!c.ok){const r=s;throw new Error(r?.message||`HTTP error! status: ${c.status}`)}return{data:s,error:null}}catch(i){return{data:null,error:i instanceof Error?i.message:"An error occurred"}}},le=({title:n="",children:e,onClose:t,showBackBtn:l=!1,showCloseBtn:a=!0})=>{const h=u("button",{className:"back-btn",innerHTML:ee,dataset:{show:String(l)},events:{click:()=>m()}}),i=u("h3",{textContent:n}),c=u("button",{className:"close-btn",innerHTML:"&times;",dataset:{show:String(a)},attributes:{"aria-label":"Close modal"},events:{click:()=>m()}}),p=u("div",{className:"modal-header",children:[h,i,c]}),s=u("div",{className:"modal-content",children:[e]}),r=u("dialog",{className:"custom-modal",children:[p,s],events:{cancel:o=>{o.preventDefault(),m()}}}),m=()=>{r.close(),t?.()};return{element:r,setModalVisibility:o=>{o?r.showModal():r.close()}}},ce=({token:n,endpoint:e,beneficiaryCard:t=!1,isModal:l=!1,onCallback:a=()=>null})=>{const h=t?"Enter Recipient Debit Card Details":"Enter Your Debit Card Details",i=t?"Enter the debit card details of the recipient you're sending funds to.":"Linking an external account allows you to send and receive money to your account.",c=t?"Debit Card Number":"Your Debit Card Number",p=t?"Enter recipient's card number":"Enter your card number",s=`add-card-form-wrapper${t?" recipient-form":""}`,r={cardNumber:"",expiryDate:"",cvv:"",zipCode:""},{element:m,setError:d}=$({label:c,placeholder:p,id:"card-number-input",name:"cardNumber",maskType:"card",onChange(f){L("cardNumber",f,d)}}),{element:o,setError:v}=$({label:"Expiration Date",placeholder:"MM/YY",id:"expiry-input",name:"expiryDate",maskType:"expiry",onChange(f){L("expiryDate",f,v)}}),{element:y,setError:w}=$({label:"CVV",placeholder:"3-Digit",type:"number",maskType:"cvv",id:"cvv-input",name:"cvv",tooltip:"A CVV is a 3-digit number on your debit card. You can find it on the back side of the card.",onChange(f){L("cvv",f,w)}}),{element:g,setError:N}=$({label:"ZIP Code",placeholder:t?"ZIP Code":"Enter your ZIP Code",id:"zip-input",name:"zipCode",maskType:"zip",onChange(f){L("zipCode",f,N)}}),C=u("div",{className:t?"input-sections":"inputs",children:[m,o,y,g]}),A=u("p",{className:"submit-error",dataset:{show:"false"}}),{element:j,setDisabled:b,setLoading:D}=te({children:"Link Card",type:"submit",disabled:!0}),S=(f="")=>{x({element:A},{dataset:{show:String(!!f)},innerHTML:`
56
+ <span>${w||""}</span>
57
+ `})}}},oe=async(t,n={})=>{const{method:e="GET",headers:a={},body:l=null,...m}=n;try{const c={method:e,headers:{Accept:"*/*","Content-Type":"application/json",...a},...m};l&&["POST","PUT","PATCH","DELETE"].includes(e.toUpperCase())&&(c.body=typeof l=="string"?l:JSON.stringify(l));const o=await fetch(t,c),h=o.headers.get("content-type");let s;if(h?.includes("application/json")?s=await o.json():s=await o.text(),!o.ok){const r=s;throw new Error(r?.message||`HTTP error! status: ${o.status}`)}return{data:s,error:null}}catch(c){return{data:null,error:c instanceof Error?c.message:"An error occurred"}}},ie=({title:t="",children:n,onClose:e,showBackBtn:a=!1,showCloseBtn:l=!0})=>{const m=u("button",{className:"back-btn",innerHTML:X,dataset:{show:String(a)},events:{click:()=>d()}}),c=u("h3",{textContent:t}),o=u("button",{className:"close-btn",innerHTML:"&times;",dataset:{show:String(l)},attributes:{"aria-label":"Close modal"},events:{click:()=>d()}}),h=u("div",{className:"modal-header",children:[m,c,o]}),s=u("div",{className:"modal-content",children:[n]}),r=u("dialog",{className:"custom-modal",children:[h,s],events:{cancel:i=>{i.preventDefault(),d()}}}),d=()=>{r.close(),e?.()};return{element:r,setModalVisibility:i=>{i?r.showModal():r.close()}}},le=({token:t,endpoint:n,beneficiaryCard:e=!1,isModal:a=!1,onCallback:l=()=>null})=>{const m=e?"Enter Recipient Debit Card Details":"Enter Your Debit Card Details",c=e?"Enter the debit card details of the recipient you're sending funds to.":"Linking an external account allows you to send and receive money to your account.",o=e?"Debit Card Number":"Your Debit Card Number",h=e?"Enter recipient's card number":"Enter your card number",s=`add-card-form-wrapper${e?" recipient-form":""}`,r={cardNumber:"",expiryDate:"",cvv:"",zipCode:""},{element:d,setError:p}=$({label:o,placeholder:h,id:"card-number-input",name:"cardNumber",maskType:"card",onChange(v){L("cardNumber",v,p)}}),{element:i,setError:g}=$({label:"Expiration Date",placeholder:"MM/YY",id:"expiry-input",name:"expiryDate",maskType:"expiry",onChange(v){L("expiryDate",v,g)}}),{element:b,setError:f}=$({label:"CVV",placeholder:"3-Digit",type:"number",maskType:"cvv",id:"cvv-input",name:"cvv",tooltip:"A CVV is a 3-digit number on your debit card. You can find it on the back side of the card.",onChange(v){L("cvv",v,f)}}),{element:y,setError:N}=$({label:"ZIP Code",placeholder:e?"ZIP Code":"Enter your ZIP Code",id:"zip-input",name:"zipCode",maskType:"zip",onChange(v){L("zipCode",v,N)}}),D=u("div",{className:e?"input-sections":"inputs",children:[d,i,b,y]}),A=u("p",{className:"submit-error",dataset:{show:"false"}}),{element:V,setDisabled:w,setLoading:T}=ee({children:"Link Card",type:"submit",disabled:!0}),j=(v="")=>{M({element:A},{dataset:{show:String(!!v)},innerHTML:`
58
58
  ${k}
59
- ${f||""}
60
- `})},B=(f=!0)=>{b(f),D(f)};function L(f,H,E){r[f]=H;const{isValid:I,errors:T}=se(r);T[f]?E(T[f]):E(""),b(!I)}const O=u("div",{className:"submit-button-wrapper",children:[A,j]});async function P(f){f.preventDefault();const H=new FormData(f.target),E=Object.fromEntries(H.entries());console.log(E);const I=E?.cardNumber,T=E?.expiryDate,_=E?.cvv,G=E?.zipCode,K=Number(T?.split("/")[0]),U=re(T?.split("/")[1]),J=V(I);B(!0),S("");const M=await ie(e,{method:"POST",body:{token:n,pan:J,expiry_month:K,expiry_year:U,cvv:V(_),address:{postal_code:V(G)}}});M.error?(console.error("Request failed:",M.error),B(!1),S(M.error),a?.({success:!1,error:M.error})):(console.log("Request success:",M.data),B(!1),a?.({success:!0,data:M.data}))}const Z=()=>u("form",{events:{submit:P},children:[C,O]}),W=()=>u("div",{className:"form-title",innerHTML:`
61
- <p>${i}</p>
59
+ ${v||""}
60
+ `})},B=(v=!0)=>{w(v),T(v)};function L(v,H,E){r[v]=H;const{isValid:S,errors:x}=ne(r,e);x[v]?E(x[v]):E(""),w(!S)}const O=u("div",{className:"submit-button-wrapper",children:[A,V]});async function P(v){v.preventDefault();const H=new FormData(v.target),E=Object.fromEntries(H.entries()),S=E?.cardNumber?I(E?.cardNumber):null,x=E?.expiryDate||null,_=E?.cvv?I(E?.cvv):null,G=E?.zipCode?I(E?.zipCode):null,K=x?Number(x?.split("/")[0]):null,U=x?se(x?.split("/")[1]):null;B(!0),j("");const C=await oe(n,{method:"POST",body:{token:t,pan:S,expiry_month:K,expiry_year:U,cvv:_,address:{postal_code:G}}});C.error?(console.error("Request failed:",C.error),B(!1),j(C.error),l?.({success:!1,error:C.error})):(console.log("Request success:",C.data),B(!1),l?.({success:!0,data:C.data}))}const Z=()=>u("form",{events:{submit:P},children:[D,O]}),W=()=>u("div",{className:"form-title",innerHTML:`
61
+ <p>${c}</p>
62
62
 
63
63
  <div>
64
- ${Q}
64
+ ${J}
65
65
 
66
66
  <span>Secured with 256-bit encryption</span>
67
67
  </div>
68
- `}),z=()=>u("div",{className:l?"":"non-modal-content",children:[W(),Z()]}),q=l?null:u("div",{className:`${s} non-modal`,children:[u("div",{className:"non-modal-header",innerHTML:`
68
+ `}),z=()=>u("div",{className:a?"":"non-modal-content",children:[W(),Z()]}),R=a?null:u("div",{className:`${s} non-modal`,children:[u("div",{className:"non-modal-header",innerHTML:`
69
69
  <span></span>
70
- <h3>${h}</h3>
70
+ <h3>${m}</h3>
71
71
  <span></span>
72
- `}),z()]}),{element:Y,setModalVisibility:F}=l?le({title:h,children:z()}):{element:null,setModalVisibility:()=>{}};function R(){Y&&(document.body.appendChild(u("div",{className:s,children:[Y]})),F(!0))}return{renderFormWithModal:R,nonModalForm:q,closeModal:()=>F(!1)}};function de({token:n,endpoint:e,beneficiaryCard:t,isModal:l,onCallback:a,onModalClose:h}){const{renderFormWithModal:i,nonModalForm:c,closeModal:p}=ce({token:n,endpoint:e,beneficiaryCard:t,isModal:l,onCallback:a});return{mount(s){const r="className"in s?document.querySelector(s.className):"id"in s?document.getElementById(s.id):s.element;r&&c&&r.appendChild(c)},open(){i()},destroy(){p(),h?.()}}}exports.init=de;
72
+ `}),z()]}),{element:Y,setModalVisibility:F}=a?ie({title:m,children:z()}):{element:null,setModalVisibility:()=>{}};function q(){Y&&(document.body.appendChild(u("div",{className:s,children:[Y]})),F(!0))}return{renderFormWithModal:q,nonModalForm:R,closeModal:()=>F(!1)}};function ce({token:t,endpoint:n,beneficiaryCard:e,isModal:a,onCallback:l,onModalClose:m}){const{renderFormWithModal:c,nonModalForm:o,closeModal:h}=le({token:t,endpoint:n,beneficiaryCard:e,isModal:a,onCallback:l});return{mount(s){const r="className"in s?document.querySelector(s.className):"id"in s?document.getElementById(s.id):s.element;r&&o&&r.appendChild(o)},open(){c()},destroy(){h(),m?.()}}}exports.init=ce;