@test-glide/glide-payment 0.0.2 → 0.0.4

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.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const X=require("react/jsx-runtime"),O=require("react");function p(n,e={}){const t=document.createElement(n),{className:o,id:s,innerHTML:m,textContent:r,attributes:c,styles:d,dataset:i,children:l,events:h}=e;if(o){const u=Array.isArray(o)?o:o.split(" ");t.classList.add(...u.filter(Boolean))}if(s&&(t.id=s),m&&(t.innerHTML=m),r&&(t.textContent=r),c)for(const[u,a]of Object.entries(c))a&&t.setAttribute(u,a);if(d)for(const[u,a]of Object.entries(d))t.style[u]=a;if(i)for(const[u,a]of Object.entries(i))t.dataset[u]=a;if(l&&t.append(...l.filter(Boolean)),h)for(const[u,a]of Object.entries(h))t.addEventListener(u,a);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 o of t){const{styles:s,attributes:m,dataset:r,innerHTML:c,textContent:d,className:i}=e;if(s)for(const[l,h]of Object.entries(s))o.style[l]=h;if(m)for(const[l,h]of Object.entries(m))o.setAttribute(l,h);if(r)for(const[l,h]of Object.entries(r))o.dataset[l]=h;if(c!==void 0&&(o.innerHTML=c),d!==void 0&&(o.textContent=d),i?.add){const l=Array.isArray(i.add)?i.add:[i.add];o.classList.add(...l)}if(i?.remove){const l=Array.isArray(i.remove)?i.remove:[i.remove];o.classList.remove(...l)}i?.toggle&&(Array.isArray(i.toggle)?i.toggle:[i.toggle]).forEach(h=>o.classList.toggle(h))}}const ee=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const X=require("react/jsx-runtime"),O=require("react");function p(t,n={}){const e=document.createElement(t),{className:a,id:i,innerHTML:m,textContent:l,attributes:r,styles:u,dataset:s,children:o,events:d}=n;if(a){const h=Array.isArray(a)?a:a.split(" ");e.classList.add(...h.filter(Boolean))}if(i&&(e.id=i),m&&(e.innerHTML=m),l&&(e.textContent=l),r)for(const[h,c]of Object.entries(r))c&&e.setAttribute(h,c);if(u)for(const[h,c]of Object.entries(u))e.style[h]=c;if(s)for(const[h,c]of Object.entries(s))e.dataset[h]=c;if(o&&e.append(...o.filter(Boolean)),d)for(const[h,c]of Object.entries(d))e.addEventListener(h,c);return e}function x(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:i,attributes:m,dataset:l,innerHTML:r,textContent:u,className:s}=n;if(i)for(const[o,d]of Object.entries(i))a.style[o]=d;if(m)for(const[o,d]of Object.entries(m))a.setAttribute(o,d);if(l)for(const[o,d]of Object.entries(l))a.dataset[o]=d;if(r!==void 0&&(a.innerHTML=r),u!==void 0&&(a.textContent=u),s?.add){const o=Array.isArray(s.add)?s.add:[s.add];a.classList.add(...o)}if(s?.remove){const o=Array.isArray(s.remove)?s.remove:[s.remove];a.classList.remove(...o)}s?.toggle&&(Array.isArray(s.toggle)?s.toggle:[s.toggle]).forEach(d=>a.classList.toggle(d))}}const ee=`
2
2
  <svg
3
3
  xmlns="http://www.w3.org/2000/svg"
4
4
  width="16"
@@ -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
- `,re=({children:n,onClick:e,disabled:t=!1,size:o="medium",type:s="button",className:m="",variant:r="primary"})=>{const c=p("span",{className:"button-spinner",innerHTML:te,dataset:{show:"false"}}),d=p("span",{className:"button-label",children:[null],textContent:n}),i=p("button",{className:`custom-button ${r} ${o} ${m}`,attributes:{type:s,...t?{disabled:"true"}:{}},events:{click:e},children:[c,d]}),l=(u=!1)=>{x({element:c},{dataset:{show:String(u)}}),h(u)},h=(u=!1)=>{u?i.setAttribute("disabled","true"):i.removeAttribute("disabled")};return{element:i,setLoading:l,setDisabled:h}},se=({content:n,position:e="top",delay:t=200,maxWidth:o=250,className:s="",id:m=""})=>{var r=p("div",{className:`tooltip ${e} ${s}`,styles:{maxWidth:`${o}px`},attributes:{role:"tooltip"},dataset:{show:"false"},innerHTML:`
49
- <div class="tooltip-content">${n}</div>
48
+ `,se=({children:t,onClick:n,disabled:e=!1,size:a="medium",type:i="button",className:m="",variant:l="primary"})=>{const r=p("span",{className:"button-spinner",innerHTML:te,dataset:{show:"false"}}),u=p("span",{className:"button-label",children:[null],textContent:t}),s=p("button",{className:`custom-button ${l} ${a} ${m}`,attributes:{type:i,...e?{disabled:"true"}:{}},events:{click:n},children:[r,u]}),o=(h=!1)=>{x({element:r},{dataset:{show:String(h)}}),d(h)},d=(h=!1)=>{h?s.setAttribute("disabled","true"):s.removeAttribute("disabled")};return{element:s,setLoading:o,setDisabled:d}},re=({content:t,position:n="top",delay:e=200,maxWidth:a=250,className:i="",id:m=""})=>{var l=p("div",{className:`tooltip ${n} ${i}`,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 l=p("span",{className:"tooltip-trigger",innerHTML:k,events:{mouseenter:()=>{t>0?c=window.setTimeout(()=>{r.dataset.show="true",h()},t):(r.dataset.show="true",h())},mouseleave:()=>{c&&clearTimeout(c),r.dataset.show="false"}}});function h(){if(!l||!r)return;const a=l.getBoundingClientRect(),v=r.getBoundingClientRect(),y=8;let w,g;switch(e){case"top":w=a.top-v.height-y,g=a.left+a.width/2-v.width/2;break;case"bottom":w=a.bottom+y,g=a.left+a.width/2-v.width/2;break;case"left":w=a.top+a.height/2-v.height/2,g=a.left-v.width-y;break;case"right":w=a.top+a.height/2-v.height/2,g=a.right+y;break;default:w=a.top-v.height-y,g=a.left+a.width/2-v.width/2}const N=window.innerWidth,M=window.innerHeight;g<0&&(g=y),g+v.width>N&&(g=N-v.width-y),w<0&&(w=y),w+v.height>M&&(w=M-v.height-y),r.style.top=`${w}px`,r.style.left=`${g}px`}return p("div",{className:"tooltip-wrapper",id:`tooltip-${m}`,children:[l,r]})},oe=n=>{const e={},t=Object.values(n).every(s=>!s||s.trim()===""),o=n.cardNumber?.replace(/\s/g,"");if(o?/^\d{13,19}$/.test(o)||(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 s=n.expiryDate.replace(/\D/g,"");if(s.length<4)e.expiryDate="Enter complete expiry date (MM/YY)";else{const m=parseInt(s.substring(0,2),10),r=parseInt(s.substring(2,4),10);if(isNaN(m)||m<1||m>12)e.expiryDate="Invalid month (must be 01-12)";else if(isNaN(r)||r<0||r>99)e.expiryDate="Invalid year";else{const c=new Date,d=c.getFullYear(),i=c.getMonth()+1,l=Math.floor(d/100)*100,h=l+r,u=l+100+r;let a;h>=d&&h<=d+20?a=h:(u>=d&&u<=d+20,a=u),a<d||a===d&&m<i?e.expiryDate="Card has expired":a>d+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 ae(n){const e=parseInt(n,10);if(isNaN(e)||e<0||e>99)return null;const t=new Date().getFullYear(),o=Math.floor(t/100)*100;let s=o+e;return s>=t&&s<=t+20||(s=o+100+e,s>=t&&s<=t+20)?s:o+100+e}function I(n=""){return n.trim().replaceAll(/\s/g,"").replaceAll("-","")}const ie={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 le(n,e){return e==="none"?n:ie[e](n)}const $=({label:n,maskType:e,id:t,name:o,type:s="text",placeholder:m="Enter value",tooltip:r="",onChange:c})=>{const d=["card","expiry","phone","cvv","zip"].includes(e)?"numeric":"",i=p("label",{className:"input-label",innerHTML:n,attributes:{for:t}});let l=!1;const u=p("input",{id:t||"input-id",className:"styled-input",attributes:{placeholder:m,type:s,inputMode:d,name:o},events:{input:a,blur:v,keydown:b=>{b.key==="Enter"&&(l=!0)}}});function a(b){const D=e!=="none"?le(b?.target?.value,e):b?.target?.value;u.value=D,c?.(D)}function v(){l=!0,c?.(u?.value||"")}const y=p("div",{className:"input-loader",innerHTML:'<div class="loader"></div>',dataset:{show:"false"}}),w=r?p("div",{className:"input-right-element",children:[se({content:r,id:t})]}):null,g=p("div",{className:"input-wrapper",children:[u,y,w]}),N=p("div",{className:"error-message",dataset:{show:"false"},innerHTML:`
51
+ `});let r=null;var o=p("span",{className:"tooltip-trigger",innerHTML:k,events:{mouseenter:()=>{e>0?r=window.setTimeout(()=>{l.dataset.show="true",d()},e):(l.dataset.show="true",d())},mouseleave:()=>{r&&clearTimeout(r),l.dataset.show="false"}}});function d(){if(!o||!l)return;const c=o.getBoundingClientRect(),v=l.getBoundingClientRect(),b=8;let f,y;switch(n){case"top":f=c.top-v.height-b,y=c.left+c.width/2-v.width/2;break;case"bottom":f=c.bottom+b,y=c.left+c.width/2-v.width/2;break;case"left":f=c.top+c.height/2-v.height/2,y=c.left-v.width-b;break;case"right":f=c.top+c.height/2-v.height/2,y=c.right+b;break;default:f=c.top-v.height-b,y=c.left+c.width/2-v.width/2}const N=window.innerWidth,C=window.innerHeight;y<0&&(y=b),y+v.width>N&&(y=N-v.width-b),f<0&&(f=b),f+v.height>C&&(f=C-v.height-b),l.style.top=`${f}px`,l.style.left=`${y}px`}return p("div",{className:"tooltip-wrapper",id:`tooltip-${m}`,children:[o,l]})},oe=(t,n=!1)=>{const e={},a=Object.values(t).every(r=>!r||r.trim()===""),i=t.cardNumber?.replace(/\s/g,"");if(i?/^\d{13,19}$/.test(i)||(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 r=t.expiryDate.replace(/\D/g,"");if(r.length<4)e.expiryDate="Enter complete expiry date (MM/YY)";else{const u=parseInt(r.substring(0,2),10),s=parseInt(r.substring(2,4),10);if(isNaN(u)||u<1||u>12)e.expiryDate="Invalid month (must be 01-12)";else if(isNaN(s)||s<0||s>99)e.expiryDate="Invalid year";else{const o=new Date,d=o.getFullYear(),h=o.getMonth()+1,c=Math.floor(d/100)*100,v=c+s,b=c+100+s;let f;v>=d&&v<=d+20?f=v:(b>=d&&b<=d+20,f=b),f<d||f===d&&u<h?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 l=t.zipCode.trim();return l&&!/^[A-Z0-9\s-]{3,10}$/i.test(l)&&(e.zipCode="Invalid ZIP code format"),{isValid:Object.keys(e).length===0,errors:e,isEmpty:a}};function ae(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 i=a+n;return i>=e&&i<=e+20||(i=a+100+n,i>=e&&i<=e+20)?i:a+100+n}function S(t=""){return t.trim().replaceAll(/\s/g,"").replaceAll("-","")}const ie={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 le(t,n){return n==="none"?t:ie[n](t)}const $=({label:t,maskType:n,id:e,name:a,type:i="text",placeholder:m="Enter value",tooltip:l="",onChange:r})=>{const u=["card","expiry","phone","cvv","zip"].includes(n)?"numeric":"",s=p("label",{className:"input-label",innerHTML:t,attributes:{for:e}});let o=!1;const h=p("input",{id:e||"input-id",className:"styled-input",attributes:{placeholder:m,type:i,inputMode:u,name:a},events:{input:c,blur:v,keydown:w=>{w.key==="Enter"&&(o=!0)}}});function c(w){const T=n!=="none"?le(w?.target?.value,n):w?.target?.value;h.value=T,r?.(T)}function v(){o=!0,r?.(h?.value||"")}const b=p("div",{className:"input-loader",innerHTML:'<div class="loader"></div>',dataset:{show:"false"}}),f=l?p("div",{className:"input-right-element",children:[re({content:l,id:e})]}):null,y=p("div",{className:"input-wrapper",children:[h,b,f]}),N=p("div",{className:"error-message",dataset:{show:"false"},innerHTML:`
52
52
  ${k}
53
53
  <span></span>
54
- `});return{element:p("div",{className:"custom-input-group",children:[i,g,N]}),setLoading:b=>{x({element:g},{dataset:{loading:b?"true":"false"}}),x({element:u},{attributes:{disabled:b?"true":"false"}}),x({element:y},{dataset:{show:b?"true":"false"}})},setError:(b="")=>{x({element:g},{className:b&&l?{add:"input-error"}:{remove:"input-error"}}),x({element:N},{dataset:{show:b&&l?"true":"false"},innerHTML:`
54
+ `});return{element:p("div",{className:"custom-input-group",children:[s,y,N]}),setLoading:w=>{x({element:y},{dataset:{loading:w?"true":"false"}}),x({element:h},{attributes:{disabled:w?"true":"false"}}),x({element:b},{dataset:{show:w?"true":"false"}})},setError:(w="")=>{x({element:y},{className:w&&o?{add:"input-error"}:{remove:"input-error"}}),x({element:N},{dataset:{show:w&&o?"true":"false"},innerHTML:`
55
55
  ${k}
56
- <span>${b||""}</span>
57
- `})}}},ce=async(n,e={})=>{const{method:t="GET",headers:o={},body:s=null,...m}=e;try{const r={method:t,headers:{Accept:"*/*","Content-Type":"application/json",...o},...m};s&&["POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())&&(r.body=typeof s=="string"?s:JSON.stringify(s));const c=await fetch(n,r),d=c.headers.get("content-type");let i;if(d?.includes("application/json")?i=await c.json():i=await c.text(),!c.ok){const l=i;throw new Error(l?.message||`HTTP error! status: ${c.status}`)}return{data:i,error:null}}catch(r){return{data:null,error:r instanceof Error?r.message:"An error occurred"}}},de=({title:n="",children:e,onClose:t,showBackBtn:o=!1,showCloseBtn:s=!0})=>{const m=p("button",{className:"back-btn",innerHTML:ne,dataset:{show:String(o)},events:{click:()=>h()}}),r=p("h3",{textContent:n}),c=p("button",{className:"close-btn",innerHTML:"&times;",dataset:{show:String(s)},attributes:{"aria-label":"Close modal"},events:{click:()=>h()}}),d=p("div",{className:"modal-header",children:[m,r,c]}),i=p("div",{className:"modal-content",children:[e]}),l=p("dialog",{className:"custom-modal",children:[d,i],events:{cancel:a=>{a.preventDefault(),h()}}}),h=()=>{l.close(),t?.()};return{element:l,setModalVisibility:a=>{a?l.showModal():l.close()}}},ue=({token:n,endpoint:e,beneficiaryCard:t=!1,isModal:o=!1,onCallback:s=()=>null})=>{const m=t?"Enter Recipient Debit Card Details":"Enter Your Debit Card Details",r=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",d=t?"Enter recipient's card number":"Enter your card number",i=`add-card-form-wrapper${t?" recipient-form":""}`,l={cardNumber:"",expiryDate:"",cvv:"",zipCode:""},{element:h,setError:u}=$({label:c,placeholder:d,id:"card-number-input",name:"cardNumber",maskType:"card",onChange(f){L("cardNumber",f,u)}}),{element:a,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)}}),M=p("div",{className:t?"input-sections":"inputs",children:[h,a,y,g]}),A=p("p",{className:"submit-error",dataset:{show:"false"}}),{element:V,setDisabled:b,setLoading:D}=re({children:"Link Card",type:"submit",disabled:!0}),S=(f="")=>{x({element:A},{dataset:{show:String(!!f)},innerHTML:`
56
+ <span>${w||""}</span>
57
+ `})}}},ce=async(t,n={})=>{const{method:e="GET",headers:a={},body:i=null,...m}=n;try{const l={method:e,headers:{Accept:"*/*","Content-Type":"application/json",...a},...m};i&&["POST","PUT","PATCH","DELETE"].includes(e.toUpperCase())&&(l.body=typeof i=="string"?i:JSON.stringify(i));const r=await fetch(t,l),u=r.headers.get("content-type");let s;if(u?.includes("application/json")?s=await r.json():s=await r.text(),!r.ok){const o=s;throw new Error(o?.message||`HTTP error! status: ${r.status}`)}return{data:s,error:null}}catch(l){return{data:null,error:l instanceof Error?l.message:"An error occurred"}}},de=({title:t="",children:n,onClose:e,showBackBtn:a=!1,showCloseBtn:i=!0})=>{const m=p("button",{className:"back-btn",innerHTML:ne,dataset:{show:String(a)},events:{click:()=>d()}}),l=p("h3",{textContent:t}),r=p("button",{className:"close-btn",innerHTML:"&times;",dataset:{show:String(i)},attributes:{"aria-label":"Close modal"},events:{click:()=>d()}}),u=p("div",{className:"modal-header",children:[m,l,r]}),s=p("div",{className:"modal-content",children:[n]}),o=p("dialog",{className:"custom-modal",children:[u,s],events:{cancel:c=>{c.preventDefault(),d()}}}),d=()=>{o.close(),e?.()};return{element:o,setModalVisibility:c=>{c?o.showModal():o.close()}}},ue=({token:t,endpoint:n,beneficiaryCard:e=!1,isModal:a=!1,onCallback:i=()=>null})=>{const m=e?"Enter Recipient Debit Card Details":"Enter Your Debit Card Details",l=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.",r=e?"Debit Card Number":"Your Debit Card Number",u=e?"Enter recipient's card number":"Enter your card number",s=`add-card-form-wrapper${e?" recipient-form":""}`,o={cardNumber:"",expiryDate:"",cvv:"",zipCode:""},{element:d,setError:h}=$({label:r,placeholder:u,id:"card-number-input",name:"cardNumber",maskType:"card",onChange(g){L("cardNumber",g,h)}}),{element:c,setError:v}=$({label:"Expiration Date",placeholder:"MM/YY",id:"expiry-input",name:"expiryDate",maskType:"expiry",onChange(g){L("expiryDate",g,v)}}),{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(g){L("cvv",g,f)}}),{element:y,setError:N}=$({label:"ZIP Code",placeholder:e?"ZIP Code":"Enter your ZIP Code",id:"zip-input",name:"zipCode",maskType:"zip",onChange(g){L("zipCode",g,N)}}),C=p("div",{className:e?"input-sections":"inputs",children:[d,c,b,y]}),A=p("p",{className:"submit-error",dataset:{show:"false"}}),{element:I,setDisabled:w,setLoading:T}=se({children:"Link Card",type:"submit",disabled:!0}),V=(g="")=>{x({element:A},{dataset:{show:String(!!g)},innerHTML:`
58
58
  ${k}
59
- ${f||""}
60
- `})},B=(f=!0)=>{b(f),D(f)};function L(f,H,E){l[f]=H;const{isValid:j,errors:T}=oe(l);T[f]?E(T[f]):E(""),b(!j)}const P=p("div",{className:"submit-button-wrapper",children:[A,V]});async function Z(f){f.preventDefault();const H=new FormData(f.target),E=Object.fromEntries(H.entries());console.log(E);const j=E?.cardNumber,T=E?.expiryDate,G=E?.cvv,K=E?.zipCode,U=Number(T?.split("/")[0]),J=ae(T?.split("/")[1]),Q=I(j);B(!0),S("");const C=await ce(e,{method:"POST",body:{token:n,pan:Q,expiry_month:U,expiry_year:J,cvv:I(G),address:{postal_code:I(K)}}});C.error?(console.error("Request failed:",C.error),B(!1),S(C.error),s?.({success:!1,error:C.error})):(console.log("Request success:",C.data),B(!1),s?.({success:!0,data:C.data}))}const q=()=>p("form",{events:{submit:Z},children:[M,P]}),R=()=>p("div",{className:"form-title",innerHTML:`
61
- <p>${r}</p>
59
+ ${g||""}
60
+ `})},B=(g=!0)=>{w(g),T(g)};function L(g,H,E){o[g]=H;const{isValid:j,errors:D}=oe(o,e);D[g]?E(D[g]):E(""),w(!j)}const P=p("div",{className:"submit-button-wrapper",children:[A,I]});async function Z(g){g.preventDefault();const H=new FormData(g.target),E=Object.fromEntries(H.entries());console.log(E);const j=E?.cardNumber,D=E?.expiryDate,G=E?.cvv,K=E?.zipCode,U=Number(D?.split("/")[0]),J=ae(D?.split("/")[1]),Q=S(j);B(!0),V("");const M=await ce(n,{method:"POST",body:{token:t,pan:Q,expiry_month:U,expiry_year:J,cvv:S(G),address:{postal_code:S(K)}}});M.error?(console.error("Request failed:",M.error),B(!1),V(M.error),i?.({success:!1,error:M.error})):(console.log("Request success:",M.data),B(!1),i?.({success:!0,data:M.data}))}const R=()=>p("form",{events:{submit:Z},children:[C,P]}),W=()=>p("div",{className:"form-title",innerHTML:`
61
+ <p>${l}</p>
62
62
 
63
63
  <div>
64
64
  ${ee}
65
65
 
66
66
  <span>Secured with 256-bit encryption</span>
67
67
  </div>
68
- `}),z=()=>p("div",{className:o?"":"non-modal-content",children:[R(),q()]}),W=o?null:p("div",{className:`${i} non-modal`,children:[p("div",{className:"non-modal-header",innerHTML:`
68
+ `}),Y=()=>p("div",{className:a?"":"non-modal-content",children:[W(),R()]}),q=a?null:p("div",{className:`${s} non-modal`,children:[p("div",{className:"non-modal-header",innerHTML:`
69
69
  <span></span>
70
70
  <h3>${m}</h3>
71
71
  <span></span>
72
- `}),z()]}),{element:Y,setModalVisibility:F}=o?de({title:m,children:z()}):{element:null,setModalVisibility:()=>{}};function _(){Y&&(document.body.appendChild(p("div",{className:i,children:[Y]})),F(!0))}return{renderFormWithModal:_,nonModalForm:W,closeModal:()=>F(!1)}};function pe({token:n,endpoint:e,beneficiaryCard:t,isModal:o,onCallback:s}){const{renderFormWithModal:m,nonModalForm:r,closeModal:c}=ue({token:n,endpoint:e,beneficiaryCard:t,isModal:o,onCallback:s});return{mount(d){const i="className"in d?document.querySelector(d.className):"id"in d?document.getElementById(d.id):d.element;i&&r&&i.appendChild(r)},open(){m()},destroy(){c()}}}function me({token:n,endpoint:e,isModal:t=!1,beneficiaryCard:o=!1,isOpen:s=!1,onCallback:m=()=>null}){const r=O.useRef(null);return O.useEffect(()=>{let c=pe({token:n,endpoint:e,beneficiaryCard:o,isModal:t,onCallback:m});if(t)s?c.open():c.destroy();else{if(!r?.current)return;c.mount({element:r.current})}return()=>{c.destroy()}},[t,n,e,o,s]),t?null:X.jsx("div",{ref:r})}exports.AddCard=me;
72
+ `}),Y()]}),{element:z,setModalVisibility:F}=a?de({title:m,children:Y()}):{element:null,setModalVisibility:()=>{}};function _(){z&&(document.body.appendChild(p("div",{className:s,children:[z]})),F(!0))}return{renderFormWithModal:_,nonModalForm:q,closeModal:()=>F(!1)}};function pe({token:t,endpoint:n,beneficiaryCard:e,isModal:a,onCallback:i,onModalClose:m}){const{renderFormWithModal:l,nonModalForm:r,closeModal:u}=ue({token:t,endpoint:n,beneficiaryCard:e,isModal:a,onCallback:i});return{mount(s){const o="className"in s?document.querySelector(s.className):"id"in s?document.getElementById(s.id):s.element;o&&r&&o.appendChild(r)},open(){l()},destroy(){u(),m?.()}}}function me({token:t,endpoint:n,isModal:e=!1,beneficiaryCard:a=!1,isOpen:i=!1,onCallback:m=()=>null,onClose:l=()=>null}){const r=O.useRef(null);return O.useEffect(()=>{let u=pe({token:t,endpoint:n,beneficiaryCard:a,isModal:e,onCallback:m,onModalClose:l});if(e)i?u.open():u.destroy();else{if(!r?.current)return;u.mount({element:r.current})}return()=>{u.destroy()}},[e,t,n,a,i]),e?null:X.jsx("div",{ref:r})}exports.AddCard=me;