@mercoa/react 0.0.49-rc1 → 0.0.49-rc2

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.umd.js CHANGED
@@ -42,7 +42,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
42
42
  */function Point(W,re,oe){this.x=W,this.y=re,this.time=oe||new Date().getTime()}Point.prototype.velocityFrom=function(W){return this.time!==W.time?this.distanceTo(W)/(this.time-W.time):1},Point.prototype.distanceTo=function(W){return Math.sqrt(Math.pow(this.x-W.x,2)+Math.pow(this.y-W.y,2))},Point.prototype.equals=function(W){return this.x===W.x&&this.y===W.y&&this.time===W.time};function Bezier(W,re,oe,ie){this.startPoint=W,this.control1=re,this.control2=oe,this.endPoint=ie}Bezier.prototype.length=function(){for(var W=10,re=0,oe=void 0,ie=void 0,pe=0;pe<=W;pe+=1){var nr=pe/W,or=this._point(nr,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),ar=this._point(nr,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(pe>0){var ir=or-oe,sr=ar-ie;re+=Math.sqrt(ir*ir+sr*sr)}oe=or,ie=ar}return re},Bezier.prototype._point=function(W,re,oe,ie,pe){return re*(1-W)*(1-W)*(1-W)+3*oe*(1-W)*(1-W)*W+3*ie*(1-W)*W*W+pe*W*W*W};function throttle(W,re,oe){var ie,pe,nr,or=null,ar=0;oe||(oe={});var ir=function(){ar=oe.leading===!1?0:Date.now(),or=null,nr=W.apply(ie,pe),or||(ie=pe=null)};return function(){var sr=Date.now();!ar&&oe.leading===!1&&(ar=sr);var cr=re-(sr-ar);return ie=this,pe=arguments,cr<=0||cr>re?(or&&(clearTimeout(or),or=null),ar=sr,nr=W.apply(ie,pe),or||(ie=pe=null)):!or&&oe.trailing!==!1&&(or=setTimeout(ir,cr)),nr}}function SignaturePad(W,re){var oe=this,ie=re||{};this.velocityFilterWeight=ie.velocityFilterWeight||.7,this.minWidth=ie.minWidth||.5,this.maxWidth=ie.maxWidth||2.5,this.throttle="throttle"in ie?ie.throttle:16,this.minDistance="minDistance"in ie?ie.minDistance:5,this.throttle?this._strokeMoveUpdate=throttle(SignaturePad.prototype._strokeUpdate,this.throttle):this._strokeMoveUpdate=SignaturePad.prototype._strokeUpdate,this.dotSize=ie.dotSize||function(){return(this.minWidth+this.maxWidth)/2},this.penColor=ie.penColor||"black",this.backgroundColor=ie.backgroundColor||"rgba(0,0,0,0)",this.onBegin=ie.onBegin,this.onEnd=ie.onEnd,this._canvas=W,this._ctx=W.getContext("2d"),this.clear(),this._handleMouseDown=function(pe){pe.which===1&&(oe._mouseButtonDown=!0,oe._strokeBegin(pe))},this._handleMouseMove=function(pe){oe._mouseButtonDown&&oe._strokeMoveUpdate(pe)},this._handleMouseUp=function(pe){pe.which===1&&oe._mouseButtonDown&&(oe._mouseButtonDown=!1,oe._strokeEnd(pe))},this._handleTouchStart=function(pe){if(pe.targetTouches.length===1){var nr=pe.changedTouches[0];oe._strokeBegin(nr)}},this._handleTouchMove=function(pe){pe.preventDefault();var nr=pe.targetTouches[0];oe._strokeMoveUpdate(nr)},this._handleTouchEnd=function(pe){var nr=pe.target===oe._canvas;nr&&(pe.preventDefault(),oe._strokeEnd(pe))},this.on()}SignaturePad.prototype.clear=function(){var W=this._ctx,re=this._canvas;W.fillStyle=this.backgroundColor,W.clearRect(0,0,re.width,re.height),W.fillRect(0,0,re.width,re.height),this._data=[],this._reset(),this._isEmpty=!0},SignaturePad.prototype.fromDataURL=function(W){var re=this,oe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ie=new Image,pe=oe.ratio||window.devicePixelRatio||1,nr=oe.width||this._canvas.width/pe,or=oe.height||this._canvas.height/pe;this._reset(),ie.src=W,ie.onload=function(){re._ctx.drawImage(ie,0,0,nr,or)},this._isEmpty=!1},SignaturePad.prototype.toDataURL=function(W){var re;switch(W){case"image/svg+xml":return this._toSVG();default:for(var oe=arguments.length,ie=Array(oe>1?oe-1:0),pe=1;pe<oe;pe++)ie[pe-1]=arguments[pe];return(re=this._canvas).toDataURL.apply(re,[W].concat(ie))}},SignaturePad.prototype.on=function(){this._handleMouseEvents(),this._handleTouchEvents()},SignaturePad.prototype.off=function(){this._canvas.removeEventListener("mousedown",this._handleMouseDown),this._canvas.removeEventListener("mousemove",this._handleMouseMove),document.removeEventListener("mouseup",this._handleMouseUp),this._canvas.removeEventListener("touchstart",this._handleTouchStart),this._canvas.removeEventListener("touchmove",this._handleTouchMove),this._canvas.removeEventListener("touchend",this._handleTouchEnd)},SignaturePad.prototype.isEmpty=function(){return this._isEmpty},SignaturePad.prototype._strokeBegin=function(W){this._data.push([]),this._reset(),this._strokeUpdate(W),typeof this.onBegin=="function"&&this.onBegin(W)},SignaturePad.prototype._strokeUpdate=function(W){var re=W.clientX,oe=W.clientY,ie=this._createPoint(re,oe),pe=this._data[this._data.length-1],nr=pe&&pe[pe.length-1],or=nr&&ie.distanceTo(nr)<this.minDistance;if(!(nr&&or)){var ar=this._addPoint(ie),ir=ar.curve,sr=ar.widths;ir&&sr&&this._drawCurve(ir,sr.start,sr.end),this._data[this._data.length-1].push({x:ie.x,y:ie.y,time:ie.time,color:this.penColor})}},SignaturePad.prototype._strokeEnd=function(W){var re=this.points.length>2,oe=this.points[0];if(!re&&oe&&this._drawDot(oe),oe){var ie=this._data[this._data.length-1],pe=ie[ie.length-1];oe.equals(pe)||ie.push({x:oe.x,y:oe.y,time:oe.time,color:this.penColor})}typeof this.onEnd=="function"&&this.onEnd(W)},SignaturePad.prototype._handleMouseEvents=function(){this._mouseButtonDown=!1,this._canvas.addEventListener("mousedown",this._handleMouseDown),this._canvas.addEventListener("mousemove",this._handleMouseMove),document.addEventListener("mouseup",this._handleMouseUp)},SignaturePad.prototype._handleTouchEvents=function(){this._canvas.style.msTouchAction="none",this._canvas.style.touchAction="none",this._canvas.addEventListener("touchstart",this._handleTouchStart),this._canvas.addEventListener("touchmove",this._handleTouchMove),this._canvas.addEventListener("touchend",this._handleTouchEnd)},SignaturePad.prototype._reset=function(){this.points=[],this._lastVelocity=0,this._lastWidth=(this.minWidth+this.maxWidth)/2,this._ctx.fillStyle=this.penColor},SignaturePad.prototype._createPoint=function(W,re,oe){var ie=this._canvas.getBoundingClientRect();return new Point(W-ie.left,re-ie.top,oe||new Date().getTime())},SignaturePad.prototype._addPoint=function(W){var re=this.points,oe=void 0;if(re.push(W),re.length>2){re.length===3&&re.unshift(re[0]),oe=this._calculateCurveControlPoints(re[0],re[1],re[2]);var ie=oe.c2;oe=this._calculateCurveControlPoints(re[1],re[2],re[3]);var pe=oe.c1,nr=new Bezier(re[1],ie,pe,re[2]),or=this._calculateCurveWidths(nr);return re.shift(),{curve:nr,widths:or}}return{}},SignaturePad.prototype._calculateCurveControlPoints=function(W,re,oe){var ie=W.x-re.x,pe=W.y-re.y,nr=re.x-oe.x,or=re.y-oe.y,ar={x:(W.x+re.x)/2,y:(W.y+re.y)/2},ir={x:(re.x+oe.x)/2,y:(re.y+oe.y)/2},sr=Math.sqrt(ie*ie+pe*pe),cr=Math.sqrt(nr*nr+or*or),lr=ar.x-ir.x,ur=ar.y-ir.y,fr=cr/(sr+cr),dr={x:ir.x+lr*fr,y:ir.y+ur*fr},mr=re.x-dr.x,pr=re.y-dr.y;return{c1:new Point(ar.x+mr,ar.y+pr),c2:new Point(ir.x+mr,ir.y+pr)}},SignaturePad.prototype._calculateCurveWidths=function(W){var re=W.startPoint,oe=W.endPoint,ie={start:null,end:null},pe=this.velocityFilterWeight*oe.velocityFrom(re)+(1-this.velocityFilterWeight)*this._lastVelocity,nr=this._strokeWidth(pe);return ie.start=this._lastWidth,ie.end=nr,this._lastVelocity=pe,this._lastWidth=nr,ie},SignaturePad.prototype._strokeWidth=function(W){return Math.max(this.maxWidth/(W+1),this.minWidth)},SignaturePad.prototype._drawPoint=function(W,re,oe){var ie=this._ctx;ie.moveTo(W,re),ie.arc(W,re,oe,0,2*Math.PI,!1),this._isEmpty=!1},SignaturePad.prototype._drawCurve=function(W,re,oe){var ie=this._ctx,pe=oe-re,nr=Math.floor(W.length());ie.beginPath();for(var or=0;or<nr;or+=1){var ar=or/nr,ir=ar*ar,sr=ir*ar,cr=1-ar,lr=cr*cr,ur=lr*cr,fr=ur*W.startPoint.x;fr+=3*lr*ar*W.control1.x,fr+=3*cr*ir*W.control2.x,fr+=sr*W.endPoint.x;var dr=ur*W.startPoint.y;dr+=3*lr*ar*W.control1.y,dr+=3*cr*ir*W.control2.y,dr+=sr*W.endPoint.y;var mr=re+sr*pe;this._drawPoint(fr,dr,mr)}ie.closePath(),ie.fill()},SignaturePad.prototype._drawDot=function(W){var re=this._ctx,oe=typeof this.dotSize=="function"?this.dotSize():this.dotSize;re.beginPath(),this._drawPoint(W.x,W.y,oe),re.closePath(),re.fill()},SignaturePad.prototype._fromData=function(W,re,oe){for(var ie=0;ie<W.length;ie+=1){var pe=W[ie];if(pe.length>1)for(var nr=0;nr<pe.length;nr+=1){var or=pe[nr],ar=new Point(or.x,or.y,or.time),ir=or.color;if(nr===0)this.penColor=ir,this._reset(),this._addPoint(ar);else if(nr!==pe.length-1){var sr=this._addPoint(ar),cr=sr.curve,lr=sr.widths;cr&&lr&&re(cr,lr,ir)}}else{this._reset();var ur=pe[0];oe(ur)}}},SignaturePad.prototype._toSVG=function(){var W=this,re=this._data,oe=this._canvas,ie=Math.max(window.devicePixelRatio||1,1),pe=0,nr=0,or=oe.width/ie,ar=oe.height/ie,ir=document.createElementNS("http://www.w3.org/2000/svg","svg");ir.setAttributeNS(null,"width",oe.width),ir.setAttributeNS(null,"height",oe.height),this._fromData(re,function(hr,yr,gr){var wr=document.createElement("path");if(!isNaN(hr.control1.x)&&!isNaN(hr.control1.y)&&!isNaN(hr.control2.x)&&!isNaN(hr.control2.y)){var br="M "+hr.startPoint.x.toFixed(3)+","+hr.startPoint.y.toFixed(3)+" "+("C "+hr.control1.x.toFixed(3)+","+hr.control1.y.toFixed(3)+" ")+(hr.control2.x.toFixed(3)+","+hr.control2.y.toFixed(3)+" ")+(hr.endPoint.x.toFixed(3)+","+hr.endPoint.y.toFixed(3));wr.setAttribute("d",br),wr.setAttribute("stroke-width",(yr.end*2.25).toFixed(3)),wr.setAttribute("stroke",gr),wr.setAttribute("fill","none"),wr.setAttribute("stroke-linecap","round"),ir.appendChild(wr)}},function(hr){var yr=document.createElement("circle"),gr=typeof W.dotSize=="function"?W.dotSize():W.dotSize;yr.setAttribute("r",gr),yr.setAttribute("cx",hr.x),yr.setAttribute("cy",hr.y),yr.setAttribute("fill",hr.color),ir.appendChild(yr)});var sr="data:image/svg+xml;base64,",cr='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"'+(' viewBox="'+pe+" "+nr+" "+or+" "+ar+'"')+(' width="'+or+'"')+(' height="'+ar+'"')+">",lr=ir.innerHTML;if(lr===void 0){var ur=document.createElement("dummy"),fr=ir.childNodes;ur.innerHTML="";for(var dr=0;dr<fr.length;dr+=1)ur.appendChild(fr[dr].cloneNode(!0));lr=ur.innerHTML}var mr="</svg>",pr=cr+lr+mr;return sr+btoa(pr)},SignaturePad.prototype.fromData=function(W){var re=this;this.clear(),this._fromData(W,function(oe,ie){return re._drawCurve(oe,ie.start,ie.end)},function(oe){return re._drawDot(oe)}),this._data=W},SignaturePad.prototype.toData=function(){return this._data};const signature_pad=Object.freeze(Object.defineProperty({__proto__:null,default:SignaturePad},Symbol.toStringTag,{value:"Module"})),require$$2=getAugmentedNamespace(signature_pad);var build={exports:{}},hasRequiredBuild;function requireBuild(){return hasRequiredBuild||(hasRequiredBuild=1,function(W,re){(function(oe,ie){W.exports=ie()})(commonjsGlobal$1,function(){return function(oe){function ie(nr){if(pe[nr])return pe[nr].exports;var or=pe[nr]={exports:{},id:nr,loaded:!1};return oe[nr].call(or.exports,or,or.exports,ie),or.loaded=!0,or.exports}var pe={};return ie.m=oe,ie.c=pe,ie.p="",ie(0)}([function(oe,ie){function pe(sr){var cr=sr.getContext("2d"),lr=sr.width,ur=sr.height,fr=cr.getImageData(0,0,lr,ur).data,dr=ar(!0,lr,ur,fr),mr=ar(!1,lr,ur,fr),pr=ir(!0,lr,ur,fr),hr=ir(!1,lr,ur,fr),yr=hr-pr+1,gr=mr-dr+1,wr=cr.getImageData(pr,dr,yr,gr);return sr.width=yr,sr.height=gr,cr.clearRect(0,0,yr,gr),cr.putImageData(wr,0,0),sr}function nr(sr,cr,lr,ur){return{red:ur[4*(lr*cr+sr)],green:ur[4*(lr*cr+sr)+1],blue:ur[4*(lr*cr+sr)+2],alpha:ur[4*(lr*cr+sr)+3]}}function or(sr,cr,lr,ur){return nr(sr,cr,lr,ur).alpha}function ar(sr,cr,lr,ur){for(var fr=sr?1:-1,dr=sr?0:lr-1,mr=dr;sr?mr<lr:mr>-1;mr+=fr)for(var pr=0;pr<cr;pr++)if(or(pr,mr,cr,ur))return mr;return null}function ir(sr,cr,lr,ur){for(var fr=sr?1:-1,dr=sr?0:cr-1,mr=dr;sr?mr<cr:mr>-1;mr+=fr)for(var pr=0;pr<lr;pr++)if(or(mr,pr,cr,ur))return mr;return null}Object.defineProperty(ie,"__esModule",{value:!0}),ie.default=pe}])})}(build)),build.exports}(function(W,re){(function(oe,ie){W.exports=ie(propTypesExports,React,require$$2,requireBuild())})(commonjsGlobal$1,function(oe,ie,pe,nr){return function(or){function ar(sr){if(ir[sr])return ir[sr].exports;var cr=ir[sr]={exports:{},id:sr,loaded:!1};return or[sr].call(cr.exports,cr,cr.exports,ar),cr.loaded=!0,cr.exports}var ir={};return ar.m=or,ar.c=ir,ar.p="",ar(0)}([function(or,ar,ir){function sr(vr){return vr&&vr.__esModule?vr:{default:vr}}function cr(vr,Or){var Sr={};for(var Cr in vr)Or.indexOf(Cr)>=0||Object.prototype.hasOwnProperty.call(vr,Cr)&&(Sr[Cr]=vr[Cr]);return Sr}function lr(vr,Or){if(!(vr instanceof Or))throw new TypeError("Cannot call a class as a function")}function ur(vr,Or){if(!vr)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!Or||typeof Or!="object"&&typeof Or!="function"?vr:Or}function fr(vr,Or){if(typeof Or!="function"&&Or!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof Or);vr.prototype=Object.create(Or&&Or.prototype,{constructor:{value:vr,enumerable:!1,writable:!0,configurable:!0}}),Or&&(Object.setPrototypeOf?Object.setPrototypeOf(vr,Or):vr.__proto__=Or)}Object.defineProperty(ar,"__esModule",{value:!0});var dr=Object.assign||function(vr){for(var Or=1;Or<arguments.length;Or++){var Sr=arguments[Or];for(var Cr in Sr)Object.prototype.hasOwnProperty.call(Sr,Cr)&&(vr[Cr]=Sr[Cr])}return vr},mr=function(){function vr(Or,Sr){for(var Cr=0;Cr<Sr.length;Cr++){var Ir=Sr[Cr];Ir.enumerable=Ir.enumerable||!1,Ir.configurable=!0,"value"in Ir&&(Ir.writable=!0),Object.defineProperty(Or,Ir.key,Ir)}}return function(Or,Sr,Cr){return Sr&&vr(Or.prototype,Sr),Cr&&vr(Or,Cr),Or}}(),pr=ir(1),hr=sr(pr),yr=ir(2),gr=sr(yr),wr=ir(3),br=sr(wr),_r=ir(4),Mr=sr(_r),$r=function(vr){function Or(){var Sr,Cr,Ir,Dr;lr(this,Or);for(var qr=arguments.length,Zr=Array(qr),Yr=0;Yr<qr;Yr++)Zr[Yr]=arguments[Yr];return Cr=Ir=ur(this,(Sr=Or.__proto__||Object.getPrototypeOf(Or)).call.apply(Sr,[this].concat(Zr))),Ir._sigPad=null,Ir._excludeOurProps=function(){var en=Ir.props,Jr=(en.canvasProps,en.clearOnResize,cr(en,["canvasProps","clearOnResize"]));return Jr},Ir.getCanvas=function(){return Ir._canvas},Ir.getTrimmedCanvas=function(){var en=document.createElement("canvas");return en.width=Ir._canvas.width,en.height=Ir._canvas.height,en.getContext("2d").drawImage(Ir._canvas,0,0),(0,Mr.default)(en)},Ir.getSignaturePad=function(){return Ir._sigPad},Ir._checkClearOnResize=function(){Ir.props.clearOnResize&&Ir._resizeCanvas()},Ir._resizeCanvas=function(){var en=Ir.props.canvasProps||{},Jr=en.width,kr=en.height;if(!Jr||!kr){var on=Ir._canvas,Xr=Math.max(window.devicePixelRatio||1,1);Jr||(on.width=on.offsetWidth*Xr),kr||(on.height=on.offsetHeight*Xr),on.getContext("2d").scale(Xr,Xr),Ir.clear()}},Ir.on=function(){return window.addEventListener("resize",Ir._checkClearOnResize),Ir._sigPad.on()},Ir.off=function(){return window.removeEventListener("resize",Ir._checkClearOnResize),Ir._sigPad.off()},Ir.clear=function(){return Ir._sigPad.clear()},Ir.isEmpty=function(){return Ir._sigPad.isEmpty()},Ir.fromDataURL=function(en,Jr){return Ir._sigPad.fromDataURL(en,Jr)},Ir.toDataURL=function(en,Jr){return Ir._sigPad.toDataURL(en,Jr)},Ir.fromData=function(en){return Ir._sigPad.fromData(en)},Ir.toData=function(){return Ir._sigPad.toData()},Dr=Cr,ur(Ir,Dr)}return fr(Or,vr),mr(Or,[{key:"componentDidMount",value:function(){this._sigPad=new br.default(this._canvas,this._excludeOurProps()),this._resizeCanvas(),this.on()}},{key:"componentWillUnmount",value:function(){this.off()}},{key:"componentDidUpdate",value:function(){Object.assign(this._sigPad,this._excludeOurProps())}},{key:"render",value:function(){var Sr=this,Cr=this.props.canvasProps;return gr.default.createElement("canvas",dr({ref:function(Ir){Sr._canvas=Ir}},Cr))}}]),Or}(yr.Component);$r.propTypes={velocityFilterWeight:hr.default.number,minWidth:hr.default.number,maxWidth:hr.default.number,minDistance:hr.default.number,dotSize:hr.default.oneOfType([hr.default.number,hr.default.func]),penColor:hr.default.string,throttle:hr.default.number,onEnd:hr.default.func,onBegin:hr.default.func,canvasProps:hr.default.object,clearOnResize:hr.default.bool},$r.defaultProps={clearOnResize:!0},ar.default=$r},function(or,ar){or.exports=oe},function(or,ar){or.exports=ie},function(or,ar){or.exports=pe},function(or,ar){or.exports=nr}])})})(build$1);var buildExports=build$1.exports;const SignatureCanvas=getDefaultExportFromCjs(buildExports);function Cache(W){this._maxSize=W,this.clear()}Cache.prototype.clear=function(){this._size=0,this._values=Object.create(null)},Cache.prototype.get=function(W){return this._values[W]},Cache.prototype.set=function(W,re){return this._size>=this._maxSize&&this.clear(),W in this._values||this._size++,this._values[W]=re};var SPLIT_REGEX=/[^.^\]^[]+|(?=\[\]|\.\.)/g,DIGIT_REGEX=/^\d+$/,LEAD_DIGIT_REGEX=/^\d/,SPEC_CHAR_REGEX=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,CLEAN_QUOTES_REGEX=/^\s*(['"]?)(.*?)(\1)\s*$/,MAX_CACHE_SIZE=512,pathCache=new Cache(MAX_CACHE_SIZE),setCache=new Cache(MAX_CACHE_SIZE),getCache=new Cache(MAX_CACHE_SIZE),propertyExpr={Cache,split,normalizePath,setter:function(W){var re=normalizePath(W);return setCache.get(W)||setCache.set(W,function(ie,pe){for(var nr=0,or=re.length,ar=ie;nr<or-1;){var ir=re[nr];if(ir==="__proto__"||ir==="constructor"||ir==="prototype")return ie;ar=ar[re[nr++]]}ar[re[nr]]=pe})},getter:function(W,re){var oe=normalizePath(W);return getCache.get(W)||getCache.set(W,function(pe){for(var nr=0,or=oe.length;nr<or;)if(pe!=null||!re)pe=pe[oe[nr++]];else return;return pe})},join:function(W){return W.reduce(function(re,oe){return re+(isQuoted(oe)||DIGIT_REGEX.test(oe)?"["+oe+"]":(re?".":"")+oe)},"")},forEach:function(W,re,oe){forEach(Array.isArray(W)?W:split(W),re,oe)}};function normalizePath(W){return pathCache.get(W)||pathCache.set(W,split(W).map(function(re){return re.replace(CLEAN_QUOTES_REGEX,"$2")}))}function split(W){return W.match(SPLIT_REGEX)||[""]}function forEach(W,re,oe){var ie=W.length,pe,nr,or,ar;for(nr=0;nr<ie;nr++)pe=W[nr],pe&&(shouldBeQuoted(pe)&&(pe='"'+pe+'"'),ar=isQuoted(pe),or=!ar&&/^\d+$/.test(pe),re.call(oe,pe,ar,or,nr,W))}function isQuoted(W){return typeof W=="string"&&W&&["'",'"'].indexOf(W.charAt(0))!==-1}function hasLeadingNumber(W){return W.match(LEAD_DIGIT_REGEX)&&!W.match(DIGIT_REGEX)}function hasSpecialChars(W){return SPEC_CHAR_REGEX.test(W)}function shouldBeQuoted(W){return!isQuoted(W)&&(hasLeadingNumber(W)||hasSpecialChars(W))}const reWords=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,words=W=>W.match(reWords)||[],upperFirst=W=>W[0].toUpperCase()+W.slice(1),join=(W,re)=>words(W).join(re).toLowerCase(),camelCase=W=>words(W).reduce((re,oe)=>`${re}${re?oe[0].toUpperCase()+oe.slice(1).toLowerCase():oe.toLowerCase()}`,""),pascalCase=W=>upperFirst(camelCase(W)),snakeCase=W=>join(W,"_"),kebabCase=W=>join(W,"-"),sentenceCase=W=>upperFirst(join(W," ")),titleCase=W=>words(W).map(upperFirst).join(" ");var tinyCase={words,upperFirst,camelCase,pascalCase,snakeCase,kebabCase,sentenceCase,titleCase},toposort$2={exports:{}};toposort$2.exports=function(W){return toposort(uniqueNodes(W),W)},toposort$2.exports.array=toposort;function toposort(W,re){var oe=W.length,ie=new Array(oe),pe={},nr=oe,or=makeOutgoingEdges(re),ar=makeNodesHash(W);for(re.forEach(function(sr){if(!ar.has(sr[0])||!ar.has(sr[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});nr--;)pe[nr]||ir(W[nr],nr,new Set);return ie;function ir(sr,cr,lr){if(lr.has(sr)){var ur;try{ur=", node was:"+JSON.stringify(sr)}catch{ur=""}throw new Error("Cyclic dependency"+ur)}if(!ar.has(sr))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(sr));if(!pe[cr]){pe[cr]=!0;var fr=or.get(sr)||new Set;if(fr=Array.from(fr),cr=fr.length){lr.add(sr);do{var dr=fr[--cr];ir(dr,ar.get(dr),lr)}while(cr);lr.delete(sr)}ie[--oe]=sr}}}function uniqueNodes(W){for(var re=new Set,oe=0,ie=W.length;oe<ie;oe++){var pe=W[oe];re.add(pe[0]),re.add(pe[1])}return Array.from(re)}function makeOutgoingEdges(W){for(var re=new Map,oe=0,ie=W.length;oe<ie;oe++){var pe=W[oe];re.has(pe[0])||re.set(pe[0],new Set),re.has(pe[1])||re.set(pe[1],new Set),re.get(pe[0]).add(pe[1])}return re}function makeNodesHash(W){for(var re=new Map,oe=0,ie=W.length;oe<ie;oe++)re.set(W[oe],oe);return re}var toposortExports=toposort$2.exports;const toposort$1=getDefaultExportFromCjs(toposortExports),toString$2=Object.prototype.toString,errorToString=Error.prototype.toString,regExpToString=RegExp.prototype.toString,symbolToString$1=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",SYMBOL_REGEXP=/^Symbol\((.*)\)(.*)$/;function printNumber(W){return W!=+W?"NaN":W===0&&1/W<0?"-0":""+W}function printSimpleValue(W,re=!1){if(W==null||W===!0||W===!1)return""+W;const oe=typeof W;if(oe==="number")return printNumber(W);if(oe==="string")return re?`"${W}"`:W;if(oe==="function")return"[Function "+(W.name||"anonymous")+"]";if(oe==="symbol")return symbolToString$1.call(W).replace(SYMBOL_REGEXP,"Symbol($1)");const ie=toString$2.call(W).slice(8,-1);return ie==="Date"?isNaN(W.getTime())?""+W:W.toISOString(W):ie==="Error"||W instanceof Error?"["+errorToString.call(W)+"]":ie==="RegExp"?regExpToString.call(W):null}function printValue(W,re){let oe=printSimpleValue(W,re);return oe!==null?oe:JSON.stringify(W,function(ie,pe){let nr=printSimpleValue(this[ie],re);return nr!==null?nr:pe},2)}function toArray(W){return W==null?[]:[].concat(W)}let _Symbol$toStringTag,_Symbol$hasInstance,_Symbol$toStringTag2,strReg=/\$\{\s*(\w+)\s*\}/g;_Symbol$toStringTag=Symbol.toStringTag;class ValidationErrorNoStack{constructor(re,oe,ie,pe){this.name=void 0,this.message=void 0,this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=void 0,this.inner=void 0,this[_Symbol$toStringTag]="Error",this.name="ValidationError",this.value=oe,this.path=ie,this.type=pe,this.errors=[],this.inner=[],toArray(re).forEach(nr=>{if(ValidationError.isError(nr)){this.errors.push(...nr.errors);const or=nr.inner.length?nr.inner:[nr];this.inner.push(...or)}else this.errors.push(nr)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0]}}_Symbol$hasInstance=Symbol.hasInstance,_Symbol$toStringTag2=Symbol.toStringTag;class ValidationError extends Error{static formatError(re,oe){const ie=oe.label||oe.path||"this";return ie!==oe.path&&(oe=Object.assign({},oe,{path:ie})),typeof re=="string"?re.replace(strReg,(pe,nr)=>printValue(oe[nr])):typeof re=="function"?re(oe):re}static isError(re){return re&&re.name==="ValidationError"}constructor(re,oe,ie,pe,nr){const or=new ValidationErrorNoStack(re,oe,ie,pe);if(nr)return or;super(),this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=[],this.inner=[],this[_Symbol$toStringTag2]="Error",this.name=or.name,this.message=or.message,this.type=or.type,this.value=or.value,this.path=or.path,this.errors=or.errors,this.inner=or.inner,Error.captureStackTrace&&Error.captureStackTrace(this,ValidationError)}static[_Symbol$hasInstance](re){return ValidationErrorNoStack[Symbol.hasInstance](re)||super[Symbol.hasInstance](re)}}let mixed={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:W,type:re,value:oe,originalValue:ie})=>{const pe=ie!=null&&ie!==oe?` (cast from the value \`${printValue(ie,!0)}\`).`:".";return re!=="mixed"?`${W} must be a \`${re}\` type, but the final value was: \`${printValue(oe,!0)}\``+pe:`${W} must match the configured type. The validated value was: \`${printValue(oe,!0)}\``+pe}},string={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",datetime:"${path} must be a valid ISO date-time",datetime_precision:"${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits",datetime_offset:'${path} must be a valid ISO date-time with UTC "Z" timezone',trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},number={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},date={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},boolean={isValue:"${path} field must be ${value}"},object={noUnknown:"${path} field has unspecified keys: ${unknown}"},array={min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"},tuple={notType:W=>{const{path:re,value:oe,spec:ie}=W,pe=ie.types.length;if(Array.isArray(oe)){if(oe.length<pe)return`${re} tuple value has too few items, expected a length of ${pe} but got ${oe.length} for value: \`${printValue(oe,!0)}\``;if(oe.length>pe)return`${re} tuple value has too many items, expected a length of ${pe} but got ${oe.length} for value: \`${printValue(oe,!0)}\``}return ValidationError.formatError(mixed.notType,W)}};Object.assign(Object.create(null),{mixed,string,number,date,object,array,boolean,tuple});const isSchema=W=>W&&W.__isYupSchema__;class Condition{static fromOptions(re,oe){if(!oe.then&&!oe.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:ie,then:pe,otherwise:nr}=oe,or=typeof ie=="function"?ie:(...ar)=>ar.every(ir=>ir===ie);return new Condition(re,(ar,ir)=>{var sr;let cr=or(...ar)?pe:nr;return(sr=cr==null?void 0:cr(ir))!=null?sr:ir})}constructor(re,oe){this.fn=void 0,this.refs=re,this.refs=re,this.fn=oe}resolve(re,oe){let ie=this.refs.map(nr=>nr.getValue(oe==null?void 0:oe.value,oe==null?void 0:oe.parent,oe==null?void 0:oe.context)),pe=this.fn(ie,re,oe);if(pe===void 0||pe===re)return re;if(!isSchema(pe))throw new TypeError("conditions must return a schema object");return pe.resolve(oe)}}const prefixes={context:"$",value:"."};let Reference$1=class{constructor(re,oe={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,typeof re!="string")throw new TypeError("ref must be a string, got: "+re);if(this.key=re.trim(),re==="")throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===prefixes.context,this.isValue=this.key[0]===prefixes.value,this.isSibling=!this.isContext&&!this.isValue;let ie=this.isContext?prefixes.context:this.isValue?prefixes.value:"";this.path=this.key.slice(ie.length),this.getter=this.path&&propertyExpr.getter(this.path,!0),this.map=oe.map}getValue(re,oe,ie){let pe=this.isContext?ie:this.isValue?re:oe;return this.getter&&(pe=this.getter(pe||{})),this.map&&(pe=this.map(pe)),pe}cast(re,oe){return this.getValue(re,oe==null?void 0:oe.parent,oe==null?void 0:oe.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(re){return re&&re.__isYupRef}};Reference$1.prototype.__isYupRef=!0;const isAbsent=W=>W==null;function createValidation(W){function re({value:oe,path:ie="",options:pe,originalValue:nr,schema:or},ar,ir){const{name:sr,test:cr,params:lr,message:ur,skipAbsent:fr}=W;let{parent:dr,context:mr,abortEarly:pr=or.spec.abortEarly,disableStackTrace:hr=or.spec.disableStackTrace}=pe;function yr(Sr){return Reference$1.isRef(Sr)?Sr.getValue(oe,dr,mr):Sr}function gr(Sr={}){const Cr=Object.assign({value:oe,originalValue:nr,label:or.spec.label,path:Sr.path||ie,spec:or.spec,disableStackTrace:Sr.disableStackTrace||hr},lr,Sr.params);for(const Dr of Object.keys(Cr))Cr[Dr]=yr(Cr[Dr]);const Ir=new ValidationError(ValidationError.formatError(Sr.message||ur,Cr),oe,Cr.path,Sr.type||sr,Cr.disableStackTrace);return Ir.params=Cr,Ir}const wr=pr?ar:ir;let br={path:ie,parent:dr,type:sr,from:pe.from,createError:gr,resolve:yr,options:pe,originalValue:nr,schema:or};const _r=Sr=>{ValidationError.isError(Sr)?wr(Sr):Sr?ir(null):wr(gr())},Mr=Sr=>{ValidationError.isError(Sr)?wr(Sr):ar(Sr)};if(fr&&isAbsent(oe))return _r(!0);let vr;try{var Or;if(vr=cr.call(br,oe,br),typeof((Or=vr)==null?void 0:Or.then)=="function"){if(pe.sync)throw new Error(`Validation test of type: "${br.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);return Promise.resolve(vr).then(_r,Mr)}}catch(Sr){Mr(Sr);return}_r(vr)}return re.OPTIONS=W,re}function getIn(W,re,oe,ie=oe){let pe,nr,or;return re?(propertyExpr.forEach(re,(ar,ir,sr)=>{let cr=ir?ar.slice(1,ar.length-1):ar;W=W.resolve({context:ie,parent:pe,value:oe});let lr=W.type==="tuple",ur=sr?parseInt(cr,10):0;if(W.innerType||lr){if(lr&&!sr)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${or}" must contain an index to the tuple element, e.g. "${or}[0]"`);if(oe&&ur>=oe.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${ar}, in the path: ${re}. because there is no value at that index. `);pe=oe,oe=oe&&oe[ur],W=lr?W.spec.types[ur]:W.innerType}if(!sr){if(!W.fields||!W.fields[cr])throw new Error(`The schema does not contain the path: ${re}. (failed at: ${or} which is a type: "${W.type}")`);pe=oe,oe=oe&&oe[cr],W=W.fields[cr]}nr=cr,or=ir?"["+ar+"]":"."+ar}),{schema:W,parent:pe,parentPath:nr}):{parent:pe,parentPath:re,schema:W}}class ReferenceSet extends Set{describe(){const re=[];for(const oe of this.values())re.push(Reference$1.isRef(oe)?oe.describe():oe);return re}resolveAll(re){let oe=[];for(const ie of this.values())oe.push(re(ie));return oe}clone(){return new ReferenceSet(this.values())}merge(re,oe){const ie=this.clone();return re.forEach(pe=>ie.add(pe)),oe.forEach(pe=>ie.delete(pe)),ie}}function clone(W,re=new Map){if(isSchema(W)||!W||typeof W!="object")return W;if(re.has(W))return re.get(W);let oe;if(W instanceof Date)oe=new Date(W.getTime()),re.set(W,oe);else if(W instanceof RegExp)oe=new RegExp(W),re.set(W,oe);else if(Array.isArray(W)){oe=new Array(W.length),re.set(W,oe);for(let ie=0;ie<W.length;ie++)oe[ie]=clone(W[ie],re)}else if(W instanceof Map){oe=new Map,re.set(W,oe);for(const[ie,pe]of W.entries())oe.set(ie,clone(pe,re))}else if(W instanceof Set){oe=new Set,re.set(W,oe);for(const ie of W)oe.add(clone(ie,re))}else if(W instanceof Object){oe={},re.set(W,oe);for(const[ie,pe]of Object.entries(W))oe[ie]=clone(pe,re)}else throw Error(`Unable to clone ${W}`);return oe}class Schema{constructor(re){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new ReferenceSet,this._blacklist=new ReferenceSet,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError(mixed.notType)}),this.type=re.type,this._typeCheck=re.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,disableStackTrace:!1,nullable:!1,optional:!0,coerce:!0},re==null?void 0:re.spec),this.withMutation(oe=>{oe.nonNullable()})}get _type(){return this.type}clone(re){if(this._mutate)return re&&Object.assign(this.spec,re),this;const oe=Object.create(Object.getPrototypeOf(this));return oe.type=this.type,oe._typeCheck=this._typeCheck,oe._whitelist=this._whitelist.clone(),oe._blacklist=this._blacklist.clone(),oe.internalTests=Object.assign({},this.internalTests),oe.exclusiveTests=Object.assign({},this.exclusiveTests),oe.deps=[...this.deps],oe.conditions=[...this.conditions],oe.tests=[...this.tests],oe.transforms=[...this.transforms],oe.spec=clone(Object.assign({},this.spec,re)),oe}label(re){let oe=this.clone();return oe.spec.label=re,oe}meta(...re){if(re.length===0)return this.spec.meta;let oe=this.clone();return oe.spec.meta=Object.assign(oe.spec.meta||{},re[0]),oe}withMutation(re){let oe=this._mutate;this._mutate=!0;let ie=re(this);return this._mutate=oe,ie}concat(re){if(!re||re===this)return this;if(re.type!==this.type&&this.type!=="mixed")throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${re.type}`);let oe=this,ie=re.clone();const pe=Object.assign({},oe.spec,ie.spec);return ie.spec=pe,ie.internalTests=Object.assign({},oe.internalTests,ie.internalTests),ie._whitelist=oe._whitelist.merge(re._whitelist,re._blacklist),ie._blacklist=oe._blacklist.merge(re._blacklist,re._whitelist),ie.tests=oe.tests,ie.exclusiveTests=oe.exclusiveTests,ie.withMutation(nr=>{re.tests.forEach(or=>{nr.test(or.OPTIONS)})}),ie.transforms=[...oe.transforms,...ie.transforms],ie}isType(re){return re==null?!!(this.spec.nullable&&re===null||this.spec.optional&&re===void 0):this._typeCheck(re)}resolve(re){let oe=this;if(oe.conditions.length){let ie=oe.conditions;oe=oe.clone(),oe.conditions=[],oe=ie.reduce((pe,nr)=>nr.resolve(pe,re),oe),oe=oe.resolve(re)}return oe}resolveOptions(re){var oe,ie,pe,nr;return Object.assign({},re,{from:re.from||[],strict:(oe=re.strict)!=null?oe:this.spec.strict,abortEarly:(ie=re.abortEarly)!=null?ie:this.spec.abortEarly,recursive:(pe=re.recursive)!=null?pe:this.spec.recursive,disableStackTrace:(nr=re.disableStackTrace)!=null?nr:this.spec.disableStackTrace})}cast(re,oe={}){let ie=this.resolve(Object.assign({value:re},oe)),pe=oe.assert==="ignore-optionality",nr=ie._cast(re,oe);if(oe.assert!==!1&&!ie.isType(nr)){if(pe&&isAbsent(nr))return nr;let or=printValue(re),ar=printValue(nr);throw new TypeError(`The value of ${oe.path||"field"} could not be cast to a value that satisfies the schema type: "${ie.type}".
43
43
 
44
44
  attempted value: ${or}
45
- `+(ar!==or?`result of cast: ${ar}`:""))}return nr}_cast(re,oe){let ie=re===void 0?re:this.transforms.reduce((pe,nr)=>nr.call(this,pe,re,this),re);return ie===void 0&&(ie=this.getDefault(oe)),ie}_validate(re,oe={},ie,pe){let{path:nr,originalValue:or=re,strict:ar=this.spec.strict}=oe,ir=re;ar||(ir=this._cast(ir,Object.assign({assert:!1},oe)));let sr=[];for(let cr of Object.values(this.internalTests))cr&&sr.push(cr);this.runTests({path:nr,value:ir,originalValue:or,options:oe,tests:sr},ie,cr=>{if(cr.length)return pe(cr,ir);this.runTests({path:nr,value:ir,originalValue:or,options:oe,tests:this.tests},ie,pe)})}runTests(re,oe,ie){let pe=!1,{tests:nr,value:or,originalValue:ar,path:ir,options:sr}=re,cr=mr=>{pe||(pe=!0,oe(mr,or))},lr=mr=>{pe||(pe=!0,ie(mr,or))},ur=nr.length,fr=[];if(!ur)return lr([]);let dr={value:or,originalValue:ar,path:ir,options:sr,schema:this};for(let mr=0;mr<nr.length;mr++){const pr=nr[mr];pr(dr,cr,function(yr){yr&&(Array.isArray(yr)?fr.push(...yr):fr.push(yr)),--ur<=0&&lr(fr)})}}asNestedTest({key:re,index:oe,parent:ie,parentPath:pe,originalParent:nr,options:or}){const ar=re??oe;if(ar==null)throw TypeError("Must include `key` or `index` for nested validations");const ir=typeof ar=="number";let sr=ie[ar];const cr=Object.assign({},or,{strict:!0,parent:ie,value:sr,originalValue:nr[ar],key:void 0,[ir?"index":"key"]:ar,path:ir||ar.includes(".")?`${pe||""}[${ir?ar:`"${ar}"`}]`:(pe?`${pe}.`:"")+re});return(lr,ur,fr)=>this.resolve(cr)._validate(sr,cr,ur,fr)}validate(re,oe){var ie;let pe=this.resolve(Object.assign({},oe,{value:re})),nr=(ie=oe==null?void 0:oe.disableStackTrace)!=null?ie:pe.spec.disableStackTrace;return new Promise((or,ar)=>pe._validate(re,oe,(ir,sr)=>{ValidationError.isError(ir)&&(ir.value=sr),ar(ir)},(ir,sr)=>{ir.length?ar(new ValidationError(ir,sr,void 0,void 0,nr)):or(sr)}))}validateSync(re,oe){var ie;let pe=this.resolve(Object.assign({},oe,{value:re})),nr,or=(ie=oe==null?void 0:oe.disableStackTrace)!=null?ie:pe.spec.disableStackTrace;return pe._validate(re,Object.assign({},oe,{sync:!0}),(ar,ir)=>{throw ValidationError.isError(ar)&&(ar.value=ir),ar},(ar,ir)=>{if(ar.length)throw new ValidationError(ar,re,void 0,void 0,or);nr=ir}),nr}isValid(re,oe){return this.validate(re,oe).then(()=>!0,ie=>{if(ValidationError.isError(ie))return!1;throw ie})}isValidSync(re,oe){try{return this.validateSync(re,oe),!0}catch(ie){if(ValidationError.isError(ie))return!1;throw ie}}_getDefault(re){let oe=this.spec.default;return oe==null?oe:typeof oe=="function"?oe.call(this,re):clone(oe)}getDefault(re){return this.resolve(re||{})._getDefault(re)}default(re){return arguments.length===0?this._getDefault():this.clone({default:re})}strict(re=!0){return this.clone({strict:re})}nullability(re,oe){const ie=this.clone({nullable:re});return ie.internalTests.nullable=createValidation({message:oe,name:"nullable",test(pe){return pe===null?this.schema.spec.nullable:!0}}),ie}optionality(re,oe){const ie=this.clone({optional:re});return ie.internalTests.optionality=createValidation({message:oe,name:"optionality",test(pe){return pe===void 0?this.schema.spec.optional:!0}}),ie}optional(){return this.optionality(!0)}defined(re=mixed.defined){return this.optionality(!1,re)}nullable(){return this.nullability(!0)}nonNullable(re=mixed.notNull){return this.nullability(!1,re)}required(re=mixed.required){return this.clone().withMutation(oe=>oe.nonNullable(re).defined(re))}notRequired(){return this.clone().withMutation(re=>re.nullable().optional())}transform(re){let oe=this.clone();return oe.transforms.push(re),oe}test(...re){let oe;if(re.length===1?typeof re[0]=="function"?oe={test:re[0]}:oe=re[0]:re.length===2?oe={name:re[0],test:re[1]}:oe={name:re[0],message:re[1],test:re[2]},oe.message===void 0&&(oe.message=mixed.default),typeof oe.test!="function")throw new TypeError("`test` is a required parameters");let ie=this.clone(),pe=createValidation(oe),nr=oe.exclusive||oe.name&&ie.exclusiveTests[oe.name]===!0;if(oe.exclusive&&!oe.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return oe.name&&(ie.exclusiveTests[oe.name]=!!oe.exclusive),ie.tests=ie.tests.filter(or=>!(or.OPTIONS.name===oe.name&&(nr||or.OPTIONS.test===pe.OPTIONS.test))),ie.tests.push(pe),ie}when(re,oe){!Array.isArray(re)&&typeof re!="string"&&(oe=re,re=".");let ie=this.clone(),pe=toArray(re).map(nr=>new Reference$1(nr));return pe.forEach(nr=>{nr.isSibling&&ie.deps.push(nr.key)}),ie.conditions.push(typeof oe=="function"?new Condition(pe,oe):Condition.fromOptions(pe,oe)),ie}typeError(re){let oe=this.clone();return oe.internalTests.typeError=createValidation({message:re,name:"typeError",skipAbsent:!0,test(ie){return this.schema._typeCheck(ie)?!0:this.createError({params:{type:this.schema.type}})}}),oe}oneOf(re,oe=mixed.oneOf){let ie=this.clone();return re.forEach(pe=>{ie._whitelist.add(pe),ie._blacklist.delete(pe)}),ie.internalTests.whiteList=createValidation({message:oe,name:"oneOf",skipAbsent:!0,test(pe){let nr=this.schema._whitelist,or=nr.resolveAll(this.resolve);return or.includes(pe)?!0:this.createError({params:{values:Array.from(nr).join(", "),resolved:or}})}}),ie}notOneOf(re,oe=mixed.notOneOf){let ie=this.clone();return re.forEach(pe=>{ie._blacklist.add(pe),ie._whitelist.delete(pe)}),ie.internalTests.blacklist=createValidation({message:oe,name:"notOneOf",test(pe){let nr=this.schema._blacklist,or=nr.resolveAll(this.resolve);return or.includes(pe)?this.createError({params:{values:Array.from(nr).join(", "),resolved:or}}):!0}}),ie}strip(re=!0){let oe=this.clone();return oe.spec.strip=re,oe}describe(re){const oe=(re?this.resolve(re):this).clone(),{label:ie,meta:pe,optional:nr,nullable:or}=oe.spec;return{meta:pe,label:ie,optional:nr,nullable:or,default:oe.getDefault(re),type:oe.type,oneOf:oe._whitelist.describe(),notOneOf:oe._blacklist.describe(),tests:oe.tests.map(ir=>({name:ir.OPTIONS.name,params:ir.OPTIONS.params})).filter((ir,sr,cr)=>cr.findIndex(lr=>lr.name===ir.name)===sr)}}}Schema.prototype.__isYupSchema__=!0;for(const W of["validate","validateSync"])Schema.prototype[`${W}At`]=function(re,oe,ie={}){const{parent:pe,parentPath:nr,schema:or}=getIn(this,re,oe,ie.context);return or[W](pe&&pe[nr],Object.assign({},ie,{parent:pe,path:re}))};for(const W of["equals","is"])Schema.prototype[W]=Schema.prototype.oneOf;for(const W of["not","nope"])Schema.prototype[W]=Schema.prototype.notOneOf;const returnsTrue=()=>!0;function create$8(W){return new MixedSchema(W)}class MixedSchema extends Schema{constructor(re){super(typeof re=="function"?{type:"mixed",check:re}:Object.assign({type:"mixed",check:returnsTrue},re))}}create$8.prototype=MixedSchema.prototype;function create$7(){return new BooleanSchema}class BooleanSchema extends Schema{constructor(){super({type:"boolean",check(re){return re instanceof Boolean&&(re=re.valueOf()),typeof re=="boolean"}}),this.withMutation(()=>{this.transform((re,oe,ie)=>{if(ie.spec.coerce&&!ie.isType(re)){if(/^(true|1)$/i.test(String(re)))return!0;if(/^(false|0)$/i.test(String(re)))return!1}return re})})}isTrue(re=boolean.isValue){return this.test({message:re,name:"is-value",exclusive:!0,params:{value:"true"},test(oe){return isAbsent(oe)||oe===!0}})}isFalse(re=boolean.isValue){return this.test({message:re,name:"is-value",exclusive:!0,params:{value:"false"},test(oe){return isAbsent(oe)||oe===!1}})}default(re){return super.default(re)}defined(re){return super.defined(re)}optional(){return super.optional()}required(re){return super.required(re)}notRequired(){return super.notRequired()}nullable(){return super.nullable()}nonNullable(re){return super.nonNullable(re)}strip(re){return super.strip(re)}}create$7.prototype=BooleanSchema.prototype;const isoReg=/^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;function parseIsoDate(W){const re=parseDateStruct(W);if(!re)return Date.parse?Date.parse(W):Number.NaN;if(re.z===void 0&&re.plusMinus===void 0)return new Date(re.year,re.month,re.day,re.hour,re.minute,re.second,re.millisecond).valueOf();let oe=0;return re.z!=="Z"&&re.plusMinus!==void 0&&(oe=re.hourOffset*60+re.minuteOffset,re.plusMinus==="+"&&(oe=0-oe)),Date.UTC(re.year,re.month,re.day,re.hour,re.minute+oe,re.second,re.millisecond)}function parseDateStruct(W){var re,oe;const ie=isoReg.exec(W);return ie?{year:toNumber$2(ie[1]),month:toNumber$2(ie[2],1)-1,day:toNumber$2(ie[3],1),hour:toNumber$2(ie[4]),minute:toNumber$2(ie[5]),second:toNumber$2(ie[6]),millisecond:ie[7]?toNumber$2(ie[7].substring(0,3)):0,precision:(re=(oe=ie[7])==null?void 0:oe.length)!=null?re:void 0,z:ie[8]||void 0,plusMinus:ie[9]||void 0,hourOffset:toNumber$2(ie[10]),minuteOffset:toNumber$2(ie[11])}:null}function toNumber$2(W,re=0){return Number(W)||re}let rEmail=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,rUrl=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,rUUID=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,yearMonthDay="^\\d{4}-\\d{2}-\\d{2}",hourMinuteSecond="\\d{2}:\\d{2}:\\d{2}",zOrOffset="(([+-]\\d{2}(:?\\d{2})?)|Z)",rIsoDateTime=new RegExp(`${yearMonthDay}T${hourMinuteSecond}(\\.\\d+)?${zOrOffset}$`),isTrimmed=W=>isAbsent(W)||W===W.trim(),objStringTag={}.toString();function create$6(){return new StringSchema}class StringSchema extends Schema{constructor(){super({type:"string",check(re){return re instanceof String&&(re=re.valueOf()),typeof re=="string"}}),this.withMutation(()=>{this.transform((re,oe,ie)=>{if(!ie.spec.coerce||ie.isType(re)||Array.isArray(re))return re;const pe=re!=null&&re.toString?re.toString():re;return pe===objStringTag?re:pe})})}required(re){return super.required(re).withMutation(oe=>oe.test({message:re||mixed.required,name:"required",skipAbsent:!0,test:ie=>!!ie.length}))}notRequired(){return super.notRequired().withMutation(re=>(re.tests=re.tests.filter(oe=>oe.OPTIONS.name!=="required"),re))}length(re,oe=string.length){return this.test({message:oe,name:"length",exclusive:!0,params:{length:re},skipAbsent:!0,test(ie){return ie.length===this.resolve(re)}})}min(re,oe=string.min){return this.test({message:oe,name:"min",exclusive:!0,params:{min:re},skipAbsent:!0,test(ie){return ie.length>=this.resolve(re)}})}max(re,oe=string.max){return this.test({name:"max",exclusive:!0,message:oe,params:{max:re},skipAbsent:!0,test(ie){return ie.length<=this.resolve(re)}})}matches(re,oe){let ie=!1,pe,nr;return oe&&(typeof oe=="object"?{excludeEmptyString:ie=!1,message:pe,name:nr}=oe:pe=oe),this.test({name:nr||"matches",message:pe||string.matches,params:{regex:re},skipAbsent:!0,test:or=>or===""&&ie||or.search(re)!==-1})}email(re=string.email){return this.matches(rEmail,{name:"email",message:re,excludeEmptyString:!0})}url(re=string.url){return this.matches(rUrl,{name:"url",message:re,excludeEmptyString:!0})}uuid(re=string.uuid){return this.matches(rUUID,{name:"uuid",message:re,excludeEmptyString:!1})}datetime(re){let oe="",ie,pe;return re&&(typeof re=="object"?{message:oe="",allowOffset:ie=!1,precision:pe=void 0}=re:oe=re),this.matches(rIsoDateTime,{name:"datetime",message:oe||string.datetime,excludeEmptyString:!0}).test({name:"datetime_offset",message:oe||string.datetime_offset,params:{allowOffset:ie},skipAbsent:!0,test:nr=>{if(!nr||ie)return!0;const or=parseDateStruct(nr);return or?!!or.z:!1}}).test({name:"datetime_precision",message:oe||string.datetime_precision,params:{precision:pe},skipAbsent:!0,test:nr=>{if(!nr||pe==null)return!0;const or=parseDateStruct(nr);return or?or.precision===pe:!1}})}ensure(){return this.default("").transform(re=>re===null?"":re)}trim(re=string.trim){return this.transform(oe=>oe!=null?oe.trim():oe).test({message:re,name:"trim",test:isTrimmed})}lowercase(re=string.lowercase){return this.transform(oe=>isAbsent(oe)?oe:oe.toLowerCase()).test({message:re,name:"string_case",exclusive:!0,skipAbsent:!0,test:oe=>isAbsent(oe)||oe===oe.toLowerCase()})}uppercase(re=string.uppercase){return this.transform(oe=>isAbsent(oe)?oe:oe.toUpperCase()).test({message:re,name:"string_case",exclusive:!0,skipAbsent:!0,test:oe=>isAbsent(oe)||oe===oe.toUpperCase()})}}create$6.prototype=StringSchema.prototype;let isNaN$1=W=>W!=+W;function create$5(){return new NumberSchema}class NumberSchema extends Schema{constructor(){super({type:"number",check(re){return re instanceof Number&&(re=re.valueOf()),typeof re=="number"&&!isNaN$1(re)}}),this.withMutation(()=>{this.transform((re,oe,ie)=>{if(!ie.spec.coerce)return re;let pe=re;if(typeof pe=="string"){if(pe=pe.replace(/\s/g,""),pe==="")return NaN;pe=+pe}return ie.isType(pe)||pe===null?pe:parseFloat(pe)})})}min(re,oe=number.min){return this.test({message:oe,name:"min",exclusive:!0,params:{min:re},skipAbsent:!0,test(ie){return ie>=this.resolve(re)}})}max(re,oe=number.max){return this.test({message:oe,name:"max",exclusive:!0,params:{max:re},skipAbsent:!0,test(ie){return ie<=this.resolve(re)}})}lessThan(re,oe=number.lessThan){return this.test({message:oe,name:"max",exclusive:!0,params:{less:re},skipAbsent:!0,test(ie){return ie<this.resolve(re)}})}moreThan(re,oe=number.moreThan){return this.test({message:oe,name:"min",exclusive:!0,params:{more:re},skipAbsent:!0,test(ie){return ie>this.resolve(re)}})}positive(re=number.positive){return this.moreThan(0,re)}negative(re=number.negative){return this.lessThan(0,re)}integer(re=number.integer){return this.test({name:"integer",message:re,skipAbsent:!0,test:oe=>Number.isInteger(oe)})}truncate(){return this.transform(re=>isAbsent(re)?re:re|0)}round(re){var oe;let ie=["ceil","floor","round","trunc"];if(re=((oe=re)==null?void 0:oe.toLowerCase())||"round",re==="trunc")return this.truncate();if(ie.indexOf(re.toLowerCase())===-1)throw new TypeError("Only valid options for round() are: "+ie.join(", "));return this.transform(pe=>isAbsent(pe)?pe:Math[re](pe))}}create$5.prototype=NumberSchema.prototype;let invalidDate=new Date(""),isDate$1=W=>Object.prototype.toString.call(W)==="[object Date]";function create$4(){return new DateSchema}class DateSchema extends Schema{constructor(){super({type:"date",check(re){return isDate$1(re)&&!isNaN(re.getTime())}}),this.withMutation(()=>{this.transform((re,oe,ie)=>!ie.spec.coerce||ie.isType(re)||re===null?re:(re=parseIsoDate(re),isNaN(re)?DateSchema.INVALID_DATE:new Date(re)))})}prepareParam(re,oe){let ie;if(Reference$1.isRef(re))ie=re;else{let pe=this.cast(re);if(!this._typeCheck(pe))throw new TypeError(`\`${oe}\` must be a Date or a value that can be \`cast()\` to a Date`);ie=pe}return ie}min(re,oe=date.min){let ie=this.prepareParam(re,"min");return this.test({message:oe,name:"min",exclusive:!0,params:{min:re},skipAbsent:!0,test(pe){return pe>=this.resolve(ie)}})}max(re,oe=date.max){let ie=this.prepareParam(re,"max");return this.test({message:oe,name:"max",exclusive:!0,params:{max:re},skipAbsent:!0,test(pe){return pe<=this.resolve(ie)}})}}DateSchema.INVALID_DATE=invalidDate,create$4.prototype=DateSchema.prototype,create$4.INVALID_DATE=invalidDate;function sortFields(W,re=[]){let oe=[],ie=new Set,pe=new Set(re.map(([or,ar])=>`${or}-${ar}`));function nr(or,ar){let ir=propertyExpr.split(or)[0];ie.add(ir),pe.has(`${ar}-${ir}`)||oe.push([ar,ir])}for(const or of Object.keys(W)){let ar=W[or];ie.add(or),Reference$1.isRef(ar)&&ar.isSibling?nr(ar.path,or):isSchema(ar)&&"deps"in ar&&ar.deps.forEach(ir=>nr(ir,or))}return toposort$1.array(Array.from(ie),oe).reverse()}function findIndex$1(W,re){let oe=1/0;return W.some((ie,pe)=>{var nr;if((nr=re.path)!=null&&nr.includes(ie))return oe=pe,!0}),oe}function sortByKeyOrder(W){return(re,oe)=>findIndex$1(W,re)-findIndex$1(W,oe)}const parseJson=(W,re,oe)=>{if(typeof W!="string")return W;let ie=W;try{ie=JSON.parse(W)}catch{}return oe.isType(ie)?ie:W};function deepPartial(W){if("fields"in W){const re={};for(const[oe,ie]of Object.entries(W.fields))re[oe]=deepPartial(ie);return W.setFields(re)}if(W.type==="array"){const re=W.optional();return re.innerType&&(re.innerType=deepPartial(re.innerType)),re}return W.type==="tuple"?W.optional().clone({types:W.spec.types.map(deepPartial)}):"optional"in W?W.optional():W}const deepHas=(W,re)=>{const oe=[...propertyExpr.normalizePath(re)];if(oe.length===1)return oe[0]in W;let ie=oe.pop(),pe=propertyExpr.getter(propertyExpr.join(oe),!0)(W);return!!(pe&&ie in pe)};let isObject$6=W=>Object.prototype.toString.call(W)==="[object Object]";function unknown(W,re){let oe=Object.keys(W.fields);return Object.keys(re).filter(ie=>oe.indexOf(ie)===-1)}const defaultSort=sortByKeyOrder([]);function create$3(W){return new ObjectSchema(W)}class ObjectSchema extends Schema{constructor(re){super({type:"object",check(oe){return isObject$6(oe)||typeof oe=="function"}}),this.fields=Object.create(null),this._sortErrors=defaultSort,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{re&&this.shape(re)})}_cast(re,oe={}){var ie;let pe=super._cast(re,oe);if(pe===void 0)return this.getDefault(oe);if(!this._typeCheck(pe))return pe;let nr=this.fields,or=(ie=oe.stripUnknown)!=null?ie:this.spec.noUnknown,ar=[].concat(this._nodes,Object.keys(pe).filter(lr=>!this._nodes.includes(lr))),ir={},sr=Object.assign({},oe,{parent:ir,__validating:oe.__validating||!1}),cr=!1;for(const lr of ar){let ur=nr[lr],fr=lr in pe;if(ur){let dr,mr=pe[lr];sr.path=(oe.path?`${oe.path}.`:"")+lr,ur=ur.resolve({value:mr,context:oe.context,parent:ir});let pr=ur instanceof Schema?ur.spec:void 0,hr=pr==null?void 0:pr.strict;if(pr!=null&&pr.strip){cr=cr||lr in pe;continue}dr=!oe.__validating||!hr?ur.cast(pe[lr],sr):pe[lr],dr!==void 0&&(ir[lr]=dr)}else fr&&!or&&(ir[lr]=pe[lr]);(fr!==lr in ir||ir[lr]!==pe[lr])&&(cr=!0)}return cr?ir:pe}_validate(re,oe={},ie,pe){let{from:nr=[],originalValue:or=re,recursive:ar=this.spec.recursive}=oe;oe.from=[{schema:this,value:or},...nr],oe.__validating=!0,oe.originalValue=or,super._validate(re,oe,ie,(ir,sr)=>{if(!ar||!isObject$6(sr)){pe(ir,sr);return}or=or||sr;let cr=[];for(let lr of this._nodes){let ur=this.fields[lr];!ur||Reference$1.isRef(ur)||cr.push(ur.asNestedTest({options:oe,key:lr,parent:sr,parentPath:oe.path,originalParent:or}))}this.runTests({tests:cr,value:sr,originalValue:or,options:oe},ie,lr=>{pe(lr.sort(this._sortErrors).concat(ir),sr)})})}clone(re){const oe=super.clone(re);return oe.fields=Object.assign({},this.fields),oe._nodes=this._nodes,oe._excludedEdges=this._excludedEdges,oe._sortErrors=this._sortErrors,oe}concat(re){let oe=super.concat(re),ie=oe.fields;for(let[pe,nr]of Object.entries(this.fields)){const or=ie[pe];ie[pe]=or===void 0?nr:or}return oe.withMutation(pe=>pe.setFields(ie,[...this._excludedEdges,...re._excludedEdges]))}_getDefault(re){if("default"in this.spec)return super._getDefault(re);if(!this._nodes.length)return;let oe={};return this._nodes.forEach(ie=>{var pe;const nr=this.fields[ie];let or=re;(pe=or)!=null&&pe.value&&(or=Object.assign({},or,{parent:or.value,value:or.value[ie]})),oe[ie]=nr&&"getDefault"in nr?nr.getDefault(or):void 0}),oe}setFields(re,oe){let ie=this.clone();return ie.fields=re,ie._nodes=sortFields(re,oe),ie._sortErrors=sortByKeyOrder(Object.keys(re)),oe&&(ie._excludedEdges=oe),ie}shape(re,oe=[]){return this.clone().withMutation(ie=>{let pe=ie._excludedEdges;return oe.length&&(Array.isArray(oe[0])||(oe=[oe]),pe=[...ie._excludedEdges,...oe]),ie.setFields(Object.assign(ie.fields,re),pe)})}partial(){const re={};for(const[oe,ie]of Object.entries(this.fields))re[oe]="optional"in ie&&ie.optional instanceof Function?ie.optional():ie;return this.setFields(re)}deepPartial(){return deepPartial(this)}pick(re){const oe={};for(const ie of re)this.fields[ie]&&(oe[ie]=this.fields[ie]);return this.setFields(oe,this._excludedEdges.filter(([ie,pe])=>re.includes(ie)&&re.includes(pe)))}omit(re){const oe=[];for(const ie of Object.keys(this.fields))re.includes(ie)||oe.push(ie);return this.pick(oe)}from(re,oe,ie){let pe=propertyExpr.getter(re,!0);return this.transform(nr=>{if(!nr)return nr;let or=nr;return deepHas(nr,re)&&(or=Object.assign({},nr),ie||delete or[re],or[oe]=pe(nr)),or})}json(){return this.transform(parseJson)}noUnknown(re=!0,oe=object.noUnknown){typeof re!="boolean"&&(oe=re,re=!0);let ie=this.test({name:"noUnknown",exclusive:!0,message:oe,test(pe){if(pe==null)return!0;const nr=unknown(this.schema,pe);return!re||nr.length===0||this.createError({params:{unknown:nr.join(", ")}})}});return ie.spec.noUnknown=re,ie}unknown(re=!0,oe=object.noUnknown){return this.noUnknown(!re,oe)}transformKeys(re){return this.transform(oe=>{if(!oe)return oe;const ie={};for(const pe of Object.keys(oe))ie[re(pe)]=oe[pe];return ie})}camelCase(){return this.transformKeys(tinyCase.camelCase)}snakeCase(){return this.transformKeys(tinyCase.snakeCase)}constantCase(){return this.transformKeys(re=>tinyCase.snakeCase(re).toUpperCase())}describe(re){const oe=(re?this.resolve(re):this).clone(),ie=super.describe(re);ie.fields={};for(const[nr,or]of Object.entries(oe.fields)){var pe;let ar=re;(pe=ar)!=null&&pe.value&&(ar=Object.assign({},ar,{parent:ar.value,value:ar.value[nr]})),ie.fields[nr]=or.describe(ar)}return ie}}create$3.prototype=ObjectSchema.prototype;function create$2(W){return new ArraySchema(W)}class ArraySchema extends Schema{constructor(re){super({type:"array",spec:{types:re},check(oe){return Array.isArray(oe)}}),this.innerType=void 0,this.innerType=re}_cast(re,oe){const ie=super._cast(re,oe);if(!this._typeCheck(ie)||!this.innerType)return ie;let pe=!1;const nr=ie.map((or,ar)=>{const ir=this.innerType.cast(or,Object.assign({},oe,{path:`${oe.path||""}[${ar}]`}));return ir!==or&&(pe=!0),ir});return pe?nr:ie}_validate(re,oe={},ie,pe){var nr;let or=this.innerType,ar=(nr=oe.recursive)!=null?nr:this.spec.recursive;oe.originalValue!=null&&oe.originalValue,super._validate(re,oe,ie,(ir,sr)=>{var cr;if(!ar||!or||!this._typeCheck(sr)){pe(ir,sr);return}let lr=new Array(sr.length);for(let fr=0;fr<sr.length;fr++){var ur;lr[fr]=or.asNestedTest({options:oe,index:fr,parent:sr,parentPath:oe.path,originalParent:(ur=oe.originalValue)!=null?ur:re})}this.runTests({value:sr,tests:lr,originalValue:(cr=oe.originalValue)!=null?cr:re,options:oe},ie,fr=>pe(fr.concat(ir),sr))})}clone(re){const oe=super.clone(re);return oe.innerType=this.innerType,oe}json(){return this.transform(parseJson)}concat(re){let oe=super.concat(re);return oe.innerType=this.innerType,re.innerType&&(oe.innerType=oe.innerType?oe.innerType.concat(re.innerType):re.innerType),oe}of(re){let oe=this.clone();if(!isSchema(re))throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: "+printValue(re));return oe.innerType=re,oe.spec=Object.assign({},oe.spec,{types:re}),oe}length(re,oe=array.length){return this.test({message:oe,name:"length",exclusive:!0,params:{length:re},skipAbsent:!0,test(ie){return ie.length===this.resolve(re)}})}min(re,oe){return oe=oe||array.min,this.test({message:oe,name:"min",exclusive:!0,params:{min:re},skipAbsent:!0,test(ie){return ie.length>=this.resolve(re)}})}max(re,oe){return oe=oe||array.max,this.test({message:oe,name:"max",exclusive:!0,params:{max:re},skipAbsent:!0,test(ie){return ie.length<=this.resolve(re)}})}ensure(){return this.default(()=>[]).transform((re,oe)=>this._typeCheck(re)?re:oe==null?[]:[].concat(oe))}compact(re){let oe=re?(ie,pe,nr)=>!re(ie,pe,nr):ie=>!!ie;return this.transform(ie=>ie!=null?ie.filter(oe):ie)}describe(re){const oe=(re?this.resolve(re):this).clone(),ie=super.describe(re);if(oe.innerType){var pe;let nr=re;(pe=nr)!=null&&pe.value&&(nr=Object.assign({},nr,{parent:nr.value,value:nr.value[0]})),ie.innerType=oe.innerType.describe(nr)}return ie}}create$2.prototype=ArraySchema.prototype;function addMethod(W,re,oe){if(!W||!isSchema(W.prototype))throw new TypeError("You must provide a yup schema constructor function");if(typeof re!="string")throw new TypeError("A Method name must be provided");if(typeof oe!="function")throw new TypeError("Method function must be provided");W.prototype[re]=oe}function capitalize(W){var re,oe;return W||(W=""),((re=W==null?void 0:W[0])==null?void 0:re.toUpperCase())+((oe=W==null?void 0:W.substring(1))==null?void 0:oe.toLowerCase())}function classNames(...W){return W.filter(Boolean).join(" ")}function constructFullName(W,re,oe,ie){return`${W}${oe?" "+oe:""} ${re}${ie?" "+ie:""}`}function getEndpoint(){return"https://api.mercoa.com"}function BankAccounts({children:W,onSelect:re,showAdd:oe,showEdit:ie,verifiedOnly:pe}){var ir;const[nr,or]=React.useState(),ar=useMercoaSession();return React.useEffect(()=>{var sr,cr,lr;ar.token&&((sr=ar.entity)!=null&&sr.id)&&((lr=ar.client)==null||lr.entity.paymentMethod.getAll((cr=ar.entity)==null?void 0:cr.id,{type:"bankAccount"}).then(ur=>{or(ur.map(fr=>fr).filter(fr=>pe&&fr.status!="VERIFIED"?null:fr))}))},[(ir=ar.entity)==null?void 0:ir.id,ar.token,ar.refreshId]),ar.client?W?W({bankAccounts:nr}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[!nr&&jsxRuntimeExports.jsx("div",{className:"mercoa-p-9 mercoa-text-center",children:jsxRuntimeExports.jsx(LoadingSpinnerIcon,{})}),jsxRuntimeExports.jsx(PaymentMethodList,{accounts:nr,showEdit:ie,addAccount:nr&&oe?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(AddBankAccountButton,{onSelect:sr=>{nr.find(cr=>cr.accountNumber===sr.accountNumber&&cr.routingNumber===sr.routingNumber)||or([...nr,sr]),re&&re(sr)}})}):void 0,formatAccount:sr=>jsxRuntimeExports.jsx(BankAccount,{account:sr,onSelect:re,showEdit:ie})}),nr&&nr.length==0&&pe&&jsxRuntimeExports.jsx("div",{className:"mercoa-mt-2 mercoa-text-left mercoa-text-gray-700",children:"No verified bank accounts found. Please add and verify at least one bank account."})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"BankAccounts"})}function BankAccount({children:W,account:re,onSelect:oe,showEdit:ie,selected:pe}){var ur,fr,dr;const nr=useMercoaSession(),[or,ar]=React.useState(!1),[ir,sr]=React.useState(!1),{register:cr,handleSubmit:lr}=useForm();return nr.client?re?jsxRuntimeExports.jsxs("div",{onClick:()=>{oe&&oe(re)},className:`mercoa-relative mercoa-flex mercoa-items-center mercoa-space-x-3 mercoa-rounded-mercoa mercoa-border ${pe?"mercoa-border-gray-600":"mercoa-border-gray-300"} mercoa-bg-white mercoa-px-6 mercoa-py-5 mercoa-shadow-sm focus-within:mercoa-ring-2 focus-within:mercoa-ring-indigo-500 focus-within:mercoa-ring-offset-2 ${oe?"mercoa-cursor-pointer hover:mercoa-border-gray-400":""}`,children:[jsxRuntimeExports.jsx("div",{className:`mercoa-flex-shrink-0 mercoa-rounded-full mercoa-p-1 ${pe?"mercoa-text-mercoa-primary-text-invert mercoa-bg-mercoa-primary-light":"mercoa-bg-gray-200 mercoa-text-gray-600"}`,children:jsxRuntimeExports.jsx(ForwardRef$I,{className:"mercoa-size-5"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-min-w-0 mercoa-flex-1 mercoa-justify-between mercoa-group",children:jsxRuntimeExports.jsxs("div",{className:"mercoa-flex",children:[jsxRuntimeExports.jsxs("div",{children:[!ie&&jsxRuntimeExports.jsx("span",{className:"mercoa-absolute mercoa-inset-0","aria-hidden":"true"}),jsxRuntimeExports.jsx(AddDialog,{component:jsxRuntimeExports.jsx(EditBankAccount,{account:re,onSubmit:()=>sr(!1)}),onClose:()=>sr(!1),show:ir}),re!=null&&re.accountName?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("p",{className:`mercoa-text-sm mercoa-font-medium mercoa-text-gray-900 ${pe?"mercoa-underline":""}`,children:re.accountName}),jsxRuntimeExports.jsxs("p",{className:`mercoa-text-xs mercoa-font-medium mercoa-text-gray-800 ${pe?"mercoa-underline":""}`,children:[re==null?void 0:re.bankName,` ••••${String(re==null?void 0:re.accountNumber).slice(-4)}`]})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("p",{className:`mercoa-text-sm mercoa-font-medium mercoa-text-gray-900 ${pe?"mercoa-underline":""}`,children:`${capitalize(re==null?void 0:re.accountType)} ••••${String(re==null?void 0:re.accountNumber).slice(-4)}`}),jsxRuntimeExports.jsx("p",{className:`mercoa-text-xs mercoa-font-medium mercoa-text-gray-800 ${pe?"mercoa-underline":""}`,children:re==null?void 0:re.bankName})]})]}),ie&&((re==null?void 0:re.status)===javascript.Mercoa.BankStatus.New||(re==null?void 0:re.status)===javascript.Mercoa.BankStatus.Pending)&&jsxRuntimeExports.jsxs(MercoaButton,{isEmphasized:!0,size:"md",className:"mercoa-ml-2",onClick:()=>ar(!0),children:[(re==null?void 0:re.status)===javascript.Mercoa.BankStatus.New&&"Start Verification",(re==null?void 0:re.status)===javascript.Mercoa.BankStatus.Pending&&"Complete Verification"]})]})}),ie&&jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-items-center mercoa-gap-x-1",children:[jsxRuntimeExports.jsx(DefaultPaymentMethodIndicator,{paymentMethod:re}),jsxRuntimeExports.jsxs("div",{children:[(re==null?void 0:re.status)===javascript.Mercoa.BankStatus.New&&jsxRuntimeExports.jsx(Tooltip,{title:"Can only receive funds",children:jsxRuntimeExports.jsx("span",{className:"mercoa-inline-flex mercoa-items-center mercoa-rounded-full mercoa-bg-indigo-100 mercoa-px-2.5 mercoa-py-0.5 mercoa-text-xs mercoa-font-medium mercoa-text-indigo-800",children:"New"})}),(re==null?void 0:re.status)===javascript.Mercoa.BankStatus.Verified&&jsxRuntimeExports.jsx(Tooltip,{title:"Can send and receive funds",children:jsxRuntimeExports.jsx("span",{className:"mercoa-inline-flex mercoa-items-center mercoa-rounded-full mercoa-bg-green-100 mercoa-px-2.5 mercoa-py-0.5 mercoa-text-xs mercoa-font-medium mercoa-text-green-800",children:"Verified"})}),(re==null?void 0:re.status)===javascript.Mercoa.BankStatus.Pending&&jsxRuntimeExports.jsx(Tooltip,{title:"Can only receive funds",children:jsxRuntimeExports.jsx("span",{className:"mercoa-inline-flex mercoa-items-center mercoa-rounded-full mercoa-bg-yellow-100 mercoa-px-2.5 mercoa-py-0.5 mercoa-text-xs mercoa-font-medium mercoa-text-yellow-800",children:"Pending"})}),((re==null?void 0:re.status)===javascript.Mercoa.BankStatus.VerificationFailed||(re==null?void 0:re.status)===javascript.Mercoa.BankStatus.Errored)&&jsxRuntimeExports.jsx(Tooltip,{title:"Can only receive funds",children:jsxRuntimeExports.jsx("span",{className:"mercoa-inline-flex mercoa-items-center mercoa-rounded-full mercoa-bg-red-100 mercoa-px-2.5 mercoa-py-0.5 mercoa-text-xs mercoa-font-medium mercoa-text-red-800",children:"VERIFICATION FAILED"})})]}),jsxRuntimeExports.jsx("div",{children:(ur=re.checkOptions)!=null&&ur.enabled?jsxRuntimeExports.jsx(Tooltip,{title:"Can send checks",children:jsxRuntimeExports.jsxs("span",{className:"mercoa-inline-flex mercoa-items-center mercoa-rounded-full mercoa-bg-green-100 mercoa-px-2.5 mercoa-py-0.5 mercoa-text-xs mercoa-font-medium mercoa-text-green-800",children:["_",jsxRuntimeExports.jsx(ForwardRef$v,{className:"mercoa-size-4"})]})}):jsxRuntimeExports.jsx(Tooltip,{title:"Check send disabled",children:jsxRuntimeExports.jsxs("span",{className:"mercoa-inline-flex mercoa-items-center mercoa-rounded-full mercoa-bg-gray-100 mercoa-px-2.5 mercoa-py-0.5 mercoa-text-xs mercoa-font-medium mercoa-text-gray-800",children:["_",jsxRuntimeExports.jsx(ForwardRef$v,{className:"mercoa-size-4"})]})})}),jsxRuntimeExports.jsx(MercoaButton,{size:"sm",isEmphasized:!1,className:"mercoa-mr-2 mercoa-px-[4px] mercoa-py-[4px]",onClick:()=>sr(!0),children:jsxRuntimeExports.jsx(Tooltip,{title:"Edit",children:jsxRuntimeExports.jsx(ForwardRef$f,{className:"mercoa-size-4"})})}),jsxRuntimeExports.jsx(qe$1.Root,{show:!!or,as:React.Fragment,children:jsxRuntimeExports.jsxs(_t$1,{as:"div",className:"mercoa-relative mercoa-z-10",onClose:()=>ar(!1),children:[jsxRuntimeExports.jsx(qe$1.Child,{as:React.Fragment,enter:"mercoa-ease-out mercoa-duration-300",enterFrom:"mercoa-opacity-0",enterTo:"mercoa-opacity-100",leave:"mercoa-ease-in mercoa-duration-200",leaveFrom:"mercoa-opacity-100",leaveTo:"mercoa-opacity-0",children:jsxRuntimeExports.jsx("div",{className:"mercoa-fixed mercoa-inset-0 mercoa-bg-gray-500 mercoa-bg-mercoa-opacity-75 mercoa-transition-opacity"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-fixed mercoa-inset-0 mercoa-z-10 mercoa-overflow-y-auto",children:jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-min-h-full mercoa-items-end mercoa-justify-center mercoa-p-4 mercoa-text-center sm:mercoa-items-center sm:mercoa-p-0",children:jsxRuntimeExports.jsx(qe$1.Child,{as:React.Fragment,enter:"mercoa-ease-out mercoa-duration-300",enterFrom:"mercoa-opacity-0 mercoa-translate-y-4 sm:mercoa-translate-y-0 sm:mercoa-scale-95",enterTo:"mercoa-opacity-100 mercoa-translate-y-0 sm:mercoa-scale-100",leave:"mercoa-ease-in mercoa-duration-200",leaveFrom:"mercoa-opacity-100 mercoa-translate-y-0 sm:mercoa-scale-100",leaveTo:"mercoa-opacity-0 mercoa-translate-y-4 sm:mercoa-translate-y-0 sm:mercoa-scale-95",children:jsxRuntimeExports.jsxs(_t$1.Panel,{className:"mercoa-relative mercoa-transform mercoa-rounded-mercoa mercoa-bg-white mercoa-px-4 mercoa-pt-5 mercoa-pb-4 mercoa-text-left mercoa-shadow-xl mercoa-transition-all sm:mercoa-my-8 sm:mercoa-w-full sm:mercoa-max-w-lg sm:mercoa-p-6",children:[jsxRuntimeExports.jsx(_t$1.Title,{as:"h3",className:"mercoa-text-lg mercoa-font-medium mercoa-leading-6 mercoa-text-gray-900",children:"Verify Account"}),(re==null?void 0:re.status)===javascript.Mercoa.BankStatus.New&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("p",{className:"mercoa-mt-5 mercoa-text-sm",children:"Mercoa will send two small deposits to verify this account. These deposits may take up to 1-2 days to appear."}),jsxRuntimeExports.jsx("p",{className:"mercoa-mt-3 mercoa-text-sm",children:"Once transactions have been sent, you'll have 14 days to verify their values."}),((fr=nr.organization)==null?void 0:fr.sandbox)&&jsxRuntimeExports.jsxs("p",{className:"mercoa-mt-3 mercoa-rounded-mercoa mercoa-bg-orange-200 mercoa-p-1 mercoa-text-sm",children:[jsxRuntimeExports.jsx("b",{children:"Test Mode:"})," actual deposits will not be sent. Use 0 and 0 as the values to instantly verify the account in the next step."]}),jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!0,onClick:async()=>{var mr,pr,hr;(mr=nr.entity)!=null&&mr.id&&(re!=null&&re.id)&&(await((hr=nr.client)==null?void 0:hr.entity.paymentMethod.initiateMicroDeposits((pr=nr.entity)==null?void 0:pr.id,re==null?void 0:re.id)),ar(!1),nr.refresh())},className:"mercoa-mt-5 mercoa-inline-flex mercoa-w-full mercoa-justify-center",children:"Send deposits"})]}),(re==null?void 0:re.status)===javascript.Mercoa.BankStatus.Pending&&jsxRuntimeExports.jsxs("form",{onSubmit:lr(async mr=>{var pr,hr,yr;(pr=nr.entity)!=null&&pr.id&&(re!=null&&re.id)&&(await((yr=nr.client)==null?void 0:yr.entity.paymentMethod.completeMicroDeposits((hr=nr.entity)==null?void 0:hr.id,re==null?void 0:re.id,{amounts:[Number(mr.md1),Number(mr.md2)]})),ar(!1),nr.refresh())}),children:[jsxRuntimeExports.jsx("p",{className:"mercoa-mt-5 mercoa-text-sm",children:"Micro-deposits may take up to 2 days to appear on your statement. Once you have both values please enter the amounts to verify this account."}),((dr=nr.organization)==null?void 0:dr.sandbox)&&jsxRuntimeExports.jsxs("p",{className:"mercoa-mt-3 mercoa-rounded-mercoa mercoa-bg-orange-200 mercoa-p-1 mercoa-text-sm",children:[jsxRuntimeExports.jsx("b",{children:"Test Mode:"})," use 0 and 0 to instantly verify this account."]}),jsxRuntimeExports.jsx(MercoaInput,{name:"md1",label:"Amount",type:"number",placeholder:"0.00",step:.01,min:0,max:.99,register:cr,className:"mercoa-mt-2"}),jsxRuntimeExports.jsx(MercoaInput,{name:"md2",label:"Amount",type:"number",placeholder:"0.00",step:.01,min:0,max:.99,register:cr,className:"mercoa-mt-2"}),jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!0,className:"mercoa-mt-5",children:"Verify Account"})]})]})})})})]})})]})})]},`${re==null?void 0:re.routingNumber} ${re==null?void 0:re.accountNumber}`):jsxRuntimeExports.jsxs("div",{onClick:()=>{oe&&oe(re)},className:`mercoa-relative mercoa-flex mercoa-items-center mercoa-space-x-3 mercoa-rounded-mercoa mercoa-border mercoa-border-gray-300 mercoa-bg-white mercoa-px-6 mercoa-py-5 mercoa-shadow-sm focus-within:mercoa-ring-2 focus-within:mercoa-ring-indigo-500 focus-within:mercoa-ring-offset-2 hover:mercoa-border-gray-400 ${oe?"mercoa-cursor-pointer ":""}`,children:[jsxRuntimeExports.jsx("div",{className:`mercoa-flex-shrink-0 mercoa-rounded-full mercoa-p-1 ${pe?"mercoa-text-mercoa-primary-text-invert mercoa-bg-mercoa-primary-light":"mercoa-bg-gray-200 mercoa-text-gray-600"}`,children:jsxRuntimeExports.jsx(ForwardRef$d,{className:"mercoa-size-5"})}),jsxRuntimeExports.jsxs("div",{className:"mercoa-min-w-0 mercoa-flex-1",children:[jsxRuntimeExports.jsx("span",{className:"mercoa-absolute mercoa-inset-0","aria-hidden":"true"}),jsxRuntimeExports.jsx("p",{className:"mercoa-text-sm mercoa-font-medium mercoa-text-gray-900",children:"Add new bank account"}),jsxRuntimeExports.jsx("p",{className:"mercoa-truncate mercoa-text-sm mercoa-text-gray-500"})]})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"BankAccountComponent"})}function AddBankAccountButton({entityId:W,onSelect:re,bankAccount:oe}){const[ie,pe]=React.useState(!1),nr=or=>{pe(!1),re&&or&&re(or)};return jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-2",children:[jsxRuntimeExports.jsx(AddDialog,{show:ie,onClose:nr,component:jsxRuntimeExports.jsx(AddBankViaPlaidOrManual,{onSubmit:or=>{nr(or)},entityId:W,bankAccount:oe})}),jsxRuntimeExports.jsx(BankAccount,{onSelect:()=>pe(!0)})]})}function PlaidPopup({onExit:W,onSubmit:re,paymentMethodId:oe}){const ie=useMercoaSession(),[pe,nr]=React.useState(null),or=async()=>{var cr;if(!ie.entityId)return;const sr=await((cr=ie.client)==null?void 0:cr.entity.plaidLinkToken(ie.entityId,{paymentMethodId:oe}));sr&&nr(sr)},{open:ar,ready:ir}=usePlaidLink({token:pe,onSuccess:async(sr,cr)=>{let lr;await Promise.all(cr.accounts.map(async ur=>{var dr,mr,pr;let fr=javascript.Mercoa.BankType.Checking;if(ur.subtype=="savings"&&(fr=javascript.Mercoa.BankType.Savings),!!ie.entityId)try{oe?lr=await((dr=ie.client)==null?void 0:dr.entity.paymentMethod.update(ie.entityId,oe,{type:"bankAccount",plaid:{publicToken:sr,accountId:ur.id}})):lr=await((pr=ie.client)==null?void 0:pr.entity.paymentMethod.create(ie.entityId,{type:"bankAccount",plaid:{publicToken:sr,accountId:ur.id},accountNumber:ur.mask,routingNumber:"",accountType:fr,bankName:((mr=cr==null?void 0:cr.institution)==null?void 0:mr.name)??""}))}catch(hr){console.error(hr)}})),lr?re&&re(lr):W&&W(null,null)},onExit:(sr,cr)=>{console.log("onPlaidExit",{err:sr,metadata:cr}),W&&W(sr,cr)}});return React.useEffect(()=>{ie.entityId&&or()},[ie.entityId]),React.useEffect(()=>{pe&&ir&&ar()},[pe,ir,ar]),ie.client?!pe||!ir?jsxRuntimeExports.jsx("div",{className:"mercoa-p-9 mercoa-text-center",children:jsxRuntimeExports.jsx(LoadingSpinnerIcon,{})}):jsxRuntimeExports.jsx("div",{className:"mercoa-p-10 mercoa-text-center"}):jsxRuntimeExports.jsx(NoSession,{componentName:"PlaidPopup"})}function AddBankViaPlaidOrManual({title:W,actions:re,onSubmit:oe,entityId:ie,bankAccount:pe}){const nr=useMercoaSession(),[or,ar]=React.useState(null);return React.useEffect(()=>{nr.entityId&&(ie&&ie!=nr.entityId?ar(!0):ar(!1))},[nr.entityId,ie]),nr.client?or?jsxRuntimeExports.jsx(AddBankAccount,{title:W,actions:re,onSubmit:oe,entityId:ie,bankAccount:pe}):or===!1?jsxRuntimeExports.jsx(PlaidPopup,{onSubmit:oe,onExit:(ir,sr)=>{ir&&Q$1.error("There was an error adding your bank account automatically. Please try again or add manually."),ar(!0)}}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{}):jsxRuntimeExports.jsx(NoSession,{componentName:"AddBankViaPlaidOrManual"})}function AddBankAccount({onSubmit:W,title:re,actions:oe,bankAccount:ie,entityId:pe}){const nr=useMercoaSession();addMethod(create$6,"accountNumber",function(sr){return this.test({name:"accountNumber",exclusive:!0,message:sr||"Invalid Account Number",test:cr=>!!cr&&Number(cr)>0})}),addMethod(create$6,"routingNumber",function(sr){return this.test({name:"routingNumber",exclusive:!0,message:sr||"Invalid Routing Number",test:cr=>!!cr&&cr.length==9&&Number(cr)>0})});const or=create$3({routingNumber:create$6().required("Please enter a valid routing number"),accountNumber:create$6().accountNumber().required("Please enter a valid account number")}).required(),ar=useForm({defaultValues:ie,resolver:o(or)});async function ir(sr){var cr,lr,ur;if((cr=nr.entity)!=null&&cr.id){const fr=await((ur=nr.client)==null?void 0:ur.entity.paymentMethod.create(pe??((lr=nr.entity)==null?void 0:lr.id),{...sr,type:"bankAccount"}));if(!W)return;fr?W(fr):W()}}return nr.client?jsxRuntimeExports.jsx(FormProvider,{...ar,children:jsxRuntimeExports.jsxs("form",{className:"mercoa-space-y-3 mercoa-text-left",onSubmit:ar.handleSubmit(ir),children:[re||jsxRuntimeExports.jsx("h3",{className:"mercoa-text-center mercoa-text-lg mercoa-font-medium mercoa-leading-6 mercoa-text-gray-900",children:"Add Bank Account"}),jsxRuntimeExports.jsx(AddBankAccountForm,{}),oe||jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-justify-between",children:[jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!1,onClick:()=>{W&&W()},type:"button",children:"Back"}),jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!0,children:"Add Bank Account"})]})]})}):jsxRuntimeExports.jsx(NoSession,{componentName:"AddBankAccount"})}function AddBankAccountForm({prefix:W}){const re=useMercoaSession();W||(W="");const{register:oe,setValue:ie,setError:pe,clearErrors:nr,watch:or,formState:{errors:ar}}=useFormContext(),ir=or(W+"routingNumber"),sr=or(W+"bankName");return React.useEffect(()=>{var cr;ie(W+"bankName","",{shouldDirty:!0,shouldTouch:!0}),ir&&(ir.length===9?(cr=re.client)==null||cr.bankLookup.find({routingNumber:ir}).then(lr=>{lr.bankName?(ie(W+"bankName",lr.bankName),nr(W+"routingNumber")):pe(W+"routingNumber",{message:"Please enter a valid routing number"})}):ir&&pe(W+"routingNumber",{message:"Please enter a valid routing number"}))},[ir]),re.client?jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-flex-col mercoa-gap-y-2",children:[jsxRuntimeExports.jsx(MercoaInput,{label:`Routing Number ${sr?` - ${sr}`:""}`,name:W+"routingNumber",register:oe,errors:ar}),jsxRuntimeExports.jsx(MercoaInput,{label:"Account Number",name:W+"accountNumber",register:oe,errors:ar}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("label",{htmlFor:"accountType",className:"mercoa-block mercoa-text-sm mercoa-font-medium mercoa-text-gray-900",children:"Account Type"}),jsxRuntimeExports.jsx("div",{className:"mercoa-mt-1",children:jsxRuntimeExports.jsxs("select",{...oe(W+"accountType"),className:inputClassName({}),children:[jsxRuntimeExports.jsx("option",{value:"CHECKING",children:"Checking"}),jsxRuntimeExports.jsx("option",{value:"SAVINGS",children:"Savings"}),jsxRuntimeExports.jsx("option",{value:"UNKNOWN",children:"Other"})]})})]}),jsxRuntimeExports.jsx(MercoaInput,{label:"Account Name",name:W+"accountName",register:oe,errors:ar,optional:!0})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"AddBankAccountForm"})}function EditBankAccount({account:W,onSubmit:re}){var pr;const oe=useMercoaSession(),[ie,pe]=React.useState(!1),nr=React.useRef(null),or=React.useRef(null),[ar,ir]=React.useState([]),{register:sr,handleSubmit:cr,watch:lr,setValue:ur}=useForm({defaultValues:{accountName:W.accountName,checkOptions:W.checkOptions,externalAccountingSystemId:W.externalAccountingSystemId}});function fr(hr){var gr,wr,br,_r,Mr,$r,vr,Or,Sr;let yr;(gr=hr.checkOptions)!=null&&gr.useSignatureImage&&(yr=((wr=nr.current)==null?void 0:wr.getTrimmedCanvas().toDataURL("image/png"))??""),(br=oe.entity)!=null&&br.id&&((Sr=oe.client)==null||Sr.entity.paymentMethod.update((_r=oe.entity)==null?void 0:_r.id,W.id,{accountName:hr.accountName,checkOptions:{enabled:(Mr=hr.checkOptions)==null?void 0:Mr.enabled,initialCheckNumber:Number(($r=hr.checkOptions)==null?void 0:$r.initialCheckNumber),signatoryName:`${(vr=hr.checkOptions)==null?void 0:vr.signatoryName}`,useSignatureImage:(Or=hr.checkOptions)==null?void 0:Or.useSignatureImage,...yr&&{signatureImage:yr}},type:javascript.Mercoa.PaymentMethodType.BankAccount,externalAccountingSystemId:hr.externalAccountingSystemId}).then(()=>{Q$1.success("Bank account updated"),re&&re(hr),oe.refresh()}).catch(Cr=>{Q$1.error("There was an error updating your bank account")}))}const dr=!!(W.accountType==="CHECKING"&&lr("checkOptions.enabled")),mr=lr("checkOptions.useSignatureImage");return React.useEffect(()=>{var hr,yr,gr;(hr=W.checkOptions)!=null&&hr.signatureImage&&nr.current&&((gr=nr.current)==null||gr.fromDataURL("data:image/gif;base64,"+((yr=W.checkOptions)==null?void 0:yr.signatureImage)))},[(pr=W.checkOptions)==null?void 0:pr.signatureImage,mr]),React.useEffect(()=>{var hr;oe.entityId&&((hr=oe.client)==null||hr.entity.metadata.get(oe.entityId,"externalAccountingSystemBankAccounts").then(yr=>{if(yr){const gr=yr.map(wr=>JSON.parse(wr));console.log(gr),ir(gr)}}))},[oe.entityId,oe.refreshId]),console.log(lr("externalAccountingSystemId")),oe.client?jsxRuntimeExports.jsxs("form",{onSubmit:cr(fr),children:[jsxRuntimeExports.jsx(MercoaInput,{label:"Account Name",name:"accountName",register:sr,optional:!0}),ar.length>0&&jsxRuntimeExports.jsx(MercoaCombobox,{label:"Accounting System Bank Name",onChange:hr=>{ur("externalAccountingSystemId",hr.key)},options:ar.map(hr=>({disabled:!1,value:hr})),displayIndex:"value",value:ar.find(hr=>hr.key===lr("externalAccountingSystemId")),className:"mercoa-mt-2"}),W.accountType==="CHECKING"&&jsxRuntimeExports.jsxs("div",{className:"mercoa-relative mercoa-mt-5 mercoa-flex mercoa-items-start mercoa-items-center",children:[jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-h-5 mercoa-items-center",children:jsxRuntimeExports.jsx("input",{...sr("checkOptions.enabled"),type:"checkbox",className:"mercoa-size-4 mercoa-rounded mercoa-border-gray-300 mercoa-text-mercoa-primary-text focus:mercoa-ring-mercoa-primary"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-ml-3 mercoa-text-sm",children:jsxRuntimeExports.jsx(Tooltip,{title:"If enabled, checks can be printed with the account and routing number of this account.",children:jsxRuntimeExports.jsxs("label",{htmlFor:"checkOptions.enabled",className:"mercoa-font-medium mercoa-text-gray-700",children:["Enable Check Payments",jsxRuntimeExports.jsx(ForwardRef$n,{className:"mercoa-inline mercoa-size-5"})]})})})]}),dr&&jsxRuntimeExports.jsxs("div",{className:"mercoa-bg-gray-100 mercoa-p-2 mercoa-rounded-mercoa mercoa-mt-2",children:[jsxRuntimeExports.jsx(MercoaInput,{label:"Initial Check Number",name:"checkOptions.initialCheckNumber",register:sr,optional:!0,className:"mercoa-mt-2"}),jsxRuntimeExports.jsx(MercoaInput,{label:"Signatory Name",name:"checkOptions.signatoryName",register:sr,required:!0,className:"mercoa-mt-2"}),jsxRuntimeExports.jsxs("div",{className:"mercoa-relative mercoa-mt-5 mercoa-flex mercoa-items-start mercoa-items-center",children:[jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-h-5 mercoa-items-center",children:jsxRuntimeExports.jsx("input",{...sr("checkOptions.useSignatureImage"),type:"checkbox",className:"mercoa-size-4 mercoa-rounded mercoa-border-gray-300 mercoa-text-mercoa-primary-text focus:mercoa-ring-mercoa-primary"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-ml-3 mercoa-text-sm",children:jsxRuntimeExports.jsx("label",{htmlFor:"useSig",className:"mercoa-font-medium mercoa-text-gray-700",children:"Use Custom Signature"})})]}),mr&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"mercoa-mt-2 mercoa-bg-white",children:jsxRuntimeExports.jsx(SignatureCanvas,{ref:nr,canvasProps:{width:375,height:150}})}),jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-2 mercoa-flex mercoa-gap-x-2",children:[jsxRuntimeExports.jsx("input",{type:"file",ref:or,style:{display:"none"},accept:"image/*",onChange:hr=>{var yr;hr.target.files&&((yr=nr.current)==null||yr.fromDataURL(URL.createObjectURL(hr.target.files[0])))}}),jsxRuntimeExports.jsx(MercoaButton,{size:"sm",isEmphasized:!1,type:"button",onClick:()=>{var hr;return(hr=or==null?void 0:or.current)==null?void 0:hr.click()},children:"Upload Image"}),jsxRuntimeExports.jsx(MercoaButton,{color:"red",size:"sm",isEmphasized:!1,type:"button",onClick:()=>{var hr;return(hr=nr.current)==null?void 0:hr.clear()},children:"Clear Signature"})]})]})]}),jsxRuntimeExports.jsx(MercoaButton,{size:"sm",isEmphasized:!1,className:"mercoa-mt-5",type:"button",onClick:()=>pe(!0),children:"Reconnect Bank Account"}),ie&&jsxRuntimeExports.jsx(PlaidPopup,{onExit:()=>pe(!1),paymentMethodId:W.id}),jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-justify-between mercoa-mt-5",children:[jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!1,onClick:()=>{re&&re()},type:"button",children:"Back"}),jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!0,children:"Update"})]})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"EditBankAccount"})}const moovCssVariables={"--moov-color-background":"#FFFFFF","--moov-color-background-secondary":"#F5F6F9","--moov-color-background-tertiary":"#E7E7F1","--moov-color-mercoa-primary":"#4A5CF5","--moov-color-secondary":"#3D50EC","--moov-color-tertiary":"#B9BBC3","--moov-color-info":"#94CBFF","--moov-color-warn":"#EB5757","--moov-color-danger":"#EA0F43","--moov-color-success":"#62E599","--moov-color-low-contrast":"#5B5D6A","--moov-color-medium-contrast":"#494A57","--moov-color-high-contrast":"#000000","--moov-color-graphic-1":"#3D50EC","--moov-color-graphic-2":"#3D50EC","--moov-color-graphic-3":"#3D50EC"};function Cards({children:W,onSelect:re,showAdd:oe,showEdit:ie}){var cr;const[pe,nr]=React.useState(),[or,ar]=React.useState(!1),ir=useMercoaSession();React.useEffect(()=>{var lr,ur,fr;ir.token&&((lr=ir.entity)!=null&&lr.id)&&((fr=ir.client)==null||fr.entity.paymentMethod.getAll((ur=ir.entity)==null?void 0:ur.id,{type:"card"}).then(dr=>{nr(dr.filter(mr=>mr).map(mr=>mr))}))},[(cr=ir.entity)==null?void 0:cr.id,ir.token,or,ir.refreshId]);const sr=lr=>{ar(!1),re&&lr&&re(lr)};return ir.client?W?W({bankAccounts:pe}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[!pe&&jsxRuntimeExports.jsx("div",{className:"mercoa-p-9 mercoa-text-center",children:jsxRuntimeExports.jsx(LoadingSpinnerIcon,{})}),jsxRuntimeExports.jsx(PaymentMethodList,{accounts:pe,showEdit:ie,addAccount:pe&&oe?jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-2",children:[jsxRuntimeExports.jsx(AddDialog,{show:or,onClose:sr,component:jsxRuntimeExports.jsx(AddCard,{onSubmit:lr=>{sr(lr)}})}),jsxRuntimeExports.jsx(Card,{onSelect:()=>ar(!0)})]}):void 0,formatAccount:lr=>jsxRuntimeExports.jsx(Card,{account:lr,onSelect:re,showEdit:ie})})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"CreditCards"})}function AddCard({onSubmit:W,title:re,actions:oe}){const ie=useMercoaSession();return React.useEffect(()=>{if(!ie.entityId||!ie.moovToken||!ie.moovAccountId)return;const pe=document.documentElement;for(let ar in moovCssVariables)pe.style.setProperty(ar,moovCssVariables[ar]);const nr=document.querySelector("moov-card-link");if(!nr)return;nr.setAttribute("oauth-token",ie.moovToken),nr.setAttribute("account-id",ie.moovAccountId);const or=async ar=>{var sr;const ir=await((sr=ie.client)==null?void 0:sr.entity.paymentMethod.create((ie==null?void 0:ie.entityId)??"",{type:"card",cardType:ar.cardType,cardBrand:ar.brand.replace(" ",""),lastFour:ar.lastFourCardNumber,expMonth:ar.expiration.month,expYear:ar.expiration.year,token:ar.cardID}));if(!ir)throw new Error("Failed to create payment method");W(ir)};nr.onSuccess=or},[ie.moovToken,ie.moovAccountId,ie.entityId]),ie.client?jsxRuntimeExports.jsxs("div",{className:"mercoa-space-y-3 mercoa-text-left",children:[re||jsxRuntimeExports.jsx("h3",{className:"mercoa-text-center mercoa-text-lg mercoa-font-medium mercoa-leading-6 mercoa-text-gray-900",children:"Add Card"}),jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-items-center mercoa-justify-center",children:[jsxRuntimeExports.jsx("moov-card-link",{}),jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!0,onClick:()=>{document.querySelector("moov-card-link").submit()},children:"Add"})]}),oe&&jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-justify-between",children:oe})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"AddCreditCard"})}function Card({children:W,account:re,onSelect:oe,showEdit:ie,selected:pe}){var ar,ir,sr;const nr=useMercoaSession();if(!nr.client)return jsxRuntimeExports.jsx(NoSession,{componentName:"CreditCardComponent"});if(!((sr=(ir=(ar=nr.organization)==null?void 0:ar.paymentMethods)==null?void 0:ir.payerPayments)!=null&&sr.find(cr=>cr.type==="card"&&cr.active)))return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{});let or=re==null?void 0:re.cardBrand;return or==="AmericanExpress"&&(or="Amex"),re?jsxRuntimeExports.jsxs("div",{onClick:()=>{oe&&oe(re)},className:`mercoa-relative mercoa-flex mercoa-items-center mercoa-space-x-3 mercoa-rounded-mercoa mercoa-border ${pe?"mercoa-border-gray-600":"mercoa-border-gray-300"} mercoa-bg-white mercoa-px-6 mercoa-py-5 mercoa-shadow-sm focus-within:mercoa-ring-2 focus-within:mercoa-ring-indigo-500 focus-within:mercoa-ring-offset-2 ${oe?"mercoa-cursor-pointer hover:mercoa-border-gray-400":""}`,children:[jsxRuntimeExports.jsx("div",{className:`mercoa-flex-shrink-0 mercoa-rounded-full mercoa-p-1 ${pe?"mercoa-text-mercoa-primary-text-invert mercoa-bg-mercoa-primary-light":"mercoa-bg-gray-200 mercoa-text-gray-600"}`,children:jsxRuntimeExports.jsx(ForwardRef$A,{className:"mercoa-size-5"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-min-w-0 mercoa-flex-1 mercoa-justify-between",children:jsxRuntimeExports.jsxs("div",{children:[!ie&&jsxRuntimeExports.jsx("span",{className:"mercoa-absolute mercoa-inset-0","aria-hidden":"true"}),jsxRuntimeExports.jsx("p",{className:`mercoa-text-sm mercoa-font-medium mercoa-text-gray-900 ${pe?"mercoa-underline":""}`,children:`${capitalize(or)} ••••${re==null?void 0:re.lastFour}`})]})}),ie&&jsxRuntimeExports.jsx("div",{className:"mercoa-flex",children:jsxRuntimeExports.jsx(DefaultPaymentMethodIndicator,{paymentMethod:re})})]},`${re==null?void 0:re.id}`):jsxRuntimeExports.jsxs("div",{onClick:()=>{oe&&oe(re)},className:`mercoa-relative mercoa-flex mercoa-items-center mercoa-space-x-3 mercoa-rounded-mercoa mercoa-border mercoa-border-gray-300 mercoa-bg-white mercoa-px-6 mercoa-py-5 mercoa-shadow-sm focus-within:mercoa-ring-2 focus-within:mercoa-ring-indigo-500 focus-within:mercoa-ring-offset-2 hover:mercoa-border-gray-400 ${oe?"mercoa-cursor-pointer ":""}`,children:[jsxRuntimeExports.jsx("div",{className:`mercoa-flex-shrink-0 mercoa-rounded-full mercoa-p-1 ${pe?"mercoa-text-mercoa-primary-text-invert mercoa-bg-mercoa-primary-light":"mercoa-bg-gray-200 mercoa-text-gray-600"}`,children:jsxRuntimeExports.jsx(ForwardRef$d,{className:"mercoa-size-5"})}),jsxRuntimeExports.jsxs("div",{className:"mercoa-min-w-0 mercoa-flex-1",children:[jsxRuntimeExports.jsx("span",{className:"mercoa-absolute mercoa-inset-0","aria-hidden":"true"}),jsxRuntimeExports.jsx("p",{className:"mercoa-text-sm mercoa-font-medium mercoa-text-gray-900",children:"Add new card"}),jsxRuntimeExports.jsx("p",{className:"mercoa-truncate mercoa-text-sm mercoa-text-gray-500"})]})]})}const postalCodeRegex=/(^\d{5}$)|(^\d{5}-\d{4}$)/,usaStates=[{name:"Alabama",abbreviation:"AL"},{name:"Alaska",abbreviation:"AK"},{name:"American Samoa",abbreviation:"AS"},{name:"Arizona",abbreviation:"AZ"},{name:"Arkansas",abbreviation:"AR"},{name:"California",abbreviation:"CA"},{name:"Colorado",abbreviation:"CO"},{name:"Connecticut",abbreviation:"CT"},{name:"Delaware",abbreviation:"DE"},{name:"District Of Columbia",abbreviation:"DC"},{name:"Federated States Of Micronesia",abbreviation:"FM"},{name:"Florida",abbreviation:"FL"},{name:"Georgia",abbreviation:"GA"},{name:"Guam",abbreviation:"GU"},{name:"Hawaii",abbreviation:"HI"},{name:"Idaho",abbreviation:"ID"},{name:"Illinois",abbreviation:"IL"},{name:"Indiana",abbreviation:"IN"},{name:"Iowa",abbreviation:"IA"},{name:"Kansas",abbreviation:"KS"},{name:"Kentucky",abbreviation:"KY"},{name:"Louisiana",abbreviation:"LA"},{name:"Maine",abbreviation:"ME"},{name:"Marshall Islands",abbreviation:"MH"},{name:"Maryland",abbreviation:"MD"},{name:"Massachusetts",abbreviation:"MA"},{name:"Michigan",abbreviation:"MI"},{name:"Minnesota",abbreviation:"MN"},{name:"Mississippi",abbreviation:"MS"},{name:"Missouri",abbreviation:"MO"},{name:"Montana",abbreviation:"MT"},{name:"Nebraska",abbreviation:"NE"},{name:"Nevada",abbreviation:"NV"},{name:"New Hampshire",abbreviation:"NH"},{name:"New Jersey",abbreviation:"NJ"},{name:"New Mexico",abbreviation:"NM"},{name:"New York",abbreviation:"NY"},{name:"North Carolina",abbreviation:"NC"},{name:"North Dakota",abbreviation:"ND"},{name:"Northern Mariana Islands",abbreviation:"MP"},{name:"Ohio",abbreviation:"OH"},{name:"Oklahoma",abbreviation:"OK"},{name:"Oregon",abbreviation:"OR"},{name:"Palau",abbreviation:"PW"},{name:"Pennsylvania",abbreviation:"PA"},{name:"Puerto Rico",abbreviation:"PR"},{name:"Rhode Island",abbreviation:"RI"},{name:"South Carolina",abbreviation:"SC"},{name:"South Dakota",abbreviation:"SD"},{name:"Tennessee",abbreviation:"TN"},{name:"Texas",abbreviation:"TX"},{name:"Utah",abbreviation:"UT"},{name:"Vermont",abbreviation:"VT"},{name:"Virgin Islands",abbreviation:"VI"},{name:"Virginia",abbreviation:"VA"},{name:"Washington",abbreviation:"WA"},{name:"West Virginia",abbreviation:"WV"},{name:"Wisconsin",abbreviation:"WI"},{name:"Wyoming",abbreviation:"WY"}];function Check({account:W,onSelect:re,showEdit:oe,selected:ie}){const pe=useMercoaSession();async function nr(){var or,ar,ir;pe.token&&((or=pe.entity)!=null&&or.id)&&(W!=null&&W.id)&&(await((ir=pe.client)==null?void 0:ir.entity.paymentMethod.delete((ar=pe.entity)==null?void 0:ar.id,W==null?void 0:W.id)),pe.refresh())}return pe.client?W?jsxRuntimeExports.jsxs("div",{onClick:()=>{re&&re(W)},className:`mercoa-relative mercoa-flex mercoa-items-center mercoa-space-x-3 mercoa-rounded-mercoa mercoa-border ${ie?"mercoa-border-gray-600":"mercoa-border-gray-300"} mercoa-bg-white mercoa-px-6 mercoa-py-5 mercoa-shadow-sm focus-within:mercoa-ring-2 focus-within:mercoa-ring-indigo-500 focus-within:mercoa-ring-offset-2 ${re?"mercoa-cursor-pointer hover:mercoa-border-gray-400":""}`,children:[jsxRuntimeExports.jsx("div",{className:`mercoa-flex-shrink-0 mercoa-rounded-full mercoa-p-1 ${ie?"mercoa-text-mercoa-primary-text-invert mercoa-bg-mercoa-primary-light":"mercoa-bg-gray-200 mercoa-text-gray-600"}`,children:jsxRuntimeExports.jsx(ForwardRef$v,{className:"mercoa-size-5"})}),jsxRuntimeExports.jsxs("div",{className:"mercoa-min-w-0 mercoa-flex-1",children:[!oe&&jsxRuntimeExports.jsx("span",{className:"mercoa-absolute mercoa-inset-0","aria-hidden":"true"}),jsxRuntimeExports.jsx("p",{className:`mercoa-text-sm mercoa-font-medium mercoa-text-gray-900 ${ie?"mercoa-underline":""}`,children:`${W==null?void 0:W.payToTheOrderOf}`}),jsxRuntimeExports.jsx("p",{className:`mercoa-text-sm mercoa-font-medium mercoa-text-gray-900 ${ie?"mercoa-underline":""}`,children:`${W==null?void 0:W.addressLine1}, ${W==null?void 0:W.addressLine2}`}),jsxRuntimeExports.jsx("p",{className:`mercoa-text-sm mercoa-font-medium mercoa-text-gray-900 ${ie?"mercoa-underline":""}`,children:`${W==null?void 0:W.city} ${W==null?void 0:W.stateOrProvince}, ${W==null?void 0:W.postalCode}`})]}),oe&&jsxRuntimeExports.jsxs("div",{className:"mercoa-flex-shrink-0",children:[jsxRuntimeExports.jsx(DefaultPaymentMethodIndicator,{paymentMethod:W}),jsxRuntimeExports.jsxs("button",{className:"mercoa-ml-1 mercoa-cursor-pointer hover:mercoa-text-red-300",onClick:()=>nr(),children:[" ",jsxRuntimeExports.jsx(ForwardRef$6,{className:"mercoa-size-5"})]})]})]},`${W==null?void 0:W.addressLine1} ${W==null?void 0:W.addressLine1}`):jsxRuntimeExports.jsxs("div",{onClick:()=>{re&&re()},className:`mercoa-relative mercoa-flex mercoa-items-center mercoa-space-x-3 mercoa-rounded-mercoa mercoa-border mercoa-border-gray-300 mercoa-bg-white mercoa-px-6 mercoa-py-5 mercoa-shadow-sm focus-within:mercoa-ring-2 focus-within:mercoa-ring-indigo-500 focus-within:mercoa-ring-offset-2 hover:mercoa-border-gray-400 ${re?"mercoa-cursor-pointer ":""}`,children:[jsxRuntimeExports.jsx("div",{className:`mercoa-flex-shrink-0 mercoa-rounded-full mercoa-p-1 ${ie?"mercoa-text-mercoa-primary-text-invert mercoa-bg-mercoa-primary-light":"mercoa-bg-gray-200 mercoa-text-gray-600"}`,children:jsxRuntimeExports.jsx(ForwardRef$d,{className:"mercoa-size-5"})}),jsxRuntimeExports.jsxs("div",{className:"mercoa-min-w-0 mercoa-flex-1",children:[jsxRuntimeExports.jsx("span",{className:"mercoa-absolute mercoa-inset-0","aria-hidden":"true"}),jsxRuntimeExports.jsx("p",{className:"mercoa-text-sm mercoa-font-medium mercoa-text-gray-900",children:"Add new address"}),jsxRuntimeExports.jsx("p",{className:"mercoa-truncate mercoa-text-sm mercoa-text-gray-500"})]})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"CheckComponent"})}function AddCheckDialog({entityId:W,onSelect:re,check:oe}){const[ie,pe]=React.useState(!1),nr=or=>{pe(!1),re&&or&&re(or)};return jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-2",children:[jsxRuntimeExports.jsx(AddDialog,{show:ie,onClose:nr,component:jsxRuntimeExports.jsx(AddCheck,{onSubmit:or=>{nr(or)},entityId:W,check:oe})}),jsxRuntimeExports.jsx(Check,{onSelect:()=>pe(!0)})]})}function AddCheck({onSubmit:W,title:re,actions:oe,check:ie,entityId:pe}){const nr=useMercoaSession(),or=create$3({payToTheOrderOf:create$6().required(),addressLine1:create$6().required(),city:create$6().required(),stateOrProvince:create$6().required(),postalCode:create$6().required()}).required(),ar=useForm({defaultValues:ie,resolver:o(or)});async function ir(sr){var cr,lr,ur;if((cr=nr.entity)!=null&&cr.id){sr.country="US";const fr=await((ur=nr.client)==null?void 0:ur.entity.paymentMethod.create(pe??((lr=nr.entity)==null?void 0:lr.id),{...sr,type:"check"}));if(!W)return;fr?W(fr):W()}}return nr.client?jsxRuntimeExports.jsx(FormProvider,{...ar,children:jsxRuntimeExports.jsxs("form",{className:"mercoa-space-y-3 mercoa-text-left",onSubmit:ar.handleSubmit(ir),children:[re||jsxRuntimeExports.jsx("h3",{className:"mercoa-text-center mercoa-text-lg mercoa-font-medium mercoa-leading-6 mercoa-text-gray-900",children:"Add Check Address"}),jsxRuntimeExports.jsx(AddCheckForm,{}),jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-justify-end",children:oe||jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!0,children:"Add Check Address"})})]})}):jsxRuntimeExports.jsx(NoSession,{componentName:"AddCheck"})}function AddCheckForm({prefix:W}){const{register:re,setValue:oe,watch:ie,formState:{errors:pe}}=useFormContext();W||(W="");const nr=ie(W+"stateOrProvince");return jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-flex-col mercoa-gap-y-2",children:[jsxRuntimeExports.jsx(MercoaInput,{register:re,name:W+"payToTheOrderOf",label:"Pay To The Order Of",className:"mercoa-mt-1"}),jsxRuntimeExports.jsx(MercoaInput,{register:re,name:W+"addressLine1",label:"Address Line 1",className:"mercoa-mt-1",errors:pe}),jsxRuntimeExports.jsxs("div",{className:"mercoa-grid mercoa-grid-cols-2 mercoa-gap-x-4",children:[jsxRuntimeExports.jsx(MercoaInput,{register:re,name:W+"addressLine2",label:"Address Line 2",className:"mercoa-mt-1",errors:pe}),jsxRuntimeExports.jsx(MercoaInput,{register:re,name:W+"city",label:"City",className:"mercoa-mt-1",errors:pe})]}),jsxRuntimeExports.jsxs("div",{className:"mercoa-grid mercoa-grid-cols-2 mercoa-gap-x-4",children:[jsxRuntimeExports.jsx(MercoaCombobox,{options:usaStates.map(({name:or,abbreviation:ar})=>({disabled:!1,value:ar})),label:"State",value:nr,onChange:or=>{oe(W+"stateOrProvince",or,{shouldDirty:!0})}}),jsxRuntimeExports.jsx(MercoaInput,{register:re,name:W+"postalCode",label:"Postal Code",className:"mercoa-mt-1",errors:pe})]})]})}var humanparser={exports:{}};const parser$2=humanparser.exports={};function diff(W,re){return W.concat(re).filter((oe,ie,pe)=>pe.indexOf(oe)===pe.lastIndexOf(oe))}const lc=W=>W.toLowerCase();parser$2.parseName=function(W,re={}){let oe=[],ie=[],pe=[],nr=[],or=[],ar=[];Array.isArray(re)?ar=re.map(mr=>mr.toLowerCase()):({extraCompound:oe=[],extraSalutations:ie=[],extraSuffixes:pe=[],ignoreCompound:nr=[],ignoreSalutation:or=[],ignoreSuffix:ar=[]}=re,oe=oe.map(lc),ie=ie.map(lc),pe=pe.map(lc),nr=nr.map(lc),or=or.map(lc),ar=ar.map(lc));const ir=["mr","master","mister","mrs","miss","ms","dr","prof","rev","fr","judge","honorable","hon","tuan","sr","srta","br","pr","mx","sra",...ie].filter(mr=>!or.includes(mr)),sr=["i","ii","iii","iv","v","senior","junior","jr","sr","phd","apr","rph","pe","md","ma","dmd","cme","qc","kc",...pe].filter(mr=>!ar.includes(mr)),cr=["vere","von","van","de","del","della","der","den","di","da","pietro","vanden","du","st.","st","la","lo","ter","bin","ibn","te","ten","op","ben","al",...oe].filter(mr=>!nr.includes(mr));let lr=W.trim().replace(/\b\s+(,\s+)\b/,"$1").replace(/\b,\b/,", ");lr=(lr.match(/[^\s"]+|"[^"]+"/g)||lr.split(/\s+/)).map(mr=>mr.match(/^".*"$/)?mr.slice(1,-1):mr);const ur={};if(!lr.length)return ur;if(lr.length===1&&(ur.firstName=lr[0]),lr.length>1&&sr.indexOf(lr[lr.length-1].toLowerCase().replace(/\./g,""))>-1&&(ur.suffix=lr.pop(),lr[lr.length-1]=lr[lr.length-1].replace(",","")),lr.every(mr=>mr.indexOf(",")===-1)){lr.length>1&&ir.indexOf(lr[0].toLowerCase().replace(/\./g,""))>-1?(ur.salutation=lr.shift(),lr.length===1?ur.lastName=lr.shift():ur.firstName=lr.shift()):ur.firstName=lr.shift(),ur.lastName||(ur.lastName=lr.length?lr.pop():"");const mr=lr.slice(0).reverse(),pr=[];mr.every(hr=>{const yr=hr.toLowerCase().replace(/\./g,"");return cr.indexOf(yr)>-1?(pr.push(hr),!0):!1}),pr.length&&(ur.lastName=pr.reverse().join(" ")+" "+ur.lastName,lr=diff(lr,pr)),lr.length&&(ur.middleName=lr.join(" ")),ur.lastName&&(ur.lastName=ur.lastName.replace(",","")),ur.fullName=W}else{let mr;const pr=lr.reduce((yr,gr,wr)=>Array.isArray(yr)?gr.indexOf(",")===-1?(yr.push(gr),yr):(gr=gr.replace(",",""),sr.indexOf(gr.toLowerCase().replace(/\./g,""))>-1?ur.suffix=gr:yr.push(gr),mr=wr+1,yr.join(" ")):yr,[]);ur.lastName=pr;var dr=lr.slice(mr);dr.length>1?(ur.firstName=dr.shift(),ur.middleName=dr.join(" ")):dr.length&&(ur.firstName=dr[0]);const hr=[];ur.firstName&&hr.push(ur.firstName),ur.middleName&&hr.push(ur.middleName),hr.push(ur.lastName),ur.suffix&&hr.push(ur.suffix),ur.fullName=hr.join(" ")}for(const[mr,pr]of Object.entries(ur))ur[mr]=pr.trim();return ur},parser$2.getFullestName=W=>{let re=W,oe=[];return(re.indexOf("&")>-1||re.toLowerCase().indexOf(" and ")>-1)&&(oe=re.split(/\s+(?:and|&)\s+/gi),oe.length&&(re=oe.sort(function(ie,pe){return pe.split(/\s+/).length-ie.split(/\s+/).length})[0])),re},parser$2.parseAddress=W=>{W=W.replace(/\n/gi,", ");const re=W.split(/,\s+/).reverse();let oe,ie;const pe={};return oe=re[0].split(/\s+/),re.shift(),ie=re.shift(),pe.address=re.reverse().join(", "),pe.city=ie,pe.state=oe[0],pe.zip=oe[1],pe.fullAddress=W,pe};var humanparserExports=humanparser.exports;const vitePluginRequire_1721688910731_31976934=getDefaultExportFromCjs(humanparserExports);function isObject$5(W){var re=typeof W;return W!=null&&(re=="object"||re=="function")}var isObject_1=isObject$5,freeGlobal$1=typeof commonjsGlobal$1=="object"&&commonjsGlobal$1&&commonjsGlobal$1.Object===Object&&commonjsGlobal$1,_freeGlobal=freeGlobal$1,freeGlobal=_freeGlobal,freeSelf=typeof self=="object"&&self&&self.Object===Object&&self,root$4=freeGlobal||freeSelf||Function("return this")(),_root=root$4,root$3=_root,now$1=function(){return root$3.Date.now()},now_1=now$1,reWhitespace=/\s/;function trimmedEndIndex$1(W){for(var re=W.length;re--&&reWhitespace.test(W.charAt(re)););return re}var _trimmedEndIndex=trimmedEndIndex$1,trimmedEndIndex=_trimmedEndIndex,reTrimStart=/^\s+/;function baseTrim$1(W){return W&&W.slice(0,trimmedEndIndex(W)+1).replace(reTrimStart,"")}var _baseTrim=baseTrim$1,root$2=_root,Symbol$4=root$2.Symbol,_Symbol=Symbol$4,Symbol$3=_Symbol,objectProto$4=Object.prototype,hasOwnProperty$3=objectProto$4.hasOwnProperty,nativeObjectToString$1=objectProto$4.toString,symToStringTag$1=Symbol$3?Symbol$3.toStringTag:void 0;function getRawTag$1(W){var re=hasOwnProperty$3.call(W,symToStringTag$1),oe=W[symToStringTag$1];try{W[symToStringTag$1]=void 0;var ie=!0}catch{}var pe=nativeObjectToString$1.call(W);return ie&&(re?W[symToStringTag$1]=oe:delete W[symToStringTag$1]),pe}var _getRawTag=getRawTag$1,objectProto$3=Object.prototype,nativeObjectToString=objectProto$3.toString;function objectToString$1(W){return nativeObjectToString.call(W)}var _objectToString=objectToString$1,Symbol$2=_Symbol,getRawTag=_getRawTag,objectToString=_objectToString,nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=Symbol$2?Symbol$2.toStringTag:void 0;function baseGetTag$2(W){return W==null?W===void 0?undefinedTag:nullTag:symToStringTag&&symToStringTag in Object(W)?getRawTag(W):objectToString(W)}var _baseGetTag=baseGetTag$2;function isObjectLike$1(W){return W!=null&&typeof W=="object"}var isObjectLike_1=isObjectLike$1,baseGetTag$1=_baseGetTag,isObjectLike=isObjectLike_1,symbolTag="[object Symbol]";function isSymbol$4(W){return typeof W=="symbol"||isObjectLike(W)&&baseGetTag$1(W)==symbolTag}var isSymbol_1=isSymbol$4,baseTrim=_baseTrim,isObject$4=isObject_1,isSymbol$3=isSymbol_1,NAN=NaN,reIsBadHex=/^[-+]0x[0-9a-f]+$/i,reIsBinary=/^0b[01]+$/i,reIsOctal=/^0o[0-7]+$/i,freeParseInt=parseInt;function toNumber$1(W){if(typeof W=="number")return W;if(isSymbol$3(W))return NAN;if(isObject$4(W)){var re=typeof W.valueOf=="function"?W.valueOf():W;W=isObject$4(re)?re+"":re}if(typeof W!="string")return W===0?W:+W;W=baseTrim(W);var oe=reIsBinary.test(W);return oe||reIsOctal.test(W)?freeParseInt(W.slice(2),oe?2:8):reIsBadHex.test(W)?NAN:+W}var toNumber_1=toNumber$1,isObject$3=isObject_1,now=now_1,toNumber=toNumber_1,FUNC_ERROR_TEXT$1="Expected a function",nativeMax=Math.max,nativeMin=Math.min;function debounce$1(W,re,oe){var ie,pe,nr,or,ar,ir,sr=0,cr=!1,lr=!1,ur=!0;if(typeof W!="function")throw new TypeError(FUNC_ERROR_TEXT$1);re=toNumber(re)||0,isObject$3(oe)&&(cr=!!oe.leading,lr="maxWait"in oe,nr=lr?nativeMax(toNumber(oe.maxWait)||0,re):nr,ur="trailing"in oe?!!oe.trailing:ur);function fr(_r){var Mr=ie,$r=pe;return ie=pe=void 0,sr=_r,or=W.apply($r,Mr),or}function dr(_r){return sr=_r,ar=setTimeout(hr,re),cr?fr(_r):or}function mr(_r){var Mr=_r-ir,$r=_r-sr,vr=re-Mr;return lr?nativeMin(vr,nr-$r):vr}function pr(_r){var Mr=_r-ir,$r=_r-sr;return ir===void 0||Mr>=re||Mr<0||lr&&$r>=nr}function hr(){var _r=now();if(pr(_r))return yr(_r);ar=setTimeout(hr,mr(_r))}function yr(_r){return ar=void 0,ur&&ie?fr(_r):(ie=pe=void 0,or)}function gr(){ar!==void 0&&clearTimeout(ar),sr=0,ie=ir=pe=ar=void 0}function wr(){return ar===void 0?or:yr(now())}function br(){var _r=now(),Mr=pr(_r);if(ie=arguments,pe=this,ir=_r,Mr){if(ar===void 0)return dr(ir);if(lr)return clearTimeout(ar),ar=setTimeout(hr,re),fr(ir)}return ar===void 0&&(ar=setTimeout(hr,re)),or}return br.cancel=gr,br.flush=wr,br}var debounce_1=debounce$1;const debounce$2=getDefaultExportFromCjs(debounce_1),human=vitePluginRequire_1721688910731_31976934;async function onSubmitCounterparty({data:W,mercoaSession:re,type:oe,setError:ie,onSelect:pe}){var ar,ir,sr,cr,lr;if(!((ar=re.entity)!=null&&ar.id))return;const nr={};if(W.accountType==="individual"){if(nr.individual={email:W.email,name:{firstName:W.firstName??"",lastName:W.lastName??"",middleName:W.middleName??"",suffix:W.suffix??""}},!nr.individual.name.firstName){ie("vendor.firstName",{type:"manual",message:"First Name is required"});return}if(!nr.individual.name.lastName){ie("vendor.lastName",{type:"manual",message:"Last Name is required"});return}}else{if(nr.business={email:W.email,description:W.description,website:W.website,legalBusinessName:W.name},!nr.business.legalBusinessName){ie("vendor.name",{type:"manual",message:"Name is required"});return}if(!nr.business.website&&!nr.business.description){ie("vendor.website",{type:"manual",message:"Website or description is required"}),ie("vendor.description",{type:"manual",message:"Website or description is required"});return}}let or;W!=null&&W.id&&W.id!=="new"?or=await((ir=re.client)==null?void 0:ir.entity.update(W.id,{profile:nr,accountType:W.accountType})):or=await((sr=re.client)==null?void 0:sr.entity.create({profile:nr,accountType:W.accountType,isPayee:oe==="payee",isPayor:oe==="payor",isCustomer:!1})),or!=null&&or.id&&(oe==="payee"?await((cr=re.client)==null?void 0:cr.entity.counterparty.addPayees(re.entity.id,{payees:[or.id]})):await((lr=re.client)==null?void 0:lr.entity.counterparty.addPayors(re.entity.id,{payors:[or.id]})),pe&&pe(or))}const counterpartyYupValidation={id:create$6().nullable(),name:create$6().typeError("Please enter a name"),email:create$6().email("Please enter a valid email"),accountType:create$6(),firstName:create$6(),lastName:create$6(),middleName:create$6(),suffix:create$6(),website:create$6().url("Website must start with http:// or https:// and be a valid URL"),description:create$6(),accounts:create$2().of(create$3().shape({accountId:create$6(),postalCode:create$6().nullable(),nameOnAccount:create$6().nullable()}))};function CounterpartySearch({counterparty:W,disableCreation:re,onSelect:oe,type:ie,network:pe}){var ur,fr,dr,mr,pr,hr,yr,gr,wr,br,_r,Mr,$r,vr,Or,Sr,Cr,Ir,Dr,qr;const nr=useMercoaSession(),[or,ar]=React.useState(!1),ir=useForm({resolver:o(create$3({vendor:create$3().shape(counterpartyYupValidation)}).required()),defaultValues:{vendor:{id:W==null?void 0:W.id,accountType:W==null?void 0:W.accountType,name:W==null?void 0:W.name,firstName:(dr=(fr=(ur=W==null?void 0:W.profile)==null?void 0:ur.individual)==null?void 0:fr.name)==null?void 0:dr.firstName,lastName:(hr=(pr=(mr=W==null?void 0:W.profile)==null?void 0:mr.individual)==null?void 0:pr.name)==null?void 0:hr.lastName,middleName:(wr=(gr=(yr=W==null?void 0:W.profile)==null?void 0:yr.individual)==null?void 0:gr.name)==null?void 0:wr.middleName,suffix:(Mr=(_r=(br=W==null?void 0:W.profile)==null?void 0:br.individual)==null?void 0:_r.name)==null?void 0:Mr.suffix,email:(W==null?void 0:W.accountType)==="business"?(vr=($r=W==null?void 0:W.profile)==null?void 0:$r.business)==null?void 0:vr.email:(Sr=(Or=W==null?void 0:W.profile)==null?void 0:Or.individual)==null?void 0:Sr.email,website:(Ir=(Cr=W==null?void 0:W.profile)==null?void 0:Cr.business)==null?void 0:Ir.website,description:(qr=(Dr=W==null?void 0:W.profile)==null?void 0:Dr.business)==null?void 0:qr.description}}}),{handleSubmit:sr,setError:cr}=ir,lr=async Zr=>{var en;if(!((en=nr.entity)!=null&&en.id))return;const Yr=Zr.vendor;await onSubmitCounterparty({data:Yr,mercoaSession:nr,type:ie,setError:cr,onSelect:Jr=>{oe==null||oe(Jr),ar(!1)}})};return jsxRuntimeExports.jsx(FormProvider,{...ir,children:jsxRuntimeExports.jsx("form",{onSubmit:sr(lr),className:"mercoa-p-3 mercoa-bg-gray-100 mercoa-rounded-mercoa mercoa-relative mercoa-w-full",children:jsxRuntimeExports.jsx(CounterpartySearchBase,{counterparty:W,disableCreation:re,onSelect:oe,type:ie,network:pe,edit:or,setEdit:ar})})})}function PayableCounterpartySearch({counterparty:W,disableCreation:re,onSelect:oe,network:ie}){var sr,cr;const[pe,nr]=React.useState(!1),{formState:{errors:or}}=useFormContext();React.useEffect(()=>{nr(!1)},[W]);const{watch:ar}=useFormContext(),ir=ar("status");return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"sm:mercoa-col-span-3",children:[jsxRuntimeExports.jsx("label",{htmlFor:"vendor-name",className:"mercoa-block mercoa-text-lg mercoa-font-medium mercoa-leading-6 mercoa-text-gray-700",children:"Vendor"}),jsxRuntimeExports.jsx("div",{className:"mercoa-mt-2 mercoa-flex mercoa-items-center mercoa-justify-left",children:jsxRuntimeExports.jsx("div",{className:"mercoa-p-3 mercoa-bg-gray-100 mercoa-rounded-mercoa mercoa-relative mercoa-w-full",children:jsxRuntimeExports.jsx(CounterpartySearchBase,{counterparty:W,disableCreation:re,onSelect:oe,type:"payee",network:ie,edit:pe,setEdit:nr,readOnly:!!ir&&ir!==javascript.Mercoa.InvoiceStatus.Draft})})}),((sr=or.vendorId)==null?void 0:sr.message)&&jsxRuntimeExports.jsx("p",{className:"mercoa-text-sm mercoa-text-red-500",children:(cr=or.vendorId)==null?void 0:cr.message.toString()})]})})}function AddCounterpartyModal({type:W,show:re,setShow:oe}){const ie=useMercoaSession(),pe=useForm({resolver:o(create$3({vendor:create$3().shape(counterpartyYupValidation)}).required()),defaultValues:{vendor:{id:"",accountType:"business",name:"",firstName:"",lastName:"",middleName:"",suffix:"",email:"",website:"",description:""}}}),{handleSubmit:nr,setError:or}=pe,ar=async ir=>{var cr;if(!((cr=ie.entity)!=null&&cr.id))return;const sr=ir.vendor;await onSubmitCounterparty({data:sr,mercoaSession:ie,type:W,setError:or,onSelect:lr=>{oe(!1),ie.refresh()}})};return ie.client?jsxRuntimeExports.jsx(qe$1.Root,{show:re,as:React.Fragment,children:jsxRuntimeExports.jsxs(_t$1,{as:"div",className:"mercoa-relative mercoa-z-10",onClose:()=>{ie.refresh(),oe(!1)},children:[jsxRuntimeExports.jsx(qe$1.Child,{as:React.Fragment,enter:"mercoa-ease-out mercoa-duration-300",enterFrom:"mercoa-opacity-0",enterTo:"mercoa-opacity-100",leave:"mercoa-ease-in mercoa-duration-200",leaveFrom:"mercoa-opacity-100",leaveTo:"mercoa-opacity-0",children:jsxRuntimeExports.jsx("div",{className:"mercoa-fixed mercoa-inset-0 mercoa-bg-gray-500 mercoa-bg-mercoa-opacity-75 mercoa-transition-opacity"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-fixed mercoa-inset-0 mercoa-z-10 mercoa-overflow-y-auto",children:jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-min-h-full mercoa-items-end mercoa-justify-center mercoa-p-4 mercoa-text-center sm:mercoa-items-center sm:mercoa-p-0",children:jsxRuntimeExports.jsx(qe$1.Child,{as:React.Fragment,enter:"mercoa-ease-out mercoa-duration-300",enterFrom:"mercoa-opacity-0 mercoa-translate-y-4 sm:mercoa-translate-y-0 sm:mercoa-scale-95",enterTo:"mercoa-opacity-100 mercoa-translate-y-0 sm:mercoa-scale-100",leave:"mercoa-ease-in mercoa-duration-200",leaveFrom:"mercoa-opacity-100 mercoa-translate-y-0 sm:mercoa-scale-100",leaveTo:"mercoa-opacity-0 mercoa-translate-y-4 sm:mercoa-translate-y-0 sm:mercoa-scale-95",children:jsxRuntimeExports.jsx(_t$1.Panel,{className:"mercoa-relative mercoa-transform mercoa-rounded-mercoa mercoa-bg-white mercoa-text-left mercoa-shadow-xl mercoa-transition-all",children:jsxRuntimeExports.jsx("div",{className:"mercoa-w-[600px]",children:jsxRuntimeExports.jsx(FormProvider,{...pe,children:jsxRuntimeExports.jsx("form",{onSubmit:nr(ar),className:"mercoa-p-3 mercoa-bg-gray-100 mercoa-rounded-mercoa mercoa-relative mercoa-w-full",children:jsxRuntimeExports.jsx(CounterpartyAddOrEditForm,{onComplete:()=>{oe(!1),ie.refresh()},onExit:()=>{oe(!1)}})})})})})})})})]})}):jsxRuntimeExports.jsx(NoSession,{componentName:"AddCounterpartyModal"})}function CounterpartySearchBase({counterparty:W,disableCreation:re,onSelect:oe,type:ie,network:pe,edit:nr,setEdit:or,readOnly:ar}){var _r,Mr,$r,vr,Or,Sr,Cr;const ir=useMercoaSession(),sr=React.useRef(null),[cr,lr]=React.useState(""),[ur,fr]=React.useState(),[dr,mr]=React.useState(),[pr,hr]=React.useState(),[yr,gr]=React.useState(),wr=React.useRef(debounce$2(fr,200)).current;React.useEffect(()=>{wr(yr)},[yr]),React.useEffect(()=>{W&&hr(W)},[W]),React.useEffect(()=>{var Dr,qr,Zr,Yr,en,Jr,kr,on,Xr,Br,xr;if(!((Dr=ir.entity)!=null&&Dr.id))return;let Ir=[javascript.Mercoa.CounterpartyNetworkType.Entity];(((Yr=(Zr=(qr=ir.iframeOptions)==null?void 0:qr.options)==null?void 0:Zr.vendors)==null?void 0:Yr.network)==="platform"||((kr=(Jr=(en=ir.iframeOptions)==null?void 0:en.options)==null?void 0:Jr.vendors)==null?void 0:kr.network)==="all")&&Ir.push(javascript.Mercoa.CounterpartyNetworkType.Network),pe&&(Ir=[...pe]),ie==="payee"?(Xr=ir.client)==null||Xr.entity.counterparty.findPayees((on=ir.entity)==null?void 0:on.id,{paymentMethods:!0,networkType:Ir,name:ur}).then(Rr=>{mr(Rr.data)}):(xr=ir.client)==null||xr.entity.counterparty.findPayors((Br=ir.entity)==null?void 0:Br.id,{paymentMethods:!0,networkType:Ir,name:ur}).then(Rr=>{mr(Rr.data)})},[(_r=ir.entity)==null?void 0:_r.id,ir.token,ir.refreshId,ur]);function br(Ir){hr(Ir),oe==null||oe(Ir),Ir&&or(!1)}if(pr!=null&&pr.id&&(pr==null?void 0:pr.id)!=="new"&&!nr)return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{className:"mercoa-w-full mercoa-flex mercoa-items-center",children:jsxRuntimeExports.jsx("div",{className:"mercoa-flex-auto",children:jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-items-center mercoa-bg-gray-50 mercoa-rounded-mercoa",children:[jsxRuntimeExports.jsxs("div",{className:"mercoa-flex-auto mercoa-p-3",children:[jsxRuntimeExports.jsx("div",{className:"mercoa-text-sm mercoa-font-medium mercoa-text-gray-900",children:pr==null?void 0:pr.name}),!((vr=($r=(Mr=ir.iframeOptions)==null?void 0:Mr.options)==null?void 0:$r.vendors)!=null&&vr.disableCreation)&&!re&&jsxRuntimeExports.jsx("div",{className:"mercoa-text-sm mercoa-text-gray-500",children:pr==null?void 0:pr.email})]}),!ar&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("button",{onClick:()=>{br(void 0)},type:"button",className:"mercoa-ml-4 mercoa-flex-shrink-0 mercoa-p-1 mercoa-text-mercoa-primary-text hover:mercoa-opacity-75",children:[jsxRuntimeExports.jsx(ForwardRef$2,{className:"mercoa-size-5 mercoa-text-gray-400","aria-hidden":"true"}),jsxRuntimeExports.jsx("span",{className:"mercoa-sr-only",children:"Clear"})]}),!((Cr=(Sr=(Or=ir.iframeOptions)==null?void 0:Or.options)==null?void 0:Sr.vendors)!=null&&Cr.disableCreation)&&!re&&jsxRuntimeExports.jsxs("button",{onClick:()=>{or(!0)},type:"button",className:"mercoa-ml-4 mercoa-flex-shrink-0 mercoa-p-1 mercoa-text-mercoa-primary-text hover:mercoa-opacity-75",children:[jsxRuntimeExports.jsx(ForwardRef$g,{className:"mercoa-size-5 mercoa-text-gray-400","aria-hidden":"true"}),jsxRuntimeExports.jsx("span",{className:"mercoa-sr-only",children:"Edit"})]})]})]})})})});if((pr==null?void 0:pr.id)==="new"){if(cr)return jsxRuntimeExports.jsx(CounterpartyAddOrEditForm,{name:cr,onComplete:Ir=>{br(Ir),setTimeout(()=>or(!0),100)},onExit:oe});if(pr)return jsxRuntimeExports.jsx(CounterpartyAddOrEditForm,{counterparty:pr,onComplete:br,onExit:oe})}else if(pr!=null&&pr.id&&nr)return jsxRuntimeExports.jsx(CounterpartyAddOrEditForm,{counterparty:pr,onComplete:br,onExit:oe});return dr?(ir.debug({selectedCounterparty:pr}),ir.client?jsxRuntimeExports.jsx(qt$1,{as:"div",value:pr,onChange:br,nullable:!0,className:"mercoa-w-full",children:({open:Ir})=>{var Dr,qr,Zr;return jsxRuntimeExports.jsxs("div",{className:"mercoa-relative mercoa-mt-2 mercoa-w-full",children:[jsxRuntimeExports.jsx(qt$1.Input,{placeholder:"Enter a company name...",autoComplete:"off",className:"mercoa-w-full mercoa-rounded-mercoa mercoa-border-0 mercoa-bg-white mercoa-py-1.5 mercoa-pl-3 mercoa-pr-10 mercoa-text-gray-900 mercoa-shadow-sm mercoa-ring-1 mercoa-ring-inset mercoa-ring-gray-300 focus:mercoa-ring-2 focus:mercoa-ring-inset focus:mercoa-ring-mercoa-primary sm:mercoa-text-sm sm:mercoa-leading-6",onFocus:()=>{var Yr;Ir||(gr(void 0),(Yr=sr.current)==null||Yr.click())},onChange:Yr=>{var en;lr(Yr.target.value),gr(((en=Yr.target.value)==null?void 0:en.toLowerCase())??"")},displayValue:Yr=>(Yr==null?void 0:Yr.name)??""}),jsxRuntimeExports.jsx(qt$1.Button,{className:"mercoa-absolute mercoa-inset-y-0 mercoa-right-0 mercoa-flex mercoa-items-center mercoa-rounded-r-md mercoa-px-2 focus:mercoa-outline-none",ref:sr,children:jsxRuntimeExports.jsx(ForwardRef$D,{className:"mercoa-size-5 mercoa-text-gray-400","aria-hidden":"true"})}),jsxRuntimeExports.jsxs(qt$1.Options,{className:"mercoa-absolute mercoa-z-10 mercoa-mt-1 mercoa-max-h-60 mercoa-w-full mercoa-overflow-auto mercoa-rounded-mercoa mercoa-bg-white mercoa-py-1 mercoa-text-base mercoa-shadow-lg mercoa-ring-1 mercoa-ring-black mercoa-ring-opacity-5 focus:mercoa-outline-none sm:mercoa-text-sm",children:[dr.map(Yr=>jsxRuntimeExports.jsx(qt$1.Option,{value:Yr,className:({active:en})=>`mercoa-relative mercoa-cursor-pointer mercoa-py-2 mercoa-pl-3 mercoa-pr-9 ${en?"mercoa-bg-mercoa-primary mercoa-text-mercoa-primary-text-invert":"mercoa-text-gray-900"}`,children:jsxRuntimeExports.jsx("span",{children:Yr.name})},Yr.id)),!((Zr=(qr=(Dr=ir.iframeOptions)==null?void 0:Dr.options)==null?void 0:qr.vendors)!=null&&Zr.disableCreation)&&!re&&jsxRuntimeExports.jsx(qt$1.Option,{value:{id:"new"},children:({active:Yr})=>jsxRuntimeExports.jsxs("div",{className:`mercoa-flex mercoa-items-center mercoa-cursor-pointer mercoa-py-2 mercoa-pl-3 mercoa-pr-9 ${Yr?"mercoa-bg-mercoa-primary mercoa-text-mercoa-primary-text-invert":"mercoa-text-gray-900"}`,children:[jsxRuntimeExports.jsx(ForwardRef$d,{className:"mercoa-size-5 mercoa-pr-1"}),"Add New"]})})]})]})}}):jsxRuntimeExports.jsx(NoSession,{componentName:"CounterpartySearch"})):jsxRuntimeExports.jsxs("div",{className:"mercoa-relative mercoa-mt-2",children:[jsxRuntimeExports.jsx("input",{className:inputClassName({}),placeholder:"Loading...",value:"Loading...",readOnly:!0}),jsxRuntimeExports.jsx("button",{className:"mercoa-absolute mercoa-inset-y-0 mercoa-right-0 mercoa-flex mercoa-items-center mercoa-rounded-r-md mercoa-px-2 focus:mercoa-outline-none",children:jsxRuntimeExports.jsx(ForwardRef$D,{className:"mercoa-size-5 mercoa-text-gray-400","aria-hidden":"true"})})]})}function CounterpartyAddOrEditForm({counterparty:W,name:re,onComplete:oe,onExit:ie}){var lr,ur,fr;const{register:pe,watch:nr,setValue:or,formState:{errors:ar}}=useFormContext();let ir=re;!ir&&(W==null?void 0:W.accountType)==="business"?ir=(ur=(lr=W==null?void 0:W.profile)==null?void 0:lr.business)==null?void 0:ur.legalBusinessName:!ir&&(W==null?void 0:W.accountType)==="individual"&&((fr=W==null?void 0:W.profile)!=null&&fr.individual)&&(ir=`${constructFullName(W.profile.individual.name.firstName,W.profile.individual.name.lastName,W.profile.individual.name.middleName,W.profile.individual.name.suffix)}`),React.useEffect(()=>{var dr,mr,pr,hr,yr,gr,wr,br,_r,Mr,$r,vr,Or,Sr,Cr,Ir,Dr,qr,Zr,Yr;or("vendor.id",W==null?void 0:W.id),or("vendor.accountType",W==null?void 0:W.accountType),or("vendor.name",ir),or("vendor.firstName",(pr=(mr=(dr=W==null?void 0:W.profile)==null?void 0:dr.individual)==null?void 0:mr.name)==null?void 0:pr.firstName),or("vendor.lastName",(gr=(yr=(hr=W==null?void 0:W.profile)==null?void 0:hr.individual)==null?void 0:yr.name)==null?void 0:gr.lastName),or("vendor.middleName",(_r=(br=(wr=W==null?void 0:W.profile)==null?void 0:wr.individual)==null?void 0:br.name)==null?void 0:_r.middleName),or("vendor.suffix",(vr=($r=(Mr=W==null?void 0:W.profile)==null?void 0:Mr.individual)==null?void 0:$r.name)==null?void 0:vr.suffix),or("vendor.email",(W==null?void 0:W.accountType)==="business"?(Sr=(Or=W==null?void 0:W.profile)==null?void 0:Or.business)==null?void 0:Sr.email:(Ir=(Cr=W==null?void 0:W.profile)==null?void 0:Cr.individual)==null?void 0:Ir.email),or("vendor.website",(qr=(Dr=W==null?void 0:W.profile)==null?void 0:Dr.business)==null?void 0:qr.website),or("vendor.description",(Yr=(Zr=W==null?void 0:W.profile)==null?void 0:Zr.business)==null?void 0:Yr.description)},[W]);const sr=nr("vendor.accountType"),cr=nr("vendor.name");return React.useEffect(()=>{if(!(!cr&&!sr))if(sr==="business")or("vendor.firstName","business"),or("vendor.lastName","business");else{const{firstName:dr,suffix:mr,lastName:pr,middleName:hr}=human.parseName(cr);or("vendor.firstName",dr),or("vendor.lastName",pr),or("vendor.middleName",hr),or("vendor.suffix",mr)}},[cr,sr]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("button",{type:"button",className:"mercoa-absolute mercoa-top-2 mercoa-right-2",onClick:()=>{oe(void 0),(W==null?void 0:W.id)==="new"&&ie&&ie({id:""})},children:[jsxRuntimeExports.jsx(ForwardRef$1,{className:"mercoa-size-5 mercoa-text-gray-400","aria-hidden":"true"}),jsxRuntimeExports.jsx("span",{className:"mercoa-sr-only",children:"Close"})]}),jsxRuntimeExports.jsx(MercoaInput,{label:"Name",name:"vendor.name",register:pe,placeholder:"Name",errors:ar,leadingIcon:jsxRuntimeExports.jsx(ForwardRef$4,{className:"mercoa-size-5 mercoa-text-gray-400","aria-hidden":"true"}),className:"mercoa-mt-1"}),jsxRuntimeExports.jsx(MercoaInput,{label:"Email",name:"vendor.email",register:pe,placeholder:"Email",errors:ar,leadingIcon:jsxRuntimeExports.jsx(ForwardRef$v,{className:"mercoa-size-5 mercoa-text-gray-400","aria-hidden":"true"}),className:"mercoa-mt-1"}),jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-1 mercoa-mt-2 mercoa-flex mercoa-space-x-2",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>or("vendor.accountType","individual"),className:`mercoa-flex-grow mercoa-rounded-mercoa mercoa-border mercoa-border-gray-300 mercoa-text-center mercoa-text-gray-600
45
+ `+(ar!==or?`result of cast: ${ar}`:""))}return nr}_cast(re,oe){let ie=re===void 0?re:this.transforms.reduce((pe,nr)=>nr.call(this,pe,re,this),re);return ie===void 0&&(ie=this.getDefault(oe)),ie}_validate(re,oe={},ie,pe){let{path:nr,originalValue:or=re,strict:ar=this.spec.strict}=oe,ir=re;ar||(ir=this._cast(ir,Object.assign({assert:!1},oe)));let sr=[];for(let cr of Object.values(this.internalTests))cr&&sr.push(cr);this.runTests({path:nr,value:ir,originalValue:or,options:oe,tests:sr},ie,cr=>{if(cr.length)return pe(cr,ir);this.runTests({path:nr,value:ir,originalValue:or,options:oe,tests:this.tests},ie,pe)})}runTests(re,oe,ie){let pe=!1,{tests:nr,value:or,originalValue:ar,path:ir,options:sr}=re,cr=mr=>{pe||(pe=!0,oe(mr,or))},lr=mr=>{pe||(pe=!0,ie(mr,or))},ur=nr.length,fr=[];if(!ur)return lr([]);let dr={value:or,originalValue:ar,path:ir,options:sr,schema:this};for(let mr=0;mr<nr.length;mr++){const pr=nr[mr];pr(dr,cr,function(yr){yr&&(Array.isArray(yr)?fr.push(...yr):fr.push(yr)),--ur<=0&&lr(fr)})}}asNestedTest({key:re,index:oe,parent:ie,parentPath:pe,originalParent:nr,options:or}){const ar=re??oe;if(ar==null)throw TypeError("Must include `key` or `index` for nested validations");const ir=typeof ar=="number";let sr=ie[ar];const cr=Object.assign({},or,{strict:!0,parent:ie,value:sr,originalValue:nr[ar],key:void 0,[ir?"index":"key"]:ar,path:ir||ar.includes(".")?`${pe||""}[${ir?ar:`"${ar}"`}]`:(pe?`${pe}.`:"")+re});return(lr,ur,fr)=>this.resolve(cr)._validate(sr,cr,ur,fr)}validate(re,oe){var ie;let pe=this.resolve(Object.assign({},oe,{value:re})),nr=(ie=oe==null?void 0:oe.disableStackTrace)!=null?ie:pe.spec.disableStackTrace;return new Promise((or,ar)=>pe._validate(re,oe,(ir,sr)=>{ValidationError.isError(ir)&&(ir.value=sr),ar(ir)},(ir,sr)=>{ir.length?ar(new ValidationError(ir,sr,void 0,void 0,nr)):or(sr)}))}validateSync(re,oe){var ie;let pe=this.resolve(Object.assign({},oe,{value:re})),nr,or=(ie=oe==null?void 0:oe.disableStackTrace)!=null?ie:pe.spec.disableStackTrace;return pe._validate(re,Object.assign({},oe,{sync:!0}),(ar,ir)=>{throw ValidationError.isError(ar)&&(ar.value=ir),ar},(ar,ir)=>{if(ar.length)throw new ValidationError(ar,re,void 0,void 0,or);nr=ir}),nr}isValid(re,oe){return this.validate(re,oe).then(()=>!0,ie=>{if(ValidationError.isError(ie))return!1;throw ie})}isValidSync(re,oe){try{return this.validateSync(re,oe),!0}catch(ie){if(ValidationError.isError(ie))return!1;throw ie}}_getDefault(re){let oe=this.spec.default;return oe==null?oe:typeof oe=="function"?oe.call(this,re):clone(oe)}getDefault(re){return this.resolve(re||{})._getDefault(re)}default(re){return arguments.length===0?this._getDefault():this.clone({default:re})}strict(re=!0){return this.clone({strict:re})}nullability(re,oe){const ie=this.clone({nullable:re});return ie.internalTests.nullable=createValidation({message:oe,name:"nullable",test(pe){return pe===null?this.schema.spec.nullable:!0}}),ie}optionality(re,oe){const ie=this.clone({optional:re});return ie.internalTests.optionality=createValidation({message:oe,name:"optionality",test(pe){return pe===void 0?this.schema.spec.optional:!0}}),ie}optional(){return this.optionality(!0)}defined(re=mixed.defined){return this.optionality(!1,re)}nullable(){return this.nullability(!0)}nonNullable(re=mixed.notNull){return this.nullability(!1,re)}required(re=mixed.required){return this.clone().withMutation(oe=>oe.nonNullable(re).defined(re))}notRequired(){return this.clone().withMutation(re=>re.nullable().optional())}transform(re){let oe=this.clone();return oe.transforms.push(re),oe}test(...re){let oe;if(re.length===1?typeof re[0]=="function"?oe={test:re[0]}:oe=re[0]:re.length===2?oe={name:re[0],test:re[1]}:oe={name:re[0],message:re[1],test:re[2]},oe.message===void 0&&(oe.message=mixed.default),typeof oe.test!="function")throw new TypeError("`test` is a required parameters");let ie=this.clone(),pe=createValidation(oe),nr=oe.exclusive||oe.name&&ie.exclusiveTests[oe.name]===!0;if(oe.exclusive&&!oe.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return oe.name&&(ie.exclusiveTests[oe.name]=!!oe.exclusive),ie.tests=ie.tests.filter(or=>!(or.OPTIONS.name===oe.name&&(nr||or.OPTIONS.test===pe.OPTIONS.test))),ie.tests.push(pe),ie}when(re,oe){!Array.isArray(re)&&typeof re!="string"&&(oe=re,re=".");let ie=this.clone(),pe=toArray(re).map(nr=>new Reference$1(nr));return pe.forEach(nr=>{nr.isSibling&&ie.deps.push(nr.key)}),ie.conditions.push(typeof oe=="function"?new Condition(pe,oe):Condition.fromOptions(pe,oe)),ie}typeError(re){let oe=this.clone();return oe.internalTests.typeError=createValidation({message:re,name:"typeError",skipAbsent:!0,test(ie){return this.schema._typeCheck(ie)?!0:this.createError({params:{type:this.schema.type}})}}),oe}oneOf(re,oe=mixed.oneOf){let ie=this.clone();return re.forEach(pe=>{ie._whitelist.add(pe),ie._blacklist.delete(pe)}),ie.internalTests.whiteList=createValidation({message:oe,name:"oneOf",skipAbsent:!0,test(pe){let nr=this.schema._whitelist,or=nr.resolveAll(this.resolve);return or.includes(pe)?!0:this.createError({params:{values:Array.from(nr).join(", "),resolved:or}})}}),ie}notOneOf(re,oe=mixed.notOneOf){let ie=this.clone();return re.forEach(pe=>{ie._blacklist.add(pe),ie._whitelist.delete(pe)}),ie.internalTests.blacklist=createValidation({message:oe,name:"notOneOf",test(pe){let nr=this.schema._blacklist,or=nr.resolveAll(this.resolve);return or.includes(pe)?this.createError({params:{values:Array.from(nr).join(", "),resolved:or}}):!0}}),ie}strip(re=!0){let oe=this.clone();return oe.spec.strip=re,oe}describe(re){const oe=(re?this.resolve(re):this).clone(),{label:ie,meta:pe,optional:nr,nullable:or}=oe.spec;return{meta:pe,label:ie,optional:nr,nullable:or,default:oe.getDefault(re),type:oe.type,oneOf:oe._whitelist.describe(),notOneOf:oe._blacklist.describe(),tests:oe.tests.map(ir=>({name:ir.OPTIONS.name,params:ir.OPTIONS.params})).filter((ir,sr,cr)=>cr.findIndex(lr=>lr.name===ir.name)===sr)}}}Schema.prototype.__isYupSchema__=!0;for(const W of["validate","validateSync"])Schema.prototype[`${W}At`]=function(re,oe,ie={}){const{parent:pe,parentPath:nr,schema:or}=getIn(this,re,oe,ie.context);return or[W](pe&&pe[nr],Object.assign({},ie,{parent:pe,path:re}))};for(const W of["equals","is"])Schema.prototype[W]=Schema.prototype.oneOf;for(const W of["not","nope"])Schema.prototype[W]=Schema.prototype.notOneOf;const returnsTrue=()=>!0;function create$8(W){return new MixedSchema(W)}class MixedSchema extends Schema{constructor(re){super(typeof re=="function"?{type:"mixed",check:re}:Object.assign({type:"mixed",check:returnsTrue},re))}}create$8.prototype=MixedSchema.prototype;function create$7(){return new BooleanSchema}class BooleanSchema extends Schema{constructor(){super({type:"boolean",check(re){return re instanceof Boolean&&(re=re.valueOf()),typeof re=="boolean"}}),this.withMutation(()=>{this.transform((re,oe,ie)=>{if(ie.spec.coerce&&!ie.isType(re)){if(/^(true|1)$/i.test(String(re)))return!0;if(/^(false|0)$/i.test(String(re)))return!1}return re})})}isTrue(re=boolean.isValue){return this.test({message:re,name:"is-value",exclusive:!0,params:{value:"true"},test(oe){return isAbsent(oe)||oe===!0}})}isFalse(re=boolean.isValue){return this.test({message:re,name:"is-value",exclusive:!0,params:{value:"false"},test(oe){return isAbsent(oe)||oe===!1}})}default(re){return super.default(re)}defined(re){return super.defined(re)}optional(){return super.optional()}required(re){return super.required(re)}notRequired(){return super.notRequired()}nullable(){return super.nullable()}nonNullable(re){return super.nonNullable(re)}strip(re){return super.strip(re)}}create$7.prototype=BooleanSchema.prototype;const isoReg=/^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;function parseIsoDate(W){const re=parseDateStruct(W);if(!re)return Date.parse?Date.parse(W):Number.NaN;if(re.z===void 0&&re.plusMinus===void 0)return new Date(re.year,re.month,re.day,re.hour,re.minute,re.second,re.millisecond).valueOf();let oe=0;return re.z!=="Z"&&re.plusMinus!==void 0&&(oe=re.hourOffset*60+re.minuteOffset,re.plusMinus==="+"&&(oe=0-oe)),Date.UTC(re.year,re.month,re.day,re.hour,re.minute+oe,re.second,re.millisecond)}function parseDateStruct(W){var re,oe;const ie=isoReg.exec(W);return ie?{year:toNumber$2(ie[1]),month:toNumber$2(ie[2],1)-1,day:toNumber$2(ie[3],1),hour:toNumber$2(ie[4]),minute:toNumber$2(ie[5]),second:toNumber$2(ie[6]),millisecond:ie[7]?toNumber$2(ie[7].substring(0,3)):0,precision:(re=(oe=ie[7])==null?void 0:oe.length)!=null?re:void 0,z:ie[8]||void 0,plusMinus:ie[9]||void 0,hourOffset:toNumber$2(ie[10]),minuteOffset:toNumber$2(ie[11])}:null}function toNumber$2(W,re=0){return Number(W)||re}let rEmail=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,rUrl=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,rUUID=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,yearMonthDay="^\\d{4}-\\d{2}-\\d{2}",hourMinuteSecond="\\d{2}:\\d{2}:\\d{2}",zOrOffset="(([+-]\\d{2}(:?\\d{2})?)|Z)",rIsoDateTime=new RegExp(`${yearMonthDay}T${hourMinuteSecond}(\\.\\d+)?${zOrOffset}$`),isTrimmed=W=>isAbsent(W)||W===W.trim(),objStringTag={}.toString();function create$6(){return new StringSchema}class StringSchema extends Schema{constructor(){super({type:"string",check(re){return re instanceof String&&(re=re.valueOf()),typeof re=="string"}}),this.withMutation(()=>{this.transform((re,oe,ie)=>{if(!ie.spec.coerce||ie.isType(re)||Array.isArray(re))return re;const pe=re!=null&&re.toString?re.toString():re;return pe===objStringTag?re:pe})})}required(re){return super.required(re).withMutation(oe=>oe.test({message:re||mixed.required,name:"required",skipAbsent:!0,test:ie=>!!ie.length}))}notRequired(){return super.notRequired().withMutation(re=>(re.tests=re.tests.filter(oe=>oe.OPTIONS.name!=="required"),re))}length(re,oe=string.length){return this.test({message:oe,name:"length",exclusive:!0,params:{length:re},skipAbsent:!0,test(ie){return ie.length===this.resolve(re)}})}min(re,oe=string.min){return this.test({message:oe,name:"min",exclusive:!0,params:{min:re},skipAbsent:!0,test(ie){return ie.length>=this.resolve(re)}})}max(re,oe=string.max){return this.test({name:"max",exclusive:!0,message:oe,params:{max:re},skipAbsent:!0,test(ie){return ie.length<=this.resolve(re)}})}matches(re,oe){let ie=!1,pe,nr;return oe&&(typeof oe=="object"?{excludeEmptyString:ie=!1,message:pe,name:nr}=oe:pe=oe),this.test({name:nr||"matches",message:pe||string.matches,params:{regex:re},skipAbsent:!0,test:or=>or===""&&ie||or.search(re)!==-1})}email(re=string.email){return this.matches(rEmail,{name:"email",message:re,excludeEmptyString:!0})}url(re=string.url){return this.matches(rUrl,{name:"url",message:re,excludeEmptyString:!0})}uuid(re=string.uuid){return this.matches(rUUID,{name:"uuid",message:re,excludeEmptyString:!1})}datetime(re){let oe="",ie,pe;return re&&(typeof re=="object"?{message:oe="",allowOffset:ie=!1,precision:pe=void 0}=re:oe=re),this.matches(rIsoDateTime,{name:"datetime",message:oe||string.datetime,excludeEmptyString:!0}).test({name:"datetime_offset",message:oe||string.datetime_offset,params:{allowOffset:ie},skipAbsent:!0,test:nr=>{if(!nr||ie)return!0;const or=parseDateStruct(nr);return or?!!or.z:!1}}).test({name:"datetime_precision",message:oe||string.datetime_precision,params:{precision:pe},skipAbsent:!0,test:nr=>{if(!nr||pe==null)return!0;const or=parseDateStruct(nr);return or?or.precision===pe:!1}})}ensure(){return this.default("").transform(re=>re===null?"":re)}trim(re=string.trim){return this.transform(oe=>oe!=null?oe.trim():oe).test({message:re,name:"trim",test:isTrimmed})}lowercase(re=string.lowercase){return this.transform(oe=>isAbsent(oe)?oe:oe.toLowerCase()).test({message:re,name:"string_case",exclusive:!0,skipAbsent:!0,test:oe=>isAbsent(oe)||oe===oe.toLowerCase()})}uppercase(re=string.uppercase){return this.transform(oe=>isAbsent(oe)?oe:oe.toUpperCase()).test({message:re,name:"string_case",exclusive:!0,skipAbsent:!0,test:oe=>isAbsent(oe)||oe===oe.toUpperCase()})}}create$6.prototype=StringSchema.prototype;let isNaN$1=W=>W!=+W;function create$5(){return new NumberSchema}class NumberSchema extends Schema{constructor(){super({type:"number",check(re){return re instanceof Number&&(re=re.valueOf()),typeof re=="number"&&!isNaN$1(re)}}),this.withMutation(()=>{this.transform((re,oe,ie)=>{if(!ie.spec.coerce)return re;let pe=re;if(typeof pe=="string"){if(pe=pe.replace(/\s/g,""),pe==="")return NaN;pe=+pe}return ie.isType(pe)||pe===null?pe:parseFloat(pe)})})}min(re,oe=number.min){return this.test({message:oe,name:"min",exclusive:!0,params:{min:re},skipAbsent:!0,test(ie){return ie>=this.resolve(re)}})}max(re,oe=number.max){return this.test({message:oe,name:"max",exclusive:!0,params:{max:re},skipAbsent:!0,test(ie){return ie<=this.resolve(re)}})}lessThan(re,oe=number.lessThan){return this.test({message:oe,name:"max",exclusive:!0,params:{less:re},skipAbsent:!0,test(ie){return ie<this.resolve(re)}})}moreThan(re,oe=number.moreThan){return this.test({message:oe,name:"min",exclusive:!0,params:{more:re},skipAbsent:!0,test(ie){return ie>this.resolve(re)}})}positive(re=number.positive){return this.moreThan(0,re)}negative(re=number.negative){return this.lessThan(0,re)}integer(re=number.integer){return this.test({name:"integer",message:re,skipAbsent:!0,test:oe=>Number.isInteger(oe)})}truncate(){return this.transform(re=>isAbsent(re)?re:re|0)}round(re){var oe;let ie=["ceil","floor","round","trunc"];if(re=((oe=re)==null?void 0:oe.toLowerCase())||"round",re==="trunc")return this.truncate();if(ie.indexOf(re.toLowerCase())===-1)throw new TypeError("Only valid options for round() are: "+ie.join(", "));return this.transform(pe=>isAbsent(pe)?pe:Math[re](pe))}}create$5.prototype=NumberSchema.prototype;let invalidDate=new Date(""),isDate$1=W=>Object.prototype.toString.call(W)==="[object Date]";function create$4(){return new DateSchema}class DateSchema extends Schema{constructor(){super({type:"date",check(re){return isDate$1(re)&&!isNaN(re.getTime())}}),this.withMutation(()=>{this.transform((re,oe,ie)=>!ie.spec.coerce||ie.isType(re)||re===null?re:(re=parseIsoDate(re),isNaN(re)?DateSchema.INVALID_DATE:new Date(re)))})}prepareParam(re,oe){let ie;if(Reference$1.isRef(re))ie=re;else{let pe=this.cast(re);if(!this._typeCheck(pe))throw new TypeError(`\`${oe}\` must be a Date or a value that can be \`cast()\` to a Date`);ie=pe}return ie}min(re,oe=date.min){let ie=this.prepareParam(re,"min");return this.test({message:oe,name:"min",exclusive:!0,params:{min:re},skipAbsent:!0,test(pe){return pe>=this.resolve(ie)}})}max(re,oe=date.max){let ie=this.prepareParam(re,"max");return this.test({message:oe,name:"max",exclusive:!0,params:{max:re},skipAbsent:!0,test(pe){return pe<=this.resolve(ie)}})}}DateSchema.INVALID_DATE=invalidDate,create$4.prototype=DateSchema.prototype,create$4.INVALID_DATE=invalidDate;function sortFields(W,re=[]){let oe=[],ie=new Set,pe=new Set(re.map(([or,ar])=>`${or}-${ar}`));function nr(or,ar){let ir=propertyExpr.split(or)[0];ie.add(ir),pe.has(`${ar}-${ir}`)||oe.push([ar,ir])}for(const or of Object.keys(W)){let ar=W[or];ie.add(or),Reference$1.isRef(ar)&&ar.isSibling?nr(ar.path,or):isSchema(ar)&&"deps"in ar&&ar.deps.forEach(ir=>nr(ir,or))}return toposort$1.array(Array.from(ie),oe).reverse()}function findIndex$1(W,re){let oe=1/0;return W.some((ie,pe)=>{var nr;if((nr=re.path)!=null&&nr.includes(ie))return oe=pe,!0}),oe}function sortByKeyOrder(W){return(re,oe)=>findIndex$1(W,re)-findIndex$1(W,oe)}const parseJson=(W,re,oe)=>{if(typeof W!="string")return W;let ie=W;try{ie=JSON.parse(W)}catch{}return oe.isType(ie)?ie:W};function deepPartial(W){if("fields"in W){const re={};for(const[oe,ie]of Object.entries(W.fields))re[oe]=deepPartial(ie);return W.setFields(re)}if(W.type==="array"){const re=W.optional();return re.innerType&&(re.innerType=deepPartial(re.innerType)),re}return W.type==="tuple"?W.optional().clone({types:W.spec.types.map(deepPartial)}):"optional"in W?W.optional():W}const deepHas=(W,re)=>{const oe=[...propertyExpr.normalizePath(re)];if(oe.length===1)return oe[0]in W;let ie=oe.pop(),pe=propertyExpr.getter(propertyExpr.join(oe),!0)(W);return!!(pe&&ie in pe)};let isObject$6=W=>Object.prototype.toString.call(W)==="[object Object]";function unknown(W,re){let oe=Object.keys(W.fields);return Object.keys(re).filter(ie=>oe.indexOf(ie)===-1)}const defaultSort=sortByKeyOrder([]);function create$3(W){return new ObjectSchema(W)}class ObjectSchema extends Schema{constructor(re){super({type:"object",check(oe){return isObject$6(oe)||typeof oe=="function"}}),this.fields=Object.create(null),this._sortErrors=defaultSort,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{re&&this.shape(re)})}_cast(re,oe={}){var ie;let pe=super._cast(re,oe);if(pe===void 0)return this.getDefault(oe);if(!this._typeCheck(pe))return pe;let nr=this.fields,or=(ie=oe.stripUnknown)!=null?ie:this.spec.noUnknown,ar=[].concat(this._nodes,Object.keys(pe).filter(lr=>!this._nodes.includes(lr))),ir={},sr=Object.assign({},oe,{parent:ir,__validating:oe.__validating||!1}),cr=!1;for(const lr of ar){let ur=nr[lr],fr=lr in pe;if(ur){let dr,mr=pe[lr];sr.path=(oe.path?`${oe.path}.`:"")+lr,ur=ur.resolve({value:mr,context:oe.context,parent:ir});let pr=ur instanceof Schema?ur.spec:void 0,hr=pr==null?void 0:pr.strict;if(pr!=null&&pr.strip){cr=cr||lr in pe;continue}dr=!oe.__validating||!hr?ur.cast(pe[lr],sr):pe[lr],dr!==void 0&&(ir[lr]=dr)}else fr&&!or&&(ir[lr]=pe[lr]);(fr!==lr in ir||ir[lr]!==pe[lr])&&(cr=!0)}return cr?ir:pe}_validate(re,oe={},ie,pe){let{from:nr=[],originalValue:or=re,recursive:ar=this.spec.recursive}=oe;oe.from=[{schema:this,value:or},...nr],oe.__validating=!0,oe.originalValue=or,super._validate(re,oe,ie,(ir,sr)=>{if(!ar||!isObject$6(sr)){pe(ir,sr);return}or=or||sr;let cr=[];for(let lr of this._nodes){let ur=this.fields[lr];!ur||Reference$1.isRef(ur)||cr.push(ur.asNestedTest({options:oe,key:lr,parent:sr,parentPath:oe.path,originalParent:or}))}this.runTests({tests:cr,value:sr,originalValue:or,options:oe},ie,lr=>{pe(lr.sort(this._sortErrors).concat(ir),sr)})})}clone(re){const oe=super.clone(re);return oe.fields=Object.assign({},this.fields),oe._nodes=this._nodes,oe._excludedEdges=this._excludedEdges,oe._sortErrors=this._sortErrors,oe}concat(re){let oe=super.concat(re),ie=oe.fields;for(let[pe,nr]of Object.entries(this.fields)){const or=ie[pe];ie[pe]=or===void 0?nr:or}return oe.withMutation(pe=>pe.setFields(ie,[...this._excludedEdges,...re._excludedEdges]))}_getDefault(re){if("default"in this.spec)return super._getDefault(re);if(!this._nodes.length)return;let oe={};return this._nodes.forEach(ie=>{var pe;const nr=this.fields[ie];let or=re;(pe=or)!=null&&pe.value&&(or=Object.assign({},or,{parent:or.value,value:or.value[ie]})),oe[ie]=nr&&"getDefault"in nr?nr.getDefault(or):void 0}),oe}setFields(re,oe){let ie=this.clone();return ie.fields=re,ie._nodes=sortFields(re,oe),ie._sortErrors=sortByKeyOrder(Object.keys(re)),oe&&(ie._excludedEdges=oe),ie}shape(re,oe=[]){return this.clone().withMutation(ie=>{let pe=ie._excludedEdges;return oe.length&&(Array.isArray(oe[0])||(oe=[oe]),pe=[...ie._excludedEdges,...oe]),ie.setFields(Object.assign(ie.fields,re),pe)})}partial(){const re={};for(const[oe,ie]of Object.entries(this.fields))re[oe]="optional"in ie&&ie.optional instanceof Function?ie.optional():ie;return this.setFields(re)}deepPartial(){return deepPartial(this)}pick(re){const oe={};for(const ie of re)this.fields[ie]&&(oe[ie]=this.fields[ie]);return this.setFields(oe,this._excludedEdges.filter(([ie,pe])=>re.includes(ie)&&re.includes(pe)))}omit(re){const oe=[];for(const ie of Object.keys(this.fields))re.includes(ie)||oe.push(ie);return this.pick(oe)}from(re,oe,ie){let pe=propertyExpr.getter(re,!0);return this.transform(nr=>{if(!nr)return nr;let or=nr;return deepHas(nr,re)&&(or=Object.assign({},nr),ie||delete or[re],or[oe]=pe(nr)),or})}json(){return this.transform(parseJson)}noUnknown(re=!0,oe=object.noUnknown){typeof re!="boolean"&&(oe=re,re=!0);let ie=this.test({name:"noUnknown",exclusive:!0,message:oe,test(pe){if(pe==null)return!0;const nr=unknown(this.schema,pe);return!re||nr.length===0||this.createError({params:{unknown:nr.join(", ")}})}});return ie.spec.noUnknown=re,ie}unknown(re=!0,oe=object.noUnknown){return this.noUnknown(!re,oe)}transformKeys(re){return this.transform(oe=>{if(!oe)return oe;const ie={};for(const pe of Object.keys(oe))ie[re(pe)]=oe[pe];return ie})}camelCase(){return this.transformKeys(tinyCase.camelCase)}snakeCase(){return this.transformKeys(tinyCase.snakeCase)}constantCase(){return this.transformKeys(re=>tinyCase.snakeCase(re).toUpperCase())}describe(re){const oe=(re?this.resolve(re):this).clone(),ie=super.describe(re);ie.fields={};for(const[nr,or]of Object.entries(oe.fields)){var pe;let ar=re;(pe=ar)!=null&&pe.value&&(ar=Object.assign({},ar,{parent:ar.value,value:ar.value[nr]})),ie.fields[nr]=or.describe(ar)}return ie}}create$3.prototype=ObjectSchema.prototype;function create$2(W){return new ArraySchema(W)}class ArraySchema extends Schema{constructor(re){super({type:"array",spec:{types:re},check(oe){return Array.isArray(oe)}}),this.innerType=void 0,this.innerType=re}_cast(re,oe){const ie=super._cast(re,oe);if(!this._typeCheck(ie)||!this.innerType)return ie;let pe=!1;const nr=ie.map((or,ar)=>{const ir=this.innerType.cast(or,Object.assign({},oe,{path:`${oe.path||""}[${ar}]`}));return ir!==or&&(pe=!0),ir});return pe?nr:ie}_validate(re,oe={},ie,pe){var nr;let or=this.innerType,ar=(nr=oe.recursive)!=null?nr:this.spec.recursive;oe.originalValue!=null&&oe.originalValue,super._validate(re,oe,ie,(ir,sr)=>{var cr;if(!ar||!or||!this._typeCheck(sr)){pe(ir,sr);return}let lr=new Array(sr.length);for(let fr=0;fr<sr.length;fr++){var ur;lr[fr]=or.asNestedTest({options:oe,index:fr,parent:sr,parentPath:oe.path,originalParent:(ur=oe.originalValue)!=null?ur:re})}this.runTests({value:sr,tests:lr,originalValue:(cr=oe.originalValue)!=null?cr:re,options:oe},ie,fr=>pe(fr.concat(ir),sr))})}clone(re){const oe=super.clone(re);return oe.innerType=this.innerType,oe}json(){return this.transform(parseJson)}concat(re){let oe=super.concat(re);return oe.innerType=this.innerType,re.innerType&&(oe.innerType=oe.innerType?oe.innerType.concat(re.innerType):re.innerType),oe}of(re){let oe=this.clone();if(!isSchema(re))throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: "+printValue(re));return oe.innerType=re,oe.spec=Object.assign({},oe.spec,{types:re}),oe}length(re,oe=array.length){return this.test({message:oe,name:"length",exclusive:!0,params:{length:re},skipAbsent:!0,test(ie){return ie.length===this.resolve(re)}})}min(re,oe){return oe=oe||array.min,this.test({message:oe,name:"min",exclusive:!0,params:{min:re},skipAbsent:!0,test(ie){return ie.length>=this.resolve(re)}})}max(re,oe){return oe=oe||array.max,this.test({message:oe,name:"max",exclusive:!0,params:{max:re},skipAbsent:!0,test(ie){return ie.length<=this.resolve(re)}})}ensure(){return this.default(()=>[]).transform((re,oe)=>this._typeCheck(re)?re:oe==null?[]:[].concat(oe))}compact(re){let oe=re?(ie,pe,nr)=>!re(ie,pe,nr):ie=>!!ie;return this.transform(ie=>ie!=null?ie.filter(oe):ie)}describe(re){const oe=(re?this.resolve(re):this).clone(),ie=super.describe(re);if(oe.innerType){var pe;let nr=re;(pe=nr)!=null&&pe.value&&(nr=Object.assign({},nr,{parent:nr.value,value:nr.value[0]})),ie.innerType=oe.innerType.describe(nr)}return ie}}create$2.prototype=ArraySchema.prototype;function addMethod(W,re,oe){if(!W||!isSchema(W.prototype))throw new TypeError("You must provide a yup schema constructor function");if(typeof re!="string")throw new TypeError("A Method name must be provided");if(typeof oe!="function")throw new TypeError("Method function must be provided");W.prototype[re]=oe}function capitalize(W){var re,oe;return W||(W=""),((re=W==null?void 0:W[0])==null?void 0:re.toUpperCase())+((oe=W==null?void 0:W.substring(1))==null?void 0:oe.toLowerCase())}function classNames(...W){return W.filter(Boolean).join(" ")}function constructFullName(W,re,oe,ie){return`${W}${oe?" "+oe:""} ${re}${ie?" "+ie:""}`}function getEndpoint(){return"https://api.mercoa.com"}function BankAccounts({children:W,onSelect:re,showAdd:oe,showEdit:ie,verifiedOnly:pe}){var ir;const[nr,or]=React.useState(),ar=useMercoaSession();return React.useEffect(()=>{var sr,cr,lr;ar.token&&((sr=ar.entity)!=null&&sr.id)&&((lr=ar.client)==null||lr.entity.paymentMethod.getAll((cr=ar.entity)==null?void 0:cr.id,{type:"bankAccount"}).then(ur=>{or(ur.map(fr=>fr).filter(fr=>pe&&fr.status!="VERIFIED"?null:fr))}))},[(ir=ar.entity)==null?void 0:ir.id,ar.token,ar.refreshId]),ar.client?W?W({bankAccounts:nr}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[!nr&&jsxRuntimeExports.jsx("div",{className:"mercoa-p-9 mercoa-text-center",children:jsxRuntimeExports.jsx(LoadingSpinnerIcon,{})}),jsxRuntimeExports.jsx(PaymentMethodList,{accounts:nr,showEdit:ie,addAccount:nr&&oe?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(AddBankAccountButton,{onSelect:sr=>{nr.find(cr=>cr.accountNumber===sr.accountNumber&&cr.routingNumber===sr.routingNumber)||or([...nr,sr]),re&&re(sr)}})}):void 0,formatAccount:sr=>jsxRuntimeExports.jsx(BankAccount,{account:sr,onSelect:re,showEdit:ie})}),nr&&nr.length==0&&pe&&jsxRuntimeExports.jsx("div",{className:"mercoa-mt-2 mercoa-text-left mercoa-text-gray-700",children:"No verified bank accounts found. Please add and verify at least one bank account."})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"BankAccounts"})}function BankAccount({children:W,account:re,onSelect:oe,showEdit:ie,selected:pe}){var ur,fr,dr;const nr=useMercoaSession(),[or,ar]=React.useState(!1),[ir,sr]=React.useState(!1),{register:cr,handleSubmit:lr}=useForm();return nr.client?re?jsxRuntimeExports.jsxs("div",{onClick:()=>{oe&&oe(re)},className:`mercoa-relative mercoa-flex mercoa-items-center mercoa-space-x-3 mercoa-rounded-mercoa mercoa-border ${pe?"mercoa-border-gray-600":"mercoa-border-gray-300"} mercoa-bg-white mercoa-px-6 mercoa-py-5 mercoa-shadow-sm focus-within:mercoa-ring-2 focus-within:mercoa-ring-indigo-500 focus-within:mercoa-ring-offset-2 ${oe?"mercoa-cursor-pointer hover:mercoa-border-gray-400":""}`,children:[jsxRuntimeExports.jsx("div",{className:`mercoa-flex-shrink-0 mercoa-rounded-full mercoa-p-1 ${pe?"mercoa-text-mercoa-primary-text-invert mercoa-bg-mercoa-primary-light":"mercoa-bg-gray-200 mercoa-text-gray-600"}`,children:jsxRuntimeExports.jsx(ForwardRef$I,{className:"mercoa-size-5"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-min-w-0 mercoa-flex-1 mercoa-justify-between mercoa-group",children:jsxRuntimeExports.jsxs("div",{className:"mercoa-flex",children:[jsxRuntimeExports.jsxs("div",{children:[!ie&&jsxRuntimeExports.jsx("span",{className:"mercoa-absolute mercoa-inset-0","aria-hidden":"true"}),jsxRuntimeExports.jsx(AddDialog,{component:jsxRuntimeExports.jsx(EditBankAccount,{account:re,onSubmit:()=>sr(!1)}),onClose:()=>sr(!1),show:ir}),re!=null&&re.accountName?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("p",{className:`mercoa-text-sm mercoa-font-medium mercoa-text-gray-900 ${pe?"mercoa-underline":""}`,children:re.accountName}),jsxRuntimeExports.jsxs("p",{className:`mercoa-text-xs mercoa-font-medium mercoa-text-gray-800 ${pe?"mercoa-underline":""}`,children:[re==null?void 0:re.bankName,` ••••${String(re==null?void 0:re.accountNumber).slice(-4)}`]})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("p",{className:`mercoa-text-sm mercoa-font-medium mercoa-text-gray-900 ${pe?"mercoa-underline":""}`,children:`${capitalize(re==null?void 0:re.accountType)} ••••${String(re==null?void 0:re.accountNumber).slice(-4)}`}),jsxRuntimeExports.jsx("p",{className:`mercoa-text-xs mercoa-font-medium mercoa-text-gray-800 ${pe?"mercoa-underline":""}`,children:re==null?void 0:re.bankName})]})]}),ie&&((re==null?void 0:re.status)===javascript.Mercoa.BankStatus.New||(re==null?void 0:re.status)===javascript.Mercoa.BankStatus.Pending)&&jsxRuntimeExports.jsxs(MercoaButton,{isEmphasized:!0,size:"md",className:"mercoa-ml-2",onClick:()=>ar(!0),children:[(re==null?void 0:re.status)===javascript.Mercoa.BankStatus.New&&"Start Verification",(re==null?void 0:re.status)===javascript.Mercoa.BankStatus.Pending&&"Complete Verification"]})]})}),ie&&jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-items-center mercoa-gap-x-1",children:[jsxRuntimeExports.jsx(DefaultPaymentMethodIndicator,{paymentMethod:re}),jsxRuntimeExports.jsxs("div",{children:[(re==null?void 0:re.status)===javascript.Mercoa.BankStatus.New&&jsxRuntimeExports.jsx(Tooltip,{title:"Can only receive funds",children:jsxRuntimeExports.jsx("span",{className:"mercoa-inline-flex mercoa-items-center mercoa-rounded-full mercoa-bg-indigo-100 mercoa-px-2.5 mercoa-py-0.5 mercoa-text-xs mercoa-font-medium mercoa-text-indigo-800",children:"New"})}),(re==null?void 0:re.status)===javascript.Mercoa.BankStatus.Verified&&jsxRuntimeExports.jsx(Tooltip,{title:"Can send and receive funds",children:jsxRuntimeExports.jsx("span",{className:"mercoa-inline-flex mercoa-items-center mercoa-rounded-full mercoa-bg-green-100 mercoa-px-2.5 mercoa-py-0.5 mercoa-text-xs mercoa-font-medium mercoa-text-green-800",children:"Verified"})}),(re==null?void 0:re.status)===javascript.Mercoa.BankStatus.Pending&&jsxRuntimeExports.jsx(Tooltip,{title:"Can only receive funds",children:jsxRuntimeExports.jsx("span",{className:"mercoa-inline-flex mercoa-items-center mercoa-rounded-full mercoa-bg-yellow-100 mercoa-px-2.5 mercoa-py-0.5 mercoa-text-xs mercoa-font-medium mercoa-text-yellow-800",children:"Pending"})}),((re==null?void 0:re.status)===javascript.Mercoa.BankStatus.VerificationFailed||(re==null?void 0:re.status)===javascript.Mercoa.BankStatus.Errored)&&jsxRuntimeExports.jsx(Tooltip,{title:"Can only receive funds",children:jsxRuntimeExports.jsx("span",{className:"mercoa-inline-flex mercoa-items-center mercoa-rounded-full mercoa-bg-red-100 mercoa-px-2.5 mercoa-py-0.5 mercoa-text-xs mercoa-font-medium mercoa-text-red-800",children:"VERIFICATION FAILED"})})]}),jsxRuntimeExports.jsx("div",{children:(ur=re.checkOptions)!=null&&ur.enabled?jsxRuntimeExports.jsx(Tooltip,{title:"Can send checks",children:jsxRuntimeExports.jsxs("span",{className:"mercoa-inline-flex mercoa-items-center mercoa-rounded-full mercoa-bg-green-100 mercoa-px-2.5 mercoa-py-0.5 mercoa-text-xs mercoa-font-medium mercoa-text-green-800",children:["_",jsxRuntimeExports.jsx(ForwardRef$v,{className:"mercoa-size-4"})]})}):jsxRuntimeExports.jsx(Tooltip,{title:"Check send disabled",children:jsxRuntimeExports.jsxs("span",{className:"mercoa-inline-flex mercoa-items-center mercoa-rounded-full mercoa-bg-gray-100 mercoa-px-2.5 mercoa-py-0.5 mercoa-text-xs mercoa-font-medium mercoa-text-gray-800",children:["_",jsxRuntimeExports.jsx(ForwardRef$v,{className:"mercoa-size-4"})]})})}),jsxRuntimeExports.jsx(MercoaButton,{size:"sm",isEmphasized:!1,className:"mercoa-mr-2 mercoa-px-[4px] mercoa-py-[4px]",onClick:()=>sr(!0),children:jsxRuntimeExports.jsx(Tooltip,{title:"Edit",children:jsxRuntimeExports.jsx(ForwardRef$f,{className:"mercoa-size-4"})})}),jsxRuntimeExports.jsx(qe$1.Root,{show:!!or,as:React.Fragment,children:jsxRuntimeExports.jsxs(_t$1,{as:"div",className:"mercoa-relative mercoa-z-10",onClose:()=>ar(!1),children:[jsxRuntimeExports.jsx(qe$1.Child,{as:React.Fragment,enter:"mercoa-ease-out mercoa-duration-300",enterFrom:"mercoa-opacity-0",enterTo:"mercoa-opacity-100",leave:"mercoa-ease-in mercoa-duration-200",leaveFrom:"mercoa-opacity-100",leaveTo:"mercoa-opacity-0",children:jsxRuntimeExports.jsx("div",{className:"mercoa-fixed mercoa-inset-0 mercoa-bg-gray-500 mercoa-bg-mercoa-opacity-75 mercoa-transition-opacity"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-fixed mercoa-inset-0 mercoa-z-10 mercoa-overflow-y-auto",children:jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-min-h-full mercoa-items-end mercoa-justify-center mercoa-p-4 mercoa-text-center sm:mercoa-items-center sm:mercoa-p-0",children:jsxRuntimeExports.jsx(qe$1.Child,{as:React.Fragment,enter:"mercoa-ease-out mercoa-duration-300",enterFrom:"mercoa-opacity-0 mercoa-translate-y-4 sm:mercoa-translate-y-0 sm:mercoa-scale-95",enterTo:"mercoa-opacity-100 mercoa-translate-y-0 sm:mercoa-scale-100",leave:"mercoa-ease-in mercoa-duration-200",leaveFrom:"mercoa-opacity-100 mercoa-translate-y-0 sm:mercoa-scale-100",leaveTo:"mercoa-opacity-0 mercoa-translate-y-4 sm:mercoa-translate-y-0 sm:mercoa-scale-95",children:jsxRuntimeExports.jsxs(_t$1.Panel,{className:"mercoa-relative mercoa-transform mercoa-rounded-mercoa mercoa-bg-white mercoa-px-4 mercoa-pt-5 mercoa-pb-4 mercoa-text-left mercoa-shadow-xl mercoa-transition-all sm:mercoa-my-8 sm:mercoa-w-full sm:mercoa-max-w-lg sm:mercoa-p-6",children:[jsxRuntimeExports.jsx(_t$1.Title,{as:"h3",className:"mercoa-text-lg mercoa-font-medium mercoa-leading-6 mercoa-text-gray-900",children:"Verify Account"}),(re==null?void 0:re.status)===javascript.Mercoa.BankStatus.New&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("p",{className:"mercoa-mt-5 mercoa-text-sm",children:"Mercoa will send two small deposits to verify this account. These deposits may take up to 1-2 days to appear."}),jsxRuntimeExports.jsx("p",{className:"mercoa-mt-3 mercoa-text-sm",children:"Once transactions have been sent, you'll have 14 days to verify their values."}),((fr=nr.organization)==null?void 0:fr.sandbox)&&jsxRuntimeExports.jsxs("p",{className:"mercoa-mt-3 mercoa-rounded-mercoa mercoa-bg-orange-200 mercoa-p-1 mercoa-text-sm",children:[jsxRuntimeExports.jsx("b",{children:"Test Mode:"})," actual deposits will not be sent. Use 0 and 0 as the values to instantly verify the account in the next step."]}),jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!0,onClick:async()=>{var mr,pr,hr;(mr=nr.entity)!=null&&mr.id&&(re!=null&&re.id)&&(await((hr=nr.client)==null?void 0:hr.entity.paymentMethod.initiateMicroDeposits((pr=nr.entity)==null?void 0:pr.id,re==null?void 0:re.id)),ar(!1),nr.refresh())},className:"mercoa-mt-5 mercoa-inline-flex mercoa-w-full mercoa-justify-center",children:"Send deposits"})]}),(re==null?void 0:re.status)===javascript.Mercoa.BankStatus.Pending&&jsxRuntimeExports.jsxs("form",{onSubmit:lr(async mr=>{var pr,hr,yr;(pr=nr.entity)!=null&&pr.id&&(re!=null&&re.id)&&(await((yr=nr.client)==null?void 0:yr.entity.paymentMethod.completeMicroDeposits((hr=nr.entity)==null?void 0:hr.id,re==null?void 0:re.id,{amounts:[Number(mr.md1),Number(mr.md2)]})),ar(!1),nr.refresh())}),children:[jsxRuntimeExports.jsx("p",{className:"mercoa-mt-5 mercoa-text-sm",children:"Micro-deposits may take up to 2 days to appear on your statement. Once you have both values please enter the amounts to verify this account."}),((dr=nr.organization)==null?void 0:dr.sandbox)&&jsxRuntimeExports.jsxs("p",{className:"mercoa-mt-3 mercoa-rounded-mercoa mercoa-bg-orange-200 mercoa-p-1 mercoa-text-sm",children:[jsxRuntimeExports.jsx("b",{children:"Test Mode:"})," use 0 and 0 to instantly verify this account."]}),jsxRuntimeExports.jsx(MercoaInput,{name:"md1",label:"Amount",type:"number",placeholder:"0.00",step:.01,min:0,max:.99,register:cr,className:"mercoa-mt-2"}),jsxRuntimeExports.jsx(MercoaInput,{name:"md2",label:"Amount",type:"number",placeholder:"0.00",step:.01,min:0,max:.99,register:cr,className:"mercoa-mt-2"}),jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!0,className:"mercoa-mt-5",children:"Verify Account"})]})]})})})})]})})]})})]},`${re==null?void 0:re.routingNumber} ${re==null?void 0:re.accountNumber}`):jsxRuntimeExports.jsxs("div",{onClick:()=>{oe&&oe(re)},className:`mercoa-relative mercoa-flex mercoa-items-center mercoa-space-x-3 mercoa-rounded-mercoa mercoa-border mercoa-border-gray-300 mercoa-bg-white mercoa-px-6 mercoa-py-5 mercoa-shadow-sm focus-within:mercoa-ring-2 focus-within:mercoa-ring-indigo-500 focus-within:mercoa-ring-offset-2 hover:mercoa-border-gray-400 ${oe?"mercoa-cursor-pointer ":""}`,children:[jsxRuntimeExports.jsx("div",{className:`mercoa-flex-shrink-0 mercoa-rounded-full mercoa-p-1 ${pe?"mercoa-text-mercoa-primary-text-invert mercoa-bg-mercoa-primary-light":"mercoa-bg-gray-200 mercoa-text-gray-600"}`,children:jsxRuntimeExports.jsx(ForwardRef$d,{className:"mercoa-size-5"})}),jsxRuntimeExports.jsxs("div",{className:"mercoa-min-w-0 mercoa-flex-1",children:[jsxRuntimeExports.jsx("span",{className:"mercoa-absolute mercoa-inset-0","aria-hidden":"true"}),jsxRuntimeExports.jsx("p",{className:"mercoa-text-sm mercoa-font-medium mercoa-text-gray-900",children:"Add new bank account"}),jsxRuntimeExports.jsx("p",{className:"mercoa-truncate mercoa-text-sm mercoa-text-gray-500"})]})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"BankAccountComponent"})}function AddBankAccountButton({entityId:W,onSelect:re,bankAccount:oe}){const[ie,pe]=React.useState(!1),nr=or=>{pe(!1),re&&or&&re(or)};return jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-2",children:[jsxRuntimeExports.jsx(AddDialog,{show:ie,onClose:nr,component:jsxRuntimeExports.jsx(AddBankViaPlaidOrManual,{onSubmit:or=>{nr(or)},entityId:W,bankAccount:oe})}),jsxRuntimeExports.jsx(BankAccount,{onSelect:()=>pe(!0)})]})}function PlaidPopup({onExit:W,onSubmit:re,paymentMethodId:oe}){const ie=useMercoaSession(),[pe,nr]=React.useState(null),or=async()=>{var cr;if(!ie.entityId)return;const sr=await((cr=ie.client)==null?void 0:cr.entity.plaidLinkToken(ie.entityId,{paymentMethodId:oe}));sr&&nr(sr)},{open:ar,ready:ir}=usePlaidLink({token:pe,onSuccess:async(sr,cr)=>{let lr;await Promise.all(cr.accounts.map(async ur=>{var dr,mr,pr;let fr=javascript.Mercoa.BankType.Checking;if(ur.subtype=="savings"&&(fr=javascript.Mercoa.BankType.Savings),!!ie.entityId)try{oe?lr=await((dr=ie.client)==null?void 0:dr.entity.paymentMethod.update(ie.entityId,oe,{type:"bankAccount",plaid:{publicToken:sr,accountId:ur.id}})):lr=await((pr=ie.client)==null?void 0:pr.entity.paymentMethod.create(ie.entityId,{type:"bankAccount",plaid:{publicToken:sr,accountId:ur.id},accountNumber:ur.mask,routingNumber:"",accountType:fr,bankName:((mr=cr==null?void 0:cr.institution)==null?void 0:mr.name)??""}))}catch(hr){console.error(hr)}})),lr?re&&re(lr):W&&W(null,null)},onExit:(sr,cr)=>{console.log("onPlaidExit",{err:sr,metadata:cr}),W&&W(sr,cr)}});return React.useEffect(()=>{ie.entityId&&or()},[ie.entityId]),React.useEffect(()=>{pe&&ir&&ar()},[pe,ir,ar]),ie.client?!pe||!ir?jsxRuntimeExports.jsx("div",{className:"mercoa-p-9 mercoa-text-center",children:jsxRuntimeExports.jsx(LoadingSpinnerIcon,{})}):jsxRuntimeExports.jsx("div",{className:"mercoa-p-10 mercoa-text-center"}):jsxRuntimeExports.jsx(NoSession,{componentName:"PlaidPopup"})}function AddBankViaPlaidOrManual({title:W,actions:re,onSubmit:oe,entityId:ie,bankAccount:pe}){const nr=useMercoaSession(),[or,ar]=React.useState(null);return React.useEffect(()=>{nr.entityId&&(ie&&ie!=nr.entityId?ar(!0):ar(!1))},[nr.entityId,ie]),nr.client?or?jsxRuntimeExports.jsx(AddBankAccount,{title:W,actions:re,onSubmit:oe,entityId:ie,bankAccount:pe}):or===!1?jsxRuntimeExports.jsx(PlaidPopup,{onSubmit:oe,onExit:(ir,sr)=>{ir&&Q$1.error("There was an error adding your bank account automatically. Please try again or add manually."),ar(!0)}}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{}):jsxRuntimeExports.jsx(NoSession,{componentName:"AddBankViaPlaidOrManual"})}function AddBankAccount({onSubmit:W,title:re,actions:oe,bankAccount:ie,entityId:pe}){const nr=useMercoaSession();addMethod(create$6,"accountNumber",function(sr){return this.test({name:"accountNumber",exclusive:!0,message:sr||"Invalid Account Number",test:cr=>!!cr&&Number(cr)>0})}),addMethod(create$6,"routingNumber",function(sr){return this.test({name:"routingNumber",exclusive:!0,message:sr||"Invalid Routing Number",test:cr=>!!cr&&cr.length==9&&Number(cr)>0})});const or=create$3({routingNumber:create$6().required("Please enter a valid routing number"),accountNumber:create$6().accountNumber().required("Please enter a valid account number")}).required(),ar=useForm({defaultValues:ie,resolver:o(or)});async function ir(sr){var cr,lr,ur;if((cr=nr.entity)!=null&&cr.id){const fr=await((ur=nr.client)==null?void 0:ur.entity.paymentMethod.create(pe??((lr=nr.entity)==null?void 0:lr.id),{...sr,type:"bankAccount"}));if(!W)return;fr?W(fr):W()}}return nr.client?jsxRuntimeExports.jsx(FormProvider,{...ar,children:jsxRuntimeExports.jsxs("form",{className:"mercoa-space-y-3 mercoa-text-left",onSubmit:ar.handleSubmit(ir),children:[re||jsxRuntimeExports.jsx("h3",{className:"mercoa-text-center mercoa-text-lg mercoa-font-medium mercoa-leading-6 mercoa-text-gray-900",children:"Add Bank Account"}),jsxRuntimeExports.jsx(AddBankAccountForm,{}),oe||jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-justify-between",children:[jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!1,onClick:()=>{W&&W()},type:"button",children:"Back"}),jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!0,children:"Add Bank Account"})]})]})}):jsxRuntimeExports.jsx(NoSession,{componentName:"AddBankAccount"})}function AddBankAccountForm({prefix:W}){const re=useMercoaSession();W||(W="");const{register:oe,setValue:ie,setError:pe,clearErrors:nr,watch:or,formState:{errors:ar}}=useFormContext(),ir=or(W+"routingNumber"),sr=or(W+"bankName");return React.useEffect(()=>{var cr;ie(W+"bankName","",{shouldDirty:!0,shouldTouch:!0}),ir&&(ir.length===9?(cr=re.client)==null||cr.bankLookup.find({routingNumber:ir}).then(lr=>{lr.bankName?(ie(W+"bankName",lr.bankName),nr(W+"routingNumber")):pe(W+"routingNumber",{message:"Please enter a valid routing number"})}):ir&&pe(W+"routingNumber",{message:"Please enter a valid routing number"}))},[ir]),re.client?jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-flex-col mercoa-gap-y-2",children:[jsxRuntimeExports.jsx(MercoaInput,{label:`Routing Number ${sr?` - ${sr}`:""}`,name:W+"routingNumber",register:oe,errors:ar}),jsxRuntimeExports.jsx(MercoaInput,{label:"Account Number",name:W+"accountNumber",register:oe,errors:ar}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("label",{htmlFor:"accountType",className:"mercoa-block mercoa-text-sm mercoa-font-medium mercoa-text-gray-900",children:"Account Type"}),jsxRuntimeExports.jsx("div",{className:"mercoa-mt-1",children:jsxRuntimeExports.jsxs("select",{...oe(W+"accountType"),className:inputClassName({}),children:[jsxRuntimeExports.jsx("option",{value:"CHECKING",children:"Checking"}),jsxRuntimeExports.jsx("option",{value:"SAVINGS",children:"Savings"}),jsxRuntimeExports.jsx("option",{value:"UNKNOWN",children:"Other"})]})})]}),jsxRuntimeExports.jsx(MercoaInput,{label:"Account Name",name:W+"accountName",register:oe,errors:ar,optional:!0})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"AddBankAccountForm"})}function EditBankAccount({account:W,onSubmit:re}){var pr;const oe=useMercoaSession(),[ie,pe]=React.useState(!1),nr=React.useRef(null),or=React.useRef(null),[ar,ir]=React.useState([]),{register:sr,handleSubmit:cr,watch:lr,setValue:ur}=useForm({defaultValues:{accountName:W.accountName,checkOptions:W.checkOptions,externalAccountingSystemId:W.externalAccountingSystemId}});function fr(hr){var gr,wr,br,_r,Mr,$r,vr,Or,Sr;let yr;(gr=hr.checkOptions)!=null&&gr.useSignatureImage&&(yr=((wr=nr.current)==null?void 0:wr.getTrimmedCanvas().toDataURL("image/png"))??""),(br=oe.entity)!=null&&br.id&&((Sr=oe.client)==null||Sr.entity.paymentMethod.update((_r=oe.entity)==null?void 0:_r.id,W.id,{accountName:hr.accountName,checkOptions:{enabled:(Mr=hr.checkOptions)==null?void 0:Mr.enabled,initialCheckNumber:Number(($r=hr.checkOptions)==null?void 0:$r.initialCheckNumber),signatoryName:`${(vr=hr.checkOptions)==null?void 0:vr.signatoryName}`,useSignatureImage:(Or=hr.checkOptions)==null?void 0:Or.useSignatureImage,...yr&&{signatureImage:yr}},type:javascript.Mercoa.PaymentMethodType.BankAccount,externalAccountingSystemId:hr.externalAccountingSystemId}).then(()=>{Q$1.success("Bank account updated"),re&&re(hr),oe.refresh()}).catch(Cr=>{Q$1.error("There was an error updating your bank account")}))}const dr=!!(W.accountType==="CHECKING"&&lr("checkOptions.enabled")),mr=lr("checkOptions.useSignatureImage");return React.useEffect(()=>{var hr,yr,gr;(hr=W.checkOptions)!=null&&hr.signatureImage&&nr.current&&((gr=nr.current)==null||gr.fromDataURL("data:image/gif;base64,"+((yr=W.checkOptions)==null?void 0:yr.signatureImage)))},[(pr=W.checkOptions)==null?void 0:pr.signatureImage,mr]),React.useEffect(()=>{var hr;oe.entityId&&((hr=oe.client)==null||hr.entity.metadata.get(oe.entityId,"externalAccountingSystemBankAccounts").then(yr=>{if(yr){const gr=yr.map(wr=>JSON.parse(wr));console.log(gr),ir(gr)}}))},[oe.entityId,oe.refreshId]),console.log(lr("externalAccountingSystemId")),oe.client?jsxRuntimeExports.jsxs("form",{onSubmit:cr(fr),children:[jsxRuntimeExports.jsx(MercoaInput,{label:"Account Name",name:"accountName",register:sr,optional:!0}),ar.length>0&&jsxRuntimeExports.jsx(MercoaCombobox,{label:"Accounting System Bank Name",onChange:hr=>{ur("externalAccountingSystemId",hr.key)},options:ar.map(hr=>({disabled:!1,value:hr})),displayIndex:"value",value:ar.find(hr=>hr.key===lr("externalAccountingSystemId")),className:"mercoa-mt-2"}),W.accountType==="CHECKING"&&jsxRuntimeExports.jsxs("div",{className:"mercoa-relative mercoa-mt-5 mercoa-flex mercoa-items-start mercoa-items-center",children:[jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-h-5 mercoa-items-center",children:jsxRuntimeExports.jsx("input",{...sr("checkOptions.enabled"),type:"checkbox",className:"mercoa-size-4 mercoa-rounded mercoa-border-gray-300 mercoa-text-mercoa-primary-text focus:mercoa-ring-mercoa-primary"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-ml-3 mercoa-text-sm",children:jsxRuntimeExports.jsx(Tooltip,{title:"If enabled, checks can be printed with the account and routing number of this account.",children:jsxRuntimeExports.jsxs("label",{htmlFor:"checkOptions.enabled",className:"mercoa-font-medium mercoa-text-gray-700",children:["Enable Check Payments",jsxRuntimeExports.jsx(ForwardRef$n,{className:"mercoa-inline mercoa-size-5"})]})})})]}),dr&&jsxRuntimeExports.jsxs("div",{className:"mercoa-bg-gray-100 mercoa-p-2 mercoa-rounded-mercoa mercoa-mt-2",children:[jsxRuntimeExports.jsx(MercoaInput,{label:"Initial Check Number",name:"checkOptions.initialCheckNumber",register:sr,optional:!0,className:"mercoa-mt-2"}),jsxRuntimeExports.jsx(MercoaInput,{label:"Signatory Name",name:"checkOptions.signatoryName",register:sr,required:!0,className:"mercoa-mt-2"}),jsxRuntimeExports.jsxs("div",{className:"mercoa-relative mercoa-mt-5 mercoa-flex mercoa-items-start mercoa-items-center",children:[jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-h-5 mercoa-items-center",children:jsxRuntimeExports.jsx("input",{...sr("checkOptions.useSignatureImage"),type:"checkbox",className:"mercoa-size-4 mercoa-rounded mercoa-border-gray-300 mercoa-text-mercoa-primary-text focus:mercoa-ring-mercoa-primary"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-ml-3 mercoa-text-sm",children:jsxRuntimeExports.jsx("label",{htmlFor:"useSig",className:"mercoa-font-medium mercoa-text-gray-700",children:"Use Custom Signature"})})]}),mr&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"mercoa-mt-2 mercoa-bg-white",children:jsxRuntimeExports.jsx(SignatureCanvas,{ref:nr,canvasProps:{width:375,height:150}})}),jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-2 mercoa-flex mercoa-gap-x-2",children:[jsxRuntimeExports.jsx("input",{type:"file",ref:or,style:{display:"none"},accept:"image/*",onChange:hr=>{var yr;hr.target.files&&((yr=nr.current)==null||yr.fromDataURL(URL.createObjectURL(hr.target.files[0])))}}),jsxRuntimeExports.jsx(MercoaButton,{size:"sm",isEmphasized:!1,type:"button",onClick:()=>{var hr;return(hr=or==null?void 0:or.current)==null?void 0:hr.click()},children:"Upload Image"}),jsxRuntimeExports.jsx(MercoaButton,{color:"red",size:"sm",isEmphasized:!1,type:"button",onClick:()=>{var hr;return(hr=nr.current)==null?void 0:hr.clear()},children:"Clear Signature"})]})]})]}),jsxRuntimeExports.jsx(MercoaButton,{size:"sm",isEmphasized:!1,className:"mercoa-mt-5",type:"button",onClick:()=>pe(!0),children:"Reconnect Bank Account"}),ie&&jsxRuntimeExports.jsx(PlaidPopup,{onExit:()=>pe(!1),paymentMethodId:W.id}),jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-justify-between mercoa-mt-5",children:[jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!1,onClick:()=>{re&&re()},type:"button",children:"Back"}),jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!0,children:"Update"})]})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"EditBankAccount"})}const moovCssVariables={"--moov-color-background":"#FFFFFF","--moov-color-background-secondary":"#F5F6F9","--moov-color-background-tertiary":"#E7E7F1","--moov-color-mercoa-primary":"#4A5CF5","--moov-color-secondary":"#3D50EC","--moov-color-tertiary":"#B9BBC3","--moov-color-info":"#94CBFF","--moov-color-warn":"#EB5757","--moov-color-danger":"#EA0F43","--moov-color-success":"#62E599","--moov-color-low-contrast":"#5B5D6A","--moov-color-medium-contrast":"#494A57","--moov-color-high-contrast":"#000000","--moov-color-graphic-1":"#3D50EC","--moov-color-graphic-2":"#3D50EC","--moov-color-graphic-3":"#3D50EC"};function Cards({children:W,onSelect:re,showAdd:oe,showEdit:ie}){var cr;const[pe,nr]=React.useState(),[or,ar]=React.useState(!1),ir=useMercoaSession();React.useEffect(()=>{var lr,ur,fr;ir.token&&((lr=ir.entity)!=null&&lr.id)&&((fr=ir.client)==null||fr.entity.paymentMethod.getAll((ur=ir.entity)==null?void 0:ur.id,{type:"card"}).then(dr=>{nr(dr.filter(mr=>mr).map(mr=>mr))}))},[(cr=ir.entity)==null?void 0:cr.id,ir.token,or,ir.refreshId]);const sr=lr=>{ar(!1),re&&lr&&re(lr)};return ir.client?W?W({bankAccounts:pe}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[!pe&&jsxRuntimeExports.jsx("div",{className:"mercoa-p-9 mercoa-text-center",children:jsxRuntimeExports.jsx(LoadingSpinnerIcon,{})}),jsxRuntimeExports.jsx(PaymentMethodList,{accounts:pe,showEdit:ie,addAccount:pe&&oe?jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-2",children:[jsxRuntimeExports.jsx(AddDialog,{show:or,onClose:sr,component:jsxRuntimeExports.jsx(AddCard,{onSubmit:lr=>{sr(lr)}})}),jsxRuntimeExports.jsx(Card,{onSelect:()=>ar(!0)})]}):void 0,formatAccount:lr=>jsxRuntimeExports.jsx(Card,{account:lr,onSelect:re,showEdit:ie})})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"CreditCards"})}function AddCard({onSubmit:W,title:re,actions:oe}){const ie=useMercoaSession();return React.useEffect(()=>{if(!ie.entityId||!ie.moovToken||!ie.moovAccountId)return;const pe=document.documentElement;for(let ar in moovCssVariables)pe.style.setProperty(ar,moovCssVariables[ar]);const nr=document.querySelector("moov-card-link");if(!nr)return;nr.setAttribute("oauth-token",ie.moovToken),nr.setAttribute("account-id",ie.moovAccountId);const or=async ar=>{var sr;const ir=await((sr=ie.client)==null?void 0:sr.entity.paymentMethod.create((ie==null?void 0:ie.entityId)??"",{type:"card",cardType:ar.cardType,cardBrand:ar.brand.replace(" ",""),lastFour:ar.lastFourCardNumber,expMonth:ar.expiration.month,expYear:ar.expiration.year,token:ar.cardID}));if(!ir)throw new Error("Failed to create payment method");W(ir)};nr.onSuccess=or},[ie.moovToken,ie.moovAccountId,ie.entityId]),ie.client?jsxRuntimeExports.jsxs("div",{className:"mercoa-space-y-3 mercoa-text-left",children:[re||jsxRuntimeExports.jsx("h3",{className:"mercoa-text-center mercoa-text-lg mercoa-font-medium mercoa-leading-6 mercoa-text-gray-900",children:"Add Card"}),jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-items-center mercoa-justify-center",children:[jsxRuntimeExports.jsx("moov-card-link",{}),jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!0,onClick:()=>{document.querySelector("moov-card-link").submit()},children:"Add"})]}),oe&&jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-justify-between",children:oe})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"AddCreditCard"})}function Card({children:W,account:re,onSelect:oe,showEdit:ie,selected:pe}){var ar,ir,sr;const nr=useMercoaSession();if(!nr.client)return jsxRuntimeExports.jsx(NoSession,{componentName:"CreditCardComponent"});if(!((sr=(ir=(ar=nr.organization)==null?void 0:ar.paymentMethods)==null?void 0:ir.payerPayments)!=null&&sr.find(cr=>cr.type==="card"&&cr.active)))return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{});let or=re==null?void 0:re.cardBrand;return or==="AmericanExpress"&&(or="Amex"),re?jsxRuntimeExports.jsxs("div",{onClick:()=>{oe&&oe(re)},className:`mercoa-relative mercoa-flex mercoa-items-center mercoa-space-x-3 mercoa-rounded-mercoa mercoa-border ${pe?"mercoa-border-gray-600":"mercoa-border-gray-300"} mercoa-bg-white mercoa-px-6 mercoa-py-5 mercoa-shadow-sm focus-within:mercoa-ring-2 focus-within:mercoa-ring-indigo-500 focus-within:mercoa-ring-offset-2 ${oe?"mercoa-cursor-pointer hover:mercoa-border-gray-400":""}`,children:[jsxRuntimeExports.jsx("div",{className:`mercoa-flex-shrink-0 mercoa-rounded-full mercoa-p-1 ${pe?"mercoa-text-mercoa-primary-text-invert mercoa-bg-mercoa-primary-light":"mercoa-bg-gray-200 mercoa-text-gray-600"}`,children:jsxRuntimeExports.jsx(ForwardRef$A,{className:"mercoa-size-5"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-min-w-0 mercoa-flex-1 mercoa-justify-between",children:jsxRuntimeExports.jsxs("div",{children:[!ie&&jsxRuntimeExports.jsx("span",{className:"mercoa-absolute mercoa-inset-0","aria-hidden":"true"}),jsxRuntimeExports.jsx("p",{className:`mercoa-text-sm mercoa-font-medium mercoa-text-gray-900 ${pe?"mercoa-underline":""}`,children:`${capitalize(or)} ••••${re==null?void 0:re.lastFour}`})]})}),ie&&jsxRuntimeExports.jsx("div",{className:"mercoa-flex",children:jsxRuntimeExports.jsx(DefaultPaymentMethodIndicator,{paymentMethod:re})})]},`${re==null?void 0:re.id}`):jsxRuntimeExports.jsxs("div",{onClick:()=>{oe&&oe(re)},className:`mercoa-relative mercoa-flex mercoa-items-center mercoa-space-x-3 mercoa-rounded-mercoa mercoa-border mercoa-border-gray-300 mercoa-bg-white mercoa-px-6 mercoa-py-5 mercoa-shadow-sm focus-within:mercoa-ring-2 focus-within:mercoa-ring-indigo-500 focus-within:mercoa-ring-offset-2 hover:mercoa-border-gray-400 ${oe?"mercoa-cursor-pointer ":""}`,children:[jsxRuntimeExports.jsx("div",{className:`mercoa-flex-shrink-0 mercoa-rounded-full mercoa-p-1 ${pe?"mercoa-text-mercoa-primary-text-invert mercoa-bg-mercoa-primary-light":"mercoa-bg-gray-200 mercoa-text-gray-600"}`,children:jsxRuntimeExports.jsx(ForwardRef$d,{className:"mercoa-size-5"})}),jsxRuntimeExports.jsxs("div",{className:"mercoa-min-w-0 mercoa-flex-1",children:[jsxRuntimeExports.jsx("span",{className:"mercoa-absolute mercoa-inset-0","aria-hidden":"true"}),jsxRuntimeExports.jsx("p",{className:"mercoa-text-sm mercoa-font-medium mercoa-text-gray-900",children:"Add new card"}),jsxRuntimeExports.jsx("p",{className:"mercoa-truncate mercoa-text-sm mercoa-text-gray-500"})]})]})}const postalCodeRegex=/(^\d{5}$)|(^\d{5}-\d{4}$)/,usaStates=[{name:"Alabama",abbreviation:"AL"},{name:"Alaska",abbreviation:"AK"},{name:"American Samoa",abbreviation:"AS"},{name:"Arizona",abbreviation:"AZ"},{name:"Arkansas",abbreviation:"AR"},{name:"California",abbreviation:"CA"},{name:"Colorado",abbreviation:"CO"},{name:"Connecticut",abbreviation:"CT"},{name:"Delaware",abbreviation:"DE"},{name:"District Of Columbia",abbreviation:"DC"},{name:"Federated States Of Micronesia",abbreviation:"FM"},{name:"Florida",abbreviation:"FL"},{name:"Georgia",abbreviation:"GA"},{name:"Guam",abbreviation:"GU"},{name:"Hawaii",abbreviation:"HI"},{name:"Idaho",abbreviation:"ID"},{name:"Illinois",abbreviation:"IL"},{name:"Indiana",abbreviation:"IN"},{name:"Iowa",abbreviation:"IA"},{name:"Kansas",abbreviation:"KS"},{name:"Kentucky",abbreviation:"KY"},{name:"Louisiana",abbreviation:"LA"},{name:"Maine",abbreviation:"ME"},{name:"Marshall Islands",abbreviation:"MH"},{name:"Maryland",abbreviation:"MD"},{name:"Massachusetts",abbreviation:"MA"},{name:"Michigan",abbreviation:"MI"},{name:"Minnesota",abbreviation:"MN"},{name:"Mississippi",abbreviation:"MS"},{name:"Missouri",abbreviation:"MO"},{name:"Montana",abbreviation:"MT"},{name:"Nebraska",abbreviation:"NE"},{name:"Nevada",abbreviation:"NV"},{name:"New Hampshire",abbreviation:"NH"},{name:"New Jersey",abbreviation:"NJ"},{name:"New Mexico",abbreviation:"NM"},{name:"New York",abbreviation:"NY"},{name:"North Carolina",abbreviation:"NC"},{name:"North Dakota",abbreviation:"ND"},{name:"Northern Mariana Islands",abbreviation:"MP"},{name:"Ohio",abbreviation:"OH"},{name:"Oklahoma",abbreviation:"OK"},{name:"Oregon",abbreviation:"OR"},{name:"Palau",abbreviation:"PW"},{name:"Pennsylvania",abbreviation:"PA"},{name:"Puerto Rico",abbreviation:"PR"},{name:"Rhode Island",abbreviation:"RI"},{name:"South Carolina",abbreviation:"SC"},{name:"South Dakota",abbreviation:"SD"},{name:"Tennessee",abbreviation:"TN"},{name:"Texas",abbreviation:"TX"},{name:"Utah",abbreviation:"UT"},{name:"Vermont",abbreviation:"VT"},{name:"Virgin Islands",abbreviation:"VI"},{name:"Virginia",abbreviation:"VA"},{name:"Washington",abbreviation:"WA"},{name:"West Virginia",abbreviation:"WV"},{name:"Wisconsin",abbreviation:"WI"},{name:"Wyoming",abbreviation:"WY"}];function Check({account:W,onSelect:re,showEdit:oe,selected:ie}){const pe=useMercoaSession();async function nr(){var or,ar,ir;pe.token&&((or=pe.entity)!=null&&or.id)&&(W!=null&&W.id)&&(await((ir=pe.client)==null?void 0:ir.entity.paymentMethod.delete((ar=pe.entity)==null?void 0:ar.id,W==null?void 0:W.id)),pe.refresh())}return pe.client?W?jsxRuntimeExports.jsxs("div",{onClick:()=>{re&&re(W)},className:`mercoa-relative mercoa-flex mercoa-items-center mercoa-space-x-3 mercoa-rounded-mercoa mercoa-border ${ie?"mercoa-border-gray-600":"mercoa-border-gray-300"} mercoa-bg-white mercoa-px-6 mercoa-py-5 mercoa-shadow-sm focus-within:mercoa-ring-2 focus-within:mercoa-ring-indigo-500 focus-within:mercoa-ring-offset-2 ${re?"mercoa-cursor-pointer hover:mercoa-border-gray-400":""}`,children:[jsxRuntimeExports.jsx("div",{className:`mercoa-flex-shrink-0 mercoa-rounded-full mercoa-p-1 ${ie?"mercoa-text-mercoa-primary-text-invert mercoa-bg-mercoa-primary-light":"mercoa-bg-gray-200 mercoa-text-gray-600"}`,children:jsxRuntimeExports.jsx(ForwardRef$v,{className:"mercoa-size-5"})}),jsxRuntimeExports.jsxs("div",{className:"mercoa-min-w-0 mercoa-flex-1",children:[!oe&&jsxRuntimeExports.jsx("span",{className:"mercoa-absolute mercoa-inset-0","aria-hidden":"true"}),jsxRuntimeExports.jsx("p",{className:`mercoa-text-sm mercoa-font-medium mercoa-text-gray-900 ${ie?"mercoa-underline":""}`,children:`${W==null?void 0:W.payToTheOrderOf}`}),jsxRuntimeExports.jsx("p",{className:`mercoa-text-sm mercoa-font-medium mercoa-text-gray-900 ${ie?"mercoa-underline":""}`,children:`${W==null?void 0:W.addressLine1}, ${W==null?void 0:W.addressLine2}`}),jsxRuntimeExports.jsx("p",{className:`mercoa-text-sm mercoa-font-medium mercoa-text-gray-900 ${ie?"mercoa-underline":""}`,children:`${W==null?void 0:W.city} ${W==null?void 0:W.stateOrProvince}, ${W==null?void 0:W.postalCode}`})]}),oe&&jsxRuntimeExports.jsxs("div",{className:"mercoa-flex-shrink-0",children:[jsxRuntimeExports.jsx(DefaultPaymentMethodIndicator,{paymentMethod:W}),jsxRuntimeExports.jsxs("button",{className:"mercoa-ml-1 mercoa-cursor-pointer hover:mercoa-text-red-300",onClick:()=>nr(),children:[" ",jsxRuntimeExports.jsx(ForwardRef$6,{className:"mercoa-size-5"})]})]})]},`${W==null?void 0:W.addressLine1} ${W==null?void 0:W.addressLine1}`):jsxRuntimeExports.jsxs("div",{onClick:()=>{re&&re()},className:`mercoa-relative mercoa-flex mercoa-items-center mercoa-space-x-3 mercoa-rounded-mercoa mercoa-border mercoa-border-gray-300 mercoa-bg-white mercoa-px-6 mercoa-py-5 mercoa-shadow-sm focus-within:mercoa-ring-2 focus-within:mercoa-ring-indigo-500 focus-within:mercoa-ring-offset-2 hover:mercoa-border-gray-400 ${re?"mercoa-cursor-pointer ":""}`,children:[jsxRuntimeExports.jsx("div",{className:`mercoa-flex-shrink-0 mercoa-rounded-full mercoa-p-1 ${ie?"mercoa-text-mercoa-primary-text-invert mercoa-bg-mercoa-primary-light":"mercoa-bg-gray-200 mercoa-text-gray-600"}`,children:jsxRuntimeExports.jsx(ForwardRef$d,{className:"mercoa-size-5"})}),jsxRuntimeExports.jsxs("div",{className:"mercoa-min-w-0 mercoa-flex-1",children:[jsxRuntimeExports.jsx("span",{className:"mercoa-absolute mercoa-inset-0","aria-hidden":"true"}),jsxRuntimeExports.jsx("p",{className:"mercoa-text-sm mercoa-font-medium mercoa-text-gray-900",children:"Add new address"}),jsxRuntimeExports.jsx("p",{className:"mercoa-truncate mercoa-text-sm mercoa-text-gray-500"})]})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"CheckComponent"})}function AddCheckDialog({entityId:W,onSelect:re,check:oe}){const[ie,pe]=React.useState(!1),nr=or=>{pe(!1),re&&or&&re(or)};return jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-2",children:[jsxRuntimeExports.jsx(AddDialog,{show:ie,onClose:nr,component:jsxRuntimeExports.jsx(AddCheck,{onSubmit:or=>{nr(or)},entityId:W,check:oe})}),jsxRuntimeExports.jsx(Check,{onSelect:()=>pe(!0)})]})}function AddCheck({onSubmit:W,title:re,actions:oe,check:ie,entityId:pe}){const nr=useMercoaSession(),or=create$3({payToTheOrderOf:create$6().required(),addressLine1:create$6().required(),city:create$6().required(),stateOrProvince:create$6().required(),postalCode:create$6().required()}).required(),ar=useForm({defaultValues:ie,resolver:o(or)});async function ir(sr){var cr,lr,ur;if((cr=nr.entity)!=null&&cr.id){sr.country="US";const fr=await((ur=nr.client)==null?void 0:ur.entity.paymentMethod.create(pe??((lr=nr.entity)==null?void 0:lr.id),{...sr,type:"check"}));if(!W)return;fr?W(fr):W()}}return nr.client?jsxRuntimeExports.jsx(FormProvider,{...ar,children:jsxRuntimeExports.jsxs("form",{className:"mercoa-space-y-3 mercoa-text-left",onSubmit:ar.handleSubmit(ir),children:[re||jsxRuntimeExports.jsx("h3",{className:"mercoa-text-center mercoa-text-lg mercoa-font-medium mercoa-leading-6 mercoa-text-gray-900",children:"Add Check Address"}),jsxRuntimeExports.jsx(AddCheckForm,{}),jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-justify-end",children:oe||jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!0,children:"Add Check Address"})})]})}):jsxRuntimeExports.jsx(NoSession,{componentName:"AddCheck"})}function AddCheckForm({prefix:W}){const{register:re,setValue:oe,watch:ie,formState:{errors:pe}}=useFormContext();W||(W="");const nr=ie(W+"stateOrProvince");return jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-flex-col mercoa-gap-y-2",children:[jsxRuntimeExports.jsx(MercoaInput,{register:re,name:W+"payToTheOrderOf",label:"Pay To The Order Of",className:"mercoa-mt-1"}),jsxRuntimeExports.jsx(MercoaInput,{register:re,name:W+"addressLine1",label:"Address Line 1",className:"mercoa-mt-1",errors:pe}),jsxRuntimeExports.jsxs("div",{className:"mercoa-grid mercoa-grid-cols-2 mercoa-gap-x-4",children:[jsxRuntimeExports.jsx(MercoaInput,{register:re,name:W+"addressLine2",label:"Address Line 2",className:"mercoa-mt-1",errors:pe}),jsxRuntimeExports.jsx(MercoaInput,{register:re,name:W+"city",label:"City",className:"mercoa-mt-1",errors:pe})]}),jsxRuntimeExports.jsxs("div",{className:"mercoa-grid mercoa-grid-cols-2 mercoa-gap-x-4",children:[jsxRuntimeExports.jsx(MercoaCombobox,{options:usaStates.map(({name:or,abbreviation:ar})=>({disabled:!1,value:ar})),label:"State",value:nr,onChange:or=>{oe(W+"stateOrProvince",or,{shouldDirty:!0})}}),jsxRuntimeExports.jsx(MercoaInput,{register:re,name:W+"postalCode",label:"Postal Code",className:"mercoa-mt-1",errors:pe})]})]})}var humanparser={exports:{}};const parser$2=humanparser.exports={};function diff(W,re){return W.concat(re).filter((oe,ie,pe)=>pe.indexOf(oe)===pe.lastIndexOf(oe))}const lc=W=>W.toLowerCase();parser$2.parseName=function(W,re={}){let oe=[],ie=[],pe=[],nr=[],or=[],ar=[];Array.isArray(re)?ar=re.map(mr=>mr.toLowerCase()):({extraCompound:oe=[],extraSalutations:ie=[],extraSuffixes:pe=[],ignoreCompound:nr=[],ignoreSalutation:or=[],ignoreSuffix:ar=[]}=re,oe=oe.map(lc),ie=ie.map(lc),pe=pe.map(lc),nr=nr.map(lc),or=or.map(lc),ar=ar.map(lc));const ir=["mr","master","mister","mrs","miss","ms","dr","prof","rev","fr","judge","honorable","hon","tuan","sr","srta","br","pr","mx","sra",...ie].filter(mr=>!or.includes(mr)),sr=["i","ii","iii","iv","v","senior","junior","jr","sr","phd","apr","rph","pe","md","ma","dmd","cme","qc","kc",...pe].filter(mr=>!ar.includes(mr)),cr=["vere","von","van","de","del","della","der","den","di","da","pietro","vanden","du","st.","st","la","lo","ter","bin","ibn","te","ten","op","ben","al",...oe].filter(mr=>!nr.includes(mr));let lr=W.trim().replace(/\b\s+(,\s+)\b/,"$1").replace(/\b,\b/,", ");lr=(lr.match(/[^\s"]+|"[^"]+"/g)||lr.split(/\s+/)).map(mr=>mr.match(/^".*"$/)?mr.slice(1,-1):mr);const ur={};if(!lr.length)return ur;if(lr.length===1&&(ur.firstName=lr[0]),lr.length>1&&sr.indexOf(lr[lr.length-1].toLowerCase().replace(/\./g,""))>-1&&(ur.suffix=lr.pop(),lr[lr.length-1]=lr[lr.length-1].replace(",","")),lr.every(mr=>mr.indexOf(",")===-1)){lr.length>1&&ir.indexOf(lr[0].toLowerCase().replace(/\./g,""))>-1?(ur.salutation=lr.shift(),lr.length===1?ur.lastName=lr.shift():ur.firstName=lr.shift()):ur.firstName=lr.shift(),ur.lastName||(ur.lastName=lr.length?lr.pop():"");const mr=lr.slice(0).reverse(),pr=[];mr.every(hr=>{const yr=hr.toLowerCase().replace(/\./g,"");return cr.indexOf(yr)>-1?(pr.push(hr),!0):!1}),pr.length&&(ur.lastName=pr.reverse().join(" ")+" "+ur.lastName,lr=diff(lr,pr)),lr.length&&(ur.middleName=lr.join(" ")),ur.lastName&&(ur.lastName=ur.lastName.replace(",","")),ur.fullName=W}else{let mr;const pr=lr.reduce((yr,gr,wr)=>Array.isArray(yr)?gr.indexOf(",")===-1?(yr.push(gr),yr):(gr=gr.replace(",",""),sr.indexOf(gr.toLowerCase().replace(/\./g,""))>-1?ur.suffix=gr:yr.push(gr),mr=wr+1,yr.join(" ")):yr,[]);ur.lastName=pr;var dr=lr.slice(mr);dr.length>1?(ur.firstName=dr.shift(),ur.middleName=dr.join(" ")):dr.length&&(ur.firstName=dr[0]);const hr=[];ur.firstName&&hr.push(ur.firstName),ur.middleName&&hr.push(ur.middleName),hr.push(ur.lastName),ur.suffix&&hr.push(ur.suffix),ur.fullName=hr.join(" ")}for(const[mr,pr]of Object.entries(ur))ur[mr]=pr.trim();return ur},parser$2.getFullestName=W=>{let re=W,oe=[];return(re.indexOf("&")>-1||re.toLowerCase().indexOf(" and ")>-1)&&(oe=re.split(/\s+(?:and|&)\s+/gi),oe.length&&(re=oe.sort(function(ie,pe){return pe.split(/\s+/).length-ie.split(/\s+/).length})[0])),re},parser$2.parseAddress=W=>{W=W.replace(/\n/gi,", ");const re=W.split(/,\s+/).reverse();let oe,ie;const pe={};return oe=re[0].split(/\s+/),re.shift(),ie=re.shift(),pe.address=re.reverse().join(", "),pe.city=ie,pe.state=oe[0],pe.zip=oe[1],pe.fullAddress=W,pe};var humanparserExports=humanparser.exports;const vitePluginRequire_1721693194810_68601018=getDefaultExportFromCjs(humanparserExports);function isObject$5(W){var re=typeof W;return W!=null&&(re=="object"||re=="function")}var isObject_1=isObject$5,freeGlobal$1=typeof commonjsGlobal$1=="object"&&commonjsGlobal$1&&commonjsGlobal$1.Object===Object&&commonjsGlobal$1,_freeGlobal=freeGlobal$1,freeGlobal=_freeGlobal,freeSelf=typeof self=="object"&&self&&self.Object===Object&&self,root$4=freeGlobal||freeSelf||Function("return this")(),_root=root$4,root$3=_root,now$1=function(){return root$3.Date.now()},now_1=now$1,reWhitespace=/\s/;function trimmedEndIndex$1(W){for(var re=W.length;re--&&reWhitespace.test(W.charAt(re)););return re}var _trimmedEndIndex=trimmedEndIndex$1,trimmedEndIndex=_trimmedEndIndex,reTrimStart=/^\s+/;function baseTrim$1(W){return W&&W.slice(0,trimmedEndIndex(W)+1).replace(reTrimStart,"")}var _baseTrim=baseTrim$1,root$2=_root,Symbol$4=root$2.Symbol,_Symbol=Symbol$4,Symbol$3=_Symbol,objectProto$4=Object.prototype,hasOwnProperty$3=objectProto$4.hasOwnProperty,nativeObjectToString$1=objectProto$4.toString,symToStringTag$1=Symbol$3?Symbol$3.toStringTag:void 0;function getRawTag$1(W){var re=hasOwnProperty$3.call(W,symToStringTag$1),oe=W[symToStringTag$1];try{W[symToStringTag$1]=void 0;var ie=!0}catch{}var pe=nativeObjectToString$1.call(W);return ie&&(re?W[symToStringTag$1]=oe:delete W[symToStringTag$1]),pe}var _getRawTag=getRawTag$1,objectProto$3=Object.prototype,nativeObjectToString=objectProto$3.toString;function objectToString$1(W){return nativeObjectToString.call(W)}var _objectToString=objectToString$1,Symbol$2=_Symbol,getRawTag=_getRawTag,objectToString=_objectToString,nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=Symbol$2?Symbol$2.toStringTag:void 0;function baseGetTag$2(W){return W==null?W===void 0?undefinedTag:nullTag:symToStringTag&&symToStringTag in Object(W)?getRawTag(W):objectToString(W)}var _baseGetTag=baseGetTag$2;function isObjectLike$1(W){return W!=null&&typeof W=="object"}var isObjectLike_1=isObjectLike$1,baseGetTag$1=_baseGetTag,isObjectLike=isObjectLike_1,symbolTag="[object Symbol]";function isSymbol$4(W){return typeof W=="symbol"||isObjectLike(W)&&baseGetTag$1(W)==symbolTag}var isSymbol_1=isSymbol$4,baseTrim=_baseTrim,isObject$4=isObject_1,isSymbol$3=isSymbol_1,NAN=NaN,reIsBadHex=/^[-+]0x[0-9a-f]+$/i,reIsBinary=/^0b[01]+$/i,reIsOctal=/^0o[0-7]+$/i,freeParseInt=parseInt;function toNumber$1(W){if(typeof W=="number")return W;if(isSymbol$3(W))return NAN;if(isObject$4(W)){var re=typeof W.valueOf=="function"?W.valueOf():W;W=isObject$4(re)?re+"":re}if(typeof W!="string")return W===0?W:+W;W=baseTrim(W);var oe=reIsBinary.test(W);return oe||reIsOctal.test(W)?freeParseInt(W.slice(2),oe?2:8):reIsBadHex.test(W)?NAN:+W}var toNumber_1=toNumber$1,isObject$3=isObject_1,now=now_1,toNumber=toNumber_1,FUNC_ERROR_TEXT$1="Expected a function",nativeMax=Math.max,nativeMin=Math.min;function debounce$1(W,re,oe){var ie,pe,nr,or,ar,ir,sr=0,cr=!1,lr=!1,ur=!0;if(typeof W!="function")throw new TypeError(FUNC_ERROR_TEXT$1);re=toNumber(re)||0,isObject$3(oe)&&(cr=!!oe.leading,lr="maxWait"in oe,nr=lr?nativeMax(toNumber(oe.maxWait)||0,re):nr,ur="trailing"in oe?!!oe.trailing:ur);function fr(_r){var Mr=ie,$r=pe;return ie=pe=void 0,sr=_r,or=W.apply($r,Mr),or}function dr(_r){return sr=_r,ar=setTimeout(hr,re),cr?fr(_r):or}function mr(_r){var Mr=_r-ir,$r=_r-sr,vr=re-Mr;return lr?nativeMin(vr,nr-$r):vr}function pr(_r){var Mr=_r-ir,$r=_r-sr;return ir===void 0||Mr>=re||Mr<0||lr&&$r>=nr}function hr(){var _r=now();if(pr(_r))return yr(_r);ar=setTimeout(hr,mr(_r))}function yr(_r){return ar=void 0,ur&&ie?fr(_r):(ie=pe=void 0,or)}function gr(){ar!==void 0&&clearTimeout(ar),sr=0,ie=ir=pe=ar=void 0}function wr(){return ar===void 0?or:yr(now())}function br(){var _r=now(),Mr=pr(_r);if(ie=arguments,pe=this,ir=_r,Mr){if(ar===void 0)return dr(ir);if(lr)return clearTimeout(ar),ar=setTimeout(hr,re),fr(ir)}return ar===void 0&&(ar=setTimeout(hr,re)),or}return br.cancel=gr,br.flush=wr,br}var debounce_1=debounce$1;const debounce$2=getDefaultExportFromCjs(debounce_1),human=vitePluginRequire_1721693194810_68601018;async function onSubmitCounterparty({data:W,mercoaSession:re,type:oe,setError:ie,onSelect:pe}){var ar,ir,sr,cr,lr;if(!((ar=re.entity)!=null&&ar.id))return;const nr={};if(W.accountType==="individual"){if(nr.individual={email:W.email,name:{firstName:W.firstName??"",lastName:W.lastName??"",middleName:W.middleName??"",suffix:W.suffix??""}},!nr.individual.name.firstName){ie("vendor.firstName",{type:"manual",message:"First Name is required"});return}if(!nr.individual.name.lastName){ie("vendor.lastName",{type:"manual",message:"Last Name is required"});return}}else{if(nr.business={email:W.email,description:W.description,website:W.website,legalBusinessName:W.name},!nr.business.legalBusinessName){ie("vendor.name",{type:"manual",message:"Name is required"});return}if(!nr.business.website&&!nr.business.description){ie("vendor.website",{type:"manual",message:"Website or description is required"}),ie("vendor.description",{type:"manual",message:"Website or description is required"});return}}let or;W!=null&&W.id&&W.id!=="new"?or=await((ir=re.client)==null?void 0:ir.entity.update(W.id,{profile:nr,accountType:W.accountType})):or=await((sr=re.client)==null?void 0:sr.entity.create({profile:nr,accountType:W.accountType,isPayee:oe==="payee",isPayor:oe==="payor",isCustomer:!1})),or!=null&&or.id&&(oe==="payee"?await((cr=re.client)==null?void 0:cr.entity.counterparty.addPayees(re.entity.id,{payees:[or.id]})):await((lr=re.client)==null?void 0:lr.entity.counterparty.addPayors(re.entity.id,{payors:[or.id]})),pe&&pe(or))}const counterpartyYupValidation={id:create$6().nullable(),name:create$6().typeError("Please enter a name"),email:create$6().email("Please enter a valid email"),accountType:create$6(),firstName:create$6(),lastName:create$6(),middleName:create$6(),suffix:create$6(),website:create$6().url("Website must be a valid URL").transform(W=>W&&!W.startsWith("http://")&&!W.startsWith("https://")?`http://${W}`:W),description:create$6(),accounts:create$2().of(create$3().shape({accountId:create$6(),postalCode:create$6().nullable(),nameOnAccount:create$6().nullable()}))};function CounterpartySearch({counterparty:W,disableCreation:re,onSelect:oe,type:ie,network:pe}){var ur,fr,dr,mr,pr,hr,yr,gr,wr,br,_r,Mr,$r,vr,Or,Sr,Cr,Ir,Dr,qr;const nr=useMercoaSession(),[or,ar]=React.useState(!1),ir=useForm({resolver:o(create$3({vendor:create$3().shape(counterpartyYupValidation)}).required()),defaultValues:{vendor:{id:W==null?void 0:W.id,accountType:W==null?void 0:W.accountType,name:W==null?void 0:W.name,firstName:(dr=(fr=(ur=W==null?void 0:W.profile)==null?void 0:ur.individual)==null?void 0:fr.name)==null?void 0:dr.firstName,lastName:(hr=(pr=(mr=W==null?void 0:W.profile)==null?void 0:mr.individual)==null?void 0:pr.name)==null?void 0:hr.lastName,middleName:(wr=(gr=(yr=W==null?void 0:W.profile)==null?void 0:yr.individual)==null?void 0:gr.name)==null?void 0:wr.middleName,suffix:(Mr=(_r=(br=W==null?void 0:W.profile)==null?void 0:br.individual)==null?void 0:_r.name)==null?void 0:Mr.suffix,email:(W==null?void 0:W.accountType)==="business"?(vr=($r=W==null?void 0:W.profile)==null?void 0:$r.business)==null?void 0:vr.email:(Sr=(Or=W==null?void 0:W.profile)==null?void 0:Or.individual)==null?void 0:Sr.email,website:(Ir=(Cr=W==null?void 0:W.profile)==null?void 0:Cr.business)==null?void 0:Ir.website,description:(qr=(Dr=W==null?void 0:W.profile)==null?void 0:Dr.business)==null?void 0:qr.description}}}),{handleSubmit:sr,setError:cr}=ir,lr=async Zr=>{var en;if(!((en=nr.entity)!=null&&en.id))return;const Yr=Zr.vendor;await onSubmitCounterparty({data:Yr,mercoaSession:nr,type:ie,setError:cr,onSelect:Jr=>{oe==null||oe(Jr),ar(!1)}})};return jsxRuntimeExports.jsx(FormProvider,{...ir,children:jsxRuntimeExports.jsx("form",{onSubmit:sr(lr),className:"mercoa-p-3 mercoa-bg-gray-100 mercoa-rounded-mercoa mercoa-relative mercoa-w-full",children:jsxRuntimeExports.jsx(CounterpartySearchBase,{counterparty:W,disableCreation:re,onSelect:oe,type:ie,network:pe,edit:or,setEdit:ar})})})}function PayableCounterpartySearch({counterparty:W,disableCreation:re,onSelect:oe,network:ie}){var sr,cr;const[pe,nr]=React.useState(!1),{formState:{errors:or}}=useFormContext();React.useEffect(()=>{nr(!1)},[W]);const{watch:ar}=useFormContext(),ir=ar("status");return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"sm:mercoa-col-span-3",children:[jsxRuntimeExports.jsx("label",{htmlFor:"vendor-name",className:"mercoa-block mercoa-text-lg mercoa-font-medium mercoa-leading-6 mercoa-text-gray-700",children:"Vendor"}),jsxRuntimeExports.jsx("div",{className:"mercoa-mt-2 mercoa-flex mercoa-items-center mercoa-justify-left",children:jsxRuntimeExports.jsx("div",{className:"mercoa-p-3 mercoa-bg-gray-100 mercoa-rounded-mercoa mercoa-relative mercoa-w-full",children:jsxRuntimeExports.jsx(CounterpartySearchBase,{counterparty:W,disableCreation:re,onSelect:oe,type:"payee",network:ie,edit:pe,setEdit:nr,readOnly:!!ir&&ir!==javascript.Mercoa.InvoiceStatus.Draft})})}),((sr=or.vendorId)==null?void 0:sr.message)&&jsxRuntimeExports.jsx("p",{className:"mercoa-text-sm mercoa-text-red-500",children:(cr=or.vendorId)==null?void 0:cr.message.toString()})]})})}function AddCounterpartyModal({type:W,show:re,setShow:oe}){const ie=useMercoaSession(),pe=useForm({resolver:o(create$3({vendor:create$3().shape(counterpartyYupValidation)}).required()),defaultValues:{vendor:{id:"",accountType:"business",name:"",firstName:"",lastName:"",middleName:"",suffix:"",email:"",website:"",description:""}}}),{handleSubmit:nr,setError:or}=pe,ar=async ir=>{var cr;if(!((cr=ie.entity)!=null&&cr.id))return;const sr=ir.vendor;await onSubmitCounterparty({data:sr,mercoaSession:ie,type:W,setError:or,onSelect:lr=>{oe(!1),ie.refresh()}})};return ie.client?jsxRuntimeExports.jsx(qe$1.Root,{show:re,as:React.Fragment,children:jsxRuntimeExports.jsxs(_t$1,{as:"div",className:"mercoa-relative mercoa-z-10",onClose:()=>{ie.refresh(),oe(!1)},children:[jsxRuntimeExports.jsx(qe$1.Child,{as:React.Fragment,enter:"mercoa-ease-out mercoa-duration-300",enterFrom:"mercoa-opacity-0",enterTo:"mercoa-opacity-100",leave:"mercoa-ease-in mercoa-duration-200",leaveFrom:"mercoa-opacity-100",leaveTo:"mercoa-opacity-0",children:jsxRuntimeExports.jsx("div",{className:"mercoa-fixed mercoa-inset-0 mercoa-bg-gray-500 mercoa-bg-mercoa-opacity-75 mercoa-transition-opacity"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-fixed mercoa-inset-0 mercoa-z-10 mercoa-overflow-y-auto",children:jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-min-h-full mercoa-items-end mercoa-justify-center mercoa-p-4 mercoa-text-center sm:mercoa-items-center sm:mercoa-p-0",children:jsxRuntimeExports.jsx(qe$1.Child,{as:React.Fragment,enter:"mercoa-ease-out mercoa-duration-300",enterFrom:"mercoa-opacity-0 mercoa-translate-y-4 sm:mercoa-translate-y-0 sm:mercoa-scale-95",enterTo:"mercoa-opacity-100 mercoa-translate-y-0 sm:mercoa-scale-100",leave:"mercoa-ease-in mercoa-duration-200",leaveFrom:"mercoa-opacity-100 mercoa-translate-y-0 sm:mercoa-scale-100",leaveTo:"mercoa-opacity-0 mercoa-translate-y-4 sm:mercoa-translate-y-0 sm:mercoa-scale-95",children:jsxRuntimeExports.jsx(_t$1.Panel,{className:"mercoa-relative mercoa-transform mercoa-rounded-mercoa mercoa-bg-white mercoa-text-left mercoa-shadow-xl mercoa-transition-all",children:jsxRuntimeExports.jsx("div",{className:"mercoa-w-[600px]",children:jsxRuntimeExports.jsx(FormProvider,{...pe,children:jsxRuntimeExports.jsx("form",{onSubmit:nr(ar),className:"mercoa-p-3 mercoa-bg-gray-100 mercoa-rounded-mercoa mercoa-relative mercoa-w-full",children:jsxRuntimeExports.jsx(CounterpartyAddOrEditForm,{onComplete:()=>{oe(!1),ie.refresh()},onExit:()=>{oe(!1)}})})})})})})})})]})}):jsxRuntimeExports.jsx(NoSession,{componentName:"AddCounterpartyModal"})}function CounterpartySearchBase({counterparty:W,disableCreation:re,onSelect:oe,type:ie,network:pe,edit:nr,setEdit:or,readOnly:ar}){var _r,Mr,$r,vr,Or,Sr,Cr;const ir=useMercoaSession(),sr=React.useRef(null),[cr,lr]=React.useState(""),[ur,fr]=React.useState(),[dr,mr]=React.useState(),[pr,hr]=React.useState(),[yr,gr]=React.useState(),wr=React.useRef(debounce$2(fr,200)).current;React.useEffect(()=>{wr(yr)},[yr]),React.useEffect(()=>{W&&hr(W)},[W]),React.useEffect(()=>{var Dr,qr,Zr,Yr,en,Jr,kr,on,Xr,Br,xr;if(!((Dr=ir.entity)!=null&&Dr.id))return;let Ir=[javascript.Mercoa.CounterpartyNetworkType.Entity];(((Yr=(Zr=(qr=ir.iframeOptions)==null?void 0:qr.options)==null?void 0:Zr.vendors)==null?void 0:Yr.network)==="platform"||((kr=(Jr=(en=ir.iframeOptions)==null?void 0:en.options)==null?void 0:Jr.vendors)==null?void 0:kr.network)==="all")&&Ir.push(javascript.Mercoa.CounterpartyNetworkType.Network),pe&&(Ir=[...pe]),ie==="payee"?(Xr=ir.client)==null||Xr.entity.counterparty.findPayees((on=ir.entity)==null?void 0:on.id,{paymentMethods:!0,networkType:Ir,name:ur}).then(Rr=>{mr(Rr.data)}):(xr=ir.client)==null||xr.entity.counterparty.findPayors((Br=ir.entity)==null?void 0:Br.id,{paymentMethods:!0,networkType:Ir,name:ur}).then(Rr=>{mr(Rr.data)})},[(_r=ir.entity)==null?void 0:_r.id,ir.token,ir.refreshId,ur]);function br(Ir){hr(Ir),oe==null||oe(Ir),Ir&&or(!1)}if(pr!=null&&pr.id&&(pr==null?void 0:pr.id)!=="new"&&!nr)return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{className:"mercoa-w-full mercoa-flex mercoa-items-center",children:jsxRuntimeExports.jsx("div",{className:"mercoa-flex-auto",children:jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-items-center mercoa-bg-gray-50 mercoa-rounded-mercoa",children:[jsxRuntimeExports.jsxs("div",{className:"mercoa-flex-auto mercoa-p-3",children:[jsxRuntimeExports.jsx("div",{className:"mercoa-text-sm mercoa-font-medium mercoa-text-gray-900",children:pr==null?void 0:pr.name}),!((vr=($r=(Mr=ir.iframeOptions)==null?void 0:Mr.options)==null?void 0:$r.vendors)!=null&&vr.disableCreation)&&!re&&jsxRuntimeExports.jsx("div",{className:"mercoa-text-sm mercoa-text-gray-500",children:pr==null?void 0:pr.email})]}),!ar&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("button",{onClick:()=>{br(void 0)},type:"button",className:"mercoa-ml-4 mercoa-flex-shrink-0 mercoa-p-1 mercoa-text-mercoa-primary-text hover:mercoa-opacity-75",children:[jsxRuntimeExports.jsx(ForwardRef$2,{className:"mercoa-size-5 mercoa-text-gray-400","aria-hidden":"true"}),jsxRuntimeExports.jsx("span",{className:"mercoa-sr-only",children:"Clear"})]}),!((Cr=(Sr=(Or=ir.iframeOptions)==null?void 0:Or.options)==null?void 0:Sr.vendors)!=null&&Cr.disableCreation)&&!re&&jsxRuntimeExports.jsxs("button",{onClick:()=>{or(!0)},type:"button",className:"mercoa-ml-4 mercoa-flex-shrink-0 mercoa-p-1 mercoa-text-mercoa-primary-text hover:mercoa-opacity-75",children:[jsxRuntimeExports.jsx(ForwardRef$g,{className:"mercoa-size-5 mercoa-text-gray-400","aria-hidden":"true"}),jsxRuntimeExports.jsx("span",{className:"mercoa-sr-only",children:"Edit"})]})]})]})})})});if((pr==null?void 0:pr.id)==="new"){if(cr)return jsxRuntimeExports.jsx(CounterpartyAddOrEditForm,{name:cr,onComplete:Ir=>{br(Ir),setTimeout(()=>or(!0),100)},onExit:oe});if(pr)return jsxRuntimeExports.jsx(CounterpartyAddOrEditForm,{counterparty:pr,onComplete:br,onExit:oe})}else if(pr!=null&&pr.id&&nr)return jsxRuntimeExports.jsx(CounterpartyAddOrEditForm,{counterparty:pr,onComplete:br,onExit:oe});return dr?(ir.debug({selectedCounterparty:pr}),ir.client?jsxRuntimeExports.jsx(qt$1,{as:"div",value:pr,onChange:br,nullable:!0,className:"mercoa-w-full",children:({open:Ir})=>{var Dr,qr,Zr;return jsxRuntimeExports.jsxs("div",{className:"mercoa-relative mercoa-mt-2 mercoa-w-full",children:[jsxRuntimeExports.jsx(qt$1.Input,{placeholder:"Enter a company name...",autoComplete:"off",className:"mercoa-w-full mercoa-rounded-mercoa mercoa-border-0 mercoa-bg-white mercoa-py-1.5 mercoa-pl-3 mercoa-pr-10 mercoa-text-gray-900 mercoa-shadow-sm mercoa-ring-1 mercoa-ring-inset mercoa-ring-gray-300 focus:mercoa-ring-2 focus:mercoa-ring-inset focus:mercoa-ring-mercoa-primary sm:mercoa-text-sm sm:mercoa-leading-6",onFocus:()=>{var Yr;Ir||(gr(void 0),(Yr=sr.current)==null||Yr.click())},onChange:Yr=>{var en;lr(Yr.target.value),gr(((en=Yr.target.value)==null?void 0:en.toLowerCase())??"")},displayValue:Yr=>(Yr==null?void 0:Yr.name)??""}),jsxRuntimeExports.jsx(qt$1.Button,{className:"mercoa-absolute mercoa-inset-y-0 mercoa-right-0 mercoa-flex mercoa-items-center mercoa-rounded-r-md mercoa-px-2 focus:mercoa-outline-none",ref:sr,children:jsxRuntimeExports.jsx(ForwardRef$D,{className:"mercoa-size-5 mercoa-text-gray-400","aria-hidden":"true"})}),jsxRuntimeExports.jsxs(qt$1.Options,{className:"mercoa-absolute mercoa-z-10 mercoa-mt-1 mercoa-max-h-60 mercoa-w-full mercoa-overflow-auto mercoa-rounded-mercoa mercoa-bg-white mercoa-py-1 mercoa-text-base mercoa-shadow-lg mercoa-ring-1 mercoa-ring-black mercoa-ring-opacity-5 focus:mercoa-outline-none sm:mercoa-text-sm",children:[dr.map(Yr=>jsxRuntimeExports.jsx(qt$1.Option,{value:Yr,className:({active:en})=>`mercoa-relative mercoa-cursor-pointer mercoa-py-2 mercoa-pl-3 mercoa-pr-9 ${en?"mercoa-bg-mercoa-primary mercoa-text-mercoa-primary-text-invert":"mercoa-text-gray-900"}`,children:jsxRuntimeExports.jsx("span",{children:Yr.name})},Yr.id)),!((Zr=(qr=(Dr=ir.iframeOptions)==null?void 0:Dr.options)==null?void 0:qr.vendors)!=null&&Zr.disableCreation)&&!re&&jsxRuntimeExports.jsx(qt$1.Option,{value:{id:"new"},children:({active:Yr})=>jsxRuntimeExports.jsxs("div",{className:`mercoa-flex mercoa-items-center mercoa-cursor-pointer mercoa-py-2 mercoa-pl-3 mercoa-pr-9 ${Yr?"mercoa-bg-mercoa-primary mercoa-text-mercoa-primary-text-invert":"mercoa-text-gray-900"}`,children:[jsxRuntimeExports.jsx(ForwardRef$d,{className:"mercoa-size-5 mercoa-pr-1"}),"Add New"]})})]})]})}}):jsxRuntimeExports.jsx(NoSession,{componentName:"CounterpartySearch"})):jsxRuntimeExports.jsxs("div",{className:"mercoa-relative mercoa-mt-2",children:[jsxRuntimeExports.jsx("input",{className:inputClassName({}),placeholder:"Loading...",value:"Loading...",readOnly:!0}),jsxRuntimeExports.jsx("button",{className:"mercoa-absolute mercoa-inset-y-0 mercoa-right-0 mercoa-flex mercoa-items-center mercoa-rounded-r-md mercoa-px-2 focus:mercoa-outline-none",children:jsxRuntimeExports.jsx(ForwardRef$D,{className:"mercoa-size-5 mercoa-text-gray-400","aria-hidden":"true"})})]})}function CounterpartyAddOrEditForm({counterparty:W,name:re,onComplete:oe,onExit:ie}){var lr,ur,fr;const{register:pe,watch:nr,setValue:or,formState:{errors:ar}}=useFormContext();let ir=re;!ir&&(W==null?void 0:W.accountType)==="business"?ir=(ur=(lr=W==null?void 0:W.profile)==null?void 0:lr.business)==null?void 0:ur.legalBusinessName:!ir&&(W==null?void 0:W.accountType)==="individual"&&((fr=W==null?void 0:W.profile)!=null&&fr.individual)&&(ir=`${constructFullName(W.profile.individual.name.firstName,W.profile.individual.name.lastName,W.profile.individual.name.middleName,W.profile.individual.name.suffix)}`),React.useEffect(()=>{var dr,mr,pr,hr,yr,gr,wr,br,_r,Mr,$r,vr,Or,Sr,Cr,Ir,Dr,qr,Zr,Yr;or("vendor.id",W==null?void 0:W.id),or("vendor.accountType",W==null?void 0:W.accountType),or("vendor.name",ir),or("vendor.firstName",(pr=(mr=(dr=W==null?void 0:W.profile)==null?void 0:dr.individual)==null?void 0:mr.name)==null?void 0:pr.firstName),or("vendor.lastName",(gr=(yr=(hr=W==null?void 0:W.profile)==null?void 0:hr.individual)==null?void 0:yr.name)==null?void 0:gr.lastName),or("vendor.middleName",(_r=(br=(wr=W==null?void 0:W.profile)==null?void 0:wr.individual)==null?void 0:br.name)==null?void 0:_r.middleName),or("vendor.suffix",(vr=($r=(Mr=W==null?void 0:W.profile)==null?void 0:Mr.individual)==null?void 0:$r.name)==null?void 0:vr.suffix),or("vendor.email",(W==null?void 0:W.accountType)==="business"?(Sr=(Or=W==null?void 0:W.profile)==null?void 0:Or.business)==null?void 0:Sr.email:(Ir=(Cr=W==null?void 0:W.profile)==null?void 0:Cr.individual)==null?void 0:Ir.email),or("vendor.website",(qr=(Dr=W==null?void 0:W.profile)==null?void 0:Dr.business)==null?void 0:qr.website),or("vendor.description",(Yr=(Zr=W==null?void 0:W.profile)==null?void 0:Zr.business)==null?void 0:Yr.description)},[W]);const sr=nr("vendor.accountType"),cr=nr("vendor.name");return React.useEffect(()=>{if(!(!cr&&!sr))if(sr==="business")or("vendor.firstName","business"),or("vendor.lastName","business");else{const{firstName:dr,suffix:mr,lastName:pr,middleName:hr}=human.parseName(cr);or("vendor.firstName",dr),or("vendor.lastName",pr),or("vendor.middleName",hr),or("vendor.suffix",mr)}},[cr,sr]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("button",{type:"button",className:"mercoa-absolute mercoa-top-2 mercoa-right-2",onClick:()=>{oe(void 0),(W==null?void 0:W.id)==="new"&&ie&&ie({id:""})},children:[jsxRuntimeExports.jsx(ForwardRef$1,{className:"mercoa-size-5 mercoa-text-gray-400","aria-hidden":"true"}),jsxRuntimeExports.jsx("span",{className:"mercoa-sr-only",children:"Close"})]}),jsxRuntimeExports.jsx(MercoaInput,{label:"Name",name:"vendor.name",register:pe,placeholder:"Name",errors:ar,leadingIcon:jsxRuntimeExports.jsx(ForwardRef$4,{className:"mercoa-size-5 mercoa-text-gray-400","aria-hidden":"true"}),className:"mercoa-mt-1"}),jsxRuntimeExports.jsx(MercoaInput,{label:"Email",name:"vendor.email",register:pe,placeholder:"Email",errors:ar,leadingIcon:jsxRuntimeExports.jsx(ForwardRef$v,{className:"mercoa-size-5 mercoa-text-gray-400","aria-hidden":"true"}),className:"mercoa-mt-1"}),jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-1 mercoa-mt-2 mercoa-flex mercoa-space-x-2",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>or("vendor.accountType","individual"),className:`mercoa-flex-grow mercoa-rounded-mercoa mercoa-border mercoa-border-gray-300 mercoa-text-center mercoa-text-gray-600
46
46
  ${sr==="individual"?"mercoa-border-mercoa-primary mercoa-text-gray-800":""}
47
47
  ${sr==="business"?"mercoa-text-gray-300":""}
48
48
  mercoa-cursor-pointer mercoa-bg-white mercoa-px-6 mercoa-py-5 mercoa-shadow-sm hover:mercoa-border-mercoa-primary hover:mercoa-text-gray-800`,children:"Individual"}),jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>or("vendor.accountType","business"),className:`mercoa-flex-grow mercoa-rounded-mercoa mercoa-border mercoa-border-gray-300 mercoa-text-center mercoa-text-gray-600
@@ -65,7 +65,7 @@ attempted value: ${or}
65
65
  Prefix can't start with '-' when allowNegative is true.
66
66
  prefix: `+pe+`
67
67
  allowNegative: `+nr+`
68
- `),nr=!1),Object.assign(Object.assign({},W),{allowNegative:nr})}function useNumericFormat(W){W=validateAndUpdateProps(W),W.decimalSeparator,W.allowedDecimalSeparators,W.thousandsGroupStyle;var re=W.suffix,oe=W.allowNegative,ie=W.allowLeadingZeros,pe=W.onKeyDown;pe===void 0&&(pe=noop$1);var nr=W.onBlur;nr===void 0&&(nr=noop$1);var or=W.thousandSeparator,ar=W.decimalScale,ir=W.fixedDecimalScale,sr=W.prefix;sr===void 0&&(sr="");var cr=W.defaultValue,lr=W.value,ur=W.valueIsNumericString,fr=W.onValueChange,dr=__rest$2(W,["decimalSeparator","allowedDecimalSeparators","thousandsGroupStyle","suffix","allowNegative","allowLeadingZeros","onKeyDown","onBlur","thousandSeparator","decimalScale","fixedDecimalScale","prefix","defaultValue","value","valueIsNumericString","onValueChange"]),mr=getSeparators(W),pr=mr.decimalSeparator,hr=mr.allowedDecimalSeparators,yr=function(Zr){return format$1(Zr,W)},gr=function(Zr,Yr){return removeFormatting(Zr,Yr,W)},wr=isNil(lr)?cr:lr,br=ur??isNumericString(wr,sr,re);isNil(lr)?isNil(cr)||(br=br||typeof cr=="number"):br=br||typeof lr=="number";var _r=function(Zr){return isNotValidValue(Zr)?Zr:(typeof Zr=="number"&&(Zr=toNumericString(Zr)),br&&typeof ar=="number"?roundToPrecision(Zr,ar,!!ir):Zr)},Mr=useInternalValues(_r(lr),_r(cr),!!br,yr,gr,fr),$r=Mr[0],vr=$r.numAsString,Or=$r.formattedValue,Sr=Mr[1],Cr=function(Zr){var Yr=Zr.target,en=Zr.key,Jr=Yr.selectionStart,kr=Yr.selectionEnd,on=Yr.value;if(on===void 0&&(on=""),Jr!==kr){pe(Zr);return}en==="Backspace"&&on[0]==="-"&&Jr===sr.length+1&&oe&&setCaretPosition(Yr,1),ar&&ir&&(en==="Backspace"&&on[Jr-1]===pr?(setCaretPosition(Yr,Jr-1),Zr.preventDefault()):en==="Delete"&&on[Jr]===pr&&Zr.preventDefault()),hr!=null&&hr.includes(en)&&on[Jr]===pr&&setCaretPosition(Yr,Jr+1);var Xr=or===!0?",":or;en==="Backspace"&&on[Jr-1]===Xr&&setCaretPosition(Yr,Jr-1),en==="Delete"&&on[Jr]===Xr&&setCaretPosition(Yr,Jr+1),pe(Zr)},Ir=function(Zr){var Yr=vr;if(Yr.match(/\d/g)||(Yr=""),ie||(Yr=fixLeadingZero(Yr)),ir&&ar&&(Yr=roundToPrecision(Yr,ar,ir)),Yr!==vr){var en=format$1(Yr,W);Sr({formattedValue:en,value:Yr,floatValue:parseFloat(Yr)},{event:Zr,source:SourceType.event})}nr(Zr)},Dr=function(Zr){return Zr===pr?!0:charIsNumber(Zr)},qr=function(Zr){var Yr=Zr.currentValue,en=Zr.lastValue,Jr=Zr.formattedValue,kr=Zr.currentValueIndex,on=Zr.formattedValueIndex,Xr=Yr[kr],Br=Jr[on],xr=findChangeRange(en,Yr),Rr=xr.to;return kr>=Rr.start&&kr<Rr.end&&hr&&hr.includes(Xr)&&Br===pr?!0:Xr===Br};return Object.assign(Object.assign({},dr),{value:Or,valueIsNumericString:!1,isValidInputCharacter:Dr,isCharacterSame:qr,onValueChange:Sr,format:yr,removeFormatting:gr,getCaretBoundary:function(Zr){return getCaretBoundary(Zr,W)},onKeyDown:Cr,onBlur:Ir})}function NumericFormat(W){var re=useNumericFormat(W);return React.createElement(NumberFormatBase,Object.assign({},re))}function format$1$1(W,re){var oe=re.format,ie=re.allowEmptyFormatting,pe=re.mask,nr=re.patternChar;if(nr===void 0&&(nr="#"),W===""&&!ie)return"";for(var or=0,ar=oe.split(""),ir=0,sr=oe.length;ir<sr;ir++)oe[ir]===nr&&(ar[ir]=W[or]||getMaskAtIndex(pe,or),or+=1);return ar.join("")}function removeFormatting$1(W,re,oe){re===void 0&&(re=getDefaultChangeMeta(W));var ie=oe.format,pe=oe.patternChar;pe===void 0&&(pe="#");var nr=re.from,or=re.to,ar=re.lastValue;ar===void 0&&(ar="");var ir=function(pr){return ie[pr]===pe},sr=function(pr,hr){for(var yr="",gr=0;gr<pr.length;gr++)ir(hr+gr)&&charIsNumber(pr[gr])&&(yr+=pr[gr]);return yr},cr=function(pr){return pr.replace(/[^0-9]/g,"")};if(!ie.match(/\d/))return cr(W);if(ar===""&&W.length===ie.length){for(var lr="",ur=0;ur<W.length;ur++)if(ir(ur))charIsNumber(W[ur])&&(lr+=W[ur]);else if(W[ur]!==ie[ur])return cr(W);return lr}var fr=ar.substring(0,nr.start),dr=W.substring(or.start,or.end),mr=ar.substring(nr.end);return""+sr(fr,0)+cr(dr)+sr(mr,nr.end)}function getCaretBoundary$1(W,re){var oe=re.format,ie=re.mask,pe=re.patternChar;pe===void 0&&(pe="#");var nr=Array.from({length:W.length+1}).map(function(){return!0}),or=0,ar=-1,ir={};oe.split("").forEach(function(ur,fr){var dr=void 0;ur===pe&&(or++,dr=getMaskAtIndex(ie,or-1),ar===-1&&W[fr]===dr&&(ar=fr)),ir[fr]=dr});for(var sr=function(ur){return oe[ur]===pe&&W[ur]!==ir[ur]},cr=0,lr=nr.length;cr<lr;cr++)nr[cr]=cr===ar||sr(cr)||sr(cr-1);return nr[oe.indexOf(pe)]=!0,nr}function validateProps(W){var re=W.mask;if(re){var oe=re==="string"?re:re.toString();if(oe.match(/\d/g))throw new Error("Mask "+re+" should not contain numeric character;")}}function isNumericString$1(W,re){return W===""?!0:!(re!=null&&re.match(/\d/))&&typeof W=="string"&&(!!W.match(/^\d+$/)||W==="")}function usePatternFormat(W){W.mask,W.allowEmptyFormatting;var re=W.format,oe=W.inputMode;oe===void 0&&(oe="numeric");var ie=W.onKeyDown;ie===void 0&&(ie=noop$1);var pe=W.patternChar;pe===void 0&&(pe="#");var nr=W.value,or=W.defaultValue,ar=W.valueIsNumericString,ir=__rest$2(W,["mask","allowEmptyFormatting","format","inputMode","onKeyDown","patternChar","value","defaultValue","valueIsNumericString"]);validateProps(W);var sr=function(dr){return getCaretBoundary$1(dr,W)},cr=function(dr){var mr=dr.key,pr=dr.target,hr=pr.selectionStart,yr=pr.selectionEnd,gr=pr.value;if(hr!==yr){ie(dr);return}var wr=hr;if(mr==="Backspace"||mr==="Delete"){var br="right";if(mr==="Backspace"){for(;wr>0&&re[wr-1]!==pe;)wr--;br="left"}else{for(var _r=re.length;wr<_r&&re[wr]!==pe;)wr++;br="right"}wr=getCaretPosInBoundary(gr,wr,sr(gr),br)}else re[wr]!==pe&&mr!=="ArrowLeft"&&mr!=="ArrowRight"&&(wr=getCaretPosInBoundary(gr,wr+1,sr(gr),"right"));wr!==hr&&setCaretPosition(pr,wr),ie(dr)},lr=isNil(nr)?or:nr,ur=ar??isNumericString$1(lr,re),fr=Object.assign(Object.assign({},W),{valueIsNumericString:ur});return Object.assign(Object.assign({},ir),{value:nr,defaultValue:or,valueIsNumericString:ur,inputMode:oe,format:function(dr){return format$1$1(dr,fr)},removeFormatting:function(dr,mr){return removeFormatting$1(dr,mr,fr)},getCaretBoundary:sr,onKeyDown:cr})}function PatternFormat(W){var re=usePatternFormat(W);return React.createElement(NumberFormatBase,Object.assign({},re))}const mccCodes=[{code:"7623",name:"AC, Refrigeration Repair - 7623"},{code:"8931",name:"Accounting, Bookkeeping - 8931"},{code:"7311",name:"Advertising Services - 7311"},{code:"0763",name:"Agricultural Cooperative - 0763"},{code:"4511",name:"Airlines, Air Carriers - 4511"},{code:"4582",name:"Airports, Flying Fields - 4582"},{code:"4119",name:"Ambulance Services - 4119"},{code:"7996",name:"Amusement Parks, Carnivals - 7996"},{code:"5937",name:"Antique Reproductions - 5937"},{code:"5932",name:"Antiques - 5932"},{code:"7998",name:"Aquariums - 7998"},{code:"8911",name:"Architectural, Surveying - 8911"},{code:"5971",name:"Art Dealers, Galleries - 5971"},{code:"5970",name:"Artists Supply, Crafts - 5970"},{code:"5531",name:"Auto and Home Supplies - 5531"},{code:"7531",name:"Auto Body Repair - 7531"},{code:"7535",name:"Auto Paint - 7535"},{code:"7538",name:"Auto Service - 7538"},{code:"6011",name:"Automated Cash Disburse - 6011"},{code:"5542",name:"Automated Fuel Dispensers - 5542"},{code:"8675",name:"Automobile Associations - 8675"},{code:"5511",name:"Automobile Dealers (New &amp; Used) - 5511"},{code:"5521",name:"Automobile Dealers (Used Only) - 5521"},{code:"5533",name:"Automotive Parts, Accessories - 5533"},{code:"5532",name:"Automotive Tire - 5532"},{code:"9223",name:"Bail, Bond Payments - 9223"},{code:"5462",name:"Bakeries - 5462"},{code:"7929",name:"Bands, Orchestras - 7929"},{code:"7230",name:"Barber, Beauty - 7230"},{code:"7995",name:"Betting, Casino Gambling - 7995"},{code:"5940",name:"Bicycle - 5940"},{code:"7932",name:"Billiard, Pool Establishments - 7932"},{code:"5551",name:"Boat Dealers - 5551"},{code:"4457",name:"Boat Rentals, Leases - 4457"},{code:"5942",name:"Books - 5942"},{code:"5192",name:"Books, Periodicals, Newspapers - 5192"},{code:"7933",name:"Bowling Alleys - 7933"},{code:"4131",name:"Bus Lines - 4131"},{code:"8244",name:"Business, Secretarial Schools - 8244"},{code:"7278",name:"Buying, Shopping Services - 7278"},{code:"4899",name:"Cable, Satellite, Pay Television and Radio - 4899"},{code:"5946",name:"Camera, Photographic Supply - 5946"},{code:"5441",name:"Candy, Nut, Confectionery - 5441"},{code:"7512",name:"Car Rental Agencies - 7512"},{code:"7542",name:"Car Washes - 7542"},{code:"1750",name:"Carpentry Contractors - 1750"},{code:"7217",name:"Carpet, Upholstery Cleaning - 7217"},{code:"5811",name:"Caterers - 5811"},{code:"8398",name:"Charitable, Social Service Organizations - 8398"},{code:"5169",name:"Chemical Products - 5169"},{code:"8351",name:"Child Care Services - 8351"},{code:"5641",name:"Childrens, Infants Wear - 5641"},{code:"8049",name:"Chiropodists, Podiatrists - 8049"},{code:"8041",name:"Chiropractors - 8041"},{code:"5993",name:"Cigars - 5993"},{code:"8641",name:"Civic, Social, Fraternal Associations - 8641"},{code:"7349",name:"Cleaning, Maintenance - 7349"},{code:"7296",name:"Clothing Rental - 7296"},{code:"8220",name:"Colleges, Universities - 8220"},{code:"5046",name:"Commercial Equipment - 5046"},{code:"5139",name:"Commercial Footwear - 5139"},{code:"7333",name:"Commercial Photography, Art, Graphics - 7333"},{code:"4111",name:"Commuter Transport, Ferries - 4111"},{code:"4816",name:"Computer Networks - 4816"},{code:"7372",name:"Computer Programming - 7372"},{code:"7379",name:"Computer Repair - 7379"},{code:"5734",name:"Computer Software - 5734"},{code:"5045",name:"Computers, Peripherals, Software - 5045"},{code:"1771",name:"Concrete Work - 1771"},{code:"5039",name:"Construction Materials - 5039"},{code:"7392",name:"Consulting, Public Relations - 7392"},{code:"5499",name:"Convenience Stores, Specialty Markets - 5499"},{code:"8241",name:"Correspondence Schools - 8241"},{code:"5977",name:"Cosmetics - 5977"},{code:"7277",name:"Counseling Services - 7277"},{code:"4215",name:"Courier Services - 4215"},{code:"9211",name:"Court Costs, Alimony, Child Support - 9211"},{code:"7321",name:"Credit Reporting Agencies - 7321"},{code:"4411",name:"Cruise Lines - 4411"},{code:"5451",name:"Dairy Products - 5451"},{code:"7911",name:"Dance Hall, Studios, Schools - 7911"},{code:"7273",name:"Dating, Escort Services - 7273"},{code:"8021",name:"Dentists, Orthodontists - 8021"},{code:"5311",name:"Department Stores - 5311"},{code:"7393",name:"Detective Agencies - 7393"},{code:"5817",name:"Digital Goods - Applications - 5817"},{code:"5816",name:"Digital Goods – Games - 5816"},{code:"5818",name:"Digital Goods – Large Digital Goods Merchant - 5818"},{code:"5815",name:"Digital Goods Media – Books, Movies, Music - 5815"},{code:"5964",name:"Direct Marketing - Catalog Merchant - 5964"},{code:"5965",name:"Direct Marketing - Catalog, Retail - 5965"},{code:"5967",name:"Direct Marketing - Inbound Telemarketing - 5967"},{code:"5960",name:"Direct Marketing - Insurance Services - 5960"},{code:"5969",name:"Direct Marketing - Other - 5969"},{code:"5966",name:"Direct Marketing - Outbound Telemarketing - 5966"},{code:"5968",name:"Direct Marketing - Subscription - 5968"},{code:"5962",name:"Direct Marketing - Travel - 5962"},{code:"5310",name:"Discount Stores - 5310"},{code:"8011",name:"Doctors - 8011"},{code:"5963",name:"Door-To-Door Sales - 5963"},{code:"5714",name:"Drapery, Window Covering, Upholstery - 5714"},{code:"5813",name:"Drinking Places - 5813"},{code:"5912",name:"Drug Stores, Pharmacies - 5912"},{code:"5122",name:"Drugs, Drug Proprietaries - 5122"},{code:"7216",name:"Dry Cleaners - 7216"},{code:"5099",name:"Durable Goods - 5099"},{code:"5309",name:"Duty Free - 5309"},{code:"5812",name:"Eating Places, Restaurants - 5812"},{code:"8299",name:"Educational Services - 8299"},{code:"5997",name:"Electric Razor - 5997"},{code:"1731",name:"Electrical Contractors - 1731"},{code:"5065",name:"Electrical Parts - 5065"},{code:"5732",name:"Electronics - 5732"},{code:"7622",name:"Electronics Repair - 7622"},{code:"8211",name:"Elementary, Secondary Schools - 8211"},{code:"7361",name:"Employment, Temp Agencies - 7361"},{code:"7394",name:"Equipment Rental - 7394"},{code:"7342",name:"Exterminating Services - 7342"},{code:"5651",name:"Family Clothing - 5651"},{code:"5814",name:"Fast Food Restaurants - 5814"},{code:"6012",name:"Financial Institutions - 6012"},{code:"9222",name:"Fines - Government Administrative Entities - 9222"},{code:"5718",name:"Fireplace - 5718"},{code:"5713",name:"Floor Covering - 5713"},{code:"5992",name:"Florists - 5992"},{code:"5193",name:"Florists Supplies, Nursery Stock, Flowers - 5193"},{code:"5661",name:"Footwear - 5661"},{code:"5422",name:"Freezer, Locker Meat Provisioners - 5422"},{code:"4214",name:"Freight Carriers, Trucking - 4214"},{code:"5983",name:"Fuel Dealers - 5983"},{code:"7261",name:"Funeral Services, Crematories - 7261"},{code:"5712",name:"Furniture - 5712"},{code:"7641",name:"Furniture Repair, Refinishing - 7641"},{code:"5681",name:"Furriers, Fur - 5681"},{code:"1520",name:"General Contractors - 1520"},{code:"5947",name:"Gift, Card, Novelty, Souvenir Shops - 5947"},{code:"5231",name:"Glass, Paint, Wallpaper - 5231"},{code:"5950",name:"Glassware, Crystal - 5950"},{code:"9399",name:"Government Services - 9399"},{code:"5411",name:"Grocery Stores, Supermarkets - 5411"},{code:"5251",name:"Hardware - 5251"},{code:"5072",name:"Hardware, Equipment - 5072"},{code:"7298",name:"Health, Beauty Spas - 7298"},{code:"5975",name:"Hearing Aids - 5975"},{code:"1711",name:"Heating, Plumbing, AC - 1711"},{code:"5945",name:"Hobby, Toy, Games - 5945"},{code:"5200",name:"Home Supply Warehouse - 5200"},{code:"8062",name:"Hospitals - 8062"},{code:"7011",name:"Hotels, Motels, Resorts - 7011"},{code:"5722",name:"Household Appliance - 5722"},{code:"5085",name:"Industrial Supplies - 5085"},{code:"7375",name:"Information Retrieval Services - 7375"},{code:"6300",name:"Insurance Underwriting, Premiums - 6300"},{code:"5944",name:"Jewelry, Watches, Clocks, Silverware - 5944"},{code:"0780",name:"Landscaping Services - 0780"},{code:"7211",name:"Laundries - 7211"},{code:"7210",name:"Laundry, Cleaning Services - 7210"},{code:"8111",name:"Legal Services, Attorneys - 8111"},{code:"5948",name:"Luggage, Leather Goods - 5948"},{code:"5211",name:"Lumber, Building Materials - 5211"},{code:"6010",name:"Manual Cash Disburse - 6010"},{code:"4468",name:"Marinas - 4468"},{code:"1740",name:"Masonry, Stonework, Plaster - 1740"},{code:"7297",name:"Massage Parlors - 7297"},{code:"8099",name:"Medical Services - 8099"},{code:"8071",name:"Medical, Dental Labs - 8071"},{code:"5047",name:"Medical, Dental, Ophthalmic, Hospital Equipment - 5047"},{code:"7997",name:"Membership Clubs - 7997"},{code:"8699",name:"Membership Organizations - 8699"},{code:"5611",name:"Mens and Boys Clothing, Accessories - 5611"},{code:"5691",name:"Mens, Womens Clothing - 5691"},{code:"5051",name:"Metal Service Centers - 5051"},{code:"5699",name:"Miscellaneous Apparel, Accessories - 5699"},{code:"5599",name:"Miscellaneous Auto Dealers - 5599"},{code:"7399",name:"Miscellaneous Business Services - 7399"},{code:"5399",name:"Miscellaneous General Merchandise - 5399"},{code:"7299",name:"Miscellaneous General Services - 7299"},{code:"5719",name:"Miscellaneous Home Furnishing Specialty - 5719"},{code:"2741",name:"Miscellaneous Publishing, Printing - 2741"},{code:"7999",name:"Miscellaneous Recreation Services - 7999"},{code:"7699",name:"Miscellaneous Repair - 7699"},{code:"5999",name:"Miscellaneous Specialty Retail - 5999"},{code:"5271",name:"Mobile Home Dealers - 5271"},{code:"7832",name:"Motion Picture Theaters - 7832"},{code:"5592",name:"Motor Homes Dealers - 5592"},{code:"5013",name:"Motor Vehicle Supplies - 5013"},{code:"5561",name:"Motorcycle Dealers - 5561"},{code:"5733",name:"Musical Instruments, Pianos, Sheet Music - 5733"},{code:"5994",name:"News Dealers, Newsstands - 5994"},{code:"6051",name:"Non-FI, Money Orders - 6051"},{code:"6540",name:"Non-FI, Stored Value Card Purchase - 6540"},{code:"5199",name:"Nondurable Goods - 5199"},{code:"5261",name:"Nurseries, Lawn, Garden Supply - 5261"},{code:"8050",name:"Nursing, Personal Care - 8050"},{code:"5021",name:"Office, Commercial Furniture - 5021"},{code:"8043",name:"Opticians, Eyeglasses - 8043"},{code:"8042",name:"Optometrists, Ophthalmologist - 8042"},{code:"5976",name:"Orthopedic Goods, Prosthetic Devices - 5976"},{code:"8031",name:"Osteopaths - 8031"},{code:"5921",name:"Package - Beer, Wine, Liquor - 5921"},{code:"5198",name:"Paints, Varnishes - 5198"},{code:"7523",name:"Parking Lots, Garages - 7523"},{code:"4112",name:"Passenger Railways - 4112"},{code:"5933",name:"Pawn Shops - 5933"},{code:"5995",name:"Pet Supplies, Food - 5995"},{code:"5172",name:"Petroleum Products - 5172"},{code:"7395",name:"Photo Developing - 7395"},{code:"7221",name:"Photographic Studios - 7221"},{code:"5044",name:"Photographic, Photocopy, Microfilm Equipment - 5044"},{code:"5131",name:"Piece Goods, Other Dry Goods - 5131"},{code:"5074",name:"Plumbing, Heating Equipment - 5074"},{code:"8651",name:"Political Organizations - 8651"},{code:"9402",name:"Postal Services - 9402"},{code:"5094",name:"Precious Stones and Metals, Watches, Jewelry - 5094"},{code:"8999",name:"Professional Services - 8999"},{code:"7992",name:"Public Golf Courses - 7992"},{code:"4225",name:"Public Warehousing, Storage - 4225"},{code:"7338",name:"Quick Copy, Repro, Blueprint - 7338"},{code:"4011",name:"Railroads - 4011"},{code:"6513",name:"Real Estate Agents, Rentals - 6513"},{code:"5735",name:"Record Stores - 5735"},{code:"7519",name:"Recreational Vehicle Rentals - 7519"},{code:"5973",name:"Religious Goods - 5973"},{code:"8661",name:"Religious Organizations - 8661"},{code:"1761",name:"Roofing, Siding, Sheet Metal - 1761"},{code:"7339",name:"Secretarial Support Services - 7339"},{code:"6211",name:"Security Brokers, Dealers - 6211"},{code:"5541",name:"Service Stations - 5541"},{code:"5949",name:"Sewing, Needlework, Fabric, Piece Goods - 5949"},{code:"7251",name:"Shoe Repair, Hat Cleaning - 7251"},{code:"7629",name:"Small Appliance Repair - 7629"},{code:"5598",name:"Snowmobile Dealers - 5598"},{code:"1799",name:"Special Trade Contractors - 1799"},{code:"2842",name:"Specialty Cleaning - 2842"},{code:"5941",name:"Sporting Goods - 5941"},{code:"7032",name:"Sporting, Recreation Camps - 7032"},{code:"7941",name:"Sports Clubs, Fields - 7941"},{code:"5655",name:"Sports, Riding Apparel - 5655"},{code:"5972",name:"Stamps, Coins - 5972"},{code:"5111",name:"Stationary, Office Supplies, Printing, Writing Paper - 5111"},{code:"5943",name:"Stationery, Office, School Supplies - 5943"},{code:"5996",name:"Swimming Pools - 5996"},{code:"5697",name:"Tailors, Alterations - 5697"},{code:"9311",name:"Tax Payments - 9311"},{code:"7276",name:"Tax Preparation Services - 7276"},{code:"4121",name:"Taxicabs, Limousines - 4121"},{code:"4814",name:"Telecommunication - 4814"},{code:"4812",name:"Telecommunication Equipment - 4812"},{code:"4821",name:"Telegraph - 4821"},{code:"5998",name:"Tent, Awning - 5998"},{code:"8734",name:"Testing Laboratories - 8734"},{code:"7922",name:"Theatrical Ticket Agencies - 7922"},{code:"7012",name:"Timeshares - 7012"},{code:"7534",name:"Tire Retreading, Repair - 7534"},{code:"4784",name:"Tolls, Bridge Fees - 4784"},{code:"7991",name:"Tourist Attractions, Exhibits - 7991"},{code:"7549",name:"Towing Services - 7549"},{code:"7033",name:"Trailer Parks, Campgrounds - 7033"},{code:"4789",name:"Transportation Services - 4789"},{code:"4722",name:"Travel Agencies, Tour Operators - 4722"},{code:"7511",name:"Truck Stop - 7511"},{code:"7513",name:"Truck, Utility Trailer Rentals - 7513"},{code:"2791",name:"Typesetting, Plate Making - 2791"},{code:"5978",name:"Typewriters - 5978"},{code:"9405",name:"U.S. Federal Government Agencies or Departments - 9405"},{code:"5137",name:"Uniforms, Commercial Clothing - 5137"},{code:"5931",name:"Used or Secondhand Merchandise - 5931"},{code:"4900",name:"Utilities - 4900"},{code:"5331",name:"Variety Stores - 5331"},{code:"0742",name:"Veterinary Services - 0742"},{code:"7993",name:"Video Amusement Game Supplies - 7993"},{code:"7994",name:"Video Game Arcades - 7994"},{code:"7829",name:"Video Production - 7829"},{code:"7841",name:"Video Tape Rental - 7841"},{code:"8249",name:"Vocational, Trade Schools - 8249"},{code:"7631",name:"Watch, Jewelry Repair - 7631"},{code:"7692",name:"Welding Repair - 7692"},{code:"5300",name:"Wholesale Clubs - 5300"},{code:"5698",name:"Wig, Toupee - 5698"},{code:"4829",name:"Wires, Money Orders - 4829"},{code:"5631",name:"Womens Accessories - 5631"},{code:"5621",name:"Womens Ready-To-Wear - 5621"},{code:"5935",name:"Wrecking, Salvage Yards - 5935"}],addressBlockSchema={addressLine1:create$6().required("Address is required").test("addressLine1","PO Boxes are not supported",W=>!(W!=null&&W.trim().startsWith("PO")||W!=null&&W.trim().startsWith("P.O."))).test("addressLine1","Address is required",W=>!(W!=null&&W.trim().startsWith("undefined"))),addressLine2:create$6(),city:create$6().required("City is required"),stateOrProvince:create$6().length(2).required(),postalCode:create$6().matches(postalCodeRegex,"Invalid Postal Code").required()};function AddressBlock({register:W,errors:re,watch:oe,setValue:ie,trigger:pe,readOnly:nr,required:or,label:ar,placeholder:ir}){var dr,mr;const sr=useMercoaSession(),{ref:cr}=reactGoogleAutocomplete.usePlacesWidget({apiKey:sr.googleMapsApiKey,onPlaceSelected:async pr=>{var _r,Mr,$r,vr,Or;if(!pr)return;const hr=(_r=pr.address_components.find(Sr=>Sr.types.includes("street_number")))==null?void 0:_r.long_name,yr=(Mr=pr.address_components.find(Sr=>Sr.types.includes("route")))==null?void 0:Mr.long_name,gr=($r=pr.address_components.find(Sr=>Sr.types.includes("locality")))==null?void 0:$r.long_name,wr=(vr=pr.address_components.find(Sr=>Sr.types.includes("administrative_area_level_1")))==null?void 0:vr.short_name,br=(Or=pr.address_components.find(Sr=>Sr.types.includes("postal_code")))==null?void 0:Or.long_name;fr(!0),ie("addressLine1",hr+" "+yr,{shouldDirty:!0}),ie("city",gr??"",{shouldDirty:!0}),ie("stateOrProvince",wr??"",{shouldDirty:!0}),ie("postalCode",br??"",{shouldDirty:!0}),ie("country","US",{shouldDirty:!0}),pe()},options:{fields:["address_components"],types:["address"]}});React.useEffect(()=>{ie("country","US",{shouldDirty:!0})},[]);const lr=oe("stateOrProvince"),[ur,fr]=React.useState(!!nr||lr);return jsxRuntimeExports.jsx("div",{children:ur?jsxRuntimeExports.jsxs("div",{className:"mercoa-grid mercoa-grid-cols-2 mercoa-gap-3 mercoa-mb-5",children:[jsxRuntimeExports.jsx(MercoaInput,{label:ar??"Address",register:W,name:"addressLine1",className:"mercoa-mt-1 mercoa-col-span-2",errors:re,readOnly:nr,required:or}),jsxRuntimeExports.jsx(MercoaInput,{label:"Apartment, suite, etc.",register:W,name:"addressLine2",className:"mercoa-mt-1",errors:re,readOnly:nr}),jsxRuntimeExports.jsx(MercoaInput,{label:"City",register:W,name:"city",className:"mercoa-mt-1",errors:re,readOnly:nr,required:or}),jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-1",children:[jsxRuntimeExports.jsx(MercoaCombobox,{options:usaStates.map(({name:pr,abbreviation:hr})=>({disabled:!1,value:hr})),label:"State",value:lr,onChange:pr=>{ie("stateOrProvince",pr,{shouldDirty:!0})},labelClassName:"mercoa-block mercoa-text-left mercoa-text-sm mercoa-font-medium mercoa-text-gray-700 -mercoa-mb-1"}),((dr=re.stateOrProvince)==null?void 0:dr.message)&&jsxRuntimeExports.jsx("p",{className:"mercoa-text-sm mercoa-text-red-500 mercoa-text-left",children:(mr=re.stateOrProvince)==null?void 0:mr.message})]}),jsxRuntimeExports.jsx(MercoaInput,{label:"Postal Code",register:W,name:"postalCode",className:"mercoa-mt-1",errors:re,readOnly:nr,required:or})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(MercoaInputLabel,{label:ar??"Address",name:"addressLine1"}),jsxRuntimeExports.jsx("div",{className:"mercoa-mt-1",children:jsxRuntimeExports.jsx("input",{ref:cr,onBlur:()=>{fr(!0)},type:"text",placeholder:ir??"Enter a location",className:inputClassName({}),required:or})})]})})}const nameBlockSchema={firstName:create$6().required("First name is required"),middleName:create$6(),lastName:create$6().required("Last name is required"),suffix:create$6()};function NameBlock({register:W,errors:re,readOnly:oe,required:ie}){return jsxRuntimeExports.jsxs("div",{className:"mercoa-grid mercoa-grid-cols-2 mercoa-gap-3",children:[jsxRuntimeExports.jsx(MercoaInput,{label:"First Name",register:W,name:"firstName",errors:re,readOnly:oe,required:ie}),jsxRuntimeExports.jsx(MercoaInput,{label:"Middle Name",register:W,name:"middleName",errors:re,readOnly:oe,required:ie,optional:!0}),jsxRuntimeExports.jsx(MercoaInput,{label:"Last Name",register:W,name:"lastName",errors:re,readOnly:oe,required:ie}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(MercoaInputLabel,{label:"Suffix",name:"suffix"}),jsxRuntimeExports.jsx("div",{className:"mercoa-mt-1",children:jsxRuntimeExports.jsxs("select",{...W("suffix"),disabled:oe,className:inputClassName({}),children:[jsxRuntimeExports.jsx("option",{value:"",children:"None"}),jsxRuntimeExports.jsx("option",{value:"Sr.",children:"Sr."}),jsxRuntimeExports.jsx("option",{value:"Jr.",children:"Jr."}),jsxRuntimeExports.jsx("option",{value:"II",children:"II"}),jsxRuntimeExports.jsx("option",{value:"III",children:"III"}),jsxRuntimeExports.jsx("option",{value:"IV",children:"IV"}),jsxRuntimeExports.jsx("option",{value:"V",children:"V"})]})})]})]})}const dateOfBirthSchema={dob:create$4().typeError("Date of birth is required").required("Date of birth is required").test("dob","Must be at least 18 years old",W=>!dayjs$1(W).isAfter(dayjs$1().subtract(18,"years")))};function DateOfBirthBlock({control:W,errors:re,readOnly:oe,required:ie}){return jsxRuntimeExports.jsx(MercoaInput,{type:"date",label:"Date of Birth",name:"dob",errors:re,readOnly:oe,required:ie,control:W})}const SSNSchema={taxID:create$6().matches(/^\d{3}-\d{2}-\d{4}$/,"Invalid SSN").required("SSN is required")};function SSNBlock({control:W,errors:re,readOnly:oe,required:ie}){var pe,nr;return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(MercoaInputLabel,{label:"SSN",name:"taxID"}),jsxRuntimeExports.jsx("div",{className:"mercoa-mt-1",children:jsxRuntimeExports.jsx(Controller,{control:W,name:"taxID",render:({field:or})=>or.value==="****"?jsxRuntimeExports.jsx("input",{type:"text",className:inputClassName({}),placeholder:"123-45-6789",value:or.value,onChange:or.onChange,readOnly:oe}):jsxRuntimeExports.jsx(PatternFormat,{format:"###-##-####",allowEmptyFormatting:!0,mask:"_",value:or.value,onChange:or.onChange,readOnly:oe,required:ie,placeholder:"123-45-6789",className:inputClassName({})})})}),((pe=re.taxID)==null?void 0:pe.message)&&jsxRuntimeExports.jsx("p",{className:"mercoa-text-sm mercoa-text-red-500 mercoa-text-left",children:(nr=re.taxID)==null?void 0:nr.message.toString()})]})}const emailSchema={email:create$6().email("Email is not valid").required("Email is required")};function EmailBlock({register:W,errors:re,readOnly:oe,required:ie}){return jsxRuntimeExports.jsx(MercoaInput,{label:"Email",register:W,name:"email",errors:re,readOnly:oe,required:ie})}const phoneSchema={phoneNumber:create$6().matches(/^\(\d{3}\) \d{3}-\d{4}$/,"Invalid phone number").required("Phone number is required")};function PhoneBlock({control:W,errors:re,readOnly:oe,required:ie}){return jsxRuntimeExports.jsx(MercoaInput,{label:"Phone",control:W,name:"phoneNumber",errors:re,readOnly:oe,required:ie,inputMask:"(###) ###-####"})}const accountTypeSchema={accountType:create$6().required()};function AccountTypeRadioBlock({register:W,errors:re}){return jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-1",children:[jsxRuntimeExports.jsx(MercoaInputLabel,{label:"Account Type",name:"accountType"}),jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-items-center",children:[jsxRuntimeExports.jsx("input",{...W("accountType"),value:javascript.Mercoa.AccountType.Individual,type:"radio",className:inputClassName({})}),jsxRuntimeExports.jsx("label",{htmlFor:"accountType",className:"mercoa-ml-3 mercoa-block mercoa-text-sm mercoa-font-medium mercoa-text-gray-700",children:"Individual"})]}),jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-items-center",children:[jsxRuntimeExports.jsx("input",{...W("accountType"),value:javascript.Mercoa.AccountType.Business,type:"radio",className:inputClassName({})}),jsxRuntimeExports.jsx("label",{htmlFor:"accountType",className:"mercoa-ml-3 mercoa-block mercoa-text-sm mercoa-font-medium mercoa-text-gray-700",children:"Business"})]})]})}function AccountTypeSelectBlock({register:W,errors:re}){return jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-1",children:[jsxRuntimeExports.jsx(MercoaInputLabel,{label:"Account Type",name:"accountType"}),jsxRuntimeExports.jsx("div",{className:"mercoa-mt-1",children:jsxRuntimeExports.jsxs("select",{...W("accountType"),className:inputClassName({}),children:[jsxRuntimeExports.jsx("option",{value:javascript.Mercoa.AccountType.Individual,children:"Individual"}),jsxRuntimeExports.jsx("option",{value:javascript.Mercoa.AccountType.Business,children:"Business"})]})})]})}function BusinessTypeBlock({register:W,errors:re,readOnly:oe,required:ie}){return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(MercoaInputLabel,{label:"Business Type",name:"businessType"}),jsxRuntimeExports.jsx("div",{className:"mercoa-mt-1",children:jsxRuntimeExports.jsxs("select",{...W("businessType"),disabled:oe,required:ie,className:inputClassName({}),children:[jsxRuntimeExports.jsx("option",{value:"",disabled:!0,children:"Select an option"}),jsxRuntimeExports.jsx("option",{value:"soleProprietorship",children:"Sole proprietorship"}),jsxRuntimeExports.jsx("option",{value:"llc",children:"LLC"}),jsxRuntimeExports.jsx("option",{value:"trust",children:"Trust"}),jsxRuntimeExports.jsx("option",{value:"publicCorporation",children:"Public Corporation"}),jsxRuntimeExports.jsx("option",{value:"privateCorporation",children:"Private Corporation"}),jsxRuntimeExports.jsx("option",{value:"partnership",children:"Partnership"}),jsxRuntimeExports.jsx("option",{value:"unincorporatedAssociation",children:"Unincorporated association"}),jsxRuntimeExports.jsx("option",{value:"unincorporatedNonProfit",children:"Unincorporated Non-Profit "}),jsxRuntimeExports.jsx("option",{value:"incorporatedNonProfit",children:"Incorporated Non-Profit "})]})})]})}const legalBusinessNameSchema={legalBusinessName:create$6().required("Business name is required")};function LegalBusinessNameBlock({register:W,errors:re,readOnly:oe,required:ie}){return jsxRuntimeExports.jsx(MercoaInput,{label:"Business Name",register:W,name:"legalBusinessName",errors:re,readOnly:oe,required:ie})}const doingBusinessAsSchema={doingBusinessAs:create$6()};function DoingBusinessAsBlock({register:W,errors:re,readOnly:oe,required:ie}){return jsxRuntimeExports.jsx(MercoaInput,{label:"Doing Business As",register:W,name:"doingBusinessAs",errors:re,readOnly:oe,required:ie})}const einSchema={taxID:create$6().matches(/^(0[1-9]|[1-9]\d)-\d{7}|[*]{2}-[*]{7}$/,"Invalid EIN").required("EIN is required")};function EINBlock({control:W,errors:re,readOnly:oe,required:ie}){var pe,nr;return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(MercoaInputLabel,{label:"EIN",name:"taxID"}),jsxRuntimeExports.jsx("div",{className:"mercoa-mt-1",children:jsxRuntimeExports.jsx(Controller,{control:W,name:"taxID",render:({field:or})=>or.value==="**-*******"?jsxRuntimeExports.jsx("input",{type:"text",className:inputClassName({}),placeholder:"12-3456789",value:or.value,onChange:or.onChange,readOnly:oe}):jsxRuntimeExports.jsx(PatternFormat,{format:"##-#######",allowEmptyFormatting:!0,mask:"_",value:or.value,onChange:or.onChange,readOnly:oe,required:ie,placeholder:"12-3456789",className:inputClassName({})})})}),((pe=re.taxID)==null?void 0:pe.message)&&jsxRuntimeExports.jsx("p",{className:"mercoa-text-sm mercoa-text-red-500 mercoa-text-left",children:(nr=re.taxID)==null?void 0:nr.message.toString()})]})}const mccSchema={mcc:create$6().required("MCC is required")};function MCCBlock({watch:W,setValue:re}){const oe=W("mcc");return jsxRuntimeExports.jsx(MercoaCombobox,{options:mccCodes.map(ie=>({disabled:!1,value:ie})),displayIndex:"name",label:"Merchant Categorization Code",value:mccCodes.find(ie=>ie.code===oe),onChange:({code:ie})=>{re("mcc",ie,{shouldDirty:!0})},labelClassName:"mercoa-block mercoa-text-left mercoa-text-sm mercoa-font-medium mercoa-text-gray-700 -mercoa-mb-1"})}const websiteSchema={website:create$6().url("Website must start with http:// or https:// and be a valid URL").required("Website is required")};function WebsiteBlock({register:W,errors:re,readOnly:oe,required:ie}){return jsxRuntimeExports.jsx(MercoaInput,{label:"Website",register:W,name:"website",errors:re,readOnly:oe,required:ie})}const descriptionSchema={description:create$6().required("Description is required")};function DescriptionBlock({register:W,errors:re,readOnly:oe,required:ie}){return jsxRuntimeExports.jsx(MercoaInput,{label:"Business Description",register:W,name:"description",errors:re,readOnly:oe,required:ie})}const formationDateSchema={formationDate:create$4().required("Formation date is required")};function FormationDateBlock({control:W,errors:re,readOnly:oe,required:ie}){return jsxRuntimeExports.jsx(MercoaInput,{type:"date",label:"Business Formation Date",name:"formationDate",errors:re,readOnly:oe,required:ie,control:W})}async function createOrUpdateEntity({entityId:W,onClose:re,data:oe,isPayee:ie,isPayor:pe,mercoaClient:nr}){const or={};oe.accountType==="individual"?or.individual={email:oe.email,...oe.phoneNumber&&{phone:{number:oe.phoneNumber,countryCode:"1"}},...oe.taxID&&oe.taxID!="****"&&{governmentId:{ssn:oe.taxID}},name:{firstName:oe.firstName??"",lastName:oe.lastName??"",middleName:oe.middleName??"",suffix:oe.suffix??""},...oe.dob&&{birthDate:{day:dayjs$1(oe.dob).format("D"),month:dayjs$1(oe.dob).format("M"),year:dayjs$1(oe.dob).format("YYYY")}},...oe.addressLine1&&oe.city&&oe.stateOrProvince&&oe.postalCode&&{address:{addressLine1:oe.addressLine1,addressLine2:oe.addressLine2,postalCode:oe.postalCode,stateOrProvince:oe.stateOrProvince,city:oe.city,country:"US"}}}:or.business={email:oe.email,...oe.phoneNumber&&{phone:{number:oe.phoneNumber,countryCode:"1"}},businessType:oe.businessType??"llc",legalBusinessName:oe.legalBusinessName,doingBusinessAs:oe.doingBusinessAs,website:oe.website,description:oe.description,formationDate:oe.formationDate?dayjs$1(oe.formationDate).toDate():void 0,...oe.taxID&&oe.taxID!="**-*******"&&{taxId:{ein:{number:oe.taxID}}},...oe.mcc&&{industryCodes:{mcc:oe.mcc}},...oe.addressLine1&&oe.city&&oe.stateOrProvince&&oe.postalCode&&{address:{addressLine1:oe.addressLine1,addressLine2:oe.addressLine2,postalCode:oe.postalCode,stateOrProvince:oe.stateOrProvince,city:oe.city,country:"US"}}};const ar={isCustomer:!0,accountType:oe.accountType,profile:or,isPayee:ie,isPayor:pe,foreignId:oe.foreignId,emailTo:oe.emailTo};let ir;try{W?ir=await(nr==null?void 0:nr.entity.update(W,ar)):ir=await(nr==null?void 0:nr.entity.create(ar)),re&&re(ir)}catch(sr){Q$1.error(`There was an error saving your data.
68
+ `),nr=!1),Object.assign(Object.assign({},W),{allowNegative:nr})}function useNumericFormat(W){W=validateAndUpdateProps(W),W.decimalSeparator,W.allowedDecimalSeparators,W.thousandsGroupStyle;var re=W.suffix,oe=W.allowNegative,ie=W.allowLeadingZeros,pe=W.onKeyDown;pe===void 0&&(pe=noop$1);var nr=W.onBlur;nr===void 0&&(nr=noop$1);var or=W.thousandSeparator,ar=W.decimalScale,ir=W.fixedDecimalScale,sr=W.prefix;sr===void 0&&(sr="");var cr=W.defaultValue,lr=W.value,ur=W.valueIsNumericString,fr=W.onValueChange,dr=__rest$2(W,["decimalSeparator","allowedDecimalSeparators","thousandsGroupStyle","suffix","allowNegative","allowLeadingZeros","onKeyDown","onBlur","thousandSeparator","decimalScale","fixedDecimalScale","prefix","defaultValue","value","valueIsNumericString","onValueChange"]),mr=getSeparators(W),pr=mr.decimalSeparator,hr=mr.allowedDecimalSeparators,yr=function(Zr){return format$1(Zr,W)},gr=function(Zr,Yr){return removeFormatting(Zr,Yr,W)},wr=isNil(lr)?cr:lr,br=ur??isNumericString(wr,sr,re);isNil(lr)?isNil(cr)||(br=br||typeof cr=="number"):br=br||typeof lr=="number";var _r=function(Zr){return isNotValidValue(Zr)?Zr:(typeof Zr=="number"&&(Zr=toNumericString(Zr)),br&&typeof ar=="number"?roundToPrecision(Zr,ar,!!ir):Zr)},Mr=useInternalValues(_r(lr),_r(cr),!!br,yr,gr,fr),$r=Mr[0],vr=$r.numAsString,Or=$r.formattedValue,Sr=Mr[1],Cr=function(Zr){var Yr=Zr.target,en=Zr.key,Jr=Yr.selectionStart,kr=Yr.selectionEnd,on=Yr.value;if(on===void 0&&(on=""),Jr!==kr){pe(Zr);return}en==="Backspace"&&on[0]==="-"&&Jr===sr.length+1&&oe&&setCaretPosition(Yr,1),ar&&ir&&(en==="Backspace"&&on[Jr-1]===pr?(setCaretPosition(Yr,Jr-1),Zr.preventDefault()):en==="Delete"&&on[Jr]===pr&&Zr.preventDefault()),hr!=null&&hr.includes(en)&&on[Jr]===pr&&setCaretPosition(Yr,Jr+1);var Xr=or===!0?",":or;en==="Backspace"&&on[Jr-1]===Xr&&setCaretPosition(Yr,Jr-1),en==="Delete"&&on[Jr]===Xr&&setCaretPosition(Yr,Jr+1),pe(Zr)},Ir=function(Zr){var Yr=vr;if(Yr.match(/\d/g)||(Yr=""),ie||(Yr=fixLeadingZero(Yr)),ir&&ar&&(Yr=roundToPrecision(Yr,ar,ir)),Yr!==vr){var en=format$1(Yr,W);Sr({formattedValue:en,value:Yr,floatValue:parseFloat(Yr)},{event:Zr,source:SourceType.event})}nr(Zr)},Dr=function(Zr){return Zr===pr?!0:charIsNumber(Zr)},qr=function(Zr){var Yr=Zr.currentValue,en=Zr.lastValue,Jr=Zr.formattedValue,kr=Zr.currentValueIndex,on=Zr.formattedValueIndex,Xr=Yr[kr],Br=Jr[on],xr=findChangeRange(en,Yr),Rr=xr.to;return kr>=Rr.start&&kr<Rr.end&&hr&&hr.includes(Xr)&&Br===pr?!0:Xr===Br};return Object.assign(Object.assign({},dr),{value:Or,valueIsNumericString:!1,isValidInputCharacter:Dr,isCharacterSame:qr,onValueChange:Sr,format:yr,removeFormatting:gr,getCaretBoundary:function(Zr){return getCaretBoundary(Zr,W)},onKeyDown:Cr,onBlur:Ir})}function NumericFormat(W){var re=useNumericFormat(W);return React.createElement(NumberFormatBase,Object.assign({},re))}function format$1$1(W,re){var oe=re.format,ie=re.allowEmptyFormatting,pe=re.mask,nr=re.patternChar;if(nr===void 0&&(nr="#"),W===""&&!ie)return"";for(var or=0,ar=oe.split(""),ir=0,sr=oe.length;ir<sr;ir++)oe[ir]===nr&&(ar[ir]=W[or]||getMaskAtIndex(pe,or),or+=1);return ar.join("")}function removeFormatting$1(W,re,oe){re===void 0&&(re=getDefaultChangeMeta(W));var ie=oe.format,pe=oe.patternChar;pe===void 0&&(pe="#");var nr=re.from,or=re.to,ar=re.lastValue;ar===void 0&&(ar="");var ir=function(pr){return ie[pr]===pe},sr=function(pr,hr){for(var yr="",gr=0;gr<pr.length;gr++)ir(hr+gr)&&charIsNumber(pr[gr])&&(yr+=pr[gr]);return yr},cr=function(pr){return pr.replace(/[^0-9]/g,"")};if(!ie.match(/\d/))return cr(W);if(ar===""&&W.length===ie.length){for(var lr="",ur=0;ur<W.length;ur++)if(ir(ur))charIsNumber(W[ur])&&(lr+=W[ur]);else if(W[ur]!==ie[ur])return cr(W);return lr}var fr=ar.substring(0,nr.start),dr=W.substring(or.start,or.end),mr=ar.substring(nr.end);return""+sr(fr,0)+cr(dr)+sr(mr,nr.end)}function getCaretBoundary$1(W,re){var oe=re.format,ie=re.mask,pe=re.patternChar;pe===void 0&&(pe="#");var nr=Array.from({length:W.length+1}).map(function(){return!0}),or=0,ar=-1,ir={};oe.split("").forEach(function(ur,fr){var dr=void 0;ur===pe&&(or++,dr=getMaskAtIndex(ie,or-1),ar===-1&&W[fr]===dr&&(ar=fr)),ir[fr]=dr});for(var sr=function(ur){return oe[ur]===pe&&W[ur]!==ir[ur]},cr=0,lr=nr.length;cr<lr;cr++)nr[cr]=cr===ar||sr(cr)||sr(cr-1);return nr[oe.indexOf(pe)]=!0,nr}function validateProps(W){var re=W.mask;if(re){var oe=re==="string"?re:re.toString();if(oe.match(/\d/g))throw new Error("Mask "+re+" should not contain numeric character;")}}function isNumericString$1(W,re){return W===""?!0:!(re!=null&&re.match(/\d/))&&typeof W=="string"&&(!!W.match(/^\d+$/)||W==="")}function usePatternFormat(W){W.mask,W.allowEmptyFormatting;var re=W.format,oe=W.inputMode;oe===void 0&&(oe="numeric");var ie=W.onKeyDown;ie===void 0&&(ie=noop$1);var pe=W.patternChar;pe===void 0&&(pe="#");var nr=W.value,or=W.defaultValue,ar=W.valueIsNumericString,ir=__rest$2(W,["mask","allowEmptyFormatting","format","inputMode","onKeyDown","patternChar","value","defaultValue","valueIsNumericString"]);validateProps(W);var sr=function(dr){return getCaretBoundary$1(dr,W)},cr=function(dr){var mr=dr.key,pr=dr.target,hr=pr.selectionStart,yr=pr.selectionEnd,gr=pr.value;if(hr!==yr){ie(dr);return}var wr=hr;if(mr==="Backspace"||mr==="Delete"){var br="right";if(mr==="Backspace"){for(;wr>0&&re[wr-1]!==pe;)wr--;br="left"}else{for(var _r=re.length;wr<_r&&re[wr]!==pe;)wr++;br="right"}wr=getCaretPosInBoundary(gr,wr,sr(gr),br)}else re[wr]!==pe&&mr!=="ArrowLeft"&&mr!=="ArrowRight"&&(wr=getCaretPosInBoundary(gr,wr+1,sr(gr),"right"));wr!==hr&&setCaretPosition(pr,wr),ie(dr)},lr=isNil(nr)?or:nr,ur=ar??isNumericString$1(lr,re),fr=Object.assign(Object.assign({},W),{valueIsNumericString:ur});return Object.assign(Object.assign({},ir),{value:nr,defaultValue:or,valueIsNumericString:ur,inputMode:oe,format:function(dr){return format$1$1(dr,fr)},removeFormatting:function(dr,mr){return removeFormatting$1(dr,mr,fr)},getCaretBoundary:sr,onKeyDown:cr})}function PatternFormat(W){var re=usePatternFormat(W);return React.createElement(NumberFormatBase,Object.assign({},re))}const mccCodes=[{code:"7623",name:"AC, Refrigeration Repair - 7623"},{code:"8931",name:"Accounting, Bookkeeping - 8931"},{code:"7311",name:"Advertising Services - 7311"},{code:"0763",name:"Agricultural Cooperative - 0763"},{code:"4511",name:"Airlines, Air Carriers - 4511"},{code:"4582",name:"Airports, Flying Fields - 4582"},{code:"4119",name:"Ambulance Services - 4119"},{code:"7996",name:"Amusement Parks, Carnivals - 7996"},{code:"5937",name:"Antique Reproductions - 5937"},{code:"5932",name:"Antiques - 5932"},{code:"7998",name:"Aquariums - 7998"},{code:"8911",name:"Architectural, Surveying - 8911"},{code:"5971",name:"Art Dealers, Galleries - 5971"},{code:"5970",name:"Artists Supply, Crafts - 5970"},{code:"5531",name:"Auto and Home Supplies - 5531"},{code:"7531",name:"Auto Body Repair - 7531"},{code:"7535",name:"Auto Paint - 7535"},{code:"7538",name:"Auto Service - 7538"},{code:"6011",name:"Automated Cash Disburse - 6011"},{code:"5542",name:"Automated Fuel Dispensers - 5542"},{code:"8675",name:"Automobile Associations - 8675"},{code:"5511",name:"Automobile Dealers (New &amp; Used) - 5511"},{code:"5521",name:"Automobile Dealers (Used Only) - 5521"},{code:"5533",name:"Automotive Parts, Accessories - 5533"},{code:"5532",name:"Automotive Tire - 5532"},{code:"9223",name:"Bail, Bond Payments - 9223"},{code:"5462",name:"Bakeries - 5462"},{code:"7929",name:"Bands, Orchestras - 7929"},{code:"7230",name:"Barber, Beauty - 7230"},{code:"7995",name:"Betting, Casino Gambling - 7995"},{code:"5940",name:"Bicycle - 5940"},{code:"7932",name:"Billiard, Pool Establishments - 7932"},{code:"5551",name:"Boat Dealers - 5551"},{code:"4457",name:"Boat Rentals, Leases - 4457"},{code:"5942",name:"Books - 5942"},{code:"5192",name:"Books, Periodicals, Newspapers - 5192"},{code:"7933",name:"Bowling Alleys - 7933"},{code:"4131",name:"Bus Lines - 4131"},{code:"8244",name:"Business, Secretarial Schools - 8244"},{code:"7278",name:"Buying, Shopping Services - 7278"},{code:"4899",name:"Cable, Satellite, Pay Television and Radio - 4899"},{code:"5946",name:"Camera, Photographic Supply - 5946"},{code:"5441",name:"Candy, Nut, Confectionery - 5441"},{code:"7512",name:"Car Rental Agencies - 7512"},{code:"7542",name:"Car Washes - 7542"},{code:"1750",name:"Carpentry Contractors - 1750"},{code:"7217",name:"Carpet, Upholstery Cleaning - 7217"},{code:"5811",name:"Caterers - 5811"},{code:"8398",name:"Charitable, Social Service Organizations - 8398"},{code:"5169",name:"Chemical Products - 5169"},{code:"8351",name:"Child Care Services - 8351"},{code:"5641",name:"Childrens, Infants Wear - 5641"},{code:"8049",name:"Chiropodists, Podiatrists - 8049"},{code:"8041",name:"Chiropractors - 8041"},{code:"5993",name:"Cigars - 5993"},{code:"8641",name:"Civic, Social, Fraternal Associations - 8641"},{code:"7349",name:"Cleaning, Maintenance - 7349"},{code:"7296",name:"Clothing Rental - 7296"},{code:"8220",name:"Colleges, Universities - 8220"},{code:"5046",name:"Commercial Equipment - 5046"},{code:"5139",name:"Commercial Footwear - 5139"},{code:"7333",name:"Commercial Photography, Art, Graphics - 7333"},{code:"4111",name:"Commuter Transport, Ferries - 4111"},{code:"4816",name:"Computer Networks - 4816"},{code:"7372",name:"Computer Programming - 7372"},{code:"7379",name:"Computer Repair - 7379"},{code:"5734",name:"Computer Software - 5734"},{code:"5045",name:"Computers, Peripherals, Software - 5045"},{code:"1771",name:"Concrete Work - 1771"},{code:"5039",name:"Construction Materials - 5039"},{code:"7392",name:"Consulting, Public Relations - 7392"},{code:"5499",name:"Convenience Stores, Specialty Markets - 5499"},{code:"8241",name:"Correspondence Schools - 8241"},{code:"5977",name:"Cosmetics - 5977"},{code:"7277",name:"Counseling Services - 7277"},{code:"4215",name:"Courier Services - 4215"},{code:"9211",name:"Court Costs, Alimony, Child Support - 9211"},{code:"7321",name:"Credit Reporting Agencies - 7321"},{code:"4411",name:"Cruise Lines - 4411"},{code:"5451",name:"Dairy Products - 5451"},{code:"7911",name:"Dance Hall, Studios, Schools - 7911"},{code:"7273",name:"Dating, Escort Services - 7273"},{code:"8021",name:"Dentists, Orthodontists - 8021"},{code:"5311",name:"Department Stores - 5311"},{code:"7393",name:"Detective Agencies - 7393"},{code:"5817",name:"Digital Goods - Applications - 5817"},{code:"5816",name:"Digital Goods – Games - 5816"},{code:"5818",name:"Digital Goods – Large Digital Goods Merchant - 5818"},{code:"5815",name:"Digital Goods Media – Books, Movies, Music - 5815"},{code:"5964",name:"Direct Marketing - Catalog Merchant - 5964"},{code:"5965",name:"Direct Marketing - Catalog, Retail - 5965"},{code:"5967",name:"Direct Marketing - Inbound Telemarketing - 5967"},{code:"5960",name:"Direct Marketing - Insurance Services - 5960"},{code:"5969",name:"Direct Marketing - Other - 5969"},{code:"5966",name:"Direct Marketing - Outbound Telemarketing - 5966"},{code:"5968",name:"Direct Marketing - Subscription - 5968"},{code:"5962",name:"Direct Marketing - Travel - 5962"},{code:"5310",name:"Discount Stores - 5310"},{code:"8011",name:"Doctors - 8011"},{code:"5963",name:"Door-To-Door Sales - 5963"},{code:"5714",name:"Drapery, Window Covering, Upholstery - 5714"},{code:"5813",name:"Drinking Places - 5813"},{code:"5912",name:"Drug Stores, Pharmacies - 5912"},{code:"5122",name:"Drugs, Drug Proprietaries - 5122"},{code:"7216",name:"Dry Cleaners - 7216"},{code:"5099",name:"Durable Goods - 5099"},{code:"5309",name:"Duty Free - 5309"},{code:"5812",name:"Eating Places, Restaurants - 5812"},{code:"8299",name:"Educational Services - 8299"},{code:"5997",name:"Electric Razor - 5997"},{code:"1731",name:"Electrical Contractors - 1731"},{code:"5065",name:"Electrical Parts - 5065"},{code:"5732",name:"Electronics - 5732"},{code:"7622",name:"Electronics Repair - 7622"},{code:"8211",name:"Elementary, Secondary Schools - 8211"},{code:"7361",name:"Employment, Temp Agencies - 7361"},{code:"7394",name:"Equipment Rental - 7394"},{code:"7342",name:"Exterminating Services - 7342"},{code:"5651",name:"Family Clothing - 5651"},{code:"5814",name:"Fast Food Restaurants - 5814"},{code:"6012",name:"Financial Institutions - 6012"},{code:"9222",name:"Fines - Government Administrative Entities - 9222"},{code:"5718",name:"Fireplace - 5718"},{code:"5713",name:"Floor Covering - 5713"},{code:"5992",name:"Florists - 5992"},{code:"5193",name:"Florists Supplies, Nursery Stock, Flowers - 5193"},{code:"5661",name:"Footwear - 5661"},{code:"5422",name:"Freezer, Locker Meat Provisioners - 5422"},{code:"4214",name:"Freight Carriers, Trucking - 4214"},{code:"5983",name:"Fuel Dealers - 5983"},{code:"7261",name:"Funeral Services, Crematories - 7261"},{code:"5712",name:"Furniture - 5712"},{code:"7641",name:"Furniture Repair, Refinishing - 7641"},{code:"5681",name:"Furriers, Fur - 5681"},{code:"1520",name:"General Contractors - 1520"},{code:"5947",name:"Gift, Card, Novelty, Souvenir Shops - 5947"},{code:"5231",name:"Glass, Paint, Wallpaper - 5231"},{code:"5950",name:"Glassware, Crystal - 5950"},{code:"9399",name:"Government Services - 9399"},{code:"5411",name:"Grocery Stores, Supermarkets - 5411"},{code:"5251",name:"Hardware - 5251"},{code:"5072",name:"Hardware, Equipment - 5072"},{code:"7298",name:"Health, Beauty Spas - 7298"},{code:"5975",name:"Hearing Aids - 5975"},{code:"1711",name:"Heating, Plumbing, AC - 1711"},{code:"5945",name:"Hobby, Toy, Games - 5945"},{code:"5200",name:"Home Supply Warehouse - 5200"},{code:"8062",name:"Hospitals - 8062"},{code:"7011",name:"Hotels, Motels, Resorts - 7011"},{code:"5722",name:"Household Appliance - 5722"},{code:"5085",name:"Industrial Supplies - 5085"},{code:"7375",name:"Information Retrieval Services - 7375"},{code:"6300",name:"Insurance Underwriting, Premiums - 6300"},{code:"5944",name:"Jewelry, Watches, Clocks, Silverware - 5944"},{code:"0780",name:"Landscaping Services - 0780"},{code:"7211",name:"Laundries - 7211"},{code:"7210",name:"Laundry, Cleaning Services - 7210"},{code:"8111",name:"Legal Services, Attorneys - 8111"},{code:"5948",name:"Luggage, Leather Goods - 5948"},{code:"5211",name:"Lumber, Building Materials - 5211"},{code:"6010",name:"Manual Cash Disburse - 6010"},{code:"4468",name:"Marinas - 4468"},{code:"1740",name:"Masonry, Stonework, Plaster - 1740"},{code:"7297",name:"Massage Parlors - 7297"},{code:"8099",name:"Medical Services - 8099"},{code:"8071",name:"Medical, Dental Labs - 8071"},{code:"5047",name:"Medical, Dental, Ophthalmic, Hospital Equipment - 5047"},{code:"7997",name:"Membership Clubs - 7997"},{code:"8699",name:"Membership Organizations - 8699"},{code:"5611",name:"Mens and Boys Clothing, Accessories - 5611"},{code:"5691",name:"Mens, Womens Clothing - 5691"},{code:"5051",name:"Metal Service Centers - 5051"},{code:"5699",name:"Miscellaneous Apparel, Accessories - 5699"},{code:"5599",name:"Miscellaneous Auto Dealers - 5599"},{code:"7399",name:"Miscellaneous Business Services - 7399"},{code:"5399",name:"Miscellaneous General Merchandise - 5399"},{code:"7299",name:"Miscellaneous General Services - 7299"},{code:"5719",name:"Miscellaneous Home Furnishing Specialty - 5719"},{code:"2741",name:"Miscellaneous Publishing, Printing - 2741"},{code:"7999",name:"Miscellaneous Recreation Services - 7999"},{code:"7699",name:"Miscellaneous Repair - 7699"},{code:"5999",name:"Miscellaneous Specialty Retail - 5999"},{code:"5271",name:"Mobile Home Dealers - 5271"},{code:"7832",name:"Motion Picture Theaters - 7832"},{code:"5592",name:"Motor Homes Dealers - 5592"},{code:"5013",name:"Motor Vehicle Supplies - 5013"},{code:"5561",name:"Motorcycle Dealers - 5561"},{code:"5733",name:"Musical Instruments, Pianos, Sheet Music - 5733"},{code:"5994",name:"News Dealers, Newsstands - 5994"},{code:"6051",name:"Non-FI, Money Orders - 6051"},{code:"6540",name:"Non-FI, Stored Value Card Purchase - 6540"},{code:"5199",name:"Nondurable Goods - 5199"},{code:"5261",name:"Nurseries, Lawn, Garden Supply - 5261"},{code:"8050",name:"Nursing, Personal Care - 8050"},{code:"5021",name:"Office, Commercial Furniture - 5021"},{code:"8043",name:"Opticians, Eyeglasses - 8043"},{code:"8042",name:"Optometrists, Ophthalmologist - 8042"},{code:"5976",name:"Orthopedic Goods, Prosthetic Devices - 5976"},{code:"8031",name:"Osteopaths - 8031"},{code:"5921",name:"Package - Beer, Wine, Liquor - 5921"},{code:"5198",name:"Paints, Varnishes - 5198"},{code:"7523",name:"Parking Lots, Garages - 7523"},{code:"4112",name:"Passenger Railways - 4112"},{code:"5933",name:"Pawn Shops - 5933"},{code:"5995",name:"Pet Supplies, Food - 5995"},{code:"5172",name:"Petroleum Products - 5172"},{code:"7395",name:"Photo Developing - 7395"},{code:"7221",name:"Photographic Studios - 7221"},{code:"5044",name:"Photographic, Photocopy, Microfilm Equipment - 5044"},{code:"5131",name:"Piece Goods, Other Dry Goods - 5131"},{code:"5074",name:"Plumbing, Heating Equipment - 5074"},{code:"8651",name:"Political Organizations - 8651"},{code:"9402",name:"Postal Services - 9402"},{code:"5094",name:"Precious Stones and Metals, Watches, Jewelry - 5094"},{code:"8999",name:"Professional Services - 8999"},{code:"7992",name:"Public Golf Courses - 7992"},{code:"4225",name:"Public Warehousing, Storage - 4225"},{code:"7338",name:"Quick Copy, Repro, Blueprint - 7338"},{code:"4011",name:"Railroads - 4011"},{code:"6513",name:"Real Estate Agents, Rentals - 6513"},{code:"5735",name:"Record Stores - 5735"},{code:"7519",name:"Recreational Vehicle Rentals - 7519"},{code:"5973",name:"Religious Goods - 5973"},{code:"8661",name:"Religious Organizations - 8661"},{code:"1761",name:"Roofing, Siding, Sheet Metal - 1761"},{code:"7339",name:"Secretarial Support Services - 7339"},{code:"6211",name:"Security Brokers, Dealers - 6211"},{code:"5541",name:"Service Stations - 5541"},{code:"5949",name:"Sewing, Needlework, Fabric, Piece Goods - 5949"},{code:"7251",name:"Shoe Repair, Hat Cleaning - 7251"},{code:"7629",name:"Small Appliance Repair - 7629"},{code:"5598",name:"Snowmobile Dealers - 5598"},{code:"1799",name:"Special Trade Contractors - 1799"},{code:"2842",name:"Specialty Cleaning - 2842"},{code:"5941",name:"Sporting Goods - 5941"},{code:"7032",name:"Sporting, Recreation Camps - 7032"},{code:"7941",name:"Sports Clubs, Fields - 7941"},{code:"5655",name:"Sports, Riding Apparel - 5655"},{code:"5972",name:"Stamps, Coins - 5972"},{code:"5111",name:"Stationary, Office Supplies, Printing, Writing Paper - 5111"},{code:"5943",name:"Stationery, Office, School Supplies - 5943"},{code:"5996",name:"Swimming Pools - 5996"},{code:"5697",name:"Tailors, Alterations - 5697"},{code:"9311",name:"Tax Payments - 9311"},{code:"7276",name:"Tax Preparation Services - 7276"},{code:"4121",name:"Taxicabs, Limousines - 4121"},{code:"4814",name:"Telecommunication - 4814"},{code:"4812",name:"Telecommunication Equipment - 4812"},{code:"4821",name:"Telegraph - 4821"},{code:"5998",name:"Tent, Awning - 5998"},{code:"8734",name:"Testing Laboratories - 8734"},{code:"7922",name:"Theatrical Ticket Agencies - 7922"},{code:"7012",name:"Timeshares - 7012"},{code:"7534",name:"Tire Retreading, Repair - 7534"},{code:"4784",name:"Tolls, Bridge Fees - 4784"},{code:"7991",name:"Tourist Attractions, Exhibits - 7991"},{code:"7549",name:"Towing Services - 7549"},{code:"7033",name:"Trailer Parks, Campgrounds - 7033"},{code:"4789",name:"Transportation Services - 4789"},{code:"4722",name:"Travel Agencies, Tour Operators - 4722"},{code:"7511",name:"Truck Stop - 7511"},{code:"7513",name:"Truck, Utility Trailer Rentals - 7513"},{code:"2791",name:"Typesetting, Plate Making - 2791"},{code:"5978",name:"Typewriters - 5978"},{code:"9405",name:"U.S. Federal Government Agencies or Departments - 9405"},{code:"5137",name:"Uniforms, Commercial Clothing - 5137"},{code:"5931",name:"Used or Secondhand Merchandise - 5931"},{code:"4900",name:"Utilities - 4900"},{code:"5331",name:"Variety Stores - 5331"},{code:"0742",name:"Veterinary Services - 0742"},{code:"7993",name:"Video Amusement Game Supplies - 7993"},{code:"7994",name:"Video Game Arcades - 7994"},{code:"7829",name:"Video Production - 7829"},{code:"7841",name:"Video Tape Rental - 7841"},{code:"8249",name:"Vocational, Trade Schools - 8249"},{code:"7631",name:"Watch, Jewelry Repair - 7631"},{code:"7692",name:"Welding Repair - 7692"},{code:"5300",name:"Wholesale Clubs - 5300"},{code:"5698",name:"Wig, Toupee - 5698"},{code:"4829",name:"Wires, Money Orders - 4829"},{code:"5631",name:"Womens Accessories - 5631"},{code:"5621",name:"Womens Ready-To-Wear - 5621"},{code:"5935",name:"Wrecking, Salvage Yards - 5935"}],addressBlockSchema={addressLine1:create$6().required("Address is required").test("addressLine1","PO Boxes are not supported",W=>!(W!=null&&W.trim().startsWith("PO")||W!=null&&W.trim().startsWith("P.O."))).test("addressLine1","Address is required",W=>!(W!=null&&W.trim().startsWith("undefined"))),addressLine2:create$6(),city:create$6().required("City is required"),stateOrProvince:create$6().length(2).required(),postalCode:create$6().matches(postalCodeRegex,"Invalid Postal Code").required()};function AddressBlock({register:W,errors:re,watch:oe,setValue:ie,trigger:pe,readOnly:nr,required:or,label:ar,placeholder:ir}){var dr,mr;const sr=useMercoaSession(),{ref:cr}=reactGoogleAutocomplete.usePlacesWidget({apiKey:sr.googleMapsApiKey,onPlaceSelected:async pr=>{var _r,Mr,$r,vr,Or;if(!pr)return;const hr=(_r=pr.address_components.find(Sr=>Sr.types.includes("street_number")))==null?void 0:_r.long_name,yr=(Mr=pr.address_components.find(Sr=>Sr.types.includes("route")))==null?void 0:Mr.long_name,gr=($r=pr.address_components.find(Sr=>Sr.types.includes("locality")))==null?void 0:$r.long_name,wr=(vr=pr.address_components.find(Sr=>Sr.types.includes("administrative_area_level_1")))==null?void 0:vr.short_name,br=(Or=pr.address_components.find(Sr=>Sr.types.includes("postal_code")))==null?void 0:Or.long_name;fr(!0),ie("addressLine1",hr+" "+yr,{shouldDirty:!0}),ie("city",gr??"",{shouldDirty:!0}),ie("stateOrProvince",wr??"",{shouldDirty:!0}),ie("postalCode",br??"",{shouldDirty:!0}),ie("country","US",{shouldDirty:!0}),pe()},options:{fields:["address_components"],types:["address"]}});React.useEffect(()=>{ie("country","US",{shouldDirty:!0})},[]);const lr=oe("stateOrProvince"),[ur,fr]=React.useState(!!nr||lr);return jsxRuntimeExports.jsx("div",{children:ur?jsxRuntimeExports.jsxs("div",{className:"mercoa-grid mercoa-grid-cols-2 mercoa-gap-3 mercoa-mb-5",children:[jsxRuntimeExports.jsx(MercoaInput,{label:ar??"Address",register:W,name:"addressLine1",className:"mercoa-mt-1 mercoa-col-span-2",errors:re,readOnly:nr,required:or}),jsxRuntimeExports.jsx(MercoaInput,{label:"Apartment, suite, etc.",register:W,name:"addressLine2",className:"mercoa-mt-1",errors:re,readOnly:nr}),jsxRuntimeExports.jsx(MercoaInput,{label:"City",register:W,name:"city",className:"mercoa-mt-1",errors:re,readOnly:nr,required:or}),jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-1",children:[jsxRuntimeExports.jsx(MercoaCombobox,{options:usaStates.map(({name:pr,abbreviation:hr})=>({disabled:!1,value:hr})),label:"State",value:lr,onChange:pr=>{ie("stateOrProvince",pr,{shouldDirty:!0})},labelClassName:"mercoa-block mercoa-text-left mercoa-text-sm mercoa-font-medium mercoa-text-gray-700 -mercoa-mb-1"}),((dr=re.stateOrProvince)==null?void 0:dr.message)&&jsxRuntimeExports.jsx("p",{className:"mercoa-text-sm mercoa-text-red-500 mercoa-text-left",children:(mr=re.stateOrProvince)==null?void 0:mr.message})]}),jsxRuntimeExports.jsx(MercoaInput,{label:"Postal Code",register:W,name:"postalCode",className:"mercoa-mt-1",errors:re,readOnly:nr,required:or})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(MercoaInputLabel,{label:ar??"Address",name:"addressLine1"}),jsxRuntimeExports.jsx("div",{className:"mercoa-mt-1",children:jsxRuntimeExports.jsx("input",{ref:cr,onBlur:()=>{fr(!0)},type:"text",placeholder:ir??"Enter a location",className:inputClassName({}),required:or})})]})})}const nameBlockSchema={firstName:create$6().required("First name is required"),middleName:create$6(),lastName:create$6().required("Last name is required"),suffix:create$6()};function NameBlock({register:W,errors:re,readOnly:oe,required:ie}){return jsxRuntimeExports.jsxs("div",{className:"mercoa-grid mercoa-grid-cols-2 mercoa-gap-3",children:[jsxRuntimeExports.jsx(MercoaInput,{label:"First Name",register:W,name:"firstName",errors:re,readOnly:oe,required:ie}),jsxRuntimeExports.jsx(MercoaInput,{label:"Middle Name",register:W,name:"middleName",errors:re,readOnly:oe,required:ie,optional:!0}),jsxRuntimeExports.jsx(MercoaInput,{label:"Last Name",register:W,name:"lastName",errors:re,readOnly:oe,required:ie}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(MercoaInputLabel,{label:"Suffix",name:"suffix"}),jsxRuntimeExports.jsx("div",{className:"mercoa-mt-1",children:jsxRuntimeExports.jsxs("select",{...W("suffix"),disabled:oe,className:inputClassName({}),children:[jsxRuntimeExports.jsx("option",{value:"",children:"None"}),jsxRuntimeExports.jsx("option",{value:"Sr.",children:"Sr."}),jsxRuntimeExports.jsx("option",{value:"Jr.",children:"Jr."}),jsxRuntimeExports.jsx("option",{value:"II",children:"II"}),jsxRuntimeExports.jsx("option",{value:"III",children:"III"}),jsxRuntimeExports.jsx("option",{value:"IV",children:"IV"}),jsxRuntimeExports.jsx("option",{value:"V",children:"V"})]})})]})]})}const dateOfBirthSchema={dob:create$4().typeError("Date of birth is required").required("Date of birth is required").test("dob","Must be at least 18 years old",W=>!dayjs$1(W).isAfter(dayjs$1().subtract(18,"years")))};function DateOfBirthBlock({control:W,errors:re,readOnly:oe,required:ie}){return jsxRuntimeExports.jsx(MercoaInput,{type:"date",label:"Date of Birth",name:"dob",errors:re,readOnly:oe,required:ie,control:W})}const SSNSchema={taxID:create$6().matches(/^\d{3}-\d{2}-\d{4}$/,"Invalid SSN").required("SSN is required")};function SSNBlock({control:W,errors:re,readOnly:oe,required:ie}){var pe,nr;return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(MercoaInputLabel,{label:"SSN",name:"taxID"}),jsxRuntimeExports.jsx("div",{className:"mercoa-mt-1",children:jsxRuntimeExports.jsx(Controller,{control:W,name:"taxID",render:({field:or})=>or.value==="****"?jsxRuntimeExports.jsx("input",{type:"text",className:inputClassName({}),placeholder:"123-45-6789",value:or.value,onChange:or.onChange,readOnly:oe}):jsxRuntimeExports.jsx(PatternFormat,{format:"###-##-####",allowEmptyFormatting:!0,mask:"_",value:or.value,onChange:or.onChange,readOnly:oe,required:ie,placeholder:"123-45-6789",className:inputClassName({})})})}),((pe=re.taxID)==null?void 0:pe.message)&&jsxRuntimeExports.jsx("p",{className:"mercoa-text-sm mercoa-text-red-500 mercoa-text-left",children:(nr=re.taxID)==null?void 0:nr.message.toString()})]})}const emailSchema={email:create$6().email("Email is not valid").required("Email is required")};function EmailBlock({register:W,errors:re,readOnly:oe,required:ie}){return jsxRuntimeExports.jsx(MercoaInput,{label:"Email",register:W,name:"email",errors:re,readOnly:oe,required:ie})}const phoneSchema={phoneNumber:create$6().matches(/^\(\d{3}\) \d{3}-\d{4}$/,"Invalid phone number").required("Phone number is required")};function PhoneBlock({control:W,errors:re,readOnly:oe,required:ie}){return jsxRuntimeExports.jsx(MercoaInput,{label:"Phone",control:W,name:"phoneNumber",errors:re,readOnly:oe,required:ie,inputMask:"(###) ###-####"})}const accountTypeSchema={accountType:create$6().required()};function AccountTypeRadioBlock({register:W,errors:re}){return jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-1",children:[jsxRuntimeExports.jsx(MercoaInputLabel,{label:"Account Type",name:"accountType"}),jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-items-center",children:[jsxRuntimeExports.jsx("input",{...W("accountType"),value:javascript.Mercoa.AccountType.Individual,type:"radio",className:inputClassName({})}),jsxRuntimeExports.jsx("label",{htmlFor:"accountType",className:"mercoa-ml-3 mercoa-block mercoa-text-sm mercoa-font-medium mercoa-text-gray-700",children:"Individual"})]}),jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-items-center",children:[jsxRuntimeExports.jsx("input",{...W("accountType"),value:javascript.Mercoa.AccountType.Business,type:"radio",className:inputClassName({})}),jsxRuntimeExports.jsx("label",{htmlFor:"accountType",className:"mercoa-ml-3 mercoa-block mercoa-text-sm mercoa-font-medium mercoa-text-gray-700",children:"Business"})]})]})}function AccountTypeSelectBlock({register:W,errors:re}){return jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-1",children:[jsxRuntimeExports.jsx(MercoaInputLabel,{label:"Account Type",name:"accountType"}),jsxRuntimeExports.jsx("div",{className:"mercoa-mt-1",children:jsxRuntimeExports.jsxs("select",{...W("accountType"),className:inputClassName({}),children:[jsxRuntimeExports.jsx("option",{value:javascript.Mercoa.AccountType.Individual,children:"Individual"}),jsxRuntimeExports.jsx("option",{value:javascript.Mercoa.AccountType.Business,children:"Business"})]})})]})}function BusinessTypeBlock({register:W,errors:re,readOnly:oe,required:ie}){return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(MercoaInputLabel,{label:"Business Type",name:"businessType"}),jsxRuntimeExports.jsx("div",{className:"mercoa-mt-1",children:jsxRuntimeExports.jsxs("select",{...W("businessType"),disabled:oe,required:ie,className:inputClassName({}),children:[jsxRuntimeExports.jsx("option",{value:"",disabled:!0,children:"Select an option"}),jsxRuntimeExports.jsx("option",{value:"soleProprietorship",children:"Sole proprietorship"}),jsxRuntimeExports.jsx("option",{value:"llc",children:"LLC"}),jsxRuntimeExports.jsx("option",{value:"trust",children:"Trust"}),jsxRuntimeExports.jsx("option",{value:"publicCorporation",children:"Public Corporation"}),jsxRuntimeExports.jsx("option",{value:"privateCorporation",children:"Private Corporation"}),jsxRuntimeExports.jsx("option",{value:"partnership",children:"Partnership"}),jsxRuntimeExports.jsx("option",{value:"unincorporatedAssociation",children:"Unincorporated association"}),jsxRuntimeExports.jsx("option",{value:"unincorporatedNonProfit",children:"Unincorporated Non-Profit "}),jsxRuntimeExports.jsx("option",{value:"incorporatedNonProfit",children:"Incorporated Non-Profit "})]})})]})}const legalBusinessNameSchema={legalBusinessName:create$6().required("Business name is required")};function LegalBusinessNameBlock({register:W,errors:re,readOnly:oe,required:ie}){return jsxRuntimeExports.jsx(MercoaInput,{label:"Business Name",register:W,name:"legalBusinessName",errors:re,readOnly:oe,required:ie})}const doingBusinessAsSchema={doingBusinessAs:create$6()};function DoingBusinessAsBlock({register:W,errors:re,readOnly:oe,required:ie}){return jsxRuntimeExports.jsx(MercoaInput,{label:"Doing Business As",register:W,name:"doingBusinessAs",errors:re,readOnly:oe,required:ie})}const einSchema={taxID:create$6().matches(/^(0[1-9]|[1-9]\d)-\d{7}|[*]{2}-[*]{7}$/,"Invalid EIN").required("EIN is required")};function EINBlock({control:W,errors:re,readOnly:oe,required:ie}){var pe,nr;return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(MercoaInputLabel,{label:"EIN",name:"taxID"}),jsxRuntimeExports.jsx("div",{className:"mercoa-mt-1",children:jsxRuntimeExports.jsx(Controller,{control:W,name:"taxID",render:({field:or})=>or.value==="**-*******"?jsxRuntimeExports.jsx("input",{type:"text",className:inputClassName({}),placeholder:"12-3456789",value:or.value,onChange:or.onChange,readOnly:oe}):jsxRuntimeExports.jsx(PatternFormat,{format:"##-#######",allowEmptyFormatting:!0,mask:"_",value:or.value,onChange:or.onChange,readOnly:oe,required:ie,placeholder:"12-3456789",className:inputClassName({})})})}),((pe=re.taxID)==null?void 0:pe.message)&&jsxRuntimeExports.jsx("p",{className:"mercoa-text-sm mercoa-text-red-500 mercoa-text-left",children:(nr=re.taxID)==null?void 0:nr.message.toString()})]})}const mccSchema={mcc:create$6().required("MCC is required")};function MCCBlock({watch:W,setValue:re}){const oe=W("mcc");return jsxRuntimeExports.jsx(MercoaCombobox,{options:mccCodes.map(ie=>({disabled:!1,value:ie})),displayIndex:"name",label:"Merchant Categorization Code",value:mccCodes.find(ie=>ie.code===oe),onChange:({code:ie})=>{re("mcc",ie,{shouldDirty:!0})},labelClassName:"mercoa-block mercoa-text-left mercoa-text-sm mercoa-font-medium mercoa-text-gray-700 -mercoa-mb-1"})}const websiteSchema={website:create$6().url("Website must be a valid URL").transform(W=>W&&!W.startsWith("http://")&&!W.startsWith("https://")?`https://${W}`:W).required("Website is required")};function WebsiteBlock({register:W,errors:re,readOnly:oe,required:ie}){return jsxRuntimeExports.jsx(MercoaInput,{label:"Website",register:W,name:"website",errors:re,readOnly:oe,required:ie})}const descriptionSchema={description:create$6().required("Description is required")};function DescriptionBlock({register:W,errors:re,readOnly:oe,required:ie}){return jsxRuntimeExports.jsx(MercoaInput,{label:"Business Description",register:W,name:"description",errors:re,readOnly:oe,required:ie})}const formationDateSchema={formationDate:create$4().required("Formation date is required")};function FormationDateBlock({control:W,errors:re,readOnly:oe,required:ie}){return jsxRuntimeExports.jsx(MercoaInput,{type:"date",label:"Business Formation Date",name:"formationDate",errors:re,readOnly:oe,required:ie,control:W})}async function createOrUpdateEntity({entityId:W,onClose:re,data:oe,isPayee:ie,isPayor:pe,mercoaClient:nr}){const or={};oe.accountType==="individual"?or.individual={email:oe.email,...oe.phoneNumber&&{phone:{number:oe.phoneNumber,countryCode:"1"}},...oe.taxID&&oe.taxID!="****"&&{governmentId:{ssn:oe.taxID}},name:{firstName:oe.firstName??"",lastName:oe.lastName??"",middleName:oe.middleName??"",suffix:oe.suffix??""},...oe.dob&&{birthDate:{day:dayjs$1(oe.dob).format("D"),month:dayjs$1(oe.dob).format("M"),year:dayjs$1(oe.dob).format("YYYY")}},...oe.addressLine1&&oe.city&&oe.stateOrProvince&&oe.postalCode&&{address:{addressLine1:oe.addressLine1,addressLine2:oe.addressLine2,postalCode:oe.postalCode,stateOrProvince:oe.stateOrProvince,city:oe.city,country:"US"}}}:or.business={email:oe.email,...oe.phoneNumber&&{phone:{number:oe.phoneNumber,countryCode:"1"}},businessType:oe.businessType??"llc",legalBusinessName:oe.legalBusinessName,doingBusinessAs:oe.doingBusinessAs,website:oe.website,description:oe.description,formationDate:oe.formationDate?dayjs$1(oe.formationDate).toDate():void 0,...oe.taxID&&oe.taxID!="**-*******"&&{taxId:{ein:{number:oe.taxID}}},...oe.mcc&&{industryCodes:{mcc:oe.mcc}},...oe.addressLine1&&oe.city&&oe.stateOrProvince&&oe.postalCode&&{address:{addressLine1:oe.addressLine1,addressLine2:oe.addressLine2,postalCode:oe.postalCode,stateOrProvince:oe.stateOrProvince,city:oe.city,country:"US"}}};const ar={isCustomer:!0,accountType:oe.accountType,profile:or,isPayee:ie,isPayor:pe,foreignId:oe.foreignId,emailTo:oe.emailTo};let ir;try{W?ir=await(nr==null?void 0:nr.entity.update(W,ar)):ir=await(nr==null?void 0:nr.entity.create(ar)),re&&re(ir)}catch(sr){Q$1.error(`There was an error saving your data.
69
69
  Error: ${sr.body}`),console.error(sr)}return ir}function EntityOnboardingButton({className:W,buttonText:re,title:oe,onClose:ie,isPayee:pe,isPayor:nr}){const[or,ar]=React.useState(!1),ir=useMercoaSession(),{register:sr,handleSubmit:cr,watch:lr,formState:ur,reset:fr}=useForm({defaultValues:{accountType:javascript.Mercoa.AccountType.Business,legalBusinessName:"",email:"",firstName:"",lastName:""},resolver:async(mr,pr,hr)=>mr.accountType===javascript.Mercoa.AccountType.Business?await o(create$3({...accountTypeSchema,...legalBusinessNameSchema,...emailSchema}))(mr,pr,hr):await o(create$3({...accountTypeSchema,...nameBlockSchema,...emailSchema}))(mr,pr,hr)}),dr=lr("accountType");return ir.client?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("button",{onClick:()=>{ar(!0)},className:W||"mercoa-inline-flex mercoa-items-center mercoa-justify-center mercoa-rounded-mercoa mercoa-border mercoa-border-transparent mercoa-bg-mercoa-primary mercoa-px-4 mercoa-py-2 mercoa-text-sm mercoa-font-medium mercoa-text-white mercoa-shadow-sm hover:mercoa-bg-mercoa-primary-dark focus:mercoa-outline-none focus:mercoa-ring-2 focus:mercoa-ring-mercoa-primary focus:mercoa-ring-offset-2 sm:mercoa-w-auto",children:re||"Get Started"}),jsxRuntimeExports.jsx(qe$1.Root,{show:or,as:React.Fragment,children:jsxRuntimeExports.jsxs(_t$1,{as:"div",className:"mercoa-relative mercoa-z-10",onClose:ar,children:[jsxRuntimeExports.jsx(qe$1.Child,{as:React.Fragment,enter:"mercoa-ease-out mercoa-duration-300",enterFrom:"mercoa-opacity-0",enterTo:"mercoa-opacity-100",leave:"mercoa-ease-in mercoa-duration-200",leaveFrom:"mercoa-opacity-100",leaveTo:"mercoa-opacity-0",children:jsxRuntimeExports.jsx("div",{className:"mercoa-fixed mercoa-inset-0 mercoa-bg-gray-500 mercoa-bg-mercoa-opacity-75 mercoa-transition-opacity"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-fixed mercoa-inset-0 mercoa-z-10 mercoa-overflow-y-auto",children:jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-min-h-full mercoa-items-end mercoa-justify-center mercoa-p-4 mercoa-text-center sm:mercoa-items-center sm:mercoa-p-0",children:jsxRuntimeExports.jsx(qe$1.Child,{as:React.Fragment,enter:"mercoa-ease-out mercoa-duration-300",enterFrom:"mercoa-opacity-0 mercoa-translate-y-4 sm:mercoa-translate-y-0 sm:mercoa-scale-95",enterTo:"mercoa-opacity-100 mercoa-translate-y-0 sm:mercoa-scale-100",leave:"mercoa-ease-in mercoa-duration-200",leaveFrom:"mercoa-opacity-100 mercoa-translate-y-0 sm:mercoa-scale-100",leaveTo:"mercoa-opacity-0 mercoa-translate-y-4 sm:mercoa-translate-y-0 sm:mercoa-scale-95",children:jsxRuntimeExports.jsx(_t$1.Panel,{className:"mercoa-relative mercoa-transform mercoa-rounded-mercoa mercoa-bg-white mercoa-px-4 mercoa-pt-5 mercoa-pb-4 mercoa-text-left mercoa-shadow-xl mercoa-transition-all sm:mercoa-my-8 sm:mercoa-w-full sm:mercoa-max-w-sm sm:mercoa-p-6",children:jsxRuntimeExports.jsxs("form",{onSubmit:cr(async mr=>{ir.client&&await createOrUpdateEntity({data:mr,onClose:pr=>{fr(),ar(!1),ie&&ie(pr)},isPayee:pe,isPayor:nr,mercoaClient:ir.client})}),children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(AccountTypeSelectBlock,{register:sr,errors:ur.errors}),dr===javascript.Mercoa.AccountType.Business?jsxRuntimeExports.jsx(LegalBusinessNameBlock,{register:sr,errors:ur.errors}):jsxRuntimeExports.jsx(NameBlock,{register:sr,errors:ur.errors}),jsxRuntimeExports.jsx(EmailBlock,{register:sr,errors:ur.errors})]}),jsxRuntimeExports.jsx("div",{className:"mercoa-mt-4",children:jsxRuntimeExports.jsx("button",{type:"submit",className:"mercoa-w-full mercoa-inline-flex mercoa-justify-center mercoa-rounded-mercoa mercoa-border mercoa-border-transparent mercoa-bg-mercoa-primary mercoa-px-4 mercoa-py-2 mercoa-text-sm mercoa-font-medium mercoa-text-white mercoa-shadow-sm hover:mercoa-bg-mercoa-primary-dark focus:mercoa-outline-none focus:mercoa-ring-2 focus:mercoa-ring-mercoa-primary focus:mercoa-ring-offset-2 sm:mercoa-w-auto",children:"Continue"})})]})})})})})]})})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"EntityOnboardingButton"})}function RepresentativeOnboardingForm({entityId:W,title:re,onClose:oe}){const ie=useMercoaSession(),pe=create$3({email:create$6().email("Email is not valid").required("Email is required"),...phoneSchema,...addressBlockSchema,...nameBlockSchema,...dateOfBirthSchema,...SSNSchema,jobTitle:create$6().required("Job title is required"),ownershipPercentage:create$5().typeError("Ownership percentage is required").min(0,"Ownership percentage must be greater than 0").max(100,"Ownership percentage must be less than 100").required("Ownership percentage is required"),isController:create$7().required()}).required(),{control:nr,register:or,handleSubmit:ar,setValue:ir,trigger:sr,watch:cr,formState:{errors:lr,isValid:ur}}=useForm({mode:"onChange",resolver:o(pe)});async function fr(dr){var pr;const mr={email:dr.email,phone:{number:dr.phoneNumber,countryCode:"1"},name:{firstName:dr.firstName,lastName:dr.lastName,middleName:dr.middleName,suffix:dr.suffix},birthDate:{day:dayjs$1(dr.dob).format("D"),month:dayjs$1(dr.dob).format("M"),year:dayjs$1(dr.dob).format("YYYY")},address:{addressLine1:dr.addressLine1,addressLine2:dr.addressLine2,postalCode:dr.postalCode,stateOrProvince:dr.stateOrProvince,city:dr.city,country:"US"},governmentId:{ssn:dr.taxID},responsibilities:{isController:dr.isController,isOwner:dr.ownershipPercentage>=25,ownershipPercentage:Number(dr.ownershipPercentage),jobTitle:dr.jobTitle}};try{await((pr=ie.client)==null?void 0:pr.entity.representative.create(W,mr)),await ie.refresh(),oe&&oe(dr)}catch(hr){console.error(hr),Q$1.error("There was an issue creating this representative. Please check your information and try again.")}}return ie.client?jsxRuntimeExports.jsxs("form",{onSubmit:ar(fr),children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-1",children:[jsxRuntimeExports.jsxs("div",{className:"mercoa-flex",children:[jsxRuntimeExports.jsx("div",{className:"mercoa-flex-1"}),jsxRuntimeExports.jsxs("h3",{className:"mercoa-text-lg mercoa-font-medium mercoa-leading-6 mercoa-text-gray-900",children:[jsxRuntimeExports.jsx("button",{}),re||"Create Account"]}),jsxRuntimeExports.jsx("div",{className:"mercoa-flex-1"}),jsxRuntimeExports.jsx(ForwardRef$1,{className:"mercoa-size-5 mercoa-cursor-pointer mercoa-rounded-mercoa mercoa-p-0.5 hover:mercoa-bg-gray-100",type:"button",onClick:()=>{oe&&oe()}})]}),jsxRuntimeExports.jsxs("div",{className:"mercoa-grid mercoa-grid-cols-2 mercoa-gap-3",children:[jsxRuntimeExports.jsx("div",{className:"mercoa-col-span-2",children:jsxRuntimeExports.jsx(NameBlock,{register:or,errors:lr})}),jsxRuntimeExports.jsx(EmailBlock,{register:or,errors:lr}),jsxRuntimeExports.jsx(PhoneBlock,{control:nr,errors:lr}),jsxRuntimeExports.jsx(DateOfBirthBlock,{control:nr,errors:lr}),jsxRuntimeExports.jsx(SSNBlock,{control:nr,errors:lr}),jsxRuntimeExports.jsx(MercoaInput,{label:"Job Title",register:or,name:"jobTitle",errors:lr}),jsxRuntimeExports.jsx(MercoaInput,{label:"Percent Ownership",register:or,name:"ownershipPercentage",errors:lr,type:"number",min:0,max:100,placeholder:"0-100"}),jsxRuntimeExports.jsx("div",{className:"mercoa-col-span-2",children:jsxRuntimeExports.jsx(AddressBlock,{register:or,errors:lr,setValue:ir,trigger:sr,watch:cr,label:"Residential Address"})}),jsxRuntimeExports.jsxs("div",{className:"mercoa-relative mercoa-mt-2 mercoa-flex mercoa-items-start mercoa-items-center mercoa-col-span-2",children:[jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-h-5 mercoa-items-center",children:jsxRuntimeExports.jsx("input",{...or("isController"),type:"checkbox",className:"mercoa-size-4 mercoa-rounded mercoa-border-gray-300 mercoa-text-mercoa-primary-text focus:mercoa-ring-mercoa-primary"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-ml-3 mercoa-text-sm",children:jsxRuntimeExports.jsx(Tooltip,{title:"Every business requires a controller. Examples include the CEO, COO, Treasurer, President, Vice President, or Managing Partner.",children:jsxRuntimeExports.jsxs("label",{htmlFor:"isController",className:"mercoa-font-medium mercoa-text-gray-700",children:["This person is a company controller"," ",jsxRuntimeExports.jsx(ForwardRef$n,{className:"mercoa-inline mercoa-size-5"})]})})})]})]})]})}),jsxRuntimeExports.jsx("div",{className:"mercoa-mt-5 sm:mercoa-mt-6",children:jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!0,className:"mercoa-w-full",children:"Add Representative"})})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"RepresentativeOnboardingForm"})}function Representatives({children:W,onSelect:re,showAdd:oe,showEdit:ie}){var cr;const[pe,nr]=React.useState(),[or,ar]=React.useState(!1),ir=useMercoaSession();React.useEffect(()=>{var lr,ur;ir.token&&((lr=ir.entity)!=null&&lr.id)&&((ur=ir.client)==null||ur.entity.representative.getAll(ir.entity.id).then(fr=>{nr(fr)}))},[ir.entity,ir.token,or,ir.refreshId]);const sr=()=>{ar(!1)};return ir.client?W?W({representatives:pe}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[pe&&pe.map(lr=>jsxRuntimeExports.jsx("div",{className:"mercoa-mt-2",children:jsxRuntimeExports.jsx(RepresentativeComponent,{representative:lr,onSelect:re,showEdit:ie})},lr.id)),oe&&jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-2",children:[jsxRuntimeExports.jsx(AddDialog,{show:or,onClose:sr,component:jsxRuntimeExports.jsx(RepresentativeOnboardingForm,{title:"Create Representative",onClose:sr,entityId:((cr=ir.entity)==null?void 0:cr.id)??""})}),jsxRuntimeExports.jsx(RepresentativeComponent,{onSelect:()=>ar(!0)})]}),jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-items-center mercoa-space-x-3 mercoa-mt-5",children:pe!=null&&pe.some(lr=>lr.responsibilities.isController)?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ForwardRef$G,{className:"mercoa-size-5 mercoa-text-green-400"}),jsxRuntimeExports.jsx("p",{className:"mercoa-font-gray-700 mercoa-text-sm",children:"At least one controller is added"})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ForwardRef$2,{className:"mercoa-size-5 mercoa-text-red-400"}),jsxRuntimeExports.jsx("p",{className:"mercoa-font-gray-700 mercoa-text-sm",children:"At least one controller needs to be added"})]})}),jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-items-center mercoa-space-x-3",children:pe&&(pe==null?void 0:pe.length)>0?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ForwardRef$G,{className:"mercoa-size-5 mercoa-text-green-400"}),jsxRuntimeExports.jsx("p",{className:"mercoa-font-gray-700 mercoa-text-sm",children:"At least one representative is added"})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ForwardRef$2,{className:"mercoa-size-5 mercoa-text-red-400"}),jsxRuntimeExports.jsx("p",{className:"mercoa-font-gray-700 mercoa-text-sm",children:"At least one representative needs to be added"})]})})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"Representatives"})}function RepresentativeComponent({children:W,representative:re,onSelect:oe,showEdit:ie,selected:pe}){var ar,ir,sr;const nr=useMercoaSession();async function or(){var cr,lr,ur;if(nr.token){if(!((cr=nr.entity)!=null&&cr.id)){Q$1.error("Entity not found");return}await((ur=(lr=nr.client)==null?void 0:lr.entity.representative)==null?void 0:ur.delete(nr.entity.id,(re==null?void 0:re.id)??"")),await nr.refresh()}}return nr.client?re?jsxRuntimeExports.jsxs("div",{onClick:()=>{oe&&oe(re)},className:`mercoa-relative mercoa-flex mercoa-items-center mercoa-space-x-3 mercoa-rounded-mercoa mercoa-border ${pe?"mercoa-border-mercoa-primary":"mercoa-border-gray-300"} mercoa-bg-white mercoa-px-6 mercoa-py-5 mercoa-shadow-sm focus-within:mercoa-ring-2 focus-within:mercoa-ring-mercoa-primary focus-within:mercoa-ring-offset-2 ${oe?"mercoa-cursor-pointer hover:mercoa-border-gray-400":""}`,children:[jsxRuntimeExports.jsx("div",{className:`mercoa-flex-shrink-0 mercoa-rounded-full mercoa-p-1 ${pe?"mercoa-text-mercoa-primary-text-invert mercoa-bg-mercoa-primary-light":"mercoa-bg-gray-200 mercoa-text-gray-600"}`,children:jsxRuntimeExports.jsx(ForwardRef$4,{className:"mercoa-size-5"})}),jsxRuntimeExports.jsxs("div",{className:"mercoa-min-w-0 mercoa-flex-1",children:[!ie&&jsxRuntimeExports.jsx("span",{className:"mercoa-absolute mercoa-inset-0","aria-hidden":"true"}),jsxRuntimeExports.jsxs("p",{className:`mercoa-text-sm mercoa-font-medium mercoa-text-gray-900 ${pe?"mercoa-underline":""}`,children:[re.name.firstName," ",re.name.lastName," - ",(ar=re.responsibilities)==null?void 0:ar.jobTitle]}),jsxRuntimeExports.jsxs("p",{className:`mercoa-text-xs mercoa-font-medium mercoa-text-gray-900 ${pe?"mercoa-underline":""}`,children:["Ownership: ",(ir=re.responsibilities)==null?void 0:ir.ownershipPercentage,"%"]}),((sr=re.responsibilities)==null?void 0:sr.isController)&&jsxRuntimeExports.jsx("p",{className:`mercoa-text-xs mercoa-font-medium mercoa-text-gray-900 ${pe?"mercoa-underline":""}`,children:"Controller"})]}),ie&&jsxRuntimeExports.jsx("div",{className:"mercoa-flex-shrink-0",children:jsxRuntimeExports.jsxs("button",{className:"mercoa-ml-1 mercoa-cursor-pointer hover:mercoa-text-red-300",onClick:()=>or(),children:[" ",jsxRuntimeExports.jsx(ForwardRef$6,{className:"mercoa-size-5"})]})})]},re==null?void 0:re.id):jsxRuntimeExports.jsxs("div",{onClick:()=>{oe&&oe(re)},className:`mercoa-relative mercoa-flex mercoa-items-center mercoa-space-x-3 mercoa-rounded-mercoa mercoa-border mercoa-border-gray-300 mercoa-bg-white mercoa-px-6 mercoa-py-5 mercoa-shadow-sm focus-within:mercoa-ring-2 focus-within:mercoa-ring-mercoa-primary focus-within:mercoa-ring-offset-2 hover:mercoa-border-gray-400 ${oe?"mercoa-cursor-pointer ":""}`,children:[jsxRuntimeExports.jsx("div",{className:`mercoa-flex-shrink-0 mercoa-rounded-full mercoa-p-1 ${pe?"mercoa-text-mercoa-primary-text-invert mercoa-bg-mercoa-primary-light":"mercoa-bg-gray-200 mercoa-text-gray-600"}`,children:jsxRuntimeExports.jsx(ForwardRef$d,{className:"mercoa-size-5"})}),jsxRuntimeExports.jsxs("div",{className:"mercoa-min-w-0 mercoa-flex-1",children:[jsxRuntimeExports.jsx("span",{className:"mercoa-absolute mercoa-inset-0","aria-hidden":"true"}),jsxRuntimeExports.jsx("p",{className:"mercoa-text-sm mercoa-font-medium mercoa-text-gray-900",children:"Add new representative"}),jsxRuntimeExports.jsx("p",{className:"mercoa-truncate mercoa-text-sm mercoa-text-gray-500"})]})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"RepresentativeComponent"})}function VerifyOwnersButton({entity:W}){var nr,or;const re=useMercoaSession(),[oe,ie]=React.useState();React.useEffect(()=>{var ar,ir;re.token&&((ar=re.entity)!=null&&ar.id)&&((ir=re.client)==null||ir.entity.representative.getAll(re.entity.id).then(sr=>{ie(sr)}))},[re.entity,re.token,re.refreshId]);const pe=oe==null?void 0:oe.some(ar=>ar.responsibilities.isController);return re.client?!W||(or=(nr=W.profile)==null?void 0:nr.business)!=null&&or.ownersProvided?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{}):jsxRuntimeExports.jsx(MercoaButton,{onClick:async()=>{var ar;W.accountType==="business"?(await((ar=re.client)==null?void 0:ar.entity.initiateKyb(W.id)),Q$1.success("Verification Started")):W.accountType==="individual"&&Q$1.error("not implemented yet!"),await re.refresh()},disabled:!pe,tooltip:pe?void 0:"Please add at least one representative who is a controller",isEmphasized:!0,className:"mercoa-mt-2",children:"Verify Account"}):jsxRuntimeExports.jsx(NoSession,{componentName:"VerifyOwnersButton"})}function AcceptToSButton({className:W,buttonText:re,title:oe,onClose:ie,entity:pe}){const[nr,or]=React.useState(!1);function ar(){or(!1),ie&&ie()}return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(MercoaButton,{onClick:()=>{or(!0)},isEmphasized:!0,size:"md",children:re||"Terms of Service"}),jsxRuntimeExports.jsx(qe$1.Root,{show:nr,as:React.Fragment,children:jsxRuntimeExports.jsxs(_t$1,{as:"div",className:"mercoa-relative mercoa-z-10",onClose:ar,children:[jsxRuntimeExports.jsx(qe$1.Child,{as:React.Fragment,enter:"mercoa-ease-out mercoa-duration-300",enterFrom:"mercoa-opacity-0",enterTo:"mercoa-opacity-100",leave:"mercoa-ease-in mercoa-duration-200",leaveFrom:"mercoa-opacity-100",leaveTo:"mercoa-opacity-0",children:jsxRuntimeExports.jsx("div",{className:"mercoa-fixed mercoa-inset-0 mercoa-bg-gray-500 mercoa-bg-mercoa-opacity-75 mercoa-transition-opacity"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-fixed mercoa-inset-0 mercoa-z-10 mercoa-overflow-y-auto",children:jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-min-h-full mercoa-items-end mercoa-justify-center mercoa-p-4 mercoa-text-center sm:mercoa-items-center sm:mercoa-p-0",children:jsxRuntimeExports.jsx(qe$1.Child,{as:React.Fragment,enter:"mercoa-ease-out mercoa-duration-300",enterFrom:"mercoa-opacity-0 mercoa-translate-y-4 sm:mercoa-translate-y-0 sm:mercoa-scale-95",enterTo:"mercoa-opacity-100 mercoa-translate-y-0 sm:mercoa-scale-100",leave:"mercoa-ease-in mercoa-duration-200",leaveFrom:"mercoa-opacity-100 mercoa-translate-y-0 sm:mercoa-scale-100",leaveTo:"mercoa-opacity-0 mercoa-translate-y-4 sm:mercoa-translate-y-0 sm:mercoa-scale-95",children:jsxRuntimeExports.jsxs(_t$1.Panel,{className:"mercoa-relative mercoa-transform mercoa-rounded-mercoa mercoa-bg-white mercoa-px-4 mercoa-pt-5 mercoa-pb-4 mercoa-text-left mercoa-shadow-xl mercoa-transition-all sm:mercoa-my-8 sm:mercoa-w-full sm:mercoa-max-w-md sm:mercoa-p-6",children:[jsxRuntimeExports.jsx(_t$1.Title,{className:"mercoa-mb-3 mercoa-w-full mercoa-text-center mercoa-text-xl mercoa-text-gray-800 mercoa-underline",children:oe||"Terms of Service"}),jsxRuntimeExports.jsx(AcceptTosForm,{entity:pe,onComplete:async()=>{}})]})})})})]})})]})}function AcceptTosForm({entity:W,onComplete:re}){var ar;const oe=useMercoaSession(),{register:ie,watch:pe,handleSubmit:nr}=useForm(),or=pe();return oe.client?jsxRuntimeExports.jsxs("form",{onSubmit:nr(async()=>{var ir;if(!W.id){Q$1.error("Entity not found");return}await((ir=oe.client)==null?void 0:ir.entity.acceptTermsOfService(W.id)),re&&await re()}),children:[jsxRuntimeExports.jsxs("div",{className:"mercoa-mb-10 mercoa-text-sm",children:[jsxRuntimeExports.jsx("b",{children:capitalize((ar=oe.organization)==null?void 0:ar.name)})," has partnered with"," ",jsxRuntimeExports.jsx("a",{href:"https://mercoa.com",target:"_blank",rel:"noreferrer",className:"mercoa-text-blue-500 mercoa-underline",children:"Mercoa"})," ","to provide financial services.",jsxRuntimeExports.jsx("br",{}),jsxRuntimeExports.jsx("br",{}),"By clicking the button below, you agree to the"," ",jsxRuntimeExports.jsx("a",{href:"https://mercoa.com/legal/platform-agreement/",target:"_blank",rel:"noreferrer",className:"mercoa-text-blue-500 mercoa-underline",children:"Mercoa Platform Agreement"})," ","and"," ",jsxRuntimeExports.jsx("a",{href:"https://mercoa.com/legal/privacy-policy/",target:"_blank",rel:"noreferrer",className:"mercoa-text-blue-500 mercoa-underline",children:"Privacy Policy"}),"."]}),jsxRuntimeExports.jsxs("div",{className:"mercoa-relative mercoa-mt-2 mercoa-flex mercoa-items-start mercoa-items-center",children:[jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-h-5 mercoa-items-center",children:jsxRuntimeExports.jsx("input",{...ie("mercoa"),type:"checkbox",className:"mercoa-size-4 mercoa-rounded mercoa-border-gray-300 mercoa-text-mercoa-primary-text focus:mercoa-ring-mercoa-primary"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-ml-3 mercoa-text-sm",children:jsxRuntimeExports.jsxs("label",{htmlFor:"isController",className:"mercoa-font-medium mercoa-text-gray-700",children:["I have read and accept the"," ",jsxRuntimeExports.jsxs("a",{href:"https://mercoa.com/legal/platform-agreement/",target:"_blank",rel:"noreferrer",className:"mercoa-text-blue-500 mercoa-underline",children:[" ","Mercoa terms of service"]})]})})]}),jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!0,disabled:!or.mercoa,className:"mercoa-mt-5",size:"md",children:"Confirm"})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"AcceptTosForm"})}function EntityOnboardingForm({entity:W,type:re,onOnboardingSubmit:oe,onCancel:ie,admin:pe}){var mr,pr,hr,yr,gr,wr,br,_r,Mr,$r,vr,Or,Sr,Cr,Ir,Dr,qr,Zr,Yr,en,Jr,kr,on,Xr,Br,xr,Rr,jr,Er,Pr,zr,Hr,Ur,Kr,an,bn,_n,wn,En,cn,fn,vn,Sn;const nr=useMercoaSession(),{register:or,handleSubmit:ar,setValue:ir,trigger:sr,control:cr,watch:lr,formState:{errors:ur}}=useForm({defaultValues:{accountType:W.accountType,email:W.email,firstName:((mr=W.profile.individual)==null?void 0:mr.name.firstName)??"",middleName:(pr=W.profile.individual)==null?void 0:pr.name.middleName,lastName:((hr=W.profile.individual)==null?void 0:hr.name.lastName)??"",suffix:(yr=W.profile.individual)==null?void 0:yr.name.suffix,phoneNumber:formatPhoneNumber(((wr=(gr=W.profile.individual)==null?void 0:gr.phone)==null?void 0:wr.number)??((_r=(br=W.profile.business)==null?void 0:br.phone)==null?void 0:_r.number)),addressLine1:(($r=(Mr=W.profile.individual)==null?void 0:Mr.address)==null?void 0:$r.addressLine1)??((Or=(vr=W.profile.business)==null?void 0:vr.address)==null?void 0:Or.addressLine1),addressLine2:((Cr=(Sr=W.profile.individual)==null?void 0:Sr.address)==null?void 0:Cr.addressLine2)??((Dr=(Ir=W.profile.business)==null?void 0:Ir.address)==null?void 0:Dr.addressLine2),city:((Zr=(qr=W.profile.individual)==null?void 0:qr.address)==null?void 0:Zr.city)??((en=(Yr=W.profile.business)==null?void 0:Yr.address)==null?void 0:en.city),stateOrProvince:((kr=(Jr=W.profile.individual)==null?void 0:Jr.address)==null?void 0:kr.stateOrProvince)??((Xr=(on=W.profile.business)==null?void 0:on.address)==null?void 0:Xr.stateOrProvince),postalCode:((xr=(Br=W.profile.individual)==null?void 0:Br.address)==null?void 0:xr.postalCode)??((jr=(Rr=W.profile.business)==null?void 0:Rr.address)==null?void 0:jr.postalCode),country:((Pr=(Er=W.profile.individual)==null?void 0:Er.address)==null?void 0:Pr.country)??((Hr=(zr=W.profile.business)==null?void 0:zr.address)==null?void 0:Hr.country)??"US",taxID:(Ur=W.profile.individual)!=null&&Ur.governmentIdProvided?"****":(Kr=W.profile.business)!=null&&Kr.taxIdProvided?"**-*******":"",mcc:((bn=(an=W.profile.business)==null?void 0:an.industryCodes)==null?void 0:bn.mcc)??"",dob:new Date,legalBusinessName:((_n=W.profile.business)==null?void 0:_n.legalBusinessName)??"",doingBusinessAs:(wn=W.profile.business)==null?void 0:wn.doingBusinessAs,description:(En=W.profile.business)==null?void 0:En.description,website:(cn=W.profile.business)==null?void 0:cn.website,formationDate:new Date,foreignId:W.foreignId,emailTo:W.emailTo,isCustomer:W.isCustomer,isPayor:W.isPayor,isPayee:W.isPayee},resolver:async(yn,ln,Ar)=>yn.accountType===javascript.Mercoa.AccountType.Individual?o(create$3({...(dr==null?void 0:dr.individual.name.required)&&nameBlockSchema,...(dr==null?void 0:dr.individual.email.required)&&emailSchema,...(dr==null?void 0:dr.individual.phone.required)&&phoneSchema,...(dr==null?void 0:dr.individual.dateOfBirth.required)&&dateOfBirthSchema,...(dr==null?void 0:dr.individual.address.required)&&addressBlockSchema,...(dr==null?void 0:dr.individual.ssn.required)&&SSNSchema}).required())(yn,ln,Ar):o(create$3({...(dr==null?void 0:dr.business.name.required)&&legalBusinessNameSchema,...(dr==null?void 0:dr.business.email.required)&&emailSchema,...(dr==null?void 0:dr.business.phone.required)&&phoneSchema,...(dr==null?void 0:dr.business.website.required)&&websiteSchema,...(dr==null?void 0:dr.business.address.required)&&addressBlockSchema,...(dr==null?void 0:dr.business.ein.required)&&einSchema,...(dr==null?void 0:dr.business.mcc.required)&&mccSchema,...(dr==null?void 0:dr.business.formationDate.required)&&formationDateSchema,...(dr==null?void 0:dr.business.description.required)&&descriptionSchema}).required())(yn,ln,Ar)}),fr=lr("accountType");if(!nr.client)return jsxRuntimeExports.jsx(NoSession,{componentName:"EntityOnboardingForm"});if(!nr.organization)return jsxRuntimeExports.jsx(LoadingSpinner,{});const dr=re==="payee"?(fn=nr.organization)==null?void 0:fn.payeeOnboardingOptions:(vn=nr.organization)==null?void 0:vn.payorOnboardingOptions;return pe&&dr&&(Object.keys(dr.individual).forEach(yn=>{dr.individual[yn].show=!0,dr.individual[yn].edit=!0,dr.individual[yn].required=!1}),Object.keys(dr.business).forEach(yn=>{dr.business[yn].show=!0,dr.business[yn].edit=!0,dr.business[yn].required=!1}),dr.paymentMethod=!1),jsxRuntimeExports.jsxs("form",{onSubmit:ar(async yn=>{W&&yn&&nr.client&&(await createOrUpdateEntity({data:yn,entityId:W.id,mercoaClient:nr.client,isPayee:pe?yn.isPayee:re==="payee",isPayor:pe?yn.isPayor:re==="payor"}),pe&&Q$1.success("Entity Updated"),oe?oe(yn):await nr.refresh())}),children:[jsxRuntimeExports.jsxs("div",{className:"sm:mercoa-grid sm:mercoa-grid-cols-2 mercoa-gap-3",children:[(dr==null?void 0:dr.enableBusiness)&&(dr==null?void 0:dr.enableIndividual)&&jsxRuntimeExports.jsx("div",{className:"mercoa-col-span-2",children:jsxRuntimeExports.jsx(AccountTypeSelectBlock,{register:or,errors:ur})}),fr==="individual"&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[(dr==null?void 0:dr.individual.email.show)&&jsxRuntimeExports.jsx("div",{className:"mercoa-col-span-2",children:jsxRuntimeExports.jsx(EmailBlock,{register:or,errors:ur,readOnly:!dr.individual.email.edit,required:dr.individual.email.required})}),(dr==null?void 0:dr.individual.name.show)&&jsxRuntimeExports.jsx("div",{className:"mercoa-col-span-2",children:jsxRuntimeExports.jsx(NameBlock,{register:or,errors:ur,readOnly:!dr.individual.name.edit,required:dr.individual.name.required})}),(dr==null?void 0:dr.individual.phone.show)&&jsxRuntimeExports.jsx(PhoneBlock,{control:cr,errors:ur,readOnly:!dr.individual.phone.edit,required:dr.individual.phone.required}),(dr==null?void 0:dr.individual.dateOfBirth.show)&&jsxRuntimeExports.jsx(DateOfBirthBlock,{control:cr,errors:ur,readOnly:!dr.individual.dateOfBirth.edit,required:dr.individual.dateOfBirth.required}),(dr==null?void 0:dr.individual.address.show)&&jsxRuntimeExports.jsx("div",{className:"mercoa-col-span-2",children:jsxRuntimeExports.jsx(AddressBlock,{register:or,errors:ur,setValue:ir,trigger:sr,watch:lr,readOnly:!dr.individual.address.edit,required:dr.individual.address.required})}),(dr==null?void 0:dr.individual.ssn.show)&&jsxRuntimeExports.jsx(SSNBlock,{control:cr,errors:ur,readOnly:!dr.individual.ssn.edit,required:dr.individual.ssn.required})]}),fr==="business"&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[(dr==null?void 0:dr.business.name.show)&&jsxRuntimeExports.jsx(LegalBusinessNameBlock,{register:or,errors:ur,readOnly:!dr.business.name.edit,required:dr.business.name.required}),(dr==null?void 0:dr.business.doingBusinessAs.show)&&jsxRuntimeExports.jsx(DoingBusinessAsBlock,{register:or,errors:ur,readOnly:!dr.business.doingBusinessAs.edit,required:dr.business.doingBusinessAs.required}),(dr==null?void 0:dr.business.email.show)&&jsxRuntimeExports.jsx(EmailBlock,{register:or,errors:ur,readOnly:!dr.business.email.edit,required:dr.business.email.required}),(dr==null?void 0:dr.business.phone.show)&&jsxRuntimeExports.jsx(PhoneBlock,{control:cr,errors:ur,readOnly:!dr.business.phone.edit,required:dr.business.phone.required}),(dr==null?void 0:dr.business.website.show)&&jsxRuntimeExports.jsx(WebsiteBlock,{register:or,errors:ur,readOnly:!dr.business.website.edit,required:dr.business.website.required}),(dr==null?void 0:dr.business.address.show)&&jsxRuntimeExports.jsx("div",{className:"mercoa-col-span-2",children:jsxRuntimeExports.jsx(AddressBlock,{label:"Business Address",register:or,errors:ur,setValue:ir,trigger:sr,watch:lr,readOnly:!dr.business.address.edit,required:dr.business.address.required})}),(dr==null?void 0:dr.business.type.show)&&jsxRuntimeExports.jsx(BusinessTypeBlock,{register:or,errors:ur,readOnly:!dr.business.type.edit,required:dr.business.type.required}),(dr==null?void 0:dr.business.ein.show)&&jsxRuntimeExports.jsx(EINBlock,{control:cr,errors:ur,readOnly:!dr.business.ein.edit,required:dr.business.ein.required}),(dr==null?void 0:dr.business.mcc.show)&&jsxRuntimeExports.jsx(MCCBlock,{watch:lr,setValue:ir}),(dr==null?void 0:dr.business.formationDate.show)&&jsxRuntimeExports.jsx(FormationDateBlock,{control:cr,errors:ur,readOnly:!dr.business.formationDate.edit,required:dr.business.formationDate.required}),(dr==null?void 0:dr.business.description.show)&&jsxRuntimeExports.jsx("div",{className:"mercoa-col-span-2",children:jsxRuntimeExports.jsx(DescriptionBlock,{register:or,errors:ur,readOnly:!dr.business.description.edit,required:dr.business.description.required})})]}),pe&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("h3",{className:"mercoa-col-span-2 mercoa-text-lg mercoa-font-medium mercoa-text-gray-900 mercoa-my-2 mercoa-pt-3 mercoa-border-t-2",children:"Admin Options"}),jsxRuntimeExports.jsx(MercoaInput,{register:or,name:"emailTo",label:"Email Inbox Address",type:"text",trailingIcon:jsxRuntimeExports.jsxs("span",{className:"mercoa-px-2 mercoa-text-sm mercoa-text-gray-600",children:["@",(Sn=nr.organization.emailProvider)==null?void 0:Sn.inboxDomain]})}),jsxRuntimeExports.jsx(MercoaInput,{register:or,name:"foreignId",label:"Foreign ID",type:"text"}),jsxRuntimeExports.jsxs("div",{className:"mercoa-col-span-full mercoa-grid mercoa-grid-cols-3 mercoa-space-x-2",children:[jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-items-center mercoa-space-x-2 mercoa-rounded-mercoa mercoa-border mercoa-p-2",children:[jsxRuntimeExports.jsx("label",{htmlFor:"isCustomer",className:"mercoa-block mercoa-text-sm mercoa-font-medium mercoa-leading-6 mercoa-text-gray-900",children:"Customer"}),jsxRuntimeExports.jsx("input",{type:"checkbox",...or("isCustomer"),className:"mercoa-size-4 mercoa-rounded mercoa-border-gray-300 focus:mercoa-ring-mercoa-primary"})]}),jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-items-center mercoa-space-x-2 mercoa-rounded-mercoa mercoa-border mercoa-p-2",children:[jsxRuntimeExports.jsx("label",{htmlFor:"isPayor",className:"mercoa-block mercoa-text-sm mercoa-font-medium mercoa-leading-6 mercoa-text-gray-900",children:"Payor"}),jsxRuntimeExports.jsx("input",{type:"checkbox",...or("isPayor"),className:"mercoa-size-4 mercoa-rounded mercoa-border-gray-300 focus:mercoa-ring-mercoa-primary"})]}),jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-items-center mercoa-space-x-2 mercoa-rounded-mercoa mercoa-border mercoa-p-2",children:[jsxRuntimeExports.jsx("label",{htmlFor:"isPayee",className:"mercoa-block mercoa-text-sm mercoa-font-medium mercoa-leading-6 mercoa-text-gray-900",children:"Payee"}),jsxRuntimeExports.jsx("input",{type:"checkbox",...or("isPayee"),className:"mercoa-size-4 mercoa-rounded mercoa-border-gray-300 focus:mercoa-ring-mercoa-primary"})]})]})]})]}),jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-8 mercoa-flex",children:[jsxRuntimeExports.jsx("div",{className:"mercoa-flex-1"}),ie&&jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!1,color:"red",className:"mercoa-mr-2",type:"button",onClick:ie,children:"Cancel"}),jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!0,children:ie?"Update":pe?"Submit":"Next"})]})]})}function EntityCreation({organization:W,type:re,setEntityData:oe}){const ie=re==="payee"?W.payeeOnboardingOptions:W.payorOnboardingOptions,{register:pe,handleSubmit:nr,watch:or,formState:{errors:ar}}=useForm({defaultValues:{accountType:ie!=null&&ie.enableBusiness?javascript.Mercoa.AccountType.Business:javascript.Mercoa.AccountType.Individual,email:"",legalBusinessName:"",firstName:"",middleName:"",lastName:"",suffix:""}}),ir=or("accountType");return jsxRuntimeExports.jsxs("form",{onSubmit:nr(async sr=>{oe(sr)}),children:[jsxRuntimeExports.jsxs("div",{className:"mercoa-gap-3",children:[(ie==null?void 0:ie.enableBusiness)&&(ie==null?void 0:ie.enableIndividual)&&jsxRuntimeExports.jsx("div",{className:"mercoa-col-span-2",children:jsxRuntimeExports.jsx(AccountTypeSelectBlock,{register:pe,errors:ar})}),ir==="individual"&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[(ie==null?void 0:ie.individual.email.show)&&jsxRuntimeExports.jsx(EmailBlock,{register:pe,errors:ar,readOnly:!ie.individual.email.edit,required:ie.individual.email.required}),(ie==null?void 0:ie.individual.name.show)&&jsxRuntimeExports.jsx(NameBlock,{register:pe,errors:ar,readOnly:!ie.individual.name.edit,required:ie.individual.name.required})]}),ir==="business"&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[(ie==null?void 0:ie.business.name.show)&&jsxRuntimeExports.jsx(LegalBusinessNameBlock,{register:pe,errors:ar,readOnly:!ie.business.name.edit,required:ie.business.name.required}),(ie==null?void 0:ie.business.doingBusinessAs.show)&&jsxRuntimeExports.jsx(DoingBusinessAsBlock,{register:pe,errors:ar,readOnly:!ie.business.doingBusinessAs.edit,required:ie.business.doingBusinessAs.required}),(ie==null?void 0:ie.business.email.show)&&jsxRuntimeExports.jsx(EmailBlock,{register:pe,errors:ar,readOnly:!ie.business.email.edit,required:ie.business.email.required})]})]}),jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-8 mercoa-flex",children:[jsxRuntimeExports.jsx("div",{className:"mercoa-flex-1"}),jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!0,children:"Next"})]})]})}function entityDetailsForMercoaPaymentsCompleted(W){if(!W.profile)return!1;if(W.accountType==="business"){if(!W.profile.business||!W.profile.business.address||!W.profile.business.legalBusinessName||!W.profile.business.taxIdProvided||!W.profile.business.businessType||!(W.profile.business.description||W.profile.business.website))return!1}else if(W.accountType==="individual"&&(!W.profile.individual||!W.profile.individual.address||!W.profile.individual.name||!W.profile.individual.phone||!W.profile.individual.birthDateProvided||!W.profile.individual.governmentIdProvided))return!1;return!0}function EntityOnboarding({entityId:W,connectedEntityName:re,type:oe}){const[ie,pe]=React.useState(),[nr,or]=React.useState([]),[ar,ir]=React.useState(),[sr,cr]=React.useState("entity"),[lr,ur]=React.useState(!1),fr=useMercoaSession();React.useEffect(()=>{!fr.client||!W||fr.client.entity.get(W).then(hr=>{pe(hr)})},[fr.client,W,fr.refreshId]),React.useEffect(()=>{var yr,gr;if(!fr.organization||!fr.client||!ie)return;let hr=!1;(oe==="payee"&&((yr=fr.organization.payeeOnboardingOptions)!=null&&yr.business.representatives.show)||oe==="payor"&&((gr=fr.organization.payorOnboardingOptions)!=null&&gr.business.representatives.show))&&(hr=!0),hr&&fr.client.entity.representative.getAll(ie.id).then(wr=>{or(wr)})},[fr.organization,fr.client,ie,oe]),React.useEffect(()=>{var hr,yr,gr,wr;if(fr.organization&&fr.client&&ie){if(sr==="representatives"){if((ar==null?void 0:ar.accountType)==="individual"){cr("payments");return}if(oe==="payee"&&!((hr=fr.organization.payeeOnboardingOptions)!=null&&hr.business.representatives.show)){cr("payments");return}if(oe==="payor"&&!((yr=fr.organization.payorOnboardingOptions)!=null&&yr.business.representatives.show)){cr("payments");return}}if(sr==="payments"){if(oe==="payee"){if(!((gr=fr.organization.payeeOnboardingOptions)!=null&&gr.paymentMethod)){cr("tos");return}}else if(oe==="payor"&&!((wr=fr.organization.payorOnboardingOptions)!=null&&wr.paymentMethod)){cr("tos");return}}sr==="tos"&&!dr()&&mr()}},[fr.organization,fr.client,ie,ar,sr,oe]);function dr(){var hr,yr,gr,wr,br,_r,Mr,$r;if(ie!=null&&ie.acceptedTos)return!1;if(oe==="payee"){if((ie==null?void 0:ie.accountType)==="business"){if(!((yr=(hr=fr.organization)==null?void 0:hr.payeeOnboardingOptions)!=null&&yr.business.termsOfService.required))return!1}else if(!((wr=(gr=fr.organization)==null?void 0:gr.payeeOnboardingOptions)!=null&&wr.individual.termsOfService.required))return!1}if(oe==="payor"){if((ie==null?void 0:ie.accountType)==="business"){if(!((_r=(br=fr.organization)==null?void 0:br.payorOnboardingOptions)!=null&&_r.business.termsOfService.required))return!1}else if(!(($r=(Mr=fr.organization)==null?void 0:Mr.payorOnboardingOptions)!=null&&$r.individual.termsOfService.required))return!1}return!0}async function mr(hr){if(!ie||!ar||!fr.client)return;const yr=oe==="payee"||ie.isPayee,gr=oe==="payor"||ie.isPayor;await createOrUpdateEntity({data:ar,entityId:ie.id,mercoaClient:fr.client,isPayee:yr,isPayor:gr}),cr("complete")}if(lr||!ie||!fr.organization||!fr.client)return jsxRuntimeExports.jsx("div",{className:"mercoa-text-center mercoa-pt-20 mercoa-w-full",children:jsxRuntimeExports.jsx(LoadingSpinnerIcon,{})});const pr=jsxRuntimeExports.jsxs("div",{className:"mercoa-p-4 mercoa-text-sm mercoa-rounded-mercoa mercoa-bg-gray-100 mercoa-my-4 mercoa-grid mercoa-grid-cols-12 mercoa-gap-3 mercoa-items-center",children:[jsxRuntimeExports.jsx("div",{className:"mercoa-w-full mercoa-flex mercoa-justify-center",children:jsxRuntimeExports.jsx(ForwardRef$m,{className:"mercoa-w-[22px]"})}),jsxRuntimeExports.jsx("p",{className:"mercoa-col-span-11",children:"Your information is used for verification purposes and isn't used for third-party marketing. We take your privacy seriously."}),jsxRuntimeExports.jsx("div",{className:"mercoa-w-full mercoa-flex mercoa-justify-center",children:jsxRuntimeExports.jsx(ForwardRef$B,{className:"mercoa-w-[22px]"})}),jsxRuntimeExports.jsx("p",{className:"mercoa-col-span-11",style:{lineHeight:"48px"},children:"This process should take approximately 5 minutes to complete."})]});return fr.client?jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-flex-col mercoa-rounded-l-md mercoa-p-8 mercoa-text-center mercoa-text-gray-900 mercoa-shadow-sm mercoa-w-full",children:[jsxRuntimeExports.jsxs("div",{className:sr==="entity"?"":"mercoa-hidden",children:[oe==="payee"?jsxRuntimeExports.jsxs("div",{className:"mercoa-text-gray-800 mercoa-text-left",children:[jsxRuntimeExports.jsxs("p",{className:"mercoa-text-lg mercoa-font-normal mercoa-text-left",children:[re||"A customer"," has opted to pay you using"," ",fr.organization.name,". To receive payments from ",fr.organization.name,", you'll need to provide us with a few pieces of information."]}),pr]}):jsxRuntimeExports.jsxs("div",{className:"mercoa-text-gray-800 mercoa-text-left",children:[jsxRuntimeExports.jsxs("p",{className:"mercoa-text-lg mercoa-font-normal mercoa-text-left",children:["To pay bills and invoices with ",fr.organization.name,", you'll need to provide us with a few pieces of information."]}),pr]}),jsxRuntimeExports.jsx(EntityOnboardingForm,{entity:ie,type:oe,onOnboardingSubmit:hr=>{ir(hr),cr("representatives")}})]}),jsxRuntimeExports.jsxs("div",{className:sr==="representatives"?"mercoa-text-center mercoa-text-lg":"mercoa-hidden",children:[jsxRuntimeExports.jsxs("div",{className:"mercoa-text-left",children:[jsxRuntimeExports.jsx("h2",{className:"mercoa-font-gray-800 mercoa-text-xl mercoa-font-normal mercoa-text-center",children:"Representative Verification"}),jsxRuntimeExports.jsxs("div",{className:"mercoa-p-4 mercoa-text-sm mercoa-rounded-mercoa mercoa-bg-gray-100 mercoa-my-4 mercoa-grid mercoa-grid-cols-12 mercoa-gap-3 mercoa-items-center",children:[jsxRuntimeExports.jsx("div",{className:"mercoa-w-full mercoa-flex mercoa-justify-center",children:jsxRuntimeExports.jsx(ForwardRef$I,{className:"mercoa-w-[22px]"})}),jsxRuntimeExports.jsx("p",{className:"mercoa-col-span-11",children:'Banking regulations require that we perform a "Know Your Customer" (KYC) process to verify account identity before enabling the ability to pay bills or send invoices.'}),jsxRuntimeExports.jsx("div",{className:"mercoa-w-full mercoa-flex mercoa-justify-center",children:jsxRuntimeExports.jsx(ForwardRef$5,{className:"mercoa-w-[22px]"})}),jsxRuntimeExports.jsx("p",{className:"mercoa-col-span-11",children:"Individuals with significant ownership in the business (over 25%) must be added as representatives."}),jsxRuntimeExports.jsx("div",{className:"mercoa-w-full mercoa-flex mercoa-justify-center",children:jsxRuntimeExports.jsx(ForwardRef$u,{className:"mercoa-w-[22px]"})}),jsxRuntimeExports.jsx("p",{className:"mercoa-col-span-11",children:"At least one controller must be added as a representative. Examples include the CEO, COO, Treasurer, President, Vice President, or Managing Partner."})]})]})," ",jsxRuntimeExports.jsx("div",{className:"mercoa-mt-10",children:jsxRuntimeExports.jsx(Representatives,{showAdd:!0,showEdit:!0})}),jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-justify-between",children:[jsxRuntimeExports.jsx(MercoaButton,{className:"mercoa-mt-10",isEmphasized:!1,size:"md",onClick:()=>{cr("entity")},children:"Go Back"}),jsxRuntimeExports.jsx(MercoaButton,{className:"mercoa-mt-10 mercoa-ml-5",isEmphasized:!0,size:"md",disabled:!nr.find(hr=>hr.responsibilities.isController),onClick:()=>{cr("payments")},children:"Continue"})]})]}),sr==="payments"&&jsxRuntimeExports.jsx("div",{className:"mercoa-p-8 mercoa-text-center mercoa-text-lg",children:jsxRuntimeExports.jsx(DisbursementMethods,{type:oe==="payor"?"payment":"disbursement",entity:ie,onSelect:()=>{dr()?cr("tos"):cr("complete")},goToPreviousStep:async()=>{await fr.refresh(),cr("entity")}})}),jsxRuntimeExports.jsx("div",{className:sr==="tos"?"p-8 mercoa-text-center mercoa-text-lg":"mercoa-hidden",children:jsxRuntimeExports.jsx(AcceptTosForm,{entity:ie,onComplete:async()=>{var hr;if(ur(!0),ie.accountType==="business")try{await((hr=fr.client)==null?void 0:hr.entity.initiateKyb(ie.id))}catch(yr){console.error(yr)}await fr.refresh(),ur(!1),cr("complete")}})}),jsxRuntimeExports.jsxs("div",{className:sr==="complete"?"p-8 mercoa-text-center mercoa-text-lg":"mercoa-hidden",children:[jsxRuntimeExports.jsx("h1",{className:"mercoa-text-2xl mercoa-font-medium mercoa-text-gray-900",children:"Thank you!"}),jsxRuntimeExports.jsx("p",{className:"mercoa-text-gray-700",children:"Your information has been submitted."}),jsxRuntimeExports.jsx(MercoaButton,{className:"mercoa-mt-10",isEmphasized:!0,size:"md",onClick:async()=>{await fr.refresh(),cr("entity")},children:"Edit your information"})]})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"EntityOnboarding"})}function formatPhoneNumber(W){var re=(""+W).replace(/\D/g,""),oe=re.match(/^(\d{3})(\d{3})(\d{4})$/);return oe?"("+oe[1]+") "+oe[2]+"-"+oe[3]:W}class InvalidTokenError extends Error{}InvalidTokenError.prototype.name="InvalidTokenError";function b64DecodeUnicode(W){return decodeURIComponent(atob(W).replace(/(.)/g,(re,oe)=>{let ie=oe.charCodeAt(0).toString(16).toUpperCase();return ie.length<2&&(ie="0"+ie),"%"+ie}))}function base64UrlDecode(W){let re=W.replace(/-/g,"+").replace(/_/g,"/");switch(re.length%4){case 0:break;case 2:re+="==";break;case 3:re+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return b64DecodeUnicode(re)}catch{return atob(re)}}function jwtDecode(W,re){if(typeof W!="string")throw new InvalidTokenError("Invalid token specified: must be a string");re||(re={});const oe=re.header===!0?0:1,ie=W.split(".")[oe];if(typeof ie!="string")throw new InvalidTokenError(`Invalid token specified: missing part #${oe+1}`);let pe;try{pe=base64UrlDecode(ie)}catch(nr){throw new InvalidTokenError(`Invalid token specified: invalid base64 for part #${oe+1} (${nr.message})`)}try{return JSON.parse(pe)}catch(nr){throw new InvalidTokenError(`Invalid token specified: invalid json for part #${oe+1} (${nr.message})`)}}function EntityPortal({token:W}){var mr,pr,hr,yr,gr,wr,br,_r,Mr,$r,vr,Or,Sr,Cr,Ir,Dr,qr,Zr,Yr,en,Jr,kr;const re=useMercoaSession(),oe=typeof window<"u"?window.location.search:"",ie=new URLSearchParams(oe),pe=Object.fromEntries(ie.entries()),{invoiceId:nr}=pe,[or,ar]=React.useState("inbox"),[ir,sr]=React.useState(),cr=re.entity,lr=re.user,ur=re.organization;let fr;try{const{options:on}=jwtDecode(W);fr=on}catch(on){console.error(on)}async function dr(on){await re.getNewToken(),ar(on)}if(React.useEffect(()=>{re.setIframeOptions({options:fr})},[W]),React.useEffect(()=>{var on;nr&&((on=re.client)==null||on.invoice.get(nr).then(Xr=>{sr(Xr),dr("invoice")}))},[nr]),!re.client)return jsxRuntimeExports.jsx(NoSession,{componentName:"EntityPortal"});if(!cr||!re.organization)return jsxRuntimeExports.jsx(LoadingSpinner,{});if(cr&&((hr=(pr=(mr=re.iframeOptions)==null?void 0:mr.options)==null?void 0:pr.entity)!=null&&hr.enableMercoaPayments)&&cr.status!=javascript.Mercoa.EntityStatus.Verified){let on=jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{});return cr!=null&&cr.acceptedTos?entityDetailsForMercoaPaymentsCompleted(cr)?!((gr=(yr=cr==null?void 0:cr.profile)==null?void 0:yr.business)!=null&&gr.ownersProvided)&&cr.accountType==="business"?on=jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("p",{className:"mercoa-mb-5",children:[" ","Before you can pay bills, you must add business representatives and verify your account."]}),jsxRuntimeExports.jsx("div",{className:"mercoa-mt-8",children:jsxRuntimeExports.jsx(Representatives,{showEdit:!0,showAdd:!0})}),!((br=(wr=re.entity)==null?void 0:wr.profile.business)!=null&&br.ownersProvided)&&jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-8 mercoa-text-left",children:[jsxRuntimeExports.jsx("h2",{className:"mercoa-font-gray-800 mercoa-text-lg",children:"KYC Verification"}),jsxRuntimeExports.jsx("p",{className:"mercoa-font-gray-700 mercoa-mt-2 mercoa-text-sm",children:'Banking regulations require that we perform a "Know Your Customer" (KYC) process to verify account identity before enabling the ability to pay bills or send invoices.'}),jsxRuntimeExports.jsx("p",{className:"mercoa-font-gray-700 mercoa-mt-2 mercoa-text-sm",children:"Individuals with significant ownership in the business (over 25%) must be added as representatives."}),jsxRuntimeExports.jsx("p",{className:"mercoa-font-gray-700 mercoa-mt-2 mercoa-text-sm",children:"At least one controller must be added as a representative. Examples include the CEO, COO, Treasurer, President, Vice President, or Managing Partner."}),jsxRuntimeExports.jsx("p",{className:"mercoa-font-gray-700 mercoa-mt-2 mercoa-text-sm",children:'Once all representatives have been added, click "Verify Account" to start this process.'}),jsxRuntimeExports.jsx(VerifyOwnersButton,{entity:cr})]})]}):on=jsxRuntimeExports.jsx("div",{className:"mercoa-mt-10 mercoa-text-center mercoa-text-gray-800",children:jsxRuntimeExports.jsx("p",{className:"mercoa-mb-5",children:" We are currently verifying your account. Please come back shortly."})}):on=jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"mercoa-text-gray-800",children:[jsxRuntimeExports.jsxs("p",{className:"mercoa-text-lg mercoa-font-normal",children:["To pay bills and invoices with ",re.organization.name,", you'll need to provide us with a few pieces of information."]}),jsxRuntimeExports.jsxs("div",{className:"mercoa-p-4 mercoa-text-sm mercoa-rounded-mercoa mercoa-bg-gray-100 mercoa-my-4 mercoa-grid mercoa-gap-3",children:[jsxRuntimeExports.jsxs("p",{className:"mercoa-flex mercoa-items-center",children:[jsxRuntimeExports.jsx(ForwardRef$m,{className:"mercoa-size-5 mercoa-mr-5"})," Your information is used for verification purposes and isn't used for third-party marketing. We take your privacy seriously."]}),jsxRuntimeExports.jsxs("p",{className:"mercoa-flex mercoa-items-center",children:[jsxRuntimeExports.jsx(ForwardRef$B,{className:"mercoa-size-4 mercoa-mr-5"})," This process should take approximately 5 minutes to complete."]})]})]}),jsxRuntimeExports.jsx(EntityOnboardingForm,{entity:cr,type:"payor"})]}):on=jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("p",{className:"mercoa-font-gray-700 mercoa-my-2 mercoa-text-sm",children:"Before you can get started, please read and accept the terms of service"}),jsxRuntimeExports.jsx(AcceptToSButton,{title:"Terms of Service",buttonText:"View Terms of Service",entity:cr})]}),jsxRuntimeExports.jsxs("div",{className:"mercoa-mx-auto mercoa-mt-5 mercoa-text-center",children:[jsxRuntimeExports.jsx("h2",{className:"mercoa-font-gray-800 mercoa-text-lg",children:"Welcome to your Accounts Payable Dashboard"}),on]})}return jsxRuntimeExports.jsxs("div",{className:"mercoa-mx-auto mercoa-px-4",children:[jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-items-center",children:[jsxRuntimeExports.jsx("div",{className:"mercoa-flex-auto mercoa-text-sm mercoa-text-gray-700 mercoa-my-4 sm:mercoa-mt-0",children:or==="inbox"?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:((_r=ur==null?void 0:ur.emailProvider)==null?void 0:_r.inboxDomain)&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:["Forward invoices to: ",jsxRuntimeExports.jsx("br",{}),jsxRuntimeExports.jsx(EntityInboxEmail,{})]})}):jsxRuntimeExports.jsxs(MercoaButton,{onClick:()=>{re.refresh(),dr("inbox")},type:"button",isEmphasized:!1,className:"mercoa-ml-2 mercoa-inline-flex mercoa-text-sm",children:[jsxRuntimeExports.jsx(ForwardRef$L,{className:"-mercoa-ml-1 mercoa-inline-flex mercoa-size-5 md:mercoa-mr-2"})," ",jsxRuntimeExports.jsx("span",{className:"mercoa-hidden md:mercoa-inline-block",children:"Back"})]})}),jsxRuntimeExports.jsxs("div",{className:"mercoa-my-4 mercoa-flex-none sm:mercoa-mt-0 sm:mercoa-ml-16",children:[lr&&((Mr=fr==null?void 0:fr.pages)==null?void 0:Mr.notifications)&&or!=="notifications"&&or!=="invoice"&&jsxRuntimeExports.jsxs(MercoaButton,{onClick:()=>dr("notifications"),type:"button",isEmphasized:!1,className:"mercoa-ml-2 mercoa-inline-flex mercoa-text-sm",children:[jsxRuntimeExports.jsx(ForwardRef$v,{className:"-mercoa-ml-1 mercoa-inline-flex mercoa-size-5 md:mercoa-mr-2"})," ",jsxRuntimeExports.jsx("span",{className:"mercoa-hidden md:mercoa-inline-block",children:"Notifications"})]}),(($r=fr==null?void 0:fr.pages)==null?void 0:$r.representatives)&&or!=="representatives"&&or!=="invoice"&&jsxRuntimeExports.jsxs(MercoaButton,{onClick:()=>dr("representatives"),type:"button",isEmphasized:!1,className:"mercoa-ml-2 mercoa-inline-flex mercoa-text-sm",children:[jsxRuntimeExports.jsx(ForwardRef$3,{className:"-mercoa-ml-1 mercoa-inline-flex mercoa-size-5 md:mercoa-mr-2"})," ",jsxRuntimeExports.jsx("span",{className:"mercoa-hidden md:mercoa-inline-block",children:"Representatives"})]}),((vr=fr==null?void 0:fr.pages)==null?void 0:vr.approvals)&&or!=="approvals"&&or!=="invoice"&&jsxRuntimeExports.jsxs(MercoaButton,{onClick:()=>dr("approvals"),type:"button",isEmphasized:!1,className:"mercoa-ml-2 mercoa-inline-flex mercoa-text-sm",children:[jsxRuntimeExports.jsx(ForwardRef$l,{className:"-mercoa-ml-1 mercoa-inline-flex mercoa-size-5 md:mercoa-mr-2"})," ",jsxRuntimeExports.jsx("span",{className:"mercoa-hidden md:mercoa-inline-block",children:"Approval Rules"})]}),((Cr=(Sr=(Or=re.iframeOptions)==null?void 0:Or.options)==null?void 0:Sr.entity)==null?void 0:Cr.enableMercoaPayments)&&((Ir=fr==null?void 0:fr.pages)==null?void 0:Ir.paymentMethods)&&or!=="payments"&&or!=="invoice"&&jsxRuntimeExports.jsxs(MercoaButton,{onClick:()=>dr("payments"),type:"button",isEmphasized:!1,className:"mercoa-ml-2 mercoa-inline-flex mercoa-text-sm",children:[jsxRuntimeExports.jsx(ForwardRef$I,{className:"-mercoa-ml-1 mercoa-inline-flex mercoa-size-5 md:mercoa-mr-2"})," ",jsxRuntimeExports.jsx("span",{className:"mercoa-hidden md:mercoa-inline-block",children:"Payment Methods"})]}),((Zr=(qr=(Dr=re.iframeOptions)==null?void 0:Dr.options)==null?void 0:qr.pages)==null?void 0:Zr.counterparties)&&or!=="counterparties"&&or!=="invoice"&&jsxRuntimeExports.jsxs(MercoaButton,{onClick:()=>dr("counterparties"),type:"button",isEmphasized:!1,className:"mercoa-ml-2 mercoa-inline-flex mercoa-text-sm",children:[jsxRuntimeExports.jsx(ForwardRef$p,{className:"-mercoa-ml-1 mercoa-inline-flex mercoa-size-5 md:mercoa-mr-2"})," ",jsxRuntimeExports.jsx("span",{className:"mercoa-hidden md:mercoa-inline-block",children:"Vendors"})]}),((Yr=fr==null?void 0:fr.pages)==null?void 0:Yr.emailLog)&&or==="inbox"&&jsxRuntimeExports.jsxs(MercoaButton,{onClick:()=>dr("emailLog"),type:"button",isEmphasized:!1,className:"mercoa-ml-2 mercoa-inline-flex mercoa-text-sm",children:[jsxRuntimeExports.jsx(ForwardRef$o,{className:"-mercoa-ml-1 mercoa-inline-flex mercoa-size-5 md:mercoa-mr-2"})," ",jsxRuntimeExports.jsx("span",{className:"mercoa-hidden md:mercoa-inline-block",children:"Email Log"})]}),or!=="invoice"&&or!=="counterparties"&&jsxRuntimeExports.jsxs(MercoaButton,{isEmphasized:!0,type:"button",className:"mercoa-ml-2 mercoa-inline-flex mercoa-text-sm",onClick:()=>{dr("invoice"),sr(void 0)},children:[jsxRuntimeExports.jsx(ForwardRef$d,{className:"-mercoa-ml-1 mercoa-inline-flex mercoa-size-5 md:mercoa-mr-2"})," ",jsxRuntimeExports.jsx("span",{className:"mercoa-hidden md:mercoa-inline-block",children:"New Invoice"})]})]})]}),jsxRuntimeExports.jsx("div",{className:or==="inbox"?"":"mercoa-hidden",children:jsxRuntimeExports.jsx(Payables,{statuses:(en=fr==null?void 0:fr.invoice)==null?void 0:en.status,onSelectInvoice:on=>{sr(on),dr("invoice")}})}),or==="payments"&&jsxRuntimeExports.jsx(PaymentMethods,{}),lr&&or==="notifications"&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h3",{className:"mercoa-mt-8",children:"Notifications"}),jsxRuntimeExports.jsx(EntityUserNotificationTable,{entityId:cr.id,userId:lr.id})]}),or==="approvals"&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h3",{className:"mercoa-my-8",children:"Approval Rules"}),jsxRuntimeExports.jsx(ApprovalPolicies,{})]}),or==="emailLog"&&jsxRuntimeExports.jsx(EntityEmailLogs,{onClick:on=>{var Xr;(Xr=re.client)==null||Xr.invoice.get(on).then(Br=>{sr(Br),dr("invoice")})}}),or==="counterparties"&&jsxRuntimeExports.jsx(Counterparties,{type:"payee"}),or==="representatives"&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("p",{className:"mercoa-font-gray-700 mercoa-mt-2 mercoa-text-sm",children:"Regulatory guidelines require that all individuals with significant ownership in the business (over 25%) must be added as representatives."}),jsxRuntimeExports.jsx("p",{className:"mercoa-font-gray-700 mercoa-mt-1 mercoa-text-sm",children:"Every business also requires a controller. Examples include the CEO, COO, Treasurer, President, Vice President, or Managing Partner."}),jsxRuntimeExports.jsx(Representatives,{showEdit:!0,showAdd:!0}),cr&&cr.accountType==="business"&&!((kr=(Jr=cr.profile)==null?void 0:Jr.business)!=null&&kr.ownersProvided)&&jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-8",children:[jsxRuntimeExports.jsx("h2",{className:"mercoa-font-gray-800 mercoa-text-lg",children:"KYC Verification"}),jsxRuntimeExports.jsx("p",{className:"mercoa-font-gray-700 mercoa-mt-2 mercoa-text-sm",children:'Banking regulations require that we perform a "Know Your Customer" (KYC) process to verify account identity before enabling the ability to pay bills or send invoices.'}),jsxRuntimeExports.jsx("p",{className:"mercoa-font-gray-700 mercoa-mt-2 mercoa-text-sm",children:'Once all representatives have been added, click "Verify Account" to start this process.'}),jsxRuntimeExports.jsx(VerifyOwnersButton,{entity:cr})]})]}),or==="invoice"&&jsxRuntimeExports.jsx(PayableDetails,{invoice:ir,onRedirect:on=>{on||(re.refresh(),dr("inbox"))}})]})}const notificationTypeToText={[javascript.Mercoa.NotificationType.InvoiceEmailed]:"Invoice Email Received",[javascript.Mercoa.NotificationType.InvoiceCreated]:"Invoice Created",[javascript.Mercoa.NotificationType.InvoicePaid]:"Invoice Paid",[javascript.Mercoa.NotificationType.InvoiceScheduled]:"Invoice Scheduled",[javascript.Mercoa.NotificationType.InvoiceApprovalNeeded]:"Invoice Approval Needed",[javascript.Mercoa.NotificationType.InvoiceApproved]:"Invoice Approved",[javascript.Mercoa.NotificationType.InvoiceCanceled]:"Invoice Canceled",[javascript.Mercoa.NotificationType.InvoiceRejected]:"Invoice Rejected",[javascript.Mercoa.NotificationType.InvoicePending]:"Invoice Payment Initiated",[javascript.Mercoa.NotificationType.InvoiceFailed]:"Invoice Payment Failed"};function EntityUserNotificationTable({entityId:W,userId:re,onClick:oe}){const ie=useMercoaSession(),[pe,nr]=React.useState(),[or,ar]=React.useState(),[ir,sr]=React.useState([]),[cr,lr]=React.useState(20),[ur,fr]=React.useState(1),[dr,mr]=React.useState(!0),[pr,hr]=React.useState(0),{handleSubmit:yr}=useForm({defaultValues:{}});return React.useEffect(()=>{var wr;let gr=!0;return(wr=ie.client)==null||wr.entity.user.notifications.find(W,re,{limit:cr,startingAfter:ir[ir.length-1]}).then(br=>{br&&gr&&(mr(br.hasMore),hr(br.count),nr(br.data))}),()=>{gr=!1}},[ie.client,ir,cr]),React.useEffect(()=>{var gr;(gr=ie.client)==null||gr.entity.invoice.find(W,{invoiceId:(pe==null?void 0:pe.filter(wr=>wr.invoiceId).map(wr=>`${wr.invoiceId}`))??[],limit:cr}).then(wr=>{wr&&ar(wr.data)})},[ie.client,W,pe]),ie.client?jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-flex-col",children:[jsxRuntimeExports.jsxs("form",{className:"mercoa-grid mercoa-items-center mercoa-grid-cols-3 mercoa-mb-3",onSubmit:yr(gr=>{console.log(gr)}),children:[jsxRuntimeExports.jsx("div",{className:"mercoa-hidden md:mercoa-block md:mercoa-col-span-2"}),jsxRuntimeExports.jsx("div",{className:"mercoa-mt-2 mercoa-flex mercoa-w-full mercoa-rounded-mercoa mercoa-shadow-sm mercoa-mr-2 mercoa-col-span-3 md:mercoa-col-span-1"})]}),jsxRuntimeExports.jsx("div",{className:"-mercoa-my-2 -mercoa-mx-4 mercoa-overflow-x-auto sm:-mercoa-mx-6 lg:-mercoa-mx-8",children:jsxRuntimeExports.jsx("div",{className:"mercoa-inline-block mercoa-min-w-full mercoa-py-2 mercoa-align-middle md:mercoa-px-6 lg:mercoa-px-8",children:jsxRuntimeExports.jsx("div",{className:"mercoa-overflow-hidden mercoa-shadow mercoa-ring-1 mercoa-ring-black mercoa-ring-opacity-5 md:mercoa-rounded-mercoa",children:jsxRuntimeExports.jsxs("table",{className:"mercoa-min-w-full mercoa-divide-y mercoa-divide-gray-300",children:[jsxRuntimeExports.jsx("thead",{className:"mercoa-bg-gray-50",children:jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("th",{scope:"col",className:"mercoa-py-3.5 mercoa-pl-4 mercoa-pr-3 mercoa-text-left mercoa-text-sm mercoa-font-semibold mercoa-text-gray-900 sm:mercoa-pl-6",children:"Action"}),jsxRuntimeExports.jsx("th",{scope:"col",className:"mercoa-px-3 mercoa-py-3.5 mercoa-text-left mercoa-text-sm mercoa-font-semibold mercoa-text-gray-900",children:"Date"}),jsxRuntimeExports.jsx("th",{scope:"col",className:"mercoa-px-3 mercoa-py-3.5 mercoa-text-left mercoa-text-sm mercoa-font-semibold mercoa-text-gray-900",children:"Vendor"}),jsxRuntimeExports.jsx("th",{scope:"col",className:"mercoa-px-3 mercoa-py-3.5 mercoa-text-left mercoa-text-sm mercoa-font-semibold mercoa-text-gray-900",children:"Amount"}),jsxRuntimeExports.jsx("th",{scope:"col",className:"mercoa-py-3.5 mercoa-pl-4 mercoa-pr-3 mercoa-text-left mercoa-text-sm mercoa-font-semibold mercoa-text-gray-900 sm:mercoa-pl-6",children:"Invoice ID"}),jsxRuntimeExports.jsx("th",{})]})}),jsxRuntimeExports.jsxs("tbody",{className:"mercoa-bg-white",children:[!pe&&jsxRuntimeExports.jsx("tr",{children:jsxRuntimeExports.jsx("td",{colSpan:5,className:"mercoa-p-9 mercoa-text-center",children:jsxRuntimeExports.jsx(LoadingSpinnerIcon,{})})}),pe&&pe.map((gr,wr)=>{var br,_r,Mr,$r;return jsxRuntimeExports.jsxs("tr",{onClick:()=>oe==null?void 0:oe({entityId:W,userId:re,invoiceId:gr.invoiceId}),className:`hover:mercoa-bg-gray-100 ${wr%2===0?void 0:"mercoa-bg-gray-50"}`,children:[jsxRuntimeExports.jsx("td",{className:"mercoa-whitespace-nowrap mercoa-py-4 mercoa-pl-4 mercoa-pr-3 mercoa-text-sm mercoa-font-medium mercoa-text-gray-900 sm:mercoa-pl-6",children:notificationTypeToText[gr.type]}),jsxRuntimeExports.jsxs("td",{className:"mercoa-whitespace-nowrap mercoa-px-3 mercoa-py-4 mercoa-text-sm mercoa-text-gray-900",children:[" ",dayjs$1(gr.createdAt).format("MM/DD/YY")]}),jsxRuntimeExports.jsx("td",{className:"mercoa-whitespace-nowrap mercoa-px-3 mercoa-py-4 mercoa-text-sm mercoa-text-gray-900",children:((_r=(br=or==null?void 0:or.find(vr=>gr.invoiceId===vr.id))==null?void 0:br.vendor)==null?void 0:_r.name)??""}),jsxRuntimeExports.jsx("td",{className:"mercoa-whitespace-nowrap mercoa-px-3 mercoa-py-4 mercoa-text-sm mercoa-text-gray-900",children:accounting.formatMoney(((Mr=or==null?void 0:or.find(vr=>gr.invoiceId===vr.id))==null?void 0:Mr.amount)??"",currencyCodeToSymbol(($r=or==null?void 0:or.find(vr=>gr.invoiceId===vr.id))==null?void 0:$r.currency))}),jsxRuntimeExports.jsx("td",{className:"mercoa-whitespace-nowrap mercoa-px-3 mercoa-py-4 mercoa-text-sm mercoa-text-gray-900",children:gr.invoiceId})]},gr.id)})]})]})})})})]}),pe&&jsxRuntimeExports.jsx(TableNavigation,{data:pe,page:ur,setPage:fr,hasMore:dr,startingAfter:ir,setStartingAfter:sr,count:pr,resultsPerPage:cr,setResultsPerPage:lr})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"EntityUserNotificationTable"})}function EntityUsersTable({openNotificationPreferences:W}){const[re,oe]=React.useState(),[ie,pe]=React.useState({}),[nr,or]=React.useState([]),[ar,ir]=React.useState(),sr=useMercoaSession();React.useEffect(()=>{sr.users&&(oe(sr.users),or([...new Set(sr.users.map(lr=>lr.roles).flat())]))},[sr.users]);function cr({user:lr}){const{register:ur,handleSubmit:fr,setValue:dr,watch:mr}=useForm({defaultValues:{id:lr==null?void 0:lr.id,roles:lr==null?void 0:lr.roles.join(", "),email:lr==null?void 0:lr.email,name:lr==null?void 0:lr.name,foreignId:lr==null?void 0:lr.foreignId}});return jsxRuntimeExports.jsxs("form",{onSubmit:fr(async pr=>{var yr,gr,wr,br,_r;if(!((yr=sr.entity)!=null&&yr.id))return;const hr={roles:[...new Set((wr=(gr=pr==null?void 0:pr.roles)==null?void 0:gr.trim())==null?void 0:wr.split(",").filter(Mr=>Mr).map(Mr=>Mr.trim()))],email:pr.email,name:pr.name,foreignId:pr.foreignId};lr!=null&&lr.id&&(lr==null?void 0:lr.id)!="new"?await((br=sr.client)==null?void 0:br.entity.user.update(sr.entity.id,lr.id,hr)):await((_r=sr.client)==null?void 0:_r.entity.user.create(sr.entity.id,hr)),ir(void 0),Q$1("User Saved!",{type:"success"}),sr.refresh()}),children:[jsxRuntimeExports.jsx(MercoaInput,{label:"Email",register:ur,name:"email",className:"mercoa-mt-2"}),jsxRuntimeExports.jsx(MercoaInput,{label:"Name",register:ur,name:"name",className:"mercoa-mt-2"}),jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-2",children:[jsxRuntimeExports.jsx("label",{htmlFor:"roles",className:"mercoa-block mercoa-text-sm mercoa-font-medium mercoa-leading-6 mercoa-text-gray-900 mercoa-whitespace-nowrap",children:"Roles"}),jsxRuntimeExports.jsxs("div",{className:"mercoa-mt-1 mercoa-flex mercoa-items-center mercoa-gap-x-1",children:[jsxRuntimeExports.jsx("div",{className:"mercoa-flex-grow",children:jsxRuntimeExports.jsx(MercoaCombobox,{options:nr.map(pr=>({disabled:!1,value:pr})),onChange:pr=>{pr.length!=0&&dr("roles",pr.filter(hr=>hr).join(","),{shouldDirty:!0})},value:mr("roles").split(","),multiple:!0,displaySelectedAs:"pill"})}),jsxRuntimeExports.jsxs("button",{className:"mercoa-mt-1",onClick:()=>{const pr=prompt("Create a new role");pr&&or([...nr,pr])},children:[" ",jsxRuntimeExports.jsxs(Tooltip,{title:"Create a new role",children:[jsxRuntimeExports.jsx(ForwardRef$e,{className:"mercoa-h-6 mercoa-w-6 mercoa-text-gray-400"})," "]})]})]})]}),jsxRuntimeExports.jsx(MercoaInput,{label:"Foreign ID",register:ur,name:"foreignId",className:"mercoa-mt-2",placeholder:"The ID of the user in your system"}),jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!0,color:"green",className:"mercoa-mt-5 mercoa-w-full",children:"Save"})]})}return sr.client?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"mercoa-rounded-mercoa mercoa-bg-gray-100 mercoa-p-8",children:jsxRuntimeExports.jsxs("ul",{role:"list",className:"mercoa-divide-y mercoa-divide-gray-100 mercoa-overflow-hidden mercoa-bg-white mercoa-shadow-sm mercoa-ring-1 mercoa-ring-gray-900/5 sm:mercoa-rounded-xl",children:[re==null?void 0:re.map((lr,ur)=>{var fr,dr,mr,pr,hr,yr,gr;return jsxRuntimeExports.jsx("li",{onClick:()=>ir(lr),className:"mercoa-relative mercoa-flex mercoa-gap-x-6 mercoa-px-4 mercoa-py-5 hover:mercoa-bg-gray-50 sm:mercoa-px-6 mercoa-cursor-pointer ",children:jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-gap-x-4 mercoa-w-full",children:[jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-justify-left",children:jsxRuntimeExports.jsx("span",{className:"mercoa-inline-flex mercoa-h-16 mercoa-w-16 mercoa-items-center mercoa-justify-center mercoa-rounded-full mercoa-bg-gray-500",children:jsxRuntimeExports.jsxs("span",{className:"mercoa-mt-0.5 mercoa-text-xl mercoa-font-medium mercoa-leading-none mercoa-text-white",children:[((fr=lr.name)==null?void 0:fr.charAt(0))??"N/A",((pr=(mr=(dr=lr.name)==null?void 0:dr.split(" "))==null?void 0:mr[1])==null?void 0:pr.charAt(0))??""]})})}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("p",{className:"mercoa-text-sm mercoa-font-semibold mercoa-leading-6 mercoa-text-gray-900",children:jsxRuntimeExports.jsx("a",{children:lr.name})}),jsxRuntimeExports.jsx("p",{className:"mercoa-mt-1 mercoa-flex mercoa-text-xs mercoa-leading-5 mercoa-text-gray-600",children:lr.email}),jsxRuntimeExports.jsx("p",{className:"mercoa-mt-1 mercoa-flex mercoa-text-xs mercoa-leading-5 mercoa-text-gray-500",children:lr.id})]}),jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-items-center mercoa-gap-x-2 grow",children:(hr=lr==null?void 0:lr.roles)==null?void 0:hr.map(wr=>jsxRuntimeExports.jsx("span",{className:"mercoa-inline-flex mercoa-items-center mercoa-px-2.5 mercoa-py-0.5 mercoa-rounded-full mercoa-text-xs mercoa-font-medium mercoa-bg-green-100 mercoa-text-green-800",children:wr},wr))}),jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-items-center mercoa-rounded-mercoa mercoa-p-2 hover:mercoa-bg-gray-200",onClick:wr=>{var br;wr.preventDefault(),wr.stopPropagation(),W&&((br=sr.entity)!=null&&br.id)&&lr.id&&W({entityId:sr.entity.id,userId:lr.id})},children:ie[lr.id]&&jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-flex-col mercoa-items-center mercoa-gap-y-2",children:[(yr=ie[lr.id])!=null&&yr.every(wr=>wr.disabled)?jsxRuntimeExports.jsx("span",{className:"mercoa-inline-flex mercoa-items-center mercoa-px-2.5 mercoa-py-0.5 mercoa-rounded-full mercoa-text-xs mercoa-font-medium mercoa-bg-red-100 mercoa-text-red-800",children:"Notifications Disabled"}):jsxRuntimeExports.jsx("span",{className:"mercoa-inline-flex mercoa-items-center mercoa-px-2.5 mercoa-py-0.5 mercoa-rounded-full mercoa-text-xs mercoa-font-medium mercoa-bg-green-100 mercoa-text-green-800",children:"Notifications Enabled"}),((gr=ie[lr.id])==null?void 0:gr.every(wr=>wr.digest))&&jsxRuntimeExports.jsx("span",{className:"mercoa-inline-flex mercoa-items-center mercoa-px-2.5 mercoa-py-0.5 mercoa-rounded-full mercoa-text-xs mercoa-font-medium mercoa-bg-blue-100 mercoa-text-blue-800",children:"Daily Digest Enabled"})]})}),jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-gap-3",children:[jsxRuntimeExports.jsx("button",{onMouseOver:wr=>{var br,_r,Mr;!((br=sr.entity)!=null&&br.id)||!lr.id||(Mr=sr.client)==null||Mr.entity.user.notificationPolicy.getAll((_r=sr.entity)==null?void 0:_r.id,lr.id).then($r=>{$r&&pe(vr=>({...vr,[lr.id]:$r}))})},onClick:wr=>{var br;wr.preventDefault(),wr.stopPropagation(),W&&((br=sr.entity)!=null&&br.id)&&lr.id&&W({entityId:sr.entity.id,userId:lr.id})},children:jsxRuntimeExports.jsx(ForwardRef$v,{className:"mercoa-p-2 mercoa-rounded-xl mercoa-h-10 mercoa-w-10 mercoa-text-gray-400 hover:mercoa-text-gray-500 hover:mercoa-bg-gray-200"})}),jsxRuntimeExports.jsx("button",{onClick:async wr=>{var br,_r;if(wr.preventDefault(),wr.stopPropagation(),confirm("Are you sure you want to delete this user?")){if(!((br=sr.entity)!=null&&br.id))return;if(lr!=null&&lr.id&&(lr==null?void 0:lr.id)!="new")try{await((_r=sr.client)==null?void 0:_r.entity.user.delete(sr.entity.id,lr.id))}catch(Mr){Q$1.error(Mr.body);return}sr.refresh()}},children:jsxRuntimeExports.jsx(ForwardRef$6,{className:"mercoa-p-2 mercoa-rounded-xl mercoa-h-10 mercoa-w-10 mercoa-text-gray-400 hover:mercoa-text-gray-500 hover:mercoa-bg-gray-200"})})]})]})},(lr==null?void 0:lr.id)??ur)}),jsxRuntimeExports.jsxs("li",{className:"mercoa-relative mercoa-flex mercoa-gap-x-6 mercoa-px-4 mercoa-py-5 hover:mercoa-bg-gray-50 sm:mercoa-px-6 mercoa-cursor-pointer mercoa-items-center mercoa-justify-center mercoa-align-center",onClick:()=>{ir({id:"",roles:[""],email:"",name:"",foreignId:"",createdAt:new Date,updatedAt:new Date})},children:[jsxRuntimeExports.jsx(ForwardRef$e,{className:"mercoa-h-6 mercoa-w-6 mercoa-text-gray-400"}),jsxRuntimeExports.jsx("div",{className:"mercoa-text-sm mercoa-font-semibold mercoa-leading-6 mercoa-text-gray-900",children:"Add User"})]})]})}),jsxRuntimeExports.jsx(qe$1.Root,{show:!!ar,as:React.Fragment,children:jsxRuntimeExports.jsxs(_t$1,{as:"div",className:"mercoa-relative mercoa-z-10",onClose:()=>ir(void 0),children:[jsxRuntimeExports.jsx(qe$1.Child,{as:React.Fragment,enter:"mercoa-ease-out mercoa-duration-300",enterFrom:"mercoa-opacity-0",enterTo:"mercoa-opacity-100",leave:"mercoa-ease-in mercoa-duration-200",leaveFrom:"mercoa-opacity-100",leaveTo:"mercoa-opacity-0",children:jsxRuntimeExports.jsx("div",{className:"mercoa-fixed mercoa-inset-0 mercoa-bg-gray-500 mercoa-bg-mercoa-opacity-75 mercoa-transition-opacity"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-fixed mercoa-inset-0 mercoa-z-10 mercoa-overflow-y-auto",children:jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-min-h-full mercoa-items-end mercoa-justify-center mercoa-p-4 mercoa-text-center sm:mercoa-items-center sm:mercoa-p-0",children:jsxRuntimeExports.jsx(qe$1.Child,{as:React.Fragment,enter:"mercoa-ease-out mercoa-duration-300",enterFrom:"mercoa-opacity-0 mercoa-translate-y-4 sm:mercoa-translate-y-0 sm:mercoa-scale-95",enterTo:"mercoa-opacity-100 mercoa-translate-y-0 sm:mercoa-scale-100",leave:"mercoa-ease-in mercoa-duration-200",leaveFrom:"mercoa-opacity-100 mercoa-translate-y-0 sm:mercoa-scale-100",leaveTo:"mercoa-opacity-0 mercoa-translate-y-4 sm:mercoa-translate-y-0 sm:mercoa-scale-95",children:jsxRuntimeExports.jsx(_t$1.Panel,{className:"mercoa-relative mercoa-transform mercoa-rounded-mercoa mercoa-bg-white mercoa-px-4 mercoa-pt-5 mercoa-pb-4 mercoa-text-left mercoa-shadow-xl mercoa-transition-all sm:mercoa-my-8 sm:mercoa-max-w-lg sm:mercoa-p-6",children:ar&&jsxRuntimeExports.jsx(cr,{user:ar})})})})})]})})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"EntityUsersTable"})}function ManageExternalAccountingSystem(){var nr,or,ar,ir;const W=useMercoaSession(),[re,oe]=React.useState();React.useEffect(()=>{var sr;!W||!W.entityId||(sr=W.client)==null||sr.entity.externalAccountingSystem.get(W.entityId).then(cr=>{oe(cr.type!=="none")})});async function ie(){var cr,lr,ur;const sr=(lr=(cr=W.organization)==null?void 0:cr.externalAccountingSystemProvider)==null?void 0:lr.type;W.entityId&&(!sr||sr==="none"||await((ur=W.client)==null?void 0:ur.entity.externalAccountingSystem.create(W.entityId,{type:sr})))}async function pe(){var ur;if(!W.entityId)return;const sr=await((ur=W.client)==null?void 0:ur.entity.externalAccountingSystem.connect(W.entityId));if(!sr)return;const cr=window.open(sr,"_blank"),lr=setInterval(()=>{cr&&cr.closed&&(clearInterval(lr),console.log("> Popup Closed"),W.refresh())},500)}return!((or=(nr=W.organization)==null?void 0:nr.externalAccountingSystemProvider)!=null&&or.type)||((ir=(ar=W.organization)==null?void 0:ar.externalAccountingSystemProvider)==null?void 0:ir.type)==="none"?null:W.client?jsxRuntimeExports.jsxs("div",{className:"mercoa-flex mercoa-gap-x-2",children:[jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!0,type:"button",className:"mercoa-inline-flex mercoa-text-sm",onClick:async()=>{await ie(),pe()},children:"Manage Connection"}),re&&jsxRuntimeExports.jsx(SyncExternalAccountingSystemButton,{})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"ManageExternalAccountingSystem"})}function SyncExternalAccountingSystemButton(){const W=useMercoaSession(),[re,oe]=React.useState(!1),[ie,pe]=React.useState(!1),{register:nr,handleSubmit:or}=useForm({defaultValues:{vendors:!0,glAccounts:!0,bills:!0}});async function ar(ir){var sr;W.entityId&&(pe(!0),await((sr=W.client)==null?void 0:sr.entity.externalAccountingSystem.sync(W.entityId,{vendors:ir.vendors?"both":"none",glAccounts:ir.glAccounts?"pull":"none",bills:ir.bills?"both":"none"})),pe(!1),oe(!1))}return W.client?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!0,type:"button",className:"mercoa-inline-flex mercoa-text-sm",onClick:()=>oe(!0),children:"Sync Now"}),jsxRuntimeExports.jsx(qe$1.Root,{show:re,as:React.Fragment,children:jsxRuntimeExports.jsxs(_t$1,{as:"div",className:"mercoa-relative mercoa-z-10",onClose:()=>oe(!1),children:[jsxRuntimeExports.jsx(qe$1.Child,{as:React.Fragment,enter:"mercoa-ease-out mercoa-duration-300",enterFrom:"mercoa-opacity-0",enterTo:"mercoa-opacity-100",leave:"mercoa-ease-in mercoa-duration-200",leaveFrom:"mercoa-opacity-100",leaveTo:"mercoa-opacity-0",children:jsxRuntimeExports.jsx("div",{className:"mercoa-fixed mercoa-inset-0 mercoa-bg-gray-500 mercoa-bg-mercoa-opacity-75 mercoa-transition-opacity"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-fixed mercoa-inset-0 mercoa-z-10 mercoa-overflow-y-auto",children:jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-min-h-full mercoa-items-end mercoa-justify-center mercoa-p-4 mercoa-text-center sm:mercoa-items-center sm:mercoa-p-0",children:jsxRuntimeExports.jsx(qe$1.Child,{as:React.Fragment,enter:"mercoa-ease-out mercoa-duration-300",enterFrom:"mercoa-opacity-0 mercoa-translate-y-4 sm:mercoa-translate-y-0 sm:mercoa-scale-95",enterTo:"mercoa-opacity-100 mercoa-translate-y-0 sm:mercoa-scale-100",leave:"mercoa-ease-in mercoa-duration-200",leaveFrom:"mercoa-opacity-100 mercoa-translate-y-0 sm:mercoa-scale-100",leaveTo:"mercoa-opacity-0 mercoa-translate-y-4 sm:mercoa-translate-y-0 sm:mercoa-scale-95",children:jsxRuntimeExports.jsx(_t$1.Panel,{className:"mercoa-relative mercoa-transform mercoa-rounded-mercoa mercoa-bg-white mercoa-px-4 mercoa-pt-5 mercoa-pb-4 mercoa-text-left mercoa-shadow-xl mercoa-transition-all sm:mercoa-my-8 sm:mercoa-max-w-md sm:mercoa-p-6",children:ie?jsxRuntimeExports.jsxs("div",{className:"mercoa-min-w-24 mercoa-flex mercoa-items-center mercoa-mt-3",children:[jsxRuntimeExports.jsx(LoadingSpinnerIcon,{}),jsxRuntimeExports.jsx("p",{className:"mercoa-text-sm mercoa-text-gray-500",children:"Syncing..."})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("label",{className:"mercoa-block mercoa-text-lg mercoa-font-medium mercoa-leading-6 mercoa-text-gray-900 mercoa-mb-5",children:"What should be synced?"}),jsxRuntimeExports.jsxs("form",{onSubmit:or(ar),children:[jsxRuntimeExports.jsxs("div",{className:"mercoa-space-y-5",children:[jsxRuntimeExports.jsxs("div",{className:"mercoa-relative mercoa-flex mercoa-items-start",children:[jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-h-6 mercoa-items-center",children:jsxRuntimeExports.jsx("input",{...nr("vendors"),type:"checkbox",className:"mercoa-h-4 mercoa-w-4 mercoa-rounded mercoa-border-gray-300 mercoa-text-mercoa-primary-text mercoa-focus:ring-mercoa-primary-text"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-ml-3 mercoa-text-sm mercoa-leading-6",children:jsxRuntimeExports.jsx("label",{htmlFor:"comments",className:"mercoa-font-medium mercoa-text-gray-900",children:"Vendors"})})]}),jsxRuntimeExports.jsxs("div",{className:"mercoa-relative mercoa-flex mercoa-items-start",children:[jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-h-6 mercoa-items-center",children:jsxRuntimeExports.jsx("input",{...nr("glAccounts"),type:"checkbox",className:"mercoa-h-4 mercoa-w-4 mercoa-rounded mercoa-border-gray-300 mercoa-text-mercoa-primary-text mercoa-focus:ring-mercoa-primary-text"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-ml-3 mercoa-text-sm mercoa-leading-6",children:jsxRuntimeExports.jsx("label",{htmlFor:"comments",className:"mercoa-font-medium mercoa-text-gray-900",children:"GL Accounts"})})]}),jsxRuntimeExports.jsxs("div",{className:"mercoa-relative mercoa-flex mercoa-items-start",children:[jsxRuntimeExports.jsx("div",{className:"mercoa-flex mercoa-h-6 mercoa-items-center",children:jsxRuntimeExports.jsx("input",{...nr("bills"),type:"checkbox",className:"mercoa-h-4 mercoa-w-4 mercoa-rounded mercoa-border-gray-300 mercoa-text-mercoa-primary-text mercoa-focus:ring-mercoa-primary-text"})}),jsxRuntimeExports.jsx("div",{className:"mercoa-ml-3 mercoa-text-sm mercoa-leading-6",children:jsxRuntimeExports.jsx("label",{htmlFor:"comments",className:"mercoa-font-medium mercoa-text-gray-900",children:"Bills"})})]})]}),jsxRuntimeExports.jsx(MercoaButton,{isEmphasized:!0,size:"md",className:"mercoa-mt-5",children:"Sync"})]})]})})})})})]})})]}):jsxRuntimeExports.jsx(NoSession,{componentName:"SyncExternalAccountingSystemButton"})}var resizeObservers=[],hasActiveObservations=function(){return resizeObservers.some(function(W){return W.activeTargets.length>0})},hasSkippedObservations=function(){return resizeObservers.some(function(W){return W.skippedTargets.length>0})},msg="ResizeObserver loop completed with undelivered notifications.",deliverResizeLoopError=function(){var W;typeof ErrorEvent=="function"?W=new ErrorEvent("error",{message:msg}):(W=document.createEvent("Event"),W.initEvent("error",!1,!1),W.message=msg),window.dispatchEvent(W)},ResizeObserverBoxOptions;(function(W){W.BORDER_BOX="border-box",W.CONTENT_BOX="content-box",W.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"})(ResizeObserverBoxOptions||(ResizeObserverBoxOptions={}));var freeze=function(W){return Object.freeze(W)},ResizeObserverSize=function(){function W(re,oe){this.inlineSize=re,this.blockSize=oe,freeze(this)}return W}(),DOMRectReadOnly=function(){function W(re,oe,ie,pe){return this.x=re,this.y=oe,this.width=ie,this.height=pe,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,freeze(this)}return W.prototype.toJSON=function(){var re=this,oe=re.x,ie=re.y,pe=re.top,nr=re.right,or=re.bottom,ar=re.left,ir=re.width,sr=re.height;return{x:oe,y:ie,top:pe,right:nr,bottom:or,left:ar,width:ir,height:sr}},W.fromRect=function(re){return new W(re.x,re.y,re.width,re.height)},W}(),isSVG=function(W){return W instanceof SVGElement&&"getBBox"in W},isHidden=function(W){if(isSVG(W)){var re=W.getBBox(),oe=re.width,ie=re.height;return!oe&&!ie}var pe=W,nr=pe.offsetWidth,or=pe.offsetHeight;return!(nr||or||W.getClientRects().length)},isElement$1=function(W){var re;if(W instanceof Element)return!0;var oe=(re=W==null?void 0:W.ownerDocument)===null||re===void 0?void 0:re.defaultView;return!!(oe&&W instanceof oe.Element)},isReplacedElement=function(W){switch(W.tagName){case"INPUT":if(W.type!=="image")break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1},global$1=typeof window<"u"?window:{},cache=new WeakMap,scrollRegexp=/auto|scroll/,verticalRegexp=/^tb|vertical/,IE=/msie|trident/i.test(global$1.navigator&&global$1.navigator.userAgent),parseDimension=function(W){return parseFloat(W||"0")},size=function(W,re,oe){return W===void 0&&(W=0),re===void 0&&(re=0),oe===void 0&&(oe=!1),new ResizeObserverSize((oe?re:W)||0,(oe?W:re)||0)},zeroBoxes=freeze({devicePixelContentBoxSize:size(),borderBoxSize:size(),contentBoxSize:size(),contentRect:new DOMRectReadOnly(0,0,0,0)}),calculateBoxSizes=function(W,re){if(re===void 0&&(re=!1),cache.has(W)&&!re)return cache.get(W);if(isHidden(W))return cache.set(W,zeroBoxes),zeroBoxes;var oe=getComputedStyle(W),ie=isSVG(W)&&W.ownerSVGElement&&W.getBBox(),pe=!IE&&oe.boxSizing==="border-box",nr=verticalRegexp.test(oe.writingMode||""),or=!ie&&scrollRegexp.test(oe.overflowY||""),ar=!ie&&scrollRegexp.test(oe.overflowX||""),ir=ie?0:parseDimension(oe.paddingTop),sr=ie?0:parseDimension(oe.paddingRight),cr=ie?0:parseDimension(oe.paddingBottom),lr=ie?0:parseDimension(oe.paddingLeft),ur=ie?0:parseDimension(oe.borderTopWidth),fr=ie?0:parseDimension(oe.borderRightWidth),dr=ie?0:parseDimension(oe.borderBottomWidth),mr=ie?0:parseDimension(oe.borderLeftWidth),pr=lr+sr,hr=ir+cr,yr=mr+fr,gr=ur+dr,wr=ar?W.offsetHeight-gr-W.clientHeight:0,br=or?W.offsetWidth-yr-W.clientWidth:0,_r=pe?pr+yr:0,Mr=pe?hr+gr:0,$r=ie?ie.width:parseDimension(oe.width)-_r-br,vr=ie?ie.height:parseDimension(oe.height)-Mr-wr,Or=$r+pr+br+yr,Sr=vr+hr+wr+gr,Cr=freeze({devicePixelContentBoxSize:size(Math.round($r*devicePixelRatio),Math.round(vr*devicePixelRatio),nr),borderBoxSize:size(Or,Sr,nr),contentBoxSize:size($r,vr,nr),contentRect:new DOMRectReadOnly(lr,ir,$r,vr)});return cache.set(W,Cr),Cr},calculateBoxSize=function(W,re,oe){var ie=calculateBoxSizes(W,oe),pe=ie.borderBoxSize,nr=ie.contentBoxSize,or=ie.devicePixelContentBoxSize;switch(re){case ResizeObserverBoxOptions.DEVICE_PIXEL_CONTENT_BOX:return or;case ResizeObserverBoxOptions.BORDER_BOX:return pe;default:return nr}},ResizeObserverEntry=function(){function W(re){var oe=calculateBoxSizes(re);this.target=re,this.contentRect=oe.contentRect,this.borderBoxSize=freeze([oe.borderBoxSize]),this.contentBoxSize=freeze([oe.contentBoxSize]),this.devicePixelContentBoxSize=freeze([oe.devicePixelContentBoxSize])}return W}(),calculateDepthForNode=function(W){if(isHidden(W))return 1/0;for(var re=0,oe=W.parentNode;oe;)re+=1,oe=oe.parentNode;return re},broadcastActiveObservations=function(){var W=1/0,re=[];resizeObservers.forEach(function(or){if(or.activeTargets.length!==0){var ar=[];or.activeTargets.forEach(function(sr){var cr=new ResizeObserverEntry(sr.target),lr=calculateDepthForNode(sr.target);ar.push(cr),sr.lastReportedSize=calculateBoxSize(sr.target,sr.observedBox),lr<W&&(W=lr)}),re.push(function(){or.callback.call(or.observer,ar,or.observer)}),or.activeTargets.splice(0,or.activeTargets.length)}});for(var oe=0,ie=re;oe<ie.length;oe++){var pe=ie[oe];pe()}return W},gatherActiveObservationsAtDepth=function(W){resizeObservers.forEach(function(oe){oe.activeTargets.splice(0,oe.activeTargets.length),oe.skippedTargets.splice(0,oe.skippedTargets.length),oe.observationTargets.forEach(function(pe){pe.isActive()&&(calculateDepthForNode(pe.target)>W?oe.activeTargets.push(pe):oe.skippedTargets.push(pe))})})},process=function(){var W=0;for(gatherActiveObservationsAtDepth(W);hasActiveObservations();)W=broadcastActiveObservations(),gatherActiveObservationsAtDepth(W);return hasSkippedObservations()&&deliverResizeLoopError(),W>0},trigger,callbacks=[],notify=function(){return callbacks.splice(0).forEach(function(W){return W()})},queueMicroTask=function(W){if(!trigger){var re=0,oe=document.createTextNode(""),ie={characterData:!0};new MutationObserver(function(){return notify()}).observe(oe,ie),trigger=function(){oe.textContent="".concat(re?re--:re++)}}callbacks.push(W),trigger()},queueResizeObserver=function(W){queueMicroTask(function(){requestAnimationFrame(W)})},watching=0,isWatching=function(){return!!watching},CATCH_PERIOD=250,observerConfig={attributes:!0,characterData:!0,childList:!0,subtree:!0},events$1=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],time=function(W){return W===void 0&&(W=0),Date.now()+W},scheduled=!1,Scheduler=function(){function W(){var re=this;this.stopped=!0,this.listener=function(){return re.schedule()}}return W.prototype.run=function(re){var oe=this;if(re===void 0&&(re=CATCH_PERIOD),!scheduled){scheduled=!0;var ie=time(re);queueResizeObserver(function(){var pe=!1;try{pe=process()}finally{if(scheduled=!1,re=ie-time(),!isWatching())return;pe?oe.run(1e3):re>0?oe.run(re):oe.start()}})}},W.prototype.schedule=function(){this.stop(),this.run()},W.prototype.observe=function(){var re=this,oe=function(){return re.observer&&re.observer.observe(document.body,observerConfig)};document.body?oe():global$1.addEventListener("DOMContentLoaded",oe)},W.prototype.start=function(){var re=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),events$1.forEach(function(oe){return global$1.addEventListener(oe,re.listener,!0)}))},W.prototype.stop=function(){var re=this;this.stopped||(this.observer&&this.observer.disconnect(),events$1.forEach(function(oe){return global$1.removeEventListener(oe,re.listener,!0)}),this.stopped=!0)},W}(),scheduler=new Scheduler,updateCount=function(W){!watching&&W>0&&scheduler.start(),watching+=W,!watching&&scheduler.stop()},skipNotifyOnElement=function(W){return!isSVG(W)&&!isReplacedElement(W)&&getComputedStyle(W).display==="inline"},ResizeObservation=function(){function W(re,oe){this.target=re,this.observedBox=oe||ResizeObserverBoxOptions.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return W.prototype.isActive=function(){var re=calculateBoxSize(this.target,this.observedBox,!0);return skipNotifyOnElement(this.target)&&(this.lastReportedSize=re),this.lastReportedSize.inlineSize!==re.inlineSize||this.lastReportedSize.blockSize!==re.blockSize},W}(),ResizeObserverDetail=function(){function W(re,oe){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=re,this.callback=oe}return W}(),observerMap=new WeakMap,getObservationIndex=function(W,re){for(var oe=0;oe<W.length;oe+=1)if(W[oe].target===re)return oe;return-1},ResizeObserverController=function(){function W(){}return W.connect=function(re,oe){var ie=new ResizeObserverDetail(re,oe);observerMap.set(re,ie)},W.observe=function(re,oe,ie){var pe=observerMap.get(re),nr=pe.observationTargets.length===0;getObservationIndex(pe.observationTargets,oe)<0&&(nr&&resizeObservers.push(pe),pe.observationTargets.push(new ResizeObservation(oe,ie&&ie.box)),updateCount(1),scheduler.schedule())},W.unobserve=function(re,oe){var ie=observerMap.get(re),pe=getObservationIndex(ie.observationTargets,oe),nr=ie.observationTargets.length===1;pe>=0&&(nr&&resizeObservers.splice(resizeObservers.indexOf(ie),1),ie.observationTargets.splice(pe,1),updateCount(-1))},W.disconnect=function(re){var oe=this,ie=observerMap.get(re);ie.observationTargets.slice().forEach(function(pe){return oe.unobserve(re,pe.target)}),ie.activeTargets.splice(0,ie.activeTargets.length)},W}(),ResizeObserver$2=function(){function W(re){if(arguments.length===0)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if(typeof re!="function")throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");ResizeObserverController.connect(this,re)}return W.prototype.observe=function(re,oe){if(arguments.length===0)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!isElement$1(re))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");ResizeObserverController.observe(this,re,oe)},W.prototype.unobserve=function(re){if(arguments.length===0)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!isElement$1(re))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");ResizeObserverController.unobserve(this,re)},W.prototype.disconnect=function(){ResizeObserverController.disconnect(this)},W.toString=function(){return"function ResizeObserver () { [polyfill code] }"},W}();const usePassiveLayoutEffect=React[typeof document<"u"&&document.createElement!==void 0?"useLayoutEffect":"useEffect"],useLatest=W=>{const re=React__namespace.useRef(W);return React__namespace.useEffect(()=>{re.current=W}),re},ResizeObserver$1=typeof window<"u"&&"ResizeObserver"in window?window.ResizeObserver:ResizeObserver$2;function _ref(){}function useResizeObserver(W,re){const oe=getResizeObserver(),ie=useLatest(re);return usePassiveLayoutEffect(()=>{let pe=!1;const nr=W&&"current"in W?W.current:W;if(!nr)return _ref;function or(ar,ir){pe||ie.current(ar,ir)}return oe.subscribe(nr,or),()=>{pe=!0,oe.unsubscribe(nr,or)}},[W,oe,ie]),oe.observer}function createResizeObserver(){let W=!1,re=[];const oe=new Map,ie=new ResizeObserver$1((pe,nr)=>{re=re.concat(pe);function or(){const ar=new Set;for(let ir=0;ir<re.length;ir++){if(ar.has(re[ir].target))continue;ar.add(re[ir].target);const sr=oe.get(re[ir].target);sr==null||sr.forEach(cr=>cr(re[ir],nr))}re=[],W=!1}W||window.requestAnimationFrame(or),W=!0});return{observer:ie,subscribe(pe,nr){var or;ie.observe(pe);const ar=(or=oe.get(pe))!==null&&or!==void 0?or:[];ar.push(nr),oe.set(pe,ar)},unsubscribe(pe,nr){var or;const ar=(or=oe.get(pe))!==null&&or!==void 0?or:[];if(ar.length===1){ie.unobserve(pe),oe.delete(pe);return}const ir=ar.indexOf(nr);ir!==-1&&ar.splice(ir,1),oe.set(pe,ar)}}}let _resizeObserver;const getResizeObserver=()=>_resizeObserver||(_resizeObserver=createResizeObserver());var isArray$3=Array.isArray,isArray_1=isArray$3,isArray$2=isArray_1,isSymbol$2=isSymbol_1,reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/;function isKey$1(W,re){if(isArray$2(W))return!1;var oe=typeof W;return oe=="number"||oe=="symbol"||oe=="boolean"||W==null||isSymbol$2(W)?!0:reIsPlainProp.test(W)||!reIsDeepProp.test(W)||re!=null&&W in Object(re)}var _isKey=isKey$1,baseGetTag=_baseGetTag,isObject$2=isObject_1,asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction$1(W){if(!isObject$2(W))return!1;var re=baseGetTag(W);return re==funcTag||re==genTag||re==asyncTag||re==proxyTag}var isFunction_1=isFunction$1,root$1=_root,coreJsData$1=root$1["__core-js_shared__"],_coreJsData=coreJsData$1,coreJsData=_coreJsData,maskSrcKey=function(){var W=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return W?"Symbol(src)_1."+W:""}();function isMasked$1(W){return!!maskSrcKey&&maskSrcKey in W}var _isMasked=isMasked$1,funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString;function toSource$1(W){if(W!=null){try{return funcToString$1.call(W)}catch{}try{return W+""}catch{}}return""}var _toSource=toSource$1,isFunction=isFunction_1,isMasked=_isMasked,isObject$1=isObject_1,toSource=_toSource,reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto$2=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$2=objectProto$2.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$2).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative$1(W){if(!isObject$1(W)||isMasked(W))return!1;var re=isFunction(W)?reIsNative:reIsHostCtor;return re.test(toSource(W))}var _baseIsNative=baseIsNative$1;function getValue$1(W,re){return W==null?void 0:W[re]}var _getValue=getValue$1,baseIsNative=_baseIsNative,getValue=_getValue;function getNative$2(W,re){var oe=getValue(W,re);return baseIsNative(oe)?oe:void 0}var _getNative=getNative$2,getNative$1=_getNative,nativeCreate$4=getNative$1(Object,"create"),_nativeCreate=nativeCreate$4,nativeCreate$3=_nativeCreate;function hashClear$1(){this.__data__=nativeCreate$3?nativeCreate$3(null):{},this.size=0}var _hashClear=hashClear$1;function hashDelete$1(W){var re=this.has(W)&&delete this.__data__[W];return this.size-=re?1:0,re}var _hashDelete=hashDelete$1,nativeCreate$2=_nativeCreate,HASH_UNDEFINED$1="__lodash_hash_undefined__",objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function hashGet$1(W){var re=this.__data__;if(nativeCreate$2){var oe=re[W];return oe===HASH_UNDEFINED$1?void 0:oe}return hasOwnProperty$1.call(re,W)?re[W]:void 0}var _hashGet=hashGet$1,nativeCreate$1=_nativeCreate,objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function hashHas$1(W){var re=this.__data__;return nativeCreate$1?re[W]!==void 0:hasOwnProperty.call(re,W)}var _hashHas=hashHas$1,nativeCreate=_nativeCreate,HASH_UNDEFINED="__lodash_hash_undefined__";function hashSet$1(W,re){var oe=this.__data__;return this.size+=this.has(W)?0:1,oe[W]=nativeCreate&&re===void 0?HASH_UNDEFINED:re,this}var _hashSet=hashSet$1,hashClear=_hashClear,hashDelete=_hashDelete,hashGet=_hashGet,hashHas=_hashHas,hashSet=_hashSet;function Hash$1(W){var re=-1,oe=W==null?0:W.length;for(this.clear();++re<oe;){var ie=W[re];this.set(ie[0],ie[1])}}Hash$1.prototype.clear=hashClear,Hash$1.prototype.delete=hashDelete,Hash$1.prototype.get=hashGet,Hash$1.prototype.has=hashHas,Hash$1.prototype.set=hashSet;var _Hash=Hash$1;function listCacheClear$1(){this.__data__=[],this.size=0}var _listCacheClear=listCacheClear$1;function eq$1(W,re){return W===re||W!==W&&re!==re}var eq_1=eq$1,eq=eq_1;function assocIndexOf$4(W,re){for(var oe=W.length;oe--;)if(eq(W[oe][0],re))return oe;return-1}var _assocIndexOf=assocIndexOf$4,assocIndexOf$3=_assocIndexOf,arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete$1(W){var re=this.__data__,oe=assocIndexOf$3(re,W);if(oe<0)return!1;var ie=re.length-1;return oe==ie?re.pop():splice.call(re,oe,1),--this.size,!0}var _listCacheDelete=listCacheDelete$1,assocIndexOf$2=_assocIndexOf;function listCacheGet$1(W){var re=this.__data__,oe=assocIndexOf$2(re,W);return oe<0?void 0:re[oe][1]}var _listCacheGet=listCacheGet$1,assocIndexOf$1=_assocIndexOf;function listCacheHas$1(W){return assocIndexOf$1(this.__data__,W)>-1}var _listCacheHas=listCacheHas$1,assocIndexOf=_assocIndexOf;function listCacheSet$1(W,re){var oe=this.__data__,ie=assocIndexOf(oe,W);return ie<0?(++this.size,oe.push([W,re])):oe[ie][1]=re,this}var _listCacheSet=listCacheSet$1,listCacheClear=_listCacheClear,listCacheDelete=_listCacheDelete,listCacheGet=_listCacheGet,listCacheHas=_listCacheHas,listCacheSet=_listCacheSet;function ListCache$1(W){var re=-1,oe=W==null?0:W.length;for(this.clear();++re<oe;){var ie=W[re];this.set(ie[0],ie[1])}}ListCache$1.prototype.clear=listCacheClear,ListCache$1.prototype.delete=listCacheDelete,ListCache$1.prototype.get=listCacheGet,ListCache$1.prototype.has=listCacheHas,ListCache$1.prototype.set=listCacheSet;var _ListCache=ListCache$1,getNative=_getNative,root=_root,Map$2=getNative(root,"Map"),_Map=Map$2,Hash=_Hash,ListCache=_ListCache,Map$1=_Map;function mapCacheClear$1(){this.size=0,this.__data__={hash:new Hash,map:new(Map$1||ListCache),string:new Hash}}var _mapCacheClear=mapCacheClear$1;function isKeyable$1(W){var re=typeof W;return re=="string"||re=="number"||re=="symbol"||re=="boolean"?W!=="__proto__":W===null}var _isKeyable=isKeyable$1,isKeyable=_isKeyable;function getMapData$4(W,re){var oe=W.__data__;return isKeyable(re)?oe[typeof re=="string"?"string":"hash"]:oe.map}var _getMapData=getMapData$4,getMapData$3=_getMapData;function mapCacheDelete$1(W){var re=getMapData$3(this,W).delete(W);return this.size-=re?1:0,re}var _mapCacheDelete=mapCacheDelete$1,getMapData$2=_getMapData;function mapCacheGet$1(W){return getMapData$2(this,W).get(W)}var _mapCacheGet=mapCacheGet$1,getMapData$1=_getMapData;function mapCacheHas$1(W){return getMapData$1(this,W).has(W)}var _mapCacheHas=mapCacheHas$1,getMapData=_getMapData;function mapCacheSet$1(W,re){var oe=getMapData(this,W),ie=oe.size;return oe.set(W,re),this.size+=oe.size==ie?0:1,this}var _mapCacheSet=mapCacheSet$1,mapCacheClear=_mapCacheClear,mapCacheDelete=_mapCacheDelete,mapCacheGet=_mapCacheGet,mapCacheHas=_mapCacheHas,mapCacheSet=_mapCacheSet;function MapCache$1(W){var re=-1,oe=W==null?0:W.length;for(this.clear();++re<oe;){var ie=W[re];this.set(ie[0],ie[1])}}MapCache$1.prototype.clear=mapCacheClear,MapCache$1.prototype.delete=mapCacheDelete,MapCache$1.prototype.get=mapCacheGet,MapCache$1.prototype.has=mapCacheHas,MapCache$1.prototype.set=mapCacheSet;var _MapCache=MapCache$1,MapCache=_MapCache,FUNC_ERROR_TEXT="Expected a function";function memoize$1(W,re){if(typeof W!="function"||re!=null&&typeof re!="function")throw new TypeError(FUNC_ERROR_TEXT);var oe=function(){var ie=arguments,pe=re?re.apply(this,ie):ie[0],nr=oe.cache;if(nr.has(pe))return nr.get(pe);var or=W.apply(this,ie);return oe.cache=nr.set(pe,or)||nr,or};return oe.cache=new(memoize$1.Cache||MapCache),oe}memoize$1.Cache=MapCache;var memoize_1=memoize$1,memoize=memoize_1,MAX_MEMOIZE_SIZE=500;function memoizeCapped$1(W){var re=memoize(W,function(ie){return oe.size===MAX_MEMOIZE_SIZE&&oe.clear(),ie}),oe=re.cache;return re}var _memoizeCapped=memoizeCapped$1,memoizeCapped=_memoizeCapped,rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,reEscapeChar=/\\(\\)?/g,stringToPath$1=memoizeCapped(function(W){var re=[];return W.charCodeAt(0)===46&&re.push(""),W.replace(rePropName,function(oe,ie,pe,nr){re.push(pe?nr.replace(reEscapeChar,"$1"):ie||oe)}),re}),_stringToPath=stringToPath$1;function arrayMap$1(W,re){for(var oe=-1,ie=W==null?0:W.length,pe=Array(ie);++oe<ie;)pe[oe]=re(W[oe],oe,W);return pe}var _arrayMap=arrayMap$1,Symbol$1=_Symbol,arrayMap=_arrayMap,isArray$1=isArray_1,isSymbol$1=isSymbol_1,INFINITY$1=1/0,symbolProto=Symbol$1?Symbol$1.prototype:void 0,symbolToString=symbolProto?symbolProto.toString:void 0;function baseToString$1(W){if(typeof W=="string")return W;if(isArray$1(W))return arrayMap(W,baseToString$1)+"";if(isSymbol$1(W))return symbolToString?symbolToString.call(W):"";var re=W+"";return re=="0"&&1/W==-INFINITY$1?"-0":re}var _baseToString=baseToString$1,baseToString=_baseToString;function toString$1(W){return W==null?"":baseToString(W)}var toString_1=toString$1,isArray=isArray_1,isKey=_isKey,stringToPath=_stringToPath,toString=toString_1;function castPath$1(W,re){return isArray(W)?W:isKey(W,re)?[W]:stringToPath(toString(W))}var _castPath=castPath$1,isSymbol=isSymbol_1,INFINITY=1/0;function toKey$1(W){if(typeof W=="string"||isSymbol(W))return W;var re=W+"";return re=="0"&&1/W==-INFINITY?"-0":re}var _toKey=toKey$1,castPath=_castPath,toKey=_toKey;function baseGet$1(W,re){re=castPath(re,W);for(var oe=0,ie=re.length;W!=null&&oe<ie;)W=W[toKey(re[oe++])];return oe&&oe==ie?W:void 0}var _baseGet=baseGet$1,baseGet=_baseGet;function get(W,re,oe){var ie=W==null?void 0:baseGet(W,re);return ie===void 0?oe:ie}var get_1=get;const get$1=getDefaultExportFromCjs(get_1);var classnames={exports:{}};/*!
70
70
  Copyright (c) 2018 Jed Watson.
71
71
  Licensed under the MIT License (MIT), see