1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-15 15:42:51 +01:00
invoiceninja/public/build/assets/authorize-credit-card-payment-bd9c9d4d.js
Benjamin Beganović 044b4bce72
Fixes for Forte & Authorize.net (#83)
* configure manual chunks for forte & authorize

* assets build
2024-08-22 07:44:57 +10:00

21 lines
23 KiB
JavaScript
Vendored
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var G=Object.defineProperty;var J=(t,e,n)=>e in t?G(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var T=(t,e,n)=>(J(t,typeof e!="symbol"?e+"":e,n),n);var q=t=>{throw TypeError(t)},Q=(t,e,n)=>e.has(t)||q("Cannot "+n),ee=(t,e,n)=>e.has(t)?q("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),te=(t,e,n)=>(Q(t,e,"access private method"),n);const B={mask:/^.*$/,preprocessors:[],postprocessors:[],plugins:[],overwriteMode:"shift"};class ne{constructor(){this.now=null,this.past=[],this.future=[]}undo(){const e=this.past.pop();e&&this.now&&(this.future.push(this.now),this.updateElement(e,"historyUndo"))}redo(){const e=this.future.pop();e&&this.now&&(this.past.push(this.now),this.updateElement(e,"historyRedo"))}updateHistory(e){if(!this.now){this.now=e;return}const n=this.now.value!==e.value,a=this.now.selection.some((s,r)=>s!==e.selection[r]);!n&&!a||(n&&(this.past.push(this.now),this.future=[]),this.now=e)}updateElement(e,n){this.now=e,this.updateElementState(e,{inputType:n,data:null})}}function ae(t,...e){return e.every(({value:n})=>n===t.value)}function se(t,...e){return e.every(({value:n,selection:a})=>n===t.value&&a[0]===t.selection[0]&&a[1]===t.selection[1])}function re({value:t,selection:e},n,a){const[s,r]=e,i=typeof a=="function"?a({value:t,selection:e}):a;return{value:t,selection:i==="replace"?[s,s+n.length]:[s,r]}}function I(t){return typeof t=="string"}function O(t,e,n,a){let s="";for(let r=e.length;r<t.length;r++){const i=t[r],l=(a==null?void 0:a.value[r])===i;if(!I(i)||i===n&&!l)return s;s+=i}return s}function H(t,e){return Array.isArray(e)?t.length===e.length&&Array.from(t).every((n,a)=>{const s=e[a];return I(s)?n===s:n.match(s)}):e.test(t)}function ie(t,e,n){let a=null,s=null;const r=Array.from(t.value).reduce((l,o,c)=>{const u=O(e,l,o,n),d=l+u,h=e[d.length];return I(h)?d+h:o.match(h)?(a===null&&c>=t.selection[0]&&(a=d.length),s===null&&c>=t.selection[1]&&(s=d.length),d+o):d},""),i=O(e,r,"",n);return{value:H(r+i,e)?r+i:r,selection:[a??r.length,s??r.length]}}function le({value:t,selection:e},n){const[a,s]=e;let r=a,i=s;return{value:Array.from(t).reduce((l,o,c)=>{const u=l+o;return a===c&&(r=l.length),s===c&&(i=l.length),u.match(n)?u:l},""),selection:[r,i]}}function A(t,e,n=null){if(H(t.value,e))return t;const{value:a,selection:s}=Array.isArray(e)?ie(t,e,n):le(t,e);return{selection:s,value:Array.isArray(e)?a.slice(0,e.length):a}}function R(t,e){if(!Array.isArray(e))return t;const[n,a]=t.selection,s=[],r=Array.from(t.value).reduce((i,l,o)=>{const c=e[o];return o===n&&s.push(i.length),o===a&&s.push(i.length),I(c)&&c===l?i:i+l},"");return s.length<2&&s.push(...new Array(2-s.length).fill(r.length)),{value:r,selection:[s[0],s[1]]}}class D{constructor(e,n){this.initialElementState=e,this.maskOptions=n,this.value="",this.selection=[0,0];const{value:a,selection:s}=A(this.initialElementState,this.getMaskExpression(this.initialElementState));this.value=a,this.selection=s}addCharacters([e,n],a){const{value:s}=this,r=this.getMaskExpression({value:s.slice(0,e)+a+s.slice(n),selection:[e+a.length,e+a.length]}),i={value:s,selection:[e,n]},l=R(i,r),[o,c]=re(l,a,this.maskOptions.overwriteMode).selection,u=l.value.slice(0,o)+a,d=u.length,h=A({value:u+l.value.slice(c),selection:[d,d]},r,i);if(s.slice(0,o)===A({value:u,selection:[d,d]},r,i).value||se(this,h))throw new Error("Invalid mask value");this.value=h.value,this.selection=h.selection}deleteCharacters([e,n]){if(e===n||!n)return;const{value:a}=this,s=this.getMaskExpression({value:a.slice(0,e)+a.slice(n),selection:[e,e]}),r={value:a,selection:[e,n]},i=R(r,s),[l,o]=i.selection,c=i.value.slice(0,l)+i.value.slice(o),u=A({value:c,selection:[l,l]},s,r);this.value=u.value,this.selection=u.selection}getMaskExpression(e){const{mask:n}=this.maskOptions;return typeof n=="function"?n(e):n}}class oe{constructor(e){this.element=e,this.listeners=[]}listen(e,n,a){const s=n;this.element.addEventListener(e,s,a),this.listeners.push(()=>this.element.removeEventListener(e,s))}destroy(){this.listeners.forEach(e=>e())}}const g={CTRL:1,ALT:2,SHIFT:4,META:8},w={Y:89,Z:90};function b(t,e,n){return t.ctrlKey===!!(e&g.CTRL)&&t.altKey===!!(e&g.ALT)&&t.shiftKey===!!(e&g.SHIFT)&&t.metaKey===!!(e&g.META)&&t.keyCode===n}function ce(t){return b(t,g.CTRL,w.Y)||b(t,g.CTRL|g.SHIFT,w.Z)||b(t,g.META|g.SHIFT,w.Z)}function ue(t){return b(t,g.CTRL,w.Z)||b(t,g.META,w.Z)}function de({value:t,selection:e},n){const[a,s]=e;if(a!==s)return[a,s];const r=n?t.slice(a).indexOf(`
`)+1||t.length:t.slice(0,s).lastIndexOf(`
`)+1;return[n?a:r,n?r:s]}function he({value:t,selection:e},n){const[a,s]=e;return a!==s?[a,s]:(n?[a,s+1]:[a-1,s]).map(r=>Math.min(Math.max(r,0),t.length))}const me=/\s+$/g,pe=/^\s+/g,j=/\s/;function ve({value:t,selection:e},n){const[a,s]=e;if(a!==s)return[a,s];if(n){const o=t.slice(a),[c]=o.match(pe)||[""],u=o.trimStart().search(j);return[a,u!==-1?a+c.length+u:t.length]}const r=t.slice(0,s),[i]=r.match(me)||[""],l=r.trimEnd().split("").reverse().findIndex(o=>o.match(j));return[l!==-1?s-i.length-l:0,s]}function k(t=[]){return(e,...n)=>t.reduce((a,s)=>Object.assign(Object.assign({},a),s(a,...n)),e)}function ge(t,e){const n=Object.assign(Object.assign({},B),e),a=k(n.preprocessors),s=k(n.postprocessors),r=typeof t=="string"?{value:t,selection:[0,0]}:t,{elementState:i}=a({elementState:r,data:""},"validation"),l=new D(i,n),{value:o,selection:c}=s(l,r);return typeof t=="string"?o:{value:o,selection:c}}class M extends ne{constructor(e,n){super(),this.element=e,this.maskitoOptions=n,this.isTextArea=this.element.nodeName==="TEXTAREA",this.eventListener=new oe(this.element),this.options=Object.assign(Object.assign({},B),this.maskitoOptions),this.preprocessor=k(this.options.preprocessors),this.postprocessor=k(this.options.postprocessors),this.teardowns=this.options.plugins.map(a=>a(this.element,this.options)),this.updateHistory(this.elementState),this.eventListener.listen("keydown",a=>{if(ce(a))return a.preventDefault(),this.redo();if(ue(a))return a.preventDefault(),this.undo()}),this.eventListener.listen("beforeinput",a=>{var s;const r=a.inputType.includes("Forward");switch(this.updateHistory(this.elementState),a.inputType){case"historyUndo":return a.preventDefault(),this.undo();case"historyRedo":return a.preventDefault(),this.redo();case"deleteByCut":case"deleteContentBackward":case"deleteContentForward":return this.handleDelete({event:a,isForward:r,selection:he(this.elementState,r)});case"deleteWordForward":case"deleteWordBackward":return this.handleDelete({event:a,isForward:r,selection:ve(this.elementState,r),force:!0});case"deleteSoftLineBackward":case"deleteSoftLineForward":case"deleteHardLineBackward":case"deleteHardLineForward":return this.handleDelete({event:a,isForward:r,selection:de(this.elementState,r),force:!0});case"insertCompositionText":return;case"insertReplacementText":return;case"insertLineBreak":case"insertParagraph":return this.handleEnter(a);case"insertFromPaste":case"insertText":case"insertFromDrop":default:return this.handleInsert(a,a.data||((s=a.dataTransfer)===null||s===void 0?void 0:s.getData("text/plain"))||"")}}),this.eventListener.listen("input",({inputType:a})=>{a!=="insertCompositionText"&&(this.ensureValueFitsMask(),this.updateHistory(this.elementState))}),this.eventListener.listen("compositionend",()=>{this.ensureValueFitsMask(),this.updateHistory(this.elementState)})}get elementState(){const{value:e,selectionStart:n,selectionEnd:a}=this.element;return{value:e,selection:[n||0,a||0]}}get maxLength(){const{maxLength:e}=this.element;return e===-1?1/0:e}destroy(){this.eventListener.destroy(),this.teardowns.forEach(e=>e==null?void 0:e())}updateElementState({value:e,selection:n},a={inputType:"insertText",data:null}){const s=this.elementState.value;this.updateValue(e),this.updateSelectionRange(n),s!==e&&this.dispatchInputEvent(a)}updateSelectionRange([e,n]){var a;const{element:s}=this;s.matches(":focus")&&(s.selectionStart!==e||s.selectionEnd!==n)&&((a=s.setSelectionRange)===null||a===void 0||a.call(s,e,n))}updateValue(e){this.element.value=e}ensureValueFitsMask(){this.updateElementState(ge(this.elementState,this.options))}dispatchInputEvent(e={inputType:"insertText",data:null}){globalThis.InputEvent&&this.element.dispatchEvent(new InputEvent("input",Object.assign(Object.assign({},e),{bubbles:!0,cancelable:!1})))}handleDelete({event:e,selection:n,isForward:a,force:s=!1}){const r={value:this.elementState.value,selection:n},[i,l]=r.selection,{elementState:o}=this.preprocessor({elementState:r,data:""},a?"deleteForward":"deleteBackward"),c=new D(o,this.options),[u,d]=o.selection;c.deleteCharacters([u,d]);const h=this.postprocessor(c,r);if(!(r.value.slice(0,i)+r.value.slice(l)===h.value&&!s&&!this.element.isContentEditable)){if(e.preventDefault(),ae(r,o,c,h))return this.updateSelectionRange(a?[d,d]:[u,u]);this.updateElementState(h,{inputType:e.inputType,data:null}),this.updateHistory(h)}}handleInsert(e,n){const a=this.elementState,{elementState:s,data:r=n}=this.preprocessor({data:n,elementState:a},"insert"),i=new D(s,this.options);try{i.addCharacters(s.selection,r)}catch{return e.preventDefault()}const[l,o]=s.selection,c=a.value.slice(0,l)+n+a.value.slice(o),u=this.postprocessor(i,a);if(u.value.length>this.maxLength)return e.preventDefault();(c!==u.value||this.element.isContentEditable)&&(e.preventDefault(),this.updateElementState(u,{data:n,inputType:e.inputType}),this.updateHistory(u))}handleEnter(e){(this.isTextArea||this.element.isContentEditable)&&this.handleInsert(e,`
`)}}function fe(t,e,n){const a=Math.min(Number(n),Math.max(Number(e),Number(t)));return t instanceof Date?new Date(a):a}function ye(t){return t.replaceAll(/\W/g,"").length}const V=t=>{var e,n,a;return{day:((e=t.match(/d/g))===null||e===void 0?void 0:e.length)||0,month:((n=t.match(/m/g))===null||n===void 0?void 0:n.length)||0,year:((a=t.match(/y/g))===null||a===void 0?void 0:a.length)||0}};function Se(t){return{day:String(t.getDate()).padStart(2,"0"),month:String(t.getMonth()+1).padStart(2,"0"),year:String(t.getFullYear()).padStart(4,"0"),hours:String(t.getHours()).padStart(2,"0"),minutes:String(t.getMinutes()).padStart(2,"0"),seconds:String(t.getSeconds()).padStart(2,"0"),milliseconds:String(t.getMilliseconds()).padStart(3,"0")}}function we(t,e){return t.length<e.length?!1:t.split(/\D/).every(n=>!n.match(/^0+$/))}function W(t,e,n){const a=ye(e);return t.replace(n,"").match(new RegExp(`(\\D*\\d[^\\d\\s]*){1,${a}}`,"g"))||[]}function C(t,e){const n=e.replaceAll(/[^dmy]/g,""),a=t.replaceAll(/\D+/g,""),s={day:a.slice(n.indexOf("d"),n.lastIndexOf("d")+1),month:a.slice(n.indexOf("m"),n.lastIndexOf("m")+1),year:a.slice(n.indexOf("y"),n.lastIndexOf("y")+1)};return Object.fromEntries(Object.entries(s).filter(([r,i])=>!!i).sort(([r],[i])=>e.toLowerCase().indexOf(r[0])>e.toLowerCase().indexOf(i[0])?1:-1))}function be(t,e){var n,a,s,r,i,l,o;const c=((n=t.year)===null||n===void 0?void 0:n.length)===2?`20${t.year}`:t.year,u=new Date(Number(c??"0"),Number((a=t.month)!==null&&a!==void 0?a:"1")-1,Number((s=t.day)!==null&&s!==void 0?s:"1"),Number((r=void 0)!==null&&r!==void 0?r:"0"),Number((i=void 0)!==null&&i!==void 0?i:"0"),Number((l=void 0)!==null&&l!==void 0?l:"0"),Number((o=void 0)!==null&&o!==void 0?o:"0"));return u.setFullYear(Number(c??"0")),u}const z=", ";function E({day:t,month:e,year:n,hours:a,minutes:s,seconds:r,milliseconds:i},{dateMode:l,dateTimeSeparator:o=z,timeMode:c}){var u;const d=((u=l.match(/y/g))===null||u===void 0?void 0:u.length)===2?n==null?void 0:n.slice(-2):n;return(l+(c?o+c:"")).replaceAll(/d+/g,t??"").replaceAll(/m+/g,e??"").replaceAll(/y+/g,d??"").replaceAll(/H+/g,a??"").replaceAll("MSS",i??"").replaceAll(/M+/g,s??"").replaceAll(/S+/g,r??"").replaceAll(/^\D+/g,"").replaceAll(/\D+$/g,"")}const K={day:31,month:12,year:9999},Ee=new Date("0001-01-01"),xe=new Date("9999-12-31"),Te=[":","."];function Ae({dateString:t,dateModeTemplate:e,dateSegmentsSeparator:n,offset:a,selection:[s,r]}){const i=C(t,e),l=Object.entries(i),o={};for(const[d,h]of l){const p=E(o,{dateMode:e}),S=K[d],f=p.length&&n.length,v=a+p.length+f+V(e)[d],y=v>=s&&v===r;if(y&&Number(h)>Number(S))return{validatedDateString:"",updatedSelection:[s,r]};if(y&&Number(h)<1)return{validatedDateString:"",updatedSelection:[s,r]};o[d]=h}const c=E(o,{dateMode:e}),u=c.length-t.length;return{validatedDateString:c,updatedSelection:[s+u,r+u]}}const Z=/[\\^$.*+?()[\]{}|]/g,ke=new RegExp(Z.source);function P(t){return t&&ke.test(t)?t.replaceAll(Z,"\\$&"):t}function L(t,e,n=0){return Number(t.padEnd(e.length,"0"))<=Number(e)?{validatedSegmentValue:t,prefixedZeroesCount:n}:t.endsWith("0")?L(`0${t.slice(0,e.length-1)}`,e,n+1):L(`${t.slice(0,e.length-1)}0`,e,n)}function F(t){return t.replaceAll(/[-]/g,e=>String.fromCharCode(e.charCodeAt(0)-65248))}function Ie({dateModeTemplate:t,dateSegmentSeparator:e,splitFn:n,uniteFn:a}){return({value:s,selection:r})=>{var i;const[l,o]=r,{dateStrings:c,restPart:u=""}=n(s),d=[];let h=0;c.forEach(S=>{const f=C(S,t),v=Object.entries(f).reduce((y,[x,_])=>{const{validatedSegmentValue:U,prefixedZeroesCount:X}=L(_,`${K[x]}`);return h+=X,Object.assign(Object.assign({},y),{[x]:U})},{});d.push(E(v,{dateMode:t}))});const p=a(d,s)+(!((i=c[c.length-1])===null||i===void 0)&&i.endsWith(e)?e:"")+u;return h&&p.slice(o+h,o+h+e.length)===e&&(h+=e.length),{selection:[l+h,o+h],value:p}}}function Me(){return({elementState:t,data:e})=>{const{value:n,selection:a}=t;return{elementState:{selection:a,value:F(n)},data:F(e)}}}function De(t,e){const n=V(e);return Object.fromEntries(Object.entries(t).map(([a,s])=>{const r=n[a];return[a,s.length===r&&s.match(/^0+$/)?"1".padStart(r,"0"):s]}))}function Le({dateModeTemplate:t,min:e=Ee,max:n=xe,rangeSeparator:a="",dateSegmentSeparator:s="."}){return({value:r,selection:i})=>{const l=a&&r.endsWith(a),o=W(r,t,a);let c="";for(const u of o){c+=c?a:"";const d=C(u,t);if(!we(u,t)){const S=De(d,t),f=E(S,{dateMode:t}),v=u.endsWith(s)?s:"";c+=f+v;continue}const h=be(d),p=fe(h,e,n);c+=E(Se(p),{dateMode:t})}return{selection:i,value:c+(l?a:"")}}}function $e({dateModeTemplate:t,dateSegmentsSeparator:e,rangeSeparator:n="",dateTimeSeparator:a=z}){return({elementState:s,data:r})=>{const i=n?new RegExp(`${n}|-`):a,l=r.split(i),o=r.includes(a)?[l[0]]:l;if(o.every(c=>c.trim().split(/\D/).filter(Boolean).length===t.split(e).length)){const c=o.map(u=>Be(u,t,e)).join(n);return{elementState:s,data:`${c}${r.includes(a)&&a+l[1]||""}`}}return{elementState:s,data:r}}}function Be(t,e,n){const a=t.split(/\D/).filter(Boolean),s=e.split(n);return a.map((r,i)=>i===s.length-1?r:r.padStart(s[i].length,"0")).join(n)}function Ce({dateModeTemplate:t,dateSegmentsSeparator:e,rangeSeparator:n=""}){return({elementState:a,data:s})=>{const{value:r,selection:i}=a;if(s===e)return{elementState:a,data:i[0]===r.length?s:""};const l=s.replaceAll(new RegExp(`[^\\d${P(e)}${n}]`,"g"),"");if(!l)return{elementState:a,data:""};const[o,c]=i;let u=c+s.length;const d=r.slice(0,o)+l+r.slice(u),h=W(d,t,n);let p="";const S=!!n&&d.includes(n);for(const v of h){const{validatedDateString:y,updatedSelection:x}=Ae({dateString:v,dateModeTemplate:t,dateSegmentsSeparator:e,offset:p.length,selection:[o,u]});if(v&&!y)return{elementState:a,data:""};u=x[1],p+=S&&!p?y+n:y}const f=p.slice(o,u);return{elementState:{selection:i,value:p.slice(0,o)+f.split(e).map(v=>"0".repeat(v.length)).join(e)+p.slice(u)},data:f}}}function Oe(){return({elementState:t},e)=>{const{value:n,selection:a}=t;if(!n||Re(n,a))return{elementState:t};const[s,r]=a,i=n.slice(s,r).replaceAll(/\d/g,"0"),l=n.slice(0,s)+i+n.slice(r);return e==="validation"||e==="insert"&&s===r?{elementState:{selection:a,value:l}}:{elementState:{selection:e==="deleteBackward"||e==="insert"?[s,s]:[r,r],value:l}}}}function Re(t,[e,n]){return n===t.length}function je({mode:t,separator:e=".",max:n,min:a}){const s=t.split("/").join(e);return Object.assign(Object.assign({},B),{mask:Array.from(s).map(r=>e.includes(r)?r:/\d/),overwriteMode:"replace",preprocessors:[Me(),Oe(),$e({dateModeTemplate:s,dateSegmentsSeparator:e}),Ce({dateModeTemplate:s,dateSegmentsSeparator:e})],postprocessors:[Ie({dateModeTemplate:s,dateSegmentSeparator:e,splitFn:r=>({dateStrings:[r]}),uniteFn:([r])=>r}),Le({min:a,max:n,dateModeTemplate:s,dateSegmentSeparator:e})]})}new RegExp(`[${Te.map(P).join("")}]$`);const Fe=/^(?:\d{4}[ -]?){0,3}\d{0,4}$/,m={visa:{final:/^4(?:\d{3}[- ]?){3}\d{3,4}$/,start:/^4/,length:/^4\d{0,15}$/},mastercard:{final:/^5[1-5]\d{3}[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}$/,start:/^5[1-5]/,length:/^5[1-5]\d{0,15}$/},amex:{final:/^3[47]\d{2}[- ]?\d{6}[- ]?\d{5}$/,start:/^3[47]/,length:/^3[47]\d{0,15}$/},discover:{final:/^(6011|65|64[4-9])\d{4}[- ]?\d{4}[- ]?\d{4}$/,start:/^(6011|65|64[4-9])/,length:/^(6011|65|64[4-9])\d{0,15}$/},diners:{final:/^(30[0-5]|36|38|39)\d{4}[- ]?\d{4}[- ]?\d{4}$/,start:/^(30[0-5]|36|38|39)/,length:/^(30[0-5]|36|38|39)\d{0,14}$/},jcb:{final:/^(2131|1800|35[0-9]{3})\d{4}[- ]?\d{4}[- ]?\d{4}$/,start:/^(2131|1800|35[0-9]{3})/,length:/^(2131|1800|35[0-9]{3})\d{0,15}$/}};var $,Y;class Ne{constructor(e){ee(this,$),this.options=e}mount(){return this.number=this.options.fields.card.number instanceof HTMLInputElement?this.options.fields.card.number:document.querySelector(this.options.fields.card.number),this.date=this.options.fields.card.date instanceof HTMLInputElement?this.options.fields.card.date:document.querySelector(this.options.fields.card.date),this.cvv=this.options.fields.card.cvv instanceof HTMLInputElement?this.options.fields.card.cvv:document.querySelector(this.options.fields.card.cvv),te(this,$,Y).call(this),this}check(){const e=m.visa.final.test(this.number.value)||m.mastercard.final.test(this.number.value)||m.amex.final.test(this.number.value)||m.discover.final.test(this.number.value)||m.diners.final.test(this.number.value)||m.jcb.final.test(this.number.value),n=new RegExp("^(0[1-9]|1[0-2])/(?:\\d{2})$").test(this.date.value),a=new RegExp("^\\d{3}$").test(this.cvv.value);return{valid:e&&n&&a,number:{valid:e,value:this.number.value},date:{valid:n,value:this.date.value},cvv:{valid:a,value:this.cvv.value}}}type(){return m.visa.start.test(this.number.value)?"visa":m.mastercard.start.test(this.number.value)?"mastercard":m.amex.start.test(this.number.value)?"amex":m.discover.start.test(this.number.value)?"discover":m.diners.start.test(this.number.value)?"diners":m.jcb.start.test(this.number.value)?"jcb":"unknown"}value(e){if(e==="number")return this.number.value;if(e==="date")return this.date.value;if(e==="year"){const[,n]=this.date.value.split("/");return n}if(e==="month"){const[n]=this.date.value.split("/");return n}return e==="cvv"?this.cvv.value:null}}$=new WeakSet,Y=function(){new M(this.number,{mask:t=>m.visa.start.test(t.value)?new RegExp(m.visa.length):m.mastercard.start.test(t.value)?new RegExp(m.mastercard.length):m.amex.start.test(t.value)?new RegExp(m.amex.length):m.discover.start.test(t.value)?new RegExp(m.discover.length):m.diners.start.test(t.value)?new RegExp(m.diners.length):m.jcb.start.test(t.value)?new RegExp(m.jcb.length):new RegExp(Fe)}),new M(this.date,je({mode:"mm/yy",separator:"/"})),new M(this.cvv,{mask:[/\d/,/\d/,/\d/]})};/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/function qe(...t){return new Promise(e=>{if(!t.length){e([]);return}const n=t.map(s=>document.querySelector(s)).filter(Boolean);if(n.length===t.length){e(n);return}const a=new MutationObserver(()=>{const s=t.map(r=>document.querySelector(r)).filter(Boolean);s.length===t.length&&(a.disconnect(),e(s))});a.observe(document.body,{childList:!0,subtree:!0})})}function He(){const t=document.querySelector('meta[name="instant-payment"]');return!!(t&&t instanceof HTMLMetaElement&&t.content==="yes")}/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/class Ve{constructor(e,n){T(this,"handleAuthorization",()=>{var r,i,l,o;if(this.cvvRequired=="1"&&document.getElementById("cvv").value.length<3){const c=document.getElementById("errors");c&&(c.innerText="CVV is required",c.style.display="block"),document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden");return}var e={};e.clientKey=this.publicKey,e.apiLoginID=this.loginId;var n={};n.cardNumber=(r=this.sc.value("number"))==null?void 0:r.replace(/[^\d]/g,""),n.month=(i=this.sc.value("month"))==null?void 0:i.replace(/[^\d]/g,""),n.year=`20${(l=this.sc.value("year"))==null?void 0:l.replace(/[^\d]/g,"")}`,n.cardCode=(o=this.sc.value("cvv"))==null?void 0:o.replace(/[^\d]/g,"");var a={};return a.authData=e,a.cardData=n,document.getElementById("pay-now")&&(document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden")),Accept.dispatchData(a,this.responseHandler),!1});T(this,"responseHandler",e=>{if(e.messages.resultCode==="Error"){var n=0;const a=document.getElementById("errors");a&&(a.innerText=`${e.messages.message[n].code}: ${e.messages.message[n].text}`,a.style.display="block"),document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden")}else if(e.messages.resultCode==="Ok"){document.getElementById("dataDescriptor").value=e.opaqueData.dataDescriptor,document.getElementById("dataValue").value=e.opaqueData.dataValue;let a=document.querySelector("input[name=token-billing-checkbox]:checked");a&&(document.getElementById("store_card").value=a.value),document.getElementById("server_response").submit()}return!1});T(this,"handle",()=>{Array.from(document.getElementsByClassName("toggle-payment-with-token")).forEach(a=>a.addEventListener("click",s=>{document.getElementById("save-card--container").style.display="none",document.getElementById("authorize--credit-card-container").style.display="none",document.getElementById("token").value=s.target.dataset.token}));let e=document.getElementById("toggle-payment-with-credit-card");e&&e.addEventListener("click",()=>{document.getElementById("save-card--container").style.display="grid",document.getElementById("authorize--credit-card-container").style.display="flex",document.getElementById("token").value=null});let n=document.getElementById("pay-now");return n&&n.addEventListener("click",a=>{let s=document.getElementById("token");s.value?this.handlePayNowAction(s.value):this.handleAuthorization()}),this});this.publicKey=e,this.loginId=n,this.cardHolderName=document.getElementById("cardholder_name"),this.sc=new Ne({fields:{card:{number:"#number",date:"#date",cvv:"#cvv"}}}),this.sc.mount(),this.cvvRequired=document.querySelector('meta[name="authnet-require-cvv"]').content}handlePayNowAction(e){document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),document.getElementById("token").value=e,document.getElementById("server_response").submit()}}function N(){const t=document.querySelector('meta[name="authorize-public-key"]').content,e=document.querySelector('meta[name="authorize-login-id"]').content;new Ve(t,e).handle()}He()?N():qe("#authorize-net-credit-card-payment").then(()=>N());export{Ne as $,He as i,qe as w};